@hypersocial/decks-cli 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/ops.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  import { zipSync } from "fflate";
2
+ import { COLOR_KEYS, FONT_PAIRINGS, FONT_ROLES, findPairing, googleFontsUrl } from "./brand.mjs";
2
3
  import { api, client, target, uploadBytes as runtimeUploadBytes } from "./runtime.mjs";
3
4
  import {
4
5
  bytesFromText,
@@ -1019,6 +1020,68 @@ export async function setNarratorVoice(opts, ref, voice) {
1019
1020
  return { narrator: n.id, name: n.name, voice: String(voice) };
1020
1021
  }
1021
1022
 
1023
+ export async function renameNarrator(opts, ref, name) {
1024
+ if (!String(name ?? "").trim()) throw new Error("usage: narrator rename <name|id> <new name>");
1025
+ const n = await findNarrator(opts, ref);
1026
+ if (n.builtin) throw new Error("D.A.S.H. is built in; its name stays");
1027
+ await (await client(opts)).mutation(api.narrators.rename, { narrator: n.id, name: String(name).trim() });
1028
+ return { narrator: n.id, was: n.name, name: String(name).trim() };
1029
+ }
1030
+
1031
+ // face: one of your avatars (name or id from `avatar`); D.A.S.H. keeps its own.
1032
+ export async function setNarratorFace(opts, ref, avatarRef) {
1033
+ if (!avatarRef) throw new Error("usage: narrator face <name|id> <avatar>");
1034
+ const n = await findNarrator(opts, ref);
1035
+ if (n.builtin) throw new Error("D.A.S.H. is built in and keeps its face");
1036
+ const a = await findAvatar(opts, avatarRef);
1037
+ if (a.source === "dash") throw new Error("D.A.S.H.'s face is D.A.S.H.'s; pick one of your avatars");
1038
+ await (await client(opts)).mutation(api.narrators.setFace, { narrator: n.id, avatarId: a.id });
1039
+ return { narrator: n.id, name: n.name, face: a.name };
1040
+ }
1041
+
1042
+ // A short sample of a voice, or of a narrator's voice: { url, caption } (what
1043
+ // the dashboard's play buttons play). A narrator also brings its face still.
1044
+ export async function hearVoice(opts, { voice, narrator } = {}) {
1045
+ const c = await client(opts);
1046
+ if (!voice && !narrator) throw new Error("name a voice or a narrator (list_voices / list_narrators)");
1047
+ let ref = voice ? String(voice) : null;
1048
+ let who = null;
1049
+ if (narrator) {
1050
+ const n = await findNarrator(opts, narrator);
1051
+ const raw = (await c.query(api.narrators.list, {})).narrators.find((x) => x.id === n.id);
1052
+ if (!raw?.voice) throw new Error(`${n.name} has no voice yet; give it one (narrator voice)`);
1053
+ if (!raw.voice.ready) throw new Error(`${n.name}'s voice ${raw.voice.name} is not ready yet`);
1054
+ ref = raw.voice.ref;
1055
+ who = { narrator: n.id, name: n.name, faceUrl: raw.face?.thumbUrl ?? null, faceName: raw.face?.name ?? null };
1056
+ }
1057
+ const out = await c.action(api.narratorsNode.hear, { voice: ref });
1058
+ return { ...out, voice: ref, ...(who ?? {}) };
1059
+ }
1060
+
1061
+ // A photo drawing started from chat (avatar_from_photo with a photo): still
1062
+ // drawing, failed, or drawn, when it hands back the link where the person
1063
+ // approves it. Nothing is used before they do.
1064
+ export async function startAvatarDrawing(opts, { bytes, contentType }) {
1065
+ if (!/^image\/(jpeg|png)$/.test(contentType ?? "")) throw new Error("the photo must be a .jpg or .png");
1066
+ const c = await client(opts);
1067
+ const storageId = await runtimeUploadBytes(c, bytes, contentType);
1068
+ const { draftId } = await c.mutation(api.avatars.drawSelfie, { storageId });
1069
+ return { status: "drawing", draftId };
1070
+ }
1071
+
1072
+ export async function avatarDraftStatus(opts, draftId) {
1073
+ if (!draftId) throw new Error("draftId is required");
1074
+ const c = await client(opts);
1075
+ const draft = await c.query(api.avatars.getDraft, { draftId: String(draftId) });
1076
+ if (!draft) throw new Error("the drawing is gone; start again with avatar_from_photo");
1077
+ if (draft.status === "drawing") return { status: "drawing", draftId };
1078
+ if (draft.status === "failed") throw new Error(draft.error || "the drawing failed; try another photo");
1079
+ if (draft.status === "added") return { status: "added", draftId, avatarId: draft.avatarId ?? null };
1080
+ if (draft.status !== "drawn") throw new Error(`the drawing is in an unexpected state (${draft.status}); start again with avatar_from_photo`);
1081
+ const link = await c.mutation(api.avatars.createLink, { kind: "review", draftId });
1082
+ return { status: "waiting", reviewUrl: link.url, token: link.token, draftId, expiresAt: link.expiresAt };
1083
+ }
1084
+
1022
1085
  // A deck's own narrator: a narrator, `none` (captions only) or `default`.
1023
1086
  export async function setDeckNarrator(opts, slug, ref) {
1024
1087
  if (!slug || !ref) throw new Error("usage: deck narrator <slug> <narrator|none|default>");
@@ -1026,6 +1089,58 @@ export async function setDeckNarrator(opts, slug, ref) {
1026
1089
  return (await client(opts)).mutation(api.narrators.setDeckNarrator, { slug, narrator: value });
1027
1090
  }
1028
1091
 
1092
+ // The account's brand (convex/brand.ts): what new_deck / deck new start from.
1093
+ export async function getBrand(opts = {}) {
1094
+ return (await client(opts)).query(api.brand.get, {});
1095
+ }
1096
+
1097
+ // Merge into the saved brand: a field left out keeps its value, "" clears it.
1098
+ // fontPairing names one of FONT_PAIRINGS and fills the three fonts (an explicit
1099
+ // font still wins). logoUrl is fetched into our storage; logoBytes (with
1100
+ // logoType) is a file the CLI read. clearLogo removes the logo.
1101
+ export async function setBrand(opts, { name, designMd, colors, fonts, fontPairing, presenterStyle, logoUrl, logoBytes, logoType, clearLogo } = {}) {
1102
+ const c = await client(opts);
1103
+ let fontSet = fonts;
1104
+ if (fontPairing) {
1105
+ const p = findPairing(fontPairing);
1106
+ if (!p) throw new Error(`no font pairing "${fontPairing}": pick one of ${FONT_PAIRINGS.map((x) => x.id).join(", ")}`);
1107
+ fontSet = { display: p.display, body: p.body, mono: p.mono, ...(fonts ?? {}) };
1108
+ }
1109
+ if (logoUrl && logoBytes) throw new Error("pass logoUrl or a logo file, not both");
1110
+ if (clearLogo && (logoUrl || logoBytes)) throw new Error("clearLogo removes the logo; do not also pass one");
1111
+ const known = (map, keys, what) => {
1112
+ const extra = Object.keys(map ?? {}).filter((k) => !keys.includes(k));
1113
+ if (extra.length) throw new Error(`unknown ${what} ${extra.join(", ")}: use ${keys.join(", ")}`);
1114
+ return map;
1115
+ };
1116
+ known(colors, COLOR_KEYS, "colour");
1117
+ known(fontSet, FONT_ROLES, "font role");
1118
+ const fields = { name, designMd, colors, fonts: fontSet, presenterStyle };
1119
+ const defined = Object.fromEntries(Object.entries(fields).filter(([, v]) => v !== undefined && v !== null));
1120
+ if (!Object.keys(defined).length && !logoUrl && !logoBytes && !clearLogo) throw new Error("nothing to set: pass colors, fonts, fontPairing, logoUrl, designMd, name or presenterStyle");
1121
+ let out = Object.keys(defined).length ? await c.mutation(api.brand.set, defined) : null;
1122
+ try {
1123
+ if (clearLogo) out = await c.mutation(api.brand.clear, { logoOnly: true });
1124
+ if (logoUrl) out = await c.action(api.brandNode.importLogo, { url: String(logoUrl) });
1125
+ if (logoBytes) {
1126
+ const bytes = logoBytes instanceof ArrayBuffer ? logoBytes : new Uint8Array(logoBytes).slice().buffer;
1127
+ out = await c.action(api.brandNode.uploadLogo, { bytes, contentType: String(logoType ?? "") });
1128
+ }
1129
+ } catch (e) {
1130
+ // The fields above are already saved: say so, so nobody redoes or reports them as lost.
1131
+ const kept = Object.keys(defined);
1132
+ throw new Error(`${kept.length ? `brand saved (${kept.join(", ")}) but the logo was not` : "the logo was not saved"}: ${errorText(e)}`);
1133
+ }
1134
+ return out ?? getBrand(opts);
1135
+ }
1136
+
1137
+ export async function clearBrand(opts = {}) {
1138
+ await (await client(opts)).mutation(api.brand.clear, {});
1139
+ return { cleared: true };
1140
+ }
1141
+
1142
+ export const listFontPairings = () => ({ pairings: FONT_PAIRINGS.map((p) => ({ ...p, urls: [googleFontsUrl(p.display, "display"), googleFontsUrl(p.body, "body"), googleFontsUrl(p.mono, "mono")] })) });
1143
+
1029
1144
  // Polls `read` until `done`; a few failed reads in a row (a network blip) are
1030
1145
  // retried, since the person may still be finishing in the browser.
1031
1146
  async function pollUntil(read, done, { intervalMs = 2000, timeoutMs }) {
package/src/presenter.mjs CHANGED
@@ -26,3 +26,12 @@ export function withAvatar(html, { avatarUrl, imageUrl }) {
26
26
  const next = none ? tag.replace(/\sdata-presenter="none"/, face) : tag.replace(/>$/, `${face}>`);
27
27
  return html.replace(tag, () => next);
28
28
  }
29
+
30
+ // One line for who presents a deck, from narrate's or release's `presenter`
31
+ // ({ narrator, voice, face, reason }); a warning when it plays captions only.
32
+ // Empty for an older backend that sends none.
33
+ export function presenterLine(p) {
34
+ if (!p) return "";
35
+ if (!p.face) return `⚠ captions only: ${p.reason ?? `no face for voice "${p.voice}"`}`;
36
+ return `presented by ${p.face}${p.narrator && p.narrator !== p.face ? ` (narrator ${p.narrator})` : ""}, voice "${p.voice}"`;
37
+ }
package/src/release.mjs CHANGED
@@ -108,6 +108,8 @@ export async function release(pos, opts = {}, io = {}) {
108
108
  }
109
109
  const released = presenter ? releaseBundle(deckDir, presenter) : bundle;
110
110
  if (presenter) log("✓ presented by your avatar");
111
+ // A terminal user sees this before it ships, so the CLI warns rather than refuses.
112
+ else if (job.presenter && !job.presenter.face) log(`⚠ releasing captions only: ${job.presenter.reason ?? "no face"}`);
111
113
  const imported = await ops.importDeckFromBytes(opts, {
112
114
  slug,
113
115
  title: opts.title,
@@ -142,5 +144,5 @@ export async function release(pos, opts = {}, io = {}) {
142
144
  log(`✓ share for "${r.recipient}"${share.qa ? " (QA, untracked)" : ""} → ${share.url}`);
143
145
  }
144
146
  if (!shares.length) log(` no --to given: \`hyperdecks share new ${imported.slug} "Me" --qa\` makes a link for your own viewing`);
145
- return { slug: imported.slug, deckDir, commit: sha, deckUrl: imported.deckUrl, totalDuration: checked.totalDuration, files: bundle.files, shares };
147
+ return { slug: imported.slug, deckDir, commit: sha, deckUrl: imported.deckUrl, totalDuration: checked.totalDuration, presenter: job.presenter ?? null, files: bundle.files, shares };
146
148
  }
package/src/runtime.mjs CHANGED
@@ -8,7 +8,7 @@ import { fileURLToPath } from "node:url";
8
8
  import { ConvexHttpClient } from "convex/browser";
9
9
  import { makeFunctionReference } from "convex/server";
10
10
 
11
- export const VERSION = "0.4.0";
11
+ export const VERSION = "0.6.0";
12
12
  const UPLOAD_TIMEOUT_MS = 125_000;
13
13
 
14
14
  export const PROD = {
@@ -40,6 +40,20 @@ export const api = {
40
40
  setVoice: makeFunctionReference("narrators:setVoice"),
41
41
  setDeckNarrator: makeFunctionReference("narrators:setDeckNarrator"),
42
42
  newLink: makeFunctionReference("narrators:newLink"),
43
+ rename: makeFunctionReference("narrators:rename"),
44
+ setFace: makeFunctionReference("narrators:setFace"),
45
+ },
46
+ brand: {
47
+ get: makeFunctionReference("brand:get"),
48
+ set: makeFunctionReference("brand:set"),
49
+ clear: makeFunctionReference("brand:clear"),
50
+ },
51
+ brandNode: {
52
+ importLogo: makeFunctionReference("brandNode:importLogo"),
53
+ uploadLogo: makeFunctionReference("brandNode:uploadLogo"),
54
+ },
55
+ narratorsNode: {
56
+ hear: makeFunctionReference("narratorsNode:hear"),
43
57
  },
44
58
  avatarsNode: {
45
59
  options: makeFunctionReference("avatarsNode:options"),
@@ -49,6 +63,7 @@ export const api = {
49
63
  assets: {
50
64
  generateUploadUrl: makeFunctionReference("assets:generateUploadUrl"),
51
65
  saveAsset: makeFunctionReference("assets:saveAsset"),
66
+ list: makeFunctionReference("assets:list"),
52
67
  },
53
68
  assetsNode: {
54
69
  importAssetFromUrl: makeFunctionReference("assetsNode:importAssetFromUrl"),
@@ -130,7 +145,7 @@ export const api = {
130
145
  },
131
146
  };
132
147
 
133
- const BOOL = new Set(["prod", "dev", "admin", "json", "require-email", "qa", "no-notify", "allow-forward", "no-forward", "help", "version", "all-agents", "global", "project", "transparent", "upload", "dry-run", "narrated", "layout", "full-page", "force", "hosted", "yes", "no-voice", "no-skill", "no-release", "no-open", "save-to-minimoji"]);
148
+ const BOOL = new Set(["prod", "dev", "admin", "json", "require-email", "qa", "no-notify", "allow-forward", "no-forward", "help", "version", "all-agents", "global", "project", "transparent", "upload", "dry-run", "narrated", "layout", "full-page", "force", "hosted", "yes", "no-voice", "no-skill", "no-release", "no-open", "save-to-minimoji", "captions-only", "no-brand", "no-logo"]);
134
149
  // release's recipients, in order: each --to starts one, and an --email right
135
150
  // after it belongs to it (`--to A --email a --to B`). Collected as opts.recipients;
136
151
  // opts.email stays the last --email for the other commands (share new).
package/src/scaffold.mjs CHANGED
@@ -9,12 +9,13 @@ import { existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
9
9
  import { join, resolve } from "node:path";
10
10
  import * as ops from "./ops.mjs";
11
11
  import { PRESENTER_STYLES } from "./checkRules.mjs";
12
- import { LAYOUTS, NARRATED_FILES, assembleLayoutDeck, fillTemplate } from "./layouts.mjs";
12
+ import { LAYOUTS, NARRATED_FILES, assembleLayoutDeck, fillTemplate, parseLayouts } from "./layouts.mjs";
13
+ import { applyBrand, brandForNewDeck, brandSummary } from "./brand.mjs";
13
14
 
14
15
  export { LAYOUTS, NARRATED_FILES, assembleLayoutDeck, fillTemplate, parseLayouts, readLayout } from "./layouts.mjs";
15
16
 
16
17
  const SLUG = /^[a-z0-9][a-z0-9-]{0,63}$/;
17
- const USAGE = 'usage: deck new <slug> "<title>" --narrated [--layouts hero,product,number,closer] [--presenter-style <stage|bubble|glass|corner>] [--dir <path>]';
18
+ const USAGE = 'usage: deck new <slug> "<title>" --narrated [--layouts hero,product,number,closer] [--presenter-style <stage|bubble|glass|corner>] [--no-brand] [--dir <path>]';
18
19
 
19
20
  export async function deckNew(pos, opts = {}, { log = (line) => console.log(line), cwd = process.cwd() } = {}) {
20
21
  const [slug, title] = pos;
@@ -28,9 +29,15 @@ export async function deckNew(pos, opts = {}, { log = (line) => console.log(line
28
29
  const dir = resolve(/*turbopackIgnore: true*/ cwd, typeof opts.dir === "string" ? opts.dir : join("decks", slug));
29
30
  if (existsSync(dir)) throw new Error(`${dir} already exists; pick another slug or --dir`);
30
31
  if (opts.layouts === true) throw new Error(`--layouts needs a list, e.g. --layouts ${LAYOUTS.slice(0, 3).join(",")},closer`);
31
- const files = opts.layouts !== undefined
32
- ? Object.entries(assembleLayoutDeck({ slug, title, presenterStyle, layouts: opts.layouts }))
33
- : Object.entries(NARRATED_FILES).map(([out, file]) => [out, fillTemplate(file, { slug, title, presenterStyle })]);
32
+ if (opts.layouts !== undefined) parseLayouts(opts.layouts);
33
+ // The account's brand goes on the template (--no-brand: the template's look);
34
+ // an explicit --presenter-style wins over the brand's.
35
+ const { brand, readError } = await brandForNewDeck(() => ops.getBrand(opts), !(opts["no-brand"] || opts.brand === false));
36
+ const style = presenterStyle ?? (PRESENTER_STYLES.includes(brand?.presenterStyle) ? brand.presenterStyle : undefined);
37
+ const files = (opts.layouts !== undefined
38
+ ? Object.entries(assembleLayoutDeck({ slug, title, presenterStyle: style, layouts: opts.layouts }))
39
+ : Object.entries(NARRATED_FILES).map(([out, file]) => [out, fillTemplate(file, { slug, title, presenterStyle: style })]))
40
+ .map(([out, text]) => [out, out === "index.html" ? applyBrand(text, brand) : text]);
34
41
  await ops.createDeck(opts, { slug, title });
35
42
  try {
36
43
  mkdirSync(dir, { recursive: true });
@@ -39,6 +46,7 @@ export async function deckNew(pos, opts = {}, { log = (line) => console.log(line
39
46
  rmSync(dir, { recursive: true, force: true });
40
47
  throw new Error(`deck ${slug} is registered but its files could not be written (${e.message}); remove the draft with \`hyperdecks deck rm ${slug}\` and run deck new again`);
41
48
  }
42
- log(`✓ created deck "${slug}" → ${dir}\n files: ${Object.keys(NARRATED_FILES).join(", ")}\n next: hyperdecks narrate ${dir} --dry-run`);
43
- return { slug, title, dir, files: Object.keys(NARRATED_FILES) };
49
+ const summary = brandSummary(brand, readError);
50
+ log(`✓ created deck "${slug}" → ${dir}\n files: ${Object.keys(NARRATED_FILES).join(", ")}\n brand: ${summary.error ? `could not read it (${summary.error}); template look` : summary.applied.length ? summary.applied.join(", ") : "none applied (hyperdecks brand set)"}\n next: hyperdecks narrate ${dir} --dry-run`);
51
+ return { slug, title, dir, files: Object.keys(NARRATED_FILES), brand: summary };
44
52
  }
@@ -0,0 +1,43 @@
1
+ ISC License
2
+
3
+ Copyright (c) 2026 Lucide Icons and Contributors
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
+
17
+ ---
18
+
19
+ The following Lucide icons are derived from the Feather project:
20
+
21
+ airplay, alert-circle, alert-octagon, alert-triangle, aperture, arrow-down-circle, arrow-down-left, arrow-down-right, arrow-down, arrow-left-circle, arrow-left, arrow-right-circle, arrow-right, arrow-up-circle, arrow-up-left, arrow-up-right, arrow-up, at-sign, calendar, cast, check, chevron-down, chevron-left, chevron-right, chevron-up, chevrons-down, chevrons-left, chevrons-right, chevrons-up, circle, clipboard, clock, code, columns, command, compass, corner-down-left, corner-down-right, corner-left-down, corner-left-up, corner-right-down, corner-right-up, corner-up-left, corner-up-right, crosshair, database, divide-circle, divide-square, dollar-sign, download, external-link, feather, frown, hash, headphones, help-circle, info, italic, key, layout, life-buoy, link-2, link, loader, lock, log-in, log-out, maximize, meh, minimize, minimize-2, minus-circle, minus-square, minus, monitor, moon, more-horizontal, more-vertical, move, music, navigation-2, navigation, octagon, pause-circle, percent, plus-circle, plus-square, plus, power, radio, rss, search, server, share, shopping-bag, sidebar, smartphone, smile, square, table-2, tablet, target, terminal, trash-2, trash, triangle, tv, type, upload, x-circle, x-octagon, x-square, x, zoom-in, zoom-out
22
+
23
+ The MIT License (MIT) (for the icons listed above)
24
+
25
+ Copyright (c) 2013-present Cole Bemis
26
+
27
+ Permission is hereby granted, free of charge, to any person obtaining a copy
28
+ of this software and associated documentation files (the "Software"), to deal
29
+ in the Software without restriction, including without limitation the rights
30
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
31
+ copies of the Software, and to permit persons to whom the Software is
32
+ furnished to do so, subject to the following conditions:
33
+
34
+ The above copyright notice and this permission notice shall be included in all
35
+ copies or substantial portions of the Software.
36
+
37
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
38
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
39
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
40
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
41
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
42
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
43
+ SOFTWARE.