@gjermundgaraba/clankermux 0.6.0 → 0.8.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.
@@ -13,6 +13,7 @@ export const FLAG = {
13
13
  };
14
14
  export const NO_COLOR = -1;
15
15
  const CURSOR_STYLES = ["bar", "block", "underline", "block_hollow"];
16
+ const STYLE_FLAGS = ["bold", "italic", "faint", "blink", "inverse", "invisible", "strikethrough", "overline"];
16
17
  export const PACKED_STRIDE = 4;
17
18
  export const PACKED_TEXT = 0;
18
19
  export const PACKED_FG = 1;
@@ -44,6 +45,7 @@ export class RenderState {
44
45
  tags;
45
46
  wide;
46
47
  cell;
48
+ style;
47
49
  cursorStyles;
48
50
  constructor(engine) {
49
51
  this.engine = engine;
@@ -76,7 +78,8 @@ export class RenderState {
76
78
  codepoint: engine.bits("GhosttyCell", "content", "CODEPOINT", "codepoint"),
77
79
  wide: engine.bits("GhosttyCell", "wide"),
78
80
  };
79
- this.cursorStyles = new Map(CURSOR_STYLES.map((style) => [engine.enumValue("GhosttyRenderStateCursorVisualStyle", style.toUpperCase()), style]));
81
+ this.style = Object.fromEntries([...STYLE_FLAGS, "underline"].map((key) => [key, engine.bits("GhosttyStyleFlags", key)]));
82
+ this.cursorStyles = new Map(CURSOR_STYLES.map((style) => [engine.enumValue("GhosttyCursorStyle", style.toUpperCase()), style]));
80
83
  }
81
84
  update(term) {
82
85
  return this.frame(term, (cols) => {
@@ -179,7 +182,6 @@ export class RenderState {
179
182
  e.view.setUint32(out, this.cells, true);
180
183
  e.check("ghostty_render_state_row_get", this.iterator, this.keys.row["CELLS"], out);
181
184
  });
182
- const styleSize = e.sizeOf("GhosttyStyle");
183
185
  let count = 0;
184
186
  const utf8Cap = 64;
185
187
  const layout = scratchLayout(e, ["GhosttyCell", "GhosttyColorRgb", "GhosttyStyle", "GhosttyBuffer"]);
@@ -208,26 +210,13 @@ export class RenderState {
208
210
  const bg = this.color(this.keys.cell["BG_COLOR"], color);
209
211
  e.check("ghostty_render_state_row_cells_get", this.cells, this.keys.cell["HAS_STYLING"], raw);
210
212
  if (e.memory[raw]) {
211
- e.view.setUint32(style, styleSize, true);
212
213
  e.check("ghostty_render_state_row_cells_get", this.cells, this.keys.cell["STYLE"], style);
213
- const f = (key) => e.field("GhosttyStyle", style, key) !== 0;
214
- if (f("bold"))
215
- flags |= FLAG.BOLD;
216
- if (f("italic"))
217
- flags |= FLAG.ITALIC;
218
- if (f("faint"))
219
- flags |= FLAG.FAINT;
220
- if (f("blink"))
221
- flags |= FLAG.BLINK;
222
- if (f("inverse"))
223
- flags |= FLAG.INVERSE;
224
- if (f("invisible"))
225
- flags |= FLAG.INVISIBLE;
226
- if (f("strikethrough"))
227
- flags |= FLAG.STRIKETHROUGH;
228
- if (f("overline"))
229
- flags |= FLAG.OVERLINE;
230
- underline = e.field("GhosttyStyle", style, "underline");
214
+ const styleFlags = style + e.offsetOf("GhosttyStyle", "flags");
215
+ for (const key of STYLE_FLAGS) {
216
+ if (e.readBits(styleFlags, this.style[key]))
217
+ flags |= FLAG[key.toUpperCase()];
218
+ }
219
+ underline = e.readBits(styleFlags, this.style.underline);
231
220
  }
232
221
  write(codepoint, text, fg, bg, flags, underline);
233
222
  count++;
@@ -237,7 +226,7 @@ export class RenderState {
237
226
  color(key, out) {
238
227
  const e = this.engine;
239
228
  const code = e.call("ghostty_render_state_row_cells_get", this.cells, key, out);
240
- if (code === e.result.INVALID_VALUE)
229
+ if (code === e.result.NO_VALUE)
241
230
  return NO_COLOR;
242
231
  if (code !== e.result.SUCCESS)
243
232
  throw new EngineError("ghostty_render_state_row_cells_get", code);
@@ -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,42 @@
1
- // Generated from the catalog by `cargo xtask protocol`; do not edit.
2
- export const VERSION = 1;
1
+ export const VERSION = 2;
2
+ /** Each frame type's header byte. */
3
+ export const FrameType = {
4
+ /** Opens the connection: version, client and engine */
5
+ Hello: 0x01,
6
+ /** A method call, answered by `REPLY` or `ERROR` with its `id` */
7
+ Request: 0x02,
8
+ /** Attaches the channel to a session */
9
+ Open: 0x10,
10
+ /** Bytes for the PTY */
11
+ Input: 0x11,
12
+ /** The attachment's size and profile */
13
+ Viewport: 0x12,
14
+ /** Detaches the channel */
15
+ Close: 0x13,
16
+ /** Accepts the connection: the server's engine, incarnation and limits */
17
+ Welcome: 0x81,
18
+ /** A method's result */
19
+ Reply: 0x82,
20
+ /** A change, once subscribed */
21
+ Event: 0x83,
22
+ /** A request's or an attachment's failure, or the connection's end */
23
+ Error: 0x8f,
24
+ /** The attachment's start: snapshot or resume */
25
+ Attached: 0x90,
26
+ /** Snapshot bytes */
27
+ Snapshot: 0x91,
28
+ /** The snapshot holds the screen; stream frames may follow */
29
+ SnapshotReady: 0x92,
30
+ /** The last snapshot byte was sent */
31
+ SnapshotEnd: 0x93,
32
+ /** `offset u64` and PTY bytes from that stream offset */
33
+ Output: 0x94,
34
+ /** A size marker in the stream */
35
+ Resized: 0x95,
36
+ /** The end of the stream */
37
+ Exited: 0x96,
38
+ /** Bytes were not delivered; a new bootstrap follows */
39
+ Gap: 0x97,
40
+ /** The attachment ended */
41
+ Closed: 0x99,
42
+ };
package/ghostty-vt.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjermundgaraba/clankermux",
3
- "version": "0.6.0",
3
+ "version": "0.8.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -35,10 +35,13 @@
35
35
  "publishConfig": {
36
36
  "access": "public"
37
37
  },
38
+ "dependencies": {
39
+ "xstate": "6.0.0-alpha.71"
40
+ },
38
41
  "devDependencies": {
39
42
  "@types/ws": "^8.18.0",
40
43
  "ajv": "^8.20.0",
41
- "ws": "^8.18.0"
44
+ "ws": "^8.23.0"
42
45
  },
43
46
  "scripts": {
44
47
  "typecheck": "tsc -p tsconfig.json && tsc -p tsconfig.worker.json",