@bigmistqke/whiteboard 0.3.0 → 0.4.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 +67 -17
- package/bin/whiteboard.ts +268 -71
- package/dist/client/runtime.js +88 -41
- 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/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 +3 -1
- package/dist/plugins/mermaid/index.js +3 -1
- package/dist/plugins/mermaid/{style.css → public/style.css} +7 -2
- package/dist/plugins/terminal/index.js +10 -9
- package/dist/plugins/terminal/{style.css → public/style.css} +199 -45
- package/dist/plugins/toc/README.md +12 -0
- package/dist/plugins/toc/index.js +9 -5
- package/dist/plugins/toc/public/client.js +1 -0
- package/dist/plugins/toc/public/style.css +93 -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/client/page/base.css +1078 -199
- package/dist/src/client/page/main.js +174 -32
- package/dist/src/loader.js +7 -2
- 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 +73 -13
- package/dist/src/pages/window.js +30 -0
- package/dist/src/public.js +24 -0
- package/dist/src/server.js +37 -15
- package/package.json +3 -1
- 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 +30 -20
- 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/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 +16 -1
- package/plugins/mermaid/index.ts +3 -1
- package/plugins/mermaid/{style.css → public/style.css} +7 -2
- package/plugins/terminal/client.ts +105 -48
- package/plugins/terminal/host.ts +131 -29
- 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 +13 -3
- package/plugins/toc/README.md +12 -0
- package/plugins/toc/client.ts +58 -29
- package/plugins/toc/index.ts +22 -5
- package/plugins/toc/public/style.css +93 -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 +25 -7
- 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 +106 -34
- 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 +130 -35
- package/src/client/scroll.ts +14 -4
- package/src/client/toast.ts +19 -5
- package/src/config.ts +20 -5
- package/src/define.ts +67 -23
- 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 +75 -11
- package/src/package.ts +9 -8
- package/src/pages/blocks.ts +20 -14
- package/src/pages/markdown.ts +113 -34
- package/src/pages/render.ts +198 -37
- package/src/pages/window.ts +71 -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 +351 -108
- 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
|
@@ -311,12 +311,41 @@ export default defineConfig({
|
|
|
311
311
|
})
|
|
312
312
|
```
|
|
313
313
|
|
|
314
|
+
The page's look is CSS custom properties, set in the base stylesheet and
|
|
315
|
+
used by every built-in plugin, which a project's stylesheet overrides:
|
|
316
|
+
|
|
317
|
+
- colours: `--bg`, `--text`, `--muted`, `--border`, `--accent`,
|
|
318
|
+
`--accent-text`, `--ok`, `--warn`, `--bad`;
|
|
319
|
+
- type: `--serif`, `--sans`, `--mono`; the article's `--text-size` and
|
|
320
|
+
`--line-height` (its margins and headings are in `em`, so they follow);
|
|
321
|
+
the interface's `--ui-tiny`, `--ui-small`, `--ui-text` and
|
|
322
|
+
`--ui-line-height`;
|
|
323
|
+
- space: the article's `--rhythm` (between blocks; a set-off block such as
|
|
324
|
+
a form gets three), the interface's `--space-2xs` … `--space-3xl` (2, 4,
|
|
325
|
+
6, 8, 10, 12, 16, 24px);
|
|
326
|
+
- shape: `--radius-sm`, `--radius`, `--radius-lg`, `--radius-pill`,
|
|
327
|
+
`--hairline`, `--shadow-pop`; tints `--tint-faint`, `--tint-soft`,
|
|
328
|
+
`--tint-strong`; `--speed`;
|
|
329
|
+
- widths: `--measure`, `--wide`; layers: `--layer-aside`,
|
|
330
|
+
`--layer-popover`, `--layer-window`, `--layer-top` (for a plugin's own
|
|
331
|
+
floating things).
|
|
332
|
+
|
|
333
|
+
Every colour is a `light-dark()` pair, so one line sets it for both themes:
|
|
334
|
+
|
|
335
|
+
```css
|
|
336
|
+
/* .whiteboard/site.css */
|
|
337
|
+
:root { --accent: light-dark(#c2410c, #fb923c); --serif: "Source Serif 4", Georgia, serif; }
|
|
338
|
+
/* denser: smaller text, tighter blocks */
|
|
339
|
+
:root { --text-size: 17px; --rhythm: 1em; }
|
|
340
|
+
```
|
|
341
|
+
|
|
314
342
|
The built-in plugins are callout, chat, code, comments, details, forge,
|
|
315
|
-
form, gallery, grid, iframe, mermaid and
|
|
343
|
+
form, gallery, grid, iframe, mermaid, quiet and window: every project has them, and
|
|
316
344
|
`whiteboard docs` shows how to write each. A config's `plugins` add to them,
|
|
317
345
|
and one with a built-in's name replaces it. The terminal and the Claude Code
|
|
318
346
|
plugin are opt-in, since they run code or are about one agent, and so is the
|
|
319
|
-
table of contents (`toc`), which
|
|
347
|
+
table of contents (`toc`), which a page then asks for in its frontmatter
|
|
348
|
+
(`toc: true`).
|
|
320
349
|
|
|
321
350
|
Named forms need nothing in the config: the core sends a submit of any
|
|
322
351
|
`<form name>` as an event, on any page.
|
|
@@ -362,7 +391,7 @@ export default function checklist() {
|
|
|
362
391
|
},
|
|
363
392
|
// shown until the client mounts, then replaced
|
|
364
393
|
html: () => html`<ul class="checklist"></ul>`,
|
|
365
|
-
client:
|
|
394
|
+
client: 'client.js', // in its public/ folder
|
|
366
395
|
},
|
|
367
396
|
},
|
|
368
397
|
// its events, and whether a `wait` on the page hands them out (a tick is information: no)
|
|
@@ -374,7 +403,7 @@ export default function checklist() {
|
|
|
374
403
|
```
|
|
375
404
|
|
|
376
405
|
```js
|
|
377
|
-
// .whiteboard/plugins/checklist/client.js:
|
|
406
|
+
// .whiteboard/plugins/checklist/public/client.js: its public/ folder is served, nothing else of it
|
|
378
407
|
export default function mount(el, { name, items }, api) {
|
|
379
408
|
const ticked = () => {
|
|
380
409
|
const state = new Map()
|
|
@@ -393,7 +422,7 @@ export default function mount(el, { name, items }, api) {
|
|
|
393
422
|
}
|
|
394
423
|
draw()
|
|
395
424
|
// the page's events, also the ones it appends itself, come back here
|
|
396
|
-
return api.
|
|
425
|
+
return api.events.on(draw)
|
|
397
426
|
}
|
|
398
427
|
```
|
|
399
428
|
|
|
@@ -413,7 +442,7 @@ An agent can wait for a tick by asking for it: `whiteboard wait --page
|
|
|
413
442
|
A plugin can also put something on every page, and add commands:
|
|
414
443
|
|
|
415
444
|
```ts
|
|
416
|
-
// .whiteboard/plugins/votes.ts
|
|
445
|
+
// .whiteboard/plugins/votes/index.ts
|
|
417
446
|
import { definePlugin } from '@bigmistqke/whiteboard'
|
|
418
447
|
import { read } from '@bigmistqke/whiteboard/log'
|
|
419
448
|
|
|
@@ -433,19 +462,19 @@ export default function votes() {
|
|
|
433
462
|
},
|
|
434
463
|
docs: () => 'The reader can vote a page up: a `votes:up` event. `whiteboard votes` counts them.',
|
|
435
464
|
// from setup: what the running server adds (routes, markup, the browser module)
|
|
436
|
-
setup: () => ({ client:
|
|
465
|
+
setup: () => ({ client: 'client.js' }),
|
|
437
466
|
})
|
|
438
467
|
}
|
|
439
468
|
```
|
|
440
469
|
|
|
441
470
|
```js
|
|
442
|
-
// .whiteboard/plugins/votes
|
|
471
|
+
// .whiteboard/plugins/votes/public/client.js
|
|
443
472
|
export default function mount(root, page, api) {
|
|
444
473
|
const button = document.createElement('button')
|
|
445
474
|
const draw = () => { button.textContent = `👍 ${api.events().filter(e => e.type === 'votes:up').length}` }
|
|
446
475
|
button.addEventListener('click', () => api.append('votes:up'))
|
|
447
476
|
api.corner().append(button) // the page's corner, for floating buttons
|
|
448
|
-
api.
|
|
477
|
+
api.events.on(draw)
|
|
449
478
|
draw()
|
|
450
479
|
}
|
|
451
480
|
```
|
|
@@ -481,17 +510,36 @@ export default function mount(root, page, api) {
|
|
|
481
510
|
- `shell`, markup at the end of every page's `<head>` and `<body>`;
|
|
482
511
|
- `client`, a module on every page, run once per page load.
|
|
483
512
|
|
|
484
|
-
**
|
|
485
|
-
|
|
513
|
+
**A block can draw a window** around what it shows, the same one as
|
|
514
|
+
`::iframe`, `::image`, `::video` and `:::window`: `windowFrame({ label, open,
|
|
515
|
+
body })` from `@bigmistqke/whiteboard` gives it a header with its label, a
|
|
516
|
+
button that opens `open` on its own, and one that fills the browser window
|
|
517
|
+
(the page does that part).
|
|
518
|
+
|
|
519
|
+
**A plugin's browser files live in its `public/` folder**, and only that
|
|
520
|
+
folder is served: its client modules, styles, images and fonts, never its
|
|
521
|
+
server code or the project's files beside it. `client` and `style` (a
|
|
522
|
+
plugin's and a block's) name files in it: `'client.js'`. `definePlugin` puts
|
|
523
|
+
it next to the module that calls it (`plugins/checklist/public/` for
|
|
524
|
+
`plugins/checklist/index.ts`); say another with `public: new URL('./assets/',
|
|
525
|
+
import.meta.url)`; a plain object plugin, or one written in the config, has
|
|
526
|
+
`.whiteboard/public/`. A file named outside it is a config error. Browser
|
|
527
|
+
code is JavaScript or TypeScript: a `.ts` file is served with its types
|
|
528
|
+
stripped (Node's type stripping, as for server code: types only, so no
|
|
529
|
+
`enum` or `namespace`, and imports name their `.ts` files). JSX still needs
|
|
530
|
+
building first. A block's `client` gets
|
|
486
531
|
`mount(element, props, api)` and may return a cleanup, run when the block
|
|
487
532
|
is replaced on a live update; it replaces the server's HTML when it mounts.
|
|
488
533
|
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),
|
|
534
|
+
the page's `api`: its `events` and `append` (which comes back through
|
|
535
|
+
`events.on`), the `listeners`, `forms` and `unread` messages, `onRendered`
|
|
536
|
+
(after a live update, to put back what it adds), the page's `frontmatter`
|
|
537
|
+
on the page handle, `corner()` for floating buttons, `toast()` for a label in
|
|
492
538
|
the corner that says what is going on and goes there (one that hides after a
|
|
493
539
|
few seconds, or one that stays with a count), `badge()` for counts in the
|
|
494
|
-
tab title, and the theme
|
|
540
|
+
tab title, and the `theme`. Every value that changes is called for what it
|
|
541
|
+
is now and has `.on(fn)` for each change: `api.events()`,
|
|
542
|
+
`api.events.on(draw)`, `page.frontmatter.on(…)`. Files beside a browser module that are browser
|
|
495
543
|
assets (scripts, styles, images, fonts) are served too.
|
|
496
544
|
|
|
497
545
|
Something that covers the bottom of the window says how much in
|
|
@@ -540,8 +588,10 @@ Not started.
|
|
|
540
588
|
message). A message is read once it has been in view, and that is
|
|
541
589
|
recorded in the log, so it holds in every browser. An answered form waits
|
|
542
590
|
for the agent until it picks the answer up, then it is decided and folds
|
|
543
|
-
|
|
544
|
-
|
|
591
|
+
into a card: what you chose (several answers each on a line, under the
|
|
592
|
+
button you pressed), what you wrote, "decided · change"; a click opens
|
|
593
|
+
it again. Its chat folds into "💬 n messages", and opens when the agent
|
|
594
|
+
writes there, or stays open while you are writing in it. A line above the page counts all this, the corner's
|
|
545
595
|
toasts go to the next question ("→ unanswered (n)") and the next
|
|
546
596
|
unread message ("→ unread (n)"), and the tab title gets a `(!n)` prefix. An answer sent while no agent
|
|
547
597
|
listens says so in a toast; it stays in the log for the next agent that
|