@opentui/core 0.1.6 → 0.1.7

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
@@ -34873,7 +34873,7 @@ function getOpenTUILib(libPath) {
34873
34873
  returns: "ptr"
34874
34874
  },
34875
34875
  destroyRenderer: {
34876
- args: ["ptr"],
34876
+ args: ["ptr", "bool", "u32"],
34877
34877
  returns: "void"
34878
34878
  },
34879
34879
  setUseThread: {
@@ -35028,6 +35028,14 @@ function getOpenTUILib(libPath) {
35028
35028
  args: ["ptr", "i64"],
35029
35029
  returns: "void"
35030
35030
  },
35031
+ enableMouse: {
35032
+ args: ["ptr", "bool"],
35033
+ returns: "void"
35034
+ },
35035
+ disableMouse: {
35036
+ args: ["ptr"],
35037
+ returns: "void"
35038
+ },
35031
35039
  createTextBuffer: {
35032
35040
  args: ["u32"],
35033
35041
  returns: "ptr"
@@ -35136,8 +35144,8 @@ class FFIRenderLib {
35136
35144
  createRenderer(width, height) {
35137
35145
  return this.opentui.symbols.createRenderer(width, height);
35138
35146
  }
35139
- destroyRenderer(renderer) {
35140
- this.opentui.symbols.destroyRenderer(renderer);
35147
+ destroyRenderer(renderer, useAlternateScreen, splitHeight) {
35148
+ this.opentui.symbols.destroyRenderer(renderer, useAlternateScreen, splitHeight);
35141
35149
  }
35142
35150
  setUseThread(renderer, useThread) {
35143
35151
  this.opentui.symbols.setUseThread(renderer, useThread);
@@ -35347,6 +35355,12 @@ class FFIRenderLib {
35347
35355
  const ts = timestamp ?? Date.now();
35348
35356
  this.opentui.symbols.dumpStdoutBuffer(renderer, ts);
35349
35357
  }
35358
+ enableMouse(renderer, enableMovement) {
35359
+ this.opentui.symbols.enableMouse(renderer, enableMovement);
35360
+ }
35361
+ disableMouse(renderer) {
35362
+ this.opentui.symbols.disableMouse(renderer);
35363
+ }
35350
35364
  createTextBuffer(capacity) {
35351
35365
  const bufferPtr = this.opentui.symbols.createTextBuffer(capacity);
35352
35366
  if (!bufferPtr) {
@@ -36204,7 +36218,10 @@ var ANSI = {
36204
36218
  enableAnyEventTracking: "\x1B[?1003h",
36205
36219
  disableAnyEventTracking: "\x1B[?1003l",
36206
36220
  enableSGRMouseMode: "\x1B[?1006h",
36207
- disableSGRMouseMode: "\x1B[?1006l"
36221
+ disableSGRMouseMode: "\x1B[?1006l",
36222
+ makeRoomForRenderer: (height) => `
36223
+ `.repeat(height) + `\x1B[${height}A`,
36224
+ clearRendererSpace: (height) => `\x1B[${height}A\x1B[1G\x1B[J`
36208
36225
  };
36209
36226
 
36210
36227
  // src/console.ts
@@ -36987,6 +37004,11 @@ class MouseEvent {
36987
37004
  this._defaultPrevented = true;
36988
37005
  }
36989
37006
  }
37007
+ ["SIGINT", "SIGTERM", "SIGQUIT", "SIGABRT"].forEach((signal) => {
37008
+ process.on(signal, () => {
37009
+ process.exit();
37010
+ });
37011
+ });
36990
37012
  var animationFrameId = 0;
36991
37013
 
36992
37014
  class CliRenderer extends EventEmitter6 {
@@ -36996,7 +37018,6 @@ class CliRenderer extends EventEmitter6 {
36996
37018
  stdout;
36997
37019
  exitOnCtrlC;
36998
37020
  isDestroyed = false;
36999
- isShuttingDown = false;
37000
37021
  nextRenderBuffer;
37001
37022
  currentRenderBuffer;
37002
37023
  _isRunning = false;
@@ -37018,6 +37039,7 @@ class CliRenderer extends EventEmitter6 {
37018
37039
  postProcessFns = [];
37019
37040
  backgroundColor = RGBA.fromHex("#000000");
37020
37041
  waitingForPixelResolution = false;
37042
+ shutdownRequested = null;
37021
37043
  rendering = false;
37022
37044
  renderingNative = false;
37023
37045
  renderTimeout = null;
@@ -37121,8 +37143,6 @@ class CliRenderer extends EventEmitter6 {
37121
37143
  }
37122
37144
  this.stdout.write = this.interceptStdoutWrite.bind(this);
37123
37145
  this.sigwinchHandler = () => {
37124
- if (this.isShuttingDown)
37125
- return;
37126
37146
  const width2 = this.stdout.columns || 80;
37127
37147
  const height2 = this.stdout.rows || 24;
37128
37148
  this.handleResize(width2, height2);
@@ -37130,6 +37150,7 @@ class CliRenderer extends EventEmitter6 {
37130
37150
  process.on("SIGWINCH", this.sigwinchHandler);
37131
37151
  const handleError = (error) => {
37132
37152
  this.stop();
37153
+ this.destroy();
37133
37154
  new Promise((resolve2) => {
37134
37155
  setTimeout(() => {
37135
37156
  resolve2(true);
@@ -37163,8 +37184,7 @@ Error details:
37163
37184
  };
37164
37185
  process.on("uncaughtException", handleError);
37165
37186
  process.on("unhandledRejection", handleError);
37166
- process.on("exit", (code) => {
37167
- this.stop();
37187
+ process.on("exit", () => {
37168
37188
  this.destroy();
37169
37189
  });
37170
37190
  this._console = new TerminalConsole(this, config.consoleOptions);
@@ -37183,6 +37203,13 @@ Error details:
37183
37203
  }
37184
37204
  global.window.requestAnimationFrame = requestAnimationFrame;
37185
37205
  this.queryPixelResolution();
37206
+ if (process.env.OTUI_NO_NATIVE_RENDER === "true") {
37207
+ this.renderNative = () => {
37208
+ if (this._splitHeight > 0) {
37209
+ this.flushStdoutCache(this._splitHeight);
37210
+ }
37211
+ };
37212
+ }
37186
37213
  }
37187
37214
  writeOut(chunk, encoding, callback) {
37188
37215
  return this.realStdoutWrite.call(this.stdout, chunk, encoding, callback);
@@ -37314,30 +37341,17 @@ Error details:
37314
37341
  return true;
37315
37342
  }
37316
37343
  enableMouse() {
37317
- this.writeOut(ANSI.enableSGRMouseMode);
37318
- this.writeOut(ANSI.enableMouseTracking);
37319
- this.writeOut(ANSI.enableButtonEventTracking);
37320
- if (this.enableMouseMovement) {
37321
- this.writeOut(ANSI.enableAnyEventTracking);
37322
- }
37344
+ this.lib.enableMouse(this.rendererPtr, this.enableMouseMovement);
37323
37345
  }
37324
37346
  disableMouse() {
37325
- if (this.enableMouseMovement) {
37326
- this.writeOut(ANSI.disableAnyEventTracking);
37327
- }
37328
- this.writeOut(ANSI.disableButtonEventTracking);
37329
- this.writeOut(ANSI.disableMouseTracking);
37330
- this.writeOut(ANSI.disableSGRMouseMode);
37331
37347
  this.capturedRenderable = undefined;
37332
37348
  this.mouseParser.reset();
37349
+ this.lib.disableMouse(this.rendererPtr);
37333
37350
  }
37334
37351
  set useThread(useThread) {
37335
37352
  this._useThread = useThread;
37336
37353
  this.lib.setUseThread(this.rendererPtr, useThread);
37337
37354
  }
37338
- setTerminalSize(width, height) {
37339
- this.handleResize(width, height);
37340
- }
37341
37355
  setupTerminal() {
37342
37356
  this.writeOut(ANSI.saveCursorState);
37343
37357
  if (this.stdin.setRawMode) {
@@ -37364,7 +37378,7 @@ Error details:
37364
37378
  }
37365
37379
  if (this.exitOnCtrlC && str === "\x03") {
37366
37380
  process.nextTick(() => {
37367
- process.exit(0);
37381
+ process.exit();
37368
37382
  });
37369
37383
  return;
37370
37384
  }
@@ -37375,6 +37389,8 @@ Error details:
37375
37389
  });
37376
37390
  if (this._useAlternateScreen) {
37377
37391
  this.writeOut(ANSI.switchToAlternateScreen);
37392
+ } else {
37393
+ this.writeOut(ANSI.makeRoomForRenderer(this.height - 1));
37378
37394
  }
37379
37395
  this.setCursorPosition(0, 0, false);
37380
37396
  }
@@ -37496,7 +37512,7 @@ Error details:
37496
37512
  }
37497
37513
  }
37498
37514
  handleResize(width, height) {
37499
- if (this.isShuttingDown)
37515
+ if (this.isDestroyed)
37500
37516
  return;
37501
37517
  if (this._splitHeight > 0) {
37502
37518
  this.processResize(width, height);
@@ -37633,44 +37649,31 @@ Error details:
37633
37649
  this._isRunning = false;
37634
37650
  }
37635
37651
  stop() {
37636
- if (this.isShuttingDown)
37652
+ if (this.isRunning && !this.isDestroyed) {
37653
+ this._isRunning = false;
37654
+ if (this.memorySnapshotTimer) {
37655
+ clearInterval(this.memorySnapshotTimer);
37656
+ this.memorySnapshotTimer = null;
37657
+ }
37658
+ if (this.renderTimeout) {
37659
+ clearTimeout(this.renderTimeout);
37660
+ this.renderTimeout = null;
37661
+ }
37662
+ }
37663
+ }
37664
+ destroy() {
37665
+ if (this.isDestroyed)
37637
37666
  return;
37638
- this._isRunning = false;
37639
- this.isShuttingDown = true;
37667
+ this.isDestroyed = true;
37640
37668
  this.waitingForPixelResolution = false;
37669
+ this.capturedRenderable = undefined;
37641
37670
  if (this.sigwinchHandler) {
37642
37671
  process.removeListener("SIGWINCH", this.sigwinchHandler);
37643
37672
  this.sigwinchHandler = null;
37644
37673
  }
37645
37674
  this._console.deactivate();
37675
+ this.lib.destroyRenderer(this.rendererPtr, this._useAlternateScreen, this._splitHeight);
37646
37676
  this.disableStdoutInterception();
37647
- if (this.renderTimeout) {
37648
- clearTimeout(this.renderTimeout);
37649
- this.renderTimeout = null;
37650
- }
37651
- if (this.memorySnapshotTimer) {
37652
- clearInterval(this.memorySnapshotTimer);
37653
- this.memorySnapshotTimer = null;
37654
- }
37655
- if (this._splitHeight > 0) {
37656
- const consoleEndLine = this._terminalHeight - this._splitHeight;
37657
- this.writeOut(ANSI.moveCursor(consoleEndLine, 1));
37658
- }
37659
- this.capturedRenderable = undefined;
37660
- if (this._useMouse) {
37661
- this.disableMouse();
37662
- }
37663
- this.writeOut(ANSI.resetCursorColor);
37664
- this.writeOut(ANSI.showCursor);
37665
- if (this._useAlternateScreen) {
37666
- this.writeOut(ANSI.switchToMainScreen);
37667
- }
37668
- }
37669
- destroy() {
37670
- if (this.isDestroyed)
37671
- return;
37672
- this.lib.destroyRenderer(this.rendererPtr);
37673
- this.isDestroyed = true;
37674
37677
  }
37675
37678
  startRenderLoop() {
37676
37679
  if (!this._isRunning)
@@ -37683,7 +37686,7 @@ Error details:
37683
37686
  this.loop();
37684
37687
  }
37685
37688
  async loop() {
37686
- if (this.rendering)
37689
+ if (this.rendering || this.isDestroyed)
37687
37690
  return;
37688
37691
  this.rendering = true;
37689
37692
  if (this.renderTimeout) {
@@ -37989,8 +37992,8 @@ class TextRenderable extends Renderable {
37989
37992
  const changed = this.selectionHelper.reevaluateSelection(this.width, this.height);
37990
37993
  if (changed) {
37991
37994
  this.syncSelectionToTextBuffer();
37992
- this.needsUpdate();
37993
37995
  }
37996
+ this.needsUpdate();
37994
37997
  }
37995
37998
  setupMeasureFunc() {
37996
37999
  if (this._positionType === "relative" && this._width === "auto") {
package/README.md CHANGED
@@ -3,6 +3,8 @@
3
3
  OpenTUI Core is a TypeScript library for building terminal user interfaces (TUIs). It is currently in
4
4
  development and is not ready for production use.
5
5
 
6
+ [Getting Started](docs/getting-started.md)
7
+
6
8
  ## Install
7
9
 
8
10
  ```bash
package/ansi.d.ts CHANGED
@@ -23,4 +23,6 @@ export declare const ANSI: {
23
23
  disableAnyEventTracking: string;
24
24
  enableSGRMouseMode: string;
25
25
  disableSGRMouseMode: string;
26
+ makeRoomForRenderer: (height: number) => string;
27
+ clearRendererSpace: (height: number) => string;
26
28
  };
package/index.js CHANGED
@@ -3160,7 +3160,7 @@ function getOpenTUILib(libPath) {
3160
3160
  returns: "ptr"
3161
3161
  },
3162
3162
  destroyRenderer: {
3163
- args: ["ptr"],
3163
+ args: ["ptr", "bool", "u32"],
3164
3164
  returns: "void"
3165
3165
  },
3166
3166
  setUseThread: {
@@ -3315,6 +3315,14 @@ function getOpenTUILib(libPath) {
3315
3315
  args: ["ptr", "i64"],
3316
3316
  returns: "void"
3317
3317
  },
3318
+ enableMouse: {
3319
+ args: ["ptr", "bool"],
3320
+ returns: "void"
3321
+ },
3322
+ disableMouse: {
3323
+ args: ["ptr"],
3324
+ returns: "void"
3325
+ },
3318
3326
  createTextBuffer: {
3319
3327
  args: ["u32"],
3320
3328
  returns: "ptr"
@@ -3423,8 +3431,8 @@ class FFIRenderLib {
3423
3431
  createRenderer(width, height) {
3424
3432
  return this.opentui.symbols.createRenderer(width, height);
3425
3433
  }
3426
- destroyRenderer(renderer) {
3427
- this.opentui.symbols.destroyRenderer(renderer);
3434
+ destroyRenderer(renderer, useAlternateScreen, splitHeight) {
3435
+ this.opentui.symbols.destroyRenderer(renderer, useAlternateScreen, splitHeight);
3428
3436
  }
3429
3437
  setUseThread(renderer, useThread) {
3430
3438
  this.opentui.symbols.setUseThread(renderer, useThread);
@@ -3634,6 +3642,12 @@ class FFIRenderLib {
3634
3642
  const ts = timestamp ?? Date.now();
3635
3643
  this.opentui.symbols.dumpStdoutBuffer(renderer, ts);
3636
3644
  }
3645
+ enableMouse(renderer, enableMovement) {
3646
+ this.opentui.symbols.enableMouse(renderer, enableMovement);
3647
+ }
3648
+ disableMouse(renderer) {
3649
+ this.opentui.symbols.disableMouse(renderer);
3650
+ }
3637
3651
  createTextBuffer(capacity) {
3638
3652
  const bufferPtr = this.opentui.symbols.createTextBuffer(capacity);
3639
3653
  if (!bufferPtr) {
@@ -7442,7 +7456,10 @@ var ANSI = {
7442
7456
  enableAnyEventTracking: "\x1B[?1003h",
7443
7457
  disableAnyEventTracking: "\x1B[?1003l",
7444
7458
  enableSGRMouseMode: "\x1B[?1006h",
7445
- disableSGRMouseMode: "\x1B[?1006l"
7459
+ disableSGRMouseMode: "\x1B[?1006l",
7460
+ makeRoomForRenderer: (height) => `
7461
+ `.repeat(height) + `\x1B[${height}A`,
7462
+ clearRendererSpace: (height) => `\x1B[${height}A\x1B[1G\x1B[J`
7446
7463
  };
7447
7464
 
7448
7465
  // src/console.ts
@@ -8240,6 +8257,11 @@ var MouseButton;
8240
8257
  MouseButton2[MouseButton2["WHEEL_UP"] = 4] = "WHEEL_UP";
8241
8258
  MouseButton2[MouseButton2["WHEEL_DOWN"] = 5] = "WHEEL_DOWN";
8242
8259
  })(MouseButton ||= {});
8260
+ ["SIGINT", "SIGTERM", "SIGQUIT", "SIGABRT"].forEach((signal) => {
8261
+ process.on(signal, () => {
8262
+ process.exit();
8263
+ });
8264
+ });
8243
8265
  async function createCliRenderer(config = {}) {
8244
8266
  if (process.argv.includes("--delay-start")) {
8245
8267
  await new Promise((resolve) => setTimeout(resolve, 5000));
@@ -8276,7 +8298,6 @@ class CliRenderer extends EventEmitter6 {
8276
8298
  stdout;
8277
8299
  exitOnCtrlC;
8278
8300
  isDestroyed = false;
8279
- isShuttingDown = false;
8280
8301
  nextRenderBuffer;
8281
8302
  currentRenderBuffer;
8282
8303
  _isRunning = false;
@@ -8298,6 +8319,7 @@ class CliRenderer extends EventEmitter6 {
8298
8319
  postProcessFns = [];
8299
8320
  backgroundColor = RGBA.fromHex("#000000");
8300
8321
  waitingForPixelResolution = false;
8322
+ shutdownRequested = null;
8301
8323
  rendering = false;
8302
8324
  renderingNative = false;
8303
8325
  renderTimeout = null;
@@ -8401,8 +8423,6 @@ class CliRenderer extends EventEmitter6 {
8401
8423
  }
8402
8424
  this.stdout.write = this.interceptStdoutWrite.bind(this);
8403
8425
  this.sigwinchHandler = () => {
8404
- if (this.isShuttingDown)
8405
- return;
8406
8426
  const width2 = this.stdout.columns || 80;
8407
8427
  const height2 = this.stdout.rows || 24;
8408
8428
  this.handleResize(width2, height2);
@@ -8410,6 +8430,7 @@ class CliRenderer extends EventEmitter6 {
8410
8430
  process.on("SIGWINCH", this.sigwinchHandler);
8411
8431
  const handleError = (error) => {
8412
8432
  this.stop();
8433
+ this.destroy();
8413
8434
  new Promise((resolve) => {
8414
8435
  setTimeout(() => {
8415
8436
  resolve(true);
@@ -8443,8 +8464,7 @@ Error details:
8443
8464
  };
8444
8465
  process.on("uncaughtException", handleError);
8445
8466
  process.on("unhandledRejection", handleError);
8446
- process.on("exit", (code) => {
8447
- this.stop();
8467
+ process.on("exit", () => {
8448
8468
  this.destroy();
8449
8469
  });
8450
8470
  this._console = new TerminalConsole(this, config.consoleOptions);
@@ -8463,6 +8483,13 @@ Error details:
8463
8483
  }
8464
8484
  global.window.requestAnimationFrame = requestAnimationFrame;
8465
8485
  this.queryPixelResolution();
8486
+ if (process.env.OTUI_NO_NATIVE_RENDER === "true") {
8487
+ this.renderNative = () => {
8488
+ if (this._splitHeight > 0) {
8489
+ this.flushStdoutCache(this._splitHeight);
8490
+ }
8491
+ };
8492
+ }
8466
8493
  }
8467
8494
  writeOut(chunk, encoding, callback) {
8468
8495
  return this.realStdoutWrite.call(this.stdout, chunk, encoding, callback);
@@ -8594,30 +8621,17 @@ Error details:
8594
8621
  return true;
8595
8622
  }
8596
8623
  enableMouse() {
8597
- this.writeOut(ANSI.enableSGRMouseMode);
8598
- this.writeOut(ANSI.enableMouseTracking);
8599
- this.writeOut(ANSI.enableButtonEventTracking);
8600
- if (this.enableMouseMovement) {
8601
- this.writeOut(ANSI.enableAnyEventTracking);
8602
- }
8624
+ this.lib.enableMouse(this.rendererPtr, this.enableMouseMovement);
8603
8625
  }
8604
8626
  disableMouse() {
8605
- if (this.enableMouseMovement) {
8606
- this.writeOut(ANSI.disableAnyEventTracking);
8607
- }
8608
- this.writeOut(ANSI.disableButtonEventTracking);
8609
- this.writeOut(ANSI.disableMouseTracking);
8610
- this.writeOut(ANSI.disableSGRMouseMode);
8611
8627
  this.capturedRenderable = undefined;
8612
8628
  this.mouseParser.reset();
8629
+ this.lib.disableMouse(this.rendererPtr);
8613
8630
  }
8614
8631
  set useThread(useThread) {
8615
8632
  this._useThread = useThread;
8616
8633
  this.lib.setUseThread(this.rendererPtr, useThread);
8617
8634
  }
8618
- setTerminalSize(width, height) {
8619
- this.handleResize(width, height);
8620
- }
8621
8635
  setupTerminal() {
8622
8636
  this.writeOut(ANSI.saveCursorState);
8623
8637
  if (this.stdin.setRawMode) {
@@ -8644,7 +8658,7 @@ Error details:
8644
8658
  }
8645
8659
  if (this.exitOnCtrlC && str === "\x03") {
8646
8660
  process.nextTick(() => {
8647
- process.exit(0);
8661
+ process.exit();
8648
8662
  });
8649
8663
  return;
8650
8664
  }
@@ -8655,6 +8669,8 @@ Error details:
8655
8669
  });
8656
8670
  if (this._useAlternateScreen) {
8657
8671
  this.writeOut(ANSI.switchToAlternateScreen);
8672
+ } else {
8673
+ this.writeOut(ANSI.makeRoomForRenderer(this.height - 1));
8658
8674
  }
8659
8675
  this.setCursorPosition(0, 0, false);
8660
8676
  }
@@ -8776,7 +8792,7 @@ Error details:
8776
8792
  }
8777
8793
  }
8778
8794
  handleResize(width, height) {
8779
- if (this.isShuttingDown)
8795
+ if (this.isDestroyed)
8780
8796
  return;
8781
8797
  if (this._splitHeight > 0) {
8782
8798
  this.processResize(width, height);
@@ -8913,44 +8929,31 @@ Error details:
8913
8929
  this._isRunning = false;
8914
8930
  }
8915
8931
  stop() {
8916
- if (this.isShuttingDown)
8932
+ if (this.isRunning && !this.isDestroyed) {
8933
+ this._isRunning = false;
8934
+ if (this.memorySnapshotTimer) {
8935
+ clearInterval(this.memorySnapshotTimer);
8936
+ this.memorySnapshotTimer = null;
8937
+ }
8938
+ if (this.renderTimeout) {
8939
+ clearTimeout(this.renderTimeout);
8940
+ this.renderTimeout = null;
8941
+ }
8942
+ }
8943
+ }
8944
+ destroy() {
8945
+ if (this.isDestroyed)
8917
8946
  return;
8918
- this._isRunning = false;
8919
- this.isShuttingDown = true;
8947
+ this.isDestroyed = true;
8920
8948
  this.waitingForPixelResolution = false;
8949
+ this.capturedRenderable = undefined;
8921
8950
  if (this.sigwinchHandler) {
8922
8951
  process.removeListener("SIGWINCH", this.sigwinchHandler);
8923
8952
  this.sigwinchHandler = null;
8924
8953
  }
8925
8954
  this._console.deactivate();
8955
+ this.lib.destroyRenderer(this.rendererPtr, this._useAlternateScreen, this._splitHeight);
8926
8956
  this.disableStdoutInterception();
8927
- if (this.renderTimeout) {
8928
- clearTimeout(this.renderTimeout);
8929
- this.renderTimeout = null;
8930
- }
8931
- if (this.memorySnapshotTimer) {
8932
- clearInterval(this.memorySnapshotTimer);
8933
- this.memorySnapshotTimer = null;
8934
- }
8935
- if (this._splitHeight > 0) {
8936
- const consoleEndLine = this._terminalHeight - this._splitHeight;
8937
- this.writeOut(ANSI.moveCursor(consoleEndLine, 1));
8938
- }
8939
- this.capturedRenderable = undefined;
8940
- if (this._useMouse) {
8941
- this.disableMouse();
8942
- }
8943
- this.writeOut(ANSI.resetCursorColor);
8944
- this.writeOut(ANSI.showCursor);
8945
- if (this._useAlternateScreen) {
8946
- this.writeOut(ANSI.switchToMainScreen);
8947
- }
8948
- }
8949
- destroy() {
8950
- if (this.isDestroyed)
8951
- return;
8952
- this.lib.destroyRenderer(this.rendererPtr);
8953
- this.isDestroyed = true;
8954
8957
  }
8955
8958
  startRenderLoop() {
8956
8959
  if (!this._isRunning)
@@ -8963,7 +8966,7 @@ Error details:
8963
8966
  this.loop();
8964
8967
  }
8965
8968
  async loop() {
8966
- if (this.rendering)
8969
+ if (this.rendering || this.isDestroyed)
8967
8970
  return;
8968
8971
  this.rendering = true;
8969
8972
  if (this.renderTimeout) {
@@ -9429,8 +9432,8 @@ class TextRenderable extends Renderable {
9429
9432
  const changed = this.selectionHelper.reevaluateSelection(this.width, this.height);
9430
9433
  if (changed) {
9431
9434
  this.syncSelectionToTextBuffer();
9432
- this.needsUpdate();
9433
9435
  }
9436
+ this.needsUpdate();
9434
9437
  }
9435
9438
  setupMeasureFunc() {
9436
9439
  if (this._positionType === "relative" && this._width === "auto") {
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "type": "module",
7
- "version": "0.1.6",
7
+ "version": "0.1.7",
8
8
  "description": "OpenTUI is a TypeScript library for building terminal user interfaces (TUIs)",
9
9
  "license": "MIT",
10
10
  "repository": {
@@ -39,11 +39,11 @@
39
39
  "bun-webgpu": "0.1.3",
40
40
  "planck": "^1.4.2",
41
41
  "three": "0.177.0",
42
- "@opentui/core-darwin-x64": "0.1.6",
43
- "@opentui/core-darwin-arm64": "0.1.6",
44
- "@opentui/core-linux-x64": "0.1.6",
45
- "@opentui/core-linux-arm64": "0.1.6",
46
- "@opentui/core-win32-x64": "0.1.6",
47
- "@opentui/core-win32-arm64": "0.1.6"
42
+ "@opentui/core-darwin-x64": "0.1.7",
43
+ "@opentui/core-darwin-arm64": "0.1.7",
44
+ "@opentui/core-linux-x64": "0.1.7",
45
+ "@opentui/core-linux-arm64": "0.1.7",
46
+ "@opentui/core-win32-x64": "0.1.7",
47
+ "@opentui/core-win32-arm64": "0.1.7"
48
48
  }
49
49
  }
package/renderer.d.ts CHANGED
@@ -67,7 +67,6 @@ export declare class CliRenderer extends EventEmitter {
67
67
  private stdout;
68
68
  private exitOnCtrlC;
69
69
  private isDestroyed;
70
- private isShuttingDown;
71
70
  nextRenderBuffer: OptimizedBuffer;
72
71
  currentRenderBuffer: OptimizedBuffer;
73
72
  private _isRunning;
@@ -85,6 +84,7 @@ export declare class CliRenderer extends EventEmitter {
85
84
  private postProcessFns;
86
85
  private backgroundColor;
87
86
  private waitingForPixelResolution;
87
+ private shutdownRequested;
88
88
  private rendering;
89
89
  private renderingNative;
90
90
  private renderTimeout;
@@ -146,7 +146,6 @@ export declare class CliRenderer extends EventEmitter {
146
146
  private enableMouse;
147
147
  private disableMouse;
148
148
  set useThread(useThread: boolean);
149
- setTerminalSize(width: number, height: number): void;
150
149
  private setupTerminal;
151
150
  private handleMouseData;
152
151
  private takeMemorySnapshot;
package/zig.d.ts CHANGED
@@ -5,7 +5,7 @@ import { OptimizedBuffer } from "./buffer";
5
5
  import { TextBuffer } from "./text-buffer";
6
6
  export interface RenderLib {
7
7
  createRenderer: (width: number, height: number) => Pointer | null;
8
- destroyRenderer: (renderer: Pointer) => void;
8
+ destroyRenderer: (renderer: Pointer, useAlternateScreen: boolean, splitHeight: number) => void;
9
9
  setUseThread: (renderer: Pointer, useThread: boolean) => void;
10
10
  setBackgroundColor: (renderer: Pointer, color: RGBA) => void;
11
11
  setRenderOffset: (renderer: Pointer, offset: number) => void;
@@ -49,6 +49,8 @@ export interface RenderLib {
49
49
  dumpHitGrid: (renderer: Pointer) => void;
50
50
  dumpBuffers: (renderer: Pointer, timestamp?: number) => void;
51
51
  dumpStdoutBuffer: (renderer: Pointer, timestamp?: number) => void;
52
+ enableMouse: (renderer: Pointer, enableMovement: boolean) => void;
53
+ disableMouse: (renderer: Pointer) => void;
52
54
  createTextBuffer: (capacity: number) => TextBuffer;
53
55
  destroyTextBuffer: (buffer: Pointer) => void;
54
56
  textBufferGetCharPtr: (buffer: Pointer) => Pointer;