decklight 0.8.0 → 0.9.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/PLATFORM.md +666 -0
- package/README.md +224 -150
- package/SPEC.md +732 -886
- package/cli/agent-review.mjs +245 -0
- package/cli/agents.mjs +25 -5
- package/cli/associate.mjs +12 -12
- package/cli/audit.mjs +42 -10
- package/cli/banner.mjs +41 -17
- package/cli/bundle-audio.mjs +183 -0
- package/cli/bundle.mjs +383 -31
- package/cli/cast.mjs +7 -7
- package/cli/check.mjs +961 -0
- package/cli/clone-deck.mjs +179 -0
- package/cli/commands.mjs +345 -0
- package/cli/comments.mjs +64 -18
- package/cli/commit-flow.mjs +44 -19
- package/cli/commit-message.mjs +51 -74
- package/cli/commit-split.mjs +601 -0
- package/cli/deck-refs.mjs +59 -0
- package/cli/deck-routes.mjs +67 -0
- package/cli/deckfile.mjs +3 -5
- package/cli/decklight.mjs +68 -289
- package/cli/design-system-deps.mjs +209 -0
- package/cli/design-system-edit.mjs +194 -0
- package/cli/design-system-refs.mjs +409 -0
- package/cli/design-system.mjs +429 -0
- package/cli/doctor.mjs +115 -0
- package/cli/edit-git.mjs +353 -0
- package/cli/edit-handover.mjs +445 -0
- package/cli/edit-look.mjs +388 -0
- package/cli/edit-slides.mjs +683 -0
- package/cli/edit.mjs +2126 -842
- package/cli/enhance.mjs +483 -0
- package/cli/extension.mjs +10 -10
- package/cli/font-refs.mjs +273 -0
- package/cli/font.mjs +246 -0
- package/cli/git-tree.mjs +1 -1
- package/cli/git.mjs +65 -11
- package/cli/import.mjs +56 -10
- package/cli/init.mjs +400 -234
- package/cli/library.mjs +127 -0
- package/cli/loader.mjs +3 -1
- package/cli/marketplace.mjs +215 -21
- package/cli/narrate.mjs +176 -0
- package/cli/open-browser.mjs +63 -0
- package/cli/open.mjs +943 -0
- package/cli/pdf.mjs +41 -13
- package/cli/pkg.mjs +44 -2
- package/cli/plugin.mjs +43 -41
- package/cli/port-conflict.mjs +53 -23
- package/cli/pptx-export.mjs +71 -26
- package/cli/publish.mjs +8 -4
- package/cli/qr.mjs +1 -1
- package/cli/record.mjs +14 -12
- package/cli/remote.mjs +11 -11
- package/cli/restore.mjs +11 -4
- package/cli/review-ref.mjs +125 -0
- package/cli/review-remote.mjs +92 -48
- package/cli/review-routes.mjs +254 -0
- package/cli/review-store.mjs +47 -7
- package/cli/review-submit.mjs +47 -57
- package/cli/runtime-link.mjs +560 -0
- package/cli/serve.mjs +235 -44
- package/cli/setup.mjs +112 -0
- package/cli/sign.mjs +1 -1
- package/cli/skill-content.mjs +190 -33
- package/cli/skills.mjs +107 -24
- package/cli/start.mjs +110 -0
- package/cli/supervise.mjs +6 -6
- package/cli/theme-refs.mjs +515 -0
- package/cli/theme.mjs +181 -137
- package/cli/trust.mjs +83 -0
- package/cli/units.mjs +39 -42
- package/cli/update-check.mjs +1 -5
- package/cli/upgrade.mjs +194 -28
- package/cli/upstream.mjs +4 -3
- package/cli/util.mjs +4 -4
- package/cli/wizard.mjs +6 -6
- package/dist/build-info.json +1 -1
- package/dist/decklight.css +1126 -49
- package/dist/decklight.js +212 -115
- package/dist/decklight.js.map +4 -4
- package/docs/GLOSSARY.md +141 -0
- package/docs/architecture.svg +17 -17
- package/package.json +4 -2
- package/themes/README.md +9 -8
- package/themes/reveal-solarized.css +10 -0
- package/tools/args.mjs +20 -0
- package/tools/atomic-write.mjs +48 -0
- package/tools/brand-palette.mjs +717 -0
- package/tools/bridge.mjs +1 -1
- package/tools/build-groups.mjs +42 -0
- package/tools/color.mjs +48 -0
- package/tools/deck-html.mjs +396 -11
- package/tools/design-system-format.mjs +753 -0
- package/tools/elevenlabs-tts.mjs +110 -17
- package/tools/exec.mjs +35 -2
- package/tools/extension-check.mjs +31 -7
- package/tools/font-format.mjs +190 -0
- package/tools/font-stacks.mjs +24 -0
- package/tools/gemini-tts.mjs +3 -0
- package/tools/lipsync-config.mjs +103 -0
- package/tools/lipsync-engines.mjs +205 -2
- package/tools/lipsync-server.mjs +264 -41
- package/tools/lipsync.mjs +37 -18
- package/tools/local-voice.mjs +32 -42
- package/tools/narration-manifest.mjs +196 -0
- package/tools/narration-synth.mjs +416 -0
- package/tools/pptx.mjs +776 -19
- package/tools/publish-targets.mjs +1 -1
- package/tools/publish-voices.mjs +3 -3
- package/tools/recording-impact.mjs +7 -3
- package/tools/render-theme.mjs +33 -0
- package/tools/review-anchor.mjs +28 -12
- package/tools/semver.mjs +40 -0
- package/tools/sentences.mjs +180 -0
- package/tools/shot.mjs +14 -7
- package/tools/site-voices.mjs +232 -0
- package/tools/template-theme.mjs +1 -1
- package/tools/test-impact.mjs +19 -10
- package/tools/theme-check.mjs +30 -3
- package/tools/tts-cache.mjs +4 -3
- package/tools/tts-engines.mjs +38 -20
- package/tools/tts-setup.mjs +7 -7
- package/tools/video-options.mjs +34 -0
- package/tools/video.mjs +461 -48
- package/tools/voiceover-server.mjs +185 -104
- package/tools/voiceover.mjs +119 -261
- package/tools/zip.mjs +1 -1
- package/cli/dev.mjs +0 -623
- package/cli/present.mjs +0 -853
- package/cli/review.mjs +0 -361
- package/tools/publish-site-voices.mjs +0 -75
package/cli/pptx-export.mjs
CHANGED
|
@@ -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 {
|
|
18
|
-
import {
|
|
17
|
+
import { renderThemeParams } from '../tools/render-theme.mjs';
|
|
18
|
+
import { runAsync, CODEC_MS } from '../tools/exec.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 './
|
|
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
|
|
@@ -52,45 +58,83 @@ export function notesLines(html) {
|
|
|
52
58
|
/** The deck's <title>, else its file name. */
|
|
53
59
|
const titleOf = (html, file) => cleanNotes(/<title>([\s\S]*?)<\/title>/i.exec(html)?.[1] ?? '') || basename(file).replace(/\.html?$/i, '');
|
|
54
60
|
|
|
55
|
-
|
|
56
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Chrome, ASYNC — `runAsync`, never `run`.
|
|
63
|
+
*
|
|
64
|
+
* The deck is served from THIS process (serveForRender, PRESENTING) so that a
|
|
65
|
+
* relative asset still resolves and the CSP is the one `--no-trust` applies. A
|
|
66
|
+
* synchronous child blocks the event loop, so the server never answers the
|
|
67
|
+
* browser it just launched: Chrome waits for a first byte that cannot arrive
|
|
68
|
+
* until Chrome exits. 0.8.0 shipped exactly that — every `decklight pptx`
|
|
69
|
+
* stalled for the full five-minute budget and then reported a hang whose real
|
|
70
|
+
* cause was one import. tools/shot.mjs carries the same warning above the same
|
|
71
|
+
* call; test/pptx-render.mjs is what now notices.
|
|
72
|
+
*/
|
|
73
|
+
export async function chromeShot(bin, argv, _ctx, { timeout = CODEC_MS } = {}) {
|
|
74
|
+
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' });
|
|
57
75
|
}
|
|
58
76
|
|
|
59
|
-
export async function pptxMain(args = [], { render = chromeShot, log = console.error } = {}) {
|
|
77
|
+
export async function pptxMain(args = [], { render = chromeShot, log = console.error, onSlide = null } = {}) {
|
|
60
78
|
if (args.includes('--help') || args.includes('-h')) { console.log(USAGE); return 0; }
|
|
61
79
|
const { opt } = argReader(args);
|
|
62
80
|
const deck = args.find((a) => !a.startsWith('-') && /\.html?$/i.test(a));
|
|
63
81
|
if (!deck) { log(`decklight pptx: needs a deck\n\n${USAGE}`); return 1; }
|
|
64
82
|
const src = resolve(deck);
|
|
65
83
|
if (!existsSync(src)) { log(`decklight pptx: no such deck: ${deck}`); return 1; }
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
84
|
+
// The deck is SERVED (see chromeShot), and a server has one root. A deck
|
|
85
|
+
// under the current directory keeps it as the root, which is what lets a
|
|
86
|
+
// deck in a subdirectory reach the dist/ and themes/ at the top of its
|
|
87
|
+
// project. A deck anywhere else is served from its OWN directory rather
|
|
88
|
+
// than refused: `decklight pptx ~/talks/q3.html` is a reasonable thing to
|
|
89
|
+
// type from anywhere, and a deck's assets are its siblings.
|
|
90
|
+
const root = src.startsWith(process.cwd() + sep) ? process.cwd() : dirname(src);
|
|
71
91
|
const out = pptxOut(src, opt('-o'));
|
|
72
92
|
const wait = Number(opt('--wait', 1500));
|
|
73
|
-
|
|
93
|
+
let themeParams;
|
|
94
|
+
try { themeParams = renderThemeParams({ theme: opt('--theme'), gen: opt('--gen') }); } catch (e) { log(`decklight pptx: ${e.message}`); return 1; }
|
|
74
95
|
const html = readFileSync(src, 'utf8');
|
|
75
96
|
const notes = notesLines(html);
|
|
76
|
-
|
|
77
|
-
|
|
97
|
+
// HIDDEN_SLIDES — the file you hand over holds what the audience saw, the
|
|
98
|
+
// same rule `pdf`, `video` and `voiceover` already keep. Not merely a
|
|
99
|
+
// preference: a deep link onto a hidden slide lands on its nearest SHOWN
|
|
100
|
+
// neighbour (the engine's `goto`), so exporting one wrote that neighbour's
|
|
101
|
+
// picture a second time, carrying the hidden slide's notes.
|
|
102
|
+
const shown = sectionBodies(html).map((b, i) => (isHiddenSection(b) ? 0 : i + 1)).filter(Boolean);
|
|
103
|
+
const total = notes.length;
|
|
104
|
+
const count = shown.length;
|
|
105
|
+
if (!total) { log('decklight pptx: the deck has no <section> slides'); return 1; }
|
|
106
|
+
if (!count) { log('decklight pptx: every slide in this deck is hidden — there is nothing to hand over'); return 1; }
|
|
78
107
|
|
|
79
|
-
// served, not file://, so every relative asset the deck names still resolves
|
|
80
|
-
|
|
81
|
-
|
|
108
|
+
// served, not file://, so every relative asset the deck names still resolves.
|
|
109
|
+
// --theme rides the URL (`?theme=`), which the runtime applies to any kind
|
|
110
|
+
// of theme the deck holds — a <link> to themes/<name>.css reached only file
|
|
111
|
+
// themes, and missed a deck whose themes are inline blocks (#547).
|
|
112
|
+
const renderQuery = `?${['capture', ...themeParams].join('&')}`;
|
|
113
|
+
const server = await serveForRender(root);
|
|
82
114
|
const scratch = mkdtempSync(join(tmpdir(), 'decklight-pptx-'));
|
|
83
115
|
const slides = [];
|
|
84
116
|
try {
|
|
85
117
|
const deckPath = '/' + relative(root, src).split(sep).join('/');
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
118
|
+
// Resolved only when Chrome is what will render. `chromeBin` exits the
|
|
119
|
+
// process when it finds none, so resolving it unconditionally made every
|
|
120
|
+
// caller that injected its own renderer — the unit test, first of all —
|
|
121
|
+
// die on a machine with no browser, for a browser it was never going to
|
|
122
|
+
// start.
|
|
123
|
+
const bin = render === chromeShot ? chromeBin('pptx') : null;
|
|
124
|
+
log(`pptx: rendering ${basename(src)} — ${count} slides at 1280×720, builds complete`
|
|
125
|
+
+ (total > count ? ` · ${total - count} hidden, skipped` : ''));
|
|
126
|
+
for (const [i, n] of shown.entries()) {
|
|
127
|
+
// Position in the FILE being written, not in the deck — a caller showing
|
|
128
|
+
// "slide 3 of 5" means the third of five pictures, and a hidden slide in
|
|
129
|
+
// between would make the deck's own numbering count past the end.
|
|
130
|
+
onSlide?.(i + 1, count);
|
|
89
131
|
const png = join(scratch, `slide-${n}.png`);
|
|
90
|
-
// /999 lands on the last build step, whatever the slide has
|
|
132
|
+
// /999 lands on the last build step, whatever the slide has; `?capture`
|
|
133
|
+
// keeps the live-viewer chrome (toasts, the voice-over hint) off the
|
|
134
|
+
// picture (#548)
|
|
91
135
|
await render(bin, chromeArgs(
|
|
92
136
|
'--hide-scrollbars', '--window-size=1280,720', `--virtual-time-budget=${wait}`,
|
|
93
|
-
`--screenshot=${png}`, `${server.origin}${deckPath}#/${n}/999`,
|
|
137
|
+
`--screenshot=${png}`, `${server.origin}${deckPath}${renderQuery}#/${n}/999`,
|
|
94
138
|
), { n, png });
|
|
95
139
|
if (!existsSync(png) || statSync(png).size === 0) { log(`decklight pptx: slide ${n} did not render — try a longer --wait`); return 1; }
|
|
96
140
|
slides.push({ png: readFileSync(png), notes: notes[n - 1] });
|
|
@@ -101,7 +145,8 @@ export async function pptxMain(args = [], { render = chromeShot, log = console.e
|
|
|
101
145
|
}
|
|
102
146
|
const bytes = buildPptx(slides, { title: titleOf(html, src) });
|
|
103
147
|
writeFileSync(out, bytes);
|
|
104
|
-
const withNotes =
|
|
105
|
-
console.log(`${out} · ${count} slides as pictures
|
|
148
|
+
const withNotes = shown.filter((n) => notes[n - 1].length).length;
|
|
149
|
+
console.log(`${out} · ${count} slides as pictures${total > count ? ` (${total - count} hidden, skipped)` : ''}`
|
|
150
|
+
+ ` · ${withNotes} with notes · ${Math.round(bytes.length / 1024)} KB`);
|
|
106
151
|
return 0;
|
|
107
152
|
}
|
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 — `
|
|
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
|
|
5
|
+
// decklight narrate --mic — capture the deck's narration in YOUR voice.
|
|
6
6
|
//
|
|
7
|
-
// decklight
|
|
7
|
+
// decklight narrate --mic <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
10
|
// deck (V → Record this deck… → With your voice…): it has to, because the notes, the builds and the microphone are
|
|
@@ -21,19 +21,19 @@
|
|
|
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
|
|
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 './
|
|
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
|
|
33
|
+
const USAGE = `usage: decklight narrate --mic <deck.html> [--port 8788] [--dir voiceover] [--slides a-b] [--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
|
|
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
38
|
deck exactly as it will when you present it
|
|
39
39
|
|
|
@@ -48,6 +48,8 @@ const USAGE = `usage: decklight record <deck.html> [--port 8788] [--dir voiceove
|
|
|
48
48
|
writes <dir>/slide-NN.wav (the whole slide) and <dir>/slide-NN-KK.wav (one
|
|
49
49
|
per beat); play them back with:
|
|
50
50
|
narration: { files: '<dir>', ext: 'wav', segments: true }
|
|
51
|
+
(the same one-track form decklight narrate prints; several tracks are a
|
|
52
|
+
list of the same fields, each with a label)
|
|
51
53
|
|
|
52
54
|
a microphone needs a secure context, which is why this serves the deck rather
|
|
53
55
|
than opening the file — and why the recorder on a file:// deck says so instead of failing
|
|
@@ -118,14 +120,14 @@ export async function recordMain(args, { open = openUrl, out = process.stdout, o
|
|
|
118
120
|
const dir = opt('--dir');
|
|
119
121
|
const slides = opt('--slides');
|
|
120
122
|
for (const bad of [dirProblem(dir), slidesProblem(slides)]) {
|
|
121
|
-
if (bad) { process.stderr.write(`decklight
|
|
123
|
+
if (bad) { process.stderr.write(`decklight narrate --mic: ${bad}\n`); return 2; }
|
|
122
124
|
}
|
|
123
125
|
|
|
124
126
|
const deck = firstPositional(args, ['--dir', '--slides', '--port']);
|
|
125
127
|
// Before the server, not after: this used to serve the YAML file, print a
|
|
126
128
|
// URL and open a browser on it, with no error anywhere.
|
|
127
|
-
const mixedUp = wrongRecorder('
|
|
128
|
-
if (mixedUp) { process.stderr.write(`decklight
|
|
129
|
+
const mixedUp = wrongRecorder('narrate', deck);
|
|
130
|
+
if (mixedUp) { process.stderr.write(`decklight narrate --mic: ${mixedUp}\n`); return 2; }
|
|
129
131
|
let started;
|
|
130
132
|
// `--no-git`, always: recording is not editing, and a take that happens to
|
|
131
133
|
// coincide with the autocommit cadence has no business creating a commit.
|
|
@@ -140,7 +142,7 @@ export async function recordMain(args, { open = openUrl, out = process.stdout, o
|
|
|
140
142
|
if (!started) return process.exitCode ?? 1;
|
|
141
143
|
|
|
142
144
|
const url = recordUrl(started.port, started.deckUrl, dir, slides);
|
|
143
|
-
out.write(`decklight
|
|
145
|
+
out.write(`decklight narrate --mic on ${url}\n`);
|
|
144
146
|
out.write(' V → Record this deck… → With your voice… opens the recorder · → ends a beat and reveals the next build · Esc stops\n');
|
|
145
147
|
out.write(` files land in ${dir ?? "the deck's narration folder"}, next to the deck.`
|
|
146
148
|
+ `${slides ? ` Only slide${/-/.test(slides) ? 's' : ''} ${slides}.` : ''} Ctrl-C when you are done.\n`);
|
|
@@ -150,5 +152,5 @@ export async function recordMain(args, { open = openUrl, out = process.stdout, o
|
|
|
150
152
|
|
|
151
153
|
if (isMain(import.meta.url)) {
|
|
152
154
|
exitWhenOrphaned();
|
|
153
|
-
recordMain(process.argv.slice(2))
|
|
155
|
+
process.exitCode = await runMain('record', () => recordMain(process.argv.slice(2)));
|
|
154
156
|
}
|
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
|
-
// `
|
|
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';
|
|
@@ -59,14 +59,14 @@ export function remoteControllerHtml(deckName) {
|
|
|
59
59
|
var pos = document.getElementById('pos');
|
|
60
60
|
var state = document.getElementById('state');
|
|
61
61
|
function send(key) {
|
|
62
|
-
return fetch('/remote/key' + q, {
|
|
62
|
+
return fetch('/deck/remote/key' + q, {
|
|
63
63
|
method: 'POST', headers: { 'content-type': 'application/json' },
|
|
64
64
|
body: JSON.stringify({ key: key }),
|
|
65
65
|
}).catch(function () { state.textContent = 'offline'; });
|
|
66
66
|
}
|
|
67
67
|
document.getElementById('next').onclick = function () { send('next'); };
|
|
68
68
|
document.getElementById('prev').onclick = function () { send('prev'); };
|
|
69
|
-
var es = new EventSource('/remote/events' + q);
|
|
69
|
+
var es = new EventSource('/deck/remote/events' + q);
|
|
70
70
|
es.addEventListener('pos', function (e) {
|
|
71
71
|
try { var p = JSON.parse(e.data); pos.textContent = p.i + ' / ' + p.n; } catch (err) {}
|
|
72
72
|
});
|
|
@@ -78,7 +78,7 @@ export function remoteControllerHtml(deckName) {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
|
-
* The relay. handle(req, res, url[, body]) answers every /remote/* route and
|
|
81
|
+
* The relay. handle(req, res, url[, body]) answers every /deck/remote/* route and
|
|
82
82
|
* returns whether it did. GET routes need no body; the mounting server hands
|
|
83
83
|
* POST bodies in after its own read. A bad payload throws — the mounting
|
|
84
84
|
* server's error path answers 400, exactly as when this lived inline.
|
|
@@ -87,11 +87,11 @@ export function remoteControllerHtml(deckName) {
|
|
|
87
87
|
* token the per-run token (null when --remote is off — QR refuses)
|
|
88
88
|
* remoteUrl () => the LAN URL the QR encodes (port known only after bind)
|
|
89
89
|
* relayToDeck (event, data) => broadcast into the deck's own SSE stream
|
|
90
|
-
* deckCount () => how many decks are listening (the /remote/key echo)
|
|
90
|
+
* deckCount () => how many decks are listening (the /deck/remote/key echo)
|
|
91
91
|
* CORS the mounting server's CORS headers
|
|
92
92
|
*/
|
|
93
93
|
export function createRemoteRelay({ deckName, token, remoteUrl, relayToDeck, deckCount, CORS }) {
|
|
94
|
-
const phones = sseChannel(); // phones watching /remote/events
|
|
94
|
+
const phones = sseChannel(); // phones watching /deck/remote/events
|
|
95
95
|
let lastPos = null; // the last position the deck reported
|
|
96
96
|
const pushPos = () => { if (lastPos) phones.raw(`event: pos\ndata: ${JSON.stringify(lastPos)}\n\n`); };
|
|
97
97
|
return {
|
|
@@ -101,12 +101,12 @@ export function createRemoteRelay({ deckName, token, remoteUrl, relayToDeck, dec
|
|
|
101
101
|
res.end(JSON.stringify(obj));
|
|
102
102
|
return true;
|
|
103
103
|
};
|
|
104
|
-
if (req.method === 'GET' && url.pathname === '/remote') {
|
|
104
|
+
if (req.method === 'GET' && url.pathname === '/deck/remote') {
|
|
105
105
|
res.writeHead(200, { ...CORS, 'content-type': 'text/html; charset=utf-8', 'cache-control': 'no-cache' });
|
|
106
106
|
res.end(remoteControllerHtml(deckName));
|
|
107
107
|
return true;
|
|
108
108
|
}
|
|
109
|
-
if (req.method === 'GET' && url.pathname === '/remote/qr.svg') {
|
|
109
|
+
if (req.method === 'GET' && url.pathname === '/deck/remote/qr.svg') {
|
|
110
110
|
// Only meaningful with --remote: without it there is no LAN URL to
|
|
111
111
|
// scan, and a QR encoding 127.0.0.1 would be a lie a phone can't use.
|
|
112
112
|
if (!token) return json(404, { ok: false, error: 'the remote is off — start with --remote' });
|
|
@@ -114,14 +114,14 @@ export function createRemoteRelay({ deckName, token, remoteUrl, relayToDeck, dec
|
|
|
114
114
|
res.end(qrSvg(remoteUrl()));
|
|
115
115
|
return true;
|
|
116
116
|
}
|
|
117
|
-
if (req.method === 'GET' && url.pathname === '/remote/events') {
|
|
117
|
+
if (req.method === 'GET' && url.pathname === '/deck/remote/events') {
|
|
118
118
|
const sub = phones.add(req, res, CORS);
|
|
119
119
|
// a phone joining mid-talk should show the right number immediately,
|
|
120
120
|
// not stay blank until the presenter happens to advance
|
|
121
121
|
if (lastPos) sub.write(`event: pos\ndata: ${JSON.stringify(lastPos)}\n\n`);
|
|
122
122
|
return true;
|
|
123
123
|
}
|
|
124
|
-
if (req.method === 'POST' && url.pathname === '/remote/key') {
|
|
124
|
+
if (req.method === 'POST' && url.pathname === '/deck/remote/key') {
|
|
125
125
|
const { key } = JSON.parse(body);
|
|
126
126
|
if (key !== 'next' && key !== 'prev') throw new Error('bad payload');
|
|
127
127
|
// relayed as a named event on the stream the deck ALREADY listens to —
|
|
@@ -129,7 +129,7 @@ export function createRemoteRelay({ deckName, token, remoteUrl, relayToDeck, dec
|
|
|
129
129
|
relayToDeck('remote', { key });
|
|
130
130
|
return json(200, { ok: true, key, decks: deckCount() });
|
|
131
131
|
}
|
|
132
|
-
if (req.method === 'POST' && url.pathname === '/remote/pos') {
|
|
132
|
+
if (req.method === 'POST' && url.pathname === '/deck/remote/pos') {
|
|
133
133
|
// The deck→phones direction, and only that. The deck reporting its
|
|
134
134
|
// position is a loopback caller; a phone — or anyone who obtained the
|
|
135
135
|
// QR token — has no business posting here, and accepting it would let
|
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:
|
|
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}`], {
|
|
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
|
*
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// Copyright 2026 Gilles Philippart
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
// A review is a branch (SPEC REVIEW).
|
|
5
|
+
//
|
|
6
|
+
// A reviewer's records never touch the branch she has checked out, nor the
|
|
7
|
+
// tracked sidecar in her work tree. Each one is a commit of its own on a LOCAL
|
|
8
|
+
// review branch, `refs/heads/review/<me>-<date>`, built with plumbing the way
|
|
9
|
+
// the wip snapshot and `comments submit` build theirs: a blob, a tree that is
|
|
10
|
+
// the parent's with one path replaced, `commit-tree`, `update-ref`. Nothing
|
|
11
|
+
// here touches the index, the work tree or HEAD, so a pull never diverges and a
|
|
12
|
+
// `git reset --hard` never loses a comment. Submit pushes the branch.
|
|
13
|
+
//
|
|
14
|
+
// What the reviewer sees is read back from those branches (`localReviews`), and
|
|
15
|
+
// so is what she submits.
|
|
16
|
+
|
|
17
|
+
import { execFileSync } from 'node:child_process';
|
|
18
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
19
|
+
import { basename, dirname } from 'node:path';
|
|
20
|
+
import { parseReview, mergeById, reviewPathFor } from './review-store.mjs';
|
|
21
|
+
import { putBlob } from './git-tree.mjs';
|
|
22
|
+
import { isIdentityError } from './git.mjs';
|
|
23
|
+
|
|
24
|
+
const run = (cwd, exec) => (args, input) =>
|
|
25
|
+
exec('git', args, { cwd, encoding: 'utf8', input, stdio: ['pipe', 'pipe', 'pipe'] }).trim();
|
|
26
|
+
|
|
27
|
+
/** The sidecar's path inside the repository, as forward-slashed parts. */
|
|
28
|
+
export function sidecarInRepo(deckPath, exec = execFileSync) {
|
|
29
|
+
const cwd = dirname(deckPath);
|
|
30
|
+
const prefix = run(cwd, exec)(['rev-parse', '--show-prefix']);
|
|
31
|
+
return [...prefix.split('/').filter(Boolean), basename(reviewPathFor(deckPath))];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Today's review branch for `who` (a slug, `slugUser`), as a full ref: one per reviewer per day. */
|
|
35
|
+
export const reviewRef = (who, date = new Date()) => `refs/heads/review/${who}-${date.toISOString().slice(0, 10)}`;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Append one serialized record to the reviewer's review branch, as a commit
|
|
39
|
+
* of its own. The branch is created on first use, parented on the checkout's
|
|
40
|
+
* upstream as this clone knows it (no network), else on HEAD: what `submit`
|
|
41
|
+
* pushes is re-parented on what the remote has anyway, so the local parent
|
|
42
|
+
* only has to make `git log review/…` read sensibly.
|
|
43
|
+
*
|
|
44
|
+
* Returns `{ ref, commit, created }`. Throws when there is nothing to base
|
|
45
|
+
* the branch on (an empty repository): a review branch is never an orphan,
|
|
46
|
+
* for the same reason a submit never is.
|
|
47
|
+
*/
|
|
48
|
+
export function appendToReviewRef(deckPath, line, message, { who, date = new Date(), exec = execFileSync } = {}) {
|
|
49
|
+
const cwd = dirname(deckPath);
|
|
50
|
+
const git = run(cwd, exec);
|
|
51
|
+
const ref = reviewRef(who, date);
|
|
52
|
+
const inRepo = sidecarInRepo(deckPath, exec);
|
|
53
|
+
let parent = null;
|
|
54
|
+
try { parent = git(['rev-parse', '--verify', '--quiet', ref]); } catch { parent = null; }
|
|
55
|
+
const created = !parent;
|
|
56
|
+
if (!parent) {
|
|
57
|
+
try { parent = git(['rev-parse', '--verify', '--quiet', '@{upstream}']); } catch { parent = null; }
|
|
58
|
+
if (!parent) { try { parent = git(['rev-parse', '--verify', '--quiet', 'HEAD']); } catch { parent = null; } }
|
|
59
|
+
}
|
|
60
|
+
if (!parent) throw new Error('the repository has no commit to base a review branch on');
|
|
61
|
+
let current = '';
|
|
62
|
+
try { current = git(['show', `${parent}:${inRepo.join('/')}`]); } catch { current = ''; }
|
|
63
|
+
const text = (current && !current.endsWith('\n') ? `${current}\n` : current) + line;
|
|
64
|
+
const blob = git(['hash-object', '-w', '--stdin'], text);
|
|
65
|
+
const tree = putBlob(git, parent, inRepo, blob);
|
|
66
|
+
let commit;
|
|
67
|
+
try {
|
|
68
|
+
commit = git(['commit-tree', tree, '-p', parent, '-m', message]);
|
|
69
|
+
} catch (e) {
|
|
70
|
+
// a fresh machine has no git identity: a review still lands, under a
|
|
71
|
+
// name that says so, the way gitAutocommit does for the deck
|
|
72
|
+
if (!isIdentityError(e)) throw e;
|
|
73
|
+
commit = git(['-c', 'user.name=decklight', '-c', 'user.email=decklight@localhost', 'commit-tree', tree, '-p', parent, '-m', message]);
|
|
74
|
+
}
|
|
75
|
+
git(['update-ref', '-m', message, ref, commit]);
|
|
76
|
+
return { ref, branch: ref.slice('refs/heads/'.length), commit, created };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The records on this reviewer's LOCAL review branches for this deck, merged
|
|
81
|
+
* by id, oldest branch first: what she wrote here, whether or not it was
|
|
82
|
+
* submitted yet. No network. `{ records, branches }`.
|
|
83
|
+
*/
|
|
84
|
+
export function localReviews(deckPath, who, { exec = execFileSync } = {}) {
|
|
85
|
+
const cwd = dirname(deckPath);
|
|
86
|
+
const git = run(cwd, exec);
|
|
87
|
+
const out = { records: [], branches: [] };
|
|
88
|
+
if (!who) return out;
|
|
89
|
+
let names = [];
|
|
90
|
+
try {
|
|
91
|
+
names = git(['for-each-ref', '--format=%(refname:short)', '--sort=refname', `refs/heads/review/${who}-*`])
|
|
92
|
+
.split('\n').filter(Boolean);
|
|
93
|
+
} catch { return out; }
|
|
94
|
+
if (!names.length) return out;
|
|
95
|
+
const inRepo = sidecarInRepo(deckPath, exec).join('/');
|
|
96
|
+
for (const b of names) {
|
|
97
|
+
let text = '';
|
|
98
|
+
try { text = git(['show', `${b}:${inRepo}`]); } catch { continue; } // a review of another deck
|
|
99
|
+
out.branches.push(b);
|
|
100
|
+
out.records = mergeById(out.records, parseReview(text).records).records;
|
|
101
|
+
}
|
|
102
|
+
return out;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* The deck's review state as ONE reader sees it, so the CLI, the no-trust
|
|
107
|
+
* server and submit never disagree: the sidecar beside the deck (the deck
|
|
108
|
+
* branch's, carrying the author's ops after a pull) and the reviewer's own
|
|
109
|
+
* local review branches, merged by id in that order. `who` is the slug the
|
|
110
|
+
* branch names carry (`slugUser`); `''` reads the file alone.
|
|
111
|
+
*/
|
|
112
|
+
export function reviewState(deckPath, who, { exec = execFileSync } = {}) {
|
|
113
|
+
const storePath = reviewPathFor(deckPath);
|
|
114
|
+
const fileExists = existsSync(storePath);
|
|
115
|
+
let text = '';
|
|
116
|
+
if (fileExists) { try { text = readFileSync(storePath, 'utf8'); } catch { text = ''; } }
|
|
117
|
+
const file = parseReview(text);
|
|
118
|
+
const mine = who ? localReviews(deckPath, who, { exec }) : { records: [], branches: [] };
|
|
119
|
+
return {
|
|
120
|
+
records: mergeById(file.records, mine.records).records,
|
|
121
|
+
skipped: file.skipped,
|
|
122
|
+
branches: mine.branches,
|
|
123
|
+
fileExists,
|
|
124
|
+
};
|
|
125
|
+
}
|