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.
- package/PLATFORM.md +707 -0
- package/README.md +226 -150
- package/SPEC.md +803 -888
- package/cli/agent-review.mjs +246 -0
- package/cli/agents.mjs +35 -9
- package/cli/associate.mjs +12 -12
- package/cli/audit.mjs +42 -10
- package/cli/banner.mjs +41 -17
- package/cli/bundle-audio.mjs +190 -0
- package/cli/bundle-module.mjs +95 -0
- package/cli/bundle.mjs +439 -35
- package/cli/cast.mjs +48 -12
- package/cli/check-fixes.mjs +186 -0
- package/cli/check.mjs +988 -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 +51 -22
- package/cli/commit-message.mjs +51 -74
- package/cli/commit-split.mjs +601 -0
- package/cli/deck-refs.mjs +64 -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 +666 -0
- package/cli/design-system.mjs +497 -0
- package/cli/doctor.mjs +115 -0
- package/cli/edit-git.mjs +353 -0
- package/cli/edit-handover.mjs +551 -0
- package/cli/edit-look.mjs +631 -0
- package/cli/edit-slides.mjs +683 -0
- package/cli/edit.mjs +2585 -855
- package/cli/enhance.mjs +485 -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 +78 -11
- package/cli/import.mjs +56 -10
- package/cli/init.mjs +407 -236
- package/cli/library.mjs +127 -0
- package/cli/loader.mjs +3 -1
- package/cli/marketplace-autocheck.mjs +200 -0
- package/cli/marketplace.mjs +460 -29
- package/cli/narrate.mjs +251 -0
- package/cli/open-browser.mjs +63 -0
- package/cli/open.mjs +961 -0
- package/cli/pdf.mjs +64 -17
- package/cli/pkg.mjs +44 -2
- package/cli/plugin.mjs +43 -41
- package/cli/port-conflict.mjs +53 -23
- package/cli/pptx-export.mjs +63 -27
- package/cli/publish.mjs +8 -4
- package/cli/qr.mjs +1 -1
- package/cli/record.mjs +85 -23
- package/cli/remote.mjs +43 -17
- 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 +236 -45
- package/cli/setup.mjs +112 -0
- package/cli/sign.mjs +1 -1
- package/cli/skill-content.mjs +229 -35
- package/cli/skills.mjs +353 -26
- package/cli/start.mjs +110 -0
- package/cli/supervise.mjs +6 -6
- package/cli/theme-refs.mjs +527 -0
- package/cli/theme.mjs +181 -137
- package/cli/trust.mjs +83 -0
- package/cli/units.mjs +112 -47
- 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 +1533 -59
- package/dist/decklight.js +258 -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 +778 -0
- package/tools/design-system-migrations.mjs +207 -0
- package/tools/elevenlabs-tts.mjs +110 -17
- package/tools/exec.mjs +11 -3
- 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 +270 -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-clip.mjs +114 -0
- package/tools/site-voices.mjs +232 -0
- package/tools/template-theme.mjs +1 -1
- package/tools/test-impact.mjs +17 -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 +530 -54
- 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/narrate.mjs
ADDED
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
// Copyright 2026 Gilles Philippart
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* decklight narrate — put the deck's narration into a folder beside it.
|
|
6
|
+
*
|
|
7
|
+
* decklight narrate <deck.html> [--engine E] [--voice V] [--format F] [--slides a-b] [--dir NAME]
|
|
8
|
+
* decklight narrate <deck.html> --mic [--slides a-b] [--dir NAME] [--port N] [--remote] [--no-open]
|
|
9
|
+
* decklight narrate <deck.html> --face [--video] [--dir NAME]
|
|
10
|
+
*
|
|
11
|
+
* One command for the two ways a deck gets a recorded voice: an engine reads
|
|
12
|
+
* the notes (what `decklight voiceover` did), or you do, into the microphone,
|
|
13
|
+
* one [click] beat at a time (what `decklight record` did). Both write the
|
|
14
|
+
* same files into the same folder, the deck's own `narration.files` or
|
|
15
|
+
* `voiceover/`, and both refresh only `--slides` when asked. They were two
|
|
16
|
+
* commands with two spellings of the folder (`-o PATH` and `--dir NAME`) and
|
|
17
|
+
* a help that had to say which one was not `cast` (ROADMAP section 4).
|
|
18
|
+
*
|
|
19
|
+
* The implementations stay where they were: tools/voiceover.mjs (spawned: it
|
|
20
|
+
* parses its argv at load) and cli/record.mjs. This is the grammar in front.
|
|
21
|
+
* `video --voiceover` stays a flag of `video`, and `enhance` rewrites the
|
|
22
|
+
* script rather than voicing it, so neither is here.
|
|
23
|
+
*
|
|
24
|
+
* `--face` is the third: the narration already in the folder gets the
|
|
25
|
+
* character's lip-sync (tools/lipsync.mjs, which had no command). It never
|
|
26
|
+
* voices anything, so a take recorded at the microphone cannot be replaced by
|
|
27
|
+
* an engine on the way to getting a face; voice first, then `--face`.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
import { spawnSync } from 'node:child_process';
|
|
31
|
+
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
32
|
+
import { dirname, join, relative, resolve, isAbsolute } from 'node:path';
|
|
33
|
+
import { fileURLToPath } from 'node:url';
|
|
34
|
+
import { firstPositional, isMain } from '../tools/args.mjs';
|
|
35
|
+
import { runMain, wrongRecorder } from './util.mjs';
|
|
36
|
+
import { configuredTrackDirs } from './edit.mjs';
|
|
37
|
+
|
|
38
|
+
const VOICEOVER = fileURLToPath(new URL('../tools/voiceover.mjs', import.meta.url));
|
|
39
|
+
const LIPSYNC = fileURLToPath(new URL('../tools/lipsync.mjs', import.meta.url));
|
|
40
|
+
// the flags either side takes a value for, so the deck is found past them
|
|
41
|
+
const VALUE_FLAGS = new Set(['-o', '--dir', '--engine', '--voice', '--style', '--data-dir', '--project',
|
|
42
|
+
'--format', '--slides', '--beats', '--countdown', '--takes', '--port', '--model', '--lang', '--location', '--tts-format', '--tts-stability',
|
|
43
|
+
'--rhubarb', '--portrait', '--python', '--wav2lip-dir', '--wav2lip-ckpt', '--sadtalker-dir',
|
|
44
|
+
'--veo-project', '--veo-location', '--veo-model', '--veo-seconds', '--veo-prompt', '--veo-face-y']);
|
|
45
|
+
|
|
46
|
+
export const USAGE = `usage: decklight narrate <deck.html> [--mic] [--slides a-b] [--dir NAME] …
|
|
47
|
+
|
|
48
|
+
writes the deck's narration into a folder beside it: one slide-NN file per
|
|
49
|
+
slide and one per [click] beat, which the deck then plays
|
|
50
|
+
|
|
51
|
+
an engine reads the notes (the default)
|
|
52
|
+
--engine E piper (local, free) · chirp · gemini · elevenlabs · a native voice
|
|
53
|
+
--voice V the engine's voice name
|
|
54
|
+
--format F m4a (a new track's default) · wav · mp3
|
|
55
|
+
--reuse-text, --keep-wav, --no-cache (decklight narrate <deck> --help --engine)
|
|
56
|
+
EXAMPLE: decklight narrate talk.html --engine chirp --voice Achernar
|
|
57
|
+
|
|
58
|
+
you read the notes, into the microphone
|
|
59
|
+
--mic serves the deck on http://127.0.0.1 (a microphone needs it) and
|
|
60
|
+
opens it with the recorder up; → ends a beat and reveals the
|
|
61
|
+
next build, so your voice paces the deck as it will be presented
|
|
62
|
+
--beats k-l with --slides N: only these beats of slide N; the others are kept
|
|
63
|
+
--takes slide|beat one take per slide (→ cuts a beat and keeps going), or per beat
|
|
64
|
+
--countdown N seconds of count-in before each take, 0 for none
|
|
65
|
+
--remote the phone remote too: its next ends a beat, its retake redoes one,
|
|
66
|
+
so no keystroke gets into the take
|
|
67
|
+
--port N, --no-open
|
|
68
|
+
EXAMPLE: decklight narrate talk.html --mic
|
|
69
|
+
|
|
70
|
+
either way, an engine or the microphone
|
|
71
|
+
--slides a-b only these slides; every other slide's files are left alone
|
|
72
|
+
--dir NAME the folder, relative to the deck
|
|
73
|
+
[an engine: its narration.files, else voiceover · --mic: voices/me]
|
|
74
|
+
|
|
75
|
+
the character mouths what is already there (--face)
|
|
76
|
+
--face lip-sync for every slide and [click] beat in the folder, which the
|
|
77
|
+
character plays with no bridge running; voices nothing, so voice first
|
|
78
|
+
--video a talking-head clip per slide too (SadTalker or Wav2Lip, slow)
|
|
79
|
+
uses what decklight setup face saved: rhubarb, the portrait, the engine, Veo
|
|
80
|
+
--rhubarb, --portrait NAME|FILE, --engine sadtalker|wav2lip, --no-veo for this run only
|
|
81
|
+
--dir NAME only this folder [every one the deck's narration.files names]
|
|
82
|
+
EXAMPLE: decklight narrate talk.html --face
|
|
83
|
+
|
|
84
|
+
is the narration still the notes? (--check)
|
|
85
|
+
--check every track beside the deck, slide by slide: in step, the words
|
|
86
|
+
changed, or (your own voice) only the [click] split moved, which
|
|
87
|
+
a recording cannot follow; each with the command that fixes it.
|
|
88
|
+
Exits 1 when something is out of step
|
|
89
|
+
--dir NAME only this folder
|
|
90
|
+
EXAMPLE: decklight narrate talk.html --check
|
|
91
|
+
|
|
92
|
+
the deck plays the folder back with
|
|
93
|
+
narration: { files: '<dir>', segments: true } (wav: ext: 'wav')
|
|
94
|
+
`;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* The argv for the side that does the work. Pure, so the folder translation
|
|
98
|
+
* (`--dir NAME` relative to the deck, `-o PATH` from here) is testable.
|
|
99
|
+
*/
|
|
100
|
+
export function narratePlan(argv = [], cwd = process.cwd()) {
|
|
101
|
+
const mic = argv.includes('--mic');
|
|
102
|
+
const args = argv.filter((a) => a !== '--mic');
|
|
103
|
+
const deck = firstPositional(args, VALUE_FLAGS);
|
|
104
|
+
const deckDir = deck ? dirname(resolve(cwd, deck)) : cwd;
|
|
105
|
+
const out = [];
|
|
106
|
+
for (let i = 0; i < args.length; i++) {
|
|
107
|
+
const a = args[i];
|
|
108
|
+
if (a === '--dir' || a === '-o') {
|
|
109
|
+
const v = args[++i];
|
|
110
|
+
if (v === undefined) { out.push(a); continue; }
|
|
111
|
+
const abs = isAbsolute(v) ? v : (a === '--dir' ? join(deckDir, v) : resolve(cwd, v));
|
|
112
|
+
// the recorder names its folder relative to the deck; the synthesizer takes a path
|
|
113
|
+
if (mic) out.push('--dir', relative(deckDir, abs) || '.');
|
|
114
|
+
else out.push('-o', abs);
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
out.push(a);
|
|
118
|
+
}
|
|
119
|
+
return { mic, deck, args: out };
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** Audio a track folder holds: `slide-NN.wav|m4a`, the whole slide or one beat. */
|
|
123
|
+
const hasAudio = (dir) => existsSync(dir) && readdirSync(dir).some((f) => /^slide-\d+(?:-\d+)?\.(wav|m4a)$/.test(f));
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* The folders `--face` cuts sidecars into: `--dir NAME`, else every local
|
|
127
|
+
* folder the deck's `narration.files` names, else `voiceover/`. A folder
|
|
128
|
+
* without audio is skipped, but only when the deck chose it; one named by
|
|
129
|
+
* `--dir` that has nothing in it is the caller's mistake and is reported.
|
|
130
|
+
*/
|
|
131
|
+
export function faceFolders(deckPath, html, dirArg) {
|
|
132
|
+
const deckDir = dirname(resolve(deckPath));
|
|
133
|
+
if (dirArg) return [resolve(deckDir, dirArg)];
|
|
134
|
+
const named = configuredTrackDirs(html).filter((d) => !/^[a-z][a-z0-9+.-]*:/i.test(d));
|
|
135
|
+
const dirs = (named.length ? named : ['voiceover']).map((d) => resolve(deckDir, d));
|
|
136
|
+
return [...new Set(dirs)].filter(hasAudio);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* `--face`: the deck's narration folders, each through tools/lipsync.mjs.
|
|
141
|
+
* `--slides` is refused rather than ignored: the batch is incremental by
|
|
142
|
+
* audio hash, so a rerun already touches only what changed.
|
|
143
|
+
*/
|
|
144
|
+
function faceMain(plan, argv) {
|
|
145
|
+
if (plan.mic) { console.error('decklight narrate: --face gives a recorded track its lip-sync; record it first (--mic), then run --face'); return 2; }
|
|
146
|
+
if (argv.includes('--slides')) { console.error('decklight narrate: --face takes no --slides; a rerun only redoes the slides whose audio changed'); return 2; }
|
|
147
|
+
if (!plan.deck || !existsSync(plan.deck)) { console.error(`decklight narrate: ${plan.deck ? `no deck at ${plan.deck}` : 'name the deck'}`); return 1; }
|
|
148
|
+
const html = readFileSync(plan.deck, 'utf8');
|
|
149
|
+
const dirAt = argv.indexOf('--dir');
|
|
150
|
+
const dirArg = dirAt === -1 ? null : argv[dirAt + 1];
|
|
151
|
+
const folders = faceFolders(plan.deck, html, dirArg);
|
|
152
|
+
if (!folders.length || (dirArg && !hasAudio(folders[0]))) {
|
|
153
|
+
console.error(`decklight narrate: no narration to give a face to${dirArg ? ` in ${dirArg}` : ''}; `
|
|
154
|
+
+ `voice it first: decklight narrate ${plan.deck}`);
|
|
155
|
+
return 1;
|
|
156
|
+
}
|
|
157
|
+
// everything else passes through: the folder goes first, and the deck,
|
|
158
|
+
// --face and --dir NAME are this command's, not the tool's
|
|
159
|
+
const deckAt = argv.indexOf(plan.deck);
|
|
160
|
+
const rest = argv.filter((a, i) => i !== deckAt && a !== '--face' && (dirAt === -1 || (i !== dirAt && i !== dirAt + 1)));
|
|
161
|
+
for (const dir of folders) {
|
|
162
|
+
const r = spawnSync(process.execPath, [LIPSYNC, dir, ...rest], { stdio: 'inherit' });
|
|
163
|
+
if (r.status !== 0) return r.status ?? 1;
|
|
164
|
+
}
|
|
165
|
+
return 0;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* The track folders beside a deck that carry a manifest: the same two levels
|
|
170
|
+
* the edit server's track list walks (`voices/<voice>`), relative to the deck.
|
|
171
|
+
*/
|
|
172
|
+
export function manifestTracks(deckDir) {
|
|
173
|
+
const out = [];
|
|
174
|
+
const look = (rel) => {
|
|
175
|
+
let entries;
|
|
176
|
+
try { entries = readdirSync(join(deckDir, rel), { withFileTypes: true }); } catch { return []; }
|
|
177
|
+
if (entries.some((e) => e.isFile() && e.name === 'manifest.json')) out.push(rel);
|
|
178
|
+
return entries.filter((e) => e.isDirectory() && !e.name.startsWith('.') && e.name !== 'node_modules');
|
|
179
|
+
};
|
|
180
|
+
for (const e of look('.')) {
|
|
181
|
+
for (const k of look(e.name)) look(`${e.name}/${k.name}`);
|
|
182
|
+
}
|
|
183
|
+
return out.filter((d) => d !== '.');
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* `--check` (#850): each track against the deck's notes, said per slide, with
|
|
188
|
+
* the re-record line. A track recorded by hand before a manifest existed has
|
|
189
|
+
* nothing to compare and is named as unchecked rather than passed.
|
|
190
|
+
*/
|
|
191
|
+
async function checkMain(plan, argv) {
|
|
192
|
+
if (!plan.deck || !existsSync(plan.deck)) { console.error(`decklight narrate: ${plan.deck ? `no deck at ${plan.deck}` : 'name the deck'}`); return 1; }
|
|
193
|
+
const { trackDrift, rerecordLine } = await import('../tools/narration-manifest.mjs');
|
|
194
|
+
const html = readFileSync(plan.deck, 'utf8');
|
|
195
|
+
const deckDir = dirname(resolve(plan.deck));
|
|
196
|
+
const dirAt = argv.indexOf('--dir');
|
|
197
|
+
const dirs = dirAt === -1 ? manifestTracks(deckDir) : [argv[dirAt + 1]];
|
|
198
|
+
let out = 0;
|
|
199
|
+
if (!dirs.length) { console.log('no narration track with a manifest beside this deck — nothing to check'); return 0; }
|
|
200
|
+
for (const dir of dirs) {
|
|
201
|
+
let m = null;
|
|
202
|
+
try { m = JSON.parse(readFileSync(join(deckDir, dir, 'manifest.json'), 'utf8')); } catch { /* reported below */ }
|
|
203
|
+
if (!Array.isArray(m?.slides)) { console.log(`${dir}/ no manifest: recorded before decklight kept one, not checked`); continue; }
|
|
204
|
+
const mine = m.recorder === 'mic';
|
|
205
|
+
const who = mine ? 'your voice' : [m.voice, m.engine].filter(Boolean).join(' · ') || 'recorded';
|
|
206
|
+
const { drift, unknown } = trackDrift(m, html);
|
|
207
|
+
const note = unknown ? ` (${unknown} slide${unknown === 1 ? '' : 's'} recorded before the script was kept: not checked)` : '';
|
|
208
|
+
if (!drift.length) { console.log(`${dir}/ ${who}: in step with the notes${note}`); continue; }
|
|
209
|
+
out = 1;
|
|
210
|
+
console.log(`${dir}/ ${who}: ${drift.length} slide${drift.length === 1 ? '' : 's'} out of step${note}`);
|
|
211
|
+
for (const d of drift) {
|
|
212
|
+
console.log(d.why === 'clicks'
|
|
213
|
+
? ` slide ${d.slide}: the [click] split moved${d.was !== d.now ? ` (${d.was} beats → ${d.now})` : ''}, the words did not`
|
|
214
|
+
+ (mine ? ' — a recorded beat is cut where you pressed →, so the marker alone cannot move a build' : '')
|
|
215
|
+
: ` slide ${d.slide}: the notes changed since it was recorded`);
|
|
216
|
+
console.log(` ${rerecordLine(plan.deck, dir, [d.slide], { mine })}`);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return out;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export async function narrateMain(argv = []) {
|
|
223
|
+
const wantsHelp = argv.includes('--help') || argv.includes('-h');
|
|
224
|
+
if (!argv.length || (wantsHelp && !argv.includes('--engine') && !argv.includes('--mic'))) {
|
|
225
|
+
console.log(USAGE);
|
|
226
|
+
return argv.length ? 0 : 1;
|
|
227
|
+
}
|
|
228
|
+
const plan = narratePlan(argv);
|
|
229
|
+
if (argv.includes('--check')) return checkMain(plan, argv);
|
|
230
|
+
if (argv.includes('--face')) return faceMain(plan, argv);
|
|
231
|
+
// a terminal script is `cast`'s, whichever way it was meant to be narrated
|
|
232
|
+
const mixedUp = wrongRecorder('narrate', plan.deck);
|
|
233
|
+
if (mixedUp) { console.error(mixedUp); return 2; } // the code record and cast give it
|
|
234
|
+
// an engine re-voices a slide from its notes in seconds; --beats exists
|
|
235
|
+
// because reading a slide aloud again is what costs
|
|
236
|
+
if (!plan.mic && argv.includes('--beats')) {
|
|
237
|
+
console.error('decklight narrate: --beats re-records beats of your own voice; it goes with --mic');
|
|
238
|
+
return 2;
|
|
239
|
+
}
|
|
240
|
+
if (plan.mic) {
|
|
241
|
+
const { recordMain } = await import('./record.mjs');
|
|
242
|
+
return recordMain(plan.args);
|
|
243
|
+
}
|
|
244
|
+
// spawned, exactly as `video --voiceover` spawns it: voiceover.mjs parses its
|
|
245
|
+
// argv and exits at load. stdio inherited: its per-slide progress and cost
|
|
246
|
+
// lines are the point of running it in a terminal.
|
|
247
|
+
const r = spawnSync(process.execPath, [VOICEOVER, ...plan.args], { stdio: 'inherit' });
|
|
248
|
+
return r.status ?? 1;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
if (isMain(import.meta.url)) process.exitCode = await runMain('narrate', narrateMain);
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// Copyright 2026 Gilles Philippart
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
// Hand a URL to the platform's launcher. Lived in init.mjs, which meant
|
|
5
|
+
// `record` and `--no-trust` imported the whole scaffolding module — the skill text,
|
|
6
|
+
// the template machinery — to open one browser tab. Nothing here reads a file.
|
|
7
|
+
|
|
8
|
+
import { spawn } from 'node:child_process';
|
|
9
|
+
import path from 'node:path';
|
|
10
|
+
import { pathToFileURL } from 'node:url';
|
|
11
|
+
|
|
12
|
+
const DIM = '\x1b[2m';
|
|
13
|
+
const RESET = '\x1b[0m';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The platform's "open this URL" command — a description, so a unit test can
|
|
17
|
+
* check the choice without spawning anything. macOS ships `open`; Windows goes
|
|
18
|
+
* through cmd's `start` (the empty string is the window title, or the URL would
|
|
19
|
+
* become the title); everything else gets freedesktop's xdg-open. Zero new
|
|
20
|
+
* dependencies.
|
|
21
|
+
*/
|
|
22
|
+
export function openCommand(platform, url) {
|
|
23
|
+
if (platform === 'darwin') return { cmd: 'open', args: [url] };
|
|
24
|
+
if (platform === 'win32') return { cmd: 'cmd', args: ['/c', 'start', '', url] };
|
|
25
|
+
return { cmd: 'xdg-open', args: [url] };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Open the deck FILE in the default browser. A machine that cannot launch
|
|
30
|
+
* (headless, no xdg-open) gets one dim line and a normal exit: opening is a
|
|
31
|
+
* courtesy, and its failure is not the command's.
|
|
32
|
+
*/
|
|
33
|
+
export async function openDeck(deckPath, opts = {}) {
|
|
34
|
+
const rel = path.relative('.', deckPath) || deckPath;
|
|
35
|
+
return openUrl(pathToFileURL(deckPath).href, { ...opts, what: rel, prefix: opts.prefix ?? '--open: ' });
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The same launcher, for a URL that is not a file — the edit server's, or
|
|
40
|
+
* `decklight narrate --mic`'s, which serves the deck over http://127.0.0.1 precisely
|
|
41
|
+
* because a browser will not open a microphone for a `file://` page.
|
|
42
|
+
*/
|
|
43
|
+
export async function openUrl(url, {
|
|
44
|
+
platform = process.platform, spawnFn = spawn, out = process.stdout, what = url, prefix = '',
|
|
45
|
+
} = {}) {
|
|
46
|
+
const { cmd, args } = openCommand(platform, url);
|
|
47
|
+
const rel = what;
|
|
48
|
+
const dim = (s) => (out.isTTY && !process.env.NO_COLOR ? `${DIM}${s}${RESET}` : s);
|
|
49
|
+
const skipped = (err) =>
|
|
50
|
+
out.write(dim(`${prefix}could not launch a browser (${cmd}: ${err.code ?? err.message}) — open ${rel} yourself\n`));
|
|
51
|
+
await new Promise((resolve) => {
|
|
52
|
+
let child;
|
|
53
|
+
try {
|
|
54
|
+
child = spawnFn(cmd, args, { stdio: 'ignore', detached: true });
|
|
55
|
+
} catch (err) { skipped(err); resolve(); return; }
|
|
56
|
+
child.once('error', (err) => { skipped(err); resolve(); });
|
|
57
|
+
child.once('spawn', () => {
|
|
58
|
+
child.unref();
|
|
59
|
+
out.write(`opening ${rel} in your default browser\n`);
|
|
60
|
+
resolve();
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
}
|