@gjermundgaraba/clankermux 0.5.0 → 0.6.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.
@@ -1,50 +1,34 @@
1
1
  import { isText } from "../engine/index.js";
2
- /** Whether the browser keeps the key: its own shortcuts with the platform's
3
- * command modifier, and Ctrl+Shift+V, the paste shortcut where Ctrl+V is
4
- * the terminal's. */
2
+ const IME_PROCESSING_KEY_CODE = 229;
3
+ function isTerminalPasteShortcut(e) {
4
+ return e.ctrlKey && e.shiftKey && e.code === "KeyV";
5
+ }
5
6
  export function browserKeeps(e) {
6
- return e.metaKey || (e.ctrlKey && e.shiftKey && e.code === "KeyV");
7
+ return e.metaKey || isTerminalPasteShortcut(e);
7
8
  }
8
- /** Whether the key belongs to an input method: it is composing, or
9
- * processing the key (`Process`, key code 229), or the key is a dead key
10
- * that starts a composition. Its text arrives at `compositionend`. */
11
9
  export function composing(e) {
12
- return e.isComposing || e.keyCode === 229 || e.key === "Process" || e.key === "Dead";
10
+ return e.isComposing || e.keyCode === IME_PROCESSING_KEY_CODE || e.key === "Process" || e.key === "Dead";
13
11
  }
14
- /** A key with no modifiers, pressed. */
15
12
  function pressed(code) {
16
13
  return { code, key: code, action: "press", shift: false, ctrl: false, alt: false, meta: false };
17
14
  }
18
- /**
19
- * Typing on the terminal's input element, a textarea: keys go to the key
20
- * encoder, and text that no key sent goes as text. Keys the browser keeps
21
- * and keys of a composition are left to the browser; a composition's text
22
- * is sent when it ends, and text inserted without a key (a dead key's
23
- * character, the emoji picker, dictation) as it is inserted.
24
- */
25
15
  export class Typing {
26
16
  keyboard;
27
- /** Keys whose press was sent, so their release is too: a key that
28
- * ended a composition sends no release of a press it never sent. */
29
- down = new Set();
17
+ pressesSent = new Set();
30
18
  constructor(keyboard) {
31
19
  this.keyboard = keyboard;
32
20
  }
33
- /** A key to send, or undefined to leave the event to the browser. */
34
21
  keydown(e) {
35
22
  if (browserKeeps(e) || composing(e))
36
23
  return undefined;
37
- this.down.add(e.code);
24
+ this.pressesSent.add(e.code);
38
25
  return keyInput(e, this.keyboard);
39
26
  }
40
27
  keyup(e) {
41
- if (!this.down.delete(e.code))
28
+ if (!this.pressesSent.delete(e.code))
42
29
  return undefined;
43
30
  return keyInput(e, this.keyboard);
44
31
  }
45
- /** `beforeinput`: what the element would insert or delete, when no key
46
- * sent it. A composition's own steps wait for `compositionend`; a paste
47
- * is the `paste` event's. */
48
32
  beforeinput(e) {
49
33
  if (e.isComposing)
50
34
  return undefined;
@@ -60,7 +44,6 @@ export class Typing {
60
44
  return undefined;
61
45
  }
62
46
  }
63
- /** `compositionend`: the composed text. */
64
47
  compositionend(data) {
65
48
  return data ? { text: data } : undefined;
66
49
  }
@@ -80,13 +63,14 @@ export function keyInput(e, keyboard) {
80
63
  const unshifted = keyboard.layout?.get(e.code);
81
64
  if (unshifted !== undefined)
82
65
  input.unshifted = unshifted;
83
- // Alt composed the text when it differs from the key's own character
84
- // (Option on macOS, AltGr elsewhere). Without a layout to compare
85
- // against, macOS Option composes and other platforms' Alt modifies.
86
- if (e.altKey && isText(e.key)) {
87
- const composed = unshifted !== undefined ? e.key.toLowerCase() !== unshifted.toLowerCase() : keyboard.mac;
88
- if (composed)
89
- input.altComposed = true;
90
- }
66
+ if (altComposedText(e, unshifted, keyboard))
67
+ input.altComposed = true;
91
68
  return input;
92
69
  }
70
+ function altComposedText(e, unshifted, keyboard) {
71
+ if (!e.altKey || !isText(e.key))
72
+ return false;
73
+ if (unshifted === undefined)
74
+ return keyboard.mac;
75
+ return e.key.toLowerCase() !== unshifted.toLowerCase();
76
+ }
@@ -1,7 +1,9 @@
1
- /** Listeners of one kind, and the latest value they were told. */
1
+ export type ListenerMode = "replayLatest" | "isolateErrors";
2
2
  export declare class Listeners<T> {
3
3
  private readonly all;
4
4
  private latest;
5
+ private readonly mode;
6
+ constructor(mode?: ListenerMode);
5
7
  add(listener: (value: T) => void): () => void;
6
8
  emit(value: T): void;
7
9
  clear(): void;
@@ -1,7 +1,10 @@
1
- /** Listeners of one kind, and the latest value they were told. */
2
1
  export class Listeners {
3
2
  all = new Set();
4
3
  latest;
4
+ mode;
5
+ constructor(mode = "replayLatest") {
6
+ this.mode = mode;
7
+ }
5
8
  add(listener) {
6
9
  this.all.add(listener);
7
10
  if (this.latest)
@@ -9,9 +12,22 @@ export class Listeners {
9
12
  return () => void this.all.delete(listener);
10
13
  }
11
14
  emit(value) {
12
- this.latest = { value };
13
- for (const listener of this.all)
14
- listener(value);
15
+ if (this.mode === "replayLatest") {
16
+ this.latest = { value };
17
+ for (const listener of this.all)
18
+ listener(value);
19
+ return;
20
+ }
21
+ for (const listener of this.all) {
22
+ try {
23
+ listener(value);
24
+ }
25
+ catch (err) {
26
+ queueMicrotask(() => {
27
+ throw err;
28
+ });
29
+ }
30
+ }
15
31
  }
16
32
  clear() {
17
33
  this.all.clear();
@@ -75,19 +75,14 @@ export interface Terminal {
75
75
  * copy. A listener added later is not told of earlier copies. */
76
76
  onCopy(listener: (copy: Copy) => void): () => void;
77
77
  }
78
- /** The client's side of a terminal: its messages to the worker, and
79
- * word that it is disposed. */
80
78
  export interface MountHost {
81
79
  send(message: ToWorker): void;
82
80
  disposed(): void;
83
81
  }
84
82
  type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
85
- /** A message for one terminal, without its number. */
86
83
  export type ToMount = DistributiveOmit<Extract<ToWorker, {
87
84
  mount: number;
88
85
  }>, "mount">;
89
- /** Mounts a terminal as `id` of the client `host` serves, and the
90
- * handler of the worker's messages for it. */
91
86
  export declare function mountOn(host: MountHost, id: number, options: MountOptions): {
92
87
  terminal: Terminal;
93
88
  receive: (message: ToPage) => void;
@@ -3,7 +3,6 @@ import { Copier } from "./copy.js";
3
3
  import { Typing, composing } from "./keyboard.js";
4
4
  import { Listeners } from "./listeners.js";
5
5
  import { profileFrom, schemeOf } from "./profile.js";
6
- /** Cell metrics from the font. */
7
6
  function measure(font) {
8
7
  const ctx = document.createElement("canvas").getContext("2d");
9
8
  ctx.font = font;
@@ -21,8 +20,9 @@ function measure(font) {
21
20
  boldItalicFont: `bold italic ${font}`,
22
21
  };
23
22
  }
24
- /** Mounts a terminal as `id` of the client `host` serves, and the
25
- * handler of the worker's messages for it. */
23
+ function isCopyChord(e) {
24
+ return e.ctrlKey && e.shiftKey && !e.altKey && !e.metaKey && e.code === "KeyC";
25
+ }
26
26
  export function mountOn(host, id, options) {
27
27
  const { canvas, container, colors } = options;
28
28
  const light = matchMedia("(prefers-color-scheme: light)");
@@ -42,10 +42,8 @@ export function mountOn(host, id, options) {
42
42
  cell_height: Math.round(metrics.cellHeight * dpr()),
43
43
  };
44
44
  }
45
- /** The canvas backing store for the grid at the current pixel ratio;
46
- * the next frame is drawn in full after a change. */
47
45
  let grid = { cols: 0, rows: 0, dpr: 0 };
48
- let fullNext = false;
46
+ let backingStoreReset = false;
49
47
  function fitCanvas(cols, rows) {
50
48
  const scale = dpr();
51
49
  if (grid.cols === cols && grid.rows === rows && grid.dpr === scale)
@@ -57,9 +55,8 @@ export function mountOn(host, id, options) {
57
55
  canvas.style.height = `${rows * metrics.cellHeight}px`;
58
56
  ctx.setTransform(scale, 0, 0, scale, 0, 0);
59
57
  ctx.textBaseline = "alphabetic";
60
- fullNext = true;
58
+ backingStoreReset = true;
61
59
  }
62
- /** The keyboard layout, when the browser exposes it (Chromium does). */
63
60
  const keyboard = { layout: undefined, mac: /Mac|iPhone|iPad/.test(navigator.platform) };
64
61
  navigator.keyboard
65
62
  ?.getLayoutMap()
@@ -73,29 +70,13 @@ export function mountOn(host, id, options) {
73
70
  const links = new Listeners();
74
71
  const scrolls = new Listeners();
75
72
  const statuses = new Listeners();
76
- const copies = new Set();
77
- /** The selection's text, for a copy. */
73
+ const copies = new Listeners("isolateErrors");
78
74
  let selected;
79
75
  const copier = new Copier({
80
76
  clipboard: () => navigator.clipboard,
81
77
  item: typeof ClipboardItem === "undefined" ? undefined : (text) => new ClipboardItem({ "text/plain": text }),
82
- // Told from a promise's callback: a listener's throw is reported as
83
- // a listener's throw is elsewhere, and the rest are told.
84
- report: (copy) => {
85
- for (const listener of copies) {
86
- try {
87
- listener(copy);
88
- }
89
- catch (err) {
90
- queueMicrotask(() => {
91
- throw err;
92
- });
93
- }
94
- }
95
- },
78
+ report: (copy) => copies.emit(copy),
96
79
  });
97
- /** Rows the view is scrolled back, as `onScroll` last reported;
98
- * undefined before the first frame. */
99
80
  let scrolled;
100
81
  const visible = () => document.visibilityState === "visible";
101
82
  let pendingFrame;
@@ -108,12 +89,11 @@ export function mountOn(host, id, options) {
108
89
  return;
109
90
  if (visible()) {
110
91
  fitCanvas(frame.cols, frame.rows);
111
- if (fullNext && !frame.full) {
112
- // The backing store was recreated; a partial frame cannot fill it.
92
+ if (backingStoreReset && !frame.full) {
113
93
  send({ type: "repaint" });
114
94
  }
115
95
  else {
116
- fullNext = false;
96
+ backingStoreReset = false;
117
97
  renderer.draw(frame);
118
98
  }
119
99
  }
@@ -156,8 +136,6 @@ export function mountOn(host, id, options) {
156
136
  break;
157
137
  }
158
138
  };
159
- /** Where the input element goes for a composition: the cursor's cell,
160
- * as the latest frame that had the cursor in view placed it. */
161
139
  let cursorAt = { x: 0, y: 0 };
162
140
  // An input method composes only into an editable element: a textarea
163
141
  // after the canvas takes the focus, invisible but at the cursor so the
@@ -187,10 +165,7 @@ export function mountOn(host, id, options) {
187
165
  caretColor: "transparent",
188
166
  });
189
167
  canvas.after(input);
190
- /** Moves the input element to the cursor, and shows it while composing. */
191
168
  function placeInput(composing) {
192
- // Its position is against its containing block: a positioned
193
- // ancestor, or else the document.
194
169
  const cell = canvas.getBoundingClientRect();
195
170
  const parent = input.offsetParent;
196
171
  let left = cell.left + window.scrollX;
@@ -216,8 +191,6 @@ export function mountOn(host, id, options) {
216
191
  });
217
192
  }
218
193
  canvas.addEventListener("focus", () => input.focus({ preventScroll: true }), { signal });
219
- // Whether the terminal has the keyboard and its window the focus, for
220
- // `ackOnFocus`.
221
194
  let focused = false;
222
195
  const watchFocus = () => {
223
196
  const now = document.activeElement === input && document.hasFocus();
@@ -233,9 +206,7 @@ export function mountOn(host, id, options) {
233
206
  const typing = new Typing(keyboard);
234
207
  const typed = (what) => send("text" in what ? { type: "text", text: what.text } : { type: "key", input: what.key });
235
208
  input.addEventListener("keydown", (e) => {
236
- // Ctrl+Shift+C copies a selection, where Ctrl+C is the terminal's;
237
- // without one it is a key.
238
- if (e.ctrlKey && e.shiftKey && !e.altKey && !e.metaKey && e.code === "KeyC" && selected) {
209
+ if (isCopyChord(e) && selected) {
239
210
  copier.write(selected, "keys");
240
211
  e.preventDefault();
241
212
  return;
@@ -246,8 +217,6 @@ export function mountOn(host, id, options) {
246
217
  e.preventDefault();
247
218
  }
248
219
  else if (composing(e)) {
249
- // At the cursor before the input method opens its window; shown
250
- // once a composition starts.
251
220
  placeInput(false);
252
221
  }
253
222
  }, { signal });
@@ -272,7 +241,6 @@ export function mountOn(host, id, options) {
272
241
  if (what)
273
242
  typed(what);
274
243
  placeInput(false);
275
- // Emptied once the composition has left it.
276
244
  setTimeout(() => (input.value = ""));
277
245
  }, { signal });
278
246
  input.addEventListener("input", (e) => {
@@ -285,7 +253,6 @@ export function mountOn(host, id, options) {
285
253
  send({ type: "paste", text });
286
254
  e.preventDefault();
287
255
  }, { signal });
288
- // The browser's copy (Cmd+C, Ctrl+C in a menu) copies the selection.
289
256
  // WebKit offers Copy on an empty textarea only when `beforecopy` is
290
257
  // cancelled.
291
258
  input.addEventListener("beforecopy", (e) => {
@@ -299,7 +266,6 @@ export function mountOn(host, id, options) {
299
266
  e.preventDefault();
300
267
  copier.copied(selected);
301
268
  }, { signal });
302
- /** The pointer in cells of the grid, fractions included, kept inside it. */
303
269
  function cellAt(e) {
304
270
  const rect = canvas.getBoundingClientRect();
305
271
  const inside = (value, cells) => Math.min(Math.max(value, 0), Math.max(cells - 0.01, 0));
@@ -308,10 +274,6 @@ export function mountOn(host, id, options) {
308
274
  y: inside((e.clientY - rect.top) / metrics.cellHeight, grid.rows),
309
275
  };
310
276
  }
311
- // Selection: press, drag (once a frame) and release, followed outside
312
- // the canvas until the button is up. A release the page never saw (the
313
- // button let go over another window) ends the drag at the next move or
314
- // press.
315
277
  let endDrag;
316
278
  canvas.addEventListener("mousedown", (e) => {
317
279
  e.preventDefault();
@@ -350,8 +312,6 @@ export function mountOn(host, id, options) {
350
312
  window.addEventListener("mousemove", move, { signal });
351
313
  window.addEventListener("mouseup", up, { signal });
352
314
  }, { signal });
353
- // The wheel scrolls the history in whole rows; what a trackpad sends in
354
- // pixels adds up until it makes one. Ctrl+wheel stays the browser's zoom.
355
315
  let wheeled = 0;
356
316
  canvas.addEventListener("wheel", (e) => {
357
317
  if (e.ctrlKey)
@@ -369,39 +329,32 @@ export function mountOn(host, id, options) {
369
329
  wheeled -= whole;
370
330
  send({ type: "wheel", rows: whole });
371
331
  }, { passive: false, signal });
372
- /** The profile last reported, to tell when it changed. */
373
332
  let reported = "";
374
333
  const profile = () => {
375
334
  const current = profileFrom(colors(), scheme());
376
335
  reported = JSON.stringify(current);
377
336
  return current;
378
337
  };
379
- /** Whether the user is looking at this page: it is visible and its
380
- * window has the focus. Only then does the session get its size, so
381
- * of several clients the one in use sets it. */
382
338
  const active = () => visible() && document.hasFocus();
383
339
  const report = () => send({ type: "viewport", size: viewport(), profile: profile(), active: active() });
384
340
  const resizes = new ResizeObserver(report);
385
341
  resizes.observe(container);
386
342
  light.addEventListener("change", report, { signal });
387
- // Shown or focused: the session takes this page's size again; hidden or
388
- // blurred: the worker stops reporting.
343
+ const releaseFrameWhileHidden = () => {
344
+ if (visible() || !pendingFrame)
345
+ return;
346
+ cancelAnimationFrame(paintRequest);
347
+ paintRequest = 0;
348
+ pendingFrame = undefined;
349
+ send({ type: "painted" });
350
+ };
389
351
  document.addEventListener("visibilitychange", () => {
390
352
  send({ type: "visibility", visible: visible() });
391
- if (!visible() && pendingFrame) {
392
- cancelAnimationFrame(paintRequest);
393
- paintRequest = 0;
394
- pendingFrame = undefined;
395
- // Hidden documents may never get another animation callback. Release
396
- // the frame after hiding the worker; showing requests a full refresh.
397
- send({ type: "painted" });
398
- }
353
+ releaseFrameWhileHidden();
399
354
  report();
400
355
  }, { signal });
401
356
  window.addEventListener("focus", report, { signal });
402
357
  window.addEventListener("blur", report, { signal });
403
- // A page pins its scheme (and its colours with it) with an attribute or
404
- // a class on the canvas or an ancestor, which no event announces.
405
358
  const restyles = new MutationObserver(() => {
406
359
  if (JSON.stringify(profileFrom(colors(), scheme())) !== reported)
407
360
  report();
@@ -409,8 +362,6 @@ export function mountOn(host, id, options) {
409
362
  for (let element = canvas; element; element = element.parentElement) {
410
363
  restyles.observe(element, { attributes: true });
411
364
  }
412
- // Zoom or a move to another screen changes the pixel ratio: the canvas
413
- // is refitted on the next frame; the cell size in pixels is re-reported.
414
365
  const watchRatio = () => {
415
366
  matchMedia(`(resolution: ${dpr()}dppx)`).addEventListener("change", () => {
416
367
  send({ type: "repaint" });
@@ -463,10 +414,7 @@ export function mountOn(host, id, options) {
463
414
  onLink: (listener) => links.add(listener),
464
415
  onScroll: (listener) => scrolls.add(listener),
465
416
  onStatus: (listener) => statuses.add(listener),
466
- onCopy: (listener) => {
467
- copies.add(listener);
468
- return () => void copies.delete(listener);
469
- },
417
+ onCopy: (listener) => copies.add(listener),
470
418
  };
471
419
  return { terminal, receive };
472
420
  }
@@ -1,14 +1,11 @@
1
1
  export interface ClipboardWrite {
2
- /** The selection parameter: `c` or empty for the clipboard, `p`, `s`, `q` otherwise. */
3
- selection: string;
2
+ toClipboard: boolean;
4
3
  text: string;
5
4
  }
6
5
  export declare class Osc52Scanner {
7
6
  private state;
8
7
  private payload;
9
- /** Forgets a sequence in progress: the stream it came from is gone. */
10
8
  reset(): void;
11
- /** Feeds output bytes; returns the clipboard writes they completed. */
12
9
  feed(bytes: Uint8Array): ClipboardWrite[];
13
10
  private finish;
14
11
  }
@@ -13,18 +13,15 @@ const ESC = 0x1b;
13
13
  const BEL = 0x07;
14
14
  const CAN = 0x18;
15
15
  const SUB = 0x1a;
16
- /** Longer OSC 52 payloads are abandoned, not buffered. */
17
16
  const MAX_OSC = 1 << 20;
18
17
  const PREFIX = "52;";
19
18
  export class Osc52Scanner {
20
19
  state = "text";
21
20
  payload = [];
22
- /** Forgets a sequence in progress: the stream it came from is gone. */
23
21
  reset() {
24
22
  this.state = "text";
25
23
  this.payload = [];
26
24
  }
27
- /** Feeds output bytes; returns the clipboard writes they completed. */
28
25
  feed(bytes) {
29
26
  const writes = [];
30
27
  for (let at = 0; at < bytes.length; at++) {
@@ -37,14 +34,13 @@ export class Osc52Scanner {
37
34
  this.state = "esc";
38
35
  break;
39
36
  case "esc":
40
- // The payload is empty: every way out of an OSC clears it.
41
37
  if (b === 0x5d)
42
- this.state = "osc";
38
+ this.state = "maybeOsc52";
43
39
  else
44
40
  this.state = b === ESC ? "esc" : "text";
45
41
  break;
46
- case "osc":
47
- case "skip":
42
+ case "maybeOsc52":
43
+ case "otherOsc":
48
44
  if (b === BEL) {
49
45
  this.finish(writes);
50
46
  }
@@ -55,10 +51,10 @@ export class Osc52Scanner {
55
51
  else if (b === CAN || b === SUB) {
56
52
  this.reset();
57
53
  }
58
- else if (this.state === "osc") {
54
+ else if (this.state === "maybeOsc52") {
59
55
  const length = this.payload.length;
60
56
  if ((length < PREFIX.length && b !== PREFIX.charCodeAt(length)) || length === MAX_OSC) {
61
- this.state = "skip";
57
+ this.state = "otherOsc";
62
58
  this.payload = [];
63
59
  }
64
60
  else {
@@ -71,7 +67,7 @@ export class Osc52Scanner {
71
67
  return writes;
72
68
  }
73
69
  finish(writes) {
74
- const collected = this.state === "osc";
70
+ const collected = this.state === "maybeOsc52";
75
71
  const payload = new TextDecoder().decode(Uint8Array.from(this.payload));
76
72
  this.reset();
77
73
  if (!collected)
@@ -79,15 +75,22 @@ export class Osc52Scanner {
79
75
  const match = /^52;([^;]*);(.*)$/s.exec(payload);
80
76
  if (!match || match[2] === "?")
81
77
  return;
82
- try {
83
- writes.push({ selection: match[1], text: new TextDecoder().decode(base64(match[2])) });
84
- }
85
- catch {
86
- // Not base64: ignored, as a terminal would.
87
- }
78
+ const bytes = base64(match[2]);
79
+ if (bytes === undefined)
80
+ return;
81
+ writes.push({ toClipboard: isClipboardSelection(match[1]), text: new TextDecoder().decode(bytes) });
88
82
  }
89
83
  }
84
+ function isClipboardSelection(selection) {
85
+ return selection === "" || selection.includes("c");
86
+ }
90
87
  function base64(text) {
91
- const binary = atob(text.replace(/\s+/g, ""));
88
+ let binary;
89
+ try {
90
+ binary = atob(text.replace(/\s+/g, ""));
91
+ }
92
+ catch {
93
+ return undefined;
94
+ }
92
95
  return Uint8Array.from(binary, (c) => c.charCodeAt(0));
93
96
  }
@@ -1,12 +1,6 @@
1
1
  import type { Profile, Scheme } from "../proto/index.ts";
2
- /** `#rrggbb` from a CSS colour as a custom property holds it (hex, or
3
- * `rgb()` when the stylesheet writes it that way); undefined otherwise. */
4
2
  export declare function hexColor(value: string): string | undefined;
5
- /** The scheme of an element whose computed `color-scheme` is
6
- * `colorScheme`: the one it names when it names one of `light` and
7
- * `dark`, else (`normal`, or both) the page's preference. */
8
3
  export declare function schemeOf(colorScheme: string, prefersLight: boolean): Scheme;
9
- /** The profile a page with these colours and scheme reports. */
10
4
  export declare function profileFrom(colors: {
11
5
  fg: string;
12
6
  bg: string;
@@ -1,5 +1,3 @@
1
- /** `#rrggbb` from a CSS colour as a custom property holds it (hex, or
2
- * `rgb()` when the stylesheet writes it that way); undefined otherwise. */
3
1
  export function hexColor(value) {
4
2
  const text = value.trim();
5
3
  const hex = /^#([0-9a-f]{6})$/i.exec(text);
@@ -14,9 +12,6 @@ export function hexColor(value) {
14
12
  const channel = (s) => Math.min(255, Number(s)).toString(16).padStart(2, "0");
15
13
  return `#${channel(rgb[1])}${channel(rgb[2])}${channel(rgb[3])}`;
16
14
  }
17
- /** The scheme of an element whose computed `color-scheme` is
18
- * `colorScheme`: the one it names when it names one of `light` and
19
- * `dark`, else (`normal`, or both) the page's preference. */
20
15
  export function schemeOf(colorScheme, prefersLight) {
21
16
  const names = colorScheme.split(/\s+/);
22
17
  const light = names.includes("light");
@@ -25,7 +20,6 @@ export function schemeOf(colorScheme, prefersLight) {
25
20
  return light ? "light" : "dark";
26
21
  return prefersLight ? "light" : "dark";
27
22
  }
28
- /** The profile a page with these colours and scheme reports. */
29
23
  export function profileFrom(colors, scheme) {
30
24
  const profile = { scheme };
31
25
  const fg = hexColor(colors.fg);
@@ -1,10 +1,3 @@
1
- /**
2
- * The engine side of a client: the connection, the attachments and their
3
- * render state live in a worker; the page draws frames and reports input.
4
- * One worker serves one `Client` and every terminal mounted from it.
5
- * Imported as `@gjermundgaraba/clankermux/worker`, so a worker typechecked
6
- * without the DOM library does not see the page's types.
7
- */
8
1
  import { type CellPoint, type PackedFrame, type KeyInput } from "../engine/index.ts";
9
2
  import { type ErrorCode, type ErrorMessage, type Event, type Exit, type Peer, type Profile, type Session, type Size } from "../proto/index.ts";
10
3
  import { type ErrorKind } from "./connection.ts";