decklight 0.8.1 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/PLATFORM.md +707 -0
  2. package/README.md +226 -150
  3. package/SPEC.md +803 -888
  4. package/cli/agent-review.mjs +246 -0
  5. package/cli/agents.mjs +35 -9
  6. package/cli/associate.mjs +12 -12
  7. package/cli/audit.mjs +42 -10
  8. package/cli/banner.mjs +41 -17
  9. package/cli/bundle-audio.mjs +190 -0
  10. package/cli/bundle-module.mjs +95 -0
  11. package/cli/bundle.mjs +439 -35
  12. package/cli/cast.mjs +48 -12
  13. package/cli/check-fixes.mjs +186 -0
  14. package/cli/check.mjs +988 -0
  15. package/cli/clone-deck.mjs +179 -0
  16. package/cli/commands.mjs +345 -0
  17. package/cli/comments.mjs +64 -18
  18. package/cli/commit-flow.mjs +51 -22
  19. package/cli/commit-message.mjs +51 -74
  20. package/cli/commit-split.mjs +601 -0
  21. package/cli/deck-refs.mjs +64 -0
  22. package/cli/deck-routes.mjs +67 -0
  23. package/cli/deckfile.mjs +3 -5
  24. package/cli/decklight.mjs +68 -289
  25. package/cli/design-system-deps.mjs +209 -0
  26. package/cli/design-system-edit.mjs +194 -0
  27. package/cli/design-system-refs.mjs +666 -0
  28. package/cli/design-system.mjs +497 -0
  29. package/cli/doctor.mjs +115 -0
  30. package/cli/edit-git.mjs +353 -0
  31. package/cli/edit-handover.mjs +551 -0
  32. package/cli/edit-look.mjs +631 -0
  33. package/cli/edit-slides.mjs +683 -0
  34. package/cli/edit.mjs +2585 -855
  35. package/cli/enhance.mjs +485 -0
  36. package/cli/extension.mjs +10 -10
  37. package/cli/font-refs.mjs +273 -0
  38. package/cli/font.mjs +246 -0
  39. package/cli/git-tree.mjs +1 -1
  40. package/cli/git.mjs +78 -11
  41. package/cli/import.mjs +56 -10
  42. package/cli/init.mjs +407 -236
  43. package/cli/library.mjs +127 -0
  44. package/cli/loader.mjs +3 -1
  45. package/cli/marketplace-autocheck.mjs +200 -0
  46. package/cli/marketplace.mjs +460 -29
  47. package/cli/narrate.mjs +251 -0
  48. package/cli/open-browser.mjs +63 -0
  49. package/cli/open.mjs +961 -0
  50. package/cli/pdf.mjs +64 -17
  51. package/cli/pkg.mjs +44 -2
  52. package/cli/plugin.mjs +43 -41
  53. package/cli/port-conflict.mjs +53 -23
  54. package/cli/pptx-export.mjs +63 -27
  55. package/cli/publish.mjs +8 -4
  56. package/cli/qr.mjs +1 -1
  57. package/cli/record.mjs +85 -23
  58. package/cli/remote.mjs +43 -17
  59. package/cli/restore.mjs +11 -4
  60. package/cli/review-ref.mjs +125 -0
  61. package/cli/review-remote.mjs +92 -48
  62. package/cli/review-routes.mjs +254 -0
  63. package/cli/review-store.mjs +47 -7
  64. package/cli/review-submit.mjs +47 -57
  65. package/cli/runtime-link.mjs +560 -0
  66. package/cli/serve.mjs +236 -45
  67. package/cli/setup.mjs +112 -0
  68. package/cli/sign.mjs +1 -1
  69. package/cli/skill-content.mjs +229 -35
  70. package/cli/skills.mjs +353 -26
  71. package/cli/start.mjs +110 -0
  72. package/cli/supervise.mjs +6 -6
  73. package/cli/theme-refs.mjs +527 -0
  74. package/cli/theme.mjs +181 -137
  75. package/cli/trust.mjs +83 -0
  76. package/cli/units.mjs +112 -47
  77. package/cli/update-check.mjs +1 -5
  78. package/cli/upgrade.mjs +194 -28
  79. package/cli/upstream.mjs +4 -3
  80. package/cli/util.mjs +4 -4
  81. package/cli/wizard.mjs +6 -6
  82. package/dist/build-info.json +1 -1
  83. package/dist/decklight.css +1533 -59
  84. package/dist/decklight.js +258 -115
  85. package/dist/decklight.js.map +4 -4
  86. package/docs/GLOSSARY.md +141 -0
  87. package/docs/architecture.svg +17 -17
  88. package/package.json +4 -2
  89. package/themes/README.md +9 -8
  90. package/themes/reveal-solarized.css +10 -0
  91. package/tools/args.mjs +20 -0
  92. package/tools/atomic-write.mjs +48 -0
  93. package/tools/brand-palette.mjs +717 -0
  94. package/tools/bridge.mjs +1 -1
  95. package/tools/build-groups.mjs +42 -0
  96. package/tools/color.mjs +48 -0
  97. package/tools/deck-html.mjs +396 -11
  98. package/tools/design-system-format.mjs +778 -0
  99. package/tools/design-system-migrations.mjs +207 -0
  100. package/tools/elevenlabs-tts.mjs +110 -17
  101. package/tools/exec.mjs +11 -3
  102. package/tools/extension-check.mjs +31 -7
  103. package/tools/font-format.mjs +190 -0
  104. package/tools/font-stacks.mjs +24 -0
  105. package/tools/gemini-tts.mjs +3 -0
  106. package/tools/lipsync-config.mjs +103 -0
  107. package/tools/lipsync-engines.mjs +205 -2
  108. package/tools/lipsync-server.mjs +264 -41
  109. package/tools/lipsync.mjs +37 -18
  110. package/tools/local-voice.mjs +32 -42
  111. package/tools/narration-manifest.mjs +270 -0
  112. package/tools/narration-synth.mjs +416 -0
  113. package/tools/pptx.mjs +776 -19
  114. package/tools/publish-targets.mjs +1 -1
  115. package/tools/publish-voices.mjs +3 -3
  116. package/tools/recording-impact.mjs +7 -3
  117. package/tools/render-theme.mjs +33 -0
  118. package/tools/review-anchor.mjs +28 -12
  119. package/tools/semver.mjs +40 -0
  120. package/tools/sentences.mjs +180 -0
  121. package/tools/shot.mjs +14 -7
  122. package/tools/site-clip.mjs +114 -0
  123. package/tools/site-voices.mjs +232 -0
  124. package/tools/template-theme.mjs +1 -1
  125. package/tools/test-impact.mjs +17 -10
  126. package/tools/theme-check.mjs +30 -3
  127. package/tools/tts-cache.mjs +4 -3
  128. package/tools/tts-engines.mjs +38 -20
  129. package/tools/tts-setup.mjs +7 -7
  130. package/tools/video-options.mjs +34 -0
  131. package/tools/video.mjs +530 -54
  132. package/tools/voiceover-server.mjs +185 -104
  133. package/tools/voiceover.mjs +119 -261
  134. package/tools/zip.mjs +1 -1
  135. package/cli/dev.mjs +0 -623
  136. package/cli/present.mjs +0 -853
  137. package/cli/review.mjs +0 -361
  138. package/tools/publish-site-voices.mjs +0 -75
@@ -15,7 +15,7 @@
15
15
  *
16
16
  * WHERE THE TOKEN COMES FROM. Not a terminal prompt, and not the browser wizard.
17
17
  * `decklight publish` is a one-shot, often-headless command (CI has no browser to
18
- * paste a key into, and no /edit/wizard to post it to — that endpoint is served by
18
+ * paste a key into, and no /deck/edit/wizard to post it to — that endpoint is served by
19
19
  * the AUTHOR server, which publish never starts). The existing precedent for
20
20
  * exactly this shape is ElevenLabs' own key (tools/elevenlabs-tts.mjs): read from
21
21
  * the environment, never written to disk, "not boring enough" for a config file.
@@ -27,7 +27,7 @@ import { run, NETWORK_MS } from './exec.mjs';
27
27
 
28
28
  const USAGE = `usage: node tools/publish-voices.mjs <voice-dir> --bucket gs://bucket/prefix [--sign 7d]
29
29
  uploads a recorded track's audio to Cloud Storage and writes a manifest of
30
- URLs to deploy next to the deck — one per slide, plus one per ⟨CLICK⟩ beat,
30
+ URLs to deploy next to the deck — one per slide, plus one per [click] beat,
31
31
  which is what lets a cloud-hosted track pace the builds and not just the slides
32
32
 
33
33
  --bucket gs://… destination; the track's own folder name is appended
@@ -252,7 +252,7 @@ export async function publishVoicesMain(args = []) {
252
252
  // Said out loud, because it is the difference between a cloud track that
253
253
  // paces the builds and one that only changes slides — and the count is the
254
254
  // only place a publisher can notice the beats were never recorded.
255
- const tally = `${all.length} URL(s)` + (beats ? ` (${slideCount} slides + ${beats} ⟨CLICK⟩ beats)` : '');
255
+ const tally = `${all.length} URL(s)` + (beats ? ` (${slideCount} slides + ${beats} [click] beats)` : '');
256
256
  const urls = new Map();
257
257
  let expires = null;
258
258
  if (signSeconds === null) {
@@ -283,7 +283,7 @@ export async function publishVoicesMain(args = []) {
283
283
  console.log(` narration: { files: [{ label: '${manifest.voice ?? dirName}', manifest: '${dir}/manifest.signed.json' }] }`);
284
284
  // A manifest track needs no `segments: true` — the manifest IS the list of
285
285
  // what exists — so the only thing left to say is that the beats are in it.
286
- if (beats) console.log(` ${beats} ⟨CLICK⟩ beat(s) signed too — this track paces the builds, not just the slides`);
286
+ if (beats) console.log(` ${beats} [click] beat(s) signed too — this track paces the builds, not just the slides`);
287
287
  return 0;
288
288
  }
289
289
 
@@ -28,11 +28,15 @@
28
28
 
29
29
  import { sectionBodies, NOTES_ASIDE, cleanNotes } from './deck-html.mjs';
30
30
 
31
- /** Each slide's notes as plain compared text, index-aligned to the deck. */
31
+ /**
32
+ * Each slide's notes as plain compared text, index-aligned to the deck —
33
+ * ⟨PAUSE⟩ markers kept, since a recording bakes them in (#560) and adding or
34
+ * moving one stales the take as surely as a changed word.
35
+ */
32
36
  function notesPerSlide(html) {
33
37
  return sectionBodies(html).map((body) => {
34
38
  const m = body.match(NOTES_ASIDE);
35
- return m ? cleanNotes(m[1]) : '';
39
+ return m ? cleanNotes(m[1], { marks: true }) : '';
36
40
  });
37
41
  }
38
42
 
@@ -93,7 +97,7 @@ export function impactWarning(impact) {
93
97
  const list = s.slides.join(', ');
94
98
  parts.push(`${s.dir}: the recording no longer matches the notes on slide${s.slides.length === 1 ? '' : 's'} ${list}`);
95
99
  }
96
- return `🎙 heads up — ${parts.join('; ')}. Z takes the edit back; the audio is still on disk.`;
100
+ return `🎙 heads up — ${parts.join('; ')}. ⌘Z (Ctrl+Z) takes the edit back; the audio is still on disk.`;
97
101
  }
98
102
 
99
103
  /**
@@ -0,0 +1,33 @@
1
+ // Copyright 2026 Gilles Philippart
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ /**
5
+ * Which theme a render opens on — the query parameters `video`, `pptx` and
6
+ * `pdf` put on the deck URL (#547).
7
+ *
8
+ * A render is a fresh browser with an empty profile, so a theme picked in the
9
+ * presenter's has to be TOLD to it. Two forms, the two the runtime's resolver
10
+ * already reads (src/core/themes.js `restoreSaved`):
11
+ *
12
+ * --theme <name> `?theme=` — one of the deck's own blocks, an added one,
13
+ * or a themes/<name>.css file.
14
+ * --gen <b64url> `?gen=` — a theme with no name the deck knows (a saved
15
+ * custom theme, an unsaved ⌃T roll): its tokens as base64url
16
+ * JSON `{ name, tokens }`, the form the picker's previews
17
+ * load. The runtime vets every token before it becomes CSS.
18
+ *
19
+ * Checked here, because both arrive from argv — and from a page, through the
20
+ * edit server's export route, which checks them the same way.
21
+ */
22
+ export const THEME_NAME = /^[\w-]{1,64}$/;
23
+ export const GEN_THEME = /^[\w-]{1,16384}$/;
24
+
25
+ /** `['theme=…']`, `['gen=…']` or `[]` — throws on a value that is neither. */
26
+ export function renderThemeParams({ theme = null, gen = null } = {}) {
27
+ if (theme != null && !THEME_NAME.test(theme)) throw new Error(`--theme takes a theme name, not ${JSON.stringify(theme)}`);
28
+ if (gen != null && !GEN_THEME.test(gen)) {
29
+ throw new Error('--gen takes a generated theme as base64url JSON {name, tokens}, at most 16 KB');
30
+ }
31
+ if (theme != null && gen != null) throw new Error('--theme or --gen, not both — one theme per render');
32
+ return [theme != null ? `theme=${encodeURIComponent(theme)}` : null, gen != null ? `gen=${gen}` : null].filter(Boolean);
33
+ }
@@ -131,8 +131,8 @@ export function indexSlides(sections, { titleOf, bodyOf }) {
131
131
  }
132
132
 
133
133
  /**
134
- * Fold the records into what a reader wants: comments, each with its replies and
135
- * whether it has been resolved.
134
+ * Fold the records into what a reader wants: comments, each with whether it
135
+ * has been resolved and where it was last moved to.
136
136
  *
137
137
  * The fold is the whole reason `op:"resolve"` is a separate line — state is
138
138
  * DERIVED from the log rather than stored, so two people resolving the same
@@ -142,23 +142,33 @@ export function indexSlides(sections, { titleOf, bodyOf }) {
142
142
  */
143
143
  export function foldReview(records) {
144
144
  const byId = new Map();
145
- const replies = [];
146
- const resolves = [];
145
+ const resolves = []; // resolve AND reopen: one history, applied in order
147
146
  const anchors = [];
147
+ const deletes = [];
148
148
  for (const r of records) {
149
- if (r.op === 'resolve') { resolves.push(r); continue; }
149
+ if (r.op === 'resolve' || r.op === 'reopen') { resolves.push(r); continue; }
150
150
  if (r.op === 'anchor') { anchors.push(r); continue; }
151
- if (r.re) { replies.push(r); continue; }
151
+ if (r.op === 'delete') { deletes.push(r); continue; }
152
+ // A record that names another comment and is no op was a reply, which an
153
+ // older decklight wrote and this one does not read (REVIEW: comments are
154
+ // one-way). Skipped, never a comment of its own: it has no slide.
155
+ if (r.re) continue;
152
156
  // A duplicate id is the same comment arriving twice (an import, a union
153
157
  // merge that saw both sides). First one wins; it is the same text.
154
- if (!byId.has(r.id)) byId.set(r.id, { ...r, replies: [], resolved: null });
158
+ if (!byId.has(r.id)) byId.set(r.id, { ...r, resolved: null });
155
159
  }
156
- for (const r of replies) byId.get(r.re)?.replies.push(r);
157
- for (const r of resolves) {
160
+ // Resolve and reopen are one history per comment and the LATEST wins: by
161
+ // `at` where both sides stamped one (a union merge keeps each side's order
162
+ // and nothing else, so file order alone would let a stale resolve from one
163
+ // clone outrank a later reopen from another), by file order otherwise. A
164
+ // comment resolved and then resolved again by somebody else is still
165
+ // resolved; reopened after, it is open.
166
+ const stamped = resolves.map((r, i) => ({ r, i })).sort((a, b) =>
167
+ String(a.r.at ?? '').localeCompare(String(b.r.at ?? '')) || a.i - b.i);
168
+ for (const { r } of stamped) {
158
169
  const c = byId.get(r.re);
159
- // Last resolve wins, but only over another resolve — a comment resolved and
160
- // then resolved again by somebody else is still resolved.
161
- if (c) c.resolved = { at: r.at ?? null, by: r.by ?? null };
170
+ if (!c) continue;
171
+ c.resolved = r.op === 'resolve' ? { at: r.at ?? null, by: r.by ?? null } : null;
162
172
  }
163
173
  // An anchor op MOVES a comment: the author, standing where the content
164
174
  // lives now, re-pins a comment whose slide was deleted or rewritten past
@@ -176,5 +186,11 @@ export function foldReview(records) {
176
186
  c.fp = r.fp ?? null;
177
187
  c.anchored = { at: r.at ?? null, by: r.by ?? null };
178
188
  }
189
+ // A delete op takes the comment out of every view — the CLI's, the panel's,
190
+ // the submit count's — while its line stays in the file, because the file
191
+ // is a log and an edit in place is what would break merge=union. Applied
192
+ // last, so a delete that a union merge placed above its comment still
193
+ // lands, and there is no undelete: the comment is its author's to withdraw.
194
+ for (const r of deletes) byId.delete(r.re);
179
195
  return [...byId.values()];
180
196
  }
@@ -0,0 +1,40 @@
1
+ // Copyright 2026 Gilles Philippart
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // Semantic Versioning, as decklight reads it (SPEC UNIT_VERSIONS): the pattern
5
+ // a catalog entry's or a design system's `version` must match, and precedence
6
+ // between two of them. Pure and dependency-free, so a module the runtime may
7
+ // one day bundle can share it with the CLI.
8
+
9
+ /** Semantic Versioning 2.0.0, exactly — no leading `v`, no two-part `1.1`. */
10
+ export const SEMVER_RE = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
11
+
12
+ /**
13
+ * Semver precedence: < 0 when `a` is older than `b`, 0 when equal, > 0 when
14
+ * newer. Build metadata is ignored; a prerelease sorts before its release,
15
+ * its dot-separated identifiers compared numerically where both are numbers.
16
+ * Null when either is not semver.
17
+ */
18
+ export function semverCompare(a, b) {
19
+ const pa = SEMVER_RE.exec(String(a ?? ''));
20
+ const pb = SEMVER_RE.exec(String(b ?? ''));
21
+ if (!pa || !pb) return null;
22
+ for (let i = 1; i <= 3; i++) {
23
+ const d = Number(pa[i]) - Number(pb[i]);
24
+ if (d) return Math.sign(d);
25
+ }
26
+ const ra = pa[4], rb = pb[4];
27
+ if (ra === rb) return 0;
28
+ if (ra === undefined) return 1; // 1.0.0 > 1.0.0-rc.1
29
+ if (rb === undefined) return -1;
30
+ const xa = ra.split('.'), xb = rb.split('.');
31
+ for (let i = 0; i < Math.max(xa.length, xb.length); i++) {
32
+ if (xa[i] === undefined) return -1;
33
+ if (xb[i] === undefined) return 1;
34
+ const na = /^\d+$/.test(xa[i]), nb = /^\d+$/.test(xb[i]);
35
+ if (na && nb) { const d = Number(xa[i]) - Number(xb[i]); if (d) return Math.sign(d); }
36
+ else if (na !== nb) return na ? -1 : 1;
37
+ else if (xa[i] !== xb[i]) return xa[i] < xb[i] ? -1 : 1;
38
+ }
39
+ return 0;
40
+ }
@@ -0,0 +1,180 @@
1
+ // Copyright 2026 Gilles Philippart
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // Where speech breaks into sentences — one rule for the live voice and captions
5
+ // (src/core/narration.js, which re-exports it) and for a rendered video's
6
+ // subtitles (tools/video.mjs), so the two break in the same places.
7
+ //
8
+ // In tools/ because the package ships tools/ and not src/: the CLI may not
9
+ // import from the runtime, and the runtime bundles what it imports from here.
10
+
11
+ /**
12
+ * Where the live voice breathes: sentence ends, with closing quotes kept on
13
+ * the sentence. An audio tag that FOLLOWS a sentence — `Wow! [laughs]` — is
14
+ * direction for that sentence, not one of its own: on its own it would be a
15
+ * clip that is only a laugh, or, on an engine that cannot act on tags, a clip
16
+ * of nothing.
17
+ */
18
+ export function splitSentences(text) {
19
+ const out = [];
20
+ for (let s of ((text ?? '').match(/[^.!?…]+[.!?…]+[”’"')\]]*|[^.!?…]+$/g) ?? []).map((x) => x.trim()).filter(Boolean)) {
21
+ // a `[pause]` a voice holds itself (`voicedPauses`) belongs to the words
22
+ // BEFORE it, as a ⟨PAUSE⟩ does — and so does any tag ahead of it
23
+ const held = out.length ? LEADING_PAUSE.exec(s) : null;
24
+ if (held) { out[out.length - 1] += ` ${held[1]}`; s = s.slice(held[0].length); }
25
+ if (!s) continue;
26
+ if (out.length && ONLY_TAGS.test(s)) out[out.length - 1] += ` ${s}`;
27
+ else out.push(s);
28
+ }
29
+ return out;
30
+ }
31
+
32
+ /**
33
+ * The let-it-sink-in marker (#560): `⟨PAUSE⟩` anywhere in a slide's notes
34
+ * holds twice the beat pause at that spot. Like ⟨CLICK⟩ it is punctuation for
35
+ * the voice, never words — and unlike ⟨CLICK⟩ it cuts no beat, so it lives
36
+ * INSIDE one, where only a recording can hold it. One definition here, read
37
+ * by the live voice, the deck's recorder, the synthesis core and a video's
38
+ * subtitles alike, so all four hold it in the same place.
39
+ */
40
+ export const PAUSE_MARK = '⟨PAUSE⟩';
41
+
42
+ /** The beat marker: segment k of a slide's notes narrates build step k. */
43
+ export const CLICK_MARK = '⟨CLICK⟩';
44
+
45
+ /**
46
+ * A long hold — ElevenLabs v4's own `[long pause]` — is two pauses: held by
47
+ * decklight the same on every engine, the way `[pause]` is, so a script
48
+ * written for v4 paces the same in piper's voice. As two marks it needs no
49
+ * path of its own anywhere downstream; `writtenMarks` gives the words back.
50
+ */
51
+ export const LONG_PAUSE = PAUSE_MARK + PAUSE_MARK;
52
+
53
+ /**
54
+ * `[slow]` WAS a marker — decklight said the stretch slower itself — and is
55
+ * now what any other bracketed word is, an audio tag (below): direction a
56
+ * voice that can act on it performs, and any other never hears. Its old
57
+ * spellings (`<slow>`, `⟨SLOW⟩`, `&lt;slow&gt;`) read as that tag, and a
58
+ * closing one (`[/slow]`) as nothing — never read aloud as words.
59
+ */
60
+ const SLOW_TAG = '[slow]';
61
+
62
+ const MARK_OF = { pause: PAUSE_MARK, 'short pause': PAUSE_MARK, click: CLICK_MARK, slow: SLOW_TAG, 'long pause': LONG_PAUSE };
63
+ const markFor = (close, word) => (close ? '' : MARK_OF[word.toLowerCase().replace(/\s+/g, ' ')]); // nothing has a close
64
+
65
+ // `[pause]`, `[short pause]` (ElevenLabs' own spelling of it), `<Click>`,
66
+ // `&lt;pause&gt;`, `[/slow]`, `⟨pause⟩` — any case, spaces
67
+ // inside allowed, the brackets a matched pair. Only these words: `[1]`,
68
+ // `[data-mouth]` and `<script>` in a note are somebody's prose.
69
+ const TEXT_MARK = /\[\s*(\/?)\s*(long\s+pause|short\s+pause|pause|click|slow)\s*\]|<\s*(\/?)\s*(long\s+pause|short\s+pause|pause|click|slow)\s*\/?\s*>|&lt;\s*(\/?)\s*(long\s+pause|short\s+pause|pause|click|slow)\s*\/?\s*&gt;|⟨\s*(\/?)\s*(long\s+pause|short\s+pause|pause|click|slow)\s*⟩/gi;
70
+
71
+ /**
72
+ * Every spelling of a marker written as TEXT, in its one canonical form —
73
+ * `[pause]` and `<PAUSE>` are `⟨PAUSE⟩`, `[click]` is `⟨CLICK⟩` — and any
74
+ * `slow` spelling is the `[slow]` tag, a closing one nothing. A script written
75
+ * for a person to record says `[pause]`; the deck should do what it says, not read it out.
76
+ * The canonical forms map to themselves, so a deck using only those reads —
77
+ * and hashes — exactly as before.
78
+ */
79
+ export const canonMarks = (text) => String(text ?? '').replace(TEXT_MARK,
80
+ (m, c1, w1, c2, w2, c3, w3, c4, w4) => markFor(c1 || c2 || c3 || c4, w1 || w2 || w3 || w4));
81
+
82
+ const MARK_TAG = /<(\/?)\s*(pause|click|slow)\b[^>]*>/gi;
83
+
84
+ /**
85
+ * Marker ELEMENTS in notes markup as their canonical text: `<pause>` and
86
+ * `<click>` (their closing tags dropped — an unclosed one only wraps the words
87
+ * after it, which stay words), and an old `<slow>` as the `[slow]` tag.
88
+ * Written in a deck's HTML they ARE elements, which `textContent` reads as
89
+ * nothing, so a tool reading the file has to see them the way the runtime's
90
+ * walk does (`notesPlain` in src/core/narration.js).
91
+ */
92
+ export const markTags = (html) => String(html ?? '').replace(MARK_TAG, (m, close, word) => markFor(close, word));
93
+
94
+ /** Notes MARKUP, every marker spelling — element or text — in canonical form. */
95
+ export const notesMarks = (html) => canonMarks(markTags(html));
96
+
97
+ /**
98
+ * The markers as decklight WRITES them: `[click]`, `[pause]` and
99
+ * `[long pause]` — the square brackets a script for a voice is
100
+ * written with (and ElevenLabs v4 reads). Every spelling is still READ
101
+ * (`canonMarks`); this is only what the notes editor shows, what a scaffold
102
+ * and a saved script are written in. Internally the forms stay ⟨…⟩ — that is
103
+ * what recordings were hashed against — so writing brackets re-voices nothing.
104
+ */
105
+ export const writtenMarks = (text) => String(text ?? '')
106
+ .replaceAll(LONG_PAUSE, '[long pause]').replaceAll(PAUSE_MARK, '[pause]').replaceAll(CLICK_MARK, '[click]');
107
+
108
+ /**
109
+ * The text as a voice that acts on audio tags is sent it: each ⟨PAUSE⟩ as
110
+ * `[pause]`, two as `[long pause]` — the voice holds them itself, in its own
111
+ * breath, inside one clip, rather than decklight cutting the sentence there
112
+ * and joining the pieces with silence. Only where there are words to hold
113
+ * between: a beat of nothing but pauses has no clip to put them in, so
114
+ * decklight holds it on every engine (`hasWords`).
115
+ */
116
+ export const voicedPauses = (text) => (hasWords(text)
117
+ ? String(text ?? '').replaceAll(LONG_PAUSE, ' [long pause] ').replaceAll(PAUSE_MARK, ' [pause] ').replace(/[ \t]+/g, ' ').trim()
118
+ : String(text ?? ''));
119
+
120
+ /**
121
+ * An AUDIO TAG: direction for a voice that can act on it — ElevenLabs v3 and
122
+ * v4's `[whispers]`, `[laughs]`, `[excited]`, `[door slams]`. Square brackets
123
+ * around words and nothing else (letters, spaces, a hyphen or an apostrophe),
124
+ * so `[1]`, `[ ]` and `[2024]` stay prose. The markers are not tags — they
125
+ * are read first (`canonMarks`) and never reach this.
126
+ */
127
+ const AUDIO_TAG = /\[\s*\p{L}[\p{L}' -]{0,38}\]/gu;
128
+ const ONLY_TAGS = /^(?:\[\s*\p{L}[\p{L}' -]{0,38}\]\s*)+$/u;
129
+ const LEADING_PAUSE = /^((?:\[\s*\p{L}[\p{L}' -]{0,38}\]\s*)*\[\s*(?:long\s+|short\s+)?pause\s*\])\s*/iu;
130
+
131
+ /** The text as an engine that CANNOT act on audio tags should hear it: every tag taken out, never read aloud. */
132
+ export const stripAudioTags = (text) => String(text ?? '').replace(AUDIO_TAG, ' ')
133
+ .replace(/[ \t]+/g, ' ').replace(/ ([.,;:!?…])/g, '$1').trim();
134
+
135
+ /** Each audio tag in `text` replaced by `fn(words)` — how a view shows one as a cue, not as prose. */
136
+ export const markAudioTags = (text, fn) => String(text ?? '').replace(AUDIO_TAG, (m) => fn(m.slice(1, -1).trim()));
137
+
138
+ /** What an engine is sent: tags kept for one that acts on them (`audioTags`), taken out for any other. */
139
+ export const forEngine = (engine, text) => (engine?.audioTags ? String(text ?? '') : stripAudioTags(text));
140
+
141
+ /** The text with every ⟨PAUSE⟩ gone — what is spoken, captioned, subtitled. */
142
+ export const stripPauses = (text) => String(text ?? '').replaceAll(PAUSE_MARK, ' ');
143
+
144
+ /** What of a text is words: every ⟨PAUSE⟩ gone, whitespace flat. */
145
+ export const spoken = (text) => stripPauses(text).replace(/\s+/g, ' ').trim();
146
+
147
+ /** What of a text is SAID, for a caption or a subtitle: `spoken`, and no audio tag — tags are direction, not words. */
148
+ export const captioned = (text) => stripAudioTags(spoken(text));
149
+
150
+ /**
151
+ * Is there anything here to TAKE? Words, not direction: a beat that is only
152
+ * `[pause]`s and audio tags has no take of its own on any engine — direction
153
+ * needs words to direct. Engine-blind on purpose: the runtime predicts the
154
+ * recorder's file names with it (`segmentFileIndex`), so a take cannot exist
155
+ * for one voice and not another.
156
+ */
157
+ export const hasWords = (text) => captioned(text) !== '';
158
+
159
+ /**
160
+ * A text cut at its ⟨PAUSE⟩ markers: `runs` are the stretches of words, each
161
+ * with the number of markers that FOLLOW it; `lead` counts the markers before
162
+ * any word at all.
163
+ *
164
+ * Every ⟨PAUSE⟩ belongs to the words before it — between two sentences,
165
+ * attached to one, or standing on its own line — except the ones before the
166
+ * first word, which hold before it. That difference is what keeps
167
+ * `A. ⟨PAUSE⟩ ⟨CLICK⟩ B.` (hold, then reveal) apart from
168
+ * `A. ⟨CLICK⟩ ⟨PAUSE⟩ B.` (reveal, then hold). A marker mid-sentence cuts the
169
+ * sentence there: the author put the silence exactly where they wanted it.
170
+ */
171
+ export function speechRuns(text) {
172
+ const runs = [];
173
+ let lead = 0;
174
+ String(text ?? '').split(PAUSE_MARK).forEach((p, j) => {
175
+ if (j > 0) { if (runs.length) runs[runs.length - 1].pause++; else lead++; }
176
+ const words = p.replace(/\s+/g, ' ').trim();
177
+ if (words) runs.push({ text: words, pause: 0 });
178
+ });
179
+ return { lead, runs };
180
+ }
package/tools/shot.mjs CHANGED
@@ -17,7 +17,7 @@
17
17
  // // shots/solo.mjs
18
18
  // press('/'); for (const c of 'solo') press(c); await sleep(100); press('Enter');
19
19
  //
20
- // The deck is served over http://127.0.0.1 under the `present` CSP — NOT opened
20
+ // The deck is served over http://127.0.0.1 under the `--no-trust` CSP — NOT opened
21
21
  // over file:// with --allow-file-access-from-files (#229). That flag let a
22
22
  // deck's own JS read any local file it could name (.git/config, tokens, keys)
23
23
  // and exfiltrate it, and shot runs on decks you have not vetted — a repro deck
@@ -34,7 +34,7 @@ import { promisify } from 'node:util';
34
34
  import { chromeBin, chromeArgs } from './chrome.mjs';
35
35
  import { argReader, isMain } from './args.mjs';
36
36
  import { injectBeforeBodyEnd } from './deck-html.mjs';
37
- import { serveForRender } from '../cli/present.mjs';
37
+ import { serveForRender } from '../cli/serve.mjs';
38
38
 
39
39
  const run = promisify(execFile);
40
40
 
@@ -68,7 +68,7 @@ export async function shotMain(argv, { render = chromeShot } = {}) {
68
68
 
69
69
  // The served root is the directory you run from — the deck must sit inside it,
70
70
  // so a source deck's `../dist/decklight.js` and `themes/…` still resolve as
71
- // relative URLs off the loopback origin. This is exactly `present`'s rule and
71
+ // relative URLs off the loopback origin. This is exactly the no-trust mode's rule and
72
72
  // for the same reason: exposure is chosen by where you run the command, and a
73
73
  // read cannot escape the served tree. `cd` to a directory containing the deck.
74
74
  const root = process.cwd();
@@ -94,19 +94,26 @@ export async function shotMain(argv, { render = chromeShot } = {}) {
94
94
  ${driver}
95
95
  </script>`;
96
96
 
97
- // Only the deck itself gets the theme link and the driver; every other html
97
+ // Only the deck itself gets the driver; every other html
98
98
  // asset under the root is served untouched.
99
99
  const inject = (text, file) => {
100
100
  if (file !== src) return text;
101
- let h = theme ? text.replace(/(<\/head>)/i, `<link rel="stylesheet" href="themes/${theme}.css">$1`) : text;
102
- return injectBeforeBodyEnd(h, boot) ?? h + boot;
101
+ return injectBeforeBodyEnd(text, boot) ?? text + boot;
103
102
  };
104
103
 
105
104
  mkdirSync(dirname(out), { recursive: true });
106
105
  const server = await serveForRender(root, { html: inject });
107
106
  try {
108
107
  const deckPath = '/' + relative(root, src).split(sep).join('/');
109
- const url = `${server.origin}${deckPath}${query ? `?${query}` : ''}${slide ? `#/${slide}/0` : ''}`;
108
+ // A plain shot is a picture of the DECK, so it loads as a render
109
+ // (`?capture`, #548): no toasts, no voice-over hint, no welcome card. A
110
+ // driven one is a picture of a feature being used, and the toast it raises
111
+ // may be the very thing the ticket asked to see — that load stays live.
112
+ // --theme rides the URL (`?theme=`), as in pdf/pptx/video: the runtime
113
+ // applies it to an inline block, an added one or a file alike (#547).
114
+ const search = [drive || keys.length ? null : 'capture', theme ? `theme=${encodeURIComponent(theme)}` : null, query]
115
+ .filter(Boolean).join('&');
116
+ const url = `${server.origin}${deckPath}${search ? `?${search}` : ''}${slide ? `#/${slide}/0` : ''}`;
110
117
  await render(chromeBin('shot'), chromeArgs(
111
118
  '--hide-scrollbars',
112
119
  '--autoplay-policy=no-user-gesture-required',
@@ -0,0 +1,114 @@
1
+ // Copyright 2026 Gilles Philippart
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // The narration clip on decklight.io: one showcase slide, narrated by the
5
+ // site's own voice track with captions on, its builds stepping with the voice.
6
+ // It is a RECORDING of the live deck, not a `decklight video` render: a render
7
+ // is one still per build step, so the strokes drawing in and the caption bar
8
+ // following the voice would never be in it.
9
+ //
10
+ // node tools/site-voices.mjs pull the voice track → site/voices/ (once)
11
+ // node tools/site-clip.mjs re-record site/img/narration.{webm,mp4,jpg}
12
+ //
13
+ // It bundles the showcase the way the site deploy does, with the voice track's
14
+ // per-beat clips switched on (segments), serves it on 127.0.0.1, plays the
15
+ // slide in Chrome (Playwright) and keeps the stretch from the first build to
16
+ // the last one plus a short hold, muted, as VP9 WebM, an H.264 MP4 for older
17
+ // Safari, and a poster frame. Re-run it when the slide or its notes change.
18
+ // Needs Playwright, Chrome and ffmpeg; never runs in CI.
19
+
20
+ import fs from 'node:fs';
21
+ import http from 'node:http';
22
+ import os from 'node:os';
23
+ import path from 'node:path';
24
+ import { execFileSync } from 'node:child_process';
25
+ import { fileURLToPath } from 'node:url';
26
+
27
+ const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
28
+ const args = process.argv.slice(2);
29
+ const opt = (name, fallback) => { const i = args.indexOf(name); return i === -1 ? fallback : args[i + 1]; };
30
+ const SLIDE = Number(opt('--slide', 7));
31
+ const OUT = path.resolve(ROOT, opt('--out', 'site/img/narration'));
32
+ const HOLD_MS = Number(opt('--hold', 2500));
33
+ const LIMIT_MS = 90_000;
34
+
35
+ const cfg = JSON.parse(fs.readFileSync(path.join(ROOT, 'site/voices.json'), 'utf8'));
36
+ const voices = path.join(ROOT, cfg.dir);
37
+ if (!fs.existsSync(path.join(voices, path.basename(cfg.voices[0].dir), 'manifest.json'))) {
38
+ console.error(`no voice track in ${cfg.dir}/ — run: node tools/site-voices.mjs pull`);
39
+ process.exit(1);
40
+ }
41
+
42
+ // ── the showcase, bundled with its voice, as the deploy does ─────────────────
43
+ const work = fs.mkdtempSync(path.join(os.tmpdir(), 'decklight-site-clip-'));
44
+ const site = path.join(work, 'site');
45
+ fs.mkdirSync(site);
46
+ fs.cpSync(voices, path.join(site, 'voices'), { recursive: true });
47
+ execFileSync(process.execPath, [path.join(ROOT, 'cli/decklight.mjs'), 'bundle', path.join(ROOT, cfg.deck),
48
+ '--themes', 'all', '-o', path.join(site, 'showcase.html')], { stdio: 'ignore' });
49
+ {
50
+ // segments: the per-beat clips drive the builds, one beat per [click]
51
+ const files = cfg.voices.map((v) => `{ label: ${JSON.stringify(v.label)}, dir: ${JSON.stringify(v.dir)}, segments: true }`).join(', ');
52
+ const p = path.join(site, 'showcase.html');
53
+ const html = fs.readFileSync(p, 'utf8');
54
+ const out = html.replace('Decklight.init({', `Decklight.init({\n narration: { files: [${files}] },`);
55
+ if (out === html) throw new Error('init config anchor not found in the bundled showcase');
56
+ fs.writeFileSync(p, out);
57
+ }
58
+
59
+ const TYPES = { '.html': 'text/html', '.m4a': 'audio/mp4', '.json': 'application/json', '.txt': 'text/plain' };
60
+ const server = http.createServer((req, res) => {
61
+ const rel = decodeURIComponent(new URL(req.url, 'http://x').pathname);
62
+ const file = path.join(site, rel);
63
+ if (!file.startsWith(site) || !fs.existsSync(file) || !fs.statSync(file).isFile()) { res.writeHead(404).end(); return; }
64
+ res.writeHead(200, { 'content-type': TYPES[path.extname(file)] ?? 'application/octet-stream' });
65
+ fs.createReadStream(file).pipe(res);
66
+ });
67
+ await new Promise((r) => server.listen(0, '127.0.0.1', r));
68
+ const base = `http://127.0.0.1:${server.address().port}`;
69
+
70
+ // ── play the slide and record it ─────────────────────────────────────────────
71
+ const { chromium } = await import('playwright');
72
+ const browser = await chromium.launch({ channel: 'chrome', args: ['--autoplay-policy=no-user-gesture-required'] });
73
+ const videoDir = path.join(work, 'video');
74
+ const ctx = await browser.newContext({ viewport: { width: 1280, height: 720 }, recordVideo: { dir: videoDir, size: { width: 1280, height: 720 } } });
75
+ const recordingFrom = Date.now();
76
+ const page = await ctx.newPage();
77
+ // ?embedded hides the controls and saves nothing; &captions shows the caption bar
78
+ await page.goto(`${base}/showcase.html?embedded&captions&voiceover#/${SLIDE}/0`, { waitUntil: 'networkidle' });
79
+ await page.evaluate(() => {
80
+ // the engine dispatches on the deck's root, and the event does not bubble
81
+ window.__steps = [];
82
+ document.querySelector('.decklight').addEventListener('decklight:build',
83
+ (e) => window.__steps.push({ at: Date.now(), index: e.detail.index, total: e.detail.total }));
84
+ });
85
+ await page.waitForTimeout(500);
86
+ await page.keyboard.press('Shift'); // the gesture ?voiceover waits for, without moving the deck
87
+ const deadline = Date.now() + LIMIT_MS;
88
+ let steps = [];
89
+ while (Date.now() < deadline) {
90
+ steps = await page.evaluate(() => window.__steps);
91
+ if (steps.length && steps.at(-1).index >= steps.at(-1).total) break;
92
+ await page.waitForTimeout(250);
93
+ }
94
+ if (!steps.length) throw new Error(`slide ${SLIDE} never stepped: is the voice track playing?`);
95
+ await page.waitForTimeout(HOLD_MS);
96
+ const video = await page.video().path();
97
+ await ctx.close();
98
+ await browser.close();
99
+ server.close();
100
+
101
+ // ── cut from just before the first build to the hold after the last ──────────
102
+ const from = Math.max(0, (steps[0].at - recordingFrom) / 1000 - 0.8);
103
+ const to = (steps.at(-1).at - recordingFrom + HOLD_MS) / 1000;
104
+ const ff = (...a) => execFileSync('ffmpeg', ['-loglevel', 'error', '-y', ...a], { stdio: 'inherit' });
105
+ const cut = ['-ss', from.toFixed(2), '-to', to.toFixed(2), '-i', video, '-vf', 'scale=960:-2', '-an'];
106
+ fs.mkdirSync(path.dirname(OUT), { recursive: true });
107
+ ff(...cut, '-c:v', 'libvpx-vp9', '-crf', '34', '-b:v', '0', '-row-mt', '1', `${OUT}.webm`);
108
+ ff(...cut, '-c:v', 'libx264', '-crf', '26', '-preset', 'slow', '-pix_fmt', 'yuv420p', '-movflags', '+faststart', `${OUT}.mp4`);
109
+ ff('-sseof', '-0.3', '-i', `${OUT}.mp4`, '-frames:v', '1', '-q:v', '4', `${OUT}.jpg`);
110
+ fs.rmSync(work, { recursive: true, force: true });
111
+
112
+ const kb = (f) => `${Math.round(fs.statSync(f).size / 1024)} KB`;
113
+ console.log(`slide ${SLIDE}: ${steps.length} builds, ${(to - from).toFixed(1)}s`
114
+ + ` → ${path.relative(ROOT, OUT)}.webm (${kb(`${OUT}.webm`)}), .mp4 (${kb(`${OUT}.mp4`)}), .jpg (${kb(`${OUT}.jpg`)})`);