@hypersocial/decks-cli 0.9.22 → 0.9.24

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 (88) hide show
  1. package/package.json +1 -1
  2. package/skills/hyperdecks/SKILL.md +113 -67
  3. package/skills/hyperdecks/chat.md +11 -8
  4. package/skills/hyperdecks/terminal.md +82 -0
  5. package/src/bars.mjs +268 -0
  6. package/src/brand.mjs +51 -8
  7. package/src/check.mjs +311 -15
  8. package/src/checkRules.mjs +616 -27
  9. package/src/commands.mjs +157 -28
  10. package/src/deckSlug.mjs +41 -0
  11. package/src/export-video.mjs +75 -5
  12. package/src/files.mjs +35 -0
  13. package/src/frame-clock.mjs +6 -2
  14. package/src/guide.mjs +91 -13
  15. package/src/hosted.mjs +18 -8
  16. package/src/iconAliasNames.mjs +70 -0
  17. package/src/iconChoice.mjs +97 -0
  18. package/src/iconSets.mjs +89 -0
  19. package/src/iconSlots.mjs +48 -0
  20. package/src/icons.mjs +285 -45
  21. package/src/iconsCli.mjs +76 -0
  22. package/src/layoutRoutes.mjs +92 -0
  23. package/src/layouts.mjs +4 -4
  24. package/src/mediaPreviews.mjs +3 -1
  25. package/src/narrate.mjs +31 -4
  26. package/src/opening.mjs +9 -3
  27. package/src/ops.mjs +49 -0
  28. package/src/photosGuide.mjs +47 -0
  29. package/src/picturesGuide.mjs +53 -0
  30. package/src/play.mjs +3 -2
  31. package/src/presenter.mjs +3 -1
  32. package/src/preview-moment.mjs +10 -2
  33. package/src/release.mjs +13 -5
  34. package/src/runtime.mjs +9 -2
  35. package/src/scaffold.mjs +73 -13
  36. package/src/source.mjs +86 -14
  37. package/src/stockMedia.mjs +299 -0
  38. package/src/themeCli.mjs +41 -0
  39. package/src/themes.mjs +345 -0
  40. package/templates/icons/material.LICENSE +202 -0
  41. package/templates/icons/material.json.gz +0 -0
  42. package/templates/icons/phosphor.LICENSE +21 -0
  43. package/templates/icons/phosphor.json.gz +0 -0
  44. package/templates/icons/tabler.LICENSE +21 -0
  45. package/templates/icons/tabler.json.gz +0 -0
  46. package/templates/layouts/_deck.html +177 -36
  47. package/templates/layouts/bento.html +75 -0
  48. package/templates/layouts/chart.html +6 -4
  49. package/templates/layouts/closer.html +10 -3
  50. package/templates/layouts/compare.html +13 -4
  51. package/templates/layouts/cover-band.html +10 -8
  52. package/templates/layouts/cover-frame.html +9 -7
  53. package/templates/layouts/cover-poster.html +8 -5
  54. package/templates/layouts/cover-split.html +7 -6
  55. package/templates/layouts/cover-type.html +1 -0
  56. package/templates/layouts/features.html +9 -7
  57. package/templates/layouts/funnel.html +60 -0
  58. package/templates/layouts/hero.html +40 -22
  59. package/templates/layouts/lanes.html +63 -0
  60. package/templates/layouts/loop.html +81 -0
  61. package/templates/layouts/number.html +2 -1
  62. package/templates/layouts/phone-stage.html +68 -0
  63. package/templates/layouts/phones.html +1 -0
  64. package/templates/layouts/picture-full.html +48 -0
  65. package/templates/layouts/portrait.html +45 -0
  66. package/templates/layouts/product.html +7 -6
  67. package/templates/layouts/quote.html +2 -1
  68. package/templates/layouts/rail.html +71 -0
  69. package/templates/layouts/scorecard.html +70 -0
  70. package/templates/layouts/screens.html +85 -0
  71. package/templates/layouts/sentence.html +39 -0
  72. package/templates/layouts/split.html +22 -7
  73. package/templates/layouts/spotlight.html +77 -0
  74. package/templates/layouts/stack.html +83 -0
  75. package/templates/layouts/staircase.html +76 -0
  76. package/templates/layouts/strike.html +46 -0
  77. package/templates/layouts/tap-through.html +73 -0
  78. package/templates/layouts/team.html +3 -2
  79. package/templates/layouts/timeline.html +16 -6
  80. package/templates/layouts/two-bars.html +53 -0
  81. package/templates/layouts/two-by-two.html +71 -0
  82. package/templates/layouts/video-beats.html +66 -0
  83. package/templates/layouts/video-full.html +62 -0
  84. package/templates/layouts/wall.html +81 -0
  85. package/templates/layouts/zoom.html +144 -0
  86. package/templates/narrated-deck.html +12 -7
  87. package/templates/script.md +2 -2
  88. /package/templates/icons/{LICENSE → lucide.LICENSE} +0 -0
@@ -5,7 +5,12 @@
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 { FRAME, alternativesFor } from "./layoutRoutes.mjs";
13
+ import { MAX_DECK_GIFS, creditLines, hasGiphyCredit, hasUnsplashCredit, stockRefs, stockSource } from "./stockMedia.mjs";
9
14
 
10
15
  export const PLAYER_V1 = "https://hyperdecks.ai/player/v1/player.js";
11
16
  // Decks released before the app moved to hyperdecks.ai load the same player
@@ -25,6 +30,8 @@ export const TRANSITIONS = ["drift", "cut", "push", "wipe", "zoom", "morph", "fl
25
30
  export const MAX_TRANSITION_KINDS = 2;
26
31
 
27
32
  export const MESSAGES = {
33
+ unknownTheme: (name) => `<html data-hd-theme="${name}"> is not a theme: pick one of ${THEME_IDS.join(", ")} (hyperdecks theme set <deck-dir> <name>)`,
34
+ 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
35
  noPlayer: () => `no player script: add <script type="module" src="${PLAYER_V1}" data-manifest="…">`,
29
36
  player: (src) => `player script must be ${PLAYER_V1} (got ${src})`,
30
37
  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 +65,7 @@ export const MESSAGES = {
58
65
  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
66
  mobileTitle: (id, title) => `slide ${id}: title "${title}" is over ${MOBILE_TITLE_CHARS} characters and needs a data-title-mobile`,
60
67
  slideId: (n) => `slide ${n} has no id`,
68
+ silentCue: (err) => `${err} (script.md is unused on a silent deck: it is never narrated)`,
61
69
  selector: (line, cue, selector, id) => `script.md line ${line}: [${cue}: ${selector}] matches nothing in slide ${id}`,
62
70
  gestureColon: (line, id) => `script.md line ${line}: [gesture ${id}] needs a colon: [gesture: ${id}]`,
63
71
  gesture: (line, id) => `script.md line ${line}: [gesture: ${id}] is not one of the head's gestures: ${GESTURES.join(", ")}`,
@@ -73,9 +81,19 @@ export const MESSAGES = {
73
81
  flyTwice: (ids) => `fly is for the deck's one big moment, but slides ${ids.join(", ")} all use it`,
74
82
  // Warnings from the look topic (deck_guide look): the deck passes, but a person should look.
75
83
  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)`,
84
+ 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}" })`,
85
+ 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})`,
86
+ 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)`,
87
+ // Variety (layoutRoutes.mjs): one shape over and over reads as the same slide again. Warnings only: a deliberate
88
+ // repeat is the author's call. `alts` is [[slide id, [layout, layout]], …], other shapes from the guide's table.
89
+ 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)`,
90
+ 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)`,
91
+ // A slide whose items have icons on some only (iconSlots.mjs). An empty slot is never warned about: icons are optional.
92
+ 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
93
  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)`,
94
+ // sets: [label, slide ids]; the slides are named so a deliberate mix is easy to keep and an accidental one easy to find.
95
+ iconChoice: (problem) => `${problem}; later icon searches cannot stay in it until it names a set and weight (icons sets)`,
96
+ 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
97
  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
98
  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
99
  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 +101,43 @@ export const MESSAGES = {
83
101
  placeholder: (id, what, el, how, img) => `slide ${id}: ${what} is still the layout's placeholder (${el}); ${how}, then put it in as ${img}`,
84
102
  // Warnings (check --layout): the deck still passes.
85
103
  layoutUnchecked: (why) => `layout not checked: ${why}`,
104
+ // Found pictures (stockMedia.mjs): the credit their terms require, and links that died.
105
+ 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\`)`,
106
+ 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`,
107
+ 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`,
108
+ stockUnchecked: (id, url, why) => `slide ${id}: ${url} ${why}, so check could not tell whether it still shows; try check again later`,
109
+ 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 " · "`,
110
+ tooManyGifs: (n) => `${n} GIFs in the deck: one or two at most, on casual slides (deck_guide topic look)`,
111
+ 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
112
  hotlink: (url) => `${url} is hotlinked from another site and can vanish after release; upload it with upload_deck_asset`,
87
113
  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
114
  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`,
115
+ pictureEmpty: (id, picture, frame, share, better) => `slide ${id}: the picture (${picture}) leaves ${share}% of its ${frame} frame empty; ${better} (deck_guide topic look)`,
116
+ barsUnchecked: (why) => `pictures and clips were not checked for bars baked into their files (${why})`,
117
+ 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)`,
118
+ 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)`,
119
+ overlap: (id, style, stage, fix) => `slide ${id}: the ${style} presenter would overlap the title at ${stage}; ${fix} (deck_guide topic presenter)`,
120
+ // The word layouts' boxes (wordFitWarnings): text that runs past its box.
121
+ 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)`,
122
+ 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)`,
123
+ 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)`,
124
+ // The media layouts' own rule (presenterMediaWarnings): what the presenter must leave clear on each.
125
+ presenterOnMedia: (id, style, what, stage, fix) => `slide ${id}: the ${style} presenter would cover ${what} at ${stage}; ${fix} (deck_guide topic layouts)`,
126
+ 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)`,
127
+ 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)`,
128
+ 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)`,
129
+ 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)`,
130
+ // An error: a <video> whose src is not a recording, or whose poster is not a still, plays black.
131
+ 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)"}`,
132
+ // A warning: the file could not be read, so its kind is unknown and the slide may play black.
133
+ 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
134
  // An error, though only check --layout can see it.
91
135
  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
136
  };
93
137
 
138
+ 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
139
  // The framed player's slide card on a phone (player.css): the screen less the
95
140
  // 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
141
  export const PHONE = { width: 390, height: 844, card: { width: 374, height: 736 } };
98
142
 
99
143
  const uncommented = (html) => html.replace(/<!--[\s\S]*?-->/g, "");
@@ -343,9 +387,29 @@ export function playerScript(html) {
343
387
  manifest: attr(tag, "data-manifest") || null,
344
388
  silent: hasAttr(tag, "data-silent") && !/^(false|0|no)$/i.test(attr(tag, "data-silent") ?? ""),
345
389
  kind: attr(tag, "data-kind")?.trim().toLowerCase() || null,
390
+ silentPresenter: attr(tag, "data-silent-presenter") ?? null,
346
391
  };
347
392
  }
348
393
 
394
+ // A silent deck: it declares data-silent, has no manifest and no slide with
395
+ // data-clip audio (those are narrated: the player plays them).
396
+ export function silentDeck(html) {
397
+ const player = playerScript(html);
398
+ return !!player && !player.manifest && player.silent && !slides(html).some((s) => attr(s.tag, "data-clip"));
399
+ }
400
+
401
+ // script.md's [go]/[look] and [gesture] cues.
402
+ const scriptCueErrors = (html, script) => [...cueSelectorErrors(html, script), ...cueGestureErrors(script)];
403
+
404
+ // A silent deck (data-silent, no manifest, no slide's data-clip) the player
405
+ // shows with no presenter: one made since decks carry data-silent-presenter="hide"
406
+ // (player.js silentFaceless). Its corner is the slide's, so check says nothing
407
+ // about the presenter's room. "show", or no attribute (a deck released before), keeps the face.
408
+ export function silentWithoutPresenter(html) {
409
+ const player = playerScript(html);
410
+ return !!player && !player.manifest && player.silent && player.silentPresenter === "hide" && !slides(html).some((s) => attr(s.tag, "data-clip"));
411
+ }
412
+
349
413
  // Source notes are required on a pitch deck (its claims) and under check
350
414
  // --strict; elsewhere a missing one is a warning.
351
415
  export const notesRequired = (html, { strict = false } = {}) => !!strict || playerScript(html)?.kind === "pitch";
@@ -578,6 +642,42 @@ const PLACEHOLDERS = [
578
642
  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
643
  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
644
  },
645
+ {
646
+ 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>)',
647
+ 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`" },
648
+ },
649
+ {
650
+ 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"',
651
+ 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`" },
652
+ },
653
+ {
654
+ layout: "l-screens", tag: "div", cls: "shot", what: "each screen", img: '<img class="shot" src="…" alt="…" width="…" height="…"> in each step',
655
+ 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`" },
656
+ },
657
+ {
658
+ 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',
659
+ how: { hosted: "capture the real page with capture_url", cli: "capture the real page with `hyperdecks screenshot <url>`" },
660
+ },
661
+ {
662
+ layout: "l-video-full", tag: "div", cls: "clip", what: "the recording", img: '<video class="clip" src="…" autoplay muted loop playsinline>',
663
+ how: { hosted: "upload the screen recording with upload_deck_asset", cli: "add the screen recording with `hyperdecks asset add`" },
664
+ },
665
+ {
666
+ layout: "l-video-beats", tag: "div", cls: "clip", what: "the recording", img: '<video class="clip" src="…" autoplay muted loop playsinline>',
667
+ how: { hosted: "upload the screen recording with upload_deck_asset", cli: "add the screen recording with `hyperdecks asset add`" },
668
+ },
669
+ {
670
+ layout: "l-picture-full", tag: "div", cls: "pic", what: "the picture", img: '<img class="pic" src="…" alt="…">',
671
+ how: { hosted: "upload the real photo with upload_deck_asset", cli: "add the real photo with `hyperdecks asset add`" },
672
+ },
673
+ {
674
+ layout: "l-wall", tag: "div", cls: "pic", what: "each picture on the wall", img: '<img class="pic" src="…" alt="…"> for each (three to five)',
675
+ how: { hosted: "upload the real photos with upload_deck_asset", cli: "add the real photos with `hyperdecks asset add`" },
676
+ },
677
+ {
678
+ layout: "l-portrait", tag: "div", cls: "pic", what: "the portrait", img: '<img class="pic" src="…" alt="…" width="…" height="…">',
679
+ how: { hosted: "upload the real photo with upload_deck_asset", cli: "add the real photo with `hyperdecks asset add`" },
680
+ },
581
681
  {
582
682
  layout: "l-chart", tag: "svg", cls: "chart", label: /placeholder/i, what: "the chart (made-up numbers)", img: '<img class="chart" src="…" alt="…">',
583
683
  how: { hosted: "draw the real data with render_chart", cli: "draw the real data with `hyperdecks chart <spec.json>`" },
@@ -598,7 +698,10 @@ export function placeholderErrors(html, { hosted = false } = {}) {
598
698
  // Everything checkable from the deck's own files. `exists(ref)` answers whether a
599
699
  // local reference resolves inside the deck folder: true, false or "outside".
600
700
  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 })];
701
+ const themeName = deckTheme(html);
702
+ const errs = themeName !== null && !findTheme(themeName) ? [MESSAGES.unknownTheme(themeName)] : [];
703
+ // A silent deck never plays script.md, so its cues warn instead (checkSources).
704
+ errs.push(...presenterStyleErrors(html, script), ...transitionErrors(html, script), ...(silentDeck(html) ? [] : scriptCueErrors(html, script)), ...placeholderErrors(html, { hosted }));
602
705
  const player = playerScript(html);
603
706
  if (!player) errs.push(MESSAGES.noPlayer());
604
707
  else if (!isPlayerV1(player.src)) errs.push(MESSAGES.player(player.src));
@@ -613,7 +716,9 @@ export function htmlErrors(html, { exists = () => true, forbid = [], script = ""
613
716
  const id = s.id || `${i + 1}`;
614
717
  if (!s.id) errs.push(MESSAGES.slideId(i + 1));
615
718
  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")) {
719
+ // sentence and strike: the title is the slide's whole statement (its mark included), set to wrap on a phone, so a
720
+ // shorter phone title would change what it says; they need none.
721
+ 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
722
  errs.push(MESSAGES.mobileTitle(id, s.title));
618
723
  }
619
724
  });
@@ -722,7 +827,16 @@ export function slideStyles(html, manifest = null) {
722
827
  const known = (v) => (PRESENTER_STYLES.includes(v) ? v : null);
723
828
  const deck = known(attr(tag, "data-presenter-style")) ?? known(manifest?.presenterStyle) ?? (attr(tag, "data-presenter") === "head" ? "stage" : "bubble");
724
829
  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 }));
830
+ const size = (v) => (PRESENTER_SIZES.includes(v) && v !== "m" ? v : null);
831
+ const deckSize = size(attr(tag, "data-presenter-size"));
832
+ return slides(html).map((s) => {
833
+ const style = known(attr(s.tag, "data-presenter-style")) ?? known(clips.get(s.id)?.presenterStyle) ?? deck;
834
+ // A slide's data-presenter-size (or the tag's) scales its footprint; the default (m) is left out. A slide's own m
835
+ // wins over the tag's size, as in the player.
836
+ const own = attr(s.tag, "data-presenter-size")?.trim();
837
+ const scale = PRESENTER_SIZES.includes(own) ? size(own) : deckSize;
838
+ return { id: s.id, style, ...(scale ? { size: scale } : {}) };
839
+ });
726
840
  }
727
841
 
728
842
  // What each style occupies at desktop size, in stage pixels (player.css): the
@@ -736,9 +850,31 @@ export const PRESENTER_FOOTPRINT = {
736
850
 
737
851
  // Measured boxes → warnings. Each entry: { id, style, presenter, title } with
738
852
  // { x, y, width, height } boxes (title null when the slide has none).
853
+ // data-presenter-size's scale (player.css --hd-presenter-scale: s .7, m 1, l 1.3, xl 1.6).
854
+ export const PRESENTER_SCALE = { s: 0.7, m: 1, l: 1.3, xl: 1.6 };
855
+
856
+ // The layouts that make room for a large presenter (data-presenter-size l or xl on the slide's own <section>): closer,
857
+ // split and the word shapes, for the stage presenter (closer for glass too; bubble is smaller than stage, so it fits
858
+ // all). A size on the player tag is not seen by a layout's CSS.
859
+ const WORD_ROOM = ["stage", "bubble"];
860
+ 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 };
861
+ // What clears an overlap (measureLayout gives the slide's layout, its own data-presenter-size (`sized`) and the size it plays at).
862
+ function overlapFix(m) {
863
+ const big = m.size === "l" || m.size === "xl";
864
+ // A deck made before its layout made room keeps its old styles: re-copying them is the step that works.
865
+ 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`;
866
+ const styles = ROOMY_LAYOUTS[m.layout];
867
+ 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`;
868
+ 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`;
869
+ 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>';
870
+ // Already on a layout that makes room: the title is what runs into the presenter.
871
+ const room = big && styles ? null : "use a layout that makes room for a large presenter (closer, split)";
872
+ const steps = [smaller, "shorten the title so it ends clear of the presenter's corner", room].filter(Boolean);
873
+ return steps.length > 1 ? `${steps.slice(0, -1).join(", ")}, or ${steps.at(-1)}` : steps[0];
874
+ }
739
875
  export function overlapWarnings(measured, stage = "1600×900") {
740
876
  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));
877
+ return measured.filter((m) => hit(m.presenter, m.title)).map((m) => MESSAGES.overlap(m.id, m.style, stage, overlapFix(m)));
742
878
  }
743
879
 
744
880
  // Covers whose rendered title lands on their picture, as warnings. Each entry: { id, onPicture }
@@ -747,11 +883,310 @@ export function coverTextWarnings(measured) {
747
883
  return measured.filter((m) => m.onPicture).map((m) => MESSAGES.coverText(`slide ${m.id}`));
748
884
  }
749
885
 
886
+ // 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
887
+ // past its edge or be clipped (measureLayout's `fit`, wordFitWarnings). Selectors per layout class.
888
+ export const FIT_BOXES = {
889
+ "l-spotlight": ".row > li", "l-funnel": ".stages > li", "l-scorecard": ".rows > li, .rows .state", "l-bento": ".tiles > *",
890
+ "l-two-by-two": ".q b", "l-staircase": ".steps > li", "l-rail": ".track > li", "l-loop": ".ring li", "l-lanes": ".lanes .chip, .lanes .who",
891
+ "l-two-bars": ".bars > li", "l-stack": ".layers > li",
892
+ };
893
+ // The rows of boxes that widen to their longest word (min-content tracks): the row must still fit its column.
894
+ export const FIT_ROWS = { "l-staircase": ".steps", "l-rail": ".track", "l-lanes": ".lanes" };
895
+ // Text that runs out of its box, and words broken across two lines in one, as warnings. Each measured entry:
896
+ // { id, fit: [text, …], broken: [word, …], wide: the longest name in a row wider than its column }.
897
+ export function wordFitWarnings(measured, { phone = false } = {}) {
898
+ const where = phone ? ` on a ${PHONE.width}×${PHONE.height} phone` : "";
899
+ 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)] : [])]);
900
+ }
901
+
902
+ // The layouts whose title is the whole statement and shows in full on a phone (no data-title-mobile needed).
903
+ export const FULL_TITLE_LAYOUTS = /(?:^|\s)l-(?:sentence|strike)(?:\s|$)/;
904
+ // The word layouts' parts that sit beside the presenter (measureLayout's media.words; their title is measured as every slide's).
905
+ 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" };
906
+ // The media layouts whose presenter must keep off what they show (measureLayout's `media`: boxes by role).
907
+ // zoom: the full screenshot, the lens and its label; video-full: the recording as drawn; picture-full: the presenter stays
908
+ // in the panel's column (the picture's subject is in the right two-thirds).
909
+ const MEDIA_CLEAR = {
910
+ shot: ["the full screenshot", "keep the full screenshot in its column, clear of the bottom-right corner, as the layout places it"],
911
+ lens: ["the lens", "keep the screenshot (and the lens on it) clear of the bottom-right corner, as the layout places it"],
912
+ 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"],
913
+ 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"],
914
+ art: ["the picture", "keep the picture in hero's frame (420px tall at most), which ends above the presenter's head"],
915
+ beyondPanel: ["the picture beyond the panel", "keep the slide's slot-left so the presenter stands under the panel"],
916
+ words: ["the words", "keep the layout's widths, which end left of the presenter's corner"],
917
+ };
918
+ // The word layouts make room for an l or xl presenter set on the slide's own <section>, as closer and split do.
919
+ function wordsFix(m) {
920
+ const name = m.layout.slice(2), big = m.size === "l" || m.size === "xl";
921
+ 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`;
922
+ 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`;
923
+ return MEDIA_CLEAR.words[1];
924
+ }
925
+ export function presenterMediaWarnings(measured, stage = "1600×900") {
926
+ 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;
927
+ return measured.flatMap((m) => {
928
+ if (!m.presenter || !m.media) return [];
929
+ // The hero's picture is kept clear of the head: the caption moves off pictures on its own (the player).
930
+ const roles = Object.entries(m.media).filter(([role, box]) => role === "beyondPanel"
931
+ ? box && m.presenter.x + m.presenter.width > box.x + box.width + 4
932
+ : hit(role === "art" ? m.head ?? m.presenter : m.presenter, box));
933
+ // The layouts are placed for the stage presenter; another style is larger (glass) or ignores the slot (corner).
934
+ 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" : ""})`);
935
+ return roles.map(([role]) => MESSAGES.presenterOnMedia(m.id, m.style, MEDIA_CLEAR[role][0], stage, fix(role)));
936
+ });
937
+ }
938
+
939
+ // zoom's lens enlarges its picture: past this many times its own pixels it reads blurred. Counted in a screen's
940
+ // pixels where decks are watched, a 1440×900 retina screen: the player draws the 1600px stage 1387px wide there, at
941
+ // 2 device pixels a pixel (a 1280px screenshot at --zoom 3 across a 950px frame is 4.3×, and reads soft).
942
+ export const LENS_MAX_ENLARGE = 2.5;
943
+ export const LENS_SCREEN = (1387 / 1600) * 2;
944
+ export function lensWarnings(measured) {
945
+ return measured.flatMap((m) => {
946
+ const times = m.lens && m.lens.natural > 0 ? (m.lens.shown * LENS_SCREEN) / m.lens.natural : 0;
947
+ return times > LENS_MAX_ENLARGE ? [MESSAGES.lensBlur(m.id, round(times), m.lens.natural, Math.ceil((m.lens.shown * LENS_SCREEN) / LENS_MAX_ENLARGE))] : [];
948
+ });
949
+ }
950
+
951
+ // zoom's lens is centred on its spot, never clamped (a clamp moves it off its target): a spot near the slide's edge
952
+ // takes the lens, or the label under it, past the slide. measureLayout gives the zoom slide's media boxes and the
953
+ // slide's own box (bounds). With { phone: true } the slides were measured in a phone's card.
954
+ export function lensOffSlideWarnings(measured, { phone = false } = {}) {
955
+ return measured.flatMap((m) => {
956
+ const { lens, label } = m.media ?? {}, slide = m.bounds;
957
+ if (!lens || !slide) return [];
958
+ const id = phone ? `${m.id} on a ${PHONE.width}×${PHONE.height} phone` : m.id;
959
+ return [["the lens", lens], ["the lens's label", label]].flatMap(([what, b]) => {
960
+ if (!b || b.width <= 0) return [];
961
+ 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);
962
+ return sides.length ? [MESSAGES.lensOffSlide(id, what, sides.join(" and "))] : [];
963
+ });
964
+ });
965
+ }
966
+
967
+ // A picture's fit in its frame (check --layout; measureLayout gives each slide's `pictures`:
968
+ // { natural, frame: { width, height }, fit, edge, shot }). Thresholds, picked from real decks: the
969
+ // minimoji-worlds cover's 1420×500 strip, contained in the old 7:6 hero frame (552×472 inside its
970
+ // border), left 59% of it empty (yellow bands above and below), and a 16:9 picture in that frame lost
971
+ // 34% to the crop. A fifth empty is a visible band; a third cropped is where a subject at the edge
972
+ // goes. Edge-to-edge covers (EDGE_PICTURES) crop by design and their strip or half shrinks as the
973
+ // title grows, so they warn only past a half: a 16:9 in cover-poster's strip loses 33% at 1600×900
974
+ // with a short title and more with a long one; a 3:1 strip in cover-split's half loses 70%, which warns.
975
+ // A laptop frame's shot crops a tall page capture to its top on purpose, so it is not measured.
976
+ export const PICTURE_FIT = { empty: 0.2, cropped: 1 / 3, edgeCropped: 1 / 2 };
977
+ export const EDGE_PICTURES = ".l-cover-band .art, .l-cover-split .art, .l-cover-poster .art, .l-picture-full .pic";
978
+ // Frames whose shape is the layout's, not the picture's (the edge-to-edge pictures and the wall's cells): trimming a
979
+ // picture's bars changes its shape, and such a frame then crops the trimmed picture (barsWarnings). The wall is not
980
+ // edge-to-edge: its cells warn past a third cropped (not a half), and the warning names the cells' class.
981
+ export const CELL_PICTURES = `${EDGE_PICTURES}, .l-wall .pic`;
982
+ // zoom's lens shows a part of its picture on purpose: it is not a frame.
983
+ export const UNMEASURED_PICTURES = ".frame.laptop > .shot, .l-zoom .lens .shot";
984
+ // The hero's frame takes any shape between these (hero.html: 552 wide at most, 178 to 472 tall).
985
+ const HERO_SHAPES = { min: 3 / 4, max: 3 };
986
+ const shapeName = (ar) => (ar >= 2 ? "a wide strip" : ar <= 0.85 ? "a portrait" : ar >= 1.2 ? "landscape" : "near-square");
987
+ // The cover layouts that suit a picture of this shape, best first (the hero suits any within HERO_SHAPES).
988
+ const SUITS = {
989
+ "a wide strip": ["cover-poster"],
990
+ "a portrait": ["cover-split"],
991
+ landscape: ["cover-frame", "cover-band", "cover-poster"],
992
+ "near-square": ["cover-split"],
993
+ };
994
+ function betterFit(m, p, ar) {
995
+ 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";
996
+ 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)";
997
+ // split's .shot.wide takes its picture's shape (a square sheet, 4:3, 16:9): no styling needed there.
998
+ 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)";
999
+ 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)";
1000
+ // The wall's cells are its .pics' class: upright (default), square or wide. Name the one that suits the picture.
1001
+ if (p.pic && m.layout === "l-wall" && !m.phone) {
1002
+ 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";
1003
+ const want = ar >= 1.2 ? "wide" : ar > 0.85 ? "square" : "";
1004
+ 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`;
1005
+ if (!want && p.cells) return `upright photos suit the wall's default cells: remove "${p.cells}" from <div class="pics ${p.cells}">`;
1006
+ return "use photos of one shape for the wall, or set object-position on the <img> to keep its subject in view";
1007
+ }
1008
+ if (p.pic) return "use a photo shaped like its frame, or set object-position on the <img> to keep its subject in view";
1009
+ const hero = ar >= HERO_SHAPES.min && ar <= HERO_SHAPES.max;
1010
+ 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";
1011
+ const kind = shapeName(ar);
1012
+ // A wide strip belongs edge to edge: cover-poster first, never away from it (in hero it needs class="art wide").
1013
+ 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";
1014
+ const suits = (kind === "a wide strip" ? [...SUITS[kind], ...(hero ? ['hero (with class="art wide")'] : [])] : [...(hero ? ["hero"] : []), ...SUITS[kind]]).filter((l) => `l-${l}` !== m.layout);
1015
+ 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`;
1016
+ }
1017
+ // With { phone: true } the slides were measured as a phone shows them (measureLayout's card): the
1018
+ // edge-to-edge frames there do not shrink with the title, so every picture warns past a third, and
1019
+ // each warning names the phone.
1020
+ export function pictureFitWarnings(measured, { phone = false } = {}) {
1021
+ const shape = ({ width, height }) => `${Math.round(width)}×${Math.round(height)}`;
1022
+ return measured.flatMap((m) => (m.pictures ?? []).flatMap((p) => {
1023
+ const ar = p.natural.width / p.natural.height, box = p.frame.width / p.frame.height;
1024
+ const lost = 1 - Math.min(ar, box) / Math.max(ar, box);
1025
+ const id = phone ? `${m.id} on a ${PHONE.width}×${PHONE.height} phone` : m.id, at = phone ? { ...m, phone } : m;
1026
+ 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))];
1027
+ // A hero picture wider than 2:1 belongs across the slide (class="art wide"), not in the corner column (said once, at desktop size).
1028
+ if (!phone && m.layout === "l-hero" && p.art && !p.wide && ar > 2) return [MESSAGES.heroStrip(id, shape(p.natural))];
1029
+ // The edge-to-edge covers crop a strip's sides by design on a phone too: they warn only past a half there.
1030
+ const edge = p.edge && (!phone || /^l-cover-/.test(m.layout ?? ""));
1031
+ 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))];
1032
+ return [];
1033
+ }));
1034
+ }
1035
+
1036
+ // A frame's drawn corner (the radius inside its border and padding) over this share of its shorter side cuts into
1037
+ // what it holds: an eighth for a photo or art, a sixteenth for a screenshot or clip, whose corners hold interface.
1038
+ // The built-in layouts cap each frame's corner at its share of the shortest side the layout draws it at
1039
+ // (min(calc(N * var(--round)), var(--frame-min) / 8), / 16 for a screenshot or clip), so a theme with big corners
1040
+ // rounds a short frame less. check --layout measures images (img.art, .shot, .pic); clips and product's browser frame
1041
+ // are held to it by lib/deckPictureCorners.test.ts.
1042
+ export const CORNER_SHARE = { picture: 1 / 8, screen: 1 / 16 };
1043
+ // Phone screens (a phone card's screen, product's phone, screens' phone shots) keep a phone's own corner.
1044
+ export const PHONE_SCREENS = ".frame.card .shot, .frame.phone .shot, .l-screens .shot:not(.wide)";
1045
+ // Warnings for each measured picture (measureLayout's pictures, with their drawn `corner`) whose corner is over
1046
+ // 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
1047
+ // wide: the wide frame's corner is capped for a strip.
1048
+ export function pictureCornerWarnings(measured, { phone = false } = {}) {
1049
+ return measured.flatMap((m) => (m.pictures ?? []).flatMap((p) => {
1050
+ const side = Math.min(p.frame.width, p.frame.height), screen = !!p.shot;
1051
+ const share = screen ? CORNER_SHARE.screen : CORNER_SHARE.picture;
1052
+ if (!(p.corner > side * share + 0.5)) return [];
1053
+ const id = phone ? `${m.id} on a ${PHONE.width}×${PHONE.height} phone` : m.id;
1054
+ const strip = m.layout === "l-hero" && p.art && !p.wide && p.natural.width / p.natural.height > 2;
1055
+ // Shown at its own size (or smaller than it is): the frame is under the layout's floor, so a larger picture fixes it.
1056
+ const own = p.natural.width <= p.frame.width + 1 && p.natural.height <= p.frame.height + 1;
1057
+ const fix = strip ? 'the picture is wider than 2:1: add class="art wide" to the <img>, whose frame rounds a strip less'
1058
+ : 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`
1059
+ : `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`;
1060
+ return [MESSAGES.pictureCorner(id, screen ? "screenshot" : "picture", Math.round(p.corner), Math.round(side), screen ? "a sixteenth" : "an eighth", fix)];
1061
+ }));
1062
+ }
1063
+
1064
+ // Bars baked into a framed picture or clip (packages/decks-cli/src/bars.mjs): past this share of the
1065
+ // width or height it is drawn at (both sides together), check --layout warns.
1066
+ export const PICTURE_BARS = 0.15;
1067
+ // The bars as drawn: { x, y } shares of the drawn width and height that are bars, for a file of
1068
+ // barsResult `r` in a frame ({ width, height }) with object-fit `fit`. cover crops from the centre
1069
+ // (object-position is not read); every other fit shows the whole file, so its bars keep their share.
1070
+ export function drawnBars(r, frame, fit) {
1071
+ 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;
1072
+ if (fit !== "cover") return { x: (left + right) / r.width, y: (top + bottom) / r.height };
1073
+ const s = Math.max(frame.width / r.width, frame.height / r.height);
1074
+ const cropX = (r.width * s - frame.width) / 2, cropY = (r.height * s - frame.height) / 2;
1075
+ const seen = (bar, crop) => Math.max(0, bar * s - crop);
1076
+ return { x: (seen(left, cropX) + seen(right, cropX)) / frame.width, y: (seen(top, cropY) + seen(bottom, cropY)) / frame.height };
1077
+ }
1078
+ // Warnings for each framed picture or clip whose file has bars past PICTURE_BARS as drawn. `measured`
1079
+ // is measureLayout's (each slide's `framed`: { src, kind, frame, fit }); `barsBySrc` maps a src to its
1080
+ // barsResult (a file that could not be read is absent and raises nothing).
1081
+ export function barsWarnings(measured, barsBySrc) {
1082
+ const pct = (n) => `${Math.round(n * 100)}%`;
1083
+ return measured.flatMap((m) => (m.framed ?? []).flatMap((f) => {
1084
+ const r = barsBySrc.get(f.src);
1085
+ if (!r?.reported) return [];
1086
+ // A frame of the layout's shape (a wall cell, an edge-to-edge picture) crops: trimming changes the picture's shape,
1087
+ // and if the frame would then crop the trimmed picture past its limit (PICTURE_FIT.cropped; edgeCropped for an
1088
+ // edge-to-edge picture), the trim advice trades
1089
+ // bars for a crop; say nothing.
1090
+ if (f.cell && f.fit === "cover") {
1091
+ const a = r.content.width / r.content.height, b = f.frame.width / f.frame.height;
1092
+ if (1 - Math.min(a, b) / Math.max(a, b) > (f.edge ? PICTURE_FIT.edgeCropped : PICTURE_FIT.cropped)) return [];
1093
+ }
1094
+ const d = drawnBars(r, f.frame, f.fit);
1095
+ if (d.x <= PICTURE_BARS && d.y <= PICTURE_BARS) return [];
1096
+ 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(", ");
1097
+ const sides = ["left", "right", "top", "bottom"].filter((s) => r.bars[s] > 0).map((s) => `${pct(r.bars[s])} ${s}`).join(", ");
1098
+ // cover helps when the frame would crop the bars under the limit and keep two thirds of the content.
1099
+ let cover = false;
1100
+ if (f.fit !== "cover") {
1101
+ const c = drawnBars(r, f.frame, "cover"), s = Math.max(f.frame.width / r.width, f.frame.height / r.height);
1102
+ 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);
1103
+ cover = c.x <= PICTURE_BARS && c.y <= PICTURE_BARS && kept >= 1 - PICTURE_FIT.cropped;
1104
+ }
1105
+ return [MESSAGES.pictureBars(m.id, f.kind === "video" ? "clip" : "picture", drawn, sides, `${r.content.width}×${r.content.height} of ${r.width}×${r.height}`, cover)];
1106
+ }));
1107
+ }
1108
+
750
1109
  // Slides whose content overflows the phone card, as errors. Each entry: { id, overflow } in px.
751
1110
  export function phoneOverflowErrors(measured) {
752
1111
  return measured.filter((m) => m.overflow > 1).map((m) => MESSAGES.phoneOverflow(m.id, Math.ceil(m.overflow)));
753
1112
  }
754
1113
 
1114
+ // Each <video>'s src and poster, with its slide: { where, which, url }.
1115
+ export function videoMediaRefs(html) {
1116
+ const out = [];
1117
+ for (const [i, s] of slides(html).entries()) {
1118
+ for (const [tag] of s.body.matchAll(/<video\b[^>]*>/gi)) {
1119
+ for (const which of ["src", "poster"]) {
1120
+ const url = attr(tag, which)?.trim();
1121
+ if (url) out.push({ where: `slide ${s.id || i + 1}`, which, url });
1122
+ }
1123
+ }
1124
+ }
1125
+ return out;
1126
+ }
1127
+ const VIDEO_EXT = /\.(?:mp4|m4v|webm|mov|ogv)$/i;
1128
+ const IMAGE_EXT = /\.(?:png|jpe?g|webp|avif|gif|svg)$/i;
1129
+ // .ogg is left out: an Ogg file may hold video.
1130
+ const OTHER_EXT = /\.(?:mp3|m4a|aac|wav|opus|flac|json|html?|pdf|txt|css|m?js)$/i;
1131
+ // What a URL names by its extension: "video", "image", another kind, or null when it has none of these.
1132
+ export function mediaKindByName(url) {
1133
+ const path = stripQuery(url);
1134
+ if (VIDEO_EXT.test(path)) return "video";
1135
+ if (IMAGE_EXT.test(path)) return "image";
1136
+ const other = OTHER_EXT.exec(path);
1137
+ return other ? `a file ending ${other[0].toLowerCase()}` : null;
1138
+ }
1139
+ // What a file's first bytes say it is (ISO media, WebM, Ogg; PNG, JPEG, GIF, WebP, AVIF, HEIC; and the
1140
+ // plainly-not-video: MP3, PDF, text), or null.
1141
+ export function mediaKindByBytes(bytes) {
1142
+ const b = bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes);
1143
+ const ascii = (from, to) => String.fromCharCode(...b.subarray(from, to));
1144
+ if (b[0] === 0x89 && ascii(1, 4) === "PNG") return "image";
1145
+ if (b[0] === 0xff && b[1] === 0xd8) return "image";
1146
+ if (ascii(0, 3) === "ID3" || (b[0] === 0xff && (b[1] & 0xe0) === 0xe0)) return "an MP3 file";
1147
+ if (ascii(0, 4) === "%PDF") return "a PDF";
1148
+ if (ascii(0, 4) === "GIF8") return "image";
1149
+ if (ascii(0, 4) === "RIFF" && ascii(8, 12) === "WEBP") return "image";
1150
+ if (ascii(4, 8) === "ftyp") return /^(avi[fs]|hei[cxs]|hevc|mif1|msf1)/.test(ascii(8, 12)) ? "image" : "video";
1151
+ if (b[0] === 0x1a && b[1] === 0x45 && b[2] === 0xdf && b[3] === 0xa3) return "video";
1152
+ if (ascii(0, 4) === "OggS") return "video";
1153
+ const text = ascii(0, 16);
1154
+ if (/^\s*<svg/i.test(text)) return "image";
1155
+ if (/^\s*<\?xml/i.test(text)) return null; // maybe an SVG with a prolog
1156
+ if (/^\s*[<{[]/.test(text)) return "a text file";
1157
+ return null;
1158
+ }
1159
+ // A generic type (octet-stream) says nothing: browsers sniff such a file and play it.
1160
+ const kindOfType = (type) => (/^video\//.test(type) ? "video" : /^image\//.test(type) ? "image" : !type || /octet-stream$/.test(type) ? null : `served as ${type}`);
1161
+ // <video> src and poster that are the wrong kind of file, as errors. The kind comes from the extension,
1162
+ // else from the file's first bytes (a local file, when `readBytes` is given; it throws on a file outside
1163
+ // the folder, which localRef reports) or its served content type (a URL, when `fetch` is given); one that
1164
+ // cannot be told is let through. A URL that does not load is a warning (a flaky network should not block).
1165
+ // Returns { errors, warnings }.
1166
+ export async function videoMediaChecks(html, { fetch: fetchImpl = null, readBytes = null } = {}) {
1167
+ const errors = [], warnings = [];
1168
+ for (const ref of videoMediaRefs(html)) {
1169
+ const want = ref.which === "src" ? "video" : "image";
1170
+ let kind = mediaKindByName(ref.url);
1171
+ if (!kind && /^https?:\/\//i.test(ref.url) && fetchImpl) {
1172
+ try {
1173
+ const r = await fetchImpl(decode(ref.url), { signal: AbortSignal.timeout(FETCH_TIMEOUT_MS) });
1174
+ if (r.ok) kind = kindOfType((r.headers.get("content-type") || "").split(";")[0].trim().toLowerCase());
1175
+ else warnings.push(MESSAGES.videoUnreachable(ref.where, ref.which, ref.url, `returned HTTP ${r.status}`));
1176
+ await r.body?.cancel?.().catch(() => {});
1177
+ } catch (e) {
1178
+ warnings.push(MESSAGES.videoUnreachable(ref.where, ref.which, ref.url, `could not be fetched (${e.message})`));
1179
+ }
1180
+ } else if (!kind && !SCHEME.test(ref.url) && readBytes) {
1181
+ let bytes = null;
1182
+ try { bytes = readBytes(stripQuery(decode(ref.url))); } catch { /* outside the folder or missing: localRef's error */ }
1183
+ if (bytes) kind = mediaKindByBytes(bytes);
1184
+ }
1185
+ if (kind && kind !== want) errors.push(MESSAGES.videoMedia(ref.where, ref.which, ref.url, kind === "video" ? "a video" : kind === "image" ? "an image" : kind));
1186
+ }
1187
+ return { errors, warnings };
1188
+ }
1189
+
755
1190
  // The deck's own cap: `maxTotalSeconds` in script.md's front matter.
756
1191
  export function scriptCap(script) {
757
1192
  const front = /^---\r?\n([\s\S]*?)\r?\n---/.exec(script)?.[1] ?? "";
@@ -829,28 +1264,133 @@ const isHostedAsset = (url) => {
829
1264
  // (not the brand logo or an icon), <video>, <canvas>, <iframe>, a chart <svg> or an
830
1265
  // 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
1266
  // 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).
1267
+ // product to show may have fewer). Icons count as one set each: inline Lucide <svg> (by stroke width), an inline
1268
+ // <svg> from another library set (data-icon="<set> <weight>", by set and weight), and <img> icons (class icon, or a
1269
+ // generated icon-* asset). A mix is a warning only: never a failure, and no slide is asked to have an icon.
834
1270
  const iconImg = (tag) => /\bicon\b/.test(attr(tag, "class") ?? "") || /\/icon-[\w-]+\.(png|webp|svg)\b/i.test(attr(tag, "src") ?? "");
1271
+ // Text contrast on each ground the deck paints, computed from its :root colours
1272
+ // (hex only: a colour the deck sets some other way is taken on trust).
1273
+ export function contrastWarnings(html) {
1274
+ const root = /:root\s*\{[^}]*--ink:[^}]*\}/.exec(uncommented(html))?.[0];
1275
+ if (!root) return [];
1276
+ const get = (name) => new RegExp(`(?:^|[\\s;{])${name}\\s*:\\s*(${CSS_VALUE})`).exec(root)?.[1].trim();
1277
+ const hex = (name) => (/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i.test(get(name) ?? "") ? get(name) : undefined);
1278
+ const [ink, paper, accent] = [hex("--ink"), hex("--paper"), hex("--accent")];
1279
+ if (!ink || !paper || !accent) return [];
1280
+ 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",
1281
+ // The on-ink ground and its text when the deck sets them (a theme's --ink-ground and --ink-text).
1282
+ inkGround: hex("--ink-ground") ?? ink, inkText: hex("--ink-text") ?? (get("--ink-text") === "var(--ink)" ? ink : paper) });
1283
+ return pairs.filter(([, g, t]) => contrastRatio(g, t) < 4.5).map(([n, g, t]) => MESSAGES.lowContrast(n, contrastRatio(g, t)));
1284
+ }
1285
+
1286
+ // A theme part whose tokens are set but whose drawing rules the deck's shell lacks (or has in an older form):
1287
+ // the film (docs/roadmap/carousel-film-no-frozen-scratch-when-the-film-holds-still-du.md). applyTheme brings the
1288
+ // rules, so only a deck themed before that, or edited by hand, gets here.
1289
+ export function themePartWarnings(html) {
1290
+ const css = [...uncommented(html).matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/gi)].map((m) => m[1]).join("\n");
1291
+ const roots = [...css.replace(/\/\*[\s\S]*?\*\//g, "").matchAll(/:root\s*\{[^}]*\}/g)].map((m) => m[0]);
1292
+ if (!roots.some((r) => /--film\s*:\s*1\s*[;}]/.test(r))) return [];
1293
+ const theme = deckTheme(html) ?? "carousel";
1294
+ if (!/@keyframes\s+hd-film\b/.test(css)) return [MESSAGES.filmUndrawn(theme)];
1295
+ return css.includes("/* hd-film {") ? [] : [MESSAGES.filmOld(theme)];
1296
+ }
1297
+
1298
+ // A slide's layout (its l-<name> class), and for a layout with an icon slot how many items it has and how many
1299
+ // carry an icon (an <svg> or <img> of class icon).
1300
+ const layoutOf = (s) => /\bl-([a-z0-9-]+)/.exec(attr(s.tag, "class") ?? "")?.[1] ?? null;
1301
+ function iconSlotFill(s) {
1302
+ const layout = layoutOf(s);
1303
+ if (!s.id || !ICON_SLOTS[layout]) return null;
1304
+ const body = uncommented(s.body);
1305
+ const items = [...body.matchAll(ICON_SLOTS[layout].count ?? ICON_SLOTS[layout].at)].length;
1306
+ const icons = [...body.matchAll(/<(?:svg|img)\b[^>]*\bclass=["'](?:[^"']*\s)?icon[\s"']/gi)].length;
1307
+ return items ? { id: s.id, layout, items, icons } : null;
1308
+ }
1309
+ // The kind of picture a slide with none could take, by its layout (deck_guide topic pictures). A layout not named
1310
+ // here is words on purpose (a quote, a sentence, a closer) or draws its own figure (funnel, two-bars, loop).
1311
+ const PICTURE_KIND = {
1312
+ hero: "a photo", "cover-frame": "a photo", "cover-split": "a photo", "cover-band": "a photo", "cover-poster": "a photo",
1313
+ split: "a screenshot", "picture-full": "a photo", portrait: "their own photo", wall: "photos", team: "their faces",
1314
+ product: "a screenshot", phones: "screenshots", "phone-stage": "a screenshot", screens: "screenshots", zoom: "a screenshot", "tap-through": "screenshots",
1315
+ "video-full": "a recording", "video-beats": "a recording", number: "a chart", chart: "a chart",
1316
+ };
1317
+
1318
+ // Slides offered the same shapes are named together: "features-2, features-3: bento or spotlight".
1319
+ function otherShapes(alts) {
1320
+ const groups = new Map();
1321
+ for (const [id, names] of alts) groups.set(names.join(" or "), [...(groups.get(names.join(" or ")) ?? []), id]);
1322
+ return groups.size ? `; other shapes that could carry them: ${[...groups].map(([names, ids]) => `${ids.join(", ")}: ${names}`).join("; ")}` : "";
1323
+ }
1324
+
1325
+ // The deck-level variety warnings (docs/roadmap/slides-route-to-the-right-shape-and-the-check-warns-when-a-d.md),
1326
+ // on a deck of five or more slides: one layout on more than a third of the content slides (the covers and the
1327
+ // closer are not content), and three or more content slides in a row of one layout. A slide with no l-<name> class is
1328
+ // counted as content but never as a repeat. Each names the slides and offers two other shapes for each, from
1329
+ // what the slide's title says first, then from the table's rows its layout sits in.
1330
+ export function varietyWarnings(all) {
1331
+ if (all.length < 5) return [];
1332
+ const content = all.map((s) => ({ s, layout: layoutOf(s) })).filter(({ layout }) => !FRAME.has(layout));
1333
+ const said = (s) => `${s.title} ${textOf(/class=["'][^"']*\bkicker\b[^"']*["'][^>]*>([\s\S]*?)</.exec(s.body)?.[1] ?? "")}`;
1334
+ const altsFor = (layout, list, avoid) => list.map(({ s }) => [s.id, alternativesFor(layout, said(s), { avoid })]).filter(([id, names]) => id && names.length);
1335
+ const counts = new Map();
1336
+ for (const { layout } of content) if (layout) counts.set(layout, (counts.get(layout) ?? 0) + 1);
1337
+ const over = [...counts].filter(([, n]) => n >= 3 && n * 3 > content.length).map(([layout]) => layout);
1338
+ const out = over.map((layout) => {
1339
+ const list = content.filter((c) => c.layout === layout);
1340
+ // The first one stays; the others are the ones to change.
1341
+ return MESSAGES.layoutOverused(layout, list.map(({ s }) => s.id || "a slide with no id"), content.length, altsFor(layout, list.slice(1), over));
1342
+ });
1343
+ // Runs over the whole deck, in order; a layout already named as over-used is not named again for its run.
1344
+ for (let i = 0; i < all.length; ) {
1345
+ const layout = layoutOf(all[i]);
1346
+ let j = i + 1;
1347
+ while (j < all.length && layout && layoutOf(all[j]) === layout) j++;
1348
+ if (layout && j - i >= 3 && !over.includes(layout) && !FRAME.has(layout)) {
1349
+ const run = all.slice(i, j).map((s) => ({ s }));
1350
+ out.push(MESSAGES.layoutRun(layout, run.map(({ s }) => s.id || "a slide with no id"), altsFor(layout, run.slice(1), over)));
1351
+ }
1352
+ i = j;
1353
+ }
1354
+ return out;
1355
+ }
1356
+
835
1357
  export function lookWarnings(html) {
836
1358
  const all = slides(html);
837
1359
  const out = [];
838
1360
  const picture = (body) =>
839
1361
  /<(video|canvas|iframe)\b/i.test(body) ||
840
- /<svg\b[^>]*class=["'][^"']*\bchart\b/i.test(body) ||
1362
+ // A chart <svg>, not an icon named chart-… (class "icon tabler-chart-pie").
1363
+ [...body.matchAll(/<svg\b[^>]*>/gi)].some(([tag]) => /\bchart\b/.test(attr(tag, "class") ?? "") && !/\bicon\b/.test(attr(tag, "class") ?? "")) ||
841
1364
  [...body.matchAll(/\bstyle=("[^"]*"|'[^']*')/gi)].some(([, v]) => /\burl\(/i.test(v)) ||
842
1365
  [...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"}`);
1366
+ const bare = all.filter((s) => !(picture(uncommented(s.body)) || /\burl\(/i.test(attr(s.tag, "style") ?? "")));
1367
+ const shown = all.length - bare.length;
1368
+ const slots = all.map((s) => iconSlotFill(s)).filter(Boolean);
1369
+ for (const f of slots) if (f.icons && f.icons < f.items) out.push(MESSAGES.partIconSlot(f.id, f.layout, f.icons, f.items));
1370
+ if (all.length >= 3 && shown * 3 < all.length) {
1371
+ const could = bare.map((s) => [s.id, PICTURE_KIND[layoutOf(s)]]).filter(([id, kind]) => id && kind);
1372
+ out.push(MESSAGES.fewPictures(shown, all.length, could));
849
1373
  }
850
- for (const [tag] of body.matchAll(/<img\b[^>]*>/gi)) {
851
- if (iconImg(tag)) sets.add("image icons");
1374
+ const sets = new Map();
1375
+ const seen = (label, id) => {
1376
+ if (!sets.has(label)) sets.set(label, []);
1377
+ if (id && !sets.get(label).includes(id)) sets.get(label).push(id);
1378
+ };
1379
+ for (const slide of all) {
1380
+ const body = uncommented(slide.body);
1381
+ for (const [tag] of body.matchAll(/<svg\b[^>]*>/gi)) {
1382
+ const from = attr(tag, "data-icon");
1383
+ if (from) seen(from.trim().toLowerCase().replace(/\s+/g, " "), slide.id);
1384
+ else if (/\blucide/.test(attr(tag, "class") ?? "")) seen(`Lucide at stroke-width ${attr(tag, "stroke-width") ?? "2"}`, slide.id);
1385
+ }
1386
+ for (const [tag] of body.matchAll(/<img\b[^>]*>/gi)) {
1387
+ if (iconImg(tag)) seen("image icons", slide.id);
1388
+ }
852
1389
  }
853
- if (sets.size > 1) out.push(MESSAGES.mixedIcons([...sets].sort()));
1390
+ const choice = deckIconChoice(html);
1391
+ if (choice?.problem) out.push(MESSAGES.iconChoice(choice.problem));
1392
+ if (sets.size > 1) out.push(MESSAGES.mixedIcons([...sets].sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))));
1393
+ out.push(...varietyWarnings(all));
854
1394
  out.push(...textureWarnings(all, html), ...coverFadeWarnings(html));
855
1395
  return out;
856
1396
  }
@@ -986,11 +1526,14 @@ const RETIRED_TEXTURES = {
986
1526
  const SIGNATURES = ["bg-corner", "bg-mark"];
987
1527
  export const MAX_SIGNATURE_SLIDES = 3;
988
1528
  const BUSY_LAYOUTS = ["l-number", "l-features", "l-team", "l-timeline", "l-compare"]; // full-width content: nothing to back
1529
+ // The media layouts: the picture or recording is the slide's object and fills its column; no texture backs it.
1530
+ 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"];
1531
+ 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
1532
  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
1533
  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],
1534
+ "bg-corner": ["l-split", "l-product", "l-chart", "l-quote", ...BUSY_LAYOUTS, ...PICTURE_COVERS, ...MEDIA_LAYOUTS, ...WORD_LAYOUTS],
1535
+ "bg-stage": ["l-split", "l-chart", "l-quote", "l-closer", ...BUSY_LAYOUTS, ...PICTURE_COVERS, "l-cover-type", "l-cover-frame", ...MEDIA_LAYOUTS, ...WORD_LAYOUTS],
1536
+ "bg-mark": ["l-split", "l-product", "l-chart", "l-phones", ...BUSY_LAYOUTS, ...PICTURE_COVERS, ...MEDIA_LAYOUTS, ...WORD_LAYOUTS],
994
1537
  };
995
1538
  function textureWarnings(all, html) {
996
1539
  const css = [...uncommented(html).matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/gi)].map((m) => m[1].replace(/\/\*[\s\S]*?\*\//g, "")).join("\n");
@@ -1079,6 +1622,48 @@ export function presenterGutterWarnings(html) {
1079
1622
  // not checked. `strict: true` makes every slide's data-note an error, as on a
1080
1623
  // pitch deck. Returns { slides, totalDuration, manifestUrl, manifest, silent,
1081
1624
  // passed, errors, warnings }; `silent` is a deck with no manifest that declared data-silent.
1625
+ // Found pictures (Unsplash, GIPHY): each slide that shows one carries its
1626
+ // credit (an error without it); too many GIFs, or a raw .gif, warn; with a
1627
+ // fetch, a link that no longer answers warns (the player hides it, so the
1628
+ // slide still shows, but without its picture).
1629
+ const STOCK_CHECKS = 20;
1630
+ export async function stockMediaChecks(html, { fetch: fetchImpl = null } = {}) {
1631
+ const errors = [];
1632
+ const warnings = [];
1633
+ const where = new Map();
1634
+ let gifs = 0;
1635
+ for (const [i, s] of slides(html).entries()) {
1636
+ const id = s.id || `${i + 1}`;
1637
+ const body = uncommented(s.body);
1638
+ const refs = stockRefs(`${s.tag}${body}`);
1639
+ if (!refs.length) continue;
1640
+ const sources = new Set(refs.map(stockSource));
1641
+ if (sources.has("unsplash") && !hasUnsplashCredit(body)) errors.push(MESSAGES.unsplashCredit(id));
1642
+ if (sources.has("giphy") && !hasGiphyCredit(body)) errors.push(MESSAGES.giphyCredit(id));
1643
+ if (creditLines(body).length > 1) warnings.push(MESSAGES.creditLines(id));
1644
+ // A GIF is one <video>/<img> on GIPHY; its poster is the same GIF.
1645
+ gifs += [...body.matchAll(/<(video|img)\b[^>]*>/gi)].filter(([tag]) => stockSource(attr(tag, "src") ?? "") === "giphy").length;
1646
+ // An <img> of the .gif itself (a <video>'s poster is the GIF's still, which is fine).
1647
+ 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));
1648
+ for (const u of refs) if (!where.has(u)) where.set(u, id);
1649
+ }
1650
+ if (gifs > MAX_DECK_GIFS) warnings.push(MESSAGES.tooManyGifs(gifs));
1651
+ if (fetchImpl) {
1652
+ const checks = [...where].slice(0, STOCK_CHECKS).map(async ([url, id]) => {
1653
+ try {
1654
+ const r = await fetchImpl(url, { method: "HEAD", redirect: "follow", signal: AbortSignal.timeout(FETCH_TIMEOUT_MS) });
1655
+ await r.body?.cancel?.().catch(() => {});
1656
+ if (r.status === 404 || r.status === 410) warnings.push(MESSAGES.stockGone(id, url, `returned HTTP ${r.status}`));
1657
+ else if (!r.ok) warnings.push(MESSAGES.stockUnchecked(id, url, `returned HTTP ${r.status}`));
1658
+ } catch (e) {
1659
+ warnings.push(MESSAGES.stockUnchecked(id, url, `could not be reached (${e.message})`));
1660
+ }
1661
+ });
1662
+ await Promise.all(checks);
1663
+ }
1664
+ return { errors, warnings };
1665
+ }
1666
+
1082
1667
  export async function checkSources({ html, script = "" }, opts = {}, { fetch: fetchImpl = globalThis.fetch } = {}) {
1083
1668
  const forbid = phraseList(opts.forbid);
1084
1669
  const flagCap = opts["max-duration"] ?? opts.maxDuration;
@@ -1089,9 +1674,13 @@ export async function checkSources({ html, script = "" }, opts = {}, { fetch: fe
1089
1674
  const exists = opts.hosted ? () => "hosted" : (opts.exists ?? (() => true));
1090
1675
  const strict = !!opts.strict;
1091
1676
  const errors = htmlErrors(html, { exists, forbid, script, hosted: !!opts.hosted, strict });
1677
+ const video = await videoMediaChecks(html, { fetch: fetchImpl, readBytes: opts.hosted ? null : opts.readBytes });
1678
+ errors.push(...video.errors);
1679
+ const stock = await stockMediaChecks(html, { fetch: fetchImpl });
1680
+ errors.push(...stock.errors);
1092
1681
  const warnings = [];
1093
1682
  if (!notesRequired(html, { strict })) for (const id of slidesWithoutNotes(html)) warnings.push(MESSAGES.noteSoft(id));
1094
- warnings.push(...lookWarnings(html), ...presenterGutterWarnings(html));
1683
+ warnings.push(...contrastWarnings(html), ...lookWarnings(html), ...themePartWarnings(html), ...(silentWithoutPresenter(html) ? [] : presenterGutterWarnings(html)), ...video.warnings, ...stock.warnings);
1095
1684
  // Without a folder (hosted, or a caller that passes no reader) only the inline scripts are read.
1096
1685
  const walked = deckFiles(html, opts.hosted ? {} : { pathExists: opts.pathExists, read: opts.read, isDir: opts.isDir });
1097
1686
  for (const m of walked.missing) errors.push(MESSAGES.scriptRef(m.ref, m.from));
@@ -1101,8 +1690,8 @@ export async function checkSources({ html, script = "" }, opts = {}, { fetch: fe
1101
1690
  // A deck that declares itself silent plays without narration; without the
1102
1691
  // declaration a missing manifest is still a forgotten narrate. Slides with
1103
1692
  // 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());
1693
+ const silent = silentDeck(html);
1694
+ if (silent) warnings.push(opts.hosted ? MESSAGES.silentHosted() : MESSAGES.silent(), ...scriptCueErrors(html, script).map(MESSAGES.silentCue));
1106
1695
  else if (player && !player.manifest) errors.push(opts.hosted ? MESSAGES.noManifestHosted() : MESSAGES.noManifest());
1107
1696
  if (player?.manifest) {
1108
1697
  const got = await fetchCheck(fetchImpl, player.manifest, JSON_TYPE);
@@ -1178,7 +1767,7 @@ export async function checkSources({ html, script = "" }, opts = {}, { fetch: fe
1178
1767
  for (const t of walked.templates) warnings.push(MESSAGES.scriptTemplate(t.from, t.samples));
1179
1768
  for (const c of walked.computed) warnings.push(MESSAGES.scriptComputed(c.from, c.calls));
1180
1769
  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));
1770
+ 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
1771
  warnings.push(MESSAGES.layoutUnchecked(HOSTED_LAYOUT_WHY));
1183
1772
  }
1184
1773
  return {