@treasure-ai/treasure-deck 2026.11.5 → 2026.11.7

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 (55) hide show
  1. package/dist/build.d.ts +10 -4
  2. package/dist/build.js +27 -8
  3. package/dist/build.js.map +1 -1
  4. package/dist/charts.d.ts +17 -0
  5. package/dist/charts.js +454 -0
  6. package/dist/charts.js.map +1 -0
  7. package/dist/check.d.ts +6 -0
  8. package/dist/check.js +47 -1
  9. package/dist/check.js.map +1 -1
  10. package/dist/chrome.js +2 -0
  11. package/dist/chrome.js.map +1 -1
  12. package/dist/cli.js +4 -4
  13. package/dist/cli.js.map +1 -1
  14. package/dist/components.d.ts +13 -0
  15. package/dist/components.js +46 -0
  16. package/dist/components.js.map +1 -0
  17. package/dist/deckindex.js +2 -2
  18. package/dist/deckindex.js.map +1 -1
  19. package/dist/deckstyle.js +1 -1
  20. package/dist/dev.js +15 -11
  21. package/dist/dev.js.map +1 -1
  22. package/dist/diagrams.d.ts +15 -8
  23. package/dist/diagrams.js +60 -26
  24. package/dist/diagrams.js.map +1 -1
  25. package/dist/render.d.ts +21 -1
  26. package/dist/render.js +111 -1
  27. package/dist/render.js.map +1 -1
  28. package/dist/scaffold.d.ts +2 -0
  29. package/dist/scaffold.js +4 -2
  30. package/dist/scaffold.js.map +1 -1
  31. package/dist/slides.js +8 -4
  32. package/dist/slides.js.map +1 -1
  33. package/dist/slidesexport.js +2 -2
  34. package/dist/slidesexport.js.map +1 -1
  35. package/dist/themecheck.d.ts +2 -2
  36. package/dist/themecheck.js +5 -5
  37. package/dist/themecheck.js.map +1 -1
  38. package/dist/vendor.d.ts +10 -1
  39. package/dist/vendor.js +32 -2
  40. package/dist/vendor.js.map +1 -1
  41. package/docs/commands.md +5 -2
  42. package/docs/syntax.md +102 -2
  43. package/docs/themes.md +1 -1
  44. package/package.json +8 -1
  45. package/runtime/base.css +73 -0
  46. package/runtime/embed.js +9 -6
  47. package/runtime/runtime.js +321 -10
  48. package/skills/treasure-deck/SKILL.md +53 -2
  49. package/vendor/echarts/LICENSE +222 -0
  50. package/vendor/echarts/echarts.min.js +45 -0
  51. package/vendor/react/LICENSE-react +21 -0
  52. package/vendor/react/LICENSE-react-dom +21 -0
  53. package/vendor/react/LICENSE-recharts +22 -0
  54. package/vendor/react/LICENSE-tailwindcss +21 -0
  55. package/vendor/react/deck-react.js +78 -0
@@ -59,10 +59,30 @@
59
59
  '<h2>Keyboard shortcuts</h2><table>' +
60
60
  [['→ Space PgDn', 'Next slide'], ['← PgUp', 'Previous slide'], ['Home / End', 'First / last'],
61
61
  ['1 2 … Enter', 'Go to slide'], ['f', 'Full screen'], ['o / Esc', 'Overview'], ['t', 'Table of contents', 1], ['p', 'Speaker notes + timer', 1], ['P', 'Presenter window', 1], ['k / r', 'Pause / reset the timer', 1],
62
- ['b / .', 'Black screen', 1], ['d', 'Light / dark', 1], ['l', 'Laser pointer', 1], ['s', 'Share'], ['?', 'This help']]
62
+ ['b / .', 'Black screen', 1], ['d', 'Light / dark', 1], ['l', 'Laser pointer', 1], ['s', 'Share'], ['i', 'About this deck'], ['?', 'This help']]
63
63
  .map(function (r) { return '<tr' + (r[2] ? ' class="deck-not-embed"' : '') + '><td><kbd>' + r[0] + '</kbd></td><td>' + r[1] + '</td></tr>'; }).join('') +
64
64
  '</table>');
65
65
  help.hidden = true;
66
+ // Who wrote the deck and when, from the page's <meta> tags (the frontmatter's author, date, and description), so
67
+ // a reader of a published or embedded copy can find its contact.
68
+ var about = el('div', 'deck-panel deck-about');
69
+ about.hidden = true;
70
+ function renderAbout() {
71
+ var field = function (name) { var m = document.querySelector('meta[name="' + name + '"]'); return m && m.content.trim(); };
72
+ var rows = [['Author', field('author')], ['Date', field('date')], ['About', field('description')]].filter(function (r) { return r[1]; });
73
+ about.textContent = '';
74
+ about.appendChild(el('h2')).textContent = document.title || 'About this deck';
75
+ if (!rows.length) {
76
+ about.appendChild(el('p', 'deck-about-none')).textContent = 'This deck names no author or date. Add author: and date: to its frontmatter.';
77
+ return;
78
+ }
79
+ var table = about.appendChild(el('table'));
80
+ rows.forEach(function (r) {
81
+ var tr = table.appendChild(el('tr'));
82
+ tr.appendChild(el('td')).textContent = r[0];
83
+ tr.appendChild(el('td')).textContent = r[1];
84
+ });
85
+ }
66
86
  var share = el('div', 'deck-panel deck-share',
67
87
  '<h2>Share</h2>' +
68
88
  '<button data-act="link">Copy link to deck</button>' +
@@ -89,7 +109,7 @@
89
109
  '<button data-act="fullscreen" aria-label="Full screen">⛶</button>' +
90
110
  '<a data-act="open" target="_blank" rel="noopener">Open ↗</a>');
91
111
  embedBar.hidden = true;
92
- [progress, black, laser, gotoBox, help, share, notesPanel, embedBar].forEach(function (e) { deck.appendChild(e); });
112
+ [progress, black, laser, gotoBox, help, about, share, notesPanel, embedBar].forEach(function (e) { deck.appendChild(e); });
93
113
 
94
114
  function fit() {
95
115
  if (presenter) { layoutPresenter(); return; }
@@ -119,6 +139,7 @@
119
139
  renderPresenter();
120
140
  renderEmbedBar();
121
141
  playVideos(i);
142
+ replayComponents(i);
122
143
  if (deck.classList.contains('is-overview')) slides[i].scrollIntoView({ block: 'nearest' });
123
144
  // For the access metrics `deck build` adds: page numbers as presented, from 1.
124
145
  var heading = slides[i].querySelector('h1, h2, h3');
@@ -228,10 +249,11 @@
228
249
 
229
250
  function toggle(panel) {
230
251
  var open = panel.hidden;
231
- [help, share].forEach(function (p) { if (p !== panel) p.hidden = true; });
252
+ [help, about, share].forEach(function (p) { if (p !== panel) p.hidden = true; });
232
253
  panel.hidden = !open;
233
254
  if (panel === share) offerOpen();
234
- if (open) used(panel === share ? 'share' : panel === help ? 'help' : 'notes');
255
+ if (open) used(panel === share ? 'share' : panel === help ? 'help' : panel === about ? 'about' : 'notes');
256
+ if (panel === about) renderAbout();
235
257
  if (panel === notesPanel) renderNotes();
236
258
  }
237
259
 
@@ -240,7 +262,7 @@
240
262
  var pressed = null;
241
263
  document.addEventListener('pointerdown', function (e) { pressed = e.target; }, true);
242
264
  document.addEventListener('click', function (e) {
243
- var open = [help, share].filter(function (p) { return !p.hidden; });
265
+ var open = [help, about, share].filter(function (p) { return !p.hidden; });
244
266
  var inside = function (p) { return p.contains(e.target) || (pressed && p.contains(pressed)); };
245
267
  if (!open.length || open.some(inside)) return;
246
268
  open.forEach(function (p) { p.hidden = true; });
@@ -409,7 +431,7 @@
409
431
  document.addEventListener('keydown', function (e) {
410
432
  if (e.metaKey || e.ctrlKey || e.altKey) return;
411
433
  var k = e.key;
412
- if (embedded && !/^([0-9]|Enter|Arrow(Left|Right|Up|Down)|Page(Up|Down)|Backspace|Home|End| |f|o|Escape|s|\?)$/.test(k)) return;
434
+ if (embedded && !/^([0-9]|Enter|Arrow(Left|Right|Up|Down)|Page(Up|Down)|Backspace|Home|End| |f|o|Escape|s|i|\?)$/.test(k)) return;
413
435
  if (/^[0-9]$/.test(k)) { typeDigit(k); return; }
414
436
  if (k === 'Enter' && typed) { show(parseInt(typed, 10) - 1); typed = ''; gotoBox.hidden = true; return; }
415
437
  if (deck.classList.contains('is-black') && k !== 'b' && k !== '.') { deck.classList.remove('is-black'); sync({ black: false }); renderPresenter(); return; }
@@ -421,7 +443,7 @@
421
443
  case 'f': fullscreen(); break;
422
444
  case 'o': deck.classList.toggle('is-overview'); show(current); break;
423
445
  case 'Escape':
424
- if (!help.hidden || !share.hidden) { help.hidden = share.hidden = true; }
446
+ if (!help.hidden || !about.hidden || !share.hidden) { help.hidden = about.hidden = share.hidden = true; }
425
447
  else { deck.classList.toggle('is-overview'); show(current); }
426
448
  break;
427
449
  case 't': deck.classList.toggle('show-toc'); sync({ toc: deck.classList.contains('show-toc') }); if (deck.classList.contains('show-toc')) used('toc'); break;
@@ -433,6 +455,7 @@
433
455
  case 'd': setMode(deck.getAttribute('data-mode') === 'dark' ? 'light' : 'dark'); used('mode'); break;
434
456
  case 'l': deck.classList.toggle('is-laser'); if (deck.classList.contains('is-laser')) used('laser'); break;
435
457
  case 's': toggle(share); break;
458
+ case 'i': toggle(about); break;
436
459
  case '?': toggle(help); break;
437
460
  default: return;
438
461
  }
@@ -629,6 +652,290 @@
629
652
  return diagramQueue;
630
653
  }
631
654
  var diagramsDone = renderDiagrams(Array.prototype.slice.call(stage.querySelectorAll('pre.mermaid:not([data-processed])')));
655
+
656
+ // Theme colors of one slide, for charts and components: `rgb(value)` resolves any CSS color (var(--deck-…),
657
+ // color-mix() of them) against the slide to rgb()/rgba(), through a canvas since derived tokens compute to oklch().
658
+ var THEME_TOKENS = ['--deck-series-1', '--deck-series-2', '--deck-series-3', '--deck-series-4', '--deck-series-5', '--deck-series-6',
659
+ '--deck-accent', '--deck-accent-2', '--deck-fg', '--deck-fg-muted', '--deck-line', '--deck-bg', '--deck-card', '--deck-ok', '--deck-warn'];
660
+ function slideColors(slide) {
661
+ var probe = document.createElement('span');
662
+ probe.style.display = 'none';
663
+ slide.appendChild(probe);
664
+ var pixel = document.createElement('canvas').getContext('2d', { willReadFrequently: true });
665
+ var cache = {};
666
+ function rgb(value) {
667
+ if (cache[value]) return cache[value];
668
+ probe.style.color = '';
669
+ probe.style.color = value;
670
+ var c = getComputedStyle(probe).color;
671
+ if (!/^rgba?\(/.test(c) && pixel) {
672
+ pixel.clearRect(0, 0, 1, 1);
673
+ pixel.fillStyle = c;
674
+ pixel.fillRect(0, 0, 1, 1);
675
+ var d = pixel.getImageData(0, 0, 1, 1).data;
676
+ c = d[3] === 255 ? 'rgb(' + d[0] + ', ' + d[1] + ', ' + d[2] + ')' : 'rgba(' + d[0] + ', ' + d[1] + ', ' + d[2] + ', ' + (d[3] / 255).toFixed(3) + ')';
677
+ }
678
+ return (cache[value] = c);
679
+ }
680
+ var cs = getComputedStyle(slide);
681
+ var t = {};
682
+ THEME_TOKENS.forEach(function (n) { t[n] = rgb('var(' + n + ')'); });
683
+ var bg = /(\d+)\D+(\d+)\D+(\d+)/.exec(t['--deck-bg']) || [0, 255, 255, 255];
684
+ var dark = (0.2126 * bg[1] + 0.7152 * bg[2] + 0.0722 * bg[3]) / 255 < 0.5;
685
+ var colors = {
686
+ rgb: rgb, tokens: t, dark: dark,
687
+ font: (cs.getPropertyValue('--deck-font-body') || cs.fontFamily || 'sans-serif').trim(),
688
+ done: function () { probe.remove(); },
689
+ };
690
+ return colors;
691
+ }
692
+
693
+ // ```chart: an ECharts option (compiled by `deck build` from the short form, src/charts.ts), drawn as SVG with the
694
+ // slide's theme: series colors, text, lines, and font. Strings in the option with var() or color-mix() resolve
695
+ // against the slide, and the drawing's colors point back at the tokens, so the `d` mode switch recolors it. As with
696
+ // Mermaid, `deck build` draws charts ahead of time in headless Chrome and inlines the SVG (data-processed); ECharts
697
+ // comes from a page-provided window.echarts (deck dev, check, pdf) or jsDelivr. A chart that fails records data-error.
698
+ var loadECharts = null, chartQueue = Promise.resolve();
699
+ function chartTheme(c) {
700
+ var t = c.tokens;
701
+ var axis = {
702
+ axisLine: { lineStyle: { color: t['--deck-line'], width: 1.5 } }, axisTick: { lineStyle: { color: t['--deck-line'] } },
703
+ axisLabel: { color: t['--deck-fg-muted'], fontSize: 17, fontFamily: c.font },
704
+ splitLine: { lineStyle: { color: t['--deck-line'], type: [4, 4] } },
705
+ nameTextStyle: { color: t['--deck-fg-muted'], fontSize: 16, fontFamily: c.font },
706
+ };
707
+ return {
708
+ color: [1, 2, 3, 4, 5, 6].map(function (n) { return t['--deck-series-' + n]; }),
709
+ backgroundColor: 'transparent',
710
+ textStyle: { color: t['--deck-fg'], fontFamily: c.font, fontSize: 17 },
711
+ title: { textStyle: { color: t['--deck-fg'], fontSize: 22, fontWeight: 700, fontFamily: c.font } },
712
+ legend: { textStyle: { color: t['--deck-fg'], fontSize: 17, fontFamily: c.font }, itemWidth: 18, itemHeight: 12 },
713
+ categoryAxis: axis, valueAxis: axis, logAxis: axis, timeAxis: axis,
714
+ radar: { axisName: { color: t['--deck-fg'], fontSize: 17 }, splitLine: { lineStyle: { color: t['--deck-line'] } }, splitArea: { show: false }, axisLine: { lineStyle: { color: t['--deck-line'] } } },
715
+ gauge: { title: { color: t['--deck-fg-muted'] }, detail: { color: t['--deck-fg'] } },
716
+ };
717
+ }
718
+ function resolveOption(value, c) {
719
+ if (typeof value === 'string') return /var\(|color-mix\(/.test(value) ? c.rgb(value) : value;
720
+ if (Array.isArray(value)) return value.map(function (v) { return resolveOption(v, c); });
721
+ if (value && typeof value === 'object') {
722
+ var out = {};
723
+ Object.keys(value).forEach(function (k) { out[k] = resolveOption(value[k], c); });
724
+ return out;
725
+ }
726
+ return value;
727
+ }
728
+ function renderCharts(plots) {
729
+ if (!plots.length) return Promise.resolve();
730
+ var fontsReady = document.fonts && document.fonts.ready ? document.fonts.ready : Promise.resolve();
731
+ loadECharts = loadECharts || (window.echarts ? Promise.resolve(window.echarts)
732
+ : import('https://cdn.jsdelivr.net/npm/echarts@6/dist/echarts.esm.min.mjs').then(function (m) { return m.default || m; }));
733
+ chartQueue = chartQueue.then(function () { return Promise.all([loadECharts, fontsReady]); }).then(function (r) {
734
+ var echarts = r[0];
735
+ plots.forEach(function (plot) {
736
+ var box = plot.parentNode, slide = box.closest('.slide');
737
+ if (!slide) return;
738
+ var c = slideColors(slide);
739
+ try {
740
+ var option = resolveOption(JSON.parse(box.querySelector('script[type="application/json"]').textContent), c);
741
+ option.animation = false;
742
+ var w = plot.clientWidth || 640, h = plot.clientHeight || 360;
743
+ // Server-side rendering mode draws at once, to a string (the DOM renderer paints on a later frame).
744
+ var chart = echarts.init(null, chartTheme(c), { renderer: 'svg', ssr: true, width: w, height: h });
745
+ chart.setOption(option);
746
+ plot.innerHTML = chart.renderToSVGString();
747
+ chart.dispose();
748
+ var svg = plot.querySelector('svg');
749
+ if (!svg) throw new Error('ECharts drew nothing');
750
+ svg.setAttribute('viewBox', '0 0 ' + w + ' ' + h);
751
+ svg.removeAttribute('width');
752
+ svg.removeAttribute('height');
753
+ svg.style.cssText = '';
754
+ // Colors that are theme tokens follow them (the `d` switch, a theme edit), with today's color as the fallback.
755
+ var tokenOf = {};
756
+ THEME_TOKENS.forEach(function (n) { var k = c.tokens[n].replace(/\s/g, ''); if (!tokenOf[k]) tokenOf[k] = n; });
757
+ svg.querySelectorAll('[fill], [stroke]').forEach(function (n) {
758
+ ['fill', 'stroke'].forEach(function (p) {
759
+ var v = n.getAttribute(p), k = v && tokenOf[v.replace(/\s/g, '')];
760
+ if (k) n.style.setProperty(p, 'var(' + k + ', ' + v + ')');
761
+ });
762
+ });
763
+ plot.setAttribute('data-processed', 'true');
764
+ plot.removeAttribute('data-error');
765
+ } catch (e) {
766
+ plot.setAttribute('data-error', (e && e.message) || String(e));
767
+ plot.textContent = 'Chart failed: ' + ((e && e.message) || e);
768
+ console.warn('treasure-deck: a chart failed', e);
769
+ } finally {
770
+ c.done();
771
+ }
772
+ });
773
+ }).catch(function (e) { console.warn('treasure-deck: ECharts failed to load', e); });
774
+ return chartQueue;
775
+ }
776
+ var chartsDone = renderCharts(Array.prototype.slice.call(stage.querySelectorAll('.chart > .chart-plot:not([data-processed])')));
777
+
778
+ // React components (`![](kpi.jsx)`, ```react; compiled by `deck build`, src/components.ts): each mounts in its own
779
+ // shadow root with Treasure Work's render_react contract, React's hooks and Recharts in scope, `data` from data=,
780
+ // `isDark` and `theme` from the slide's background, and `palette` with the slide's resolved theme colors. The
781
+ // Tailwind subset render_react ships is scoped to the shadow root, so its reset never touches the slide. React comes
782
+ // from window.__DECK_REACT__ (inlined by `deck build`, vendor/react/deck-react.js). A component that throws shows its
783
+ // error and records data-error. When its slide is shown it mounts again, so its charts animate in (unless the
784
+ // viewer prefers reduced motion, as `deck check` and `deck pdf` do).
785
+ var reactLib = null, reactSheet = null, mounted = [];
786
+ function reactOf() {
787
+ if (reactLib) return reactLib;
788
+ var lib = window.__DECK_REACT__;
789
+ try { if (!lib && window.opener) lib = window.opener.__DECK_REACT__; } catch (e) { /* cross-origin opener */ }
790
+ if (!lib) return null;
791
+ // @property rules don't apply inside a shadow root: Tailwind's are declared on the page instead.
792
+ var props = (lib.css.match(/@property[^{]+\{[^}]*\}/g) || []).join('\n');
793
+ if (props) { var st = document.createElement('style'); st.textContent = props; document.head.appendChild(st); }
794
+ try { reactSheet = new CSSStyleSheet(); reactSheet.replaceSync(lib.css); } catch (e) { reactSheet = null; }
795
+ return (reactLib = lib);
796
+ }
797
+ var factoryId = 0;
798
+ function componentFactory(code) {
799
+ // An inline script rather than eval, as render_react does (a page's CSP may forbid eval).
800
+ var key = '__deckComponent' + (++factoryId);
801
+ var R = reactOf();
802
+ var s = document.createElement('script');
803
+ s.textContent = 'window.' + key + ' = function (React, Recharts, isDark, theme, palette) {\n' +
804
+ 'const { ' + REACT_NAMES + ' } = React;\nconst { ' + Object.keys(R.Recharts).filter(function (n) { return /^[A-Z][\w$]*$/.test(n); }).join(', ') + ' } = Recharts;\n' +
805
+ 'return (function () {\n' + code + '\n})();\n};';
806
+ document.head.appendChild(s);
807
+ s.remove();
808
+ var f = window[key];
809
+ delete window[key];
810
+ if (typeof f !== 'function') throw new Error('the component did not load (a syntax error? see the console)');
811
+ return f;
812
+ }
813
+ var REACT_NAMES = 'useState, useEffect, useMemo, useCallback, useRef, useReducer, useContext, useLayoutEffect, useId, Fragment, createElement';
814
+ function mountComponents(hosts) {
815
+ var R = reactOf(), added = [];
816
+ hosts.forEach(function (host) {
817
+ if (host.shadowRoot || !host.closest('.slide')) return;
818
+ var root = host.attachShadow({ mode: 'open' });
819
+ if (!R) {
820
+ host.setAttribute('data-error', 'React is not loaded on this page');
821
+ root.innerHTML = '<div style="padding:12px;border:1px dashed currentColor;opacity:.6">React component: this page has no React (build it with deck build)</div>';
822
+ return;
823
+ }
824
+ if (reactSheet) root.adoptedStyleSheets = [reactSheet];
825
+ else { var st = document.createElement('style'); st.textContent = R.css; root.appendChild(st); }
826
+ var frame = document.createElement('div');
827
+ frame.className = 'deck-component-root';
828
+ root.appendChild(frame);
829
+ var scripts = host.querySelectorAll(':scope > script');
830
+ var entry = { host: host, frame: frame, code: scripts[0].textContent, data: JSON.parse(scripts[1].textContent || 'null'), round: 0 };
831
+ try {
832
+ entry.factory = componentFactory(entry.code);
833
+ } catch (e) {
834
+ failComponent(entry, e);
835
+ return;
836
+ }
837
+ entry.root = R.createRoot(frame);
838
+ mounted.push(entry);
839
+ added.push(entry);
840
+ renderComponent(entry);
841
+ });
842
+ return added;
843
+ }
844
+ var ERROR_STYLE = 'padding:12px 14px;border-radius:8px;border:1px solid #f87171;background:#fef2f2;color:#991b1b;font:14px/1.4 ui-monospace,monospace;white-space:pre-wrap';
845
+ function errorElement(React, message) {
846
+ return React.createElement('div', { ref: function (n) { if (n) n.style.cssText = ERROR_STYLE; } }, 'Component error: ' + message);
847
+ }
848
+ function failComponent(entry, e) {
849
+ var message = (e && e.message) || String(e);
850
+ entry.host.setAttribute('data-error', message);
851
+ console.warn('treasure-deck: a component failed', e);
852
+ if (entry.root) {
853
+ var React = reactLib.React;
854
+ reactLib.flushSync(function () { entry.root.render(errorElement(React, message)); });
855
+ return;
856
+ }
857
+ var box = document.createElement('div');
858
+ box.style.cssText = ERROR_STYLE;
859
+ box.textContent = 'Component error: ' + message;
860
+ entry.frame.appendChild(box);
861
+ }
862
+ function renderComponent(entry) {
863
+ var R = reactLib, React = R.React;
864
+ var slide = entry.host.closest('.slide');
865
+ if (!slide) return;
866
+ var c = slideColors(slide);
867
+ c.done();
868
+ var t = c.tokens;
869
+ var palette = {
870
+ series: [1, 2, 3, 4, 5, 6].map(function (n) { return t['--deck-series-' + n]; }),
871
+ accent: t['--deck-accent'], accent2: t['--deck-accent-2'], fg: t['--deck-fg'], muted: t['--deck-fg-muted'],
872
+ line: t['--deck-line'], card: t['--deck-card'], bg: t['--deck-bg'], ok: t['--deck-ok'], warn: t['--deck-warn'], font: c.font,
873
+ };
874
+ var mode = c.dark ? 'dark' : 'light';
875
+ entry.frame.classList.toggle('dark', c.dark);
876
+ entry.host.removeAttribute('data-error');
877
+ var Component;
878
+ try {
879
+ if (entry.mode !== mode || !entry.Component) entry.Component = entry.factory(React, R.Recharts, c.dark, mode, palette);
880
+ Component = entry.Component;
881
+ if (typeof Component !== 'function') throw new Error('the code must export a component: export default function Name({ data }) { ... }');
882
+ } catch (e) {
883
+ failComponent(entry, e);
884
+ return;
885
+ }
886
+ entry.mode = mode;
887
+ function Boundary(props) { React.Component.call(this, props); this.state = { error: null }; }
888
+ Boundary.prototype = Object.create(React.Component.prototype);
889
+ Boundary.prototype.constructor = Boundary;
890
+ Boundary.getDerivedStateFromError = function (error) { return { error: error }; };
891
+ Boundary.prototype.componentDidCatch = function (error) {
892
+ entry.host.setAttribute('data-error', (error && error.message) || String(error));
893
+ console.warn('treasure-deck: a component failed', error);
894
+ };
895
+ Boundary.prototype.render = function () {
896
+ var error = this.state.error;
897
+ return error ? errorElement(React, (error && error.message) || String(error)) : this.props.children;
898
+ };
899
+ R.flushSync(function () {
900
+ entry.root.render(React.createElement(Boundary, { key: entry.round },
901
+ React.createElement(Component, { data: entry.data, isDark: c.dark, theme: mode, palette: palette })));
902
+ });
903
+ }
904
+ // Resolves once the components' DOM has been quiet for a moment (Recharts draws after measuring its container).
905
+ function componentsSettled(entries) {
906
+ if (!entries.length) return Promise.resolve();
907
+ return new Promise(function (resolve) {
908
+ var timer = null, start = Date.now();
909
+ var observer = new MutationObserver(function () { kick(); });
910
+ entries.forEach(function (e) { observer.observe(e.frame, { childList: true, subtree: true, attributes: true, characterData: true }); });
911
+ function kick() {
912
+ clearTimeout(timer);
913
+ timer = setTimeout(function () { observer.disconnect(); resolve(); }, Date.now() - start > 4000 ? 0 : 200);
914
+ }
915
+ kick();
916
+ });
917
+ }
918
+ var reducedMotion = window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
919
+ function replayComponents(i) {
920
+ if (!mounted || presenter || reducedMotion || deck.classList.contains('is-overview')) return;
921
+ mounted.forEach(function (entry) {
922
+ if (entry.host.closest('.slide') !== slides[i] || !entry.Component) return;
923
+ entry.round++;
924
+ renderComponent(entry);
925
+ });
926
+ }
927
+ // The deck's mode switched (`d`): components on slides whose background changed render again with isDark.
928
+ function refreshComponents() {
929
+ if (!mounted) return;
930
+ mounted = mounted.filter(function (entry) { if (entry.host.isConnected) return true; if (entry.root) entry.root.unmount(); return false; });
931
+ mounted.forEach(function (entry) { if (entry.Component) renderComponent(entry); });
932
+ }
933
+ function componentHosts(root) { return Array.prototype.slice.call(root.querySelectorAll('.slide .component')); }
934
+ var componentsDone = componentsSettled(mountComponents(componentHosts(stage)));
935
+ // The editor's thumbnails are copies of the slides: it mounts their components with this.
936
+ window.deckMountComponents = function (root) {
937
+ return componentsSettled(mountComponents(Array.prototype.slice.call(root.querySelectorAll('.component'))));
938
+ };
632
939
  // Code blocks whose longest line is wider than their panel (a long line, or a column narrowed by the table of
633
940
  // contents sidebar) shrink their font just enough to fit, down to 12px, instead of clipping. Blocks that fit
634
941
  // keep the theme's size. Runs once fonts are ready and again whenever the sidebar is toggled.
@@ -688,7 +995,7 @@
688
995
  }
689
996
  window.addEventListener('beforeprint', function () { measureTableHeads(); });
690
997
  // Resolves once fonts and diagrams are rendered; `deck pdf` waits on it before printing.
691
- window.deckReady = Promise.all([document.fonts ? document.fonts.ready : null, diagramsDone]).then(function () {
998
+ window.deckReady = Promise.all([document.fonts ? document.fonts.ready : null, diagramsDone, chartsDone, componentsDone]).then(function () {
692
999
  fitSlides();
693
1000
  fitCode();
694
1001
  measureTableHeads();
@@ -698,9 +1005,12 @@
698
1005
  // window.deckUpdated resolves once they are.
699
1006
  document.addEventListener('deck:slides-updated', function (e) {
700
1007
  var changed = e.detail.slides;
701
- window.deckUpdated = renderDiagrams(changed.reduce(function (all, s) {
1008
+ var plots = changed.reduce(function (all, s) { return all.concat(Array.prototype.slice.call(s.querySelectorAll('.chart > .chart-plot:not([data-processed])'))); }, []);
1009
+ mounted = mounted.filter(function (entry) { if (entry.host.isConnected) return true; entry.root.unmount(); return false; });
1010
+ var added = mountComponents(changed.reduce(function (all, s) { return all.concat(Array.prototype.slice.call(s.querySelectorAll('.component'))); }, []));
1011
+ window.deckUpdated = Promise.all([renderDiagrams(changed.reduce(function (all, s) {
702
1012
  return all.concat(Array.prototype.slice.call(s.querySelectorAll('pre.mermaid:not([data-processed])')));
703
- }, [])).then(function () {
1013
+ }, [])), renderCharts(plots), componentsSettled(added)]).then(function () {
704
1014
  fitSlides(changed);
705
1015
  changed.forEach(function (s) { fitCode(s); measureTableHeads(s); });
706
1016
  return true;
@@ -738,6 +1048,7 @@
738
1048
  function setMode(mode, fromPeer) {
739
1049
  deck.setAttribute('data-mode', mode);
740
1050
  if (!fromPeer) sync({ mode: mode });
1051
+ refreshComponents();
741
1052
  renderPresenter();
742
1053
  }
743
1054
  // An embed is a reader's copy: it neither steers nor follows a talk being presented from the same deck.
@@ -32,7 +32,7 @@ Open the editor as soon as the starter exists, then write the deck while the use
32
32
  1. **Create the file.** `deck new deck/YYYY-MM-DD-<slug>` writes a starter deck that already builds. Options: `--title`, `--theme` (`default`, `editorial`, `pastel`, `gold`, `treasure-ai`, `treasure-ai-2026`, `wvlet`), `--author` (defaults to git's `user.name`). For an existing deck, read the whole file first and match its style.
33
33
  2. **Open the editor immediately.** In Treasure Work, call the `work` server's `deck_editor` with `action: "open"` and the absolute path. Elsewhere, run `deck editor <folder>` in the background. Open it once: it reloads on each save and never overwrites the user's edits.
34
34
  3. **Plan the story.** Write the sections and one sentence per slide saying what it proves. Plan one content slide per 1.5–2 minutes of talk, and 3–5 sections for 20 minutes or more.
35
- 4. **Write in small steps.** Replace the starter's slides with the title slide and `--- section` lines first, then add a section or a few slides per edit. Keep the file building after every edit.
35
+ 4. **Write in small steps.** Replace the starter's slides with the title slide and `--- section` lines first (keep the author and date lines on the title slide), then add a section or a few slides per edit. Keep the file building after every edit.
36
36
  5. **Check.** Run `deck check <folder>` and fix every finding: shorten, split the slide, or switch to columns. Rerun until clean.
37
37
  6. **Hand over.** Name anything you were unsure of, such as inferred numbers or images still to supply. Don't call the deck done before the check is clean.
38
38
 
@@ -53,7 +53,7 @@ A deck is CommonMark + GFM with the additions below. Anything unknown is a build
53
53
  |---|---|
54
54
  | `deck: true` | Marks the file as a deck (required) |
55
55
  | `title` | The page title, or the first heading when unset |
56
- | `author`, `date` | Not used by the slides: write them in the title slide's body, as `deck new` does |
56
+ | `author`, `date` | Who to contact and when, after the deck is published: in the page's `<meta>` tags and the `i` panel. Write them on the title slide too, as `deck new` does (the slides don't show them on their own) |
57
57
  | `theme` | `default` (unbranded), `editorial`, `pastel`, `gold` (Treasure Work), `treasure-ai`, `treasure-ai-2026` (the 2026 Treasure AI brand), `wvlet`, or `./folder` (a theme folder next to the deck) |
58
58
  | `mode` | `light` or `dark` |
59
59
  | `accent` | `"#hex"`, recolors the accent everywhere |
@@ -132,11 +132,21 @@ Reach for `nowrap` on short label, number, and unit columns that break awkwardly
132
132
  - A `mermaid` fence draws a diagram colored by the theme. Give a node a role with `A[Label]:::accent` (also `:::dark`, `:::muted`, `:::light`). Size it on the fence line: `mermaid {w=60%}` (canvas px or % of the column) or `mermaid {h=300}`.
133
133
  - A diagram scales to its column's width, so its text shrinks with it. Keep it to about 5–6 nodes with one-to-three-word labels. Use `flowchart TB` in a column, and `LR` only for a short chain (3–4 nodes) or a full-width slide. `deck check` warns when labels render below 13px.
134
134
 
135
+ ### Charts and components
136
+
137
+ - A `chart` fence draws a chart in the theme's colors. Short form: `type:` (`bar`, `line`, `area`, `pie`, `donut`, `scatter`, `funnel`, `gauge`, `radar`, `treemap`, `sankey`, `horizontal-bar`, `stacked-bar`), `x: [categories]`, `series: {Name: [values]}` (or one list), or `data: file.csv` (first column the categories); a `sankey` takes `links: [[from, to, value], ...]` by name. Options: `stack: true`, `horizontal: true`, `labels: true`, `highlight: Q4` (that bar in the accent, the rest muted), `prefix: "$"`, `unit: M`, `min`/`max`, and for a gauge `value:` and `name:`. `render_chart`'s arguments (`labels`, `datasets`, `x_axis_title`, `nodes`/`links`, `treemap_data`) work as written, so a chart from chat can be pasted in; `x_axis_title`/`y_axis_title` name the axes in the short form too. A block without `type:` is an ECharts option as is. Size: `chart {h=300}` or `{w=60%}`; the default is the column's width at 16:9, at most 440px tall.
138
+ - A React component goes on a slide as `![Alt](kpi.jsx){data=kpi.json}`, or inline as a `react` fence: the `render_react` format (`export default function Name({ data })`, React hooks, Recharts components, and Tailwind classes in scope, no imports). It also gets `isDark` and `palette` (the slide's theme colors: `palette.accent`, `palette.series[0..5]`, `palette.fg`, `palette.muted`, `palette.line`, `palette.card`): use them instead of hard-coded hex colors so the component matches the theme. `scale=0.8` shrinks a dashboard designed for a bigger screen; `h=` fixes its height.
139
+ - Prefer a `chart` for a single chart (static, small, crisp in PDF). Reach for a component for a KPI row with a chart, an interactive view, or a dashboard the user already made with `render_react`.
140
+
135
141
  ### Classes
136
142
 
137
143
  - Blocks: `{.lead}` (the key sentence, 1.2× body size), `{.muted}`, `{.small}` (sources, footnotes), `{.center}` and `{.right}` (horizontal alignment only), `{.subtitle}` and `{.meta}` (title slides; under a columns slide's heading, a `{.subtitle}` spans all columns), `{.callout}`, `{.note}`, `{.warn}` (boxed asides).
138
144
  - Spans: `[text]{.hl}`, `[new]{.badge}`, `[old]{.del}`.
139
145
  - `{.steps}` under a numbered list draws it as a row of chevrons, a progress bar for a procedure; bold the current step (`3. **Folder**`). Repeat it on each step's slide with the next step bold.
146
+ - Three list classes turn a list into a designed block; in each, an item's first `**bold**` is its headline and the rest its caption. Reach for them before a component or a wall of bullets:
147
+ - `{.stats}`: big-number tiles in one row (`- **3.2×** faster builds`). Use it for 2–4 numbers the slide is about.
148
+ - `{.grid}`: cards, three across (two for 2 or 4 items, four for 7+), with an optional leading icon (`- :lock: **Private** Stays on your machine`). Use it for features, principles, or options in place of one `=== col` per card.
149
+ - `{.timeline}`: dates along a line (`1. **Q3 2026** Beta`). Use it for 3–6 milestones; keep each date short.
140
150
  - `:name:` is a [Lucide](https://lucide.dev/icons/) icon in the text's color, e.g. `### :shield-check: Read-only`. A card heading or a list item that opens with an icon reads best (in a list it replaces the bullet). Put a space or punctuation before it; a name Lucide doesn't have stays as text, so check the slide.
141
151
  - A trailing `\` breaks a line inside a paragraph or heading (raw HTML such as `<br>` is off).
142
152
  - Any other class needs a `theme.css` next to the deck, or it is a build error.
@@ -286,6 +296,46 @@ Text over the photo.{.lead}
286
296
  flowchart LR
287
297
  A[Source]:::accent --> B[Build] --> C[Publish]
288
298
  ```
299
+
300
+ --- columns 2:3
301
+
302
+ # Revenue grew 40% in Q4
303
+
304
+ - **Enterprise** drove most of it
305
+ - Margins held at 31%
306
+
307
+ === col
308
+
309
+ ```chart
310
+ type: bar
311
+ x: [Q1, Q2, Q3, Q4]
312
+ series:
313
+ Revenue: [12, 18, 25, 35]
314
+ highlight: Q4
315
+ labels: true
316
+ prefix: "$"
317
+ unit: M
318
+ ```
319
+
320
+ ---
321
+
322
+ # Q3 at a glance
323
+
324
+ ```react
325
+ export default function KPIs() {
326
+ const kpis = [['ARR', '$42M'], ['Net retention', '128%'], ['Customers', '312']];
327
+ return (
328
+ <div className="grid grid-cols-3 gap-6">
329
+ {kpis.map(([label, value]) => (
330
+ <div key={label} className="p-6 rounded-xl" style={{ background: palette.card }}>
331
+ <div className="text-4xl font-bold" style={{ color: palette.accent }}>{value}</div>
332
+ <div style={{ color: palette.muted }}>{label}</div>
333
+ </div>
334
+ ))}
335
+ </div>
336
+ );
337
+ }
338
+ ```
289
339
  ````
290
340
 
291
341
  ## House style
@@ -296,6 +346,7 @@ The canvas is 1280×720 with 21–22px body text, so slides hold real content
296
346
  - **One idea per slide.** If a slide needs two titles, it's two slides.
297
347
  - **Bullets are short statements**, 5–6 at most, one line each where possible; start with the bolded key phrase (`- **Strict** — typos fail the build`). Nest at most one level.
298
348
  - **Use columns for comparison and for text + evidence** (claim on the left, code/table/image on the right) — `--- columns 3:2` or `1:1`. Cards (`### Heading` columns) suit 2–4 parallel options.
349
+ - **Show the number.** A claim about data ("Q4 revenue grew 40%") gets a chart beside it, not a bullet restating it: the title says the point, the chart is the evidence, and `highlight:` marks the bar the slide is about. A slide of three or four headline numbers is a KPI row (a small component, or `### $42M` cards in columns).
299
350
  - **Prefer a table** over bullets when items share attributes; prefer a Mermaid diagram over a bullet list describing a flow. Right-align number columns (`--:`) and keep them, and short labels, on one line with `{nowrap}` on the header cell; give a long text column a `{w=…%}` so it takes the wrapping.
300
351
  - **Fill the slide, or make it a statement.** Two bullets under a title leave most of the canvas empty. Merge the slide with a neighbor, add the evidence (a table, diagram, code, or image beside the text in columns), or make it a deliberate one-line statement with `.lead`.
301
352
  - **One `.lead` sentence** per slide at most, for the takeaway; `.muted` for context the speaker will say aloud anyway.