@bigmistqke/whiteboard 0.0.0-stage → 0.1.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 (138) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +609 -2
  3. package/bin/whiteboard.ts +431 -0
  4. package/dist/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/taggedTemplateLiteral.js +5 -0
  5. package/dist/bin/whiteboard.js +471 -0
  6. package/dist/client/runtime.js +391 -0
  7. package/dist/define.js +7 -0
  8. package/dist/plugins/callout/README.md +13 -0
  9. package/dist/plugins/callout/index.js +27 -0
  10. package/dist/plugins/callout/style.css +12 -0
  11. package/dist/plugins/chat/README.md +45 -0
  12. package/dist/plugins/chat/client.js +3 -0
  13. package/dist/plugins/chat/index.js +46 -0
  14. package/dist/plugins/chat/style.css +17 -0
  15. package/dist/plugins/claude-code/index.js +120 -0
  16. package/dist/plugins/code/README.md +42 -0
  17. package/dist/plugins/code/diff.js +64 -0
  18. package/dist/plugins/code/index.js +77 -0
  19. package/dist/plugins/code/style.css +29 -0
  20. package/dist/plugins/comments/client.js +10 -0
  21. package/dist/plugins/comments/index.js +51 -0
  22. package/dist/plugins/comments/style.css +32 -0
  23. package/dist/plugins/details/README.md +17 -0
  24. package/dist/plugins/details/index.js +17 -0
  25. package/dist/plugins/details/style.css +3 -0
  26. package/dist/plugins/form/README.md +111 -0
  27. package/dist/plugins/form/index.js +102 -0
  28. package/dist/plugins/form/style.css +41 -0
  29. package/dist/plugins/gallery/README.md +30 -0
  30. package/dist/plugins/gallery/client.js +1 -0
  31. package/dist/plugins/gallery/index.js +74 -0
  32. package/dist/plugins/gallery/style.css +27 -0
  33. package/dist/plugins/grid/README.md +33 -0
  34. package/dist/plugins/grid/index.js +33 -0
  35. package/dist/plugins/grid/style.css +25 -0
  36. package/dist/plugins/index.js +26 -0
  37. package/dist/plugins/mermaid/README.md +21 -0
  38. package/dist/plugins/mermaid/index.js +34 -0
  39. package/dist/plugins/mermaid/style.css +16 -0
  40. package/dist/plugins/quiet/README.md +26 -0
  41. package/dist/plugins/quiet/index.js +17 -0
  42. package/dist/plugins/terminal/client.js +41 -0
  43. package/dist/plugins/terminal/host.js +332 -0
  44. package/dist/plugins/terminal/index.js +171 -0
  45. package/dist/plugins/terminal/modes.js +32 -0
  46. package/dist/plugins/terminal/server.js +256 -0
  47. package/dist/plugins/terminal/sizes.js +57 -0
  48. package/dist/plugins/terminal/style.css +357 -0
  49. package/dist/solid/index.js +35 -0
  50. package/dist/src/auth.js +54 -0
  51. package/dist/src/client/page/base.css +274 -0
  52. package/dist/src/client/page/main.js +1004 -0
  53. package/dist/src/config.js +76 -0
  54. package/dist/src/events.js +162 -0
  55. package/dist/src/html.js +34 -0
  56. package/dist/src/load.js +77 -0
  57. package/dist/src/loader.js +120 -0
  58. package/dist/src/package.js +33 -0
  59. package/dist/src/pages/blocks.js +49 -0
  60. package/dist/src/pages/index.js +14 -0
  61. package/dist/src/pages/markdown.js +307 -0
  62. package/dist/src/pages/render.js +257 -0
  63. package/dist/src/plugins.js +238 -0
  64. package/dist/src/running.js +24 -0
  65. package/dist/src/serve.js +71 -0
  66. package/dist/src/server.js +700 -0
  67. package/dist/src/status.js +43 -0
  68. package/package.json +131 -4
  69. package/plugins/callout/README.md +13 -0
  70. package/plugins/callout/index.ts +25 -0
  71. package/plugins/callout/style.css +12 -0
  72. package/plugins/chat/README.md +45 -0
  73. package/plugins/chat/autosize.ts +101 -0
  74. package/plugins/chat/client.tsx +81 -0
  75. package/plugins/chat/index.ts +61 -0
  76. package/plugins/chat/style.css +17 -0
  77. package/plugins/claude-code/index.ts +136 -0
  78. package/plugins/code/README.md +42 -0
  79. package/plugins/code/diff.ts +58 -0
  80. package/plugins/code/index.ts +94 -0
  81. package/plugins/code/style.css +29 -0
  82. package/plugins/comments/client.ts +448 -0
  83. package/plugins/comments/index.ts +52 -0
  84. package/plugins/comments/style.css +32 -0
  85. package/plugins/details/README.md +17 -0
  86. package/plugins/details/index.ts +21 -0
  87. package/plugins/details/style.css +3 -0
  88. package/plugins/form/README.md +111 -0
  89. package/plugins/form/index.ts +104 -0
  90. package/plugins/form/style.css +41 -0
  91. package/plugins/gallery/README.md +30 -0
  92. package/plugins/gallery/client.tsx +64 -0
  93. package/plugins/gallery/index.ts +67 -0
  94. package/plugins/gallery/style.css +27 -0
  95. package/plugins/grid/README.md +33 -0
  96. package/plugins/grid/index.ts +36 -0
  97. package/plugins/grid/style.css +25 -0
  98. package/plugins/index.ts +19 -0
  99. package/plugins/mermaid/README.md +21 -0
  100. package/plugins/mermaid/index.ts +39 -0
  101. package/plugins/mermaid/style.css +16 -0
  102. package/plugins/quiet/README.md +26 -0
  103. package/plugins/quiet/index.ts +27 -0
  104. package/plugins/terminal/client.ts +317 -0
  105. package/plugins/terminal/host.ts +326 -0
  106. package/plugins/terminal/index.ts +138 -0
  107. package/plugins/terminal/modes.ts +30 -0
  108. package/plugins/terminal/server.ts +215 -0
  109. package/plugins/terminal/sizes.ts +60 -0
  110. package/plugins/terminal/style.css +71 -0
  111. package/skills/whiteboard/SKILL.md +292 -0
  112. package/solid/index.tsx +56 -0
  113. package/src/auth.ts +66 -0
  114. package/src/client/forms.ts +186 -0
  115. package/src/client/page/base.css +274 -0
  116. package/src/client/page/fresh.ts +205 -0
  117. package/src/client/page/main.ts +249 -0
  118. package/src/client/page/orphans.ts +46 -0
  119. package/src/client/page/theme.ts +32 -0
  120. package/src/client/page/view.ts +9 -0
  121. package/src/client/page/waiting.ts +109 -0
  122. package/src/client/runtime.ts +170 -0
  123. package/src/config.ts +96 -0
  124. package/src/define.ts +546 -0
  125. package/src/events.ts +194 -0
  126. package/src/html.ts +40 -0
  127. package/src/load.ts +89 -0
  128. package/src/loader.ts +109 -0
  129. package/src/package.ts +39 -0
  130. package/src/pages/blocks.ts +67 -0
  131. package/src/pages/index.ts +36 -0
  132. package/src/pages/markdown.ts +276 -0
  133. package/src/pages/render.ts +196 -0
  134. package/src/plugins.ts +197 -0
  135. package/src/running.ts +22 -0
  136. package/src/serve.ts +52 -0
  137. package/src/server.ts +644 -0
  138. package/src/status.ts +69 -0
@@ -0,0 +1,256 @@
1
+ import { createRequire } from "node:module";
2
+ import fs from "node:fs";
3
+ import "node:os";
4
+ import path from "node:path";
5
+ import { spawn } from "node:child_process";
6
+ import { fileURLToPath } from "node:url";
7
+ import crypto from "node:crypto";
8
+ import net from "node:net";
9
+ // plugins/terminal/server.ts
10
+ const require = createRequire(import.meta.url);
11
+ const HOST = fileURLToPath(new URL(`./host${path.extname(fileURLToPath(import.meta.url))}`, import.meta.url));
12
+ const hasPty = () => {
13
+ try {
14
+ require.resolve("node-pty");
15
+ return true;
16
+ } catch {
17
+ return false;
18
+ }
19
+ };
20
+ /**
21
+ * Where the host listens: `host.sock` in the terminal's folder, or, when that path is too long for
22
+ * a Unix socket (about 100 bytes), a name in /tmp made from it.
23
+ */
24
+ function hostSocket(home) {
25
+ const own = path.join(home, "host.sock");
26
+ return Buffer.byteLength(own) < 100 ? own : path.join("/tmp", `wb-term-${crypto.createHash("sha1").update(home).digest("hex").slice(0, 12)}.sock`);
27
+ }
28
+ /** `dir` the folder the sessions run in, `home` where the socket and log go */
29
+ function createTerminal({ dir, home }) {
30
+ const own = hostSocket(home);
31
+ const log = path.join(home, "host.log");
32
+ /** A connection to the host, or null when none runs. */
33
+ function connect() {
34
+ return new Promise((resolve) => {
35
+ const conn = net.connect(own);
36
+ conn.once("connect", () => resolve(conn));
37
+ conn.once("error", () => resolve(null));
38
+ });
39
+ }
40
+ /** Send one request; its one reply, or null when no host runs. */
41
+ async function ask(req, timeout = 2e3) {
42
+ const conn = await connect();
43
+ if (!conn) return null;
44
+ return new Promise((resolve) => {
45
+ let buf = "";
46
+ const done = (value) => {
47
+ clearTimeout(timer);
48
+ conn.destroy();
49
+ resolve(value);
50
+ };
51
+ const timer = setTimeout(() => done(null), timeout);
52
+ conn.setEncoding("utf8");
53
+ conn.on("data", (c) => {
54
+ buf += c;
55
+ const nl = buf.indexOf("\n");
56
+ if (nl >= 0) try {
57
+ done(JSON.parse(buf.slice(0, nl)));
58
+ } catch {
59
+ done(null);
60
+ }
61
+ });
62
+ conn.on("error", () => done(null));
63
+ conn.on("end", () => done(null));
64
+ conn.write(JSON.stringify(req) + "\n");
65
+ });
66
+ }
67
+ /** Start the host (detached: it outlives this server) and wait until it answers. */
68
+ async function startHost() {
69
+ const out = fs.openSync(log, "a");
70
+ spawn(process.execPath, [
71
+ HOST,
72
+ dir,
73
+ own
74
+ ], {
75
+ cwd: dir,
76
+ detached: true,
77
+ stdio: [
78
+ "ignore",
79
+ out,
80
+ out
81
+ ],
82
+ env: process.env
83
+ }).unref();
84
+ fs.closeSync(out);
85
+ for (let i = 0; i < 40; i++) {
86
+ await new Promise((r) => setTimeout(r, 100));
87
+ if (await ask({ t: "list" }, 500)) return true;
88
+ }
89
+ return false;
90
+ }
91
+ const shell = process.env.SHELL || "/bin/sh";
92
+ /** The sessions, as tabs: `{ id, label, running, exited, started }` each. */
93
+ async function sessions() {
94
+ const reply = await ask({ t: "list" });
95
+ return {
96
+ available: hasPty(),
97
+ sessions: reply?.sessions ?? []
98
+ };
99
+ }
100
+ /** The screens as HTML rows by session id, for a page's first render. */
101
+ async function screens(list) {
102
+ const out = {};
103
+ await Promise.all(list.map(async (s) => {
104
+ out[s.id] = (await ask({
105
+ t: "html",
106
+ id: s.id
107
+ }, 300))?.html ?? "";
108
+ }));
109
+ return out;
110
+ }
111
+ const failure = (message, status = 500) => Object.assign(new Error(message), { status });
112
+ /**
113
+ * Start a tab: the shell, or `program` in it (a new tab without `id`). In a running session it
114
+ * reports it (`already`) unless `restart`; restarting without a program runs what it ran before.
115
+ */
116
+ async function start({ id, program = [], restart = false } = {}) {
117
+ if (!hasPty()) throw failure("the terminal needs node-pty: npm install node-pty");
118
+ const request = program.length ? {
119
+ t: "start",
120
+ id,
121
+ command: shell,
122
+ args: [
123
+ "-c",
124
+ "\"$@\"; exec \"$0\" -l",
125
+ shell,
126
+ ...program
127
+ ],
128
+ label: path.basename(program[0]),
129
+ restart
130
+ } : restart && id != null ? {
131
+ t: "start",
132
+ id,
133
+ restart
134
+ } : {
135
+ t: "start",
136
+ id,
137
+ command: shell,
138
+ args: ["-l"],
139
+ label: path.basename(shell),
140
+ restart
141
+ };
142
+ let reply = await ask(request);
143
+ if (!reply) {
144
+ if (!await startHost()) throw failure(`the terminal's host did not start; see ${log}`);
145
+ reply = await ask(request);
146
+ }
147
+ if (!reply || reply.error) throw failure(reply?.error ?? "no answer from the terminal host");
148
+ return {
149
+ available: true,
150
+ session: reply.session ?? "1",
151
+ already: !!reply.already
152
+ };
153
+ }
154
+ const input = async (id, data) => {
155
+ await ask({
156
+ t: "input",
157
+ id,
158
+ d: data
159
+ });
160
+ };
161
+ /** The size that fits drawer `viewer`; `active`: the reader is using that drawer now (see host.ts, Sizes). */
162
+ const resize = async (id, viewer, cols, rows, active = false) => {
163
+ await ask({
164
+ t: "resize",
165
+ id,
166
+ viewer,
167
+ cols,
168
+ rows,
169
+ active
170
+ });
171
+ };
172
+ /** End one session and drop its tab. */
173
+ async function close(id) {
174
+ await ask({
175
+ t: "close",
176
+ id
177
+ });
178
+ return { ok: true };
179
+ }
180
+ /**
181
+ * Follow a session as server-sent events on `res`: `sessions` (the tabs) and `screen` first, then
182
+ * `data`, `exit` and `sessions` as they come.
183
+ */
184
+ async function stream(req, res, id, viewer) {
185
+ res.writeHead(200, {
186
+ "content-type": "text/event-stream",
187
+ "cache-control": "no-store",
188
+ connection: "keep-alive"
189
+ });
190
+ res.write(": terminal\n\n");
191
+ const ping = setInterval(() => res.write(": ping\n\n"), 25e3);
192
+ const conn = await connect();
193
+ if (!conn) {
194
+ clearInterval(ping);
195
+ res.end("retry: 2000\nevent: none\ndata: {}\n\n");
196
+ return;
197
+ }
198
+ let buf = "";
199
+ conn.setEncoding("utf8");
200
+ conn.on("data", (chunk) => {
201
+ buf += chunk;
202
+ let nl;
203
+ while ((nl = buf.indexOf("\n")) >= 0) {
204
+ const line = buf.slice(0, nl);
205
+ buf = buf.slice(nl + 1);
206
+ try {
207
+ const { t, ...data } = JSON.parse(line);
208
+ res.write(`event: ${t}\ndata: ${JSON.stringify(data)}\n\n`);
209
+ } catch {}
210
+ }
211
+ });
212
+ conn.on("close", () => {
213
+ if (!res.writableEnded) res.write("event: exit\ndata: {\"code\":null}\n\n");
214
+ });
215
+ conn.on("error", () => {});
216
+ req.on("close", () => {
217
+ clearInterval(ping);
218
+ conn.destroy();
219
+ });
220
+ conn.write(JSON.stringify({
221
+ t: "attach",
222
+ id,
223
+ viewer
224
+ }) + "\n");
225
+ }
226
+ /** End the session and its host. */
227
+ async function stop() {
228
+ return { stopped: !!await ask({ t: "stop" }) };
229
+ }
230
+ /**
231
+ * Show the page at `path` (a path on this server) in the browser tab whose drawer the reader used
232
+ * last: for session `id`, or without one, of all sessions.
233
+ */
234
+ async function open(id, path) {
235
+ if (!path.startsWith("/") || path.startsWith("//")) throw failure("open takes a path on this server, like /plan", 400);
236
+ const reply = await ask({
237
+ t: "open",
238
+ id,
239
+ path
240
+ });
241
+ if (!reply) throw failure("no terminal host runs", 404);
242
+ return { shown: Number(reply.shown ?? 0) };
243
+ }
244
+ return {
245
+ sessions,
246
+ screens,
247
+ start,
248
+ input,
249
+ resize,
250
+ close,
251
+ open,
252
+ stream,
253
+ stop
254
+ };
255
+ }
256
+ export { createTerminal, hostSocket };
@@ -0,0 +1,57 @@
1
+ // plugins/terminal/sizes.ts
2
+ /**
3
+ * A drawer reports the size that fits it; `used`: the reader uses it now. Returns the size the
4
+ * session should have: its own when the drawer is (now) the active one, else the session's as it is.
5
+ */
6
+ function report(s, viewer, cols, rows, used, now = Date.now()) {
7
+ const known = s.viewers.get(viewer);
8
+ s.viewers.set(viewer, {
9
+ cols,
10
+ rows,
11
+ used: used ? now : known?.used ?? 0
12
+ });
13
+ if (used || !s.active || !s.viewers.has(s.active)) s.active = viewer;
14
+ return s.active === viewer ? {
15
+ cols,
16
+ rows
17
+ } : {
18
+ cols: s.cols,
19
+ rows: s.rows
20
+ };
21
+ }
22
+ /** A drawer stopped showing the session. True when it was the active one: call `handOver` after a moment. */
23
+ function leave(s, viewer) {
24
+ s.viewers.delete(viewer);
25
+ return s.active === viewer;
26
+ }
27
+ /**
28
+ * After the active drawer `viewer` left: the drawer used most recently of those left becomes the
29
+ * active one. Returns the size the session should take, or null to leave it as it is (another drawer
30
+ * claimed the session in the meantime, or none is left).
31
+ */
32
+ function handOver(s, viewer) {
33
+ if (s.active !== viewer || s.viewers.has(viewer)) return null;
34
+ const next = [...s.viewers].sort((a, b) => b[1].used - a[1].used)[0];
35
+ s.active = next?.[0] ?? null;
36
+ return next ? {
37
+ cols: next[1].cols,
38
+ rows: next[1].rows
39
+ } : null;
40
+ }
41
+ /**
42
+ * Of several sessions, the one whose active drawer the reader used last: where "the browser the
43
+ * reader is in" is, for a program that doesn't know its own tab. Undefined when no drawer is active.
44
+ */
45
+ function lastUsed(sessions) {
46
+ let best;
47
+ let at = -1;
48
+ for (const s of sessions) {
49
+ const viewer = s.active ? s.viewers.get(s.active) : void 0;
50
+ if (viewer && viewer.used > at) {
51
+ best = s;
52
+ at = viewer.used;
53
+ }
54
+ }
55
+ return best;
56
+ }
57
+ export { handOver, lastUsed, leave, report };
@@ -0,0 +1,357 @@
1
+ /**
2
+ * Copyright (c) 2014 The xterm.js authors. All rights reserved.
3
+ * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
4
+ * https://github.com/chjj/term.js
5
+ * @license MIT
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in
15
+ * all copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ * THE SOFTWARE.
24
+ *
25
+ * Originally forked from (with the author's permission):
26
+ * Fabrice Bellard's javascript vt100 for jslinux:
27
+ * http://bellard.org/jslinux/
28
+ * Copyright (c) 2011 Fabrice Bellard
29
+ * The original design remains. The terminal itself
30
+ * has been extended to include xterm CSI codes, among
31
+ * other features.
32
+ */
33
+
34
+ /**
35
+ * Default styles for xterm.js
36
+ */
37
+
38
+ .xterm {
39
+ cursor: text;
40
+ position: relative;
41
+ user-select: none;
42
+ -ms-user-select: none;
43
+ -webkit-user-select: none;
44
+ }
45
+
46
+ .xterm.focus,
47
+ .xterm:focus {
48
+ outline: none;
49
+ }
50
+
51
+ .xterm .xterm-helpers {
52
+ position: absolute;
53
+ top: 0;
54
+ /**
55
+ * The z-index of the helpers must be higher than the canvases in order for
56
+ * IMEs to appear on top.
57
+ */
58
+ z-index: 5;
59
+ }
60
+
61
+ .xterm .xterm-helper-textarea {
62
+ padding: 0;
63
+ border: 0;
64
+ margin: 0;
65
+ /* Move textarea out of the screen to the far left, so that the cursor is not visible */
66
+ position: absolute;
67
+ opacity: 0;
68
+ left: -9999em;
69
+ top: 0;
70
+ width: 0;
71
+ height: 0;
72
+ z-index: -5;
73
+ /** Prevent wrapping so the IME appears against the textarea at the correct position */
74
+ white-space: nowrap;
75
+ overflow: hidden;
76
+ resize: none;
77
+ }
78
+
79
+ .xterm .composition-view {
80
+ /* TODO: Composition position got messed up somewhere */
81
+ background: #000;
82
+ color: #FFF;
83
+ display: none;
84
+ position: absolute;
85
+ white-space: nowrap;
86
+ z-index: 1;
87
+ }
88
+
89
+ .xterm .composition-view.active {
90
+ display: block;
91
+ }
92
+
93
+ .xterm .xterm-viewport {
94
+ /* On OS X this is required in order for the scroll bar to appear fully opaque */
95
+ background-color: #000;
96
+ overflow-y: scroll;
97
+ cursor: default;
98
+ position: absolute;
99
+ right: 0;
100
+ left: 0;
101
+ top: 0;
102
+ bottom: 0;
103
+ }
104
+
105
+ .xterm .xterm-screen {
106
+ position: relative;
107
+ }
108
+
109
+ .xterm .xterm-screen canvas {
110
+ position: absolute;
111
+ left: 0;
112
+ top: 0;
113
+ }
114
+
115
+ .xterm-char-measure-element {
116
+ display: inline-block;
117
+ visibility: hidden;
118
+ position: absolute;
119
+ top: 0;
120
+ left: -9999em;
121
+ line-height: normal;
122
+ }
123
+
124
+ .xterm.enable-mouse-events {
125
+ /* When mouse events are enabled (eg. tmux), revert to the standard pointer cursor */
126
+ cursor: default;
127
+ }
128
+
129
+ .xterm.xterm-cursor-pointer,
130
+ .xterm .xterm-cursor-pointer {
131
+ cursor: pointer;
132
+ }
133
+
134
+ .xterm.column-select.focus {
135
+ /* Column selection mode */
136
+ cursor: crosshair;
137
+ }
138
+
139
+ .xterm .xterm-accessibility:not(.debug),
140
+ .xterm .xterm-message {
141
+ position: absolute;
142
+ left: 0;
143
+ top: 0;
144
+ bottom: 0;
145
+ right: 0;
146
+ z-index: 10;
147
+ color: transparent;
148
+ pointer-events: none;
149
+ }
150
+
151
+ .xterm .xterm-accessibility-tree:not(.debug) *::selection {
152
+ color: transparent;
153
+ }
154
+
155
+ .xterm .xterm-accessibility-tree {
156
+ font-family: monospace;
157
+ user-select: text;
158
+ white-space: pre;
159
+ }
160
+
161
+ .xterm .xterm-accessibility-tree > div {
162
+ transform-origin: left;
163
+ width: fit-content;
164
+ }
165
+
166
+ .xterm .live-region {
167
+ position: absolute;
168
+ left: -9999px;
169
+ width: 1px;
170
+ height: 1px;
171
+ overflow: hidden;
172
+ }
173
+
174
+ .xterm-dim {
175
+ /* Dim should not apply to background, so the opacity of the foreground color is applied
176
+ * explicitly in the generated class and reset to 1 here */
177
+ opacity: 1 !important;
178
+ }
179
+
180
+ .xterm-underline-1 { text-decoration: underline; }
181
+ .xterm-underline-2 { text-decoration: double underline; }
182
+ .xterm-underline-3 { text-decoration: wavy underline; }
183
+ .xterm-underline-4 { text-decoration: dotted underline; }
184
+ .xterm-underline-5 { text-decoration: dashed underline; }
185
+
186
+ .xterm-overline {
187
+ text-decoration: overline;
188
+ }
189
+
190
+ .xterm-overline.xterm-underline-1 { text-decoration: overline underline; }
191
+ .xterm-overline.xterm-underline-2 { text-decoration: overline double underline; }
192
+ .xterm-overline.xterm-underline-3 { text-decoration: overline wavy underline; }
193
+ .xterm-overline.xterm-underline-4 { text-decoration: overline dotted underline; }
194
+ .xterm-overline.xterm-underline-5 { text-decoration: overline dashed underline; }
195
+
196
+ .xterm-strikethrough {
197
+ text-decoration: line-through;
198
+ }
199
+
200
+ .xterm-screen .xterm-decoration-container .xterm-decoration {
201
+ z-index: 6;
202
+ position: absolute;
203
+ }
204
+
205
+ .xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer {
206
+ z-index: 7;
207
+ }
208
+
209
+ .xterm-decoration-overview-ruler {
210
+ z-index: 8;
211
+ position: absolute;
212
+ top: 0;
213
+ right: 0;
214
+ pointer-events: none;
215
+ }
216
+
217
+ .xterm-decoration-top {
218
+ z-index: 2;
219
+ position: relative;
220
+ }
221
+
222
+
223
+
224
+ /* Derived from vs/base/browser/ui/scrollbar/media/scrollbar.css */
225
+
226
+ /* xterm.js customization: Override xterm's cursor style */
227
+ .xterm .xterm-scrollable-element > .scrollbar {
228
+ cursor: default;
229
+ }
230
+
231
+ /* Arrows */
232
+ .xterm .xterm-scrollable-element > .scrollbar > .scra {
233
+ cursor: pointer;
234
+ font-size: 11px !important;
235
+ }
236
+
237
+ .xterm .xterm-scrollable-element > .visible {
238
+ opacity: 1;
239
+
240
+ /* Background rule added for IE9 - to allow clicks on dom node */
241
+ background:rgba(0,0,0,0);
242
+
243
+ transition: opacity 100ms linear;
244
+ /* In front of peek view */
245
+ z-index: 11;
246
+ }
247
+ .xterm .xterm-scrollable-element > .invisible {
248
+ opacity: 0;
249
+ pointer-events: none;
250
+ }
251
+ .xterm .xterm-scrollable-element > .invisible.fade {
252
+ transition: opacity 800ms linear;
253
+ }
254
+
255
+ /* Scrollable Content Inset Shadow */
256
+ .xterm .xterm-scrollable-element > .shadow {
257
+ position: absolute;
258
+ display: none;
259
+ }
260
+ .xterm .xterm-scrollable-element > .shadow.top {
261
+ display: block;
262
+ top: 0;
263
+ left: 3px;
264
+ height: 3px;
265
+ width: 100%;
266
+ box-shadow: var(--vscode-scrollbar-shadow, #000) 0 6px 6px -6px inset;
267
+ }
268
+ .xterm .xterm-scrollable-element > .shadow.left {
269
+ display: block;
270
+ top: 3px;
271
+ left: 0;
272
+ height: 100%;
273
+ width: 3px;
274
+ box-shadow: var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset;
275
+ }
276
+ .xterm .xterm-scrollable-element > .shadow.top-left-corner {
277
+ display: block;
278
+ top: 0;
279
+ left: 0;
280
+ height: 3px;
281
+ width: 3px;
282
+ }
283
+ .xterm .xterm-scrollable-element > .shadow.top.left {
284
+ box-shadow: var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset;
285
+ }
286
+
287
+ /* The terminal drawer (see terminal.ts). Pages morph into each other on navigation, and the drawer is
288
+ named, so it keeps its place and size while the page around it changes. */
289
+ @view-transition { navigation: auto; }
290
+
291
+ /* How much of the window the drawer takes at the bottom, for the page to keep clear: its content
292
+ scrolls to above it, and its own fixed elements sit above it (the page's buttons at the bottom).
293
+ Registered as a length so that it computes to pixels a script can read. */
294
+ @property --wb-inset-bottom { syntax: '<length>'; inherits: true; initial-value: 0px; }
295
+
296
+ :root { --wb-term-h: 320px; --wb-term-bar: 34px; }
297
+ :root:has(body > #wb-terminal) { --wb-inset-bottom: var(--wb-term-bar); }
298
+ :root:has(body > #wb-terminal[data-state=open]) { --wb-inset-bottom: calc(var(--wb-term-bar) + var(--wb-term-h)); }
299
+
300
+ #wb-terminal {
301
+ view-transition-name: wb-terminal;
302
+ position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
303
+ display: flex; flex-direction: column;
304
+ background: #0f1115; color: #d7dae0;
305
+ border-top: 1px solid #2a2f3a;
306
+ box-shadow: 0 -6px 24px rgb(0 0 0 / .18);
307
+ font: 500 12px/1 ui-sans-serif, system-ui, sans-serif;
308
+ }
309
+ body:has(> #wb-terminal) { padding-bottom: var(--wb-inset-bottom); }
310
+
311
+ .wb-term-grip { position: absolute; left: 0; right: 0; top: -4px; height: 8px; cursor: ns-resize; touch-action: none; }
312
+ .wb-term-bar { height: var(--wb-term-bar); display: flex; align-items: center; gap: 12px; padding: 0 10px 0 6px; flex: none; }
313
+ .wb-term-bar button {
314
+ font: inherit; color: inherit; background: transparent; border: 1px solid transparent; border-radius: 5px;
315
+ padding: 5px 8px; cursor: pointer;
316
+ }
317
+ .wb-term-bar button:hover { background: #1c2029; border-color: #2a2f3a; }
318
+ .wb-term-toggle { display: inline-flex; align-items: center; gap: 7px; letter-spacing: .04em; text-transform: uppercase; }
319
+ /* points up while closed (it opens upward), down while open */
320
+ .wb-term-chevron { width: 7px; height: 7px; border: solid currentColor; border-width: 0 1.5px 1.5px 0; rotate: 45deg; translate: 0 -2px; transition: rotate .2s, translate .2s; }
321
+ #wb-terminal[data-state=collapsed] .wb-term-chevron { rotate: -135deg; translate: 0 2px; }
322
+ .wb-term-status { color: #8b93a3; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
323
+ .wb-term-actions { display: flex; gap: 4px; }
324
+
325
+ /* the tabs: one per session, the current one lit */
326
+ /* the bar: the toggle, what the current tab says (status, actions), then the tabs and "+" at the right */
327
+ .wb-term-tabs { display: flex; align-items: center; gap: 2px; min-width: 0; flex: 0 1 auto; overflow-x: auto; scrollbar-width: none; }
328
+ .wb-term-bar .wb-term-add { flex: none; }
329
+ .wb-term-tab { display: inline-flex; align-items: center; flex: none; border-radius: 5px; }
330
+ .wb-term-bar .wb-term-tab button { padding: 5px 4px 5px 8px; }
331
+ .wb-term-bar .wb-term-tab .wb-term-tab-close { padding: 5px 7px 5px 3px; opacity: .45; }
332
+ .wb-term-bar .wb-term-tab .wb-term-tab-close:hover { opacity: 1; background: transparent; border-color: transparent; }
333
+ .wb-term-bar .wb-term-tab button:hover { background: transparent; border-color: transparent; }
334
+ .wb-term-tab:hover { background: #1c2029; }
335
+ .wb-term-tab.wb-current { background: #232836; color: #fff; }
336
+ .wb-term-tab[data-exited] { color: #8b93a3; }
337
+ .wb-term-bar .wb-term-add { padding: 3px 8px; font-size: 15px; line-height: 1; color: #8b93a3; }
338
+ .wb-term-bar .wb-term-add:hover { color: #d7dae0; }
339
+
340
+ /* content-box: the fit addon reads this height as the room for rows, so the padding must not be in it */
341
+ .wb-term-screen { height: calc(var(--wb-term-h) - 10px); padding: 4px 0 6px 10px; box-sizing: content-box; overflow: hidden; }
342
+ /* the screen as the server wrote it into the page, over the terminal until that has drawn it */
343
+ .wb-term-screen { position: relative; }
344
+ .wb-term-placeholder {
345
+ position: absolute; inset: 4px 0 6px 10px; z-index: 1; overflow: hidden; background: #0f1115;
346
+ font: 13px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre; color: #d7dae0;
347
+ }
348
+ .wb-term-placeholder > div { height: 1.2em; }
349
+ /* the server writes every tab's screen; the current tab's shows */
350
+ .wb-term-placeholder:not(.wb-current) { display: none; }
351
+ #wb-terminal[data-state=collapsed] .wb-term-screen { height: 0; padding: 0; visibility: hidden; }
352
+
353
+ ::view-transition-group(wb-terminal) { animation-duration: .22s; animation-timing-function: cubic-bezier(.2, .7, .2, 1); }
354
+ /* opening and closing: the pictures keep their scale and stay anchored at the bar, so the text
355
+ doesn't stretch while the drawer grows */
356
+ ::view-transition-old(wb-terminal), ::view-transition-new(wb-terminal) { height: 100%; object-fit: none; object-position: top; }
357
+ @media (prefers-reduced-motion: reduce) { ::view-transition-group(*) { animation: none !important; } }
@@ -0,0 +1,35 @@
1
+ import { createComponent, render } from "@solidjs/web";
2
+ import { createContext, createSignal, onSettled, useContext } from "solid-js";
3
+ // solid/index.tsx
4
+ const WhiteboardContext = createContext();
5
+ /** The page's events and theme, as signals. Use inside a component passed to solid(). */
6
+ const useWhiteboard = () => useContext(WhiteboardContext);
7
+ /** Turn a Solid component into a template client: `export default solid(MyComponent)`. */
8
+ function solid(Component) {
9
+ return (element, props, api) => render(() => {
10
+ const [events, setEvents] = createSignal(api.events());
11
+ const [theme, setTheme] = createSignal(api.theme());
12
+ onSettled(() => {
13
+ const offEvents = api.onEvents((list) => setEvents(() => list));
14
+ const offTheme = api.onTheme(setTheme);
15
+ return () => {
16
+ offEvents();
17
+ offTheme();
18
+ };
19
+ });
20
+ const value = {
21
+ page: api.page,
22
+ events,
23
+ last: (type) => events().findLast((e) => e.type === type),
24
+ append: api.append,
25
+ theme
26
+ };
27
+ return createComponent(WhiteboardContext, {
28
+ value,
29
+ get children() {
30
+ return createComponent(Component, props);
31
+ }
32
+ });
33
+ }, element);
34
+ }
35
+ export { solid, useWhiteboard };