remotosh 1.0.0 → 1.0.1
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/bin/remoto.js +23 -9
- package/package.json +1 -1
package/bin/remoto.js
CHANGED
|
@@ -41,11 +41,14 @@ ws.on('open', () => {
|
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
ws.on('message', (data) => {
|
|
44
|
+
const raw = data.toString();
|
|
45
|
+
console.log(chalk.dim(` [debug] received: ${raw.substring(0, 100)}`));
|
|
44
46
|
try {
|
|
45
|
-
const message = JSON.parse(
|
|
47
|
+
const message = JSON.parse(raw);
|
|
46
48
|
handleServerMessage(message);
|
|
47
49
|
} catch (err) {
|
|
48
|
-
console.error(chalk.red(
|
|
50
|
+
console.error(chalk.red(` invalid message from server: ${err.message}`));
|
|
51
|
+
console.error(chalk.red(` raw data: ${raw.substring(0, 50)}`));
|
|
49
52
|
}
|
|
50
53
|
});
|
|
51
54
|
|
|
@@ -90,8 +93,12 @@ function handleServerMessage(message) {
|
|
|
90
93
|
|
|
91
94
|
case 'input':
|
|
92
95
|
// Input from phone
|
|
96
|
+
console.log(chalk.dim(` [debug] input handler, ptyProcess exists: ${!!ptyProcess}`));
|
|
93
97
|
if (ptyProcess) {
|
|
98
|
+
console.log(chalk.dim(` [debug] writing to pty: "${message.data}"`));
|
|
94
99
|
ptyProcess.write(message.data);
|
|
100
|
+
} else {
|
|
101
|
+
console.log(chalk.red(' [debug] ptyProcess is null!'));
|
|
95
102
|
}
|
|
96
103
|
break;
|
|
97
104
|
|
|
@@ -127,13 +134,20 @@ function showQRCode() {
|
|
|
127
134
|
|
|
128
135
|
function startPTY() {
|
|
129
136
|
// Initialize PTY
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
+
console.log(chalk.dim(` [debug] spawning shell: ${shell}`));
|
|
138
|
+
try {
|
|
139
|
+
ptyProcess = pty.spawn(shell, [], {
|
|
140
|
+
name: 'xterm-256color',
|
|
141
|
+
cols,
|
|
142
|
+
rows,
|
|
143
|
+
cwd: process.cwd(),
|
|
144
|
+
env: process.env,
|
|
145
|
+
});
|
|
146
|
+
console.log(chalk.dim(` [debug] pty spawned successfully, pid: ${ptyProcess.pid}`));
|
|
147
|
+
} catch (err) {
|
|
148
|
+
console.error(chalk.red(` [debug] pty spawn failed: ${err.message}`));
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
137
151
|
|
|
138
152
|
// Handle PTY output
|
|
139
153
|
ptyProcess.onData((data) => {
|