@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
package/src/hosted.mjs CHANGED
@@ -4,8 +4,9 @@
4
4
  import { api, client, target } from "./runtime.mjs";
5
5
  import { PRESENTER_STYLES } from "./checkRules.mjs";
6
6
  import { NARRATED_FILES, assembleLayoutDeck, fillTemplate, parseLayouts } from "./layouts.mjs";
7
- import { applyBrand, brandForNewDeck, brandSummary } from "./brand.mjs";
7
+ import { applyBrand, brandForNewDeck, brandSummary, brandWanted } from "./brand.mjs";
8
8
  import { getBrand } from "./ops.mjs";
9
+ import { DEFAULT_THEME, applyTheme, themeOrThrow, themeScript } from "./themes.mjs";
9
10
 
10
11
  export const SOURCE_FILES = Object.keys(NARRATED_FILES);
11
12
  const SLUG = /^[a-z0-9][a-z0-9-]{0,63}$/;
@@ -16,21 +17,29 @@ const urls = (opts, slug, previewToken) => {
16
17
 
17
18
  // Scaffold the files (the same templates as deck new) and register the draft.
18
19
  // The account's brand (colours, fonts, logo, presenter style) goes on the
19
- // template unless brand is false; an explicit presenterStyle wins over it.
20
- export async function hostedNewDeck(opts, { slug, title, layouts, presenterStyle, brand: useBrand } = {}) {
20
+ // template when no theme is named; a named theme keeps its own colours unless
21
+ // brand is true (brand false: never). An explicit presenterStyle wins over it.
22
+ export async function hostedNewDeck(opts, { slug, title, layouts, presenterStyle, brand: useBrand, theme: themeName } = {}) {
21
23
  if (!slug || !title) throw new Error("slug and title are required");
22
24
  if (!SLUG.test(slug)) throw new Error("slug must be lowercase letters, digits and dashes (max 64)");
23
25
  if (presenterStyle !== undefined && !PRESENTER_STYLES.includes(presenterStyle)) throw new Error(`presenterStyle must be one of ${PRESENTER_STYLES.join(", ")}`);
24
26
  const list = Array.isArray(layouts) ? layouts.join(",") : layouts;
25
27
  if (list) parseLayouts(list);
26
- const { brand, readError } = await brandForNewDeck(() => getBrand(opts), useBrand);
28
+ // No theme named is House, written out and marked like any other (see scaffold.mjs deckNew).
29
+ const named = themeName !== undefined && themeName !== null;
30
+ const theme = named ? themeOrThrow(themeName).id : DEFAULT_THEME;
31
+ if (useBrand !== undefined && useBrand !== null && typeof useBrand !== "boolean") throw new Error("brand must be true or false");
32
+ const wanted = brandWanted(useBrand ?? undefined, named);
33
+ const { brand, readError } = await brandForNewDeck(() => getBrand(opts), wanted);
27
34
  const style = presenterStyle ?? (PRESENTER_STYLES.includes(brand?.presenterStyle) ? brand.presenterStyle : undefined);
28
35
  const files = list
29
36
  ? assembleLayoutDeck({ slug, title, presenterStyle: style, layouts: list })
30
37
  : Object.fromEntries(Object.entries(NARRATED_FILES).map(([out, file]) => [out, fillTemplate(file, { slug, title, presenterStyle: style })]));
31
- files["index.html"] = applyBrand(files["index.html"], brand);
38
+ files["index.html"] = applyBrand(applyTheme(files["index.html"], theme), brand);
39
+ files["script.md"] = themeScript(files["script.md"], theme);
32
40
  const made = await (await client(opts)).mutation(api.deckSources.create, { slug, title, files });
33
- return { slug, rev: made.rev, files, brand: brandSummary(brand, readError), ...urls(opts, slug, made.previewToken) };
41
+ const themeNote = `In the ${theme} theme${named ? "" : " (the default)"}. Say which theme you used; another is new_deck again with theme (deck_guide { topic: "themes" } lists them).`;
42
+ return { slug, rev: made.rev, files, theme, themeNote, brand: brandSummary(brand, readError, { theme: named ? theme : undefined, wanted }), ...urls(opts, slug, made.previewToken) };
34
43
  }
35
44
 
36
45
  export async function getDeckSource(opts, { slug, file } = {}) {
@@ -48,7 +57,8 @@ export async function writeDeckSource(opts, { slug, file, content, edits, baseRe
48
57
  }
49
58
 
50
59
  // A public URL (or a ChatGPT upload's download_url) filed under the deck.
51
- export async function uploadDeckAsset(opts, { slug, name, url, file } = {}) {
60
+ // Returns { url, name, contentType, bytes, bars, trimmed? }: bars is a PNG's (bars.mjs), else null.
61
+ export async function uploadDeckAsset(opts, { slug, name, url, file, trim } = {}) {
52
62
  if (!slug) throw new Error("slug is required");
53
63
  const from = url ?? file?.download_url;
54
64
  if (!from) throw new Error("pass url, or file (a chat upload with a download_url)");
@@ -58,7 +68,7 @@ export async function uploadDeckAsset(opts, { slug, name, url, file } = {}) {
58
68
  const clean = (s) => String(s).replace(/[^A-Za-z0-9._-]+/g, "-").replace(/^[^A-Za-z0-9]+/, "");
59
69
  const unique = (s) => { const m = /^(.*?)(\.[A-Za-z0-9]{1,8})?$/.exec(clean(s) || "asset"); return `${(m[1] || "asset").slice(0, 100)}-${Date.now().toString(36)}${m[2] ?? ""}`; };
60
70
  const assetName = name ? clean(name).slice(0, 120) || "asset" : unique(fallback || "asset");
61
- return (await client(opts)).action(api.assetsNode.importAssetFromUrl, { slug, name: assetName, url: String(from), ...(file?.mime_type ? { mimeType: String(file.mime_type) } : {}) });
71
+ return (await client(opts)).action(api.assetsNode.importAssetFromUrl, { slug, name: assetName, url: String(from), ...(file?.mime_type ? { mimeType: String(file.mime_type) } : {}), ...(trim ? { trim: true } : {}) });
62
72
  }
63
73
 
64
74
  export async function hostedCheck(opts, { slug, forbid, maxDuration, strict } = {}) {
@@ -0,0 +1,70 @@
1
+ // The alias table (ICON_ALIASES in icons.mjs) names Lucide icons. Where another set has an icon of the same name it
2
+ // is used as it is (tabler's trending-up); these are the rest, each Lucide name with the set's icon that draws the
3
+ // same idea (Phosphor's money for banknote, Material's group for users). A Lucide name with no fair match in a set
4
+ // is left out, so the alias finds nothing there and the set's own names and tags answer. A set that has the name but
5
+ // not in every weight may name a stand-in for the weights it lacks (iconIn uses it only there). lib/iconSets.test.ts checks
6
+ // that each one is a real icon.
7
+ export const ICON_ALIAS_NAMES = {
8
+ phosphor: {
9
+ "arrow-left-right": "arrows-left-right", "audio-lines": "waveform", award: "medal", "badge-check": "seal-check", ban: "prohibit",
10
+ banknote: "money", blocks: "cube", bot: "robot", brush: "paint-brush", "calendar-clock": "calendar-dots", "calendar-days": "calendar-dots",
11
+ "chart-column": "chart-bar", "circle-alert": "warning-circle", "circle-check": "check-circle", "circle-dollar-sign": "currency-circle-dollar",
12
+ "circle-question-mark": "question", "circle-stop": "stop-circle", "circle-x": "x-circle", droplet: "drop", droplets: "drop",
13
+ earth: "globe-hemisphere-west", "eye-off": "eye-slash", "face-grinning": "smiley", "face-slightly-frowning": "smiley-sad",
14
+ "face-slightly-smiling": "smiley", "flower-2": "flower", "hand-helping": "hand-heart", "heart-handshake": "handshake",
15
+ "heart-pulse": "heartbeat", layers: "stack", "layout-grid": "squares-four", "life-buoy": "lifebuoy", "log-in": "sign-in",
16
+ luggage: "suitcase-rolling", mail: "envelope-simple", "mail-plus": "envelope-simple", map: "map-trifold", "message-circle": "chat-circle",
17
+ "message-circle-question-mark": "question", "message-square": "chat-centered", "message-square-reply": "arrow-bend-up-left",
18
+ "message-square-text": "chat-centered-text", "messages-square": "chats", mic: "microphone", "octagon-x": "hand-palm",
19
+ "party-popper": "confetti", "pen-tool": "pen-nib", plane: "airplane", puzzle: "puzzle-piece", "refresh-cw": "arrows-clockwise",
20
+ reply: "arrow-bend-up-left", "rotate-cw": "arrow-clockwise", route: "path", salad: "bowl-food", scale: "scales", "scroll-text": "scroll",
21
+ send: "paper-plane-tilt", "share-2": "share-network", smartphone: "device-mobile", split: "arrows-split", "spray-can": "spray-bottle",
22
+ sprout: "plant", store: "storefront", vote: "check-square", "tree-deciduous": "tree", trees: "tree-evergreen", "trending-up": "trend-up",
23
+ "triangle-alert": "warning", utensils: "fork-knife", workflow: "flow-arrow", zap: "lightning",
24
+ "calendar-clock": "calendar-dots", "clipboard-list": "clipboard-text", "clipboard-check": "clipboard-text", "id-card": "identification-card", "pill-bottle": "pill",
25
+ "pen-line": "pencil-line",
26
+ },
27
+ tabler: {
28
+ "audio-lines": "waveform", baby: "baby-carriage", "badge-check": "rosette-discount-check", banknote: "cash-banknote", "book-open": "book",
29
+ bot: "robot", "calendar-days": "calendar", "circle-alert": "alert-circle", "circle-dollar-sign": "currency-dollar",
30
+ "circle-question-mark": "help-circle", "cloud-sun": "sun", "door-open": "door-enter", earth: "world", "face-grinning": "mood-happy",
31
+ "face-slightly-frowning": "mood-sad", "face-slightly-smiling": "mood-smile", "flower-2": "flower", goal: "target",
32
+ "graduation-cap": "school", hand: "hand-stop", "hand-coins": "coins", "hand-heart": "heart-handshake", "hand-helping": "heart-handshake",
33
+ handshake: "heart-handshake", "heart-pulse": "heart-rate-monitor", house: "home", layers: "stack-2", "life-buoy": "lifebuoy",
34
+ lightbulb: "bulb", "list-checks": "list-check", "log-in": "login", "message-circle-question-mark": "help-circle",
35
+ "message-square": "message", "message-square-reply": "message-reply", "message-square-text": "message-2", "messages-square": "messages",
36
+ mic: "microphone", "octagon-x": "hand-stop", "party-popper": "confetti", "pen-tool": "pencil", "piggy-bank": "pig-money",
37
+ play: "player-play", "refresh-cw": "refresh", reply: "message-reply", "rotate-cw": "rotate-clockwise", "scroll-text": "file-text",
38
+ signpost: "direction-sign", smartphone: "device-mobile", split: "arrows-split", "spray-can": "spray", sprout: "seedling",
39
+ store: "building-store", "thumbs-up": "thumb-up", timer: "stopwatch", "tree-deciduous": "tree", "triangle-alert": "alert-triangle", vote: "checkbox",
40
+ utensils: "tools-kitchen-2", workflow: "automation", wrench: "tool", zap: "bolt",
41
+ "pill-bottle": "pill", "id-card": "id", "calendar-check": "calendar-check",
42
+ "pen-line": "pencil",
43
+ // Tabler draws no filled arrow-right; its fill weight takes the big arrow (the outline keeps arrow-right).
44
+ "arrow-right": "arrow-big-right",
45
+ },
46
+ material: {
47
+ apple: "nutrition", "arrow-left-right": "sync-alt", "audio-lines": "graphic-eq", award: "military-tech", baby: "child-care",
48
+ "badge-check": "verified", ban: "block", banknote: "payments", blocks: "extension", bot: "smart-toy", brain: "psychology",
49
+ briefcase: "work", calendar: "calendar-month", "calendar-days": "calendar-month", "chart-column": "bar-chart", "chart-line": "show-chart",
50
+ "circle-alert": "error", "circle-check": "check-circle", "circle-dollar-sign": "paid", "circle-question-mark": "help",
51
+ "circle-stop": "stop-circle", "circle-x": "cancel", clock: "schedule", "cloud-sun": "partly-cloudy-day", coins: "paid", compass: "explore",
52
+ droplet: "water-drop", droplets: "water-drop", ear: "hearing", earth: "public", eye: "visibility", "eye-off": "visibility-off",
53
+ "face-grinning": "sentiment-very-satisfied", "face-slightly-frowning": "sentiment-dissatisfied", "face-slightly-smiling": "sentiment-satisfied",
54
+ "file-text": "description", flower: "local-florist", "flower-2": "local-florist", gauge: "speed", gift: "redeem", goal: "sports-score",
55
+ "graduation-cap": "school", hammer: "construction", hand: "front-hand", "hand-coins": "savings", "hand-heart": "volunteer-activism",
56
+ "hand-helping": "volunteer-activism", headset: "headset-mic", heart: "favorite", "heart-handshake": "volunteer-activism",
57
+ "heart-pulse": "monitor-heart", "layout-grid": "grid-view", leaf: "eco", "life-buoy": "support", "list-checks": "checklist",
58
+ "log-in": "login", "mail-plus": "mail", "map-pin": "location-on", medal: "military-tech", "message-circle": "chat-bubble",
59
+ "message-circle-question-mark": "contact-support", "message-square": "chat", "message-square-reply": "reply", "message-square-text": "sms",
60
+ "messages-square": "forum", moon: "dark-mode", "octagon-x": "block", "party-popper": "celebration", "pen-tool": "draw",
61
+ "piggy-bank": "savings", plane: "flight", play: "play-arrow", plug: "power", presentation: "slideshow", puzzle: "extension",
62
+ recycle: "recycling", "refresh-cw": "refresh", "rotate-cw": "rotate-right", salad: "restaurant", "scroll-text": "policy", "share-2": "share",
63
+ "shield-check": "verified-user", shovel: "yard", split: "call-split", "spray-can": "sanitizer", sprout: "potted-plant",
64
+ "thumbs-up": "thumb-up", trash: "delete", "tree-deciduous": "park", trees: "forest", "triangle-alert": "warning", truck: "local-shipping",
65
+ user: "person", "user-plus": "person-add", users: "group", utensils: "restaurant", wind: "air", workflow: "account-tree", wrench: "build",
66
+ vote: "how-to-vote", x: "close", zap: "bolt", smartphone: "mobile", sparkles: "star-shine",
67
+ "calendar-check": "event-available", "clipboard-list": "assignment", "clipboard-check": "assignment-turned-in", "pill-bottle": "medication", "pill": "pill", "id-card": "id-card",
68
+ "pen-line": "edit",
69
+ },
70
+ };
@@ -0,0 +1,97 @@
1
+ // The icon sets' names and weights, and reading the choice a deck records, with no Node imports: the CLI, the
2
+ // hosted MCP route and check's rules (checkRules.mjs) all use it. The data itself loads in iconSets.mjs.
3
+
4
+ // draw: "stroke" for line icons (stroked in currentColor, stroke width
5
+ // adjustable), "fill" for solid shapes (filled in currentColor), "duotone" for
6
+ // a fill plus a second tone in the deck's accent.
7
+ export const ICON_SETS = [
8
+ {
9
+ id: "lucide",
10
+ name: "Lucide",
11
+ file: "templates/icons/lucide.json",
12
+ weights: { line: "stroke" },
13
+ character: "even line icons, plain and friendly (about 1,900); stroke weight set by --stroke-width, as with Tabler outline",
14
+ sample: ["rocket", "users", "shield-check", "sprout"],
15
+ },
16
+ {
17
+ id: "phosphor",
18
+ name: "Phosphor",
19
+ file: "templates/icons/phosphor.json.gz",
20
+ weights: { regular: "fill", thin: "fill", light: "fill", bold: "fill", fill: "fill", duotone: "duotone" },
21
+ character: "rounded and warm, in six weights: thin or light for a quiet or technical deck, bold or fill for a loud one, duotone (a light tint of the icon filling its body) for a soft one; a duotone row mixes solid-looking shapes (a chat bubble) with line-like ones (a stethoscope), so pick regular where the row must look even",
22
+ sample: ["rocket", "users", "shield-check", "plant"],
23
+ },
24
+ {
25
+ id: "tabler",
26
+ name: "Tabler",
27
+ file: "templates/icons/tabler.json.gz",
28
+ weights: { outline: "stroke", fill: "fill" },
29
+ character: "the largest set (about 5,000), crisp geometric lines on a 24px grid; outline for most icons, fill for about one in five",
30
+ sample: ["rocket", "users", "shield-check", "plant"],
31
+ },
32
+ {
33
+ id: "material",
34
+ name: "Material Symbols",
35
+ file: "templates/icons/material.json.gz",
36
+ weights: { outline: "fill", fill: "fill" },
37
+ character: "Google's system icons (about 3,900), sturdy and neutral; good for product, data and how-to decks",
38
+ sample: ["rocket", "group", "verified-user", "potted-plant"],
39
+ },
40
+ ];
41
+ export const ICON_SET_IDS = ICON_SETS.map((s) => s.id);
42
+ const WEIGHT_ALIASES = { filled: "fill", outlined: "outline", solid: "fill", stroke: "line" };
43
+
44
+ export function setMeta(id) {
45
+ const meta = ICON_SETS.find((s) => s.id === String(id ?? "").toLowerCase());
46
+ if (!meta) throw new Error(`unknown icon set "${id}"; one of ${ICON_SET_IDS.join(", ")} or all`);
47
+ return meta;
48
+ }
49
+
50
+ // A weight name as the set spells it (filled → fill), or the set's first weight when none is given; an
51
+ // unknown weight is an error that lists the set's own.
52
+ export function setWeight(id, weight) {
53
+ const meta = setMeta(id);
54
+ const names = Object.keys(meta.weights);
55
+ if (weight == null || weight === "") return names[0];
56
+ const w = String(weight).toLowerCase();
57
+ const plain = WEIGHT_ALIASES[w] ?? w;
58
+ if (names.includes(plain)) return plain;
59
+ if (id === "lucide" && ["regular", "outline"].includes(plain)) return "line";
60
+ throw new Error(`${meta.name} has no ${weight} weight; it has ${names.join(", ")}`);
61
+ }
62
+
63
+ // The weight in one set closest to a weight asked of all sets, or null when the set has nothing like it.
64
+ export function nearestWeight(id, weight) {
65
+ if (weight == null || weight === "") return setWeight(id);
66
+ try {
67
+ return setWeight(id, weight);
68
+ } catch {
69
+ const w = WEIGHT_ALIASES[String(weight).toLowerCase()] ?? String(weight).toLowerCase();
70
+ // Every set has a plain weight: regular, line and outline are one ask.
71
+ if (["regular", "line", "outline"].includes(w)) return setWeight(id);
72
+ return null;
73
+ }
74
+ }
75
+
76
+ // The set and weight a deck recorded in <meta name="hd-icons" content="<set> <weight>">: null when there is no
77
+ // tag; { set, weight } when it reads; and with problem (and raw, the tag's content) when it does not quite: an
78
+ // unknown weight keeps the set at its plainest weight, an unknown set has no set at all. A search says so, and
79
+ // check warns, so a typo in a hand-written tag is never taken for the deck's real choice.
80
+ export function deckIconChoice(html) {
81
+ const tag = /<meta\b[^>]*\bname=["']hd-icons["'][^>]*>/i.exec(String(html ?? ""))?.[0];
82
+ if (!tag) return null;
83
+ const raw = (/\bcontent=["']([^"']*)["']/i.exec(tag)?.[1] ?? "").trim();
84
+ const [set, weight] = raw.toLowerCase().split(/[\s/:,]+/).filter(Boolean);
85
+ if (!ICON_SET_IDS.includes(set)) return { raw, problem: `<meta name="hd-icons" content="${raw}"> names no icon set; one of ${ICON_SET_IDS.join(", ")}, e.g. content="phosphor duotone"` };
86
+ try {
87
+ return { set, weight: setWeight(set, weight) };
88
+ } catch (e) {
89
+ return { set, weight: setWeight(set), raw, problem: `<meta name="hd-icons" content="${raw}">: ${e.message}; searched ${setWeight(set)}` };
90
+ }
91
+ }
92
+
93
+ // A starting set and weight for each built-in theme: a suggestion, not a rule (the author picks for the subject too).
94
+ export const THEME_ICON_PAIRINGS = {
95
+ house: "phosphor bold", longform: "phosphor light", blueprint: "tabler outline", soft: "phosphor duotone", loud: "phosphor fill",
96
+ print: "material fill", quiet: "lucide line", evening: "phosphor light", carousel: "phosphor thin",
97
+ };
@@ -0,0 +1,89 @@
1
+ // The icon sets a deck can draw from, all vendored in templates/icons/ by
2
+ // scripts/sync-icons.mjs with their licence text beside them, and all offline:
3
+ // Lucide (plain JSON) and Phosphor, Tabler and Material Symbols (gzipped JSON,
4
+ // unzipped on first use). Brand and logo icons are left out of every set.
5
+ //
6
+ // A deck records the set and weight it draws from in one place, a meta tag in
7
+ // its <head>: <meta name="hd-icons" content="phosphor duotone">
8
+ // Later searches default to it (deckIconChoice). Icons are optional: a deck
9
+ // with no icons, or no choice recorded, is fine.
10
+ import { packageGzipText, packageText } from "./files.mjs";
11
+ import { ICON_SETS, THEME_ICON_PAIRINGS, setMeta, setWeight } from "./iconChoice.mjs";
12
+
13
+ export { ICON_SETS, ICON_SET_IDS, THEME_ICON_PAIRINGS, deckIconChoice, nearestWeight, setWeight } from "./iconChoice.mjs";
14
+
15
+ const loaded = new Map();
16
+ // A set's icons as { name: [tags[], markup per weight] } plus its viewBox, source and licence.
17
+ export function loadIconSet(id) {
18
+ const meta = setMeta(id);
19
+ if (!loaded.has(id)) {
20
+ const raw = JSON.parse(id === "lucide" ? packageText(meta.file) : packageGzipText(meta.file));
21
+ const icons = new Map();
22
+ for (const [name, entry] of Object.entries(raw.icons)) {
23
+ // Lucide keeps its original shape [markup, tags]; the others are [tags, ...markup per weight].
24
+ const [tagText, marks] = id === "lucide" ? [entry[1], [entry[0]]] : [entry[0], entry.slice(1)];
25
+ icons.set(name, [tagText ? tagText.split(",") : [], marks]);
26
+ }
27
+ loaded.set(id, { ...meta, viewBox: raw.viewBox ?? "0 0 24 24", source: raw.source, license: raw.license, icons });
28
+ }
29
+ return loaded.get(id);
30
+ }
31
+
32
+ const attrEsc = (v) => String(v).replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;");
33
+
34
+ // One icon as inline SVG in currentColor, or null when the set has no such icon in that weight. Lucide keeps the
35
+ // exact markup it always had (class "icon lucide-<name>"); the other sets carry data-icon="<set> <weight>" so
36
+ // check can tell them apart.
37
+ export function renderIcon(id, name, { weight, strokeWidth = 2 } = {}) {
38
+ const set = loadIconSet(id);
39
+ const w = setWeight(id, weight);
40
+ const entry = set.icons.get(name);
41
+ const markup = entry?.[1][Object.keys(set.weights).indexOf(w)];
42
+ if (!markup) return null;
43
+ const draw = set.weights[w];
44
+ const sw = Number(strokeWidth);
45
+ const width = Number.isFinite(sw) && sw > 0 && sw <= 4 ? sw : 2;
46
+ if (id === "lucide")
47
+ return `<svg class="icon lucide-${name}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="${width}" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${markup}</svg>`;
48
+ const head = `<svg class="icon ${id}-${attrEsc(name)}" data-icon="${id} ${w}" xmlns="http://www.w3.org/2000/svg" viewBox="${set.viewBox}"`;
49
+ if (draw === "stroke")
50
+ return `${head} fill="none" stroke="currentColor" stroke-width="${width}" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${markup}</svg>`;
51
+ // Two-tone: Phosphor marks its second tone opacity="0.2". It takes the theme's --icon-duo (the icon's own colour
52
+ // unless a theme or brand sets another) at Phosphor's own 20%: a tint of the icon, not a muddy fill (at 30% a chat
53
+ // bubble or clipboard on Soft's pink tile read as a filled shape beside line-like ones). It still shows on every ground.
54
+ const body = draw === "duotone" ? markup.replace(/ opacity="0\.2"/g, ' class="duo" style="fill:var(--icon-duo,currentColor)" opacity="0.2"') : markup;
55
+ return `${head} fill="currentColor" aria-hidden="true">${body}</svg>`;
56
+ }
57
+
58
+ // The tag that records a choice, for a deck's <head>.
59
+ export const iconChoiceTag = (set, weight) => `<meta name="hd-icons" content="${set} ${setWeight(set, weight)}">`;
60
+
61
+ // Put the choice in a deck's HTML: replace the tag if there is one, else add it at the end of <head>.
62
+ export function recordIconChoice(html, set, weight) {
63
+ const tag = iconChoiceTag(set, weight);
64
+ if (/<meta\b[^>]*\bname=["']hd-icons["'][^>]*>/i.test(html)) return html.replace(/<meta\b[^>]*\bname=["']hd-icons["'][^>]*>/i, tag);
65
+ if (/<\/head>/i.test(html)) return html.replace(/<\/head>/i, ` ${tag}\n</head>`);
66
+ throw new Error("the deck's index.html has no <head> to record the icon set in");
67
+ }
68
+
69
+ // The sets, for `icons sets` and icon_sets: each with its weights, character, size, licence and a sample.
70
+ export function listIconSets() {
71
+ return {
72
+ sets: ICON_SETS.map((meta) => {
73
+ const set = loadIconSet(meta.id);
74
+ return {
75
+ id: meta.id,
76
+ name: meta.name,
77
+ weights: Object.keys(meta.weights),
78
+ draws: meta.weights,
79
+ icons: set.icons.size,
80
+ character: meta.character,
81
+ source: set.source,
82
+ license: set.license,
83
+ sample: meta.sample.map((name) => ({ name, svg: renderIcon(meta.id, name) })).filter((s) => s.svg),
84
+ };
85
+ }),
86
+ pairings: THEME_ICON_PAIRINGS,
87
+ record: `Pick one set and weight for the deck, to suit its theme and subject, and record it with use_icon_set { slug, set, weight } (CLI: hyperdecks icons use <deck> <set> [weight]): it writes ${iconChoiceTag("phosphor", "duotone")} in the deck's <head> and puts the icons already there (the layouts' own too) in the set. Later searches default to it. pairings suggests a start per built-in theme; the subject may suggest otherwise. Icons are optional; a deck with none is fine.`,
88
+ };
89
+ }
@@ -0,0 +1,48 @@
1
+ // Where an icon goes in each layout that has an icon slot (layouts/*.html, "Icon slot"). No imports: check
2
+ // (checkRules.mjs, which Convex loads) reads it as well as the icon search and the guide.
3
+
4
+ // What a layout's icon slot takes (layouts/*.html, "Icon slot"): where the icon goes, said as the markup an agent
5
+ // sees, and how one is put there mechanically (fillIconSlots: each match of `at` keeps its first group, the item's
6
+ // opening, and the icon follows it; the rest of a match, rail's number or the features card's old icon, is replaced).
7
+ // `count`, where given, finds every item whether or not it holds an icon yet (rail's `at` stops at a filled dot).
8
+ // Every slot is optional (the owner, 2026-11-28: icons are never required). A slide that uses one keeps it on all its
9
+ // items alike.
10
+ export const ICON_SLOTS = {
11
+ features: { where: 'first inside each <li class="card">, in place of the icon there', at: /(<li\b[^>]*\bclass="card\b[^"]*"[^>]*>)(?:<svg\b[^>]*class="icon[\s\S]*?<\/svg>|<img\b[^>]*class="icon[^>]*>)?/g },
12
+ staircase: { where: 'first inside each step\'s <li>, before its <span class="n">', at: /(<li\b[^>]*>)/g },
13
+ bento: { where: 'first inside each tile (<div class="big"> and each <div class="small">)', at: /(<div class="(?:big|small)"[^>]*>)/g },
14
+ rail: { where: 'inside each stop\'s <span class="dot">, in place of its number', at: /(<span class="dot">)[^<]*(?=<\/span>)/g, count: /<span class="dot">/g },
15
+ lanes: { where: 'first inside each <b class="who">, before the actor\'s name', at: /(<b class="who">)/g },
16
+ scorecard: { where: 'first inside each row\'s <li>, before its <b>', at: /(<li\b[^>]*>)/g },
17
+ spotlight: { where: 'first inside each option\'s <li> (the picked one too), before its <b>', at: /(<li\b[^>]*>)/g },
18
+ stack: { where: 'first inside each layer\'s <li>, before its <b>', at: /(<li\b[^>]*>)/g },
19
+ timeline: { where: 'first inside each milestone\'s <li>, before its <time>', at: /(<li\b[^>]*>)/g },
20
+ split: { where: 'inside the <span class="sticker">, in place of its icon (or put the product\'s logo there instead)', at: /(<span class="sticker"[^>]*>)(?:<svg\b[\s\S]*?<\/svg>)?/g, count: /<span class="sticker"/g },
21
+ compare: { where: 'first inside each <div class="label">, before its text', at: /(<div class="label">)/g },
22
+ };
23
+ export const ICON_SLOT_LAYOUTS = Object.keys(ICON_SLOTS);
24
+
25
+ // Glyphs a layout ships that are not item icons: the closer's button arrow. --for finds them so the author can put it in
26
+ // the deck's set, and the answer draws it bare (no class "icon": the button's text colour and size, never a tile).
27
+ // Not an icon slot: check never counts it, and the pictures guide does not offer it.
28
+ export const ICON_GLYPHS = {
29
+ closer: { where: 'inside the <a class="cta">, after its text, in place of its arrow', at: /(<a\b[^>]*\bclass="cta"[^>]*>[^<]*)(?:<svg\b[\s\S]*?<\/svg>)?/g, bare: true },
30
+ };
31
+
32
+ // --for names a layout with an icon slot, a slide made from one (staircase-2) or layout:slide-id; the icon carries
33
+ // no id, so only the layout matters. Its slot, or a readable error.
34
+ export function iconSlot(target) {
35
+ const t = String(target ?? "").trim().toLowerCase();
36
+ const name = t.includes(":") ? t.split(":")[0] : t;
37
+ const glyph = Object.keys(ICON_GLYPHS).find((n) => name === n || new RegExp(`^${n}-\\d+$`).test(name));
38
+ if (glyph) return { layout: glyph, where: ICON_GLYPHS[glyph].where, bare: true, oneSet: "Draw it from the deck's set, as its other icons; paste it unedited (bare: the button sizes and colours it)." };
39
+ const layout = ICON_SLOT_LAYOUTS.find((n) => name === n || new RegExp(`^${n}-\\d+$`).test(name));
40
+ if (!layout) throw new Error(`--for takes a layout with an icon slot: ${ICON_SLOT_LAYOUTS.join(", ")}, or closer for its button's arrow (or a slide made from one, like staircase-2); "${target}" is not one`);
41
+ return { layout, where: ICON_SLOTS[layout].where, oneSet: "Optional: use an icon where it helps the reader find or remember the item, and leave it out where the words carry it. If this slide has icons, its items match (all with one, or none), in one style for the deck (one set and weight, or one generated set, not both). The theme sizes and colours it, so paste it unedited." };
42
+ }
43
+
44
+ // A section's markup with `markup` in each of its icon slots (what the guide tells an agent to do, done mechanically).
45
+ export function fillIconSlots(section, layout, markup) {
46
+ return section.replace((ICON_SLOTS[layout] ?? ICON_GLYPHS[layout]).at, (_, open) => `${open}${typeof markup === "function" ? markup() : markup}`);
47
+ }
48
+