@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.
Files changed (155) hide show
  1. package/README.md +67 -17
  2. package/bin/whiteboard.ts +268 -71
  3. package/dist/client/runtime.js +88 -41
  4. package/dist/define.js +21 -2
  5. package/dist/plugins/callout/index.js +3 -1
  6. package/dist/plugins/callout/public/style.css +30 -0
  7. package/dist/plugins/chat/index.js +7 -4
  8. package/dist/plugins/chat/{client.js → public/client.js} +1 -1
  9. package/dist/plugins/chat/public/style.css +98 -0
  10. package/dist/plugins/code/index.js +3 -1
  11. package/dist/plugins/code/public/style.css +68 -0
  12. package/dist/plugins/comments/index.js +4 -5
  13. package/dist/plugins/comments/public/client.js +19 -0
  14. package/dist/plugins/comments/public/style.css +185 -0
  15. package/dist/plugins/details/index.js +7 -2
  16. package/dist/plugins/details/public/style.css +7 -0
  17. package/dist/plugins/form/index.js +37 -8
  18. package/dist/plugins/form/public/style.css +126 -0
  19. package/dist/plugins/gallery/index.js +4 -3
  20. package/dist/plugins/gallery/public/client.js +1 -0
  21. package/dist/plugins/gallery/public/style.css +90 -0
  22. package/dist/plugins/grid/index.js +9 -3
  23. package/dist/plugins/grid/public/style.css +71 -0
  24. package/dist/plugins/iframe/index.js +13 -14
  25. package/dist/plugins/iframe/public/style.css +13 -0
  26. package/dist/plugins/index.js +3 -1
  27. package/dist/plugins/mermaid/index.js +3 -1
  28. package/dist/plugins/mermaid/{style.css → public/style.css} +7 -2
  29. package/dist/plugins/terminal/index.js +10 -9
  30. package/dist/plugins/terminal/{style.css → public/style.css} +199 -45
  31. package/dist/plugins/toc/README.md +12 -0
  32. package/dist/plugins/toc/index.js +9 -5
  33. package/dist/plugins/toc/public/client.js +1 -0
  34. package/dist/plugins/toc/public/style.css +93 -0
  35. package/dist/plugins/window/README.md +29 -0
  36. package/dist/plugins/window/index.js +64 -0
  37. package/dist/solid/index.js +14 -11
  38. package/dist/src/client/page/base.css +1078 -199
  39. package/dist/src/client/page/main.js +174 -32
  40. package/dist/src/loader.js +7 -2
  41. package/dist/src/package.js +3 -6
  42. package/dist/src/pages/blocks.js +8 -13
  43. package/dist/src/pages/markdown.js +1 -1
  44. package/dist/src/pages/render.js +73 -13
  45. package/dist/src/pages/window.js +30 -0
  46. package/dist/src/public.js +24 -0
  47. package/dist/src/server.js +37 -15
  48. package/package.json +3 -1
  49. package/plugins/callout/index.ts +3 -1
  50. package/plugins/callout/public/style.css +30 -0
  51. package/plugins/chat/autosize.ts +43 -9
  52. package/plugins/chat/client.tsx +22 -5
  53. package/plugins/chat/index.ts +22 -8
  54. package/plugins/chat/public/style.css +98 -0
  55. package/plugins/claude-code/index.ts +49 -14
  56. package/plugins/code/diff.ts +28 -8
  57. package/plugins/code/index.ts +30 -20
  58. package/plugins/code/public/style.css +68 -0
  59. package/plugins/comments/client.ts +139 -71
  60. package/plugins/comments/index.ts +9 -7
  61. package/plugins/comments/public/style.css +185 -0
  62. package/plugins/details/index.ts +7 -2
  63. package/plugins/details/public/style.css +7 -0
  64. package/plugins/forge/index.ts +16 -3
  65. package/plugins/form/index.ts +75 -27
  66. package/plugins/form/public/style.css +126 -0
  67. package/plugins/gallery/client.tsx +9 -3
  68. package/plugins/gallery/index.ts +31 -9
  69. package/plugins/gallery/public/style.css +90 -0
  70. package/plugins/grid/index.ts +19 -5
  71. package/plugins/grid/public/style.css +71 -0
  72. package/plugins/iframe/index.ts +20 -23
  73. package/plugins/iframe/public/style.css +13 -0
  74. package/plugins/index.ts +16 -1
  75. package/plugins/mermaid/index.ts +3 -1
  76. package/plugins/mermaid/{style.css → public/style.css} +7 -2
  77. package/plugins/terminal/client.ts +105 -48
  78. package/plugins/terminal/host.ts +131 -29
  79. package/plugins/terminal/index.ts +84 -25
  80. package/plugins/terminal/public/style.css +225 -0
  81. package/plugins/terminal/server.ts +64 -13
  82. package/plugins/terminal/sizes.ts +13 -3
  83. package/plugins/toc/README.md +12 -0
  84. package/plugins/toc/client.ts +58 -29
  85. package/plugins/toc/index.ts +22 -5
  86. package/plugins/toc/public/style.css +93 -0
  87. package/plugins/window/README.md +29 -0
  88. package/plugins/window/index.ts +85 -0
  89. package/skills/whiteboard/SKILL.md +3 -1
  90. package/solid/index.tsx +24 -9
  91. package/src/auth.ts +25 -7
  92. package/src/client/forms.ts +74 -28
  93. package/src/client/markdown.ts +15 -4
  94. package/src/client/page/base.css +1078 -199
  95. package/src/client/page/elsewhere.ts +32 -15
  96. package/src/client/page/fresh.ts +91 -23
  97. package/src/client/page/hold.ts +11 -2
  98. package/src/client/page/live.ts +10 -6
  99. package/src/client/page/main.ts +106 -34
  100. package/src/client/page/orphans.ts +25 -10
  101. package/src/client/page/sort.ts +14 -4
  102. package/src/client/page/sticky.ts +11 -3
  103. package/src/client/page/theme.ts +11 -7
  104. package/src/client/page/waiting.ts +141 -34
  105. package/src/client/page/window.ts +40 -0
  106. package/src/client/reactive.ts +19 -0
  107. package/src/client/read.ts +17 -10
  108. package/src/client/runtime.ts +130 -35
  109. package/src/client/scroll.ts +14 -4
  110. package/src/client/toast.ts +19 -5
  111. package/src/config.ts +20 -5
  112. package/src/define.ts +67 -23
  113. package/src/events.ts +111 -24
  114. package/src/html.ts +6 -2
  115. package/src/icons.ts +4 -2
  116. package/src/load.ts +10 -2
  117. package/src/loader.ts +75 -11
  118. package/src/package.ts +9 -8
  119. package/src/pages/blocks.ts +20 -14
  120. package/src/pages/markdown.ts +113 -34
  121. package/src/pages/render.ts +198 -37
  122. package/src/pages/window.ts +71 -0
  123. package/src/plugins.ts +90 -24
  124. package/src/public.ts +39 -0
  125. package/src/running.ts +8 -2
  126. package/src/serve.ts +29 -7
  127. package/src/server.ts +351 -108
  128. package/src/status.ts +15 -9
  129. package/dist/plugins/callout/style.css +0 -12
  130. package/dist/plugins/chat/style.css +0 -24
  131. package/dist/plugins/code/style.css +0 -29
  132. package/dist/plugins/comments/client.js +0 -10
  133. package/dist/plugins/comments/style.css +0 -40
  134. package/dist/plugins/details/style.css +0 -3
  135. package/dist/plugins/form/style.css +0 -44
  136. package/dist/plugins/gallery/client.js +0 -1
  137. package/dist/plugins/gallery/style.css +0 -27
  138. package/dist/plugins/grid/style.css +0 -25
  139. package/dist/plugins/iframe/client.js +0 -1
  140. package/dist/plugins/iframe/style.css +0 -29
  141. package/dist/plugins/toc/client.js +0 -1
  142. package/dist/plugins/toc/style.css +0 -19
  143. package/plugins/callout/style.css +0 -12
  144. package/plugins/chat/style.css +0 -24
  145. package/plugins/code/style.css +0 -29
  146. package/plugins/comments/style.css +0 -40
  147. package/plugins/details/style.css +0 -3
  148. package/plugins/form/style.css +0 -44
  149. package/plugins/gallery/style.css +0 -27
  150. package/plugins/grid/style.css +0 -25
  151. package/plugins/iframe/client.ts +0 -46
  152. package/plugins/iframe/style.css +0 -29
  153. package/plugins/terminal/style.css +0 -71
  154. package/plugins/toc/style.css +0 -19
  155. /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 quiet: every project has them, 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 takes the margin beside every page.
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: new URL('./client.js', import.meta.url),
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: plain JavaScript, served as it is
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.onEvents(draw)
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: new URL('./votes.client.js', import.meta.url) }),
465
+ setup: () => ({ client: 'client.js' }),
437
466
  })
438
467
  }
439
468
  ```
440
469
 
441
470
  ```js
442
- // .whiteboard/plugins/votes.client.js: plain JavaScript, served as it is
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.onEvents(draw)
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
- **Browser code is plain JavaScript**: the server sends it as it is, so one
485
- written in TypeScript needs building first. A block's `client` gets
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
- `onEvents`), the listeners, `onRendered` (after a live update, to put back
491
- what it adds), `corner()` for floating buttons, `toast()` for a label in
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. Files beside a browser module that are browser
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
- to one line quoting the answer, with its chat still under it; a click
544
- opens it again. A line above the page counts all this, the corner's
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