decklight 0.7.0 → 0.8.1
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 +7 -3
- package/SPEC.md +23 -15
- package/cli/associate.mjs +2 -2
- package/cli/bundle.mjs +1 -1
- package/cli/decklight.mjs +9 -1
- package/cli/edit.mjs +54 -1
- package/cli/import.mjs +41 -11
- package/cli/pdf.mjs +59 -14
- package/cli/pptx-export.mjs +119 -0
- package/cli/present.mjs +8 -4
- package/cli/publish.mjs +10 -2
- package/cli/record.mjs +3 -3
- package/cli/skill-content.mjs +1 -0
- package/dist/build-info.json +1 -1
- package/dist/decklight.css +10 -0
- package/dist/decklight.js +135 -84
- package/dist/decklight.js.map +4 -4
- package/docs/architecture.svg +3 -3
- package/package.json +2 -1
- package/tools/bridge.mjs +25 -2
- package/tools/deck-html.mjs +9 -0
- package/tools/elevenlabs-tts.mjs +2 -2
- package/tools/exec.mjs +87 -0
- package/tools/gemini-tts.mjs +4 -4
- package/tools/lipsync-server.mjs +6 -0
- package/tools/lipsync.mjs +6 -6
- package/tools/local-voice.mjs +73 -3
- package/tools/pptx-write.mjs +151 -0
- package/tools/pptx.mjs +82 -2
- package/tools/publish-site-voices.mjs +2 -2
- package/tools/publish-targets.mjs +39 -2
- package/tools/publish-voices.mjs +2 -2
- package/tools/template-theme.mjs +154 -0
- package/tools/test-impact.mjs +19 -10
- package/tools/tts-cache.mjs +191 -0
- package/tools/tts-engines.mjs +62 -7
- package/tools/tts-setup.mjs +3 -2
- package/tools/video.mjs +6 -3
- package/tools/voiceover-server.mjs +40 -54
- package/tools/voiceover.mjs +95 -16
package/docs/architecture.svg
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
<text x="155" y="136" text-anchor="middle" font-size="10.5" fill="#aeb4c6">one file, written by humans & agents</text>
|
|
19
19
|
|
|
20
20
|
<rect x="40" y="186" width="230" height="72" rx="10" fill="#23444d" stroke="#3f6a76" stroke-width="1.5"/>
|
|
21
|
-
<text x="155" y="212" text-anchor="middle" font-size="13" font-weight="700" fill="#e8eaf2">theme.css —
|
|
21
|
+
<text x="155" y="212" text-anchor="middle" font-size="13" font-weight="700" fill="#e8eaf2">theme.css — 46 shipped themes</text>
|
|
22
22
|
<text x="155" y="232" text-anchor="middle" font-size="10.5" fill="#aeb4c6">one token contract (~50 vars)</text>
|
|
23
23
|
<text x="155" y="246" text-anchor="middle" font-size="10.5" fill="#aeb4c6">+ runtime generator (⌃T)</text>
|
|
24
24
|
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
<rect x="348" y="126" width="140" height="30" rx="6" fill="#252a3a"/><text x="418" y="145" text-anchor="middle">engine · builds · nav</text>
|
|
32
32
|
<rect x="500" y="126" width="142" height="30" rx="6" fill="#252a3a"/><text x="571" y="145" text-anchor="middle">themes · generator</text>
|
|
33
33
|
<rect x="348" y="164" width="140" height="30" rx="6" fill="#252a3a"/><text x="418" y="183" text-anchor="middle">terminal player</text>
|
|
34
|
-
<rect x="500" y="164" width="142" height="30" rx="6" fill="#252a3a"/><text x="571" y="183" text-anchor="middle">
|
|
34
|
+
<rect x="500" y="164" width="142" height="30" rx="6" fill="#252a3a"/><text x="571" y="183" text-anchor="middle">svg · code · math</text>
|
|
35
35
|
<rect x="348" y="202" width="140" height="30" rx="6" fill="#252a3a"/><text x="418" y="221" text-anchor="middle">narration · captions</text>
|
|
36
36
|
<rect x="500" y="202" width="142" height="30" rx="6" fill="#252a3a"/><text x="571" y="221" text-anchor="middle">speaker · overlays</text>
|
|
37
37
|
<rect x="348" y="240" width="294" height="30" rx="6" fill="#252a3a"/><text x="495" y="259" text-anchor="middle">quiz slides · transcript · debug log · edit mode</text>
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
<rect x="40" y="356" width="620" height="86" rx="10" fill="#52402a" stroke="#7d6544" stroke-width="1.5"/>
|
|
58
58
|
<text x="350" y="382" text-anchor="middle" font-size="13" font-weight="700" fill="#e8eaf2">CLI — node, the only place with native deps</text>
|
|
59
59
|
<g font-size="10.5" fill="#efe9dd">
|
|
60
|
-
<rect x="58" y="396" width="130" height="30" rx="6" fill="#453722"/><text x="123" y="415" text-anchor="middle">
|
|
60
|
+
<rect x="58" y="396" width="130" height="30" rx="6" fill="#453722"/><text x="123" y="415" text-anchor="middle">cast — real PTY casts</text>
|
|
61
61
|
<rect x="200" y="396" width="130" height="30" rx="6" fill="#453722"/><text x="265" y="415" text-anchor="middle">refresh — drift check</text>
|
|
62
62
|
<rect x="342" y="396" width="140" height="30" rx="6" fill="#453722"/><text x="412" y="415" text-anchor="middle">export — asciicast v2</text>
|
|
63
63
|
<rect x="494" y="396" width="148" height="30" rx="6" fill="#453722"/><text x="568" y="415" text-anchor="middle">bundle — one-file deck</text>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "decklight",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "A presentation library designed to be authored by AI agents and humans alike: single-file decks, Keynote-style builds, theme-aware SVG diagrams, and truthful terminal recordings.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/decklight.js",
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"build": "node build.mjs",
|
|
38
38
|
"prepare": "npm run build",
|
|
39
39
|
"test": "node test/run.mjs",
|
|
40
|
+
"coverage": "node test/run.mjs --experimental-test-coverage --test-coverage-include=src/core/** --test-coverage-include=cli/** --test-coverage-include=tools/**",
|
|
40
41
|
"verify": "npm run build && node test/verify.mjs",
|
|
41
42
|
"test:impact": "node tools/test-impact.mjs",
|
|
42
43
|
"soak": "node test/soak.mjs",
|
package/tools/bridge.mjs
CHANGED
|
@@ -23,8 +23,31 @@ export const corsHeaders = (expose = '') => ({
|
|
|
23
23
|
* abort mid-request rejects the stream, and unguarded that would crash the
|
|
24
24
|
* whole bridge. Callers that want text `.toString()` the result.
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
/**
|
|
27
|
+
* The whole request body, as bytes.
|
|
28
|
+
*
|
|
29
|
+
* `max` is opt-in, and which callers set it is the design. The lipsync bridge
|
|
30
|
+
* receives a slide's WAV here and the TTS bridge a sentence; neither has a
|
|
31
|
+
* size a cap could sensibly name. The phone remote in cli/present.mjs does:
|
|
32
|
+
* it is the one route reachable from OFF this machine under --remote, its
|
|
33
|
+
* payloads are a few dozen bytes of "go to slide 7", and a body past 4 KB is
|
|
34
|
+
* not a bigger request, it is someone probing. So that caller passes `max`,
|
|
35
|
+
* and past it the socket is destroyed — no response, no 413 to time against,
|
|
36
|
+
* exactly what present.mjs did with its own reader before this shared one
|
|
37
|
+
* could — and the caller gets an error it can recognise and drop.
|
|
38
|
+
*/
|
|
39
|
+
export async function readBody(req, { max = Infinity } = {}) {
|
|
27
40
|
const chunks = [];
|
|
28
|
-
|
|
41
|
+
let size = 0;
|
|
42
|
+
for await (const c of req) {
|
|
43
|
+
size += c.length;
|
|
44
|
+
if (size > max) {
|
|
45
|
+
req.destroy();
|
|
46
|
+
const err = new Error(`request body past ${max} bytes`);
|
|
47
|
+
err.code = 'E2BIG';
|
|
48
|
+
throw err;
|
|
49
|
+
}
|
|
50
|
+
chunks.push(c);
|
|
51
|
+
}
|
|
29
52
|
return Buffer.concat(chunks);
|
|
30
53
|
}
|
package/tools/deck-html.mjs
CHANGED
|
@@ -21,6 +21,15 @@ export const NOTES_ASIDE = /<aside class="notes">([\s\S]*?)<\/aside>/;
|
|
|
21
21
|
*/
|
|
22
22
|
export const sectionBodies = (html) => html.split(/<section\b/).slice(1);
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Is a `sectionBodies` entry a hidden slide? `data-hidden` on the open tag
|
|
26
|
+
* (DECK_ANATOMY). File-side tools that produce one THING per slide — a video
|
|
27
|
+
* frame, a voiceover file, a PDF page — skip it; tools that NUMBER slides —
|
|
28
|
+
* comments, review anchors, history — do not, because a hidden slide keeps
|
|
29
|
+
* its number exactly as it does in PowerPoint.
|
|
30
|
+
*/
|
|
31
|
+
export const isHiddenSection = (body) => /^[^>]*\sdata-hidden(?=[\s=>\/])/.test(body);
|
|
32
|
+
|
|
24
33
|
/**
|
|
25
34
|
* A section body from `sectionBodies`, reduced to what is actually inside the
|
|
26
35
|
* section.
|
package/tools/elevenlabs-tts.mjs
CHANGED
|
@@ -65,7 +65,7 @@ export function styleTag(style, maxLen = MAX_TAG_LEN) {
|
|
|
65
65
|
return cue ? `[${cue}]` : '';
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
// PCM is what the rest of decklight is built on:
|
|
68
|
+
// PCM is what the rest of decklight is built on: the deck's recorder stitches per-slide WAVs
|
|
69
69
|
// out of the sentence cache, and rhubarb reads WAV to find visemes. mp3 plays
|
|
70
70
|
// perfectly well in the deck but does neither, so it is opt-in rather than a
|
|
71
71
|
// silent downgrade. PCM output needs a paid ElevenLabs tier; see synthError.
|
|
@@ -130,7 +130,7 @@ export function synthError(status, body, { format = 'pcm' } = {}) {
|
|
|
130
130
|
}
|
|
131
131
|
if (format === 'pcm' && /output_format|pcm|tier|subscription/i.test(text)) {
|
|
132
132
|
return 'ElevenLabs will not serve pcm_24000 on this plan (PCM output is a paid tier). '
|
|
133
|
-
+ 'Pass --tts-format mp3 to use mp3 instead — the deck plays it fine, but
|
|
133
|
+
+ 'Pass --tts-format mp3 to use mp3 instead — the deck plays it fine, but the panel\'s Record this deck… offline '
|
|
134
134
|
+ 'recording and the lip-sync bridge both need WAV and will not work with it.';
|
|
135
135
|
}
|
|
136
136
|
if (status === 429) return 'ElevenLabs rate limit (429) — the lookahead buffer is bursty; try a smaller deck or wait';
|
package/tools/exec.mjs
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// Copyright 2026 Gilles Philippart
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* One bounded child exec, for the sixteen places a hang could sit forever.
|
|
6
|
+
*
|
|
7
|
+
* #431 found a `say` with 0.31s of CPU after eight minutes, blocked in macOS's
|
|
8
|
+
* speech server, and an execFileSync above it with no timeout — so
|
|
9
|
+
* `decklight voiceover` waited with it, silently. That was one call of forty-
|
|
10
|
+
* three. The others are the same shape with different daemons behind them:
|
|
11
|
+
* gcloud waiting on a login that expired, gh waiting on the network, ffmpeg
|
|
12
|
+
* spinning on a file that is not what its extension says, Chrome waiting on
|
|
13
|
+
* a resource a slide points at. None of them ever say so.
|
|
14
|
+
*
|
|
15
|
+
* `run` is execFileSync with two things that should never be optional: a
|
|
16
|
+
* timeout, and SIGKILL rather than SIGTERM when it fires — a wedged process
|
|
17
|
+
* is blocked in a syscall and a polite signal is exactly what it is not
|
|
18
|
+
* answering. A timeout throws an error that names the binary, the wait, and
|
|
19
|
+
* WHY (the caller's word for what is probably stuck), because the person
|
|
20
|
+
* reading it will otherwise reword the sentence, re-encode the file, or
|
|
21
|
+
* reinstall the tool — anything but restart the daemon that is the actual
|
|
22
|
+
* problem.
|
|
23
|
+
*
|
|
24
|
+
* Every OTHER error is rethrown untouched. Callers inspect `.status`,
|
|
25
|
+
* `.stderr` and `.code === 'ENOENT'` — a probe that treats "present but
|
|
26
|
+
* exiting 1" as present depends on that — and wrapping them would break every
|
|
27
|
+
* one.
|
|
28
|
+
*
|
|
29
|
+
* Budgets, named for what they are rather than how long: a probe answers in
|
|
30
|
+
* milliseconds, the network in seconds, a codec in as long as the audio is.
|
|
31
|
+
*
|
|
32
|
+
* `runAsync` is the same contract without blocking the event loop, and it
|
|
33
|
+
* exists because one caller must not: a command that renders through
|
|
34
|
+
* `serveForRender` (PRESENTING) launches Chrome and then has to ANSWER it from
|
|
35
|
+
* this same process. `run` there is a deadlock — the browser waits for a
|
|
36
|
+
* server that cannot run until the browser exits — and it looks exactly like a
|
|
37
|
+
* hang, right down to this module's own timeout message. `decklight pptx`
|
|
38
|
+
* shipped that way in 0.8.0.
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
import { execFile, execFileSync } from 'node:child_process';
|
|
42
|
+
|
|
43
|
+
/** `--version` and its kin. Anything slower than this is not answering. */
|
|
44
|
+
export const PROBE_MS = 15_000;
|
|
45
|
+
/** gcloud, gh: a login prompt nobody can see, or a network that is not there. */
|
|
46
|
+
export const NETWORK_MS = 60_000;
|
|
47
|
+
/** ffmpeg, afconvert, Chrome: a whole slide's audio, a whole deck's render. */
|
|
48
|
+
export const CODEC_MS = 5 * 60_000;
|
|
49
|
+
|
|
50
|
+
export function run(bin, args, { timeout = NETWORK_MS, why = '', ...opts } = {}) {
|
|
51
|
+
try {
|
|
52
|
+
return execFileSync(bin, args, { ...opts, timeout, killSignal: 'SIGKILL' });
|
|
53
|
+
} catch (e) {
|
|
54
|
+
if (e.code === 'ETIMEDOUT' || (e.signal === 'SIGKILL' && e.status == null)) {
|
|
55
|
+
const err = new Error(`${bin} hung for ${Math.round(timeout / 1000)}s and was killed`
|
|
56
|
+
+ (why ? ` — ${why}` : ''));
|
|
57
|
+
err.code = 'ETIMEDOUT'; err.bin = bin; err.cause = e;
|
|
58
|
+
throw err;
|
|
59
|
+
}
|
|
60
|
+
throw e;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* `run`, awaited rather than blocking. Same timeout, same SIGKILL, same
|
|
66
|
+
* ETIMEDOUT error naming the binary and WHY; every other failure rejects with
|
|
67
|
+
* the untouched child_process error, so callers keep reading `.status`,
|
|
68
|
+
* `.stderr` and `.code === 'ENOENT'`.
|
|
69
|
+
*
|
|
70
|
+
* Use this — never `run` — whenever the process that spawns the child is also
|
|
71
|
+
* serving it (tools/shot.mjs, tools/video.mjs, cli/pptx-export.mjs).
|
|
72
|
+
*/
|
|
73
|
+
export function runAsync(bin, args, { timeout = NETWORK_MS, why = '', ...opts } = {}) {
|
|
74
|
+
return new Promise((resolve, reject) => {
|
|
75
|
+
execFile(bin, args, { ...opts, timeout, killSignal: 'SIGKILL' }, (e, stdout, stderr) => {
|
|
76
|
+
if (!e) return resolve(stdout);
|
|
77
|
+
if (e.killed || e.code === 'ETIMEDOUT' || (e.signal === 'SIGKILL' && e.status == null)) {
|
|
78
|
+
const err = new Error(`${bin} hung for ${Math.round(timeout / 1000)}s and was killed`
|
|
79
|
+
+ (why ? ` — ${why}` : ''));
|
|
80
|
+
err.code = 'ETIMEDOUT'; err.bin = bin; err.cause = e;
|
|
81
|
+
return reject(err);
|
|
82
|
+
}
|
|
83
|
+
e.stdout = stdout; e.stderr = stderr;
|
|
84
|
+
reject(e);
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
}
|
package/tools/gemini-tts.mjs
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
// location pair is probed once (GA vs -preview, global vs us-central1) and
|
|
10
10
|
// cached for the synth's lifetime.
|
|
11
11
|
|
|
12
|
-
import {
|
|
12
|
+
import { run, NETWORK_MS } from './exec.mjs';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* GCP project ids: 6–30 chars, lowercase, leading letter, no trailing hyphen.
|
|
@@ -38,8 +38,8 @@ export const GEMINI_VOICES = [
|
|
|
38
38
|
// ADC, not `gcloud auth login` — a separate credential store, and the one every
|
|
39
39
|
// Google client library reads. Shared with the Chirp engine (tools/tts-engines.mjs).
|
|
40
40
|
export function gcloudToken() {
|
|
41
|
-
return
|
|
42
|
-
{ encoding: 'utf8' }).trim();
|
|
41
|
+
return run('gcloud', ['auth', 'application-default', 'print-access-token'],
|
|
42
|
+
{ encoding: 'utf8', timeout: NETWORK_MS, why: 'gcloud is waiting on a login that expired, or on the network — run: gcloud auth application-default login' }).trim();
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
/**
|
|
@@ -69,7 +69,7 @@ function estimateCost(model, usage) {
|
|
|
69
69
|
/**
|
|
70
70
|
* Wrap headerless 16-bit mono PCM in a RIFF/WAVE header. Every engine that
|
|
71
71
|
* gets raw samples back lands here (Gemini's audio/L16, ElevenLabs' pcm_24000)
|
|
72
|
-
* — WAV is what the deck's
|
|
72
|
+
* — WAV is what the deck's recorder (V → Record this deck…) stitching and the lip-sync bridge both read.
|
|
73
73
|
*/
|
|
74
74
|
export function wavFromPcm(pcm, rate) {
|
|
75
75
|
const h = Buffer.alloc(44);
|
package/tools/lipsync-server.mjs
CHANGED
|
@@ -86,6 +86,12 @@ async function askLine(prompt) {
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
export async function lipsyncMain(args) {
|
|
89
|
+
// A clean exit on SIGTERM, not the default abrupt one. Invisible in
|
|
90
|
+
// production, decisive under test: V8 writes a process's coverage only when
|
|
91
|
+
// it exits through process.exit, so a bridge the suite stops with SIGKILL —
|
|
92
|
+
// or an unhandled SIGTERM — reports NOTHING of the handler it ran. The edit
|
|
93
|
+
// and present servers already do this; voiceover-server does now too.
|
|
94
|
+
process.on('SIGTERM', () => process.exit(0));
|
|
89
95
|
if (args.includes('--help')) {
|
|
90
96
|
console.log(`usage: decklight lipsync [--port 8789] [--rhubarb <bin>]
|
|
91
97
|
[--portrait <name=img.png>]... portraits offered for video mode (first = default)
|
package/tools/lipsync.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// Lip-sync generator for RECORDED narration: sidecar files for every
|
|
3
3
|
// slide-NN audio clip in a voiceover directory (tools/voiceover.mjs or a
|
|
4
|
-
//
|
|
4
|
+
// deck-recorded set — V → Record this deck…), so a deck plays back with an animated character and no
|
|
5
5
|
// bridge running. Fully offline, like everything else here.
|
|
6
6
|
//
|
|
7
7
|
// node tools/lipsync.mjs <voiceover-dir> [--visemes] [--video]
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
// --video — slide-NN.mp4 (muted talking head)
|
|
16
16
|
//
|
|
17
17
|
// Rhubarb wants WAV: slide-NN.wav is used when present (voiceover.mjs
|
|
18
|
-
// --keep-wav, or a
|
|
18
|
+
// --keep-wav, or a set the deck recorded); otherwise the .m4a is decoded on the fly with
|
|
19
19
|
// ffmpeg (afconvert fallback on macOS). The transcript slide-NN.txt, when
|
|
20
20
|
// present, markedly improves cue accuracy. For batch video SadTalker is the
|
|
21
21
|
// default engine — per-slide clips are long enough that its natural head
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
|
|
28
28
|
import { readFileSync, writeFileSync, existsSync, readdirSync, rmSync, renameSync } from 'node:fs';
|
|
29
29
|
import { createHash } from 'node:crypto';
|
|
30
|
-
import { execFileSync } from 'node:child_process';
|
|
31
30
|
import { resolve, join, basename } from 'node:path';
|
|
32
31
|
import { createVeo, DEFAULT_PROMPT, VEO_MODELS } from './veo.mjs';
|
|
33
32
|
import { argReader } from './args.mjs';
|
|
34
33
|
import { runRhubarb, runWav2lip, runSadtalker, muteFaststart } from './lipsync-engines.mjs';
|
|
34
|
+
import { run, PROBE_MS, CODEC_MS } from './exec.mjs';
|
|
35
35
|
|
|
36
36
|
const args = process.argv.slice(2);
|
|
37
37
|
const dirArg = args.find((a) => !a.startsWith('-'));
|
|
@@ -68,7 +68,7 @@ const veo = veoOn ? createVeo({
|
|
|
68
68
|
}) : null;
|
|
69
69
|
|
|
70
70
|
const have = (bin, flags = ['--version']) => {
|
|
71
|
-
try {
|
|
71
|
+
try { run(bin, flags, { stdio: 'ignore', timeout: PROBE_MS }); return true; } catch (e) { return e?.code !== 'ENOENT'; }
|
|
72
72
|
};
|
|
73
73
|
if (doVisemes && !have(rhubarb)) {
|
|
74
74
|
console.error(`rhubarb not found — install https://github.com/DanielSWolf/rhubarb-lip-sync or pass --rhubarb <bin>`);
|
|
@@ -115,8 +115,8 @@ function toWav(stem) {
|
|
|
115
115
|
if (existsSync(wav)) return { path: wav, tmp: false };
|
|
116
116
|
const m4a = join(dir, `${stem}.m4a`);
|
|
117
117
|
const tmp = join(dir, `${stem}.tmp.wav`);
|
|
118
|
-
if (ffmpegOk)
|
|
119
|
-
else
|
|
118
|
+
if (ffmpegOk) run('ffmpeg', ['-y', '-i', m4a, tmp], { stdio: 'ignore', timeout: CODEC_MS, why: 'the encoder is stuck on this file — check it plays, then retry' });
|
|
119
|
+
else run('afconvert', ['-f', 'WAVE', '-d', 'LEI16', m4a, tmp], { timeout: CODEC_MS, why: 'the encoder is stuck on this file — check it plays, then retry' });
|
|
120
120
|
return { path: tmp, tmp: true };
|
|
121
121
|
}
|
|
122
122
|
|
package/tools/local-voice.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// Copyright 2026 Gilles Philippart
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { execFileSync } from 'node:child_process';
|
|
5
4
|
import { existsSync } from 'node:fs';
|
|
6
5
|
import { delimiter, join } from 'node:path';
|
|
6
|
+
import { run, PROBE_MS } from './exec.mjs';
|
|
7
7
|
|
|
8
8
|
// What can this machine say out loud, without a credential and without a
|
|
9
9
|
// download?
|
|
@@ -96,6 +96,76 @@ export function sayTier(name, sample = '') {
|
|
|
96
96
|
*/
|
|
97
97
|
export const TIER_LABEL = ['best', 'good', 'good', 'average', 'novelty'];
|
|
98
98
|
|
|
99
|
+
/**
|
|
100
|
+
* The `average` shelf — the plain compact voice every locale ships.
|
|
101
|
+
*
|
|
102
|
+
* Derived from TIER_LABEL rather than written as 3, so inserting a shelf moves
|
|
103
|
+
* this with it instead of silently re-pointing it at the wrong one.
|
|
104
|
+
*/
|
|
105
|
+
export const PLAIN_TIER = TIER_LABEL.indexOf('average');
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The quality suffix Apple appends to a voice that has a better build.
|
|
109
|
+
*
|
|
110
|
+
* Deliberately an ALLOW-LIST of the four markers sayTier scores on, not "a
|
|
111
|
+
* trailing parenthetical": plenty of voices carry one that says nothing about
|
|
112
|
+
* quality — `Eddy (English (UK))`, `Aman (English (India))` — and stripping
|
|
113
|
+
* those would have `Aman` superseded by a novelty voice of the same name.
|
|
114
|
+
*/
|
|
115
|
+
const QUALITY_SUFFIX = /\s*\((?:Personal Voice|Siri[^)]*|Premium|Neural|Enhanced)\)\s*$/i;
|
|
116
|
+
|
|
117
|
+
/** `Daniel (Enhanced)` → `Daniel`; `Eddy (English (UK))` → unchanged. */
|
|
118
|
+
export const plainName = (name) => String(name ?? '').replace(QUALITY_SUFFIX, '').trim();
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Drop a plain voice that is the SAME VOICE as a better one beside it.
|
|
122
|
+
*
|
|
123
|
+
* A real Mac lists both `Daniel` and `Daniel (Enhanced)` in en_GB, and both
|
|
124
|
+
* `Audrey` and `Audrey (Premium)` in fr_FR. That is one voice offered twice at
|
|
125
|
+
* two build qualities, and the worse row is not a choice — nobody browsing a
|
|
126
|
+
* picker means "the compact Daniel, specifically". Twelve of this machine's
|
|
127
|
+
* 201 rows are that.
|
|
128
|
+
*
|
|
129
|
+
* The story of what this is NOT is the design.
|
|
130
|
+
*
|
|
131
|
+
* The first cut kept only `best` and `good`, took the roster to 59 rows, and
|
|
132
|
+
* read as a far bigger win — until you notice it deletes the novelty shelf
|
|
133
|
+
* entirely (130 of the 201) and leaves src/core/narration.js holding
|
|
134
|
+
* expand/collapse machinery (`COLLAPSIBLE`) for a shelf that can no longer
|
|
135
|
+
* exist. The picker already folds `novelty` and `other languages` to one
|
|
136
|
+
* expandable row each, which is the same noise handled where it is
|
|
137
|
+
* REVERSIBLE — a fold you can open, rather than a roster that never mentions
|
|
138
|
+
* Zarvox again. Somebody who wants the robot is entitled to the robot.
|
|
139
|
+
*
|
|
140
|
+
* The second cut dropped a locale's plain voices whenever the LOCALE held
|
|
141
|
+
* anything better. That is one step too far, and the names say why: it takes
|
|
142
|
+
* `Daniel` (fine — `Daniel (Enhanced)` is right there) but it also takes
|
|
143
|
+
* `Samantha`, `Rishi`, `Aman`, `Tara` and `Jacques`, which have no
|
|
144
|
+
* better-quality namesake at all. They are distinct voices, deleted because
|
|
145
|
+
* some OTHER voice in their language happens to be Premium. Samantha is the
|
|
146
|
+
* most recognisable voice macOS has ever shipped.
|
|
147
|
+
*
|
|
148
|
+
* So the rule is a NAME match inside one locale, which is exactly the
|
|
149
|
+
* duplicate and nothing else. `keep` spares the voice the bridge booted with,
|
|
150
|
+
* which may have been named on the command line, and an untiered roster (SAPI,
|
|
151
|
+
* WinRT) passes through whole: this ranks, it does not invent.
|
|
152
|
+
*/
|
|
153
|
+
export function withoutSupersededPlain(voices = [], { keep } = {}) {
|
|
154
|
+
// `locale\u0000name` of every voice that is a BETTER build of that name — the
|
|
155
|
+
// set a plain row has to be absent from to survive.
|
|
156
|
+
const better = new Set();
|
|
157
|
+
for (const v of voices) {
|
|
158
|
+
if (!Number.isInteger(v?.tier) || v.tier >= PLAIN_TIER) continue;
|
|
159
|
+
const bare = plainName(v.name);
|
|
160
|
+
if (bare && bare !== v.name) better.add(`${(v.locale || '').toLowerCase()}\u0000${bare}`);
|
|
161
|
+
}
|
|
162
|
+
return voices.filter((v) => {
|
|
163
|
+
if (!Number.isInteger(v?.tier) || v.tier !== PLAIN_TIER) return true;
|
|
164
|
+
if (keep && v.name === keep) return true;
|
|
165
|
+
return !better.has(`${(v.locale || '').toLowerCase()}\u0000${v.name}`);
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
|
|
99
169
|
/**
|
|
100
170
|
* Parse `say -v '?'`.
|
|
101
171
|
*
|
|
@@ -270,7 +340,7 @@ export function onPath(bin, env = process.env) {
|
|
|
270
340
|
|
|
271
341
|
/** Run a probe and return its stdout; anything at all going wrong is ''. */
|
|
272
342
|
export const probe = (bin, args) => {
|
|
273
|
-
try { return
|
|
343
|
+
try { return run(bin, args, { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'], timeout: PROBE_MS, why: "macOS's speech synthesizer is not answering; restart it: killall speechsynthesisd" }); }
|
|
274
344
|
catch { return ''; }
|
|
275
345
|
};
|
|
276
346
|
|
|
@@ -285,7 +355,7 @@ export function detectLocalVoice({
|
|
|
285
355
|
engine: null,
|
|
286
356
|
why: 'Android has a system voice, but only as an in-app Java API — there is no '
|
|
287
357
|
+ 'command line behind it, so nothing here can drive it',
|
|
288
|
-
suggest: 'record the narration on a desktop (decklight tts, then
|
|
358
|
+
suggest: 'record the narration on a desktop (decklight tts, then V → Record this deck…) and ship the '
|
|
289
359
|
+ 'audio with the deck — a recorded track needs no bridge at all',
|
|
290
360
|
};
|
|
291
361
|
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
// Copyright 2026 Gilles Philippart
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* decklight → PowerPoint, lossy on purpose.
|
|
6
|
+
*
|
|
7
|
+
* PPTX export was a v1 non-goal, and the reason has not changed: a decklight
|
|
8
|
+
* deck is HTML, builds, casts and a live voice, and none of that has a
|
|
9
|
+
* PowerPoint shape. What changed is who asks. Decklight is a replacement for
|
|
10
|
+
* people who never liked PowerPoint — and every one of them still has a
|
|
11
|
+
* boss, a legal team or a conference organiser who says "just send the
|
|
12
|
+
* pptx". They do not want to EDIT it there. They want a file that opens.
|
|
13
|
+
*
|
|
14
|
+
* So each slide is a picture — the slide rendered at its own 1280×720, every
|
|
15
|
+
* build complete — filling a 16:9 page, and its speaker notes ride along as
|
|
16
|
+
* real notes, because notes are the one part of a deck that survives the
|
|
17
|
+
* trip as text and is worth having in PowerPoint's notes pane. Nothing here
|
|
18
|
+
* pretends to round-trip: import this file and you get pictures.
|
|
19
|
+
*
|
|
20
|
+
* The package is the smallest one PowerPoint opens without complaint: a
|
|
21
|
+
* presentation, one master, one layout, one theme, one notes master, and per
|
|
22
|
+
* slide a slide part, a notes part and a PNG. Every part is a template string
|
|
23
|
+
* here rather than a library, because the runtime has zero dependencies and
|
|
24
|
+
* the writer lives beside the reader (tools/ooxml.mjs) that will be asked to
|
|
25
|
+
* read it back in tests.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
import { zipSync } from '../cli/zip.mjs';
|
|
29
|
+
import { escapeHtml as esc } from './escape.mjs';
|
|
30
|
+
|
|
31
|
+
const NS = {
|
|
32
|
+
p: 'http://schemas.openxmlformats.org/presentationml/2006/main',
|
|
33
|
+
a: 'http://schemas.openxmlformats.org/drawingml/2006/main',
|
|
34
|
+
r: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships',
|
|
35
|
+
};
|
|
36
|
+
const REL = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships';
|
|
37
|
+
const CT = 'application/vnd.openxmlformats-officedocument.presentationml';
|
|
38
|
+
/** 16:9 in EMU — PowerPoint's own default for a widescreen deck. */
|
|
39
|
+
export const SLIDE_W = 12192000;
|
|
40
|
+
export const SLIDE_H = 6858000;
|
|
41
|
+
|
|
42
|
+
const xml = (s) => `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n${s}`;
|
|
43
|
+
const rels = (list) => xml(`<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">`
|
|
44
|
+
+ list.map(({ id, type, target }) => `<Relationship Id="${id}" Type="${REL}/${type}" Target="${target}"/>`).join('') + '</Relationships>');
|
|
45
|
+
|
|
46
|
+
const emptyShapeTree = `<p:spTree><p:nvGrpSpPr><p:cNvPr id="1" name=""/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr><p:grpSpPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="0" cy="0"/><a:chOff x="0" y="0"/><a:chExt cx="0" cy="0"/></a:xfrm></p:grpSpPr>`;
|
|
47
|
+
|
|
48
|
+
/** A slide: one picture, the whole page. */
|
|
49
|
+
function slideXml(n) {
|
|
50
|
+
return xml(`<p:sld xmlns:p="${NS.p}" xmlns:a="${NS.a}" xmlns:r="${NS.r}"><p:cSld>${emptyShapeTree}`
|
|
51
|
+
+ `<p:pic><p:nvPicPr><p:cNvPr id="2" name="Slide ${n}"/><p:cNvPicPr><a:picLocks noChangeAspect="1"/></p:cNvPicPr><p:nvPr/></p:nvPicPr>`
|
|
52
|
+
+ `<p:blipFill><a:blip r:embed="rId2"/><a:stretch><a:fillRect/></a:stretch></p:blipFill>`
|
|
53
|
+
+ `<p:spPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="${SLIDE_W}" cy="${SLIDE_H}"/></a:xfrm><a:prstGeom prst="rect"><a:avLst/></a:prstGeom></p:spPr></p:pic>`
|
|
54
|
+
+ `</p:spTree></p:cSld><p:clrMapOvr><a:masterClrMapping/></p:clrMapOvr></p:sld>`);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** The notes part: the slide's thumbnail placeholder and the text, one paragraph per line. */
|
|
58
|
+
function notesXml(lines) {
|
|
59
|
+
const paras = (lines.length ? lines : ['']).map((l) => `<a:p><a:r><a:rPr lang="en-US" dirty="0"/><a:t>${esc(l)}</a:t></a:r></a:p>`).join('');
|
|
60
|
+
return xml(`<p:notes xmlns:p="${NS.p}" xmlns:a="${NS.a}" xmlns:r="${NS.r}"><p:cSld>${emptyShapeTree}`
|
|
61
|
+
+ `<p:sp><p:nvSpPr><p:cNvPr id="2" name="Slide Image Placeholder 1"/><p:cNvSpPr><a:spLocks noGrp="1" noRot="1" noChangeAspect="1"/></p:cNvSpPr><p:nvPr><p:ph type="sldImg"/></p:nvPr></p:nvSpPr><p:spPr/></p:sp>`
|
|
62
|
+
+ `<p:sp><p:nvSpPr><p:cNvPr id="3" name="Notes Placeholder 2"/><p:cNvSpPr><a:spLocks noGrp="1"/></p:cNvSpPr><p:nvPr><p:ph type="body" idx="1"/></p:nvPr></p:nvSpPr><p:spPr/><p:txBody><a:bodyPr/><a:lstStyle/>${paras}</p:txBody></p:sp>`
|
|
63
|
+
+ `</p:spTree></p:cSld><p:clrMapOvr><a:masterClrMapping/></p:clrMapOvr></p:notes>`);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const masterXml = xml(`<p:sldMaster xmlns:p="${NS.p}" xmlns:a="${NS.a}" xmlns:r="${NS.r}"><p:cSld><p:bg><p:bgPr><a:solidFill><a:schemeClr val="bg1"/></a:solidFill><a:effectLst/></p:bgPr></p:bg>${emptyShapeTree}</p:spTree></p:cSld>`
|
|
67
|
+
+ `<p:clrMap bg1="lt1" tx1="dk1" bg2="lt2" tx2="dk2" accent1="accent1" accent2="accent2" accent3="accent3" accent4="accent4" accent5="accent5" accent6="accent6" hlink="hlink" folHlink="folHlink"/>`
|
|
68
|
+
+ `<p:sldLayoutIdLst><p:sldLayoutId id="2147483649" r:id="rId1"/></p:sldLayoutIdLst><p:txStyles><p:titleStyle><a:lvl1pPr/></p:titleStyle><p:bodyStyle><a:lvl1pPr/></p:bodyStyle><p:otherStyle><a:lvl1pPr/></p:otherStyle></p:txStyles></p:sldMaster>`);
|
|
69
|
+
const layoutXml = xml(`<p:sldLayout xmlns:p="${NS.p}" xmlns:a="${NS.a}" xmlns:r="${NS.r}" type="blank" preserve="1"><p:cSld name="Blank">${emptyShapeTree}</p:spTree></p:cSld><p:clrMapOvr><a:masterClrMapping/></p:clrMapOvr></p:sldLayout>`);
|
|
70
|
+
const notesMasterXml = xml(`<p:notesMaster xmlns:p="${NS.p}" xmlns:a="${NS.a}" xmlns:r="${NS.r}"><p:cSld>${emptyShapeTree}</p:spTree></p:cSld>`
|
|
71
|
+
+ `<p:clrMap bg1="lt1" tx1="dk1" bg2="lt2" tx2="dk2" accent1="accent1" accent2="accent2" accent3="accent3" accent4="accent4" accent5="accent5" accent6="accent6" hlink="hlink" folHlink="folHlink"/><p:notesStyle><a:lvl1pPr/></p:notesStyle></p:notesMaster>`);
|
|
72
|
+
const themeXml = xml(`<a:theme xmlns:a="${NS.a}" name="Decklight"><a:themeElements><a:clrScheme name="Decklight">`
|
|
73
|
+
+ `<a:dk1><a:srgbClr val="1F2937"/></a:dk1><a:lt1><a:srgbClr val="FFFFFF"/></a:lt1><a:dk2><a:srgbClr val="374151"/></a:dk2><a:lt2><a:srgbClr val="F3F4F6"/></a:lt2>`
|
|
74
|
+
+ `<a:accent1><a:srgbClr val="0F6E6E"/></a:accent1><a:accent2><a:srgbClr val="B4541A"/></a:accent2><a:accent3><a:srgbClr val="2C7A4B"/></a:accent3><a:accent4><a:srgbClr val="7B1FA2"/></a:accent4><a:accent5><a:srgbClr val="0B57D0"/></a:accent5><a:accent6><a:srgbClr val="D93025"/></a:accent6>`
|
|
75
|
+
+ `<a:hlink><a:srgbClr val="0B57D0"/></a:hlink><a:folHlink><a:srgbClr val="7B1FA2"/></a:folHlink></a:clrScheme>`
|
|
76
|
+
+ `<a:fontScheme name="Decklight"><a:majorFont><a:latin typeface="Helvetica"/><a:ea typeface=""/><a:cs typeface=""/></a:majorFont><a:minorFont><a:latin typeface="Helvetica"/><a:ea typeface=""/><a:cs typeface=""/></a:minorFont></a:fontScheme>`
|
|
77
|
+
+ `<a:fmtScheme name="Decklight"><a:fillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:solidFill><a:schemeClr val="phClr"/></a:solidFill></a:fillStyleLst>`
|
|
78
|
+
+ `<a:lnStyleLst><a:ln w="6350"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill></a:ln><a:ln w="12700"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill></a:ln><a:ln w="19050"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill></a:ln></a:lnStyleLst>`
|
|
79
|
+
+ `<a:effectStyleLst><a:effectStyle><a:effectLst/></a:effectStyle><a:effectStyle><a:effectLst/></a:effectStyle><a:effectStyle><a:effectLst/></a:effectStyle></a:effectStyleLst>`
|
|
80
|
+
+ `<a:bgFillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:solidFill><a:schemeClr val="phClr"/></a:solidFill></a:bgFillStyleLst></a:fmtScheme></a:themeElements></a:theme>`);
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The package, as bytes.
|
|
84
|
+
*
|
|
85
|
+
* `slides` is `[{ png, notes }]` in deck order — `png` the rendered slide as
|
|
86
|
+
* a Buffer, `notes` the speaker notes as lines of plain text (empty for a
|
|
87
|
+
* silent slide). `title` becomes the document title.
|
|
88
|
+
*/
|
|
89
|
+
export function buildPptx(slides, { title = 'Deck' } = {}) {
|
|
90
|
+
if (!slides.length) throw new Error('a presentation needs at least one slide');
|
|
91
|
+
const entries = [];
|
|
92
|
+
const put = (name, data) => entries.push({ name, data: Buffer.isBuffer(data) ? data : Buffer.from(data, 'utf8') });
|
|
93
|
+
const n = slides.length;
|
|
94
|
+
|
|
95
|
+
put('[Content_Types].xml', xml(`<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">`
|
|
96
|
+
+ `<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Default Extension="png" ContentType="image/png"/>`
|
|
97
|
+
+ `<Override PartName="/ppt/presentation.xml" ContentType="${CT}.presentation.main+xml"/>`
|
|
98
|
+
+ `<Override PartName="/ppt/slideMasters/slideMaster1.xml" ContentType="${CT}.slideMaster+xml"/>`
|
|
99
|
+
+ `<Override PartName="/ppt/slideLayouts/slideLayout1.xml" ContentType="${CT}.slideLayout+xml"/>`
|
|
100
|
+
+ `<Override PartName="/ppt/notesMasters/notesMaster1.xml" ContentType="${CT}.notesMaster+xml"/>`
|
|
101
|
+
+ `<Override PartName="/ppt/theme/theme1.xml" ContentType="application/vnd.openxmlformats-officedocument.theme+xml"/>`
|
|
102
|
+
+ slides.map((_, i) => `<Override PartName="/ppt/slides/slide${i + 1}.xml" ContentType="${CT}.slide+xml"/>`
|
|
103
|
+
+ `<Override PartName="/ppt/notesSlides/notesSlide${i + 1}.xml" ContentType="${CT}.notesSlide+xml"/>`).join('')
|
|
104
|
+
+ `<Override PartName="/docProps/core.xml" ContentType="application/vnd.openxmlformats-package.core-properties+xml"/>`
|
|
105
|
+
+ `<Override PartName="/docProps/app.xml" ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml"/></Types>`));
|
|
106
|
+
put('_rels/.rels', rels([
|
|
107
|
+
{ id: 'rId1', type: 'officeDocument', target: 'ppt/presentation.xml' },
|
|
108
|
+
{ id: 'rId2', type: 'metadata/core-properties', target: 'docProps/core.xml' },
|
|
109
|
+
{ id: 'rId3', type: 'extended-properties', target: 'docProps/app.xml' },
|
|
110
|
+
]));
|
|
111
|
+
const now = new Date().toISOString().replace(/\.\d+Z$/, 'Z');
|
|
112
|
+
put('docProps/core.xml', xml(`<cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><dc:title>${esc(title)}</dc:title><dc:creator>decklight</dc:creator><dcterms:created xsi:type="dcterms:W3CDTF">${now}</dcterms:created><dcterms:modified xsi:type="dcterms:W3CDTF">${now}</dcterms:modified></cp:coreProperties>`));
|
|
113
|
+
put('docProps/app.xml', xml(`<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties"><Application>decklight</Application><Slides>${n}</Slides><Notes>${n}</Notes></Properties>`));
|
|
114
|
+
|
|
115
|
+
put('ppt/presentation.xml', xml(`<p:presentation xmlns:p="${NS.p}" xmlns:a="${NS.a}" xmlns:r="${NS.r}" saveSubsetFonts="1">`
|
|
116
|
+
+ `<p:sldMasterIdLst><p:sldMasterId id="2147483648" r:id="rId1"/></p:sldMasterIdLst>`
|
|
117
|
+
+ `<p:notesMasterIdLst><p:notesMasterId r:id="rId2"/></p:notesMasterIdLst>`
|
|
118
|
+
+ `<p:sldIdLst>${slides.map((_, i) => `<p:sldId id="${256 + i}" r:id="rId${10 + i}"/>`).join('')}</p:sldIdLst>`
|
|
119
|
+
+ `<p:sldSz cx="${SLIDE_W}" cy="${SLIDE_H}"/><p:notesSz cx="6858000" cy="9144000"/></p:presentation>`));
|
|
120
|
+
put('ppt/_rels/presentation.xml.rels', rels([
|
|
121
|
+
{ id: 'rId1', type: 'slideMaster', target: 'slideMasters/slideMaster1.xml' },
|
|
122
|
+
{ id: 'rId2', type: 'notesMaster', target: 'notesMasters/notesMaster1.xml' },
|
|
123
|
+
{ id: 'rId3', type: 'theme', target: 'theme/theme1.xml' },
|
|
124
|
+
...slides.map((_, i) => ({ id: `rId${10 + i}`, type: 'slide', target: `slides/slide${i + 1}.xml` })),
|
|
125
|
+
]));
|
|
126
|
+
put('ppt/slideMasters/slideMaster1.xml', masterXml);
|
|
127
|
+
put('ppt/slideMasters/_rels/slideMaster1.xml.rels', rels([{ id: 'rId1', type: 'slideLayout', target: '../slideLayouts/slideLayout1.xml' }, { id: 'rId2', type: 'theme', target: '../theme/theme1.xml' }]));
|
|
128
|
+
put('ppt/slideLayouts/slideLayout1.xml', layoutXml);
|
|
129
|
+
put('ppt/slideLayouts/_rels/slideLayout1.xml.rels', rels([{ id: 'rId1', type: 'slideMaster', target: '../slideMasters/slideMaster1.xml' }]));
|
|
130
|
+
put('ppt/notesMasters/notesMaster1.xml', notesMasterXml);
|
|
131
|
+
put('ppt/notesMasters/_rels/notesMaster1.xml.rels', rels([{ id: 'rId1', type: 'theme', target: '../theme/theme1.xml' }]));
|
|
132
|
+
put('ppt/theme/theme1.xml', themeXml);
|
|
133
|
+
|
|
134
|
+
slides.forEach(({ png, notes = [] }, i) => {
|
|
135
|
+
const k = i + 1;
|
|
136
|
+
if (!Buffer.isBuffer(png) || !png.length) throw new Error(`slide ${k}: no rendered image`);
|
|
137
|
+
put(`ppt/slides/slide${k}.xml`, slideXml(k));
|
|
138
|
+
put(`ppt/slides/_rels/slide${k}.xml.rels`, rels([
|
|
139
|
+
{ id: 'rId1', type: 'slideLayout', target: '../slideLayouts/slideLayout1.xml' },
|
|
140
|
+
{ id: 'rId2', type: 'image', target: `../media/slide${k}.png` },
|
|
141
|
+
{ id: 'rId3', type: 'notesSlide', target: `../notesSlides/notesSlide${k}.xml` },
|
|
142
|
+
]));
|
|
143
|
+
put(`ppt/media/slide${k}.png`, png);
|
|
144
|
+
put(`ppt/notesSlides/notesSlide${k}.xml`, notesXml(notes));
|
|
145
|
+
put(`ppt/notesSlides/_rels/notesSlide${k}.xml.rels`, rels([
|
|
146
|
+
{ id: 'rId1', type: 'notesMaster', target: '../notesMasters/notesMaster1.xml' },
|
|
147
|
+
{ id: 'rId2', type: 'slide', target: `../slides/slide${k}.xml` },
|
|
148
|
+
]));
|
|
149
|
+
});
|
|
150
|
+
return zipSync(entries);
|
|
151
|
+
}
|