decklight 0.8.1 → 0.10.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.
Files changed (138) hide show
  1. package/PLATFORM.md +707 -0
  2. package/README.md +226 -150
  3. package/SPEC.md +803 -888
  4. package/cli/agent-review.mjs +246 -0
  5. package/cli/agents.mjs +35 -9
  6. package/cli/associate.mjs +12 -12
  7. package/cli/audit.mjs +42 -10
  8. package/cli/banner.mjs +41 -17
  9. package/cli/bundle-audio.mjs +190 -0
  10. package/cli/bundle-module.mjs +95 -0
  11. package/cli/bundle.mjs +439 -35
  12. package/cli/cast.mjs +48 -12
  13. package/cli/check-fixes.mjs +186 -0
  14. package/cli/check.mjs +988 -0
  15. package/cli/clone-deck.mjs +179 -0
  16. package/cli/commands.mjs +345 -0
  17. package/cli/comments.mjs +64 -18
  18. package/cli/commit-flow.mjs +51 -22
  19. package/cli/commit-message.mjs +51 -74
  20. package/cli/commit-split.mjs +601 -0
  21. package/cli/deck-refs.mjs +64 -0
  22. package/cli/deck-routes.mjs +67 -0
  23. package/cli/deckfile.mjs +3 -5
  24. package/cli/decklight.mjs +68 -289
  25. package/cli/design-system-deps.mjs +209 -0
  26. package/cli/design-system-edit.mjs +194 -0
  27. package/cli/design-system-refs.mjs +666 -0
  28. package/cli/design-system.mjs +497 -0
  29. package/cli/doctor.mjs +115 -0
  30. package/cli/edit-git.mjs +353 -0
  31. package/cli/edit-handover.mjs +551 -0
  32. package/cli/edit-look.mjs +631 -0
  33. package/cli/edit-slides.mjs +683 -0
  34. package/cli/edit.mjs +2585 -855
  35. package/cli/enhance.mjs +485 -0
  36. package/cli/extension.mjs +10 -10
  37. package/cli/font-refs.mjs +273 -0
  38. package/cli/font.mjs +246 -0
  39. package/cli/git-tree.mjs +1 -1
  40. package/cli/git.mjs +78 -11
  41. package/cli/import.mjs +56 -10
  42. package/cli/init.mjs +407 -236
  43. package/cli/library.mjs +127 -0
  44. package/cli/loader.mjs +3 -1
  45. package/cli/marketplace-autocheck.mjs +200 -0
  46. package/cli/marketplace.mjs +460 -29
  47. package/cli/narrate.mjs +251 -0
  48. package/cli/open-browser.mjs +63 -0
  49. package/cli/open.mjs +961 -0
  50. package/cli/pdf.mjs +64 -17
  51. package/cli/pkg.mjs +44 -2
  52. package/cli/plugin.mjs +43 -41
  53. package/cli/port-conflict.mjs +53 -23
  54. package/cli/pptx-export.mjs +63 -27
  55. package/cli/publish.mjs +8 -4
  56. package/cli/qr.mjs +1 -1
  57. package/cli/record.mjs +85 -23
  58. package/cli/remote.mjs +43 -17
  59. package/cli/restore.mjs +11 -4
  60. package/cli/review-ref.mjs +125 -0
  61. package/cli/review-remote.mjs +92 -48
  62. package/cli/review-routes.mjs +254 -0
  63. package/cli/review-store.mjs +47 -7
  64. package/cli/review-submit.mjs +47 -57
  65. package/cli/runtime-link.mjs +560 -0
  66. package/cli/serve.mjs +236 -45
  67. package/cli/setup.mjs +112 -0
  68. package/cli/sign.mjs +1 -1
  69. package/cli/skill-content.mjs +229 -35
  70. package/cli/skills.mjs +353 -26
  71. package/cli/start.mjs +110 -0
  72. package/cli/supervise.mjs +6 -6
  73. package/cli/theme-refs.mjs +527 -0
  74. package/cli/theme.mjs +181 -137
  75. package/cli/trust.mjs +83 -0
  76. package/cli/units.mjs +112 -47
  77. package/cli/update-check.mjs +1 -5
  78. package/cli/upgrade.mjs +194 -28
  79. package/cli/upstream.mjs +4 -3
  80. package/cli/util.mjs +4 -4
  81. package/cli/wizard.mjs +6 -6
  82. package/dist/build-info.json +1 -1
  83. package/dist/decklight.css +1533 -59
  84. package/dist/decklight.js +258 -115
  85. package/dist/decklight.js.map +4 -4
  86. package/docs/GLOSSARY.md +141 -0
  87. package/docs/architecture.svg +17 -17
  88. package/package.json +4 -2
  89. package/themes/README.md +9 -8
  90. package/themes/reveal-solarized.css +10 -0
  91. package/tools/args.mjs +20 -0
  92. package/tools/atomic-write.mjs +48 -0
  93. package/tools/brand-palette.mjs +717 -0
  94. package/tools/bridge.mjs +1 -1
  95. package/tools/build-groups.mjs +42 -0
  96. package/tools/color.mjs +48 -0
  97. package/tools/deck-html.mjs +396 -11
  98. package/tools/design-system-format.mjs +778 -0
  99. package/tools/design-system-migrations.mjs +207 -0
  100. package/tools/elevenlabs-tts.mjs +110 -17
  101. package/tools/exec.mjs +11 -3
  102. package/tools/extension-check.mjs +31 -7
  103. package/tools/font-format.mjs +190 -0
  104. package/tools/font-stacks.mjs +24 -0
  105. package/tools/gemini-tts.mjs +3 -0
  106. package/tools/lipsync-config.mjs +103 -0
  107. package/tools/lipsync-engines.mjs +205 -2
  108. package/tools/lipsync-server.mjs +264 -41
  109. package/tools/lipsync.mjs +37 -18
  110. package/tools/local-voice.mjs +32 -42
  111. package/tools/narration-manifest.mjs +270 -0
  112. package/tools/narration-synth.mjs +416 -0
  113. package/tools/pptx.mjs +776 -19
  114. package/tools/publish-targets.mjs +1 -1
  115. package/tools/publish-voices.mjs +3 -3
  116. package/tools/recording-impact.mjs +7 -3
  117. package/tools/render-theme.mjs +33 -0
  118. package/tools/review-anchor.mjs +28 -12
  119. package/tools/semver.mjs +40 -0
  120. package/tools/sentences.mjs +180 -0
  121. package/tools/shot.mjs +14 -7
  122. package/tools/site-clip.mjs +114 -0
  123. package/tools/site-voices.mjs +232 -0
  124. package/tools/template-theme.mjs +1 -1
  125. package/tools/test-impact.mjs +17 -10
  126. package/tools/theme-check.mjs +30 -3
  127. package/tools/tts-cache.mjs +4 -3
  128. package/tools/tts-engines.mjs +38 -20
  129. package/tools/tts-setup.mjs +7 -7
  130. package/tools/video-options.mjs +34 -0
  131. package/tools/video.mjs +530 -54
  132. package/tools/voiceover-server.mjs +185 -104
  133. package/tools/voiceover.mjs +119 -261
  134. package/tools/zip.mjs +1 -1
  135. package/cli/dev.mjs +0 -623
  136. package/cli/present.mjs +0 -853
  137. package/cli/review.mjs +0 -361
  138. package/tools/publish-site-voices.mjs +0 -75
@@ -11,22 +11,28 @@
11
11
 
12
12
  import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync, statSync } from 'node:fs';
13
13
  import { tmpdir } from 'node:os';
14
- import { basename, join, relative, resolve, sep } from 'node:path';
14
+ import { basename, dirname, join, relative, resolve, sep } from 'node:path';
15
15
  import { chromeBin, chromeArgs } from '../tools/chrome.mjs';
16
16
  import { argReader } from '../tools/args.mjs';
17
+ import { renderThemeParams } from '../tools/render-theme.mjs';
17
18
  import { runAsync, CODEC_MS } from '../tools/exec.mjs';
18
- import { NOTES_ASIDE, cleanNotes, sectionBodies } from '../tools/deck-html.mjs';
19
+ import { NOTES_ASIDE, cleanNotes, sectionBodies, isHiddenSection } from '../tools/deck-html.mjs';
19
20
  import { buildPptx } from '../tools/pptx-write.mjs';
20
- import { serveForRender } from './present.mjs';
21
+ import { serveForRender } from './serve.mjs';
21
22
 
22
- const USAGE = `usage: decklight pptx <deck.html> [-o out.pptx] [--theme <name>] [--wait <ms>]
23
+ const USAGE = `usage: decklight pptx <deck.html> [-o out.pptx] [--theme <name> | --gen <b64url>] [--wait <ms>]
23
24
  writes a PowerPoint file: every slide as a picture, rendered at 1280×720 with
24
25
  its builds complete, and its speaker notes as real notes
25
26
 
26
27
  -o <file> output path [the deck's, with .pptx]
27
28
  --theme <name> export in another theme (rides ?theme=)
29
+ --gen <b64url> export in a custom or generated theme, as {name, tokens}
30
+ base64url JSON (rides ?gen=)
28
31
  --wait <ms> render budget per slide [1500]
29
32
 
33
+ Hidden slides (data-hidden) are not in the file, exactly as they are not in
34
+ the pdf, the video or the voiceover — the file is the talk, not the archive.
35
+
30
36
  Lossy by design: the file OPENS in PowerPoint, Keynote and Slides, and the
31
37
  notes are text there — but the slides are pictures. Import it back and you
32
38
  get pictures. Decklight is for people who never liked PowerPoint; this is
@@ -56,7 +62,7 @@ const titleOf = (html, file) => cleanNotes(/<title>([\s\S]*?)<\/title>/i.exec(ht
56
62
  * Chrome, ASYNC — `runAsync`, never `run`.
57
63
  *
58
64
  * The deck is served from THIS process (serveForRender, PRESENTING) so that a
59
- * relative asset still resolves and the CSP is the one `present` applies. A
65
+ * relative asset still resolves and the CSP is the one `--no-trust` applies. A
60
66
  * synchronous child blocks the event loop, so the server never answers the
61
67
  * browser it just launched: Chrome waits for a first byte that cannot arrive
62
68
  * until Chrome exits. 0.8.0 shipped exactly that — every `decklight pptx`
@@ -64,46 +70,75 @@ const titleOf = (html, file) => cleanNotes(/<title>([\s\S]*?)<\/title>/i.exec(ht
64
70
  * cause was one import. tools/shot.mjs carries the same warning above the same
65
71
  * call; test/pptx-render.mjs is what now notices.
66
72
  */
67
- export async function chromeShot(bin, argv, _ctx, { timeout = CODEC_MS } = {}) {
68
- await runAsync(bin, argv, { maxBuffer: 32 * 1024 * 1024, timeout, why: 'Chrome did not finish rendering a slide — it is probably waiting on a resource it cannot reach' });
73
+ export async function chromeShot(bin, argv, { signal } = {}, { timeout = CODEC_MS } = {}) {
74
+ await runAsync(bin, argv, { maxBuffer: 32 * 1024 * 1024, timeout, signal, why: 'Chrome did not finish rendering a slide — it is probably waiting on a resource it cannot reach' });
69
75
  }
70
76
 
71
- export async function pptxMain(args = [], { render = chromeShot, log = console.error } = {}) {
77
+ // `signal` stops it between slides and mid-slide (the edit server's stop
78
+ // route): it throws the AbortError, and no file is written.
79
+ export async function pptxMain(args = [], { render = chromeShot, log = console.error, onSlide = null, signal = null } = {}) {
72
80
  if (args.includes('--help') || args.includes('-h')) { console.log(USAGE); return 0; }
73
81
  const { opt } = argReader(args);
74
82
  const deck = args.find((a) => !a.startsWith('-') && /\.html?$/i.test(a));
75
83
  if (!deck) { log(`decklight pptx: needs a deck\n\n${USAGE}`); return 1; }
76
84
  const src = resolve(deck);
77
85
  if (!existsSync(src)) { log(`decklight pptx: no such deck: ${deck}`); return 1; }
78
- const root = process.cwd();
79
- if (src !== root && !src.startsWith(root + sep)) {
80
- log(`decklight pptx: the deck must live under the current directory (${root}) — cd there first`);
81
- return 1;
82
- }
86
+ // The deck is SERVED (see chromeShot), and a server has one root. A deck
87
+ // under the current directory keeps it as the root, which is what lets a
88
+ // deck in a subdirectory reach the dist/ and themes/ at the top of its
89
+ // project. A deck anywhere else is served from its OWN directory rather
90
+ // than refused: `decklight pptx ~/talks/q3.html` is a reasonable thing to
91
+ // type from anywhere, and a deck's assets are its siblings.
92
+ const root = src.startsWith(process.cwd() + sep) ? process.cwd() : dirname(src);
83
93
  const out = pptxOut(src, opt('-o'));
84
94
  const wait = Number(opt('--wait', 1500));
85
- const theme = opt('--theme');
95
+ let themeParams;
96
+ try { themeParams = renderThemeParams({ theme: opt('--theme'), gen: opt('--gen') }); } catch (e) { log(`decklight pptx: ${e.message}`); return 1; }
86
97
  const html = readFileSync(src, 'utf8');
87
98
  const notes = notesLines(html);
88
- const count = notes.length;
89
- if (!count) { log('decklight pptx: the deck has no <section> slides'); return 1; }
99
+ // HIDDEN_SLIDES — the file you hand over holds what the audience saw, the
100
+ // same rule `pdf`, `video` and `voiceover` already keep. Not merely a
101
+ // preference: a deep link onto a hidden slide lands on its nearest SHOWN
102
+ // neighbour (the engine's `goto`), so exporting one wrote that neighbour's
103
+ // picture a second time, carrying the hidden slide's notes.
104
+ const shown = sectionBodies(html).map((b, i) => (isHiddenSection(b) ? 0 : i + 1)).filter(Boolean);
105
+ const total = notes.length;
106
+ const count = shown.length;
107
+ if (!total) { log('decklight pptx: the deck has no <section> slides'); return 1; }
108
+ if (!count) { log('decklight pptx: every slide in this deck is hidden — there is nothing to hand over'); return 1; }
90
109
 
91
- // served, not file://, so every relative asset the deck names still resolves
92
- const inject = (text, file) => (file === src && theme ? text.replace(/(<\/head>)/i, `<link rel="stylesheet" href="themes/${theme}.css">$1`) : text);
93
- const server = await serveForRender(root, { html: inject });
110
+ // served, not file://, so every relative asset the deck names still resolves.
111
+ // --theme rides the URL (`?theme=`), which the runtime applies to any kind
112
+ // of theme the deck holds — a <link> to themes/<name>.css reached only file
113
+ // themes, and missed a deck whose themes are inline blocks (#547).
114
+ const renderQuery = `?${['capture', ...themeParams].join('&')}`;
115
+ const server = await serveForRender(root);
94
116
  const scratch = mkdtempSync(join(tmpdir(), 'decklight-pptx-'));
95
117
  const slides = [];
96
118
  try {
97
119
  const deckPath = '/' + relative(root, src).split(sep).join('/');
98
- const bin = chromeBin('pptx');
99
- log(`pptx: rendering ${basename(src)} — ${count} slides at 1280×720, builds complete`);
100
- for (let n = 1; n <= count; n++) {
120
+ // Resolved only when Chrome is what will render. `chromeBin` exits the
121
+ // process when it finds none, so resolving it unconditionally made every
122
+ // caller that injected its own renderer — the unit test, first of all —
123
+ // die on a machine with no browser, for a browser it was never going to
124
+ // start.
125
+ const bin = render === chromeShot ? chromeBin('pptx') : null;
126
+ log(`pptx: rendering ${basename(src)} — ${count} slides at 1280×720, builds complete`
127
+ + (total > count ? ` · ${total - count} hidden, skipped` : ''));
128
+ for (const [i, n] of shown.entries()) {
129
+ signal?.throwIfAborted();
130
+ // Position in the FILE being written, not in the deck — a caller showing
131
+ // "slide 3 of 5" means the third of five pictures, and a hidden slide in
132
+ // between would make the deck's own numbering count past the end.
133
+ onSlide?.(i + 1, count);
101
134
  const png = join(scratch, `slide-${n}.png`);
102
- // /999 lands on the last build step, whatever the slide has
135
+ // /999 lands on the last build step, whatever the slide has; `?capture`
136
+ // keeps the live-viewer chrome (toasts, the voice-over hint) off the
137
+ // picture (#548)
103
138
  await render(bin, chromeArgs(
104
139
  '--hide-scrollbars', '--window-size=1280,720', `--virtual-time-budget=${wait}`,
105
- `--screenshot=${png}`, `${server.origin}${deckPath}#/${n}/999`,
106
- ), { n, png });
140
+ `--screenshot=${png}`, `${server.origin}${deckPath}${renderQuery}#/${n}/999`,
141
+ ), { n, png, signal });
107
142
  if (!existsSync(png) || statSync(png).size === 0) { log(`decklight pptx: slide ${n} did not render — try a longer --wait`); return 1; }
108
143
  slides.push({ png: readFileSync(png), notes: notes[n - 1] });
109
144
  }
@@ -113,7 +148,8 @@ export async function pptxMain(args = [], { render = chromeShot, log = console.e
113
148
  }
114
149
  const bytes = buildPptx(slides, { title: titleOf(html, src) });
115
150
  writeFileSync(out, bytes);
116
- const withNotes = notes.filter((l) => l.length).length;
117
- console.log(`${out} · ${count} slides as pictures · ${withNotes} with notes · ${Math.round(bytes.length / 1024)} KB`);
151
+ const withNotes = shown.filter((n) => notes[n - 1].length).length;
152
+ console.log(`${out} · ${count} slides as pictures${total > count ? ` (${total - count} hidden, skipped)` : ''}`
153
+ + ` · ${withNotes} with notes · ${Math.round(bytes.length / 1024)} KB`);
118
154
  return 0;
119
155
  }
package/cli/publish.mjs CHANGED
@@ -7,6 +7,7 @@
7
7
  *
8
8
  * decklight publish <deck.html> [--branch gh-pages] [--remote origin]
9
9
  * [--no-bundle] [--no-sign] [--path <subdir>]
10
+ * [--theme <name>]
10
11
  * [--target gh-pages|netlify|vercel|folder]
11
12
  [--out <dir> [--url <public-url>]]
12
13
  *
@@ -77,13 +78,15 @@ if (!argv.length || argv.includes('--help') || argv.includes('-h')) {
77
78
  Usage:
78
79
  decklight publish <deck.html> [--branch gh-pages] [--remote origin]
79
80
  [--no-bundle] [--no-sign] [--deck] [--path <subdir>]
80
- [--target gh-pages|netlify|vercel]
81
+ [--theme <name>] [--target gh-pages|netlify|vercel]
81
82
 
82
83
  Options:
83
84
  --branch <name> branch to publish to (default: gh-pages; gh-pages target only)
84
85
  --remote <name> git remote to push to (default: origin; gh-pages target only)
85
86
  --no-bundle push the deck file as-is (skip single-file bundling)
86
87
  --no-sign publish without a Sigstore signature
88
+ --theme <name> the theme the published page opens on — a shipped theme or
89
+ one the deck marks (default: the deck's own "theme")
87
90
  --deck also publish index.decklight — the signed container, which
88
91
  is the file a visitor downloads and forwards
89
92
  --path <subdir> publish under a subdirectory of the site (other content
@@ -111,7 +114,7 @@ orphan; later publishes append to its history.
111
114
  }
112
115
 
113
116
  let deck = null, branch = 'gh-pages', remote = 'origin', bundle = true, subdir = '', sign = true, deckFile = false,
114
- target = 'gh-pages', branchGiven = false, remoteGiven = false;
117
+ target = 'gh-pages', branchGiven = false, remoteGiven = false, theme = null;
115
118
  for (let i = 0; i < argv.length; i++) {
116
119
  const a = argv[i];
117
120
  if (a === '--branch') { branch = argv[++i]; branchGiven = true; }
@@ -119,6 +122,7 @@ for (let i = 0; i < argv.length; i++) {
119
122
  else if (a === '--no-bundle') bundle = false;
120
123
  else if (a === '--no-sign') sign = false;
121
124
  else if (a === '--deck') deckFile = true;
125
+ else if (a === '--theme') theme = argv[++i];
122
126
  else if (a === '--path') subdir = argv[++i];
123
127
  else if (a === '--target') target = argv[++i];
124
128
  // the folder target's two answers, as flags — a directory is not a secret,
@@ -192,7 +196,7 @@ if (bundle) {
192
196
  tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'decklight-publish-'));
193
197
  sitePage = path.join(tmpDir, 'index.html');
194
198
  const { bundleMain } = await import('./bundle.mjs');
195
- await bundleMain([deckPath, '-o', sitePage]);
199
+ await bundleMain([deckPath, '-o', sitePage, ...(theme ? ['--theme', theme] : [])]);
196
200
  }
197
201
 
198
202
  // --------------------------------------------------------------- plumbing
@@ -265,7 +269,7 @@ if (tmpDir) fs.rmSync(tmpDir, { recursive: true, force: true });
265
269
  // fresh, so two machines publishing the same deck append to one history.
266
270
  const parent = remoteHead(git, remote, `refs/heads/${branch}`);
267
271
 
268
- // The tree builders live in cli/git-tree.mjs now — `review submit` needs the
272
+ // The tree builders live in cli/git-tree.mjs now — `comments submit` needs the
269
273
  // same ones, and neither git's `name/` sort order nor the `--full-tree` scoping
270
274
  // bug is a thing to keep two copies of.
271
275
  const put = (treeish, parts_, blob) => putBlob(git, treeish, parts_, blob);
package/cli/qr.mjs CHANGED
@@ -4,7 +4,7 @@
4
4
  // A zero-dependency QR encoder (ISO/IEC 18004) — the building block the phone
5
5
  // remote (#39) needs to put a scannable URL in the speaker view. Deliberately
6
6
  // narrow: byte mode, error-correction level L, versions 1–10 (a v10-L symbol
7
- // holds 271 bytes; a `http://host:port/remote?t=token` URL is well under v4).
7
+ // holds 271 bytes; a `http://host:port/deck/remote?t=token` URL is well under v4).
8
8
  // Numeric/alphanumeric modes and higher EC levels buy nothing here and are
9
9
  // left out. Node-only (cli/): the browser runtime bundle never sees this.
10
10
 
package/cli/record.mjs CHANGED
@@ -2,9 +2,9 @@
2
2
  // Copyright 2026 Gilles Philippart
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
 
5
- // decklight record — capture the deck's narration in YOUR voice.
5
+ // decklight narrate --mic — capture the deck's narration in YOUR voice.
6
6
  //
7
- // decklight record <deck.html> [--port 8788] [--dir voiceover] [--no-open]
7
+ // decklight narrate --mic <deck.html> [--port 8788] [--dir voices/me] [--no-open]
8
8
  //
9
9
  // WHY THIS IS A COMMAND AND NOT JUST A KEY. The recorder itself lives in the
10
10
  // deck (V → Record this deck… → With your voice…): it has to, because the notes, the builds and the microphone are
@@ -21,33 +21,50 @@
21
21
  // one command, one Ctrl-C, and the files land in the folder the deck already
22
22
  // plays from.
23
23
  //
24
- // Deliberately NOT `decklight author`: recording is not editing. Git is off,
24
+ // Deliberately NOT `decklight <deck>`: recording is not editing. Git is off,
25
25
  // no bridge is started, nothing is spent. You are reading your own notes aloud.
26
26
 
27
27
  import { editMain } from './edit.mjs';
28
- import { openUrl } from './init.mjs';
28
+ import { openUrl } from './open-browser.mjs';
29
29
  import { argReader, firstPositional, isMain } from '../tools/args.mjs';
30
- import { wrongRecorder } from './util.mjs';
30
+ import { runMain, wrongRecorder } from './util.mjs';
31
31
  import { exitWhenOrphaned } from './supervise.mjs';
32
32
 
33
- const USAGE = `usage: decklight record <deck.html> [--port 8788] [--dir voiceover] [--slides a-b] [--no-open]
33
+ const USAGE = `usage: decklight narrate --mic <deck.html> [--port 8788] [--dir voices/me] [--slides a-b [--beats k-l]] [--takes slide|beat] [--countdown N] [--remote] [--no-open]
34
34
  serves the deck over http://127.0.0.1 and opens it with the voice recorder up
35
35
 
36
- the deck reads you its notes one ⟨CLICK⟩ beat at a time; → ends a beat, which
36
+ the deck reads you its notes one [click] beat at a time; → ends a beat, which
37
37
  both closes that file and reveals the next build — so your voice paces the
38
- deck exactly as it will when you present it
38
+ deck exactly as it will when you present it. A slide is one take by default:
39
+ → cuts the beat without stopping, and the recording runs on into the next.
40
+ E edits the words of the beat on screen, saved to the deck's notes, and
41
+ records it again
39
42
 
40
43
  --port N port to serve on (taken? moves to the next free one) [8788]
41
- --dir NAME folder to write into, relative to the deck [the deck's own
42
- narration.files, else voiceover]
44
+ --dir NAME folder to write into, relative to the deck [voices/me]
43
45
  --slides a-b re-record only this range (1-based, inclusive; "7" for one
44
46
  slide). Every other slide's files are left untouched, so a
45
47
  fluffed beat costs one slide and not the whole deck
48
+ --beats k-l with --slides naming one slide: re-record only these beats of it
49
+ ("3" for one). The other beats' files are left byte for byte, and
50
+ slide-NN.wav is rebuilt from all of them. The recorder's card can
51
+ also start from any beat: ← → pick it before you press Enter
52
+ --takes slide|beat one take per slide, read straight through, or per beat,
53
+ each counted in and retaken on its own
54
+ [the recorder card's one take choice: per slide, remembered]
55
+ --countdown N seconds of count-in before each take, 0 for none (0-9)
56
+ [the recorder card's count-in: 3 s, 1 s or off, remembered]
57
+ --remote the phone remote too, so recording needs no keyboard: its next
58
+ ends a beat and its retake redoes one, and a tap is not in the
59
+ take the way a keystroke is. The recorder's card shows the QR;
60
+ off this machine only the remote answers, as with decklight <deck> --remote
46
61
  --no-open don't launch a browser — print the URL and wait
47
62
 
48
63
  writes <dir>/slide-NN.wav (the whole slide) and <dir>/slide-NN-KK.wav (one
49
64
  per beat); play them back with:
50
65
  narration: { files: '<dir>', ext: 'wav', segments: true }
66
+ (the same one-track form decklight narrate prints; several tracks are a
67
+ list of the same fields, each with a label)
51
68
 
52
69
  a microphone needs a secure context, which is why this serves the deck rather
53
70
  than opening the file — and why the recorder on a file:// deck says so instead of failing
@@ -83,10 +100,13 @@ export function dirProblem(name) {
83
100
  * record against the slides your audience will see, at the build they will see
84
101
  * them at.
85
102
  */
86
- export function recordUrl(port, deckUrl, dir, slides) {
103
+ export function recordUrl(port, deckUrl, dir, slides, beats, countdown, takes) {
87
104
  const q = ['record',
88
105
  ...(dir ? [`dir=${encodeURIComponent(dir)}`] : []),
89
- ...(slides ? [`slides=${encodeURIComponent(slides)}`] : [])].join('&');
106
+ ...(slides ? [`slides=${encodeURIComponent(slides)}`] : []),
107
+ ...(beats ? [`beats=${encodeURIComponent(beats)}`] : []),
108
+ ...(countdown != null ? [`countdown=${countdown}`] : []),
109
+ ...(takes ? [`takes=${takes}`] : [])].join('&');
90
110
  return `http://127.0.0.1:${port}${deckUrl}?${q}`;
91
111
  }
92
112
 
@@ -109,6 +129,39 @@ export function slidesProblem(range) {
109
129
  return null;
110
130
  }
111
131
 
132
+ /**
133
+ * `3` or `3-4` with `--slides` naming one slide → null; anything else → a
134
+ * message. Beats are counted per slide, so a range of slides has no beat 3 to
135
+ * name. Whether the slide HAS that many beats is the runtime's to say (it
136
+ * reads the notes), and the card says it with the count.
137
+ */
138
+ export function beatsProblem(beats, slides) {
139
+ if (beats === undefined || beats === null) return null;
140
+ const m = /^(\d+)(?:-(\d+))?$/.exec(String(beats).trim());
141
+ if (!m) return `--beats must be k-l or a single beat number (got "${beats}")`;
142
+ const from = Number(m[1]);
143
+ const to = m[2] ? Number(m[2]) : from;
144
+ if (from < 1) return '--beats is 1-based — there is no beat 0';
145
+ if (to < from) return `--beats ${beats} ends before it starts`;
146
+ const one = /^(\d+)(?:-(\d+))?$/.exec(String(slides ?? '').trim());
147
+ if (!one || (one[2] && one[2] !== one[1])) {
148
+ return `--beats needs --slides to name one slide, since beats are counted per slide (--slides 6 --beats ${beats})`;
149
+ }
150
+ return null;
151
+ }
152
+
153
+ /** `--countdown`: whole seconds, 0 to 9; anything else → a message. */
154
+ export function countdownProblem(value) {
155
+ if (value === undefined || value === null) return null;
156
+ return /^\d$/.test(String(value).trim()) ? null : `--countdown is whole seconds from 0 (none) to 9 (got "${value}")`;
157
+ }
158
+
159
+ /** `--takes`: `slide` or `beat`; anything else → a message. */
160
+ export function takesProblem(value) {
161
+ if (value === undefined || value === null) return null;
162
+ return ['slide', 'beat'].includes(value) ? null : `--takes is slide or beat (got "${value}")`;
163
+ }
164
+
112
165
  export async function recordMain(args, { open = openUrl, out = process.stdout, onListen = null } = {}) {
113
166
  if (args.includes('--help') || args.includes('-h') || !args.filter((a) => !a.startsWith('-')).length) {
114
167
  out.write(USAGE);
@@ -117,19 +170,25 @@ export async function recordMain(args, { open = openUrl, out = process.stdout, o
117
170
  const { opt } = argReader(args);
118
171
  const dir = opt('--dir');
119
172
  const slides = opt('--slides');
120
- for (const bad of [dirProblem(dir), slidesProblem(slides)]) {
121
- if (bad) { process.stderr.write(`decklight record: ${bad}\n`); return 2; }
173
+ const beats = opt('--beats');
174
+ const countdown = opt('--countdown');
175
+ const takes = opt('--takes');
176
+ for (const bad of [dirProblem(dir), slidesProblem(slides), beatsProblem(beats, slides), countdownProblem(countdown), takesProblem(takes)]) {
177
+ if (bad) { process.stderr.write(`decklight narrate --mic: ${bad}\n`); return 2; }
122
178
  }
123
179
 
124
- const deck = firstPositional(args, ['--dir', '--slides', '--port']);
180
+ const deck = firstPositional(args, ['--dir', '--slides', '--beats', '--countdown', '--takes', '--port']);
125
181
  // Before the server, not after: this used to serve the YAML file, print a
126
182
  // URL and open a browser on it, with no error anywhere.
127
- const mixedUp = wrongRecorder('record', deck);
128
- if (mixedUp) { process.stderr.write(`decklight record: ${mixedUp}\n`); return 2; }
183
+ const mixedUp = wrongRecorder('narrate', deck);
184
+ if (mixedUp) { process.stderr.write(`decklight narrate --mic: ${mixedUp}\n`); return 2; }
129
185
  let started;
130
186
  // `--no-git`, always: recording is not editing, and a take that happens to
131
187
  // coincide with the autocommit cadence has no business creating a commit.
132
- await editMain([deck, '--port', String(opt('--port', 8788)), '--no-git'], {
188
+ // `--remote` passes through untouched: the edit server owns the LAN
189
+ // listener, the token and the line that prints its URL (NO_TRUST#REMOTE).
190
+ const remote = args.includes('--remote');
191
+ await editMain([deck, '--port', String(opt('--port', 8788)), '--no-git', ...(remote ? ['--remote'] : [])], {
133
192
  // the same seam editMain offers, passed through: this server outlives the
134
193
  // call (it is the whole point), so a caller that is not a terminal — a
135
194
  // test — needs a handle to close it
@@ -139,16 +198,19 @@ export async function recordMain(args, { open = openUrl, out = process.stdout, o
139
198
  // missing or outside the served root — say nothing on top of it.
140
199
  if (!started) return process.exitCode ?? 1;
141
200
 
142
- const url = recordUrl(started.port, started.deckUrl, dir, slides);
143
- out.write(`decklight record on ${url}\n`);
201
+ const url = recordUrl(started.port, started.deckUrl, dir, slides, beats, countdown == null ? null : Number(countdown), takes);
202
+ out.write(`decklight narrate --mic on ${url}\n`);
144
203
  out.write(' V → Record this deck… → With your voice… opens the recorder · → ends a beat and reveals the next build · Esc stops\n');
145
- out.write(` files land in ${dir ?? "the deck's narration folder"}, next to the deck.`
146
- + `${slides ? ` Only slide${/-/.test(slides) ? 's' : ''} ${slides}.` : ''} Ctrl-C when you are done.\n`);
204
+ if (remote) out.write(' the phone remote is on: scan the QR on the recorder\'s card; next ends a beat, retake redoes it\n');
205
+ out.write(` files land in ${dir ?? 'voices/me'}, next to the deck.`
206
+ + `${dir ? '' : ' Recording again refreshes it.'}`
207
+ + `${slides ? ` Only slide${/-/.test(slides) ? 's' : ''} ${slides}${beats ? `, beat${/-/.test(beats) ? 's' : ''} ${beats}` : ''}.` : ''}`
208
+ + ' Ctrl-C when you are done.\n');
147
209
  if (!args.includes('--no-open')) await open(url, { out, what: url });
148
210
  return 0;
149
211
  }
150
212
 
151
213
  if (isMain(import.meta.url)) {
152
214
  exitWhenOrphaned();
153
- recordMain(process.argv.slice(2)).then((code) => { if (code) process.exitCode = code; });
215
+ process.exitCode = await runMain('record', () => recordMain(process.argv.slice(2)));
154
216
  }
package/cli/remote.mjs CHANGED
@@ -7,7 +7,7 @@
7
7
  // business receiving position echoes of its own movement.
8
8
  //
9
9
  // The relay is mounted by whichever server owns the deck (edit today;
10
- // `present` after PRESENT#REMOTE in MARKETPLACE.md) and never touches the
10
+ // `--no-trust` after NO_TRUST#REMOTE in MARKETPLACE.md) and never touches the
11
11
  // deck file: the phone asks the deck to move, it never edits.
12
12
 
13
13
  import { qrSvg } from './qr.mjs';
@@ -16,7 +16,9 @@ import { escapeHtml, isLoopback, sseChannel } from './serve.mjs';
16
16
  /**
17
17
  * The phone controller page (#39): a clicker, NOT a second screen — SPEC NON_GOALS
18
18
  * rules out multiplex/follow-along, so this renders no slides, only two big
19
- * targets and the position readout. Self-contained by necessity: the phone is
19
+ * targets and the position readout. While the voice recorder is capturing a
20
+ * beat (`narrate --mic --remote`, #848) prev gives its place to retake and the
21
+ * readout says which beat. Self-contained by necessity: the phone is
20
22
  * off-loopback, and every asset it could reference is one more thing the token
21
23
  * would have to guard. It carries the token it was opened with into both its
22
24
  * POSTs and its SSE subscription.
@@ -37,6 +39,12 @@ export function remoteControllerHtml(deckName) {
37
39
  .deck { font-weight: 400; opacity: .6; font-size: .8rem; }
38
40
  .pos { font-size: 1.6rem; font-variant-numeric: tabular-nums; }
39
41
  main { flex: 1; display: grid; grid-template-rows: 1fr 1fr; gap: .6rem; padding: .6rem; }
42
+ .rec { display: none; color: #ff6b6b; font-size: .85rem; letter-spacing: .04em; }
43
+ #retake { display: none; }
44
+ body.recording .rec { display: block; }
45
+ body.recording #prev { display: none; }
46
+ body.recording #retake { display: block; background: #3a2226; }
47
+ body.recording header { border-bottom-color: #5a2a2f; }
40
48
  button { font: inherit; font-size: 2rem; border: 0; border-radius: 1rem; color: #eee;
41
49
  background: #26262b; touch-action: manipulation; }
42
50
  button:active { background: #3a3a44; }
@@ -46,29 +54,43 @@ export function remoteControllerHtml(deckName) {
46
54
  <body>
47
55
  <header>
48
56
  <div class="deck">${escapeHtml(deckName)}</div>
57
+ <div class="rec" id="rec">● recording</div>
49
58
  <div class="pos" id="pos">—</div>
50
59
  </header>
51
60
  <main>
52
61
  <button id="next" aria-label="next">▼ next</button>
53
62
  <button id="prev" aria-label="previous">▲ prev</button>
63
+ <button id="retake" aria-label="retake this beat">↺ retake</button>
54
64
  </main>
55
65
  <footer id="state">connecting…</footer>
56
66
  <script>
57
67
  var t = new URLSearchParams(location.search).get('t') || '';
58
68
  var q = t ? '?t=' + encodeURIComponent(t) : '';
59
69
  var pos = document.getElementById('pos');
70
+ var rec = document.getElementById('rec');
71
+ var next = document.getElementById('next');
60
72
  var state = document.getElementById('state');
61
73
  function send(key) {
62
- return fetch('/remote/key' + q, {
74
+ return fetch('/deck/remote/key' + q, {
63
75
  method: 'POST', headers: { 'content-type': 'application/json' },
64
76
  body: JSON.stringify({ key: key }),
65
77
  }).catch(function () { state.textContent = 'offline'; });
66
78
  }
67
- document.getElementById('next').onclick = function () { send('next'); };
79
+ next.onclick = function () { send('next'); };
68
80
  document.getElementById('prev').onclick = function () { send('prev'); };
69
- var es = new EventSource('/remote/events' + q);
81
+ document.getElementById('retake').onclick = function () { send('retake'); };
82
+ var es = new EventSource('/deck/remote/events' + q);
70
83
  es.addEventListener('pos', function (e) {
71
- try { var p = JSON.parse(e.data); pos.textContent = p.i + ' / ' + p.n; } catch (err) {}
84
+ try {
85
+ var p = JSON.parse(e.data);
86
+ // the voice recorder is capturing a beat: say which, so the phone is
87
+ // usable without looking at the laptop, and offer retake in prev's place
88
+ var r = p.rec;
89
+ document.body.classList.toggle('recording', !!r);
90
+ rec.textContent = r ? '● recording · beat ' + r.beat + ' of ' + r.of : '● recording';
91
+ pos.textContent = r ? 'slide ' + r.slide + ' / ' + p.n : p.i + ' / ' + p.n;
92
+ next.textContent = r ? '▼ next beat' : '▼ next';
93
+ } catch (err) {}
72
94
  });
73
95
  es.onopen = function () { state.textContent = 'connected'; };
74
96
  es.onerror = function () { state.textContent = 'reconnecting…'; };
@@ -78,7 +100,7 @@ export function remoteControllerHtml(deckName) {
78
100
  }
79
101
 
80
102
  /**
81
- * The relay. handle(req, res, url[, body]) answers every /remote/* route and
103
+ * The relay. handle(req, res, url[, body]) answers every /deck/remote/* route and
82
104
  * returns whether it did. GET routes need no body; the mounting server hands
83
105
  * POST bodies in after its own read. A bad payload throws — the mounting
84
106
  * server's error path answers 400, exactly as when this lived inline.
@@ -87,11 +109,11 @@ export function remoteControllerHtml(deckName) {
87
109
  * token the per-run token (null when --remote is off — QR refuses)
88
110
  * remoteUrl () => the LAN URL the QR encodes (port known only after bind)
89
111
  * relayToDeck (event, data) => broadcast into the deck's own SSE stream
90
- * deckCount () => how many decks are listening (the /remote/key echo)
112
+ * deckCount () => how many decks are listening (the /deck/remote/key echo)
91
113
  * CORS the mounting server's CORS headers
92
114
  */
93
115
  export function createRemoteRelay({ deckName, token, remoteUrl, relayToDeck, deckCount, CORS }) {
94
- const phones = sseChannel(); // phones watching /remote/events
116
+ const phones = sseChannel(); // phones watching /deck/remote/events
95
117
  let lastPos = null; // the last position the deck reported
96
118
  const pushPos = () => { if (lastPos) phones.raw(`event: pos\ndata: ${JSON.stringify(lastPos)}\n\n`); };
97
119
  return {
@@ -101,12 +123,12 @@ export function createRemoteRelay({ deckName, token, remoteUrl, relayToDeck, dec
101
123
  res.end(JSON.stringify(obj));
102
124
  return true;
103
125
  };
104
- if (req.method === 'GET' && url.pathname === '/remote') {
126
+ if (req.method === 'GET' && url.pathname === '/deck/remote') {
105
127
  res.writeHead(200, { ...CORS, 'content-type': 'text/html; charset=utf-8', 'cache-control': 'no-cache' });
106
128
  res.end(remoteControllerHtml(deckName));
107
129
  return true;
108
130
  }
109
- if (req.method === 'GET' && url.pathname === '/remote/qr.svg') {
131
+ if (req.method === 'GET' && url.pathname === '/deck/remote/qr.svg') {
110
132
  // Only meaningful with --remote: without it there is no LAN URL to
111
133
  // scan, and a QR encoding 127.0.0.1 would be a lie a phone can't use.
112
134
  if (!token) return json(404, { ok: false, error: 'the remote is off — start with --remote' });
@@ -114,22 +136,24 @@ export function createRemoteRelay({ deckName, token, remoteUrl, relayToDeck, dec
114
136
  res.end(qrSvg(remoteUrl()));
115
137
  return true;
116
138
  }
117
- if (req.method === 'GET' && url.pathname === '/remote/events') {
139
+ if (req.method === 'GET' && url.pathname === '/deck/remote/events') {
118
140
  const sub = phones.add(req, res, CORS);
119
141
  // a phone joining mid-talk should show the right number immediately,
120
142
  // not stay blank until the presenter happens to advance
121
143
  if (lastPos) sub.write(`event: pos\ndata: ${JSON.stringify(lastPos)}\n\n`);
122
144
  return true;
123
145
  }
124
- if (req.method === 'POST' && url.pathname === '/remote/key') {
146
+ if (req.method === 'POST' && url.pathname === '/deck/remote/key') {
125
147
  const { key } = JSON.parse(body);
126
- if (key !== 'next' && key !== 'prev') throw new Error('bad payload');
148
+ // `retake` means something only while the voice recorder is capturing
149
+ // a beat (#848); the deck ignores it anywhere else
150
+ if (key !== 'next' && key !== 'prev' && key !== 'retake') throw new Error('bad payload');
127
151
  // relayed as a named event on the stream the deck ALREADY listens to —
128
152
  // no second socket, no WebSockets anywhere in this codebase
129
153
  relayToDeck('remote', { key });
130
154
  return json(200, { ok: true, key, decks: deckCount() });
131
155
  }
132
- if (req.method === 'POST' && url.pathname === '/remote/pos') {
156
+ if (req.method === 'POST' && url.pathname === '/deck/remote/pos') {
133
157
  // The deck→phones direction, and only that. The deck reporting its
134
158
  // position is a loopback caller; a phone — or anyone who obtained the
135
159
  // QR token — has no business posting here, and accepting it would let
@@ -137,9 +161,11 @@ export function createRemoteRelay({ deckName, token, remoteUrl, relayToDeck, dec
137
161
  if (!isLoopback(req.socket?.remoteAddress)) {
138
162
  return json(403, { ok: false, error: 'position reports come from the deck, not the phone' });
139
163
  }
140
- const { i, n } = JSON.parse(body);
164
+ const { i, n, rec = null } = JSON.parse(body);
141
165
  if (!Number.isInteger(i) || !Number.isInteger(n)) throw new Error('bad payload');
142
- lastPos = { i, n };
166
+ // the beat the voice recorder is capturing, or null (#848)
167
+ if (rec !== null && !['slide', 'beat', 'of'].every((k) => Number.isInteger(rec?.[k]))) throw new Error('bad payload');
168
+ lastPos = { i, n, rec: rec && { slide: rec.slide, beat: rec.beat, of: rec.of } };
143
169
  pushPos();
144
170
  return json(200, { ok: true });
145
171
  }
package/cli/restore.mjs CHANGED
@@ -26,7 +26,7 @@ import { execFileSync } from 'node:child_process';
26
26
  import { existsSync, writeFileSync } from 'node:fs';
27
27
  import { resolve, dirname, relative, basename } from 'node:path';
28
28
  import { isMain } from '../tools/args.mjs';
29
- import { git, inGitRepo, isIdentityError, oneline } from './git.mjs';
29
+ import { git, inGitRepo, isIdentityError, oneline, GIT_MAX_BUFFER } from './git.mjs';
30
30
 
31
31
  // A control character, written as an escape so no editor can silently strip
32
32
  // it: a commit subject may contain any printable character, so a printable
@@ -155,7 +155,7 @@ export function decorateHistory(entries, deckPath, cwd, {
155
155
  const buf = exec('git', ['cat-file', '--batch'], {
156
156
  cwd,
157
157
  input: heads.map((h) => `${h}:${rel}\n`).join(''),
158
- maxBuffer: 128 * 1024 * 1024,
158
+ maxBuffer: GIT_MAX_BUFFER,
159
159
  stdio: ['pipe', 'pipe', 'ignore'],
160
160
  });
161
161
  const slides = parseCatFileBatch(buf, heads);
@@ -173,9 +173,16 @@ export function formatEntry({ hash, when, subject }, pad = 14) {
173
173
  * Read the deck's content AT `ref` without going through git()'s trim — a
174
174
  * deck's trailing newline is content, and a restore that quietly reformats
175
175
  * the file is not a restore.
176
+ *
177
+ * `maxBuffer` is the whole of #508: a deck over Node's 1 MB default made this
178
+ * THROW `ENOBUFS` rather than return, which the preview route reported as
179
+ * "no such revision" and the panel drew as a black rectangle. Single-file
180
+ * decks are over that cap as a matter of course.
176
181
  */
177
182
  function showAt(ref, rel, cwd, exec = execFileSync) {
178
- return exec('git', ['show', `${ref}:./${rel}`], { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] });
183
+ return exec('git', ['show', `${ref}:./${rel}`], {
184
+ cwd, encoding: 'utf8', maxBuffer: GIT_MAX_BUFFER, stdio: ['ignore', 'pipe', 'pipe'],
185
+ });
179
186
  }
180
187
 
181
188
  /**
@@ -188,7 +195,7 @@ export function deckAt(deckPath, ref, cwd, exec = execFileSync) {
188
195
  }
189
196
 
190
197
  /**
191
- * Give a previewed deck a root `<base>`, because it is served from `/edit/`
198
+ * Give a previewed deck a root `<base>`, because it is served from `/deck/edit/`
192
199
  * rather than the root and every relative `../dist` and `./casts` path in it
193
200
  * would otherwise resolve one directory too deep — a preview with no runtime.
194
201
  *