decklight 0.8.1 → 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 +57 -24
- 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 +1 -1
- 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 +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 +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
|
@@ -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.
|
package/tools/publish-voices.mjs
CHANGED
|
@@ -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
|
|
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}
|
|
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}
|
|
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
|
-
/**
|
|
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
|
+
}
|
package/tools/review-anchor.mjs
CHANGED
|
@@ -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
|
|
135
|
-
*
|
|
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
|
|
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.
|
|
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,
|
|
158
|
+
if (!byId.has(r.id)) byId.set(r.id, { ...r, resolved: null });
|
|
155
159
|
}
|
|
156
|
-
|
|
157
|
-
|
|
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
|
-
|
|
160
|
-
|
|
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
|
}
|
package/tools/semver.mjs
ADDED
|
@@ -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⟩`, `<slow>`) 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
|
+
// `<pause>`, `[/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*>|<\s*(\/?)\s*(long\s+pause|short\s+pause|pause|click|slow)\s*\/?\s*>|⟨\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 `
|
|
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/
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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',
|