decklight 0.2.0 → 0.3.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 (137) hide show
  1. package/README.md +69 -31
  2. package/SPEC.md +855 -80
  3. package/cli/agents.mjs +113 -9
  4. package/cli/associate.mjs +279 -0
  5. package/cli/audit.mjs +424 -0
  6. package/cli/bundle.mjs +174 -46
  7. package/cli/deckfile.mjs +233 -0
  8. package/cli/decklight.mjs +201 -8
  9. package/cli/dev.mjs +244 -55
  10. package/cli/edit.mjs +564 -107
  11. package/cli/extension.mjs +108 -0
  12. package/cli/git.mjs +141 -0
  13. package/cli/import.mjs +398 -0
  14. package/cli/init.mjs +421 -116
  15. package/cli/loader.mjs +263 -0
  16. package/cli/marketplace.mjs +730 -0
  17. package/cli/pdf.mjs +156 -0
  18. package/cli/pkg.mjs +69 -0
  19. package/cli/plugin.mjs +646 -0
  20. package/cli/port-conflict.mjs +94 -0
  21. package/cli/present.mjs +560 -0
  22. package/cli/publish.mjs +342 -0
  23. package/cli/qr.mjs +334 -0
  24. package/cli/rec.mjs +5 -8
  25. package/cli/remote.mjs +149 -0
  26. package/cli/report-bug.mjs +97 -0
  27. package/cli/restore.mjs +174 -0
  28. package/cli/serve.mjs +247 -0
  29. package/cli/sign.mjs +216 -0
  30. package/cli/skill-content.mjs +222 -0
  31. package/cli/skills.mjs +338 -0
  32. package/cli/supervise.mjs +57 -0
  33. package/cli/theme.mjs +201 -0
  34. package/cli/units.mjs +488 -0
  35. package/cli/upgrade.mjs +250 -0
  36. package/cli/util.mjs +90 -0
  37. package/cli/wizard.mjs +432 -0
  38. package/cli/zip.mjs +121 -0
  39. package/dist/decklight.css +716 -29
  40. package/dist/decklight.js +198 -125
  41. package/dist/decklight.js.map +4 -4
  42. package/docs/architecture.svg +1 -1
  43. package/package.json +5 -4
  44. package/themes/README.md +6 -4
  45. package/themes/aurora.css +1 -1
  46. package/themes/berry.css +1 -1
  47. package/themes/carbon.css +1 -1
  48. package/themes/citrus.css +1 -1
  49. package/themes/coastal.css +1 -1
  50. package/themes/cosmos.css +1 -1
  51. package/themes/dune.css +1 -1
  52. package/themes/eclipse.css +1 -1
  53. package/themes/ember.css +1 -1
  54. package/themes/fjord.css +1 -1
  55. package/themes/gallery.html +3 -11
  56. package/themes/glacier.css +1 -1
  57. package/themes/graphite.css +1 -1
  58. package/themes/harvest.css +1 -1
  59. package/themes/ibm-modern.css +1 -1
  60. package/themes/ink.css +1 -1
  61. package/themes/latte.css +1 -1
  62. package/themes/linen.css +1 -1
  63. package/themes/meadow.css +1 -1
  64. package/themes/metropolis.css +1 -1
  65. package/themes/midnight.css +1 -1
  66. package/themes/mint.css +1 -1
  67. package/themes/moss.css +1 -1
  68. package/themes/obsidian.css +1 -1
  69. package/themes/orchid.css +1 -1
  70. package/themes/packs.json +2 -30
  71. package/themes/paper.css +1 -1
  72. package/themes/peony.css +1 -1
  73. package/themes/porcelain.css +1 -1
  74. package/themes/reveal-beige.css +1 -1
  75. package/themes/reveal-black.css +1 -1
  76. package/themes/reveal-blood.css +1 -1
  77. package/themes/reveal-dracula.css +1 -1
  78. package/themes/reveal-league.css +1 -1
  79. package/themes/reveal-moon.css +1 -1
  80. package/themes/reveal-night.css +1 -1
  81. package/themes/reveal-serif.css +1 -1
  82. package/themes/reveal-simple.css +1 -1
  83. package/themes/reveal-sky.css +1 -1
  84. package/themes/reveal-solarized.css +1 -1
  85. package/themes/reveal-white.css +1 -1
  86. package/themes/sepia.css +1 -1
  87. package/themes/seriph.css +1 -1
  88. package/themes/slate.css +1 -1
  89. package/themes/storm.css +1 -1
  90. package/themes/synthwave.css +1 -1
  91. package/themes/velvet.css +1 -1
  92. package/themes/yamabuki.css +1 -1
  93. package/tools/args.mjs +32 -0
  94. package/tools/bridge.mjs +30 -0
  95. package/tools/chrome.mjs +11 -2
  96. package/tools/color.mjs +110 -0
  97. package/tools/deck-html.mjs +138 -0
  98. package/tools/elevenlabs-tts.mjs +248 -0
  99. package/tools/escape.mjs +40 -0
  100. package/tools/extension-check-runner.mjs +41 -0
  101. package/tools/extension-check.mjs +266 -0
  102. package/tools/gemini-tts.mjs +25 -3
  103. package/tools/lipsync-engines.mjs +81 -0
  104. package/tools/lipsync-server.mjs +78 -37
  105. package/tools/lipsync.mjs +36 -21
  106. package/tools/local-voice.mjs +209 -0
  107. package/tools/ooxml.mjs +151 -0
  108. package/tools/pptx.mjs +320 -0
  109. package/tools/publish-site-voices.mjs +2 -1
  110. package/tools/publish-targets.mjs +143 -0
  111. package/tools/publish-voices.mjs +230 -0
  112. package/tools/shot.mjs +91 -47
  113. package/tools/theme-check.mjs +139 -0
  114. package/tools/tts-engines.mjs +270 -41
  115. package/tools/tts-setup.mjs +257 -0
  116. package/tools/veo.mjs +204 -0
  117. package/tools/video.mjs +316 -0
  118. package/tools/voiceover-server.mjs +163 -54
  119. package/tools/voiceover.mjs +24 -7
  120. package/tools/zip.mjs +143 -0
  121. package/docs/demo.svg +0 -124
  122. package/themes/aliens.css +0 -87
  123. package/themes/apple2.css +0 -129
  124. package/themes/blade-runner.css +0 -86
  125. package/themes/c64.css +0 -88
  126. package/themes/friends.css +0 -85
  127. package/themes/gameboy.css +0 -121
  128. package/themes/genesis.css +0 -87
  129. package/themes/godfather.css +0 -85
  130. package/themes/ibm-oldschool.css +0 -87
  131. package/themes/miami-vice.css +0 -87
  132. package/themes/pulp-fiction.css +0 -87
  133. package/themes/severance.css +0 -85
  134. package/themes/snes.css +0 -85
  135. package/themes/star-wars.css +0 -88
  136. package/themes/stranger-things.css +0 -87
  137. package/themes/terminator.css +0 -87
package/cli/pdf.mjs ADDED
@@ -0,0 +1,156 @@
1
+ #!/usr/bin/env node
2
+ // Copyright 2026 Gilles Philippart
3
+ // SPDX-License-Identifier: Apache-2.0
4
+
5
+ // decklight pdf — a deck as one shareable file, without the print dialog.
6
+ //
7
+ // decklight pdf <deck.html> [-o out.pdf] [--theme name] [--wait ms]
8
+ //
9
+ // There is almost nothing here, and that is the point: `?print` (SPEC PRESENTING)
10
+ // already renders every slide with every build complete, casts expanded and
11
+ // strokes drawn, at 1280×720 with a matching @page. A human can already get
12
+ // this PDF through File → Print → Save as PDF. This command only removes the
13
+ // human from that loop — headless Chrome, the same one tools/shot.mjs drives,
14
+ // pointed at the same URL.
15
+ //
16
+ // The one thing it does beyond printing is TELL YOU what is wrong: print mode
17
+ // stamps [data-overflow] on every clipped slide, so a second pass over the same
18
+ // URL reads those back and names them on stderr. A clipped slide in a PDF you
19
+ // have already emailed is a slide nobody can fix.
20
+
21
+ import { execFileSync } from 'node:child_process';
22
+ import { existsSync, readFileSync, rmSync, statSync } from 'node:fs';
23
+ import { basename, resolve } from 'node:path';
24
+ import { chromeBin, chromeArgs } from '../tools/chrome.mjs';
25
+ import { argReader, isMain } from '../tools/args.mjs';
26
+
27
+ const USAGE = `usage: decklight pdf <deck.html> [-o out.pdf] [--theme <name>] [--wait <ms>]
28
+ renders the deck's ?print view to a PDF — one slide per page, at the deck's
29
+ own 1280×720, in its theme, with every build complete
30
+
31
+ -o <file> output path [the deck's, with .pdf]
32
+ --theme <name> export in another theme (rides ?theme=)
33
+ --wait <ms> render budget for heavy decks [8000]
34
+
35
+ slides the print-mode overflow guardrail flags are named on stderr; the PDF
36
+ is still written (a clipped slide is worth knowing about, not worth refusing)`;
37
+
38
+ /** The deck's path with .pdf in place of .html — or whatever -o said. */
39
+ export function pdfOut(deckPath, oFlag) {
40
+ if (oFlag) return resolve(oFlag);
41
+ return resolve(deckPath.replace(/\.html?$/i, '') + '.pdf');
42
+ }
43
+
44
+ /**
45
+ * The URL to print. `?print` is the whole rendering contract; `?theme=` is the
46
+ * existing startup override, so exporting in another theme costs nothing here.
47
+ */
48
+ export function printUrl(absDeckPath, { theme } = {}) {
49
+ const q = theme ? `?print&theme=${encodeURIComponent(theme)}` : '?print';
50
+ return `file://${absDeckPath}${q}`;
51
+ }
52
+
53
+ /**
54
+ * How many pages Chrome actually wrote.
55
+ *
56
+ * By regex over the bytes, deliberately: a PDF library would be the only
57
+ * runtime-adjacent dependency in the repo, for one number. `/Type /Page` (not
58
+ * `/Pages`, the tree node) appears once per page object. If a future Chrome
59
+ * moves those into compressed object streams the count comes back 0, so the
60
+ * page-tree `/Count` is read as a fallback and 0 means "could not tell" — the
61
+ * caller reports rather than asserts.
62
+ */
63
+ export function pdfPageCount(buf) {
64
+ const pages = (buf.toString('latin1').match(/\/Type\s*\/Page(?![s\w])/g) ?? []).length;
65
+ if (pages) return pages;
66
+ const counts = [...buf.toString('latin1').matchAll(/\/Count\s+(\d+)/g)].map((m) => Number(m[1]));
67
+ return counts.length ? Math.max(...counts) : 0;
68
+ }
69
+
70
+ /**
71
+ * Which slides carry a guardrail attribute, 1-based, from a dumped DOM.
72
+ * Sections are in document order in print mode (print never re-runs sync()),
73
+ * so position IS the slide number. The attribute must sit in the section TAG:
74
+ * a deck that merely talks about data-overflow in a code sample stays clean.
75
+ */
76
+ function flaggedSlides(html, attr) {
77
+ const out = [];
78
+ const has = new RegExp(`\\b${attr}\\b`);
79
+ let n = 0;
80
+ for (const m of html.matchAll(/<section\b[^>]*>/g)) {
81
+ n += 1;
82
+ if (has.test(m[0])) out.push(n);
83
+ }
84
+ return out;
85
+ }
86
+
87
+ /** Slides the overflow guardrail flagged (SPEC PRESENTING). */
88
+ export const overflowSlides = (html) => flaggedSlides(html, 'data-overflow');
89
+
90
+ /**
91
+ * Slides mixing data-layout="split" with their own column flexbox (SPEC
92
+ * COMPARISON_SLIDES) — the engine marks the cause the overflow guardrail
93
+ * only ever catches the symptom of.
94
+ */
95
+ export const splitConflictSlides = (html) => flaggedSlides(html, 'data-split-conflict');
96
+
97
+ /** Slides in the printed deck — the number the page count should equal. */
98
+ export const slideCount = (html) => (html.match(/<section\b/g) ?? []).length;
99
+
100
+ const KB = (n) => (n < 1024 * 1024 ? `${Math.round(n / 1024)} KB` : `${(n / 1048576).toFixed(1)} MB`);
101
+
102
+ export async function pdfMain(args = []) {
103
+ if (args.includes('--help') || args.includes('-h')) { console.log(USAGE); return 0; }
104
+ const { opt } = argReader(args);
105
+ const deck = args.find((a) => !a.startsWith('-') && /\.html?$/i.test(a));
106
+ if (!deck) { console.error(`decklight pdf: needs a deck\n\n${USAGE}`); return 1; }
107
+ const src = resolve(deck);
108
+ if (!existsSync(src)) { console.error(`decklight pdf: no such deck: ${deck}`); return 1; }
109
+
110
+ const out = pdfOut(src, opt('-o'));
111
+ const theme = opt('--theme');
112
+ const wait = Number(opt('--wait', 8000));
113
+ const url = printUrl(src, { theme });
114
+ const bin = chromeBin('pdf');
115
+ // file:// decks load their runtime, themes and casts as siblings
116
+ const shared = chromeArgs('--allow-file-access-from-files', `--virtual-time-budget=${wait}`);
117
+
118
+ // Pass one: the DOM, for the slide count and the overflow audit. Cheap — the
119
+ // same URL, the same budget, and it is the only way to know what the PDF is
120
+ // about to hide.
121
+ let html = '';
122
+ try {
123
+ html = execFileSync(bin, [...shared, '--dump-dom', url],
124
+ { encoding: 'utf8', maxBuffer: 64 * 1024 * 1024, stdio: ['ignore', 'pipe', 'ignore'] });
125
+ } catch { /* the print pass below is the one that must succeed */ }
126
+ const slides = slideCount(html);
127
+ console.error(`pdf: rendering ${basename(src)}?print${theme ? ` · theme ${theme}` : ''}`
128
+ + `${slides ? ` — ${slides} slides, builds complete, casts expanded` : ''}`);
129
+
130
+ rmSync(out, { force: true }); // never leave a stale PDF looking like a fresh one
131
+ try {
132
+ execFileSync(bin, [...shared, '--no-pdf-header-footer', `--print-to-pdf=${out}`, url],
133
+ { stdio: ['ignore', 'ignore', 'ignore'] });
134
+ } catch (e) {
135
+ console.error(`decklight pdf: Chrome failed — ${String(e.message ?? e).split('\n')[0]}`);
136
+ return 1;
137
+ }
138
+ if (!existsSync(out) || statSync(out).size === 0) {
139
+ console.error('decklight pdf: Chrome produced no PDF — try a longer --wait');
140
+ return 1;
141
+ }
142
+
143
+ for (const n of overflowSlides(html)) {
144
+ console.error(`pdf: ⚠ slide ${n} overflows — it will be clipped in the PDF`);
145
+ }
146
+ for (const n of splitConflictSlides(html)) {
147
+ console.error(`pdf: ⚠ slide ${n} mixes data-layout="split" with its own column flexbox — `
148
+ + 'two layout systems fight; drop one (SPEC COMPARISON_SLIDES)');
149
+ }
150
+ const buf = readFileSync(out);
151
+ const pages = pdfPageCount(buf);
152
+ console.log(`${out} · ${pages || '?'} pages · 1280×720 (16:9) · ${KB(buf.length)}`);
153
+ return 0;
154
+ }
155
+
156
+ if (isMain(import.meta.url)) process.exit(await pdfMain(process.argv.slice(2)));
package/cli/pkg.mjs ADDED
@@ -0,0 +1,69 @@
1
+ // Copyright 2026 Gilles Philippart
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // Where the installed package is, and the one way its build artifacts become
5
+ // deck bytes.
6
+ //
7
+ // WHY THIS IS ONE MODULE AND NOT FIVE CONSTANTS. Four commands write a deck
8
+ // that carries the runtime inline — `init` scaffolds one, `import` converts
9
+ // one, `upgrade` refreshes one, `bundle` inlines a referenced one — and
10
+ // `audit` recomputes what they SHOULD have produced, so that `present` can
11
+ // say whether the runtime in a file is this install's build (PRESENT#AUDIT).
12
+ // That makes the inlining transform a contract between five files, and it was
13
+ // copied into each of them. `import` copied it slightly wrong: its local
14
+ // escape covered `</script` and `</style` but not `<!--`, so an imported deck
15
+ // audited as
16
+ //
17
+ // runtime 0.3.0 — DIFFERS from this install's build of 0.3.0
18
+ //
19
+ // which is the label's alarm, raised on a deck decklight had just written
20
+ // itself. The transform lives here now, and the auditor's model of it is the
21
+ // same function the producers call, so the two cannot drift again.
22
+ //
23
+ // The package root is `fileURLToPath`, never a URL `.pathname` — see the
24
+ // sweep test in test/cli.test.mjs for what that costs (#275).
25
+ //
26
+ // ONE ROOT STAYS OUTSIDE THIS FILE ON PURPOSE. tools/extension-check.mjs
27
+ // keeps its own, because tools/ does not import from cli/ — it ships so that
28
+ // a marketplace's own CI can run the admission gate from the installed
29
+ // package, and a dependency pointing the wrong way up the layering would
30
+ // drag the whole command surface into that runtime. Two definitions is the
31
+ // price of that direction; it is not an oversight to tidy.
32
+
33
+ import fs from 'node:fs';
34
+ import path from 'node:path';
35
+ import { fileURLToPath } from 'node:url';
36
+ import { scriptSafe } from './util.mjs';
37
+
38
+ /** The installed package's root — the directory holding dist/, themes/, SPEC.md. */
39
+ export const PKG_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
40
+
41
+ /** package.json, parsed once. `PKG.version` is the version every command prints. */
42
+ export const PKG = JSON.parse(fs.readFileSync(path.join(PKG_ROOT, 'package.json'), 'utf8'));
43
+
44
+ /** The shipped theme set — the graded and compat themes that stay in core. */
45
+ export const THEMES_DIR = path.join(PKG_ROOT, 'themes');
46
+
47
+ /** One shipped theme's CSS. Throws ENOENT for a name that is not shipped. */
48
+ export const themeCss = (name) => fs.readFileSync(path.join(THEMES_DIR, `${name}.css`), 'utf8');
49
+
50
+ /**
51
+ * Turn runtime JavaScript into the exact text that goes inside a deck's
52
+ * `<script>` — the sourceMappingURL comment dropped (it points at a .map that
53
+ * does not travel), then `scriptSafe` (whose docblock in util.mjs carries the
54
+ * reasoning for both sequences it rewrites).
55
+ *
56
+ * Callers that already hold the text — `bundle`, inlining whatever a deck's
57
+ * own `<script src>` pointed at — pass it in; the rest read the installed
58
+ * build through `runtimeJs()`.
59
+ */
60
+ export const inlineRuntime = (js) => scriptSafe(js.replace(/\/\/# sourceMappingURL=.*$/m, ''));
61
+
62
+ /** The installed runtime, ready to inline. Null when dist/ has not been built. */
63
+ export function runtimeJs() {
64
+ const file = path.join(PKG_ROOT, 'dist/decklight.js');
65
+ return fs.existsSync(file) ? inlineRuntime(fs.readFileSync(file, 'utf8')) : null;
66
+ }
67
+
68
+ /** The installed runtime stylesheet. */
69
+ export const runtimeCss = () => fs.readFileSync(path.join(PKG_ROOT, 'dist/decklight.css'), 'utf8');