@opentui/core 0.5.1 → 0.5.2

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.
@@ -41,7 +41,7 @@ import {
41
41
  toArrayBuffer,
42
42
  treeSitterToTextChunks,
43
43
  yoga_default
44
- } from "./chunk-bun-83ry0rzt.js";
44
+ } from "./chunk-bun-26r5c5w5.js";
45
45
 
46
46
  // src/Renderable.ts
47
47
  import { EventEmitter } from "events";
@@ -3116,6 +3116,9 @@ class CodeRenderable extends TextBufferRenderable {
3116
3116
  _treeSitterClient;
3117
3117
  _highlightsDirty = false;
3118
3118
  _highlightSnapshotId = 0;
3119
+ _highlightLoopActive = false;
3120
+ _highlightPromise;
3121
+ _highlightRerun = false;
3119
3122
  _conceal;
3120
3123
  _drawUnstyledText;
3121
3124
  _shouldRenderTextBuffer = true;
@@ -3162,11 +3165,14 @@ class CodeRenderable extends TextBufferRenderable {
3162
3165
  get content() {
3163
3166
  return this._content;
3164
3167
  }
3168
+ invalidateHighlights() {
3169
+ this._highlightsDirty = true;
3170
+ this._highlightSnapshotId++;
3171
+ }
3165
3172
  set content(value) {
3166
3173
  if (this._content !== value) {
3167
3174
  this._content = value;
3168
- this._highlightsDirty = true;
3169
- this._highlightSnapshotId++;
3175
+ this.invalidateHighlights();
3170
3176
  if (this._streaming && this._filetype && !this._drawUnstyledText) {
3171
3177
  this.requestRender();
3172
3178
  return;
@@ -3216,7 +3222,7 @@ class CodeRenderable extends TextBufferRenderable {
3216
3222
  set filetype(value) {
3217
3223
  if (this._filetype !== value) {
3218
3224
  this._filetype = value;
3219
- this._highlightsDirty = true;
3225
+ this.invalidateHighlights();
3220
3226
  }
3221
3227
  }
3222
3228
  get syntaxStyle() {
@@ -3225,7 +3231,7 @@ class CodeRenderable extends TextBufferRenderable {
3225
3231
  set syntaxStyle(value) {
3226
3232
  if (this._syntaxStyle !== value) {
3227
3233
  this._syntaxStyle = value;
3228
- this._highlightsDirty = true;
3234
+ this.invalidateHighlights();
3229
3235
  }
3230
3236
  }
3231
3237
  get conceal() {
@@ -3234,7 +3240,7 @@ class CodeRenderable extends TextBufferRenderable {
3234
3240
  set conceal(value) {
3235
3241
  if (this._conceal !== value) {
3236
3242
  this._conceal = value;
3237
- this._highlightsDirty = true;
3243
+ this.invalidateHighlights();
3238
3244
  }
3239
3245
  }
3240
3246
  get drawUnstyledText() {
@@ -3243,7 +3249,7 @@ class CodeRenderable extends TextBufferRenderable {
3243
3249
  set drawUnstyledText(value) {
3244
3250
  if (this._drawUnstyledText !== value) {
3245
3251
  this._drawUnstyledText = value;
3246
- this._highlightsDirty = true;
3252
+ this.invalidateHighlights();
3247
3253
  }
3248
3254
  }
3249
3255
  get streaming() {
@@ -3252,7 +3258,7 @@ class CodeRenderable extends TextBufferRenderable {
3252
3258
  set initialStyledText(value) {
3253
3259
  if (this._initialStyledText !== value) {
3254
3260
  this._initialStyledText = value;
3255
- this._highlightsDirty = true;
3261
+ this.invalidateHighlights();
3256
3262
  }
3257
3263
  }
3258
3264
  set streaming(value) {
@@ -3260,7 +3266,7 @@ class CodeRenderable extends TextBufferRenderable {
3260
3266
  this._streaming = value;
3261
3267
  this._hadInitialContent = false;
3262
3268
  this._lastHighlights = [];
3263
- this._highlightsDirty = true;
3269
+ this.invalidateHighlights();
3264
3270
  }
3265
3271
  }
3266
3272
  get treeSitterClient() {
@@ -3269,7 +3275,7 @@ class CodeRenderable extends TextBufferRenderable {
3269
3275
  set treeSitterClient(value) {
3270
3276
  if (this._treeSitterClient !== value) {
3271
3277
  this._treeSitterClient = value;
3272
- this._highlightsDirty = true;
3278
+ this.invalidateHighlights();
3273
3279
  }
3274
3280
  }
3275
3281
  get onHighlight() {
@@ -3281,13 +3287,13 @@ class CodeRenderable extends TextBufferRenderable {
3281
3287
  set baseHighlight(value) {
3282
3288
  if (this._baseHighlight !== value) {
3283
3289
  this._baseHighlight = value;
3284
- this._highlightsDirty = true;
3290
+ this.invalidateHighlights();
3285
3291
  }
3286
3292
  }
3287
3293
  set onHighlight(value) {
3288
3294
  if (this._onHighlight !== value) {
3289
3295
  this._onHighlight = value;
3290
- this._highlightsDirty = true;
3296
+ this.invalidateHighlights();
3291
3297
  }
3292
3298
  }
3293
3299
  get onChunks() {
@@ -3296,11 +3302,11 @@ class CodeRenderable extends TextBufferRenderable {
3296
3302
  set onChunks(value) {
3297
3303
  if (this._onChunks !== value) {
3298
3304
  this._onChunks = value;
3299
- this._highlightsDirty = true;
3305
+ this.invalidateHighlights();
3300
3306
  }
3301
3307
  }
3302
3308
  get isHighlighting() {
3303
- return this._isHighlighting;
3309
+ return this._isHighlighting || this._highlightRerun;
3304
3310
  }
3305
3311
  get highlightingDone() {
3306
3312
  return this._highlightingPromise;
@@ -3425,6 +3431,23 @@ class CodeRenderable extends TextBufferRenderable {
3425
3431
  this.requestRender();
3426
3432
  }
3427
3433
  }
3434
+ async runHighlights() {
3435
+ try {
3436
+ do {
3437
+ this._highlightRerun = false;
3438
+ await this.startHighlight();
3439
+ } while (this._highlightRerun && !this.isDestroyed && this._content.length > 0 && this._filetype);
3440
+ } finally {
3441
+ this._highlightLoopActive = false;
3442
+ this._highlightRerun = false;
3443
+ }
3444
+ }
3445
+ clearPendingHighlight() {
3446
+ this._highlightSnapshotId++;
3447
+ this._isHighlighting = false;
3448
+ this._highlightRerun = false;
3449
+ this._highlightingPromise = Promise.resolve();
3450
+ }
3428
3451
  setRenderedLineSources(lineSources) {
3429
3452
  this._renderedLineSources = lineSources;
3430
3453
  this._mappedLineInfo = undefined;
@@ -3521,22 +3544,53 @@ class CodeRenderable extends TextBufferRenderable {
3521
3544
  if (this._highlightsDirty) {
3522
3545
  if (this.isDestroyed)
3523
3546
  return;
3524
- if (this._content.length === 0) {
3525
- this._shouldRenderTextBuffer = false;
3526
- this._highlightsDirty = false;
3527
- } else if (!this._filetype) {
3528
- this._shouldRenderTextBuffer = true;
3547
+ const hasContent = this._content.length > 0;
3548
+ if (!hasContent || !this._filetype) {
3549
+ this._shouldRenderTextBuffer = hasContent;
3529
3550
  this._highlightsDirty = false;
3551
+ this.clearPendingHighlight();
3552
+ if (hasContent) {
3553
+ this.textBuffer.setText(this._content);
3554
+ this.setRenderedLineSources(undefined);
3555
+ this.updateTextInfo();
3556
+ }
3530
3557
  } else {
3531
3558
  this.ensureVisibleTextBeforeHighlight();
3532
3559
  this._highlightsDirty = false;
3533
- this._highlightingPromise = this.startHighlight();
3560
+ if (this._highlightLoopActive) {
3561
+ this._isHighlighting = true;
3562
+ this._highlightRerun = true;
3563
+ this._highlightingPromise = this._highlightPromise;
3564
+ } else {
3565
+ const { promise: highlightingPromise, resolve, reject } = Promise.withResolvers();
3566
+ this._highlightLoopActive = true;
3567
+ this._highlightPromise = highlightingPromise;
3568
+ this._highlightingPromise = highlightingPromise;
3569
+ const clearHighlight = () => {
3570
+ if (this._highlightPromise === highlightingPromise) {
3571
+ this._highlightPromise = undefined;
3572
+ }
3573
+ };
3574
+ this.runHighlights().then(() => {
3575
+ clearHighlight();
3576
+ resolve();
3577
+ }, (error) => {
3578
+ clearHighlight();
3579
+ reject(error);
3580
+ });
3581
+ }
3534
3582
  }
3535
3583
  }
3536
3584
  if (!this._shouldRenderTextBuffer)
3537
3585
  return;
3538
3586
  super.renderSelf(buffer);
3539
3587
  }
3588
+ destroy() {
3589
+ if (this.isDestroyed)
3590
+ return;
3591
+ this.clearPendingHighlight();
3592
+ super.destroy();
3593
+ }
3540
3594
  }
3541
3595
 
3542
3596
  // src/renderables/TextNode.ts
@@ -6806,6 +6860,10 @@ class ScrollbackSnapshotRenderContext extends EventEmitter5 {
6806
6860
  updateSelection(_currentRenderable, _x, _y, _options) {}
6807
6861
  }
6808
6862
  var DEFAULT_FORWARDED_ENV_KEYS = [
6863
+ "SSH_CONNECTION",
6864
+ "SSH_CLIENT",
6865
+ "SSH_TTY",
6866
+ "MOSH_CONNECTION",
6809
6867
  "TMUX",
6810
6868
  "ZELLIJ",
6811
6869
  "ZELLIJ_SESSION_NAME",
@@ -7036,6 +7094,7 @@ class CliRenderer extends EventEmitter5 {
7036
7094
  animationRequest = new Map;
7037
7095
  resizeTimeoutId = null;
7038
7096
  capabilityTimeoutId = null;
7097
+ terminalKeepAliveTimer = null;
7039
7098
  xtVersionWaiters = new Set;
7040
7099
  splitStartupSeedTimeoutId = null;
7041
7100
  pendingSplitStartupCursorSeed = false;
@@ -7241,7 +7300,7 @@ Captured external output:
7241
7300
  this.rendererPtr = rendererPtr;
7242
7301
  this.clearOnShutdown = config.clearOnShutdown ?? true;
7243
7302
  this.lib.setClearOnShutdown(this.rendererPtr, this.clearOnShutdown);
7244
- const forwardEnvKeys = config.forwardEnvKeys ?? (config.remote === false ? [...DEFAULT_FORWARDED_ENV_KEYS] : []);
7303
+ const forwardEnvKeys = config.forwardEnvKeys ?? (remoteMode === true ? [] : [...DEFAULT_FORWARDED_ENV_KEYS]);
7245
7304
  for (const key of forwardEnvKeys) {
7246
7305
  const value = process.env[key];
7247
7306
  if (value === undefined)
@@ -7255,8 +7314,8 @@ Captured external output:
7255
7314
  "SIGQUIT",
7256
7315
  "SIGABRT",
7257
7316
  "SIGHUP",
7258
- "SIGBREAK",
7259
7317
  "SIGPIPE",
7318
+ "SIGBREAK",
7260
7319
  "SIGBUS"
7261
7320
  ];
7262
7321
  this.clipboard = new Clipboard(this.lib, this.rendererPtr);
@@ -7300,7 +7359,6 @@ Captured external output:
7300
7359
  process.on("warning", this.warningHandler);
7301
7360
  process.on("uncaughtException", this.handleError);
7302
7361
  process.on("unhandledRejection", this.handleError);
7303
- process.on("beforeExit", this.exitHandler);
7304
7362
  const useKittyForParsing = kittyConfig !== null;
7305
7363
  this._keyHandler = new InternalKeyHandler;
7306
7364
  this._keyHandler.on("keypress", (event) => {
@@ -7384,6 +7442,17 @@ Captured external output:
7384
7442
  });
7385
7443
  this._exitListenersAdded = true;
7386
7444
  }
7445
+ startTerminalKeepAlive() {
7446
+ if (this.stdin !== process.stdin || this.terminalKeepAliveTimer !== null)
7447
+ return;
7448
+ this.terminalKeepAliveTimer = setInterval(() => {}, 60000);
7449
+ }
7450
+ stopTerminalKeepAlive() {
7451
+ if (this.terminalKeepAliveTimer === null)
7452
+ return;
7453
+ clearInterval(this.terminalKeepAliveTimer);
7454
+ this.terminalKeepAliveTimer = null;
7455
+ }
7387
7456
  removeExitListeners() {
7388
7457
  if (!this._exitListenersAdded || this.exitSignals.length === 0)
7389
7458
  return;
@@ -8954,6 +9023,7 @@ Captured external output:
8954
9023
  }
8955
9024
  this.stdin.on("data", this.stdinListener);
8956
9025
  this.stdin.resume();
9026
+ this.startTerminalKeepAlive();
8957
9027
  }
8958
9028
  dispatchMouseEvent(target, attributes) {
8959
9029
  const event = new MouseEvent(target, attributes);
@@ -9426,6 +9496,7 @@ Captured external output:
9426
9496
  else
9427
9497
  this.stdinParser?.reset();
9428
9498
  this.stdin.removeListener("data", this.stdinListener);
9499
+ this.stopTerminalKeepAlive();
9429
9500
  this.themeModeState.cancelRefresh();
9430
9501
  this.lib.suspendRenderer(this.rendererPtr);
9431
9502
  if (this.stdin.setRawMode) {
@@ -9446,6 +9517,7 @@ Captured external output:
9446
9517
  this.stdinParser?.reset();
9447
9518
  this.stdin.on("data", this.stdinListener);
9448
9519
  this.stdin.resume();
9520
+ this.startTerminalKeepAlive();
9449
9521
  this.addExitListeners();
9450
9522
  const resumePreservedNonAltSurface = this.pendingSuspendedTerminalSetup && this._screenMode !== "alternate-screen" && this.suspendedNonAltSurfacePreserved && this.renderOffset > 0;
9451
9523
  if (this.pendingSuspendedTerminalSetup) {
@@ -9529,7 +9601,6 @@ Captured external output:
9529
9601
  process.removeListener("uncaughtException", this.handleError);
9530
9602
  process.removeListener("unhandledRejection", this.handleError);
9531
9603
  process.removeListener("warning", this.warningHandler);
9532
- process.removeListener("beforeExit", this.exitHandler);
9533
9604
  this.removeExitListeners();
9534
9605
  if (this.resizeTimeoutId !== null) {
9535
9606
  this.clock.clearTimeout(this.resizeTimeoutId);
@@ -9561,6 +9632,7 @@ Captured external output:
9561
9632
  this._useMouse = false;
9562
9633
  this.setCapturedRenderable(undefined);
9563
9634
  this.stdin.removeListener("data", this.stdinListener);
9635
+ this.stopTerminalKeepAlive();
9564
9636
  if (this.stdin.setRawMode) {
9565
9637
  try {
9566
9638
  this.stdin.setRawMode(false);
@@ -10153,5 +10225,5 @@ Captured external output:
10153
10225
 
10154
10226
  export { h, isVNode, maybeMakeRenderable, wrapWithDelegates, instantiate, delegate, LayoutEvents, RenderableEvents, isRenderable, BaseRenderable, Renderable, RootRenderable, TextBufferView, EditBuffer, EditorView, convertThemeToStyles, SyntaxStyle, ANSI, BoxRenderable, TextBufferRenderable, CodeRenderable, isTextNodeRenderable, TextNodeRenderable, RootTextNodeRenderable, TextRenderable, NativeSpanFeed, defaultKeyAliases, mergeKeyAliases, mergeKeyBindings, getKeyBindingAction, buildKeyBindingsMap, capture, ConsolePosition, TerminalConsole, getObjectsInViewport, EditBufferRenderableEvents, isEditBufferRenderable, EditBufferRenderable, buildKittyKeyboardFlags, MouseEvent, MouseButton, createCliRenderer, CliRenderEvents, RendererControlState, CliRenderer };
10155
10227
 
10156
- //# debugId=0B8AB9B3E8D95E9A64756E2164756E21
10157
- //# sourceMappingURL=chunk-bun-8fkgaxc6.js.map
10228
+ //# debugId=38FE27A155CAB92764756E2164756E21
10229
+ //# sourceMappingURL=chunk-bun-t68f2fmr.js.map