@hypersocial/decks-cli 0.5.0 → 0.7.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,6 @@
1
1
  import { zipSync } from "fflate";
2
+ import { COLOR_KEYS, FONT_PAIRINGS, FONT_ROLES, findPairing, googleFontsUrl } from "./brand.mjs";
3
+ import { MAX_IMPORT_FILE_BYTES, draftArgs, extractFile } from "./brandImport.mjs";
2
4
  import { api, client, target, uploadBytes as runtimeUploadBytes } from "./runtime.mjs";
3
5
  import {
4
6
  bytesFromText,
@@ -119,8 +121,9 @@ export async function pollImageJob(opts, jobId, { intervalMs = 3000, timeoutMs =
119
121
 
120
122
  // Generate a short clip via fal (MiniMax H3 Max by default, Kling v3 with
121
123
  // model "kling-v3": text→video, or image→video when an image URL is given as the
122
- // first frame). Always a background job: returns
123
- // { jobId, status, seconds, aspect?, creditsRemaining? } without waiting, so the MCP
124
+ // first frame; loop starts and ends on one frame, transparent mattes the background
125
+ // out). Always a background job: returns
126
+ // { jobId, status, seconds, aspect?, loop, transparent, creditsRemaining? } without waiting, so the MCP
124
127
  // tool never blocks; the CLI polls with pollVideoJob.
125
128
  export async function generateVideo(opts, fields = {}) {
126
129
  if (!fields.prompt) throw new Error("prompt is required");
@@ -130,6 +133,8 @@ export async function generateVideo(opts, fields = {}) {
130
133
  if (fields.seconds != null && fields.seconds !== "") args.seconds = Number(fields.seconds);
131
134
  if (fields.aspect) args.aspect = String(fields.aspect);
132
135
  if (fields.model) args.model = String(fields.model);
136
+ if (fields.loop === true || fields.loop === "true") args.loop = true;
137
+ if (fields.transparent === true || fields.transparent === "true") args.transparent = true;
133
138
  if (fields.slug) args.slug = String(fields.slug);
134
139
  if (fields.name) args.name = String(fields.name);
135
140
  return (await client(opts)).action(api.videogen.generateVideo, args);
@@ -231,11 +236,11 @@ export async function checkVideoJob(opts, jobId) {
231
236
  }
232
237
 
233
238
  // Poll a video job until it finishes. Returns the job (its `video` holds the hosted
234
- // URL); throws on job error or timeout. The server settles every job within 15
235
- // minutes, so the 16-minute default only trips if the job row itself stalls. A few
236
- // failed checks in a row (network, Convex hiccup) are tolerated: the job keeps
239
+ // URL); throws on job error or timeout. A few failed checks in a row (network, Convex hiccup) are tolerated: the job keeps
237
240
  // running server-side either way, so giving up early would only lose the result.
238
- export async function pollVideoJob(opts, jobId, { intervalMs = 5000, timeoutMs = 960_000, maxErrors = 5, onProgress } = {}) {
241
+ // 30 minutes: a transparent clip can take the render's 12 minutes, then up to 14
242
+ // more to matte and store it (convex/videogen.ts gives the matte its own clock).
243
+ export async function pollVideoJob(opts, jobId, { intervalMs = 5000, timeoutMs = 1_800_000, maxErrors = 5, onProgress } = {}) {
239
244
  const c = await client(opts);
240
245
  const start = Date.now();
241
246
  const resume = `check it later with: video-job ${jobId}`;
@@ -746,7 +751,7 @@ function designServeUrl(projectId, token, path) {
746
751
  }
747
752
 
748
753
  // Pull every local asset path a deck file references (HTML or CSS): the
749
- // ext-resource-dependency manifest, src/href/poster/data-presenter-image, srcset, <script>/<link>,
754
+ // ext-resource-dependency manifest, src/href/poster/data-presenter-image/data-alpha-stacked, srcset, <script>/<link>,
750
755
  // and CSS url(). Mirrors the importer's rewrite surface so we fetch the same set
751
756
  // it will later rewrite. External/data/blob refs are skipped.
752
757
  function extractDesignRefs(text) {
@@ -758,7 +763,7 @@ function extractDesignRefs(text) {
758
763
  if (clean) out.add(clean);
759
764
  };
760
765
  for (const m of text.matchAll(/ext-resource-dependency"\s+content="([^"]+)"/gi)) add(m[1]);
761
- for (const m of text.matchAll(/\b(?:src|href|poster|data-presenter-image)\s*=\s*["']([^"']+)["']/gi)) add(m[1]);
766
+ for (const m of text.matchAll(/\b(?:src|href|poster|data-presenter-image|data-alpha-stacked)\s*=\s*["']([^"']+)["']/gi)) add(m[1]);
762
767
  for (const m of text.matchAll(/\bsrcset\s*=\s*["']([^"']+)["']/gi)) {
763
768
  for (const part of m[1].split(",")) add(part.trim().split(/\s+/)[0]);
764
769
  }
@@ -1088,6 +1093,75 @@ export async function setDeckNarrator(opts, slug, ref) {
1088
1093
  return (await client(opts)).mutation(api.narrators.setDeckNarrator, { slug, narrator: value });
1089
1094
  }
1090
1095
 
1096
+ // The account's brand (convex/brand.ts): what new_deck / deck new start from.
1097
+ export async function getBrand(opts = {}) {
1098
+ return (await client(opts)).query(api.brand.get, {});
1099
+ }
1100
+
1101
+ // Merge into the saved brand: a field left out keeps its value, "" clears it.
1102
+ // fontPairing names one of FONT_PAIRINGS and fills the three fonts (an explicit
1103
+ // font still wins). logoUrl is fetched into our storage; logoBytes (with
1104
+ // logoType) is a file the CLI read. clearLogo removes the logo. draft is a
1105
+ // brand import's token (importBrand): its colours, fonts, name and logo,
1106
+ // saved after the person has seen the preview; other fields still win.
1107
+ export async function setBrand(opts, { name, designMd, colors, fonts, fontPairing, presenterStyle, logoUrl, logoBytes, logoType, clearLogo, draft } = {}) {
1108
+ const c = await client(opts);
1109
+ let fontSet = fonts;
1110
+ if (fontPairing) {
1111
+ const p = findPairing(fontPairing);
1112
+ if (!p) throw new Error(`no font pairing "${fontPairing}": pick one of ${FONT_PAIRINGS.map((x) => x.id).join(", ")}`);
1113
+ fontSet = { display: p.display, body: p.body, mono: p.mono, ...(fonts ?? {}) };
1114
+ }
1115
+ if (logoUrl && logoBytes) throw new Error("pass logoUrl or a logo file, not both");
1116
+ if (clearLogo && (logoUrl || logoBytes)) throw new Error("clearLogo removes the logo; do not also pass one");
1117
+ const known = (map, keys, what) => {
1118
+ const extra = Object.keys(map ?? {}).filter((k) => !keys.includes(k));
1119
+ if (extra.length) throw new Error(`unknown ${what} ${extra.join(", ")}: use ${keys.join(", ")}`);
1120
+ return map;
1121
+ };
1122
+ known(colors, COLOR_KEYS, "colour");
1123
+ known(fontSet, FONT_ROLES, "font role");
1124
+ const fields = { name, designMd, colors, fonts: fontSet, presenterStyle, draft: draft ? String(draft).trim() : undefined };
1125
+ const defined = Object.fromEntries(Object.entries(fields).filter(([, v]) => v !== undefined && v !== null));
1126
+ if (!Object.keys(defined).length && !logoUrl && !logoBytes && !clearLogo) throw new Error("nothing to set: pass draft, colors, fonts, fontPairing, logoUrl, designMd, name or presenterStyle");
1127
+ let out = Object.keys(defined).length ? await c.mutation(api.brand.set, defined) : null;
1128
+ try {
1129
+ if (clearLogo) out = await c.mutation(api.brand.clear, { logoOnly: true });
1130
+ if (logoUrl) out = await c.action(api.brandNode.importLogo, { url: String(logoUrl) });
1131
+ if (logoBytes) {
1132
+ const bytes = logoBytes instanceof ArrayBuffer ? logoBytes : new Uint8Array(logoBytes).slice().buffer;
1133
+ out = await c.action(api.brandNode.uploadLogo, { bytes, contentType: String(logoType ?? "") });
1134
+ }
1135
+ } catch (e) {
1136
+ // The fields above are already saved: say so, so nobody redoes or reports them as lost.
1137
+ const kept = Object.keys(defined);
1138
+ throw new Error(`${kept.length ? `brand saved (${kept.join(", ")}) but the logo was not` : "the logo was not saved"}: ${errorText(e)}`);
1139
+ }
1140
+ return out ?? getBrand(opts);
1141
+ }
1142
+
1143
+ // Read a brand from a website (url), one of your decks (slug) or a .pptx /
1144
+ // .potx / .pdf (bytes + fileName, read here with brandImport.mjs) into a
1145
+ // draft. Returns { token, colors, fonts, logoUrl, notes, previewUrl, … };
1146
+ // nothing is saved until setBrand({ draft: token }).
1147
+ export async function importBrand(opts, { url, slug, bytes, fileName } = {}) {
1148
+ const given = [url, slug, bytes].filter((x) => x !== undefined && x !== null && x !== "");
1149
+ if (given.length !== 1) throw new Error("import a brand from one of: a website url, a deck slug or a .pptx / .potx / .pdf file");
1150
+ const c = await client(opts);
1151
+ if (url) return c.action(api.brandNode.importFromUrl, { url: String(url) });
1152
+ if (slug) return c.action(api.brandNode.importFromDeck, { slug: String(slug) });
1153
+ const data = bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes);
1154
+ if (data.byteLength > MAX_IMPORT_FILE_BYTES) throw new Error(`${fileName ?? "the file"} is over ${MAX_IMPORT_FILE_BYTES / 1024 / 1024} MB`);
1155
+ return c.action(api.brandNode.createDraft, draftArgs(extractFile(data, fileName)));
1156
+ }
1157
+
1158
+ export async function clearBrand(opts = {}) {
1159
+ await (await client(opts)).mutation(api.brand.clear, {});
1160
+ return { cleared: true };
1161
+ }
1162
+
1163
+ export const listFontPairings = () => ({ pairings: FONT_PAIRINGS.map((p) => ({ ...p, urls: [googleFontsUrl(p.display, "display"), googleFontsUrl(p.body, "body"), googleFontsUrl(p.mono, "mono")] })) });
1164
+
1091
1165
  // Polls `read` until `done`; a few failed reads in a row (a network blip) are
1092
1166
  // retried, since the person may still be finishing in the browser.
1093
1167
  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.5.0";
11
+ export const VERSION = "0.7.0";
12
12
  const UPLOAD_TIMEOUT_MS = 125_000;
13
13
 
14
14
  export const PROD = {
@@ -43,6 +43,18 @@ export const api = {
43
43
  rename: makeFunctionReference("narrators:rename"),
44
44
  setFace: makeFunctionReference("narrators:setFace"),
45
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
+ importFromUrl: makeFunctionReference("brandNode:importFromUrl"),
55
+ importFromDeck: makeFunctionReference("brandNode:importFromDeck"),
56
+ createDraft: makeFunctionReference("brandNode:createDraft"),
57
+ },
46
58
  narratorsNode: {
47
59
  hear: makeFunctionReference("narratorsNode:hear"),
48
60
  },
@@ -136,7 +148,7 @@ export const api = {
136
148
  },
137
149
  };
138
150
 
139
- 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"]);
151
+ const BOOL = new Set(["prod", "dev", "admin", "json", "require-email", "qa", "no-notify", "allow-forward", "no-forward", "help", "version", "all-agents", "global", "project", "transparent", "loop", "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"]);
140
152
  // release's recipients, in order: each --to starts one, and an --email right
141
153
  // after it belongs to it (`--to A --email a --to B`). Collected as opts.recipients;
142
154
  // 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.