@opentui/core 0.0.0-20250922-6d7f4921 → 0.0.0-20250922-ce4434a8

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/3d.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  __export,
6
6
  __require,
7
7
  __toESM
8
- } from "./index-ra8j4k81.js";
8
+ } from "./index-qgmnmj4t.js";
9
9
 
10
10
  // ../../node_modules/omggif/omggif.js
11
11
  var require_omggif = __commonJS((exports) => {
package/ansi.d.ts CHANGED
@@ -23,6 +23,5 @@ export declare const ANSI: {
23
23
  disableAnyEventTracking: string;
24
24
  enableSGRMouseMode: string;
25
25
  disableSGRMouseMode: string;
26
- makeRoomForRenderer: (height: number) => string;
27
26
  clearRendererSpace: (height: number) => string;
28
27
  };
@@ -2189,6 +2189,7 @@ function singleton(key, factory) {
2189
2189
  class KeyHandler extends EventEmitter {
2190
2190
  stdin;
2191
2191
  useKittyKeyboard;
2192
+ listener;
2192
2193
  constructor(stdin, useKittyKeyboard = false) {
2193
2194
  super();
2194
2195
  this.stdin = stdin || process.stdin;
@@ -2198,7 +2199,7 @@ class KeyHandler extends EventEmitter {
2198
2199
  }
2199
2200
  this.stdin.resume();
2200
2201
  this.stdin.setEncoding("utf8");
2201
- this.stdin.on("data", (key) => {
2202
+ this.listener = (key) => {
2202
2203
  const parsedKey = parseKeypress(key, { useKittyKeyboard: this.useKittyKeyboard });
2203
2204
  switch (parsedKey.eventType) {
2204
2205
  case "press":
@@ -2214,10 +2215,15 @@ class KeyHandler extends EventEmitter {
2214
2215
  this.emit("keypress", parsedKey);
2215
2216
  break;
2216
2217
  }
2217
- });
2218
+ };
2219
+ this.stdin.on("data", this.listener);
2218
2220
  }
2219
2221
  destroy() {
2220
- this.stdin.removeAllListeners("data");
2222
+ this.stdin.removeListener("data", this.listener);
2223
+ if (this.stdin.setRawMode) {
2224
+ this.stdin.setRawMode(false);
2225
+ }
2226
+ keyHandler = null;
2221
2227
  }
2222
2228
  }
2223
2229
  var keyHandler = null;
@@ -8135,8 +8141,6 @@ var ANSI = {
8135
8141
  disableAnyEventTracking: "\x1B[?1003l",
8136
8142
  enableSGRMouseMode: "\x1B[?1006h",
8137
8143
  disableSGRMouseMode: "\x1B[?1006l",
8138
- makeRoomForRenderer: (height) => `
8139
- `.repeat(height) + `\x1B[${height}A`,
8140
8144
  clearRendererSpace: (height) => `\x1B[${height}A\x1B[1G\x1B[J`
8141
8145
  };
8142
8146
 
@@ -8270,6 +8274,21 @@ singleton("ProcessExitSignals", () => {
8270
8274
  });
8271
8275
  });
8272
8276
  });
8277
+ var rendererTracker = singleton("RendererTracker", () => {
8278
+ const renderers = new Set;
8279
+ return {
8280
+ addRenderer: (renderer) => {
8281
+ renderers.add(renderer);
8282
+ },
8283
+ removeRenderer: (renderer) => {
8284
+ renderers.delete(renderer);
8285
+ if (renderers.size === 0) {
8286
+ getKeyHandler().destroy();
8287
+ process.stdin.pause();
8288
+ }
8289
+ }
8290
+ };
8291
+ });
8273
8292
  async function createCliRenderer(config = {}) {
8274
8293
  if (process.argv.includes("--delay-start")) {
8275
8294
  await new Promise((resolve) => setTimeout(resolve, 5000));
@@ -8401,17 +8420,7 @@ class CliRenderer extends EventEmitter5 {
8401
8420
  this.realStdoutWrite.call(this.stdout, `
8402
8421
  === FATAL ERROR OCCURRED ===
8403
8422
  `);
8404
- this.realStdoutWrite.call(this.stdout, `Console cache:
8405
- `);
8406
- this.realStdoutWrite.call(this.stdout, this.console.getCachedLogs());
8407
- this.realStdoutWrite.call(this.stdout, `
8408
- Captured output:
8409
- `);
8410
- const capturedOutput = capture.claimOutput();
8411
- if (capturedOutput) {
8412
- this.realStdoutWrite.call(this.stdout, capturedOutput + `
8413
- `);
8414
- }
8423
+ this.dumpOutputCache();
8415
8424
  this.realStdoutWrite.call(this.stdout, `
8416
8425
  Error details:
8417
8426
  `);
@@ -8424,7 +8433,31 @@ Error details:
8424
8433
  process.exit(1);
8425
8434
  });
8426
8435
  }).bind(this);
8436
+ dumpOutputCache(optionalMessage = "") {
8437
+ const cachedLogs = this.console.getCachedLogs();
8438
+ const capturedOutput = capture.claimOutput();
8439
+ if (capturedOutput.length > 0 || cachedLogs.length > 0) {
8440
+ this.realStdoutWrite.call(this.stdout, optionalMessage);
8441
+ }
8442
+ if (cachedLogs.length > 0) {
8443
+ this.realStdoutWrite.call(this.stdout, `Console cache:
8444
+ `);
8445
+ this.realStdoutWrite.call(this.stdout, cachedLogs);
8446
+ }
8447
+ if (capturedOutput.length > 0) {
8448
+ this.realStdoutWrite.call(this.stdout, `
8449
+ Captured output:
8450
+ `);
8451
+ this.realStdoutWrite.call(this.stdout, capturedOutput + `
8452
+ `);
8453
+ }
8454
+ }
8427
8455
  exitHandler = (() => {
8456
+ if (true) {
8457
+ this.dumpOutputCache(`
8458
+ === UNHANDLED OUTPUT (this is only printed in non-production environments) ===
8459
+ `);
8460
+ }
8428
8461
  this.destroy();
8429
8462
  }).bind(this);
8430
8463
  warningHandler = ((warning) => {
@@ -8432,6 +8465,7 @@ Error details:
8432
8465
  }).bind(this);
8433
8466
  constructor(lib, rendererPtr, stdin, stdout, width, height, config = {}) {
8434
8467
  super();
8468
+ rendererTracker.addRenderer(this);
8435
8469
  this.stdin = stdin;
8436
8470
  this.stdout = stdout;
8437
8471
  this.realStdoutWrite = stdout.write;
@@ -8732,7 +8766,7 @@ Error details:
8732
8766
  }
8733
8767
  if (this.exitOnCtrlC && str === "\x03") {
8734
8768
  process.nextTick(() => {
8735
- process.exit();
8769
+ this.destroy();
8736
8770
  });
8737
8771
  return;
8738
8772
  }
@@ -9089,7 +9123,6 @@ Error details:
9089
9123
  process.removeListener("SIGWINCH", this.sigwinchHandler);
9090
9124
  process.removeListener("uncaughtException", this.handleError);
9091
9125
  process.removeListener("unhandledRejection", this.handleError);
9092
- process.removeListener("exit", this.exitHandler);
9093
9126
  process.removeListener("warning", this.warningHandler);
9094
9127
  capture.removeListener("write", this.captureCallback);
9095
9128
  if (this.memorySnapshotTimer) {
@@ -9111,6 +9144,7 @@ Error details:
9111
9144
  this.flushStdoutCache(this._splitHeight, true);
9112
9145
  }
9113
9146
  this.lib.destroyRenderer(this.rendererPtr);
9147
+ rendererTracker.removeRenderer(this);
9114
9148
  }
9115
9149
  startRenderLoop() {
9116
9150
  if (!this._isRunning)
@@ -9336,5 +9370,5 @@ Error details:
9336
9370
 
9337
9371
  export { __toESM, __commonJS, __export, __require, Edge, Gutter, exports_src, BorderChars, getBorderFromSides, getBorderSides, borderCharsToArray, BorderCharArrays, nonAlphanumericKeys, parseKeypress, KeyHandler, getKeyHandler, RGBA, hexToRgb, rgbToHex, hsvToRgb, parseColor, fonts, measureText, getCharacterPositions, coordinateToCharacterIndex, renderFontToFrameBuffer, TextAttributes, DebugOverlayCorner, createTextAttributes, visualizeRenderableTree, isStyledText, StyledText, stringToStyledText, black, red, green, yellow, blue, magenta, cyan, white, brightBlack, brightRed, brightGreen, brightYellow, brightBlue, brightMagenta, brightCyan, brightWhite, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, bold, italic, underline, strikethrough, dim, reverse, blink, fg, bg, t, SyntaxStyle, hastToStyledText, parseAlign, parseBoxSizing, parseDimension, parseDirection, parseDisplay, parseEdge, parseFlexDirection, parseGutter, parseJustify, parseLogLevel, parseMeasureMode, parseOverflow, parsePositionType, parseUnit, parseWrap, MouseParser, Selection, convertGlobalToLocalSelection, ASCIIFontSelectionHelper, TextBuffer, LogLevel2 as LogLevel, setRenderLibPath, resolveRenderLib, OptimizedBuffer, h, isVNode, maybeMakeRenderable, wrapWithDelegates, instantiate, delegate, isValidPercentage, LayoutEvents, RenderableEvents, isRenderable, BaseRenderable, Renderable, RootRenderable, capture, ConsolePosition, TerminalConsole, getObjectsInViewport, MouseEvent, MouseButton, createCliRenderer, CliRenderEvents, CliRenderer };
9338
9372
 
9339
- //# debugId=14D9680358C8A23C64756E2164756E21
9340
- //# sourceMappingURL=index-ra8j4k81.js.map
9373
+ //# debugId=79C4862CCD9B2E9164756E2164756E21
9374
+ //# sourceMappingURL=index-qgmnmj4t.js.map