@opentui/core 0.4.1 → 0.4.3

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.
@@ -1,6 +1,8 @@
1
1
  import {
2
+ Clipboard,
2
3
  InternalKeyHandler,
3
4
  KeyHandler,
5
+ NativeMeasureTargetKind,
4
6
  OptimizedBuffer,
5
7
  RGBA,
6
8
  Selection,
@@ -38,7 +40,7 @@ import {
38
40
  toArrayBuffer,
39
41
  treeSitterToTextChunks,
40
42
  yoga_default
41
- } from "./index-pcvh9d34.js";
43
+ } from "./index-d5xqskty.js";
42
44
 
43
45
  // src/Renderable.ts
44
46
  import { EventEmitter } from "events";
@@ -121,8 +123,6 @@ var BrandedRenderable = Symbol.for("@opentui/core/Renderable");
121
123
  var LayoutEvents;
122
124
  ((LayoutEvents2) => {
123
125
  LayoutEvents2["LAYOUT_CHANGED"] = "layout-changed";
124
- LayoutEvents2["ADDED"] = "added";
125
- LayoutEvents2["REMOVED"] = "removed";
126
126
  LayoutEvents2["RESIZED"] = "resized";
127
127
  })(LayoutEvents ||= {});
128
128
  var RenderableEvents;
@@ -225,7 +225,6 @@ class Renderable extends BaseRenderable {
225
225
  _position = {};
226
226
  _opacity = 1;
227
227
  _flexShrink = 1;
228
- renderableMapById = new Map;
229
228
  _childrenInLayoutOrder = [];
230
229
  _childrenInZIndexOrder = [];
231
230
  needsZIndexSort = false;
@@ -266,16 +265,6 @@ class Renderable extends BaseRenderable {
266
265
  this.createFrameBuffer();
267
266
  }
268
267
  }
269
- get id() {
270
- return this._id;
271
- }
272
- set id(value) {
273
- if (this.parent) {
274
- this.parent.renderableMapById.delete(this.id);
275
- this.parent.renderableMapById.set(value, this);
276
- }
277
- super.id = value;
278
- }
279
268
  get focusable() {
280
269
  return this._focusable;
281
270
  }
@@ -981,7 +970,7 @@ class Renderable extends BaseRenderable {
981
970
  }
982
971
  replaceParent(obj) {
983
972
  if (obj.parent) {
984
- obj.parent.remove(obj.id);
973
+ obj.parent.remove(obj);
985
974
  }
986
975
  obj.parent = this;
987
976
  }
@@ -1009,7 +998,6 @@ class Renderable extends BaseRenderable {
1009
998
  } else {
1010
999
  this.replaceParent(renderable);
1011
1000
  this.needsZIndexSort = true;
1012
- this.renderableMapById.set(renderable.id, renderable);
1013
1001
  this._childrenInZIndexOrder.push(renderable);
1014
1002
  if (typeof renderable.onLifecyclePass === "function") {
1015
1003
  this._ctx.registerLifecyclePass(renderable);
@@ -1054,13 +1042,13 @@ class Renderable extends BaseRenderable {
1054
1042
  }
1055
1043
  return -1;
1056
1044
  }
1057
- if (!this.renderableMapById.has(anchor.id)) {
1045
+ if (this._childrenInLayoutOrder.indexOf(anchor) === -1) {
1058
1046
  if (true) {
1059
1047
  console.warn(`Anchor with id ${anchor.id} does not exist within the parent ${this.id}, skipping insertBefore`);
1060
1048
  }
1061
1049
  return -1;
1062
1050
  }
1063
- if (renderable === anchor || renderable.id === anchor.id) {
1051
+ if (renderable === anchor) {
1064
1052
  if (true) {
1065
1053
  console.warn(`Anchor is the same as the node ${renderable.id} being inserted, skipping insertBefore`);
1066
1054
  }
@@ -1072,7 +1060,6 @@ class Renderable extends BaseRenderable {
1072
1060
  } else {
1073
1061
  this.replaceParent(renderable);
1074
1062
  this.needsZIndexSort = true;
1075
- this.renderableMapById.set(renderable.id, renderable);
1076
1063
  this._childrenInZIndexOrder.push(renderable);
1077
1064
  if (typeof renderable.onLifecyclePass === "function") {
1078
1065
  this._ctx.registerLifecyclePass(renderable);
@@ -1092,37 +1079,36 @@ class Renderable extends BaseRenderable {
1092
1079
  return insertedIndex;
1093
1080
  }
1094
1081
  getRenderable(id) {
1095
- return this.renderableMapById.get(id);
1082
+ return this._childrenInLayoutOrder.find((child) => child.id === id);
1096
1083
  }
1097
- remove(id) {
1098
- if (!id) {
1099
- return;
1084
+ remove(child) {
1085
+ if (!(child instanceof BaseRenderable)) {
1086
+ throw new Error("remove expects a renderable child object");
1100
1087
  }
1101
- if (this.renderableMapById.has(id)) {
1102
- const obj = this.renderableMapById.get(id);
1103
- if (obj) {
1104
- if (obj._liveCount > 0) {
1105
- this.propagateLiveCount(-obj._liveCount);
1106
- }
1107
- const childLayoutNode = obj.getLayoutNode();
1108
- this.yogaNode.removeChild(childLayoutNode);
1109
- this.requestRender();
1110
- obj.onRemove();
1111
- obj.parent = null;
1112
- this._ctx.unregisterLifecyclePass(obj);
1113
- this.renderableMapById.delete(id);
1114
- const index = this._childrenInLayoutOrder.findIndex((obj2) => obj2.id === id);
1115
- if (index !== -1) {
1116
- this._childrenInLayoutOrder.splice(index, 1);
1117
- }
1118
- const zIndexIndex = this._childrenInZIndexOrder.findIndex((obj2) => obj2.id === id);
1119
- if (zIndexIndex !== -1) {
1120
- this._childrenInZIndexOrder.splice(zIndexIndex, 1);
1121
- }
1122
- this.childrenPrimarySortDirty = true;
1123
- bumpRenderListRevision(this._ctx);
1088
+ const index = this._childrenInLayoutOrder.indexOf(child);
1089
+ if (index === -1) {
1090
+ if (true) {
1091
+ console.warn(`Renderable with id ${child.id} is not a child of ${this.id}, skipping remove`);
1124
1092
  }
1093
+ return;
1094
+ }
1095
+ const renderable = this._childrenInLayoutOrder[index];
1096
+ if (renderable._liveCount > 0) {
1097
+ this.propagateLiveCount(-renderable._liveCount);
1098
+ }
1099
+ this.yogaNode.removeChild(renderable.getLayoutNode());
1100
+ this._childrenInLayoutOrder.splice(index, 1);
1101
+ const zIndexIndex = this._childrenInZIndexOrder.indexOf(renderable);
1102
+ if (zIndexIndex !== -1) {
1103
+ this._childrenInZIndexOrder.splice(zIndexIndex, 1);
1125
1104
  }
1105
+ this._shouldUpdateBefore.delete(renderable);
1106
+ this.requestRender();
1107
+ renderable.onRemove();
1108
+ renderable.parent = null;
1109
+ this._ctx.unregisterLifecyclePass(renderable);
1110
+ this.childrenPrimarySortDirty = true;
1111
+ bumpRenderListRevision(this._ctx);
1126
1112
  }
1127
1113
  onRemove() {}
1128
1114
  getChildren() {
@@ -1241,17 +1227,18 @@ class Renderable extends BaseRenderable {
1241
1227
  this._isDestroyed = true;
1242
1228
  this.emit("destroyed" /* DESTROYED */);
1243
1229
  if (this.parent) {
1244
- this.parent.remove(this.id);
1230
+ this.parent.remove(this);
1245
1231
  }
1246
1232
  if (this.frameBuffer) {
1247
1233
  this.frameBuffer.destroy();
1248
1234
  this.frameBuffer = null;
1249
1235
  }
1250
- for (const child of this._childrenInLayoutOrder) {
1251
- this.remove(child.id);
1236
+ for (const child of [...this._childrenInLayoutOrder]) {
1237
+ this.remove(child);
1252
1238
  }
1253
1239
  this._childrenInLayoutOrder = [];
1254
- this.renderableMapById.clear();
1240
+ this._childrenInZIndexOrder = [];
1241
+ this._shouldUpdateBefore.clear();
1255
1242
  Renderable.renderablesByNumber.delete(this.num);
1256
1243
  this.blur();
1257
1244
  this.removeAllListeners();
@@ -1402,7 +1389,9 @@ class RootRenderable extends Renderable {
1402
1389
  if (!this.visible)
1403
1390
  return;
1404
1391
  for (const renderable of this._ctx.getLifecyclePasses()) {
1405
- renderable.onLifecyclePass?.call(renderable);
1392
+ if (!renderable.isDestroyed) {
1393
+ renderable.onLifecyclePass?.call(renderable);
1394
+ }
1406
1395
  }
1407
1396
  if (this.yogaNode.isDirty()) {
1408
1397
  this.calculateLayout();
@@ -1563,19 +1552,8 @@ function maybeMakeRenderable(ctx, node) {
1563
1552
  function wrapWithDelegates(instance, delegateMap) {
1564
1553
  if (!delegateMap || Object.keys(delegateMap).length === 0)
1565
1554
  return instance;
1566
- const descendantCache = new Map;
1567
1555
  const getDescendant = (id) => {
1568
- if (descendantCache.has(id)) {
1569
- const cached = descendantCache.get(id);
1570
- if (cached !== undefined) {
1571
- return cached;
1572
- }
1573
- }
1574
- const descendant = instance.findDescendantById(id);
1575
- if (descendant) {
1576
- descendantCache.set(id, descendant);
1577
- }
1578
- return descendant;
1556
+ return instance.findDescendantById(id);
1579
1557
  };
1580
1558
  const proxy = new Proxy(instance, {
1581
1559
  get(target, prop, receiver) {
@@ -2768,6 +2746,7 @@ class TextBufferRenderable extends Renderable {
2768
2746
  textBuffer;
2769
2747
  textBufferView;
2770
2748
  _textBufferSyntaxStyle;
2749
+ nativeRenderable = null;
2771
2750
  _defaultOptions = {
2772
2751
  fg: RGBA.fromValues(1, 1, 1, 1),
2773
2752
  bg: RGBA.fromValues(0, 0, 0, 0),
@@ -2799,7 +2778,7 @@ class TextBufferRenderable extends Renderable {
2799
2778
  this.textBuffer.setSyntaxStyle(this._textBufferSyntaxStyle);
2800
2779
  this.textBufferView.setWrapMode(this._wrapMode);
2801
2780
  this.textBufferView.setFirstLineOffset(this._firstLineOffset);
2802
- this.setupMeasureFunc();
2781
+ this.setupNativeRenderable();
2803
2782
  this.textBuffer.setDefaultFg(this._defaultFg);
2804
2783
  this.textBuffer.setDefaultBg(this._defaultBg);
2805
2784
  this.textBuffer.setDefaultAttributes(this._defaultAttributes);
@@ -3033,30 +3012,18 @@ class TextBufferRenderable extends Renderable {
3033
3012
  this.requestRender();
3034
3013
  this.emit("line-info-change");
3035
3014
  }
3036
- setupMeasureFunc() {
3037
- const measureFunc = (width, widthMode, height, heightMode) => {
3038
- let effectiveWidth;
3039
- if (widthMode === 0 /* Undefined */ || isNaN(width)) {
3040
- effectiveWidth = 0;
3041
- } else {
3042
- effectiveWidth = width;
3043
- }
3044
- const effectiveHeight = isNaN(height) ? 1 : height;
3045
- const measureResult = this.textBufferView.measureForDimensions(Math.floor(effectiveWidth), Math.floor(effectiveHeight));
3046
- const measuredWidth = measureResult ? Math.max(1, measureResult.widthColsMax) : 1;
3047
- const measuredHeight = measureResult ? Math.max(1, measureResult.lineCount) : 1;
3048
- if (widthMode === 2 /* AtMost */ && this._positionType !== "absolute") {
3049
- return {
3050
- width: Math.min(effectiveWidth, measuredWidth),
3051
- height: Math.min(effectiveHeight, measuredHeight)
3052
- };
3053
- }
3054
- return {
3055
- width: measuredWidth,
3056
- height: measuredHeight
3057
- };
3058
- };
3059
- this.yogaNode.setMeasureFunc(measureFunc);
3015
+ setupNativeRenderable() {
3016
+ const lib = resolveRenderLib();
3017
+ const nativeRenderable = lib.createNativeRenderable();
3018
+ if (!lib.nativeRenderableAttachYogaNode(nativeRenderable, this.yogaNode.ptr)) {
3019
+ lib.destroyNativeRenderable(nativeRenderable);
3020
+ throw new Error("Failed to attach native renderable Yoga node");
3021
+ }
3022
+ if (!lib.nativeRenderableSetMeasureTarget(nativeRenderable, NativeMeasureTargetKind.TextBufferView, this.textBufferView.ptr)) {
3023
+ lib.destroyNativeRenderable(nativeRenderable);
3024
+ throw new Error("Failed to attach text buffer native measure target");
3025
+ }
3026
+ this.nativeRenderable = nativeRenderable;
3060
3027
  }
3061
3028
  shouldStartSelection(x, y) {
3062
3029
  if (!this.selectable)
@@ -3111,6 +3078,10 @@ class TextBufferRenderable extends Renderable {
3111
3078
  destroy() {
3112
3079
  if (this.isDestroyed)
3113
3080
  return;
3081
+ if (this.nativeRenderable) {
3082
+ resolveRenderLib().destroyNativeRenderable(this.nativeRenderable);
3083
+ this.nativeRenderable = null;
3084
+ }
3114
3085
  this.textBuffer.setSyntaxStyle(null);
3115
3086
  this._textBufferSyntaxStyle.destroy();
3116
3087
  this.textBufferView.destroy();
@@ -3591,6 +3562,19 @@ class TextNodeRenderable extends BaseRenderable {
3591
3562
  return this._children;
3592
3563
  }
3593
3564
  set children(children) {
3565
+ for (const child of this._children) {
3566
+ if (isTextNodeRenderable(child) && child.parent === this) {
3567
+ child.parent = null;
3568
+ }
3569
+ }
3570
+ for (const child of children) {
3571
+ if (isTextNodeRenderable(child)) {
3572
+ if (child.parent && child.parent !== this) {
3573
+ child.parent.remove(child);
3574
+ }
3575
+ child.parent = this;
3576
+ }
3577
+ }
3594
3578
  this._children = children;
3595
3579
  this.requestRender();
3596
3580
  }
@@ -3611,14 +3595,8 @@ class TextNodeRenderable extends BaseRenderable {
3611
3595
  return insertIndex;
3612
3596
  }
3613
3597
  if (isTextNodeRenderable(obj)) {
3614
- if (index !== undefined) {
3615
- this._children.splice(index, 0, obj);
3616
- obj.parent = this;
3617
- this.requestRender();
3618
- return index;
3619
- }
3620
- const insertIndex = this._children.length;
3621
- this._children.push(obj);
3598
+ const insertIndex = this.prepareChildInsert(obj, index);
3599
+ this._children.splice(insertIndex, 0, obj);
3622
3600
  obj.parent = this;
3623
3601
  this.requestRender();
3624
3602
  return insertIndex;
@@ -3639,11 +3617,39 @@ class TextNodeRenderable extends BaseRenderable {
3639
3617
  }
3640
3618
  throw new Error("TextNodeRenderable only accepts strings, TextNodeRenderable instances, or StyledText instances");
3641
3619
  }
3620
+ prepareChildInsert(child, index) {
3621
+ let insertIndex = index ?? this._children.length;
3622
+ if (child.parent && child.parent !== this) {
3623
+ child.parent.remove(child);
3624
+ } else if (child.parent === this) {
3625
+ const currentIndex = this._children.indexOf(child);
3626
+ if (currentIndex !== -1) {
3627
+ this._children.splice(currentIndex, 1);
3628
+ if (currentIndex < insertIndex)
3629
+ insertIndex -= 1;
3630
+ }
3631
+ }
3632
+ return Math.max(0, Math.min(insertIndex, this._children.length));
3633
+ }
3642
3634
  replace(obj, index) {
3643
- this._children[index] = obj;
3644
- if (typeof obj !== "string") {
3635
+ const existing = this._children[index];
3636
+ if (isTextNodeRenderable(existing) && existing.parent === this) {
3637
+ existing.parent = null;
3638
+ }
3639
+ if (isTextNodeRenderable(obj)) {
3640
+ if (obj.parent && obj.parent !== this) {
3641
+ obj.parent.remove(obj);
3642
+ } else if (obj.parent === this) {
3643
+ const currentIndex = this._children.indexOf(obj);
3644
+ if (currentIndex !== -1 && currentIndex !== index) {
3645
+ this._children.splice(currentIndex, 1);
3646
+ if (currentIndex < index)
3647
+ index -= 1;
3648
+ }
3649
+ }
3645
3650
  obj.parent = this;
3646
3651
  }
3652
+ this._children[index] = obj;
3647
3653
  this.requestRender();
3648
3654
  }
3649
3655
  insertBefore(child, anchorNode) {
@@ -3654,12 +3660,16 @@ class TextNodeRenderable extends BaseRenderable {
3654
3660
  if (anchorIndex === -1) {
3655
3661
  throw new Error("Anchor node not found in children");
3656
3662
  }
3663
+ if (child === anchorNode) {
3664
+ return this;
3665
+ }
3666
+ if (isTextNodeRenderable(child)) {
3667
+ this.add(child, anchorIndex);
3668
+ return this;
3669
+ }
3657
3670
  if (typeof child === "string") {
3658
3671
  this._children.splice(anchorIndex, 0, child);
3659
- } else if (isTextNodeRenderable(child)) {
3660
- this._children.splice(anchorIndex, 0, child);
3661
- child.parent = this;
3662
- } else if (child instanceof StyledText) {
3672
+ } else if (isStyledText(child)) {
3663
3673
  const textNodes = styledTextToTextNodes(child);
3664
3674
  this._children.splice(anchorIndex, 0, ...textNodes);
3665
3675
  textNodes.forEach((node) => node.parent = this);
@@ -3669,18 +3679,27 @@ class TextNodeRenderable extends BaseRenderable {
3669
3679
  this.requestRender();
3670
3680
  return this;
3671
3681
  }
3672
- remove(id) {
3673
- const childIndex = this.getRenderableIndex(id);
3682
+ remove(child) {
3683
+ if (!isTextNodeRenderable(child)) {
3684
+ throw new Error("remove expects a TextNodeRenderable child object");
3685
+ }
3686
+ const childIndex = this._children.indexOf(child);
3674
3687
  if (childIndex === -1) {
3675
- throw new Error("Child not found in children");
3688
+ if (true) {
3689
+ console.warn(`TextNodeRenderable with id ${child.id} is not a child of ${this.id}, skipping remove`);
3690
+ }
3691
+ return;
3676
3692
  }
3677
- const child = this._children[childIndex];
3678
3693
  this._children.splice(childIndex, 1);
3679
3694
  child.parent = null;
3680
3695
  this.requestRender();
3681
- return this;
3682
3696
  }
3683
3697
  clear() {
3698
+ for (const child of this._children) {
3699
+ if (isTextNodeRenderable(child) && child.parent === this) {
3700
+ child.parent = null;
3701
+ }
3702
+ }
3684
3703
  this._children = [];
3685
3704
  this.requestRender();
3686
3705
  }
@@ -3866,8 +3885,8 @@ class TextRenderable extends TextBufferRenderable {
3866
3885
  add(obj, index) {
3867
3886
  return this.rootTextNode.add(obj, index);
3868
3887
  }
3869
- remove(id) {
3870
- this.rootTextNode.remove(id);
3888
+ remove(child) {
3889
+ this.rootTextNode.remove(child);
3871
3890
  }
3872
3891
  insertBefore(obj, anchor) {
3873
3892
  this.rootTextNode.insertBefore(obj, anchor);
@@ -5405,6 +5424,7 @@ class EditBufferRenderable extends Renderable {
5405
5424
  _keyboardSelectionActive = false;
5406
5425
  editBuffer;
5407
5426
  editorView;
5427
+ nativeRenderable = null;
5408
5428
  _defaultOptions = {
5409
5429
  textColor: RGBA.fromValues(1, 1, 1, 1),
5410
5430
  backgroundColor: "transparent",
@@ -5456,7 +5476,7 @@ class EditBufferRenderable extends Renderable {
5456
5476
  if (this._tabIndicatorColor !== undefined) {
5457
5477
  this.editorView.setTabIndicatorColor(this._tabIndicatorColor);
5458
5478
  }
5459
- this.setupMeasureFunc();
5479
+ this.setupNativeRenderable();
5460
5480
  this.setupEventListeners(options);
5461
5481
  }
5462
5482
  get lineInfo() {
@@ -6085,30 +6105,18 @@ class EditBufferRenderable extends Renderable {
6085
6105
  this.requestRender();
6086
6106
  return true;
6087
6107
  }
6088
- setupMeasureFunc() {
6089
- const measureFunc = (width, widthMode, height, heightMode) => {
6090
- let effectiveWidth;
6091
- if (widthMode === 0 /* Undefined */ || isNaN(width)) {
6092
- effectiveWidth = 0;
6093
- } else {
6094
- effectiveWidth = width;
6095
- }
6096
- const effectiveHeight = isNaN(height) ? 1 : height;
6097
- const measureResult = this.editorView.measureForDimensions(Math.floor(effectiveWidth), Math.floor(effectiveHeight));
6098
- const measuredWidth = measureResult ? Math.max(1, measureResult.widthColsMax) : 1;
6099
- const measuredHeight = measureResult ? Math.max(1, measureResult.lineCount) : 1;
6100
- if (widthMode === 2 /* AtMost */ && this._positionType !== "absolute") {
6101
- return {
6102
- width: Math.min(effectiveWidth, measuredWidth),
6103
- height: Math.min(effectiveHeight, measuredHeight)
6104
- };
6105
- }
6106
- return {
6107
- width: measuredWidth,
6108
- height: measuredHeight
6109
- };
6110
- };
6111
- this.yogaNode.setMeasureFunc(measureFunc);
6108
+ setupNativeRenderable() {
6109
+ const lib = resolveRenderLib();
6110
+ const nativeRenderable = lib.createNativeRenderable();
6111
+ if (!lib.nativeRenderableAttachYogaNode(nativeRenderable, this.yogaNode.ptr)) {
6112
+ lib.destroyNativeRenderable(nativeRenderable);
6113
+ throw new Error("Failed to attach native renderable Yoga node");
6114
+ }
6115
+ if (!lib.nativeRenderableSetMeasureTarget(nativeRenderable, NativeMeasureTargetKind.EditorView, this.editorView.ptr)) {
6116
+ lib.destroyNativeRenderable(nativeRenderable);
6117
+ throw new Error("Failed to attach editor native measure target");
6118
+ }
6119
+ this.nativeRenderable = nativeRenderable;
6112
6120
  }
6113
6121
  render(buffer, deltaTime) {
6114
6122
  if (!this.visible)
@@ -6159,6 +6167,10 @@ class EditBufferRenderable extends Renderable {
6159
6167
  this._ctx.setCursorPosition(0, 0, false);
6160
6168
  this.blur();
6161
6169
  }
6170
+ if (this.nativeRenderable) {
6171
+ resolveRenderLib().destroyNativeRenderable(this.nativeRenderable);
6172
+ this.nativeRenderable = null;
6173
+ }
6162
6174
  this.editorView.destroy();
6163
6175
  this.editBuffer.destroy();
6164
6176
  super.destroy();
@@ -6273,38 +6285,6 @@ var ANSI = {
6273
6285
  bracketedPasteEnd: "\x1B[201~"
6274
6286
  };
6275
6287
 
6276
- // src/lib/clipboard.ts
6277
- function encodeOsc52Payload(text, encoder = new TextEncoder) {
6278
- const base64 = Buffer.from(text).toString("base64");
6279
- return encoder.encode(base64);
6280
- }
6281
-
6282
- class Clipboard {
6283
- lib;
6284
- rendererPtr;
6285
- constructor(lib, rendererPtr) {
6286
- this.lib = lib;
6287
- this.rendererPtr = rendererPtr;
6288
- }
6289
- copyToClipboardOSC52(text, target = 0 /* Clipboard */) {
6290
- if (!this.isOsc52Supported()) {
6291
- return false;
6292
- }
6293
- const payload = encodeOsc52Payload(text, this.lib.encoder);
6294
- return this.lib.copyToClipboardOSC52(this.rendererPtr, target, payload);
6295
- }
6296
- clearClipboardOSC52(target = 0 /* Clipboard */) {
6297
- if (!this.isOsc52Supported()) {
6298
- return false;
6299
- }
6300
- return this.lib.clearClipboardOSC52(this.rendererPtr, target);
6301
- }
6302
- isOsc52Supported() {
6303
- const caps = this.lib.getTerminalCapabilities(this.rendererPtr);
6304
- return Boolean(caps?.osc52);
6305
- }
6306
- }
6307
-
6308
6288
  // src/renderer.ts
6309
6289
  import { EventEmitter as EventEmitter5 } from "events";
6310
6290
 
@@ -6437,6 +6417,9 @@ function isCapabilityResponse(sequence) {
6437
6417
  if (/\x1bP>\|[\s\S]*?\x1b\\/.test(sequence)) {
6438
6418
  return true;
6439
6419
  }
6420
+ if (/\x1bP(?:1\+r4d73(?:=[^\x1b]*)?|0\+r(?:4d73)?)\x1b\\/i.test(sequence)) {
6421
+ return true;
6422
+ }
6440
6423
  if (/\x1b_G[\s\S]*?\x1b\\/.test(sequence)) {
6441
6424
  return true;
6442
6425
  }
@@ -7497,6 +7480,8 @@ Captured external output:
7497
7480
  return "retryable-skip";
7498
7481
  }
7499
7482
  if (status === NATIVE_RENDER_STATUS_SKIPPED) {
7483
+ if (this._useThread && this._usesProcessStdout)
7484
+ return "backpressured";
7500
7485
  console.error("[CliRenderer] Native frame render unexpectedly skipped without a feed");
7501
7486
  return "failed";
7502
7487
  }
@@ -9232,7 +9217,7 @@ Captured external output:
9232
9217
  return this.clipboard.clearClipboardOSC52(target);
9233
9218
  }
9234
9219
  isOsc52Supported() {
9235
- return this._capabilities?.osc52 ?? this.clipboard.isOsc52Supported();
9220
+ return this._capabilities ? this._capabilities.osc52_support !== "unsupported" : this.clipboard.isOsc52Supported();
9236
9221
  }
9237
9222
  dumpHitGrid() {
9238
9223
  this.lib.dumpHitGrid(this.rendererPtr);
@@ -9592,6 +9577,7 @@ Captured external output:
9592
9577
  this.frameCount = 0;
9593
9578
  this.lastFpsTime = this.lastTime;
9594
9579
  this.currentFps = 0;
9580
+ this.renderStats.fps = 0;
9595
9581
  if (this.feedIdleRenderScheduled)
9596
9582
  return;
9597
9583
  this.loop();
@@ -9611,14 +9597,7 @@ Captured external output:
9611
9597
  const elapsed = this.getElapsedMs(now, this.lastTime);
9612
9598
  const deltaTime = elapsed;
9613
9599
  this.lastTime = now;
9614
- this.frameCount++;
9615
- if (this.getElapsedMs(now, this.lastFpsTime) >= 1000) {
9616
- this.currentFps = this.frameCount;
9617
- this.frameCount = 0;
9618
- this.lastFpsTime = now;
9619
- }
9620
9600
  this.renderStats.frameCount++;
9621
- this.renderStats.fps = this.currentFps;
9622
9601
  const overallStart = performance.now();
9623
9602
  const frameRequests = Array.from(this.animationRequest.values());
9624
9603
  this.animationRequest.clear();
@@ -9646,6 +9625,14 @@ Captured external output:
9646
9625
  this._console.renderToBuffer(this.nextRenderBuffer);
9647
9626
  if (!this._isDestroyed) {
9648
9627
  const nativeStatus = this.renderNative() ?? "rendered";
9628
+ if (nativeStatus === "rendered")
9629
+ this.frameCount++;
9630
+ if (this.getElapsedMs(now, this.lastFpsTime) >= 1000) {
9631
+ this.currentFps = this.frameCount;
9632
+ this.frameCount = 0;
9633
+ this.lastFpsTime = now;
9634
+ }
9635
+ this.renderStats.fps = this.currentFps;
9649
9636
  if (nativeStatus === "rendered") {
9650
9637
  if (this._useMouse && this.lib.getHitGridDirty(this.rendererPtr)) {
9651
9638
  this.recheckHoverState();
@@ -10054,5 +10041,5 @@ Captured external output:
10054
10041
 
10055
10042
  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 };
10056
10043
 
10057
- //# debugId=D566D64CFF69CBEF64756E2164756E21
10058
- //# sourceMappingURL=index-07zpr2dg.js.map
10044
+ //# debugId=9F3FCD78D0AED08D64756E2164756E21
10045
+ //# sourceMappingURL=index-xt9f071j.js.map