@netnodeag/kraftwerk 0.82.0 → 0.83.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.
Files changed (77) hide show
  1. package/README.md +175 -0
  2. package/dist/cli/init.js +1 -0
  3. package/dist/cli/kraftwerk.js +3 -0
  4. package/dist/cli/presentations.d.ts +2 -0
  5. package/dist/cli/presentations.js +261 -0
  6. package/dist/client/routes.d.ts +18 -0
  7. package/dist/client/routes.js +18 -0
  8. package/dist/config.d.ts +16 -0
  9. package/dist/config.js +10 -2
  10. package/dist/core/boards.d.ts +14 -1
  11. package/dist/core/boards.js +34 -1
  12. package/dist/core/chat/context.js +11 -2
  13. package/dist/core/git.js +3 -1
  14. package/dist/core/presentations/browser.d.ts +43 -0
  15. package/dist/core/presentations/browser.js +53 -0
  16. package/dist/core/presentations/builtin.d.ts +3 -0
  17. package/dist/core/presentations/builtin.js +142 -0
  18. package/dist/core/presentations/chart.d.ts +34 -0
  19. package/dist/core/presentations/chart.js +159 -0
  20. package/dist/core/presentations/deck.d.ts +63 -0
  21. package/dist/core/presentations/deck.js +198 -0
  22. package/dist/core/presentations/export.d.ts +21 -0
  23. package/dist/core/presentations/export.js +75 -0
  24. package/dist/core/presentations/html.d.ts +135 -0
  25. package/dist/core/presentations/html.js +389 -0
  26. package/dist/core/presentations/index.d.ts +252 -0
  27. package/dist/core/presentations/index.js +753 -0
  28. package/dist/core/presentations/layout.d.ts +47 -0
  29. package/dist/core/presentations/layout.js +147 -0
  30. package/dist/core/presentations/markdown.d.ts +49 -0
  31. package/dist/core/presentations/markdown.js +158 -0
  32. package/dist/core/presentations/merge.d.ts +26 -0
  33. package/dist/core/presentations/merge.js +28 -0
  34. package/dist/core/presentations/presence.d.ts +31 -0
  35. package/dist/core/presentations/presence.js +131 -0
  36. package/dist/core/presentations/render.d.ts +33 -0
  37. package/dist/core/presentations/render.js +318 -0
  38. package/dist/core/presentations/slots.d.ts +33 -0
  39. package/dist/core/presentations/slots.js +114 -0
  40. package/dist/core/presentations/template.d.ts +253 -0
  41. package/dist/core/presentations/template.js +141 -0
  42. package/dist/core/presentations/versions.d.ts +30 -0
  43. package/dist/core/presentations/versions.js +75 -0
  44. package/dist/core/refs.d.ts +1 -1
  45. package/dist/core/refs.js +9 -1
  46. package/dist/core/search.d.ts +10 -0
  47. package/dist/core/search.js +6 -0
  48. package/dist/core/settings.d.ts +2 -0
  49. package/dist/core/settings.js +12 -1
  50. package/dist/core/trash.d.ts +1 -1
  51. package/dist/server/api/index.d.ts +62 -1
  52. package/dist/server/api/index.js +2 -0
  53. package/dist/server/api/presentations.d.ts +66 -0
  54. package/dist/server/api/presentations.js +185 -0
  55. package/dist/server/api/socket.js +24 -1
  56. package/dist/server/api/workspace.d.ts +5 -0
  57. package/dist/server/api/workspace.js +2 -0
  58. package/package.json +6 -2
  59. package/schema/kraftwerk.schema.json +18 -0
  60. package/web/dist/assets/{dist-DvkrCSGL.js → dist-5-ibIscm.js} +1 -1
  61. package/web/dist/assets/{dist-Bie1ebP9.js → dist-5lgY5B-M.js} +1 -1
  62. package/web/dist/assets/{dist-BuwdjX6z.js → dist-BJaPgnhj.js} +1 -1
  63. package/web/dist/assets/{dist-C_rJjRj7.js → dist-Bar1_NBq.js} +1 -1
  64. package/web/dist/assets/{dist-DtUB2Uu2.js → dist-BxCxboU8.js} +1 -1
  65. package/web/dist/assets/dist-CDitSY16.js +1 -0
  66. package/web/dist/assets/{dist-C16bXf8c.js → dist-CRXT8IL6.js} +1 -1
  67. package/web/dist/assets/{dist-CH73jsgO.js → dist-CXRjiHpl.js} +1 -1
  68. package/web/dist/assets/{dist-BBFUIftm.js → dist-CpnB7MfK.js} +1 -1
  69. package/web/dist/assets/{dist-C0ve4Tka.js → dist-D1VK1YdB.js} +1 -1
  70. package/web/dist/assets/{dist-CDUZdAAS.js → dist-D52LvyO8.js} +1 -1
  71. package/web/dist/assets/{editor-3z92i0tV.js → editor-HCNTXWWs.js} +3 -3
  72. package/web/dist/assets/index-Dnlu16AL.css +2 -0
  73. package/web/dist/assets/index-kwWnQOhD.js +473 -0
  74. package/web/dist/index.html +2 -2
  75. package/web/dist/assets/dist-DYICNp09.js +0 -1
  76. package/web/dist/assets/index-DRhNELK_.js +0 -232
  77. package/web/dist/assets/index-unGEux3Y.css +0 -2
@@ -7,7 +7,7 @@ import { getOutputDir, workspaceRoot } from "./context.js";
7
7
  import { mergeDays } from "./journal.js";
8
8
  import { newestMtime } from "./mtime.js";
9
9
  import { openProjects, safeProjectSlug } from "./projects.js";
10
- import { findRefs } from "./refs.js";
10
+ import { findRefs, resolveTokens } from "./refs.js";
11
11
  import { SLUG_RE, slugify } from "./slug.js";
12
12
  import { moveToTrash } from "./trash.js";
13
13
  /**
@@ -917,6 +917,38 @@ export async function boardsContext(project, actor, agent) {
917
917
  return blocks.join("\n\n");
918
918
  }
919
919
  /** The block a session gets when it was opened for one task: the task, its files and its whole log. */
920
+ /** The task's refs for its agent: each target with its label, a deck with its folder and how to open it. */
921
+ async function linkedBlock(refs) {
922
+ const parsed = refs.flatMap((r) => findRefs(r)).map((r) => ({ kind: r.kind, slug: r.slug }));
923
+ if (!parsed.length)
924
+ return "";
925
+ const resolved = await resolveTokens(parsed).catch(() => []);
926
+ const { listAllDecks, presentationCliScope } = await import("./presentations/index.js");
927
+ const decks = resolved.some((r) => r.kind === "presentations") ? await listAllDecks().catch(() => []) : [];
928
+ const lines = resolved.map((r) => {
929
+ if (!r.found)
930
+ return `- ${r.token} — not found (renamed or removed?)`;
931
+ const deck = r.kind === "presentations" ? decks.find((d) => d.name === r.slug) : undefined;
932
+ return deck
933
+ ? `- ${r.token} — "${deck.title}"${deck.project ? ` in project ${deck.project}` : ""}, ${deck.slides} slides, folder ${deck.path} (\`npx kraftwerk presentations show ${deck.name}${deck.project ? ` ${presentationCliScope({ name: deck.name, project: deck.project })}` : ""}\`)`
934
+ : `- ${r.token}${r.label ? ` — ${r.label}` : ""}`;
935
+ });
936
+ return `\n### Linked\n${lines.join("\n")}\n`;
937
+ }
938
+ /** Every task whose refs name the token (presentation:town-hall), across the workspace's boards. */
939
+ export async function tasksReferencing(token) {
940
+ const out = [];
941
+ for (const b of await listAllBoards().catch(() => [])) {
942
+ const detail = await getBoard(b).catch(() => null);
943
+ for (const t of detail?.items ?? []) {
944
+ if (!t.refs.includes(token))
945
+ continue;
946
+ const base = b.project ? `/projects/${b.project}/boards/${b.board}` : `/boards/${b.board}`;
947
+ out.push({ ref: t.ref, number: t.number, title: t.title, status: t.status, ...(t.assignee ? { assignee: t.assignee } : {}), board: b.board, ...(b.project ? { project: b.project } : {}), href: `${base}/${t.slug}` });
948
+ }
949
+ }
950
+ return out;
951
+ }
920
952
  export async function taskContext(reference) {
921
953
  const t = await findTask(reference);
922
954
  if (!t)
@@ -928,6 +960,7 @@ export async function taskContext(reference) {
928
960
  `Board ${boardKey(ref)}${board ? ` (columns: ${cols})` : ""}; status ${t.status}${t.assignee ? `, assigned to ${t.assignee}` : ""}${t.due ? `, due ${t.due}` : ""}. Folder: ${t.path}\n` +
929
961
  (board?.notes.trim() ? `Board rules: ${board.notes.trim()}\n` : "") +
930
962
  `\n### task.md\n${t.notes.trim() || "(no description — ask the user what done looks like and write it with `tasks set <n> --notes-file`)"}\n` +
963
+ (await linkedBlock(t.refs)) +
931
964
  `\n### Files\n${t.fileList.length ? t.fileList.map((f) => `- ${f}`).join("\n") : "(none yet)"}\n` +
932
965
  `\n### Log (newest first)\n${t.log.trim() || "(empty)"}\n\n` +
933
966
  `Work it through the CLI (${cliBoard(ref)}, the number ${t.number} names the task): \`npx kraftwerk tasks move ${t.number} progress ${cliBoard(ref)}\` when you start, ` +
@@ -9,6 +9,7 @@ import { listVibeables, vibeableStatus, VIBEABLE_CONFIG_FILE } from "../vibeable
9
9
  import { projectContext } from "../projects.js";
10
10
  import { entitiesContext } from "../entities.js";
11
11
  import { boardsContext, taskContext } from "../boards.js";
12
+ import { presentationsContext } from "../presentations/index.js";
12
13
  import { unattendedTimeoutLabel } from "./permissions.js";
13
14
  import { getChannel } from "../channels.js";
14
15
  import { JOURNAL_FILE, journalExcerpt, readJournal } from "../journal.js";
@@ -396,7 +397,7 @@ export async function scopeContext(meta, seat) {
396
397
  const agent = seat.harness;
397
398
  // The repositories block reads every clone from git, so it runs alongside
398
399
  // the rest instead of adding its spawns to the first prompt's latency.
399
- const [base, repos, vibe, skills, channel, project, entities, boards] = await Promise.all([
400
+ const [base, repos, vibe, skills, channel, project, entities, boards, decks] = await Promise.all([
400
401
  baseScopeContext(scope, agent),
401
402
  scope.kind === "agent" || scope.kind === "kraftwerk" ? reposContext() : Promise.resolve(""),
402
403
  meta.vibeable ? vibeableContext(meta.vibeable, meta.cwd) : Promise.resolve(""),
@@ -414,13 +415,21 @@ export async function scopeContext(meta, seat) {
414
415
  .then((xs) => xs.filter(Boolean).join("\n\n"))
415
416
  .catch(() => "")
416
417
  : Promise.resolve(""),
418
+ // Presentations: a project chat sees the project's decks; an agent the workspace's, plus its project's when filed under one.
419
+ scope.kind === "project"
420
+ ? presentationsContext(scope.slug).catch(() => "")
421
+ : scope.kind === "agent"
422
+ ? Promise.all([presentationsContext(undefined), meta.project ? presentationsContext(meta.project) : Promise.resolve("")])
423
+ .then((xs) => xs.filter(Boolean).join("\n\n"))
424
+ .catch(() => "")
425
+ : Promise.resolve(""),
417
426
  ]);
418
427
  // Every session has a scratch folder of its own (core/temp.ts), named by its absolute path: a run chat or a
419
428
  // vibeable session works in another folder than the workspace root. The block comes after the files blocks it refers to.
420
429
  const temp = await sessionTemp(meta.id).catch(() => null);
421
430
  // "Work on this" from a task page: the chat is tagged with the task (meta.task) and reads it like the agent's own task session would.
422
431
  const task = meta.task && !(scope.kind === "agent" && scope.task === meta.task) ? await taskContext(meta.task).catch(() => "") : "";
423
- return [base, channel, project, boards, task, repos, entities, vibe, temp ? tempContext(temp.abs) : "", RENDERING_BLOCK, skillsBlock(skills)].filter(Boolean).join("\n\n");
432
+ return [base, channel, project, boards, task, decks, repos, entities, vibe, temp ? tempContext(temp.abs) : "", RENDERING_BLOCK, skillsBlock(skills)].filter(Boolean).join("\n\n");
424
433
  }
425
434
  /** The channel block a member agent gets once per process: who is here, how turns work, how to hand over. */
426
435
  async function channelContext(slug, self) {
package/dist/core/git.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { spawn } from "node:child_process";
2
2
  import { realpathSync } from "node:fs";
3
3
  import path from "node:path";
4
- import { boardsRootFor, ENTITY_KINDS, entitiesRootFor, projectsRootFor, reposRootFor, resolveWorkspace, vibeablesRootFor, isSafeGitName } from "../config.js";
4
+ import { boardsRootFor, presentationsRootFor, ENTITY_KINDS, entitiesRootFor, projectsRootFor, reposRootFor, resolveWorkspace, vibeablesRootFor, isSafeGitName } from "../config.js";
5
5
  import { ENV_FILE } from "../runner/docker.js";
6
6
  import { getOutputDir, workspaceRoot } from "./context.js";
7
7
  import { perWorkspace, workspaceOpen } from "./workspace.js";
@@ -243,6 +243,8 @@ function scopeFor({ project, repoRoot }) {
243
243
  ...ENTITY_KINDS.map((kind) => entitiesRootFor(project, kind)),
244
244
  // Workspace boards: tasks, logs and their files (project boards sit inside the projects root).
245
245
  boardsRootFor(project),
246
+ // Workspace presentations: decks, their assets and templates (project decks sit inside the projects root).
247
+ presentationsRootFor(project),
246
248
  // Workspace files: shared material, versioned (files over 25 MB ignore themselves, see files.ts).
247
249
  path.resolve(project.root, "kraftwerk-data/files"),
248
250
  project.configPath,
@@ -0,0 +1,43 @@
1
+ /**
2
+ * A headless browser for the exports that need the HTML drawn: slide PNGs
3
+ * (what an agent looks at), the PDF, and the HTML pieces of a PowerPoint
4
+ * file. playwright-core drives it — its own downloaded Chromium when the
5
+ * machine has one (`npx playwright install chromium`), else the installed
6
+ * Google Chrome. Without either, callers fall back to the PowerPoint
7
+ * model's raster (core/presentations/export.ts) and say so.
8
+ */
9
+ type Page = {
10
+ setViewportSize(s: {
11
+ width: number;
12
+ height: number;
13
+ }): Promise<void>;
14
+ goto(url: string, o?: {
15
+ waitUntil?: "load" | "networkidle";
16
+ }): Promise<unknown>;
17
+ emulateMedia(o: {
18
+ media: "print" | "screen";
19
+ }): Promise<void>;
20
+ locator(sel: string): {
21
+ nth(i: number): {
22
+ screenshot(o?: {
23
+ type?: "png";
24
+ omitBackground?: boolean;
25
+ }): Promise<Buffer>;
26
+ };
27
+ count(): Promise<number>;
28
+ };
29
+ pdf(o: Record<string, unknown>): Promise<Buffer>;
30
+ evaluate<T>(fn: () => T | Promise<T>): Promise<T>;
31
+ };
32
+ /** Why the last launch failed (for the fallback's warning). */
33
+ export declare const browserProblem: () => string;
34
+ /**
35
+ * Open a standalone deck HTML (from html.ts) in print layout — every slide
36
+ * stacked at its stage size, no scaling — and hand the page over. Null
37
+ * when no browser can be started.
38
+ */
39
+ export declare function withDeckPage<T>(html: string, size: {
40
+ width: number;
41
+ height: number;
42
+ }, fn: (page: Page) => Promise<T>): Promise<T | null>;
43
+ export {};
@@ -0,0 +1,53 @@
1
+ import { promises as fs } from "node:fs";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+ import { pathToFileURL } from "node:url";
5
+ let reason = "";
6
+ /** Why the last launch failed (for the fallback's warning). */
7
+ export const browserProblem = () => reason;
8
+ async function launch() {
9
+ let pw;
10
+ try {
11
+ pw = (await import("playwright-core"));
12
+ }
13
+ catch {
14
+ reason = "playwright-core is not installed";
15
+ return null;
16
+ }
17
+ const errors = [];
18
+ for (const opts of [{}, { channel: "chrome" }, { channel: "msedge" }]) {
19
+ try {
20
+ return await pw.chromium.launch({ headless: true, ...opts });
21
+ }
22
+ catch (err) {
23
+ errors.push(err.message.split("\n")[0]);
24
+ }
25
+ }
26
+ reason = `no browser to render with (run \`npx playwright install chromium\` or install Google Chrome): ${errors[0] ?? ""}`;
27
+ return null;
28
+ }
29
+ /**
30
+ * Open a standalone deck HTML (from html.ts) in print layout — every slide
31
+ * stacked at its stage size, no scaling — and hand the page over. Null
32
+ * when no browser can be started.
33
+ */
34
+ export async function withDeckPage(html, size, fn) {
35
+ const browser = await launch();
36
+ if (!browser)
37
+ return null;
38
+ const dir = await fs.mkdtemp(path.join(os.tmpdir(), "kraftwerk-deck-"));
39
+ const file = path.join(dir, "deck.html");
40
+ try {
41
+ await fs.writeFile(file, html);
42
+ const page = await browser.newPage();
43
+ await page.setViewportSize(size);
44
+ await page.emulateMedia({ media: "print" });
45
+ await page.goto(pathToFileURL(file).href, { waitUntil: "load" });
46
+ await page.evaluate(() => document.fonts.ready.then(() => true));
47
+ return await fn(page);
48
+ }
49
+ finally {
50
+ await browser.close().catch(() => { });
51
+ await fs.rm(dir, { recursive: true, force: true }).catch(() => { });
52
+ }
53
+ }
@@ -0,0 +1,3 @@
1
+ import type { Template } from "./template.js";
2
+ export declare const DEFAULT_CSS = "/* kraftwerk default theme: the slides' look. Scoped to the slide; every class here can be used in a slot's HTML. */\n.eyebrow { text-transform: uppercase; letter-spacing: 0.09em; font-weight: 600; }\n.statement { letter-spacing: -0.02em; line-height: 1.15; }\n.muted { color: var(--c-muted); }\n.accent { color: var(--c-accent); }\n.small { font-size: 0.8em; }\n\n.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 0.9em; }\n.card { background: var(--c-surface); border: 1px solid var(--c-line); border-radius: 0.5em; padding: 0.9em 1em; }\n.card h3 { font-size: 1em; margin: 0 0 0.3em; }\n.card p { color: var(--c-muted); font-size: 0.82em; line-height: 1.35; }\n.card .num { display: block; font-size: 1.6em; font-weight: 700; color: var(--c-accent); line-height: 1; margin-bottom: 0.35em; letter-spacing: -0.02em; }\n\n.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 1.2em; }\n.kpi { border-top: 3px solid var(--c-accent); padding-top: 0.5em; }\n.kpi strong { display: block; font-family: var(--font-heading); font-size: 2.4em; line-height: 1; letter-spacing: -0.03em; }\n.kpi span { display: block; margin-top: 0.35em; color: var(--c-muted); font-size: 0.8em; }\n\n.flow { display: flex; align-items: stretch; gap: 0.6em; }\n.flow .arrow { align-self: center; color: var(--c-muted); font-size: 1.3em; }\n.box { flex: 1; border-radius: 0.5em; padding: 0.8em 0.9em; font-weight: 600; display: flex; flex-direction: column; justify-content: center; font-size: 0.9em; }\n.box small { display: block; font-weight: 400; color: var(--c-muted); font-size: 0.8em; margin-top: 0.25em; }\n.box.ghost { border: 1px dashed #c3c2b7; color: var(--c-muted); }\n.box.solid { border: 1px solid var(--c-line); background: var(--c-surface); }\n.box.accent { border: 1px solid var(--c-accent); background: color-mix(in srgb, var(--c-accent) 10%, transparent); }\n\n.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 1.6em; }\n.cols h3 { font-size: 0.75em; text-transform: uppercase; letter-spacing: 0.08em; color: var(--c-accent); margin-bottom: 0.4em; }\n.cols p { font-size: 0.9em; }\n\n.timeline { list-style: none; padding: 0; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 0.8em; border-top: 2px solid var(--c-line); }\n.timeline li { position: relative; padding-top: 0.9em; margin: 0; }\n.timeline li::before { content: \"\"; position: absolute; top: -0.42em; left: 0; width: 0.7em; height: 0.7em; border-radius: 50%; background: var(--c-accent); }\n.timeline b { display: block; color: var(--c-accent); }\n.timeline span { display: block; font-size: 0.82em; color: var(--c-muted); margin-top: 0.2em; }\n\n.callout { border-left: 4px solid var(--c-accent); background: color-mix(in srgb, var(--c-accent) 8%, transparent); padding: 0.7em 1em; border-radius: 0 0.4em 0.4em 0; }\n.pill { display: inline-block; border: 1px solid var(--c-line); border-radius: 999px; padding: 0.15em 0.65em; font-size: 0.75em; color: var(--c-muted); }\n.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2em; }\n.compare > div { border-radius: 0.5em; padding: 0.9em 1em; background: var(--c-surface); border: 1px solid var(--c-line); }\n.compare > div:last-child { border-color: var(--c-accent); }\n.compare h3 { font-size: 0.75em; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 0.5em; }\n\n/* The slide number, bottom right, on every slide but the title and section slides. */\n&[data-nn]:not(.layout-title):not(.layout-section)::after { content: attr(data-nn); position: absolute; right: 72px; bottom: 30px; font-size: 18px; color: var(--c-muted); font-variant-numeric: tabular-nums; }\n";
3
+ export declare const DEFAULT_TEMPLATE: Template;
@@ -0,0 +1,142 @@
1
+ /**
2
+ * The built-in template: a calm, light look (warm page, ink, one accent,
3
+ * hairlines) with ten layouts on a 16:9 canvas, the theme CSS that styles
4
+ * the HTML slides, and snippets for the editor's insert menu. Workspace
5
+ * templates copy its shape (`kraftwerk presentations templates init`).
6
+ */
7
+ const slot = (kind, x, y, w, h, more = {}) => ({ kind, x, y, w, h, ...more });
8
+ /** The head of a content slide: the title, a small label at the right, a hairline under both. */
9
+ const head = () => ({
10
+ slots: {
11
+ title: slot("text", 0.44, 0.28, 7.3, 0.8, { size: 24, bold: true, font: "heading", color: "text", valign: "bottom", placeholder: "Title" }),
12
+ eyebrow: slot("text", 7.74, 0.28, 1.82, 0.8, { size: 9, color: "muted", align: "right", valign: "bottom", class: "eyebrow", placeholder: "Label" }),
13
+ },
14
+ shapes: [{ kind: "rect", x: 0.54, y: 1.12, w: 8.92, h: 0.012, fill: "line" }],
15
+ });
16
+ const withHead = (description, slots, extra = {}) => {
17
+ const h = head();
18
+ return { description, shapes: h.shapes, slots: { ...h.slots, ...slots }, ...extra };
19
+ };
20
+ export const DEFAULT_CSS = `/* kraftwerk default theme: the slides' look. Scoped to the slide; every class here can be used in a slot's HTML. */
21
+ .eyebrow { text-transform: uppercase; letter-spacing: 0.09em; font-weight: 600; }
22
+ .statement { letter-spacing: -0.02em; line-height: 1.15; }
23
+ .muted { color: var(--c-muted); }
24
+ .accent { color: var(--c-accent); }
25
+ .small { font-size: 0.8em; }
26
+
27
+ .cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 0.9em; }
28
+ .card { background: var(--c-surface); border: 1px solid var(--c-line); border-radius: 0.5em; padding: 0.9em 1em; }
29
+ .card h3 { font-size: 1em; margin: 0 0 0.3em; }
30
+ .card p { color: var(--c-muted); font-size: 0.82em; line-height: 1.35; }
31
+ .card .num { display: block; font-size: 1.6em; font-weight: 700; color: var(--c-accent); line-height: 1; margin-bottom: 0.35em; letter-spacing: -0.02em; }
32
+
33
+ .kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 1.2em; }
34
+ .kpi { border-top: 3px solid var(--c-accent); padding-top: 0.5em; }
35
+ .kpi strong { display: block; font-family: var(--font-heading); font-size: 2.4em; line-height: 1; letter-spacing: -0.03em; }
36
+ .kpi span { display: block; margin-top: 0.35em; color: var(--c-muted); font-size: 0.8em; }
37
+
38
+ .flow { display: flex; align-items: stretch; gap: 0.6em; }
39
+ .flow .arrow { align-self: center; color: var(--c-muted); font-size: 1.3em; }
40
+ .box { flex: 1; border-radius: 0.5em; padding: 0.8em 0.9em; font-weight: 600; display: flex; flex-direction: column; justify-content: center; font-size: 0.9em; }
41
+ .box small { display: block; font-weight: 400; color: var(--c-muted); font-size: 0.8em; margin-top: 0.25em; }
42
+ .box.ghost { border: 1px dashed #c3c2b7; color: var(--c-muted); }
43
+ .box.solid { border: 1px solid var(--c-line); background: var(--c-surface); }
44
+ .box.accent { border: 1px solid var(--c-accent); background: color-mix(in srgb, var(--c-accent) 10%, transparent); }
45
+
46
+ .cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 1.6em; }
47
+ .cols h3 { font-size: 0.75em; text-transform: uppercase; letter-spacing: 0.08em; color: var(--c-accent); margin-bottom: 0.4em; }
48
+ .cols p { font-size: 0.9em; }
49
+
50
+ .timeline { list-style: none; padding: 0; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 0.8em; border-top: 2px solid var(--c-line); }
51
+ .timeline li { position: relative; padding-top: 0.9em; margin: 0; }
52
+ .timeline li::before { content: ""; position: absolute; top: -0.42em; left: 0; width: 0.7em; height: 0.7em; border-radius: 50%; background: var(--c-accent); }
53
+ .timeline b { display: block; color: var(--c-accent); }
54
+ .timeline span { display: block; font-size: 0.82em; color: var(--c-muted); margin-top: 0.2em; }
55
+
56
+ .callout { border-left: 4px solid var(--c-accent); background: color-mix(in srgb, var(--c-accent) 8%, transparent); padding: 0.7em 1em; border-radius: 0 0.4em 0.4em 0; }
57
+ .pill { display: inline-block; border: 1px solid var(--c-line); border-radius: 999px; padding: 0.15em 0.65em; font-size: 0.75em; color: var(--c-muted); }
58
+ .compare { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2em; }
59
+ .compare > div { border-radius: 0.5em; padding: 0.9em 1em; background: var(--c-surface); border: 1px solid var(--c-line); }
60
+ .compare > div:last-child { border-color: var(--c-accent); }
61
+ .compare h3 { font-size: 0.75em; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 0.5em; }
62
+
63
+ /* The slide number, bottom right, on every slide but the title and section slides. */
64
+ &[data-nn]:not(.layout-title):not(.layout-section)::after { content: attr(data-nn); position: absolute; right: 72px; bottom: 30px; font-size: 18px; color: var(--c-muted); font-variant-numeric: tabular-nums; }
65
+ `;
66
+ export const DEFAULT_TEMPLATE = {
67
+ slug: "default",
68
+ name: "Default",
69
+ builtin: true,
70
+ size: "16:9",
71
+ fonts: { heading: "Helvetica Neue", body: "Helvetica Neue" },
72
+ colors: { background: "#F9F9F7", surface: "#FFFFFF", text: "#161310", muted: "#6F6D67", accent: "#0284C7", onAccent: "#FFFFFF", line: "#E1E0D9" },
73
+ default: "content",
74
+ cssText: DEFAULT_CSS,
75
+ layouts: {
76
+ title: {
77
+ description: "Opening slide: a big title with a line above and a footer",
78
+ shapes: [{ kind: "rect", x: 0.54, y: 4.72, w: 8.92, h: 0.012, fill: "line" }],
79
+ slots: {
80
+ kicker: slot("text", 0.44, 1.45, 9.12, 0.5, { size: 13, color: "muted", placeholder: "What this is about" }),
81
+ title: slot("text", 0.44, 1.95, 9.12, 1.75, { size: 50, bold: true, font: "heading", color: "text", valign: "top", required: true, class: "statement", placeholder: "Title" }),
82
+ subtitle: slot("text", 0.44, 3.7, 9.12, 0.6, { size: 16, color: "muted", placeholder: "Subtitle" }),
83
+ foot: slot("text", 0.44, 4.8, 9.12, 0.5, { size: 10, color: "muted", placeholder: "Who · where · when" }),
84
+ },
85
+ },
86
+ section: {
87
+ description: "Divider between parts, on dark",
88
+ background: "text",
89
+ shapes: [{ kind: "rect", x: 0.54, y: 2.1, w: 0.9, h: 0.05, fill: "accent" }],
90
+ slots: {
91
+ eyebrow: slot("text", 0.44, 1.6, 9.12, 0.45, { size: 11, color: "accent", class: "eyebrow", placeholder: "Part 1" }),
92
+ title: slot("text", 0.44, 2.3, 9.12, 1.4, { size: 40, bold: true, font: "heading", color: "background", valign: "top", required: true, class: "statement", placeholder: "Section title" }),
93
+ },
94
+ },
95
+ content: withHead("Title and a body of text, lists or HTML", {
96
+ body: slot("markdown", 0.44, 1.32, 9.12, 3.95, { size: 15, color: "text", required: true, placeholder: "The slide's text, lists or a table" }),
97
+ }),
98
+ statement: {
99
+ description: "One sentence that carries the slide",
100
+ shapes: [],
101
+ slots: {
102
+ eyebrow: slot("text", 0.44, 1.2, 9.12, 0.45, { size: 11, color: "accent", class: "eyebrow", placeholder: "In one sentence" }),
103
+ title: slot("text", 0.44, 1.7, 8.4, 2.6, { size: 34, bold: true, font: "heading", color: "text", valign: "top", required: true, class: "statement", placeholder: "The statement" }),
104
+ note: slot("markdown", 0.44, 4.4, 9.12, 0.85, { size: 13, color: "muted", placeholder: "Why it matters" }),
105
+ },
106
+ },
107
+ "two-column": withHead("Title with a left and a right column", {
108
+ left: slot("markdown", 0.44, 1.32, 4.46, 3.95, { size: 14, color: "text", required: true }),
109
+ right: slot("markdown", 5.1, 1.32, 4.46, 3.95, { size: 14, color: "text", required: true }),
110
+ }),
111
+ image: withHead("Title, text on the left, a picture on the right", {
112
+ body: slot("markdown", 0.44, 1.32, 4.1, 3.95, { size: 14, color: "text" }),
113
+ image: slot("image", 4.74, 1.32, 4.82, 3.95, { required: true, placeholder: "![caption](assets/picture.png)" }),
114
+ }),
115
+ chart: withHead("Title, a chart, a caption below it", {
116
+ chart: slot("chart", 0.44, 1.32, 9.12, 3.45, { size: 11, required: true, placeholder: "```chart\nkind: column\ncategories: [Q1, Q2]\nseries:\n - name: Revenue\n values: [120, 180]\n```" }),
117
+ caption: slot("text", 0.44, 4.82, 9.12, 0.45, { size: 10, color: "muted", placeholder: "Source or takeaway" }),
118
+ }),
119
+ table: withHead("Title and a table", {
120
+ table: slot("table", 0.44, 1.32, 9.12, 3.95, { size: 13, color: "text", required: true, placeholder: "| Item | Value |\n|---|---|\n| Pages | 120 |" }),
121
+ }),
122
+ quote: {
123
+ description: "A quotation and who said it",
124
+ background: "surface",
125
+ shapes: [{ kind: "rect", x: 0.7, y: 1.45, w: 0.06, h: 2.4, fill: "accent" }],
126
+ slots: {
127
+ quote: slot("text", 1.0, 1.4, 8.2, 2.1, { size: 28, italic: true, font: "heading", color: "text", valign: "middle", required: true, class: "statement", placeholder: "The quote" }),
128
+ attribution: slot("text", 1.0, 3.55, 8.2, 0.5, { size: 13, color: "muted", placeholder: "Who said it" }),
129
+ },
130
+ },
131
+ blank: { description: "The whole canvas as one body (HTML welcome)", shapes: [], slots: { body: slot("markdown", 0.44, 0.35, 9.12, 4.95, { size: 15, color: "text", required: true }) } },
132
+ },
133
+ snippets: [
134
+ { name: "Cards", description: "Three cards with a number, a heading and a line", kind: "html", w: 9.12, h: 2.2, content: '<div class="cards">\n <div class="card"><span class="num">01</span><h3>First</h3><p>What it is and why it matters.</p></div>\n <div class="card"><span class="num">02</span><h3>Second</h3><p>What it is and why it matters.</p></div>\n <div class="card"><span class="num">03</span><h3>Third</h3><p>What it is and why it matters.</p></div>\n</div>' },
135
+ { name: "Key figures", description: "Big numbers with a label", kind: "html", w: 9.12, h: 1.6, content: '<div class="kpis">\n <div class="kpi"><strong>120</strong><span>pages migrated</span></div>\n <div class="kpi"><strong>5 min</strong><span>to publish a text</span></div>\n <div class="kpi"><strong>−60%</strong><span>time per text</span></div>\n</div>' },
136
+ { name: "Flow", description: "Boxes from left to right with arrows", kind: "html", w: 9.12, h: 1.6, content: '<div class="flow">\n <div class="box ghost">Sources<small>CSV, Excel</small></div>\n <div class="arrow">→</div>\n <div class="box accent">We build this<small>import, checks, API</small></div>\n <div class="arrow">→</div>\n <div class="box solid">Channels<small>web, newsletter, social</small></div>\n</div>' },
137
+ { name: "Timeline", description: "Points on a line, left to right", kind: "html", w: 9.12, h: 1.4, content: '<ol class="timeline">\n <li><b>December</b><span>Website</span></li>\n <li><b>January</b><span>Newsletter, LinkedIn</span></li>\n <li><b>February</b><span>Review with the same texts</span></li>\n</ol>' },
138
+ { name: "Before / after", description: "Two boxes side by side", kind: "html", w: 9.12, h: 2.2, content: '<div class="compare">\n <div><h3>Today</h3><p>Every text is copied by hand into four tools.</p></div>\n <div><h3>With the change</h3><p>Written once, published everywhere.</p></div>\n</div>' },
139
+ { name: "Columns", description: "Three columns with a small heading", kind: "html", w: 9.12, h: 2, content: '<div class="cols">\n <div><h3>For</h3><p>Who it serves.</p></div>\n <div><h3>Not now</h3><p>What stays out.</p></div>\n <div><h3>Next</h3><p>What follows.</p></div>\n</div>' },
140
+ { name: "Callout", description: "A highlighted note", kind: "html", w: 6, h: 1, content: '<div class="callout"><strong>Note:</strong> the one thing to remember.</div>' },
141
+ ],
142
+ };
@@ -0,0 +1,34 @@
1
+ /** Series colors, shared by the HTML chart and the PPTX one so both look alike: the template's accent, then fixed extras. */
2
+ export declare const chartPalette: (accent?: string) => string[];
3
+ /**
4
+ * Charts as SVG for the HTML slides: column, bar, line, area, pie and
5
+ * doughnut from the same `chart` block the PowerPoint export turns into a
6
+ * native chart. Pure — the web editor bundles it.
7
+ */
8
+ export declare const CHART_KINDS: readonly ["column", "bar", "line", "pie", "doughnut", "area"];
9
+ export type ChartKind = (typeof CHART_KINDS)[number];
10
+ export interface ChartData {
11
+ kind: ChartKind;
12
+ title?: string;
13
+ categories: string[];
14
+ series: {
15
+ name: string;
16
+ values: number[];
17
+ }[];
18
+ }
19
+ /** A chart block's YAML (fenced or bare) read and checked; throws with what is wrong. */
20
+ export declare function parseChart(source: string): ChartData;
21
+ /** The chart as an SVG string sized w × h (the slot's box in px), in the theme's palette and text colors. */
22
+ export declare function chartSvg(c: ChartData, w: number, h: number, look: {
23
+ palette: string[];
24
+ text: string;
25
+ muted: string;
26
+ line: string;
27
+ fontSize: number;
28
+ }): string;
29
+ /**
30
+ * A chart written back as its block: what the editor's data grid saves.
31
+ * Compact and in the order people read it (kind, title, categories,
32
+ * series); `fenced` keeps the ```chart fence the slot had.
33
+ */
34
+ export declare function chartSource(c: ChartData, fenced: boolean): string;
@@ -0,0 +1,159 @@
1
+ import { parse } from "yaml";
2
+ /** Series colors, shared by the HTML chart and the PPTX one so both look alike: the template's accent, then fixed extras. */
3
+ export const chartPalette = (accent) => [accent ?? "#0284C7", "#F59E0B", "#10B981", "#8B5CF6", "#EF4444", "#64748B", "#EC4899"];
4
+ /**
5
+ * Charts as SVG for the HTML slides: column, bar, line, area, pie and
6
+ * doughnut from the same `chart` block the PowerPoint export turns into a
7
+ * native chart. Pure — the web editor bundles it.
8
+ */
9
+ export const CHART_KINDS = ["column", "bar", "line", "pie", "doughnut", "area"];
10
+ /** A chart block's YAML (fenced or bare) read and checked; throws with what is wrong. */
11
+ export function parseChart(source) {
12
+ const body = source.replace(/^\s*```\s*chart\s*\n/, "").replace(/\n?```\s*$/, "");
13
+ const data = parse(body);
14
+ if (!data || typeof data !== "object")
15
+ throw new Error("chart block must be a YAML mapping (kind, categories, series)");
16
+ const kind = String(data.kind ?? "column");
17
+ if (!CHART_KINDS.includes(kind))
18
+ throw new Error(`chart kind "${kind}" is not one of ${CHART_KINDS.join(", ")}`);
19
+ const categories = Array.isArray(data.categories) ? data.categories.map(String) : [];
20
+ if (!categories.length)
21
+ throw new Error("chart needs categories: [a, b, …]");
22
+ const seriesIn = Array.isArray(data.series) ? data.series : [];
23
+ if (!seriesIn.length)
24
+ throw new Error("chart needs series: [{name, values}]");
25
+ const series = seriesIn.map((x, i) => {
26
+ const row = (x ?? {});
27
+ const values = Array.isArray(row.values) ? row.values.map(Number) : [];
28
+ if (values.length !== categories.length || values.some((v) => Number.isNaN(v)))
29
+ throw new Error(`series ${i + 1}: values must be ${categories.length} numbers`);
30
+ return { name: String(row.name ?? `Series ${i + 1}`), values };
31
+ });
32
+ return { kind: kind, categories, series, ...(typeof data.title === "string" && data.title.trim() ? { title: data.title.trim() } : {}) };
33
+ }
34
+ /** Two decimals are plenty for a slide 1600 px wide. */
35
+ const tidy = (svg) => svg.replace(/-?\d+\.\d{3,}/g, (n) => String(Math.round(Number(n) * 100) / 100));
36
+ const esc = (s) => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
37
+ const fmt = (n) => (Math.abs(n) >= 1000 ? n.toLocaleString("en-US").replace(/,/g, "'") : String(Math.round(n * 100) / 100));
38
+ /** A "nice" axis: max and step for about five ticks. */
39
+ function niceAxis(max, min) {
40
+ const span = Math.max(max - Math.min(0, min), 1e-9);
41
+ const raw = span / 5;
42
+ const pow = 10 ** Math.floor(Math.log10(raw));
43
+ const step = [1, 2, 2.5, 5, 10].map((m) => m * pow).find((s) => s >= raw) ?? pow * 10;
44
+ return { lo: Math.min(0, Math.floor(min / step) * step), hi: Math.ceil(max / step) * step || step, step };
45
+ }
46
+ /** The chart as an SVG string sized w × h (the slot's box in px), in the theme's palette and text colors. */
47
+ export function chartSvg(c, w, h, look) {
48
+ const fs = look.fontSize;
49
+ const color = (i) => look.palette[i % look.palette.length];
50
+ const parts = [];
51
+ let top = 4;
52
+ if (c.title) {
53
+ parts.push(`<text x="${w / 2}" y="${fs * 1.1}" text-anchor="middle" font-weight="700" font-size="${fs * 1.1}" fill="${look.text}">${esc(c.title)}</text>`);
54
+ top += fs * 1.7;
55
+ }
56
+ const legend = c.series.length > 1 || c.kind === "pie" || c.kind === "doughnut";
57
+ const legendItems = c.kind === "pie" || c.kind === "doughnut" ? c.categories : c.series.map((s) => s.name);
58
+ const bottomLegend = legend ? fs * 1.8 : 0;
59
+ if (legend) {
60
+ const itemW = legendItems.map((t) => t.length * fs * 0.55 + fs * 1.8);
61
+ let x = (w - itemW.reduce((a, b) => a + b, 0)) / 2;
62
+ const y = h - fs * 0.5;
63
+ legendItems.forEach((t, i) => {
64
+ parts.push(`<rect x="${x}" y="${y - fs * 0.75}" width="${fs * 0.8}" height="${fs * 0.8}" rx="${fs * 0.15}" fill="${color(i)}"/><text x="${x + fs * 1.1}" y="${y}" font-size="${fs * 0.9}" fill="${look.muted}">${esc(t)}</text>`);
65
+ x += itemW[i];
66
+ });
67
+ }
68
+ const plotH = h - top - bottomLegend;
69
+ if (c.kind === "pie" || c.kind === "doughnut") {
70
+ const vals = c.series[0].values.map((v) => Math.max(0, v));
71
+ const total = vals.reduce((a, b) => a + b, 0) || 1;
72
+ const r = Math.max(10, Math.min(w, plotH) / 2 - 4);
73
+ const cx = w / 2;
74
+ const cy = top + plotH / 2;
75
+ let a0 = -Math.PI / 2;
76
+ vals.forEach((v, i) => {
77
+ const a1 = a0 + (v / total) * Math.PI * 2;
78
+ const large = a1 - a0 > Math.PI ? 1 : 0;
79
+ const p = (a, rr) => `${cx + rr * Math.cos(a)} ${cy + rr * Math.sin(a)}`;
80
+ if (v / total >= 0.9999)
81
+ parts.push(`<circle cx="${cx}" cy="${cy}" r="${r}" fill="${color(i)}"/>`);
82
+ else
83
+ parts.push(`<path d="M ${cx} ${cy} L ${p(a0, r)} A ${r} ${r} 0 ${large} 1 ${p(a1, r)} Z" fill="${color(i)}" stroke="#fff" stroke-width="2"/>`);
84
+ const mid = (a0 + a1) / 2;
85
+ if (v / total > 0.06)
86
+ parts.push(`<text x="${cx + r * (c.kind === "doughnut" ? 0.78 : 0.62) * Math.cos(mid)}" y="${cy + r * (c.kind === "doughnut" ? 0.78 : 0.62) * Math.sin(mid) + fs * 0.35}" text-anchor="middle" font-size="${fs}" font-weight="700" fill="#fff">${Math.round((v / total) * 100)}%</text>`);
87
+ a0 = a1;
88
+ });
89
+ if (c.kind === "doughnut")
90
+ parts.push(`<circle cx="${cx}" cy="${cy}" r="${r * 0.55}" fill="var(--c-background, #fff)"/>`);
91
+ return tidy(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${w} ${h}" width="100%" height="100%" font-family="inherit">${parts.join("")}</svg>`);
92
+ }
93
+ const all = c.series.flatMap((s) => s.values);
94
+ const { lo, hi, step } = niceAxis(Math.max(...all, 0), Math.min(...all, 0));
95
+ const horizontal = c.kind === "bar";
96
+ const labelW = horizontal ? Math.min(w * 0.3, Math.max(...c.categories.map((t) => t.length)) * fs * 0.55 + fs) : Math.max(...[lo, hi].map((v) => fmt(v).length)) * fs * 0.6 + fs * 0.6;
97
+ const left = labelW;
98
+ const right = w - fs;
99
+ const bottom = top + plotH - (horizontal ? fs * 1.6 : fs * 1.8);
100
+ const plotTop = top + fs * 0.6;
101
+ const ticks = [];
102
+ for (let v = lo; v <= hi + step / 2; v += step)
103
+ ticks.push(Math.round(v * 1e6) / 1e6);
104
+ const n = c.categories.length;
105
+ if (horizontal) {
106
+ const scale = (v) => left + ((v - lo) / (hi - lo)) * (right - left);
107
+ for (const t of ticks)
108
+ parts.push(`<line x1="${scale(t)}" x2="${scale(t)}" y1="${plotTop}" y2="${bottom}" stroke="${look.line}"/><text x="${scale(t)}" y="${bottom + fs * 1.2}" text-anchor="middle" font-size="${fs * 0.85}" fill="${look.muted}">${fmt(t)}</text>`);
109
+ const band = (bottom - plotTop) / n;
110
+ const barH = (band * 0.7) / c.series.length;
111
+ c.categories.forEach((cat, i) => {
112
+ parts.push(`<text x="${left - fs * 0.5}" y="${plotTop + band * (i + 0.5) + fs * 0.35}" text-anchor="end" font-size="${fs * 0.9}" fill="${look.text}">${esc(cat)}</text>`);
113
+ c.series.forEach((s, j) => {
114
+ const y = plotTop + band * i + band * 0.15 + barH * j;
115
+ const x0 = scale(Math.min(0, s.values[i]));
116
+ parts.push(`<rect x="${x0}" y="${y}" width="${Math.abs(scale(s.values[i]) - scale(0))}" height="${barH * 0.92}" rx="2" fill="${color(j)}"/>`);
117
+ });
118
+ });
119
+ return tidy(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${w} ${h}" width="100%" height="100%" font-family="inherit">${parts.join("")}</svg>`);
120
+ }
121
+ const scale = (v) => bottom - ((v - lo) / (hi - lo)) * (bottom - plotTop);
122
+ for (const t of ticks)
123
+ parts.push(`<line x1="${left}" x2="${right}" y1="${scale(t)}" y2="${scale(t)}" stroke="${look.line}"/><text x="${left - fs * 0.4}" y="${scale(t) + fs * 0.32}" text-anchor="end" font-size="${fs * 0.85}" fill="${look.muted}">${fmt(t)}</text>`);
124
+ const band = (right - left) / n;
125
+ c.categories.forEach((cat, i) => parts.push(`<text x="${left + band * (i + 0.5)}" y="${bottom + fs * 1.3}" text-anchor="middle" font-size="${fs * 0.9}" fill="${look.text}">${esc(cat)}</text>`));
126
+ if (c.kind === "column") {
127
+ const barW = (band * 0.7) / c.series.length;
128
+ c.series.forEach((s, j) => s.values.forEach((v, i) => {
129
+ const x = left + band * i + band * 0.15 + barW * j;
130
+ const y = Math.min(scale(v), scale(0));
131
+ parts.push(`<rect x="${x}" y="${y}" width="${barW * 0.92}" height="${Math.abs(scale(v) - scale(0))}" rx="2" fill="${color(j)}"/>`);
132
+ }));
133
+ }
134
+ else {
135
+ c.series.forEach((s, j) => {
136
+ const pts = s.values.map((v, i) => `${left + band * (i + 0.5)},${scale(v)}`);
137
+ if (c.kind === "area")
138
+ parts.push(`<polygon points="${left + band * 0.5},${scale(Math.max(lo, 0))} ${pts.join(" ")} ${left + band * (n - 0.5)},${scale(Math.max(lo, 0))}" fill="${color(j)}" fill-opacity="0.22"/>`);
139
+ parts.push(`<polyline points="${pts.join(" ")}" fill="none" stroke="${color(j)}" stroke-width="${Math.max(2, fs * 0.18)}" stroke-linejoin="round" stroke-linecap="round"/>`);
140
+ s.values.forEach((v, i) => parts.push(`<circle cx="${left + band * (i + 0.5)}" cy="${scale(v)}" r="${Math.max(3, fs * 0.22)}" fill="${color(j)}"/>`));
141
+ });
142
+ }
143
+ parts.push(`<line x1="${left}" x2="${right}" y1="${scale(Math.max(lo, 0))}" y2="${scale(Math.max(lo, 0))}" stroke="${look.muted}"/>`);
144
+ return tidy(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${w} ${h}" width="100%" height="100%" font-family="inherit">${parts.join("")}</svg>`);
145
+ }
146
+ /** A YAML scalar: plain when it reads back the same, else quoted. */
147
+ const scalar = (s) => (/^[\p{L}\p{N}][\p{L}\p{N} ._%'()/&+-]*$/u.test(s) && !/^(true|false|null|yes|no|on|off|~)$/i.test(s) && !/^[\d.+-]+$/.test(s) ? s : JSON.stringify(s));
148
+ /**
149
+ * A chart written back as its block: what the editor's data grid saves.
150
+ * Compact and in the order people read it (kind, title, categories,
151
+ * series); `fenced` keeps the ```chart fence the slot had.
152
+ */
153
+ export function chartSource(c, fenced) {
154
+ const lines = [`kind: ${c.kind}`, ...(c.title ? [`title: ${scalar(c.title)}`] : []), `categories: [${c.categories.map(scalar).join(", ")}]`, "series:"];
155
+ for (const s of c.series)
156
+ lines.push(` - name: ${scalar(s.name)}`, ` values: [${s.values.map((v) => String(Math.round(v * 1e6) / 1e6)).join(", ")}]`);
157
+ const body = lines.join("\n");
158
+ return fenced ? `\`\`\`chart\n${body}\n\`\`\`` : body;
159
+ }
@@ -0,0 +1,63 @@
1
+ export { DEFAULT_SLOT, NOTES_SLOT, joinSlots, slotsOf } from "./slots.js";
2
+ /**
3
+ * deck.md: the whole presentation in one Markdown file, Slidev-style.
4
+ *
5
+ * --- headmatter: the deck (title, template, size) and the
6
+ * title: Why NodeHive first slide's own keys (layout, notes, background)
7
+ * template: default
8
+ * layout: title
9
+ * ---
10
+ * # Why NodeHive slide 1 — content before the first ::slot:: marker is
11
+ * ::subtitle:: the default content: a leading heading fills the
12
+ * Review · Nov 2026 layout's title slot, the rest its body slot
13
+ * ::notes:: ::notes:: are the speaker notes
14
+ * Open with the timeline.
15
+ *
16
+ * --- a `---` line starts the next slide; an optional YAML
17
+ * layout: two-column block right after it (closed by another `---`) is
18
+ * --- the slide's keys
19
+ * # Faster editing
20
+ * ::left::
21
+ * - One API for every channel
22
+ * ::right::
23
+ * ![Architecture](assets/arch.png)
24
+ *
25
+ * The parser is tolerant: a fence (```) hides separators and markers inside
26
+ * it, a `---` with no YAML after it is just a separator, and anything that
27
+ * is not a mapping stays content. `serializeDeck` writes the normalised
28
+ * form back; the editor and the CLI both go through it, agents may edit
29
+ * the file directly.
30
+ */
31
+ /** Headmatter keys the deck reads itself; every other non-slide key stays in `meta` (author, date, …). */
32
+ export declare const DECK_KEYS: readonly ["title", "template", "size", "css", "numbers"];
33
+ export declare const SLIDE_KEYS: readonly ["layout", "notes", "background", "transition"];
34
+ export interface SlideDef {
35
+ /** The layout of the template this slide uses; the template's default when missing. */
36
+ layout?: string;
37
+ /** Speaker notes (the `notes:` key or the ::notes:: slot). */
38
+ notes?: string;
39
+ /** A color name of the template or #hex; overrides the layout's background. */
40
+ background?: string;
41
+ transition?: string;
42
+ /** Other keys of the slide's YAML block, kept as they are. */
43
+ extra: Record<string, unknown>;
44
+ /** The slide's markdown including its `::slot::` markers (the notes slot removed when `notes` came from it). */
45
+ content: string;
46
+ }
47
+ export interface DeckDoc {
48
+ title: string;
49
+ template: string;
50
+ /** The deck's own CSS over the template's theme (scoped to its slides). */
51
+ css?: string;
52
+ size?: "16:9" | "4:3";
53
+ /** `numbers: false` turns the slide numbers off for the whole deck; on when missing. A slide's own `number: false` hides it there. */
54
+ numbers?: false;
55
+ /** Other headmatter keys (author, date, …), kept as they are. */
56
+ meta: Record<string, unknown>;
57
+ slides: SlideDef[];
58
+ }
59
+ export declare function parseDeck(raw: string): DeckDoc;
60
+ /** A deck in its file form: headmatter, then slides separated by `---` lines with their YAML blocks. */
61
+ export declare function serializeDeck(doc: DeckDoc): string;
62
+ /** A new deck's file: a title slide and one content slide, so the editor opens with something to show. */
63
+ export declare function starterDeck(title: string, template: string): DeckDoc;