restty 0.1.16 → 0.1.18
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/README.md +4 -9
- package/dist/app/atlas-builder.d.ts +38 -0
- package/dist/app/font-sources.d.ts +2 -0
- package/dist/app/pane-app-manager.d.ts +43 -0
- package/dist/app/panes-context-menu.d.ts +10 -0
- package/dist/app/panes-styles.d.ts +5 -0
- package/dist/app/panes-types.d.ts +89 -0
- package/dist/app/panes.d.ts +10 -0
- package/dist/app/restty.d.ts +20 -0
- package/dist/app/session.d.ts +6 -0
- package/dist/app/types.d.ts +123 -0
- package/dist/{app/index.js → chunk-53vdvhe3.js} +24014 -23787
- package/dist/fonts/manager.d.ts +24 -0
- package/dist/fonts/nerd-constraints.d.ts +4 -0
- package/dist/fonts/nerd-ranges.d.ts +2 -0
- package/dist/fonts/types.d.ts +51 -0
- package/dist/grid/grid.d.ts +22 -0
- package/dist/grid/types.d.ts +32 -0
- package/dist/ime/ime.d.ts +13 -0
- package/dist/ime/types.d.ts +8 -0
- package/dist/input/ansi.d.ts +3 -0
- package/dist/input/mouse.d.ts +10 -0
- package/dist/input/output.d.ts +11 -0
- package/dist/input/types.d.ts +7 -0
- package/dist/internal.js +105 -56213
- package/dist/pty/kitty-media.d.ts +3 -0
- package/dist/pty/pty.d.ts +11 -0
- package/dist/pty/types.d.ts +49 -0
- package/dist/renderer/box-drawing-map.d.ts +4 -0
- package/dist/renderer/shaders.d.ts +7 -0
- package/dist/renderer/shapes.d.ts +42 -1
- package/dist/renderer/types.d.ts +43 -0
- package/dist/renderer/webgpu.d.ts +11 -0
- package/dist/restty.js +20 -0
- package/dist/selection/selection.d.ts +24 -0
- package/dist/selection/types.d.ts +13 -0
- package/dist/theme/catalog.d.ts +5 -0
- package/dist/theme/ghostty.d.ts +18 -0
- package/dist/unicode/ghostty-symbol-ranges.d.ts +1 -0
- package/dist/unicode/symbols.d.ts +6 -0
- package/dist/wasm/embedded.d.ts +1 -0
- package/dist/wasm/runtime.d.ts +29 -0
- package/package.json +8 -61
- package/dist/fonts/index.js +0 -5332
- package/dist/grid/index.js +0 -71
- package/dist/ime/index.js +0 -84
- package/dist/index.js +0 -56210
- package/dist/input/index.js +0 -1047
- package/dist/pty/index.js +0 -338
- package/dist/renderer/index.js +0 -1612
- package/dist/selection/index.js +0 -226
- package/dist/theme/index.js +0 -11218
- package/dist/wasm/index.js +0 -6003
package/dist/pty/index.js
DELETED
|
@@ -1,338 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __export = (target, all) => {
|
|
3
|
-
for (var name in all)
|
|
4
|
-
__defProp(target, name, {
|
|
5
|
-
get: all[name],
|
|
6
|
-
enumerable: true,
|
|
7
|
-
configurable: true,
|
|
8
|
-
set: (newValue) => all[name] = () => newValue
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
// src/pty/pty.ts
|
|
12
|
-
function decodePtyBinary(decoder, payload, stream = true) {
|
|
13
|
-
const bytes = payload instanceof Uint8Array ? payload : new Uint8Array(payload);
|
|
14
|
-
return decoder.decode(bytes, { stream });
|
|
15
|
-
}
|
|
16
|
-
function createPtyConnection() {
|
|
17
|
-
return {
|
|
18
|
-
socket: null,
|
|
19
|
-
status: "idle",
|
|
20
|
-
url: "",
|
|
21
|
-
decoder: null,
|
|
22
|
-
connectId: 0
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
function setConnectionStatus(state, status) {
|
|
26
|
-
state.status = status;
|
|
27
|
-
}
|
|
28
|
-
function connectPty(state, options, callbacks) {
|
|
29
|
-
if (state.status === "connecting" || state.status === "connected" || state.status === "closing") {
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
const url = options.url?.trim?.() ?? "";
|
|
33
|
-
if (!url)
|
|
34
|
-
return false;
|
|
35
|
-
const ws = new WebSocket(url);
|
|
36
|
-
const decoder = new TextDecoder;
|
|
37
|
-
const connectId = state.connectId + 1;
|
|
38
|
-
state.connectId = connectId;
|
|
39
|
-
state.url = url;
|
|
40
|
-
state.socket = ws;
|
|
41
|
-
state.decoder = decoder;
|
|
42
|
-
setConnectionStatus(state, "connecting");
|
|
43
|
-
ws.binaryType = "arraybuffer";
|
|
44
|
-
const flushDecoder = () => {
|
|
45
|
-
if (state.connectId !== connectId)
|
|
46
|
-
return;
|
|
47
|
-
if (!decoder)
|
|
48
|
-
return;
|
|
49
|
-
const tail = decoder.decode();
|
|
50
|
-
if (state.decoder === decoder) {
|
|
51
|
-
state.decoder = null;
|
|
52
|
-
}
|
|
53
|
-
if (tail)
|
|
54
|
-
callbacks.onData?.(tail);
|
|
55
|
-
};
|
|
56
|
-
let disconnectedNotified = false;
|
|
57
|
-
const notifyDisconnected = () => {
|
|
58
|
-
if (disconnectedNotified)
|
|
59
|
-
return;
|
|
60
|
-
disconnectedNotified = true;
|
|
61
|
-
callbacks.onDisconnect?.();
|
|
62
|
-
};
|
|
63
|
-
const clearCurrentSocket = () => {
|
|
64
|
-
if (state.connectId !== connectId)
|
|
65
|
-
return;
|
|
66
|
-
if (state.socket === ws) {
|
|
67
|
-
state.socket = null;
|
|
68
|
-
}
|
|
69
|
-
setConnectionStatus(state, "idle");
|
|
70
|
-
if (state.decoder === decoder) {
|
|
71
|
-
state.decoder = null;
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
ws.addEventListener("open", () => {
|
|
75
|
-
if (state.connectId !== connectId) {
|
|
76
|
-
try {
|
|
77
|
-
ws.close();
|
|
78
|
-
} catch {}
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
if (state.socket !== ws)
|
|
82
|
-
return;
|
|
83
|
-
setConnectionStatus(state, "connected");
|
|
84
|
-
callbacks.onConnect?.();
|
|
85
|
-
if (Number.isFinite(options.cols) && Number.isFinite(options.rows)) {
|
|
86
|
-
const cols = Math.max(0, Number(options.cols));
|
|
87
|
-
const rows = Math.max(0, Number(options.rows));
|
|
88
|
-
sendPtyResize(state, cols, rows);
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
ws.addEventListener("close", () => {
|
|
92
|
-
flushDecoder();
|
|
93
|
-
clearCurrentSocket();
|
|
94
|
-
notifyDisconnected();
|
|
95
|
-
});
|
|
96
|
-
ws.addEventListener("error", () => {
|
|
97
|
-
flushDecoder();
|
|
98
|
-
clearCurrentSocket();
|
|
99
|
-
notifyDisconnected();
|
|
100
|
-
});
|
|
101
|
-
ws.addEventListener("message", (event) => {
|
|
102
|
-
if (state.connectId !== connectId || state.socket !== ws)
|
|
103
|
-
return;
|
|
104
|
-
const payload = event.data;
|
|
105
|
-
if (payload instanceof ArrayBuffer) {
|
|
106
|
-
const text = decodePtyBinary(decoder, payload, true);
|
|
107
|
-
if (text)
|
|
108
|
-
callbacks.onData?.(text);
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
if (payload instanceof Blob) {
|
|
112
|
-
payload.arrayBuffer().then((buf) => {
|
|
113
|
-
if (state.connectId !== connectId || state.socket !== ws)
|
|
114
|
-
return;
|
|
115
|
-
const text = decodePtyBinary(decoder, buf, true);
|
|
116
|
-
if (text)
|
|
117
|
-
callbacks.onData?.(text);
|
|
118
|
-
});
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
if (typeof payload === "string") {
|
|
122
|
-
if (handleServerMessage(payload, callbacks))
|
|
123
|
-
return;
|
|
124
|
-
callbacks.onData?.(payload);
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
return true;
|
|
128
|
-
}
|
|
129
|
-
function disconnectPty(state) {
|
|
130
|
-
const socket = state.socket;
|
|
131
|
-
if (state.decoder && !socket) {
|
|
132
|
-
state.decoder.decode();
|
|
133
|
-
state.decoder = null;
|
|
134
|
-
}
|
|
135
|
-
if (!socket) {
|
|
136
|
-
setConnectionStatus(state, "idle");
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
setConnectionStatus(state, "closing");
|
|
140
|
-
if (socket) {
|
|
141
|
-
try {
|
|
142
|
-
if (socket.readyState === WebSocket.OPEN || socket.readyState === WebSocket.CONNECTING) {
|
|
143
|
-
socket.close();
|
|
144
|
-
} else {
|
|
145
|
-
if (state.socket === socket) {
|
|
146
|
-
state.socket = null;
|
|
147
|
-
}
|
|
148
|
-
setConnectionStatus(state, "idle");
|
|
149
|
-
}
|
|
150
|
-
} catch {
|
|
151
|
-
if (state.socket === socket) {
|
|
152
|
-
state.socket = null;
|
|
153
|
-
}
|
|
154
|
-
setConnectionStatus(state, "idle");
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
function sendPtyInput(state, data) {
|
|
159
|
-
if (!state.socket || state.socket.readyState !== WebSocket.OPEN)
|
|
160
|
-
return false;
|
|
161
|
-
const message = { type: "input", data };
|
|
162
|
-
state.socket.send(JSON.stringify(message));
|
|
163
|
-
return true;
|
|
164
|
-
}
|
|
165
|
-
function sendPtyResize(state, cols, rows) {
|
|
166
|
-
if (!state.socket || state.socket.readyState !== WebSocket.OPEN)
|
|
167
|
-
return false;
|
|
168
|
-
const message = { type: "resize", cols, rows };
|
|
169
|
-
state.socket.send(JSON.stringify(message));
|
|
170
|
-
return true;
|
|
171
|
-
}
|
|
172
|
-
function handleServerMessage(payload, callbacks) {
|
|
173
|
-
try {
|
|
174
|
-
const msg = JSON.parse(payload);
|
|
175
|
-
if (msg.type === "status") {
|
|
176
|
-
callbacks.onStatus?.(msg.shell ?? "");
|
|
177
|
-
return true;
|
|
178
|
-
}
|
|
179
|
-
if (msg.type === "error") {
|
|
180
|
-
callbacks.onError?.(msg.message ?? "", msg.errors);
|
|
181
|
-
return true;
|
|
182
|
-
}
|
|
183
|
-
if (msg.type === "exit") {
|
|
184
|
-
callbacks.onExit?.(msg.code ?? 0);
|
|
185
|
-
return true;
|
|
186
|
-
}
|
|
187
|
-
} catch {}
|
|
188
|
-
return false;
|
|
189
|
-
}
|
|
190
|
-
function isPtyConnected(state) {
|
|
191
|
-
return state.status === "connected" && state.socket?.readyState === WebSocket.OPEN;
|
|
192
|
-
}
|
|
193
|
-
function createWebSocketPtyTransport(state = createPtyConnection()) {
|
|
194
|
-
return {
|
|
195
|
-
connect: (options) => {
|
|
196
|
-
const url = options.url?.trim?.() ?? "";
|
|
197
|
-
if (!url) {
|
|
198
|
-
throw new Error("PTY URL is required for WebSocket transport");
|
|
199
|
-
}
|
|
200
|
-
const connected = connectPty(state, options, options.callbacks);
|
|
201
|
-
if (!connected && state.status !== "connected") {
|
|
202
|
-
throw new Error(`PTY connection is busy (${state.status})`);
|
|
203
|
-
}
|
|
204
|
-
},
|
|
205
|
-
disconnect: () => {
|
|
206
|
-
disconnectPty(state);
|
|
207
|
-
},
|
|
208
|
-
sendInput: (data) => {
|
|
209
|
-
return sendPtyInput(state, data);
|
|
210
|
-
},
|
|
211
|
-
resize: (cols, rows) => {
|
|
212
|
-
return sendPtyResize(state, cols, rows);
|
|
213
|
-
},
|
|
214
|
-
isConnected: () => {
|
|
215
|
-
return isPtyConnected(state);
|
|
216
|
-
},
|
|
217
|
-
destroy: () => {
|
|
218
|
-
disconnectPty(state);
|
|
219
|
-
}
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
// src/pty/kitty-media.ts
|
|
223
|
-
function findKittyTerminator(data, from) {
|
|
224
|
-
const bel = data.indexOf("\x07", from);
|
|
225
|
-
const st = data.indexOf("\x1B\\", from);
|
|
226
|
-
if (bel === -1 && st === -1)
|
|
227
|
-
return null;
|
|
228
|
-
if (bel !== -1 && (st === -1 || bel < st))
|
|
229
|
-
return { index: bel, len: 1 };
|
|
230
|
-
return { index: st, len: 2 };
|
|
231
|
-
}
|
|
232
|
-
function decodeBase64Bytes(text) {
|
|
233
|
-
const cleaned = text.replace(/\s+/g, "");
|
|
234
|
-
if (!cleaned)
|
|
235
|
-
return new Uint8Array(0);
|
|
236
|
-
const binary = atob(cleaned);
|
|
237
|
-
const out = new Uint8Array(binary.length);
|
|
238
|
-
for (let i = 0;i < binary.length; i += 1) {
|
|
239
|
-
out[i] = binary.charCodeAt(i) & 255;
|
|
240
|
-
}
|
|
241
|
-
return out;
|
|
242
|
-
}
|
|
243
|
-
function encodeBase64Bytes(bytes) {
|
|
244
|
-
let binary = "";
|
|
245
|
-
for (let i = 0;i < bytes.length; i += 1) {
|
|
246
|
-
binary += String.fromCharCode(bytes[i] ?? 0);
|
|
247
|
-
}
|
|
248
|
-
return btoa(binary);
|
|
249
|
-
}
|
|
250
|
-
function decodeBase64Text(text) {
|
|
251
|
-
try {
|
|
252
|
-
const bytes = decodeBase64Bytes(text);
|
|
253
|
-
return new TextDecoder().decode(bytes);
|
|
254
|
-
} catch {
|
|
255
|
-
return "";
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
function rewriteOneKittyCommand(body, readFile) {
|
|
259
|
-
const sep = body.indexOf(";");
|
|
260
|
-
if (sep < 0)
|
|
261
|
-
return body;
|
|
262
|
-
const control = body.slice(0, sep);
|
|
263
|
-
const payload = body.slice(sep + 1);
|
|
264
|
-
if (!control || !payload)
|
|
265
|
-
return body;
|
|
266
|
-
const parts = control.split(",");
|
|
267
|
-
let medium = null;
|
|
268
|
-
let hasMedium = false;
|
|
269
|
-
let hasMore = false;
|
|
270
|
-
for (const part of parts) {
|
|
271
|
-
if (part.startsWith("t=")) {
|
|
272
|
-
hasMedium = true;
|
|
273
|
-
medium = part.slice(2);
|
|
274
|
-
} else if (part.startsWith("m=")) {
|
|
275
|
-
hasMore = true;
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
if (medium !== "f" && medium !== "t")
|
|
279
|
-
return body;
|
|
280
|
-
const path = decodeBase64Text(payload);
|
|
281
|
-
if (!path || path.includes("\x00"))
|
|
282
|
-
return body;
|
|
283
|
-
let bytes;
|
|
284
|
-
try {
|
|
285
|
-
bytes = readFile(path);
|
|
286
|
-
} catch {
|
|
287
|
-
return body;
|
|
288
|
-
}
|
|
289
|
-
const nextParts = parts.map((part) => {
|
|
290
|
-
if (part.startsWith("t="))
|
|
291
|
-
return "t=d";
|
|
292
|
-
if (part.startsWith("m="))
|
|
293
|
-
return "m=0";
|
|
294
|
-
return part;
|
|
295
|
-
});
|
|
296
|
-
if (!hasMedium)
|
|
297
|
-
nextParts.push("t=d");
|
|
298
|
-
if (hasMore) {}
|
|
299
|
-
return `${nextParts.join(",")};${encodeBase64Bytes(bytes)}`;
|
|
300
|
-
}
|
|
301
|
-
function rewriteKittyFileMediaToDirect(chunk, state, readFile) {
|
|
302
|
-
const input = (state.remainder ?? "") + chunk;
|
|
303
|
-
let out = "";
|
|
304
|
-
let i = 0;
|
|
305
|
-
while (i < input.length) {
|
|
306
|
-
const start = input.indexOf("\x1B_G", i);
|
|
307
|
-
if (start < 0) {
|
|
308
|
-
out += input.slice(i);
|
|
309
|
-
state.remainder = "";
|
|
310
|
-
return out;
|
|
311
|
-
}
|
|
312
|
-
out += input.slice(i, start);
|
|
313
|
-
const terminator = findKittyTerminator(input, start + 3);
|
|
314
|
-
if (!terminator) {
|
|
315
|
-
state.remainder = input.slice(start);
|
|
316
|
-
return out;
|
|
317
|
-
}
|
|
318
|
-
const body = input.slice(start + 3, terminator.index);
|
|
319
|
-
const rewritten = rewriteOneKittyCommand(body, readFile);
|
|
320
|
-
out += "\x1B_G";
|
|
321
|
-
out += rewritten;
|
|
322
|
-
out += terminator.len === 2 ? "\x1B\\" : "\x07";
|
|
323
|
-
i = terminator.index + terminator.len;
|
|
324
|
-
}
|
|
325
|
-
state.remainder = "";
|
|
326
|
-
return out;
|
|
327
|
-
}
|
|
328
|
-
export {
|
|
329
|
-
sendPtyResize,
|
|
330
|
-
sendPtyInput,
|
|
331
|
-
rewriteKittyFileMediaToDirect,
|
|
332
|
-
isPtyConnected,
|
|
333
|
-
disconnectPty,
|
|
334
|
-
decodePtyBinary,
|
|
335
|
-
createWebSocketPtyTransport,
|
|
336
|
-
createPtyConnection,
|
|
337
|
-
connectPty
|
|
338
|
-
};
|