@lark-codem/codem-core 0.8.5 → 0.8.6-windows-input-diagnostics.202608191130.0.g715d8fa
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/lib/launch.js +46 -2
- package/package.json +6 -10
package/bin/lib/launch.js
CHANGED
|
@@ -44,6 +44,41 @@ function hintsFor(code, platform, binary) {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
/// Should the platform binary be spawned with `windowsHide`?
|
|
48
|
+
///
|
|
49
|
+
/// `windowsHide` is not just cosmetic on Windows: libuv translates it into
|
|
50
|
+
/// `CREATE_NO_WINDOW`, and per MSDN "Creation of a Console" a process created
|
|
51
|
+
/// with that flag gets a **brand new console** (merely one without a window)
|
|
52
|
+
/// instead of inheriting the parent's.
|
|
53
|
+
///
|
|
54
|
+
/// For an ordinary child that is harmless — stdout/stdin still reach the
|
|
55
|
+
/// parent's console through the explicitly inherited handles. linco is not an
|
|
56
|
+
/// ordinary child: it is a full-screen TUI, and crossterm does NOT read the
|
|
57
|
+
/// keyboard from inherited fd 0. It opens `CONIN$` (crossterm_winapi
|
|
58
|
+
/// `Handle::current_in_handle`), i.e. the input buffer of **the console this
|
|
59
|
+
/// process is attached to**. Hide the window and the two diverge: the frame
|
|
60
|
+
/// renders fine over the inherited output handle while keystrokes are read
|
|
61
|
+
/// from the freshly allocated, forever-empty buffer.
|
|
62
|
+
///
|
|
63
|
+
/// So: when the parent is already attached to a console, never hide — there is
|
|
64
|
+
/// no window to suppress in that case anyway, which is the only thing the flag
|
|
65
|
+
/// was ever wanted for. When it is not (spawned from a GUI app, a service, or
|
|
66
|
+
/// any other windowless context), keep hiding so no console box flashes up.
|
|
67
|
+
///
|
|
68
|
+
/// Non-Windows platforms ignore the option entirely; keep passing `true` there
|
|
69
|
+
/// so this stays a Windows-only behaviour change.
|
|
70
|
+
function shouldHideWindow({ platform, stdinIsTTY, stdoutIsTTY, stderrIsTTY }) {
|
|
71
|
+
if (platform !== "win32") {
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
// Any std stream being a TTY proves a console is attached. Checking all three
|
|
75
|
+
// (rather than just stdin) keeps redirection from producing a false negative:
|
|
76
|
+
// `codem < input.txt` still has a console, and hiding it there would break
|
|
77
|
+
// the keyboard for exactly the same reason.
|
|
78
|
+
const attachedToConsole = Boolean(stdinIsTTY || stdoutIsTTY || stderrIsTTY);
|
|
79
|
+
return !attachedToConsole;
|
|
80
|
+
}
|
|
81
|
+
|
|
47
82
|
function reportFatal({ error, binary, platform, stderr, exit }) {
|
|
48
83
|
stderr(`linco: failed to launch ${binary}`);
|
|
49
84
|
stderr(` ${error && error.message ? error.message : String(error)}`);
|
|
@@ -68,12 +103,21 @@ function launch({
|
|
|
68
103
|
args,
|
|
69
104
|
stdio,
|
|
70
105
|
platform = process.platform,
|
|
106
|
+
stdinIsTTY = process.stdin.isTTY,
|
|
107
|
+
stdoutIsTTY = process.stdout.isTTY,
|
|
108
|
+
stderrIsTTY = process.stderr.isTTY,
|
|
71
109
|
spawnImpl = require("node:child_process").spawn,
|
|
72
110
|
stderr = (line) => console.error(line),
|
|
73
111
|
exit = (code) => process.exit(code),
|
|
74
112
|
}) {
|
|
113
|
+
const windowsHide = shouldHideWindow({
|
|
114
|
+
platform,
|
|
115
|
+
stdinIsTTY,
|
|
116
|
+
stdoutIsTTY,
|
|
117
|
+
stderrIsTTY,
|
|
118
|
+
});
|
|
75
119
|
const attempt = (stdioForAttempt) =>
|
|
76
|
-
spawnImpl(binary, args, { stdio: stdioForAttempt, windowsHide
|
|
120
|
+
spawnImpl(binary, args, { stdio: stdioForAttempt, windowsHide });
|
|
77
121
|
|
|
78
122
|
let child;
|
|
79
123
|
try {
|
|
@@ -103,4 +147,4 @@ function launch({
|
|
|
103
147
|
return child;
|
|
104
148
|
}
|
|
105
149
|
|
|
106
|
-
module.exports = { launch, hintsFor };
|
|
150
|
+
module.exports = { launch, hintsFor, shouldHideWindow };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lark-codem/codem-core",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.6-windows-input-diagnostics.202608191130.0.g715d8fa",
|
|
4
4
|
"description": "CodeM CLI.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"bin": {
|
|
@@ -11,15 +11,11 @@
|
|
|
11
11
|
"LICENSE"
|
|
12
12
|
],
|
|
13
13
|
"optionalDependencies": {
|
|
14
|
-
"@lark-codem/codem-core-darwin-arm64": "0.8.
|
|
15
|
-
"@lark-codem/codem-core-
|
|
16
|
-
"@lark-codem/codem-core-linux-
|
|
17
|
-
"@lark-codem/codem-core-
|
|
18
|
-
"@lark-codem/codem-core-
|
|
19
|
-
"@lark-codem/codem-core-linux-x64-musl": "0.8.5",
|
|
20
|
-
"@lark-codem/codem-core-win32-arm64-gnu": "0.8.5",
|
|
21
|
-
"@lark-codem/codem-core-win32-ia32-gnu": "0.8.5",
|
|
22
|
-
"@lark-codem/codem-core-win32-x64-gnu": "0.8.5"
|
|
14
|
+
"@lark-codem/codem-core-darwin-arm64": "0.8.6-windows-input-diagnostics.202608191130.0.g715d8fa",
|
|
15
|
+
"@lark-codem/codem-core-linux-arm64-gnu": "0.8.6-windows-input-diagnostics.202608191130.0.g715d8fa",
|
|
16
|
+
"@lark-codem/codem-core-linux-x64-gnu": "0.8.6-windows-input-diagnostics.202608191130.0.g715d8fa",
|
|
17
|
+
"@lark-codem/codem-core-win32-arm64-gnu": "0.8.6-windows-input-diagnostics.202608191130.0.g715d8fa",
|
|
18
|
+
"@lark-codem/codem-core-win32-x64-gnu": "0.8.6-windows-input-diagnostics.202608191130.0.g715d8fa"
|
|
23
19
|
},
|
|
24
20
|
"engines": {
|
|
25
21
|
"node": ">=18"
|