tycono 0.1.96-beta.52 → 0.1.96-beta.53
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/tycono.ts +9 -25
- package/package.json +1 -1
package/bin/tycono.ts
CHANGED
|
@@ -221,40 +221,24 @@ async function startServerForTui(): Promise<void> {
|
|
|
221
221
|
const origStdoutWrite = process.stdout.write.bind(process.stdout);
|
|
222
222
|
const origLog = (...args: unknown[]) => origStdoutWrite(args.join(' ') + '\n');
|
|
223
223
|
|
|
224
|
-
//
|
|
225
|
-
//
|
|
226
|
-
|
|
227
|
-
console.log = (...a: unknown[]) => logStream.write(a.join(' ') + '\n');
|
|
228
|
-
console.error = (...a: unknown[]) => logStream.write(a.join(' ') + '\n');
|
|
229
|
-
console.warn = (...a: unknown[]) => logStream.write(a.join(' ') + '\n');
|
|
230
|
-
console.info = (...a: unknown[]) => logStream.write(a.join(' ') + '\n');
|
|
224
|
+
// Redirect console methods to log file BEFORE importing server code
|
|
225
|
+
// This is the ONLY output suppression — NO stdout.write hijacking
|
|
226
|
+
// Ink needs full control of stdout.write, any interception breaks rendering
|
|
227
|
+
console.log = (...a: unknown[]) => { logStream.write(a.join(' ') + '\n'); };
|
|
228
|
+
console.error = (...a: unknown[]) => { logStream.write(a.join(' ') + '\n'); };
|
|
229
|
+
console.warn = (...a: unknown[]) => { logStream.write(a.join(' ') + '\n'); };
|
|
230
|
+
console.info = (...a: unknown[]) => { logStream.write(a.join(' ') + '\n'); };
|
|
231
231
|
|
|
232
232
|
const { createHttpServer } = await import('../src/api/src/create-server.js');
|
|
233
233
|
const server = createHttpServer();
|
|
234
234
|
|
|
235
|
-
const host = process.env.HOST || '0.0.0.0';
|
|
236
|
-
|
|
237
235
|
await new Promise<void>((resolve) => {
|
|
238
|
-
server.listen(port,
|
|
236
|
+
server.listen(port, '0.0.0.0', () => resolve());
|
|
239
237
|
});
|
|
240
238
|
|
|
241
239
|
origLog(` API server started on port ${port}`);
|
|
242
240
|
origLog(` Logs: ${logFile}`);
|
|
243
241
|
|
|
244
|
-
// Now hijack stdout.write AFTER server started but BEFORE Ink
|
|
245
|
-
// Block non-Ink output from reaching terminal
|
|
246
|
-
// Ink always writes ANSI escape sequences — server text output doesn't
|
|
247
|
-
process.stdout.write = ((chunk: any, ...args: any[]) => {
|
|
248
|
-
const str = typeof chunk === 'string' ? chunk : chunk.toString();
|
|
249
|
-
// Ink output: contains ANSI CSI sequences
|
|
250
|
-
if (str.includes('\x1b[') || str.includes('\x1b(')) {
|
|
251
|
-
return origStdoutWrite(chunk, ...args);
|
|
252
|
-
}
|
|
253
|
-
// Non-Ink (server log leaked): redirect to file
|
|
254
|
-
logStream.write(str);
|
|
255
|
-
return true;
|
|
256
|
-
}) as any;
|
|
257
|
-
|
|
258
242
|
// Graceful shutdown
|
|
259
243
|
const shutdown = () => {
|
|
260
244
|
server.close(() => process.exit(0));
|
|
@@ -263,7 +247,7 @@ async function startServerForTui(): Promise<void> {
|
|
|
263
247
|
process.on('SIGINT', shutdown);
|
|
264
248
|
process.on('SIGTERM', shutdown);
|
|
265
249
|
|
|
266
|
-
// Start TUI
|
|
250
|
+
// Start TUI — stdout.write is NOT intercepted, Ink has full control
|
|
267
251
|
const { startTui } = await import('../src/tui/index.tsx');
|
|
268
252
|
await startTui({ port });
|
|
269
253
|
}
|