@treasure-ai/treasure-deck 0.0.0-stage → 2026.10.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.
Files changed (110) hide show
  1. package/LICENSE.md +5 -0
  2. package/README.md +109 -2
  3. package/dist/analytics.d.ts +34 -0
  4. package/dist/analytics.js +93 -0
  5. package/dist/analytics.js.map +1 -0
  6. package/dist/attrs.d.ts +10 -0
  7. package/dist/attrs.js +22 -0
  8. package/dist/attrs.js.map +1 -0
  9. package/dist/build.d.ts +67 -0
  10. package/dist/build.js +247 -0
  11. package/dist/build.js.map +1 -0
  12. package/dist/check.d.ts +30 -0
  13. package/dist/check.js +142 -0
  14. package/dist/check.js.map +1 -0
  15. package/dist/chrome.d.ts +20 -0
  16. package/dist/chrome.js +162 -0
  17. package/dist/chrome.js.map +1 -0
  18. package/dist/cli.d.ts +2 -0
  19. package/dist/cli.js +246 -0
  20. package/dist/cli.js.map +1 -0
  21. package/dist/dev.d.ts +28 -0
  22. package/dist/dev.js +557 -0
  23. package/dist/dev.js.map +1 -0
  24. package/dist/diagrams.d.ts +18 -0
  25. package/dist/diagrams.js +57 -0
  26. package/dist/diagrams.js.map +1 -0
  27. package/dist/highlight.d.ts +7 -0
  28. package/dist/highlight.js +26 -0
  29. package/dist/highlight.js.map +1 -0
  30. package/dist/hot.d.ts +31 -0
  31. package/dist/hot.js +34 -0
  32. package/dist/hot.js.map +1 -0
  33. package/dist/media.d.ts +24 -0
  34. package/dist/media.js +82 -0
  35. package/dist/media.js.map +1 -0
  36. package/dist/parse.d.ts +109 -0
  37. package/dist/parse.js +313 -0
  38. package/dist/parse.js.map +1 -0
  39. package/dist/patch.d.ts +22 -0
  40. package/dist/patch.js +53 -0
  41. package/dist/patch.js.map +1 -0
  42. package/dist/pdf.d.ts +10 -0
  43. package/dist/pdf.js +53 -0
  44. package/dist/pdf.js.map +1 -0
  45. package/dist/render.d.ts +101 -0
  46. package/dist/render.js +513 -0
  47. package/dist/render.js.map +1 -0
  48. package/dist/scaffold.d.ts +27 -0
  49. package/dist/scaffold.js +83 -0
  50. package/dist/scaffold.js.map +1 -0
  51. package/dist/themecheck.d.ts +34 -0
  52. package/dist/themecheck.js +228 -0
  53. package/dist/themecheck.js.map +1 -0
  54. package/docs/adrs/2026-10-03-chrome-over-devtools.md +29 -0
  55. package/docs/adrs/2026-10-03-fixed-canvas.md +25 -0
  56. package/docs/adrs/2026-10-03-four-layouts-plus-attributes.md +25 -0
  57. package/docs/adrs/2026-10-03-hybrid-pdf-over-devtools.md +25 -0
  58. package/docs/adrs/2026-10-03-keyword-lines-and-one-attribute-syntax.md +36 -0
  59. package/docs/adrs/2026-10-03-one-behavior-instead-of-settings.md +30 -0
  60. package/docs/adrs/2026-10-03-overflow-is-reported-not-hidden.md +27 -0
  61. package/docs/adrs/2026-10-03-single-file-html.md +26 -0
  62. package/docs/adrs/2026-10-03-strict-build-forgiving-preview.md +31 -0
  63. package/docs/adrs/2026-10-04-edit-in-place-by-alignment.md +28 -0
  64. package/docs/adrs/2026-10-04-editor-in-the-deck-page.md +31 -0
  65. package/docs/adrs/2026-10-04-edits-are-line-range-patches.md +35 -0
  66. package/docs/adrs/2026-10-04-per-slide-hot-swap.md +33 -0
  67. package/docs/adrs/2026-10-04-theme-colors-derive-in-css.md +32 -0
  68. package/docs/adrs/2026-10-05-host-owns-undo.md +26 -0
  69. package/docs/adrs/2026-10-07-anonymous-access-metrics.md +38 -0
  70. package/docs/adrs/2026-10-14-dev-links-media-by-url.md +25 -0
  71. package/docs/adrs/2026-10-14-media-dir-for-the-publish-limit.md +28 -0
  72. package/docs/adrs/2026-10-14-videos-are-inlined-images.md +28 -0
  73. package/docs/adrs/2026-10-15-public-npm-under-labs-terms.md +37 -0
  74. package/docs/adrs/README.md +34 -0
  75. package/docs/commands.md +104 -0
  76. package/docs/editor.md +114 -0
  77. package/docs/syntax.md +157 -0
  78. package/docs/themes.md +134 -0
  79. package/package.json +68 -4
  80. package/runtime/base.css +354 -0
  81. package/runtime/edit-core.cjs +877 -0
  82. package/runtime/embed.js +5259 -0
  83. package/runtime/hot.js +136 -0
  84. package/runtime/runtime.js +729 -0
  85. package/skills/treasure-deck/SKILL.md +136 -0
  86. package/templates/deck.md +78 -0
  87. package/templates/specimen/specimen.md +104 -0
  88. package/templates/theme/assets/mark.svg +1 -0
  89. package/templates/theme/theme.css +97 -0
  90. package/templates/theme/theme.yaml +7 -0
  91. package/themes/default/theme.css +183 -0
  92. package/themes/default/theme.yaml +6 -0
  93. package/themes/editorial/theme.css +168 -0
  94. package/themes/editorial/theme.yaml +7 -0
  95. package/themes/gold/assets/gem.svg +130 -0
  96. package/themes/gold/theme.css +303 -0
  97. package/themes/gold/theme.yaml +7 -0
  98. package/themes/pastel/theme.css +187 -0
  99. package/themes/pastel/theme.yaml +6 -0
  100. package/themes/treasure-ai/assets/gem-line.svg +7 -0
  101. package/themes/treasure-ai/assets/gem.png +0 -0
  102. package/themes/treasure-ai/assets/gem.svg +25 -0
  103. package/themes/treasure-ai/assets/glass.svg +12 -0
  104. package/themes/treasure-ai/assets/logo-white.png +0 -0
  105. package/themes/treasure-ai/assets/logo.png +0 -0
  106. package/themes/treasure-ai/theme.css +239 -0
  107. package/themes/treasure-ai/theme.yaml +6 -0
  108. package/themes/wvlet/assets/wvlet-icon.svg +27 -0
  109. package/themes/wvlet/theme.css +238 -0
  110. package/themes/wvlet/theme.yaml +6 -0
package/runtime/hot.js ADDED
@@ -0,0 +1,136 @@
1
+ /* treasure-deck hot swap (deck dev only), a module served by Vite (src/dev.ts). Vite's HMR channel announces each
2
+ * rebuild (`deck:build`); the page then asks /__changes for what changed since the build it shows.
3
+ * window.__DECK_HOT__ = {page, build} says which page this is and which build it shows. The answer is null (nothing
4
+ * new), {type: 'reload'}, {type: 'update', units, changes, sources?} (src/hot.ts), {type: 'update', build, noop} (a
5
+ * rebuild with nothing for this page), or, for a build error outside the slides, {type: 'error', file, line,
6
+ * message}, shown in a bar over this build. Each change replaces a
7
+ * slide ({i, html}) or only moves its source lines ({i, src}). Slides are patched in place, so every reference to a
8
+ * <section> the runtime and the bridge hold stays valid; then `deck:slides-updated {slides, sources}` lets them set
9
+ * the new content up. A listener can hold updates by cancelling `deck:before-update` (an edit in progress), or a
10
+ * reload by cancelling `deck:before-reload` (until what was typed is saved), and
11
+ * releases them with deckHot.flush(). A build error is also dispatched as `deck:build-error {file, line, message}`. */
12
+ (function () {
13
+ 'use strict';
14
+ var cfg = window.__DECK_HOT__ || { page: 'main', build: 0 };
15
+ // The build this page has been sent last: after a lost connection (a laptop waking up) it asks from there.
16
+ var build = cfg.build, erred = false, asking = null;
17
+ function ask() {
18
+ if (asking) { asking.again = true; return; }
19
+ var a = asking = { again: false };
20
+ var done = function () { asking = null; if (a.again) ask(); };
21
+ fetch('/__changes?page=' + encodeURIComponent(cfg.page) + '&build=' + build + (erred ? '&erred=1' : ''))
22
+ .then(function (r) { return r.json(); })
23
+ .then(function (msg) { if (msg) receive(msg); done(); }, done);
24
+ }
25
+ var deck = document.querySelector('.deck');
26
+ // A build error page: any rebuild reloads it.
27
+ var receive = function () { location.reload(); };
28
+ if (import.meta.hot) {
29
+ import.meta.hot.on('deck:build', ask);
30
+ import.meta.hot.on('vite:ws:connect', ask);
31
+ }
32
+ // A rebuild between serving the page and now.
33
+ ask();
34
+ if (!deck) return;
35
+ var stage = deck.querySelector('.deck-stage');
36
+
37
+ // A reload carries the table of contents state (`t`) and the light/dark mode (`d`); the URL hash already keeps the
38
+ // current slide. Each is restored only while the deck's own default (`toc: sidebar`, `mode:`) is unchanged, so
39
+ // editing that setting takes effect.
40
+ var dflt = deck.classList.contains('show-toc') ? '1' : '0';
41
+ var modeDflt = deck.getAttribute('data-mode');
42
+ try {
43
+ var saved = JSON.parse(sessionStorage.getItem('deck-dev-toc') || 'null');
44
+ if (saved && saved.dflt === dflt) deck.classList.toggle('show-toc', saved.on === '1');
45
+ var savedMode = JSON.parse(sessionStorage.getItem('deck-dev-mode') || 'null');
46
+ if (savedMode && savedMode.dflt === modeDflt) deck.setAttribute('data-mode', savedMode.mode);
47
+ } catch (e) { /* storage unavailable */ }
48
+ function reload() {
49
+ var on = deck.classList.contains('show-toc') ? '1' : '0';
50
+ try {
51
+ sessionStorage.setItem('deck-dev-toc', JSON.stringify({ on: on, dflt: dflt }));
52
+ sessionStorage.setItem('deck-dev-mode', JSON.stringify({ mode: deck.getAttribute('data-mode'), dflt: modeDflt }));
53
+ } catch (e) { /* ignore */ }
54
+ location.reload();
55
+ }
56
+
57
+ // A build error outside the slides (the frontmatter, the theme): the slides stay as they are, under a bar that
58
+ // the next good build takes away.
59
+ var bar = null;
60
+ function showError(msg) {
61
+ if (!bar) {
62
+ bar = document.createElement('div');
63
+ bar.className = 'deck-error-bar';
64
+ bar.setAttribute('role', 'alert');
65
+ bar.style.cssText = 'position:fixed;left:0;right:0;bottom:0;z-index:2000;padding:10px 16px;box-sizing:border-box;' +
66
+ 'background:#1b1210;border-top:3px solid #d64532;color:#ffd7c2;font:13px/1.45 ui-monospace,SFMono-Regular,Menlo,monospace;' +
67
+ 'white-space:pre-wrap;max-height:40vh;overflow:auto';
68
+ document.body.appendChild(bar);
69
+ }
70
+ erred = true;
71
+ bar.textContent = 'Build error: ' + msg.message;
72
+ document.dispatchEvent(new CustomEvent('deck:build-error', { detail: { file: msg.file, line: msg.line, message: msg.message } }));
73
+ }
74
+
75
+ var queue = [];
76
+ receive = function (msg) {
77
+ if (msg.type === 'error') return showError(msg);
78
+ if (msg.type === 'update' && msg.noop) { build = msg.build; return; }
79
+ // A reload asks first (`deck:before-reload`): the editor holds it only until what was typed is saved.
80
+ if (!msg || msg.type !== 'update') queue.push({ reload: true });
81
+ else { build = msg.build; queue.push(msg); }
82
+ flush();
83
+ };
84
+ function flush() {
85
+ while (queue.length) {
86
+ var event = queue[0].reload ? 'deck:before-reload' : 'deck:before-update';
87
+ if (!document.dispatchEvent(new CustomEvent(event, { cancelable: true }))) return;
88
+ var next = queue.shift();
89
+ if (next.reload || !apply(next)) return reload();
90
+ // Gone with the good build it came with, so it goes when the host hears `ready` (an edit can hold updates).
91
+ if (bar) { bar.remove(); bar = null; erred = false; }
92
+ }
93
+ }
94
+ window.deckHot = { flush: flush };
95
+
96
+ // Classes the runtime sets on a slide, which the new HTML doesn't know about.
97
+ var STATE = ['active', 'past', 'next'];
98
+ function patch(el, html) {
99
+ var t = document.createElement('template');
100
+ t.innerHTML = html;
101
+ var next = t.content.firstElementChild;
102
+ if (!next || next.tagName !== el.tagName) return false;
103
+ var keep = STATE.filter(function (c) { return el.classList.contains(c); });
104
+ Array.prototype.slice.call(el.attributes).forEach(function (a) { if (!next.hasAttribute(a.name)) el.removeAttribute(a.name); });
105
+ Array.prototype.forEach.call(next.attributes, function (a) { el.setAttribute(a.name, a.value); });
106
+ keep.forEach(function (c) { el.classList.add(c); });
107
+ el.innerHTML = next.innerHTML;
108
+ return true;
109
+ }
110
+ // New source lines for a slide whose content didn't change: the same elements in the same order. The bridge
111
+ // renames data-src to data-src-old on blocks a saved patch replaced, so they still count.
112
+ function move(el, src) {
113
+ var marked = [el].concat(Array.prototype.slice.call(el.querySelectorAll('[data-src], [data-src-old]')));
114
+ if (marked.length !== src.length) return false;
115
+ marked.forEach(function (m, k) { m.removeAttribute('data-src-old'); m.setAttribute('data-src', src[k]); });
116
+ return true;
117
+ }
118
+ function apply(msg) {
119
+ var units = stage.querySelectorAll(':scope > .slide, :scope > .slide-stub');
120
+ if (units.length !== msg.units) return false;
121
+ var swapped = [];
122
+ for (var k = 0; k < msg.changes.length; k++) {
123
+ var c = msg.changes[k], el = units[c.i];
124
+ if (!(c.html !== undefined ? patch(el, c.html) : move(el, c.src))) return false;
125
+ if (c.html !== undefined) swapped.push(el);
126
+ }
127
+ document.dispatchEvent(new CustomEvent('deck:slides-updated', {
128
+ detail: {
129
+ slides: swapped.filter(function (u) { return u.classList.contains('slide'); }),
130
+ stubs: swapped.filter(function (u) { return u.classList.contains('slide-stub'); }),
131
+ sources: msg.sources,
132
+ },
133
+ }));
134
+ return true;
135
+ }
136
+ })();