@bigmistqke/whiteboard 0.3.1 → 0.5.0
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 +119 -18
- package/bin/whiteboard.ts +300 -71
- package/dist/bin/whiteboard.js +21 -0
- package/dist/client/runtime.js +132 -54
- package/dist/define.js +21 -2
- package/dist/plugins/callout/index.js +3 -1
- package/dist/plugins/callout/public/style.css +30 -0
- package/dist/plugins/chat/index.js +7 -4
- package/dist/plugins/chat/{client.js → public/client.js} +1 -1
- package/dist/plugins/chat/public/style.css +98 -0
- package/dist/plugins/code/index.js +3 -1
- package/dist/plugins/code/public/style.css +68 -0
- package/dist/plugins/comments/index.js +4 -5
- package/dist/plugins/comments/public/client.js +19 -0
- package/dist/plugins/comments/public/style.css +185 -0
- package/dist/plugins/details/index.js +7 -2
- package/dist/plugins/details/public/style.css +7 -0
- package/dist/plugins/draft/README.md +14 -0
- package/dist/plugins/draft/index.js +21 -0
- package/dist/plugins/draft/public/style.css +21 -0
- package/dist/plugins/form/index.js +37 -8
- package/dist/plugins/form/public/style.css +126 -0
- package/dist/plugins/gallery/index.js +4 -3
- package/dist/plugins/gallery/public/client.js +1 -0
- package/dist/plugins/gallery/public/style.css +90 -0
- package/dist/plugins/grid/index.js +9 -3
- package/dist/plugins/grid/public/style.css +71 -0
- package/dist/plugins/iframe/index.js +13 -14
- package/dist/plugins/iframe/public/style.css +13 -0
- package/dist/plugins/index.js +7 -1
- package/dist/plugins/mermaid/index.js +3 -1
- package/dist/plugins/mermaid/{style.css → public/style.css} +7 -2
- package/dist/plugins/steps/README.md +42 -0
- package/dist/plugins/steps/index.js +99 -0
- package/dist/plugins/steps/public/client.js +1 -0
- package/dist/plugins/steps/public/style.css +77 -0
- package/dist/plugins/terminal/host.js +9 -3
- package/dist/plugins/terminal/index.js +10 -9
- package/dist/plugins/terminal/{style.css → public/style.css} +199 -45
- package/dist/plugins/terminal/sizes.js +2 -1
- package/dist/plugins/toc/README.md +21 -3
- package/dist/plugins/toc/index.js +12 -5
- package/dist/plugins/toc/public/client.js +1 -0
- package/dist/plugins/toc/public/style.css +99 -0
- package/dist/plugins/window/README.md +29 -0
- package/dist/plugins/window/index.js +64 -0
- package/dist/solid/index.js +14 -11
- package/dist/src/auth.js +2 -1
- package/dist/src/client/page/base.css +1078 -199
- package/dist/src/client/page/main.js +188 -39
- package/dist/src/loader.js +14 -3
- package/dist/src/package.js +3 -6
- package/dist/src/pages/blocks.js +8 -13
- package/dist/src/pages/markdown.js +1 -1
- package/dist/src/pages/render.js +106 -20
- package/dist/src/pages/window.js +31 -0
- package/dist/src/public.js +24 -0
- package/dist/src/server.js +251 -23
- package/package.json +5 -2
- package/plugins/callout/index.ts +3 -1
- package/plugins/callout/public/style.css +30 -0
- package/plugins/chat/autosize.ts +43 -9
- package/plugins/chat/client.tsx +22 -5
- package/plugins/chat/index.ts +22 -8
- package/plugins/chat/public/style.css +98 -0
- package/plugins/claude-code/index.ts +49 -14
- package/plugins/code/diff.ts +28 -8
- package/plugins/code/index.ts +33 -21
- package/plugins/code/public/style.css +68 -0
- package/plugins/comments/client.ts +139 -71
- package/plugins/comments/index.ts +9 -7
- package/plugins/comments/public/style.css +185 -0
- package/plugins/details/index.ts +7 -2
- package/plugins/details/public/style.css +7 -0
- package/plugins/draft/README.md +14 -0
- package/plugins/draft/index.ts +23 -0
- package/plugins/draft/public/style.css +21 -0
- package/plugins/forge/index.ts +16 -3
- package/plugins/form/index.ts +75 -27
- package/plugins/form/public/style.css +126 -0
- package/plugins/gallery/client.tsx +9 -3
- package/plugins/gallery/index.ts +31 -9
- package/plugins/gallery/public/style.css +90 -0
- package/plugins/grid/index.ts +19 -5
- package/plugins/grid/public/style.css +71 -0
- package/plugins/iframe/index.ts +20 -23
- package/plugins/iframe/public/style.css +13 -0
- package/plugins/index.ts +20 -1
- package/plugins/mermaid/index.ts +7 -3
- package/plugins/mermaid/{style.css → public/style.css} +7 -2
- package/plugins/steps/README.md +42 -0
- package/plugins/steps/client.ts +66 -0
- package/plugins/steps/index.ts +127 -0
- package/plugins/steps/public/style.css +77 -0
- package/plugins/terminal/client.ts +105 -48
- package/plugins/terminal/host.ts +143 -35
- package/plugins/terminal/index.ts +84 -25
- package/plugins/terminal/public/style.css +225 -0
- package/plugins/terminal/server.ts +64 -13
- package/plugins/terminal/sizes.ts +16 -4
- package/plugins/toc/README.md +21 -3
- package/plugins/toc/client.ts +90 -30
- package/plugins/toc/index.ts +26 -10
- package/plugins/toc/public/style.css +99 -0
- package/plugins/window/README.md +29 -0
- package/plugins/window/index.ts +85 -0
- package/skills/whiteboard/SKILL.md +3 -1
- package/solid/index.tsx +24 -9
- package/src/auth.ts +28 -9
- package/src/client/forms.ts +74 -28
- package/src/client/markdown.ts +15 -4
- package/src/client/page/base.css +1078 -199
- package/src/client/page/elsewhere.ts +32 -15
- package/src/client/page/fresh.ts +91 -23
- package/src/client/page/hold.ts +11 -2
- package/src/client/page/live.ts +10 -6
- package/src/client/page/main.ts +124 -42
- package/src/client/page/orphans.ts +25 -10
- package/src/client/page/sort.ts +14 -4
- package/src/client/page/sticky.ts +11 -3
- package/src/client/page/theme.ts +11 -7
- package/src/client/page/waiting.ts +141 -34
- package/src/client/page/window.ts +40 -0
- package/src/client/reactive.ts +19 -0
- package/src/client/read.ts +17 -10
- package/src/client/runtime.ts +170 -40
- package/src/client/scroll.ts +14 -4
- package/src/client/toast.ts +19 -5
- package/src/config.ts +20 -5
- package/src/define.ts +119 -31
- package/src/events.ts +111 -24
- package/src/html.ts +6 -2
- package/src/icons.ts +4 -2
- package/src/load.ts +10 -2
- package/src/loader.ts +81 -12
- package/src/package.ts +9 -8
- package/src/pages/blocks.ts +20 -14
- package/src/pages/index.ts +2 -2
- package/src/pages/markdown.ts +113 -34
- package/src/pages/render.ts +233 -41
- package/src/pages/window.ts +78 -0
- package/src/plugins.ts +90 -24
- package/src/public.ts +39 -0
- package/src/running.ts +8 -2
- package/src/serve.ts +29 -7
- package/src/server.ts +591 -110
- package/src/status.ts +15 -9
- package/dist/plugins/callout/style.css +0 -12
- package/dist/plugins/chat/style.css +0 -24
- package/dist/plugins/code/style.css +0 -29
- package/dist/plugins/comments/client.js +0 -10
- package/dist/plugins/comments/style.css +0 -40
- package/dist/plugins/details/style.css +0 -3
- package/dist/plugins/form/style.css +0 -44
- package/dist/plugins/gallery/client.js +0 -1
- package/dist/plugins/gallery/style.css +0 -27
- package/dist/plugins/grid/style.css +0 -25
- package/dist/plugins/iframe/client.js +0 -1
- package/dist/plugins/iframe/style.css +0 -29
- package/dist/plugins/toc/client.js +0 -1
- package/dist/plugins/toc/style.css +0 -19
- package/plugins/callout/style.css +0 -12
- package/plugins/chat/style.css +0 -24
- package/plugins/code/style.css +0 -29
- package/plugins/comments/style.css +0 -40
- package/plugins/details/style.css +0 -3
- package/plugins/form/style.css +0 -44
- package/plugins/gallery/style.css +0 -27
- package/plugins/grid/style.css +0 -25
- package/plugins/iframe/client.ts +0 -46
- package/plugins/iframe/style.css +0 -29
- package/plugins/terminal/style.css +0 -71
- package/plugins/toc/style.css +0 -19
- /package/dist/plugins/terminal/{client.js → public/client.js} +0 -0
package/README.md
CHANGED
|
@@ -280,6 +280,7 @@ upward with a `.whiteboard/` folder.
|
|
|
280
280
|
| `whiteboard append --page <p> --type <t> [--data <json>]` | add an event to a page's log, such as a reply to a comment |
|
|
281
281
|
| `whiteboard pick <event id>` | record an event as picked up, as `wait` does when it hands one out |
|
|
282
282
|
| `whiteboard status [--page <p>]` | per page: questions without an answer, answers no agent picked up, who is listening |
|
|
283
|
+
| `whiteboard build [globs…] [--out <dir>] [--skip <a,b>]` | pages as a static site (see [Building a site](#building-a-site)) |
|
|
283
284
|
| `whiteboard serve` | run the server in the foreground |
|
|
284
285
|
| `whiteboard skill [dir]` | print where the agent skill is, or link it into a skills folder |
|
|
285
286
|
|
|
@@ -308,15 +309,45 @@ export default defineConfig({
|
|
|
308
309
|
],
|
|
309
310
|
style: new URL('./site.css', import.meta.url), // a stylesheet on every page, after the others
|
|
310
311
|
files: true, // serve and watch the rest of the project at /-/ (default: true)
|
|
312
|
+
build: { pages: ['docs/**/*.md'] }, // what `whiteboard build` makes (see Building a site)
|
|
311
313
|
})
|
|
312
314
|
```
|
|
313
315
|
|
|
314
|
-
The
|
|
315
|
-
|
|
316
|
+
The page's look is CSS custom properties, set in the base stylesheet and
|
|
317
|
+
used by every built-in plugin, which a project's stylesheet overrides:
|
|
318
|
+
|
|
319
|
+
- colours: `--bg`, `--text`, `--muted`, `--border`, `--accent`,
|
|
320
|
+
`--accent-text`, `--ok`, `--warn`, `--bad`;
|
|
321
|
+
- type: `--serif`, `--sans`, `--mono`; the article's `--text-size` and
|
|
322
|
+
`--line-height` (its margins and headings are in `em`, so they follow);
|
|
323
|
+
the interface's `--ui-tiny`, `--ui-small`, `--ui-text` and
|
|
324
|
+
`--ui-line-height`;
|
|
325
|
+
- space: the article's `--rhythm` (between blocks; a set-off block such as
|
|
326
|
+
a form gets three), the interface's `--space-2xs` … `--space-3xl` (2, 4,
|
|
327
|
+
6, 8, 10, 12, 16, 24px);
|
|
328
|
+
- shape: `--radius-sm`, `--radius`, `--radius-lg`, `--radius-pill`,
|
|
329
|
+
`--hairline`, `--shadow-pop`; tints `--tint-faint`, `--tint-soft`,
|
|
330
|
+
`--tint-strong`; `--speed`;
|
|
331
|
+
- widths: `--measure`, `--wide`; layers: `--layer-aside`,
|
|
332
|
+
`--layer-popover`, `--layer-window`, `--layer-top` (for a plugin's own
|
|
333
|
+
floating things).
|
|
334
|
+
|
|
335
|
+
Every colour is a `light-dark()` pair, so one line sets it for both themes:
|
|
336
|
+
|
|
337
|
+
```css
|
|
338
|
+
/* .whiteboard/site.css */
|
|
339
|
+
:root { --accent: light-dark(#c2410c, #fb923c); --serif: "Source Serif 4", Georgia, serif; }
|
|
340
|
+
/* denser: smaller text, tighter blocks */
|
|
341
|
+
:root { --text-size: 17px; --rhythm: 1em; }
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
The built-in plugins are callout, chat, code, comments, details, draft,
|
|
345
|
+
forge, form, gallery, grid, iframe, mermaid, quiet, steps and window: every project has them, and
|
|
316
346
|
`whiteboard docs` shows how to write each. A config's `plugins` add to them,
|
|
317
347
|
and one with a built-in's name replaces it. The terminal and the Claude Code
|
|
318
348
|
plugin are opt-in, since they run code or are about one agent, and so is the
|
|
319
|
-
table of contents (`toc`), which
|
|
349
|
+
table of contents (`toc`), which a page then asks for in its frontmatter
|
|
350
|
+
(`plugins: { toc: true }`).
|
|
320
351
|
|
|
321
352
|
Named forms need nothing in the config: the core sends a submit of any
|
|
322
353
|
`<form name>` as an event, on any page.
|
|
@@ -325,6 +356,54 @@ Set `files: false` for a project whose folder is not a repository, such as
|
|
|
325
356
|
your home folder. Then only `.whiteboard/` is served and watched.
|
|
326
357
|
`whiteboard init` sets it when run in the home folder.
|
|
327
358
|
|
|
359
|
+
## Building a site
|
|
360
|
+
|
|
361
|
+
Docs can be written as pages: the agent drafts, you comment on passages, a
|
|
362
|
+
form settles a choice, a chat clears up a question. Kept in a folder of the
|
|
363
|
+
repository (`docs/`), they are live pages at `/-/docs/…` while you write
|
|
364
|
+
them. `whiteboard build` turns them into a site: plain HTML files with their
|
|
365
|
+
images and styles, links between them relative, for GitHub Pages or any
|
|
366
|
+
file host.
|
|
367
|
+
|
|
368
|
+
```ts
|
|
369
|
+
export default defineConfig({
|
|
370
|
+
build: {
|
|
371
|
+
pages: ['docs/**/*.md', '!docs/notes/**'], // which pages, as globs; ! leaves out
|
|
372
|
+
skip: ['form', 'chat', 'comments', 'draft'], // plugins or blocks left out (this is the default)
|
|
373
|
+
out: 'site', // where it goes (default: site)
|
|
374
|
+
},
|
|
375
|
+
})
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
```sh
|
|
379
|
+
whiteboard build # as configured
|
|
380
|
+
whiteboard build 'docs/guide/*.md' --out preview # or what is given, over the config
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
- **What is for writing is left out:** the live channel and the event log
|
|
384
|
+
(so no answers, chats or comments), new-content marks and toasts, and the
|
|
385
|
+
plugins and blocks in `skip`: their blocks render as nothing, their
|
|
386
|
+
stylesheets, browser modules and what they add to the page aren't included.
|
|
387
|
+
A plugin's `shell` is asked with no request, since no browser asked for the
|
|
388
|
+
page: the terminal's drawer, which is only for the project's own browser,
|
|
389
|
+
isn't there.
|
|
390
|
+
- **What is for reading stays:** steps, the gallery's lightbox, ⤢ on
|
|
391
|
+
windows, the theme toggle, the contents, details. Code and diagrams were
|
|
392
|
+
rendered on the server, so the site loads no highlighter.
|
|
393
|
+
- **`:::draft`** is for what is there while you write and not after: a note
|
|
394
|
+
to check something, two versions of a paragraph. It shows marked as a
|
|
395
|
+
draft, and the build leaves it out.
|
|
396
|
+
- **Where pages land:** at their places below the folder they share, a
|
|
397
|
+
README.md or index.md as its folder's index.html (`docs/api/forms.md` →
|
|
398
|
+
`site/api/forms.html`). A link to a page outside the build, or to a file
|
|
399
|
+
outside that folder, stays as written, and the build says so.
|
|
400
|
+
- **The folder is the build's:** it is replaced on each build, and one that
|
|
401
|
+
holds files a build didn't write is refused.
|
|
402
|
+
|
|
403
|
+
Open the site through a web server (`npx serve site`) rather than as files:
|
|
404
|
+
browsers don't run JavaScript modules from `file://`. The pages read either
|
|
405
|
+
way, but steps, the lightbox and the theme toggle need the server.
|
|
406
|
+
|
|
328
407
|
## Writing a plugin
|
|
329
408
|
|
|
330
409
|
Everything that extends whiteboard is a plugin: syntax for pages,
|
|
@@ -362,7 +441,7 @@ export default function checklist() {
|
|
|
362
441
|
},
|
|
363
442
|
// shown until the client mounts, then replaced
|
|
364
443
|
html: () => html`<ul class="checklist"></ul>`,
|
|
365
|
-
client:
|
|
444
|
+
client: 'client.js', // in its public/ folder
|
|
366
445
|
},
|
|
367
446
|
},
|
|
368
447
|
// its events, and whether a `wait` on the page hands them out (a tick is information: no)
|
|
@@ -374,7 +453,7 @@ export default function checklist() {
|
|
|
374
453
|
```
|
|
375
454
|
|
|
376
455
|
```js
|
|
377
|
-
// .whiteboard/plugins/checklist/client.js:
|
|
456
|
+
// .whiteboard/plugins/checklist/public/client.js: its public/ folder is served, nothing else of it
|
|
378
457
|
export default function mount(el, { name, items }, api) {
|
|
379
458
|
const ticked = () => {
|
|
380
459
|
const state = new Map()
|
|
@@ -393,7 +472,7 @@ export default function mount(el, { name, items }, api) {
|
|
|
393
472
|
}
|
|
394
473
|
draw()
|
|
395
474
|
// the page's events, also the ones it appends itself, come back here
|
|
396
|
-
return api.
|
|
475
|
+
return api.events.on(draw)
|
|
397
476
|
}
|
|
398
477
|
```
|
|
399
478
|
|
|
@@ -413,7 +492,7 @@ An agent can wait for a tick by asking for it: `whiteboard wait --page
|
|
|
413
492
|
A plugin can also put something on every page, and add commands:
|
|
414
493
|
|
|
415
494
|
```ts
|
|
416
|
-
// .whiteboard/plugins/votes.ts
|
|
495
|
+
// .whiteboard/plugins/votes/index.ts
|
|
417
496
|
import { definePlugin } from '@bigmistqke/whiteboard'
|
|
418
497
|
import { read } from '@bigmistqke/whiteboard/log'
|
|
419
498
|
|
|
@@ -433,19 +512,19 @@ export default function votes() {
|
|
|
433
512
|
},
|
|
434
513
|
docs: () => 'The reader can vote a page up: a `votes:up` event. `whiteboard votes` counts them.',
|
|
435
514
|
// from setup: what the running server adds (routes, markup, the browser module)
|
|
436
|
-
setup: () => ({ client:
|
|
515
|
+
setup: () => ({ client: 'client.js' }),
|
|
437
516
|
})
|
|
438
517
|
}
|
|
439
518
|
```
|
|
440
519
|
|
|
441
520
|
```js
|
|
442
|
-
// .whiteboard/plugins/votes
|
|
521
|
+
// .whiteboard/plugins/votes/public/client.js
|
|
443
522
|
export default function mount(root, page, api) {
|
|
444
523
|
const button = document.createElement('button')
|
|
445
524
|
const draw = () => { button.textContent = `👍 ${api.events().filter(e => e.type === 'votes:up').length}` }
|
|
446
525
|
button.addEventListener('click', () => api.append('votes:up'))
|
|
447
526
|
api.corner().append(button) // the page's corner, for floating buttons
|
|
448
|
-
api.
|
|
527
|
+
api.events.on(draw)
|
|
449
528
|
draw()
|
|
450
529
|
}
|
|
451
530
|
```
|
|
@@ -481,17 +560,37 @@ export default function mount(root, page, api) {
|
|
|
481
560
|
- `shell`, markup at the end of every page's `<head>` and `<body>`;
|
|
482
561
|
- `client`, a module on every page, run once per page load.
|
|
483
562
|
|
|
484
|
-
**
|
|
485
|
-
|
|
563
|
+
**A block can draw a window** around what it shows, the same one as
|
|
564
|
+
`::iframe`, `::image`, `::video` and `:::window`: `windowFrame({ label, open,
|
|
565
|
+
body })` from `@bigmistqke/whiteboard` gives it a header with its label, a
|
|
566
|
+
button that opens `open` on its own, and one that fills the browser window
|
|
567
|
+
(the page does that part).
|
|
568
|
+
|
|
569
|
+
**A plugin's browser files live in its `public/` folder**, and only that
|
|
570
|
+
folder is served: its client modules, styles, images and fonts, never its
|
|
571
|
+
server code or the project's files beside it. `client` and `style` (a
|
|
572
|
+
plugin's and a block's) name files in it: `'client.js'`. `definePlugin` puts
|
|
573
|
+
it next to the module that calls it (`plugins/checklist/public/` for
|
|
574
|
+
`plugins/checklist/index.ts`); say another with `public: new URL('./assets/',
|
|
575
|
+
import.meta.url)`; a plain object plugin, or one written in the config, has
|
|
576
|
+
`.whiteboard/public/`. A file named outside it is a config error. Browser
|
|
577
|
+
code is JavaScript or TypeScript: a `.ts` file is served with its types
|
|
578
|
+
stripped (Node's type stripping, as for server code: types only, so no
|
|
579
|
+
`enum` or `namespace`, and imports name their `.ts` files). JSX still needs
|
|
580
|
+
building first. A block's `client` gets
|
|
486
581
|
`mount(element, props, api)` and may return a cleanup, run when the block
|
|
487
582
|
is replaced on a live update; it replaces the server's HTML when it mounts.
|
|
488
583
|
A page module (`setup`'s `client`) gets `mount(root, page, api)`. Both get
|
|
489
|
-
the page's `api`: its events and `append` (which comes back through
|
|
490
|
-
`
|
|
491
|
-
what it adds),
|
|
584
|
+
the page's `api`: its `events` and `append` (which comes back through
|
|
585
|
+
`events.on`), the `listeners`, `forms` and `unread` messages, `onRendered`
|
|
586
|
+
(after a live update, to put back what it adds), the page's `frontmatter`
|
|
587
|
+
on the page handle (YAML, as parsed) and the plugin's own `settings` in it
|
|
588
|
+
(under `plugins:` by its name: `plugins: { toc: true }` is `true` for toc), `corner()` for floating buttons, `toast()` for a label in
|
|
492
589
|
the corner that says what is going on and goes there (one that hides after a
|
|
493
590
|
few seconds, or one that stays with a count), `badge()` for counts in the
|
|
494
|
-
tab title, and the theme
|
|
591
|
+
tab title, and the `theme`. Every value that changes is called for what it
|
|
592
|
+
is now and has `.on(fn)` for each change: `api.events()`,
|
|
593
|
+
`api.events.on(draw)`, `page.frontmatter.on(…)`. Files beside a browser module that are browser
|
|
495
594
|
assets (scripts, styles, images, fonts) are served too.
|
|
496
595
|
|
|
497
596
|
Something that covers the bottom of the window says how much in
|
|
@@ -540,8 +639,10 @@ Not started.
|
|
|
540
639
|
message). A message is read once it has been in view, and that is
|
|
541
640
|
recorded in the log, so it holds in every browser. An answered form waits
|
|
542
641
|
for the agent until it picks the answer up, then it is decided and folds
|
|
543
|
-
|
|
544
|
-
|
|
642
|
+
into a card: what you chose (several answers each on a line, under the
|
|
643
|
+
button you pressed), what you wrote, "decided · change"; a click opens
|
|
644
|
+
it again. Its chat folds into "💬 n messages", and opens when the agent
|
|
645
|
+
writes there, or stays open while you are writing in it. A line above the page counts all this, the corner's
|
|
545
646
|
toasts go to the next question ("→ unanswered (n)") and the next
|
|
546
647
|
unread message ("→ unread (n)"), and the tab title gets a `(!n)` prefix. An answer sent while no agent
|
|
547
648
|
listens says so in a toast; it stays in the log for the next agent that
|