decklight 0.1.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 (139) hide show
  1. package/LICENSE +202 -21
  2. package/README.md +105 -183
  3. package/SPEC.md +861 -74
  4. package/cli/agents.mjs +206 -0
  5. package/cli/associate.mjs +279 -0
  6. package/cli/audit.mjs +424 -0
  7. package/cli/bundle.mjs +210 -45
  8. package/cli/deckfile.mjs +233 -0
  9. package/cli/decklight.mjs +216 -5
  10. package/cli/dev.mjs +455 -0
  11. package/cli/edit.mjs +733 -63
  12. package/cli/extension.mjs +108 -0
  13. package/cli/git.mjs +141 -0
  14. package/cli/import.mjs +398 -0
  15. package/cli/init.mjs +465 -121
  16. package/cli/loader.mjs +263 -0
  17. package/cli/marketplace.mjs +730 -0
  18. package/cli/pdf.mjs +156 -0
  19. package/cli/pkg.mjs +69 -0
  20. package/cli/plugin.mjs +646 -0
  21. package/cli/port-conflict.mjs +94 -0
  22. package/cli/present.mjs +560 -0
  23. package/cli/publish.mjs +342 -0
  24. package/cli/qr.mjs +334 -0
  25. package/cli/rec.mjs +12 -8
  26. package/cli/remote.mjs +149 -0
  27. package/cli/report-bug.mjs +97 -0
  28. package/cli/restore.mjs +174 -0
  29. package/cli/serve.mjs +247 -0
  30. package/cli/sign.mjs +216 -0
  31. package/cli/skill-content.mjs +222 -0
  32. package/cli/skills.mjs +338 -0
  33. package/cli/supervise.mjs +57 -0
  34. package/cli/theme.mjs +201 -0
  35. package/cli/units.mjs +488 -0
  36. package/cli/upgrade.mjs +250 -0
  37. package/cli/util.mjs +90 -0
  38. package/cli/wizard.mjs +432 -0
  39. package/cli/zip.mjs +121 -0
  40. package/dist/decklight.css +949 -72
  41. package/dist/decklight.js +220 -103
  42. package/dist/decklight.js.map +4 -4
  43. package/docs/architecture.svg +1 -1
  44. package/package.json +9 -6
  45. package/themes/README.md +6 -4
  46. package/themes/aurora.css +4 -1
  47. package/themes/berry.css +4 -1
  48. package/themes/carbon.css +4 -1
  49. package/themes/citrus.css +4 -1
  50. package/themes/coastal.css +4 -1
  51. package/themes/cosmos.css +4 -1
  52. package/themes/dune.css +4 -1
  53. package/themes/eclipse.css +4 -1
  54. package/themes/ember.css +4 -1
  55. package/themes/fjord.css +4 -1
  56. package/themes/gallery.html +3 -11
  57. package/themes/glacier.css +4 -1
  58. package/themes/graphite.css +4 -1
  59. package/themes/harvest.css +4 -1
  60. package/themes/ibm-modern.css +4 -1
  61. package/themes/ink.css +4 -1
  62. package/themes/latte.css +4 -1
  63. package/themes/linen.css +4 -1
  64. package/themes/meadow.css +4 -1
  65. package/themes/metropolis.css +4 -1
  66. package/themes/midnight.css +4 -1
  67. package/themes/mint.css +4 -1
  68. package/themes/moss.css +4 -1
  69. package/themes/obsidian.css +4 -1
  70. package/themes/orchid.css +4 -1
  71. package/themes/packs.json +4 -31
  72. package/themes/paper.css +4 -1
  73. package/themes/peony.css +4 -1
  74. package/themes/porcelain.css +4 -1
  75. package/themes/reveal-beige.css +4 -1
  76. package/themes/reveal-black.css +4 -1
  77. package/themes/reveal-blood.css +4 -1
  78. package/themes/reveal-dracula.css +4 -1
  79. package/themes/reveal-league.css +4 -1
  80. package/themes/reveal-moon.css +4 -1
  81. package/themes/reveal-night.css +4 -1
  82. package/themes/reveal-serif.css +4 -1
  83. package/themes/reveal-simple.css +4 -1
  84. package/themes/reveal-sky.css +4 -1
  85. package/themes/reveal-solarized.css +4 -1
  86. package/themes/reveal-white.css +4 -1
  87. package/themes/sepia.css +4 -1
  88. package/themes/seriph.css +4 -1
  89. package/themes/slate.css +4 -1
  90. package/themes/storm.css +4 -1
  91. package/themes/synthwave.css +4 -1
  92. package/themes/velvet.css +4 -1
  93. package/themes/yamabuki.css +120 -0
  94. package/tools/args.mjs +32 -0
  95. package/tools/bridge.mjs +30 -0
  96. package/tools/chrome.mjs +52 -0
  97. package/tools/color.mjs +110 -0
  98. package/tools/deck-html.mjs +138 -0
  99. package/tools/elevenlabs-tts.mjs +248 -0
  100. package/tools/escape.mjs +40 -0
  101. package/tools/extension-check-runner.mjs +41 -0
  102. package/tools/extension-check.mjs +266 -0
  103. package/tools/gemini-tts.mjs +44 -4
  104. package/tools/lipsync-engines.mjs +81 -0
  105. package/tools/lipsync-server.mjs +290 -0
  106. package/tools/lipsync.mjs +181 -0
  107. package/tools/local-voice.mjs +209 -0
  108. package/tools/ooxml.mjs +151 -0
  109. package/tools/pptx.mjs +320 -0
  110. package/tools/publish-site-voices.mjs +5 -1
  111. package/tools/publish-targets.mjs +143 -0
  112. package/tools/publish-voices.mjs +230 -0
  113. package/tools/shot.mjs +129 -0
  114. package/tools/theme-check.mjs +139 -0
  115. package/tools/tts-engines.mjs +455 -0
  116. package/tools/tts-setup.mjs +257 -0
  117. package/tools/veo.mjs +204 -0
  118. package/tools/video.mjs +316 -0
  119. package/tools/visemes.mjs +26 -0
  120. package/tools/voiceover-server.mjs +0 -0
  121. package/tools/voiceover.mjs +73 -39
  122. package/tools/zip.mjs +143 -0
  123. package/docs/demo.svg +0 -124
  124. package/themes/aliens.css +0 -84
  125. package/themes/apple2.css +0 -126
  126. package/themes/blade-runner.css +0 -83
  127. package/themes/c64.css +0 -85
  128. package/themes/friends.css +0 -82
  129. package/themes/gameboy.css +0 -118
  130. package/themes/genesis.css +0 -84
  131. package/themes/godfather.css +0 -82
  132. package/themes/ibm-oldschool.css +0 -84
  133. package/themes/miami-vice.css +0 -84
  134. package/themes/pulp-fiction.css +0 -84
  135. package/themes/severance.css +0 -82
  136. package/themes/snes.css +0 -82
  137. package/themes/star-wars.css +0 -85
  138. package/themes/stranger-things.css +0 -84
  139. package/themes/terminator.css +0 -84
@@ -0,0 +1,151 @@
1
+ // Copyright 2026 Gilles Philippart
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // A small XML reader, for reading Office parts and nothing else.
5
+ //
6
+ // Regex would do for a flat scrape, and does not do here: a table cell holds
7
+ // paragraphs which hold runs, and "the paragraphs of this slide" has to mean
8
+ // something different from "the paragraphs inside its table". That is a tree
9
+ // question, so this builds a tree.
10
+ //
11
+ // Deliberately partial. No DTDs, no entities beyond the five predefined plus
12
+ // numeric, no namespace resolution (OOXML prefixes are fixed in practice —
13
+ // `a:`, `p:`, `r:` — so names are matched as written, which is what the
14
+ // documents actually use). Attribute values may be single- or double-quoted.
15
+
16
+ const NAME = /[A-Za-z_][\w.:-]*/y;
17
+
18
+ /** `&` and friends — the five predefined entities, plus numeric refs. */
19
+ export function decodeEntities(s) {
20
+ return String(s).replace(/&(#x?[0-9a-fA-F]+|amp|lt|gt|quot|apos);/g, (m, body) => {
21
+ if (body[0] === '#') {
22
+ const code = body[1] === 'x' || body[1] === 'X'
23
+ ? parseInt(body.slice(2), 16) : parseInt(body.slice(1), 10);
24
+ return Number.isFinite(code) ? String.fromCodePoint(code) : m;
25
+ }
26
+ return { amp: '&', lt: '<', gt: '>', quot: '"', apos: "'" }[body] ?? m;
27
+ });
28
+ }
29
+
30
+ function readAttrs(src, i, end) {
31
+ const attrs = {};
32
+ while (i < end) {
33
+ while (i < end && /\s/.test(src[i])) i += 1;
34
+ if (i >= end) break;
35
+ NAME.lastIndex = i;
36
+ const m = NAME.exec(src);
37
+ if (!m) break;
38
+ i = NAME.lastIndex;
39
+ while (i < end && /\s/.test(src[i])) i += 1;
40
+ if (src[i] !== '=') { attrs[m[0]] = ''; continue; }
41
+ i += 1;
42
+ while (i < end && /\s/.test(src[i])) i += 1;
43
+ const quote = src[i];
44
+ if (quote !== '"' && quote !== "'") break;
45
+ const close = src.indexOf(quote, i + 1);
46
+ if (close < 0) break;
47
+ attrs[m[0]] = decodeEntities(src.slice(i + 1, close));
48
+ i = close + 1;
49
+ }
50
+ return attrs;
51
+ }
52
+
53
+ /**
54
+ * Parse XML into `{ name, attrs, children }` nodes; text becomes a child
55
+ * `{ text }`. The return is a synthetic root holding the document element, so
56
+ * a caller never has to care whether it wanted the document or its top tag.
57
+ */
58
+ export function parseXml(src) {
59
+ const root = { name: '#root', attrs: {}, children: [] };
60
+ const stack = [root];
61
+ let i = 0;
62
+ const n = src.length;
63
+
64
+ while (i < n) {
65
+ const lt = src.indexOf('<', i);
66
+ if (lt < 0) { pushText(src.slice(i)); break; }
67
+ if (lt > i) pushText(src.slice(i, lt));
68
+
69
+ if (src.startsWith('<!--', lt)) { i = skipTo(lt, '-->'); continue; }
70
+ if (src.startsWith('<![CDATA[', lt)) {
71
+ const end = src.indexOf(']]>', lt);
72
+ const stop = end < 0 ? n : end;
73
+ pushText(src.slice(lt + 9, stop), true);
74
+ i = end < 0 ? n : end + 3;
75
+ continue;
76
+ }
77
+ if (src.startsWith('<?', lt)) { i = skipTo(lt, '?>'); continue; } // <?xml …?>
78
+ if (src.startsWith('<!', lt)) { i = skipTo(lt, '>'); continue; } // <!DOCTYPE …>
79
+
80
+ const gt = src.indexOf('>', lt);
81
+ if (gt < 0) break;
82
+
83
+ if (src[lt + 1] === '/') { // </tag>
84
+ const name = src.slice(lt + 2, gt).trim();
85
+ // an unmatched close tag closes nothing rather than unwinding the stack:
86
+ // a malformed part should lose one element, not the whole document
87
+ for (let d = stack.length - 1; d > 0; d -= 1) {
88
+ if (stack[d].name === name) { stack.length = d; break; }
89
+ }
90
+ i = gt + 1;
91
+ continue;
92
+ }
93
+
94
+ const selfClosing = src[gt - 1] === '/';
95
+ NAME.lastIndex = lt + 1;
96
+ const m = NAME.exec(src);
97
+ if (!m) { i = gt + 1; continue; }
98
+ const node = {
99
+ name: m[0],
100
+ attrs: readAttrs(src, NAME.lastIndex, selfClosing ? gt - 1 : gt),
101
+ children: [],
102
+ };
103
+ stack[stack.length - 1].children.push(node);
104
+ if (!selfClosing) stack.push(node);
105
+ i = gt + 1;
106
+ }
107
+ return root;
108
+
109
+ function skipTo(from, marker) {
110
+ const end = src.indexOf(marker, from);
111
+ return end < 0 ? n : end + marker.length;
112
+ }
113
+ function pushText(raw, literal = false) {
114
+ if (!raw) return;
115
+ const text = literal ? raw : decodeEntities(raw);
116
+ if (!text) return;
117
+ stack[stack.length - 1].children.push({ text });
118
+ }
119
+ }
120
+
121
+ const kids = (node) => node?.children ?? [];
122
+
123
+ /** Every descendant with this tag name, in document order. */
124
+ export function findAll(node, name, out = []) {
125
+ for (const c of kids(node)) {
126
+ if (c.name === name) out.push(c);
127
+ if (c.children) findAll(c, name, out);
128
+ }
129
+ return out;
130
+ }
131
+
132
+ /** The first descendant with this tag name, or null. */
133
+ export function find(node, name) {
134
+ for (const c of kids(node)) {
135
+ if (c.name === name) return c;
136
+ if (c.children) { const hit = find(c, name); if (hit) return hit; }
137
+ }
138
+ return null;
139
+ }
140
+
141
+ /** Direct children with this tag name — "the slide's shapes", not a table's. */
142
+ export function children(node, name) {
143
+ return kids(node).filter((c) => c.name === name);
144
+ }
145
+
146
+ /** All text under a node, concatenated. */
147
+ export function textOf(node) {
148
+ let out = '';
149
+ for (const c of kids(node)) out += c.text ?? textOf(c);
150
+ return out;
151
+ }
package/tools/pptx.mjs ADDED
@@ -0,0 +1,320 @@
1
+ // Copyright 2026 Gilles Philippart
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // PowerPoint → decklight, as a pure transformation over parsed XML.
5
+ //
6
+ // This is a CONTENT importer, not a pixel renderer. The template's look is
7
+ // deliberately thrown away and replaced by decklight theming — the deck you get
8
+ // is a decklight deck, not a screenshot of the old one. What that buys is
9
+ // everything downstream: themes, builds, narration, the notes editor, `dev`.
10
+ //
11
+ // What it cannot carry, it drops LOUDLY. A silent drop is the failure mode that
12
+ // matters here: a chart that quietly vanishes from slide 14 is discovered on
13
+ // stage. Every drop is named with its slide number, and where decklight has a
14
+ // native answer the report says what to rebuild it with.
15
+
16
+ import { parseXml, find, findAll, children, textOf } from './ooxml.mjs';
17
+
18
+ import { escapeHtml } from './escape.mjs';
19
+
20
+ /** OOXML relationship parts map an rId to a part path, relative to the owner. */
21
+ export function parseRels(xml) {
22
+ const rels = new Map();
23
+ for (const r of findAll(parseXml(xml ?? ''), 'Relationship')) {
24
+ if (r.attrs.Id) rels.set(r.attrs.Id, { target: r.attrs.Target ?? '', type: r.attrs.Type ?? '' });
25
+ }
26
+ return rels;
27
+ }
28
+
29
+ /** Resolve a relationship target (`../media/image1.png`) against its owner. */
30
+ export function resolvePart(ownerPath, target) {
31
+ if (target.startsWith('/')) return target.slice(1);
32
+ const parts = ownerPath.split('/').slice(0, -1);
33
+ for (const seg of target.split('/')) {
34
+ if (seg === '.' || seg === '') continue;
35
+ if (seg === '..') parts.pop();
36
+ else parts.push(seg);
37
+ }
38
+ return parts.join('/');
39
+ }
40
+
41
+ /**
42
+ * The slides, in presentation order.
43
+ *
44
+ * The order is `<p:sldIdLst>`'s, not the archive's: slide7.xml can be third in
45
+ * the deck, and importing in filename order would silently reorder the talk.
46
+ */
47
+ export function slideOrder(presentationXml, presentationRelsXml) {
48
+ const rels = parseRels(presentationRelsXml);
49
+ const lst = find(parseXml(presentationXml ?? ''), 'p:sldIdLst');
50
+ return children(lst, 'p:sldId')
51
+ .map((s) => rels.get(s.attrs['r:id'])?.target)
52
+ .filter(Boolean)
53
+ .map((t) => resolvePart('ppt/presentation.xml', t));
54
+ }
55
+
56
+ const MIME = {
57
+ png: 'image/png', jpg: 'image/jpeg', jpeg: 'image/jpeg', gif: 'image/gif',
58
+ webp: 'image/webp', svg: 'image/svg+xml', bmp: 'image/bmp', tiff: 'image/tiff',
59
+ };
60
+ export const mimeOf = (name) => MIME[name.split('.').pop()?.toLowerCase()] ?? 'application/octet-stream';
61
+
62
+ /** One `<a:p>` as inline HTML: runs, their formatting, links and breaks. */
63
+ export function paragraphHtml(p, { rels } = {}) {
64
+ let out = '';
65
+ for (const node of p.children ?? []) {
66
+ if (node.name === 'a:br') { out += '<br>'; continue; }
67
+ if (node.name !== 'a:r') continue;
68
+ const rPr = find(node, 'a:rPr');
69
+ const t = find(node, 'a:t');
70
+ let text = escapeHtml(t ? textOf(t) : '');
71
+ if (!text) continue;
72
+ if (rPr?.attrs.b === '1') text = `<strong>${text}</strong>`;
73
+ if (rPr?.attrs.i === '1') text = `<em>${text}</em>`;
74
+ const link = rPr && find(rPr, 'a:hlinkClick');
75
+ const href = link && rels?.get(link.attrs['r:id'])?.target;
76
+ if (href) text = `<a href="${escapeHtml(href)}">${text}</a>`;
77
+ out += text;
78
+ }
79
+ return out.trim();
80
+ }
81
+
82
+ const paraLevel = (p) => Number(find(p, 'a:pPr')?.attrs.lvl ?? 0) || 0;
83
+ /** A paragraph is a bullet unless it says otherwise — PowerPoint's own default. */
84
+ const isBullet = (p) => !find(p, 'a:buNone');
85
+ const isNumbered = (p) => !!find(p, 'a:buAutoNum');
86
+
87
+ /**
88
+ * A text body's paragraphs, grouped into blocks.
89
+ *
90
+ * Consecutive bulleted paragraphs become one list (their `lvl` becoming
91
+ * nesting); anything else becomes its own paragraph. Empty paragraphs are
92
+ * spacing in PowerPoint and separators here — they close a run of bullets
93
+ * rather than producing an empty `<li>`.
94
+ */
95
+ export function bodyBlocks(txBody, { rels } = {}) {
96
+ const blocks = [];
97
+ let list = null;
98
+ for (const p of children(txBody, 'a:p')) {
99
+ const html = paragraphHtml(p, { rels });
100
+ if (!html) { list = null; continue; }
101
+ if (isBullet(p)) {
102
+ const ordered = isNumbered(p);
103
+ if (!list || list.ordered !== ordered) {
104
+ list = { kind: 'list', ordered, items: [] };
105
+ blocks.push(list);
106
+ }
107
+ list.items.push({ level: paraLevel(p), html });
108
+ } else {
109
+ list = null;
110
+ blocks.push({ kind: 'p', html });
111
+ }
112
+ }
113
+ return blocks;
114
+ }
115
+
116
+ /**
117
+ * A flat list of `{level, html}` as nested `<ul>`/`<ol>` markup.
118
+ *
119
+ * PowerPoint stores indent as a number on each paragraph; HTML stores it as a
120
+ * sublist INSIDE the parent `<li>`. So an item's `</li>` cannot be written
121
+ * until the next item proves nothing nests under it — which is why the open
122
+ * `<li>` is tracked rather than closed eagerly. It also matters beyond
123
+ * validity: `data-build` makes each DIRECT child a step, so a sublist that
124
+ * escaped its parent would become a build step of its own.
125
+ */
126
+ export function listHtml(list, { build } = {}) {
127
+ const tag = list.ordered ? 'ol' : 'ul';
128
+ const attr = build ? ` data-build="${build}"` : '';
129
+ let out = `<${tag}${attr}>`;
130
+ let depth = 0;
131
+ let open = false;
132
+ for (const item of list.items) {
133
+ // a jump from level 0 to level 3 indents by one: HTML has no way to
134
+ // express the missing levels, and inventing empty <li>s to carry them
135
+ // would put bullets on screen that were never in the deck
136
+ const level = Math.max(0, Math.min(item.level, depth + 1));
137
+ if (level > depth) {
138
+ out += `<${tag}>`; // inside the open <li> — the parent stays open
139
+ depth += 1;
140
+ } else {
141
+ if (open) out += '</li>';
142
+ while (depth > level) { out += `</${tag}></li>`; depth -= 1; }
143
+ }
144
+ out += `<li>${item.html}`;
145
+ open = true;
146
+ }
147
+ if (open) out += '</li>';
148
+ while (depth > 0) { out += `</${tag}></li>`; depth -= 1; }
149
+ return out + `</${tag}>`;
150
+ }
151
+
152
+ /** An `<a:tbl>` as an HTML table; the first row becomes a header. */
153
+ export function tableHtml(tbl, { rels } = {}) {
154
+ const rows = children(tbl, 'a:tr');
155
+ const cells = (tr, cellTag) => children(tr, 'a:tc')
156
+ .map((tc) => {
157
+ const body = find(tc, 'a:txBody');
158
+ const text = body ? children(body, 'a:p').map((p) => paragraphHtml(p, { rels })).filter(Boolean).join('<br>') : '';
159
+ return `<${cellTag}>${text}</${cellTag}>`;
160
+ }).join('');
161
+ if (!rows.length) return '';
162
+ const head = `<thead><tr>${cells(rows[0], 'th')}</tr></thead>`;
163
+ const body = rows.slice(1).map((tr) => `<tr>${cells(tr, 'td')}</tr>`).join('');
164
+ return `<table>${head}${body ? `<tbody>${body}</tbody>` : ''}</table>`;
165
+ }
166
+
167
+ const GRAPHIC = {
168
+ table: null, // handled
169
+ chart: 'chart dropped — rebuild as data-chart (SPEC CHARTS)',
170
+ diagram: 'SmartArt dropped — rebuild as an SVG diagram (SPEC SVG_DIAGRAMS)',
171
+ };
172
+
173
+ /**
174
+ * One slide, as the pieces a `<section>` needs.
175
+ *
176
+ * `spTree` children are walked in document order so the section reads in the
177
+ * order the slide did. Groups are walked into: a shape inside a group is still
178
+ * content, and skipping groups loses whole slides' worth of text.
179
+ */
180
+ export function parseSlide(xml, { rels, mediaOf, slideNo = 0 } = {}) {
181
+ const doc = parseXml(xml);
182
+ const sld = find(doc, 'p:sld');
183
+ const hidden = sld?.attrs.show === '0';
184
+ const drops = [];
185
+ const drop = (what) => { if (!drops.includes(what)) drops.push(what); };
186
+
187
+ // <p:bldP> names the shapes PowerPoint reveals a paragraph at a time — which
188
+ // is exactly what data-build means. Reading the real build list beats
189
+ // guessing from the animation timeline.
190
+ const builds = new Set(findAll(sld, 'p:bldP').map((b) => b.attrs.spid).filter(Boolean));
191
+ if (find(sld, 'p:transition')) drop('slide transition dropped — decklight transitions are deck-wide');
192
+
193
+ let title = null;
194
+ let titleIsH1 = false;
195
+ let subtitle = null;
196
+ const blocks = [];
197
+
198
+ const walk = (tree) => {
199
+ for (const node of tree.children ?? []) {
200
+ if (node.name === 'p:grpSp') { walk(node); continue; }
201
+
202
+ if (node.name === 'p:sp') {
203
+ if (find(node, 'a:videoFile') || find(node, 'a:audioFile')) {
204
+ drop('embedded media dropped — use data-background-video or a <video> (SPEC DECK_ANATOMY)');
205
+ continue;
206
+ }
207
+ const ph = find(node, 'p:ph');
208
+ const type = ph?.attrs.type ?? '';
209
+ const txBody = find(node, 'p:txBody');
210
+ if (!txBody) continue;
211
+ const text = textOf(txBody).trim();
212
+
213
+ if ((type === 'title' || type === 'ctrTitle') && text && title === null) {
214
+ title = children(txBody, 'a:p').map((p) => paragraphHtml(p, { rels })).filter(Boolean).join(' ');
215
+ titleIsH1 = type === 'ctrTitle'; // the title-layout's centered title
216
+ continue;
217
+ }
218
+ if (type === 'subTitle' && text && subtitle === null) {
219
+ subtitle = children(txBody, 'a:p').map((p) => paragraphHtml(p, { rels })).filter(Boolean).join(' ');
220
+ continue;
221
+ }
222
+ if (!text) continue;
223
+ const id = find(node, 'p:cNvPr')?.attrs.id;
224
+ const wantsBuild = id && builds.has(id);
225
+ for (const b of bodyBlocks(txBody, { rels })) {
226
+ blocks.push(wantsBuild && b.kind === 'list' ? { ...b, build: true } : b);
227
+ }
228
+ continue;
229
+ }
230
+
231
+ if (node.name === 'p:pic') {
232
+ if (find(node, 'a:videoFile') || find(node, 'a:audioFile')) {
233
+ drop('embedded media dropped — use data-background-video or a <video> (SPEC DECK_ANATOMY)');
234
+ continue;
235
+ }
236
+ const blip = find(node, 'a:blip');
237
+ const rel = blip && rels?.get(blip.attrs['r:embed']);
238
+ const media = rel && mediaOf?.(rel.target);
239
+ if (!media) { drop('an image could not be read from the file'); continue; }
240
+ const alt = find(node, 'p:cNvPr')?.attrs.descr ?? '';
241
+ blocks.push({ kind: 'image', ...media, alt });
242
+ continue;
243
+ }
244
+
245
+ if (node.name === 'p:graphicFrame') {
246
+ const uri = find(node, 'a:graphicData')?.attrs.uri ?? '';
247
+ const kind = uri.split('/').pop();
248
+ if (kind === 'table') {
249
+ const tbl = find(node, 'a:tbl');
250
+ if (tbl) blocks.push({ kind: 'table', node: tbl });
251
+ continue;
252
+ }
253
+ drop(GRAPHIC[kind] ?? `an embedded ${kind || 'object'} was dropped`);
254
+ continue;
255
+ }
256
+
257
+ if (node.name === 'mc:AlternateContent' || node.name === 'p:oleObj') {
258
+ drop('an embedded object was dropped');
259
+ }
260
+ }
261
+ };
262
+ const tree = find(sld, 'p:spTree');
263
+ if (tree) walk(tree);
264
+
265
+ return { slideNo, hidden, title, titleIsH1, subtitle, blocks, drops };
266
+ }
267
+
268
+ /** The notes text of a notesSlide part — the body placeholder, paragraph per line. */
269
+ export function notesText(xml, { rels } = {}) {
270
+ const doc = parseXml(xml ?? '');
271
+ for (const sp of findAll(doc, 'p:sp')) {
272
+ const type = find(sp, 'p:ph')?.attrs.type;
273
+ if (type !== 'body') continue;
274
+ const body = find(sp, 'p:txBody');
275
+ if (!body) continue;
276
+ const lines = children(body, 'a:p').map((p) => paragraphHtml(p, { rels })).filter(Boolean);
277
+ if (lines.length) return lines;
278
+ }
279
+ return [];
280
+ }
281
+
282
+ /** A parsed slide as the `<section>` markup, plus what its report line says. */
283
+ export function slideSection(slide, notes = [], { build = 'auto' } = {}) {
284
+ const parts = [];
285
+ const did = [];
286
+ if (slide.title) {
287
+ parts.push(` <${slide.titleIsH1 ? 'h1' : 'h2'}>${slide.title}</${slide.titleIsH1 ? 'h1' : 'h2'}>`);
288
+ }
289
+ if (slide.subtitle) parts.push(` <p>${slide.subtitle}</p>`);
290
+
291
+ let bullets = 0;
292
+ for (const b of slide.blocks) {
293
+ if (b.kind === 'list') {
294
+ bullets += b.items.length;
295
+ // --build all forces it on, none forces it off; auto follows PowerPoint's
296
+ // own per-paragraph build list
297
+ const on = build === 'all' || (build === 'auto' && b.build);
298
+ parts.push(` ${listHtml(b, { build: on ? 'fade-up' : null })}`);
299
+ } else if (b.kind === 'p') {
300
+ parts.push(` <p>${b.html}</p>`);
301
+ } else if (b.kind === 'table') {
302
+ const rows = children(b.node, 'a:tr');
303
+ const cols = rows.length ? children(rows[0], 'a:tc').length : 0;
304
+ did.push(`table ${rows.length}×${cols}`);
305
+ parts.push(` ${tableHtml(b.node)}`);
306
+ } else if (b.kind === 'image') {
307
+ did.push(`image inlined (${Math.round(b.bytes.length / 1024)} KB)`);
308
+ parts.push(` <img src="data:${b.mime};base64,${b.bytes.toString('base64')}"`
309
+ + `${b.alt ? ` alt="${escapeHtml(b.alt)}"` : ' alt=""'}>`);
310
+ }
311
+ }
312
+ if (bullets) did.unshift(`${bullets} bullet${bullets === 1 ? '' : 's'}`);
313
+ if (notes.length) {
314
+ did.push('notes');
315
+ parts.push(' <aside class="notes">');
316
+ for (const line of notes) parts.push(` <p>${line}</p>`);
317
+ parts.push(' </aside>');
318
+ }
319
+ return { html: ` <section>\n${parts.join('\n')}\n </section>`, did };
320
+ }
@@ -1,4 +1,7 @@
1
1
  #!/usr/bin/env node
2
+ // Copyright 2026 Gilles Philippart
3
+ // SPDX-License-Identifier: Apache-2.0
4
+
2
5
  // Sync the locally generated voice tracks (demo/voiceover-site/<dir>/) to the
3
6
  // decklight.github.io repo under voices/<dir>/, in ONE commit via the Git
4
7
  // Data API. Only files whose git blob sha differs from the remote are
@@ -14,9 +17,10 @@ import { readFileSync, readdirSync, existsSync } from 'node:fs';
14
17
  import { execFileSync } from 'node:child_process';
15
18
  import { join } from 'node:path';
16
19
  import { createHash } from 'node:crypto';
20
+ import { argReader } from './args.mjs';
17
21
 
18
22
  const args = process.argv.slice(2);
19
- const opt = (flag, dflt) => { const i = args.indexOf(flag); return i >= 0 ? args[i + 1] : dflt; };
23
+ const { opt } = argReader(args);
20
24
  const REPO = opt('--repo', 'decklight/decklight.github.io');
21
25
  const STAGING = 'demo/voiceover-site';
22
26
 
@@ -0,0 +1,143 @@
1
+ // Copyright 2026 Gilles Philippart
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ /**
5
+ * Publish targets beyond gh-pages (MARKETPLACE.md ENGINES, UNITS#REST).
6
+ *
7
+ * gh-pages stays core because it needs git auth and no credential — cli/publish.mjs
8
+ * talks to it directly, as it always has. Netlify and Vercel need a token, so they
9
+ * follow the ENGINES rule: *anything on the authoring path that needs a credential
10
+ * becomes a marketplace engine behind a core affordance.* The affordance here is
11
+ * `decklight publish --target <name>`; the schema each target declares is validated
12
+ * by cli/wizard.mjs's `validateSchema` — the exact closed vocabulary ENGINES#WIZARD
13
+ * built for TTS and lipsync — which is what proves the framework generalizes to a
14
+ * third domain rather than one this ticket invented in parallel.
15
+ *
16
+ * WHERE THE TOKEN COMES FROM. Not a terminal prompt, and not the browser wizard.
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
19
+ * the AUTHOR server, which publish never starts). The existing precedent for
20
+ * exactly this shape is ElevenLabs' own key (tools/elevenlabs-tts.mjs): read from
21
+ * the environment, never written to disk, "not boring enough" for a config file.
22
+ * Each target's env var NAMES its provider's own CLI convention on purpose
23
+ * (NETLIFY_AUTH_TOKEN, VERCEL_TOKEN) — anyone who already deploys with that CLI in
24
+ * CI has nothing new to configure. Values are still run through the schema's own
25
+ * `checkAnswers` before anything is sent, so a missing token is refused by the same
26
+ * validation the browser wizard would have applied, not a bespoke arg check.
27
+ *
28
+ * S3 is deliberately not here yet. It is the one target that needs request signing
29
+ * (SigV4) rather than a bearer token, and a hand-rolled signer that nobody can
30
+ * exercise against a real bucket in this environment is a correctness claim this
31
+ * file is not in a position to back. Netlify and Vercel prove the shape generalizes
32
+ * — S3 is a fast follow once someone can verify a signed request lands.
33
+ */
34
+
35
+ import { zipSync } from '../cli/zip.mjs';
36
+ import { validateSchema } from '../cli/wizard.mjs';
37
+
38
+ export const TARGETS = ['netlify', 'vercel'];
39
+
40
+ // Raw schemas, in the ENGINES#WIZARD shape (cli/wizard.mjs FIELD_TYPES) — the same
41
+ // vocabulary a marketplace-declared engine is limited to, so a hand-authored schema
42
+ // here is provably no more expressive than one a plugin could have sent.
43
+ const RAW_SCHEMAS = {
44
+ netlify: {
45
+ engine: 'netlify',
46
+ title: 'Netlify',
47
+ fields: [
48
+ { name: 'token', label: 'Personal access token', type: 'secret', required: true },
49
+ { name: 'siteId', label: 'Site ID (Site settings → General → Site details)', type: 'text', required: true },
50
+ ],
51
+ },
52
+ vercel: {
53
+ engine: 'vercel',
54
+ title: 'Vercel',
55
+ fields: [
56
+ { name: 'token', label: 'Access token', type: 'secret', required: true },
57
+ { name: 'project', label: 'Project name', type: 'text', required: true },
58
+ { name: 'teamId', label: 'Team ID', type: 'text' },
59
+ ],
60
+ },
61
+ };
62
+
63
+ /** Which environment variable answers each field — the provider's OWN CLI names. */
64
+ const ENV_VARS = {
65
+ netlify: { token: 'NETLIFY_AUTH_TOKEN', siteId: 'NETLIFY_SITE_ID' },
66
+ vercel: { token: 'VERCEL_TOKEN', project: 'VERCEL_PROJECT', teamId: 'VERCEL_TEAM_ID' },
67
+ };
68
+
69
+ const known = (target) => {
70
+ if (!TARGETS.includes(target)) {
71
+ throw new Error(`"${target}" is not a publish target this decklight knows — try: ${TARGETS.join(', ')} (or omit --target for gh-pages)`);
72
+ }
73
+ };
74
+
75
+ /** The normalized wizard schema for a target — validated, same as any engine's. */
76
+ export function schemaFor(target) {
77
+ known(target);
78
+ return validateSchema(RAW_SCHEMAS[target]);
79
+ }
80
+
81
+ /** field name → the env var it reads, for error messages that name something real. */
82
+ export function envVarsFor(target) {
83
+ known(target);
84
+ return ENV_VARS[target];
85
+ }
86
+
87
+ /** Assemble a target's answers from the environment. Missing vars become `undefined` — checkAnswers names them. */
88
+ export function envAnswers(target, env = process.env) {
89
+ const vars = envVarsFor(target);
90
+ const out = {};
91
+ for (const [field, name] of Object.entries(vars)) if (env[name]) out[field] = env[name];
92
+ return out;
93
+ }
94
+
95
+ const safeText = async (r) => { try { return (await r.text()).slice(0, 300); } catch { return ''; } };
96
+
97
+ /**
98
+ * Netlify: a single zip deploy. One POST, no digest/required-files dance — the
99
+ * container plumbing already exists (cli/zip.mjs, from `skills --pack`), and a
100
+ * deck's published output is small enough that a whole-zip deploy costs nothing
101
+ * a partial one would have saved.
102
+ */
103
+ export async function deployNetlify({ token, siteId }, files, { fetchImpl = fetch } = {}) {
104
+ const zip = zipSync(files.map(({ path, data }) => ({ name: path, data })));
105
+ const r = await fetchImpl(`https://api.netlify.com/api/v1/sites/${encodeURIComponent(siteId)}/deploys`, {
106
+ method: 'POST',
107
+ headers: { authorization: `Bearer ${token}`, 'content-type': 'application/zip' },
108
+ body: zip,
109
+ });
110
+ if (!r.ok) throw new Error(`netlify: HTTP ${r.status} — ${await safeText(r)}`);
111
+ const j = await r.json();
112
+ return { url: j.ssl_url ?? j.deploy_ssl_url ?? j.url ?? null, id: j.id ?? null };
113
+ }
114
+
115
+ /** Vercel: files inline as base64 in one JSON POST — no zip, per their own API shape. */
116
+ export async function deployVercel({ token, project, teamId }, files, { fetchImpl = fetch } = {}) {
117
+ const body = {
118
+ name: project,
119
+ target: 'production',
120
+ files: files.map(({ path, data }) => ({
121
+ file: path,
122
+ data: (Buffer.isBuffer(data) ? data : Buffer.from(String(data))).toString('base64'),
123
+ encoding: 'base64',
124
+ })),
125
+ };
126
+ const url = `https://api.vercel.com/v13/deployments${teamId ? `?teamId=${encodeURIComponent(teamId)}` : ''}`;
127
+ const r = await fetchImpl(url, {
128
+ method: 'POST',
129
+ headers: { authorization: `Bearer ${token}`, 'content-type': 'application/json' },
130
+ body: JSON.stringify(body),
131
+ });
132
+ if (!r.ok) throw new Error(`vercel: HTTP ${r.status} — ${await safeText(r)}`);
133
+ const j = await r.json();
134
+ return { url: j.url ? `https://${j.url}` : null, id: j.id ?? j.uid ?? null };
135
+ }
136
+
137
+ const DEPLOYERS = { netlify: deployNetlify, vercel: deployVercel };
138
+
139
+ /** `files` is `[{ path, data: Buffer|string }]` — the same set gh-pages commits. */
140
+ export async function deploy(target, answers, files, opts = {}) {
141
+ known(target);
142
+ return DEPLOYERS[target](answers, files, opts);
143
+ }