@treasure-ai/treasure-deck 2026.10.7 → 2026.10.8
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 +10 -9
- package/dist/chrome.d.ts +10 -1
- package/dist/chrome.js +88 -13
- package/dist/chrome.js.map +1 -1
- package/dist/dev.js +5 -11
- package/dist/dev.js.map +1 -1
- package/dist/diagrams.js +2 -2
- package/dist/diagrams.js.map +1 -1
- package/dist/media.d.ts +1 -1
- package/dist/media.js +1 -1
- package/dist/update.d.ts +7 -0
- package/dist/update.js +17 -5
- package/dist/update.js.map +1 -1
- package/dist/vendor.d.ts +13 -0
- package/dist/vendor.js +46 -0
- package/dist/vendor.js.map +1 -0
- package/docs/commands.md +3 -3
- package/docs/editor.md +3 -3
- package/docs/syntax.md +2 -2
- package/docs/themes.md +1 -1
- package/package.json +5 -6
- package/runtime/edit-core.cjs +236 -1
- package/runtime/embed.js +66 -151
- package/vendor/lucide/LICENSE +43 -0
- package/vendor/lucide/align-center.svg +17 -0
- package/vendor/lucide/align-left.svg +17 -0
- package/vendor/lucide/align-right.svg +17 -0
- package/vendor/lucide/arrow-down.svg +16 -0
- package/vendor/lucide/arrow-up.svg +16 -0
- package/vendor/lucide/bold.svg +15 -0
- package/vendor/lucide/chevron-down.svg +15 -0
- package/vendor/lucide/clipboard-paste.svg +19 -0
- package/vendor/lucide/code.svg +16 -0
- package/vendor/lucide/copy-plus.svg +18 -0
- package/vendor/lucide/copy.svg +16 -0
- package/vendor/lucide/external-link.svg +17 -0
- package/vendor/lucide/eye-off.svg +18 -0
- package/vendor/lucide/eye.svg +16 -0
- package/vendor/lucide/file-code.svg +18 -0
- package/vendor/lucide/heading-1.svg +18 -0
- package/vendor/lucide/heading-2.svg +18 -0
- package/vendor/lucide/heading-3.svg +19 -0
- package/vendor/lucide/highlighter.svg +16 -0
- package/vendor/lucide/italic.svg +17 -0
- package/vendor/lucide/layers.svg +17 -0
- package/vendor/lucide/link.svg +16 -0
- package/vendor/lucide/list-ordered.svg +20 -0
- package/vendor/lucide/list.svg +20 -0
- package/vendor/lucide/pilcrow.svg +17 -0
- package/vendor/lucide/pin-off.svg +18 -0
- package/vendor/lucide/play.svg +15 -0
- package/vendor/lucide/plus.svg +16 -0
- package/vendor/lucide/presentation.svg +17 -0
- package/vendor/lucide/quote.svg +16 -0
- package/vendor/lucide/redo-2.svg +16 -0
- package/vendor/lucide/repeat.svg +18 -0
- package/vendor/lucide/scissors.svg +19 -0
- package/vendor/lucide/settings.svg +16 -0
- package/vendor/lucide/sliders-horizontal.svg +23 -0
- package/vendor/lucide/square-round-corner.svg +16 -0
- package/vendor/lucide/square.svg +15 -0
- package/vendor/lucide/strikethrough.svg +17 -0
- package/vendor/lucide/trash-2.svg +19 -0
- package/vendor/lucide/undo-2.svg +16 -0
- package/vendor/mermaid/LICENSE +21 -0
- package/vendor/mermaid/mermaid.min.js +3636 -0
- package/docs/adrs/2026-10-03-chrome-over-devtools.md +0 -29
- package/docs/adrs/2026-10-03-fixed-canvas.md +0 -25
- package/docs/adrs/2026-10-03-four-layouts-plus-attributes.md +0 -25
- package/docs/adrs/2026-10-03-hybrid-pdf-over-devtools.md +0 -25
- package/docs/adrs/2026-10-03-keyword-lines-and-one-attribute-syntax.md +0 -36
- package/docs/adrs/2026-10-03-one-behavior-instead-of-settings.md +0 -30
- package/docs/adrs/2026-10-03-overflow-is-reported-not-hidden.md +0 -27
- package/docs/adrs/2026-10-03-single-file-html.md +0 -26
- package/docs/adrs/2026-10-03-strict-build-forgiving-preview.md +0 -31
- package/docs/adrs/2026-10-04-edit-in-place-by-alignment.md +0 -28
- package/docs/adrs/2026-10-04-editor-in-the-deck-page.md +0 -31
- package/docs/adrs/2026-10-04-edits-are-line-range-patches.md +0 -35
- package/docs/adrs/2026-10-04-per-slide-hot-swap.md +0 -33
- package/docs/adrs/2026-10-04-theme-colors-derive-in-css.md +0 -32
- package/docs/adrs/2026-10-05-host-owns-undo.md +0 -26
- package/docs/adrs/2026-10-07-anonymous-access-metrics.md +0 -38
- package/docs/adrs/2026-10-14-dev-links-media-by-url.md +0 -25
- package/docs/adrs/2026-10-14-media-dir-for-the-publish-limit.md +0 -28
- package/docs/adrs/2026-10-14-videos-are-inlined-images.md +0 -28
- package/docs/adrs/2026-10-15-public-npm-under-labs-terms.md +0 -37
- package/docs/adrs/2026-10-16-updates-install-after-exit.md +0 -31
- package/docs/adrs/README.md +0 -35
package/dist/vendor.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mermaid and lucide-static are devDependencies: installed, they take about 150 MB (Mermaid's sources and its
|
|
3
|
+
* Node-only dependencies, every Lucide icon in five formats), while deck loads one Mermaid browser bundle and the
|
|
4
|
+
* editor's toolbar icons. `pnpm build` copies those files into vendor/, which the package ships; a checkout that
|
|
5
|
+
* hasn't been built reads them from node_modules.
|
|
6
|
+
*/
|
|
7
|
+
export declare const VENDOR_DIR: string;
|
|
8
|
+
/** The Lucide icons the editor's toolbar uses. */
|
|
9
|
+
export declare const ICONS: string[];
|
|
10
|
+
/** The vendored file, or in an unbuilt checkout the module file it comes from. */
|
|
11
|
+
export declare function vendorFile(file: string): string;
|
|
12
|
+
/** Copy the vendored files from node_modules into vendor/ (run by `pnpm build`). */
|
|
13
|
+
export declare function writeVendor(): void;
|
package/dist/vendor.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { copyFileSync, existsSync, mkdirSync, rmSync } from 'node:fs';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import * as path from 'node:path';
|
|
4
|
+
import { PACKAGE_ROOT } from './build.js';
|
|
5
|
+
/**
|
|
6
|
+
* Mermaid and lucide-static are devDependencies: installed, they take about 150 MB (Mermaid's sources and its
|
|
7
|
+
* Node-only dependencies, every Lucide icon in five formats), while deck loads one Mermaid browser bundle and the
|
|
8
|
+
* editor's toolbar icons. `pnpm build` copies those files into vendor/, which the package ships; a checkout that
|
|
9
|
+
* hasn't been built reads them from node_modules.
|
|
10
|
+
*/
|
|
11
|
+
export const VENDOR_DIR = path.join(PACKAGE_ROOT, 'vendor');
|
|
12
|
+
/** The Lucide icons the editor's toolbar uses. */
|
|
13
|
+
export const ICONS = [
|
|
14
|
+
'bold', 'italic', 'code', 'strikethrough', 'highlighter', 'link', 'pilcrow', 'heading-1', 'heading-2', 'heading-3',
|
|
15
|
+
'list', 'list-ordered', 'quote', 'arrow-up', 'arrow-down', 'copy', 'eye-off', 'eye', 'trash-2',
|
|
16
|
+
'align-left', 'align-center', 'align-right', 'layers', 'square-round-corner', 'square', 'file-code', 'chevron-down', 'settings',
|
|
17
|
+
'presentation', 'external-link', 'plus', 'undo-2', 'redo-2', 'scissors', 'clipboard-paste', 'copy-plus', 'pin-off',
|
|
18
|
+
'play', 'repeat', 'sliders-horizontal',
|
|
19
|
+
];
|
|
20
|
+
/** Each vendored file (a path under vendor/) and the module file it is copied from. */
|
|
21
|
+
function sources() {
|
|
22
|
+
return [
|
|
23
|
+
['mermaid/mermaid.min.js', 'mermaid/dist/mermaid.min.js'],
|
|
24
|
+
['mermaid/LICENSE', 'mermaid/LICENSE'],
|
|
25
|
+
['lucide/LICENSE', 'lucide-static/LICENSE'],
|
|
26
|
+
...ICONS.map((name) => [`lucide/${name}.svg`, `lucide-static/icons/${name}.svg`]),
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
/** The vendored file, or in an unbuilt checkout the module file it comes from. */
|
|
30
|
+
export function vendorFile(file) {
|
|
31
|
+
const own = path.join(VENDOR_DIR, file);
|
|
32
|
+
if (existsSync(own))
|
|
33
|
+
return own;
|
|
34
|
+
return createRequire(import.meta.url).resolve(sources().find(([to]) => to === file)[1]);
|
|
35
|
+
}
|
|
36
|
+
/** Copy the vendored files from node_modules into vendor/ (run by `pnpm build`). */
|
|
37
|
+
export function writeVendor() {
|
|
38
|
+
rmSync(VENDOR_DIR, { recursive: true, force: true });
|
|
39
|
+
const require = createRequire(import.meta.url);
|
|
40
|
+
for (const [to, from] of sources()) {
|
|
41
|
+
const dest = path.join(VENDOR_DIR, to);
|
|
42
|
+
mkdirSync(path.dirname(dest), { recursive: true });
|
|
43
|
+
copyFileSync(require.resolve(from), dest);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=vendor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vendor.js","sourceRoot":"","sources":["../src/vendor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;AAE5D,kDAAkD;AAClD,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW;IAClH,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS;IAC9F,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,QAAQ,EAAE,qBAAqB,EAAE,QAAQ,EAAE,WAAW,EAAE,cAAc,EAAE,UAAU;IAC/H,cAAc,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,iBAAiB,EAAE,WAAW,EAAE,SAAS;IAClH,MAAM,EAAE,QAAQ,EAAE,oBAAoB;CACvC,CAAC;AAEF,uFAAuF;AACvF,SAAS,OAAO;IACd,OAAO;QACL,CAAC,wBAAwB,EAAE,6BAA6B,CAAC;QACzD,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;QACtC,CAAC,gBAAgB,EAAE,uBAAuB,CAAC;QAC3C,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAoB,EAAE,CAAC,CAAC,UAAU,IAAI,MAAM,EAAE,uBAAuB,IAAI,MAAM,CAAC,CAAC;KACpG,CAAC;AACJ,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IACxC,IAAI,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC;IAChC,OAAO,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,KAAK,IAAI,CAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3F,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,WAAW;IACzB,MAAM,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACrD,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/C,KAAK,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,IAAI,OAAO,EAAE,EAAE,CAAC;QACnC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QACvC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACnD,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;IAC5C,CAAC;AACH,CAAC"}
|
package/docs/commands.md
CHANGED
|
@@ -69,9 +69,9 @@ Every row also carries:
|
|
|
69
69
|
- **The deck:** its title, a `deck_id`, the treasure-deck version, the theme, and the build date. The `deck_id` is a hash of the deck file's path, so it doesn't change with the title and doesn't reveal the path.
|
|
70
70
|
- **The viewing:** `host` (`apps_script`, `file`, or `web`) and a `view_id`. The `view_id` is a random ID made for each page load and never stored, which groups one viewing's rows.
|
|
71
71
|
|
|
72
|
-
The SDK adds the page URL, referrer, screen size, and user agent. The presenter window sends nothing, so a talk counts once. `deck dev`, `deck editor`, `deck pdf`, and `deck check` never add the SDK, and a deck that can't reach the CDN works as before. These are usage data under the [Treasure AI Labs Terms of Use](https://www.treasure.ai/terms/labs-terms-of-use).
|
|
72
|
+
The SDK adds the page URL, referrer, screen size, and user agent. The presenter window sends nothing, so a talk counts once. `deck dev`, `deck editor`, `deck pdf`, and `deck check` never add the SDK, and a deck that can't reach the CDN works as before. These are usage data under the [Treasure AI Labs Terms of Use](https://www.treasure.ai/terms/labs-terms-of-use).
|
|
73
73
|
|
|
74
|
-
`deck pdf` prints the deck with headless Chrome: it waits until fonts and diagrams have rendered, then prints one 1280×720 page per slide. Each slide's background layer (gradients, glass, grain, ornaments) is captured as a 2× image, and text, tables, code, images, and diagrams print as vectors on top, so the PDF looks like the HTML in every viewer (including macOS Preview) while text stays sharp and selectable. `--vector` skips the capture. Printing from the browser (share panel → Print, or ⌘P) keeps backgrounds too, but large translucent gradients may band in some PDF viewers; `deck pdf` is the faithful path.
|
|
74
|
+
`deck pdf` prints the deck with headless Chrome: it waits until fonts and diagrams have rendered, then prints one 1280×720 page per slide. Each slide's background layer (gradients, glass, grain, ornaments) is captured as a 2× image, and text, tables, code, images, and diagrams print as vectors on top, so the PDF looks like the HTML in every viewer (including macOS Preview) while text stays sharp and selectable. `--vector` skips the capture. Printing from the browser (share panel → Print, or ⌘P) keeps backgrounds too, but large translucent gradients may band in some PDF viewers; `deck pdf` is the faithful path.
|
|
75
75
|
|
|
76
76
|
## Themes: `deck themes`, `deck theme init`, `deck theme check`
|
|
77
77
|
|
|
@@ -124,4 +124,4 @@ Settings, as environment variables:
|
|
|
124
124
|
- `DECK_UPDATE_CHANNEL=next` follows `next` instead of `latest`.
|
|
125
125
|
- `npm_config_registry` points the check at another registry.
|
|
126
126
|
|
|
127
|
-
The updater keeps its state in a folder per install, `~/.treasure-deck/<hash of the install's path>/`. In it, `update.json` holds the last check and any result to report, `update.lock` and `install.lock` mark a running check and install, and `sessions/` lists the running `deck` processes of a global install. So a global install and another copy, such as one an app installs under its own prefix, each update on their own.
|
|
127
|
+
The updater keeps its state in a folder per install, `~/.treasure-deck/<hash of the install's path>/`. In it, `update.json` holds the last check and any result to report, `update.lock` and `install.lock` mark a running check and install, and `sessions/` lists the running `deck` processes of a global install. So a global install and another copy, such as one an app installs under its own prefix, each update on their own.
|
package/docs/editor.md
CHANGED
|
@@ -7,7 +7,7 @@ pnpm deck editor talk.md --no-open --port 4301 # serve it without opening a
|
|
|
7
7
|
|
|
8
8
|
`deck editor` opens the deck for editing in your browser. Like `deck dev`, it takes port 4300 or the next free one unless `--port` names one. Treasure Work shows the same page in its right dock (it starts it as `deck dev --embed`, the same server without opening a browser). It listens on 127.0.0.1 only, and it answers only requests (and live-reload WebSocket connections) addressed to `127.0.0.1:<port>` or `localhost:<port>`, so a web page that points its own hostname at 127.0.0.1 (DNS rebinding) can't read the deck through it. `deck dev` without `--embed` still answers any host, so a phone on the LAN can open the preview. `examples/playground/playground.md` is a deck for trying it; copy it somewhere first, since edits save to the file.
|
|
9
9
|
|
|
10
|
-
Edits save on their own as you type, after a short pause, and each one changes only the lines it touched: the rest of the file stays exactly as written, and a change made elsewhere meanwhile (Claude, another editor) is never overwritten.
|
|
10
|
+
Edits save on their own as you type, after a short pause, and each one changes only the lines it touched: the rest of the file stays exactly as written, and a change made elsewhere meanwhile (Claude, another editor) is never overwritten.
|
|
11
11
|
|
|
12
12
|
The page, top to bottom, in edit mode (in a host app, the app turns it on; on its own it starts on, and `e` toggles it). Out of edit mode, the page shows the slide alone, as large as the window allows.
|
|
13
13
|
|
|
@@ -105,10 +105,10 @@ The whole file holding the current slide (a part, for `parts:`), editable, with
|
|
|
105
105
|
|
|
106
106
|
## Undo
|
|
107
107
|
|
|
108
|
-
⌘Z (Ctrl+Z) undoes a pause in typing or an action at a time, and ⇧⌘Z (Ctrl+Y) redoes, in either view, with the cursor going back to the change; the toolbar has Undo and Redo too. Inside Treasure Work, the keys go to its editor, which keeps the file's undo history. On its own, `deck editor` keeps up to 200 steps, and they survive a reload. An undo never overwrites a change made since by someone else: it is refused and the page reloads.
|
|
108
|
+
⌘Z (Ctrl+Z) undoes a pause in typing or an action at a time, and ⇧⌘Z (Ctrl+Y) redoes, in either view, with the cursor going back to the change; the toolbar has Undo and Redo too. Inside Treasure Work, the keys go to its editor, which keeps the file's undo history. On its own, `deck editor` keeps up to 200 steps, and they survive a reload. An undo never overwrites a change made since by someone else: it is refused and the page reloads.
|
|
109
109
|
|
|
110
110
|
## Presenting from the editor
|
|
111
111
|
|
|
112
112
|
`/present` on the same server (for example `http://127.0.0.1:4300/present#/9`) is the deck to present, with no editor, updating on every save. A host app opens it in its own window, so you can present while you or Claude keep editing. The editor follows the slides you present, and `e` in the presenting window goes back to editing: it closes the window (or, opened on its own, switches the tab to the editor) on the same slide. The keys for presenting are in [Commands](commands.md#presenting).
|
|
113
113
|
|
|
114
|
-
The host-app protocol is in `
|
|
114
|
+
The host-app protocol is in `design/design.md` (Treasure Work integration) in the source repository.
|
package/docs/syntax.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
A deck is CommonMark + GFM (tables, task lists, strikethrough, autolinks) with a few additions for slides, columns, and attributes, so it never needs `<div>` markup. Slides are 16:9 on a 1280×720 canvas; sizes in canvas px mean the same on every screen and in PDFs.
|
|
4
4
|
|
|
5
|
-
The build is strict: an unknown layout, attribute, or class, a separator typo (`=== column`), or a missing image fails with its line number instead of reaching the audience. (`deck dev` and `deck editor` show such a slide as an error slide and keep the rest of the deck
|
|
5
|
+
The build is strict: an unknown layout, attribute, or class, a separator typo (`=== column`), or a missing image fails with its line number instead of reaching the audience. (`deck dev` and `deck editor` show such a slide as an error slide and keep the rest of the deck.)
|
|
6
6
|
|
|
7
7
|
## Frontmatter
|
|
8
8
|
|
|
@@ -82,7 +82,7 @@ Blank lines work as in a block editor. One separates blocks; each blank line mor
|
|
|
82
82
|
|
|
83
83
|
### Dense slides
|
|
84
84
|
|
|
85
|
-
Text never shrinks on its own; `deck check` reports a slide that overflows. For a slide that has to hold more, such as a reference table or an appendix, mark it `--- {fit}` (or `--- columns 1:1 {fit}`). The body below the title then zooms down just enough to fit, never below 14px text, while the title keeps its size. `deck check` warns when a fitted slide's text drops below 16px.
|
|
85
|
+
Text never shrinks on its own; `deck check` reports a slide that overflows. For a slide that has to hold more, such as a reference table or an appendix, mark it `--- {fit}` (or `--- columns 1:1 {fit}`). The body below the title then zooms down just enough to fit, never below 14px text, while the title keeps its size. `deck check` warns when a fitted slide's text drops below 16px.
|
|
86
86
|
|
|
87
87
|
### Drafts
|
|
88
88
|
|
package/docs/themes.md
CHANGED
|
@@ -45,7 +45,7 @@ fonts:
|
|
|
45
45
|
|
|
46
46
|
A theme sets a few **seed** colors on `.slide` (and again for dark slides): `--deck-bg`, `--deck-fg`, `--deck-accent`, and optionally `--deck-accent-2` (default: the accent's hue turned 150°), `--deck-warn`, and `--deck-ok`. It also sets `--deck-font-display`, `--deck-font-body`, `--deck-font-mono`, and `--deck-radius`.
|
|
47
47
|
|
|
48
|
-
`runtime/base.css` derives every other color from the seeds: muted text, lines, cards, the text on the accent, highlights, chips, chart series, code token colors, and the whole Mermaid palette. So dark mode only re-sets the seeds, and `accent:` recolors the whole deck. A theme can still set any derived token itself, as the built-in themes do for their brand palettes; set it on `.slide` too, never on `.deck`, where the derivation would shadow it
|
|
48
|
+
`runtime/base.css` derives every other color from the seeds: muted text, lines, cards, the text on the accent, highlights, chips, chart series, code token colors, and the whole Mermaid palette. So dark mode only re-sets the seeds, and `accent:` recolors the whole deck. A theme can still set any derived token itself, as the built-in themes do for their brand palettes; set it on `.slide` too, never on `.deck`, where the derivation would shadow it.
|
|
49
49
|
|
|
50
50
|
| Tokens | For |
|
|
51
51
|
|---|---|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@treasure-ai/treasure-deck",
|
|
3
|
-
"version": "2026.10.
|
|
3
|
+
"version": "2026.10.8",
|
|
4
4
|
"description": "Markdown presentations without <div> markup: four layouts, themes, and a single-file HTML output that publishes to Apps Script",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"homepage": "https://www.npmjs.com/package/@treasure-ai/treasure-deck",
|
|
@@ -26,16 +26,15 @@
|
|
|
26
26
|
"files": [
|
|
27
27
|
"dist",
|
|
28
28
|
"docs",
|
|
29
|
-
"!docs/design.md",
|
|
30
|
-
"!docs/development.md",
|
|
31
29
|
"runtime",
|
|
32
30
|
"skills",
|
|
33
31
|
"templates",
|
|
34
32
|
"themes",
|
|
33
|
+
"vendor",
|
|
35
34
|
"LICENSE.md"
|
|
36
35
|
],
|
|
37
36
|
"scripts": {
|
|
38
|
-
"build": "tsc",
|
|
37
|
+
"build": "tsc && node scripts/vendor.mjs",
|
|
39
38
|
"prepack": "pnpm build",
|
|
40
39
|
"deck": "tsx src/cli.ts",
|
|
41
40
|
"test": "vitest run",
|
|
@@ -54,16 +53,16 @@
|
|
|
54
53
|
"dependencies": {
|
|
55
54
|
"@wvlet/highlightjs-wvlet": "^2026.3.0",
|
|
56
55
|
"highlight.js": "^11.12.0",
|
|
57
|
-
"lucide-static": "^1.52.0",
|
|
58
56
|
"markdown-it": "^15.0.2",
|
|
59
57
|
"markdown-it-attrs": "^5.0.1",
|
|
60
58
|
"markdown-it-bracketed-spans": "^1.0.3",
|
|
61
|
-
"mermaid": "^11.17.2",
|
|
62
59
|
"vite": "^8.3.2",
|
|
63
60
|
"yaml": "^2.9.1"
|
|
64
61
|
},
|
|
65
62
|
"devDependencies": {
|
|
66
63
|
"@types/node": "^26.6.4",
|
|
64
|
+
"lucide-static": "^1.52.0",
|
|
65
|
+
"mermaid": "^11.17.2",
|
|
67
66
|
"tsx": "^4.23.15",
|
|
68
67
|
"typescript": "^7.0.2",
|
|
69
68
|
"vitest": "^5.0.3"
|
package/runtime/edit-core.cjs
CHANGED
|
@@ -759,6 +759,220 @@
|
|
|
759
759
|
return patch(lines, n, end, out.join('\n'));
|
|
760
760
|
}
|
|
761
761
|
|
|
762
|
+
// ---- A block's text in its source lines, as the editor types into it ----
|
|
763
|
+
|
|
764
|
+
/** A source line: its prefix (quote markers, a list marker, a heading's #s), its text, and a trailing {…} with spaces. */
|
|
765
|
+
var LINE = /^(\s*(?:>\s*)*(?:(?:[-*+]|\d+[.)])\s+)?(?:#{1,6}\s+)?)(.*?)((?:\s*\{[^{}]*\})?\s*)$/;
|
|
766
|
+
/** What continuation lines of a block start with: its quote markers and indentation. */
|
|
767
|
+
var CONT = /^\s*(?:>\s?)*/;
|
|
768
|
+
|
|
769
|
+
/**
|
|
770
|
+
* Cell spans of a table row: between unescaped pipes outside code spans, without the outer pipes, and without a
|
|
771
|
+
* trailing {…} (a column's or cell's options), which stays in the row around the text like a block's braces.
|
|
772
|
+
*/
|
|
773
|
+
function rowCells(line) {
|
|
774
|
+
var cuts = [-1], code = false;
|
|
775
|
+
for (var i = 0; i < line.length; i++) {
|
|
776
|
+
var c = line[i];
|
|
777
|
+
if (c === '\\') i++;
|
|
778
|
+
else if (c === '`') code = !code;
|
|
779
|
+
else if (c === '|' && !code) cuts.push(i);
|
|
780
|
+
}
|
|
781
|
+
cuts.push(line.length);
|
|
782
|
+
var cells = [];
|
|
783
|
+
for (var k = 0; k + 1 < cuts.length; k++) cells.push({ start: cuts[k] + 1, end: cuts[k + 1] });
|
|
784
|
+
var blank = function (cell) { return !line.slice(cell.start, cell.end).trim(); };
|
|
785
|
+
if (cells.length && blank(cells[0]) && /^\s*\|/.test(line)) cells.shift();
|
|
786
|
+
if (cells.length && blank(cells[cells.length - 1]) && /\|\s*$/.test(line)) cells.pop();
|
|
787
|
+
return cells.map(function (cell) {
|
|
788
|
+
var text = line.slice(cell.start, cell.end);
|
|
789
|
+
var lead = text.length - text.replace(/^\s+/, '').length;
|
|
790
|
+
var trimmed = text.trim(), braces = /\s*\{([^{}]*)\}$/.exec(trimmed);
|
|
791
|
+
// Not an escaped \{…\} or an empty {}, which are the cell's text.
|
|
792
|
+
if (braces && braces[1].trim() && trimmed[trimmed.lastIndexOf('{') - 1] !== '\\') trimmed = trimmed.slice(0, braces.index);
|
|
793
|
+
return { start: cell.start + lead, end: cell.start + lead + trimmed.length };
|
|
794
|
+
});
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
/** A one-line block's source line as its prefix (`- `, `## `), text, and trailing `{…}`. */
|
|
798
|
+
function lineParts(line) {
|
|
799
|
+
var m = LINE.exec(line);
|
|
800
|
+
if (!m) return null;
|
|
801
|
+
var content = m[2], after = m[3];
|
|
802
|
+
if (after.trim() && !hasBlockAttrs(line)) { content = line.slice(m[1].length).replace(/\s+$/, ''); after = line.slice(m[1].length + content.length); }
|
|
803
|
+
return { before: m[1], content: content, after: after };
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
/** What a new line of a block starts with: its first line's prefix, with a list marker as spaces and no heading marker. */
|
|
807
|
+
function contOf(before) {
|
|
808
|
+
return before.replace(/#{1,6}\s+$/, '').replace(/(?:[-*+]|\d+[.)])\s+$/, function (m) { return new Array(m.length + 1).join(' '); });
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
/**
|
|
812
|
+
* A block's source lines as its first line's prefix (`- `, `> `), each line's prefix (`heads`, the first line's
|
|
813
|
+
* included), each line's text (`rows`), and what ends the last line (a {…} for the block, spaces).
|
|
814
|
+
*/
|
|
815
|
+
function blockParts(lines) {
|
|
816
|
+
if (lines.length === 1) {
|
|
817
|
+
var one = lineParts(lines[0]);
|
|
818
|
+
return one && { before: one.before, heads: [one.before], rows: [one.content], after: one.after };
|
|
819
|
+
}
|
|
820
|
+
var m = LINE.exec(lines[0]);
|
|
821
|
+
if (!m) return null;
|
|
822
|
+
var heads = [m[1]], rows = [lines[0].slice(m[1].length)];
|
|
823
|
+
for (var k = 1; k < lines.length; k++) {
|
|
824
|
+
var h = CONT.exec(lines[k])[0];
|
|
825
|
+
heads.push(h);
|
|
826
|
+
rows.push(lines[k].slice(h.length));
|
|
827
|
+
}
|
|
828
|
+
var last = rows.length - 1, end = (hasBlockAttrs(lines[last]) ? /\s*\{[^{}]*\}\s*$/ : /\s*$/).exec(rows[last]);
|
|
829
|
+
var after = end ? end[0] : '';
|
|
830
|
+
rows[last] = rows[last].slice(0, rows[last].length - after.length);
|
|
831
|
+
return { before: m[1], heads: heads, rows: rows, after: after };
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
/**
|
|
835
|
+
* The source lines for a block's text as typed (its lines joined by \n), from `t` = {before, heads, after}: each line
|
|
836
|
+
* with the prefix it had, a new one with the last line's (or, for a block of one line, its continuation of the first's).
|
|
837
|
+
*/
|
|
838
|
+
function joinLines(t, text) {
|
|
839
|
+
var heads = t.heads || [t.before], cont = heads.length > 1 ? heads[heads.length - 1] : contOf(t.before);
|
|
840
|
+
return text.split('\n').map(function (row, i) {
|
|
841
|
+
return (i === 0 ? t.before : heads[i] !== undefined ? heads[i] : cont) + row;
|
|
842
|
+
}).join('\n') + t.after;
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
/** The list marker after `prefix`'s: the next number for a numbered item, the same bullet otherwise. */
|
|
846
|
+
function nextItem(prefix) {
|
|
847
|
+
return prefix.replace(/(\d+)([.)])/, function (m, n, d) { return (Number(n) + 1) + d; });
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
/**
|
|
851
|
+
* Backspace at the start of block b (or Delete at the end of a): b's text joins the end of a's, keeping a's prefix
|
|
852
|
+
* and {…}; b's prefix and {…} go, and its other lines stay as they are. The joined lines and the caret (`at`, in a's
|
|
853
|
+
* text joined by \n), or null for lines that aren't blocks of text.
|
|
854
|
+
*/
|
|
855
|
+
function mergeLines(aLines, bLines) {
|
|
856
|
+
var pa = blockParts(aLines), pb = blockParts(bLines);
|
|
857
|
+
if (!pa || !pb) return null;
|
|
858
|
+
var rows = pa.rows.concat(pb.rows.slice(1)), at = pa.rows.join('\n').length;
|
|
859
|
+
rows[pa.rows.length - 1] += pb.rows[0];
|
|
860
|
+
return { text: joinLines({ before: pa.before, heads: pa.heads.concat(pb.heads.slice(1)), after: pa.after }, rows.join('\n')), at: at };
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
/**
|
|
864
|
+
* Enter inside a block's text splits it: `left` stays in the block `t` ({before, heads, after, multi}), and `right`
|
|
865
|
+
* starts the next list item (`item`: the block's list marker prefix) or a paragraph at the same depth. What would
|
|
866
|
+
* read as a block marker at the start of a new paragraph is escaped. The two blocks' lines, and the line breaks
|
|
867
|
+
* between them (`gap`: 1 between items, 2 around a paragraph).
|
|
868
|
+
*/
|
|
869
|
+
function splitLines(t, left, right, item) {
|
|
870
|
+
if (!item && /^(?:#{1,6}(?:\s|$)|[-*+]\s|\d+[.)]\s|>|---(?:\s|$)|===\s)/.test(right)) right = right.replace(/^(\d+)(?=[.)])/, '$1\\').replace(/^(?=[^\d])/, '\\');
|
|
871
|
+
var line1 = t.multi ? joinLines(t, left) : t.before + left + t.after;
|
|
872
|
+
var line2 = joinLines({ before: item ? nextItem(item) : contOf(t.before), heads: null, after: '' }, right);
|
|
873
|
+
return { line1: line1, line2: line2, gap: item ? 1 : 2 };
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
// A new block typed after another (Enter at the end of a block), before any of it is saved: its prefix, the patch
|
|
877
|
+
// that inserts it, and those that take it or a blank line out again.
|
|
878
|
+
var LIST_ITEM = /^\s*(?:>\s?)*(?:[-*+]|\d+[.)])\s+/;
|
|
879
|
+
|
|
880
|
+
/**
|
|
881
|
+
* The block typed after one whose first line is `line` (an item's, or '' for any other block): the next item of its
|
|
882
|
+
* list, or (`subLine`: the first line of the list under the item) that list's first; else a paragraph with a blank
|
|
883
|
+
* line before it. Its prefix, `sep` (the blank line), whether it is an `item`, and whether it goes in the `sub` list.
|
|
884
|
+
*/
|
|
885
|
+
function afterBlock(line, subLine) {
|
|
886
|
+
var item = LIST_ITEM.exec(line), sub = item && subLine != null && LIST_ITEM.exec(subLine);
|
|
887
|
+
if (sub) return { prefix: sub[0], sep: false, item: true, sub: true };
|
|
888
|
+
return item ? { prefix: nextItem(item[0]), sep: false, item: true, sub: false } : { prefix: '', sep: true, item: false, sub: false };
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
/**
|
|
892
|
+
* What a new block saves: its prefix and text, after the slide break typed before it (`brk`), or the break alone;
|
|
893
|
+
* null while there is nothing to save. Saved as typed, Markdown and all (a line of `=== col` starts a column).
|
|
894
|
+
*/
|
|
895
|
+
function addedText(prefix, text, brk) {
|
|
896
|
+
var typed = text.trim() ? prefix + text : '';
|
|
897
|
+
if (!typed && !brk) return null;
|
|
898
|
+
return typed ? (brk || '') + typed : brk.replace(/\n+$/, '');
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
/**
|
|
902
|
+
* Insert `body` after the lines of the block at `ref` ({start, end}), or (`before`: typed on a blank line) in that
|
|
903
|
+
* line's place, with the blank line moving below. `sep`: a blank line first. A paragraph needs a blank line before
|
|
904
|
+
* what comes next; list items (`item`) run on. Its first line lands at start + 1 with `sep`, else at start.
|
|
905
|
+
*/
|
|
906
|
+
function insertBlock(lines, ref, body, opts) {
|
|
907
|
+
var at = opts.before ? ref.start : ref.end + 1, next = lines[at - 1];
|
|
908
|
+
var trail = !opts.item && next !== undefined && next.trim() ? '\n' : '';
|
|
909
|
+
return { start: at, end: at - 1, expected: '', text: (opts.sep ? '\n' : '') + body + trail };
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
/**
|
|
913
|
+
* Enter on an empty new paragraph: a blank line in the source. After a block, its separator and one more (two,
|
|
914
|
+
* where it had none); on a blank line (`before`), one more before it. The new blank line is start + 1.
|
|
915
|
+
*/
|
|
916
|
+
function insertBlank(lines, ref, before) {
|
|
917
|
+
var at = before ? ref.start : ref.end + 1, here = lines[at - 1];
|
|
918
|
+
var text = before || (here !== undefined && !here.trim()) ? '' : '\n';
|
|
919
|
+
return { start: at, end: at - 1, expected: '', text: text };
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
/** Take blank line n out; null when it has text. */
|
|
923
|
+
function dropBlank(lines, n) {
|
|
924
|
+
if ((lines[n - 1] || '').trim()) return null;
|
|
925
|
+
return { start: n, end: n, expected: lines[n - 1], text: null };
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
/** Take out the lines of a block saved as `saved` from line `start`, with the blank line before it (`blankBefore`). */
|
|
929
|
+
function dropLines(start, saved, blankBefore) {
|
|
930
|
+
var n = saved.split('\n').length, from = start - (blankBefore ? 1 : 0);
|
|
931
|
+
return { start: from, end: start + n - 1, expected: (blankBefore ? '\n' : '') + saved, text: null };
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
// Markdown typed at the start of a block makes it a heading, a list, or a quote; the marker goes, and the text after
|
|
935
|
+
// it is in the new block.
|
|
936
|
+
var SHORTCUT = /^(#{1,6}|[-*+]|\d+[.)]|>)[ \u00a0]/;
|
|
937
|
+
function shortcutKind(marker) {
|
|
938
|
+
return marker[0] === '#' ? 'h' + marker.length : marker === '>' ? 'quote' : /\d/.test(marker) ? 'ol' : 'ul';
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
/**
|
|
942
|
+
* The block marker typed at the start of `text` (`# `, `- `, `3. `, `> `): the marker, its kind, its length with
|
|
943
|
+
* the space, and the prefix a new block saves with it. Null when there is none.
|
|
944
|
+
*/
|
|
945
|
+
function shortcut(text) {
|
|
946
|
+
var m = SHORTCUT.exec(text);
|
|
947
|
+
return m && { marker: m[1], kind: shortcutKind(m[1]), length: m[0].length, prefix: m[1] + ' ' };
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
/** The line of a block edited in place, after `marker` was typed at its start. A numbered item keeps the number typed (`3. `, `1) `). */
|
|
951
|
+
function shortcutLine(line, marker) {
|
|
952
|
+
var kind = shortcutKind(marker), out = setBlockKind(line, kind);
|
|
953
|
+
if (kind === 'ol') out = out.replace(/^(\s*)\d+[.)] /, function (x, ind) { return ind + marker + ' '; });
|
|
954
|
+
return out;
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
/** A paragraph that is only a list marker (`-`, `*`, `+`, `1.`, `1)`): Enter starts a list there. */
|
|
958
|
+
function onlyMarker(text) {
|
|
959
|
+
return /^([-*+]|\d+[.)])$/.test(text);
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
/** `===` or `---` at the start of a new list item: a divider or a slide break, not an item; the line leaves the list. */
|
|
963
|
+
function leavesList(text) {
|
|
964
|
+
return /^(?:===|---)/.test(text);
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
/**
|
|
968
|
+
* Tab (dir 1) or Shift+Tab (dir -1) on a new item with nothing saved yet: its prefix, worked out as if it were in the
|
|
969
|
+
* source after line `after` (the item before it). Null when it can't move.
|
|
970
|
+
*/
|
|
971
|
+
function indentPrefix(lines, after, prefix, dir) {
|
|
972
|
+
var q = indentItem(lines.slice(0, after).concat([prefix + 'x'], lines.slice(after)), after + 1, dir);
|
|
973
|
+
return q && q.text.split('\n')[0].slice(0, -1);
|
|
974
|
+
}
|
|
975
|
+
|
|
762
976
|
/** Whether a line ends in braces of its own (block attributes), not an inline element's. */
|
|
763
977
|
function hasBlockAttrs(line) {
|
|
764
978
|
return !!blockAttrs(line);
|
|
@@ -779,7 +993,7 @@
|
|
|
779
993
|
'©': ['(c)', '(C)'], '®': ['(r)', '(R)'], '™': ['(tm)', '(TM)'], '±': ['+-'] };
|
|
780
994
|
// What may stand between rendered characters: emphasis and code markers, link and span brackets with their target
|
|
781
995
|
// or attributes, autolink brackets.
|
|
782
|
-
var MARKUP = /^(
|
|
996
|
+
var MARKUP = /^(?:\*|_|`|~~|\[|\]\([^)\s]*(?:\s+(?:"[^"]*"|'[^']*'))?\)|\]|\{[^{}]*\}|<|>)+$/;
|
|
783
997
|
var ESCAPABLE = /[!-\/:-@\[-`{-~]/;
|
|
784
998
|
|
|
785
999
|
/**
|
|
@@ -861,6 +1075,27 @@
|
|
|
861
1075
|
alignRendered: alignRendered,
|
|
862
1076
|
spliceRendered: spliceRendered,
|
|
863
1077
|
hasBlockAttrs: hasBlockAttrs,
|
|
1078
|
+
LINE: LINE,
|
|
1079
|
+
rowCells: rowCells,
|
|
1080
|
+
lineParts: lineParts,
|
|
1081
|
+
contOf: contOf,
|
|
1082
|
+
blockParts: blockParts,
|
|
1083
|
+
joinLines: joinLines,
|
|
1084
|
+
nextItem: nextItem,
|
|
1085
|
+
mergeLines: mergeLines,
|
|
1086
|
+
splitLines: splitLines,
|
|
1087
|
+
LIST_ITEM: LIST_ITEM,
|
|
1088
|
+
afterBlock: afterBlock,
|
|
1089
|
+
addedText: addedText,
|
|
1090
|
+
insertBlock: insertBlock,
|
|
1091
|
+
insertBlank: insertBlank,
|
|
1092
|
+
dropBlank: dropBlank,
|
|
1093
|
+
dropLines: dropLines,
|
|
1094
|
+
shortcut: shortcut,
|
|
1095
|
+
shortcutLine: shortcutLine,
|
|
1096
|
+
onlyMarker: onlyMarker,
|
|
1097
|
+
leavesList: leavesList,
|
|
1098
|
+
indentPrefix: indentPrefix,
|
|
864
1099
|
keepBlockAttrs: keepBlockAttrs,
|
|
865
1100
|
spliceTyped: spliceTyped,
|
|
866
1101
|
toggleWrap: toggleWrap,
|