decklight 0.9.0 → 0.11.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/NOTICE +2 -0
- package/PLATFORM.md +61 -3
- package/README.md +58 -28
- package/SPEC.md +1326 -85
- package/cli/agent-review.mjs +5 -4
- package/cli/agents.mjs +148 -18
- package/cli/bundle-audio.mjs +10 -3
- package/cli/bundle-module.mjs +95 -0
- package/cli/bundle.mjs +125 -7
- package/cli/cast.mjs +86 -19
- package/cli/check-fixes.mjs +194 -0
- package/cli/check-watch.mjs +151 -0
- package/cli/check.mjs +491 -75
- package/cli/code-editor.mjs +287 -0
- package/cli/commands.mjs +13 -2
- package/cli/commit-flow.mjs +7 -3
- package/cli/commit-message.mjs +35 -8
- package/cli/commit-split.mjs +125 -25
- package/cli/deck-refs.mjs +8 -3
- package/cli/decklight.mjs +11 -1
- package/cli/design-system-edit.mjs +37 -1
- package/cli/design-system-refs.mjs +263 -6
- package/cli/design-system.mjs +82 -14
- package/cli/edit-address.mjs +184 -0
- package/cli/edit-git.mjs +23 -6
- package/cli/edit-handover.mjs +257 -40
- package/cli/edit-look.mjs +293 -6
- package/cli/edit-open.mjs +143 -0
- package/cli/edit-slides.mjs +1043 -67
- package/cli/edit-translate.mjs +243 -0
- package/cli/edit.mjs +3680 -319
- package/cli/editor-support.mjs +286 -0
- package/cli/enhance.mjs +157 -27
- package/cli/find-replace.mjs +142 -0
- package/cli/fix-review.mjs +368 -0
- package/cli/git.mjs +13 -0
- package/cli/init.mjs +101 -22
- package/cli/keep-awake.mjs +68 -0
- package/cli/marketplace-autocheck.mjs +200 -0
- package/cli/marketplace.mjs +250 -13
- package/cli/migrate-writing.mjs +214 -0
- package/cli/narrate.mjs +121 -5
- package/cli/open.mjs +53 -15
- package/cli/outside-edit.mjs +257 -0
- package/cli/paste.mjs +92 -0
- package/cli/pdf.mjs +88 -10
- package/cli/pptx-export.mjs +10 -5
- package/cli/publish.mjs +24 -3
- package/cli/record.mjs +86 -15
- package/cli/remote.mjs +32 -6
- package/cli/rewrite.mjs +265 -0
- package/cli/runtime-link.mjs +218 -17
- package/cli/serve.mjs +9 -6
- package/cli/setup.mjs +2 -2
- package/cli/skill-content.mjs +251 -10
- package/cli/skills/slide-writing.md +333 -0
- package/cli/skills/voiceover.md +423 -0
- package/cli/skills.mjs +282 -15
- package/cli/starter-full.mjs +353 -0
- package/cli/supervise.mjs +14 -0
- package/cli/theme-refs.mjs +14 -2
- package/cli/theme.mjs +3 -2
- package/cli/translate-core.mjs +466 -0
- package/cli/translate-files.mjs +149 -0
- package/cli/translate.mjs +458 -0
- package/cli/units.mjs +75 -7
- package/cli/util.mjs +25 -0
- package/cli/vocabulary-docs.mjs +138 -0
- package/dist/decklight.css +2506 -113
- package/dist/decklight.js +385 -175
- package/dist/decklight.js.map +4 -4
- package/docs/GLOSSARY.md +9 -2
- package/docs/WRITING_RESEARCH.md +327 -0
- package/package.json +5 -3
- package/themes/coastal.css +3 -0
- package/themes/metropolis.css +2 -0
- package/themes/reveal-blood.css +3 -0
- package/themes/reveal-league.css +2 -0
- package/themes/reveal-moon.css +2 -0
- package/themes/reveal-serif.css +1 -0
- package/themes/reveal-sky.css +1 -0
- package/themes/reveal-solarized.css +4 -0
- package/tools/brand-palette.mjs +6 -1
- package/tools/build-groups.mjs +28 -8
- package/tools/cdp.mjs +176 -0
- package/tools/chart-spec.mjs +242 -0
- package/tools/click-match.mjs +70 -0
- package/tools/code-options.mjs +174 -0
- package/tools/conversation.mjs +49 -0
- package/tools/deck-family.mjs +101 -0
- package/tools/deck-html.mjs +212 -15
- package/tools/design-system-format.mjs +40 -1
- package/tools/design-system-migrations.mjs +207 -0
- package/tools/diagram-shapes.mjs +221 -0
- package/tools/elevenlabs-tts.mjs +62 -53
- package/tools/exec.mjs +10 -2
- package/tools/face-clip.mjs +96 -0
- package/tools/face-layout.mjs +94 -0
- package/tools/gemini-tts.mjs +1 -1
- package/tools/invisible-in-print.mjs +27 -0
- package/tools/lipsync-auto.mjs +197 -0
- package/tools/lipsync-config.mjs +16 -0
- package/tools/lipsync-engines.mjs +22 -4
- package/tools/lipsync-server.mjs +8 -5
- package/tools/lipsync.mjs +122 -30
- package/tools/local-voice.mjs +1 -1
- package/tools/mouth-file.mjs +26 -0
- package/tools/mouth.mjs +320 -0
- package/tools/narration-manifest.mjs +100 -6
- package/tools/narration-synth.mjs +96 -76
- package/tools/recording-impact.mjs +16 -1
- package/tools/sentences.mjs +7 -1
- package/tools/site-clip.mjs +114 -0
- package/tools/starters.mjs +402 -0
- package/tools/steps.mjs +118 -0
- package/tools/take-check.mjs +146 -0
- package/tools/template-theme.mjs +3 -1
- package/tools/test-impact.mjs +36 -12
- package/tools/theme-check.mjs +196 -1
- package/tools/tone-cue.mjs +108 -0
- package/tools/tts-cache.mjs +9 -3
- package/tools/tts-engines.mjs +100 -11
- package/tools/video-cache.mjs +93 -0
- package/tools/video-live.mjs +349 -0
- package/tools/video-options.mjs +11 -0
- package/tools/video.mjs +825 -117
- package/tools/viseme-fit.mjs +27 -0
- package/tools/viseme-match.mjs +77 -0
- package/tools/vocabulary.mjs +397 -0
- package/tools/voice-renumber.mjs +605 -0
- package/tools/voiceover-server.mjs +42 -11
- package/tools/voiceover.mjs +48 -20
- package/dist/build-info.json +0 -1
package/cli/commit-split.mjs
CHANGED
|
@@ -31,9 +31,10 @@ import { execFileSync, execFile } from 'node:child_process';
|
|
|
31
31
|
import { createHash } from 'node:crypto';
|
|
32
32
|
import { existsSync, mkdtempSync, readFileSync, rmSync } from 'node:fs';
|
|
33
33
|
import { tmpdir } from 'node:os';
|
|
34
|
-
import { join, resolve as resolvePath } from 'node:path';
|
|
34
|
+
import { basename, join, resolve as resolvePath } from 'node:path';
|
|
35
35
|
import { agentAsk } from './agents.mjs';
|
|
36
|
-
import { ASK_TIMEOUT_MS, ask, deckOutline, deckTitle, reviewSubject } from './commit-message.mjs';
|
|
36
|
+
import { ASK_TIMEOUT_MS, ask, deckOutline, deckTitle, describeWorking, reviewSubject, slideNames } from './commit-message.mjs';
|
|
37
|
+
import { slideNamesPhrase } from '../tools/deck-html.mjs';
|
|
37
38
|
import { GIT_MAX_BUFFER, classifyRemoteError, commitSubject, isIdentityError, noPromptEnv, oneline, remoteState } from './git.mjs';
|
|
38
39
|
|
|
39
40
|
/** Past this many hunks, the hunks of one slide travel together. */
|
|
@@ -96,12 +97,20 @@ const slidesAt = (outline, from, count) => {
|
|
|
96
97
|
return outline.filter((s) => s.from <= last && s.to >= from).map((s) => s.index);
|
|
97
98
|
};
|
|
98
99
|
|
|
99
|
-
/**
|
|
100
|
-
|
|
100
|
+
/**
|
|
101
|
+
* "slide 3", "slides 3-4", "slides 2, 5", or where a change outside any slide
|
|
102
|
+
* is, followed by what the slides are called when `names` (from `slideNames`)
|
|
103
|
+
* says: `slide 3 — "The Freshness Problem"`. The agent grouping the units is
|
|
104
|
+
* asked to name slides by their words, so it has to be shown them: given only
|
|
105
|
+
* the number, it falls back on the number.
|
|
106
|
+
*/
|
|
107
|
+
export function whereLabel(slides, names = []) {
|
|
101
108
|
if (!slides.length) return 'theme or metadata';
|
|
102
|
-
if (slides.length === 1) return `slide ${slides[0]}`;
|
|
103
109
|
const run_ = slides.every((s, i) => i === 0 || s === slides[i - 1] + 1);
|
|
104
|
-
|
|
110
|
+
const at = slides.length === 1 ? `slide ${slides[0]}`
|
|
111
|
+
: run_ ? `slides ${slides[0]}-${slides[slides.length - 1]}` : `slides ${slides.join(', ')}`;
|
|
112
|
+
const called = slideNamesPhrase(slides.map((n) => names[n - 1]));
|
|
113
|
+
return called ? `${at} — ${called}` : at;
|
|
105
114
|
}
|
|
106
115
|
|
|
107
116
|
/**
|
|
@@ -143,6 +152,7 @@ export function workingUnits({ cwd, deckRel, also = [] }) {
|
|
|
143
152
|
continue;
|
|
144
153
|
}
|
|
145
154
|
const outline = deckOutline(work);
|
|
155
|
+
const names = slideNames(work);
|
|
146
156
|
let mine = hunks.map((h) => ({
|
|
147
157
|
file: rel, whole: false, hunks: [h],
|
|
148
158
|
slides: slidesAt(outline, h.newStart, h.newCount),
|
|
@@ -161,7 +171,7 @@ export function workingUnits({ cwd, deckRel, also = [] }) {
|
|
|
161
171
|
for (const u of mine) {
|
|
162
172
|
units.push({
|
|
163
173
|
...u,
|
|
164
|
-
where: whereLabel(u.slides),
|
|
174
|
+
where: whereLabel(u.slides, names),
|
|
165
175
|
lines: u.hunks.reduce((n, h) => n + h.oldCount + h.newCount, 0),
|
|
166
176
|
diff: u.hunks.map((h) => h.text.join('\n')).join('\n'),
|
|
167
177
|
});
|
|
@@ -207,13 +217,28 @@ export function planPrompt({ deck, title = null, units, max = 24 * 1024 }) {
|
|
|
207
217
|
].join('\n');
|
|
208
218
|
}
|
|
209
219
|
|
|
210
|
-
/**
|
|
220
|
+
/** One change number, or a range of them: `4`, `1-10`, `1–10`, `1..4`, `1 to 4`. */
|
|
221
|
+
const PLAN_ID = String.raw`\d+(?:\s*(?:-|–|—|\.\.\.?|to)\s*\d+)?`;
|
|
222
|
+
const PLAN_LINE = new RegExp(String.raw`^\s*[-*]?\s*\[?(${PLAN_ID}(?:(?:\s*,\s*|\s+)${PLAN_ID})*)\]?\s*[|:]\s*(.+?)\s*$`);
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* `[{ units: [ids], subject }]` from the agent's lines. Pure. The prompt asks
|
|
226
|
+
* for a comma list, but a model grouping consecutive changes writes a range
|
|
227
|
+
* (#908), so `1-10` and `1, 3-5, 8` read as the numbers they name. A range
|
|
228
|
+
* wider than any deck has changes is not a plan, and is dropped.
|
|
229
|
+
*/
|
|
211
230
|
export function parsePlan(answer) {
|
|
212
231
|
const out = [];
|
|
213
232
|
for (const line of String(answer ?? '').split('\n')) {
|
|
214
|
-
const m =
|
|
233
|
+
const m = PLAN_LINE.exec(line);
|
|
215
234
|
if (!m) continue;
|
|
216
|
-
const ids =
|
|
235
|
+
const ids = [];
|
|
236
|
+
for (const [, a, b] of m[1].matchAll(/(\d+)(?:\s*(?:-|–|—|\.\.\.?|to)\s*(\d+))?/g)) {
|
|
237
|
+
const lo = Math.min(Number(a), Number(b ?? a));
|
|
238
|
+
const hi = Math.max(Number(a), Number(b ?? a));
|
|
239
|
+
if (hi - lo > 1000) continue;
|
|
240
|
+
for (let id = lo; id <= hi; id++) ids.push(id);
|
|
241
|
+
}
|
|
217
242
|
if (ids.length && m[2]) out.push({ units: ids, subject: m[2].replace(/^["'`]|["'`]$/g, '') });
|
|
218
243
|
}
|
|
219
244
|
return out;
|
|
@@ -252,7 +277,7 @@ const addedLines = (f) => {
|
|
|
252
277
|
};
|
|
253
278
|
|
|
254
279
|
/**
|
|
255
|
-
* The commits "write
|
|
280
|
+
* The commits "write it for me" proposes: `{ work, commits }`, where
|
|
256
281
|
* `commits` is `[{ subject, units }]`, or `{ work, commits: null }` when there
|
|
257
282
|
* is nothing to cut (no HEAD: a first commit is one commit; nothing changed).
|
|
258
283
|
*
|
|
@@ -260,35 +285,50 @@ const addedLines = (f) => {
|
|
|
260
285
|
* sidecar's records say what they are (reviewSubject), so they are one commit
|
|
261
286
|
* of their own with that subject, and a .gitattributes decklight wrote goes
|
|
262
287
|
* with them. Only the deck's hunks are sent to the agent, and only on the
|
|
263
|
-
* click that asked for it. An
|
|
264
|
-
*
|
|
288
|
+
* click that asked for it. An answer with no line `parsePlan` reads is asked
|
|
289
|
+
* again as one subject (describeWorking), the deck as one commit; with still
|
|
290
|
+
* no subject, `unread` carries what the agent said, so the window can tell
|
|
291
|
+
* "couldn't read the answer" from "nothing to say" (#908).
|
|
265
292
|
*/
|
|
266
293
|
export async function planWorking({
|
|
267
294
|
cwd, deckPath, deckRel, also = [], agent = null, env = process.env,
|
|
268
295
|
timeoutMs = ASK_TIMEOUT_MS, exec = ask, resolve = agentAsk, read = readFileSync,
|
|
296
|
+
template = `decklight: autosave ${basename(deckRel)}`, describe = describeWorking,
|
|
269
297
|
}) {
|
|
270
298
|
const work = workingUnits({ cwd, deckRel, also });
|
|
271
299
|
if (!work || !work.units.length) return { work, commits: null };
|
|
272
300
|
const deckUnits = work.units.filter((u) => u.file === deckRel);
|
|
273
301
|
const rest = work.units.filter((u) => u.file !== deckRel);
|
|
274
302
|
const commits = [];
|
|
303
|
+
let unread = null;
|
|
304
|
+
let html = '';
|
|
305
|
+
try { html = read(deckPath, 'utf8'); } catch { /* the title and the names are optional */ }
|
|
275
306
|
if (deckUnits.length) {
|
|
276
307
|
let groups = [];
|
|
277
|
-
let
|
|
278
|
-
try { html = read(deckPath, 'utf8'); } catch { /* the title is optional */ }
|
|
308
|
+
let answer = null;
|
|
279
309
|
const spawned = resolve(agent, planPrompt({ deck: deckRel, title: deckTitle(html), units: deckUnits }), { env });
|
|
280
310
|
if (spawned) {
|
|
281
|
-
let answer = null;
|
|
282
311
|
try { answer = await exec(spawned, cwd, timeoutMs); } catch { answer = null; }
|
|
283
312
|
groups = parsePlan(answer);
|
|
284
313
|
}
|
|
285
|
-
|
|
314
|
+
const deckCommits = normalizePlan(groups, deckUnits).map((g) => ({ subject: g.subject, units: g.units }));
|
|
315
|
+
if (spawned && !groups.length) {
|
|
316
|
+
let subject = null;
|
|
317
|
+
try {
|
|
318
|
+
subject = await describe({
|
|
319
|
+
cwd, deckPath, deckRel, template, agent, env, timeoutMs, exec, resolve, read,
|
|
320
|
+
});
|
|
321
|
+
} catch { subject = null; }
|
|
322
|
+
if (subject) deckCommits[0].subject = subject;
|
|
323
|
+
else unread = { answer: String(answer ?? '').slice(0, 2000) };
|
|
324
|
+
}
|
|
325
|
+
commits.push(...deckCommits);
|
|
286
326
|
}
|
|
287
327
|
if (rest.length) {
|
|
288
|
-
const side = rest.map((u) => reviewSubject(addedLines(work.files[u.file]))).find(Boolean);
|
|
328
|
+
const side = rest.map((u) => reviewSubject(addedLines(work.files[u.file]), { names: slideNames(html) })).find(Boolean);
|
|
289
329
|
commits.push({ subject: side ?? '', units: rest.map((u) => u.id) });
|
|
290
330
|
}
|
|
291
|
-
return { work, commits };
|
|
331
|
+
return { work, commits, unread };
|
|
292
332
|
}
|
|
293
333
|
|
|
294
334
|
/** A unit as the window shows it: no hunk bodies, which can be large. */
|
|
@@ -345,8 +385,23 @@ export function slideChanges(before, after) {
|
|
|
345
385
|
* Pure; 1-based like `state.slide`.
|
|
346
386
|
*/
|
|
347
387
|
export function slideDiff(before, after) {
|
|
348
|
-
const
|
|
349
|
-
const
|
|
388
|
+
const stops = slideOps(before, after).filter((o) => o.kind !== 'same');
|
|
389
|
+
const count = (k) => stops.filter((s) => s.kind === k).length;
|
|
390
|
+
return { changed: count('changed'), added: count('added'), removed: count('removed'), stops };
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* slideDiff's stops with the slides that did not change between them, `{
|
|
395
|
+
* kind: 'same', slide, was }`: the whole alignment, every slide of both
|
|
396
|
+
* versions once, in reading order. What a reviewed fix merges by
|
|
397
|
+
* (cli/fix-review.mjs). Pure.
|
|
398
|
+
*/
|
|
399
|
+
export function slideOps(before, after) {
|
|
400
|
+
return slideOpsOf(slideSources(before), slideSources(after));
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/** slideOps over slides already cut out: each one's source, whitespace at line ends ignored. Pure. */
|
|
404
|
+
export function slideOpsOf(a, b) {
|
|
350
405
|
// LCS over whole slides; decks are tens of slides, so n×m is nothing
|
|
351
406
|
const n = a.length, m = b.length;
|
|
352
407
|
const L = Array.from({ length: n + 1 }, () => new Array(m + 1).fill(0));
|
|
@@ -372,15 +427,60 @@ export function slideDiff(before, after) {
|
|
|
372
427
|
};
|
|
373
428
|
let i = 0, j = 0;
|
|
374
429
|
while (i < n && j < m) {
|
|
375
|
-
if (a[i] === b[j]) { close(); i++; j++; }
|
|
430
|
+
if (a[i] === b[j]) { close(); stops.push({ kind: 'same', slide: j + 1, was: i + 1 }); i++; j++; }
|
|
376
431
|
else if (L[i + 1][j] >= L[i][j + 1]) gapOld.push(i++);
|
|
377
432
|
else gapNew.push(j++);
|
|
378
433
|
}
|
|
379
434
|
while (i < n) gapOld.push(i++);
|
|
380
435
|
while (j < m) gapNew.push(j++);
|
|
381
436
|
close();
|
|
382
|
-
|
|
383
|
-
|
|
437
|
+
return stops;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* Where each slide of `before` is in `after`, from the alignment of the
|
|
442
|
+
* sections (slideOps): `[[was, now | null]]` for every old slide whose number
|
|
443
|
+
* changed, or that went (null). What the voice folders follow after an edit
|
|
444
|
+
* that rewrote the deck at once — an agent's (#920). Read off the deck, never
|
|
445
|
+
* the audio, so it holds for a stale recording and a slide with no notes.
|
|
446
|
+
*
|
|
447
|
+
* A slide unchanged or edited keeps its alignment. One removed here and added,
|
|
448
|
+
* word for word, there was moved. What is left of one gap — the old and new
|
|
449
|
+
* slides between the same two unchanged ones — pairs up in order: a slide
|
|
450
|
+
* rewritten past recognition is still that slide, its recording kept on it
|
|
451
|
+
* (and flagged stale by its words), not thrown away. The rest went. Pure.
|
|
452
|
+
*/
|
|
453
|
+
export function slideRenumber(before, after) {
|
|
454
|
+
return slideRenumberOf(slideSources(before), slideSources(after));
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/** slideRenumber over slides already cut out, as slideOpsOf takes them. Pure. */
|
|
458
|
+
export function slideRenumberOf(a, b) {
|
|
459
|
+
const ops = slideOpsOf(a, b);
|
|
460
|
+
const now = new Map();
|
|
461
|
+
const taken = new Set();
|
|
462
|
+
const gaps = [[]];
|
|
463
|
+
for (const o of ops) {
|
|
464
|
+
if (o.kind === 'same') { now.set(o.was, o.slide); gaps.push([]); continue; }
|
|
465
|
+
gaps.at(-1).push(o);
|
|
466
|
+
if (o.kind === 'changed') now.set(o.was, o.slide);
|
|
467
|
+
}
|
|
468
|
+
const added = ops.filter((o) => o.kind === 'added');
|
|
469
|
+
for (const r of ops.filter((o) => o.kind === 'removed')) {
|
|
470
|
+
const to = added.find((o) => !taken.has(o.slide) && a[r.was - 1] === b[o.slide - 1]);
|
|
471
|
+
if (to) { now.set(r.was, to.slide); taken.add(to.slide); }
|
|
472
|
+
}
|
|
473
|
+
for (const g of gaps) {
|
|
474
|
+
const out = g.filter((o) => o.kind === 'removed' && !now.has(o.was));
|
|
475
|
+
const into = g.filter((o) => o.kind === 'added' && !taken.has(o.slide));
|
|
476
|
+
out.forEach((r, i) => { if (into[i]) { now.set(r.was, into[i].slide); taken.add(into[i].slide); } });
|
|
477
|
+
}
|
|
478
|
+
const pairs = [];
|
|
479
|
+
for (let k = 1; k <= a.length; k++) {
|
|
480
|
+
const n = now.get(k) ?? null;
|
|
481
|
+
if (n !== k) pairs.push([k, n]);
|
|
482
|
+
}
|
|
483
|
+
return pairs;
|
|
384
484
|
}
|
|
385
485
|
|
|
386
486
|
/**
|
|
@@ -464,7 +564,7 @@ function commitTree(cwd, tree, parent, message, env) {
|
|
|
464
564
|
export function commitPlan({ cwd, deckRel, also = [], base, commits, template }) {
|
|
465
565
|
const now = workingUnits({ cwd, deckRel, also });
|
|
466
566
|
if (!now || now.base !== base) {
|
|
467
|
-
return { ok: false, code: 'STALE', error: 'the deck changed since these commits were proposed — write
|
|
567
|
+
return { ok: false, code: 'STALE', error: 'the deck changed since these commits were proposed — write it again' };
|
|
468
568
|
}
|
|
469
569
|
const byId = new Map(now.units.map((u) => [u.id, u]));
|
|
470
570
|
const asked = (commits ?? []).map((c) => ({ subject: String(c?.message ?? ''), units: (c?.units ?? []).map(Number), skip: !!c?.skip }));
|
package/cli/deck-refs.mjs
CHANGED
|
@@ -35,9 +35,14 @@ export const REFERENCE_KINDS = [
|
|
|
35
35
|
{ kind: 'font', link: linkFonts, asset: fontAsset, namespace: inFontNamespace },
|
|
36
36
|
];
|
|
37
37
|
|
|
38
|
-
/**
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Every reference kind linked into a served page, in the chain's order.
|
|
40
|
+
* `dir` is the deck's folder and `deck` its file name, for what a kind reads
|
|
41
|
+
* beside it and says about it (a design system's behind check reads the
|
|
42
|
+
* stylesheets the deck links, and names the deck in its command).
|
|
43
|
+
*/
|
|
44
|
+
export function linkReferences(html, { dir = null, deck = undefined, kinds = REFERENCE_KINDS } = {}) {
|
|
45
|
+
return kinds.reduce((out, k) => k.link(out, undefined, { dir, deck }), html);
|
|
41
46
|
}
|
|
42
47
|
|
|
43
48
|
/**
|
package/cli/decklight.mjs
CHANGED
|
@@ -159,7 +159,17 @@ try {
|
|
|
159
159
|
process.exitCode = r.status ?? 1;
|
|
160
160
|
} else {
|
|
161
161
|
const mod = await import(new URL(command.module, import.meta.url));
|
|
162
|
-
const
|
|
162
|
+
const renderOption = rest.indexOf('--render');
|
|
163
|
+
const display = cmd === 'video' && renderOption >= 0 && rest[renderOption + 1] === 'live';
|
|
164
|
+
const awake = ['video', 'pdf', 'pptx', 'bundle'].includes(cmd)
|
|
165
|
+
&& !rest.some((arg) => arg === '--help' || arg === '-h')
|
|
166
|
+
? await (await import('./keep-awake.mjs')).keepAwake({ display }) : null;
|
|
167
|
+
let code;
|
|
168
|
+
try {
|
|
169
|
+
code = await mod[command.main](...(command.args ? command.args(rest, cmd) : [rest]));
|
|
170
|
+
} finally {
|
|
171
|
+
await awake?.release();
|
|
172
|
+
}
|
|
163
173
|
// A main that returns a number is naming its exit code; one that returns
|
|
164
174
|
// nothing exits 0 unless it threw. Both conventions exist today, and this
|
|
165
175
|
// is the one place that has to know.
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
// come from the deck's design systems as the server resolves them, never
|
|
19
19
|
// from the page; they are handed in, so every transform is testable alone.
|
|
20
20
|
|
|
21
|
-
import { locateSlide, sectionChildRanges, splitOpenTag, readAttrs, writeAttrs, insertSectionsAfter } from '../tools/deck-html.mjs';
|
|
21
|
+
import { locateSlide, sectionChildRanges, splitOpenTag, readAttrs, writeAttrs, insertSectionsAfter, carriedChild } from '../tools/deck-html.mjs';
|
|
22
22
|
|
|
23
23
|
/** Elements a slide carries rather than shows — never assigned to a slot. */
|
|
24
24
|
const CARRIED = new Set(['aside', 'script', 'style']);
|
|
@@ -60,6 +60,31 @@ export function slotWriteProblem(html, slide, index, outerHtml) {
|
|
|
60
60
|
: null;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Why moving element `index` to content position `to` on a design-system
|
|
65
|
+
* slide is refused, or null (PRESENTING_EDITING, Moving). The template puts
|
|
66
|
+
* each element in its slot by its `data-slot`, not by its place in the file,
|
|
67
|
+
* so the only order a move can change is the order of one slot's own
|
|
68
|
+
* elements: a move past another slot's would write a change the slide never
|
|
69
|
+
* shows, and read as a move into that slot that did not happen.
|
|
70
|
+
*/
|
|
71
|
+
export function slotMoveProblem(html, slide, index, to) {
|
|
72
|
+
if (!slideTemplateOf(html, slide)) return null;
|
|
73
|
+
const { parts, idx } = locateSlide(html, slide);
|
|
74
|
+
const seg = parts[idx];
|
|
75
|
+
const content = sectionChildRanges(seg).map((r, raw) => ({ r, raw }))
|
|
76
|
+
.filter(({ r }) => !carriedChild(seg, r))
|
|
77
|
+
.map(({ r, raw }) => ({ raw, slot: openTag(seg.slice(r.start, r.end)).attrs['data-slot'] ?? '' }));
|
|
78
|
+
const from = content.findIndex((c) => c.raw === index);
|
|
79
|
+
if (from < 0 || !Number.isInteger(to) || to < 0 || to >= content.length) return null; // the move's own checks say why
|
|
80
|
+
const mine = content[from].slot;
|
|
81
|
+
const [lo, hi] = from < to ? [from + 1, to] : [to, from - 1];
|
|
82
|
+
const other = content.slice(lo, hi + 1).find((c) => c.slot !== mine);
|
|
83
|
+
if (!other) return null;
|
|
84
|
+
const name = (s) => (s ? `the "${s}" slot` : 'the template\'s default slot');
|
|
85
|
+
return `this element fills ${name(mine)} of the slide's template, and its data-slot, not its place in the file, says where it goes: it moves only among ${name(mine)}'s own elements, not past ${name(other.slot)}'s (to put it in another slot, change its data-slot in Edit content (HTML))`;
|
|
86
|
+
}
|
|
87
|
+
|
|
63
88
|
/** A hint (`"h1,h2"`) as the tags it names. */
|
|
64
89
|
const hintTags = (hint) => String(hint ?? '').toLowerCase().split(/[\s,]+/).filter(Boolean);
|
|
65
90
|
|
|
@@ -132,6 +157,17 @@ export function applySlideTemplate(html, slide, template) {
|
|
|
132
157
|
return { html: parts.join(''), mode, moved, lacking: [...new Set(lacking)] };
|
|
133
158
|
}
|
|
134
159
|
|
|
160
|
+
/**
|
|
161
|
+
* Each of slide `n`'s children in file order, and the slot it names (null for
|
|
162
|
+
* none): what the edit bar's picker (PRESENTING_EDITING) needs to draw a
|
|
163
|
+
* slide put into a template before anything is written. Its index is the one `/deck/edit/element/*`
|
|
164
|
+
* addresses, and the one the page stamps on the element it expanded.
|
|
165
|
+
*/
|
|
166
|
+
export function slideSlots(html, slide) {
|
|
167
|
+
const { parts, idx } = locateSlide(html, slide);
|
|
168
|
+
return sectionChildRanges(parts[idx]).map((r) => openTag(parts[idx].slice(r.start, r.end)).attrs['data-slot'] ?? null);
|
|
169
|
+
}
|
|
170
|
+
|
|
135
171
|
/** A tag a hint suggests for a new slide's slot, or `p`. */
|
|
136
172
|
const tagFor = (hint) => hintTags(hint).find((t) => /^(h[1-6]|p|ul|ol|blockquote|figure|div)$/.test(t)) ?? 'p';
|
|
137
173
|
const titleCase = (name) => name.replace(/-/g, ' ').replace(/^./, (c) => c.toUpperCase());
|