@treasure-ai/treasure-deck 2026.10.16 → 2026.10.18
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.
- package/README.md +1 -0
- package/dist/build.d.ts +2 -0
- package/dist/build.js +5 -0
- package/dist/build.js.map +1 -1
- package/dist/cli.js +74 -9
- package/dist/cli.js.map +1 -1
- package/dist/deckindex.d.ts +107 -0
- package/dist/deckindex.js +479 -0
- package/dist/deckindex.js.map +1 -0
- package/dist/dev.d.ts +13 -1
- package/dist/dev.js +145 -6
- package/dist/dev.js.map +1 -1
- package/dist/host.d.ts +10 -0
- package/dist/host.js +43 -25
- package/dist/host.js.map +1 -1
- package/dist/parse.d.ts +5 -0
- package/dist/parse.js.map +1 -1
- package/dist/render.js +10 -0
- package/dist/render.js.map +1 -1
- package/dist/vendor.js +1 -1
- package/dist/vendor.js.map +1 -1
- package/docs/commands.md +45 -3
- package/docs/editor.md +2 -1
- package/docs/syntax.md +4 -0
- package/package.json +1 -1
- package/runtime/base.css +18 -1
- package/runtime/embed.js +73 -2
- package/runtime/runtime.js +80 -20
- package/skills/treasure-deck/SKILL.md +4 -0
- package/vendor/lucide/file-down.svg +18 -0
- package/vendor/lucide/layout-grid.svg +18 -0
- package/vendor/lucide/x.svg +16 -0
package/runtime/runtime.js
CHANGED
|
@@ -17,6 +17,9 @@
|
|
|
17
17
|
}
|
|
18
18
|
// True in the presenter window (#/<n>/presenter), opened from the audience window with P.
|
|
19
19
|
var presenter = false;
|
|
20
|
+
// True on a page opened with ?embed=1, set in another site's iframe: on-screen controls, and only the keys a reader
|
|
21
|
+
// needs (the page doesn't take focus, open a presenter window, or show the laser).
|
|
22
|
+
var embedded = false;
|
|
20
23
|
// The pristine deck and this script, captured before the runtime adds its panels, so a presenter window can be
|
|
21
24
|
// written from them where the page has no URL to reopen (Apps Script's sandboxed iframe).
|
|
22
25
|
var pristineDeck = deck.outerHTML;
|
|
@@ -29,12 +32,12 @@
|
|
|
29
32
|
var gs = window.google && window.google.script;
|
|
30
33
|
var host = gs && gs.history && gs.url
|
|
31
34
|
? {
|
|
32
|
-
read: function (cb) { gs.url.getLocation(function (loc) { cb(loc.hash || ''); }); },
|
|
35
|
+
read: function (cb) { gs.url.getLocation(function (loc) { cb(loc.hash || '', loc.parameter || {}); }); },
|
|
33
36
|
write: function (hash) { gs.history.replace(null, {}, hash); },
|
|
34
37
|
baseUrl: function () { return window.__DECK_URL__ || ''; },
|
|
35
38
|
}
|
|
36
39
|
: {
|
|
37
|
-
read: function (cb) { cb(location.hash.replace(/^#/, '')); },
|
|
40
|
+
read: function (cb) { cb(location.hash.replace(/^#/, ''), Object.fromEntries(new URLSearchParams(location.search))); },
|
|
38
41
|
// A presenter window written into a blank pop-up has no URL of its own, where replaceState throws.
|
|
39
42
|
write: function (hash) { try { history.replaceState(null, '', '#' + hash); } catch (e) { /* no URL to update */ } },
|
|
40
43
|
baseUrl: function () { return location.href.split('#')[0]; },
|
|
@@ -55,9 +58,9 @@
|
|
|
55
58
|
var help = el('div', 'deck-panel deck-help',
|
|
56
59
|
'<h2>Keyboard shortcuts</h2><table>' +
|
|
57
60
|
[['→ Space PgDn', 'Next slide'], ['← PgUp', 'Previous slide'], ['Home / End', 'First / last'],
|
|
58
|
-
['1 2 … Enter', 'Go to slide'], ['f', 'Full screen'], ['o / Esc', 'Overview'], ['t', 'Table of contents'], ['p', 'Speaker notes + timer'], ['P', 'Presenter window'], ['k / r', 'Pause / reset the timer'],
|
|
59
|
-
['b / .', 'Black screen'], ['d', 'Light / dark'], ['l', 'Laser pointer'], ['s', 'Share'], ['?', 'This help']]
|
|
60
|
-
.map(function (r) { return '<tr><td><kbd>' + r[0] + '</kbd></td><td>' + r[1] + '</td></tr>'; }).join('') +
|
|
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']]
|
|
63
|
+
.map(function (r) { return '<tr' + (r[2] ? ' class="deck-not-embed"' : '') + '><td><kbd>' + r[0] + '</kbd></td><td>' + r[1] + '</td></tr>'; }).join('') +
|
|
61
64
|
'</table>');
|
|
62
65
|
help.hidden = true;
|
|
63
66
|
var share = el('div', 'deck-panel deck-share',
|
|
@@ -65,6 +68,7 @@
|
|
|
65
68
|
'<button data-act="link">Copy link to deck</button>' +
|
|
66
69
|
'<button data-act="slide">Copy link to this slide</button>' +
|
|
67
70
|
'<button data-act="embed">Copy embed snippet</button>' +
|
|
71
|
+
'<p class="deck-share-note">An embed loads on other sites only when the deck is published for anyone.</p>' +
|
|
68
72
|
'<button data-act="print">Print / save as PDF</button>' +
|
|
69
73
|
'<button data-act="presenter">Open presenter window</button>' +
|
|
70
74
|
(deckSource ? '<button data-act="download">Download source (.zip)</button>' +
|
|
@@ -79,7 +83,13 @@
|
|
|
79
83
|
offerOpen();
|
|
80
84
|
var notesPanel = el('div', 'deck-panel deck-notes-panel');
|
|
81
85
|
notesPanel.hidden = true;
|
|
82
|
-
|
|
86
|
+
var embedBar = el('div', 'deck-embed-bar',
|
|
87
|
+
'<button data-go="-1" aria-label="Previous slide">‹</button><span class="deck-embed-count"></span>' +
|
|
88
|
+
'<button data-go="1" aria-label="Next slide">›</button>' +
|
|
89
|
+
'<button data-act="fullscreen" aria-label="Full screen">⛶</button>' +
|
|
90
|
+
'<a data-act="open" target="_blank" rel="noopener">Open ↗</a>');
|
|
91
|
+
embedBar.hidden = true;
|
|
92
|
+
[progress, black, laser, gotoBox, help, share, notesPanel, embedBar].forEach(function (e) { deck.appendChild(e); });
|
|
83
93
|
|
|
84
94
|
function fit() {
|
|
85
95
|
if (presenter) { layoutPresenter(); return; }
|
|
@@ -107,6 +117,7 @@
|
|
|
107
117
|
if (!fromPeer && !fromHost) sync({ slide: presentedOf(i) });
|
|
108
118
|
renderNotes();
|
|
109
119
|
renderPresenter();
|
|
120
|
+
renderEmbedBar();
|
|
110
121
|
playVideos(i);
|
|
111
122
|
if (deck.classList.contains('is-overview')) slides[i].scrollIntoView({ block: 'nearest' });
|
|
112
123
|
// For the access metrics `deck build` adds: page numbers as presented, from 1.
|
|
@@ -181,6 +192,40 @@
|
|
|
181
192
|
// A feature used, for the access metrics `deck build` adds (full screen and print are seen there directly).
|
|
182
193
|
function used(action) { document.dispatchEvent(new CustomEvent('deck:action', { detail: { action: action } })); }
|
|
183
194
|
|
|
195
|
+
// The deck's own URL, without ?embed=1: what the share panel copies and the embed bar opens.
|
|
196
|
+
function deckUrl() {
|
|
197
|
+
return host.baseUrl().replace(/([?&])embed=1(&|$)/, function (m, sep, next) { return next ? sep : ''; });
|
|
198
|
+
}
|
|
199
|
+
// Opens the whole deck in a new tab at this slide; false when the page has no URL to open.
|
|
200
|
+
function openFull() {
|
|
201
|
+
var url = deckUrl();
|
|
202
|
+
if (!url) return false;
|
|
203
|
+
// (Not 'noopener', which always returns null: a blocked pop-up falls back to the status message.)
|
|
204
|
+
var w = window.open(url + '#/' + (current + 1), '_blank');
|
|
205
|
+
if (!w) return false;
|
|
206
|
+
try { w.opener = null; } catch (e) { /* already detached */ }
|
|
207
|
+
return true;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function startEmbed() {
|
|
211
|
+
embedded = true;
|
|
212
|
+
deck.classList.add('is-embedded');
|
|
213
|
+
embedBar.hidden = false;
|
|
214
|
+
}
|
|
215
|
+
function renderEmbedBar() {
|
|
216
|
+
if (!embedded) return;
|
|
217
|
+
embedBar.querySelector('.deck-embed-count').textContent = (presentedOf(current) + 1) + ' / ' + presentedOf(slides.length);
|
|
218
|
+
var open = embedBar.querySelector('[data-act="open"]'), url = deckUrl();
|
|
219
|
+
open.hidden = !url;
|
|
220
|
+
if (url) open.href = url + '#/' + (current + 1);
|
|
221
|
+
}
|
|
222
|
+
embedBar.addEventListener('click', function (e) {
|
|
223
|
+
var b = e.target.closest && e.target.closest('[data-go], [data-act="fullscreen"]');
|
|
224
|
+
if (!b) return;
|
|
225
|
+
if (b.hasAttribute('data-go')) show(current + parseInt(b.getAttribute('data-go'), 10));
|
|
226
|
+
else fullscreen();
|
|
227
|
+
});
|
|
228
|
+
|
|
184
229
|
function toggle(panel) {
|
|
185
230
|
var open = panel.hidden;
|
|
186
231
|
[help, share].forEach(function (p) { if (p !== panel) p.hidden = true; });
|
|
@@ -209,12 +254,14 @@
|
|
|
209
254
|
var doc = document;
|
|
210
255
|
if (doc.fullscreenElement) { doc.exitFullscreen(); return; }
|
|
211
256
|
var req = doc.documentElement.requestFullscreen;
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
}
|
|
257
|
+
// In another site's iframe the browser's full screen would enlarge that site, so the deck opens in a new tab.
|
|
258
|
+
var refused = function () {
|
|
259
|
+
if (embedded && openFull()) return;
|
|
260
|
+
status('Full screen is blocked here. Use your browser’s full screen (⌃⌘F / F11).');
|
|
261
|
+
share.hidden = false;
|
|
262
|
+
};
|
|
263
|
+
if (req) req.call(doc.documentElement).catch(refused);
|
|
264
|
+
else if (embedded) refused();
|
|
218
265
|
}
|
|
219
266
|
|
|
220
267
|
function status(msg) { share.querySelector('.deck-status').textContent = msg; }
|
|
@@ -330,13 +377,19 @@
|
|
|
330
377
|
return new Blob(parts.concat(central, [end]), { type: 'application/zip' });
|
|
331
378
|
}
|
|
332
379
|
|
|
380
|
+
// A 16:9 iframe as wide as its column, starting at this slide.
|
|
381
|
+
function embedSnippet(base) {
|
|
382
|
+
var src = base + (base.indexOf('?') < 0 ? '?' : '&') + 'embed=1' + (current ? '#/' + (current + 1) : '');
|
|
383
|
+
return '<iframe src="' + src.replace(/&/g, '&').replace(/"/g, '"') + '" style="width:100%;aspect-ratio:16/9;border:0" allow="fullscreen" allowfullscreen></iframe>';
|
|
384
|
+
}
|
|
385
|
+
|
|
333
386
|
share.addEventListener('click', function (e) {
|
|
334
387
|
var act = e.target && e.target.getAttribute('data-act');
|
|
335
|
-
var base =
|
|
388
|
+
var base = deckUrl();
|
|
336
389
|
if (act === 'link' || act === 'slide' || act === 'embed') used('copy_' + act);
|
|
337
390
|
if (act === 'link') copy(base, 'Link');
|
|
338
391
|
else if (act === 'slide') copy(base && base + '#/' + (current + 1), 'Slide link');
|
|
339
|
-
else if (act === 'embed') copy(base &&
|
|
392
|
+
else if (act === 'embed') copy(base && embedSnippet(base), 'Embed snippet');
|
|
340
393
|
else if (act === 'print') { share.hidden = true; window.print(); }
|
|
341
394
|
else if (act === 'presenter') { share.hidden = true; openPresenter(); }
|
|
342
395
|
else if (act === 'download') { used('download'); downloadDeck(); }
|
|
@@ -356,6 +409,7 @@
|
|
|
356
409
|
document.addEventListener('keydown', function (e) {
|
|
357
410
|
if (e.metaKey || e.ctrlKey || e.altKey) return;
|
|
358
411
|
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;
|
|
359
413
|
if (/^[0-9]$/.test(k)) { typeDigit(k); return; }
|
|
360
414
|
if (k === 'Enter' && typed) { show(parseInt(typed, 10) - 1); typed = ''; gotoBox.hidden = true; return; }
|
|
361
415
|
if (deck.classList.contains('is-black') && k !== 'b' && k !== '.') { deck.classList.remove('is-black'); sync({ black: false }); renderPresenter(); return; }
|
|
@@ -686,14 +740,16 @@
|
|
|
686
740
|
if (!fromPeer) sync({ mode: mode });
|
|
687
741
|
renderPresenter();
|
|
688
742
|
}
|
|
743
|
+
// An embed is a reader's copy: it neither steers nor follows a talk being presented from the same deck.
|
|
689
744
|
function sync(msg) {
|
|
745
|
+
if (embedded) return;
|
|
690
746
|
msg.treasureDeck = true;
|
|
691
747
|
if (channel) channel.postMessage(msg);
|
|
692
748
|
var w = peer || window.opener;
|
|
693
749
|
if (w && w !== window && !w.closed) { try { w.postMessage(msg, '*'); } catch (e) { /* cross-origin */ } }
|
|
694
750
|
}
|
|
695
751
|
function receive(msg, source) {
|
|
696
|
-
if (!msg || msg.treasureDeck !== true) return;
|
|
752
|
+
if (!msg || msg.treasureDeck !== true || embedded) return;
|
|
697
753
|
if (source && source !== window) peer = source;
|
|
698
754
|
// (A hidden slide being edited stays, while the other window shows the slide after it.)
|
|
699
755
|
var hiddenHere = slides[current].classList.contains('is-hidden');
|
|
@@ -823,16 +879,20 @@
|
|
|
823
879
|
// A presenter window written by openPresenter (no URL): start where the audience window is.
|
|
824
880
|
startPresenter();
|
|
825
881
|
show(window.__DECK_PRESENTER__, true);
|
|
826
|
-
|
|
827
|
-
|
|
882
|
+
window.focus();
|
|
883
|
+
} else host.read(function (hash, params) {
|
|
884
|
+
if (params.embed === '1') startEmbed();
|
|
885
|
+
else if (/\/presenter$/.test(hash)) startPresenter();
|
|
828
886
|
var m = /^\/?(\d+)/.exec(hash);
|
|
829
887
|
// #/<n>/presented: slide n as presented (back to deck editor from /present), past the hidden slides.
|
|
830
888
|
var n = m ? parseInt(m[1], 10) - 1 : 0;
|
|
831
889
|
show(/\/presented$/.test(hash) ? slideOf(n) : n, true);
|
|
890
|
+
// Keyboard events need focus inside the Apps Script iframe. An embed waits for a click instead: taking focus
|
|
891
|
+
// there would scroll the other site's page to the deck and take its keys.
|
|
892
|
+
if (embedded) used('embed');
|
|
893
|
+
else window.focus();
|
|
832
894
|
});
|
|
833
|
-
//
|
|
834
|
-
// end typing in an editor on the page (deck editor).
|
|
835
|
-
window.focus();
|
|
895
|
+
// Only when nothing on the page has focus: taking it would end typing in an editor on the page (deck editor).
|
|
836
896
|
document.addEventListener('click', function () {
|
|
837
897
|
var el = document.activeElement;
|
|
838
898
|
if (!el || el === document.body || el === document.documentElement) window.focus();
|
|
@@ -319,10 +319,14 @@ Treasure Work publishes a built deck as an Apps Script web page through the `sha
|
|
|
319
319
|
4. Give the user the URL. Keep the artifact id from the result. To update the same page after edits, rebuild and pass that id as `artifact_id`; without it, the publish creates a second page.
|
|
320
320
|
5. Publishing needs the user's Google account connected in Settings ▸ Connectors. If the tool reports that it is missing, tell the user to connect it.
|
|
321
321
|
|
|
322
|
+
To embed the deck in another web page (a blog post, a wiki, Google Sites), use the deck's URL with `?embed=1` in an `<iframe>`: the share panel's "Copy embed snippet" gives one. Embed mode shows ‹ › buttons, a slide counter, full screen, and "Open ↗", and it keeps the keys to the ones a reader needs. On other sites the frame loads only when the deck is published with `scope: "anyone"`.
|
|
323
|
+
|
|
322
324
|
A built page carries the deck's source, so whoever can open it can get the deck folder back (share panel ▸ Download source, or `deck import`), hidden slides included. Build with `--no-source` when the user wants the page shared but not its source.
|
|
323
325
|
|
|
324
326
|
To start from a deck someone shared, run `deck import <page.html | url> [dir]` and edit the folder it writes. For an Apps Script deck that isn't public, it needs the user's Google sign-in (`gcloud auth login --enable-gdrive-access`); otherwise have the user download the `.zip` from the deck's share panel.
|
|
325
327
|
|
|
328
|
+
To list several published decks on one page, run `deck index` from the workspace root: it keeps `deck/index.json` (one entry per deck under `deck/`, with a thumbnail in `deck/thumbnails/`) and writes `deck/index.html`. After publishing a deck, set its entry's `url` in `deck/index.json` to the published URL (or add `url:` to its frontmatter), then run `deck index` again. When the user asks to feature or retire a deck, run `deck index --star <deck>` or `--archive <deck>` (`--unstar`, `--unarchive` undo them). Publish `deck/index.html` like a deck, with its own `artifact_id` for updates. An index shows every deck's title and first slide, so give it an audience no wider than the narrowest deck it lists, or remove the entries that audience shouldn't see.
|
|
329
|
+
|
|
326
330
|
Don't publish the deck `.md` as a `note`: it would appear as a plain document, not slides. Don't use `mechanism: "drive"` for a deck either, since Drive doesn't serve the HTML as a page. A published page is a snapshot, so rebuild and republish after each edit.
|
|
327
331
|
|
|
328
332
|
## When the user wants a different look
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<!-- @license lucide-static v1.52.0 - ISC -->
|
|
2
|
+
<svg
|
|
3
|
+
class="lucide lucide-file-down"
|
|
4
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
5
|
+
width="24"
|
|
6
|
+
height="24"
|
|
7
|
+
viewBox="0 0 24 24"
|
|
8
|
+
fill="none"
|
|
9
|
+
stroke="currentColor"
|
|
10
|
+
stroke-width="2"
|
|
11
|
+
stroke-linecap="round"
|
|
12
|
+
stroke-linejoin="round"
|
|
13
|
+
>
|
|
14
|
+
<path d="M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" />
|
|
15
|
+
<path d="M14 2v5a1 1 0 0 0 1 1h5" />
|
|
16
|
+
<path d="M12 18v-6" />
|
|
17
|
+
<path d="m9 15 3 3 3-3" />
|
|
18
|
+
</svg>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<!-- @license lucide-static v1.52.0 - ISC -->
|
|
2
|
+
<svg
|
|
3
|
+
class="lucide lucide-layout-grid"
|
|
4
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
5
|
+
width="24"
|
|
6
|
+
height="24"
|
|
7
|
+
viewBox="0 0 24 24"
|
|
8
|
+
fill="none"
|
|
9
|
+
stroke="currentColor"
|
|
10
|
+
stroke-width="2"
|
|
11
|
+
stroke-linecap="round"
|
|
12
|
+
stroke-linejoin="round"
|
|
13
|
+
>
|
|
14
|
+
<rect width="7" height="7" x="3" y="3" rx="1" />
|
|
15
|
+
<rect width="7" height="7" x="14" y="3" rx="1" />
|
|
16
|
+
<rect width="7" height="7" x="14" y="14" rx="1" />
|
|
17
|
+
<rect width="7" height="7" x="3" y="14" rx="1" />
|
|
18
|
+
</svg>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<!-- @license lucide-static v1.52.0 - ISC -->
|
|
2
|
+
<svg
|
|
3
|
+
class="lucide lucide-x"
|
|
4
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
5
|
+
width="24"
|
|
6
|
+
height="24"
|
|
7
|
+
viewBox="0 0 24 24"
|
|
8
|
+
fill="none"
|
|
9
|
+
stroke="currentColor"
|
|
10
|
+
stroke-width="2"
|
|
11
|
+
stroke-linecap="round"
|
|
12
|
+
stroke-linejoin="round"
|
|
13
|
+
>
|
|
14
|
+
<path d="M18 6 6 18" />
|
|
15
|
+
<path d="m6 6 12 12" />
|
|
16
|
+
</svg>
|