@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.
- package/package.json +1 -1
- package/skills/hyperdecks/SKILL.md +113 -67
- package/skills/hyperdecks/chat.md +11 -8
- package/skills/hyperdecks/terminal.md +82 -0
- package/src/bars.mjs +268 -0
- package/src/brand.mjs +51 -8
- package/src/check.mjs +311 -15
- package/src/checkRules.mjs +616 -27
- package/src/commands.mjs +157 -28
- package/src/deckSlug.mjs +41 -0
- package/src/export-video.mjs +75 -5
- package/src/files.mjs +35 -0
- package/src/frame-clock.mjs +6 -2
- package/src/guide.mjs +91 -13
- package/src/hosted.mjs +18 -8
- package/src/iconAliasNames.mjs +70 -0
- package/src/iconChoice.mjs +97 -0
- package/src/iconSets.mjs +89 -0
- package/src/iconSlots.mjs +48 -0
- package/src/icons.mjs +285 -45
- package/src/iconsCli.mjs +76 -0
- package/src/layoutRoutes.mjs +92 -0
- package/src/layouts.mjs +4 -4
- package/src/mediaPreviews.mjs +3 -1
- package/src/narrate.mjs +31 -4
- package/src/opening.mjs +9 -3
- package/src/ops.mjs +49 -0
- package/src/photosGuide.mjs +47 -0
- package/src/picturesGuide.mjs +53 -0
- package/src/play.mjs +3 -2
- package/src/presenter.mjs +3 -1
- package/src/preview-moment.mjs +10 -2
- package/src/release.mjs +13 -5
- package/src/runtime.mjs +9 -2
- package/src/scaffold.mjs +73 -13
- package/src/source.mjs +86 -14
- package/src/stockMedia.mjs +299 -0
- package/src/themeCli.mjs +41 -0
- package/src/themes.mjs +345 -0
- package/templates/icons/material.LICENSE +202 -0
- package/templates/icons/material.json.gz +0 -0
- package/templates/icons/phosphor.LICENSE +21 -0
- package/templates/icons/phosphor.json.gz +0 -0
- package/templates/icons/tabler.LICENSE +21 -0
- package/templates/icons/tabler.json.gz +0 -0
- package/templates/layouts/_deck.html +177 -36
- package/templates/layouts/bento.html +75 -0
- package/templates/layouts/chart.html +6 -4
- package/templates/layouts/closer.html +10 -3
- package/templates/layouts/compare.html +13 -4
- package/templates/layouts/cover-band.html +10 -8
- package/templates/layouts/cover-frame.html +9 -7
- package/templates/layouts/cover-poster.html +8 -5
- package/templates/layouts/cover-split.html +7 -6
- package/templates/layouts/cover-type.html +1 -0
- package/templates/layouts/features.html +9 -7
- package/templates/layouts/funnel.html +60 -0
- package/templates/layouts/hero.html +40 -22
- package/templates/layouts/lanes.html +63 -0
- package/templates/layouts/loop.html +81 -0
- package/templates/layouts/number.html +2 -1
- package/templates/layouts/phone-stage.html +68 -0
- package/templates/layouts/phones.html +1 -0
- package/templates/layouts/picture-full.html +48 -0
- package/templates/layouts/portrait.html +45 -0
- package/templates/layouts/product.html +7 -6
- package/templates/layouts/quote.html +2 -1
- package/templates/layouts/rail.html +71 -0
- package/templates/layouts/scorecard.html +70 -0
- package/templates/layouts/screens.html +85 -0
- package/templates/layouts/sentence.html +39 -0
- package/templates/layouts/split.html +22 -7
- package/templates/layouts/spotlight.html +77 -0
- package/templates/layouts/stack.html +83 -0
- package/templates/layouts/staircase.html +76 -0
- package/templates/layouts/strike.html +46 -0
- package/templates/layouts/tap-through.html +73 -0
- package/templates/layouts/team.html +3 -2
- package/templates/layouts/timeline.html +16 -6
- package/templates/layouts/two-bars.html +53 -0
- package/templates/layouts/two-by-two.html +71 -0
- package/templates/layouts/video-beats.html +66 -0
- package/templates/layouts/video-full.html +62 -0
- package/templates/layouts/wall.html +81 -0
- package/templates/layouts/zoom.html +144 -0
- package/templates/narrated-deck.html +12 -7
- package/templates/script.md +2 -2
- /package/templates/icons/{LICENSE → lucide.LICENSE} +0 -0
package/src/commands.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
-
import {
|
|
2
|
+
import { join, resolve } from "node:path";
|
|
3
|
+
import { deckSlug } from "./deckSlug.mjs";
|
|
3
4
|
import {
|
|
4
5
|
agentTable,
|
|
5
6
|
backupLinkUrl,
|
|
@@ -17,10 +18,12 @@ import {
|
|
|
17
18
|
import { fetchVersionInfo, updatePreflight } from "./update.mjs";
|
|
18
19
|
import { refreshSkillCopies } from "./skillFreshness.mjs";
|
|
19
20
|
import * as ops from "./ops.mjs";
|
|
21
|
+
import { FOR_HINT } from "./stockMedia.mjs";
|
|
20
22
|
import { MAX_TAGS, normalizeTags } from "./tags.mjs";
|
|
21
23
|
import { sentToLabel, sentToMatch } from "./deckSearch.mjs";
|
|
22
24
|
import { exportVideo } from "./export-video.mjs";
|
|
23
25
|
import { presenterLine } from "./presenter.mjs";
|
|
26
|
+
import { LAYOUTS } from "./layouts.mjs";
|
|
24
27
|
|
|
25
28
|
export const playbackLabel = (p) => p.narrationFinished ? "narration finished"
|
|
26
29
|
: p.narrationStarted ? "narration started"
|
|
@@ -228,7 +231,7 @@ async function deckArchive(pos, opts, archived) {
|
|
|
228
231
|
|
|
229
232
|
async function shareNew(pos, opts) {
|
|
230
233
|
const [slug, recipient] = pos;
|
|
231
|
-
const usage = "usage: share new <slug> <recipient> [--email e] [--note n] [--require-email] [--expires iso] [--limit n] [--qa] [--no-notify] [--allow-forward|--no-forward] [--pace auto|slide|step]";
|
|
234
|
+
const usage = "usage: share new <slug> <recipient> [--email e] [--note n] [--require-email] [--expires iso] [--limit n] [--qa] [--no-notify] [--allow-forward|--no-forward] [--pace auto|slide|step] [--count-on-play]";
|
|
232
235
|
if (!slug || !recipient) throw new Error(usage);
|
|
233
236
|
if (opts["allow-forward"] && opts["no-forward"]) throw new Error("pick one of --allow-forward and --no-forward");
|
|
234
237
|
// The link's own pace; without it the link follows the deck's.
|
|
@@ -243,6 +246,7 @@ async function shareNew(pos, opts) {
|
|
|
243
246
|
notify: opts["no-notify"] ? false : undefined,
|
|
244
247
|
allowForward: opts["allow-forward"] ? true : opts["no-forward"] ? false : undefined,
|
|
245
248
|
pace: opts.pace,
|
|
249
|
+
countOnPlay: opts["count-on-play"] || undefined,
|
|
246
250
|
expires: opts.expires,
|
|
247
251
|
limit: opts.limit,
|
|
248
252
|
});
|
|
@@ -266,7 +270,7 @@ async function shareList(pos, opts) {
|
|
|
266
270
|
// Rows arrive with each link's forwards right after it; indent those.
|
|
267
271
|
for (const r of rows) {
|
|
268
272
|
const who = r.parentToken ? ` ↳ ${r.recipient} via ${r.forwardedBy ?? "?"}` : r.recipient;
|
|
269
|
-
console.log(`${r.enabled ? "on " : "off"}\t${r.token}\t${who}\topens:${r.opens}\tfwd:${r.allowForward ? "on" : "off"}${r.pace ? `\tpace:${r.pace}` : ""}${r.qa ? "\tQA (untracked)" : ""}${r.notify === false ? "\tmuted" : ""}${r.probablyForwarded ? "\tprobably forwarded" : ""}${r.archived ? "\t(archived)" : ""}`);
|
|
273
|
+
console.log(`${r.enabled ? "on " : "off"}\t${r.token}\t${who}\topens:${r.opens}\tfwd:${r.allowForward ? "on" : "off"}${r.pace ? `\tpace:${r.pace}` : ""}${r.countOn === "play" ? "\tcounts on play" : ""}${r.qa ? "\tQA (untracked)" : ""}${r.notify === false ? "\tmuted" : ""}${r.probablyForwarded ? "\tprobably forwarded" : ""}${r.archived ? "\t(archived)" : ""}`);
|
|
270
274
|
}
|
|
271
275
|
if (!rows.length) console.log("(no shares)");
|
|
272
276
|
}
|
|
@@ -294,6 +298,13 @@ async function shareForward(pos, opts) {
|
|
|
294
298
|
console.log(`OK forwarding ${mode === "default" ? "follows the deck default" : mode} for ${token}`);
|
|
295
299
|
}
|
|
296
300
|
|
|
301
|
+
async function shareCount(pos, opts) {
|
|
302
|
+
const [mode, token] = pos;
|
|
303
|
+
if ((mode !== "play" && mode !== "open") || !token) throw new Error("usage: share count play|open <token>");
|
|
304
|
+
await ops.setShareCountOn(opts, token, mode === "play");
|
|
305
|
+
console.log(mode === "play" ? `OK ${token} counts an open (and alerts you) only when the viewer presses play` : `OK ${token} counts an open when the link is opened`);
|
|
306
|
+
}
|
|
307
|
+
|
|
297
308
|
async function deckForward(pos, opts) {
|
|
298
309
|
const [mode, slug] = pos;
|
|
299
310
|
if ((mode !== "on" && mode !== "off") || !slug) throw new Error("usage: deck forward on|off <slug>");
|
|
@@ -540,6 +551,18 @@ async function importDesignDeck(pos, opts) {
|
|
|
540
551
|
}
|
|
541
552
|
}
|
|
542
553
|
|
|
554
|
+
// Every layout deck new --layouts takes, from the library itself, wrapped under the help's indent.
|
|
555
|
+
export function layoutList(indent = " ".repeat(19), width = 118) {
|
|
556
|
+
const lines = [];
|
|
557
|
+
let line = `${indent}layouts:`;
|
|
558
|
+
for (const [i, name] of LAYOUTS.entries()) {
|
|
559
|
+
const word = ` ${name}${i < LAYOUTS.length - 1 ? "," : ""}`;
|
|
560
|
+
if (line.length + word.length > width) { lines.push(line); line = indent + word.slice(1); }
|
|
561
|
+
else line += word;
|
|
562
|
+
}
|
|
563
|
+
return [...lines, line].join("\n");
|
|
564
|
+
}
|
|
565
|
+
|
|
543
566
|
export function help() {
|
|
544
567
|
console.log(`decks ${VERSION}
|
|
545
568
|
|
|
@@ -585,12 +608,15 @@ commands:
|
|
|
585
608
|
how the deck opens in the player (default: as its HTML says, data-view or slides) and
|
|
586
609
|
whether viewers get the slides/scroll toggle (on by default). Every link, next load; no re-release.
|
|
587
610
|
--ai-readable: whether each link + /md serves the deck as markdown for AI assistants (on by default).
|
|
588
|
-
deck new <slug> "<title>" --narrated [--layouts hero,product,number,closer] [--presenter-style stage|bubble|glass|corner] [--no-brand] [--dir <path>] [--tag <tag,...>]
|
|
611
|
+
deck new <slug> "<title>" --narrated [--layouts hero,product,number,closer] [--presenter-style stage|bubble|glass|corner] [--presenter <narrator>] [--theme <name>] [--icons "<set> [weight]"] [--brand|--no-brand] [--dir <path>] [--tag <tag,...>]
|
|
612
|
+
--theme: a built-in theme (hyperdecks theme list; default house). A named theme (house too) keeps
|
|
613
|
+
its own colours and fonts and gets no logo; --brand puts your saved brand on top of it
|
|
614
|
+
--dir: any folder (an empty one is fine); the slug is recorded there, so later commands need no --slug
|
|
615
|
+
--presenter dash: D.A.S.H. presents (default: the account's default narrator; the output says who)
|
|
589
616
|
scaffold decks/<slug>/: index.html (8 slides, or one per layout, player/v1), script.md, evidence.md,
|
|
590
|
-
in your saved brand's colours, fonts and logo (--no-brand: the template's look)
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
check <slug|deck-dir> [--forbid "<phrase>,<phrase>"] [--max-duration <s>] [--layout] [--strict] [--fix] [--json]
|
|
617
|
+
with no --theme, in your saved brand's colours, fonts and logo (--no-brand: the template's look)
|
|
618
|
+
${layoutList()}
|
|
619
|
+
check <slug|deck-dir> [--slug <slug>] [--forbid "<phrase>,<phrase>"] [--max-duration <s>] [--layout] [--strict] [--fix] [--json]
|
|
594
620
|
the narrated-deck gate: slides vs manifest, timing, captions, clip URLs,
|
|
595
621
|
local refs, pinned player, mobile titles. data-silent on the player script: no narration
|
|
596
622
|
(a warning). Missing data-notes warn, and fail on a data-kind="pitch" deck or with --strict.
|
|
@@ -599,17 +625,25 @@ commands:
|
|
|
599
625
|
the same on a hosted draft (no folder, no git: what chat agents use over the remote MCP)
|
|
600
626
|
source pull <slug> [dir] | source push <slug> [dir] [--base-rev N]
|
|
601
627
|
move a hosted draft (index.html, script.md, evidence.md) to a folder and back
|
|
602
|
-
asset add <slug> <file|url> [--name n]
|
|
603
|
-
file an image, video, audio (mp3, m4a), font or JSON under the deck; prints
|
|
604
|
-
|
|
605
|
-
|
|
628
|
+
asset add <slug> <file|url> [--name n] [--trim]
|
|
629
|
+
file an image, video, audio (mp3, m4a), font or JSON under the deck; prints "<file> → <url>" (--json: { url, file, bars, … });
|
|
630
|
+
a picture or clip with solid bars baked in prints "bars: …", and --trim uploads it cropped to its content
|
|
631
|
+
guide [workflow|format|script|scripts|design|look|themes|layouts|photos|pictures|presenter|transitions|check] [<layout> …]
|
|
632
|
+
the skill, one topic at a time; workflow is the terminal steps; layouts is an index,
|
|
633
|
+
guide layouts <name> … each named layout's detail
|
|
634
|
+
layouts suggest "<what the slide says>" [--json]
|
|
635
|
+
two or three layouts that fit what one slide says (the guide's routing table)
|
|
606
636
|
play <slug|deck-dir> [--voice <the voice it was narrated in>] [--slug <slug>] [--port <n>] [--no-open] [--json]
|
|
607
637
|
play the folder as it is, committed or not, with its real face and voice, on 127.0.0.1
|
|
608
638
|
until Ctrl-C; nothing is written, uploaded or shared, and changed lines need narrate first
|
|
609
|
-
release <slug|deck-dir> [--to "<name>" [--email <e>]]... [--qa] [--no-notify] [--title t] [--voice v] [--captions-only (--hosted)]
|
|
610
|
-
on a committed deck: check → narrate → import → share new per --to
|
|
611
|
-
|
|
612
|
-
|
|
639
|
+
release <slug|deck-dir> [--slug <slug>] [--to "<name>" [--email <e>]]... [--qa] [--no-notify] [--title t] [--voice v] [--captions-only (--hosted)]
|
|
640
|
+
on a committed deck in a git repository: check → narrate → import → share new per --to;
|
|
641
|
+
--qa with no --to prints one QA link for you (untracked, no email)
|
|
642
|
+
share new|list|on|off|forward|count|mute|unmute|rm|url
|
|
643
|
+
share new <slug> <recipient> [--qa] [--no-notify] [--allow-forward|--no-forward] [--pace auto|slide|step] [--count-on-play]
|
|
644
|
+
share count play|open <token>
|
|
645
|
+
play: count an open, and alert you, only when the viewer presses play, for a deck
|
|
646
|
+
embedded in a page (loading the page is not watching); open: on open, the default.
|
|
613
647
|
share forward on|off|default <token>
|
|
614
648
|
let this link's viewer forward it as their own tracked link ("Dana via Peter",
|
|
615
649
|
one hop); default follows the deck. share off on a link also turns off its forwards.
|
|
@@ -622,7 +656,7 @@ commands:
|
|
|
622
656
|
activity [--deck <slug>] [--limit <n>] [--json]
|
|
623
657
|
engagement <recipient|token> [--deck <slug>] [--json]
|
|
624
658
|
what one recipient watched per deck: narration heard, replays, drop-off, visits
|
|
625
|
-
gen-image "<prompt>" [--model gpt-image-2.5|nano-banana-2.1|gpt-image-2] [--transparent] [--image <url>] [--size <
|
|
659
|
+
gen-image "<prompt>" [--model gpt-image-2.5|nano-banana-2.1|gpt-image-2] [--transparent] [--image <url>] [--size <WxH>]
|
|
626
660
|
[--quality <q>] [--count <n>] [--seed <n>] [--brand] [--slug <deck>] [--download <file>]
|
|
627
661
|
default model gpt-image-2.5; --seed applies to nano-banana-2.1;
|
|
628
662
|
--brand adds your brand's colours and "no text, no logos" to the prompt
|
|
@@ -636,8 +670,23 @@ commands:
|
|
|
636
670
|
a PNG of a public web page (private and local addresses are refused)
|
|
637
671
|
chart <spec.json|-> [--slug <deck>] [--name <name>] [--download <file>]
|
|
638
672
|
a branded SVG: { "kind": "bar|line|donut|number", "labels", "series", "values", "value", "palette" }
|
|
639
|
-
|
|
640
|
-
|
|
673
|
+
photos search <words...> [--orientation landscape|portrait|squarish] [--limit 10] [--json]
|
|
674
|
+
find a photo on Unsplash for a place, an object or a mood (free); prints each id, shape and photographer
|
|
675
|
+
photos add <id> [--for <layout>] [--json]
|
|
676
|
+
use one: prints the picture markup (from Unsplash's own URL), its credit line for the slide and
|
|
677
|
+
the data-note credit; Unsplash counts it as a download. --for cover-band|split|picture-full|wall|…
|
|
678
|
+
(or a slide id like wall-2) prints the markup that slot takes and what it replaces (guide photos)
|
|
679
|
+
gifs search <words...> [--rating g|pg] [--limit 10] [--for <layout>] [--json]
|
|
680
|
+
find a GIF on GIPHY (G-rated unless --rating pg; free); prints each GIF's markup (a muted looping
|
|
681
|
+
MP4 from GIPHY with "Powered by GIPHY"); one or two in a casual deck at most
|
|
682
|
+
icons search <word...> [--for <layout>] [--set lucide|phosphor|tabler|material|all] [--weight W] [--deck <dir>] [--limit 8] [--stroke-width 2] [--json]
|
|
683
|
+
real icons as inline SVG in currentColor (free, offline), each labelled with its set and
|
|
684
|
+
weight; looks in the deck's recorded set (icons use), else in every set; --for says where it goes
|
|
685
|
+
icons sets [--json]
|
|
686
|
+
the icon sets: weights, character, licence and a sample, to pick one for the deck
|
|
687
|
+
icons use <deck-dir|slug> <set> [weight] [--hosted]
|
|
688
|
+
record the deck's icon set and weight (<meta name="hd-icons">) and put the icons already in it
|
|
689
|
+
(the layouts' own too) in that set; later searches stay in it
|
|
641
690
|
icons <subject...> --preset line|duotone|sticker|clay | --style "<style>" [--palette "#hex,#hex"] [--slug <deck>] [--name <prefix>]
|
|
642
691
|
a style-consistent set of generated (illustrated) icons, one per subject (max 12);
|
|
643
692
|
palette defaults to your brand's colours
|
|
@@ -656,11 +705,16 @@ commands:
|
|
|
656
705
|
undo the last change, or go back to a version from brand history
|
|
657
706
|
brand edit edit design.md (voice, do and don't) in $EDITOR
|
|
658
707
|
brand fonts the curated font pairings (display + body + mono)
|
|
708
|
+
theme [list] the built-in themes (house, longform, blueprint, soft, loud, print, quiet, evening, carousel): shape,
|
|
709
|
+
title style and how photos and charts are drawn; a named theme keeps its colours unless --brand
|
|
710
|
+
theme set <deck-dir|slug> <theme> [--brand|--no-brand]
|
|
711
|
+
put a local deck in another theme, in its own colours and fonts (--brand: your brand's on top);
|
|
712
|
+
a released deck changes when you release it again
|
|
659
713
|
brand clear forget the brand; new decks get the template look
|
|
660
714
|
review <slug> [--script <script.md>] [--json]
|
|
661
715
|
GPT-6 Luna reviews every slide (desktop + phone screenshots) and lists what to fix
|
|
662
716
|
review-job <jobId> [--json]
|
|
663
|
-
export <slug|deck-dir> --pdf [--notes] [--out <file.pdf>] [--share <token>] [--json]
|
|
717
|
+
export <slug|deck-dir> [--slug <slug>] --pdf [--notes] [--out <file.pdf>] [--share <token>] [--json]
|
|
664
718
|
a PDF of the released deck: one 1600x900 page per slide (a script page after each
|
|
665
719
|
with --notes), a footer with the deck's tracked link; kept 30 days
|
|
666
720
|
export <slug|deck-dir> --video [--size 1080p|720p|4k] [--shape 16:9|9:16|1:1] [--no-captions]
|
|
@@ -739,7 +793,7 @@ async function genImage(pos, opts) {
|
|
|
739
793
|
const prompt = pos.join(" ").trim() || opts.prompt;
|
|
740
794
|
if (!prompt) {
|
|
741
795
|
throw new Error(
|
|
742
|
-
'usage: gen-image "<prompt>" [--model gpt-image-2.5|nano-banana-2.1|gpt-image-2] [--image <url>] [--transparent] [--size <
|
|
796
|
+
'usage: gen-image "<prompt>" [--model gpt-image-2.5|nano-banana-2.1|gpt-image-2] [--image <url>] [--transparent] [--size <WxH>, e.g. 1536x1024] [--quality <q>] [--count <n>] [--format png|jpeg|webp] [--seed <n>] [--brand] [--slug <deck>] [--name <name>] [--download <file>]',
|
|
743
797
|
);
|
|
744
798
|
}
|
|
745
799
|
let out = await ops.generateImage(opts, {
|
|
@@ -875,6 +929,49 @@ async function screenshot(pos, opts) {
|
|
|
875
929
|
await saveTo(opts.download, out.url);
|
|
876
930
|
}
|
|
877
931
|
|
|
932
|
+
// Found pictures (ops.searchPhotos / addPhoto / searchGifs): free, embedded from
|
|
933
|
+
// the service's own URL with a credit line.
|
|
934
|
+
async function photosSearch(words, opts) {
|
|
935
|
+
if (!words.length) throw new Error("usage: photos search <words...> [--orientation landscape|portrait|squarish] [--limit 10] [--json]");
|
|
936
|
+
const out = await ops.searchPhotos(opts, { query: words.join(" "), orientation: opts.orientation, limit: opts.limit });
|
|
937
|
+
if (opts.json) return console.log(JSON.stringify(out, null, 2));
|
|
938
|
+
if (!out.results.length) return console.log(`no photos for "${out.query}"${out.hint ? `\n${out.hint}` : ""}`);
|
|
939
|
+
for (const r of out.results) console.log(`${r.id} ${r.shape} ${r.width}x${r.height} by ${r.photographer} ${r.description}\n ${r.thumbUrl}`);
|
|
940
|
+
if (out.hint) console.log(`\n${out.hint}`);
|
|
941
|
+
console.log(`\nuse one: hyperdecks photos add <id> --for <layout> (searches are free)`);
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
async function photosAdd(pos, opts) {
|
|
945
|
+
if (!pos[0]) throw new Error("usage: photos add <id> [--for <layout>] [--json]");
|
|
946
|
+
const out = await ops.addPhoto(opts, { id: pos[0], for: opts.for });
|
|
947
|
+
if (opts.json) return console.log(JSON.stringify(out, null, 2));
|
|
948
|
+
console.log(`${slotText(out)}\n\ncredit line (once, as the slide's own child; join several credits with " · "):\n${out.creditLine}`);
|
|
949
|
+
console.log(`\ndata-note credit: ${out.note}`);
|
|
950
|
+
console.log(`${out.shape} ${out.width}x${out.height}; check fails without the credit line`);
|
|
951
|
+
if (out.tracked === false) process.stderr.write("Unsplash's download count could not be sent this time; the photo is fine to use\n");
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
async function gifsSearch(words, opts) {
|
|
955
|
+
if (!words.length) throw new Error("usage: gifs search <words...> [--rating g|pg] [--limit 10] [--for <layout>] [--json]");
|
|
956
|
+
const out = await ops.searchGifs(opts, { query: words.join(" "), rating: opts.rating, limit: opts.limit, for: opts.for });
|
|
957
|
+
if (opts.json) return console.log(JSON.stringify(out, null, 2));
|
|
958
|
+
if (!out.results.length) return console.log(`no GIFs for "${out.query}" (rating ${out.rating})`);
|
|
959
|
+
for (const r of out.results) console.log(`${r.id} ${r.shape} ${r.width}x${r.height} ${r.title}\n preview: ${r.previewUrl}\n ${r.markup}\n ${r.creditLine}\n data-note credit: ${r.note}`);
|
|
960
|
+
const slot = out.results[0]?.slot;
|
|
961
|
+
console.log(`\nPowered by GIPHY. Paste one GIF's markup ${slot ? `in place of ${slot.replaces} on the ${slot.slide} slide` : "into the picture slot"} and its credit line once as the slide's own child (searches are free).${slot ? "" : `\n${FOR_HINT}`}`);
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
// What photos add prints for the picture: the markup and what it replaces
|
|
965
|
+
// (with --for), or the default markup and the flag that fits it to a layout.
|
|
966
|
+
function slotText(out) {
|
|
967
|
+
if (!out.slot) return `picture slot:\n${out.markup}\n(${FOR_HINT})`;
|
|
968
|
+
const { slide, replaces, otherCells, cells } = out.slot;
|
|
969
|
+
const lines = [`on the ${slide} slide, in place of ${replaces}:`, out.markup];
|
|
970
|
+
if (cells) lines.push(`(${cells})`);
|
|
971
|
+
if (otherCells) lines.push(`\nfor ${otherCells.replaces} (no id):`, otherCells.markup);
|
|
972
|
+
return lines.join("\n");
|
|
973
|
+
}
|
|
974
|
+
|
|
878
975
|
async function chart(pos, opts) {
|
|
879
976
|
const [file] = pos;
|
|
880
977
|
if (!file) throw new Error("usage: chart <spec.json> [--slug <deck>] [--name <name>] [--download <file>]");
|
|
@@ -954,7 +1051,7 @@ export function exportTarget(arg, opts = {}, cwd = process.cwd()) {
|
|
|
954
1051
|
const dir = [resolve(cwd, arg), join(cwd, "decks", arg)].find((d) => existsSync(join(d, "index.html")));
|
|
955
1052
|
if (!dir) return { slug: arg, script: undefined };
|
|
956
1053
|
const scriptPath = join(dir, "script.md");
|
|
957
|
-
return { slug:
|
|
1054
|
+
return { slug: deckSlug(dir, opts), script: existsSync(scriptPath) ? readFileSync(scriptPath, "utf8") : undefined };
|
|
958
1055
|
}
|
|
959
1056
|
|
|
960
1057
|
export const EXPORT_USAGE = "usage: export <slug|deck-dir> --pdf [--notes] [--out <file.pdf>] [--share <token>]\n" +
|
|
@@ -1087,17 +1184,27 @@ function commandTable(pos, rest, opts) {
|
|
|
1087
1184
|
const tagFailed = (tagged) => {
|
|
1088
1185
|
if (tagged.tagError) throw Object.assign(new Error(tagged.tagError), { reported: true });
|
|
1089
1186
|
};
|
|
1187
|
+
// --icons "<set> [weight]": the deck's icon set, recorded and its built-in icons put in it, as icons use does.
|
|
1188
|
+
const iconsWanted = opts.icons ? String(opts.icons).trim().split(/[\s:/,]+/) : null;
|
|
1189
|
+
const iconsAfterNew = async (target, hosted) => {
|
|
1190
|
+
if (!iconsWanted) return;
|
|
1191
|
+
const { iconsUse } = await import("./iconsCli.mjs");
|
|
1192
|
+
await iconsUse([target, ...iconsWanted], { ...opts, hosted }, opts.json ? { log: (line) => console.error(line) } : {});
|
|
1193
|
+
};
|
|
1090
1194
|
if (opts.hosted) {
|
|
1091
1195
|
const { hostedNewDeck } = await import("./source.mjs");
|
|
1196
|
+
const { brandAsked } = await import("./brand.mjs");
|
|
1092
1197
|
if (!opts.narrated) throw new Error("the published CLI scaffolds narrated decks only: add --narrated");
|
|
1093
|
-
const created = await hostedNewDeck(opts, { slug: rest[0], title: rest[1], layouts: opts.layouts, presenterStyle: opts["presenter-style"], brand:
|
|
1198
|
+
const created = await hostedNewDeck(opts, { slug: rest[0], title: rest[1], layouts: opts.layouts, presenterStyle: opts["presenter-style"], brand: brandAsked(opts), theme: opts.theme });
|
|
1199
|
+
await iconsAfterNew(created.slug, true);
|
|
1094
1200
|
const tagged = await tagNew(created.slug);
|
|
1095
1201
|
const out = { ...created, ...tagged };
|
|
1096
|
-
console.log(opts.json ? JSON.stringify(out, null, 2) : `✓ created hosted deck "${out.slug}" (rev ${out.rev})${tagged.tags ? `, tagged ${tagged.tags.join(", ")}` : ""}\n preview: ${out.previewUrl}\n edit locally: hyperdecks source pull ${out.slug}`);
|
|
1202
|
+
console.log(opts.json ? JSON.stringify(out, null, 2) : `✓ created hosted deck "${out.slug}" (rev ${out.rev})${tagged.tags ? `, tagged ${tagged.tags.join(", ")}` : ""}\n theme: ${out.theme}\n brand: ${out.brand.note}\n preview: ${out.previewUrl}\n edit locally: hyperdecks source pull ${out.slug}`);
|
|
1097
1203
|
return tagFailed(tagged);
|
|
1098
1204
|
}
|
|
1099
1205
|
const { deckNew } = await import("./scaffold.mjs");
|
|
1100
1206
|
const created = await deckNew(rest, opts, opts.json ? { log: (line) => console.error(line) } : {});
|
|
1207
|
+
await iconsAfterNew(created.dir, false);
|
|
1101
1208
|
const tagged = await tagNew(created.slug);
|
|
1102
1209
|
if (tagged.tags && !opts.json) console.log(`✓ tagged ${created.slug}: ${tagged.tags.join(", ")}`);
|
|
1103
1210
|
if (opts.json) console.log(JSON.stringify({ ...created, ...tagged }, null, 2));
|
|
@@ -1159,6 +1266,11 @@ function commandTable(pos, rest, opts) {
|
|
|
1159
1266
|
const out = await assetAdd(rest, opts, opts.json ? { log: () => {} } : {});
|
|
1160
1267
|
if (opts.json) console.log(JSON.stringify(out, null, 2));
|
|
1161
1268
|
},
|
|
1269
|
+
"layouts suggest": async () => {
|
|
1270
|
+
const { layoutsSuggest } = await import("./guide.mjs");
|
|
1271
|
+
const out = await layoutsSuggest(rest, opts);
|
|
1272
|
+
if (opts.json) console.log(JSON.stringify(out.suggestions, null, 2));
|
|
1273
|
+
},
|
|
1162
1274
|
guide: async () => {
|
|
1163
1275
|
const { guide } = await import("./guide.mjs");
|
|
1164
1276
|
const out = await guide(pos.slice(1), opts);
|
|
@@ -1279,7 +1391,9 @@ function commandTable(pos, rest, opts) {
|
|
|
1279
1391
|
log(`OK ${out.slug} → ${out.narrator} (voice at its next narrate; face in play and the draft link now, on share links at its next release)`);
|
|
1280
1392
|
// The local file names the face too, so the draft opened from disk shows it.
|
|
1281
1393
|
const { writeDraftFace } = await import("./draftFace.mjs");
|
|
1282
|
-
|
|
1394
|
+
// No --dir: the folder you are in when deck new recorded this slug there, else decks/<slug>.
|
|
1395
|
+
const { recordedSlug } = await import("./deckSlug.mjs");
|
|
1396
|
+
const dir = resolve(typeof opts.dir === "string" ? opts.dir : recordedSlug(process.cwd()) === out.slug ? "." : join("decks", out.slug));
|
|
1283
1397
|
let local = { wrote: false };
|
|
1284
1398
|
try {
|
|
1285
1399
|
local = await writeDraftFace(opts, out.slug, join(dir, "index.html"), { log });
|
|
@@ -1312,6 +1426,7 @@ function commandTable(pos, rest, opts) {
|
|
|
1312
1426
|
"share on": () => shareToggle(rest, opts, true),
|
|
1313
1427
|
"share off": () => shareToggle(rest, opts, false),
|
|
1314
1428
|
"share forward": () => shareForward(rest, opts),
|
|
1429
|
+
"share count": () => shareCount(rest, opts),
|
|
1315
1430
|
"share mute": async () => { if (!rest[0]) throw new Error("usage: share mute <token>"); await ops.setShareNotify(opts, rest[0], false); console.log(`OK muted ${rest[0]}`); },
|
|
1316
1431
|
"share unmute": async () => { if (!rest[0]) throw new Error("usage: share unmute <token>"); await ops.setShareNotify(opts, rest[0], true); console.log(`OK notification preference requested for ${rest[0]} (QA links remain muted)`); },
|
|
1317
1432
|
"share rm": () => shareRm(rest, opts),
|
|
@@ -1329,17 +1444,31 @@ function commandTable(pos, rest, opts) {
|
|
|
1329
1444
|
"gen-video": () => genVideo(pos.slice(1), opts),
|
|
1330
1445
|
"video-job": () => videoJob(pos.slice(1), opts),
|
|
1331
1446
|
screenshot: () => screenshot(pos.slice(1), opts),
|
|
1447
|
+
"photos search": () => photosSearch(rest, opts),
|
|
1448
|
+
"photos add": () => photosAdd(rest, opts),
|
|
1449
|
+
"gifs search": () => gifsSearch(rest, opts),
|
|
1332
1450
|
chart: () => chart(pos.slice(1), opts),
|
|
1333
1451
|
icons: () => icons(pos.slice(1), opts),
|
|
1334
|
-
// The icon library (Lucide); `icons search … --style` still generates.
|
|
1452
|
+
// The icon library (Lucide, Phosphor, Tabler, Material Symbols); `icons search … --style` still generates.
|
|
1335
1453
|
"icons search": async () => {
|
|
1336
1454
|
if (opts.style) return icons(pos.slice(1), opts);
|
|
1337
|
-
if (!rest.length) throw new Error("usage: icons search <word...> [--limit N] [--stroke-width N] [--json]");
|
|
1338
|
-
const { icons: searchIcons } = await import("./
|
|
1455
|
+
if (!rest.length) throw new Error("usage: icons search <word...> [--for <layout>] [--set lucide|phosphor|tabler|material|all] [--weight W] [--deck <dir>] [--limit N] [--stroke-width N] [--json]");
|
|
1456
|
+
const { icons: searchIcons } = await import("./iconsCli.mjs");
|
|
1339
1457
|
const out = await searchIcons(rest, opts);
|
|
1340
1458
|
if (opts.json) console.log(JSON.stringify(out, null, 2));
|
|
1341
1459
|
},
|
|
1460
|
+
"icons sets": async () => {
|
|
1461
|
+
const out = (await import("./iconsCli.mjs")).iconSetsCli(opts);
|
|
1462
|
+
if (opts.json) console.log(JSON.stringify(out, null, 2));
|
|
1463
|
+
},
|
|
1464
|
+
"icons use": async () => {
|
|
1465
|
+
const out = await (await import("./iconsCli.mjs")).iconsUse(rest, opts);
|
|
1466
|
+
if (opts.json) console.log(JSON.stringify(out, null, 2));
|
|
1467
|
+
},
|
|
1342
1468
|
brand: async () => (await import("./brandCli.mjs")).brandShow(opts),
|
|
1469
|
+
theme: async () => (await import("./themeCli.mjs")).themeList(opts),
|
|
1470
|
+
"theme list": async () => (await import("./themeCli.mjs")).themeList(opts),
|
|
1471
|
+
"theme set": async () => (await import("./themeCli.mjs")).themeSet(rest, opts),
|
|
1343
1472
|
"brand show": async () => (await import("./brandCli.mjs")).brandShow(opts),
|
|
1344
1473
|
"brand set": async () => (await import("./brandCli.mjs")).brandSet(opts),
|
|
1345
1474
|
"brand edit": async () => (await import("./brandCli.mjs")).brandEdit(opts),
|
package/src/deckSlug.mjs
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// A deck folder's slug: --slug, else the one `deck new` recorded in the folder
|
|
2
|
+
// (.hyperdecks.json), else the folder's name. The marker lets a deck live in a
|
|
3
|
+
// folder with any name (deck new --dir) and every command still find it. It is
|
|
4
|
+
// never uploaded: release bundles only index.html and the files it references.
|
|
5
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
6
|
+
import { basename, join } from "node:path";
|
|
7
|
+
|
|
8
|
+
export const DECK_MARKER = ".hyperdecks.json";
|
|
9
|
+
const SLUG = /^[a-z0-9][a-z0-9-]{0,63}$/;
|
|
10
|
+
|
|
11
|
+
// null only when there is no marker: a marker that can't be read must not fall
|
|
12
|
+
// back to the folder's name, which is the wrong deck by design.
|
|
13
|
+
export function recordedSlug(dir) {
|
|
14
|
+
const path = join(dir, DECK_MARKER);
|
|
15
|
+
if (!existsSync(path)) return null;
|
|
16
|
+
let slug;
|
|
17
|
+
try {
|
|
18
|
+
slug = JSON.parse(readFileSync(path, "utf8"))?.slug;
|
|
19
|
+
} catch (e) {
|
|
20
|
+
throw new Error(`${path} is not a valid deck marker (${e.message}); fix it to {"slug": "<slug>"} or pass --slug`);
|
|
21
|
+
}
|
|
22
|
+
if (typeof slug !== "string" || !SLUG.test(slug)) throw new Error(`${path} names no valid slug; fix it to {"slug": "<slug>"} or pass --slug`);
|
|
23
|
+
return slug;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function deckSlug(dir, opts = {}) {
|
|
27
|
+
if ("slug" in opts && opts.slug !== undefined && (typeof opts.slug !== "string" || !opts.slug)) throw new Error("--slug needs a value");
|
|
28
|
+
return opts.slug || recordedSlug(dir) || basename(dir);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// A line to say before acting, when the slug comes from the marker and is not
|
|
32
|
+
// the folder's name (a copied folder keeps the original's marker), else null.
|
|
33
|
+
export function slugNote(dir, opts = {}) {
|
|
34
|
+
if (opts.slug) return null;
|
|
35
|
+
const slug = recordedSlug(dir);
|
|
36
|
+
return slug && slug !== basename(dir) ? `deck ${slug} (from ${join(dir, DECK_MARKER)}; a copied folder keeps the original's: pass --slug to use another)` : null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function recordSlug(dir, slug) {
|
|
40
|
+
writeFileSync(join(dir, DECK_MARKER), JSON.stringify({ slug }, null, 2) + "\n");
|
|
41
|
+
}
|
package/src/export-video.mjs
CHANGED
|
@@ -314,6 +314,55 @@ async function within(promise, ms, fallback) {
|
|
|
314
314
|
finally { clearTimeout(timer); }
|
|
315
315
|
}
|
|
316
316
|
|
|
317
|
+
// Stepped heads (packages/player/stepped-heads.js): a player whose Minimoji
|
|
318
|
+
// bundle has createManualClock publishes window.__hdExportHeads, and each head
|
|
319
|
+
// draws only when the recorder steps its clock. Real milliseconds a head may
|
|
320
|
+
// take to report ready: the player's export head budget (HEAD_BUDGET).
|
|
321
|
+
export const HEAD_READY_MS = 30000;
|
|
322
|
+
|
|
323
|
+
// Waits until every stepped head the page has can draw (`clock.ready`, the
|
|
324
|
+
// SDK's word), then draws each one's current frame (a step of 0). A page
|
|
325
|
+
// without stepped heads (an older bundle, no head) passes at once. A head that
|
|
326
|
+
// is not ready in `ms` fails the export with a plain message (as would a
|
|
327
|
+
// rejected ready; the player's registry lists a failed load instead, see
|
|
328
|
+
// headFailureWarnings).
|
|
329
|
+
export async function waitForHeads(page, ms = HEAD_READY_MS, { draw = true } = {}) {
|
|
330
|
+
const said = await within(page.evaluate(async (draw) => {
|
|
331
|
+
const heads = window.__hdExportHeads;
|
|
332
|
+
if (!heads) return { count: 0 };
|
|
333
|
+
try {
|
|
334
|
+
const count = await heads.ready();
|
|
335
|
+
// Before the first frame (real time still runs): each head measures its settled box (stepped-heads.js remeasure).
|
|
336
|
+
if (draw) { await heads.remeasure?.(); heads.step(0); }
|
|
337
|
+
return { count };
|
|
338
|
+
} catch (e) { return { error: String(e?.message ?? e) }; }
|
|
339
|
+
}, draw), ms, null);
|
|
340
|
+
if (!said) throw new Error(`the deck's live head was not ready to draw after ${Math.round(ms / 1000)}s (its model, or its narration lines still loading); nothing more was recorded`);
|
|
341
|
+
if (said.error) throw new Error(`the deck's live head could not draw: ${said.error}`);
|
|
342
|
+
return said.count;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
// The page's heads whose load failed, as export warnings: a bundle with
|
|
346
|
+
// Minimoji PR 358 rejects a stepped head's ready with what failed, and the
|
|
347
|
+
// player's registry lists it (stepped-heads.js failures) instead of failing
|
|
348
|
+
// the export. The presenter's own head falls back in the player and is warned
|
|
349
|
+
// about through the export log (state.presenter). [] for an older player or bundle.
|
|
350
|
+
// A check that could not run is a warning too, never a silent "all loaded".
|
|
351
|
+
export async function headFailureWarnings(page, ms = 5000) {
|
|
352
|
+
let list;
|
|
353
|
+
try { list = await within(page.evaluate(() => window.__hdExportHeads?.failures ?? []), ms, null); }
|
|
354
|
+
catch (e) { return [`could not check whether every head loaded (${String(e?.message ?? e).split('\n')[0]}); a head may be missing or incomplete in the video`]; }
|
|
355
|
+
if (list === null) return [`could not check whether every head loaded (the page did not answer within ${ms / 1000}s); a head may be missing or incomplete in the video`];
|
|
356
|
+
return (Array.isArray(list) ? list : []).map((f) => `${f.label} did not fully load (${f.why}); it may be missing or incomplete in the video`);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
// Freezes the page clock once every stepped head is ready: frame 0 is the deck
|
|
360
|
+
// as it starts, with its heads drawn. Returns the clock's epoch ms at freeze.
|
|
361
|
+
export async function freezeWhenHeadsReady(page, ms = HEAD_READY_MS) {
|
|
362
|
+
await waitForHeads(page, ms);
|
|
363
|
+
return page.evaluate(() => performance.timeOrigin + window.__hdFrameClock.freeze());
|
|
364
|
+
}
|
|
365
|
+
|
|
317
366
|
// The player's export log, read without trusting the page to answer quickly.
|
|
318
367
|
// undefined when it did not answer within `ms`.
|
|
319
368
|
const readLog = (page, ms = 5000) => within(page.evaluate(() => {
|
|
@@ -439,6 +488,8 @@ export async function recordVideo(config, { log = () => {}, chromium: injected,
|
|
|
439
488
|
// A range opens on its first slide (export-mode.js exportRangeStart).
|
|
440
489
|
if (config.range?.from > 0) await context.addInitScript((from) => { window.__hdExportFrom = from; }, config.range.from);
|
|
441
490
|
await context.addInitScript(() => {
|
|
491
|
+
// This recorder steps stepped heads' clocks (waitForHeads, the frame loop): the player may use them.
|
|
492
|
+
window.__hdStepsHeads = true;
|
|
442
493
|
navigator.sendBeacon = () => false;
|
|
443
494
|
window.open = () => null;
|
|
444
495
|
// The player's export mode waits for this before it plays (export-mode.js).
|
|
@@ -559,26 +610,42 @@ export async function recordVideo(config, { log = () => {}, chromium: injected,
|
|
|
559
610
|
written.catch(() => {});
|
|
560
611
|
};
|
|
561
612
|
// Frame 0 is the deck as it starts; frame n shows it n/fps seconds later on the page clock.
|
|
562
|
-
|
|
613
|
+
// Not before every stepped head is ready (waitForHeads).
|
|
614
|
+
const markMs = await freezeWhenHeadsReady(page);
|
|
563
615
|
// Each clip ends where its real audio does (the manifest's length can be off), as <audio> would end it.
|
|
564
616
|
// A range's tour ends after its last slide (export-mode.js exportRangeEnd).
|
|
565
617
|
await page.evaluate(({ lengths, to }) => { window.__hdExportClipLengths = lengths; if (to != null) window.__hdExportTo = to; window.__hdExportGo(); return window.__hdFrameClock.settle(); }, { lengths: clipLengths, to: range ? to : null });
|
|
566
618
|
const firstFrame = frameCount;
|
|
567
619
|
await capture();
|
|
568
620
|
const secondsOf = new Map(plan.ids.map((id, i) => [id, plan.seconds[i]]));
|
|
569
|
-
let shown = 0, progress = 0, movedAt = 0, end = Infinity;
|
|
621
|
+
let shown = 0, progress = 0, movedAt = 0, end = Infinity, waited = 0;
|
|
570
622
|
// A segment's seam frames (SEAM_FRAMES): recorded past its end, dropped from its start.
|
|
571
623
|
const tail = segment && to < last ? SEAM_FRAMES : 0, skip = segment && from > 0 ? SEAM_FRAMES : 0;
|
|
572
624
|
// Stuck: no slide landed and no clip started for longer than the current
|
|
573
625
|
// slide's planned clip and hold (unknown for a data-clip deck) plus a grace, on the page clock.
|
|
574
626
|
for (let n = 1; n < end; n++) {
|
|
627
|
+
// Each stepped head moves by the same 1/fps after the page clock, once
|
|
628
|
+
// per frame (a stepped head ignores requestAnimationFrame). One that
|
|
629
|
+
// mounted this frame (a guest's slide came near) is waited for first.
|
|
575
630
|
const step = await within(page.evaluate(async (ms) => {
|
|
576
631
|
const t = window.__hdFrameClock.step(ms);
|
|
577
632
|
await window.__hdFrameClock.settle();
|
|
633
|
+
const heads = window.__hdExportHeads;
|
|
634
|
+
// A line that started loading this frame finishes before the heads move (bounded by FRAME_TIMEOUT_MS).
|
|
635
|
+
await heads?.settled?.();
|
|
636
|
+
const waiting = heads ? !(await heads.idle().catch(() => false)) : false;
|
|
637
|
+
if (heads && !waiting) heads.step(ms / 1000);
|
|
578
638
|
const l = window.__hdExport;
|
|
579
|
-
return { t, moved: l.slides.length + l.clips.length, errors: l.errors.length, done: l.done };
|
|
639
|
+
return { t, moved: l.slides.length + l.clips.length, errors: l.errors.length, done: l.done, waiting };
|
|
580
640
|
}, 1000 / fps), FRAME_TIMEOUT_MS, null);
|
|
581
641
|
if (!step) throw new Error(`the page stopped answering (a frame took over ${FRAME_TIMEOUT_MS / 1000}s to draw)${pageSaid()}`);
|
|
642
|
+
if (step.waiting) {
|
|
643
|
+
// No extra draw: a step of 0 still moves a head's smoothing, so a frame that waited would differ.
|
|
644
|
+
waited++;
|
|
645
|
+
await waitForHeads(page, HEAD_READY_MS, { draw: false });
|
|
646
|
+
const stepped = await within(page.evaluate((s) => window.__hdExportHeads.step(s), 1 / fps), FRAME_TIMEOUT_MS, null);
|
|
647
|
+
if (stepped == null) throw new Error(`the page stopped answering (a head took over ${FRAME_TIMEOUT_MS / 1000}s to draw)${pageSaid()}`);
|
|
648
|
+
}
|
|
582
649
|
await capture();
|
|
583
650
|
const at = n / fps;
|
|
584
651
|
if (step.moved !== progress || step.errors || (step.done && end === Infinity)) {
|
|
@@ -605,11 +672,13 @@ export async function recordVideo(config, { log = () => {}, chromium: injected,
|
|
|
605
672
|
const seconds = frames / fps;
|
|
606
673
|
const wall = (Date.now() - startedAt) / 1000;
|
|
607
674
|
log(`rendered ${frames} frames (${clock(seconds)}) in ${clock(wall)}: ${(frames / Math.max(0.001, wall)).toFixed(1)} frames a second, ${(wall / Math.max(0.001, seconds)).toFixed(1)}× the video's length`);
|
|
675
|
+
if (waited) log(`waited for a head to finish loading on ${waited} frame(s)`);
|
|
608
676
|
// Drift means something only when every clip's planned length is known (a data-clip deck's are not).
|
|
609
677
|
const drift = (state.plan ?? []).every((s) => !s.audio || s.duration > 0) ? timelineDrift(state, markMs) : [];
|
|
610
678
|
const worst = drift.reduce((a, d) => (Math.abs(d.drift) > Math.abs(a.drift) ? d : a), { drift: 0 });
|
|
611
679
|
if (Math.abs(worst.drift) > 2) warnings.push(`the player ran up to ${worst.drift.toFixed(1)}s off the manifest's timeline (by ${worst.id}: clip loads, transitions); each clip's audio is placed where it really started, so the voice stays in sync`);
|
|
612
680
|
const render = { frames, seconds: wall };
|
|
681
|
+
warnings.push(...await headFailureWarnings(page));
|
|
613
682
|
|
|
614
683
|
if (endCard) {
|
|
615
684
|
phase = 'end card';
|
|
@@ -756,11 +825,12 @@ const mb = (n) => `${(n / 1e6).toFixed(1)} MB`;
|
|
|
756
825
|
export async function exportVideo(arg, opts = {}, { log = (l) => process.stderr.write(`${l}\n`), print = (l) => console.log(l), cwd = process.cwd(), deps = {} } = {}) {
|
|
757
826
|
const o = videoOptions(opts);
|
|
758
827
|
const { existsSync, readFileSync } = await import('node:fs');
|
|
759
|
-
const { resolve, join: joinPath
|
|
828
|
+
const { resolve, join: joinPath } = await import('node:path');
|
|
829
|
+
const { deckSlug } = await import('./deckSlug.mjs');
|
|
760
830
|
const ops = deps.ops ?? await import('./ops.mjs');
|
|
761
831
|
const local = [resolve(cwd, arg), joinPath(cwd, 'decks', arg)].find((d) => existsSync(joinPath(d, 'index.html')));
|
|
762
832
|
// --upload files the MP4 under a deck you own: checked before minutes of recording.
|
|
763
|
-
if (o.upload) await ops.ownedDeck(opts, local ? (opts
|
|
833
|
+
if (o.upload) await ops.ownedDeck(opts, local ? deckSlug(local, opts) : arg);
|
|
764
834
|
let source;
|
|
765
835
|
if (local) {
|
|
766
836
|
const { startPlay } = deps.play ?? await import('./play.mjs');
|
package/src/files.mjs
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// bundler copies next to the route and the CLI resolves next to this file. A
|
|
4
4
|
// path that is not here cannot be read, so nothing outside the package is.
|
|
5
5
|
import { readFileSync } from "node:fs";
|
|
6
|
+
import { gunzipSync } from "node:zlib";
|
|
6
7
|
|
|
7
8
|
const FILES = {
|
|
8
9
|
"templates/narrated-deck.html": () => new URL("../templates/narrated-deck.html", import.meta.url),
|
|
@@ -26,11 +27,37 @@ const FILES = {
|
|
|
26
27
|
"templates/layouts/quote.html": () => new URL("../templates/layouts/quote.html", import.meta.url),
|
|
27
28
|
"templates/layouts/team.html": () => new URL("../templates/layouts/team.html", import.meta.url),
|
|
28
29
|
"templates/layouts/timeline.html": () => new URL("../templates/layouts/timeline.html", import.meta.url),
|
|
30
|
+
"templates/layouts/phone-stage.html": () => new URL("../templates/layouts/phone-stage.html", import.meta.url),
|
|
31
|
+
"templates/layouts/tap-through.html": () => new URL("../templates/layouts/tap-through.html", import.meta.url),
|
|
32
|
+
"templates/layouts/screens.html": () => new URL("../templates/layouts/screens.html", import.meta.url),
|
|
33
|
+
"templates/layouts/zoom.html": () => new URL("../templates/layouts/zoom.html", import.meta.url),
|
|
34
|
+
"templates/layouts/video-full.html": () => new URL("../templates/layouts/video-full.html", import.meta.url),
|
|
35
|
+
"templates/layouts/video-beats.html": () => new URL("../templates/layouts/video-beats.html", import.meta.url),
|
|
36
|
+
"templates/layouts/picture-full.html": () => new URL("../templates/layouts/picture-full.html", import.meta.url),
|
|
37
|
+
"templates/layouts/wall.html": () => new URL("../templates/layouts/wall.html", import.meta.url),
|
|
38
|
+
"templates/layouts/portrait.html": () => new URL("../templates/layouts/portrait.html", import.meta.url),
|
|
39
|
+
"templates/layouts/sentence.html": () => new URL("../templates/layouts/sentence.html", import.meta.url),
|
|
40
|
+
"templates/layouts/strike.html": () => new URL("../templates/layouts/strike.html", import.meta.url),
|
|
41
|
+
"templates/layouts/spotlight.html": () => new URL("../templates/layouts/spotlight.html", import.meta.url),
|
|
42
|
+
"templates/layouts/funnel.html": () => new URL("../templates/layouts/funnel.html", import.meta.url),
|
|
43
|
+
"templates/layouts/scorecard.html": () => new URL("../templates/layouts/scorecard.html", import.meta.url),
|
|
44
|
+
"templates/layouts/bento.html": () => new URL("../templates/layouts/bento.html", import.meta.url),
|
|
45
|
+
"templates/layouts/two-by-two.html": () => new URL("../templates/layouts/two-by-two.html", import.meta.url),
|
|
46
|
+
"templates/layouts/staircase.html": () => new URL("../templates/layouts/staircase.html", import.meta.url),
|
|
47
|
+
"templates/layouts/rail.html": () => new URL("../templates/layouts/rail.html", import.meta.url),
|
|
48
|
+
"templates/layouts/loop.html": () => new URL("../templates/layouts/loop.html", import.meta.url),
|
|
49
|
+
"templates/layouts/lanes.html": () => new URL("../templates/layouts/lanes.html", import.meta.url),
|
|
50
|
+
"templates/layouts/two-bars.html": () => new URL("../templates/layouts/two-bars.html", import.meta.url),
|
|
51
|
+
"templates/layouts/stack.html": () => new URL("../templates/layouts/stack.html", import.meta.url),
|
|
29
52
|
"templates/icons/lucide.json": () => new URL("../templates/icons/lucide.json", import.meta.url),
|
|
53
|
+
"templates/icons/phosphor.json.gz": () => new URL("../templates/icons/phosphor.json.gz", import.meta.url),
|
|
54
|
+
"templates/icons/tabler.json.gz": () => new URL("../templates/icons/tabler.json.gz", import.meta.url),
|
|
55
|
+
"templates/icons/material.json.gz": () => new URL("../templates/icons/material.json.gz", import.meta.url),
|
|
30
56
|
"templates/first-deck/self.json": () => new URL("../templates/first-deck/self.json", import.meta.url),
|
|
31
57
|
"templates/first-deck/character.json": () => new URL("../templates/first-deck/character.json", import.meta.url),
|
|
32
58
|
"skills/hyperdecks/SKILL.md": () => new URL("../skills/hyperdecks/SKILL.md", import.meta.url),
|
|
33
59
|
"skills/hyperdecks/chat.md": () => new URL("../skills/hyperdecks/chat.md", import.meta.url),
|
|
60
|
+
"skills/hyperdecks/terminal.md": () => new URL("../skills/hyperdecks/terminal.md", import.meta.url),
|
|
34
61
|
};
|
|
35
62
|
|
|
36
63
|
const cache = new Map();
|
|
@@ -42,4 +69,12 @@ export function packageText(path) {
|
|
|
42
69
|
return cache.get(path);
|
|
43
70
|
}
|
|
44
71
|
|
|
72
|
+
// A packaged gzipped file (the larger icon sets), read and unzipped as text.
|
|
73
|
+
export function packageGzipText(path) {
|
|
74
|
+
const url = FILES[path];
|
|
75
|
+
if (!url || !path.endsWith(".gz")) throw new Error(`no packaged gzip file ${path}`);
|
|
76
|
+
if (!cache.has(path)) cache.set(path, gunzipSync(readFileSync(url())).toString("utf8"));
|
|
77
|
+
return cache.get(path);
|
|
78
|
+
}
|
|
79
|
+
|
|
45
80
|
export const PACKAGE_FILES = Object.keys(FILES);
|
package/src/frame-clock.mjs
CHANGED
|
@@ -236,13 +236,17 @@ export function installFrameClock(win) {
|
|
|
236
236
|
step(ms) {
|
|
237
237
|
if (!frozen) throw new Error('the frame clock is not frozen');
|
|
238
238
|
const target = t + Math.max(0, Number(ms) || 0);
|
|
239
|
+
// A timer due on the frame's edge (a clip that ends on a frame time) fires in this frame
|
|
240
|
+
// whatever float noise the clock's origin (the real time at freeze) leaves in `due`:
|
|
241
|
+
// otherwise one export ends a line a frame later than another.
|
|
242
|
+
const EDGE_MS = 0.001;
|
|
239
243
|
// A timer that keeps re-arming itself at 0 ms must not hang the step: it is reported, as a page error.
|
|
240
244
|
for (let guard = 0; ; guard++) {
|
|
241
245
|
let next = null, nextId = 0;
|
|
242
|
-
for (const [id, x] of timers) if (x.due <= target && (!next || x.due < next.due || (x.due === next.due && id < nextId))) { next = x; nextId = id; }
|
|
246
|
+
for (const [id, x] of timers) if (x.due <= target + EDGE_MS && (!next || x.due < next.due || (x.due === next.due && id < nextId))) { next = x; nextId = id; }
|
|
243
247
|
if (!next) break;
|
|
244
248
|
if (guard === 100000) { report(new Error('a timer re-armed itself 100000 times in one video frame; the rest wait for the next frame')); break; }
|
|
245
|
-
t = Math.max(t, next.due);
|
|
249
|
+
t = Math.min(target, Math.max(t, next.due));
|
|
246
250
|
fire(nextId);
|
|
247
251
|
}
|
|
248
252
|
t = target;
|