auvezy-terminal-remote 0.3.0 → 0.3.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/dist/cli.js +52 -16
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -4215,18 +4215,30 @@ ${hint}
|
|
|
4215
4215
|
if (isHeadless) {
|
|
4216
4216
|
startPty("immediate");
|
|
4217
4217
|
} else if (mustWaitEnter) {
|
|
4218
|
-
|
|
4218
|
+
const wait = waitForUserConfirm();
|
|
4219
|
+
void wait.promise.then((r) => {
|
|
4220
|
+
if (r.done === "enter")
|
|
4221
|
+
startPty("enter");
|
|
4222
|
+
}).catch((err) => {
|
|
4219
4223
|
logger.error({ err }, "\u7B49\u5F85 Enter \u5931\u8D25");
|
|
4220
4224
|
shutdown(1);
|
|
4221
4225
|
});
|
|
4222
4226
|
} else {
|
|
4227
|
+
const wait = waitForUserConfirm({ silent: true });
|
|
4228
|
+
const triggerSpawn = (reason) => {
|
|
4229
|
+
wait.cancel();
|
|
4230
|
+
startPty(reason);
|
|
4231
|
+
};
|
|
4223
4232
|
ws.onConnect((_ws, type) => {
|
|
4224
4233
|
if (type === "webapp")
|
|
4225
|
-
|
|
4234
|
+
triggerSpawn("webapp");
|
|
4235
|
+
});
|
|
4236
|
+
void wait.promise.then((r) => {
|
|
4237
|
+
if (r.done === "enter")
|
|
4238
|
+
triggerSpawn("enter");
|
|
4226
4239
|
});
|
|
4227
|
-
void waitForUserConfirm({ silent: true }).then(() => startPty("enter"));
|
|
4228
4240
|
if (cfg.spawnTimeoutSec > 0) {
|
|
4229
|
-
setTimeout(() =>
|
|
4241
|
+
setTimeout(() => triggerSpawn("timeout"), cfg.spawnTimeoutSec * 1e3).unref();
|
|
4230
4242
|
}
|
|
4231
4243
|
}
|
|
4232
4244
|
void registry.register({
|
|
@@ -4308,28 +4320,52 @@ function collectLocalHostnames() {
|
|
|
4308
4320
|
return set;
|
|
4309
4321
|
}
|
|
4310
4322
|
function waitForUserConfirm(opts = {}) {
|
|
4311
|
-
if (!process.stdin.isTTY)
|
|
4312
|
-
return
|
|
4323
|
+
if (!process.stdin.isTTY) {
|
|
4324
|
+
return {
|
|
4325
|
+
promise: Promise.resolve({ done: "enter" }),
|
|
4326
|
+
cancel: () => {
|
|
4327
|
+
}
|
|
4328
|
+
};
|
|
4329
|
+
}
|
|
4313
4330
|
if (!opts.silent) {
|
|
4314
4331
|
process.stderr.write(" \u6309 Enter \u542F\u52A8\u5B50\u8FDB\u7A0B\uFF08\u6216 Ctrl+C \u9000\u51FA backend\uFF09...");
|
|
4315
4332
|
}
|
|
4316
|
-
|
|
4317
|
-
|
|
4333
|
+
let cancelled = false;
|
|
4334
|
+
let onData = null;
|
|
4335
|
+
let resolveFn = null;
|
|
4336
|
+
const detach = () => {
|
|
4337
|
+
if (onData) {
|
|
4338
|
+
process.stdin.removeListener("data", onData);
|
|
4339
|
+
onData = null;
|
|
4340
|
+
}
|
|
4341
|
+
};
|
|
4342
|
+
const promise = new Promise((resolve9) => {
|
|
4343
|
+
resolveFn = resolve9;
|
|
4344
|
+
onData = (chunk) => {
|
|
4345
|
+
if (cancelled)
|
|
4346
|
+
return;
|
|
4318
4347
|
if (chunk.length === 0)
|
|
4319
4348
|
return;
|
|
4320
|
-
|
|
4321
|
-
if (!opts.silent)
|
|
4349
|
+
detach();
|
|
4350
|
+
if (!opts.silent)
|
|
4322
4351
|
process.stderr.write("\r\x1B[K");
|
|
4323
|
-
}
|
|
4324
|
-
resolve9();
|
|
4325
|
-
};
|
|
4326
|
-
const cleanup = () => {
|
|
4327
|
-
process.stdin.removeListener("data", onData);
|
|
4328
|
-
process.stdin.pause();
|
|
4352
|
+
resolve9({ done: "enter" });
|
|
4329
4353
|
};
|
|
4330
4354
|
process.stdin.resume();
|
|
4331
4355
|
process.stdin.on("data", onData);
|
|
4332
4356
|
});
|
|
4357
|
+
return {
|
|
4358
|
+
promise,
|
|
4359
|
+
cancel: () => {
|
|
4360
|
+
if (cancelled)
|
|
4361
|
+
return;
|
|
4362
|
+
cancelled = true;
|
|
4363
|
+
detach();
|
|
4364
|
+
if (!opts.silent)
|
|
4365
|
+
process.stderr.write("\r\x1B[K");
|
|
4366
|
+
resolveFn?.({ done: "cancelled" });
|
|
4367
|
+
}
|
|
4368
|
+
};
|
|
4333
4369
|
}
|
|
4334
4370
|
var BUILTIN_FULL_ALT_TUIS;
|
|
4335
4371
|
var init_index = __esm({
|