decklight 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cli/import.mjs CHANGED
@@ -29,6 +29,7 @@ import { THEMES_DIR, themeCss as shippedThemeCss, runtimeCss, runtimeJs } from '
29
29
  import { unzip } from '../tools/zip.mjs';
30
30
  import { decodeEntities } from '../tools/ooxml.mjs';
31
31
  import { parseRels, resolvePart, slideOrder, parseSlide, notesText, slideSection, mimeOf } from '../tools/pptx.mjs';
32
+ import { parseTemplateTheme, themeFromTemplate } from '../tools/template-theme.mjs';
32
33
 
33
34
 
34
35
  const USAGE = `usage: decklight import <deck.pptx | deck.key | google-slides-url> [options]
@@ -36,14 +37,16 @@ const USAGE = `usage: decklight import <deck.pptx | deck.key | google-slides-url
36
37
 
37
38
  -o <file> output path [the source's, with .html]
38
39
  --theme <name> theme to open in [midnight]
40
+ 'template' derives one from the file's own palette and
41
+ fonts (its ppt/theme part), gated like any shipped theme
39
42
  --build all|none|auto
40
43
  which lists step in [auto]
41
44
  auto follows PowerPoint's own per-paragraph build list
42
45
  --force overwrite an existing output file
43
46
  -v, --verbose print every slide's line, not just the ones with drops
44
47
 
45
- content crosses over — titles, bullets (nested), paragraphs, tables, images
46
- and speaker notes. The template's LOOK does not: the result is themed by
48
+ content crosses over — titles, bullets (nested), paragraphs, tables, images,
49
+ charts (as data-chart, from the values the file carries) and speaker notes. The template's LOOK does not: the result is themed by
47
50
  decklight. Anything that cannot cross is named on stderr with its slide
48
51
  number, so you know what to rebuild by hand.
49
52
 
@@ -183,9 +186,9 @@ export function convert(zip, { build = 'auto' } = {}) {
183
186
  const bytes = zip.get(p);
184
187
  return bytes ? { bytes, mime: mimeOf(p) } : null;
185
188
  },
189
+ chartOf: (target) => zip.get(resolvePart(slidePath, target))?.toString() ?? null,
186
190
  });
187
191
  n += 1;
188
- if (slide.hidden) { report.push({ n, hidden: true, title: slide.title }); continue; }
189
192
 
190
193
  const notesRel = [...rels.values()].find((r) => r.type.endsWith('/notesSlide'));
191
194
  const notes = notesRel
@@ -193,16 +196,20 @@ export function convert(zip, { build = 'auto' } = {}) {
193
196
  : [];
194
197
  const { html, did } = slideSection(slide, notes, { build });
195
198
  sections.push(html);
196
- report.push({ n, title: slide.title, did, drops: slide.drops });
199
+ // PowerPoint's hidden slide is decklight's (HIDDEN_SLIDES): kept, numbered,
200
+ // marked — never thrown away on the way in. One report row either way.
201
+ report.push({ n, title: slide.title, did, drops: slide.drops, ...(slide.hidden ? { hidden: true } : {}) });
197
202
  }
198
203
  if (!sections.length) throw new Error('every slide in this file is hidden — nothing to import');
199
204
  return { sections, report };
200
205
  }
201
206
 
202
207
  /** The self-contained deck, runtime and theme inlined — the `init` output shape. */
203
- export function deckHtml(sections, { title, theme }) {
208
+ export function deckHtml(sections, { title, theme, themeCss = null }) {
204
209
  const css = runtimeCss();
205
- const theme_ = shippedThemeCss(theme);
210
+ // `themeCss` is a theme that is not shipped — the one derived from the
211
+ // template's own palette and fonts (tools/template-theme.mjs)
212
+ const theme_ = themeCss ?? shippedThemeCss(theme);
206
213
  // runtimeJs() applies the SAME transform init/upgrade/bundle use and audit
207
214
  // recomputes. This used to be a local escape that missed `<!--`, which made
208
215
  // every imported deck audit as "runtime DIFFERS from this install's build".
@@ -270,7 +277,10 @@ export async function importMain(args = []) {
270
277
  const source = args.find((a, i) => !a.startsWith('-') && !VALUE.has(args[i - 1]));
271
278
  if (!source) { console.error(`decklight import: needs a file or a Google Slides URL\n\n${USAGE}`); return 1; }
272
279
 
273
- const theme = opt('--theme', 'midnight');
280
+ const themeFlag = opt('--theme', 'midnight');
281
+ const wantTemplate = themeFlag === 'template';
282
+ let theme = wantTemplate ? 'midnight' : themeFlag;
283
+ let themeCss = null;
274
284
  if (!existsSync(join(THEMES_DIR, `${theme}.css`))) {
275
285
  const all = readdirSync(THEMES_DIR).filter((f) => f.endsWith('.css')).map((f) => f.replace(/\.css$/, ''));
276
286
  console.error(`decklight import: no theme "${theme}"`);
@@ -359,7 +369,26 @@ export async function importMain(args = []) {
359
369
  // ---- convert ----------------------------------------------------------
360
370
  let result;
361
371
  try {
362
- result = convert(unzip(bytes), { build });
372
+ const zip = unzip(bytes);
373
+ result = convert(zip, { build });
374
+ // The template's palette and fonts — most of what "our template" means —
375
+ // are in ppt/theme/theme1.xml. Derived only when asked, because the
376
+ // default (a shipped theme) is what every existing import produced.
377
+ const themePart = [...zip.keys()].find((k) => /^ppt\/theme\/theme\d*\.xml$/.test(k));
378
+ if (wantTemplate) {
379
+ const parsed = themePart ? parseTemplateTheme(zip.get(themePart).toString()) : null;
380
+ const derived = parsed ? themeFromTemplate(parsed) : null;
381
+ if (derived?.ok) {
382
+ theme = derived.name; themeCss = derived.css;
383
+ console.error(` theme: ${derived.name} — derived from the template's palette and fonts`
384
+ + `${parsed.fonts.heading || parsed.fonts.body ? ` (${[parsed.fonts.heading, parsed.fonts.body].filter(Boolean).join(' / ')})` : ''}`);
385
+ } else {
386
+ console.error(` theme: ${!themePart ? 'this file carries no theme part' : !parsed ? 'the theme part has no colour scheme' : `the derived theme failed its contrast gates: ${derived.errors[0]}`}`
387
+ + ' — opening in midnight instead');
388
+ }
389
+ } else if (themePart) {
390
+ console.error(' this file carries a theme — `--theme template` imports its palette and fonts');
391
+ }
363
392
  } catch (e) {
364
393
  console.error(`decklight import: ${e.message}`);
365
394
  return 1;
@@ -372,7 +401,7 @@ export async function importMain(args = []) {
372
401
  for (const row of result.report) {
373
402
  if (row.hidden) {
374
403
  const t = decodeEntities((row.title ?? '').replace(/<[^>]+>/g, ''));
375
- console.error(` ${String(row.n).padStart(3)} ⊘ hidden slide skipped${t ? ` — ${t}` : ''}`);
404
+ console.error(` ${String(row.n).padStart(3)} ⊘ hidden — kept as data-hidden${t ? ` — ${t}` : ''}`);
376
405
  continue;
377
406
  }
378
407
  // the title is HTML by now; the terminal wants the words back
@@ -387,9 +416,10 @@ export async function importMain(args = []) {
387
416
  }
388
417
 
389
418
  const title = basename(out).replace(/\.html$/, '').replace(/-/g, ' ').replace(/^./, (c) => c.toUpperCase());
390
- writeFileSync(out, deckHtml(result.sections, { title, theme }));
419
+ writeFileSync(out, deckHtml(result.sections, { title, theme, themeCss }));
391
420
  const kb = Math.round(readFileSync(out).length / 1024);
392
- console.error(`${out} · ${result.sections.length} slides · theme ${theme} · ${kb} KB`
421
+ const hiddenCount = result.report.filter((r) => r.hidden).length;
422
+ console.error(`${out} · ${result.sections.length} slides${hiddenCount ? ` (${hiddenCount} hidden)` : ''} · theme ${theme} · ${kb} KB`
393
423
  + (dropped ? ` · ${dropped} thing(s) dropped — see ⚠ above` : ''));
394
424
  if (!verbose && !dropped) console.error(' everything converted; -v lists each slide');
395
425
  return 0;
package/cli/pdf.mjs CHANGED
@@ -18,17 +18,40 @@
18
18
  // URL reads those back and names them on stderr. A clipped slide in a PDF you
19
19
  // have already emailed is a slide nobody can fix.
20
20
 
21
- import { execFileSync } from 'node:child_process';
22
21
  import { existsSync, readFileSync, rmSync, statSync } from 'node:fs';
23
22
  import { basename, resolve } from 'node:path';
24
23
  import { chromeBin, chromeArgs } from '../tools/chrome.mjs';
25
24
  import { argReader, isMain } from '../tools/args.mjs';
25
+ import { run, CODEC_MS } from '../tools/exec.mjs';
26
+ import { sectionBodies, isHiddenSection } from '../tools/deck-html.mjs';
27
+
28
+ /**
29
+ * How many slides the handout puts on a page — the runtime's own number,
30
+ * RESTATED rather than imported.
31
+ *
32
+ * `src/core/print.js` exports it and this file used to import it, which works
33
+ * in a clone and cannot work in an install: the package ships `cli/`, `tools/`,
34
+ * `dist/`, `themes/` and `docs/` — never `src/`, whose only shipped form is the
35
+ * bundle. `npm test` and `npm run verify` both drive the CLI out of the working
36
+ * tree, so both were green while `decklight pdf` was a `Cannot find module` for
37
+ * everyone who had installed it. `npm run soak` caught it at step 40.
38
+ *
39
+ * The pair is kept honest by test/pdf.test.mjs, which reads the number out of
40
+ * both sources and fails when they drift — the same shape as the harness list
41
+ * that verify.mjs spells out for tools/test-impact.mjs.
42
+ */
43
+ export const HANDOUT_PER_PAGE = 3;
26
44
 
27
45
  const USAGE = `usage: decklight pdf <deck.html> [-o out.pdf] [--theme <name>] [--wait <ms>]
46
+ [--notes | --handout]
28
47
  renders the deck's ?print view to a PDF — one slide per page, at the deck's
29
48
  own 1280×720, in its theme, with every build complete
30
49
 
31
50
  -o <file> output path [the deck's, with .pdf]
51
+ --notes one slide per page with its speaker notes underneath —
52
+ the presenter's copy [out: <deck>.notes.pdf]
53
+ --handout three slides a page, portrait, ruled lines beside each for
54
+ the audience to write on [out: <deck>.handout.pdf]
32
55
  --theme <name> export in another theme (rides ?theme=)
33
56
  --wait <ms> render budget for heavy decks [8000]
34
57
 
@@ -36,20 +59,32 @@ const USAGE = `usage: decklight pdf <deck.html> [-o out.pdf] [--theme <name>] [-
36
59
  is still written (a clipped slide is worth knowing about, not worth refusing)`;
37
60
 
38
61
  /** The deck's path with .pdf in place of .html — or whatever -o said. */
39
- export function pdfOut(deckPath, oFlag) {
62
+ export function pdfOut(deckPath, oFlag, variant = '') {
40
63
  if (oFlag) return resolve(oFlag);
41
- return resolve(deckPath.replace(/\.html?$/i, '') + '.pdf');
64
+ // a variant gets its own name, so the handout never overwrites the slides
65
+ return resolve(deckPath.replace(/\.html?$/i, '') + (variant ? `.${variant}` : '') + '.pdf');
42
66
  }
43
67
 
44
68
  /**
45
69
  * The URL to print. `?print` is the whole rendering contract; `?theme=` is the
46
70
  * existing startup override, so exporting in another theme costs nothing here.
47
71
  */
48
- export function printUrl(absDeckPath, { theme } = {}) {
49
- const q = theme ? `?print&theme=${encodeURIComponent(theme)}` : '?print';
72
+ export function printUrl(absDeckPath, { theme, variant = '' } = {}) {
73
+ // `?print=notes` / `?print=handout` are the runtime's own variants (src/core/print.js)
74
+ const print = variant ? `?print=${variant}` : '?print';
75
+ const q = theme ? `${print}&theme=${encodeURIComponent(theme)}` : print;
50
76
  return `file://${absDeckPath}${q}`;
51
77
  }
52
78
 
79
+ /**
80
+ * How many pages the PDF should have: one per slide, except the handout,
81
+ * which groups HANDOUT_PER_PAGE to a page — the same number print.js
82
+ * paginates with, held to it by a test rather than by an import.
83
+ */
84
+ export function expectedPages(slides, variant = '') {
85
+ return variant === 'handout' ? Math.ceil(slides / HANDOUT_PER_PAGE) : slides;
86
+ }
87
+
53
88
  /**
54
89
  * How many pages Chrome actually wrote.
55
90
  *
@@ -95,7 +130,7 @@ export const overflowSlides = (html) => flaggedSlides(html, 'data-overflow');
95
130
  export const splitConflictSlides = (html) => flaggedSlides(html, 'data-split-conflict');
96
131
 
97
132
  /** Slides in the printed deck — the number the page count should equal. */
98
- export const slideCount = (html) => (html.match(/<section\b/g) ?? []).length;
133
+ export const slideCount = (html) => sectionBodies(html).filter((b) => !isHiddenSection(b)).length;
99
134
 
100
135
  const KB = (n) => (n < 1024 * 1024 ? `${Math.round(n / 1024)} KB` : `${(n / 1048576).toFixed(1)} MB`);
101
136
 
@@ -107,10 +142,15 @@ export async function pdfMain(args = []) {
107
142
  const src = resolve(deck);
108
143
  if (!existsSync(src)) { console.error(`decklight pdf: no such deck: ${deck}`); return 1; }
109
144
 
110
- const out = pdfOut(src, opt('-o'));
145
+ const variant = args.includes('--notes') ? 'notes' : args.includes('--handout') ? 'handout' : '';
146
+ if (args.includes('--notes') && args.includes('--handout')) {
147
+ console.error('decklight pdf: --notes and --handout are two different PDFs — run it twice');
148
+ return 1;
149
+ }
150
+ const out = pdfOut(src, opt('-o'), variant);
111
151
  const theme = opt('--theme');
112
152
  const wait = Number(opt('--wait', 8000));
113
- const url = printUrl(src, { theme });
153
+ const url = printUrl(src, { theme, variant });
114
154
  const bin = chromeBin('pdf');
115
155
  // file:// decks load their runtime, themes and casts as siblings
116
156
  const shared = chromeArgs('--allow-file-access-from-files', `--virtual-time-budget=${wait}`);
@@ -120,17 +160,17 @@ export async function pdfMain(args = []) {
120
160
  // about to hide.
121
161
  let html = '';
122
162
  try {
123
- html = execFileSync(bin, [...shared, '--dump-dom', url],
124
- { encoding: 'utf8', maxBuffer: 64 * 1024 * 1024, stdio: ['ignore', 'pipe', 'ignore'] });
163
+ html = run(bin, [...shared, '--dump-dom', url],
164
+ { encoding: 'utf8', maxBuffer: 64 * 1024 * 1024, stdio: ['ignore', 'pipe', 'ignore'], timeout: CODEC_MS, why: 'Chrome did not finish rendering — a slide is probably waiting on a resource it cannot reach' });
125
165
  } catch { /* the print pass below is the one that must succeed */ }
126
166
  const slides = slideCount(html);
127
- console.error(`pdf: rendering ${basename(src)}?print${theme ? ` · theme ${theme}` : ''}`
167
+ console.error(`pdf: rendering ${basename(src)}?print${variant ? `=${variant}` : ''}${theme ? ` · theme ${theme}` : ''}`
128
168
  + `${slides ? ` — ${slides} slides, builds complete, casts expanded` : ''}`);
129
169
 
130
170
  rmSync(out, { force: true }); // never leave a stale PDF looking like a fresh one
131
171
  try {
132
- execFileSync(bin, [...shared, '--no-pdf-header-footer', `--print-to-pdf=${out}`, url],
133
- { stdio: ['ignore', 'ignore', 'ignore'] });
172
+ run(bin, [...shared, '--no-pdf-header-footer', `--print-to-pdf=${out}`, url],
173
+ { stdio: ['ignore', 'ignore', 'ignore'], timeout: CODEC_MS, why: 'Chrome did not finish rendering — a slide is probably waiting on a resource it cannot reach' });
134
174
  } catch (e) {
135
175
  console.error(`decklight pdf: Chrome failed — ${String(e.message ?? e).split('\n')[0]}`);
136
176
  return 1;
@@ -149,7 +189,12 @@ export async function pdfMain(args = []) {
149
189
  }
150
190
  const buf = readFileSync(out);
151
191
  const pages = pdfPageCount(buf);
152
- console.log(`${out} · ${pages || '?'} pages · 1280×720 (16:9) · ${KB(buf.length)}`);
192
+ const want = slides ? expectedPages(slides, variant) : 0;
193
+ const geometry = variant === 'handout' ? 'portrait, 3 slides a page' : variant === 'notes' ? 'slide + notes per page' : '1280×720 (16:9)';
194
+ console.log(`${out} · ${pages || '?'} pages · ${geometry} · ${KB(buf.length)}`);
195
+ if (want && pages && pages !== want) {
196
+ console.error(`pdf: ⚠ expected ${want} pages for ${slides} slides${variant ? ` (${variant})` : ''}, got ${pages}`);
197
+ }
153
198
  return 0;
154
199
  }
155
200
 
@@ -0,0 +1,107 @@
1
+ // Copyright 2026 Gilles Philippart
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // decklight pptx — a deck as a PowerPoint file, lossy on purpose.
5
+ //
6
+ // Each slide is rendered by a one-shot headless Chrome at its own 1280×720
7
+ // with every build complete (the mechanism tools/video.mjs and tools/shot.mjs
8
+ // use), and becomes one picture filling one 16:9 page; the speaker notes ride
9
+ // along as real notes. Nothing round-trips — see tools/pptx-write.mjs for why
10
+ // that is the design and not a gap.
11
+
12
+ import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync, statSync } from 'node:fs';
13
+ import { tmpdir } from 'node:os';
14
+ import { basename, join, relative, resolve, sep } from 'node:path';
15
+ import { chromeBin, chromeArgs } from '../tools/chrome.mjs';
16
+ import { argReader } from '../tools/args.mjs';
17
+ import { run, CODEC_MS } from '../tools/exec.mjs';
18
+ import { NOTES_ASIDE, cleanNotes, sectionBodies } from '../tools/deck-html.mjs';
19
+ import { buildPptx } from '../tools/pptx-write.mjs';
20
+ import { serveForRender } from './present.mjs';
21
+
22
+ const USAGE = `usage: decklight pptx <deck.html> [-o out.pptx] [--theme <name>] [--wait <ms>]
23
+ writes a PowerPoint file: every slide as a picture, rendered at 1280×720 with
24
+ its builds complete, and its speaker notes as real notes
25
+
26
+ -o <file> output path [the deck's, with .pptx]
27
+ --theme <name> export in another theme (rides ?theme=)
28
+ --wait <ms> render budget per slide [1500]
29
+
30
+ Lossy by design: the file OPENS in PowerPoint, Keynote and Slides, and the
31
+ notes are text there — but the slides are pictures. Import it back and you
32
+ get pictures. Decklight is for people who never liked PowerPoint; this is
33
+ for the people around them who still ask for the file.`;
34
+
35
+ /** The deck's path with .pptx in place of .html — or whatever -o said. */
36
+ export const pptxOut = (deckPath, oFlag) => (oFlag ? resolve(oFlag) : resolve(deckPath.replace(/\.html?$/i, '') + '.pptx'));
37
+
38
+ /**
39
+ * Speaker notes per slide, as lines. Paragraphs and line breaks become lines,
40
+ * tags fall away, entities come back — the same reading the voiceover and
41
+ * the speaker view give the aside, so what PowerPoint shows is what the
42
+ * presenter saw.
43
+ */
44
+ export function notesLines(html) {
45
+ return sectionBodies(html).map((sec) => {
46
+ const m = sec.match(NOTES_ASIDE);
47
+ if (!m) return [];
48
+ return m[1].split(/<\/p>|<br\s*\/?>|\n{2,}/i).map((part) => cleanNotes(part)).filter(Boolean);
49
+ });
50
+ }
51
+
52
+ /** The deck's <title>, else its file name. */
53
+ const titleOf = (html, file) => cleanNotes(/<title>([\s\S]*?)<\/title>/i.exec(html)?.[1] ?? '') || basename(file).replace(/\.html?$/i, '');
54
+
55
+ async function chromeShot(bin, argv) {
56
+ run(bin, argv, { maxBuffer: 32 * 1024 * 1024, timeout: CODEC_MS, why: 'Chrome did not finish rendering a slide — it is probably waiting on a resource it cannot reach' });
57
+ }
58
+
59
+ export async function pptxMain(args = [], { render = chromeShot, log = console.error } = {}) {
60
+ if (args.includes('--help') || args.includes('-h')) { console.log(USAGE); return 0; }
61
+ const { opt } = argReader(args);
62
+ const deck = args.find((a) => !a.startsWith('-') && /\.html?$/i.test(a));
63
+ if (!deck) { log(`decklight pptx: needs a deck\n\n${USAGE}`); return 1; }
64
+ const src = resolve(deck);
65
+ if (!existsSync(src)) { log(`decklight pptx: no such deck: ${deck}`); return 1; }
66
+ const root = process.cwd();
67
+ if (src !== root && !src.startsWith(root + sep)) {
68
+ log(`decklight pptx: the deck must live under the current directory (${root}) — cd there first`);
69
+ return 1;
70
+ }
71
+ const out = pptxOut(src, opt('-o'));
72
+ const wait = Number(opt('--wait', 1500));
73
+ const theme = opt('--theme');
74
+ const html = readFileSync(src, 'utf8');
75
+ const notes = notesLines(html);
76
+ const count = notes.length;
77
+ if (!count) { log('decklight pptx: the deck has no <section> slides'); return 1; }
78
+
79
+ // served, not file://, so every relative asset the deck names still resolves
80
+ const inject = (text, file) => (file === src && theme ? text.replace(/(<\/head>)/i, `<link rel="stylesheet" href="themes/${theme}.css">$1`) : text);
81
+ const server = await serveForRender(root, { html: inject });
82
+ const scratch = mkdtempSync(join(tmpdir(), 'decklight-pptx-'));
83
+ const slides = [];
84
+ try {
85
+ const deckPath = '/' + relative(root, src).split(sep).join('/');
86
+ const bin = chromeBin('pptx');
87
+ log(`pptx: rendering ${basename(src)} — ${count} slides at 1280×720, builds complete`);
88
+ for (let n = 1; n <= count; n++) {
89
+ const png = join(scratch, `slide-${n}.png`);
90
+ // /999 lands on the last build step, whatever the slide has
91
+ await render(bin, chromeArgs(
92
+ '--hide-scrollbars', '--window-size=1280,720', `--virtual-time-budget=${wait}`,
93
+ `--screenshot=${png}`, `${server.origin}${deckPath}#/${n}/999`,
94
+ ), { n, png });
95
+ if (!existsSync(png) || statSync(png).size === 0) { log(`decklight pptx: slide ${n} did not render — try a longer --wait`); return 1; }
96
+ slides.push({ png: readFileSync(png), notes: notes[n - 1] });
97
+ }
98
+ } finally {
99
+ await server.close();
100
+ rmSync(scratch, { recursive: true, force: true });
101
+ }
102
+ const bytes = buildPptx(slides, { title: titleOf(html, src) });
103
+ writeFileSync(out, bytes);
104
+ const withNotes = notes.filter((l) => l.length).length;
105
+ console.log(`${out} · ${count} slides as pictures · ${withNotes} with notes · ${Math.round(bytes.length / 1024)} KB`);
106
+ return 0;
107
+ }
package/cli/present.mjs CHANGED
@@ -34,7 +34,7 @@ import { randomBytes } from 'node:crypto';
34
34
  import { argReader, isMain } from '../tools/args.mjs';
35
35
  import { allowRemote, lanAddress, staticFiles, sseChannel, listenTakingOverIfNeeded, withHeaders, isOwnOrigin } from './serve.mjs';
36
36
  import { createRemoteRelay } from './remote.mjs';
37
- import { corsHeaders } from '../tools/bridge.mjs';
37
+ import { corsHeaders, readBody } from '../tools/bridge.mjs';
38
38
 
39
39
  // The phone is a different origin from the deck (a LAN address, not localhost),
40
40
  // so the remote's own endpoints need CORS. Nothing else here does — the deck is
@@ -749,8 +749,12 @@ export async function presentMain(args, { client } = {}) {
749
749
  // writes anything — the phone asks the deck to move, it never edits.
750
750
  let body = '';
751
751
  if (req.method === 'POST') {
752
- req.on('data', (c) => { body += c; if (body.length > 4096) req.destroy(); });
753
- req.on('end', () => {
752
+ // bridge.mjs's reader with the cap this route has always had: the phone
753
+ // remote is the one path reachable from off this machine, and a body
754
+ // past 4 KB is a probe, not a request — the socket is destroyed and the
755
+ // E2BIG never becomes a response
756
+ readBody(req, { max: 4096 }).then((bytes) => {
757
+ body = bytes.toString();
754
758
  try {
755
759
  if (relay.handle(req, res, url, body)) return;
756
760
  } catch {
@@ -760,7 +764,7 @@ export async function presentMain(args, { client } = {}) {
760
764
  }
761
765
  res.writeHead(405);
762
766
  res.end('method not allowed');
763
- });
767
+ }).catch(() => { /* E2BIG: destroyed above; anything else: the socket is gone */ });
764
768
  return;
765
769
  }
766
770
  if (relay.handle(req, res, url, '')) return;
package/cli/publish.mjs CHANGED
@@ -7,7 +7,8 @@
7
7
  *
8
8
  * decklight publish <deck.html> [--branch gh-pages] [--remote origin]
9
9
  * [--no-bundle] [--no-sign] [--path <subdir>]
10
- * [--target gh-pages|netlify|vercel]
10
+ * [--target gh-pages|netlify|vercel|folder]
11
+ [--out <dir> [--url <public-url>]]
11
12
  *
12
13
  * Bundles the deck (via `decklight bundle`) to index.html + .nojekyll and
13
14
  * pushes them to a gh-pages branch on the remote, then prints the GitHub
@@ -87,9 +88,12 @@ Options:
87
88
  is the file a visitor downloads and forwards
88
89
  --path <subdir> publish under a subdirectory of the site (other content
89
90
  on the branch is preserved)
90
- --target <name> gh-pages (default, no credential) | netlify | vercel
91
+ --target <name> gh-pages (default, no credential) | netlify | vercel | folder
91
92
  netlify needs NETLIFY_AUTH_TOKEN + NETLIFY_SITE_ID
92
93
  vercel needs VERCEL_TOKEN + VERCEL_PROJECT (+ VERCEL_TEAM_ID)
94
+ folder writes the site into --out <dir> (or DECKLIGHT_PUBLISH_DIR)
95
+ for ANY static host — rsync it, S3-sync it, drop it on a share;
96
+ --url <base> (or DECKLIGHT_PUBLISH_URL) is printed as the link
93
97
 
94
98
  Publishing SIGNS by default: Sigstore keyless mints a short-lived certificate
95
99
  against an OIDC identity — the ambient token in CI (GitHub Actions
@@ -117,6 +121,10 @@ for (let i = 0; i < argv.length; i++) {
117
121
  else if (a === '--deck') deckFile = true;
118
122
  else if (a === '--path') subdir = argv[++i];
119
123
  else if (a === '--target') target = argv[++i];
124
+ // the folder target's two answers, as flags — a directory is not a secret,
125
+ // and typing it beats exporting an environment variable for a one-off
126
+ else if (a === '--out') process.env.DECKLIGHT_PUBLISH_DIR = argv[++i];
127
+ else if (a === '--url') process.env.DECKLIGHT_PUBLISH_URL = argv[++i];
120
128
  else if (!a.startsWith('-') && !deck) deck = a;
121
129
  else fail(`unknown argument: ${a}`);
122
130
  }
package/cli/record.mjs CHANGED
@@ -7,7 +7,7 @@
7
7
  // decklight record <deck.html> [--port 8788] [--dir voiceover] [--no-open]
8
8
  //
9
9
  // WHY THIS IS A COMMAND AND NOT JUST A KEY. The recorder itself lives in the
10
- // deck (⇧R): it has to, because the notes, the builds and the microphone are
10
+ // deck (V → Record this deck… → With your voice…): it has to, because the notes, the builds and the microphone are
11
11
  // all in the browser. But a browser will not open a microphone for a page it
12
12
  // loaded from `file://` — getUserMedia needs a secure context, and a local file
13
13
  // is not one, no matter how many times you click Allow. `http://127.0.0.1` IS
@@ -50,7 +50,7 @@ const USAGE = `usage: decklight record <deck.html> [--port 8788] [--dir voiceove
50
50
  narration: { files: '<dir>', ext: 'wav', segments: true }
51
51
 
52
52
  a microphone needs a secure context, which is why this serves the deck rather
53
- than opening the file — and why ⇧R on a file:// deck says so instead of failing
53
+ than opening the file — and why the recorder on a file:// deck says so instead of failing
54
54
  `;
55
55
 
56
56
  /**
@@ -141,7 +141,7 @@ export async function recordMain(args, { open = openUrl, out = process.stdout, o
141
141
 
142
142
  const url = recordUrl(started.port, started.deckUrl, dir, slides);
143
143
  out.write(`decklight record on ${url}\n`);
144
- out.write(' ⇧R opens the recorder · → ends a beat and reveals the next build · Esc stops\n');
144
+ out.write(' V → Record this deck… → With your voice… opens the recorder · → ends a beat and reveals the next build · Esc stops\n');
145
145
  out.write(` files land in ${dir ?? "the deck's narration folder"}, next to the deck.`
146
146
  + `${slides ? ` Only slide${/-/.test(slides) ? 's' : ''} ${slides}.` : ''} Ctrl-C when you are done.\n`);
147
147
  if (!args.includes('--no-open')) await open(url, { out, what: url });
@@ -75,6 +75,7 @@ with a build and notes already wired):
75
75
  - \`decklight cast script.term.yaml\` — record a truthful terminal cast in a real PTY, for \`<div class="terminal">\` (this records a TERMINAL; \`decklight record\` records the author's voice)
76
76
  - \`decklight bundle deck.html --themes all\` — flatten into one self-contained file to hand off or publish
77
77
  - \`decklight pdf deck.html\` — render every slide to a PDF, and report the ones that overflow
78
+ - \`decklight pptx deck.html\` — a PowerPoint file for whoever asks for one: every slide a picture, the notes real notes (lossy on purpose)
78
79
  - \`decklight tts\` — live voice bridge so the deck can narrate itself on the fly
79
80
  - \`decklight record deck.html\` — record the narration in the author's OWN voice: the deck shows one \`⟨CLICK⟩\` beat at a time and \`→\` ends it, writing \`slide-NN-KK.wav\` per beat so the recording paces the builds (play it back with \`narration: { files: 'voiceover', ext: 'wav', segments: true }\`)
80
81
  - \`decklight review deck.html\` / \`decklight comments deck.html\` — reviewer comments on slides, stored append-only in \`<deck>.review.jsonl\` and carried by git; a comment records the slide's title and a fingerprint of its text, so it finds its slide again after the deck moves and says so when the slide changed or is gone; \`decklight review submit deck.html\` pushes the review to a \`review/<you>-<date>\` branch (one file, never the reviewer's own commits; \`--pr\` opens the pull request), and the author hears about waiting reviews at \`decklight author\` startup, in the M overlay, and via \`decklight comments deck.html --incoming\`
@@ -1 +1 @@
1
- {"tag":"0.7.0","commits":0,"commit":"6575588","dirty":false}
1
+ {"tag":"0.8.0","commits":0,"commit":"56f6289","dirty":false}
@@ -1167,6 +1167,14 @@
1167
1167
  /* 16:9 cells: the row height is set explicitly by layoutOverview() from the
1168
1168
  resolved column width — intrinsic tricks (aspect-ratio, %-padding spacers)
1169
1169
  contribute nothing to auto row sizing here and the rows collapse. */
1170
+ /* A hidden slide (data-hidden, DECK_ANATOMY) is dimmed in the overview and
1171
+ badged, never removed: the overview is where an author finds it to unhide. */
1172
+ .decklight-overview-grid .ov-cell.ov-hidden { opacity: 0.38; }
1173
+ .decklight-overview-grid .ov-cell.ov-hidden::after {
1174
+ content: 'hidden'; position: absolute; top: 6px; left: 8px; z-index: 2;
1175
+ font: 600 11px/1 system-ui, sans-serif; letter-spacing: 0.06em; text-transform: uppercase;
1176
+ padding: 3px 6px; border-radius: 4px; background: var(--fg); color: var(--bg);
1177
+ }
1170
1178
  .decklight-overview-grid .ov-cell {
1171
1179
  position: relative;
1172
1180
  cursor: pointer;
@@ -1866,6 +1874,8 @@
1866
1874
  width: auto !important;
1867
1875
  height: auto !important;
1868
1876
  }
1877
+ /* hidden slides get no page unless ?all asked for them */
1878
+ .decklight.decklight-print:not(.decklight-show-hidden) > .decklight-stage > section[data-hidden] { display: none; }
1869
1879
  .decklight.decklight-print > .decklight-stage > section {
1870
1880
  display: flex;
1871
1881
  position: relative;