deckide 3.5.16 → 3.5.17
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/websocket.js
CHANGED
|
@@ -77,6 +77,8 @@ function untrackConnection(ip, socket) {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
function validateTerminalSize(value) {
|
|
80
|
+
if (value == null)
|
|
81
|
+
return MIN_TERMINAL_SIZE;
|
|
80
82
|
const intValue = Math.floor(value);
|
|
81
83
|
if (!Number.isFinite(intValue) || intValue < MIN_TERMINAL_SIZE) {
|
|
82
84
|
return MIN_TERMINAL_SIZE;
|
|
@@ -108,7 +110,8 @@ function rawDataToBuffer(data) {
|
|
|
108
110
|
if (data instanceof ArrayBuffer) {
|
|
109
111
|
return Buffer.from(data);
|
|
110
112
|
}
|
|
111
|
-
|
|
113
|
+
// data is Buffer
|
|
114
|
+
return Buffer.isBuffer(data) ? data : Buffer.from(data);
|
|
112
115
|
}
|
|
113
116
|
function canSendToSocket(socket) {
|
|
114
117
|
if (socket.readyState !== WebSocket.OPEN) {
|
|
@@ -305,7 +308,7 @@ export function setupWebSocketServer(server, terminals) {
|
|
|
305
308
|
}
|
|
306
309
|
}
|
|
307
310
|
sendControl(socket, { type: 'ready' });
|
|
308
|
-
socket.on('message', (data) => {
|
|
311
|
+
socket.on('message', (data, isBinary) => {
|
|
309
312
|
try {
|
|
310
313
|
const messageSize = rawDataByteLength(data);
|
|
311
314
|
if (messageSize > MAX_MESSAGE_SIZE) {
|
|
@@ -314,10 +317,18 @@ export function setupWebSocketServer(server, terminals) {
|
|
|
314
317
|
return;
|
|
315
318
|
}
|
|
316
319
|
session.lastActive = Date.now();
|
|
317
|
-
|
|
320
|
+
// Text frames carry JSON control messages (claim, resize).
|
|
321
|
+
// Note: the ws library delivers text frames as Buffer by default,
|
|
322
|
+
// so we use the isBinary flag rather than typeof === 'string'.
|
|
323
|
+
if (!isBinary) {
|
|
324
|
+
const text = typeof data === 'string'
|
|
325
|
+
? data
|
|
326
|
+
: Array.isArray(data)
|
|
327
|
+
? Buffer.concat(data).toString('utf8')
|
|
328
|
+
: Buffer.from(data).toString('utf8');
|
|
318
329
|
let control = null;
|
|
319
330
|
try {
|
|
320
|
-
control = JSON.parse(
|
|
331
|
+
control = JSON.parse(text);
|
|
321
332
|
}
|
|
322
333
|
catch {
|
|
323
334
|
control = null;
|
|
@@ -341,14 +352,16 @@ export function setupWebSocketServer(server, terminals) {
|
|
|
341
352
|
}
|
|
342
353
|
return;
|
|
343
354
|
}
|
|
355
|
+
// Unknown text frame — still forward to terminal for compatibility
|
|
344
356
|
try {
|
|
345
|
-
session.write(Buffer.from(
|
|
357
|
+
session.write(Buffer.from(text, 'utf8'));
|
|
346
358
|
}
|
|
347
359
|
catch (writeError) {
|
|
348
360
|
console.error(`Failed to write text input to terminal ${id}:`, writeError);
|
|
349
361
|
}
|
|
350
362
|
return;
|
|
351
363
|
}
|
|
364
|
+
// Binary frames carry terminal input (keystrokes, paste, etc.)
|
|
352
365
|
try {
|
|
353
366
|
session.write(rawDataToBuffer(data));
|
|
354
367
|
}
|