@hypersocial/decks-cli 0.9.23 → 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.
Files changed (91) hide show
  1. package/package.json +1 -1
  2. package/skills/hyperdecks/SKILL.md +124 -67
  3. package/skills/hyperdecks/chat.md +11 -8
  4. package/skills/hyperdecks/terminal.md +83 -0
  5. package/src/bars.mjs +268 -0
  6. package/src/brand.mjs +51 -8
  7. package/src/check.mjs +333 -20
  8. package/src/checkRules.mjs +677 -27
  9. package/src/commands.mjs +171 -31
  10. package/src/deckSlug.mjs +41 -0
  11. package/src/embedCapture.mjs +126 -0
  12. package/src/embedSources.mjs +252 -0
  13. package/src/embedsGuide.mjs +36 -0
  14. package/src/export-video.mjs +20 -3
  15. package/src/files.mjs +36 -0
  16. package/src/guide.mjs +93 -13
  17. package/src/hosted.mjs +18 -8
  18. package/src/iconAliasNames.mjs +70 -0
  19. package/src/iconChoice.mjs +97 -0
  20. package/src/iconSets.mjs +89 -0
  21. package/src/iconSlots.mjs +48 -0
  22. package/src/icons.mjs +285 -45
  23. package/src/iconsCli.mjs +76 -0
  24. package/src/layoutRoutes.mjs +97 -0
  25. package/src/layouts.mjs +9 -4
  26. package/src/mediaPreviews.mjs +3 -1
  27. package/src/narrate.mjs +31 -4
  28. package/src/opening.mjs +9 -3
  29. package/src/ops.mjs +125 -0
  30. package/src/photosGuide.mjs +47 -0
  31. package/src/picturesGuide.mjs +54 -0
  32. package/src/play.mjs +3 -2
  33. package/src/presenter.mjs +3 -1
  34. package/src/preview-capture.mjs +70 -1
  35. package/src/release.mjs +13 -5
  36. package/src/runtime.mjs +9 -2
  37. package/src/scaffold.mjs +73 -13
  38. package/src/source.mjs +86 -14
  39. package/src/stockMedia.mjs +299 -0
  40. package/src/themeCli.mjs +41 -0
  41. package/src/themes.mjs +345 -0
  42. package/templates/icons/material.LICENSE +202 -0
  43. package/templates/icons/material.json.gz +0 -0
  44. package/templates/icons/phosphor.LICENSE +21 -0
  45. package/templates/icons/phosphor.json.gz +0 -0
  46. package/templates/icons/tabler.LICENSE +21 -0
  47. package/templates/icons/tabler.json.gz +0 -0
  48. package/templates/layouts/_deck.html +231 -41
  49. package/templates/layouts/bento.html +76 -0
  50. package/templates/layouts/chart.html +6 -4
  51. package/templates/layouts/closer.html +13 -4
  52. package/templates/layouts/compare.html +13 -4
  53. package/templates/layouts/cover-band.html +13 -9
  54. package/templates/layouts/cover-frame.html +13 -7
  55. package/templates/layouts/cover-poster.html +9 -5
  56. package/templates/layouts/cover-split.html +19 -7
  57. package/templates/layouts/cover-type.html +2 -1
  58. package/templates/layouts/embed.html +93 -0
  59. package/templates/layouts/features.html +18 -10
  60. package/templates/layouts/funnel.html +62 -0
  61. package/templates/layouts/hero.html +41 -23
  62. package/templates/layouts/lanes.html +63 -0
  63. package/templates/layouts/loop.html +81 -0
  64. package/templates/layouts/number.html +3 -2
  65. package/templates/layouts/phone-stage.html +78 -0
  66. package/templates/layouts/phones.html +1 -0
  67. package/templates/layouts/picture-full.html +58 -0
  68. package/templates/layouts/portrait.html +53 -0
  69. package/templates/layouts/product.html +7 -6
  70. package/templates/layouts/quote.html +5 -3
  71. package/templates/layouts/rail.html +74 -0
  72. package/templates/layouts/scorecard.html +71 -0
  73. package/templates/layouts/screens.html +85 -0
  74. package/templates/layouts/sentence.html +39 -0
  75. package/templates/layouts/split.html +35 -7
  76. package/templates/layouts/spotlight.html +80 -0
  77. package/templates/layouts/stack.html +84 -0
  78. package/templates/layouts/staircase.html +78 -0
  79. package/templates/layouts/strike.html +46 -0
  80. package/templates/layouts/tap-through.html +73 -0
  81. package/templates/layouts/team.html +21 -6
  82. package/templates/layouts/timeline.html +21 -8
  83. package/templates/layouts/two-bars.html +53 -0
  84. package/templates/layouts/two-by-two.html +75 -0
  85. package/templates/layouts/video-beats.html +66 -0
  86. package/templates/layouts/video-full.html +62 -0
  87. package/templates/layouts/wall.html +109 -0
  88. package/templates/layouts/zoom.html +144 -0
  89. package/templates/narrated-deck.html +12 -7
  90. package/templates/script.md +2 -2
  91. /package/templates/icons/{LICENSE → lucide.LICENSE} +0 -0
@@ -5,7 +5,13 @@
5
5
  // the deck's index.html and script.md as text, with the manifest and clip fetches
6
6
  // injected.
7
7
 
8
+ import { CSS_VALUE, THEME_IDS, contrastRatio, deckTheme, findTheme, groundPairs } from "./themes.mjs";
8
9
  import { DASH_AVATAR, presenterTagIssue } from "./presenter.mjs";
10
+ import { deckIconChoice } from "./iconChoice.mjs";
11
+ import { ICON_SLOTS } from "./iconSlots.mjs";
12
+ import { FLIPPABLE, FRAME, alternativesFor } from "./layoutRoutes.mjs";
13
+ import { embedSiteHint, resolveEmbed, sharedLinkNote } from "./embedSources.mjs";
14
+ import { MAX_DECK_GIFS, creditLines, hasGiphyCredit, hasUnsplashCredit, stockRefs, stockSource } from "./stockMedia.mjs";
9
15
 
10
16
  export const PLAYER_V1 = "https://hyperdecks.ai/player/v1/player.js";
11
17
  // Decks released before the app moved to hyperdecks.ai load the same player
@@ -25,6 +31,8 @@ export const TRANSITIONS = ["drift", "cut", "push", "wipe", "zoom", "morph", "fl
25
31
  export const MAX_TRANSITION_KINDS = 2;
26
32
 
27
33
  export const MESSAGES = {
34
+ unknownTheme: (name) => `<html data-hd-theme="${name}"> is not a theme: pick one of ${THEME_IDS.join(", ")} (hyperdecks theme set <deck-dir> <name>)`,
35
+ lowContrast: (ground, ratio) => `text on the ${ground} ground is ${ratio.toFixed(1)}:1, under 4.5:1: change the colours in :root (or the brand's) so it reads`,
28
36
  noPlayer: () => `no player script: add <script type="module" src="${PLAYER_V1}" data-manifest="…">`,
29
37
  player: (src) => `player script must be ${PLAYER_V1} (got ${src})`,
30
38
  noManifest: () => "the player script has no data-manifest: run `hyperdecks narrate <deck-dir>`, which sets it (or, for a deck with no narration, add data-silent to the player script)",
@@ -58,6 +66,7 @@ export const MESSAGES = {
58
66
  noteSoft: (id) => `slide ${id}: no data-note naming the source of its facts (required on a pitch deck, data-kind="pitch", and by check --strict)`,
59
67
  mobileTitle: (id, title) => `slide ${id}: title "${title}" is over ${MOBILE_TITLE_CHARS} characters and needs a data-title-mobile`,
60
68
  slideId: (n) => `slide ${n} has no id`,
69
+ silentCue: (err) => `${err} (script.md is unused on a silent deck: it is never narrated)`,
61
70
  selector: (line, cue, selector, id) => `script.md line ${line}: [${cue}: ${selector}] matches nothing in slide ${id}`,
62
71
  gestureColon: (line, id) => `script.md line ${line}: [gesture ${id}] needs a colon: [gesture: ${id}]`,
63
72
  gesture: (line, id) => `script.md line ${line}: [gesture: ${id}] is not one of the head's gestures: ${GESTURES.join(", ")}`,
@@ -71,11 +80,31 @@ export const MESSAGES = {
71
80
  morphPair: (id, prev) => `slide ${id}: morph needs an element with the same data-morph="<name>" on this slide and the one before it (${prev})`,
72
81
  transitionStale: (where, script, manifest) => `${where}: script.md says transition "${script}" but the manifest has "${manifest}": run \`hyperdecks narrate\` so the player gets it`,
73
82
  flyTwice: (ids) => `fly is for the deck's one big moment, but slides ${ids.join(", ")} all use it`,
83
+ // Embeds (deck_guide topic embeds): warnings, so a deck made before the embed layout still passes.
84
+ iframeBare: (id) => `slide ${id}: a bare <iframe> loads its site for every viewer as the deck opens, keeps the narration running while they use it, and shows as an empty box in video and PDF exports and link previews; use the embed layout instead: a still that goes live on tap (deck_guide topic embeds)`,
85
+ embedNoStill: (id) => `slide ${id}: the embed has no still (<img class="still" src="…">), so exports, thumbnails and link previews show an empty frame; capture one with \`hyperdecks screenshot <url> --embed\` (capture_url with embed=true) (deck_guide topic embeds)`,
86
+ embedSiteLink: (id, site, host) => `slide ${id}: ${embedSiteHint(site, host)}; until then the slide shows its still with a link out (deck_guide topic embeds)`,
87
+ embedSharedLink: (id, note) => `slide ${id}: ${note} (deck_guide topic embeds)`,
88
+ embedNotLive: (id, host) => `slide ${id}: ${host} is not one of the embed sources (Google Maps, YouTube, Vimeo, Loom, Figma, Calendly), so the slide shows its still with a link that opens it in a new tab, not a live frame (deck_guide topic embeds)`,
89
+ embedNoUrl: (id, url) => `slide ${id}: data-embed "${url}" is not an https link, so the slide shows its still with no control (deck_guide topic embeds)`,
74
90
  // Warnings from the look topic (deck_guide look): the deck passes, but a person should look.
75
91
  coverFade: (where, what) => `${where}: the cover ${what}, so the title sits on a mix of picture and colour that is hard to read: prefer cover-frame or cover-split (or hero, cover-band, cover-poster, cover-type), which keep the title on a solid ground (deck_guide topic layouts)`,
76
- fewPictures: (shown, total) => `only ${shown} of ${total} slides show a picture (a screenshot, a recording, a photo, a chart); aim for a real one on every other slide (deck_guide topic look)`,
92
+ filmUndrawn: (theme) => `the theme asks for a moving film (--film: 1) but this deck's CSS has no film rule (@keyframes hd-film), so no film is drawn: set the theme again to bring it (hyperdecks theme set <deck-dir> ${theme}; a hosted deck: new_deck { theme: "${theme}" })`,
93
+ filmOld: (theme) => `this deck's film rule is an older one: its scratch and specks stay on every slide where the film holds still (reduced motion, thumbnails) and mostly miss a phone's slide; set the theme again to update it (hyperdecks theme set <deck-dir> ${theme})`,
94
+ fewPictures: (shown, total, could = []) => `only ${shown} of ${total} slides show a picture (a screenshot, a recording, a photo, a chart); a real one on about every other slide helps a deck${could.length ? `. If it helps, these could take one: ${could.map(([id, kind]) => `${id} (${kind})`).join(", ")}` : ""} (deck_guide topic pictures)`,
95
+ // Variety (layoutRoutes.mjs): one shape over and over reads as the same slide again. Warnings only: a deliberate
96
+ // repeat is the author's call. `alts` is [[slide id, [layout, layout]], …], other shapes from the guide's table.
97
+ layoutOverused: (layout, ids, total, alts) => `${ids.length} of the ${total} content slides use ${layout} (${ids.join(", ")}), so the deck reads as the same slide again${otherShapes(alts)}. A deliberate repeat (a screens walkthrough, a run of numbers) is yours to keep (deck_guide topic layouts)`,
98
+ layoutSameSide: (layout, a, b, both) => `slides ${a} and ${b} are two ${layout} slides in a row with the panel on the same side, so they read as the same slide twice. ${both ? "Take data-flip off one of them" : `Put data-flip on ${b}'s section to mirror it`} so the two alternate (deck_guide topic layouts)`,
99
+ flipValue: (id, value) => `slide ${id} has data-flip="${value}", but any value still flips it (the layout matches the attribute, not its value). Write plain data-flip to flip it, or take the attribute off`,
100
+ flipIgnored: (id, layout) => `slide ${id} has data-flip, but ${layout} does not flip, so nothing changes. Only ${FLIPPABLE.join(", ")} flip; take it off or pick one of those`,
101
+ layoutRun: (layout, ids, alts) => `slides ${ids.join(", ")} are ${ids.length} ${layout} slides in a row${otherShapes(alts)}. A deliberate run (a screens walkthrough) is yours to keep (deck_guide topic layouts)`,
102
+ // A slide whose items have icons on some only (iconSlots.mjs). An empty slot is never warned about: icons are optional.
103
+ partIconSlot: (id, layout, filled, items) => `slide ${id}: ${filled} of the ${items} items in this ${layout} slide have an icon; give the rest one too, or take them out (deck_guide topic pictures)`,
77
104
  presenterGutter: (where, decl) => `${where}: ${decl} keeps a right gutter for the presenter; leave that corner to the slide's .narration-slot so a deck without a presenter can use it (deck_guide topic look)`,
78
- mixedIcons: (sets) => `the deck mixes icon sets (${sets.join(" and ")}); keep one set per deck (deck_guide topic look)`,
105
+ // sets: [label, slide ids]; the slides are named so a deliberate mix is easy to keep and an accidental one easy to find.
106
+ iconChoice: (problem) => `${problem}; later icon searches cannot stay in it until it names a set and weight (icons sets)`,
107
+ mixedIcons: (sets) => `the deck mixes icon sets (${sets.map(([label, ids]) => (ids?.length ? `${label} on ${ids.join(", ")}` : label)).join("; ")}); one set and weight per deck reads as one design, unless the mix is deliberate (icons sets; deck_guide topic look)`,
79
108
  retiredTexture: (where, cls, instead, inlined) => `${where}: ${cls} is a whole-slide texture the kit no longer ships ${inlined ? "(this deck still carries its rule, so it runs under the text)" : "(it ran under the text), so it paints nothing"}; ${instead} (deck_guide topic look)`,
80
109
  tooManySignatures: (n) => `${n} slides carry a signature background (bg-corner or bg-mark); keep it to three at most: the cover, one opener or the ask, the closer (deck_guide topic look)`,
81
110
  textureOff: (where, cls, layout) => `${where}: ${cls} does nothing on ${layout} (the shell switches it off there: nothing to back); remove it, or use bg-pool behind the picture (deck_guide topic look)`,
@@ -83,17 +112,43 @@ export const MESSAGES = {
83
112
  placeholder: (id, what, el, how, img) => `slide ${id}: ${what} is still the layout's placeholder (${el}); ${how}, then put it in as ${img}`,
84
113
  // Warnings (check --layout): the deck still passes.
85
114
  layoutUnchecked: (why) => `layout not checked: ${why}`,
115
+ // Found pictures (stockMedia.mjs): the credit their terms require, and links that died.
116
+ unsplashCredit: (id) => `slide ${id}: an Unsplash photo needs its credit on the slide: keep add_photo's creditLine (<p class="hd-credit">Photo by <a …>name</a> on <a …>Unsplash</a></p>) as the slide's own child (\`hyperdecks photos add\`)`,
117
+ giphyCredit: (id) => `slide ${id}: a GIPHY GIF needs "Powered by GIPHY" on the slide: keep the result's creditLine (<p class="hd-credit">) as the slide's own child`,
118
+ stockGone: (id, url, why) => `slide ${id}: ${url} ${why}; it lives on ${stockSource(url) === "giphy" ? "GIPHY" : "Unsplash"} and is gone or moved: pick another or use the person's own picture`,
119
+ stockUnchecked: (id, url, why) => `slide ${id}: ${url} ${why}, so check could not tell whether it still shows; try check again later`,
120
+ creditLines: (id) => `slide ${id}: more than one .hd-credit line, and they stack in the same corner: put every found picture's creditHtml in one <p class="hd-credit">, joined with " · "`,
121
+ tooManyGifs: (n) => `${n} GIFs in the deck: one or two at most, on casual slides (deck_guide topic look)`,
122
+ gifFormat: (id) => `slide ${id}: a GIPHY .gif file is heavy and won't pause or show a still; paste search_gifs' markup (its MP4 in a <video>)`,
86
123
  hotlink: (url) => `${url} is hotlinked from another site and can vanish after release; upload it with upload_deck_asset`,
87
124
  transitionKinds: (kinds, deck) => `${kinds.length} kinds of transition besides the default (${deck}): ${kinds.join(", ")}; keep to ${MAX_TRANSITION_KINDS} so the deck reads as designed`,
88
125
  coverText: (where) => `${where}: the cover's title sits on its picture, which is hard to read: prefer a cover that keeps the title on a solid ground beside, above or below the picture (cover-frame, cover-split, hero, cover-band, cover-poster or cover-type; deck_guide topic layouts)`,
89
- overlap: (id, style, stage) => `slide ${id}: the ${style} presenter would overlap the title at ${stage}; move the .narration-slot or pick another style`,
126
+ pictureEmpty: (id, picture, frame, share, better) => `slide ${id}: the picture (${picture}) leaves ${share}% of its ${frame} frame empty; ${better} (deck_guide topic look)`,
127
+ barsUnchecked: (why) => `pictures and clips were not checked for bars baked into their files (${why})`,
128
+ pictureBars: (id, what, drawn, sides, content, cover) => `slide ${id}: the ${what} has bars baked into its file (${drawn}: ${sides}; its content is ${content}), so it shows as a box with gaps beside it; upload the file again with \`hyperdecks asset add <slug> <file> --trim\` (or upload_deck_asset with trim=true for a PNG) and use the new URL${cover ? ", or set object-fit: cover (with object-position) on it so its frame crops them away" : ""} (deck_guide topic look)`,
129
+ pictureCropped: (id, picture, frame, share, better) => `slide ${id}: the frame (${frame}) crops away ${share}% of the picture (${picture}), so its subject may be lost; ${better} (deck_guide topic look)`,
130
+ overlap: (id, style, stage, fix) => `slide ${id}: the ${style} presenter would overlap the title at ${stage}; ${fix} (deck_guide topic presenter)`,
131
+ // The word layouts' boxes (wordFitWarnings): text that runs past its box.
132
+ wordFit: (id, text, where) => `slide ${id}${where}: "${text}" runs past the edge of its box; use a shorter word or fewer words there (the layout's detail gives the lengths that fit) (deck_guide topic layouts)`,
133
+ rowWide: (id, word, where) => `slide ${id}${where}: its steps together are wider than their column (each is as wide as its longest word; the longest is "${word}"); use shorter names or fewer steps (deck_guide topic layouts)`,
134
+ wordBroken: (id, word, where) => `slide ${id}${where}: the word "${word}" is broken across two lines in its box; use a shorter word, or put a soft hyphen (&shy;) where it may break (deck_guide topic layouts)`,
135
+ // The media layouts' own rule (presenterMediaWarnings): what the presenter must leave clear on each.
136
+ presenterOnMedia: (id, style, what, stage, fix) => `slide ${id}: the ${style} presenter would cover ${what} at ${stage}; ${fix} (deck_guide topic layouts)`,
137
+ pictureCorner: (id, kind, corner, side, share, fix) => `slide ${id}: the ${kind}'s corner (${corner}px) is over ${share} of its shorter side (${side}px), so the curve cuts into it; ${fix} (deck_guide topic look)`,
138
+ heroStrip: (id, picture) => `slide ${id}: the picture (${picture}) is wider than 2:1, so in the hero's corner column it shows as a small strip beside a large empty ground; add class="art wide" to the <img> so it spans the slide above the title (or use cover-poster) (deck_guide topic look)`,
139
+ lensOffSlide: (id, what, sides) => `slide ${id}: ${what} runs off the slide's ${sides}: the lens is centred on its spot (--zx, --zy), so a spot this near the slide's edge takes it past; move the spot in (crop the screenshot so the detail sits further in) or shorten the label (deck_guide topic layouts)`,
140
+ lensBlur: (id, times, natural, needed) => `slide ${id}: the lens shows the screenshot at ${times}× its own pixels (${natural}px wide) on a 1440×900 retina screen, so it reads blurred; capture it at least ${needed}px wide (capture_url / \`hyperdecks screenshot <url>\` at full size) or lower --zoom (deck_guide topic layouts)`,
141
+ // An error: a <video> whose src is not a recording, or whose poster is not a still, plays black.
142
+ videoMedia: (where, which, url, got) => `${where}: <video ${which}="${url}"> is ${got}, not ${which === "src" ? "a video" : "an image"}; ${which === "src" ? "src takes the recording (an .mp4 or .webm)" : "poster takes a still of it (a .jpg, .png or .webp)"}`,
143
+ // A warning: the file could not be read, so its kind is unknown and the slide may play black.
144
+ videoUnreachable: (where, which, url, why) => `${where}: <video ${which}="${url}"> ${why}, so check could not tell what it is; make sure it loads (upload it with upload_deck_asset / \`hyperdecks asset add\`)`,
90
145
  // An error, though only check --layout can see it.
91
146
  phoneOverflow: (id, px) => `slide ${id}: its content runs ${px}px past the slide on a ${PHONE.width}×${PHONE.height} phone; a slide must fit one screen without scrolling, so trim it or tighten its @media (max-width: 650px) rules`,
92
147
  };
93
148
 
149
+ export const HOSTED_LAYOUT_WHY = "presenter overlap, phone fit and how each picture fits its frame need a browser: run review_deck with draft=true";
94
150
  // The framed player's slide card on a phone (player.css): the screen less the
95
151
  // 60px masthead, the 48px dock and 8px gutters.
96
- export const HOSTED_LAYOUT_WHY = "presenter overlap and phone fit need a browser: run review_deck with draft=true";
97
152
  export const PHONE = { width: 390, height: 844, card: { width: 374, height: 736 } };
98
153
 
99
154
  const uncommented = (html) => html.replace(/<!--[\s\S]*?-->/g, "");
@@ -343,9 +398,29 @@ export function playerScript(html) {
343
398
  manifest: attr(tag, "data-manifest") || null,
344
399
  silent: hasAttr(tag, "data-silent") && !/^(false|0|no)$/i.test(attr(tag, "data-silent") ?? ""),
345
400
  kind: attr(tag, "data-kind")?.trim().toLowerCase() || null,
401
+ silentPresenter: attr(tag, "data-silent-presenter") ?? null,
346
402
  };
347
403
  }
348
404
 
405
+ // A silent deck: it declares data-silent, has no manifest and no slide with
406
+ // data-clip audio (those are narrated: the player plays them).
407
+ export function silentDeck(html) {
408
+ const player = playerScript(html);
409
+ return !!player && !player.manifest && player.silent && !slides(html).some((s) => attr(s.tag, "data-clip"));
410
+ }
411
+
412
+ // script.md's [go]/[look] and [gesture] cues.
413
+ const scriptCueErrors = (html, script) => [...cueSelectorErrors(html, script), ...cueGestureErrors(script)];
414
+
415
+ // A silent deck (data-silent, no manifest, no slide's data-clip) the player
416
+ // shows with no presenter: one made since decks carry data-silent-presenter="hide"
417
+ // (player.js silentFaceless). Its corner is the slide's, so check says nothing
418
+ // about the presenter's room. "show", or no attribute (a deck released before), keeps the face.
419
+ export function silentWithoutPresenter(html) {
420
+ const player = playerScript(html);
421
+ return !!player && !player.manifest && player.silent && player.silentPresenter === "hide" && !slides(html).some((s) => attr(s.tag, "data-clip"));
422
+ }
423
+
349
424
  // Source notes are required on a pitch deck (its claims) and under check
350
425
  // --strict; elsewhere a missing one is a warning.
351
426
  export const notesRequired = (html, { strict = false } = {}) => !!strict || playerScript(html)?.kind === "pitch";
@@ -578,6 +653,46 @@ const PLACEHOLDERS = [
578
653
  layout: "l-phones", tag: "div", cls: "shot", what: "each phone screen", img: '<img class="shot" src="…" alt="…"> (or <video class="shot" src="…" autoplay muted loop playsinline>) in each card',
579
654
  how: { hosted: "capture the app at phone size with capture_url (width 390, height 844), or upload a screen recording with upload_deck_asset", cli: "capture the app at phone size with `hyperdecks screenshot <url> --width 390 --height 844`, or add a screen recording with `hyperdecks asset add`" },
580
655
  },
656
+ {
657
+ layout: "l-phone-stage", tag: "div", cls: "shot", what: "the phone screen", img: '<img class="shot" src="…" alt="…"> (or <video class="shot" src="…" autoplay muted loop playsinline>)',
658
+ how: { hosted: "capture the app at phone size with capture_url (width 390, height 844)", cli: "capture the app at phone size with `hyperdecks screenshot <url> --width 390 --height 844`" },
659
+ },
660
+ {
661
+ layout: "l-tap-through", tag: "div", cls: "shot", what: "each screen of the tap-through", img: '<img class="shot" src="…" alt="…"> in each, the later ones keeping class="shot reveal"',
662
+ how: { hosted: "capture the app at phone size with capture_url (width 390, height 844)", cli: "capture the app at phone size with `hyperdecks screenshot <url> --width 390 --height 844`" },
663
+ },
664
+ {
665
+ layout: "l-screens", tag: "div", cls: "shot", what: "each screen", img: '<img class="shot" src="…" alt="…" width="…" height="…"> in each step',
666
+ how: { hosted: "capture each screen with capture_url (width 390, height 844 for a phone), or upload the pictures with upload_deck_asset", cli: "capture each screen with `hyperdecks screenshot <url> --width 390 --height 844` (a phone), or add the pictures with `hyperdecks asset add`" },
667
+ },
668
+ {
669
+ layout: "l-zoom", tag: "div", cls: "shot", what: "the screenshot (and its enlarged part)", img: '<img class="shot" src="…" alt="…" width="…" height="…">, the same file in the full frame and in the lens',
670
+ how: { hosted: "capture the real page with capture_url", cli: "capture the real page with `hyperdecks screenshot <url>`" },
671
+ },
672
+ {
673
+ layout: "l-video-full", tag: "div", cls: "clip", what: "the recording", img: '<video class="clip" src="…" autoplay muted loop playsinline>',
674
+ how: { hosted: "upload the screen recording with upload_deck_asset", cli: "add the screen recording with `hyperdecks asset add`" },
675
+ },
676
+ {
677
+ layout: "l-video-beats", tag: "div", cls: "clip", what: "the recording", img: '<video class="clip" src="…" autoplay muted loop playsinline>',
678
+ how: { hosted: "upload the screen recording with upload_deck_asset", cli: "add the screen recording with `hyperdecks asset add`" },
679
+ },
680
+ {
681
+ layout: "l-embed", tag: "div", cls: "still", what: "the embed's still", img: '<img class="still" src="…" alt="…" width="…" height="…"> inside the .embed, which keeps its data-embed link',
682
+ how: { hosted: "capture it with capture_url (embed: true), which returns the whole .embed markup", cli: "capture it with `hyperdecks screenshot <url> --embed`, which prints the whole .embed markup" },
683
+ },
684
+ {
685
+ layout: "l-picture-full", tag: "div", cls: "pic", what: "the picture", img: '<img class="pic" src="…" alt="…">',
686
+ how: { hosted: "upload the real photo with upload_deck_asset", cli: "add the real photo with `hyperdecks asset add`" },
687
+ },
688
+ {
689
+ layout: "l-wall", tag: "div", cls: "pic", what: "each picture on the wall", img: '<img class="pic" src="…" alt="…"> for each (three to five)',
690
+ how: { hosted: "upload the real photos with upload_deck_asset", cli: "add the real photos with `hyperdecks asset add`" },
691
+ },
692
+ {
693
+ layout: "l-portrait", tag: "div", cls: "pic", what: "the portrait", img: '<img class="pic" src="…" alt="…" width="…" height="…">',
694
+ how: { hosted: "upload the real photo with upload_deck_asset", cli: "add the real photo with `hyperdecks asset add`" },
695
+ },
581
696
  {
582
697
  layout: "l-chart", tag: "svg", cls: "chart", label: /placeholder/i, what: "the chart (made-up numbers)", img: '<img class="chart" src="…" alt="…">',
583
698
  how: { hosted: "draw the real data with render_chart", cli: "draw the real data with `hyperdecks chart <spec.json>`" },
@@ -598,7 +713,10 @@ export function placeholderErrors(html, { hosted = false } = {}) {
598
713
  // Everything checkable from the deck's own files. `exists(ref)` answers whether a
599
714
  // local reference resolves inside the deck folder: true, false or "outside".
600
715
  export function htmlErrors(html, { exists = () => true, forbid = [], script = "", hosted = false, strict = false } = {}) {
601
- const errs = [...presenterStyleErrors(html, script), ...transitionErrors(html, script), ...cueSelectorErrors(html, script), ...cueGestureErrors(script), ...placeholderErrors(html, { hosted })];
716
+ const themeName = deckTheme(html);
717
+ const errs = themeName !== null && !findTheme(themeName) ? [MESSAGES.unknownTheme(themeName)] : [];
718
+ // A silent deck never plays script.md, so its cues warn instead (checkSources).
719
+ errs.push(...presenterStyleErrors(html, script), ...transitionErrors(html, script), ...(silentDeck(html) ? [] : scriptCueErrors(html, script)), ...placeholderErrors(html, { hosted }));
602
720
  const player = playerScript(html);
603
721
  if (!player) errs.push(MESSAGES.noPlayer());
604
722
  else if (!isPlayerV1(player.src)) errs.push(MESSAGES.player(player.src));
@@ -613,7 +731,9 @@ export function htmlErrors(html, { exists = () => true, forbid = [], script = ""
613
731
  const id = s.id || `${i + 1}`;
614
732
  if (!s.id) errs.push(MESSAGES.slideId(i + 1));
615
733
  if (notes && !attr(s.tag, "data-note")?.trim()) errs.push(MESSAGES.note(id));
616
- if (s.title.length > MOBILE_TITLE_CHARS && !attr(s.titleTag, "data-title-mobile") && !attr(s.tag, "data-title-mobile")) {
734
+ // sentence and strike: the title is the slide's whole statement (its mark included), set to wrap on a phone, so a
735
+ // shorter phone title would change what it says; they need none.
736
+ if (s.title.length > MOBILE_TITLE_CHARS && !FULL_TITLE_LAYOUTS.test(attr(s.tag, "class") ?? "") && !attr(s.titleTag, "data-title-mobile") && !attr(s.tag, "data-title-mobile")) {
617
737
  errs.push(MESSAGES.mobileTitle(id, s.title));
618
738
  }
619
739
  });
@@ -722,7 +842,16 @@ export function slideStyles(html, manifest = null) {
722
842
  const known = (v) => (PRESENTER_STYLES.includes(v) ? v : null);
723
843
  const deck = known(attr(tag, "data-presenter-style")) ?? known(manifest?.presenterStyle) ?? (attr(tag, "data-presenter") === "head" ? "stage" : "bubble");
724
844
  const clips = new Map((Array.isArray(manifest?.clips) ? manifest.clips : []).map((c) => [c?.id, c]));
725
- return slides(html).map((s) => ({ id: s.id, style: known(attr(s.tag, "data-presenter-style")) ?? known(clips.get(s.id)?.presenterStyle) ?? deck }));
845
+ const size = (v) => (PRESENTER_SIZES.includes(v) && v !== "m" ? v : null);
846
+ const deckSize = size(attr(tag, "data-presenter-size"));
847
+ return slides(html).map((s) => {
848
+ const style = known(attr(s.tag, "data-presenter-style")) ?? known(clips.get(s.id)?.presenterStyle) ?? deck;
849
+ // A slide's data-presenter-size (or the tag's) scales its footprint; the default (m) is left out. A slide's own m
850
+ // wins over the tag's size, as in the player.
851
+ const own = attr(s.tag, "data-presenter-size")?.trim();
852
+ const scale = PRESENTER_SIZES.includes(own) ? size(own) : deckSize;
853
+ return { id: s.id, style, ...(scale ? { size: scale } : {}) };
854
+ });
726
855
  }
727
856
 
728
857
  // What each style occupies at desktop size, in stage pixels (player.css): the
@@ -736,9 +865,31 @@ export const PRESENTER_FOOTPRINT = {
736
865
 
737
866
  // Measured boxes → warnings. Each entry: { id, style, presenter, title } with
738
867
  // { x, y, width, height } boxes (title null when the slide has none).
868
+ // data-presenter-size's scale (player.css --hd-presenter-scale: s .7, m 1, l 1.3, xl 1.6).
869
+ export const PRESENTER_SCALE = { s: 0.7, m: 1, l: 1.3, xl: 1.6 };
870
+
871
+ // The layouts that make room for a large presenter (data-presenter-size l or xl on the slide's own <section>): closer,
872
+ // split and the word shapes, for the stage presenter (closer for glass too; bubble is smaller than stage, so it fits
873
+ // all). A size on the player tag is not seen by a layout's CSS.
874
+ const WORD_ROOM = ["stage", "bubble"];
875
+ export const ROOMY_LAYOUTS = { "l-closer": ["stage", "glass", "bubble"], "l-split": ["stage", "bubble"], "l-sentence": WORD_ROOM, "l-strike": WORD_ROOM, "l-spotlight": WORD_ROOM, "l-funnel": WORD_ROOM, "l-scorecard": WORD_ROOM, "l-bento": WORD_ROOM, "l-two-by-two": WORD_ROOM, "l-staircase": WORD_ROOM, "l-rail": WORD_ROOM, "l-loop": WORD_ROOM, "l-lanes": WORD_ROOM, "l-two-bars": WORD_ROOM, "l-stack": WORD_ROOM };
876
+ // What clears an overlap (measureLayout gives the slide's layout, its own data-presenter-size (`sized`) and the size it plays at).
877
+ function overlapFix(m) {
878
+ const big = m.size === "l" || m.size === "xl";
879
+ // A deck made before its layout made room keeps its old styles: re-copying them is the step that works.
880
+ if (big && ROOMY_LAYOUTS[m.layout]?.includes(m.style) && m.current === false) return `this deck's ${m.layout.slice(2)} styles predate the room for a large presenter: copy the ${m.layout.slice(2)} layout's <style> block from a new deck (\`hyperdecks deck new <slug> "<title>" --layouts ${m.layout.slice(2)}\`) over this deck's and ${m.sized === m.size ? "keep" : "set"} data-presenter-size="${m.size}" on this slide's <section>, or set a smaller size`;
881
+ const styles = ROOMY_LAYOUTS[m.layout];
882
+ if (big && styles && m.sized !== m.size) return `set data-presenter-size="${m.size}" on this slide's <section>: ${m.layout.slice(2)} makes room for a size set on the slide, not for the deck's default on the player tag`;
883
+ if (big && styles && !styles.includes(m.style)) return `set data-presenter-style="stage" on this slide (this layout makes room for the stage presenter at l and xl), or a smaller data-presenter-size`;
884
+ const smaller = big ? 'set a smaller size on this slide\'s <section> (data-presenter-size="m", or "s")' : m.size === "s" ? null : 'set data-presenter-size="s" on this slide\'s <section>';
885
+ // Already on a layout that makes room: the title is what runs into the presenter.
886
+ const room = big && styles ? null : "use a layout that makes room for a large presenter (closer, split)";
887
+ const steps = [smaller, "shorten the title so it ends clear of the presenter's corner", room].filter(Boolean);
888
+ return steps.length > 1 ? `${steps.slice(0, -1).join(", ")}, or ${steps.at(-1)}` : steps[0];
889
+ }
739
890
  export function overlapWarnings(measured, stage = "1600×900") {
740
891
  const hit = (a, b) => a && b && Math.min(a.x + a.width, b.x + b.width) - Math.max(a.x, b.x) > 4 && Math.min(a.y + a.height, b.y + b.height) - Math.max(a.y, b.y) > 4;
741
- return measured.filter((m) => hit(m.presenter, m.title)).map((m) => MESSAGES.overlap(m.id, m.style, stage));
892
+ return measured.filter((m) => hit(m.presenter, m.title)).map((m) => MESSAGES.overlap(m.id, m.style, stage, overlapFix(m)));
742
893
  }
743
894
 
744
895
  // Covers whose rendered title lands on their picture, as warnings. Each entry: { id, onPicture }
@@ -747,11 +898,311 @@ export function coverTextWarnings(measured) {
747
898
  return measured.filter((m) => m.onPicture).map((m) => MESSAGES.coverText(`slide ${m.id}`));
748
899
  }
749
900
 
901
+ // The boxes the word layouts set text in (a card, a tile, a step, a chip): each one's words must fit it, never run
902
+ // past its edge or be clipped (measureLayout's `fit`, wordFitWarnings). Selectors per layout class.
903
+ export const FIT_BOXES = {
904
+ "l-spotlight": ".row > li", "l-funnel": ".stages > li", "l-scorecard": ".rows > li, .rows .state", "l-bento": ".tiles > *",
905
+ "l-two-by-two": ".q b", "l-staircase": ".steps > li", "l-rail": ".track > li", "l-loop": ".ring li", "l-lanes": ".lanes .chip, .lanes .who",
906
+ "l-two-bars": ".bars > li", "l-stack": ".layers > li",
907
+ };
908
+ // The rows of boxes that widen to their longest word (min-content tracks): the row must still fit its column.
909
+ export const FIT_ROWS = { "l-staircase": ".steps", "l-rail": ".track", "l-lanes": ".lanes" };
910
+ // Text that runs out of its box, and words broken across two lines in one, as warnings. Each measured entry:
911
+ // { id, fit: [text, …], broken: [word, …], wide: the longest name in a row wider than its column }.
912
+ export function wordFitWarnings(measured, { phone = false } = {}) {
913
+ const where = phone ? ` on a ${PHONE.width}×${PHONE.height} phone` : "";
914
+ return measured.flatMap((m) => [...(m.fit ?? []).map((text) => MESSAGES.wordFit(m.id, text, where)), ...(m.broken ?? []).map((word) => MESSAGES.wordBroken(m.id, word, where)), ...(m.wide ? [MESSAGES.rowWide(m.id, m.wide, where)] : [])]);
915
+ }
916
+
917
+ // The layouts whose title is the whole statement and shows in full on a phone (no data-title-mobile needed).
918
+ export const FULL_TITLE_LAYOUTS = /(?:^|\s)l-(?:sentence|strike)(?:\s|$)/;
919
+ // The word layouts' parts that sit beside the presenter (measureLayout's media.words; their title is measured as every slide's).
920
+ export const WORD_PARTS = { "l-strike": ".old", "l-spotlight": ".row > li", "l-funnel": ".stages > li", "l-scorecard": ".rows > li", "l-bento": ".tiles > *", "l-two-by-two": ".plane", "l-staircase": ".steps > li", "l-rail": ".track > li", "l-loop": ".ring li", "l-lanes": ".lanes", "l-two-bars": ".bars > li", "l-stack": ".layers > li" };
921
+ // The media layouts whose presenter must keep off what they show (measureLayout's `media`: boxes by role).
922
+ // zoom: the full screenshot, the lens and its label; video-full: the recording as drawn; picture-full: the presenter stays
923
+ // in the panel's column (the picture's subject is in the right two-thirds).
924
+ const MEDIA_CLEAR = {
925
+ shot: ["the full screenshot", "keep the full screenshot in its column, clear of the bottom-right corner, as the layout places it"],
926
+ lens: ["the lens", "keep the screenshot (and the lens on it) clear of the bottom-right corner, as the layout places it"],
927
+ label: ["the lens's label", "keep the screenshot (and the .pill under its lens) clear of the bottom-right corner, as the layout places it"],
928
+ clip: ["the recording", "keep the bar under (or beside) the recording and the presenter small on it (the layout's --hd-presenter-scale), as the layout places them"],
929
+ art: ["the picture", "keep the picture in hero's frame (420px tall at most), which ends above the presenter's head"],
930
+ beyondPanel: ["the picture beyond the panel", "keep the slide's slot-left so the presenter stands under the panel (on a flipped slide too: there slot-left stands it bottom-right)"],
931
+ words: ["the words", "keep the layout's widths, which end left of the presenter's corner"],
932
+ };
933
+ // The word layouts make room for an l or xl presenter set on the slide's own <section>, as closer and split do.
934
+ function wordsFix(m) {
935
+ const name = m.layout.slice(2), big = m.size === "l" || m.size === "xl";
936
+ if (big && m.current === false) return `this deck's ${name} styles predate the room for a large presenter: copy the ${name} layout's <style> block from a new deck (\`hyperdecks deck new <slug> "<title>" --layouts ${name}\`) over this deck's, or set a smaller size`;
937
+ if (big && m.sized !== m.size) return `set data-presenter-size="${m.size}" on this slide's <section>: ${name} makes room for a size set on the slide, not for the deck's default on the player tag`;
938
+ return MEDIA_CLEAR.words[1];
939
+ }
940
+ export function presenterMediaWarnings(measured, stage = "1600×900") {
941
+ const hit = (a, b) => a && b && Math.min(a.x + a.width, b.x + b.width) - Math.max(a.x, b.x) > 4 && Math.min(a.y + a.height, b.y + b.height) - Math.max(a.y, b.y) > 4;
942
+ return measured.flatMap((m) => {
943
+ if (!m.presenter || !m.media) return [];
944
+ // The hero's picture is kept clear of the head: the caption moves off pictures on its own (the player).
945
+ // picture-full's presenter stands under the panel: past its right edge, or its left edge on a flipped slide.
946
+ const roles = Object.entries(m.media).filter(([role, box]) => role === "beyondPanel"
947
+ ? box && (m.flipped ? m.presenter.x < box.x - 4 : m.presenter.x + m.presenter.width > box.x + box.width + 4)
948
+ : hit(role === "art" ? m.head ?? m.presenter : m.presenter, box));
949
+ // The layouts are placed for the stage presenter; another style is larger (glass) or ignores the slot (corner).
950
+ const fix = (role) => (m.style === "stage" ? (role === "words" ? wordsFix(m) : MEDIA_CLEAR[role][1]) : `set data-presenter-style="stage" on this slide (the layout leaves room for the stage presenter${m.style === "corner" ? "; the corner one ignores its slot" : ""})`);
951
+ return roles.map(([role]) => MESSAGES.presenterOnMedia(m.id, m.style, MEDIA_CLEAR[role][0], stage, fix(role)));
952
+ });
953
+ }
954
+
955
+ // zoom's lens enlarges its picture: past this many times its own pixels it reads blurred. Counted in a screen's
956
+ // pixels where decks are watched, a 1440×900 retina screen: the player draws the 1600px stage 1387px wide there, at
957
+ // 2 device pixels a pixel (a 1280px screenshot at --zoom 3 across a 950px frame is 4.3×, and reads soft).
958
+ export const LENS_MAX_ENLARGE = 2.5;
959
+ export const LENS_SCREEN = (1387 / 1600) * 2;
960
+ export function lensWarnings(measured) {
961
+ return measured.flatMap((m) => {
962
+ const times = m.lens && m.lens.natural > 0 ? (m.lens.shown * LENS_SCREEN) / m.lens.natural : 0;
963
+ return times > LENS_MAX_ENLARGE ? [MESSAGES.lensBlur(m.id, round(times), m.lens.natural, Math.ceil((m.lens.shown * LENS_SCREEN) / LENS_MAX_ENLARGE))] : [];
964
+ });
965
+ }
966
+
967
+ // zoom's lens is centred on its spot, never clamped (a clamp moves it off its target): a spot near the slide's edge
968
+ // takes the lens, or the label under it, past the slide. measureLayout gives the zoom slide's media boxes and the
969
+ // slide's own box (bounds). With { phone: true } the slides were measured in a phone's card.
970
+ export function lensOffSlideWarnings(measured, { phone = false } = {}) {
971
+ return measured.flatMap((m) => {
972
+ const { lens, label } = m.media ?? {}, slide = m.bounds;
973
+ if (!lens || !slide) return [];
974
+ const id = phone ? `${m.id} on a ${PHONE.width}×${PHONE.height} phone` : m.id;
975
+ return [["the lens", lens], ["the lens's label", label]].flatMap(([what, b]) => {
976
+ if (!b || b.width <= 0) return [];
977
+ const sides = [b.x < slide.x - 1 && "left", b.y < slide.y - 1 && "top", b.x + b.width > slide.x + slide.width + 1 && "right", b.y + b.height > slide.y + slide.height + 1 && "bottom"].filter(Boolean);
978
+ return sides.length ? [MESSAGES.lensOffSlide(id, what, sides.join(" and "))] : [];
979
+ });
980
+ });
981
+ }
982
+
983
+ // A picture's fit in its frame (check --layout; measureLayout gives each slide's `pictures`:
984
+ // { natural, frame: { width, height }, fit, edge, shot }). Thresholds, picked from real decks: the
985
+ // minimoji-worlds cover's 1420×500 strip, contained in the old 7:6 hero frame (552×472 inside its
986
+ // border), left 59% of it empty (yellow bands above and below), and a 16:9 picture in that frame lost
987
+ // 34% to the crop. A fifth empty is a visible band; a third cropped is where a subject at the edge
988
+ // goes. Edge-to-edge covers (EDGE_PICTURES) crop by design and their strip or half shrinks as the
989
+ // title grows, so they warn only past a half: a 16:9 in cover-poster's strip loses 33% at 1600×900
990
+ // with a short title and more with a long one; a 3:1 strip in cover-split's half loses 70%, which warns.
991
+ // A laptop frame's shot crops a tall page capture to its top on purpose, so it is not measured.
992
+ export const PICTURE_FIT = { empty: 0.2, cropped: 1 / 3, edgeCropped: 1 / 2 };
993
+ export const EDGE_PICTURES = ".l-cover-band .art, .l-cover-split .art, .l-cover-poster .art, .l-picture-full .pic";
994
+ // Frames whose shape is the layout's, not the picture's (the edge-to-edge pictures and the wall's cells): trimming a
995
+ // picture's bars changes its shape, and such a frame then crops the trimmed picture (barsWarnings). The wall is not
996
+ // edge-to-edge: its cells warn past a third cropped (not a half), and the warning names the cells' class.
997
+ export const CELL_PICTURES = `${EDGE_PICTURES}, .l-wall .pic`;
998
+ // zoom's lens shows a part of its picture on purpose: it is not a frame.
999
+ export const UNMEASURED_PICTURES = ".frame.laptop > .shot, .l-zoom .lens .shot";
1000
+ // The hero's frame takes any shape between these (hero.html: 552 wide at most, 178 to 472 tall).
1001
+ const HERO_SHAPES = { min: 3 / 4, max: 3 };
1002
+ const shapeName = (ar) => (ar >= 2 ? "a wide strip" : ar <= 0.85 ? "a portrait" : ar >= 1.2 ? "landscape" : "near-square");
1003
+ // The cover layouts that suit a picture of this shape, best first (the hero suits any within HERO_SHAPES).
1004
+ const SUITS = {
1005
+ "a wide strip": ["cover-poster"],
1006
+ "a portrait": ["cover-split"],
1007
+ landscape: ["cover-frame", "cover-band", "cover-poster"],
1008
+ "near-square": ["cover-split"],
1009
+ };
1010
+ function betterFit(m, p, ar) {
1011
+ if (p.attrSized) return "remove the width and height attributes on the <img>: here they set the frame's size, and without them the frame takes the picture's shape";
1012
+ if (m.layout === "l-picture-full" && m.phone) return "on a phone the picture shows at its own shape up to 300px tall, so use a landscape photo (4:3 or wider)";
1013
+ // split's .shot.wide takes its picture's shape (a square sheet, 4:3, 16:9): no styling needed there.
1014
+ if (p.shot && m.layout === "l-split" && !p.wide) return "a phone screen belongs in the .frame.card; for any other picture use <img class=\"shot wide\"> in place of the card, which takes the picture's shape (no styling needed)";
1015
+ if (p.shot) return "use a screenshot or clip shaped like its frame (a phone screen in a .frame.card; in split, any other picture in a .shot.wide, which takes its shape)";
1016
+ // The wall's cells are its .pics' class: upright (default), square or wide. Name the one that suits the picture.
1017
+ if (p.pic && m.layout === "l-wall" && !m.phone) {
1018
+ if (m.current === false) return "this deck's wall styles predate square and wide cells: copy the wall layout's <style> block from a new deck (`hyperdecks deck new <slug> \"<title>\" --layouts wall`) over this deck's, then pick the cells (<div class=\"pics square\"> or <div class=\"pics wide\">), or use photos shaped like the cells";
1019
+ const want = ar >= 1.2 ? "wide" : ar > 0.85 ? "square" : "";
1020
+ if (want && p.cells !== want) return `for ${want === "wide" ? "landscape" : "square"} photos write <div class="pics ${want}"> (cells about ${want === "wide" ? "16:9" : "square"}), and keep the set one shape`;
1021
+ if (!want && p.cells) return `upright photos suit the wall's default cells: remove "${p.cells}" from <div class="pics ${p.cells}">`;
1022
+ return "use photos of one shape for the wall, or set object-position on the <img> to keep its subject in view";
1023
+ }
1024
+ if (p.pic) return "use a photo shaped like its frame, or set object-position on the <img> to keep its subject in view";
1025
+ const hero = ar >= HERO_SHAPES.min && ar <= HERO_SHAPES.max;
1026
+ if (m.layout === "l-hero" && hero) return "remove any width, height or object-fit set on the <img> so the hero's frame takes the picture's shape";
1027
+ const kind = shapeName(ar);
1028
+ // A wide strip belongs edge to edge: cover-poster first, never away from it (in hero it needs class="art wide").
1029
+ if (kind === "a wide strip" && m.layout === "l-cover-poster") return "set object-position on the <img> to keep its subject in view, or use a wider strip";
1030
+ const suits = (kind === "a wide strip" ? [...SUITS[kind], ...(hero ? ['hero (with class="art wide")'] : [])] : [...(hero ? ["hero"] : []), ...SUITS[kind]]).filter((l) => `l-${l}` !== m.layout);
1031
+ return `a picture that is ${kind} suits ${suits.join(" or ")}${hero && kind !== "a wide strip" ? " (the hero's frame takes its shape)" : ""}, or use a picture shaped like the frame`;
1032
+ }
1033
+ // With { phone: true } the slides were measured as a phone shows them (measureLayout's card): the
1034
+ // edge-to-edge frames there do not shrink with the title, so every picture warns past a third, and
1035
+ // each warning names the phone.
1036
+ export function pictureFitWarnings(measured, { phone = false } = {}) {
1037
+ const shape = ({ width, height }) => `${Math.round(width)}×${Math.round(height)}`;
1038
+ return measured.flatMap((m) => (m.pictures ?? []).flatMap((p) => {
1039
+ const ar = p.natural.width / p.natural.height, box = p.frame.width / p.frame.height;
1040
+ const lost = 1 - Math.min(ar, box) / Math.max(ar, box);
1041
+ const id = phone ? `${m.id} on a ${PHONE.width}×${PHONE.height} phone` : m.id, at = phone ? { ...m, phone } : m;
1042
+ if (/^(contain|scale-down)$/.test(p.fit) && lost > PICTURE_FIT.empty) return [MESSAGES.pictureEmpty(id, shape(p.natural), shape(p.frame), Math.round(lost * 100), betterFit(at, p, ar))];
1043
+ // A hero picture wider than 2:1 belongs across the slide (class="art wide"), not in the corner column (said once, at desktop size).
1044
+ if (!phone && m.layout === "l-hero" && p.art && !p.wide && ar > 2) return [MESSAGES.heroStrip(id, shape(p.natural))];
1045
+ // The edge-to-edge covers crop a strip's sides by design on a phone too: they warn only past a half there.
1046
+ const edge = p.edge && (!phone || /^l-cover-/.test(m.layout ?? ""));
1047
+ if (p.fit === "cover" && lost > (edge ? PICTURE_FIT.edgeCropped : PICTURE_FIT.cropped)) return [MESSAGES.pictureCropped(id, shape(p.natural), shape(p.frame), Math.round(lost * 100), betterFit(at, p, ar))];
1048
+ return [];
1049
+ }));
1050
+ }
1051
+
1052
+ // A frame's drawn corner (the radius inside its border and padding) over this share of its shorter side cuts into
1053
+ // what it holds: an eighth for a photo or art, a sixteenth for a screenshot or clip, whose corners hold interface.
1054
+ // The built-in layouts cap each frame's corner at its share of the shortest side the layout draws it at
1055
+ // (min(calc(N * var(--round)), var(--frame-min) / 8), / 16 for a screenshot or clip), so a theme with big corners
1056
+ // rounds a short frame less. check --layout measures images (img.art, .shot, .pic); clips and product's browser frame
1057
+ // are held to it by lib/deckPictureCorners.test.ts.
1058
+ export const CORNER_SHARE = { picture: 1 / 8, screen: 1 / 16 };
1059
+ // Phone screens (a phone card's screen, product's phone, screens' phone shots) keep a phone's own corner.
1060
+ export const PHONE_SCREENS = ".frame.card .shot, .frame.phone .shot, .l-screens .shot:not(.wide)";
1061
+ // Warnings for each measured picture (measureLayout's pictures, with their drawn `corner`) whose corner is over
1062
+ // its share of its frame's shorter side. A picture wider than 2:1 in the hero's corner column is told to be marked
1063
+ // wide: the wide frame's corner is capped for a strip.
1064
+ export function pictureCornerWarnings(measured, { phone = false } = {}) {
1065
+ return measured.flatMap((m) => (m.pictures ?? []).flatMap((p) => {
1066
+ const side = Math.min(p.frame.width, p.frame.height), screen = !!p.shot;
1067
+ const share = screen ? CORNER_SHARE.screen : CORNER_SHARE.picture;
1068
+ if (!(p.corner > side * share + 0.5)) return [];
1069
+ const id = phone ? `${m.id} on a ${PHONE.width}×${PHONE.height} phone` : m.id;
1070
+ const strip = m.layout === "l-hero" && p.art && !p.wide && p.natural.width / p.natural.height > 2;
1071
+ // Shown at its own size (or smaller than it is): the frame is under the layout's floor, so a larger picture fixes it.
1072
+ const own = p.natural.width <= p.frame.width + 1 && p.natural.height <= p.frame.height + 1;
1073
+ const fix = strip ? 'the picture is wider than 2:1: add class="art wide" to the <img>, whose frame rounds a strip less'
1074
+ : own ? `it is shown at its own size (${Math.round(p.natural.width)}×${Math.round(p.natural.height)}), smaller than the layout draws this frame: use a larger picture`
1075
+ : `cap that frame's border-radius at ${screen ? "a sixteenth" : "an eighth"} of its shortest side, as the built-in layouts do (min(…, var(--frame-min) / ${screen ? 16 : 8})), or use a picture closer to the frame's shape`;
1076
+ return [MESSAGES.pictureCorner(id, screen ? "screenshot" : "picture", Math.round(p.corner), Math.round(side), screen ? "a sixteenth" : "an eighth", fix)];
1077
+ }));
1078
+ }
1079
+
1080
+ // Bars baked into a framed picture or clip (packages/decks-cli/src/bars.mjs): past this share of the
1081
+ // width or height it is drawn at (both sides together), check --layout warns.
1082
+ export const PICTURE_BARS = 0.15;
1083
+ // The bars as drawn: { x, y } shares of the drawn width and height that are bars, for a file of
1084
+ // barsResult `r` in a frame ({ width, height }) with object-fit `fit`. cover crops from the centre
1085
+ // (object-position is not read); every other fit shows the whole file, so its bars keep their share.
1086
+ export function drawnBars(r, frame, fit) {
1087
+ const left = r.content.x, right = r.width - r.content.x - r.content.width, top = r.content.y, bottom = r.height - r.content.y - r.content.height;
1088
+ if (fit !== "cover") return { x: (left + right) / r.width, y: (top + bottom) / r.height };
1089
+ const s = Math.max(frame.width / r.width, frame.height / r.height);
1090
+ const cropX = (r.width * s - frame.width) / 2, cropY = (r.height * s - frame.height) / 2;
1091
+ const seen = (bar, crop) => Math.max(0, bar * s - crop);
1092
+ return { x: (seen(left, cropX) + seen(right, cropX)) / frame.width, y: (seen(top, cropY) + seen(bottom, cropY)) / frame.height };
1093
+ }
1094
+ // Warnings for each framed picture or clip whose file has bars past PICTURE_BARS as drawn. `measured`
1095
+ // is measureLayout's (each slide's `framed`: { src, kind, frame, fit }); `barsBySrc` maps a src to its
1096
+ // barsResult (a file that could not be read is absent and raises nothing).
1097
+ export function barsWarnings(measured, barsBySrc) {
1098
+ const pct = (n) => `${Math.round(n * 100)}%`;
1099
+ return measured.flatMap((m) => (m.framed ?? []).flatMap((f) => {
1100
+ const r = barsBySrc.get(f.src);
1101
+ if (!r?.reported) return [];
1102
+ // A frame of the layout's shape (a wall cell, an edge-to-edge picture) crops: trimming changes the picture's shape,
1103
+ // and if the frame would then crop the trimmed picture past its limit (PICTURE_FIT.cropped; edgeCropped for an
1104
+ // edge-to-edge picture), the trim advice trades
1105
+ // bars for a crop; say nothing.
1106
+ if (f.cell && f.fit === "cover") {
1107
+ const a = r.content.width / r.content.height, b = f.frame.width / f.frame.height;
1108
+ if (1 - Math.min(a, b) / Math.max(a, b) > (f.edge ? PICTURE_FIT.edgeCropped : PICTURE_FIT.cropped)) return [];
1109
+ }
1110
+ const d = drawnBars(r, f.frame, f.fit);
1111
+ if (d.x <= PICTURE_BARS && d.y <= PICTURE_BARS) return [];
1112
+ const drawn = [d.x > PICTURE_BARS ? `${pct(d.x)} of its drawn width` : null, d.y > PICTURE_BARS ? `${pct(d.y)} of its drawn height` : null].filter(Boolean).join(", ");
1113
+ const sides = ["left", "right", "top", "bottom"].filter((s) => r.bars[s] > 0).map((s) => `${pct(r.bars[s])} ${s}`).join(", ");
1114
+ // cover helps when the frame would crop the bars under the limit and keep two thirds of the content.
1115
+ let cover = false;
1116
+ if (f.fit !== "cover") {
1117
+ const c = drawnBars(r, f.frame, "cover"), s = Math.max(f.frame.width / r.width, f.frame.height / r.height);
1118
+ const kept = (Math.min(r.content.width * s, f.frame.width) * Math.min(r.content.height * s, f.frame.height)) / (r.content.width * r.content.height * s * s);
1119
+ cover = c.x <= PICTURE_BARS && c.y <= PICTURE_BARS && kept >= 1 - PICTURE_FIT.cropped;
1120
+ }
1121
+ return [MESSAGES.pictureBars(m.id, f.kind === "video" ? "clip" : "picture", drawn, sides, `${r.content.width}×${r.content.height} of ${r.width}×${r.height}`, cover)];
1122
+ }));
1123
+ }
1124
+
750
1125
  // Slides whose content overflows the phone card, as errors. Each entry: { id, overflow } in px.
751
1126
  export function phoneOverflowErrors(measured) {
752
1127
  return measured.filter((m) => m.overflow > 1).map((m) => MESSAGES.phoneOverflow(m.id, Math.ceil(m.overflow)));
753
1128
  }
754
1129
 
1130
+ // Each <video>'s src and poster, with its slide: { where, which, url }.
1131
+ export function videoMediaRefs(html) {
1132
+ const out = [];
1133
+ for (const [i, s] of slides(html).entries()) {
1134
+ for (const [tag] of s.body.matchAll(/<video\b[^>]*>/gi)) {
1135
+ for (const which of ["src", "poster"]) {
1136
+ const url = attr(tag, which)?.trim();
1137
+ if (url) out.push({ where: `slide ${s.id || i + 1}`, which, url });
1138
+ }
1139
+ }
1140
+ }
1141
+ return out;
1142
+ }
1143
+ const VIDEO_EXT = /\.(?:mp4|m4v|webm|mov|ogv)$/i;
1144
+ const IMAGE_EXT = /\.(?:png|jpe?g|webp|avif|gif|svg)$/i;
1145
+ // .ogg is left out: an Ogg file may hold video.
1146
+ const OTHER_EXT = /\.(?:mp3|m4a|aac|wav|opus|flac|json|html?|pdf|txt|css|m?js)$/i;
1147
+ // What a URL names by its extension: "video", "image", another kind, or null when it has none of these.
1148
+ export function mediaKindByName(url) {
1149
+ const path = stripQuery(url);
1150
+ if (VIDEO_EXT.test(path)) return "video";
1151
+ if (IMAGE_EXT.test(path)) return "image";
1152
+ const other = OTHER_EXT.exec(path);
1153
+ return other ? `a file ending ${other[0].toLowerCase()}` : null;
1154
+ }
1155
+ // What a file's first bytes say it is (ISO media, WebM, Ogg; PNG, JPEG, GIF, WebP, AVIF, HEIC; and the
1156
+ // plainly-not-video: MP3, PDF, text), or null.
1157
+ export function mediaKindByBytes(bytes) {
1158
+ const b = bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes);
1159
+ const ascii = (from, to) => String.fromCharCode(...b.subarray(from, to));
1160
+ if (b[0] === 0x89 && ascii(1, 4) === "PNG") return "image";
1161
+ if (b[0] === 0xff && b[1] === 0xd8) return "image";
1162
+ if (ascii(0, 3) === "ID3" || (b[0] === 0xff && (b[1] & 0xe0) === 0xe0)) return "an MP3 file";
1163
+ if (ascii(0, 4) === "%PDF") return "a PDF";
1164
+ if (ascii(0, 4) === "GIF8") return "image";
1165
+ if (ascii(0, 4) === "RIFF" && ascii(8, 12) === "WEBP") return "image";
1166
+ if (ascii(4, 8) === "ftyp") return /^(avi[fs]|hei[cxs]|hevc|mif1|msf1)/.test(ascii(8, 12)) ? "image" : "video";
1167
+ if (b[0] === 0x1a && b[1] === 0x45 && b[2] === 0xdf && b[3] === 0xa3) return "video";
1168
+ if (ascii(0, 4) === "OggS") return "video";
1169
+ const text = ascii(0, 16);
1170
+ if (/^\s*<svg/i.test(text)) return "image";
1171
+ if (/^\s*<\?xml/i.test(text)) return null; // maybe an SVG with a prolog
1172
+ if (/^\s*[<{[]/.test(text)) return "a text file";
1173
+ return null;
1174
+ }
1175
+ // A generic type (octet-stream) says nothing: browsers sniff such a file and play it.
1176
+ const kindOfType = (type) => (/^video\//.test(type) ? "video" : /^image\//.test(type) ? "image" : !type || /octet-stream$/.test(type) ? null : `served as ${type}`);
1177
+ // <video> src and poster that are the wrong kind of file, as errors. The kind comes from the extension,
1178
+ // else from the file's first bytes (a local file, when `readBytes` is given; it throws on a file outside
1179
+ // the folder, which localRef reports) or its served content type (a URL, when `fetch` is given); one that
1180
+ // cannot be told is let through. A URL that does not load is a warning (a flaky network should not block).
1181
+ // Returns { errors, warnings }.
1182
+ export async function videoMediaChecks(html, { fetch: fetchImpl = null, readBytes = null } = {}) {
1183
+ const errors = [], warnings = [];
1184
+ for (const ref of videoMediaRefs(html)) {
1185
+ const want = ref.which === "src" ? "video" : "image";
1186
+ let kind = mediaKindByName(ref.url);
1187
+ if (!kind && /^https?:\/\//i.test(ref.url) && fetchImpl) {
1188
+ try {
1189
+ const r = await fetchImpl(decode(ref.url), { signal: AbortSignal.timeout(FETCH_TIMEOUT_MS) });
1190
+ if (r.ok) kind = kindOfType((r.headers.get("content-type") || "").split(";")[0].trim().toLowerCase());
1191
+ else warnings.push(MESSAGES.videoUnreachable(ref.where, ref.which, ref.url, `returned HTTP ${r.status}`));
1192
+ await r.body?.cancel?.().catch(() => {});
1193
+ } catch (e) {
1194
+ warnings.push(MESSAGES.videoUnreachable(ref.where, ref.which, ref.url, `could not be fetched (${e.message})`));
1195
+ }
1196
+ } else if (!kind && !SCHEME.test(ref.url) && readBytes) {
1197
+ let bytes = null;
1198
+ try { bytes = readBytes(stripQuery(decode(ref.url))); } catch { /* outside the folder or missing: localRef's error */ }
1199
+ if (bytes) kind = mediaKindByBytes(bytes);
1200
+ }
1201
+ if (kind && kind !== want) errors.push(MESSAGES.videoMedia(ref.where, ref.which, ref.url, kind === "video" ? "a video" : kind === "image" ? "an image" : kind));
1202
+ }
1203
+ return { errors, warnings };
1204
+ }
1205
+
755
1206
  // The deck's own cap: `maxTotalSeconds` in script.md's front matter.
756
1207
  export function scriptCap(script) {
757
1208
  const front = /^---\r?\n([\s\S]*?)\r?\n---/.exec(script)?.[1] ?? "";
@@ -829,29 +1280,179 @@ const isHostedAsset = (url) => {
829
1280
  // (not the brand logo or an icon), <video>, <canvas>, <iframe>, a chart <svg> or an
830
1281
  // inline-style url() background (not a stylesheet's: that is usually a texture); a deck of three or more slides with fewer than a third that do
831
1282
  // reads as all type (the topic aims for every other slide; a plan with no
832
- // product to show may have fewer). Icons count as one set each: inline Lucide <svg> (by stroke width),
833
- // and <img> icons (class icon, or a generated icon-* asset).
1283
+ // product to show may have fewer). Icons count as one set each: inline Lucide <svg> (by stroke width), an inline
1284
+ // <svg> from another library set (data-icon="<set> <weight>", by set and weight), and <img> icons (class icon, or a
1285
+ // generated icon-* asset). A mix is a warning only: never a failure, and no slide is asked to have an icon.
834
1286
  const iconImg = (tag) => /\bicon\b/.test(attr(tag, "class") ?? "") || /\/icon-[\w-]+\.(png|webp|svg)\b/i.test(attr(tag, "src") ?? "");
1287
+ // Text contrast on each ground the deck paints, computed from its :root colours
1288
+ // (hex only: a colour the deck sets some other way is taken on trust).
1289
+ export function contrastWarnings(html) {
1290
+ const root = /:root\s*\{[^}]*--ink:[^}]*\}/.exec(uncommented(html))?.[0];
1291
+ if (!root) return [];
1292
+ const get = (name) => new RegExp(`(?:^|[\\s;{])${name}\\s*:\\s*(${CSS_VALUE})`).exec(root)?.[1].trim();
1293
+ const hex = (name) => (/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i.test(get(name) ?? "") ? get(name) : undefined);
1294
+ const [ink, paper, accent] = [hex("--ink"), hex("--paper"), hex("--accent")];
1295
+ if (!ink || !paper || !accent) return [];
1296
+ const pairs = groundPairs({ ink, paper, accent, accent2: hex("--accent-2"), accent3: hex("--accent-3"), card: hex("--card"), accentInk: get("--accent-ink") === "var(--paper)" ? "paper" : "ink", accentGround: get("--accent-ground") === "var(--tint-1)" ? "tint-1" : "accent",
1297
+ // The on-ink ground and its text when the deck sets them (a theme's --ink-ground and --ink-text).
1298
+ inkGround: hex("--ink-ground") ?? ink, inkText: hex("--ink-text") ?? (get("--ink-text") === "var(--ink)" ? ink : paper) });
1299
+ return pairs.filter(([, g, t]) => contrastRatio(g, t) < 4.5).map(([n, g, t]) => MESSAGES.lowContrast(n, contrastRatio(g, t)));
1300
+ }
1301
+
1302
+ // A theme part whose tokens are set but whose drawing rules the deck's shell lacks (or has in an older form):
1303
+ // the film (docs/roadmap/carousel-film-no-frozen-scratch-when-the-film-holds-still-du.md). applyTheme brings the
1304
+ // rules, so only a deck themed before that, or edited by hand, gets here.
1305
+ export function themePartWarnings(html) {
1306
+ const css = [...uncommented(html).matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/gi)].map((m) => m[1]).join("\n");
1307
+ const roots = [...css.replace(/\/\*[\s\S]*?\*\//g, "").matchAll(/:root\s*\{[^}]*\}/g)].map((m) => m[0]);
1308
+ if (!roots.some((r) => /--film\s*:\s*1\s*[;}]/.test(r))) return [];
1309
+ const theme = deckTheme(html) ?? "carousel";
1310
+ if (!/@keyframes\s+hd-film\b/.test(css)) return [MESSAGES.filmUndrawn(theme)];
1311
+ return css.includes("/* hd-film {") ? [] : [MESSAGES.filmOld(theme)];
1312
+ }
1313
+
1314
+ // A slide's layout (its l-<name> class), and for a layout with an icon slot how many items it has and how many
1315
+ // carry an icon (an <svg> or <img> of class icon).
1316
+ const layoutOf = (s) => /\bl-([a-z0-9-]+)/.exec(attr(s.tag, "class") ?? "")?.[1] ?? null;
1317
+ function iconSlotFill(s) {
1318
+ const layout = layoutOf(s);
1319
+ if (!s.id || !ICON_SLOTS[layout]) return null;
1320
+ const body = uncommented(s.body);
1321
+ const items = [...body.matchAll(ICON_SLOTS[layout].count ?? ICON_SLOTS[layout].at)].length;
1322
+ const icons = [...body.matchAll(/<(?:svg|img)\b[^>]*\bclass=["'](?:[^"']*\s)?icon[\s"']/gi)].length;
1323
+ return items ? { id: s.id, layout, items, icons } : null;
1324
+ }
1325
+ // The kind of picture a slide with none could take, by its layout (deck_guide topic pictures). A layout not named
1326
+ // here is words on purpose (a quote, a sentence, a closer) or draws its own figure (funnel, two-bars, loop).
1327
+ const PICTURE_KIND = {
1328
+ hero: "a photo", "cover-frame": "a photo", "cover-split": "a photo", "cover-band": "a photo", "cover-poster": "a photo",
1329
+ split: "a screenshot", "picture-full": "a photo", portrait: "their own photo", wall: "photos", team: "their faces",
1330
+ product: "a screenshot", phones: "screenshots", "phone-stage": "a screenshot", screens: "screenshots", zoom: "a screenshot", "tap-through": "screenshots",
1331
+ "video-full": "a recording", "video-beats": "a recording", embed: "a still of the page", number: "a chart", chart: "a chart",
1332
+ };
1333
+
1334
+ // Slides offered the same shapes are named together: "features-2, features-3: bento or spotlight".
1335
+ function otherShapes(alts) {
1336
+ const groups = new Map();
1337
+ for (const [id, names] of alts) groups.set(names.join(" or "), [...(groups.get(names.join(" or ")) ?? []), id]);
1338
+ return groups.size ? `; other shapes that could carry them: ${[...groups].map(([names, ids]) => `${ids.join(", ")}: ${names}`).join("; ")}` : "";
1339
+ }
1340
+
1341
+ // The deck-level variety warnings (docs/roadmap/slides-route-to-the-right-shape-and-the-check-warns-when-a-d.md),
1342
+ // on a deck of five or more slides: one layout on more than a third of the content slides (the covers and the
1343
+ // closer are not content), and three or more content slides in a row of one layout. A slide with no l-<name> class is
1344
+ // counted as content but never as a repeat. Each names the slides and offers two other shapes for each, from
1345
+ // what the slide's title says first, then from the table's rows its layout sits in.
1346
+ export function varietyWarnings(all) {
1347
+ if (all.length < 5) return [];
1348
+ const content = all.map((s) => ({ s, layout: layoutOf(s) })).filter(({ layout }) => !FRAME.has(layout));
1349
+ const said = (s) => `${s.title} ${textOf(/class=["'][^"']*\bkicker\b[^"']*["'][^>]*>([\s\S]*?)</.exec(s.body)?.[1] ?? "")}`;
1350
+ const altsFor = (layout, list, avoid) => list.map(({ s }) => [s.id, alternativesFor(layout, said(s), { avoid })]).filter(([id, names]) => id && names.length);
1351
+ const counts = new Map();
1352
+ for (const { layout } of content) if (layout) counts.set(layout, (counts.get(layout) ?? 0) + 1);
1353
+ const over = [...counts].filter(([, n]) => n >= 3 && n * 3 > content.length).map(([layout]) => layout);
1354
+ const out = over.map((layout) => {
1355
+ const list = content.filter((c) => c.layout === layout);
1356
+ // The first one stays; the others are the ones to change.
1357
+ return MESSAGES.layoutOverused(layout, list.map(({ s }) => s.id || "a slide with no id"), content.length, altsFor(layout, list.slice(1), over));
1358
+ });
1359
+ // Runs over the whole deck, in order; a layout already named as over-used is not named again for its run.
1360
+ for (let i = 0; i < all.length; ) {
1361
+ const layout = layoutOf(all[i]);
1362
+ let j = i + 1;
1363
+ while (j < all.length && layout && layoutOf(all[j]) === layout) j++;
1364
+ if (layout && j - i >= 3 && !over.includes(layout) && !FRAME.has(layout)) {
1365
+ const run = all.slice(i, j).map((s) => ({ s }));
1366
+ out.push(MESSAGES.layoutRun(layout, run.map(({ s }) => s.id || "a slide with no id"), altsFor(layout, run.slice(1), over)));
1367
+ }
1368
+ i = j;
1369
+ }
1370
+ return out;
1371
+ }
1372
+
1373
+ // Side-panel neighbours (docs/roadmap/mirrored-layouts-side-panel-slides-can-flip-left-right-and-t.md): two slides in a
1374
+ // row of one flippable layout, both flipped or both not, put the panel on the same side; data-flip on a layout that
1375
+ // does not flip does nothing. Warnings only, on any deck size: a pair is the smallest repeat, and each pair of a longer
1376
+ // run on one side is named. The layouts match the attribute, so any value flips: data-flip="false" is flipped, and warned.
1377
+ export function flipWarnings(all) {
1378
+ const flipped = (s) => /\sdata-flip(?=[\s=>])/.test(s.tag);
1379
+ const out = [];
1380
+ for (const [i, s] of all.entries()) {
1381
+ const layout = layoutOf(s), id = s.id || "with no id";
1382
+ const value = attr(s.tag, "data-flip");
1383
+ if (value != null && value !== "" && value !== "data-flip") out.push(MESSAGES.flipValue(id, value));
1384
+ if (flipped(s) && layout && !FLIPPABLE.includes(layout)) out.push(MESSAGES.flipIgnored(id, layout));
1385
+ const prev = all[i - 1];
1386
+ if (prev && layout && FLIPPABLE.includes(layout) && layoutOf(prev) === layout && flipped(prev) === flipped(s)) out.push(MESSAGES.layoutSameSide(layout, prev.id || "with no id", id, flipped(s)));
1387
+ }
1388
+ return out;
1389
+ }
1390
+
835
1391
  export function lookWarnings(html) {
836
1392
  const all = slides(html);
837
1393
  const out = [];
838
1394
  const picture = (body) =>
839
1395
  /<(video|canvas|iframe)\b/i.test(body) ||
840
- /<svg\b[^>]*class=["'][^"']*\bchart\b/i.test(body) ||
1396
+ // A chart <svg>, not an icon named chart-… (class "icon tabler-chart-pie").
1397
+ [...body.matchAll(/<svg\b[^>]*>/gi)].some(([tag]) => /\bchart\b/.test(attr(tag, "class") ?? "") && !/\bicon\b/.test(attr(tag, "class") ?? "")) ||
841
1398
  [...body.matchAll(/\bstyle=("[^"]*"|'[^']*')/gi)].some(([, v]) => /\burl\(/i.test(v)) ||
842
1399
  [...body.matchAll(/<img\b[^>]*>/gi)].some(([tag]) => !/\bbrand-logo\b/.test(attr(tag, "class") ?? "") && !iconImg(tag));
843
- const shown = all.filter((s) => picture(uncommented(s.body)) || /\burl\(/i.test(attr(s.tag, "style") ?? "")).length;
844
- if (all.length >= 3 && shown * 3 < all.length) out.push(MESSAGES.fewPictures(shown, all.length));
845
- const body = uncommented(all.map((s) => s.body).join("\n"));
846
- const sets = new Set();
847
- for (const [tag] of body.matchAll(/<svg\b[^>]*>/gi)) {
848
- if (/\blucide/.test(attr(tag, "class") ?? "")) sets.add(`Lucide at stroke-width ${attr(tag, "stroke-width") ?? "2"}`);
1400
+ const bare = all.filter((s) => !(picture(uncommented(s.body)) || /\burl\(/i.test(attr(s.tag, "style") ?? "")));
1401
+ const shown = all.length - bare.length;
1402
+ const slots = all.map((s) => iconSlotFill(s)).filter(Boolean);
1403
+ for (const f of slots) if (f.icons && f.icons < f.items) out.push(MESSAGES.partIconSlot(f.id, f.layout, f.icons, f.items));
1404
+ if (all.length >= 3 && shown * 3 < all.length) {
1405
+ const could = bare.map((s) => [s.id, PICTURE_KIND[layoutOf(s)]]).filter(([id, kind]) => id && kind);
1406
+ out.push(MESSAGES.fewPictures(shown, all.length, could));
849
1407
  }
850
- for (const [tag] of body.matchAll(/<img\b[^>]*>/gi)) {
851
- if (iconImg(tag)) sets.add("image icons");
1408
+ const sets = new Map();
1409
+ const seen = (label, id) => {
1410
+ if (!sets.has(label)) sets.set(label, []);
1411
+ if (id && !sets.get(label).includes(id)) sets.get(label).push(id);
1412
+ };
1413
+ for (const slide of all) {
1414
+ const body = uncommented(slide.body);
1415
+ for (const [tag] of body.matchAll(/<svg\b[^>]*>/gi)) {
1416
+ const from = attr(tag, "data-icon");
1417
+ if (from) seen(from.trim().toLowerCase().replace(/\s+/g, " "), slide.id);
1418
+ else if (/\blucide/.test(attr(tag, "class") ?? "")) seen(`Lucide at stroke-width ${attr(tag, "stroke-width") ?? "2"}`, slide.id);
1419
+ }
1420
+ for (const [tag] of body.matchAll(/<img\b[^>]*>/gi)) {
1421
+ if (iconImg(tag)) seen("image icons", slide.id);
1422
+ }
852
1423
  }
853
- if (sets.size > 1) out.push(MESSAGES.mixedIcons([...sets].sort()));
1424
+ const choice = deckIconChoice(html);
1425
+ if (choice?.problem) out.push(MESSAGES.iconChoice(choice.problem));
1426
+ if (sets.size > 1) out.push(MESSAGES.mixedIcons([...sets].sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))));
1427
+ out.push(...varietyWarnings(all), ...flipWarnings(all));
854
1428
  out.push(...textureWarnings(all, html), ...coverFadeWarnings(html));
1429
+ out.push(...embedWarnings(all));
1430
+ return out;
1431
+ }
1432
+
1433
+ // The embed slide (docs/roadmap/embed-slide-a-still-first-live-on-tap-maps-video-figma-booki.md): an <iframe> written
1434
+ // into a slide, and each frame (an element with data-embed) with no still or with a URL that will not go live. A deck
1435
+ // with neither gets no line.
1436
+ export function embedWarnings(all) {
1437
+ const out = [];
1438
+ for (const slide of all) {
1439
+ const id = slide.id || "a slide with no id";
1440
+ const body = uncommented(slide.body);
1441
+ if (/<iframe\b/i.test(body)) out.push(MESSAGES.iframeBare(id));
1442
+ for (const el of slideElements({ tag: slide.tag, body }).slice(1)) {
1443
+ const url = attr(el.tag, "data-embed");
1444
+ if (url == null) continue;
1445
+ const inside = body.slice(el.start, el.end);
1446
+ // A still: an <img class="still"> with a src, or a div.still (the layout's placeholder, which check fails on by itself).
1447
+ const still = [...inside.matchAll(/<(img|div)\b[^>]*>/gi)].some(([tag, name]) => classes(tag).includes("still") && (name.toLowerCase() === "div" || (attr(tag, "src") ?? "").trim()));
1448
+ if (!still) out.push(MESSAGES.embedNoStill(id));
1449
+ // The attribute as the browser reads it: our own markup writes & as &amp;.
1450
+ const resolved = resolveEmbed(decode(url));
1451
+ if (!resolved) out.push(MESSAGES.embedNoUrl(id, url));
1452
+ else if (!resolved.live) out.push(resolved.site ? MESSAGES.embedSiteLink(id, resolved.site, resolved.host) : MESSAGES.embedNotLive(id, resolved.host));
1453
+ else if (sharedLinkNote(resolved)) out.push(MESSAGES.embedSharedLink(id, sharedLinkNote(resolved)));
1454
+ }
1455
+ }
855
1456
  return out;
856
1457
  }
857
1458
 
@@ -986,11 +1587,14 @@ const RETIRED_TEXTURES = {
986
1587
  const SIGNATURES = ["bg-corner", "bg-mark"];
987
1588
  export const MAX_SIGNATURE_SLIDES = 3;
988
1589
  const BUSY_LAYOUTS = ["l-number", "l-features", "l-team", "l-timeline", "l-compare"]; // full-width content: nothing to back
1590
+ // The media layouts: the picture or recording is the slide's object and fills its column; no texture backs it.
1591
+ const MEDIA_LAYOUTS = ["l-phone-stage", "l-tap-through", "l-screens", "l-zoom", "l-video-full", "l-video-beats", "l-picture-full", "l-wall", "l-portrait", "l-embed"];
1592
+ const WORD_LAYOUTS = ["l-sentence", "l-strike", "l-spotlight", "l-funnel", "l-scorecard", "l-bento", "l-two-by-two", "l-staircase", "l-rail", "l-loop", "l-lanes", "l-two-bars", "l-stack"]; // the word shapes: their words run beside the presenter, nothing to back
989
1593
  const PICTURE_COVERS = ["l-cover-band", "l-cover-poster", "l-cover-split"]; // the picture is the ground (or half of it): a texture would only sit under it
990
1594
  export const TEXTURE_OFF = {
991
- "bg-corner": ["l-split", "l-product", "l-chart", "l-quote", ...BUSY_LAYOUTS, ...PICTURE_COVERS],
992
- "bg-stage": ["l-split", "l-chart", "l-quote", "l-closer", ...BUSY_LAYOUTS, ...PICTURE_COVERS, "l-cover-type", "l-cover-frame"],
993
- "bg-mark": ["l-split", "l-product", "l-chart", "l-phones", ...BUSY_LAYOUTS, ...PICTURE_COVERS],
1595
+ "bg-corner": ["l-split", "l-product", "l-chart", "l-quote", ...BUSY_LAYOUTS, ...PICTURE_COVERS, ...MEDIA_LAYOUTS, ...WORD_LAYOUTS],
1596
+ "bg-stage": ["l-split", "l-chart", "l-quote", "l-closer", ...BUSY_LAYOUTS, ...PICTURE_COVERS, "l-cover-type", "l-cover-frame", ...MEDIA_LAYOUTS, ...WORD_LAYOUTS],
1597
+ "bg-mark": ["l-split", "l-product", "l-chart", "l-phones", ...BUSY_LAYOUTS, ...PICTURE_COVERS, ...MEDIA_LAYOUTS, ...WORD_LAYOUTS],
994
1598
  };
995
1599
  function textureWarnings(all, html) {
996
1600
  const css = [...uncommented(html).matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/gi)].map((m) => m[1].replace(/\/\*[\s\S]*?\*\//g, "")).join("\n");
@@ -1079,6 +1683,48 @@ export function presenterGutterWarnings(html) {
1079
1683
  // not checked. `strict: true` makes every slide's data-note an error, as on a
1080
1684
  // pitch deck. Returns { slides, totalDuration, manifestUrl, manifest, silent,
1081
1685
  // passed, errors, warnings }; `silent` is a deck with no manifest that declared data-silent.
1686
+ // Found pictures (Unsplash, GIPHY): each slide that shows one carries its
1687
+ // credit (an error without it); too many GIFs, or a raw .gif, warn; with a
1688
+ // fetch, a link that no longer answers warns (the player hides it, so the
1689
+ // slide still shows, but without its picture).
1690
+ const STOCK_CHECKS = 20;
1691
+ export async function stockMediaChecks(html, { fetch: fetchImpl = null } = {}) {
1692
+ const errors = [];
1693
+ const warnings = [];
1694
+ const where = new Map();
1695
+ let gifs = 0;
1696
+ for (const [i, s] of slides(html).entries()) {
1697
+ const id = s.id || `${i + 1}`;
1698
+ const body = uncommented(s.body);
1699
+ const refs = stockRefs(`${s.tag}${body}`);
1700
+ if (!refs.length) continue;
1701
+ const sources = new Set(refs.map(stockSource));
1702
+ if (sources.has("unsplash") && !hasUnsplashCredit(body)) errors.push(MESSAGES.unsplashCredit(id));
1703
+ if (sources.has("giphy") && !hasGiphyCredit(body)) errors.push(MESSAGES.giphyCredit(id));
1704
+ if (creditLines(body).length > 1) warnings.push(MESSAGES.creditLines(id));
1705
+ // A GIF is one <video>/<img> on GIPHY; its poster is the same GIF.
1706
+ gifs += [...body.matchAll(/<(video|img)\b[^>]*>/gi)].filter(([tag]) => stockSource(attr(tag, "src") ?? "") === "giphy").length;
1707
+ // An <img> of the .gif itself (a <video>'s poster is the GIF's still, which is fine).
1708
+ if ([...body.matchAll(/<img\b[^>]*>/gi)].some(([tag]) => { const src = attr(tag, "src") ?? ""; return stockSource(src) === "giphy" && /\.gif$/i.test(new URL(src).pathname); })) warnings.push(MESSAGES.gifFormat(id));
1709
+ for (const u of refs) if (!where.has(u)) where.set(u, id);
1710
+ }
1711
+ if (gifs > MAX_DECK_GIFS) warnings.push(MESSAGES.tooManyGifs(gifs));
1712
+ if (fetchImpl) {
1713
+ const checks = [...where].slice(0, STOCK_CHECKS).map(async ([url, id]) => {
1714
+ try {
1715
+ const r = await fetchImpl(url, { method: "HEAD", redirect: "follow", signal: AbortSignal.timeout(FETCH_TIMEOUT_MS) });
1716
+ await r.body?.cancel?.().catch(() => {});
1717
+ if (r.status === 404 || r.status === 410) warnings.push(MESSAGES.stockGone(id, url, `returned HTTP ${r.status}`));
1718
+ else if (!r.ok) warnings.push(MESSAGES.stockUnchecked(id, url, `returned HTTP ${r.status}`));
1719
+ } catch (e) {
1720
+ warnings.push(MESSAGES.stockUnchecked(id, url, `could not be reached (${e.message})`));
1721
+ }
1722
+ });
1723
+ await Promise.all(checks);
1724
+ }
1725
+ return { errors, warnings };
1726
+ }
1727
+
1082
1728
  export async function checkSources({ html, script = "" }, opts = {}, { fetch: fetchImpl = globalThis.fetch } = {}) {
1083
1729
  const forbid = phraseList(opts.forbid);
1084
1730
  const flagCap = opts["max-duration"] ?? opts.maxDuration;
@@ -1089,9 +1735,13 @@ export async function checkSources({ html, script = "" }, opts = {}, { fetch: fe
1089
1735
  const exists = opts.hosted ? () => "hosted" : (opts.exists ?? (() => true));
1090
1736
  const strict = !!opts.strict;
1091
1737
  const errors = htmlErrors(html, { exists, forbid, script, hosted: !!opts.hosted, strict });
1738
+ const video = await videoMediaChecks(html, { fetch: fetchImpl, readBytes: opts.hosted ? null : opts.readBytes });
1739
+ errors.push(...video.errors);
1740
+ const stock = await stockMediaChecks(html, { fetch: fetchImpl });
1741
+ errors.push(...stock.errors);
1092
1742
  const warnings = [];
1093
1743
  if (!notesRequired(html, { strict })) for (const id of slidesWithoutNotes(html)) warnings.push(MESSAGES.noteSoft(id));
1094
- warnings.push(...lookWarnings(html), ...presenterGutterWarnings(html));
1744
+ warnings.push(...contrastWarnings(html), ...lookWarnings(html), ...themePartWarnings(html), ...(silentWithoutPresenter(html) ? [] : presenterGutterWarnings(html)), ...video.warnings, ...stock.warnings);
1095
1745
  // Without a folder (hosted, or a caller that passes no reader) only the inline scripts are read.
1096
1746
  const walked = deckFiles(html, opts.hosted ? {} : { pathExists: opts.pathExists, read: opts.read, isDir: opts.isDir });
1097
1747
  for (const m of walked.missing) errors.push(MESSAGES.scriptRef(m.ref, m.from));
@@ -1101,8 +1751,8 @@ export async function checkSources({ html, script = "" }, opts = {}, { fetch: fe
1101
1751
  // A deck that declares itself silent plays without narration; without the
1102
1752
  // declaration a missing manifest is still a forgotten narrate. Slides with
1103
1753
  // data-clip audio are narrated (the player plays them), so not silent.
1104
- const silent = !!player && !player.manifest && player.silent && !slides(html).some((s) => attr(s.tag, "data-clip"));
1105
- if (silent) warnings.push(opts.hosted ? MESSAGES.silentHosted() : MESSAGES.silent());
1754
+ const silent = silentDeck(html);
1755
+ if (silent) warnings.push(opts.hosted ? MESSAGES.silentHosted() : MESSAGES.silent(), ...scriptCueErrors(html, script).map(MESSAGES.silentCue));
1106
1756
  else if (player && !player.manifest) errors.push(opts.hosted ? MESSAGES.noManifestHosted() : MESSAGES.noManifest());
1107
1757
  if (player?.manifest) {
1108
1758
  const got = await fetchCheck(fetchImpl, player.manifest, JSON_TYPE);
@@ -1178,7 +1828,7 @@ export async function checkSources({ html, script = "" }, opts = {}, { fetch: fe
1178
1828
  for (const t of walked.templates) warnings.push(MESSAGES.scriptTemplate(t.from, t.samples));
1179
1829
  for (const c of walked.computed) warnings.push(MESSAGES.scriptComputed(c.from, c.calls));
1180
1830
  if (opts.hosted) {
1181
- for (const url of absoluteRefs(html)) if (!isHostedAsset(url) && /\.(png|jpe?g|gif|webp|avif|svg|mp4|webm|mov)(\?|#|$)/i.test(url)) warnings.push(MESSAGES.hotlink(url));
1831
+ for (const url of absoluteRefs(html)) if (!isHostedAsset(url) && !stockSource(url) && /\.(png|jpe?g|gif|webp|avif|svg|mp4|webm|mov)(\?|#|$)/i.test(url)) warnings.push(MESSAGES.hotlink(url));
1182
1832
  warnings.push(MESSAGES.layoutUnchecked(HOSTED_LAYOUT_WHY));
1183
1833
  }
1184
1834
  return {