@hypersocial/decks-cli 0.9.24 → 0.9.25
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 +13 -2
- package/skills/hyperdecks/terminal.md +3 -2
- package/src/check.mjs +33 -16
- package/src/checkRules.mjs +67 -6
- package/src/commands.mjs +15 -4
- package/src/embedCapture.mjs +126 -0
- package/src/embedSources.mjs +252 -0
- package/src/embedsGuide.mjs +36 -0
- package/src/files.mjs +1 -0
- package/src/guide.mjs +8 -6
- package/src/layoutRoutes.mjs +6 -1
- package/src/layouts.mjs +8 -3
- package/src/ops.mjs +76 -0
- package/src/picturesGuide.mjs +1 -0
- package/src/preview-capture.mjs +70 -1
- package/src/runtime.mjs +2 -2
- package/templates/layouts/_deck.html +61 -12
- package/templates/layouts/bento.html +2 -1
- package/templates/layouts/closer.html +4 -2
- package/templates/layouts/cover-band.html +3 -1
- package/templates/layouts/cover-frame.html +5 -1
- package/templates/layouts/cover-poster.html +2 -1
- package/templates/layouts/cover-split.html +13 -2
- package/templates/layouts/cover-type.html +1 -1
- package/templates/layouts/embed.html +93 -0
- package/templates/layouts/features.html +12 -6
- package/templates/layouts/funnel.html +4 -2
- package/templates/layouts/hero.html +2 -2
- package/templates/layouts/lanes.html +3 -3
- package/templates/layouts/number.html +1 -1
- 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/quote.html +3 -2
- package/templates/layouts/rail.html +7 -4
- package/templates/layouts/scorecard.html +3 -2
- 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 +4 -2
- package/templates/layouts/strike.html +1 -1
- package/templates/layouts/team.html +19 -5
- package/templates/layouts/timeline.html +5 -2
- package/templates/layouts/two-by-two.html +5 -1
- package/templates/layouts/video-full.html +3 -3
- package/templates/layouts/wall.html +39 -11
|
@@ -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
|
@@ -49,6 +49,7 @@ const FILES = {
|
|
|
49
49
|
"templates/layouts/lanes.html": () => new URL("../templates/layouts/lanes.html", import.meta.url),
|
|
50
50
|
"templates/layouts/two-bars.html": () => new URL("../templates/layouts/two-bars.html", import.meta.url),
|
|
51
51
|
"templates/layouts/stack.html": () => new URL("../templates/layouts/stack.html", import.meta.url),
|
|
52
|
+
"templates/layouts/embed.html": () => new URL("../templates/layouts/embed.html", import.meta.url),
|
|
52
53
|
"templates/icons/lucide.json": () => new URL("../templates/icons/lucide.json", import.meta.url),
|
|
53
54
|
"templates/icons/phosphor.json.gz": () => new URL("../templates/icons/phosphor.json.gz", import.meta.url),
|
|
54
55
|
"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.
|
|
@@ -76,7 +77,7 @@ export function layoutMarkup(section) {
|
|
|
76
77
|
function layoutsDetail(names) {
|
|
77
78
|
const rows = parseLayouts(names.join(",")).filter((n, i, all) => all.indexOf(n) === i).map((name) => {
|
|
78
79
|
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");
|
|
80
|
+
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\`\`\``].filter(Boolean).join("\n");
|
|
80
81
|
});
|
|
81
82
|
return `# Layouts: detail\n\n${rows.join("\n\n")}`;
|
|
82
83
|
}
|
|
@@ -86,7 +87,7 @@ export function suggestText(says, surface) {
|
|
|
86
87
|
const found = suggestLayouts(says);
|
|
87
88
|
const detail = surface === "cli" ? "`hyperdecks guide layouts <name>`" : '`deck_guide { topic: "layouts", layouts: ["<name>"] }`';
|
|
88
89
|
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}
|
|
90
|
+
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
91
|
}
|
|
91
92
|
|
|
92
93
|
// { topic, topics, text } for one topic; no topic gives the workflow. `layouts`
|
|
@@ -108,6 +109,7 @@ export function deckGuide(topic, { layouts, surface, suggest } = {}) {
|
|
|
108
109
|
else if (t === "themes") text = themesGuide(surface);
|
|
109
110
|
else if (t === "photos") text = photosGuide(surface);
|
|
110
111
|
else if (t === "pictures") text = picturesGuide(surface);
|
|
112
|
+
else if (t === "embeds") text = embedsGuide(surface);
|
|
111
113
|
else if (t === "layouts") text = names.length ? layoutsDetail(names) : layoutsIndex(surface);
|
|
112
114
|
else {
|
|
113
115
|
const section = skillSection(packageText("skills/hyperdecks/SKILL.md"), t);
|
package/src/layoutRoutes.mjs
CHANGED
|
@@ -26,6 +26,7 @@ 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*"] },
|
|
@@ -85,7 +86,11 @@ export function alternativesFor(layout, text = "", { avoid = [], limit = 2 } = {
|
|
|
85
86
|
// The layouts that show a picture (a screenshot, a recording, a photo, a chart). Where a row offers one of these
|
|
86
87
|
// and a word shape, the picture layout comes first when the material exists, so a picture slide is offered
|
|
87
88
|
// picture layouts before word ones (the guide wants a real picture on about every other slide).
|
|
88
|
-
|
|
89
|
+
// The side-panel layouts that take data-flip: their mirror image, the panel and the presenter on the other side (each
|
|
90
|
+
// declares it in its header's `flip:` line). Two neighbours of one of these on the same side read as the same slide
|
|
91
|
+
// twice; the scaffold alternates them and check warns.
|
|
92
|
+
export const FLIPPABLE = ["cover-split", "split", "picture-full", "wall", "portrait"];
|
|
93
|
+
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
94
|
|
|
90
95
|
// The covers and the closer frame a deck; they are not counted as its content.
|
|
91
96
|
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", "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" };
|
|
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
|
});
|
package/src/ops.mjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { fitSlot, parseSlotTarget, searchHint } from "./stockMedia.mjs";
|
|
2
|
+
import { MID_STILL, PHONE_STILL, STILL_HEIGHT, STILL_WIDTH, embedMarkup, embedSiteHint, resolveEmbed, sharedLinkNote } from "./embedSources.mjs";
|
|
3
|
+
import { extensionFor, framedStill, noLocalBrowser, publishedStill, stillName } from "./embedCapture.mjs";
|
|
2
4
|
import { deckPlayer, importPlayerWarning, viewPlayerWarning } from "./deckPlayer.mjs";
|
|
3
5
|
import { zipSync } from "fflate";
|
|
4
6
|
import { SPECIES } from "./species.mjs";
|
|
@@ -220,15 +222,89 @@ export async function generateVideo(opts, fields = {}) {
|
|
|
220
222
|
// Returns { url, storageId, contentType, name?, width, height, creditsRemaining? }.
|
|
221
223
|
export async function captureUrl(opts, fields = {}) {
|
|
222
224
|
if (!fields.url) throw new Error("url is required");
|
|
225
|
+
if (fields.embed) return captureEmbed(opts, fields);
|
|
223
226
|
const args = { url: String(fields.url) };
|
|
224
227
|
if (fields.width != null && fields.width !== "") args.width = Number(fields.width);
|
|
225
228
|
if (fields.height != null && fields.height !== "") args.height = Number(fields.height);
|
|
226
229
|
if (fields.fullPage) args.fullPage = true;
|
|
227
230
|
if (fields.slug) args.slug = String(fields.slug);
|
|
228
231
|
if (fields.name) args.name = String(fields.name);
|
|
232
|
+
if (fields.requireOk) args.requireOk = true;
|
|
229
233
|
return (await client(opts)).action(api.screenshots.captureUrl, args);
|
|
230
234
|
}
|
|
231
235
|
|
|
236
|
+
// The embed slide's still (screenshot --embed, capture_url { embed: true }), saved as an asset of the deck (`slug`)
|
|
237
|
+
// at 1600x900, the frame's shape (embedCapture.mjs): a video or Figma file's own published picture; a map, a booking
|
|
238
|
+
// page or any other page captured inside a frame, in this machine's Chromium when the CLI has one (`hyperdecks
|
|
239
|
+
// preview setup`), else on the app's renderer. Refused, not saved, when the frame shows an error or a banner.
|
|
240
|
+
// Returns the asset, how the slide treats the URL (live on tap, or a still with a link out) and the frame's markup.
|
|
241
|
+
export async function captureEmbed(opts, fields = {}, { fetchImpl = fetch, framed = framedStill, local = !opts.client } = {}) {
|
|
242
|
+
const url = String(fields.url ?? "");
|
|
243
|
+
const resolved = resolveEmbed(url);
|
|
244
|
+
if (!resolved) throw new Error(`embed needs an https link (got ${url || "nothing"})`);
|
|
245
|
+
if (!resolved.live && resolved.site) throw new Error(embedSiteHint(resolved.site, resolved.host));
|
|
246
|
+
if (!fields.slug) throw new Error("embed needs the deck (--slug <deck>; capture_url: slug): the still is saved as one of its pictures");
|
|
247
|
+
const name = fields.name ? String(fields.name) : stillName(resolved);
|
|
248
|
+
const slug = String(fields.slug);
|
|
249
|
+
const save = async (still, suffix) => {
|
|
250
|
+
const c = await client(opts);
|
|
251
|
+
const storageId = await runtimeUploadBytes(c, still.bytes, still.contentType);
|
|
252
|
+
const row = await c.mutation(api.assets.saveAsset, { name: `${name}${suffix}.${extensionFor(still.contentType)}`, storageId, contentType: still.contentType, deckSlug: slug });
|
|
253
|
+
return { url: row.url, name: row.name, width: still.width, height: still.height, title: still.title };
|
|
254
|
+
};
|
|
255
|
+
// A video or Figma file: its own published picture, one for both shapes.
|
|
256
|
+
const published = resolved.live ? await publishedStill(resolved, { fetchImpl }) : null;
|
|
257
|
+
let wide, mid, phone;
|
|
258
|
+
if (published) wide = await save({ ...published, width: published.width ?? 1600, height: published.height ?? 900 }, "");
|
|
259
|
+
else {
|
|
260
|
+
// A map or a page: one still at the slide's shape and one at a phone's, each as its frame shows it, never cropped.
|
|
261
|
+
const src = resolved.live ? resolved.src : resolved.href;
|
|
262
|
+
const label = resolved.name ?? resolved.host;
|
|
263
|
+
let shots = null;
|
|
264
|
+
if (local) {
|
|
265
|
+
try {
|
|
266
|
+
shots = [await framed(src, label, { top: !resolved.live }), await framed(src, label, { top: !resolved.live, ...MID_STILL }), await framed(src, label, { top: !resolved.live, phone: true })];
|
|
267
|
+
} catch (e) {
|
|
268
|
+
// No Chromium here: the app's renderer takes it (and refuses an error page the same way).
|
|
269
|
+
if (!noLocalBrowser(e)) throw e;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
if (shots) [wide, mid, phone] = [await save(shots[0], ""), await save(shots[1], "-mid"), await save(shots[2], "-phone")];
|
|
273
|
+
else {
|
|
274
|
+
// requireOk: the renderer refuses an error answer or a blank page instead of saving it.
|
|
275
|
+
const shot = async (size, suffix) => {
|
|
276
|
+
const out = await captureUrl(opts, { url: src, ...size, slug, name: `${name}${suffix}`, requireOk: true });
|
|
277
|
+
return { url: out.url, name: out.name ?? `${name}${suffix}`, width: size.width, height: size.height, creditsRemaining: out.creditsRemaining };
|
|
278
|
+
};
|
|
279
|
+
wide = await shot({ width: STILL_WIDTH, height: STILL_HEIGHT }, "");
|
|
280
|
+
mid = await shot(MID_STILL, "-mid");
|
|
281
|
+
phone = await shot({ width: PHONE_STILL.width, height: PHONE_STILL.height }, "-phone");
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
// The alt says what the picture shows: the author's own, else the place a map is of, the page's or video's title.
|
|
285
|
+
const place = resolved.source === "google-maps" ? new URL(resolved.src).searchParams.get("q") : null;
|
|
286
|
+
const title = wide.title ?? published?.title;
|
|
287
|
+
const named = place ? `Map of ${place}` : title ? `${resolved.live ? `${resolved.name}: ` : ""}${title}` : null;
|
|
288
|
+
const alt = fields.alt ? String(fields.alt) : named ?? (resolved.live ? resolved.name : `The page at ${resolved.host}`);
|
|
289
|
+
return {
|
|
290
|
+
url: wide.url,
|
|
291
|
+
name: wide.name,
|
|
292
|
+
width: wide.width,
|
|
293
|
+
height: wide.height,
|
|
294
|
+
...(phone ? { phone: { url: phone.url, name: phone.name, width: phone.width, height: phone.height } } : {}),
|
|
295
|
+
...(phone?.creditsRemaining != null ? { creditsRemaining: phone.creditsRemaining } : {}),
|
|
296
|
+
alt,
|
|
297
|
+
altNote: fields.alt ? null : named ? `alt: "${alt}" (say what the picture shows, if it is not that)` : `alt: "${alt}" says only where it is from: replace it with what the picture shows`,
|
|
298
|
+
// No check catches every banner or pop-up: the author looks before the deck goes out.
|
|
299
|
+
...(mid ? { mid: { url: mid.url, name: mid.name, width: mid.width, height: mid.height } } : {}),
|
|
300
|
+
look: `look at the saved still${phone ? "s" : ""} before you use ${phone ? "them" : "it"}: ${[wide.url, mid?.url, phone?.url].filter(Boolean).join(" ")}`,
|
|
301
|
+
embed: resolved.live
|
|
302
|
+
? { live: true, source: resolved.source, label: resolved.label, frame: resolved.src, ...(sharedLinkNote(resolved) ? { note: sharedLinkNote(resolved) } : {}) }
|
|
303
|
+
: { live: false, label: resolved.label, note: `${resolved.host} is not one of the embed sources, so the slide shows the still with a link that opens it in a new tab` },
|
|
304
|
+
markup: embedMarkup(url, wide.url, { alt, width: wide.width, height: wide.height, id: fields.id, kind: resolved.live ? resolved.kind : "page", phone: phone && { src: phone.url, width: phone.width, height: phone.height }, mid: mid && { src: mid.url, width: mid.width, height: mid.height } }),
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
|
|
232
308
|
// Found pictures (convex/stockMedia.ts): Unsplash photos and GIPHY GIFs, free.
|
|
233
309
|
// Both are embedded from the service's own URL with a credit line (their terms);
|
|
234
310
|
// see stockMedia.mjs. Results carry the shape so a layout can be picked by it.
|
package/src/picturesGuide.mjs
CHANGED
|
@@ -32,6 +32,7 @@ export function picturesGuide(surface) {
|
|
|
32
32
|
`- **One light moment**, in a casual deck only: a GIF on a slide of its own, ${m("gif")}.`,
|
|
33
33
|
`- **Something real that has no picture** (a product not built yet, a scene that cannot be photographed): a generated image, ${m("image")}. Never as decoration or a stand-in for their product, team or event.`,
|
|
34
34
|
`- **Numbers**: a chart of the real data, ${m("chart")}.`,
|
|
35
|
+
`- **Something the viewer will use**, not just look at (a map of the venues, a video on YouTube, a Figma prototype, a booking page): the embed layout, a still that goes live on tap (${topic("embeds")}).`,
|
|
35
36
|
"- **Leave it as words** when the words are the point: a quote, a one-line claim (sentence, strike), the ask on the closer.",
|
|
36
37
|
"",
|
|
37
38
|
"## Icons",
|