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/check.mjs
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* decklight check — one headless lint of one deck, with one exit code.
|
|
7
7
|
*
|
|
8
|
-
* decklight check <deck.html> [--no-render] [--json] [--wait <ms>]
|
|
8
|
+
* decklight check <deck.html> [--no-render] [--json] [--wait <ms>] [--watch | --fix]
|
|
9
9
|
*
|
|
10
10
|
* The promise this repo makes (README, SPEC PRESENTING: the overflow guardrail
|
|
11
11
|
* is assertable headlessly) is that an agent can verify its own work without
|
|
@@ -18,8 +18,7 @@
|
|
|
18
18
|
*
|
|
19
19
|
* So this is the one command whose whole job is to REPORT, per slide, what an
|
|
20
20
|
* author or an agent would otherwise only find by looking — and to exit 1 when
|
|
21
|
-
* something is actually wrong.
|
|
22
|
-
* changes the deck.
|
|
21
|
+
* something is actually wrong. Only an explicit --fix can change the deck.
|
|
23
22
|
*
|
|
24
23
|
* TWO HALVES, AND WHY THEY ARE SEPARATE FUNCTIONS. `staticFindings` is pure
|
|
25
24
|
* over the file text (with `exists` injected, it touches no disk at all) and
|
|
@@ -47,21 +46,106 @@ import {
|
|
|
47
46
|
sectionInner, slideHeading, splitOpenTag,
|
|
48
47
|
} from '../tools/deck-html.mjs';
|
|
49
48
|
import { CLICK_MARK } from '../tools/sentences.mjs';
|
|
49
|
+
import { parseChart } from '../tools/chart-spec.mjs';
|
|
50
|
+
import { calloutBlocks, calloutSteps, calloutsOf, stepsOf as lineStepsOf } from '../tools/code-options.mjs';
|
|
51
|
+
import { clickMismatch, clickMismatchText, readClickMismatch } from '../tools/click-match.mjs';
|
|
50
52
|
import { isTemplateRef, parseTemplateRef } from '../tools/design-system-format.mjs';
|
|
51
53
|
import { auditDeck } from './audit.mjs';
|
|
52
|
-
import {
|
|
54
|
+
import {
|
|
55
|
+
designSystemRefs, packageVerdict, resolveDesignSystemRef, deckDesignSystemVersions, linkedStylesheets, migrationStatus, behindMessage,
|
|
56
|
+
} from './design-system-refs.mjs';
|
|
57
|
+
import { composeRenames, migrationsOf } from '../tools/design-system-migrations.mjs';
|
|
53
58
|
import { markedSources } from './theme-refs.mjs';
|
|
54
59
|
import { parseColor, toOklab } from '../tools/color.mjs';
|
|
55
60
|
import { ON_PALETTE_DISTANCE, offRoleColours, nearestRole, resolveTokenColours } from '../tools/brand-palette.mjs';
|
|
56
|
-
import { printUrl } from './pdf.mjs';
|
|
61
|
+
import { printUrl, invisibleSaid } from './pdf.mjs';
|
|
62
|
+
import { invisibleMessage } from '../tools/invisible-in-print.mjs';
|
|
63
|
+
import { configBlock, hasDoctype, isDeck } from './runtime-link.mjs';
|
|
64
|
+
import { attributeFindings, configFindings } from '../tools/vocabulary.mjs';
|
|
65
|
+
import { stepRuns } from '../tools/steps.mjs';
|
|
57
66
|
import { runMain } from './util.mjs';
|
|
67
|
+
import { translationFindings } from './translate-files.mjs';
|
|
68
|
+
import { legacyWriting, migrateWriting } from './migrate-writing.mjs';
|
|
58
69
|
|
|
59
70
|
/**
|
|
60
71
|
* One finding. `slide` is null for anything outside a section (the head), and
|
|
61
72
|
* `rule` is there for the `--json` reader: an agent filters on a stable name,
|
|
62
73
|
* never on the wording of a message a human reads.
|
|
74
|
+
*
|
|
75
|
+
* A finding about ONE element carries its address, `at: { path, tag }`: the
|
|
76
|
+
* element-child path below the slide's `<section>` (its first step is the
|
|
77
|
+
* raw index among the section's children, the edit routes' `index`; the rest
|
|
78
|
+
* is their `path`), and the tag found there. The panel's Fix it hands it to
|
|
79
|
+
* the agent, and a row's hover outlines the element on the stage.
|
|
80
|
+
*/
|
|
81
|
+
const finding = (level, rule, slide, title, message, at = null) => ({ level, rule, slide, title, message, ...(at ? { at } : {}) });
|
|
82
|
+
|
|
83
|
+
/** `n` as an ordinal: 1st, 2nd, 3rd, 11th, 22nd. */
|
|
84
|
+
const ordinal = (n) => `${n}${[11, 12, 13].includes(n % 100) ? 'th' : ({ 1: 'st', 2: 'nd', 3: 'rd' }[n % 10] ?? 'th')}`;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* How a finding names one element: its tag, what tells it apart from its
|
|
88
|
+
* neighbours (its class, else its id, else its data-node), then the
|
|
89
|
+
* attributes the finding is about. `<rect class="cm-grow" data-concept="full">`.
|
|
90
|
+
*/
|
|
91
|
+
function elementName(node, shown) {
|
|
92
|
+
const a = readAttrs(node.attrs);
|
|
93
|
+
const cls = String(a.class ?? '').trim().replace(/\s+/g, ' ');
|
|
94
|
+
const own = cls ? ['class', cls] : a.id ? ['id', a.id] : a['data-node'] && !('data-node' in shown) ? ['data-node', a['data-node']] : null;
|
|
95
|
+
const parts = [own, ...Object.entries(shown)].filter(Boolean).map(([k, v]) => `${k}="${v}"`);
|
|
96
|
+
return `<${node.tag}${parts.length ? ` ${parts.join(' ')}` : ''}>`;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Names for `nodes` that tell them apart: each one's `elementName`, and where
|
|
101
|
+
* two of them would read alike, its place among those that do
|
|
102
|
+
* (`<rect data-concept="full"> (2nd of 3)`), in document order. Two findings
|
|
103
|
+
* about two elements never read as one.
|
|
104
|
+
*/
|
|
105
|
+
function namesApart(nodes, shown) {
|
|
106
|
+
const named = nodes.map((n) => [n, elementName(n, shown(n))]);
|
|
107
|
+
const alike = new Map();
|
|
108
|
+
for (const [, name] of named) alike.set(name, (alike.get(name) ?? 0) + 1);
|
|
109
|
+
const seen = new Map();
|
|
110
|
+
return new Map(named.map(([n, name]) => {
|
|
111
|
+
const total = alike.get(name);
|
|
112
|
+
if (total === 1) return [n, name];
|
|
113
|
+
const i = (seen.get(name) ?? 0) + 1;
|
|
114
|
+
seen.set(name, i);
|
|
115
|
+
return [n, `${name} (${ordinal(i)} of ${total})`];
|
|
116
|
+
}));
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** Every node under `root` mapped to its element-child path from it, `[2, 0]`. */
|
|
120
|
+
function pathsBelow(root) {
|
|
121
|
+
const out = new Map();
|
|
122
|
+
const walk = (node, path) => node.children.forEach((c, i) => {
|
|
123
|
+
const p = [...path, i];
|
|
124
|
+
out.set(c, p);
|
|
125
|
+
walk(c, p);
|
|
126
|
+
});
|
|
127
|
+
walk(root, []);
|
|
128
|
+
return out;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Findings that would read as the same row (same level, rule, slide and
|
|
133
|
+
* message) folded into one, which says how many it stands for (`count`) and
|
|
134
|
+
* carries every element's address (`ats`) when they had one.
|
|
63
135
|
*/
|
|
64
|
-
|
|
136
|
+
export function foldRepeats(findings) {
|
|
137
|
+
const out = [];
|
|
138
|
+
const byKey = new Map();
|
|
139
|
+
for (const f of findings) {
|
|
140
|
+
const key = JSON.stringify([f.level, f.rule, f.slide, f.message]);
|
|
141
|
+
const first = byKey.get(key);
|
|
142
|
+
if (!first) { byKey.set(key, f); out.push(f); continue; }
|
|
143
|
+
first.count = (first.count ?? 1) + 1;
|
|
144
|
+
if (f.at) first.ats = [...(first.ats ?? (first.at ? [first.at] : [])), f.at];
|
|
145
|
+
}
|
|
146
|
+
for (const f of out) if (f.count > 1) f.message = `${f.message} (${f.count} alike here)`;
|
|
147
|
+
return out;
|
|
148
|
+
}
|
|
65
149
|
|
|
66
150
|
// ── a deck as a tree, just enough of one ─────────────────────────────────────
|
|
67
151
|
// Both static halves need the same two things — which element carries which
|
|
@@ -92,7 +176,9 @@ const IMPLIED_CLOSE = {
|
|
|
92
176
|
const TAG = /<!--[\s\S]*?-->|<(\/)?([a-zA-Z][\w:.-]*)((?:"[^"]*"|'[^']*'|[^>"'])*)>/g;
|
|
93
177
|
|
|
94
178
|
/**
|
|
95
|
-
* `html` as a tree of `{ tag, attrs, start, children }`, best-effort
|
|
179
|
+
* `html` as a tree of `{ tag, attrs, start, end, children }`, best-effort:
|
|
180
|
+
* `end` is where the node's content stops (its close tag, or the end of the
|
|
181
|
+
* document for one never closed), so its text is `html.slice(start, end)`.
|
|
96
182
|
*
|
|
97
183
|
* Best-effort is the contract: this reads a file somebody is mid-edit on, so a
|
|
98
184
|
* stray `</div>` is ignored rather than thrown on, and an unclosed tag simply
|
|
@@ -110,19 +196,22 @@ export function parseTree(html) {
|
|
|
110
196
|
const tag = rawName.toLowerCase();
|
|
111
197
|
if (closing) {
|
|
112
198
|
const at = stack.findLastIndex((n) => n.tag === tag);
|
|
113
|
-
if (at > 0)
|
|
199
|
+
if (at > 0) { // a close with no open is somebody's typo, not a nesting level
|
|
200
|
+
for (const open of stack.slice(at)) open.end = m.index;
|
|
201
|
+
stack.length = at;
|
|
202
|
+
}
|
|
114
203
|
continue;
|
|
115
204
|
}
|
|
116
205
|
const selfClosed = /\/\s*$/.test(rawAttrs);
|
|
117
|
-
const node = { tag, attrs: rawAttrs.replace(/\/\s*$/, ''), start: m.index, children: [] };
|
|
206
|
+
const node = { tag, attrs: rawAttrs.replace(/\/\s*$/, ''), start: m.index, end: html.length, children: [] };
|
|
118
207
|
for (const implied of IMPLIED_CLOSE[tag] ?? []) {
|
|
119
208
|
if (stack.at(-1).tag === implied) stack.pop();
|
|
120
209
|
}
|
|
121
210
|
stack.at(-1).children.push(node);
|
|
122
|
-
if (selfClosed || VOID_ELEMENTS.has(tag)) continue;
|
|
211
|
+
if (selfClosed || VOID_ELEMENTS.has(tag)) { node.end = re.lastIndex; continue; }
|
|
123
212
|
if (OPAQUE_ELEMENTS.has(tag)) {
|
|
124
213
|
const close = indexOfCI(html, `</${tag}`, re.lastIndex);
|
|
125
|
-
re.lastIndex = close === -1 ? html.length : close;
|
|
214
|
+
re.lastIndex = node.end = close === -1 ? html.length : close;
|
|
126
215
|
continue;
|
|
127
216
|
}
|
|
128
217
|
stack.push(node);
|
|
@@ -228,7 +317,7 @@ function assetReferences(tree) {
|
|
|
228
317
|
return out;
|
|
229
318
|
}
|
|
230
319
|
|
|
231
|
-
// ──
|
|
320
|
+
// ── [click] markers vs build clicks ──────────────────────────────────────────
|
|
232
321
|
|
|
233
322
|
const SVG_SKIP = new Set(['defs', 'title', 'desc', 'style', 'metadata']);
|
|
234
323
|
const CONTAINER_TAGS = new Set(['ul', 'ol', 'table', 'tbody', 'dl', 'svg']);
|
|
@@ -248,6 +337,8 @@ function eligibleChildren(node) {
|
|
|
248
337
|
function isContainer(node) {
|
|
249
338
|
if ('data-build-self' in readAttrs(node.attrs)) return false;
|
|
250
339
|
if (CONTAINER_TAGS.has(node.tag)) return true;
|
|
340
|
+
// a figure (DECK_ANATOMY) is one step, its value and label together
|
|
341
|
+
if (node.tag === 'div' && /(^|\s)figure(\s|$)/.test(readAttrs(node.attrs).class ?? '')) return false;
|
|
251
342
|
if (node.tag === 'div' || node.tag === 'g') return eligibleChildren(node).length >= 2;
|
|
252
343
|
return false;
|
|
253
344
|
}
|
|
@@ -270,6 +361,8 @@ function stepSource(node) {
|
|
|
270
361
|
* read a cast or parsed `data-lines`, and no file reader can count those.
|
|
271
362
|
* `hasProvider` below is why the caller does not compare on such a slide at
|
|
272
363
|
* all: a guess against a number nobody can know is a warning about nothing.
|
|
364
|
+
* The render half counts them (engine.js `markClickMismatch`), and when it
|
|
365
|
+
* runs its answer replaces this one (#929).
|
|
273
366
|
*/
|
|
274
367
|
export function buildSteps(node) {
|
|
275
368
|
return buildItems(node).length;
|
|
@@ -285,24 +378,32 @@ export function buildSteps(node) {
|
|
|
285
378
|
function buildItems(node) {
|
|
286
379
|
const items = [];
|
|
287
380
|
let auto = 0;
|
|
288
|
-
const push = (orderAttr) => { items.push(orderItem(orderAttr, auto)); auto++; };
|
|
381
|
+
const push = (orderAttr, n, withPrev = false) => { items.push({ ...orderItem(orderAttr, auto, withPrev), node: n }); auto++; };
|
|
289
382
|
const stops = (n) => parseDrawStops(readAttrs(n.attrs)['data-draw-stops']).length;
|
|
290
383
|
const stepsOf = (n) => {
|
|
291
384
|
const attrs = readAttrs(n.attrs);
|
|
292
385
|
if ('data-draw-stops' in attrs && stops(n)) {
|
|
293
386
|
// its stops count up from its data-build-order, when it has one (#524)
|
|
294
387
|
const base = parseInt(attrs['data-build-order'] ?? '', 10);
|
|
295
|
-
for (let i = 0; i < stops(n); i++) push(Number.isFinite(base) ? String(base + i) : null);
|
|
388
|
+
for (let i = 0; i < stops(n); i++) push(Number.isFinite(base) ? String(base + i) : null, n);
|
|
296
389
|
return;
|
|
297
390
|
}
|
|
298
|
-
push(attrs['data-build-order']);
|
|
391
|
+
push(attrs['data-build-order'], n, 'data-build-with' in attrs);
|
|
392
|
+
};
|
|
393
|
+
// a diagram's group that builds (builds.js isBuildingGroup): its members are steps of their own
|
|
394
|
+
const stepsIn = (container) => {
|
|
395
|
+
for (const c of stepSource(container)) {
|
|
396
|
+
const a = readAttrs(c.attrs);
|
|
397
|
+
if (c.tag === 'g' && 'data-group' in a && 'data-build' in a && isContainer(c)) stepsIn(c);
|
|
398
|
+
else stepsOf(c);
|
|
399
|
+
}
|
|
299
400
|
};
|
|
300
401
|
const walk = (parent) => {
|
|
301
402
|
for (const child of parent.children) {
|
|
302
403
|
if (child.tag === 'aside' || OPAQUE_ELEMENTS.has(child.tag)) continue;
|
|
303
404
|
const attrs = readAttrs(child.attrs);
|
|
304
405
|
if ('data-build' in attrs) {
|
|
305
|
-
if (isContainer(child)) {
|
|
406
|
+
if (isContainer(child)) { stepsIn(child); continue; }
|
|
306
407
|
stepsOf(child); // a leaf is one step, and the engine keeps walking into it
|
|
307
408
|
} else if ('data-draw-stops' in attrs && stops(child)) {
|
|
308
409
|
stepsOf(child); // a staged stroke outside any build container is its own provider
|
|
@@ -325,6 +426,24 @@ export function buildClicks(node) {
|
|
|
325
426
|
return computeGroups(buildItems(node)).length;
|
|
326
427
|
}
|
|
327
428
|
|
|
429
|
+
// What paints, for a build step read from the file: words, or one of these.
|
|
430
|
+
const PAINTS = new Set(['img', 'picture', 'video', 'canvas', 'iframe', 'object', 'embed', 'path', 'rect', 'circle',
|
|
431
|
+
'ellipse', 'line', 'polyline', 'polygon', 'text', 'image', 'use', 'foreignobject']);
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* Is one click of this slide's builds a reveal of nothing: a group whose every
|
|
435
|
+
* step has no words and nothing that paints? The commonest cause of a
|
|
436
|
+
* [click] count that is one short (#929): a `<g data-build-order>` left
|
|
437
|
+
* behind when its graphic was removed. `html` is the text `node` was parsed from.
|
|
438
|
+
*/
|
|
439
|
+
export function emptyBuildClick(node, html) {
|
|
440
|
+
const items = buildItems(node);
|
|
441
|
+
// a token along a wire is an empty <g> the runtime draws in: its click shows the token, never nothing
|
|
442
|
+
const blank = (n) => readAttrs(n.attrs)['data-build'] !== 'travel' && !PAINTS.has(n.tag) && ![...descendants(n)].some((d) => PAINTS.has(d.tag))
|
|
443
|
+
&& !html.slice(n.start, n.end).replace(/<[^>]*>/g, '').replace(/ | /g, ' ').trim();
|
|
444
|
+
return computeGroups(items).some((g) => g.length && g.every((k) => blank(items[k].node)));
|
|
445
|
+
}
|
|
446
|
+
|
|
328
447
|
/** The stop count a `data-draw-stops` attribute declares (the runtime's `parseDrawStops`, without a length to clamp to). */
|
|
329
448
|
function parseDrawStops(attr) {
|
|
330
449
|
const raw = String(attr ?? '').trim().split(/[\s,]+/).filter(Boolean);
|
|
@@ -389,8 +508,11 @@ export function deckDesignSystems(html) {
|
|
|
389
508
|
/** What `check` keeps of a design system that passed its gate: its templates, and its palette and roles when it has them. */
|
|
390
509
|
export function checkEntry(ref, verdict) {
|
|
391
510
|
const brand = verdict?.summary?.brand;
|
|
511
|
+
const m = verdict?.manifest;
|
|
392
512
|
return {
|
|
393
513
|
ref, templates: new Map((verdict?.summary?.templates ?? []).map((l) => [l.id, l.slots])),
|
|
514
|
+
// what a deck behind its version is held to (SPEC DESIGN_SYSTEM_MIGRATIONS)
|
|
515
|
+
...(m?.version ? { migrationManifest: { name: m.name, version: m.version, tokenPrefix: m.tokenPrefix, migrations: m.migrations } } : {}),
|
|
394
516
|
// component classes its base styles also give a plain element (SPEC DESIGN_SYSTEMS)
|
|
395
517
|
components: verdict?.summary?.baseStyles?.components ?? {},
|
|
396
518
|
// a palette of scales and its own themes (SPEC BRAND_PALETTE): what off-palette-literal holds slides to
|
|
@@ -529,6 +651,13 @@ function designSystemFindings(value, tree, systems, configured, push) {
|
|
|
529
651
|
|
|
530
652
|
// ── whether a slide's diagram builds ─────────────────────────────────────────
|
|
531
653
|
|
|
654
|
+
/** The longest a figure's value reads as one (DECK_ANATOMY): `$12.5M`, `1,500`, `-12.5%`. */
|
|
655
|
+
export const FIGURE_MAX_CHARS = 8;
|
|
656
|
+
/** A figure's value as a reader sees it, from its source: tags out, the common entities read, spaces folded. */
|
|
657
|
+
const figureText = (src) => src.replace(/^<[^>]*>/, '').replace(/<[^>]*>/g, '')
|
|
658
|
+
.replace(/ | /g, ' ').replace(/×/g, '×').replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/&[a-z]+;|&#\d+;/gi, '·')
|
|
659
|
+
.replace(/\s+/g, ' ').trim();
|
|
660
|
+
|
|
532
661
|
const hasClass = (node, cls) => new RegExp(`(?:^|\\s)${cls}(?:\\s|$)`).test(readAttrs(node.attrs).class ?? '');
|
|
533
662
|
/** Generated, not drawn: a chart or a terminal cast has nothing an author would build. */
|
|
534
663
|
const generated = (node) => hasClass(node, 'chart') || hasClass(node, 'terminal');
|
|
@@ -567,7 +696,7 @@ function diagramBuilds(svg) {
|
|
|
567
696
|
* `dir` is what a relative asset path resolves against — the deck's own
|
|
568
697
|
* directory, exactly as the browser would resolve it from the deck's URL.
|
|
569
698
|
*/
|
|
570
|
-
export function staticFindings(html, { dir = '.', exists = existsSync, designSystems = deckDesignSystems } = {}) {
|
|
699
|
+
export function staticFindings(html, { dir = '.', exists = existsSync, designSystems = deckDesignSystems, stylesheets = linkedStylesheets, deck = '<deck.html>' } = {}) {
|
|
571
700
|
const src = String(html ?? '');
|
|
572
701
|
const out = [];
|
|
573
702
|
const ranges = sectionRanges(src);
|
|
@@ -578,6 +707,14 @@ export function staticFindings(html, { dir = '.', exists = existsSync, designSys
|
|
|
578
707
|
const systems = configured.length ? designSystems(src) : new Map();
|
|
579
708
|
const hold = brandHold(src, systems);
|
|
580
709
|
const roles = roleHold(src, systems);
|
|
710
|
+
// A file with no doctype (#1190): every server and render puts one in front,
|
|
711
|
+
// but a browser opening the file itself lays it out in quirks mode, where a
|
|
712
|
+
// table loses the theme's text colour. A hint: Decklight's own paths are fine.
|
|
713
|
+
if (isDeck(src) && !hasDoctype(src)) {
|
|
714
|
+
out.push(finding('hint', 'no-doctype', null, 'head',
|
|
715
|
+
'no <!doctype html> at the top of the file — Decklight adds it when it serves or renders the deck, '
|
|
716
|
+
+ 'but a browser opening the file itself lays it out in quirks mode: put <!doctype html> on its first line'));
|
|
717
|
+
}
|
|
581
718
|
const offBrand = themeOffBrand(src, systems);
|
|
582
719
|
if (offBrand) {
|
|
583
720
|
out.push(finding('warn', 'theme-off-brand', null, 'head',
|
|
@@ -590,6 +727,26 @@ export function staticFindings(html, { dir = '.', exists = existsSync, designSys
|
|
|
590
727
|
`design system ${sys.ref} cannot be read on this machine — ${sys.missing}; its slides' templates and slots go unchecked`));
|
|
591
728
|
}
|
|
592
729
|
}
|
|
730
|
+
// A deck behind the major this machine serves (SPEC DESIGN_SYSTEM_MIGRATIONS):
|
|
731
|
+
// ONE finding with the renames and what moves them, read from the deck and
|
|
732
|
+
// the stylesheets it links — and the names it found are not each said again
|
|
733
|
+
// as off-role. `renamedTo` names a renamed role wherever off-role still meets one.
|
|
734
|
+
const behindNames = new Set();
|
|
735
|
+
const renamedTo = new Map();
|
|
736
|
+
const versions = configured.length ? deckDesignSystemVersions(src) : {};
|
|
737
|
+
let linked = null;
|
|
738
|
+
for (const [name, sys] of systems) {
|
|
739
|
+
const mm = sys.migrationManifest;
|
|
740
|
+
if (!mm) continue;
|
|
741
|
+
linked ??= stylesheets(src, dir).map((x) => x.text);
|
|
742
|
+
const status = migrationStatus(mm, versions[sys.ref] ?? null, [src, ...linked]);
|
|
743
|
+
for (const [from, r] of Object.entries(composeRenames(migrationsOf(mm)).roles)) {
|
|
744
|
+
renamedTo.set(`${mm.tokenPrefix ?? `--${mm.name}-`}color-${from}`, `was renamed ${r.to} in ${r.version}`);
|
|
745
|
+
}
|
|
746
|
+
if (!status.behind) continue;
|
|
747
|
+
for (const f of status.found) behindNames.add(f.as);
|
|
748
|
+
out.push(finding('warn', 'ds-behind', null, 'head', `${sys.ref} — ${behindMessage(name, status, { ref: sys.ref, deck })}`));
|
|
749
|
+
}
|
|
593
750
|
// `sectionInner`, never the raw body: a body begins mid-open-tag, so a slide
|
|
594
751
|
// with no heading to fall back on would be titled ` data-markdown>` — the
|
|
595
752
|
// remnant of its own tag, read as the slide's opening words.
|
|
@@ -599,6 +756,8 @@ export function staticFindings(html, { dir = '.', exists = existsSync, designSys
|
|
|
599
756
|
return { slide, title: title(slide) };
|
|
600
757
|
};
|
|
601
758
|
|
|
759
|
+
// a run of slides (DECK_ANATOMY, #1188), read slide by slide below, judged once the deck is read
|
|
760
|
+
const stepSlides = [];
|
|
602
761
|
for (const range of ranges) {
|
|
603
762
|
const { slide, body } = range;
|
|
604
763
|
const attrs = readAttrs(splitOpenTag(body).attrs);
|
|
@@ -623,19 +782,130 @@ export function staticFindings(html, { dir = '.', exists = existsSync, designSys
|
|
|
623
782
|
}
|
|
624
783
|
|
|
625
784
|
const tree = parseTree(inner);
|
|
626
|
-
const
|
|
785
|
+
const stepsNav = [...descendants(tree)].find((n) => n.tag === 'nav' && hasClass(n, 'steps'));
|
|
786
|
+
stepSlides.push({
|
|
787
|
+
// an attribute's value as the page reads it: its entities decoded (`Ship & tell`)
|
|
788
|
+
steps: attrs['data-steps'] == null ? null : figureText(attrs['data-steps']),
|
|
789
|
+
list: stepsNav ? [...descendants(stepsNav)].filter((n) => n.tag === 'li').map((n) => figureText(inner.slice(n.start, n.end))) : null,
|
|
790
|
+
step: attrs['data-step'] == null ? null : figureText(attrs['data-step']),
|
|
791
|
+
module: 'data-module' in attrs,
|
|
792
|
+
end: 'data-steps-end' in attrs,
|
|
793
|
+
count: 'data-steps-count' in attrs,
|
|
794
|
+
hidden: 'data-hidden' in attrs,
|
|
795
|
+
});
|
|
796
|
+
const pathOf = pathsBelow(tree);
|
|
797
|
+
const addressOf = (node) => ({ path: pathOf.get(node), tag: node.tag });
|
|
798
|
+
const push = (rule, message, node = null) => out.push(finding('warn', rule, slide, head, message, node && addressOf(node)));
|
|
627
799
|
// a slashed data-layout was how a slide named a template before 0.9.0
|
|
628
800
|
if (isTemplateRef(attrs['data-layout'])) {
|
|
629
801
|
push('ds-layout-attr', `data-layout="${attrs['data-layout']}" — a slide template is named by data-template now: write data-template="${attrs['data-layout']}" (data-layout is for the built-in layouts, L)`);
|
|
630
802
|
}
|
|
803
|
+
// a framed web page (Add ▾ › Web page): someone else's page, fetched as
|
|
804
|
+
// the slide shows, so wherever the deck cannot reach it the frame is blank
|
|
805
|
+
for (const node of descendants(tree)) {
|
|
806
|
+
if (node.tag !== 'iframe') continue;
|
|
807
|
+
const at = readAttrs(node.attrs).src ?? '';
|
|
808
|
+
if (!/^https?:\/\//i.test(at)) continue;
|
|
809
|
+
let host = at;
|
|
810
|
+
try { host = new URL(at).host; } catch { /* said as written */ }
|
|
811
|
+
push('web-page', `the web page from ${host} is blank in no-trust mode, in a video export and offline: the frame fetches it as the slide shows, so present it where it can be reached, or show a picture of it`, node);
|
|
812
|
+
}
|
|
813
|
+
// a figure's value (DECK_ANATOMY): a number and its unit, a few
|
|
814
|
+
// characters set several times the body size; a sentence there is not a
|
|
815
|
+
// figure, and is shrunk to fit its column until it is no longer large
|
|
816
|
+
for (const node of descendants(tree)) {
|
|
817
|
+
if (!('data-figure' in readAttrs(node.attrs))) continue;
|
|
818
|
+
const text = figureText(inner.slice(node.start, node.end));
|
|
819
|
+
if ([...text].length > FIGURE_MAX_CHARS) {
|
|
820
|
+
push('figure-long', `the figure's value "${text.length > 40 ? `${text.slice(0, 40)}…` : text}" is ${[...text].length} characters — a figure is a number and its unit (94%, $1.2M, 3×), at most ${FIGURE_MAX_CHARS}: put the words in its label, the <p> under it`, node);
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
// a chart's JSON (CHARTS), read as the runtime reads it: what it refuses
|
|
824
|
+
// is the error box on the slide, and what it draws without (a band
|
|
825
|
+
// shorter than the labels, a dashFrom naming no label) is said here only
|
|
826
|
+
for (const node of descendants(tree)) {
|
|
827
|
+
const a = readAttrs(node.attrs);
|
|
828
|
+
if (!('data-chart' in a)) continue;
|
|
829
|
+
const body = /<script\b[^>]*\btype\s*=\s*["']?application\/json["']?[^>]*>([\s\S]*?)<\/script\s*>/i.exec(inner.slice(node.start, node.end));
|
|
830
|
+
let spec = null;
|
|
831
|
+
try {
|
|
832
|
+
spec = parseChart(body ? body[1] : null, { type: a['data-chart'] || undefined, title: a['data-title'] || undefined, aspect: a['data-aspect'] || undefined });
|
|
833
|
+
} catch (e) {
|
|
834
|
+
out.push(finding('error', 'chart', slide, head, `the chart shows an error box instead of a chart: ${e.message}`, addressOf(node)));
|
|
835
|
+
continue;
|
|
836
|
+
}
|
|
837
|
+
for (const note of spec.notes) push('chart', `the chart: ${note}`, node);
|
|
838
|
+
}
|
|
839
|
+
// code sized by hand (CODE_AND_MATH, #1185): a font-size on a <pre>, or on
|
|
840
|
+
// a section that holds one, is right for one layout and clipped or tiny
|
|
841
|
+
// after the next edit; data-fit sizes the code to the room instead
|
|
842
|
+
const sizeOf = (a) => /(?:^|;)\s*font-size\s*:\s*([^;]+)/i.exec(a.style ?? '')?.[1].trim();
|
|
843
|
+
const pres = [...descendants(tree)].filter((n) => n.tag === 'pre');
|
|
844
|
+
if (pres.length && sizeOf(attrs)) {
|
|
845
|
+
push('code-font-size', `the slide sets font-size: ${sizeOf(attrs)} and holds code — a size set by hand is right for one layout and clipped or tiny after the next edit: take it off and mark the code data-fit (data-fit="fill" to grow short code into the room)`);
|
|
846
|
+
}
|
|
847
|
+
for (const node of pres) {
|
|
848
|
+
const size = sizeOf(readAttrs(node.attrs));
|
|
849
|
+
if (size) push('code-font-size', `<pre> sets font-size: ${size} — a size set by hand is right for one layout and clipped or tiny after the next edit: take it off and mark the block data-fit (data-fit="fill" to grow short code into the room)`, node);
|
|
850
|
+
}
|
|
851
|
+
// a line walk's callouts (CODE_AND_MATH, #1182): a label a step, and a
|
|
852
|
+
// label past the last step is never shown. They cost no click of their own.
|
|
853
|
+
const stepped = pres.filter((n) => readAttrs(n.attrs)['data-lines'] !== undefined);
|
|
854
|
+
const steps = (n) => lineStepsOf(readAttrs(n.attrs)['data-lines']).length;
|
|
855
|
+
const tooMany = (have, n) => `${have} callout${have === 1 ? '' : 's'} for ${n} line step${n === 1 ? '' : 's'}`;
|
|
856
|
+
for (const node of pres) {
|
|
857
|
+
const a = readAttrs(node.attrs);
|
|
858
|
+
if (a['data-callouts'] === undefined) continue;
|
|
859
|
+
const have = calloutsOf(a['data-callouts']).length;
|
|
860
|
+
const n = a['data-lines'] === undefined ? 0 : steps(node);
|
|
861
|
+
if (have > n) push('code-callouts', `<pre> has ${tooMany(have, n)} — ${n ? `a label past step ${n} is never shown: one label a step, | between them, in step order` : 'callouts label line steps: give the block data-lines'}`, node);
|
|
862
|
+
}
|
|
863
|
+
const asides = [...descendants(tree)].filter((n) => n.tag === 'aside' && /(^|\s)callouts(\s|$)/.test(readAttrs(n.attrs).class ?? ''));
|
|
864
|
+
const tied = calloutBlocks(stepped.map((n) => ({ id: readAttrs(n.attrs).id })), asides.map((n) => ({ for: readAttrs(n.attrs)['data-for'] })));
|
|
865
|
+
asides.forEach((node, k) => {
|
|
866
|
+
const entries = node.children.filter((c) => c.tag);
|
|
867
|
+
const last = Math.max(0, ...calloutSteps(entries.map((c) => readAttrs(c.attrs)['data-step'])));
|
|
868
|
+
const block = stepped[tied[k]];
|
|
869
|
+
if (!block) {
|
|
870
|
+
const f = readAttrs(node.attrs)['data-for'];
|
|
871
|
+
push('code-callouts', f ? `the callouts aside is for "${f}", and no block with data-lines on this slide has that id` : 'the callouts aside has no block with data-lines on this slide to label', node);
|
|
872
|
+
} else if (last > steps(block)) push('code-callouts', `the callouts aside labels step ${last}, and its block has ${steps(block)} line step${steps(block) === 1 ? '' : 's'}: one label a step`, node);
|
|
873
|
+
});
|
|
631
874
|
// a concept shape with its own fill (SVG_DIAGRAMS, #718): the concept
|
|
632
875
|
// repaints the fill on every load, so the hand-set one is never seen
|
|
633
|
-
|
|
634
|
-
|
|
876
|
+
// — each named apart from the slide's other concept shapes, quoting the fill it found
|
|
877
|
+
const conceptShapes = [...descendants(tree)].filter((n) => SHAPE_TAGS.has(n.tag) && readAttrs(n.attrs)['data-concept']);
|
|
878
|
+
const conceptNames = namesApart(conceptShapes, (n) => ({ 'data-concept': readAttrs(n.attrs)['data-concept'] }));
|
|
879
|
+
for (const node of conceptShapes) {
|
|
635
880
|
const a = readAttrs(node.attrs);
|
|
636
|
-
|
|
637
|
-
const own = a.fill && a.fill !== 'none' ? `fill="${a.fill}"` :
|
|
638
|
-
if (own) push('concept-fill',
|
|
881
|
+
const styled = /(?:^|;)\s*fill\s*:\s*(?!none\b)([^;]+)/i.exec(a.style ?? '');
|
|
882
|
+
const own = a.fill && a.fill !== 'none' ? `fill="${a.fill}"` : styled ? `fill: ${styled[1].trim()} in its style` : null;
|
|
883
|
+
if (own) push('concept-fill', `${conceptNames.get(node)} also carries ${own} — the concept colours it, and the fill is painted over; pin the concept's slot (Concept colors…) or take the concept off (Colors… → Detach from concept)`, node);
|
|
884
|
+
}
|
|
885
|
+
// a connector naming a node its svg does not have (SVG_DIAGRAMS): the
|
|
886
|
+
// runtime leaves it where the file draws it, attached to nothing
|
|
887
|
+
for (const svg of descendants(tree)) {
|
|
888
|
+
if (svg.tag !== 'svg') continue;
|
|
889
|
+
const inside = [...descendants(svg)];
|
|
890
|
+
const names = new Set(inside.map((n) => readAttrs(n.attrs)['data-node']).filter(Boolean));
|
|
891
|
+
for (const end of ['data-from', 'data-to']) {
|
|
892
|
+
const wires = inside.filter((n) => readAttrs(n.attrs)[end] !== undefined);
|
|
893
|
+
const called = namesApart(wires, (n) => ({ [end]: readAttrs(n.attrs)[end] }));
|
|
894
|
+
for (const n of wires) {
|
|
895
|
+
const value = readAttrs(n.attrs)[end];
|
|
896
|
+
if (names.has(value)) continue;
|
|
897
|
+
push('connector-node', `${called.get(n)} names no data-node in its svg — the wire stays where the file draws it, joined to nothing: give the shape it joins data-node="${value}", or take ${end} off`, n);
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
// a token along a wire (BUILD_ENTRANCES, travel) naming a wire its svg does not have: its click shows nothing
|
|
901
|
+
const wires = new Set(inside.filter((n) => /^(line|path|polyline)$/.test(n.tag)).map((n) => readAttrs(n.attrs)['data-wire']).filter(Boolean));
|
|
902
|
+
const tokens = inside.filter((n) => readAttrs(n.attrs)['data-along-wire'] !== undefined);
|
|
903
|
+
const tokenNames = namesApart(tokens, (n) => ({ 'data-along-wire': readAttrs(n.attrs)['data-along-wire'] }));
|
|
904
|
+
for (const n of tokens) {
|
|
905
|
+
const value = readAttrs(n.attrs)['data-along-wire'];
|
|
906
|
+
if (wires.has(value)) continue;
|
|
907
|
+
push('travel-wire', `${tokenNames.get(n)} names no data-wire in its svg — its click sends nothing along anything: name the wire data-wire="${value}" (Wire ▸ Send a token along it does), or point it at one the svg has${wires.size ? ` (${[...wires].slice(0, 4).join(', ')})` : ''}`, n);
|
|
908
|
+
}
|
|
639
909
|
}
|
|
640
910
|
// a deck on a design system with roles: every colour its slides name is a role (SPEC DESIGN_SYSTEM_ROLES)
|
|
641
911
|
if (roles) {
|
|
@@ -645,7 +915,7 @@ export function staticFindings(html, { dir = '.', exists = existsSync, designSys
|
|
|
645
915
|
const values = [...COLOUR_ATTRS.map((k) => [k, a[k]]).filter(([, v]) => v), ...[...(a.style ?? '').matchAll(COLOUR_DECL)].map((m) => [m[1], m[2]])];
|
|
646
916
|
for (const [prop, v] of values) {
|
|
647
917
|
for (const o of offRoleColours(v, roles.ctx)) {
|
|
648
|
-
if (off.some((x) => x.name === o.name)) continue;
|
|
918
|
+
if (off.some((x) => x.name === o.name) || behindNames.has(o.name)) continue;
|
|
649
919
|
// `border: var(--acme-rule-width) solid …`: a design-system token that is no colour is the width, not off-role
|
|
650
920
|
if (o.kind === 'token' && !o.hex && SHORTHAND.test(prop)) continue;
|
|
651
921
|
off.push({ ...o, near: (o.kind === 'contract' && roles.contract[o.name]) || nearestRole(roles.values, o.hex) });
|
|
@@ -653,7 +923,8 @@ export function staticFindings(html, { dir = '.', exists = existsSync, designSys
|
|
|
653
923
|
}
|
|
654
924
|
}
|
|
655
925
|
if (off.length) {
|
|
656
|
-
const what = (o) => `${o.name}${
|
|
926
|
+
const what = (o) => `${o.name}${renamedTo.has(o.name) ? ` (${renamedTo.get(o.name)})`
|
|
927
|
+
: `${o.kind === 'contract' ? ' (the theme contract)' : o.kind === 'swatch' ? ' (a swatch)' : o.kind === 'token' ? ' (a design-system token)' : ''}${o.near ? ` (nearest role ${o.near})` : ''}`}`;
|
|
657
928
|
push('off-role', `${off.slice(0, 3).map(what).join(', ')}${off.length > 3 ? ` and ${off.length - 3} more` : ''}`
|
|
658
929
|
+ ` ${off.length === 1 ? 'is' : 'are'} not one of the design system's roles — this deck colours through them, so every theme recolours it: pick a role in Colors…, or set "brandThemesOnly": false`);
|
|
659
930
|
}
|
|
@@ -698,18 +969,19 @@ export function staticFindings(html, { dir = '.', exists = existsSync, designSys
|
|
|
698
969
|
designSystemFindings(attrs['data-template'], tree, systems, configured.map((r) => r.ref),
|
|
699
970
|
(rule, message) => out.push(finding('warn', rule, slide, head, message)));
|
|
700
971
|
}
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
//
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
972
|
+
// ⟨CLICK⟩ markers against build clicks (tools/click-match.mjs, #929), as
|
|
973
|
+
// far as the file can count them: a provider's steps exist only once the
|
|
974
|
+
// runtime has read them, so such a slide is left to the render half,
|
|
975
|
+
// which counts them in the browser and replaces this estimate when it runs.
|
|
976
|
+
const notesHtml = NOTES_ASIDE.exec(inner)?.[1];
|
|
977
|
+
const segments = clickSegments(notesHtml);
|
|
978
|
+
if (segments > 1 && !hasProvider(tree)) {
|
|
979
|
+
const lead = !cleanNotes(readNotes(notesHtml).split(CLICK_MARK)[0]);
|
|
980
|
+
const m = clickMismatch({
|
|
981
|
+
markers: segments - 1, clicks: buildClicks(tree),
|
|
982
|
+
cause: emptyBuildClick(tree, inner) ? 'empty-build' : lead ? 'lead-click' : null,
|
|
983
|
+
});
|
|
984
|
+
if (m) out.push(finding('warn', 'clicks-vs-builds', slide, head, clickMismatchText(m, { steps: buildSteps(tree) })));
|
|
713
985
|
}
|
|
714
986
|
|
|
715
987
|
|
|
@@ -727,10 +999,35 @@ export function staticFindings(html, { dir = '.', exists = existsSync, designSys
|
|
|
727
999
|
}
|
|
728
1000
|
}
|
|
729
1001
|
|
|
1002
|
+
// A slide's group that is none of its run's (DECK_ANATOMY, #1188): the strip
|
|
1003
|
+
// cannot light it, and shows the slide as still in the group before.
|
|
1004
|
+
for (const u of stepRuns(stepSlides).unknown) {
|
|
1005
|
+
out.push(finding('warn', 'step-group', u.slide, title(u.slide), u.groups
|
|
1006
|
+
? `data-step="${u.step}" is not one of its run's groups (${u.groups.join(', ')}) — the strip shows the slide as still in the group before: name one of them, or add it to data-steps on the slide the run starts on`
|
|
1007
|
+
: `data-step="${u.step}" is on a slide in no run — a run starts on a slide with data-steps="…" and ends at the next chapter or data-steps-end: start one, or take data-step off`));
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
const tree = parseTree(src);
|
|
1011
|
+
|
|
1012
|
+
// A word Decklight does not know (tools/vocabulary.mjs): `data-buld`, a
|
|
1013
|
+
// build effect spelled `fade-upp`, a configuration key typed `trasition`
|
|
1014
|
+
// all render as if absent, and nothing else would ever say so.
|
|
1015
|
+
const titles = new Map();
|
|
1016
|
+
const titled = (slide) => {
|
|
1017
|
+
if (!titles.has(slide)) titles.set(slide, title(slide));
|
|
1018
|
+
return titles.get(slide);
|
|
1019
|
+
};
|
|
1020
|
+
out.push(...attributeFindings([...descendants(tree)].map((n) => {
|
|
1021
|
+
const slide = slideAt(ranges, n.start);
|
|
1022
|
+
return { slide, title: titled(slide), attrs: readAttrs(n.attrs) };
|
|
1023
|
+
})));
|
|
1024
|
+
const block = configBlock(src);
|
|
1025
|
+
if (block) out.push(...configFindings(block.inner, { line: src.slice(0, block.innerStart).split('\n').length }));
|
|
1026
|
+
|
|
730
1027
|
// An asset that is not on disk is the failure with no symptom: the deck
|
|
731
1028
|
// renders, the image is a blank box, and whoever exported the PDF finds out
|
|
732
1029
|
// afterwards. Resolved the way the browser would, against the deck's folder.
|
|
733
|
-
for (const ref of assetReferences(
|
|
1030
|
+
for (const ref of assetReferences(tree)) {
|
|
734
1031
|
if (exists(resolve(dir, ref.path))) continue;
|
|
735
1032
|
const where = at(ref.at);
|
|
736
1033
|
out.push(finding('error', 'missing-asset', where.slide, where.title,
|
|
@@ -755,7 +1052,7 @@ export function staticFindings(html, { dir = '.', exists = existsSync, designSys
|
|
|
755
1052
|
`line ${h.line}: ${h.kind} on <${h.tag}> (${h.attr}) — --no-trust --strict would strip this`));
|
|
756
1053
|
}
|
|
757
1054
|
|
|
758
|
-
return sortFindings(out);
|
|
1055
|
+
return foldRepeats(sortFindings(out));
|
|
759
1056
|
}
|
|
760
1057
|
|
|
761
1058
|
/** Head first, then slides in order; within a slide, the order they were found. */
|
|
@@ -810,14 +1107,17 @@ export function renderFindings(domHtml, { slides = 0 } = {}) {
|
|
|
810
1107
|
const head = slideHeading(sectionInner(bodies[i] ?? ''), i);
|
|
811
1108
|
const attrs = readAttrs(m[0].slice('<section'.length).replace(/>$/, ''));
|
|
812
1109
|
if ('data-overflow' in attrs) {
|
|
813
|
-
// The guardrail is
|
|
814
|
-
//
|
|
815
|
-
//
|
|
1110
|
+
// The guardrail names what is cut and by how much (engine.js
|
|
1111
|
+
// `checkOverflow`: data-overflow="a diagram", data-overflow-by, #1183);
|
|
1112
|
+
// a deck on an older runtime carries a bare attribute, and is told only
|
|
1113
|
+
// that it is clipped, rather than a figure this file made up.
|
|
1114
|
+
const what = attrs['data-overflow'];
|
|
816
1115
|
const by = Number(attrs['data-overflow-by']);
|
|
1116
|
+
const over = Number.isFinite(by) && by > 0;
|
|
817
1117
|
out.push(finding('error', 'overflow', slide, head,
|
|
818
|
-
|
|
819
|
-
? `content is clipped (${Math.round(by)} px over)`
|
|
820
|
-
|
|
1118
|
+
what && over ? `content is clipped: ${what} runs ${Math.round(by)}px past what the slide shows, and the audience never sees the rest`
|
|
1119
|
+
: over ? `content is clipped (${Math.round(by)} px over)`
|
|
1120
|
+
: 'content is clipped — it does not fit the slide, and the audience never sees the rest'));
|
|
821
1121
|
}
|
|
822
1122
|
// crowded past SLIDE_DENSITY: the runtime counts it as it lays the deck
|
|
823
1123
|
// out (src/core/density.js) and marks the section, like data-overflow
|
|
@@ -826,6 +1126,17 @@ export function renderFindings(domHtml, { slides = 0 } = {}) {
|
|
|
826
1126
|
`crowded: ${attrs['data-dense']} (~3–4 bullets or ~2 short paragraphs per column, SPEC SLIDE_DENSITY)`
|
|
827
1127
|
+ ' — split the slide rather than shrink it, or mark it data-dense-ok if it is meant'));
|
|
828
1128
|
}
|
|
1129
|
+
// content the print render does not show, once builds are complete and the
|
|
1130
|
+
// deck's own animations finished (src/core/print-visibility.js, #1184): a
|
|
1131
|
+
// hole in the PDF. A warning, not an error: the runtime cannot read intent.
|
|
1132
|
+
const invisible = invisibleSaid(m[0]);
|
|
1133
|
+
if (invisible) {
|
|
1134
|
+
out.push(finding('warn', 'invisible-in-print', slide, head, invisibleMessage(invisible)));
|
|
1135
|
+
}
|
|
1136
|
+
// [click] markers against build clicks, counted by the engine itself
|
|
1137
|
+
// (engine.js markClickMismatch): providers included, which the file cannot do
|
|
1138
|
+
const clicks = readClickMismatch(attrs['data-click-mismatch']);
|
|
1139
|
+
if (clicks) out.push(finding('warn', 'clicks-vs-builds', slide, head, clickMismatchText(clicks)));
|
|
829
1140
|
if ('data-split-conflict' in attrs) {
|
|
830
1141
|
out.push(finding('warn', 'split-conflict', slide, head,
|
|
831
1142
|
'data-layout="split" is fighting this slide\'s own column flexbox — two layout systems, '
|
|
@@ -881,34 +1192,101 @@ export function formatFindings(findings, { color = false, slides = 0 } = {}) {
|
|
|
881
1192
|
return lines;
|
|
882
1193
|
}
|
|
883
1194
|
|
|
884
|
-
const USAGE = `usage: decklight check <deck.html> [--no-render] [--json] [--wait <ms>]
|
|
1195
|
+
const USAGE = `usage: decklight check <deck.html> [--no-render] [--json] [--wait <ms>] [--watch | --fix]
|
|
885
1196
|
lints one deck and says, per slide, what you would otherwise only find by
|
|
886
1197
|
looking — for an AI agent after every edit, and for a human before a talk
|
|
887
1198
|
|
|
888
1199
|
what it reports
|
|
889
1200
|
from the file a <section> that is never closed · an image, video, cast
|
|
890
1201
|
or stylesheet that is not on disk · a data-markdown slide
|
|
891
|
-
(removed in 0.3.0) ·
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
1202
|
+
(removed in 0.3.0) · script blocks and inline handlers
|
|
1203
|
+
--no-trust --strict would strip · a misspelled data-*
|
|
1204
|
+
attribute, build effect, layout or other value, and a
|
|
1205
|
+
configuration block that is not JSON or has a key
|
|
1206
|
+
Decklight does not read, each with what was meant
|
|
1207
|
+
(an attribute close to nothing Decklight reads is yours,
|
|
1208
|
+
and left alone)
|
|
1209
|
+
its languages on a translation (talk.fr.html): a piece translated from
|
|
1210
|
+
words the source no longer has, or not translated, a
|
|
1211
|
+
slide changed in more than its words, a <html lang> that
|
|
1212
|
+
is not the record's. On the source, a warning per
|
|
1213
|
+
language behind. decklight translate fixes the first two
|
|
1214
|
+
from a render slides the overflow guardrail measured as clipped, slides
|
|
895
1215
|
crowded past SLIDE_DENSITY (~3–4 bullets or ~2 short
|
|
896
1216
|
paragraphs per column; a warning, and data-dense-ok on a
|
|
897
1217
|
section says it is meant), split layouts fighting their
|
|
898
|
-
own flexbox,
|
|
1218
|
+
own flexbox, [click] markers that do not match the
|
|
1219
|
+
slide's build clicks (counted by the runtime, code
|
|
1220
|
+
stepping and terminals included; from the file alone
|
|
1221
|
+
under --no-render, which skips those), and a deck whose
|
|
1222
|
+
runtime never mounted
|
|
899
1223
|
hints the same words on boxes on several slides in different
|
|
900
1224
|
colours: one idea, worth one concept (SVG_DIAGRAMS) · an
|
|
901
1225
|
SVG diagram with no build, landing all at once
|
|
902
|
-
(data-static-ok says it is meant)
|
|
1226
|
+
(data-static-ok says it is meant) · a file with no
|
|
1227
|
+
<!doctype html>, which a browser opening it directly
|
|
1228
|
+
lays out in quirks mode
|
|
903
1229
|
|
|
904
1230
|
--no-render the file half only — no Chrome, no render (a machine without
|
|
905
1231
|
Chrome skips that half by itself, and says so)
|
|
906
1232
|
--json the findings as a JSON array: level, rule, slide, title, message
|
|
1233
|
+
--fix migrate split-letter titles and their translation records to data-write
|
|
907
1234
|
--wait <ms> render budget for heavy decks [8000]
|
|
1235
|
+
--watch check, then check again each time the deck is saved: the
|
|
1236
|
+
screen is cleared and the fresh findings printed under the
|
|
1237
|
+
time, one Chrome kept open for the whole session. For a
|
|
1238
|
+
terminal beside your editor; not with --json
|
|
908
1239
|
|
|
909
|
-
exit 1 if anything is an error, 0 otherwise — warnings and hints never fail the run
|
|
1240
|
+
exit 1 if anything is an error, 0 otherwise — warnings and hints never fail the run.
|
|
1241
|
+
--watch runs until Ctrl-C and then exits 0, whatever it found`;
|
|
910
1242
|
|
|
911
|
-
|
|
1243
|
+
/**
|
|
1244
|
+
* One check of the deck at `src`: both halves, the render through `render`
|
|
1245
|
+
* (`(url, wait) => dom`), or the file half alone when `render` is null.
|
|
1246
|
+
* Returns the findings in order and the slide count; `null` when the deck is
|
|
1247
|
+
* not there to read (a watch catches it mid-save).
|
|
1248
|
+
*/
|
|
1249
|
+
export async function checkOnce(src, deck, { render, wait }) {
|
|
1250
|
+
let html;
|
|
1251
|
+
try { html = readFileSync(src, 'utf8'); } catch { return null; }
|
|
1252
|
+
const bodies = sectionBodies(html);
|
|
1253
|
+
const slides = bodies.length;
|
|
1254
|
+
const findings = staticFindings(html, { dir: dirname(src), deck });
|
|
1255
|
+
bodies.forEach((body, i) => {
|
|
1256
|
+
const title = legacyWriting(body)[0];
|
|
1257
|
+
if (title) findings.push(finding('warn', 'legacy-write', i + 1, title,
|
|
1258
|
+
'the title is stored letter by letter. Run decklight check --fix to convert it and its translations to plain text'));
|
|
1259
|
+
});
|
|
1260
|
+
// a deck's languages (SPEC TRANSLATION_RECORD): string comparison, no model
|
|
1261
|
+
try { findings.push(...translationFindings(src, html, { finding })); } catch { /* a record that cannot be read says so itself */ }
|
|
1262
|
+
if (render) {
|
|
1263
|
+
try {
|
|
1264
|
+
const dom = await render(printUrl(src), wait);
|
|
1265
|
+
// the browser counted the [click]s against the builds, providers and
|
|
1266
|
+
// all: its answer replaces the file's estimate rather than joining it
|
|
1267
|
+
const rendered = renderFindings(dom, { slides });
|
|
1268
|
+
if (!rendered.some((f) => f.rule === 'not-rendered')) {
|
|
1269
|
+
findings.splice(0, findings.length, ...findings.filter((f) => f.rule !== 'clicks-vs-builds'));
|
|
1270
|
+
}
|
|
1271
|
+
findings.push(...rendered);
|
|
1272
|
+
} catch (e) {
|
|
1273
|
+
findings.push(finding('error', 'render-failed', null, 'head',
|
|
1274
|
+
`the deck could not be rendered — ${String(e.message ?? e).split('\n')[0]}`));
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
return { findings: sortFindings(findings), slides };
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
/** A one-shot Chrome per render: `--dump-dom` under a virtual-time budget. */
|
|
1281
|
+
export const oneShot = (bin) => (url, wait) => runAsync(bin, [
|
|
1282
|
+
...chromeArgs('--allow-file-access-from-files', `--virtual-time-budget=${wait}`),
|
|
1283
|
+
'--dump-dom', url,
|
|
1284
|
+
], {
|
|
1285
|
+
encoding: 'utf8', maxBuffer: 64 * 1024 * 1024, timeout: CODEC_MS,
|
|
1286
|
+
why: 'Chrome did not finish rendering — a slide is probably waiting on a resource it cannot reach',
|
|
1287
|
+
});
|
|
1288
|
+
|
|
1289
|
+
export async function checkMain(args = [], { watchOpts = {} } = {}) {
|
|
912
1290
|
if (args.includes('--help') || args.includes('-h')) { console.log(USAGE); return 0; }
|
|
913
1291
|
const { opt } = argReader(args);
|
|
914
1292
|
const deck = firstPositional(args, ['--wait']);
|
|
@@ -916,37 +1294,36 @@ export async function checkMain(args = []) {
|
|
|
916
1294
|
const src = resolve(deck);
|
|
917
1295
|
if (!existsSync(src)) { console.error(`decklight check: no such deck: ${deck}`); return 1; }
|
|
918
1296
|
|
|
919
|
-
const html = readFileSync(src, 'utf8');
|
|
920
|
-
const slides = sectionBodies(html).length;
|
|
921
|
-
const findings = staticFindings(html, { dir: dirname(src) });
|
|
922
|
-
|
|
923
1297
|
// The render half is skipped rather than failed when there is no browser:
|
|
924
1298
|
// `findChrome` and never `chromeBin`, which exits the process — half a lint
|
|
925
1299
|
// is the useful answer on a machine that cannot run the other half.
|
|
926
1300
|
const json = args.includes('--json');
|
|
1301
|
+
const watching = args.includes('--watch');
|
|
1302
|
+
if (args.includes('--fix')) {
|
|
1303
|
+
if (watching) { console.error('decklight check: --fix and --watch cannot be combined'); return 1; }
|
|
1304
|
+
try {
|
|
1305
|
+
const count = migrateWriting(src);
|
|
1306
|
+
if (count) console.error(`check: converted ${count} split-letter title${count === 1 ? '' : 's'} to plain text`);
|
|
1307
|
+
} catch (e) { console.error(`decklight check: could not migrate split-letter titles: ${e.message}`); return 1; }
|
|
1308
|
+
}
|
|
1309
|
+
// a stream of JSON arrays over a cleared screen is nobody's input: an agent
|
|
1310
|
+
// checks once per edit, and a watch is a screen for a person
|
|
1311
|
+
if (watching && json) {
|
|
1312
|
+
console.error('decklight check: --watch is for a person at a terminal, and --json is for a program: '
|
|
1313
|
+
+ 'run `decklight check <deck> --json` once per edit instead');
|
|
1314
|
+
return 1;
|
|
1315
|
+
}
|
|
927
1316
|
const bin = args.includes('--no-render') ? null : findChrome();
|
|
928
1317
|
const notes = [];
|
|
929
1318
|
if (args.includes('--no-render')) notes.push('check: --no-render — the file half only, nothing was rendered');
|
|
930
1319
|
else if (!bin) notes.push('check: no Chrome found — the file half only; clipped slides go unreported (point $CHROME at one)');
|
|
1320
|
+
const wait = Number(opt('--wait', 8000));
|
|
931
1321
|
|
|
932
|
-
if (
|
|
933
|
-
const wait = Number(opt('--wait', 8000));
|
|
934
|
-
try {
|
|
935
|
-
const dom = await runAsync(bin, [
|
|
936
|
-
...chromeArgs('--allow-file-access-from-files', `--virtual-time-budget=${wait}`),
|
|
937
|
-
'--dump-dom', printUrl(src),
|
|
938
|
-
], {
|
|
939
|
-
encoding: 'utf8', maxBuffer: 64 * 1024 * 1024, timeout: CODEC_MS,
|
|
940
|
-
why: 'Chrome did not finish rendering — a slide is probably waiting on a resource it cannot reach',
|
|
941
|
-
});
|
|
942
|
-
findings.push(...renderFindings(dom, { slides }));
|
|
943
|
-
} catch (e) {
|
|
944
|
-
findings.push(finding('error', 'render-failed', null, 'head',
|
|
945
|
-
`the deck could not be rendered — ${String(e.message ?? e).split('\n')[0]}`));
|
|
946
|
-
}
|
|
947
|
-
}
|
|
1322
|
+
if (watching) return watchCheck(src, deck, { bin, wait, notes, ...watchOpts });
|
|
948
1323
|
|
|
949
|
-
const
|
|
1324
|
+
const once = await checkOnce(src, deck, { render: bin ? oneShot(bin) : null, wait });
|
|
1325
|
+
if (!once) { console.error(`decklight check: could not read ${deck}`); return 1; }
|
|
1326
|
+
const { findings: ordered, slides } = once;
|
|
950
1327
|
const errors = ordered.filter((f) => f.level === 'error').length;
|
|
951
1328
|
if (json) {
|
|
952
1329
|
console.log(JSON.stringify(ordered, null, 2));
|
|
@@ -958,4 +1335,43 @@ export async function checkMain(args = []) {
|
|
|
958
1335
|
return errors ? 1 : 0;
|
|
959
1336
|
}
|
|
960
1337
|
|
|
1338
|
+
/**
|
|
1339
|
+
* `--watch`: check, then check again on every save, until Ctrl-C.
|
|
1340
|
+
*
|
|
1341
|
+
* One Chrome for the whole session (persistentRenderer), the screen cleared
|
|
1342
|
+
* and the fresh report printed under a timestamp each time. It runs until
|
|
1343
|
+
* it is interrupted and then exits 0: the findings decide nothing here, a
|
|
1344
|
+
* person reads them. `signals` and `out` are injectable for a test.
|
|
1345
|
+
*/
|
|
1346
|
+
async function watchCheck(src, deck, { bin, wait, notes, signals = process, out = process.stdout, debounceMs = 150 }) {
|
|
1347
|
+
const { watchDeck, persistentRenderer, watchHeader } = await import('./check-watch.mjs');
|
|
1348
|
+
const renderer = bin ? persistentRenderer(bin) : null;
|
|
1349
|
+
const tty = !!out.isTTY;
|
|
1350
|
+
const print = (lines) => out.write(`${tty ? '\x1b[2J\x1b[3J\x1b[H' : ''}${lines.join('\n')}\n`);
|
|
1351
|
+
let stopping = false;
|
|
1352
|
+
const run = async () => {
|
|
1353
|
+
const r = await checkOnce(src, deck, { render: renderer ? (url, w) => renderer.render(url, w) : null, wait });
|
|
1354
|
+
if (stopping) return; // Ctrl-C mid-run: the browser it was using is gone, and so is the reader
|
|
1355
|
+
const dim = (x) => (tty ? `\x1b[2m${x}\x1b[0m` : x);
|
|
1356
|
+
if (!r) { print([dim(watchHeader(basename(src), 0)), '', `${deck} is not there right now; waiting for it to be saved again`]); return; }
|
|
1357
|
+
print([dim(watchHeader(basename(src), r.slides)), ...notes.map(dim), '',
|
|
1358
|
+
...formatFindings(r.findings, { color: tty, slides: r.slides })]);
|
|
1359
|
+
};
|
|
1360
|
+
const watcher = watchDeck({ file: src, run, debounceMs, onError: (e) => out.write(`check: ${e.message ?? e}\n`) });
|
|
1361
|
+
return new Promise((done) => {
|
|
1362
|
+
const stop = async () => {
|
|
1363
|
+
if (stopping) return;
|
|
1364
|
+
stopping = true;
|
|
1365
|
+
signals.off?.('SIGINT', stop);
|
|
1366
|
+
signals.off?.('SIGTERM', stop);
|
|
1367
|
+
watcher.close();
|
|
1368
|
+
await renderer?.close(); // first: a run still rendering fails at once rather than finishing
|
|
1369
|
+
await watcher.settled().catch(() => {});
|
|
1370
|
+
done(0);
|
|
1371
|
+
};
|
|
1372
|
+
signals.once('SIGINT', stop);
|
|
1373
|
+
signals.once('SIGTERM', stop);
|
|
1374
|
+
});
|
|
1375
|
+
}
|
|
1376
|
+
|
|
961
1377
|
if (isMain(import.meta.url)) process.exit(await runMain('check', () => checkMain(process.argv.slice(2))));
|