@classic-homes/slides 0.7.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -350,6 +350,120 @@ declare function validateBrandProfile(input: unknown): {
350
350
  }[];
351
351
  };
352
352
 
353
+ /**
354
+ * Chart specs for the `chart` layout. Authors describe data, never styling;
355
+ * this module turns a spec into an ECharts option themed from the brand, and
356
+ * renders it to static SVG (server-side rendering, no runtime JS) so charts
357
+ * work offline, in print, in Workers and in the browser alike.
358
+ *
359
+ * This module never imports ECharts: chart-render.ts draws with it (loaded
360
+ * lazily), and the `/core` entry leaves it out for callers that inject their
361
+ * own `ChartSvgRenderer`.
362
+ */
363
+
364
+ declare const CHART_TYPES: readonly ["column", "bar", "stacked-column", "stacked-bar", "line", "area", "pie", "donut", "funnel", "gauge", "scatter", "radar", "percent-column", "percent-bar", "combo", "waterfall", "heatmap", "dumbbell", "bullet", "treemap", "ring", "sankey", "pictogram"];
365
+ type ChartType = (typeof CHART_TYPES)[number];
366
+ /** Types that only read the first series. */
367
+ declare const SINGLE_SERIES_CHARTS: readonly ChartType[];
368
+ declare const ChartSpec: z.ZodObject<{
369
+ type: z.ZodEnum<["column", "bar", "stacked-column", "stacked-bar", "line", "area", "pie", "donut", "funnel", "gauge", "scatter", "radar", "percent-column", "percent-bar", "combo", "waterfall", "heatmap", "dumbbell", "bullet", "treemap", "ring", "sankey", "pictogram"]>;
370
+ labels: z.ZodArray<z.ZodString, "many">;
371
+ series: z.ZodArray<z.ZodObject<{
372
+ name: z.ZodString;
373
+ values: z.ZodArray<z.ZodNumber, "many">;
374
+ as: z.ZodOptional<z.ZodEnum<["bar", "line"]>>;
375
+ axis: z.ZodOptional<z.ZodEnum<["primary", "secondary"]>>;
376
+ }, "strip", z.ZodTypeAny, {
377
+ values: number[];
378
+ name: string;
379
+ as?: "bar" | "line" | undefined;
380
+ axis?: "primary" | "secondary" | undefined;
381
+ }, {
382
+ values: number[];
383
+ name: string;
384
+ as?: "bar" | "line" | undefined;
385
+ axis?: "primary" | "secondary" | undefined;
386
+ }>, "many">;
387
+ format: z.ZodDefault<z.ZodEnum<["number", "percent", "currency", "compact"]>>;
388
+ decimals: z.ZodDefault<z.ZodNumber>;
389
+ unit: z.ZodOptional<z.ZodString>;
390
+ legend: z.ZodDefault<z.ZodEnum<["auto", "show", "hide"]>>;
391
+ labelsOnData: z.ZodDefault<z.ZodBoolean>;
392
+ highlight: z.ZodOptional<z.ZodString>;
393
+ max: z.ZodOptional<z.ZodNumber>;
394
+ secondaryFormat: z.ZodOptional<z.ZodEnum<["number", "percent", "currency", "compact"]>>;
395
+ totals: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
396
+ perIcon: z.ZodOptional<z.ZodNumber>;
397
+ }, "strict", z.ZodTypeAny, {
398
+ type: "column" | "bar" | "stacked-column" | "stacked-bar" | "line" | "area" | "pie" | "donut" | "funnel" | "gauge" | "scatter" | "radar" | "percent-column" | "percent-bar" | "combo" | "waterfall" | "heatmap" | "dumbbell" | "bullet" | "treemap" | "ring" | "sankey" | "pictogram";
399
+ labels: string[];
400
+ series: {
401
+ values: number[];
402
+ name: string;
403
+ as?: "bar" | "line" | undefined;
404
+ axis?: "primary" | "secondary" | undefined;
405
+ }[];
406
+ format: "number" | "percent" | "currency" | "compact";
407
+ decimals: number;
408
+ legend: "auto" | "show" | "hide";
409
+ labelsOnData: boolean;
410
+ unit?: string | undefined;
411
+ highlight?: string | undefined;
412
+ max?: number | undefined;
413
+ secondaryFormat?: "number" | "percent" | "currency" | "compact" | undefined;
414
+ totals?: string[] | undefined;
415
+ perIcon?: number | undefined;
416
+ }, {
417
+ type: "column" | "bar" | "stacked-column" | "stacked-bar" | "line" | "area" | "pie" | "donut" | "funnel" | "gauge" | "scatter" | "radar" | "percent-column" | "percent-bar" | "combo" | "waterfall" | "heatmap" | "dumbbell" | "bullet" | "treemap" | "ring" | "sankey" | "pictogram";
418
+ labels: string[];
419
+ series: {
420
+ values: number[];
421
+ name: string;
422
+ as?: "bar" | "line" | undefined;
423
+ axis?: "primary" | "secondary" | undefined;
424
+ }[];
425
+ format?: "number" | "percent" | "currency" | "compact" | undefined;
426
+ decimals?: number | undefined;
427
+ unit?: string | undefined;
428
+ legend?: "auto" | "show" | "hide" | undefined;
429
+ labelsOnData?: boolean | undefined;
430
+ highlight?: string | undefined;
431
+ max?: number | undefined;
432
+ secondaryFormat?: "number" | "percent" | "currency" | "compact" | undefined;
433
+ totals?: string[] | undefined;
434
+ perIcon?: number | undefined;
435
+ }>;
436
+ type ChartSpecInput = z.input<typeof ChartSpec>;
437
+ type ChartSpecValue = z.output<typeof ChartSpec>;
438
+ /** Checks that fit the data shape rather than a single field. */
439
+ declare function chartIssues(spec: ChartSpecValue): string[];
440
+ declare function chartWarnings(spec: ChartSpecValue): string[];
441
+ declare function formatValue(v: number, spec: Pick<ChartSpecValue, 'format' | 'decimals' | 'unit'>): string;
442
+ /** Builds the ECharts option for a spec. Pure; exported for tests and custom renderers. */
443
+ declare function chartOption(spec: ChartSpecValue, palette?: BrandPalette): Record<string, unknown>;
444
+ interface ChartRenderer {
445
+ render(option: Record<string, unknown>, width: number, height: number): string;
446
+ }
447
+ /** One chart for a `ChartSvgRenderer` to draw. Plain data, so it can cross a process boundary. */
448
+ interface ChartSvgRequest {
449
+ spec: ChartSpecValue;
450
+ width: number;
451
+ height: number;
452
+ /** Brand palette; omitted for the stock Classic Homes brand. */
453
+ palette?: BrandPalette;
454
+ title?: string;
455
+ }
456
+ /**
457
+ * Draws charts to finished SVG strings (`renderChartSvg` output), one per
458
+ * request, in request order. `renderDeck` takes one as `renderCharts` so
459
+ * ECharts can run somewhere else, such as a separate Worker.
460
+ */
461
+ type ChartSvgRenderer = (charts: ChartSvgRequest[]) => Promise<string[]>;
462
+ /** Labels a raw ECharts SVG for screen readers and makes it responsive. */
463
+ declare function finishChartSvg(svg: string, spec: ChartSpecValue, title?: string): string;
464
+ /** Plain-language summary for screen readers. */
465
+ declare function describeChart(spec: ChartSpecValue): string;
466
+
353
467
  /** The deck-level fields a layout may read while rendering. */
354
468
  interface DeckContext {
355
469
  title: string;
@@ -571,6 +685,12 @@ interface RenderOptions {
571
685
  * stop navigating. Off by default; never use it for shared or exported decks.
572
686
  */
573
687
  editorMarkers?: boolean;
688
+ /**
689
+ * Draws the deck's charts. The main entry defaults to ECharts in process;
690
+ * the `/core` entry has no default, so a deck with charts needs one there
691
+ * (for example, a call to a Worker that runs ECharts).
692
+ */
693
+ renderCharts?: ChartSvgRenderer;
574
694
  }
575
695
  /** A field the editor runtime can match a clicked element to. */
576
696
  interface FieldMarker {
@@ -667,4 +787,4 @@ declare function inlineDeckImages(input: unknown, resolve: ImageResolver, option
667
787
  */
668
788
  declare function externalizeDeckImages(input: unknown, upload: (dataUri: string) => string | Promise<string>, options?: MapImagesOptions): Promise<unknown>;
669
789
 
670
- export { validateBrandProfile as $, type SpeakerNote as A, type BrandPalette as B, CLASSIC_HOMES_BRAND as C, type Deck as D, type SpeakerNotesOptions as E, type FieldMarker as F, type ValidationResult as G, checkPalette as H, type ImageInput as I, collectImageSources as J, externalizeDeckImages as K, type LayoutCategory as L, type MapImagesOptions as M, extractDeckSource as N, fieldMarkers as O, PREVIEW_SIZE as P, formatIssues as Q, type RenderOptions as R, type SlideData as S, formatPath as T, getLayout as U, type ValidateOptions as V, inlineDeckImages as W, mapDeckImages as X, renderDeck as Y, resolveBrand as Z, speakerNotes as _, BrandPaletteSchema as a, validateDeck as a0, type BrandProfile as b, type BrandProfileInput as c, BrandProfileSchema as d, CLASSIC_HOMES_PALETTE as e, type DeckBrand as f, DeckBrandSchema as g, DeckError as h, type DeckInput as i, DeckSchema as j, type DeckSettings as k, DeckSettingsSchema as l, type ImageResolver as m, type ImageValue as n, type InlineImagesResult as o, type ItemValue as p, LAYOUTS as q, LAYOUT_CATEGORIES as r, LAYOUT_CATEGORY_ORDER as s, type LayoutDef as t, type LayoutIssue as u, type LayoutName as v, type RenderResult as w, type ResolvedBrand as x, type SlideInput as y, SlideSchema as z };
790
+ export { collectImageSources as $, type LayoutCategory as A, type BrandPalette as B, type ChartSpecValue as C, type Deck as D, type LayoutDef as E, type FieldMarker as F, type LayoutIssue as G, type LayoutName as H, type ImageInput as I, type RenderResult as J, type ResolvedBrand as K, LAYOUTS as L, type MapImagesOptions as M, type SlideData as N, type SlideInput as O, PREVIEW_SIZE as P, SlideSchema as Q, type RenderOptions as R, SINGLE_SERIES_CHARTS as S, type SpeakerNote as T, type SpeakerNotesOptions as U, type ValidateOptions as V, type ValidationResult as W, chartIssues as X, chartOption as Y, chartWarnings as Z, checkPalette as _, type ChartSvgRenderer as a, describeChart as a0, externalizeDeckImages as a1, extractDeckSource as a2, fieldMarkers as a3, finishChartSvg as a4, formatIssues as a5, formatPath as a6, formatValue as a7, getLayout as a8, inlineDeckImages as a9, mapDeckImages as aa, resolveBrand as ab, speakerNotes as ac, validateBrandProfile as ad, validateDeck as ae, renderDeck as af, BrandPaletteSchema as b, type BrandProfile as c, type BrandProfileInput as d, BrandProfileSchema as e, CHART_TYPES as f, CLASSIC_HOMES_BRAND as g, CLASSIC_HOMES_PALETTE as h, type ChartRenderer as i, ChartSpec as j, type ChartSpecInput as k, type ChartSvgRequest as l, type ChartType as m, type DeckBrand as n, DeckBrandSchema as o, DeckError as p, type DeckInput as q, DeckSchema as r, type DeckSettings as s, DeckSettingsSchema as t, type ImageResolver as u, type ImageValue as v, type InlineImagesResult as w, type ItemValue as x, LAYOUT_CATEGORIES as y, LAYOUT_CATEGORY_ORDER as z };
package/dist/index.d.ts CHANGED
@@ -1,301 +1,17 @@
1
- import { L as LayoutCategory, B as BrandPalette } from './images-rkJZtnjl.js';
2
- export { a as BrandPaletteSchema, b as BrandProfile, c as BrandProfileInput, d as BrandProfileSchema, C as CLASSIC_HOMES_BRAND, e as CLASSIC_HOMES_PALETTE, D as Deck, f as DeckBrand, g as DeckBrandSchema, h as DeckError, i as DeckInput, j as DeckSchema, k as DeckSettings, l as DeckSettingsSchema, F as FieldMarker, I as ImageInput, m as ImageResolver, n as ImageValue, o as InlineImagesResult, p as ItemValue, q as LAYOUTS, r as LAYOUT_CATEGORIES, s as LAYOUT_CATEGORY_ORDER, t as LayoutDef, u as LayoutIssue, v as LayoutName, M as MapImagesOptions, P as PREVIEW_SIZE, R as RenderOptions, w as RenderResult, x as ResolvedBrand, S as SlideData, y as SlideInput, z as SlideSchema, A as SpeakerNote, E as SpeakerNotesOptions, V as ValidateOptions, G as ValidationResult, H as checkPalette, J as collectImageSources, K as externalizeDeckImages, N as extractDeckSource, O as fieldMarkers, Q as formatIssues, T as formatPath, U as getLayout, W as inlineDeckImages, X as mapDeckImages, Y as renderDeck, Z as resolveBrand, _ as speakerNotes, $ as validateBrandProfile, a0 as validateDeck } from './images-rkJZtnjl.js';
3
- import * as zod_to_json_schema from 'zod-to-json-schema';
4
- import { z } from 'zod';
1
+ import { C as ChartSpecValue, B as BrandPalette, a as ChartSvgRenderer } from './images-G0nQyKJE.js';
2
+ export { b as BrandPaletteSchema, c as BrandProfile, d as BrandProfileInput, e as BrandProfileSchema, f as CHART_TYPES, g as CLASSIC_HOMES_BRAND, h as CLASSIC_HOMES_PALETTE, i as ChartRenderer, j as ChartSpec, k as ChartSpecInput, l as ChartSvgRequest, m as ChartType, D as Deck, n as DeckBrand, o as DeckBrandSchema, p as DeckError, q as DeckInput, r as DeckSchema, s as DeckSettings, t as DeckSettingsSchema, F as FieldMarker, I as ImageInput, u as ImageResolver, v as ImageValue, w as InlineImagesResult, x as ItemValue, L as LAYOUTS, y as LAYOUT_CATEGORIES, z as LAYOUT_CATEGORY_ORDER, A as LayoutCategory, E as LayoutDef, G as LayoutIssue, H as LayoutName, M as MapImagesOptions, P as PREVIEW_SIZE, R as RenderOptions, J as RenderResult, K as ResolvedBrand, S as SINGLE_SERIES_CHARTS, N as SlideData, O as SlideInput, Q as SlideSchema, T as SpeakerNote, U as SpeakerNotesOptions, V as ValidateOptions, W as ValidationResult, X as chartIssues, Y as chartOption, Z as chartWarnings, _ as checkPalette, $ as collectImageSources, a0 as describeChart, a1 as externalizeDeckImages, a2 as extractDeckSource, a3 as fieldMarkers, a4 as finishChartSvg, a5 as formatIssues, a6 as formatPath, a7 as formatValue, a8 as getLayout, a9 as inlineDeckImages, aa as mapDeckImages, ab as resolveBrand, ac as speakerNotes, ad as validateBrandProfile, ae as validateDeck } from './images-G0nQyKJE.js';
3
+ export { AUTHORING_GUIDE, EditableDeck, EditorField, LOGO_SVG, LayoutEditorInfo, PALETTE, PLACEHOLDER_IMAGE, RUNTIME_SCRIPT_HASH, SlideRef, VideoRef, addSlide, allLayoutEditorInfo, blankSlide, commonSlideFields, deckEditorFields, deckJsonSchema, describeLayout, ensureSlideIds, escapeHtml, findSlide, inline, isPlaceholderImage, layoutEditorInfo, layoutGalleryDeck, listLayouts, logoLockup, moveSlide, newSlideId, outline, parseDeckSource, parseVideoUrl, prose, removeSlide, slideKey, stringifyDeck, updateSlide, videoEmbedUrl } from './core.js';
4
+ export { r as renderDeck } from './render-default-0SAePU6r.js';
5
+ import 'zod';
6
+ import 'zod-to-json-schema';
5
7
 
6
- interface LayoutSummary {
7
- name: string;
8
- category: LayoutCategory;
9
- description: string;
10
- whenToUse: string;
11
- }
12
- declare function listLayouts(): LayoutSummary[];
13
- /** Full description of one layout: fields as JSON Schema plus a working example. */
14
- declare function describeLayout(name: string): {
15
- name: string;
16
- description: string;
17
- whenToUse: string;
18
- defaults: {
19
- background?: string;
20
- track?: "value" | "build" | "neutral";
21
- };
22
- schema: zod_to_json_schema.JsonSchema7Type & {
23
- $schema?: string | undefined;
24
- definitions?: {
25
- [key: string]: zod_to_json_schema.JsonSchema7Type;
26
- } | undefined;
27
- };
28
- example: Record<string, unknown>;
29
- } | undefined;
30
- /** JSON Schema for a whole deck (editor tooling, `$schema` in deck files). */
31
- declare function deckJsonSchema(): zod_to_json_schema.JsonSchema7Type & {
32
- $schema?: string | undefined;
33
- definitions?: {
34
- [key: string]: zod_to_json_schema.JsonSchema7Type;
35
- } | undefined;
36
- };
37
- /** Authoring guidance shared by the CLI, MCP server and docs. */
38
- declare const AUTHORING_GUIDE = "# Writing a Classic Homes deck\n\nA deck is a YAML (or JSON) file: deck-level fields plus a list of slides. Each slide\npicks a **layout** and fills its fields. Layouts own all styling \u2014 there is no way to\nset colours, fonts or sizes directly, which is what keeps every deck on-brand.\n\n## Principles\n- **One idea per slide.** The headline states the point. Detail goes in `notes`.\n- **Short copy.** Titles under ~70 characters, bullets a few words, at most 6 bullets.\n `validate` warns when a slide gets crowded \u2014 split it rather than shrinking text.\n- **Speaker notes on every content slide.** Presenters press N (or P for presenter view).\n- **Real photos over decoration.** Every image needs `alt` text.\n- **Tracks** colour the accent: `value` (red, default) for the homeowner/value story,\n `build` (teal) for construction/process, `neutral` (navy) for framing slides.\n- **Backgrounds**: `paper` (default) for content; solid `navy`/`red`/`teal`/`plum`/`grey`/`stone`\n for dividers. `backgroundImage` + `overlay` puts a photo behind title/section/statement slides.\n\n## Picking a layout\n- **Numbers:** `stats` (2\u20136 headline figures, optional trend + sparkline), `chart` (a real chart \u2014\n put the takeaway in the title), `table` (exact figures people compare).\n- **Processes & structure:** `flow` (ordered steps with arrows), `timeline` (dated milestones, phases),\n `cycle` (things that repeat), `hierarchy` (org chart / tree), `matrix` (2\u00D72), `tiers`\n (funnel or pyramid), `walkthrough` (photo per stage), `journey` (deck agenda).\n- **Media:** `split` (text + photos), `photos`, `image` (with numbered `hotspots` for floor plans\n and site maps), `compare` (before/after slider), `video` (YouTube/Vimeo), `embed` (any https page:\n maps, dashboards, 3D tours, forms).\n- **Words:** `statement`, `bullets`, `cards`, `comparison`, `quote`.\n- **Wrap-up:** `qr` (send people somewhere), `contacts`, closing `statement`.\n\n## Charts\n`chart.labels` are the categories; each series has one value per label. Use `highlight` to\nemphasise one category and `format`/`unit` instead of typing symbols into numbers.\n- **Compare:** `column`/`bar`; `dumbbell` (2+ series as dots per row, e.g. last year vs this\n year); `bullet` (series 1 actual, series 2 target; `max` sets the track).\n- **Part of whole:** `stacked-*` (absolute), `percent-column`/`percent-bar` (each row = 100%),\n `pie`/`donut` (\u2264 7 slices), `treemap` (many categories).\n- **Change:** `line`/`area`; `combo` (series 1 bars, the rest lines; set a series' `as` to\n override and `axis: secondary` + `secondaryFormat` for a second scale, e.g. closings and average\n price); `waterfall` (series 1 is signed changes; list running-total rows in `totals`).\n- **Single value:** `gauge` (one value, needs `max`); `ring` (up to 4 progress rings, one per label;\n `max`, or `format: percent` for 100); `pictogram` (house icons per row; `perIcon` sets the step).\n- **Grid & flow:** `heatmap` (labels are rows, series names are columns); `sankey` (labels are\n sources, series names are destinations, each cell a flow; a destination that is also a label chains\n stages; no loops).\n- **Other:** `funnel` (drop-off, first series), `scatter` (two series as x and y), `radar`.\nPie, donut, funnel, gauge, ring, treemap, waterfall and pictogram read the first series only.\n\n## Video & embeds\nThey need internet while presenting. Offline, in print and in PDF they show a poster (or\n`fallback` screenshot) with a QR code. Some sites refuse to be framed \u2014 the \"Open \u2197\" link\nalways works; add a `fallback` image for anything critical.\n\n## Brand\n`brand.profile` picks who the deck speaks for (default `classic-homes`). You may override\n`name`, `tagline`, `logo`, `logoOnDark`, `favicon` and `footer`; colours come from the profile.\n`settings` controls slide numbers, logo placement, a confidential label and kiosk auto-advance.\n\n## Presenting\nArrow keys / Space advance (and step through `build: true` reveals). N notes \u00B7 P presenter window\n(current + next slide, notes, timer) \u00B7 O overview \u00B7 F fullscreen \u00B7 `?kiosk=15` on the URL loops\nunattended. `hidden: true` skips a slide without deleting it.\n\n## Inline text\n`**bold**`, `*highlight*` (accent colour), `\\`code\\``, `[label](https://\u2026)`. No HTML.\n\n## Journey decks\nSet `journey.steps` at deck level to get a numbered agenda. Then:\n- a `journey` slide shows the full map,\n- `step: 3` on any slide draws the vertical STEP rail,\n- `showJourney: true` adds the compact \"you are here\" strip (great on `section` slides).\n\n## Typical shape\n1. `title`\n2. `statement` or `journey` (why we're here / the agenda)\n3. per part: `section` \u2192 2\u20135 content slides\n4. `qr` (where to go next) \u2192 `contacts` \u2192 closing `statement`\n";
39
-
40
- /** Parses deck source text. YAML is a superset of JSON, so both work. */
41
- declare function parseDeckSource(text: string): unknown;
42
- /** Serializes a deck back to YAML, the human-editable format. */
43
- declare function stringifyDeck(deck: unknown): string;
44
-
45
- /**
46
- * Inline text formatting for slide copy and speaker notes.
47
- *
48
- * Deck text is never raw HTML: authors and agents write a tiny markdown subset
49
- * and everything else is escaped. That keeps decks on-brand (no inline styles)
50
- * and makes rendered output safe to publish.
51
- *
52
- * **bold** → <b> (strong ink colour)
53
- * *highlight* → <em class="hl"> (track accent colour)
54
- * `code` → <code>
55
- * [label](url) → <a> (http/https/mailto/tel only)
56
- * single newline → <br>
57
- */
58
- declare function escapeHtml(value: string): string;
59
- /** Formats one run of inline text. Newlines become line breaks. */
60
- declare function inline(text: string | undefined | null): string;
61
- /**
62
- * Formats a block of prose (speaker notes, long captions): blank lines split
63
- * paragraphs, lines starting with "- " become a bullet list.
64
- */
65
- declare function prose(text: string | undefined | null): string;
66
-
67
- /**
68
- * Slide palette. Mostly brand tokens used as-is; the few surface tints
69
- * (paper, soft accents) are deck-specific and derived here.
70
- */
71
- declare const PALETTE: {
72
- readonly red: "#a91c22";
73
- readonly redLogo: "#e02726";
74
- readonly teal: "#236265";
75
- readonly tealFill: "#236265";
76
- readonly navy: "#002e3f";
77
- readonly plum: "#5e2c41";
78
- readonly sage: "#969a82";
79
- readonly stone: "#676d69";
80
- readonly grey: "#4f4f4f";
81
- readonly ink: "#002e3f";
82
- readonly inkSoft: "#4f4f4f";
83
- readonly inkFaint: "#7a7a7a";
84
- };
85
- /** Horizontal Classic Homes lockup (mark + wordmark), mirrors LogoMain in theme-svelte. Colours follow CSS. */
86
- declare const LOGO_SVG: string;
87
- /**
88
- * Logo lockup from a name. Classic Homes brands (divisions, studios) keep the
89
- * flower mark; partner brands without a logo file get a clean wordmark so
90
- * they are never shown under the Classic Homes mark.
91
- */
92
- declare function logoLockup(name: string, withMark?: boolean): string;
93
-
94
- /**
95
- * Slide-level edits on a deck object. Pure functions shared by the MCP
96
- * server and (later) the hosted editor, so agents change one slide at a
97
- * time instead of rewriting whole files.
98
- */
99
- interface EditableDeck {
100
- slides: Record<string, unknown>[];
101
- [key: string]: unknown;
102
- }
103
- /** A slide reference: its `id`, or its 1-based position. */
104
- type SlideRef = string | number;
105
- declare function findSlide(deck: EditableDeck, ref: SlideRef): number;
106
- /** A short random slide id such as "s-k3f9x2" (valid for the slide `id` field). */
107
- declare function newSlideId(taken?: ReadonlySet<string>): string;
108
8
  /**
109
- * Gives every slide without an `id` a stable random one, so comments and
110
- * analytics can anchor to slides across edits and reorders. Idempotent;
111
- * returns how many ids were added.
9
+ * The built-in chart renderer: ECharts server-side SVG, in process. ECharts
10
+ * is imported lazily (echarts-render.ts) so decks without charts never load
11
+ * it. Only the main entry reaches this module; `/core` callers inject their
12
+ * own `ChartSvgRenderer`.
112
13
  */
113
- declare function ensureSlideIds(deck: EditableDeck): number;
114
- /** Stable key for a slide: its id, or "#<position>" for decks saved before ids existed. */
115
- declare function slideKey(slide: {
116
- id?: unknown;
117
- }, index: number): string;
118
- /** Inserts a slide. `position` is 1-based; omitted appends. Returns the new slide's position. */
119
- declare function addSlide(deck: EditableDeck, slide: Record<string, unknown>, position?: number): number;
120
- /** Shallow-merges fields into a slide. A field set to null is removed. Changing `layout` replaces the slide. */
121
- declare function updateSlide(deck: EditableDeck, ref: SlideRef, patch: Record<string, unknown>): number;
122
- declare function moveSlide(deck: EditableDeck, ref: SlideRef, to: number): number;
123
- declare function removeSlide(deck: EditableDeck, ref: SlideRef): Record<string, unknown>;
124
- /** One-line outline of each slide, for agents and CLIs. */
125
- declare function outline(deck: EditableDeck): string[];
126
14
 
127
- type EditorField = FieldBase<'inline'> | FieldBase<'string'> | (FieldBase<'enum'> & {
128
- options: (string | number)[];
129
- }) | FieldBase<'boolean'> | (FieldBase<'number'> & {
130
- min?: number;
131
- max?: number;
132
- integer: boolean;
133
- }) | FieldBase<'image'> | FieldBase<'item'> | (FieldBase<'list'> & {
134
- of: EditorField;
135
- min?: number;
136
- max?: number;
137
- }) | (FieldBase<'group'> & {
138
- fields: EditorField[];
139
- });
140
- interface FieldBase<K extends string> {
141
- kind: K;
142
- /** Property name ('' for list elements). */
143
- key: string;
144
- label: string;
145
- description?: string;
146
- required: boolean;
147
- default?: unknown;
148
- /** Suggest a textarea rather than a one-line input. */
149
- multiline?: boolean;
150
- /**
151
- * Suggests a richer widget; editors that don't know a hint can fall back to `kind`.
152
- * - url: https link · video-url: YouTube/Vimeo link
153
- * - chart: ChartSpec group (edit labels × series as a grid)
154
- * - grid: list of rows of cells (table layout)
155
- * - point: {x, y} in % of an image (hotspot picker)
156
- */
157
- hint?: 'url' | 'video-url' | 'chart' | 'grid' | 'point';
158
- /** Rarely changed; editors should tuck it behind an "Advanced" section. */
159
- advanced?: boolean;
160
- }
161
- /** Deck-level fields for a settings panel: brand overrides and presentation settings. */
162
- declare function deckEditorFields(): {
163
- brand: EditorField[];
164
- settings: EditorField[];
165
- };
166
- interface LayoutEditorInfo {
167
- name: string;
168
- category: LayoutCategory;
169
- description: string;
170
- whenToUse: string;
171
- defaults: {
172
- background?: string;
173
- track?: string;
174
- };
175
- /** Layout-specific fields, in declaration order. */
176
- fields: EditorField[];
177
- /** A valid starting slide for this layout. */
178
- example: Record<string, unknown>;
179
- }
180
- /** Fields shared by every slide (track, background, notes, step…). */
181
- declare function commonSlideFields(): EditorField[];
182
- declare function layoutEditorInfo(name: string): LayoutEditorInfo | undefined;
183
- declare function allLayoutEditorInfo(): LayoutEditorInfo[];
184
- /**
185
- * One deck holding every layout's starting slide, in palette order, for
186
- * rendering layout thumbnails once (render it, then show slide N of the
187
- * result per layout). `slideFor[layout]` is that layout's slide index.
188
- */
189
- declare function layoutGalleryDeck(): {
190
- deck: {
191
- title: string;
192
- journey: {
193
- steps: string[];
194
- };
195
- slides: Record<string, unknown>[];
196
- };
197
- slideFor: Record<string, number>;
198
- };
199
- /**
200
- * Stand-in image for new slides: a neutral frame reading "Add a photo".
201
- * It validates (so a fresh slide previews immediately) but lint warns until
202
- * it is replaced.
203
- */
204
- declare const PLACEHOLDER_IMAGE: string;
205
- declare function isPlaceholderImage(src: string | undefined): boolean;
206
- /**
207
- * A new slide for a layout, ready to edit: the layout's example with sample
208
- * image paths swapped for {@link PLACEHOLDER_IMAGE}. Always passes validation.
209
- */
210
- declare function blankSlide(name: string): Record<string, unknown> | undefined;
211
-
212
- /**
213
- * Chart specs for the `chart` layout. Authors describe data, never styling;
214
- * this module turns a spec into an ECharts option themed from the brand, and
215
- * renders it to static SVG (server-side rendering, no runtime JS) so charts
216
- * work offline, in print, in Workers and in the browser alike.
217
- *
218
- * ECharts is imported lazily (echarts-render.ts) so decks without charts
219
- * never load it.
220
- */
221
-
222
- declare const CHART_TYPES: readonly ["column", "bar", "stacked-column", "stacked-bar", "line", "area", "pie", "donut", "funnel", "gauge", "scatter", "radar", "percent-column", "percent-bar", "combo", "waterfall", "heatmap", "dumbbell", "bullet", "treemap", "ring", "sankey", "pictogram"];
223
- type ChartType = (typeof CHART_TYPES)[number];
224
- /** Types that only read the first series. */
225
- declare const SINGLE_SERIES_CHARTS: readonly ChartType[];
226
- declare const ChartSpec: z.ZodObject<{
227
- type: z.ZodEnum<["column", "bar", "stacked-column", "stacked-bar", "line", "area", "pie", "donut", "funnel", "gauge", "scatter", "radar", "percent-column", "percent-bar", "combo", "waterfall", "heatmap", "dumbbell", "bullet", "treemap", "ring", "sankey", "pictogram"]>;
228
- labels: z.ZodArray<z.ZodString, "many">;
229
- series: z.ZodArray<z.ZodObject<{
230
- name: z.ZodString;
231
- values: z.ZodArray<z.ZodNumber, "many">;
232
- as: z.ZodOptional<z.ZodEnum<["bar", "line"]>>;
233
- axis: z.ZodOptional<z.ZodEnum<["primary", "secondary"]>>;
234
- }, "strip", z.ZodTypeAny, {
235
- values: number[];
236
- name: string;
237
- as?: "bar" | "line" | undefined;
238
- axis?: "primary" | "secondary" | undefined;
239
- }, {
240
- values: number[];
241
- name: string;
242
- as?: "bar" | "line" | undefined;
243
- axis?: "primary" | "secondary" | undefined;
244
- }>, "many">;
245
- format: z.ZodDefault<z.ZodEnum<["number", "percent", "currency", "compact"]>>;
246
- decimals: z.ZodDefault<z.ZodNumber>;
247
- unit: z.ZodOptional<z.ZodString>;
248
- legend: z.ZodDefault<z.ZodEnum<["auto", "show", "hide"]>>;
249
- labelsOnData: z.ZodDefault<z.ZodBoolean>;
250
- highlight: z.ZodOptional<z.ZodString>;
251
- max: z.ZodOptional<z.ZodNumber>;
252
- secondaryFormat: z.ZodOptional<z.ZodEnum<["number", "percent", "currency", "compact"]>>;
253
- totals: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
254
- perIcon: z.ZodOptional<z.ZodNumber>;
255
- }, "strict", z.ZodTypeAny, {
256
- type: "column" | "bar" | "stacked-column" | "stacked-bar" | "line" | "area" | "pie" | "donut" | "funnel" | "gauge" | "scatter" | "radar" | "percent-column" | "percent-bar" | "combo" | "waterfall" | "heatmap" | "dumbbell" | "bullet" | "treemap" | "ring" | "sankey" | "pictogram";
257
- labels: string[];
258
- series: {
259
- values: number[];
260
- name: string;
261
- as?: "bar" | "line" | undefined;
262
- axis?: "primary" | "secondary" | undefined;
263
- }[];
264
- format: "number" | "percent" | "currency" | "compact";
265
- decimals: number;
266
- legend: "auto" | "show" | "hide";
267
- labelsOnData: boolean;
268
- unit?: string | undefined;
269
- highlight?: string | undefined;
270
- max?: number | undefined;
271
- secondaryFormat?: "number" | "percent" | "currency" | "compact" | undefined;
272
- totals?: string[] | undefined;
273
- perIcon?: number | undefined;
274
- }, {
275
- type: "column" | "bar" | "stacked-column" | "stacked-bar" | "line" | "area" | "pie" | "donut" | "funnel" | "gauge" | "scatter" | "radar" | "percent-column" | "percent-bar" | "combo" | "waterfall" | "heatmap" | "dumbbell" | "bullet" | "treemap" | "ring" | "sankey" | "pictogram";
276
- labels: string[];
277
- series: {
278
- values: number[];
279
- name: string;
280
- as?: "bar" | "line" | undefined;
281
- axis?: "primary" | "secondary" | undefined;
282
- }[];
283
- format?: "number" | "percent" | "currency" | "compact" | undefined;
284
- decimals?: number | undefined;
285
- unit?: string | undefined;
286
- legend?: "auto" | "show" | "hide" | undefined;
287
- labelsOnData?: boolean | undefined;
288
- highlight?: string | undefined;
289
- max?: number | undefined;
290
- secondaryFormat?: "number" | "percent" | "currency" | "compact" | undefined;
291
- totals?: string[] | undefined;
292
- perIcon?: number | undefined;
293
- }>;
294
- type ChartSpecInput = z.input<typeof ChartSpec>;
295
- type ChartSpecValue = z.output<typeof ChartSpec>;
296
- declare function formatValue(v: number, spec: Pick<ChartSpecValue, 'format' | 'decimals' | 'unit'>): string;
297
- /** Builds the ECharts option for a spec. Pure; exported for tests and custom renderers. */
298
- declare function chartOption(spec: ChartSpecValue, palette?: BrandPalette): Record<string, unknown>;
299
15
  /** Renders one chart spec to an accessible, responsive SVG string. */
300
16
  declare function renderChartSvg(spec: ChartSpecValue, opts?: {
301
17
  width?: number;
@@ -303,30 +19,7 @@ declare function renderChartSvg(spec: ChartSpecValue, opts?: {
303
19
  palette?: BrandPalette;
304
20
  title?: string;
305
21
  }): Promise<string>;
306
- /** Plain-language summary for screen readers. */
307
- declare function describeChart(spec: ChartSpecValue): string;
308
-
309
- /** YouTube / Vimeo URL parsing for the video layout. */
310
- interface VideoRef {
311
- provider: 'youtube' | 'vimeo';
312
- id: string;
313
- /** Canonical watch URL (used for QR codes and "open" links). */
314
- watchUrl: string;
315
- /** Poster image URL, when the provider exposes a predictable one. */
316
- poster?: string;
317
- }
318
- declare function parseVideoUrl(url: string): VideoRef | undefined;
319
- interface EmbedOptions {
320
- start?: number;
321
- end?: number;
322
- muted?: boolean;
323
- captions?: boolean;
324
- autoplay?: boolean;
325
- }
326
- /** Privacy-friendly player URL (youtube-nocookie, Vimeo with dnt). */
327
- declare function videoEmbedUrl(ref: VideoRef, o: EmbedOptions): string;
328
-
329
- /** CSP source for the inline presenter runtime: script-src '<hash>'. */
330
- declare const RUNTIME_SCRIPT_HASH = "sha256-gElvQAb4VPvKu4UeyJRVKuoHYNp8NGhXwx2EhL7NB88=";
22
+ /** `ChartSvgRenderer` over `renderChartSvg`: the default for `renderDeck`. */
23
+ declare const renderChartSvgs: ChartSvgRenderer;
331
24
 
332
- export { AUTHORING_GUIDE, BrandPalette, CHART_TYPES, ChartSpec, type ChartSpecInput, type ChartSpecValue, type ChartType, type EditableDeck, type EditorField, LOGO_SVG, LayoutCategory, type LayoutEditorInfo, PALETTE, PLACEHOLDER_IMAGE, RUNTIME_SCRIPT_HASH, SINGLE_SERIES_CHARTS, type SlideRef, type VideoRef, addSlide, allLayoutEditorInfo, blankSlide, chartOption, commonSlideFields, deckEditorFields, deckJsonSchema, describeChart, describeLayout, ensureSlideIds, escapeHtml, findSlide, formatValue, inline, isPlaceholderImage, layoutEditorInfo, layoutGalleryDeck, listLayouts, logoLockup, moveSlide, newSlideId, outline, parseDeckSource, parseVideoUrl, prose, removeSlide, renderChartSvg, slideKey, stringifyDeck, updateSlide, videoEmbedUrl };
25
+ export { BrandPalette, ChartSpecValue, ChartSvgRenderer, renderChartSvg, renderChartSvgs };
package/dist/index.js CHANGED
@@ -1,9 +1,17 @@
1
+ import {
2
+ RUNTIME_SCRIPT_HASH
3
+ } from "./chunk-4NSKDQ5V.js";
1
4
  import {
2
5
  AUTHORING_GUIDE,
3
6
  deckJsonSchema,
4
7
  describeLayout,
5
8
  listLayouts
6
- } from "./chunk-ORNJ4CTQ.js";
9
+ } from "./chunk-TB4H2HYA.js";
10
+ import {
11
+ renderChartSvg,
12
+ renderChartSvgs,
13
+ renderDeck
14
+ } from "./chunk-WTTBHOBM.js";
7
15
  import {
8
16
  BrandPaletteSchema,
9
17
  BrandProfileSchema,
@@ -27,7 +35,9 @@ import {
27
35
  addSlide,
28
36
  allLayoutEditorInfo,
29
37
  blankSlide,
38
+ chartIssues,
30
39
  chartOption,
40
+ chartWarnings,
31
41
  checkPalette,
32
42
  collectImageSources,
33
43
  commonSlideFields,
@@ -39,6 +49,7 @@ import {
39
49
  extractDeckSource,
40
50
  fieldMarkers,
41
51
  findSlide,
52
+ finishChartSvg,
42
53
  formatIssues,
43
54
  formatPath,
44
55
  formatValue,
@@ -57,8 +68,6 @@ import {
57
68
  parseVideoUrl,
58
69
  prose,
59
70
  removeSlide,
60
- renderChartSvg,
61
- renderDeck,
62
71
  resolveBrand,
63
72
  slideKey,
64
73
  speakerNotes,
@@ -67,10 +76,7 @@ import {
67
76
  validateBrandProfile,
68
77
  validateDeck,
69
78
  videoEmbedUrl
70
- } from "./chunk-HI5ZCAHO.js";
71
-
72
- // src/generated/runtime-hash.ts
73
- var RUNTIME_SCRIPT_HASH = "sha256-gElvQAb4VPvKu4UeyJRVKuoHYNp8NGhXwx2EhL7NB88=";
79
+ } from "./chunk-R5HURANW.js";
74
80
  export {
75
81
  AUTHORING_GUIDE,
76
82
  BrandPaletteSchema,
@@ -96,7 +102,9 @@ export {
96
102
  addSlide,
97
103
  allLayoutEditorInfo,
98
104
  blankSlide,
105
+ chartIssues,
99
106
  chartOption,
107
+ chartWarnings,
100
108
  checkPalette,
101
109
  collectImageSources,
102
110
  commonSlideFields,
@@ -110,6 +118,7 @@ export {
110
118
  extractDeckSource,
111
119
  fieldMarkers,
112
120
  findSlide,
121
+ finishChartSvg,
113
122
  formatIssues,
114
123
  formatPath,
115
124
  formatValue,
@@ -130,6 +139,7 @@ export {
130
139
  prose,
131
140
  removeSlide,
132
141
  renderChartSvg,
142
+ renderChartSvgs,
133
143
  renderDeck,
134
144
  resolveBrand,
135
145
  slideKey,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/generated/runtime-hash.ts"],"sourcesContent":["// Generated by scripts/embed-fonts.ts. Do not edit.\n/** CSP source for the inline presenter runtime: script-src '<hash>'. */\nexport const RUNTIME_SCRIPT_HASH = 'sha256-gElvQAb4VPvKu4UeyJRVKuoHYNp8NGhXwx2EhL7NB88=';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEO,IAAM,sBAAsB;","names":[]}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -2,13 +2,14 @@ import {
2
2
  AUTHORING_GUIDE,
3
3
  describeLayout,
4
4
  listLayouts
5
- } from "./chunk-ORNJ4CTQ.js";
5
+ } from "./chunk-TB4H2HYA.js";
6
6
  import {
7
7
  buildDeckFile,
8
8
  confinedPath,
9
9
  loadDeckFile,
10
10
  saveDeckFile
11
- } from "./chunk-UKRX7A2V.js";
11
+ } from "./chunk-RWMCIAIW.js";
12
+ import "./chunk-WTTBHOBM.js";
12
13
  import {
13
14
  addSlide,
14
15
  formatIssues,
@@ -18,7 +19,7 @@ import {
18
19
  stringifyDeck,
19
20
  updateSlide,
20
21
  validateDeck
21
- } from "./chunk-HI5ZCAHO.js";
22
+ } from "./chunk-R5HURANW.js";
22
23
 
23
24
  // src/node/mcp.ts
24
25
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
@@ -320,4 +321,4 @@ export {
320
321
  createSlidesMcpServer,
321
322
  runStdio
322
323
  };
323
- //# sourceMappingURL=mcp-MG2E7J3I.js.map
324
+ //# sourceMappingURL=mcp-FYZGFSBM.js.map