decklight 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/PLATFORM.md +666 -0
- package/README.md +224 -150
- package/SPEC.md +732 -886
- package/cli/agent-review.mjs +245 -0
- package/cli/agents.mjs +25 -5
- package/cli/associate.mjs +12 -12
- package/cli/audit.mjs +42 -10
- package/cli/banner.mjs +41 -17
- package/cli/bundle-audio.mjs +183 -0
- package/cli/bundle.mjs +383 -31
- package/cli/cast.mjs +7 -7
- package/cli/check.mjs +961 -0
- package/cli/clone-deck.mjs +179 -0
- package/cli/commands.mjs +345 -0
- package/cli/comments.mjs +64 -18
- package/cli/commit-flow.mjs +44 -19
- package/cli/commit-message.mjs +51 -74
- package/cli/commit-split.mjs +601 -0
- package/cli/deck-refs.mjs +59 -0
- package/cli/deck-routes.mjs +67 -0
- package/cli/deckfile.mjs +3 -5
- package/cli/decklight.mjs +68 -289
- package/cli/design-system-deps.mjs +209 -0
- package/cli/design-system-edit.mjs +194 -0
- package/cli/design-system-refs.mjs +409 -0
- package/cli/design-system.mjs +429 -0
- package/cli/doctor.mjs +115 -0
- package/cli/edit-git.mjs +353 -0
- package/cli/edit-handover.mjs +445 -0
- package/cli/edit-look.mjs +388 -0
- package/cli/edit-slides.mjs +683 -0
- package/cli/edit.mjs +2126 -842
- package/cli/enhance.mjs +483 -0
- package/cli/extension.mjs +10 -10
- package/cli/font-refs.mjs +273 -0
- package/cli/font.mjs +246 -0
- package/cli/git-tree.mjs +1 -1
- package/cli/git.mjs +65 -11
- package/cli/import.mjs +56 -10
- package/cli/init.mjs +400 -234
- package/cli/library.mjs +127 -0
- package/cli/loader.mjs +3 -1
- package/cli/marketplace.mjs +215 -21
- package/cli/narrate.mjs +176 -0
- package/cli/open-browser.mjs +63 -0
- package/cli/open.mjs +943 -0
- package/cli/pdf.mjs +41 -13
- package/cli/pkg.mjs +44 -2
- package/cli/plugin.mjs +43 -41
- package/cli/port-conflict.mjs +53 -23
- package/cli/pptx-export.mjs +71 -26
- package/cli/publish.mjs +8 -4
- package/cli/qr.mjs +1 -1
- package/cli/record.mjs +14 -12
- package/cli/remote.mjs +11 -11
- package/cli/restore.mjs +11 -4
- package/cli/review-ref.mjs +125 -0
- package/cli/review-remote.mjs +92 -48
- package/cli/review-routes.mjs +254 -0
- package/cli/review-store.mjs +47 -7
- package/cli/review-submit.mjs +47 -57
- package/cli/runtime-link.mjs +560 -0
- package/cli/serve.mjs +235 -44
- package/cli/setup.mjs +112 -0
- package/cli/sign.mjs +1 -1
- package/cli/skill-content.mjs +190 -33
- package/cli/skills.mjs +107 -24
- package/cli/start.mjs +110 -0
- package/cli/supervise.mjs +6 -6
- package/cli/theme-refs.mjs +515 -0
- package/cli/theme.mjs +181 -137
- package/cli/trust.mjs +83 -0
- package/cli/units.mjs +39 -42
- package/cli/update-check.mjs +1 -5
- package/cli/upgrade.mjs +194 -28
- package/cli/upstream.mjs +4 -3
- package/cli/util.mjs +4 -4
- package/cli/wizard.mjs +6 -6
- package/dist/build-info.json +1 -1
- package/dist/decklight.css +1126 -49
- package/dist/decklight.js +212 -115
- package/dist/decklight.js.map +4 -4
- package/docs/GLOSSARY.md +141 -0
- package/docs/architecture.svg +17 -17
- package/package.json +4 -2
- package/themes/README.md +9 -8
- package/themes/reveal-solarized.css +10 -0
- package/tools/args.mjs +20 -0
- package/tools/atomic-write.mjs +48 -0
- package/tools/brand-palette.mjs +717 -0
- package/tools/bridge.mjs +1 -1
- package/tools/build-groups.mjs +42 -0
- package/tools/color.mjs +48 -0
- package/tools/deck-html.mjs +396 -11
- package/tools/design-system-format.mjs +753 -0
- package/tools/elevenlabs-tts.mjs +110 -17
- package/tools/exec.mjs +35 -2
- package/tools/extension-check.mjs +31 -7
- package/tools/font-format.mjs +190 -0
- package/tools/font-stacks.mjs +24 -0
- package/tools/gemini-tts.mjs +3 -0
- package/tools/lipsync-config.mjs +103 -0
- package/tools/lipsync-engines.mjs +205 -2
- package/tools/lipsync-server.mjs +264 -41
- package/tools/lipsync.mjs +37 -18
- package/tools/local-voice.mjs +32 -42
- package/tools/narration-manifest.mjs +196 -0
- package/tools/narration-synth.mjs +416 -0
- package/tools/pptx.mjs +776 -19
- package/tools/publish-targets.mjs +1 -1
- package/tools/publish-voices.mjs +3 -3
- package/tools/recording-impact.mjs +7 -3
- package/tools/render-theme.mjs +33 -0
- package/tools/review-anchor.mjs +28 -12
- package/tools/semver.mjs +40 -0
- package/tools/sentences.mjs +180 -0
- package/tools/shot.mjs +14 -7
- package/tools/site-voices.mjs +232 -0
- package/tools/template-theme.mjs +1 -1
- package/tools/test-impact.mjs +19 -10
- package/tools/theme-check.mjs +30 -3
- package/tools/tts-cache.mjs +4 -3
- package/tools/tts-engines.mjs +38 -20
- package/tools/tts-setup.mjs +7 -7
- package/tools/video-options.mjs +34 -0
- package/tools/video.mjs +461 -48
- package/tools/voiceover-server.mjs +185 -104
- package/tools/voiceover.mjs +119 -261
- package/tools/zip.mjs +1 -1
- package/cli/dev.mjs +0 -623
- package/cli/present.mjs +0 -853
- package/cli/review.mjs +0 -361
- package/tools/publish-site-voices.mjs +0 -75
package/cli/pdf.mjs
CHANGED
|
@@ -19,10 +19,12 @@
|
|
|
19
19
|
// have already emailed is a slide nobody can fix.
|
|
20
20
|
|
|
21
21
|
import { existsSync, readFileSync, rmSync, statSync } from 'node:fs';
|
|
22
|
-
import { basename, resolve } from 'node:path';
|
|
22
|
+
import { basename, dirname, relative, resolve, sep } from 'node:path';
|
|
23
|
+
import { serveForRender } from './serve.mjs';
|
|
23
24
|
import { chromeBin, chromeArgs } from '../tools/chrome.mjs';
|
|
24
25
|
import { argReader, isMain } from '../tools/args.mjs';
|
|
25
|
-
import {
|
|
26
|
+
import { renderThemeParams } from '../tools/render-theme.mjs';
|
|
27
|
+
import { runAsync, CODEC_MS } from '../tools/exec.mjs';
|
|
26
28
|
import { sectionBodies, isHiddenSection } from '../tools/deck-html.mjs';
|
|
27
29
|
|
|
28
30
|
/**
|
|
@@ -42,7 +44,7 @@ import { sectionBodies, isHiddenSection } from '../tools/deck-html.mjs';
|
|
|
42
44
|
*/
|
|
43
45
|
export const HANDOUT_PER_PAGE = 3;
|
|
44
46
|
|
|
45
|
-
const USAGE = `usage: decklight pdf <deck.html> [-o out.pdf] [--theme <name>] [--wait <ms>]
|
|
47
|
+
const USAGE = `usage: decklight pdf <deck.html> [-o out.pdf] [--theme <name> | --gen <b64url>] [--wait <ms>]
|
|
46
48
|
[--notes | --handout]
|
|
47
49
|
renders the deck's ?print view to a PDF — one slide per page, at the deck's
|
|
48
50
|
own 1280×720, in its theme, with every build complete
|
|
@@ -53,6 +55,8 @@ const USAGE = `usage: decklight pdf <deck.html> [-o out.pdf] [--theme <name>] [-
|
|
|
53
55
|
--handout three slides a page, portrait, ruled lines beside each for
|
|
54
56
|
the audience to write on [out: <deck>.handout.pdf]
|
|
55
57
|
--theme <name> export in another theme (rides ?theme=)
|
|
58
|
+
--gen <b64url> export in a custom or generated theme, as {name, tokens}
|
|
59
|
+
base64url JSON (rides ?gen=)
|
|
56
60
|
--wait <ms> render budget for heavy decks [8000]
|
|
57
61
|
|
|
58
62
|
slides the print-mode overflow guardrail flags are named on stderr; the PDF
|
|
@@ -68,12 +72,14 @@ export function pdfOut(deckPath, oFlag, variant = '') {
|
|
|
68
72
|
/**
|
|
69
73
|
* The URL to print. `?print` is the whole rendering contract; `?theme=` is the
|
|
70
74
|
* existing startup override, so exporting in another theme costs nothing here.
|
|
75
|
+
* `base` is where the deck is served — a `file://` path, or the render
|
|
76
|
+
* server's origin plus the deck's path under its root.
|
|
71
77
|
*/
|
|
72
|
-
export function printUrl(
|
|
78
|
+
export function printUrl(base, { theme, gen, variant = '' } = {}) {
|
|
73
79
|
// `?print=notes` / `?print=handout` are the runtime's own variants (src/core/print.js)
|
|
74
80
|
const print = variant ? `?print=${variant}` : '?print';
|
|
75
|
-
const q = theme
|
|
76
|
-
return `file://${
|
|
81
|
+
const q = [print, ...renderThemeParams({ theme, gen })].join('&');
|
|
82
|
+
return `${/^[a-z]+:\/\//i.test(base) ? base : `file://${base}`}${q}`;
|
|
77
83
|
}
|
|
78
84
|
|
|
79
85
|
/**
|
|
@@ -149,19 +155,41 @@ export async function pdfMain(args = []) {
|
|
|
149
155
|
}
|
|
150
156
|
const out = pdfOut(src, opt('-o'), variant);
|
|
151
157
|
const theme = opt('--theme');
|
|
158
|
+
const gen = opt('--gen');
|
|
159
|
+
try { renderThemeParams({ theme, gen }); } catch (e) { console.error(`decklight pdf: ${e.message}`); return 1; }
|
|
152
160
|
const wait = Number(opt('--wait', 8000));
|
|
153
|
-
const url = printUrl(src, { theme, variant });
|
|
154
161
|
const bin = chromeBin('pdf');
|
|
155
|
-
//
|
|
156
|
-
|
|
162
|
+
// The deck is SERVED, from its own directory, the way shot and video serve
|
|
163
|
+
// theirs: a deck that references the runtime (#517) or carries none at all
|
|
164
|
+
// (#520) plays from the installed package that way, where a file:// load
|
|
165
|
+
// would find no engine beside it. Same-origin, so its casts and media load
|
|
166
|
+
// exactly as siblings did.
|
|
167
|
+
const root = dirname(src);
|
|
168
|
+
const server = await serveForRender(root);
|
|
169
|
+
const url = printUrl(`${server.origin}/${relative(root, src).split(sep).join('/')}`, { theme, gen, variant });
|
|
170
|
+
const shared = chromeArgs(`--virtual-time-budget=${wait}`);
|
|
171
|
+
try {
|
|
172
|
+
return await printDeck({ src, out, url, bin, shared, variant, theme });
|
|
173
|
+
} finally {
|
|
174
|
+
await server.close();
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
async function printDeck({ src, out, url, bin, shared, variant, theme }) {
|
|
157
179
|
|
|
180
|
+
// Chrome is AWAITED, never `run`: the in-process render server above has
|
|
181
|
+
// to answer the browser it launched (the deadlock pptx documents), and the
|
|
182
|
+
// edit server runs `pdfMain` in its own process for the palette's Export
|
|
183
|
+
// rows, where a synchronous child would freeze live reload, the SSE stream
|
|
184
|
+
// and the page itself for the ten seconds Chrome takes to print.
|
|
185
|
+
//
|
|
158
186
|
// Pass one: the DOM, for the slide count and the overflow audit. Cheap — the
|
|
159
187
|
// same URL, the same budget, and it is the only way to know what the PDF is
|
|
160
188
|
// about to hide.
|
|
161
189
|
let html = '';
|
|
162
190
|
try {
|
|
163
|
-
html =
|
|
164
|
-
{ encoding: 'utf8', maxBuffer: 64 * 1024 * 1024,
|
|
191
|
+
html = await runAsync(bin, [...shared, '--dump-dom', url],
|
|
192
|
+
{ encoding: 'utf8', maxBuffer: 64 * 1024 * 1024, timeout: CODEC_MS, why: 'Chrome did not finish rendering — a slide is probably waiting on a resource it cannot reach' });
|
|
165
193
|
} catch { /* the print pass below is the one that must succeed */ }
|
|
166
194
|
const slides = slideCount(html);
|
|
167
195
|
console.error(`pdf: rendering ${basename(src)}?print${variant ? `=${variant}` : ''}${theme ? ` · theme ${theme}` : ''}`
|
|
@@ -169,8 +197,8 @@ export async function pdfMain(args = []) {
|
|
|
169
197
|
|
|
170
198
|
rmSync(out, { force: true }); // never leave a stale PDF looking like a fresh one
|
|
171
199
|
try {
|
|
172
|
-
|
|
173
|
-
{
|
|
200
|
+
await runAsync(bin, [...shared, '--no-pdf-header-footer', `--print-to-pdf=${out}`, url],
|
|
201
|
+
{ maxBuffer: 32 * 1024 * 1024, timeout: CODEC_MS, why: 'Chrome did not finish rendering — a slide is probably waiting on a resource it cannot reach' });
|
|
174
202
|
} catch (e) {
|
|
175
203
|
console.error(`decklight pdf: Chrome failed — ${String(e.message ?? e).split('\n')[0]}`);
|
|
176
204
|
return 1;
|
package/cli/pkg.mjs
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
// WHY THIS IS ONE MODULE AND NOT FIVE CONSTANTS. Four commands write a deck
|
|
8
8
|
// that carries the runtime inline — `init` scaffolds one, `import` converts
|
|
9
9
|
// one, `upgrade` refreshes one, `bundle` inlines a referenced one — and
|
|
10
|
-
// `audit` recomputes what they SHOULD have produced, so that `
|
|
11
|
-
// say whether the runtime in a file is this install's build (
|
|
10
|
+
// `audit` recomputes what they SHOULD have produced, so that `--no-trust` can
|
|
11
|
+
// say whether the runtime in a file is this install's build (NO_TRUST#AUDIT).
|
|
12
12
|
// That makes the inlining transform a contract between five files, and it was
|
|
13
13
|
// copied into each of them. `import` copied it slightly wrong: its local
|
|
14
14
|
// escape covered `</script` and `</style` but not `<!--`, so an imported deck
|
|
@@ -41,6 +41,23 @@ export const PKG_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)
|
|
|
41
41
|
/** package.json, parsed once. `PKG.version` is the version every command prints. */
|
|
42
42
|
export const PKG = JSON.parse(fs.readFileSync(path.join(PKG_ROOT, 'package.json'), 'utf8'));
|
|
43
43
|
|
|
44
|
+
/**
|
|
45
|
+
* How to type decklight here, for a line that tells someone to run it.
|
|
46
|
+
* `npx decklight` when this install is the project's own (a node_modules on
|
|
47
|
+
* the way up from `cwd` resolves to it), plain `decklight` otherwise: a
|
|
48
|
+
* global install or a link puts the bin on PATH, a project install does not,
|
|
49
|
+
* and a bare `decklight skills` in a project reads as a remark rather than a
|
|
50
|
+
* command, because typing it says "command not found".
|
|
51
|
+
*/
|
|
52
|
+
export function selfCommand(cwd = process.cwd(), root = PKG_ROOT) {
|
|
53
|
+
let mine;
|
|
54
|
+
try { mine = fs.realpathSync(root); } catch { return 'decklight'; }
|
|
55
|
+
for (let dir = path.resolve(cwd); ; dir = path.dirname(dir)) {
|
|
56
|
+
try { if (fs.realpathSync(path.join(dir, 'node_modules', 'decklight')) === mine) return 'npx decklight'; } catch { /* not here */ }
|
|
57
|
+
if (path.dirname(dir) === dir) return 'decklight';
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
44
61
|
/** The shipped theme set — the graded and compat themes that stay in core. */
|
|
45
62
|
export const THEMES_DIR = path.join(PKG_ROOT, 'themes');
|
|
46
63
|
|
|
@@ -67,3 +84,28 @@ export function runtimeJs() {
|
|
|
67
84
|
|
|
68
85
|
/** The installed runtime stylesheet. */
|
|
69
86
|
export const runtimeCss = () => fs.readFileSync(path.join(PKG_ROOT, 'dist/decklight.css'), 'utf8');
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* The installed package's own copy of a file a deck references beside itself
|
|
90
|
+
* but does not ship — `decklight.js`, `decklight.css`, `themes/<name>.css` —
|
|
91
|
+
* as `{ file, type }`, or null for anything else (#517).
|
|
92
|
+
*
|
|
93
|
+
* A deck that LINKS the runtime instead of carrying it is a few KB of slides
|
|
94
|
+
* whose runtime is whatever is installed. Every server (`open`, `--no-trust`,
|
|
95
|
+
* the render server behind pdf/pptx/video) answers those three shapes from
|
|
96
|
+
* here when nothing is on disk, and `bundle` inlines from here at hand-over,
|
|
97
|
+
* so the same deck plays served and travels self-contained. Matched on the
|
|
98
|
+
* path's TAIL, so a deck in `slides/` asking for `slides/decklight.js`, or a
|
|
99
|
+
* source deck reaching up for `../dist/decklight.js`, both resolve. A theme
|
|
100
|
+
* that is not shipped is null, like any other missing file.
|
|
101
|
+
*/
|
|
102
|
+
export function packageAsset(rel) {
|
|
103
|
+
const p = String(rel ?? '').split('\\').join('/');
|
|
104
|
+
const base = p.split('/').pop();
|
|
105
|
+
const at = (file, type) => (fs.existsSync(file) ? { file, type } : null);
|
|
106
|
+
if (base === 'decklight.js') return at(path.join(PKG_ROOT, 'dist', 'decklight.js'), 'text/javascript; charset=utf-8');
|
|
107
|
+
if (base === 'decklight.css') return at(path.join(PKG_ROOT, 'dist', 'decklight.css'), 'text/css; charset=utf-8');
|
|
108
|
+
const theme = /(?:^|\/)themes\/([\w-]+)\.css$/.exec(p);
|
|
109
|
+
if (theme) return at(path.join(THEMES_DIR, `${theme[1]}.css`), 'text/css; charset=utf-8');
|
|
110
|
+
return null;
|
|
111
|
+
}
|
package/cli/plugin.mjs
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* `decklight plugin` — the presenter's own chrome, installed from a
|
|
7
|
-
* marketplace and loaded by `
|
|
6
|
+
* `decklight library … plugin` — the presenter's own chrome, installed from a
|
|
7
|
+
* marketplace and loaded by `--no-trust` (MARKETPLACE.md NO_TRUST#PLUGINS).
|
|
8
8
|
*
|
|
9
|
-
* decklight
|
|
10
|
-
* decklight
|
|
11
|
-
* decklight plugin
|
|
12
|
-
* decklight
|
|
9
|
+
* decklight library add plugin <name[@marketplace]>
|
|
10
|
+
* decklight library list plugin
|
|
11
|
+
* decklight library gate plugin <name | directory>
|
|
12
|
+
* decklight library remove plugin <name>
|
|
13
13
|
*
|
|
14
14
|
* WHY THIS IS ALLOWED TO EXIST AT ALL. The asymmetry MARKETPLACE.md WHY is
|
|
15
15
|
* built on: a plugin is safe when the installer is the risk-bearer, and unsafe
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
*
|
|
43
43
|
* WHAT IT COSTS THE DECK: nothing. The chrome is injected on the way OUT of
|
|
44
44
|
* the presenting server, after the ingredients label has already read the
|
|
45
|
-
* bytes on disk (
|
|
46
|
-
* could not account for (
|
|
45
|
+
* bytes on disk (NO_TRUST#AUDIT) and after strict mode has stripped what it
|
|
46
|
+
* could not account for (NO_TRUST#STRICT) — so a plugin is never audited as if
|
|
47
47
|
* it came from the deck, and never stripped as if it were unaccounted. The
|
|
48
48
|
* srcdoc frame needs no route and no CSP change (see `chromeMarkup`).
|
|
49
49
|
*/
|
|
@@ -56,14 +56,14 @@ import { isMain } from '../tools/args.mjs';
|
|
|
56
56
|
import { injectBeforeBodyEnd } from '../tools/deck-html.mjs';
|
|
57
57
|
// Cache reads only. `loadCatalog` and `resolveEntry` read JSON already on
|
|
58
58
|
// disk; the fetching half of marketplace.mjs is deliberately not imported
|
|
59
|
-
// here, because `
|
|
59
|
+
// here, because `--no-trust` imports this file and a presenting path that COULD
|
|
60
60
|
// fetch a catalog breaks registered-not-fetched (SPEC MARKETPLACE_REGISTRY) —
|
|
61
61
|
// a deck on a plane has to behave exactly like a deck at a desk. The one
|
|
62
62
|
// network call in this module is `fetchPlugin`, which is an ARTIFACT fetch on
|
|
63
63
|
// an explicit `plugin add`; `resolveSource` is imported dynamically there so
|
|
64
64
|
// it is not even resolved on the serving path.
|
|
65
65
|
import {
|
|
66
|
-
configHome, loadRegistry, loadCatalog, resolveEntry, MarketplaceError, NAME_RE,
|
|
66
|
+
configHome, loadRegistry, loadCatalog, resolveEntry, MarketplaceError, NAME_RE, recordInstall, forgetInstall,
|
|
67
67
|
} from './marketplace.mjs';
|
|
68
68
|
|
|
69
69
|
/** A failure with a message for a human — the mains print it, never a stack. */
|
|
@@ -93,7 +93,7 @@ export const SLOTS = ['corner-tl', 'corner-tr', 'corner-bl', 'corner-br', 'edge-
|
|
|
93
93
|
* determinism rule is about mutation, and the speaker view already puts these
|
|
94
94
|
* exact words on this exact machine. What keeps it honest is that it is
|
|
95
95
|
* DECLARED: a plugin gets notes only by asking for them in its manifest, and
|
|
96
|
-
* both `plugin list` and the `
|
|
96
|
+
* both `plugin list` and the `--no-trust` startup line say which plugins read
|
|
97
97
|
* them. A timer never sees a word of the talk.
|
|
98
98
|
*/
|
|
99
99
|
export const NEEDS = ['position', 'notes'];
|
|
@@ -255,7 +255,7 @@ export function loadPlugin(dir) {
|
|
|
255
255
|
*
|
|
256
256
|
* A bad plugin is skipped, never fatal: the alternative is a command that
|
|
257
257
|
* refuses to present a talk because of a timer, ten minutes before the talk —
|
|
258
|
-
* the same argument
|
|
258
|
+
* the same argument NO_TRUST#STRICT settles the same way.
|
|
259
259
|
*/
|
|
260
260
|
export function loadLibrary(home = configHome()) {
|
|
261
261
|
const dir = pluginsDir(home);
|
|
@@ -326,7 +326,7 @@ ${plugin.source}
|
|
|
326
326
|
* them, and this way the shim needs no handle on a root that may not exist
|
|
327
327
|
* yet when it runs.
|
|
328
328
|
*
|
|
329
|
-
* Nothing here is added to the runtime: `
|
|
329
|
+
* Nothing here is added to the runtime: `--no-trust` injects this, `bundle` never
|
|
330
330
|
* does, and a deck opened any other way has never heard of it.
|
|
331
331
|
*/
|
|
332
332
|
function hostShim(plugins) {
|
|
@@ -408,7 +408,7 @@ const CHROME_CSS = `<style>
|
|
|
408
408
|
* instead, and the presenting CSP already carries `script-src 'unsafe-inline'`
|
|
409
409
|
* because a bundled deck IS inline script. So the chrome loads under exactly
|
|
410
410
|
* the header the deck is served with, no route is registered for it, and
|
|
411
|
-
*
|
|
411
|
+
* the no-trust mode's policy string is untouched by a plugin being installed.
|
|
412
412
|
*
|
|
413
413
|
* `sandbox="allow-scripts"` without `allow-same-origin` is the load-bearing
|
|
414
414
|
* attribute: it hands the frame an opaque origin, so `parent.document` throws.
|
|
@@ -426,11 +426,11 @@ export function chromeMarkup(plugins) {
|
|
|
426
426
|
/**
|
|
427
427
|
* Put the chrome into a served document, immediately before `</body>`.
|
|
428
428
|
*
|
|
429
|
-
* Called by `
|
|
429
|
+
* Called by `--no-trust` AFTER the audit has read the file and AFTER strict mode
|
|
430
430
|
* has run, which is the whole reason the ingredients label stays honest: the
|
|
431
431
|
* label describes the bytes on disk, and these bytes were never on disk.
|
|
432
432
|
* With no plugins installed this returns its input unchanged — byte for byte,
|
|
433
|
-
* which is what keeps `
|
|
433
|
+
* which is what keeps `--no-trust` on a machine with an empty library exactly the
|
|
434
434
|
* command it was before this existed.
|
|
435
435
|
*/
|
|
436
436
|
export function injectChrome(html, plugins) {
|
|
@@ -446,24 +446,24 @@ export function injectChrome(html, plugins) {
|
|
|
446
446
|
|
|
447
447
|
// ── the command ────────────────────────────────────────────────────────────
|
|
448
448
|
|
|
449
|
-
const USAGE = `usage: decklight
|
|
449
|
+
const USAGE = `usage: decklight library <add|list|check|remove> plugin …
|
|
450
450
|
|
|
451
|
-
decklight
|
|
451
|
+
decklight library add plugin <name[@marketplace]>
|
|
452
452
|
install a presenter plugin from a registered marketplace into your own
|
|
453
453
|
library under ~/.decklight/plugins/. It is yours: it never enters a deck,
|
|
454
454
|
never travels with one, and bundle cannot see it
|
|
455
|
-
EXAMPLE: decklight
|
|
456
|
-
EXAMPLE: decklight
|
|
455
|
+
EXAMPLE: decklight library add plugin timer
|
|
456
|
+
EXAMPLE: decklight library add plugin teleprompter@decklight
|
|
457
457
|
|
|
458
|
-
decklight
|
|
458
|
+
decklight library list plugin
|
|
459
459
|
what is installed, where each sits, and which ones read your speaker notes
|
|
460
460
|
|
|
461
|
-
decklight plugin
|
|
461
|
+
decklight library gate plugin <name | directory>
|
|
462
462
|
validate a plugin without installing it — the same manifest vocabulary and
|
|
463
463
|
the same lint the loader applies. Exits non-zero on a refusal, so a
|
|
464
464
|
plugin's own CI can gate on it
|
|
465
465
|
|
|
466
|
-
decklight
|
|
466
|
+
decklight library remove plugin <name>
|
|
467
467
|
delete it from your library
|
|
468
468
|
|
|
469
469
|
A plugin is two files. Its code runs in a sandboxed frame with an opaque
|
|
@@ -491,10 +491,10 @@ const USAGE = `usage: decklight plugin <add|list|check|remove> …
|
|
|
491
491
|
|
|
492
492
|
slots: ${SLOTS.join(', ')}
|
|
493
493
|
needs: ${NEEDS.join(', ')} — "notes" must be declared, and is named in
|
|
494
|
-
plugin list and at
|
|
494
|
+
plugin list and at every --no-trust start so you know who is reading them
|
|
495
495
|
|
|
496
|
-
|
|
497
|
-
|
|
496
|
+
--no-trust loads the library; write mode and bundle never do. With nothing
|
|
497
|
+
installed, --no-trust behaves exactly as it does with this command absent.
|
|
498
498
|
DECKLIGHT_HOME overrides ~/.decklight/.`;
|
|
499
499
|
|
|
500
500
|
/** Read a plugin's two files from a resolved source (a URL or a local dir). */
|
|
@@ -530,7 +530,7 @@ function vet(name, files) {
|
|
|
530
530
|
|
|
531
531
|
async function addMain(args, home) {
|
|
532
532
|
const [ref] = args.filter((a) => !a.startsWith('-'));
|
|
533
|
-
if (!ref) { console.error(`decklight
|
|
533
|
+
if (!ref) { console.error(`decklight library add plugin: needs a plugin name\n\n${USAGE}`); return 1; }
|
|
534
534
|
|
|
535
535
|
const reg = loadRegistry(home);
|
|
536
536
|
const catalogs = {};
|
|
@@ -539,18 +539,18 @@ async function addMain(args, home) {
|
|
|
539
539
|
if (c?.ok) catalogs[name] = c.manifest;
|
|
540
540
|
}
|
|
541
541
|
if (!Object.keys(catalogs).length) {
|
|
542
|
-
console.error('decklight
|
|
542
|
+
console.error('decklight library add plugin: no marketplace has been fetched yet'
|
|
543
543
|
+ ' — decklight marketplace update <name> (registered is not fetched)');
|
|
544
544
|
return 1;
|
|
545
545
|
}
|
|
546
546
|
|
|
547
547
|
let hit;
|
|
548
548
|
try { hit = resolveEntry(ref, catalogs); } catch (e) {
|
|
549
|
-
console.error(`decklight
|
|
549
|
+
console.error(`decklight library add plugin: ${e.message}`);
|
|
550
550
|
return 1;
|
|
551
551
|
}
|
|
552
552
|
if (hit.entry.type !== 'plugin') {
|
|
553
|
-
console.error(`decklight
|
|
553
|
+
console.error(`decklight library add plugin: ${hit.qualified} is a ${hit.entry.type}, not a plugin`);
|
|
554
554
|
return 1;
|
|
555
555
|
}
|
|
556
556
|
|
|
@@ -561,7 +561,7 @@ async function addMain(args, home) {
|
|
|
561
561
|
{ name: hit.marketplace, source: reg.marketplaces[hit.marketplace]?.source }, home);
|
|
562
562
|
} catch (e) {
|
|
563
563
|
if (!(e instanceof MarketplaceError)) throw e;
|
|
564
|
-
console.error(`decklight
|
|
564
|
+
console.error(`decklight library add plugin: ${e.message}`);
|
|
565
565
|
return 1;
|
|
566
566
|
}
|
|
567
567
|
let manifest;
|
|
@@ -571,7 +571,7 @@ async function addMain(args, home) {
|
|
|
571
571
|
manifest = vet(hit.entry.name, files);
|
|
572
572
|
} catch (e) {
|
|
573
573
|
if (!(e instanceof PluginError)) throw e;
|
|
574
|
-
console.error(`decklight
|
|
574
|
+
console.error(`decklight library add plugin: ${e.message}`);
|
|
575
575
|
console.error(`\n ${hit.qualified} was NOT installed`);
|
|
576
576
|
return 1;
|
|
577
577
|
}
|
|
@@ -580,8 +580,9 @@ async function addMain(args, home) {
|
|
|
580
580
|
mkdirSync(dir, { recursive: true });
|
|
581
581
|
writeFileSync(join(dir, 'plugin.json'), files.manifest);
|
|
582
582
|
writeFileSync(join(dir, 'plugin.js'), files.source);
|
|
583
|
-
|
|
584
|
-
console.log(`
|
|
583
|
+
recordInstall({ type: 'plugin', name: manifest.name, marketplace: hit.marketplace, version: hit.entry.version, commit: reg.marketplaces[hit.marketplace]?.commit }, home);
|
|
584
|
+
console.log(`installed ${manifest.name}${hit.entry.version ? ` ${hit.entry.version}` : ''} from ${hit.qualified} — ${manifest.slot}, reads ${manifest.needs.join(' + ')}`);
|
|
585
|
+
console.log(` it is yours, not the deck's: decklight <deck> shows it, with or without trust; bundle never will`);
|
|
585
586
|
if (manifest.needs.includes('notes')) console.log(' it reads your speaker notes — it asked, and plugin list says so');
|
|
586
587
|
return 0;
|
|
587
588
|
}
|
|
@@ -589,7 +590,7 @@ async function addMain(args, home) {
|
|
|
589
590
|
function listMain(home) {
|
|
590
591
|
const { plugins, refused } = loadLibrary(home);
|
|
591
592
|
if (!plugins.length && !refused.length) {
|
|
592
|
-
console.log('no presenter plugins installed — decklight
|
|
593
|
+
console.log('no presenter plugins installed — decklight library add plugin <name>');
|
|
593
594
|
console.log(` (a plugin is your own chrome: a timer, a teleprompter. It never enters a deck.)`);
|
|
594
595
|
return 0;
|
|
595
596
|
}
|
|
@@ -604,9 +605,9 @@ function listMain(home) {
|
|
|
604
605
|
|
|
605
606
|
function checkMain(args, home) {
|
|
606
607
|
const [target] = args.filter((a) => !a.startsWith('-'));
|
|
607
|
-
if (!target) { console.error(`decklight plugin
|
|
608
|
+
if (!target) { console.error(`decklight library gate plugin: needs a plugin name or directory\n\n${USAGE}`); return 1; }
|
|
608
609
|
const dir = existsSync(target) ? resolve(target) : join(pluginsDir(home), target);
|
|
609
|
-
if (!existsSync(dir)) { console.error(`decklight plugin
|
|
610
|
+
if (!existsSync(dir)) { console.error(`decklight library gate plugin: no such plugin or directory: ${target}`); return 1; }
|
|
610
611
|
let p;
|
|
611
612
|
try { p = loadPlugin(dir); } catch (e) {
|
|
612
613
|
if (!(e instanceof PluginError)) throw e;
|
|
@@ -621,10 +622,11 @@ function checkMain(args, home) {
|
|
|
621
622
|
|
|
622
623
|
function removeMain(args, home) {
|
|
623
624
|
const [name] = args.filter((a) => !a.startsWith('-'));
|
|
624
|
-
if (!name) { console.error(`decklight
|
|
625
|
+
if (!name) { console.error(`decklight library remove plugin: which one?\n\n${USAGE}`); return 1; }
|
|
625
626
|
const dir = join(pluginsDir(home), name);
|
|
626
|
-
if (!existsSync(dir)) { console.error(`decklight
|
|
627
|
+
if (!existsSync(dir)) { console.error(`decklight library remove plugin: no plugin "${name}" installed (decklight library list plugin)`); return 1; }
|
|
627
628
|
rmSync(dir, { recursive: true, force: true });
|
|
629
|
+
forgetInstall({ type: 'plugin', name }, home);
|
|
628
630
|
console.log(`removed ${name}`);
|
|
629
631
|
return 0;
|
|
630
632
|
}
|
|
@@ -642,12 +644,12 @@ export async function pluginMain(args = []) {
|
|
|
642
644
|
if (sub === 'remove') return removeMain(rest, home);
|
|
643
645
|
} catch (e) {
|
|
644
646
|
if (e instanceof PluginError || e instanceof MarketplaceError) {
|
|
645
|
-
console.error(`decklight
|
|
647
|
+
console.error(`decklight library ${sub} plugin: ${e.message}`);
|
|
646
648
|
return 1;
|
|
647
649
|
}
|
|
648
650
|
throw e;
|
|
649
651
|
}
|
|
650
|
-
console.error(`decklight
|
|
652
|
+
console.error(`decklight library: unknown verb "${sub}" for a plugin\n\n${USAGE}`);
|
|
651
653
|
return 1;
|
|
652
654
|
}
|
|
653
655
|
|
package/cli/port-conflict.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// Copyright 2026 Gilles Philippart
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
// Shared "the port's taken" resolution for `decklight
|
|
4
|
+
// Shared "the port's taken" resolution for `decklight <deck>`'s edit server.
|
|
5
5
|
// The occupant is usually a PAST edit server (you started one
|
|
6
|
-
// yesterday, forgot, and now `init`/`
|
|
6
|
+
// yesterday, forgot, and now `init`/`open` wants the same default port) — so
|
|
7
7
|
// rather than guess at a PID, ask it directly: every edit server answers
|
|
8
|
-
// GET /
|
|
8
|
+
// GET /deck/ping with the deck it's serving, and POST /deck/edit/shutdown stops it
|
|
9
9
|
// as cleanly as its own Ctrl-C (final autocommit included). That makes "kill
|
|
10
10
|
// it and take over" a plain HTTP round trip, no lsof/ps, no platform split.
|
|
11
11
|
//
|
|
@@ -30,7 +30,7 @@ export function isPortOpen(port, host = '127.0.0.1', timeout = 400) {
|
|
|
30
30
|
/** Ask the occupant what it's editing — null if it isn't an edit server at all. */
|
|
31
31
|
export async function identifyEditServer(port, host = '127.0.0.1') {
|
|
32
32
|
try {
|
|
33
|
-
const res = await fetch(`http://${host}:${port}/
|
|
33
|
+
const res = await fetch(`http://${host}:${port}/deck/ping`, { signal: AbortSignal.timeout(800) });
|
|
34
34
|
if (!res.ok) return null;
|
|
35
35
|
const data = await res.json();
|
|
36
36
|
return data?.ok ? data : null;
|
|
@@ -40,16 +40,18 @@ export async function identifyEditServer(port, host = '127.0.0.1') {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
|
-
* The same question for a BRIDGE — the voice
|
|
44
|
-
* `/ping`, not `/
|
|
45
|
-
* and the offer to take the port over never
|
|
43
|
+
* The same question for a BRIDGE — the voice bridge answers `/tts/ping` and
|
|
44
|
+
* the lip-sync bridge `/ping`, not `/deck/ping`, so an edit-server probe
|
|
45
|
+
* reports them as strangers and the offer to take the port over never
|
|
46
|
+
* appears.
|
|
46
47
|
*
|
|
47
48
|
* Returns the same shape the caller already handles: something with a `name`
|
|
48
49
|
* to put in a sentence.
|
|
49
50
|
*/
|
|
50
51
|
export async function identifyBridge(port, host = '127.0.0.1') {
|
|
51
52
|
try {
|
|
52
|
-
|
|
53
|
+
let res = await fetch(`http://${host}:${port}/tts/ping`, { signal: AbortSignal.timeout(800) });
|
|
54
|
+
if (!res.ok) res = await fetch(`http://${host}:${port}/ping`, { signal: AbortSignal.timeout(800) });
|
|
53
55
|
if (!res.ok) return null;
|
|
54
56
|
const d = await res.json();
|
|
55
57
|
if (!d?.ok) return null;
|
|
@@ -88,10 +90,10 @@ export function identifyStranger(port, { exec = null } = {}) {
|
|
|
88
90
|
}
|
|
89
91
|
}
|
|
90
92
|
|
|
91
|
-
/** Ask it to stop — it
|
|
93
|
+
/** Ask it to stop — it saves (a snapshot, or a commit under --git-mode timer) and exits, same as its own Ctrl-C. Resolves once the port is free. */
|
|
92
94
|
export async function shutdownEditServer(port, host = '127.0.0.1') {
|
|
93
95
|
try {
|
|
94
|
-
await fetch(`http://${host}:${port}/edit/shutdown`, { method: 'POST', signal: AbortSignal.timeout(800) });
|
|
96
|
+
await fetch(`http://${host}:${port}/deck/edit/shutdown`, { method: 'POST', signal: AbortSignal.timeout(800) });
|
|
95
97
|
} catch {
|
|
96
98
|
// it may hang up mid-response as it exits — that's the expected shape
|
|
97
99
|
}
|
|
@@ -154,14 +156,13 @@ export async function nextFreePort(port, host = '127.0.0.1', tries = 64) {
|
|
|
154
156
|
* actually bound and you open that one, so bumping costs nothing.
|
|
155
157
|
*
|
|
156
158
|
* a BRIDGE hands its address to nobody. The deck does not discover the
|
|
157
|
-
* bridge, it ASSUMES it: `src/core/narration.js`
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
* the same literal.
|
|
159
|
+
* bridge, it ASSUMES it: served over http, `src/core/narration.js` asks its
|
|
160
|
+
* own origin for `/tts` (and derives /ping, /engines, /voices from it) and
|
|
161
|
+
* `src/core/character.js` for `/lipsync`, which the edit server proxies
|
|
162
|
+
* to the ports it gave the bridges (#520); opened from disk, both fall back
|
|
163
|
+
* to `127.0.0.1:8787` and `:8789`, and the only override is a
|
|
164
|
+
* `liveUrl`/`bridgeUrl` written into the deck itself. A bridge run alone
|
|
165
|
+
* for a file:// deck is therefore still assumed at its literal port.
|
|
165
166
|
*
|
|
166
167
|
* So a bridge that bumps is a bridge nobody is talking to: the deck keeps
|
|
167
168
|
* knocking on 8787, reaches whatever squats there, and reports no live voice
|
|
@@ -192,11 +193,36 @@ export function planPortConflict({ tty = false, identified = null, stranger = nu
|
|
|
192
193
|
* planPortConflict). `kind: 'edit'` never returns null, so the two existing
|
|
193
194
|
* callers are unaffected.
|
|
194
195
|
*/
|
|
196
|
+
/**
|
|
197
|
+
* The sentence a caller prints for how a conflict ended, when it prints one
|
|
198
|
+
* itself (`outcome` below) rather than taking this file's lines. Pure, so the
|
|
199
|
+
* banner row and the standalone line are tested as words, not by binding ports.
|
|
200
|
+
*/
|
|
201
|
+
export function describePortOutcome({ ending, port, next = null, identified = null, stranger = null, kind = 'edit' }) {
|
|
202
|
+
const holder = identified
|
|
203
|
+
? (identified.bridge ? identified.name : `another decklight editing "${identified.name}"`)
|
|
204
|
+
: stranger ? `${stranger.command} (pid ${stranger.pid})` : null;
|
|
205
|
+
if (ending === 'moved') {
|
|
206
|
+
return `${port} ${holder ? (identified ? `has ${holder}` : `is held by ${holder}`) : 'was taken'} — this one is on ${next}`;
|
|
207
|
+
}
|
|
208
|
+
if (ending === 'reuse') return `${identified?.name ?? 'a decklight bridge'} is already on :${port} — using it`;
|
|
209
|
+
// refuse: a bridge that may not move, on a port somebody else holds
|
|
210
|
+
const sides = kind === 'bridge'
|
|
211
|
+
? '; free it, or move both sides (--port N and narration.liveUrl in the deck, or --tts-port N alone in write mode)'
|
|
212
|
+
: '';
|
|
213
|
+
return `port ${port} is held by ${holder ?? 'another program'} — not a decklight bridge${sides}`;
|
|
214
|
+
}
|
|
215
|
+
|
|
195
216
|
export async function resolvePortConflict(port, {
|
|
196
217
|
host = '127.0.0.1', ask, log = () => {}, kind = 'edit', stranger = identifyStranger,
|
|
197
218
|
identify = null,
|
|
219
|
+
// How it ENDED, for a caller that says so in its own shape — a banner row
|
|
220
|
+
// under `open` — instead of this file's lines: called with { ending:
|
|
221
|
+
// 'moved' | 'reuse' | 'refuse', port, next, identified, stranger }. The
|
|
222
|
+
// questions above it still print through `log`, since they are asked live.
|
|
223
|
+
outcome = null,
|
|
198
224
|
} = {}) {
|
|
199
|
-
// Ours, whichever kind: an edit server answers /
|
|
225
|
+
// Ours, whichever kind: an edit server answers /deck/ping, a bridge answers
|
|
200
226
|
// /ping. Asking only the first reported every bridge as a stranger.
|
|
201
227
|
//
|
|
202
228
|
// Injectable for the same reason `stranger` is: this REALLY CONNECTS to the
|
|
@@ -272,14 +298,16 @@ export async function resolvePortConflict(port, {
|
|
|
272
298
|
// deck never calls, so the useful move is to stand aside and say so: null
|
|
273
299
|
// means "do not listen", and the one on `port` serves the deck as before.
|
|
274
300
|
if (ending === 'reuse') {
|
|
275
|
-
|
|
301
|
+
if (outcome) outcome({ ending, port, identified });
|
|
302
|
+
else log(` port ${port} already has ${identified.name} on it — using that one rather than starting a second`);
|
|
276
303
|
return null;
|
|
277
304
|
}
|
|
278
305
|
|
|
279
306
|
// Somebody else's, and a bridge cannot work anywhere but here. Say who has
|
|
280
|
-
// it and both ways out, then decline:
|
|
307
|
+
// it and both ways out, then decline: `open` reports the bridge as gone and
|
|
281
308
|
// the deck degrades honestly, which beats a live voice that fails silently.
|
|
282
309
|
if (ending === 'refuse') {
|
|
310
|
+
if (outcome) { outcome({ ending, port, stranger: other, named }); return null; }
|
|
283
311
|
if (!named) {
|
|
284
312
|
log(other
|
|
285
313
|
? ` port ${port} is held by ${other.command} (pid ${other.pid}) — not a decklight bridge`
|
|
@@ -287,14 +315,16 @@ export async function resolvePortConflict(port, {
|
|
|
287
315
|
}
|
|
288
316
|
log(` the deck asks for this bridge on ${port} and nowhere else, so it will not start.`);
|
|
289
317
|
log(` free the port (kill ${other ? other.pid : 'the process holding it'}), or move BOTH sides:`);
|
|
290
|
-
log(` run with --port N and set narration.liveUrl in the deck to match
|
|
318
|
+
log(` run with --port N and set narration.liveUrl in the deck to match — or, in write mode,`);
|
|
319
|
+
log(` --tts-port N alone: the deck reaches the bridge on the edit server's own origin (/tts).`);
|
|
291
320
|
return null;
|
|
292
321
|
}
|
|
293
322
|
|
|
323
|
+
const next = await nextFreePort(port + 1, host);
|
|
324
|
+
if (outcome) { outcome({ ending: 'moved', port, next, identified, stranger: other }); return next; }
|
|
294
325
|
log(identified
|
|
295
326
|
? ` port ${port} is already in use — ${identified.bridge ? identified.name : `decklight is editing "${identified.name}"`} there; using a different port`
|
|
296
327
|
: ` port ${port} is already in use; using a different port`);
|
|
297
|
-
const next = await nextFreePort(port + 1, host);
|
|
298
328
|
log(` → using port ${next}`);
|
|
299
329
|
return next;
|
|
300
330
|
}
|