@gjermundgaraba/clankermux 0.5.0 → 0.7.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 (40) hide show
  1. package/README.md +1 -1
  2. package/dist/client/attachment.d.ts +9 -29
  3. package/dist/client/attachment.js +28 -41
  4. package/dist/client/client.d.ts +0 -2
  5. package/dist/client/client.js +6 -11
  6. package/dist/client/connection.d.ts +1 -19
  7. package/dist/client/connection.js +0 -17
  8. package/dist/client/copy.d.ts +0 -14
  9. package/dist/client/copy.js +4 -25
  10. package/dist/client/keyboard.d.ts +1 -27
  11. package/dist/client/keyboard.js +18 -34
  12. package/dist/client/link.d.ts +143 -0
  13. package/dist/client/link.js +205 -0
  14. package/dist/client/listeners.d.ts +3 -1
  15. package/dist/client/listeners.js +20 -4
  16. package/dist/client/mount.d.ts +0 -5
  17. package/dist/client/mount.js +20 -72
  18. package/dist/client/osc52.d.ts +1 -4
  19. package/dist/client/osc52.js +20 -17
  20. package/dist/client/profile.d.ts +0 -6
  21. package/dist/client/profile.js +0 -6
  22. package/dist/client/worker.d.ts +3 -44
  23. package/dist/client/worker.js +185 -332
  24. package/dist/engine/decoder.d.ts +0 -20
  25. package/dist/engine/decoder.js +8 -27
  26. package/dist/engine/index.d.ts +2 -49
  27. package/dist/engine/index.js +7 -48
  28. package/dist/engine/keys.d.ts +0 -7
  29. package/dist/engine/keys.js +9 -15
  30. package/dist/engine/render.d.ts +7 -18
  31. package/dist/engine/render.js +32 -32
  32. package/dist/engine/selection.d.ts +0 -17
  33. package/dist/engine/selection.js +8 -30
  34. package/dist/proto/frame.d.ts +2 -23
  35. package/dist/proto/frame.js +1 -21
  36. package/dist/proto/messages.d.ts +49 -9
  37. package/dist/proto/messages.js +42 -1
  38. package/dist/renderer/index.d.ts +3 -4
  39. package/dist/renderer/index.js +38 -42
  40. package/package.json +5 -6
@@ -1,5 +1,4 @@
1
1
  import { type Engine, type Scrollbar, type Terminal } from "./index.ts";
2
- /** Style flag bits of a [`Cell`]. */
3
2
  export declare const FLAG: {
4
3
  readonly BOLD: 1;
5
4
  readonly ITALIC: 2;
@@ -9,12 +8,9 @@ export declare const FLAG: {
9
8
  readonly INVISIBLE: 32;
10
9
  readonly STRIKETHROUGH: 64;
11
10
  readonly OVERLINE: 128;
12
- /** The cell is the left half of a wide character. */
13
11
  readonly WIDE: 256;
14
- /** The cell is the right half of a wide character; draw nothing. */
15
12
  readonly SPACER: 512;
16
13
  };
17
- /** No explicit colour; the renderer uses the default. */
18
14
  export declare const NO_COLOR = -1;
19
15
  export interface Cell {
20
16
  /** The grapheme, empty for a blank cell. */
@@ -26,7 +22,6 @@ export interface Cell {
26
22
  /** `GhosttySgrUnderline`: 0 none, 1 single, 2 double, 3 curly, 4 dotted, 5 dashed. */
27
23
  underline: number;
28
24
  }
29
- /** `GhosttyRenderStateCursorVisualStyle` by name. */
30
25
  declare const CURSOR_STYLES: readonly ["bar", "block", "underline", "block_hollow"];
31
26
  type CursorStyle = (typeof CURSOR_STYLES)[number];
32
27
  export interface FrameRow<Cells = Cell[]> {
@@ -56,10 +51,13 @@ export interface Frame<Cells = Cell[]> {
56
51
  * above the last row (`offset + len < total`). */
57
52
  scrollbar: Scrollbar;
58
53
  }
59
- /** Four signed words per cell: text code, foreground, background, style.
60
- * Text is a Unicode scalar (0 for blank), or -(grapheme index + 1).
61
- * Style holds flags in its low 16 bits and underline in its high 16. */
62
54
  export declare const PACKED_STRIDE = 4;
55
+ export declare const PACKED_TEXT = 0;
56
+ export declare const PACKED_FG = 1;
57
+ export declare const PACKED_BG = 2;
58
+ export declare const PACKED_STYLE = 3;
59
+ export declare const PACKED_FLAGS_MASK = 65535;
60
+ export declare const PACKED_UNDERLINE_SHIFT = 16;
63
61
  export interface PackedCells {
64
62
  data: Int32Array<ArrayBuffer>;
65
63
  /** Only multi-codepoint cells need strings; these are cloned on transfer. */
@@ -67,10 +65,6 @@ export interface PackedCells {
67
65
  }
68
66
  export type PackedFrame = Frame<PackedCells>;
69
67
  export declare function packedText(cells: PackedCells, x: number): string;
70
- /**
71
- * The engine's render state: updated from a terminal, read into a
72
- * [`Frame`] of the rows that changed, then cleaned.
73
- */
74
68
  export declare class RenderState {
75
69
  readonly engine: Engine;
76
70
  private readonly state;
@@ -79,22 +73,17 @@ export declare class RenderState {
79
73
  private readonly keys;
80
74
  private readonly tags;
81
75
  private readonly wide;
82
- /** `GhosttyCell` bit fields, from the manifest. */
83
76
  private readonly cell;
84
77
  private readonly cursorStyles;
85
78
  constructor(engine: Engine);
86
- /** Captures the terminal and returns the rows that changed since the last `clean`. */
87
79
  update(term: Terminal): Frame;
88
- /** Captures transferable cell buffers without allocating Cell objects.
89
- * Each row owns its buffer so the renderer can retain rows independently. */
90
80
  updatePacked(term: Terminal): PackedFrame;
81
+ takePackedFrame(term: Terminal): PackedFrame;
91
82
  private frame;
92
- /** The row's selected cells, or undefined when the selection misses it. */
93
83
  private rowSelection;
94
84
  private readRow;
95
85
  private color;
96
86
  private graphemes;
97
- /** Clears the captured dirty rows; later terminal writes remain dirty. */
98
87
  clean(): void;
99
88
  free(): void;
100
89
  }
@@ -1,5 +1,4 @@
1
1
  import { EngineError } from "./index.js";
2
- /** Style flag bits of a [`Cell`]. */
3
2
  export const FLAG = {
4
3
  BOLD: 1,
5
4
  ITALIC: 2,
@@ -9,27 +8,33 @@ export const FLAG = {
9
8
  INVISIBLE: 32,
10
9
  STRIKETHROUGH: 64,
11
10
  OVERLINE: 128,
12
- /** The cell is the left half of a wide character. */
13
11
  WIDE: 256,
14
- /** The cell is the right half of a wide character; draw nothing. */
15
12
  SPACER: 512,
16
13
  };
17
- /** No explicit colour; the renderer uses the default. */
18
14
  export const NO_COLOR = -1;
19
- /** `GhosttyRenderStateCursorVisualStyle` by name. */
20
15
  const CURSOR_STYLES = ["bar", "block", "underline", "block_hollow"];
21
- /** Four signed words per cell: text code, foreground, background, style.
22
- * Text is a Unicode scalar (0 for blank), or -(grapheme index + 1).
23
- * Style holds flags in its low 16 bits and underline in its high 16. */
24
16
  export const PACKED_STRIDE = 4;
17
+ export const PACKED_TEXT = 0;
18
+ export const PACKED_FG = 1;
19
+ export const PACKED_BG = 2;
20
+ export const PACKED_STYLE = 3;
21
+ export const PACKED_FLAGS_MASK = 0xffff;
22
+ export const PACKED_UNDERLINE_SHIFT = 16;
23
+ function scratchLayout(e, types) {
24
+ const offsets = [];
25
+ let size = 0;
26
+ for (const name of types) {
27
+ const align = e.alignOf(name);
28
+ size = Math.ceil(size / align) * align;
29
+ offsets.push(size);
30
+ size += e.sizeOf(name);
31
+ }
32
+ return { offsets, size };
33
+ }
25
34
  export function packedText(cells, x) {
26
- const code = cells.data[x * PACKED_STRIDE];
35
+ const code = cells.data[x * PACKED_STRIDE + PACKED_TEXT];
27
36
  return code < 0 ? cells.graphemes[-code - 1] : code === 0 ? "" : String.fromCodePoint(code);
28
37
  }
29
- /**
30
- * The engine's render state: updated from a terminal, read into a
31
- * [`Frame`] of the rows that changed, then cleaned.
32
- */
33
38
  export class RenderState {
34
39
  engine;
35
40
  state;
@@ -38,7 +43,6 @@ export class RenderState {
38
43
  keys;
39
44
  tags;
40
45
  wide;
41
- /** `GhosttyCell` bit fields, from the manifest. */
42
46
  cell;
43
47
  cursorStyles;
44
48
  constructor(engine) {
@@ -74,7 +78,6 @@ export class RenderState {
74
78
  };
75
79
  this.cursorStyles = new Map(CURSOR_STYLES.map((style) => [engine.enumValue("GhosttyRenderStateCursorVisualStyle", style.toUpperCase()), style]));
76
80
  }
77
- /** Captures the terminal and returns the rows that changed since the last `clean`. */
78
81
  update(term) {
79
82
  return this.frame(term, (cols) => {
80
83
  const cells = [];
@@ -84,22 +87,26 @@ export class RenderState {
84
87
  return cells;
85
88
  });
86
89
  }
87
- /** Captures transferable cell buffers without allocating Cell objects.
88
- * Each row owns its buffer so the renderer can retain rows independently. */
89
90
  updatePacked(term) {
90
91
  return this.frame(term, (cols) => {
91
92
  const data = new Int32Array(cols * PACKED_STRIDE);
92
93
  const graphemes = [];
93
94
  let at = 0;
94
95
  this.readRow(cols, (codepoint, text, fg, bg, flags, underline) => {
95
- data[at++] = text === "" ? codepoint : -graphemes.push(text);
96
- data[at++] = fg;
97
- data[at++] = bg;
98
- data[at++] = flags | (underline << 16);
96
+ data[at + PACKED_TEXT] = text === "" ? codepoint : -graphemes.push(text);
97
+ data[at + PACKED_FG] = fg;
98
+ data[at + PACKED_BG] = bg;
99
+ data[at + PACKED_STYLE] = flags | (underline << PACKED_UNDERLINE_SHIFT);
100
+ at += PACKED_STRIDE;
99
101
  });
100
102
  return { data: data.subarray(0, at), graphemes };
101
103
  });
102
104
  }
105
+ takePackedFrame(term) {
106
+ const frame = this.updatePacked(term);
107
+ this.clean();
108
+ return frame;
109
+ }
103
110
  frame(term, readRow) {
104
111
  const e = this.engine;
105
112
  e.check("ghostty_render_state_update", this.state, term.handle);
@@ -155,7 +162,6 @@ export class RenderState {
155
162
  });
156
163
  return { cols, rows, full, background, foreground, cursor, lines, scrollbar };
157
164
  }
158
- /** The row's selected cells, or undefined when the selection misses it. */
159
165
  rowSelection() {
160
166
  const e = this.engine;
161
167
  const size = e.sizeOf("GhosttyRenderStateRowSelection");
@@ -175,15 +181,11 @@ export class RenderState {
175
181
  });
176
182
  const styleSize = e.sizeOf("GhosttyStyle");
177
183
  let count = 0;
178
- // Scratch: raw cell (8), colour (3, padded to 8), the 8-aligned style,
179
- // a UTF-8 buffer struct and its bytes.
180
184
  const utf8Cap = 64;
181
- e.scratch(16 + styleSize + e.sizeOf("GhosttyBuffer") + utf8Cap, (scratch) => {
182
- const raw = scratch;
183
- const color = scratch + 8;
184
- const style = scratch + 16;
185
- const buffer = style + styleSize;
186
- const utf8 = buffer + e.sizeOf("GhosttyBuffer");
185
+ const layout = scratchLayout(e, ["GhosttyCell", "GhosttyColorRgb", "GhosttyStyle", "GhosttyBuffer"]);
186
+ e.scratch(layout.size + utf8Cap, (scratch) => {
187
+ const [raw, color, style, buffer] = layout.offsets.map((offset) => scratch + offset);
188
+ const utf8 = scratch + layout.size;
187
189
  while (e.call("ghostty_render_state_row_cells_next", this.cells) && count < cols) {
188
190
  e.check("ghostty_render_state_row_cells_get", this.cells, this.keys.cell["RAW"], raw);
189
191
  const tag = e.readBits(raw, this.cell.tag);
@@ -253,7 +255,6 @@ export class RenderState {
253
255
  }
254
256
  if (code !== e.result.OUT_OF_SPACE)
255
257
  throw new EngineError("ghostty_render_state_row_cells_get", code);
256
- // The buffer struct reports the needed length; retry through it.
257
258
  const needed = e.field("GhosttyBuffer", buffer, "len");
258
259
  return new TextDecoder().decode(e.growing("ghostty_render_state_row_cells_get", needed, (big, bigCap, len) => {
259
260
  e.view.setUint32(buffer + e.offsetOf("GhosttyBuffer", "ptr"), big, true);
@@ -263,7 +264,6 @@ export class RenderState {
263
264
  return again;
264
265
  }));
265
266
  }
266
- /** Clears the captured dirty rows; later terminal writes remain dirty. */
267
267
  clean() {
268
268
  this.engine.check("ghostty_render_state_clean", this.state);
269
269
  }
@@ -5,33 +5,16 @@ export interface CellPoint {
5
5
  x: number;
6
6
  y: number;
7
7
  }
8
- /**
9
- * Mouse selection through the engine's gesture: a press, then drags, then
10
- * a release. A single press selects nothing; a drag selects from it by
11
- * cells, a double press a word and a triple press a line, dragging by
12
- * words or lines. The gesture tracks its anchor in the terminal, so
13
- * output between press and drag does not move it.
14
- */
15
8
  export declare class SelectionGesture {
16
9
  readonly engine: Engine;
17
10
  private gesture;
18
11
  private readonly events;
19
- /** The terminal the gesture tracks its anchor in. */
20
12
  private term;
21
13
  constructor(engine: Engine);
22
- /** Presses at `at` (`time` in ms); the selection to install, or
23
- * undefined for none (a single press). */
24
14
  press(term: Terminal, at: CellPoint, time: number): Uint8Array | undefined;
25
- /** Drags to `at`; the selection from the press, or undefined when the
26
- * pointer has not left the pressed cell. */
27
15
  drag(term: Terminal, at: CellPoint): Uint8Array | undefined;
28
16
  release(term: Terminal, at: CellPoint): void;
29
- /** Starts afresh, for a terminal freed or about to be: `term` when it
30
- * is still alive, to release the tracked anchor in it, else none. The
31
- * caller says so, since a new terminal may have the handle of a freed
32
- * one. */
33
17
  forget(term?: Terminal): void;
34
- /** A gesture is in one terminal. */
35
18
  private follow;
36
19
  private set;
37
20
  private apply;
@@ -1,21 +1,9 @@
1
- /** Pixels per cell in the gesture's geometry: positions are in cells,
2
- * scaled to whole numbers. */
3
- const SCALE = 1000;
4
- /** Clicks closer together than this, and within a cell of each other,
5
- * count up to a word (two) and a line (three). */
6
- const REPEAT_MS = 500;
7
- /**
8
- * Mouse selection through the engine's gesture: a press, then drags, then
9
- * a release. A single press selects nothing; a drag selects from it by
10
- * cells, a double press a word and a triple press a line, dragging by
11
- * words or lines. The gesture tracks its anchor in the terminal, so
12
- * output between press and drag does not move it.
13
- */
1
+ const PIXELS_PER_CELL = 1000;
2
+ const MULTI_CLICK_INTERVAL_MS = 500;
14
3
  export class SelectionGesture {
15
4
  engine;
16
5
  gesture;
17
6
  events;
18
- /** The terminal the gesture tracks its anchor in. */
19
7
  term;
20
8
  constructor(engine) {
21
9
  this.engine = engine;
@@ -23,12 +11,10 @@ export class SelectionGesture {
23
11
  const event = (type) => engine.construct("ghostty_selection_gesture_event_new", engine.enumValue("GhosttySelectionGestureEventType", type));
24
12
  this.events = { press: event("PRESS"), drag: event("DRAG"), release: event("RELEASE") };
25
13
  const f64 = new Uint8Array(8);
26
- new DataView(f64.buffer).setFloat64(0, SCALE, true);
14
+ new DataView(f64.buffer).setFloat64(0, PIXELS_PER_CELL, true);
27
15
  this.set(this.events.press, "REPEAT_DISTANCE", f64);
28
- this.set(this.events.press, "REPEAT_INTERVAL_NS", u64(REPEAT_MS * 1e6));
16
+ this.set(this.events.press, "REPEAT_INTERVAL_NS", u64(MULTI_CLICK_INTERVAL_MS * 1e6));
29
17
  }
30
- /** Presses at `at` (`time` in ms); the selection to install, or
31
- * undefined for none (a single press). */
32
18
  press(term, at, time) {
33
19
  this.follow(term);
34
20
  this.set(this.events.press, "REF", term.gridRef(at));
@@ -36,17 +22,15 @@ export class SelectionGesture {
36
22
  this.set(this.events.press, "TIME_NS", u64(time * 1e6));
37
23
  return this.apply(term, this.events.press);
38
24
  }
39
- /** Drags to `at`; the selection from the press, or undefined when the
40
- * pointer has not left the pressed cell. */
41
25
  drag(term, at) {
42
26
  if (this.term !== term.handle)
43
27
  return undefined;
44
28
  const geometry = new Uint8Array(16);
45
29
  const view = new DataView(geometry.buffer);
46
30
  view.setUint32(0, term.cols, true);
47
- view.setUint32(4, SCALE, true);
31
+ view.setUint32(4, PIXELS_PER_CELL, true);
48
32
  view.setUint32(8, 0, true);
49
- view.setUint32(12, term.rows * SCALE, true);
33
+ view.setUint32(12, term.rows * PIXELS_PER_CELL, true);
50
34
  this.set(this.events.drag, "REF", term.gridRef(at));
51
35
  this.set(this.events.drag, "POSITION", position(at));
52
36
  this.set(this.events.drag, "GEOMETRY", geometry);
@@ -58,10 +42,6 @@ export class SelectionGesture {
58
42
  this.set(this.events.release, "REF", term.gridRef(at));
59
43
  this.apply(term, this.events.release);
60
44
  }
61
- /** Starts afresh, for a terminal freed or about to be: `term` when it
62
- * is still alive, to release the tracked anchor in it, else none. The
63
- * caller says so, since a new terminal may have the handle of a freed
64
- * one. */
65
45
  forget(term) {
66
46
  if (this.term === undefined)
67
47
  return;
@@ -69,7 +49,6 @@ export class SelectionGesture {
69
49
  this.gesture = this.engine.construct("ghostty_selection_gesture_new");
70
50
  this.term = undefined;
71
51
  }
72
- /** A gesture is in one terminal. */
73
52
  follow(term) {
74
53
  if (this.term !== term.handle)
75
54
  this.forget();
@@ -101,11 +80,10 @@ function u64(value) {
101
80
  new DataView(bytes.buffer).setBigUint64(0, BigInt(Math.round(value)), true);
102
81
  return bytes;
103
82
  }
104
- /** A `GhosttySurfacePosition` for `at`, in the gesture's scaled pixels. */
105
83
  function position(at) {
106
84
  const bytes = new Uint8Array(16);
107
85
  const view = new DataView(bytes.buffer);
108
- view.setFloat64(0, at.x * SCALE, true);
109
- view.setFloat64(8, at.y * SCALE, true);
86
+ view.setFloat64(0, at.x * PIXELS_PER_CELL, true);
87
+ view.setFloat64(8, at.y * PIXELS_PER_CELL, true);
110
88
  return bytes;
111
89
  }
@@ -1,26 +1,5 @@
1
+ import { FrameType } from "./messages.ts";
1
2
  export declare const HEADER_LEN = 10;
2
- export declare const FrameType: {
3
- readonly Hello: 1;
4
- readonly Request: 2;
5
- readonly Open: 16;
6
- readonly Input: 17;
7
- readonly Viewport: 18;
8
- readonly Close: 19;
9
- readonly Welcome: 129;
10
- readonly Reply: 130;
11
- readonly Event: 131;
12
- readonly Error: 143;
13
- readonly Attached: 144;
14
- readonly Snapshot: 145;
15
- readonly SnapshotReady: 146;
16
- readonly SnapshotEnd: 147;
17
- readonly Output: 148;
18
- readonly Resized: 149;
19
- readonly Exited: 150;
20
- readonly Gap: 151;
21
- readonly Closed: 153;
22
- };
23
- export type FrameType = (typeof FrameType)[keyof typeof FrameType];
24
3
  export interface Header {
25
4
  type: FrameType;
26
5
  channel: number;
@@ -33,7 +12,7 @@ export declare class FrameError extends Error {
33
12
  }
34
13
  /** Parses a header, ignoring `flags`. */
35
14
  export declare function parseHeader(bytes: Uint8Array, maxFrame: number): Header;
36
- export declare function encodeFrame(type: FrameType, channel: number, payload: Uint8Array): Uint8Array;
15
+ export declare function encodeFrame(type: FrameType, channel: number, payload: Uint8Array): Uint8Array<ArrayBuffer>;
37
16
  export interface Frame {
38
17
  header: Header;
39
18
  payload: Uint8Array;
@@ -1,25 +1,5 @@
1
+ import { FrameType } from "./messages.js";
1
2
  export const HEADER_LEN = 10;
2
- export const FrameType = {
3
- Hello: 0x01,
4
- Request: 0x02,
5
- Open: 0x10,
6
- Input: 0x11,
7
- Viewport: 0x12,
8
- Close: 0x13,
9
- Welcome: 0x81,
10
- Reply: 0x82,
11
- Event: 0x83,
12
- Error: 0x8f,
13
- Attached: 0x90,
14
- Snapshot: 0x91,
15
- SnapshotReady: 0x92,
16
- SnapshotEnd: 0x93,
17
- Output: 0x94,
18
- Resized: 0x95,
19
- Exited: 0x96,
20
- Gap: 0x97,
21
- Closed: 0x99,
22
- };
23
3
  const KNOWN_TYPES = new Set(Object.values(FrameType));
24
4
  function isFrameType(byte) {
25
5
  return KNOWN_TYPES.has(byte);
@@ -1,4 +1,46 @@
1
- export declare const VERSION = 1;
1
+ export declare const VERSION = 2;
2
+ /** Each frame type's header byte. */
3
+ export declare const FrameType: {
4
+ /** Opens the connection: version, client and engine */
5
+ readonly Hello: 1;
6
+ /** A method call, answered by `REPLY` or `ERROR` with its `id` */
7
+ readonly Request: 2;
8
+ /** Attaches the channel to a session */
9
+ readonly Open: 16;
10
+ /** Bytes for the PTY */
11
+ readonly Input: 17;
12
+ /** The attachment's size and profile */
13
+ readonly Viewport: 18;
14
+ /** Detaches the channel */
15
+ readonly Close: 19;
16
+ /** Accepts the connection: the server's engine, incarnation and limits */
17
+ readonly Welcome: 129;
18
+ /** A method's result */
19
+ readonly Reply: 130;
20
+ /** A change, once subscribed */
21
+ readonly Event: 131;
22
+ /** A request's or an attachment's failure, or the connection's end */
23
+ readonly Error: 143;
24
+ /** The attachment's start: snapshot or resume */
25
+ readonly Attached: 144;
26
+ /** Snapshot bytes */
27
+ readonly Snapshot: 145;
28
+ /** The snapshot holds the screen; stream frames may follow */
29
+ readonly SnapshotReady: 146;
30
+ /** The last snapshot byte was sent */
31
+ readonly SnapshotEnd: 147;
32
+ /** `offset u64` and PTY bytes from that stream offset */
33
+ readonly Output: 148;
34
+ /** A size marker in the stream */
35
+ readonly Resized: 149;
36
+ /** The end of the stream */
37
+ readonly Exited: 150;
38
+ /** Bytes were not delivered; a new bootstrap follows */
39
+ readonly Gap: 151;
40
+ /** The attachment ended */
41
+ readonly Closed: 153;
42
+ };
43
+ export type FrameType = (typeof FrameType)[keyof typeof FrameType];
2
44
  /** Each method's params and result. */
3
45
  export interface Methods {
4
46
  /** Starts a session: a program on a new PTY. */
@@ -108,9 +150,7 @@ export interface AckParams {
108
150
  export interface Acked {
109
151
  record_ids: string[];
110
152
  }
111
- export type AttachMode = "snapshot" | "resume";
112
153
  export interface Attached {
113
- mode: AttachMode;
114
154
  /** Cursor offset the attachment continues from. */
115
155
  offset: number;
116
156
  /**
@@ -122,9 +162,9 @@ export interface Attached {
122
162
  rows: number;
123
163
  session: Session;
124
164
  /**
125
- * Required in mode `snapshot`, absent otherwise: the total length of the
126
- * snapshot that follows (the sum of the `SNAPSHOT` payloads), so a client can
127
- * size its buffer.
165
+ * Present when a snapshot follows, absent when the attachment resumes: the
166
+ * total length of the snapshot (the sum of the `SNAPSHOT` payloads, possibly
167
+ * 0), so a client can size its buffer.
128
168
  */
129
169
  snapshot_bytes?: number;
130
170
  }
@@ -459,13 +499,13 @@ export interface Gap {
459
499
  to: number;
460
500
  }
461
501
  export interface Hello {
462
- /** Always 1. */
502
+ /** Always 2. */
463
503
  version: number;
464
504
  /** Informational. */
465
505
  client: ClientPeer;
466
506
  /** Engine id; absent for control-only clients. */
467
507
  engine?: string;
468
- /** Capability ids; version 1 defines none. */
508
+ /** Capability ids; version 2 defines none. */
469
509
  capabilities?: string[];
470
510
  }
471
511
  export interface LabelParams {
@@ -876,7 +916,7 @@ export interface Waited {
876
916
  record?: StatusRecord;
877
917
  }
878
918
  export interface Welcome {
879
- /** Always 1. */
919
+ /** Always 2. */
880
920
  version: number;
881
921
  server: Peer;
882
922
  /** Engine id of the server. */
@@ -1,2 +1,43 @@
1
1
  // Generated from the catalog by `cargo xtask protocol`; do not edit.
2
- export const VERSION = 1;
2
+ export const VERSION = 2;
3
+ /** Each frame type's header byte. */
4
+ export const FrameType = {
5
+ /** Opens the connection: version, client and engine */
6
+ Hello: 0x01,
7
+ /** A method call, answered by `REPLY` or `ERROR` with its `id` */
8
+ Request: 0x02,
9
+ /** Attaches the channel to a session */
10
+ Open: 0x10,
11
+ /** Bytes for the PTY */
12
+ Input: 0x11,
13
+ /** The attachment's size and profile */
14
+ Viewport: 0x12,
15
+ /** Detaches the channel */
16
+ Close: 0x13,
17
+ /** Accepts the connection: the server's engine, incarnation and limits */
18
+ Welcome: 0x81,
19
+ /** A method's result */
20
+ Reply: 0x82,
21
+ /** A change, once subscribed */
22
+ Event: 0x83,
23
+ /** A request's or an attachment's failure, or the connection's end */
24
+ Error: 0x8f,
25
+ /** The attachment's start: snapshot or resume */
26
+ Attached: 0x90,
27
+ /** Snapshot bytes */
28
+ Snapshot: 0x91,
29
+ /** The snapshot holds the screen; stream frames may follow */
30
+ SnapshotReady: 0x92,
31
+ /** The last snapshot byte was sent */
32
+ SnapshotEnd: 0x93,
33
+ /** `offset u64` and PTY bytes from that stream offset */
34
+ Output: 0x94,
35
+ /** A size marker in the stream */
36
+ Resized: 0x95,
37
+ /** The end of the stream */
38
+ Exited: 0x96,
39
+ /** Bytes were not delivered; a new bootstrap follows */
40
+ Gap: 0x97,
41
+ /** The attachment ended */
42
+ Closed: 0x99,
43
+ };
@@ -35,15 +35,14 @@ export declare class CanvasRenderer {
35
35
  private readonly palette;
36
36
  private rows;
37
37
  private cursorRow;
38
- /** The scrollback mark drawn last, in pixels from the top. */
39
- private mark;
38
+ private lastScrollbackMark;
40
39
  private cols;
41
40
  private background;
42
41
  private foreground;
43
42
  constructor(ctx: Context2D, metrics: Metrics, palette: Palette);
44
43
  draw(frame: Frame<Cells>): void;
45
- /** The scrollback mark for `frame`: the viewport's share of the history
46
- * at the right edge, while the view is scrolled back. */
44
+ private eraseLastMark;
45
+ private redrawVacatedCursorRow;
47
46
  private markOf;
48
47
  private drawRow;
49
48
  private font;