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.
- package/README.md +69 -31
- package/SPEC.md +855 -80
- package/cli/agents.mjs +113 -9
- package/cli/associate.mjs +279 -0
- package/cli/audit.mjs +424 -0
- package/cli/bundle.mjs +174 -46
- package/cli/deckfile.mjs +233 -0
- package/cli/decklight.mjs +201 -8
- package/cli/dev.mjs +244 -55
- package/cli/edit.mjs +564 -107
- package/cli/extension.mjs +108 -0
- package/cli/git.mjs +141 -0
- package/cli/import.mjs +398 -0
- package/cli/init.mjs +421 -116
- package/cli/loader.mjs +263 -0
- package/cli/marketplace.mjs +730 -0
- package/cli/pdf.mjs +156 -0
- package/cli/pkg.mjs +69 -0
- package/cli/plugin.mjs +646 -0
- package/cli/port-conflict.mjs +94 -0
- package/cli/present.mjs +560 -0
- package/cli/publish.mjs +342 -0
- package/cli/qr.mjs +334 -0
- package/cli/rec.mjs +5 -8
- package/cli/remote.mjs +149 -0
- package/cli/report-bug.mjs +97 -0
- package/cli/restore.mjs +174 -0
- package/cli/serve.mjs +247 -0
- package/cli/sign.mjs +216 -0
- package/cli/skill-content.mjs +222 -0
- package/cli/skills.mjs +338 -0
- package/cli/supervise.mjs +57 -0
- package/cli/theme.mjs +201 -0
- package/cli/units.mjs +488 -0
- package/cli/upgrade.mjs +250 -0
- package/cli/util.mjs +90 -0
- package/cli/wizard.mjs +432 -0
- package/cli/zip.mjs +121 -0
- package/dist/decklight.css +716 -29
- package/dist/decklight.js +198 -125
- package/dist/decklight.js.map +4 -4
- package/docs/architecture.svg +1 -1
- package/package.json +5 -4
- package/themes/README.md +6 -4
- package/themes/aurora.css +1 -1
- package/themes/berry.css +1 -1
- package/themes/carbon.css +1 -1
- package/themes/citrus.css +1 -1
- package/themes/coastal.css +1 -1
- package/themes/cosmos.css +1 -1
- package/themes/dune.css +1 -1
- package/themes/eclipse.css +1 -1
- package/themes/ember.css +1 -1
- package/themes/fjord.css +1 -1
- package/themes/gallery.html +3 -11
- package/themes/glacier.css +1 -1
- package/themes/graphite.css +1 -1
- package/themes/harvest.css +1 -1
- package/themes/ibm-modern.css +1 -1
- package/themes/ink.css +1 -1
- package/themes/latte.css +1 -1
- package/themes/linen.css +1 -1
- package/themes/meadow.css +1 -1
- package/themes/metropolis.css +1 -1
- package/themes/midnight.css +1 -1
- package/themes/mint.css +1 -1
- package/themes/moss.css +1 -1
- package/themes/obsidian.css +1 -1
- package/themes/orchid.css +1 -1
- package/themes/packs.json +2 -30
- package/themes/paper.css +1 -1
- package/themes/peony.css +1 -1
- package/themes/porcelain.css +1 -1
- package/themes/reveal-beige.css +1 -1
- package/themes/reveal-black.css +1 -1
- package/themes/reveal-blood.css +1 -1
- package/themes/reveal-dracula.css +1 -1
- package/themes/reveal-league.css +1 -1
- package/themes/reveal-moon.css +1 -1
- package/themes/reveal-night.css +1 -1
- package/themes/reveal-serif.css +1 -1
- package/themes/reveal-simple.css +1 -1
- package/themes/reveal-sky.css +1 -1
- package/themes/reveal-solarized.css +1 -1
- package/themes/reveal-white.css +1 -1
- package/themes/sepia.css +1 -1
- package/themes/seriph.css +1 -1
- package/themes/slate.css +1 -1
- package/themes/storm.css +1 -1
- package/themes/synthwave.css +1 -1
- package/themes/velvet.css +1 -1
- package/themes/yamabuki.css +1 -1
- package/tools/args.mjs +32 -0
- package/tools/bridge.mjs +30 -0
- package/tools/chrome.mjs +11 -2
- package/tools/color.mjs +110 -0
- package/tools/deck-html.mjs +138 -0
- package/tools/elevenlabs-tts.mjs +248 -0
- package/tools/escape.mjs +40 -0
- package/tools/extension-check-runner.mjs +41 -0
- package/tools/extension-check.mjs +266 -0
- package/tools/gemini-tts.mjs +25 -3
- package/tools/lipsync-engines.mjs +81 -0
- package/tools/lipsync-server.mjs +78 -37
- package/tools/lipsync.mjs +36 -21
- package/tools/local-voice.mjs +209 -0
- package/tools/ooxml.mjs +151 -0
- package/tools/pptx.mjs +320 -0
- package/tools/publish-site-voices.mjs +2 -1
- package/tools/publish-targets.mjs +143 -0
- package/tools/publish-voices.mjs +230 -0
- package/tools/shot.mjs +91 -47
- package/tools/theme-check.mjs +139 -0
- package/tools/tts-engines.mjs +270 -41
- package/tools/tts-setup.mjs +257 -0
- package/tools/veo.mjs +204 -0
- package/tools/video.mjs +316 -0
- package/tools/voiceover-server.mjs +163 -54
- package/tools/voiceover.mjs +24 -7
- package/tools/zip.mjs +143 -0
- package/docs/demo.svg +0 -124
- package/themes/aliens.css +0 -87
- package/themes/apple2.css +0 -129
- package/themes/blade-runner.css +0 -86
- package/themes/c64.css +0 -88
- package/themes/friends.css +0 -85
- package/themes/gameboy.css +0 -121
- package/themes/genesis.css +0 -87
- package/themes/godfather.css +0 -85
- package/themes/ibm-oldschool.css +0 -87
- package/themes/miami-vice.css +0 -87
- package/themes/pulp-fiction.css +0 -87
- package/themes/severance.css +0 -85
- package/themes/snes.css +0 -85
- package/themes/star-wars.css +0 -88
- package/themes/stranger-things.css +0 -87
- package/themes/terminator.css +0 -87
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
|
+
}
|
|
@@ -17,9 +17,10 @@ import { readFileSync, readdirSync, existsSync } from 'node:fs';
|
|
|
17
17
|
import { execFileSync } from 'node:child_process';
|
|
18
18
|
import { join } from 'node:path';
|
|
19
19
|
import { createHash } from 'node:crypto';
|
|
20
|
+
import { argReader } from './args.mjs';
|
|
20
21
|
|
|
21
22
|
const args = process.argv.slice(2);
|
|
22
|
-
const
|
|
23
|
+
const { opt } = argReader(args);
|
|
23
24
|
const REPO = opt('--repo', 'decklight/decklight.github.io');
|
|
24
25
|
const STAGING = 'demo/voiceover-site';
|
|
25
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
|
+
}
|