@vibecook/ghosttea-frame 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.
- package/LICENSE +21 -0
- package/README.md +7 -0
- package/dist/index.d.ts +111 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +243 -0
- package/dist/index.js.map +1 -0
- package/package.json +52 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 James Yong
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# @vibecook/ghosttea-frame
|
|
2
|
+
|
|
3
|
+
Binary frame decoder and shared renderer types for Ghosttea. Most applications
|
|
4
|
+
should consume the higher-level Ghosttea renderer integration instead of this
|
|
5
|
+
low-level package directly.
|
|
6
|
+
|
|
7
|
+
Ghosttea is developed at <https://github.com/jamesyong-42/ghosttea>.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
export declare const FRAME_MAGIC = 826692180;
|
|
2
|
+
export declare const FRAME_PROTOCOL_VERSION = 1;
|
|
3
|
+
export declare const FRAME_HEADER_BYTES = 64;
|
|
4
|
+
export declare const SECTION_HEADER_BYTES = 16;
|
|
5
|
+
export declare const MAX_FRAME_BYTES: number;
|
|
6
|
+
export declare const FrameFlag: {
|
|
7
|
+
readonly FullSnapshot: number;
|
|
8
|
+
readonly MouseTracking: number;
|
|
9
|
+
};
|
|
10
|
+
export declare enum SectionKind {
|
|
11
|
+
GlyphDefinitions = 1,
|
|
12
|
+
StyleDefinitions = 2,
|
|
13
|
+
RowReplacements = 3,
|
|
14
|
+
CursorState = 4,
|
|
15
|
+
SelectionSpans = 5,
|
|
16
|
+
ImageDefinitions = 6,
|
|
17
|
+
ImagePlacements = 7,
|
|
18
|
+
ScrollbarState = 8,
|
|
19
|
+
ViewportMetadata = 9,
|
|
20
|
+
AccessibilityText = 10,
|
|
21
|
+
ClipboardWrite = 11
|
|
22
|
+
}
|
|
23
|
+
export interface FrameSection {
|
|
24
|
+
kind: SectionKind;
|
|
25
|
+
flags: number;
|
|
26
|
+
itemCount: number;
|
|
27
|
+
bytes: Uint8Array;
|
|
28
|
+
}
|
|
29
|
+
export interface TerminalFrame {
|
|
30
|
+
protocolVersion: number;
|
|
31
|
+
flags: number;
|
|
32
|
+
sessionHandle: bigint;
|
|
33
|
+
viewHandle: bigint;
|
|
34
|
+
sessionEpoch: bigint;
|
|
35
|
+
layoutEpoch: bigint;
|
|
36
|
+
frameSequence: bigint;
|
|
37
|
+
terminalRevision: bigint;
|
|
38
|
+
cols: number;
|
|
39
|
+
rows: number;
|
|
40
|
+
sections: FrameSection[];
|
|
41
|
+
}
|
|
42
|
+
export interface TextRow {
|
|
43
|
+
row: number;
|
|
44
|
+
text: string;
|
|
45
|
+
}
|
|
46
|
+
export interface RowReplacement extends TextRow {
|
|
47
|
+
revision: bigint;
|
|
48
|
+
glyphs: GlyphInstance[];
|
|
49
|
+
styles: StyleRun[];
|
|
50
|
+
}
|
|
51
|
+
export declare enum GlyphFormat {
|
|
52
|
+
Alpha8 = 0,
|
|
53
|
+
Rgba8Premultiplied = 1
|
|
54
|
+
}
|
|
55
|
+
export interface GlyphDefinition {
|
|
56
|
+
id: number;
|
|
57
|
+
width: number;
|
|
58
|
+
height: number;
|
|
59
|
+
bearingX: number;
|
|
60
|
+
bearingY: number;
|
|
61
|
+
format: GlyphFormat;
|
|
62
|
+
pixels: Uint8Array;
|
|
63
|
+
}
|
|
64
|
+
export interface GlyphInstance {
|
|
65
|
+
glyphId: number;
|
|
66
|
+
styleId: number;
|
|
67
|
+
x: number;
|
|
68
|
+
y: number;
|
|
69
|
+
width: number;
|
|
70
|
+
height: number;
|
|
71
|
+
cellStart: number;
|
|
72
|
+
cellSpan: number;
|
|
73
|
+
}
|
|
74
|
+
export interface StyleDefinition {
|
|
75
|
+
id: number;
|
|
76
|
+
bold: boolean;
|
|
77
|
+
italic: boolean;
|
|
78
|
+
faint: boolean;
|
|
79
|
+
inverse: boolean;
|
|
80
|
+
invisible: boolean;
|
|
81
|
+
strikethrough: boolean;
|
|
82
|
+
underline: boolean;
|
|
83
|
+
foreground?: readonly [number, number, number];
|
|
84
|
+
background?: readonly [number, number, number];
|
|
85
|
+
}
|
|
86
|
+
export interface StyleRun {
|
|
87
|
+
styleId: number;
|
|
88
|
+
cellStart: number;
|
|
89
|
+
cellSpan: number;
|
|
90
|
+
}
|
|
91
|
+
export interface CursorState {
|
|
92
|
+
x: number;
|
|
93
|
+
y: number;
|
|
94
|
+
visible: boolean;
|
|
95
|
+
style: CursorStyle;
|
|
96
|
+
blinking: boolean;
|
|
97
|
+
}
|
|
98
|
+
export declare enum CursorStyle {
|
|
99
|
+
Bar = 0,
|
|
100
|
+
Block = 1,
|
|
101
|
+
Underline = 2,
|
|
102
|
+
HollowBlock = 3
|
|
103
|
+
}
|
|
104
|
+
export declare function decodeFrame(buffer: ArrayBuffer): TerminalFrame;
|
|
105
|
+
export declare function decodeAccessibilityRows(section: FrameSection): TextRow[];
|
|
106
|
+
export declare function decodeRowReplacements(section: FrameSection): RowReplacement[];
|
|
107
|
+
export declare function decodeGlyphDefinitions(section: FrameSection): GlyphDefinition[];
|
|
108
|
+
export declare function decodeStyleDefinitions(section: FrameSection): StyleDefinition[];
|
|
109
|
+
export declare function decodeCursorState(section: FrameSection): CursorState;
|
|
110
|
+
export declare function decodeClipboardWrite(section: FrameSection): string;
|
|
111
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,YAAa,CAAC;AACtC,eAAO,MAAM,sBAAsB,IAAI,CAAC;AACxC,eAAO,MAAM,kBAAkB,KAAK,CAAC;AACrC,eAAO,MAAM,oBAAoB,KAAK,CAAC;AACvC,eAAO,MAAM,eAAe,QAAmB,CAAC;AAChD,eAAO,MAAM,SAAS;aACpB,YAAY;aACZ,aAAa;CACL,CAAC;AAEX,oBAAY,WAAW;IACrB,gBAAgB,IAAI;IACpB,gBAAgB,IAAI;IACpB,eAAe,IAAI;IACnB,WAAW,IAAI;IACf,cAAc,IAAI;IAClB,gBAAgB,IAAI;IACpB,eAAe,IAAI;IACnB,cAAc,IAAI;IAClB,gBAAgB,IAAI;IACpB,iBAAiB,KAAK;IACtB,cAAc,KAAK;CACpB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,WAAW,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,KAA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OAAO,EAAE,YAAY,GAAG,MAAM,CAQlE"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
export const FRAME_MAGIC = 0x31465254;
|
|
2
|
+
export const FRAME_PROTOCOL_VERSION = 1;
|
|
3
|
+
export const FRAME_HEADER_BYTES = 64;
|
|
4
|
+
export const SECTION_HEADER_BYTES = 16;
|
|
5
|
+
export const MAX_FRAME_BYTES = 16 * 1024 * 1024;
|
|
6
|
+
export const FrameFlag = {
|
|
7
|
+
FullSnapshot: 1 << 0,
|
|
8
|
+
MouseTracking: 1 << 1,
|
|
9
|
+
};
|
|
10
|
+
export var SectionKind;
|
|
11
|
+
(function (SectionKind) {
|
|
12
|
+
SectionKind[SectionKind["GlyphDefinitions"] = 1] = "GlyphDefinitions";
|
|
13
|
+
SectionKind[SectionKind["StyleDefinitions"] = 2] = "StyleDefinitions";
|
|
14
|
+
SectionKind[SectionKind["RowReplacements"] = 3] = "RowReplacements";
|
|
15
|
+
SectionKind[SectionKind["CursorState"] = 4] = "CursorState";
|
|
16
|
+
SectionKind[SectionKind["SelectionSpans"] = 5] = "SelectionSpans";
|
|
17
|
+
SectionKind[SectionKind["ImageDefinitions"] = 6] = "ImageDefinitions";
|
|
18
|
+
SectionKind[SectionKind["ImagePlacements"] = 7] = "ImagePlacements";
|
|
19
|
+
SectionKind[SectionKind["ScrollbarState"] = 8] = "ScrollbarState";
|
|
20
|
+
SectionKind[SectionKind["ViewportMetadata"] = 9] = "ViewportMetadata";
|
|
21
|
+
SectionKind[SectionKind["AccessibilityText"] = 10] = "AccessibilityText";
|
|
22
|
+
SectionKind[SectionKind["ClipboardWrite"] = 11] = "ClipboardWrite";
|
|
23
|
+
})(SectionKind || (SectionKind = {}));
|
|
24
|
+
export var GlyphFormat;
|
|
25
|
+
(function (GlyphFormat) {
|
|
26
|
+
GlyphFormat[GlyphFormat["Alpha8"] = 0] = "Alpha8";
|
|
27
|
+
GlyphFormat[GlyphFormat["Rgba8Premultiplied"] = 1] = "Rgba8Premultiplied";
|
|
28
|
+
})(GlyphFormat || (GlyphFormat = {}));
|
|
29
|
+
export var CursorStyle;
|
|
30
|
+
(function (CursorStyle) {
|
|
31
|
+
CursorStyle[CursorStyle["Bar"] = 0] = "Bar";
|
|
32
|
+
CursorStyle[CursorStyle["Block"] = 1] = "Block";
|
|
33
|
+
CursorStyle[CursorStyle["Underline"] = 2] = "Underline";
|
|
34
|
+
CursorStyle[CursorStyle["HollowBlock"] = 3] = "HollowBlock";
|
|
35
|
+
})(CursorStyle || (CursorStyle = {}));
|
|
36
|
+
function assertRange(condition, message) {
|
|
37
|
+
if (!condition)
|
|
38
|
+
throw new RangeError(`Invalid terminal frame: ${message}`);
|
|
39
|
+
}
|
|
40
|
+
export function decodeFrame(buffer) {
|
|
41
|
+
assertRange(buffer.byteLength >= FRAME_HEADER_BYTES, "truncated header");
|
|
42
|
+
assertRange(buffer.byteLength <= MAX_FRAME_BYTES, "packet exceeds limit");
|
|
43
|
+
const view = new DataView(buffer);
|
|
44
|
+
assertRange(view.getUint32(0, true) === FRAME_MAGIC, "bad magic");
|
|
45
|
+
assertRange(view.getUint16(4, true) === FRAME_PROTOCOL_VERSION, "unsupported protocol version");
|
|
46
|
+
const sectionCount = view.getUint16(60, true);
|
|
47
|
+
const tableEnd = FRAME_HEADER_BYTES + sectionCount * SECTION_HEADER_BYTES;
|
|
48
|
+
assertRange(tableEnd <= buffer.byteLength, "truncated section table");
|
|
49
|
+
const sections = [];
|
|
50
|
+
for (let index = 0; index < sectionCount; index += 1) {
|
|
51
|
+
const base = FRAME_HEADER_BYTES + index * SECTION_HEADER_BYTES;
|
|
52
|
+
const kind = view.getUint16(base, true);
|
|
53
|
+
const flags = view.getUint16(base + 2, true);
|
|
54
|
+
const offset = view.getUint32(base + 4, true);
|
|
55
|
+
const length = view.getUint32(base + 8, true);
|
|
56
|
+
const itemCount = view.getUint32(base + 12, true);
|
|
57
|
+
const end = offset + length;
|
|
58
|
+
assertRange(end >= offset && offset >= tableEnd && end <= buffer.byteLength, "section out of bounds");
|
|
59
|
+
sections.push({ kind, flags, itemCount, bytes: new Uint8Array(buffer, offset, length) });
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
protocolVersion: view.getUint16(4, true),
|
|
63
|
+
flags: view.getUint16(6, true),
|
|
64
|
+
sessionHandle: view.getBigUint64(8, true),
|
|
65
|
+
viewHandle: view.getBigUint64(16, true),
|
|
66
|
+
sessionEpoch: view.getBigUint64(24, true),
|
|
67
|
+
layoutEpoch: view.getBigUint64(32, true),
|
|
68
|
+
frameSequence: view.getBigUint64(40, true),
|
|
69
|
+
terminalRevision: view.getBigUint64(48, true),
|
|
70
|
+
cols: view.getUint16(56, true),
|
|
71
|
+
rows: view.getUint16(58, true),
|
|
72
|
+
sections,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
export function decodeAccessibilityRows(section) {
|
|
76
|
+
const view = new DataView(section.bytes.buffer, section.bytes.byteOffset, section.bytes.byteLength);
|
|
77
|
+
assertRange(section.bytes.byteLength >= 2, "truncated text row header");
|
|
78
|
+
const count = view.getUint16(0, true);
|
|
79
|
+
assertRange(count === section.itemCount, "text row count mismatch");
|
|
80
|
+
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
81
|
+
const rows = [];
|
|
82
|
+
let offset = 2;
|
|
83
|
+
for (let index = 0; index < count; index += 1) {
|
|
84
|
+
assertRange(offset + 6 <= section.bytes.byteLength, "truncated text row");
|
|
85
|
+
const row = view.getUint16(offset, true);
|
|
86
|
+
const length = view.getUint32(offset + 2, true);
|
|
87
|
+
offset += 6;
|
|
88
|
+
assertRange(offset + length <= section.bytes.byteLength, "text row payload out of bounds");
|
|
89
|
+
rows.push({ row, text: decoder.decode(section.bytes.subarray(offset, offset + length)) });
|
|
90
|
+
offset += length;
|
|
91
|
+
}
|
|
92
|
+
assertRange(offset === section.bytes.byteLength, "trailing text row bytes");
|
|
93
|
+
return rows;
|
|
94
|
+
}
|
|
95
|
+
export function decodeRowReplacements(section) {
|
|
96
|
+
assertRange(section.kind === SectionKind.RowReplacements, "wrong row replacement section kind");
|
|
97
|
+
assertRange(section.bytes.byteLength >= 2, "truncated row replacement header");
|
|
98
|
+
const view = new DataView(section.bytes.buffer, section.bytes.byteOffset, section.bytes.byteLength);
|
|
99
|
+
const count = view.getUint16(0, true);
|
|
100
|
+
assertRange(count === section.itemCount, "row replacement count mismatch");
|
|
101
|
+
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
102
|
+
const rows = [];
|
|
103
|
+
let offset = 2;
|
|
104
|
+
for (let index = 0; index < count; index += 1) {
|
|
105
|
+
assertRange(offset + 18 <= section.bytes.byteLength, "truncated row replacement");
|
|
106
|
+
const row = view.getUint16(offset, true);
|
|
107
|
+
const revision = view.getBigUint64(offset + 2, true);
|
|
108
|
+
const length = view.getUint32(offset + 10, true);
|
|
109
|
+
const glyphCount = view.getUint16(offset + 14, true);
|
|
110
|
+
const styleCount = view.getUint16(offset + 16, true);
|
|
111
|
+
offset += 18;
|
|
112
|
+
assertRange(offset + length <= section.bytes.byteLength, "row replacement payload out of bounds");
|
|
113
|
+
const text = decoder.decode(section.bytes.subarray(offset, offset + length));
|
|
114
|
+
offset += length;
|
|
115
|
+
const glyphs = [];
|
|
116
|
+
for (let glyphIndex = 0; glyphIndex < glyphCount; glyphIndex += 1) {
|
|
117
|
+
assertRange(offset + 28 <= section.bytes.byteLength, "truncated glyph instance");
|
|
118
|
+
glyphs.push({
|
|
119
|
+
glyphId: view.getUint32(offset, true),
|
|
120
|
+
styleId: view.getUint32(offset + 4, true),
|
|
121
|
+
x: view.getFloat32(offset + 8, true),
|
|
122
|
+
y: view.getFloat32(offset + 12, true),
|
|
123
|
+
width: view.getFloat32(offset + 16, true),
|
|
124
|
+
height: view.getFloat32(offset + 20, true),
|
|
125
|
+
cellStart: view.getUint16(offset + 24, true),
|
|
126
|
+
cellSpan: view.getUint16(offset + 26, true),
|
|
127
|
+
});
|
|
128
|
+
offset += 28;
|
|
129
|
+
}
|
|
130
|
+
const styles = [];
|
|
131
|
+
for (let styleIndex = 0; styleIndex < styleCount; styleIndex += 1) {
|
|
132
|
+
assertRange(offset + 8 <= section.bytes.byteLength, "truncated row style run");
|
|
133
|
+
styles.push({
|
|
134
|
+
styleId: view.getUint32(offset, true),
|
|
135
|
+
cellStart: view.getUint16(offset + 4, true),
|
|
136
|
+
cellSpan: view.getUint16(offset + 6, true),
|
|
137
|
+
});
|
|
138
|
+
offset += 8;
|
|
139
|
+
}
|
|
140
|
+
rows.push({ row, revision, text, glyphs, styles });
|
|
141
|
+
}
|
|
142
|
+
assertRange(offset === section.bytes.byteLength, "trailing row replacement bytes");
|
|
143
|
+
return rows;
|
|
144
|
+
}
|
|
145
|
+
export function decodeGlyphDefinitions(section) {
|
|
146
|
+
assertRange(section.kind === SectionKind.GlyphDefinitions, "wrong glyph definition section kind");
|
|
147
|
+
assertRange(section.bytes.byteLength >= 4, "truncated glyph definition header");
|
|
148
|
+
const view = new DataView(section.bytes.buffer, section.bytes.byteOffset, section.bytes.byteLength);
|
|
149
|
+
const count = view.getUint32(0, true);
|
|
150
|
+
assertRange(count === section.itemCount, "glyph definition count mismatch");
|
|
151
|
+
const definitions = [];
|
|
152
|
+
let offset = 4;
|
|
153
|
+
for (let index = 0; index < count; index += 1) {
|
|
154
|
+
assertRange(offset + 20 <= section.bytes.byteLength, "truncated glyph definition");
|
|
155
|
+
const format = view.getUint8(offset + 12);
|
|
156
|
+
assertRange(format === GlyphFormat.Alpha8 || format === GlyphFormat.Rgba8Premultiplied, "invalid glyph format");
|
|
157
|
+
assertRange(view.getUint8(offset + 13) === 0 && view.getUint16(offset + 14, true) === 0, "nonzero glyph reserved bytes");
|
|
158
|
+
const pixelLength = view.getUint32(offset + 16, true);
|
|
159
|
+
const width = view.getUint16(offset + 4, true);
|
|
160
|
+
const height = view.getUint16(offset + 6, true);
|
|
161
|
+
const expectedLength = width * height * (format === GlyphFormat.Alpha8 ? 1 : 4);
|
|
162
|
+
assertRange(pixelLength === expectedLength, "glyph pixel length mismatch");
|
|
163
|
+
offset += 20;
|
|
164
|
+
assertRange(offset + pixelLength <= section.bytes.byteLength, "glyph pixels out of bounds");
|
|
165
|
+
definitions.push({
|
|
166
|
+
id: view.getUint32(offset - 20, true),
|
|
167
|
+
width,
|
|
168
|
+
height,
|
|
169
|
+
bearingX: view.getInt16(offset - 12, true),
|
|
170
|
+
bearingY: view.getInt16(offset - 10, true),
|
|
171
|
+
format,
|
|
172
|
+
pixels: section.bytes.slice(offset, offset + pixelLength),
|
|
173
|
+
});
|
|
174
|
+
offset += pixelLength;
|
|
175
|
+
}
|
|
176
|
+
assertRange(offset === section.bytes.byteLength, "trailing glyph definition bytes");
|
|
177
|
+
return definitions;
|
|
178
|
+
}
|
|
179
|
+
export function decodeStyleDefinitions(section) {
|
|
180
|
+
assertRange(section.kind === SectionKind.StyleDefinitions, "wrong style definition section kind");
|
|
181
|
+
assertRange(section.bytes.byteLength >= 4, "truncated style definition header");
|
|
182
|
+
const view = new DataView(section.bytes.buffer, section.bytes.byteOffset, section.bytes.byteLength);
|
|
183
|
+
const count = view.getUint32(0, true);
|
|
184
|
+
assertRange(count === section.itemCount, "style definition count mismatch");
|
|
185
|
+
assertRange(section.bytes.byteLength === 4 + count * 16, "invalid style definition length");
|
|
186
|
+
const styles = [];
|
|
187
|
+
for (let index = 0; index < count; index += 1) {
|
|
188
|
+
const offset = 4 + index * 16;
|
|
189
|
+
const flags = view.getUint16(offset + 4, true);
|
|
190
|
+
const foregroundKind = view.getUint8(offset + 6);
|
|
191
|
+
const backgroundKind = view.getUint8(offset + 7);
|
|
192
|
+
assertRange((flags & ~0x7f) === 0, "invalid style flags");
|
|
193
|
+
assertRange(foregroundKind <= 1 && backgroundKind <= 1, "invalid style color kind");
|
|
194
|
+
assertRange(view.getUint16(offset + 14, true) === 0, "nonzero style reserved bytes");
|
|
195
|
+
styles.push({
|
|
196
|
+
id: view.getUint32(offset, true),
|
|
197
|
+
bold: (flags & 1) !== 0,
|
|
198
|
+
italic: (flags & 2) !== 0,
|
|
199
|
+
faint: (flags & 4) !== 0,
|
|
200
|
+
inverse: (flags & 8) !== 0,
|
|
201
|
+
invisible: (flags & 16) !== 0,
|
|
202
|
+
strikethrough: (flags & 32) !== 0,
|
|
203
|
+
underline: (flags & 64) !== 0,
|
|
204
|
+
...(foregroundKind === 1
|
|
205
|
+
? { foreground: [view.getUint8(offset + 8), view.getUint8(offset + 9), view.getUint8(offset + 10)] }
|
|
206
|
+
: {}),
|
|
207
|
+
...(backgroundKind === 1
|
|
208
|
+
? { background: [view.getUint8(offset + 11), view.getUint8(offset + 12), view.getUint8(offset + 13)] }
|
|
209
|
+
: {}),
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
return styles;
|
|
213
|
+
}
|
|
214
|
+
export function decodeCursorState(section) {
|
|
215
|
+
assertRange(section.kind === SectionKind.CursorState, "wrong cursor section kind");
|
|
216
|
+
assertRange(section.itemCount === 1, "cursor item count mismatch");
|
|
217
|
+
assertRange(section.bytes.byteLength === 8, "invalid cursor payload length");
|
|
218
|
+
const view = new DataView(section.bytes.buffer, section.bytes.byteOffset, section.bytes.byteLength);
|
|
219
|
+
const visible = view.getUint8(4);
|
|
220
|
+
const style = view.getUint8(5);
|
|
221
|
+
const blinking = view.getUint8(6);
|
|
222
|
+
assertRange(visible <= 1, "invalid cursor visibility");
|
|
223
|
+
assertRange(style <= CursorStyle.HollowBlock, "invalid cursor style");
|
|
224
|
+
assertRange(blinking <= 1, "invalid cursor blinking state");
|
|
225
|
+
assertRange(view.getUint8(7) === 0, "nonzero cursor reserved byte");
|
|
226
|
+
return {
|
|
227
|
+
x: view.getUint16(0, true),
|
|
228
|
+
y: view.getUint16(2, true),
|
|
229
|
+
visible: visible === 1,
|
|
230
|
+
style,
|
|
231
|
+
blinking: blinking === 1,
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
export function decodeClipboardWrite(section) {
|
|
235
|
+
assertRange(section.kind === SectionKind.ClipboardWrite, "wrong clipboard section kind");
|
|
236
|
+
assertRange(section.itemCount === 1, "clipboard item count mismatch");
|
|
237
|
+
assertRange(section.bytes.byteLength >= 4, "truncated clipboard payload");
|
|
238
|
+
const view = new DataView(section.bytes.buffer, section.bytes.byteOffset, section.bytes.byteLength);
|
|
239
|
+
const length = view.getUint32(0, true);
|
|
240
|
+
assertRange(length === section.bytes.byteLength - 4, "clipboard length mismatch");
|
|
241
|
+
return new TextDecoder("utf-8", { fatal: true }).decode(section.bytes.subarray(4));
|
|
242
|
+
}
|
|
243
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,UAAU,CAAC;AACtC,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AACxC,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,CAAC;AACrC,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAC;AACvC,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAChD,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,YAAY,EAAE,CAAC,IAAI,CAAC;IACpB,aAAa,EAAE,CAAC,IAAI,CAAC;CACb,CAAC;AAEX,MAAM,CAAN,IAAY,WAYX;AAZD,WAAY,WAAW;IACrB,qEAAoB,CAAA;IACpB,qEAAoB,CAAA;IACpB,mEAAmB,CAAA;IACnB,2DAAe,CAAA;IACf,iEAAkB,CAAA;IAClB,qEAAoB,CAAA;IACpB,mEAAmB,CAAA;IACnB,iEAAkB,CAAA;IAClB,qEAAoB,CAAA;IACpB,wEAAsB,CAAA;IACtB,kEAAmB,CAAA;AACrB,CAAC,EAZW,WAAW,KAAX,WAAW,QAYtB;AAkCD,MAAM,CAAN,IAAY,WAGX;AAHD,WAAY,WAA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AAE,IAAI,CAAC;QAC1B,OAAO,EAAE,OAAO,KAAK,CAAC;QACtB,KAAK;QACL,QAAQ,EAAE,QAAQ,KAAK,CAAC;KACzB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,OAAqB;IACxD,WAAW,CAAC,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC,cAAc,EAAE,8BAA8B,CAAC,CAAC;IACzF,WAAW,CAAC,OAAO,CAAC,SAAS,KAAK,CAAC,EAAE,+BAA+B,CAAC,CAAC;IACtE,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU,IAAI,CAAC,EAAE,6BAA6B,CAAC,CAAC;IAC1E,MAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,UAAU,EAAE,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACpG,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IACvC,WAAW,CAAC,MAAM,KAAK,OAAO,CAAC,KAAK,CAAC,UAAU,GAAG,CAAC,EAAE,2BAA2B,CAAC,CAAC;IAClF,OAAO,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;AACrF,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vibecook/ghosttea-frame",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Binary frame decoder and shared rendering types for Ghosttea.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "James Yong",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"sideEffects": false,
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"README.md",
|
|
20
|
+
"LICENSE"
|
|
21
|
+
],
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/jamesyong-42/ghosttea.git",
|
|
25
|
+
"directory": "packages/terminal-frame"
|
|
26
|
+
},
|
|
27
|
+
"homepage": "https://github.com/jamesyong-42/ghosttea#readme",
|
|
28
|
+
"bugs": {
|
|
29
|
+
"url": "https://github.com/jamesyong-42/ghosttea/issues"
|
|
30
|
+
},
|
|
31
|
+
"keywords": [
|
|
32
|
+
"electron",
|
|
33
|
+
"ghostty",
|
|
34
|
+
"terminal",
|
|
35
|
+
"webgpu"
|
|
36
|
+
],
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public",
|
|
39
|
+
"provenance": true
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"",
|
|
43
|
+
"build": "npm run clean && tsc -p tsconfig.build.json",
|
|
44
|
+
"check": "tsc --noEmit",
|
|
45
|
+
"test": "vitest run",
|
|
46
|
+
"prepublishOnly": "npm run build"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"typescript": "7.0.2",
|
|
50
|
+
"vitest": "4.1.10"
|
|
51
|
+
}
|
|
52
|
+
}
|