Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Changelog
## Unreleased
- **Three canvas densities.** `canvas: 'low' | 'medium' | 'high'` in the model, `--canvas` on `create` and `new`. Low is 720×405 with larger type and margins; high is 1280×720 with smaller type and 32px margins. Medium is the default and builds byte-identically. Layouts, templates, the foot band and the word caps all follow the tier.
- **A viewer that blocks scripts no longer shows the deck's markup as text.** With script off by policy the parser keeps the `<noscript>` still as text, and `display:contents` painted it. The deck now says the viewer blocks scripts and how to open it.

- **Two windows no longer lose an edit in the store.** When window B was typing as window A saved, B saved its words on top of A's model, but A's older save could reach localStorage after B's. Both windows looked right and the store held A's model without B's words, so a reload lost them. A CI probe caught this on Firefox in 12 of 180 runs under load and 0 of 60 alone. A window now watches the `storage` event: when the store holds a model it already built on, it writes its newer model back, and it writes the log back when entries are missing. This was the Firefox two-window failure on `main`.
- **`validate --suggest`: the layouts and templates that fit a slide's content (#207).** `node bin/validate.mjs --suggest "three or four numbers with movement"` prints the top five of the 32 library layouts and 115 templates with kind, density and slot or fill keys. `lib/suggest.mjs` scores each by idf-weighted word overlap with its name, its `use` or `note`, and the SKILL.md routing table, which it reads at run time so the two cannot disagree. SKILL.md START HERE names it. Gate: test/suggest.test.mjs (every routing-table row finds its layout in the top three, a template is found by its note, unknown words still answer five, the CLI prints the ranking).
Expand Down
2 changes: 1 addition & 1 deletion SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ Two densities, in `lib/layouts.mjs` (`DENSITY`), so "dense" and "fluffy" build t
| `speaker` | **fluffy** | a presented deck — the speaker carries the rest | supertitle · title · one figure, number or ≤ 3 points · a caption at most | 3 points · 40 words |
| `reading` | **dense** | a leave-behind read without a speaker — the slide carries its own context | supertitle · title · `subtitle` (the claim in one sentence) · the figure or the points · `note` (what to make of it) · `source` · `legend` · footer naming the deck | 8 points · 140 words |
The dense chrome is four optional slots (`DENSE`): `subtitle` (H2 at regular weight, muted, `nowrap`: parity fails a wrap), `note`, `source` and `legend`. **The slide foot is one line:** the engine seats `source` on the footer's baseline at the left margin and `legend` on the same line left of the deck name (`foot: 'left'|'right'`; a row with its own `y` opts out), and `validate` warns on any other text row between the content bottom (`FOOT.y`, 472 on 960×540) and the footer. `note` has no generic seat: a layout with a visual names a caption position under or beside it, the rest drop it, and binding a dropped `note` is an error. At reading density a summary or number slide is capped at 60 words. A reading slide binds at least one; a speaker slide none. **The counting rule:** a *point* is a text row whose slot is not `supertitle/title/subtitle/note/source/legend/caption/number` and role not Supertitle/Title/H1/Caption/Label; the word cap counts every text row, chrome included; over budget `validate` lists what it counted.
**Canvas:** `canvas: 'low'|'medium'|'high'` (default medium) or `--canvas` sets page size: [docs/canvas.md](docs/canvas.md).
## GRAPHICS
Five kinds of picture, one rule each. Colour is always a token; nothing loads from the network.
- **Icons** — `{icon: 'factory', x, y, w: 24, h: 24, color: 'var(--accent)'}`. The set is all of Lucide (ISC), 2,147 names (`node bin/validate.mjs --icons`); `create` inlines the svg and `color` paints it. One icon per point, on the 24 grid (24/32/40 px), centred on its label's first line with an 8px gutter. An icon says what the label says, never a second idea or a filled emoji, and it is decoration: it never counts as the slide's graphic.
Expand Down Expand Up @@ -338,7 +339,6 @@ Four words, and no fifth: `rise` (text — the default), `fade` (quiet chrome),
- **Hand-built logos and rankings.** Three rows per logo with the name's x worked out from its aspect; rects computed into a bar ranking; the same data: URI pasted on nine slides. A `logo` row, `mark:'hbar'`, `deck.assets`.
- **Text-only slides.** Three text rows and no graphic, or an icon standing in for one. `validate` warns; plan the graphic in Step 1, or mark a words slide `textOnly: true`.
- **Monograms for real companies.** A listed company drawn as initials. Rerun `decklet-assets` with `--domain` or supply the file.
- **A PDF nobody asked for.** See Step 6.
- **Hardcoded counters.** `"3 / 9"` typed into a row. The footer master renders the counter.
- **Font pickers / ad-hoc colours.** No per-row font families, no rainbow of hexes. Tokens and roles only; literal hex is for chart series.
- **Walls of text.** More than ~60 Body words on a 16:9 slide, or Body wrapping past 3 lines. Split the slide.
Expand Down
13 changes: 8 additions & 5 deletions bin/create.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node
// decklet create — headless: model.json (+ style.json) → one self-contained deck.html
// usage: node bin/create.mjs --model model.json [--style style.json] --out deck.html
// [--format slides|slides-4x3|story|carousel|carousel-4x5|document-letter|document-a4|document-letter-landscape|document-a4-landscape|poster-a3] [--space 960x540|1600x900] [--title "…"] [--force]
// [--format slides|slides-4x3|story|carousel|carousel-4x5|document-letter|document-a4|document-letter-landscape|document-a4-landscape|poster-a3] [--canvas low|medium|high] [--space 960x540|1600x900] [--title "…"] [--force]
// [--from prev.html] revise an existing deck: keep its id + slide/row ids, replay the human edits it carries
// (human wins, conflicts reported), push its state into the version history
// library: import {create, FORMAT} from './create.mjs'
Expand All @@ -10,7 +10,7 @@ import path from 'node:path';
import {createHash} from 'node:crypto';
import {fileURLToPath} from 'node:url';
import {validate, mergeStyle, fillKpi, FORMAT, resolveCanvas} from './validate.mjs';
import {libraryFor} from '../lib/layouts.mjs';
import {libraryFor, applyCanvas} from '../lib/layouts.mjs';
import {expandCharts} from '../lib/chart.mjs';
import {expandTemplates} from '../lib/templates.mjs';
import {expandIcons} from '../lib/icons.mjs';
Expand Down Expand Up @@ -49,8 +49,9 @@ function inheritIds(deck, prev) {
for (const [s, ps] of pairs) (s.els || []).forEach((r, k) => { const pr = (ps.els || [])[k]; if (!r.id && pr && pr.id && (pr.role || null) === (r.role || null) && !!(pr.line || pr.curve) === !!(r.line || r.curve) && !(s.els || []).some(x => x.id === pr.id)) r.id = pr.id; });
}

export function create(model, {style = null, format, space, title, template, from = null, spell = null} = {}) {
export function create(model, {style = null, format, space, title, template, from = null, spell = null, canvas: tierName} = {}) {
const {$schema, ...rest} = model, deck = structuredClone(rest);
if (tierName) deck.canvas = tierName;
const prevHtml = from ? fs.readFileSync(from, 'utf8') : null, prev = prevHtml ? blockOf(prevHtml, 'DECK') : null;
if (prev) inheritIds(deck, prev);
const fmt = format || deck.format || 'slides';
Expand All @@ -60,6 +61,7 @@ export function create(model, {style = null, format, space, title, template, fro
deck.format = canvas.format; deck.page = canvas.page; deck.w = canvas.w; deck.h = canvas.h;
// style.json: {tokens:{bg,fg,muted,accent,card,line,sel,box}, roles:{…}, pad:{…}} — shared with validate --style so the two never drift
mergeStyle(deck, style);
applyCanvas(deck);
// `group` left the contract in 0.12.0 — a model written against an older skill still builds, minus the dead prop, so no
// deck carries a link the editor no longer honours. validate says so out loud; this only keeps the file clean.
for (const s of deck.slides || []) for (const r of (s && s.els) || []) if (r && r.group != null) delete r.group;
Expand All @@ -74,6 +76,7 @@ export function create(model, {style = null, format, space, title, template, fro
if (!deck.styles || !deck.styles.roles || !Object.keys(deck.styles.roles).length) { // no roles anywhere → inherit the template's neutral scale
const tpl = JSON.parse(html.match(/\/\*DECK\*\/([\s\S]*?)\/\*\/DECK\*\//)[1]);
deck.styles = {...tpl.styles, ...(deck.styles || {}), roles: tpl.styles.roles};
applyCanvas(deck);
}
fillKpi(deck); // the optional Stat2 role, derived from Stat when a kpi tile asks for it and the style has none
expandCharts(deck); // chart rows → the ordinary rows they stand for; the runtime draws no charts
Expand Down Expand Up @@ -106,11 +109,11 @@ export function create(model, {style = null, format, space, title, template, fro
if (isMain(import.meta.url)) {
const a = process.argv.slice(2), o = {};
for (let k = 0; k < a.length; k++) if (a[k].startsWith('--')) o[a[k].slice(2)] = a[k + 1] && !a[k + 1].startsWith('--') ? a[++k] : true;
if (!o.model || !o.out) { console.error('usage: node bin/create.mjs --model model.json [--style style.json] --out deck.html [--format …] [--space WxH] [--title …] [--from prev.html] [--force]'); process.exit(2); }
if (!o.model || !o.out) { console.error('usage: node bin/create.mjs --model model.json [--style style.json] --out deck.html [--format …] [--canvas low|medium|high] [--space WxH] [--title …] [--from prev.html] [--force]'); process.exit(2); }
const model = JSON.parse(fs.readFileSync(o.model, 'utf8'));
const style = o.style ? JSON.parse(fs.readFileSync(o.style, 'utf8')) : null;
const spell = await loadChecker(model.lang || 'en'); // optional: nspell + dictionary-en; absent → no flags, the browser's own checker only
const {html, deck, hash, migrate} = create(model, {style, format: o.format, space: o.space, title: o.title, from: o.from || null, spell});
const {html, deck, hash, migrate} = create(model, {style, canvas: o.canvas, format: o.format, space: o.space, title: o.title, from: o.from || null, spell});
const flagged = spell ? spellFlags(deck, spell) : null;
if (flagged === null) console.error('spell: nspell + dictionary-en not installed — no words flagged (npm i -D nspell dictionary-en)');
else if (flagged.length) {
Expand Down
22 changes: 13 additions & 9 deletions bin/new.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
// the study's best decks climbed. What comes out passes `validate --strict` and `verify --strict` untouched, so the
// author's first loop is replacing placeholder copy rather than debugging geometry.
//
// usage: node bin/new.mjs --out model.json [--slides 8] [--density reading|speaker] [--style <kit>] [--space WxH]
// usage: node bin/new.mjs --out model.json [--slides 8] [--density reading|speaker] [--canvas low|medium|high] [--style <kit>] [--space WxH]
import {CANVAS, mapRow} from '../lib/layouts.mjs';
import fs from 'node:fs';
import path from 'node:path';
import {fileURLToPath} from 'node:url';
Expand Down Expand Up @@ -136,16 +137,18 @@ export function run(n, density) {
return [COVER(), ...take.map(r => r.build(density)), CLOSE()];
}

export function newModel({slides = 8, density = 'reading', space = null} = {}) {
const [w, h] = space ? space.split('x').map(Number) : [960, 540];
export function newModel({slides = 8, density = 'reading', space = null, canvas = null} = {}) {
const tier = canvas && canvas !== 'medium' ? CANVAS[canvas] : null;
const [w, h] = tier ? [tier.w, tier.h] : space ? space.split('x').map(Number) : [960, 540];
const free = r => (tier && r.slot == null ? mapRow(r, tier) : r);
return {
title: `${CO} — ${MARK} deck`,
format: 'slides', w, h, density,
styles: {margin: 60},
format: 'slides', w, h, density, ...(canvas ? {canvas} : {}),
styles: {margin: tier ? tier.margin : 60},
// Master discipline (SKILL.md): one master row carries footer:1 and the engine draws the page counter with it.
// Right-anchored with w:'auto' is the anchoring that passes --strict; never type "3 / 9" into a row.
master: [{id: 'foot', footer: 1, right: 60, y: h - 34, w: 'auto', role: 'Label', nowrap: 1, text: `${CO} · ${MARK}`}],
slides: run(slides, density),
master: [{id: 'foot', footer: 1, right: tier ? tier.margin : 60, y: tier ? tier.footer : h - 34, w: 'auto', role: 'Label', nowrap: 1, text: `${CO} · ${MARK}`}],
slides: run(slides, density).map(s => ({...s, els: (s.els || []).map(free)})),
};
}

Expand Down Expand Up @@ -174,7 +177,7 @@ if (isMain(import.meta.url)) {
const a = process.argv.slice(2), o = {};
for (let k = 0; k < a.length; k++) if (a[k].startsWith('--')) o[a[k].slice(2)] = a[k + 1] && !a[k + 1].startsWith('--') ? a[++k] : true;
const die = m => { console.error(m); process.exit(2); };
if (!o.out) die('usage: node bin/new.mjs --out model.json [--slides 8] [--density reading|speaker] [--style <kit>] [--space WxH]');
if (!o.out) die('usage: node bin/new.mjs --out model.json [--slides 8] [--density reading|speaker] [--canvas low|medium|high] [--style <kit>] [--space WxH]');
const slides = o.slides == null ? 8 : Number(o.slides);
if (!Number.isInteger(slides) || slides < MIN || slides > MAX) die(`--slides must be ${MIN}..${MAX} — the shape ladder has ${MAX} rungs, and a deck that repeats a layout is worse than a shorter one`);
const density = o.density == null ? 'reading' : String(o.density);
Expand All @@ -183,7 +186,8 @@ if (isMain(import.meta.url)) {
if (o.space && !/^\d+x\d+$/.test(o.space)) die('--space must be WxH, e.g. 960x540');

const dir = path.dirname(path.resolve(o.out));
const model = newModel({slides, density, space: o.space || null});
if (o.canvas && !CANVAS[o.canvas]) die(`--canvas must be ${Object.keys(CANVAS).join('|')}`);
const model = newModel({slides, density, space: o.space || null, canvas: o.canvas || null});
const $schema = path.relative(dir, fileURLToPath(new URL('../schemas/model.schema.json', import.meta.url))).split(path.sep).join('/');
fs.writeFileSync(o.out, JSON.stringify({$schema, ...model}, null, 2) + '\n');
const man = path.join(dir, 'MANIFEST.md');
Expand Down
Loading
Loading