@gjermundgaraba/clankermux 0.7.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.
- package/dist/client/attachment.d.ts +0 -2
- package/dist/client/attachment.js +0 -2
- package/dist/client/osc52.js +0 -11
- package/dist/engine/decoder.d.ts +4 -0
- package/dist/engine/decoder.js +32 -1
- package/dist/engine/index.d.ts +2 -0
- package/dist/engine/index.js +27 -36
- package/dist/engine/keys.js +4 -2
- package/dist/engine/pin.d.ts +1 -2
- package/dist/engine/pin.js +1 -3
- package/dist/engine/render.d.ts +1 -0
- package/dist/engine/render.js +11 -22
- package/dist/proto/messages.js +0 -1
- package/ghostty-vt.wasm +0 -0
- package/package.json +2 -2
|
@@ -32,8 +32,6 @@ export declare class Attachment {
|
|
|
32
32
|
private continuation;
|
|
33
33
|
session: Session | undefined;
|
|
34
34
|
constructor(engine: Engine);
|
|
35
|
-
/** Readies an `OPEN` on the connection `welcome` began: the cursor to
|
|
36
|
-
* resume from, when there is one to keep. */
|
|
37
35
|
open(welcome: Welcome): Resume | undefined;
|
|
38
36
|
resume(): Resume | undefined;
|
|
39
37
|
ended(): boolean;
|
|
@@ -17,8 +17,6 @@ export class Attachment {
|
|
|
17
17
|
constructor(engine) {
|
|
18
18
|
this.engine = engine;
|
|
19
19
|
}
|
|
20
|
-
/** Readies an `OPEN` on the connection `welcome` began: the cursor to
|
|
21
|
-
* resume from, when there is one to keep. */
|
|
22
20
|
open(welcome) {
|
|
23
21
|
this.incarnation = welcome.incarnation;
|
|
24
22
|
this.continuation = welcome.limits.continuation;
|
package/dist/client/osc52.js
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Finds OSC 52 clipboard writes in output bytes, across chunk boundaries,
|
|
3
|
-
* ending them as the engine's parser does: BEL or any byte after ESC
|
|
4
|
-
* dispatches the sequence (ESC `\` is the string terminator; ESC `]`
|
|
5
|
-
* begins the next one), CAN and SUB abandon it. The engine raises the
|
|
6
|
-
* clipboard effect through a callback, which from wasm would need a JS
|
|
7
|
-
* function in the module's function table (a generated wrapper per
|
|
8
|
-
* signature); the scan is less machinery. OSC 1337 and 5522 clipboard
|
|
9
|
-
* forms are not scanned for, and an OSC 52 inside another string (a DCS
|
|
10
|
-
* passthrough) is taken as one, where the engine would not.
|
|
11
|
-
*/
|
|
12
1
|
const ESC = 0x1b;
|
|
13
2
|
const BEL = 0x07;
|
|
14
3
|
const CAN = 0x18;
|
package/dist/engine/decoder.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { type Engine, Terminal } from "./index.ts";
|
|
2
2
|
export declare function readyEnd(buf: Uint8Array, len?: number): number | undefined;
|
|
3
|
+
/** Where the step one decoder `next` call takes ends, from the first record
|
|
4
|
+
* it has not returned: just past the next PAGE or FINISH. After a PAGE the
|
|
5
|
+
* decoder also reads the next known record header, which must be buffered
|
|
6
|
+
* too and starts the next step. */
|
|
3
7
|
export declare function stepEnd(buf: Uint8Array, pos: number, len?: number): number | undefined;
|
|
4
8
|
export declare class Decoder {
|
|
5
9
|
readonly engine: Engine;
|
package/dist/engine/decoder.js
CHANGED
|
@@ -9,6 +9,9 @@ const RECORD_HEADER_LEN = TAG_LEN + PAYLOAD_LENGTH_LEN + CRC32C_LEN;
|
|
|
9
9
|
const TAG_PAGE = 3;
|
|
10
10
|
const TAG_READY = 5;
|
|
11
11
|
const TAG_FINISH = 6;
|
|
12
|
+
/** The record tags the wasm build decodes. It has no Kitty graphics, so it
|
|
13
|
+
* skips Kitty records (tags 8 to 10) whole, as it does any unknown record. */
|
|
14
|
+
const LAST_KNOWN_TAG = 7;
|
|
12
15
|
function recordAt(buf, len, pos) {
|
|
13
16
|
if (pos + RECORD_HEADER_LEN > len)
|
|
14
17
|
return undefined;
|
|
@@ -31,8 +34,36 @@ function endOfStep(buf, len, pos, last) {
|
|
|
31
34
|
export function readyEnd(buf, len = buf.length) {
|
|
32
35
|
return endOfStep(buf, len, ENVELOPE_LEN, (tag) => tag === TAG_READY);
|
|
33
36
|
}
|
|
37
|
+
/** Where the step one decoder `next` call takes ends, from the first record
|
|
38
|
+
* it has not returned: just past the next PAGE or FINISH. After a PAGE the
|
|
39
|
+
* decoder also reads the next known record header, which must be buffered
|
|
40
|
+
* too and starts the next step. */
|
|
34
41
|
export function stepEnd(buf, pos, len = buf.length) {
|
|
35
|
-
|
|
42
|
+
for (;;) {
|
|
43
|
+
const record = recordAt(buf, len, pos);
|
|
44
|
+
if (!record)
|
|
45
|
+
return undefined;
|
|
46
|
+
const [tag, end] = record;
|
|
47
|
+
if (tag === TAG_FINISH)
|
|
48
|
+
return end;
|
|
49
|
+
if (tag === TAG_PAGE)
|
|
50
|
+
return afterPage(buf, len, end);
|
|
51
|
+
pos = end;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function afterPage(buf, len, pos) {
|
|
55
|
+
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
56
|
+
for (;;) {
|
|
57
|
+
if (pos + RECORD_HEADER_LEN > len)
|
|
58
|
+
return undefined;
|
|
59
|
+
const tag = view.getUint16(pos, true);
|
|
60
|
+
if (tag >= 1 && tag <= LAST_KNOWN_TAG)
|
|
61
|
+
return pos;
|
|
62
|
+
const record = recordAt(buf, len, pos);
|
|
63
|
+
if (!record)
|
|
64
|
+
return undefined;
|
|
65
|
+
pos = record[1];
|
|
66
|
+
}
|
|
36
67
|
}
|
|
37
68
|
export class Decoder {
|
|
38
69
|
engine;
|
package/dist/engine/index.d.ts
CHANGED
|
@@ -98,5 +98,7 @@ export declare class Terminal {
|
|
|
98
98
|
setColor(kind: "foreground" | "background" | "cursor", color: number): void;
|
|
99
99
|
snapshot(): Uint8Array;
|
|
100
100
|
formatPlain(): string;
|
|
101
|
+
/** Plain text from a formatter, after `configure` sets its options. */
|
|
102
|
+
private format;
|
|
101
103
|
free(): void;
|
|
102
104
|
}
|
package/dist/engine/index.js
CHANGED
|
@@ -361,7 +361,6 @@ export class Terminal {
|
|
|
361
361
|
const coordinate = ptr + e.offsetOf("GhosttyPoint", "value");
|
|
362
362
|
e.view.setUint16(coordinate + e.offsetOf("GhosttyPointCoordinate", "x"), x, true);
|
|
363
363
|
e.view.setUint32(coordinate + e.offsetOf("GhosttyPointCoordinate", "y"), y, true);
|
|
364
|
-
e.view.setUint32(ptr + point, ref, true);
|
|
365
364
|
// The point is passed by value, which the wasm ABI passes by address.
|
|
366
365
|
e.check("ghostty_terminal_grid_ref", this.handle, ptr, ptr + point);
|
|
367
366
|
return e.memory.slice(ptr + point, ptr + point + ref);
|
|
@@ -376,34 +375,20 @@ export class Terminal {
|
|
|
376
375
|
}
|
|
377
376
|
selectionText() {
|
|
378
377
|
const e = this.engine;
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
unwrap: 1,
|
|
382
|
-
trim: 1,
|
|
383
|
-
});
|
|
384
|
-
return e.withBytes(options, (optionsPtr) => e.scratch(8, (out) => {
|
|
385
|
-
e.view.setUint32(out, 0, true);
|
|
386
|
-
e.view.setUint32(out + 4, 0, true);
|
|
387
|
-
// The options are passed by value, which the wasm ABI passes by address.
|
|
388
|
-
if (!e.present("ghostty_terminal_selection_format_alloc", this.handle, 0, optionsPtr, out, out + 4))
|
|
378
|
+
return e.scratch(e.sizeOf("GhosttySelection"), (selection) => {
|
|
379
|
+
if (!e.present("ghostty_terminal_get", this.handle, e.enumValue("GhosttyTerminalData", "SELECTION"), selection)) {
|
|
389
380
|
return undefined;
|
|
390
|
-
const ptr = e.view.getUint32(out, true);
|
|
391
|
-
const len = e.view.getUint32(out + 4, true);
|
|
392
|
-
try {
|
|
393
|
-
return new TextDecoder().decode(e.memory.slice(ptr, ptr + len));
|
|
394
381
|
}
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
382
|
+
return this.format((set) => {
|
|
383
|
+
set("SELECTION", selection);
|
|
384
|
+
set("UNWRAP", new Uint8Array([1]));
|
|
385
|
+
});
|
|
386
|
+
});
|
|
399
387
|
}
|
|
400
388
|
get selected() {
|
|
401
389
|
const e = this.engine;
|
|
402
390
|
const size = e.sizeOf("GhosttySelection");
|
|
403
|
-
return e.scratch(size, (out) =>
|
|
404
|
-
e.view.setUint32(out, size, true);
|
|
405
|
-
return e.present("ghostty_terminal_get", this.handle, e.enumValue("GhosttyTerminalData", "SELECTION"), out);
|
|
406
|
-
});
|
|
391
|
+
return e.scratch(size, (out) => e.present("ghostty_terminal_get", this.handle, e.enumValue("GhosttyTerminalData", "SELECTION"), out));
|
|
407
392
|
}
|
|
408
393
|
mode(number) {
|
|
409
394
|
const config = this.engine.pack("GhosttyTerminalModeConfig", { mode: number });
|
|
@@ -424,19 +409,25 @@ export class Terminal {
|
|
|
424
409
|
return this.engine.allocated((ptr, len) => this.engine.check("ghostty_snapshot_encode_alloc", this.handle, 0, ptr, len));
|
|
425
410
|
}
|
|
426
411
|
formatPlain() {
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
412
|
+
return this.format((set) => set("TRIM", new Uint8Array([0])));
|
|
413
|
+
}
|
|
414
|
+
/** Plain text from a formatter, after `configure` sets its options. */
|
|
415
|
+
format(configure) {
|
|
416
|
+
const e = this.engine;
|
|
417
|
+
const formatter = e.construct("ghostty_formatter_terminal_new", this.handle);
|
|
418
|
+
try {
|
|
419
|
+
configure((option, value) => {
|
|
420
|
+
const key = e.enumValue("GhosttyFormatterOption", option);
|
|
421
|
+
if (typeof value === "number")
|
|
422
|
+
e.check("ghostty_formatter_set", formatter, key, value);
|
|
423
|
+
else
|
|
424
|
+
e.withBytes(value, (ptr) => e.check("ghostty_formatter_set", formatter, key, ptr));
|
|
425
|
+
});
|
|
426
|
+
return new TextDecoder().decode(e.allocated((ptr, len) => e.check("ghostty_formatter_format_alloc", formatter, 0, ptr, len)));
|
|
427
|
+
}
|
|
428
|
+
finally {
|
|
429
|
+
e.call("ghostty_formatter_free", formatter);
|
|
430
|
+
}
|
|
440
431
|
}
|
|
441
432
|
free() {
|
|
442
433
|
this.engine.call("ghostty_terminal_free", this.handle);
|
package/dist/engine/keys.js
CHANGED
|
@@ -37,7 +37,7 @@ export class KeyEncoder {
|
|
|
37
37
|
}
|
|
38
38
|
encode(term, input) {
|
|
39
39
|
const e = this.engine;
|
|
40
|
-
e.
|
|
40
|
+
e.check("ghostty_key_encoder_set_from_terminal", this.encoder, term.handle);
|
|
41
41
|
const name = keyName(input.code);
|
|
42
42
|
const key = e.hasEnumValue("GhosttyKey", name) ? e.enumValue("GhosttyKey", name) : this.unidentified;
|
|
43
43
|
const composed = input.altComposed === true;
|
|
@@ -53,7 +53,9 @@ export class KeyEncoder {
|
|
|
53
53
|
e.call("ghostty_key_event_set_composing", this.event, input.composing ? 1 : 0);
|
|
54
54
|
const utf8 = new TextEncoder().encode(text);
|
|
55
55
|
return e.withBytes(utf8, (textPtr) => {
|
|
56
|
-
e.
|
|
56
|
+
const string = e.pack("GhosttyString", { ptr: textPtr, len: utf8.length });
|
|
57
|
+
// The string is passed by value, which the wasm ABI passes by address.
|
|
58
|
+
e.withBytes(string, (stringPtr) => e.check("ghostty_key_event_set_utf8", this.event, stringPtr));
|
|
57
59
|
const base = input.unshifted ?? (text ? text.toLowerCase() : "");
|
|
58
60
|
e.call("ghostty_key_event_set_unshifted_codepoint", this.event, base ? base.codePointAt(0) : 0);
|
|
59
61
|
return e.growing("ghostty_key_encoder_encode", 64, (buf, cap, len) => e.call("ghostty_key_encoder_encode", this.encoder, this.event, buf, cap, len));
|
package/dist/engine/pin.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const ENGINE = "ghostty-vt@1.3.2-main+d2865b8";
|
|
1
|
+
export declare const ENGINE = "ghostty-vt@1.0.1";
|
package/dist/engine/pin.js
CHANGED
package/dist/engine/render.d.ts
CHANGED
package/dist/engine/render.js
CHANGED
|
@@ -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.
|
|
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
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
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.
|
|
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);
|
package/dist/proto/messages.js
CHANGED
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.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/ws": "^8.18.0",
|
|
43
43
|
"ajv": "^8.20.0",
|
|
44
|
-
"ws": "^8.
|
|
44
|
+
"ws": "^8.23.0"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"typecheck": "tsc -p tsconfig.json && tsc -p tsconfig.worker.json",
|