@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
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
.wb-gallery {
|
|
2
|
+
display: grid;
|
|
3
|
+
gap: 40px var(--space-3xl);
|
|
4
|
+
margin: 4em 0;
|
|
5
|
+
grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--wb-gallery-min, 240px)), 1fr));
|
|
6
|
+
}
|
|
7
|
+
.wb-gallery-item {
|
|
8
|
+
margin: 0;
|
|
9
|
+
overflow: hidden;
|
|
10
|
+
display: flex;
|
|
11
|
+
flex-direction: column;
|
|
12
|
+
min-width: 0;
|
|
13
|
+
}
|
|
14
|
+
.wb-gallery-thumb {
|
|
15
|
+
padding: 0;
|
|
16
|
+
border: 0;
|
|
17
|
+
border-radius: var(--radius);
|
|
18
|
+
overflow: hidden;
|
|
19
|
+
background: var(--code-bg);
|
|
20
|
+
cursor: zoom-in;
|
|
21
|
+
display: block;
|
|
22
|
+
}
|
|
23
|
+
.wb-gallery-thumb img {
|
|
24
|
+
display: block;
|
|
25
|
+
width: 100%;
|
|
26
|
+
aspect-ratio: 4 / 3;
|
|
27
|
+
object-fit: cover;
|
|
28
|
+
border-radius: 0;
|
|
29
|
+
}
|
|
30
|
+
.wb-gallery-item figcaption {
|
|
31
|
+
padding: var(--space-xl) var(--space-2xs) 0;
|
|
32
|
+
font: var(--ui-text)/var(--ui-line-height) var(--serif);
|
|
33
|
+
color: var(--text);
|
|
34
|
+
}
|
|
35
|
+
.wb-gallery-item figcaption h3 {
|
|
36
|
+
margin: 0 0 0.25em;
|
|
37
|
+
font-size: 1rem;
|
|
38
|
+
}
|
|
39
|
+
.wb-gallery-item figcaption > div > :first-child {
|
|
40
|
+
margin-top: 0;
|
|
41
|
+
}
|
|
42
|
+
.wb-gallery-item figcaption > div > :last-child {
|
|
43
|
+
margin-bottom: 0;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.wb-lightbox {
|
|
47
|
+
position: fixed;
|
|
48
|
+
inset: 0;
|
|
49
|
+
z-index: var(--layer-top);
|
|
50
|
+
background: rgb(0 0 0 / 0.86);
|
|
51
|
+
display: grid;
|
|
52
|
+
place-items: center;
|
|
53
|
+
grid-template-rows: 1fr auto;
|
|
54
|
+
padding: var(--space-3xl) var(--space-2xl);
|
|
55
|
+
}
|
|
56
|
+
.wb-lightbox img {
|
|
57
|
+
max-width: 100%;
|
|
58
|
+
max-height: calc(100vh - 110px);
|
|
59
|
+
object-fit: contain;
|
|
60
|
+
border-radius: var(--radius-sm);
|
|
61
|
+
}
|
|
62
|
+
.wb-lightbox-caption {
|
|
63
|
+
color: #eee;
|
|
64
|
+
text-align: center;
|
|
65
|
+
padding-top: var(--space-lg);
|
|
66
|
+
}
|
|
67
|
+
.wb-lightbox button {
|
|
68
|
+
position: absolute;
|
|
69
|
+
background: rgb(255 255 255 / 0.12);
|
|
70
|
+
color: #fff;
|
|
71
|
+
border: 0;
|
|
72
|
+
font-size: 1.6rem;
|
|
73
|
+
line-height: 1;
|
|
74
|
+
width: 44px;
|
|
75
|
+
height: 44px;
|
|
76
|
+
border-radius: 50%;
|
|
77
|
+
padding: 0;
|
|
78
|
+
}
|
|
79
|
+
.wb-lightbox-prev {
|
|
80
|
+
left: 12px;
|
|
81
|
+
top: 50%;
|
|
82
|
+
}
|
|
83
|
+
.wb-lightbox-next {
|
|
84
|
+
right: 12px;
|
|
85
|
+
top: 50%;
|
|
86
|
+
}
|
|
87
|
+
.wb-lightbox-close {
|
|
88
|
+
right: 12px;
|
|
89
|
+
top: 12px;
|
|
90
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { builtinPublic } from "../../src/package.js";
|
|
1
2
|
import fs from "node:fs";
|
|
2
3
|
import { definePlugin, html, raw } from "@bigmistqke/whiteboard";
|
|
3
4
|
// plugins/grid/index.ts
|
|
@@ -16,16 +17,21 @@ async function render(ctx) {
|
|
|
16
17
|
}
|
|
17
18
|
const b = badge && html`<span class="wb-badge" data-badge="${slug(badge)}">${badge}</span>`;
|
|
18
19
|
const head = (title || b) && html`<header>${title && html`<h3>${raw(title)}</h3>`}${b}</header>`;
|
|
19
|
-
return html`<article class="wb-card"${badge && html` data-badge="${slug(badge)}"`}
|
|
20
|
+
return html`<article class="wb-card" ${badge && html` data-badge="${slug(badge)}"`}>
|
|
21
|
+
${head}
|
|
22
|
+
<div class="wb-card-body">${raw(s.html)}</div>
|
|
23
|
+
</article>`;
|
|
20
24
|
});
|
|
21
|
-
return html`${raw(intro)}
|
|
25
|
+
return html`${raw(intro)}
|
|
26
|
+
<div class="wb-grid${"narrow" in ctx.attrs ? "" : " wb-wide"}" ${style}>${cards}</div>`;
|
|
22
27
|
}
|
|
23
28
|
function grid() {
|
|
24
29
|
return definePlugin({
|
|
25
30
|
name: "grid",
|
|
31
|
+
public: builtinPublic("grid"),
|
|
26
32
|
blocks: { grid: {
|
|
27
33
|
html: render,
|
|
28
|
-
style:
|
|
34
|
+
style: "style.css"
|
|
29
35
|
} },
|
|
30
36
|
docs: () => fs.readFileSync(new URL("./README.md", import.meta.url), "utf8")
|
|
31
37
|
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
.wb-grid {
|
|
2
|
+
display: grid;
|
|
3
|
+
gap: var(--space-3xl);
|
|
4
|
+
margin: 4em 0;
|
|
5
|
+
grid-template-columns: repeat(
|
|
6
|
+
auto-fill,
|
|
7
|
+
minmax(min(100%, calc(var(--wide, 1040px) / var(--wb-grid-cols, 3) - 16px)), 1fr)
|
|
8
|
+
);
|
|
9
|
+
}
|
|
10
|
+
.wb-grid:not(.wb-wide) {
|
|
11
|
+
grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr));
|
|
12
|
+
}
|
|
13
|
+
.wb-card {
|
|
14
|
+
background: var(--surface);
|
|
15
|
+
border: var(--hairline) solid var(--border);
|
|
16
|
+
border-radius: var(--radius);
|
|
17
|
+
padding: var(--space-2xl) var(--space-2xl) var(--space-2xl);
|
|
18
|
+
min-width: 0;
|
|
19
|
+
}
|
|
20
|
+
.wb-card > header {
|
|
21
|
+
display: flex;
|
|
22
|
+
gap: var(--space-lg);
|
|
23
|
+
align-items: baseline;
|
|
24
|
+
justify-content: space-between;
|
|
25
|
+
margin-bottom: 0.55em;
|
|
26
|
+
}
|
|
27
|
+
.wb-card h3 {
|
|
28
|
+
margin: 0;
|
|
29
|
+
font-size: 1.02rem;
|
|
30
|
+
}
|
|
31
|
+
.wb-card-body {
|
|
32
|
+
font-size: var(--ui-text);
|
|
33
|
+
line-height: 1.6;
|
|
34
|
+
}
|
|
35
|
+
.wb-card-body > :first-child {
|
|
36
|
+
margin-top: 0;
|
|
37
|
+
}
|
|
38
|
+
.wb-card-body > :last-child {
|
|
39
|
+
margin-bottom: 0;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/* badge: a coloured dot and a word, not a pill */
|
|
43
|
+
.wb-badge {
|
|
44
|
+
--c: var(--muted);
|
|
45
|
+
flex: none;
|
|
46
|
+
display: inline-flex;
|
|
47
|
+
align-items: center;
|
|
48
|
+
gap: var(--space-sm);
|
|
49
|
+
font: 500 var(--ui-tiny)/1 var(--sans);
|
|
50
|
+
color: var(--muted);
|
|
51
|
+
white-space: nowrap;
|
|
52
|
+
}
|
|
53
|
+
.wb-badge::before {
|
|
54
|
+
content: '';
|
|
55
|
+
width: 7px;
|
|
56
|
+
height: 7px;
|
|
57
|
+
border-radius: 50%;
|
|
58
|
+
background: var(--c);
|
|
59
|
+
}
|
|
60
|
+
.wb-badge:is([data-badge='done'], [data-badge='ok'], [data-badge='yes'], [data-badge='good']) {
|
|
61
|
+
--c: var(--ok);
|
|
62
|
+
}
|
|
63
|
+
.wb-badge:is([data-badge='active'], [data-badge='new'], [data-badge='info']) {
|
|
64
|
+
--c: var(--info);
|
|
65
|
+
}
|
|
66
|
+
.wb-badge:is([data-badge='open'], [data-badge='todo'], [data-badge='maybe'], [data-badge='warning']) {
|
|
67
|
+
--c: var(--warn);
|
|
68
|
+
}
|
|
69
|
+
.wb-badge:is([data-badge='blocked'], [data-badge='no'], [data-badge='bad'], [data-badge='error']) {
|
|
70
|
+
--c: var(--bad);
|
|
71
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { builtinPublic } from "../../src/package.js";
|
|
2
2
|
import fs from "node:fs";
|
|
3
|
-
import { definePlugin, html,
|
|
3
|
+
import { definePlugin, html, windowFrame } from "@bigmistqke/whiteboard";
|
|
4
4
|
// plugins/iframe/index.ts
|
|
5
5
|
/** http(s), protocol-relative, or a path on this server; never `javascript:` or `data:`. */
|
|
6
6
|
const safeSrc = (src) => /^(https?:)?\/\//i.test(src) || !/^[a-z][a-z0-9+.-]*:/i.test(src);
|
|
@@ -10,30 +10,29 @@ function height(value) {
|
|
|
10
10
|
if (value && /^\d+(\.\d+)?(px|em|rem|vh|svh|dvh)$/.test(value)) return value;
|
|
11
11
|
return "480px";
|
|
12
12
|
}
|
|
13
|
-
const svg = (d) => raw(`<svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round">${d}</svg>`);
|
|
14
|
-
const OPEN = svg("<path d=\"M9 2.5h4.5V7M13.5 2.5 7.5 8.5M11.5 9.5v3a1 1 0 0 1-1 1h-7a1 1 0 0 1-1-1v-7a1 1 0 0 1 1-1h3\"/>");
|
|
15
|
-
const MAXIMIZE = svg("<path d=\"M2.5 6V2.5H6M10 2.5h3.5V6M13.5 10v3.5H10M6 13.5H2.5V10\"/>");
|
|
16
|
-
const RESTORE = svg("<path d=\"M6 2.5V6H2.5M13.5 6H10V2.5M10 13.5V10h3.5M2.5 10H6v3.5\"/>");
|
|
17
13
|
async function render(ctx) {
|
|
18
14
|
const src = (ctx.attrs.src ?? "").trim();
|
|
19
15
|
if (!src) return html`<pre class="wb-error">iframe: needs a src, like ::iframe{src="http://localhost:5173"}</pre>`;
|
|
20
16
|
if (!safeSrc(src)) return html`<pre class="wb-error">iframe: src must be an http(s) URL or a path, not ${src.split(":")[0]}:</pre>`;
|
|
21
17
|
const title = ctx.labelText ?? ctx.attrs.title ?? src;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
return windowFrame({
|
|
19
|
+
label: ctx.label,
|
|
20
|
+
open: src,
|
|
21
|
+
wide: "wide" in ctx.attrs,
|
|
22
|
+
bare: "bare" in ctx.attrs,
|
|
23
|
+
bodyClass: "wb-iframe-frame",
|
|
24
|
+
height: height(ctx.attrs.height),
|
|
25
|
+
body: html`<iframe src="${src}" title="${title}" loading="lazy" referrerpolicy="no-referrer"></iframe>`
|
|
26
|
+
});
|
|
28
27
|
}
|
|
29
28
|
function iframe() {
|
|
30
29
|
return definePlugin({
|
|
31
30
|
name: "iframe",
|
|
31
|
+
public: builtinPublic("iframe"),
|
|
32
32
|
blocks: { iframe: {
|
|
33
33
|
html: render,
|
|
34
|
-
style:
|
|
34
|
+
style: "style.css"
|
|
35
35
|
} },
|
|
36
|
-
setup: () => ({ client: packagePath("dist/plugins/iframe/client.js") }),
|
|
37
36
|
docs: () => fs.readFileSync(new URL("./README.md", import.meta.url), "utf8")
|
|
38
37
|
});
|
|
39
38
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/* the iframe in its window (the window's look is the page's): a frame its bottom edge drags taller */
|
|
2
|
+
.wb-iframe-frame {
|
|
3
|
+
resize: vertical;
|
|
4
|
+
overflow: hidden;
|
|
5
|
+
min-height: 120px;
|
|
6
|
+
background: #fff;
|
|
7
|
+
}
|
|
8
|
+
.wb-iframe-frame iframe {
|
|
9
|
+
display: block;
|
|
10
|
+
width: 100%;
|
|
11
|
+
height: 100%;
|
|
12
|
+
border: 0;
|
|
13
|
+
}
|
package/dist/plugins/index.js
CHANGED
|
@@ -10,6 +10,9 @@ import grid from "./grid/index.js";
|
|
|
10
10
|
import iframe from "./iframe/index.js";
|
|
11
11
|
import mermaid from "./mermaid/index.js";
|
|
12
12
|
import quiet from "./quiet/index.js";
|
|
13
|
+
import windows from "./window/index.js";
|
|
14
|
+
import steps from "./steps/index.js";
|
|
15
|
+
import draft from "./draft/index.js";
|
|
13
16
|
// plugins/index.ts
|
|
14
17
|
function builtins() {
|
|
15
18
|
return [
|
|
@@ -24,7 +27,10 @@ function builtins() {
|
|
|
24
27
|
grid(),
|
|
25
28
|
iframe(),
|
|
26
29
|
mermaid(),
|
|
27
|
-
quiet()
|
|
30
|
+
quiet(),
|
|
31
|
+
windows(),
|
|
32
|
+
steps(),
|
|
33
|
+
draft()
|
|
28
34
|
];
|
|
29
35
|
}
|
|
30
36
|
export { builtins };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { builtinPublic } from "../../src/package.js";
|
|
1
2
|
import fs from "node:fs";
|
|
2
3
|
import crypto from "node:crypto";
|
|
3
4
|
import { definePlugin, html, raw } from "@bigmistqke/whiteboard";
|
|
@@ -24,10 +25,11 @@ async function render(ctx) {
|
|
|
24
25
|
function mermaid() {
|
|
25
26
|
return definePlugin({
|
|
26
27
|
name: "mermaid",
|
|
28
|
+
public: builtinPublic("mermaid"),
|
|
27
29
|
blocks: { mermaid: {
|
|
28
30
|
fence: true,
|
|
29
31
|
html: render,
|
|
30
|
-
style:
|
|
32
|
+
style: "style.css"
|
|
31
33
|
} },
|
|
32
34
|
docs: () => fs.readFileSync(new URL("./README.md", import.meta.url), "utf8")
|
|
33
35
|
});
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/* Pele reads its colours from --pele-* variables; map them onto the page's tokens so diagrams
|
|
2
2
|
follow the theme without being re-rendered. */
|
|
3
3
|
.wb-diagram {
|
|
4
|
-
margin: 4em 0;
|
|
4
|
+
margin: 4em 0;
|
|
5
|
+
overflow-x: auto;
|
|
6
|
+
text-align: center;
|
|
5
7
|
--pele-bg: transparent;
|
|
6
8
|
--pele-fg: var(--text);
|
|
7
9
|
--pele-muted: var(--muted);
|
|
@@ -13,4 +15,7 @@
|
|
|
13
15
|
--pele-font: var(--sans);
|
|
14
16
|
--pele-radius: 6px;
|
|
15
17
|
}
|
|
16
|
-
.wb-diagram svg {
|
|
18
|
+
.wb-diagram svg {
|
|
19
|
+
max-width: 100%;
|
|
20
|
+
height: auto;
|
|
21
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
One pane, one item at a time, with ‹ › between them: an A/B, the steps of a
|
|
2
|
+
procedure, versions of a design. It is a window, so ⤢ fills the browser
|
|
3
|
+
window with it (for going through steps, large).
|
|
4
|
+
|
|
5
|
+
Each heading at the shallowest level starts an item; without headings, `---`
|
|
6
|
+
separates them. With up to four items, all titled, the header shows the
|
|
7
|
+
titles as tabs; else it counts (`2 / 5`) and each item shows its title.
|
|
8
|
+
|
|
9
|
+
The items are laid over each other, so the pane is as tall as the tallest
|
|
10
|
+
and flipping doesn't move the page. ← and → step when it has the focus (a
|
|
11
|
+
click in it) or fills the window. Which item shows stays when the page
|
|
12
|
+
updates.
|
|
13
|
+
|
|
14
|
+
Attributes: `count` (count, never tabs), `wide`, `height`.
|
|
15
|
+
|
|
16
|
+
```markdown
|
|
17
|
+
:::steps[Two headers]
|
|
18
|
+
### A
|
|
19
|
+
The label on the left, the buttons on the right.
|
|
20
|
+
|
|
21
|
+
### B
|
|
22
|
+
Everything centred.
|
|
23
|
+
:::
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
:::steps[Two headers]
|
|
27
|
+
### A
|
|
28
|
+
The label on the left, the buttons on the right.
|
|
29
|
+
|
|
30
|
+
### B
|
|
31
|
+
Everything centred.
|
|
32
|
+
:::
|
|
33
|
+
|
|
34
|
+
```markdown
|
|
35
|
+
:::steps[The migration]
|
|
36
|
+
### Copy the table
|
|
37
|
+
`migrate --dry-run` on staging first.
|
|
38
|
+
|
|
39
|
+
### Switch the reads
|
|
40
|
+
…
|
|
41
|
+
:::
|
|
42
|
+
```
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { builtinPublic } from "../../src/package.js";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import { definePlugin, html, raw, windowFrame } from "@bigmistqke/whiteboard";
|
|
4
|
+
// plugins/steps/index.ts
|
|
5
|
+
/**
|
|
6
|
+
* The items of a block: one per heading at its shallowest level (what comes before the first is an
|
|
7
|
+
* item of its own); without headings, `---` separates them; else it is one item.
|
|
8
|
+
*/
|
|
9
|
+
function split(children) {
|
|
10
|
+
const content = children.filter((n) => !(n.type === "text" && !n.value?.trim()));
|
|
11
|
+
const heads = content.filter((n) => n.type === "heading");
|
|
12
|
+
const parts = [];
|
|
13
|
+
if (heads.length) {
|
|
14
|
+
const depth = Math.min(...heads.map((h) => h.depth));
|
|
15
|
+
for (const n of content) if (n.type === "heading" && n.depth === depth) parts.push({
|
|
16
|
+
title: n.children ?? [],
|
|
17
|
+
body: []
|
|
18
|
+
});
|
|
19
|
+
else if (parts.length) parts.at(-1).body.push(n);
|
|
20
|
+
else parts.push({
|
|
21
|
+
title: null,
|
|
22
|
+
body: [n]
|
|
23
|
+
});
|
|
24
|
+
return parts;
|
|
25
|
+
}
|
|
26
|
+
let current = {
|
|
27
|
+
title: null,
|
|
28
|
+
body: []
|
|
29
|
+
};
|
|
30
|
+
for (const n of content) if (n.type === "thematicBreak") {
|
|
31
|
+
if (current.body.length) parts.push(current);
|
|
32
|
+
current = {
|
|
33
|
+
title: null,
|
|
34
|
+
body: []
|
|
35
|
+
};
|
|
36
|
+
} else current.body.push(n);
|
|
37
|
+
if (current.body.length || !parts.length) parts.push(current);
|
|
38
|
+
return parts;
|
|
39
|
+
}
|
|
40
|
+
/** A height in px (a bare number) or a CSS length; else none. */
|
|
41
|
+
const height = (value) => value && /^\d+(\.\d+)?$/.test(value) ? `${value}px` : value && /^\d+(\.\d+)?(px|em|rem|vh|svh|dvh)$/.test(value) ? value : void 0;
|
|
42
|
+
const svg = (d) => raw(`<svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`);
|
|
43
|
+
const PREV = svg("M10 3.5 5.5 8l4.5 4.5");
|
|
44
|
+
const NEXT = svg("M6 3.5 10.5 8 6 12.5");
|
|
45
|
+
/** With this many items or fewer, all titled, the header shows their titles as tabs. */
|
|
46
|
+
const TABS = 4;
|
|
47
|
+
async function render(ctx) {
|
|
48
|
+
const parts = split(ctx.children);
|
|
49
|
+
const items = await Promise.all(parts.map(async (p) => ({
|
|
50
|
+
title: p.title ? await ctx.toHtml(p.title) : null,
|
|
51
|
+
html: await ctx.toHtml(p.body)
|
|
52
|
+
})));
|
|
53
|
+
const tabs = !("count" in ctx.attrs) && items.length <= TABS && items.every((i) => i.title);
|
|
54
|
+
const n = items.length;
|
|
55
|
+
const marks = tabs ? items.map((item, i) => html`<button type="button" class="wb-steps-tab wb-steps-mark" data-steps="${String(i)}">
|
|
56
|
+
${raw(item.title)}
|
|
57
|
+
</button>`) : html`<span class="wb-steps-count">
|
|
58
|
+
${items.map((_, i) => html`<span class="wb-steps-mark">${String(i + 1)} / ${String(n)}</span>`)}
|
|
59
|
+
</span>`;
|
|
60
|
+
const controls = html`<span class="wb-steps-nav">
|
|
61
|
+
<button
|
|
62
|
+
type="button"
|
|
63
|
+
class="wb-window-button wb-steps-prev"
|
|
64
|
+
data-steps="prev"
|
|
65
|
+
title="Previous (←)"
|
|
66
|
+
aria-label="Previous"
|
|
67
|
+
>
|
|
68
|
+
${PREV}
|
|
69
|
+
</button>
|
|
70
|
+
${marks}
|
|
71
|
+
<button type="button" class="wb-window-button wb-steps-next" data-steps="next" title="Next (→)" aria-label="Next">
|
|
72
|
+
${NEXT}
|
|
73
|
+
</button>
|
|
74
|
+
</span>`;
|
|
75
|
+
const body = html`<div class="wb-steps" tabindex="0">
|
|
76
|
+
${items.map((item) => html`<section class="wb-steps-item">
|
|
77
|
+
${!tabs && item.title ? html`<div class="wb-steps-title">${raw(item.title)}</div>` : ""} ${raw(item.html)}
|
|
78
|
+
</section>`)}
|
|
79
|
+
</div>`;
|
|
80
|
+
return windowFrame({
|
|
81
|
+
label: ctx.label,
|
|
82
|
+
className: "wb-steps-window",
|
|
83
|
+
controls,
|
|
84
|
+
wide: "wide" in ctx.attrs,
|
|
85
|
+
height: height(ctx.attrs.height),
|
|
86
|
+
body
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
function steps() {
|
|
90
|
+
return definePlugin({
|
|
91
|
+
name: "steps",
|
|
92
|
+
public: builtinPublic("steps"),
|
|
93
|
+
style: "style.css",
|
|
94
|
+
setup: () => ({ client: "client.js" }),
|
|
95
|
+
blocks: { steps: { html: render } },
|
|
96
|
+
docs: () => fs.readFileSync(new URL("./README.md", import.meta.url), "utf8")
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
export { steps as default, render, split };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=()=>[...document.querySelectorAll(`#wb-main .wb-steps-window`)],t=e=>[...e.querySelectorAll(`:scope > .wb-window-body > .wb-steps > .wb-steps-item`)],n=e=>[...e.querySelectorAll(`:scope > .wb-window-bar .wb-steps-mark`)],r=/* @__PURE__ */ new Map;function i(e,i,a){let o=t(e),s=Math.max(o.length,1);a=Math.min(Math.max(a,0),s-1),r.set(i,a),e.setAttribute(`data-wb-step`,String(a)),o.forEach((e,t)=>e.toggleAttribute(`data-wb-current`,t===a)),n(e).forEach((e,t)=>e.toggleAttribute(`data-wb-current`,t===a)),e.toggleAttribute(`data-wb-first`,a===0),e.toggleAttribute(`data-wb-last`,a===s-1)}const a=()=>e().forEach((e,t)=>i(e,t,r.get(t)??0));function o(t,n){let a=e().indexOf(t);if(a<0)return;let o=r.get(a)??0;i(t,a,n===`prev`?o-1:n===`next`?o+1:n)}const s=e=>!!e?.closest?.(`input, textarea, select, [contenteditable]:not([contenteditable="false"])`);let c=!1;const l=(e,t,n)=>{a(),n.onRendered(a),c||(c=!0,document.addEventListener(`click`,e=>{let t=e.target.closest?.(`[data-steps]`),n=t?.closest(`.wb-steps-window`);if(!t||!n)return;let r=t.dataset.steps;o(n,r===`prev`||r===`next`?r:Number(r))}),document.addEventListener(`keydown`,e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`||e.metaKey||e.ctrlKey||e.altKey)return;let t=e.target;if(s(t))return;let n=t.closest?.(`.wb-steps-window`)??document.querySelector(`#wb-main .wb-steps-window[data-wb-maximized]`);n&&(e.preventDefault(),o(n,e.key===`ArrowLeft`?`prev`:`next`))}))};export{l as default};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/* Steps (index.ts): the items over each other in one grid cell, so the pane is as tall as the
|
|
2
|
+
tallest; one shows. Before the browser marks one (data-wb-step), the first. */
|
|
3
|
+
.wb-steps {
|
|
4
|
+
display: grid;
|
|
5
|
+
outline: none;
|
|
6
|
+
}
|
|
7
|
+
.wb-steps:focus-visible {
|
|
8
|
+
box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) var(--tint-strong), transparent);
|
|
9
|
+
}
|
|
10
|
+
.wb-steps > .wb-steps-item {
|
|
11
|
+
grid-area: 1 / 1;
|
|
12
|
+
min-width: 0;
|
|
13
|
+
}
|
|
14
|
+
.wb-steps > .wb-steps-item > :first-child {
|
|
15
|
+
margin-top: 0;
|
|
16
|
+
}
|
|
17
|
+
.wb-steps > .wb-steps-item > :last-child {
|
|
18
|
+
margin-bottom: 0;
|
|
19
|
+
}
|
|
20
|
+
.wb-steps-window:not([data-wb-step]) > .wb-window-body > .wb-steps > .wb-steps-item:not(:first-child),
|
|
21
|
+
.wb-steps-window[data-wb-step] > .wb-window-body > .wb-steps > .wb-steps-item:not([data-wb-current]) {
|
|
22
|
+
visibility: hidden;
|
|
23
|
+
}
|
|
24
|
+
.wb-steps-title {
|
|
25
|
+
font: var(--weight-strong) var(--ui-small) / var(--ui-line-height) var(--sans);
|
|
26
|
+
color: var(--muted);
|
|
27
|
+
letter-spacing: var(--caps-spacing);
|
|
28
|
+
text-transform: uppercase;
|
|
29
|
+
margin-bottom: var(--space-md);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/* the header: ‹ 2 / 5 › or ‹ A B › */
|
|
33
|
+
.wb-steps-nav {
|
|
34
|
+
display: flex;
|
|
35
|
+
align-items: center;
|
|
36
|
+
gap: var(--space-2xs);
|
|
37
|
+
flex: none;
|
|
38
|
+
}
|
|
39
|
+
.wb-steps-count {
|
|
40
|
+
font: var(--ui-tiny) / 1 var(--sans);
|
|
41
|
+
font-variant-numeric: tabular-nums;
|
|
42
|
+
color: var(--muted);
|
|
43
|
+
padding: 0 var(--space-2xs);
|
|
44
|
+
}
|
|
45
|
+
.wb-steps-window:not([data-wb-step]) > .wb-window-bar .wb-steps-count > .wb-steps-mark:not(:first-child),
|
|
46
|
+
.wb-steps-window[data-wb-step] > .wb-window-bar .wb-steps-count > .wb-steps-mark:not([data-wb-current]) {
|
|
47
|
+
display: none;
|
|
48
|
+
}
|
|
49
|
+
.wb-steps-tab {
|
|
50
|
+
font: var(--ui-tiny) / 1 var(--sans);
|
|
51
|
+
color: var(--muted);
|
|
52
|
+
background: none;
|
|
53
|
+
border: var(--hairline) solid transparent;
|
|
54
|
+
border-radius: var(--radius-pill);
|
|
55
|
+
padding: var(--space-xs) var(--space-md);
|
|
56
|
+
cursor: pointer;
|
|
57
|
+
white-space: nowrap;
|
|
58
|
+
}
|
|
59
|
+
.wb-steps-tab > * {
|
|
60
|
+
margin: 0;
|
|
61
|
+
}
|
|
62
|
+
.wb-steps-tab:hover {
|
|
63
|
+
color: var(--text);
|
|
64
|
+
background: color-mix(in srgb, var(--text) var(--tint-faint), transparent);
|
|
65
|
+
}
|
|
66
|
+
.wb-steps-window:not([data-wb-step]) > .wb-window-bar .wb-steps-tab:first-of-type,
|
|
67
|
+
.wb-steps-window > .wb-window-bar .wb-steps-tab[data-wb-current] {
|
|
68
|
+
color: var(--accent);
|
|
69
|
+
border-color: color-mix(in srgb, var(--accent) var(--tint-strong), transparent);
|
|
70
|
+
background: color-mix(in srgb, var(--accent) var(--tint-faint), transparent);
|
|
71
|
+
}
|
|
72
|
+
.wb-steps-window:not([data-wb-step]) > .wb-window-bar .wb-steps-prev,
|
|
73
|
+
.wb-steps-window[data-wb-first] > .wb-window-bar .wb-steps-prev,
|
|
74
|
+
.wb-steps-window[data-wb-last] > .wb-window-bar .wb-steps-next {
|
|
75
|
+
opacity: 0.35;
|
|
76
|
+
pointer-events: none;
|
|
77
|
+
}
|
|
@@ -4,6 +4,8 @@ import { createRequire } from "node:module";
|
|
|
4
4
|
import fs from "node:fs";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import net from "node:net";
|
|
7
|
+
import xtermHeadless from "@xterm/headless";
|
|
8
|
+
import xtermSerialize from "@xterm/addon-serialize";
|
|
7
9
|
// plugins/terminal/host.ts
|
|
8
10
|
const require = createRequire(import.meta.url);
|
|
9
11
|
const [dir, socket] = process.argv.slice(2);
|
|
@@ -11,7 +13,11 @@ if (!dir || !socket) {
|
|
|
11
13
|
console.error("usage: host <project dir> <socket path>");
|
|
12
14
|
process.exit(2);
|
|
13
15
|
}
|
|
14
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* node-pty, loaded when a session starts rather than imported: a native module that may not load on
|
|
18
|
+
* this machine, which then is an error to report, not a host that fails to start. Its prebuilt
|
|
19
|
+
* helper ships without execute permission (1.1.0): add it.
|
|
20
|
+
*/
|
|
15
21
|
function loadPty() {
|
|
16
22
|
const pty = require("node-pty");
|
|
17
23
|
const helper = path.join(path.dirname(require.resolve("node-pty/package.json")), "prebuilds", `${process.platform}-${process.arch}`, "spawn-helper");
|
|
@@ -20,8 +26,8 @@ function loadPty() {
|
|
|
20
26
|
} catch {}
|
|
21
27
|
return pty;
|
|
22
28
|
}
|
|
23
|
-
const { Terminal } =
|
|
24
|
-
const { SerializeAddon } =
|
|
29
|
+
const { Terminal } = xtermHeadless;
|
|
30
|
+
const { SerializeAddon } = xtermSerialize;
|
|
25
31
|
/** the sessions by id, in the order they were made */
|
|
26
32
|
const sessions = /* @__PURE__ */ new Map();
|
|
27
33
|
let nextId = 1;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { html, raw } from "../../src/html.js";
|
|
2
|
-
import {
|
|
2
|
+
import { builtinPublic } from "../../src/package.js";
|
|
3
3
|
import { createTerminal } from "./server.js";
|
|
4
4
|
import _taggedTemplateLiteral from "../../_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/taggedTemplateLiteral.js";
|
|
5
5
|
// plugins/terminal/index.ts
|
|
6
6
|
var _templateObject;
|
|
7
|
-
const CLIENT =
|
|
8
|
-
const STYLE =
|
|
7
|
+
const CLIENT = "client.js";
|
|
8
|
+
const STYLE = "style.css";
|
|
9
9
|
/**
|
|
10
10
|
* The drawer's markup, written by the server so that it is there when the page first renders and
|
|
11
11
|
* the browser can morph it from the previous page (a view transition across the page load). Its
|
|
@@ -15,20 +15,21 @@ const STYLE = packagePath("dist/plugins/terminal/style.css");
|
|
|
15
15
|
*/
|
|
16
16
|
const drawer = (state, screens, client) => html(_templateObject || (_templateObject = _taggedTemplateLiteral([
|
|
17
17
|
"<aside id=\"wb-terminal\" aria-label=\"Terminal\" data-sessions=\"",
|
|
18
|
-
"\">\n<div class=\"wb-term-grip\" title=\"drag to resize\"></div>\n<div class=\"wb-term-bar\"
|
|
19
|
-
"</span
|
|
20
|
-
"</div>\n</aside>\n<script
|
|
18
|
+
"\">\n <div class=\"wb-term-grip\" title=\"drag to resize\"></div>\n <div class=\"wb-term-bar\">\n <button type=\"button\" class=\"wb-term-toggle\" title=\"Toggle the terminal (Ctrl+`)\">\n <span class=\"wb-term-chevron\"></span>terminal</button\n ><span class=\"wb-term-status\"></span><span class=\"wb-term-actions\"></span\n ><span class=\"wb-term-tabs\"\n >",
|
|
19
|
+
"</span\n >\n </div>\n <div class=\"wb-term-screen\">\n ",
|
|
20
|
+
"\n </div>\n </aside>\n <script>\n try {\n const t = document.getElementById('wb-terminal'),\n s = sessionStorage,\n o = new URLSearchParams(location.search).get('terminal') === 'open' || s.getItem('wb-terminal-open') === '1'\n t.dataset.state = o ? 'open' : 'collapsed'\n const h = +s.getItem('wb-terminal-height')\n if (h) document.documentElement.style.setProperty('--wb-term-h', h + 'px')\n const tabs = [...t.querySelectorAll('.wb-term-tab')],\n k = s.getItem('wb-terminal-tab'),\n a = tabs.find(b => b.dataset.id === k) ?? tabs[0]\n if (a) {\n t.dataset.tab = a.dataset.id\n a.classList.add('wb-current')\n t.querySelector('.wb-term-placeholder[data-id=\"' + a.dataset.id + '\"]')?.classList.add('wb-current')\n }\n } catch {}\n <\/script>\n <script type=\"module\" src=\"",
|
|
21
21
|
"\"><\/script>"
|
|
22
22
|
], [
|
|
23
23
|
"<aside id=\"wb-terminal\" aria-label=\"Terminal\" data-sessions=\"",
|
|
24
|
-
"\">\n<div class=\"wb-term-grip\" title=\"drag to resize\"></div>\n<div class=\"wb-term-bar\"
|
|
25
|
-
"</span
|
|
26
|
-
"</div>\n</aside>\n<script
|
|
24
|
+
"\">\n <div class=\"wb-term-grip\" title=\"drag to resize\"></div>\n <div class=\"wb-term-bar\">\n <button type=\"button\" class=\"wb-term-toggle\" title=\"Toggle the terminal (Ctrl+\\`)\">\n <span class=\"wb-term-chevron\"></span>terminal</button\n ><span class=\"wb-term-status\"></span><span class=\"wb-term-actions\"></span\n ><span class=\"wb-term-tabs\"\n >",
|
|
25
|
+
"</span\n >\n </div>\n <div class=\"wb-term-screen\">\n ",
|
|
26
|
+
"\n </div>\n </aside>\n <script>\n try {\n const t = document.getElementById('wb-terminal'),\n s = sessionStorage,\n o = new URLSearchParams(location.search).get('terminal') === 'open' || s.getItem('wb-terminal-open') === '1'\n t.dataset.state = o ? 'open' : 'collapsed'\n const h = +s.getItem('wb-terminal-height')\n if (h) document.documentElement.style.setProperty('--wb-term-h', h + 'px')\n const tabs = [...t.querySelectorAll('.wb-term-tab')],\n k = s.getItem('wb-terminal-tab'),\n a = tabs.find(b => b.dataset.id === k) ?? tabs[0]\n if (a) {\n t.dataset.tab = a.dataset.id\n a.classList.add('wb-current')\n t.querySelector('.wb-term-placeholder[data-id=\"' + a.dataset.id + '\"]')?.classList.add('wb-current')\n }\n } catch {}\n <\/script>\n <script type=\"module\" src=\"",
|
|
27
27
|
"\"><\/script>"
|
|
28
28
|
])), JSON.stringify(state), state.sessions.map((s) => html`<button type="button" class="wb-term-tab" data-id="${s.id}">${s.label}</button>`), state.sessions.map((s) => screens[s.id] && html`<div class="wb-term-placeholder" data-id="${s.id}" aria-hidden="true">${raw(screens[s.id])}</div>`), client);
|
|
29
29
|
function terminal() {
|
|
30
30
|
return {
|
|
31
31
|
name: "terminal",
|
|
32
|
+
public: builtinPublic("terminal"),
|
|
32
33
|
style: STYLE,
|
|
33
34
|
setup(ctx) {
|
|
34
35
|
const term = createTerminal({
|