@opentui/core 0.5.10 → 0.5.11

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.
Files changed (40) hide show
  1. package/README.md +2 -0
  2. package/audio.d.ts +6 -1
  3. package/{chunk-bun-9gqvxy8c.js → chunk-bun-37s3zwb6.js} +1181 -1036
  4. package/{chunk-bun-9gqvxy8c.js.map → chunk-bun-37s3zwb6.js.map} +7 -7
  5. package/{chunk-bun-bb3k0yt8.js → chunk-bun-bwjmgnxw.js} +647 -582
  6. package/chunk-bun-bwjmgnxw.js.map +32 -0
  7. package/{chunk-node-6bg8r2m7.js → chunk-node-54dhb2fr.js} +647 -582
  8. package/chunk-node-54dhb2fr.js.map +32 -0
  9. package/{chunk-node-f647ts9q.js → chunk-node-70eg2nhg.js} +1188 -1040
  10. package/{chunk-node-f647ts9q.js.map → chunk-node-70eg2nhg.js.map} +7 -7
  11. package/index.bun.js +1571 -1377
  12. package/index.bun.js.map +7 -7
  13. package/index.node.js +1571 -1377
  14. package/index.node.js.map +7 -7
  15. package/lib/detect-links.d.ts +5 -0
  16. package/lib/tree-sitter/update-assets.js +4 -4
  17. package/lib/tree-sitter/update-assets.js.map +2 -2
  18. package/lib/tree-sitter-styled-text.d.ts +4 -0
  19. package/package.json +13 -9
  20. package/parser.worker.js +7 -10
  21. package/parser.worker.js.map +2 -2
  22. package/renderables/Code.d.ts +6 -0
  23. package/renderables/Diff.d.ts +1 -2
  24. package/renderables/Markdown.d.ts +6 -0
  25. package/renderables/TextBufferRenderable.d.ts +2 -0
  26. package/renderer.d.ts +2 -0
  27. package/testing.bun.js +23 -23
  28. package/testing.bun.js.map +2 -2
  29. package/testing.js +23 -23
  30. package/testing.js.map +2 -2
  31. package/text-buffer-view.d.ts +1 -0
  32. package/types.d.ts +1 -0
  33. package/yoga.bun.js +187 -187
  34. package/yoga.bun.js.map +1 -1
  35. package/yoga.js +187 -187
  36. package/yoga.js.map +1 -1
  37. package/zig-structs.d.ts +8 -1
  38. package/zig.d.ts +4 -0
  39. package/chunk-bun-bb3k0yt8.js.map +0 -32
  40. package/chunk-node-6bg8r2m7.js.map +0 -32
@@ -1,46 +1,242 @@
1
1
  import {
2
- Clipboard,
3
- InternalKeyHandler,
4
- KeyHandler,
5
- NativeMeasureTargetKind,
6
- OptimizedBuffer,
7
- RGBA,
8
- Selection,
9
- SpanInfoStruct,
10
- StdinParser,
11
- StyledText,
12
- SystemClock,
13
- TextBuffer,
14
- borderCharsToArray,
15
- buildTerminalPaletteSignature,
16
- convertGlobalToLocalSelection,
17
- createExtmarksController,
18
- createTerminalPalette,
19
- createTextAttributes,
20
- destroyTreeSitterClient,
21
- env,
22
- getBorderSides,
23
- getTreeSitterClient,
24
- isStyledText,
25
- normalizeTerminalPalette,
26
- parseAlign,
27
- parseAlignItems,
28
- parseBorderStyle,
29
- parseColor,
30
- parseFlexDirection,
31
- parseJustify,
32
- parseOverflow,
33
- parsePositionType,
34
- parseWrap,
35
- registerEnvVar,
36
- resolveRenderLib,
2
+ toArrayBuffer,
37
3
  singleton,
4
+ registerEnvVar2,
5
+ env2,
38
6
  sleep,
39
- stringToStyledText,
40
- toArrayBuffer,
41
- treeSitterToTextChunks,
7
+ RGBA2,
8
+ parseColor2,
9
+ parseBorderStyle2,
10
+ getBorderSides2,
11
+ borderCharsToArray2,
12
+ KeyHandler2,
13
+ InternalKeyHandler2,
14
+ createTextAttributes2,
15
+ getLinkId2,
16
+ isStyledText2,
17
+ StyledText2,
18
+ stringToStyledText2,
19
+ SystemClock2,
20
+ parseAlign2,
21
+ parseAlignItems2,
22
+ parseFlexDirection2,
23
+ parseJustify2,
24
+ parseOverflow2,
25
+ parsePositionType2,
26
+ parseWrap2,
27
+ Selection2,
28
+ convertGlobalToLocalSelection2,
29
+ StdinParser2,
30
+ treeSitterToTextChunks2,
31
+ getTreeSitterClient2,
32
+ destroyTreeSitterClient2,
33
+ createExtmarksController2,
34
+ createTerminalPalette2,
35
+ normalizeTerminalPalette2,
36
+ buildTerminalPaletteSignature2,
37
+ Clipboard2,
38
+ OptimizedBuffer2,
39
+ TextBuffer2,
40
+ SpanInfoStruct,
41
+ NativeMeasureTargetKind2,
42
+ resolveRenderLib2,
42
43
  yoga_default
43
- } from "./chunk-node-f647ts9q.js";
44
+ } from "./chunk-node-70eg2nhg.js";
45
+
46
+ // src/syntax-style.ts
47
+ function convertThemeToStyles2(theme) {
48
+ const flatStyles = {};
49
+ for (const tokenStyle of theme) {
50
+ const styleDefinition = {};
51
+ if (tokenStyle.style.foreground) {
52
+ styleDefinition.fg = parseColor2(tokenStyle.style.foreground);
53
+ }
54
+ if (tokenStyle.style.background) {
55
+ styleDefinition.bg = parseColor2(tokenStyle.style.background);
56
+ }
57
+ if (tokenStyle.style.bold !== undefined) {
58
+ styleDefinition.bold = tokenStyle.style.bold;
59
+ }
60
+ if (tokenStyle.style.italic !== undefined) {
61
+ styleDefinition.italic = tokenStyle.style.italic;
62
+ }
63
+ if (tokenStyle.style.underline !== undefined) {
64
+ styleDefinition.underline = tokenStyle.style.underline;
65
+ }
66
+ if (tokenStyle.style.dim !== undefined) {
67
+ styleDefinition.dim = tokenStyle.style.dim;
68
+ }
69
+ for (const scope of tokenStyle.scope) {
70
+ flatStyles[scope] = styleDefinition;
71
+ }
72
+ }
73
+ return flatStyles;
74
+ }
75
+
76
+ class SyntaxStyle2 {
77
+ lib;
78
+ stylePtr;
79
+ _destroyed = false;
80
+ nameCache = new Map;
81
+ styleDefs = new Map;
82
+ mergedCache = new Map;
83
+ constructor(lib, ptr) {
84
+ this.lib = lib;
85
+ this.stylePtr = ptr;
86
+ }
87
+ static create() {
88
+ const lib = resolveRenderLib2();
89
+ const ptr = lib.createSyntaxStyle();
90
+ return new SyntaxStyle2(lib, ptr);
91
+ }
92
+ static fromTheme(theme) {
93
+ const style = SyntaxStyle2.create();
94
+ const flatStyles = convertThemeToStyles2(theme);
95
+ for (const [name, styleDef] of Object.entries(flatStyles)) {
96
+ style.registerStyle(name, styleDef);
97
+ }
98
+ return style;
99
+ }
100
+ static fromStyles(styles) {
101
+ const style = SyntaxStyle2.create();
102
+ for (const [name, styleDef] of Object.entries(styles)) {
103
+ style.registerStyle(name, styleDef);
104
+ }
105
+ return style;
106
+ }
107
+ guard() {
108
+ if (this._destroyed)
109
+ throw new Error("NativeSyntaxStyle is destroyed");
110
+ }
111
+ registerStyle(name, style) {
112
+ this.guard();
113
+ const attributes = createTextAttributes2({
114
+ bold: style.bold,
115
+ italic: style.italic,
116
+ underline: style.underline,
117
+ dim: style.dim
118
+ });
119
+ const fg = style.fg ? parseColor2(style.fg) : null;
120
+ const bg = style.bg ? parseColor2(style.bg) : null;
121
+ const id = this.lib.syntaxStyleRegister(this.stylePtr, name, fg, bg, attributes);
122
+ this.nameCache.set(name, id);
123
+ this.styleDefs.set(name, { ...style, fg: fg ?? undefined, bg: bg ?? undefined });
124
+ return id;
125
+ }
126
+ resolveStyleId(name) {
127
+ this.guard();
128
+ const cached = this.nameCache.get(name);
129
+ if (cached !== undefined)
130
+ return cached;
131
+ const id = this.lib.syntaxStyleResolveByName(this.stylePtr, name);
132
+ if (id !== null) {
133
+ this.nameCache.set(name, id);
134
+ }
135
+ return id;
136
+ }
137
+ getStyleId(name) {
138
+ this.guard();
139
+ const id = this.resolveStyleId(name);
140
+ if (id !== null)
141
+ return id;
142
+ if (name.includes(".")) {
143
+ const baseName = name.split(".")[0];
144
+ return this.resolveStyleId(baseName);
145
+ }
146
+ return null;
147
+ }
148
+ get ptr() {
149
+ this.guard();
150
+ return this.stylePtr;
151
+ }
152
+ getStyleCount() {
153
+ this.guard();
154
+ return this.lib.syntaxStyleGetStyleCount(this.stylePtr);
155
+ }
156
+ clearNameCache() {
157
+ this.nameCache.clear();
158
+ }
159
+ getStyle(name) {
160
+ this.guard();
161
+ if (Object.prototype.hasOwnProperty.call(this.styleDefs, name)) {
162
+ return;
163
+ }
164
+ const style = this.styleDefs.get(name);
165
+ if (style)
166
+ return style;
167
+ if (name.includes(".")) {
168
+ const baseName = name.split(".")[0];
169
+ if (Object.prototype.hasOwnProperty.call(this.styleDefs, baseName)) {
170
+ return;
171
+ }
172
+ return this.styleDefs.get(baseName);
173
+ }
174
+ return;
175
+ }
176
+ mergeStyles(...styleNames) {
177
+ this.guard();
178
+ const cacheKey = styleNames.join(":");
179
+ const cached = this.mergedCache.get(cacheKey);
180
+ if (cached)
181
+ return cached;
182
+ const styleDefinition = {};
183
+ for (const name of styleNames) {
184
+ const style = this.getStyle(name);
185
+ if (!style)
186
+ continue;
187
+ if (style.fg)
188
+ styleDefinition.fg = style.fg;
189
+ if (style.bg)
190
+ styleDefinition.bg = style.bg;
191
+ if (style.bold !== undefined)
192
+ styleDefinition.bold = style.bold;
193
+ if (style.italic !== undefined)
194
+ styleDefinition.italic = style.italic;
195
+ if (style.underline !== undefined)
196
+ styleDefinition.underline = style.underline;
197
+ if (style.dim !== undefined)
198
+ styleDefinition.dim = style.dim;
199
+ }
200
+ const attributes = createTextAttributes2({
201
+ bold: styleDefinition.bold,
202
+ italic: styleDefinition.italic,
203
+ underline: styleDefinition.underline,
204
+ dim: styleDefinition.dim
205
+ });
206
+ const merged = {
207
+ fg: styleDefinition.fg,
208
+ bg: styleDefinition.bg,
209
+ attributes
210
+ };
211
+ this.mergedCache.set(cacheKey, merged);
212
+ return merged;
213
+ }
214
+ clearCache() {
215
+ this.guard();
216
+ this.mergedCache.clear();
217
+ }
218
+ getCacheSize() {
219
+ this.guard();
220
+ return this.mergedCache.size;
221
+ }
222
+ getAllStyles() {
223
+ this.guard();
224
+ return new Map(this.styleDefs);
225
+ }
226
+ getRegisteredNames() {
227
+ this.guard();
228
+ return Array.from(this.styleDefs.keys());
229
+ }
230
+ destroy() {
231
+ if (this._destroyed)
232
+ return;
233
+ this._destroyed = true;
234
+ this.nameCache.clear();
235
+ this.styleDefs.clear();
236
+ this.mergedCache.clear();
237
+ this.lib.destroySyntaxStyle(this.stylePtr);
238
+ }
239
+ }
44
240
 
45
241
  // src/Renderable.ts
46
242
  import { EventEmitter } from "events";
@@ -120,22 +316,22 @@ function isSizeType(value) {
120
316
 
121
317
  // src/Renderable.ts
122
318
  var BrandedRenderable = Symbol.for("@opentui/core/Renderable");
123
- var LayoutEvents;
124
- ((LayoutEvents2) => {
125
- LayoutEvents2["LAYOUT_CHANGED"] = "layout-changed";
126
- LayoutEvents2["RESIZED"] = "resized";
127
- })(LayoutEvents ||= {});
128
- var RenderableEvents;
129
- ((RenderableEvents2) => {
130
- RenderableEvents2["FOCUSED"] = "focused";
131
- RenderableEvents2["BLURRED"] = "blurred";
132
- RenderableEvents2["DESTROYED"] = "destroyed";
133
- })(RenderableEvents ||= {});
134
- function isRenderable(obj) {
319
+ var LayoutEvents2;
320
+ ((LayoutEvents) => {
321
+ LayoutEvents["LAYOUT_CHANGED"] = "layout-changed";
322
+ LayoutEvents["RESIZED"] = "resized";
323
+ })(LayoutEvents2 ||= {});
324
+ var RenderableEvents2;
325
+ ((RenderableEvents) => {
326
+ RenderableEvents["FOCUSED"] = "focused";
327
+ RenderableEvents["BLURRED"] = "blurred";
328
+ RenderableEvents["DESTROYED"] = "destroyed";
329
+ })(RenderableEvents2 ||= {});
330
+ function isRenderable2(obj) {
135
331
  return !!obj?.[BrandedRenderable];
136
332
  }
137
333
 
138
- class BaseRenderable extends EventEmitter {
334
+ class BaseRenderable2 extends EventEmitter {
139
335
  [BrandedRenderable] = true;
140
336
  static renderableNumber = 1;
141
337
  _id;
@@ -145,7 +341,7 @@ class BaseRenderable extends EventEmitter {
145
341
  _visible = true;
146
342
  constructor(options) {
147
343
  super();
148
- this.num = BaseRenderable.renderableNumber++;
344
+ this.num = BaseRenderable2.renderableNumber++;
149
345
  this._id = options.id ?? `renderable-${this.num}`;
150
346
  }
151
347
  get id() {
@@ -189,7 +385,7 @@ function bumpRenderListRevision(ctx) {
189
385
  generationContext.__otuiRenderListRevision = getRenderListRevision(ctx) + 1;
190
386
  }
191
387
 
192
- class Renderable extends BaseRenderable {
388
+ class Renderable2 extends BaseRenderable2 {
193
389
  static renderablesByNumber = new Map;
194
390
  _isDestroyed = false;
195
391
  _ctx;
@@ -239,7 +435,7 @@ class Renderable extends BaseRenderable {
239
435
  constructor(ctx, options) {
240
436
  super(options);
241
437
  this._ctx = ctx;
242
- Renderable.renderablesByNumber.set(this.num, this);
438
+ Renderable2.renderablesByNumber.set(this.num, this);
243
439
  validateOptions(this.id, options);
244
440
  this.renderBefore = options.renderBefore;
245
441
  this.renderAfter = options.renderAfter;
@@ -411,7 +607,7 @@ class Renderable extends BaseRenderable {
411
607
  for (const child of this._childrenInLayoutOrder) {
412
608
  if (child.id === id)
413
609
  return child;
414
- if (isRenderable(child)) {
610
+ if (isRenderable2(child)) {
415
611
  const found = child.findDescendantById(id);
416
612
  if (found)
417
613
  return found;
@@ -600,11 +796,11 @@ class Renderable extends BaseRenderable {
600
796
  this._flexShrink = hasExplicitWidth || hasExplicitHeight ? 0 : 1;
601
797
  node.setFlexShrink(this._flexShrink);
602
798
  }
603
- node.setFlexDirection(parseFlexDirection(options.flexDirection));
604
- node.setFlexWrap(parseWrap(options.flexWrap));
605
- node.setAlignItems(parseAlignItems(options.alignItems));
606
- node.setJustifyContent(parseJustify(options.justifyContent));
607
- node.setAlignSelf(parseAlign(options.alignSelf));
799
+ node.setFlexDirection(parseFlexDirection2(options.flexDirection));
800
+ node.setFlexWrap(parseWrap2(options.flexWrap));
801
+ node.setAlignItems(parseAlignItems2(options.alignItems));
802
+ node.setJustifyContent(parseJustify2(options.justifyContent));
803
+ node.setAlignSelf(parseAlign2(options.alignSelf));
608
804
  if (isDimensionType(options.width)) {
609
805
  this._width = options.width;
610
806
  this.yogaNode.setWidth(options.width);
@@ -615,11 +811,11 @@ class Renderable extends BaseRenderable {
615
811
  }
616
812
  this._positionType = options.position === "absolute" ? "absolute" : "relative";
617
813
  if (this._positionType !== "relative") {
618
- node.setPositionType(parsePositionType(this._positionType));
814
+ node.setPositionType(parsePositionType2(this._positionType));
619
815
  }
620
816
  this._overflow = options.overflow === "hidden" ? "hidden" : options.overflow === "scroll" ? "scroll" : "visible";
621
817
  if (this._overflow !== "visible") {
622
- node.setOverflow(parseOverflow(this._overflow));
818
+ node.setOverflow(parseOverflow2(this._overflow));
623
819
  }
624
820
  const hasPositionProps = options.top !== undefined || options.right !== undefined || options.bottom !== undefined || options.left !== undefined;
625
821
  if (hasPositionProps) {
@@ -688,7 +884,7 @@ class Renderable extends BaseRenderable {
688
884
  if (!isPositionTypeType(positionType) || this._positionType === positionType)
689
885
  return;
690
886
  this._positionType = positionType;
691
- this.yogaNode.setPositionType(parsePositionType(positionType));
887
+ this.yogaNode.setPositionType(parsePositionType2(positionType));
692
888
  this.requestRender();
693
889
  }
694
890
  get overflow() {
@@ -698,7 +894,7 @@ class Renderable extends BaseRenderable {
698
894
  if (!isOverflowType(overflow) || this._overflow === overflow)
699
895
  return;
700
896
  this._overflow = overflow;
701
- this.yogaNode.setOverflow(parseOverflow(overflow));
897
+ this.yogaNode.setOverflow(parseOverflow2(overflow));
702
898
  bumpRenderListRevision(this._ctx);
703
899
  this.requestRender();
704
900
  }
@@ -754,23 +950,23 @@ class Renderable extends BaseRenderable {
754
950
  this.requestRender();
755
951
  }
756
952
  set flexDirection(direction) {
757
- this.yogaNode.setFlexDirection(parseFlexDirection(direction));
953
+ this.yogaNode.setFlexDirection(parseFlexDirection2(direction));
758
954
  this.requestRender();
759
955
  }
760
956
  set flexWrap(wrap) {
761
- this.yogaNode.setFlexWrap(parseWrap(wrap));
957
+ this.yogaNode.setFlexWrap(parseWrap2(wrap));
762
958
  this.requestRender();
763
959
  }
764
960
  set alignItems(alignItems) {
765
- this.yogaNode.setAlignItems(parseAlignItems(alignItems));
961
+ this.yogaNode.setAlignItems(parseAlignItems2(alignItems));
766
962
  this.requestRender();
767
963
  }
768
964
  set justifyContent(justifyContent) {
769
- this.yogaNode.setJustifyContent(parseJustify(justifyContent));
965
+ this.yogaNode.setJustifyContent(parseJustify2(justifyContent));
770
966
  this.requestRender();
771
967
  }
772
968
  set alignSelf(alignSelf) {
773
- this.yogaNode.setAlignSelf(parseAlign(alignSelf));
969
+ this.yogaNode.setAlignSelf(parseAlign2(alignSelf));
774
970
  this.requestRender();
775
971
  }
776
972
  set flexBasis(basis) {
@@ -955,7 +1151,7 @@ class Renderable extends BaseRenderable {
955
1151
  }
956
1152
  try {
957
1153
  const widthMethod = this._ctx.widthMethod;
958
- this.frameBuffer = OptimizedBuffer.create(w, h, widthMethod, {
1154
+ this.frameBuffer = OptimizedBuffer2.create(w, h, widthMethod, {
959
1155
  respectAlpha: true,
960
1156
  id: `framebuffer-${this.id}`
961
1157
  });
@@ -978,7 +1174,7 @@ class Renderable extends BaseRenderable {
978
1174
  if (!obj) {
979
1175
  return -1;
980
1176
  }
981
- const renderable = maybeMakeRenderable(this._ctx, obj);
1177
+ const renderable = maybeMakeRenderable2(this._ctx, obj);
982
1178
  if (!renderable) {
983
1179
  return -1;
984
1180
  }
@@ -1023,7 +1219,7 @@ class Renderable extends BaseRenderable {
1023
1219
  if (!obj) {
1024
1220
  return -1;
1025
1221
  }
1026
- const renderable = maybeMakeRenderable(this._ctx, obj);
1222
+ const renderable = maybeMakeRenderable2(this._ctx, obj);
1027
1223
  if (!renderable) {
1028
1224
  return -1;
1029
1225
  }
@@ -1033,7 +1229,7 @@ class Renderable extends BaseRenderable {
1033
1229
  }
1034
1230
  return -1;
1035
1231
  }
1036
- if (!isRenderable(anchor)) {
1232
+ if (!isRenderable2(anchor)) {
1037
1233
  throw new Error("Anchor must be a Renderable");
1038
1234
  }
1039
1235
  if (anchor.isDestroyed) {
@@ -1082,7 +1278,7 @@ class Renderable extends BaseRenderable {
1082
1278
  return this._childrenInLayoutOrder.find((child) => child.id === id);
1083
1279
  }
1084
1280
  remove(child) {
1085
- if (!(child instanceof BaseRenderable)) {
1281
+ if (!(child instanceof BaseRenderable2)) {
1086
1282
  throw new Error("remove expects a renderable child object");
1087
1283
  }
1088
1284
  const index = this._childrenInLayoutOrder.indexOf(child);
@@ -1199,13 +1395,13 @@ class Renderable extends BaseRenderable {
1199
1395
  }
1200
1396
  }
1201
1397
  _hasVisibleChildFilter() {
1202
- return this._getVisibleChildren !== Renderable.prototype._getVisibleChildren;
1398
+ return this._getVisibleChildren !== Renderable2.prototype._getVisibleChildren;
1203
1399
  }
1204
1400
  _getVisibleChildren() {
1205
1401
  return this._childrenInZIndexOrder.map((child) => child.num);
1206
1402
  }
1207
1403
  canReuseRenderCommandList() {
1208
- return this.onUpdate === Renderable.prototype.onUpdate && (this._overflow === "visible" || this.getScissorRect === Renderable.prototype.getScissorRect) && !this._hasVisibleChildFilter();
1404
+ return this.onUpdate === Renderable2.prototype.onUpdate && (this._overflow === "visible" || this.getScissorRect === Renderable2.prototype.getScissorRect) && !this._hasVisibleChildFilter();
1209
1405
  }
1210
1406
  onUpdate(deltaTime) {}
1211
1407
  getScissorRect() {
@@ -1239,7 +1435,7 @@ class Renderable extends BaseRenderable {
1239
1435
  this._childrenInLayoutOrder = [];
1240
1436
  this._childrenInZIndexOrder = [];
1241
1437
  this._shouldUpdateBefore.clear();
1242
- Renderable.renderablesByNumber.delete(this.num);
1438
+ Renderable2.renderablesByNumber.delete(this.num);
1243
1439
  this.blur();
1244
1440
  this.removeAllListeners();
1245
1441
  this.destroySelf();
@@ -1363,7 +1559,7 @@ class Renderable extends BaseRenderable {
1363
1559
  }
1364
1560
  }
1365
1561
 
1366
- class RootRenderable extends Renderable {
1562
+ class RootRenderable2 extends Renderable2 {
1367
1563
  renderList = [];
1368
1564
  _currentRenderable;
1369
1565
  appliedLayoutGeneration = -1;
@@ -1490,7 +1686,7 @@ class RootRenderable extends Renderable {
1490
1686
  import util from "node:util";
1491
1687
  var BrandedVNode = Symbol.for("@opentui/core/VNode");
1492
1688
  function isRenderableConstructor(value) {
1493
- return typeof value === "function" && value.prototype && Renderable.prototype.isPrototypeOf(value.prototype);
1689
+ return typeof value === "function" && value.prototype && Renderable2.prototype.isPrototypeOf(value.prototype);
1494
1690
  }
1495
1691
  function flattenChildren(children) {
1496
1692
  const result = [];
@@ -1503,7 +1699,7 @@ function flattenChildren(children) {
1503
1699
  }
1504
1700
  return result;
1505
1701
  }
1506
- function h(type, props, ...children) {
1702
+ function h2(type, props, ...children) {
1507
1703
  if (typeof type !== "function") {
1508
1704
  throw new TypeError("h() received an invalid vnode type");
1509
1705
  }
@@ -1549,20 +1745,20 @@ function h(type, props, ...children) {
1549
1745
  }
1550
1746
  return vnode;
1551
1747
  }
1552
- function isVNode(node) {
1748
+ function isVNode2(node) {
1553
1749
  return node && node[BrandedVNode];
1554
1750
  }
1555
- function maybeMakeRenderable(ctx, node) {
1556
- if (isRenderable(node))
1751
+ function maybeMakeRenderable2(ctx, node) {
1752
+ if (isRenderable2(node))
1557
1753
  return node;
1558
- if (isVNode(node))
1559
- return instantiate(ctx, node);
1754
+ if (isVNode2(node))
1755
+ return instantiate2(ctx, node);
1560
1756
  if (true) {
1561
1757
  console.warn("maybeMakeRenderable received an invalid node", util.inspect(node, { depth: 2 }));
1562
1758
  }
1563
1759
  return null;
1564
1760
  }
1565
- function wrapWithDelegates(instance, delegateMap) {
1761
+ function wrapWithDelegates2(instance, delegateMap) {
1566
1762
  if (!delegateMap || Object.keys(delegateMap).length === 0)
1567
1763
  return instance;
1568
1764
  const getDescendant = (id) => {
@@ -1594,8 +1790,8 @@ function wrapWithDelegates(instance, delegateMap) {
1594
1790
  });
1595
1791
  return proxy;
1596
1792
  }
1597
- function instantiate(ctx, node) {
1598
- if (isRenderable(node))
1793
+ function instantiate2(ctx, node) {
1794
+ if (isRenderable2(node))
1599
1795
  return node;
1600
1796
  if (!node || typeof node !== "object") {
1601
1797
  throw new TypeError("mount() received an invalid vnode");
@@ -1607,14 +1803,14 @@ function instantiate(ctx, node) {
1607
1803
  if (isRenderableConstructor(type)) {
1608
1804
  const instance = new type(ctx, props || {});
1609
1805
  for (const child of children) {
1610
- if (isRenderable(child)) {
1806
+ if (isRenderable2(child)) {
1611
1807
  instance.add(child);
1612
1808
  } else {
1613
- const mounted = instantiate(ctx, child);
1809
+ const mounted = instantiate2(ctx, child);
1614
1810
  instance.add(mounted);
1615
1811
  }
1616
1812
  }
1617
- const delegatedInstance = wrapWithDelegates(instance, delegateMap);
1813
+ const delegatedInstance = wrapWithDelegates2(instance, delegateMap);
1618
1814
  const pendingCalls = vnode.__pendingCalls;
1619
1815
  if (pendingCalls) {
1620
1816
  for (const call of pendingCalls) {
@@ -1628,12 +1824,12 @@ function instantiate(ctx, node) {
1628
1824
  return delegatedInstance;
1629
1825
  }
1630
1826
  const resolved = type(props || {}, children);
1631
- const inst = instantiate(ctx, resolved);
1632
- return wrapWithDelegates(inst, delegateMap);
1827
+ const inst = instantiate2(ctx, resolved);
1828
+ return wrapWithDelegates2(inst, delegateMap);
1633
1829
  }
1634
- function delegate(mapping, vnode) {
1635
- if (isRenderable(vnode)) {
1636
- return wrapWithDelegates(vnode, mapping);
1830
+ function delegate2(mapping, vnode) {
1831
+ if (isRenderable2(vnode)) {
1832
+ return wrapWithDelegates2(vnode, mapping);
1637
1833
  }
1638
1834
  if (!vnode || typeof vnode !== "object")
1639
1835
  return vnode;
@@ -1642,7 +1838,7 @@ function delegate(mapping, vnode) {
1642
1838
  }
1643
1839
 
1644
1840
  // src/text-buffer-view.ts
1645
- class TextBufferView {
1841
+ class TextBufferView2 {
1646
1842
  lib;
1647
1843
  viewPtr;
1648
1844
  textBuffer;
@@ -1653,9 +1849,9 @@ class TextBufferView {
1653
1849
  this.textBuffer = textBuffer;
1654
1850
  }
1655
1851
  static create(textBuffer) {
1656
- const lib = resolveRenderLib();
1852
+ const lib = resolveRenderLib2();
1657
1853
  const viewPtr = lib.createTextBufferView(textBuffer.ptr);
1658
- return new TextBufferView(lib, viewPtr, textBuffer);
1854
+ return new TextBufferView2(lib, viewPtr, textBuffer);
1659
1855
  }
1660
1856
  guard() {
1661
1857
  if (this._destroyed)
@@ -1733,6 +1929,10 @@ class TextBufferView {
1733
1929
  this.guard();
1734
1930
  return this.lib.textBufferViewGetLogicalLineInfo(this.viewPtr);
1735
1931
  }
1932
+ getLineSources(startLine, lineCount) {
1933
+ this.guard();
1934
+ return this.lib.textBufferViewGetLineSources(this.viewPtr, startLine, lineCount);
1935
+ }
1736
1936
  getSelectedText() {
1737
1937
  this.guard();
1738
1938
  const byteSize = this.textBuffer.byteSize;
@@ -1785,7 +1985,7 @@ class TextBufferView {
1785
1985
  // src/edit-buffer.ts
1786
1986
  import { EventEmitter as EventEmitter2 } from "events";
1787
1987
 
1788
- class EditBuffer extends EventEmitter2 {
1988
+ class EditBuffer2 extends EventEmitter2 {
1789
1989
  static registry = new Map;
1790
1990
  static nativeEventsSubscribed = false;
1791
1991
  lib;
@@ -1803,23 +2003,23 @@ class EditBuffer extends EventEmitter2 {
1803
2003
  this.bufferPtr = ptr;
1804
2004
  this.textBufferPtr = lib.editBufferGetTextBuffer(ptr);
1805
2005
  this.id = lib.editBufferGetId(ptr);
1806
- EditBuffer.registry.set(this.id, this);
1807
- EditBuffer.subscribeToNativeEvents(lib);
2006
+ EditBuffer2.registry.set(this.id, this);
2007
+ EditBuffer2.subscribeToNativeEvents(lib);
1808
2008
  }
1809
2009
  static create(widthMethod) {
1810
- const lib = resolveRenderLib();
2010
+ const lib = resolveRenderLib2();
1811
2011
  const ptr = lib.createEditBuffer(widthMethod);
1812
- return new EditBuffer(lib, ptr);
2012
+ return new EditBuffer2(lib, ptr);
1813
2013
  }
1814
2014
  static subscribeToNativeEvents(lib) {
1815
- if (EditBuffer.nativeEventsSubscribed)
2015
+ if (EditBuffer2.nativeEventsSubscribed)
1816
2016
  return;
1817
- EditBuffer.nativeEventsSubscribed = true;
2017
+ EditBuffer2.nativeEventsSubscribed = true;
1818
2018
  lib.onAnyNativeEvent((name, data) => {
1819
2019
  const buffer = new Uint16Array(data);
1820
2020
  if (name.startsWith("eb_") && buffer.length >= 1) {
1821
2021
  const id = buffer[0];
1822
- const instance = EditBuffer.registry.get(id);
2022
+ const instance = EditBuffer2.registry.get(id);
1823
2023
  if (instance) {
1824
2024
  const eventName = name.slice(3);
1825
2025
  const eventData = data.slice(2);
@@ -2098,13 +2298,13 @@ class EditBuffer extends EventEmitter2 {
2098
2298
  if (this._destroyed)
2099
2299
  return;
2100
2300
  this._destroyed = true;
2101
- EditBuffer.registry.delete(this.id);
2301
+ EditBuffer2.registry.delete(this.id);
2102
2302
  this.lib.destroyEditBuffer(this.bufferPtr);
2103
2303
  }
2104
2304
  }
2105
2305
 
2106
2306
  // src/editor-view.ts
2107
- class EditorView {
2307
+ class EditorView2 {
2108
2308
  lib;
2109
2309
  viewPtr;
2110
2310
  editBuffer;
@@ -2117,9 +2317,9 @@ class EditorView {
2117
2317
  this.editBuffer = editBuffer;
2118
2318
  }
2119
2319
  static create(editBuffer, viewportWidth, viewportHeight) {
2120
- const lib = resolveRenderLib();
2320
+ const lib = resolveRenderLib2();
2121
2321
  const viewPtr = lib.createEditorView(editBuffer.ptr, viewportWidth, viewportHeight);
2122
- return new EditorView(lib, viewPtr, editBuffer);
2322
+ return new EditorView2(lib, viewPtr, editBuffer);
2123
2323
  }
2124
2324
  guard() {
2125
2325
  if (this._destroyed)
@@ -2284,7 +2484,7 @@ class EditorView {
2284
2484
  }
2285
2485
  get extmarks() {
2286
2486
  if (!this._extmarksController) {
2287
- this._extmarksController = createExtmarksController(this.editBuffer, this);
2487
+ this._extmarksController = createExtmarksController2(this.editBuffer, this);
2288
2488
  }
2289
2489
  return this._extmarksController;
2290
2490
  }
@@ -2318,201 +2518,6 @@ class EditorView {
2318
2518
  }
2319
2519
  }
2320
2520
 
2321
- // src/syntax-style.ts
2322
- function convertThemeToStyles(theme) {
2323
- const flatStyles = {};
2324
- for (const tokenStyle of theme) {
2325
- const styleDefinition = {};
2326
- if (tokenStyle.style.foreground) {
2327
- styleDefinition.fg = parseColor(tokenStyle.style.foreground);
2328
- }
2329
- if (tokenStyle.style.background) {
2330
- styleDefinition.bg = parseColor(tokenStyle.style.background);
2331
- }
2332
- if (tokenStyle.style.bold !== undefined) {
2333
- styleDefinition.bold = tokenStyle.style.bold;
2334
- }
2335
- if (tokenStyle.style.italic !== undefined) {
2336
- styleDefinition.italic = tokenStyle.style.italic;
2337
- }
2338
- if (tokenStyle.style.underline !== undefined) {
2339
- styleDefinition.underline = tokenStyle.style.underline;
2340
- }
2341
- if (tokenStyle.style.dim !== undefined) {
2342
- styleDefinition.dim = tokenStyle.style.dim;
2343
- }
2344
- for (const scope of tokenStyle.scope) {
2345
- flatStyles[scope] = styleDefinition;
2346
- }
2347
- }
2348
- return flatStyles;
2349
- }
2350
-
2351
- class SyntaxStyle {
2352
- lib;
2353
- stylePtr;
2354
- _destroyed = false;
2355
- nameCache = new Map;
2356
- styleDefs = new Map;
2357
- mergedCache = new Map;
2358
- constructor(lib, ptr) {
2359
- this.lib = lib;
2360
- this.stylePtr = ptr;
2361
- }
2362
- static create() {
2363
- const lib = resolveRenderLib();
2364
- const ptr = lib.createSyntaxStyle();
2365
- return new SyntaxStyle(lib, ptr);
2366
- }
2367
- static fromTheme(theme) {
2368
- const style = SyntaxStyle.create();
2369
- const flatStyles = convertThemeToStyles(theme);
2370
- for (const [name, styleDef] of Object.entries(flatStyles)) {
2371
- style.registerStyle(name, styleDef);
2372
- }
2373
- return style;
2374
- }
2375
- static fromStyles(styles) {
2376
- const style = SyntaxStyle.create();
2377
- for (const [name, styleDef] of Object.entries(styles)) {
2378
- style.registerStyle(name, styleDef);
2379
- }
2380
- return style;
2381
- }
2382
- guard() {
2383
- if (this._destroyed)
2384
- throw new Error("NativeSyntaxStyle is destroyed");
2385
- }
2386
- registerStyle(name, style) {
2387
- this.guard();
2388
- const attributes = createTextAttributes({
2389
- bold: style.bold,
2390
- italic: style.italic,
2391
- underline: style.underline,
2392
- dim: style.dim
2393
- });
2394
- const fg = style.fg ? parseColor(style.fg) : null;
2395
- const bg = style.bg ? parseColor(style.bg) : null;
2396
- const id = this.lib.syntaxStyleRegister(this.stylePtr, name, fg, bg, attributes);
2397
- this.nameCache.set(name, id);
2398
- this.styleDefs.set(name, { ...style, fg: fg ?? undefined, bg: bg ?? undefined });
2399
- return id;
2400
- }
2401
- resolveStyleId(name) {
2402
- this.guard();
2403
- const cached = this.nameCache.get(name);
2404
- if (cached !== undefined)
2405
- return cached;
2406
- const id = this.lib.syntaxStyleResolveByName(this.stylePtr, name);
2407
- if (id !== null) {
2408
- this.nameCache.set(name, id);
2409
- }
2410
- return id;
2411
- }
2412
- getStyleId(name) {
2413
- this.guard();
2414
- const id = this.resolveStyleId(name);
2415
- if (id !== null)
2416
- return id;
2417
- if (name.includes(".")) {
2418
- const baseName = name.split(".")[0];
2419
- return this.resolveStyleId(baseName);
2420
- }
2421
- return null;
2422
- }
2423
- get ptr() {
2424
- this.guard();
2425
- return this.stylePtr;
2426
- }
2427
- getStyleCount() {
2428
- this.guard();
2429
- return this.lib.syntaxStyleGetStyleCount(this.stylePtr);
2430
- }
2431
- clearNameCache() {
2432
- this.nameCache.clear();
2433
- }
2434
- getStyle(name) {
2435
- this.guard();
2436
- if (Object.prototype.hasOwnProperty.call(this.styleDefs, name)) {
2437
- return;
2438
- }
2439
- const style = this.styleDefs.get(name);
2440
- if (style)
2441
- return style;
2442
- if (name.includes(".")) {
2443
- const baseName = name.split(".")[0];
2444
- if (Object.prototype.hasOwnProperty.call(this.styleDefs, baseName)) {
2445
- return;
2446
- }
2447
- return this.styleDefs.get(baseName);
2448
- }
2449
- return;
2450
- }
2451
- mergeStyles(...styleNames) {
2452
- this.guard();
2453
- const cacheKey = styleNames.join(":");
2454
- const cached = this.mergedCache.get(cacheKey);
2455
- if (cached)
2456
- return cached;
2457
- const styleDefinition = {};
2458
- for (const name of styleNames) {
2459
- const style = this.getStyle(name);
2460
- if (!style)
2461
- continue;
2462
- if (style.fg)
2463
- styleDefinition.fg = style.fg;
2464
- if (style.bg)
2465
- styleDefinition.bg = style.bg;
2466
- if (style.bold !== undefined)
2467
- styleDefinition.bold = style.bold;
2468
- if (style.italic !== undefined)
2469
- styleDefinition.italic = style.italic;
2470
- if (style.underline !== undefined)
2471
- styleDefinition.underline = style.underline;
2472
- if (style.dim !== undefined)
2473
- styleDefinition.dim = style.dim;
2474
- }
2475
- const attributes = createTextAttributes({
2476
- bold: styleDefinition.bold,
2477
- italic: styleDefinition.italic,
2478
- underline: styleDefinition.underline,
2479
- dim: styleDefinition.dim
2480
- });
2481
- const merged = {
2482
- fg: styleDefinition.fg,
2483
- bg: styleDefinition.bg,
2484
- attributes
2485
- };
2486
- this.mergedCache.set(cacheKey, merged);
2487
- return merged;
2488
- }
2489
- clearCache() {
2490
- this.guard();
2491
- this.mergedCache.clear();
2492
- }
2493
- getCacheSize() {
2494
- this.guard();
2495
- return this.mergedCache.size;
2496
- }
2497
- getAllStyles() {
2498
- this.guard();
2499
- return new Map(this.styleDefs);
2500
- }
2501
- getRegisteredNames() {
2502
- this.guard();
2503
- return Array.from(this.styleDefs.keys());
2504
- }
2505
- destroy() {
2506
- if (this._destroyed)
2507
- return;
2508
- this._destroyed = true;
2509
- this.nameCache.clear();
2510
- this.styleDefs.clear();
2511
- this.mergedCache.clear();
2512
- this.lib.destroySyntaxStyle(this.stylePtr);
2513
- }
2514
- }
2515
-
2516
2521
  // src/renderables/Box.ts
2517
2522
  function isGapType(value) {
2518
2523
  if (value === undefined) {
@@ -2524,7 +2529,7 @@ function isGapType(value) {
2524
2529
  return isValidPercentage(value);
2525
2530
  }
2526
2531
 
2527
- class BoxRenderable extends Renderable {
2532
+ class BoxRenderable2 extends Renderable2 {
2528
2533
  _backgroundColor;
2529
2534
  _border;
2530
2535
  _borderStyle;
@@ -2554,20 +2559,20 @@ class BoxRenderable extends Renderable {
2554
2559
  if (options.focusable === true) {
2555
2560
  this._focusable = true;
2556
2561
  }
2557
- this._backgroundColor = parseColor(options.backgroundColor || this._defaultOptions.backgroundColor);
2562
+ this._backgroundColor = parseColor2(options.backgroundColor || this._defaultOptions.backgroundColor);
2558
2563
  this._border = options.border ?? this._defaultOptions.border;
2559
2564
  if (!options.border && (options.borderStyle || options.borderColor || options.focusedBorderColor || options.customBorderChars)) {
2560
2565
  this._border = true;
2561
2566
  }
2562
- this._borderStyle = parseBorderStyle(options.borderStyle, this._defaultOptions.borderStyle);
2563
- this._borderColor = parseColor(options.borderColor || this._defaultOptions.borderColor);
2564
- this._focusedBorderColor = parseColor(options.focusedBorderColor || this._defaultOptions.focusedBorderColor);
2567
+ this._borderStyle = parseBorderStyle2(options.borderStyle, this._defaultOptions.borderStyle);
2568
+ this._borderColor = parseColor2(options.borderColor || this._defaultOptions.borderColor);
2569
+ this._focusedBorderColor = parseColor2(options.focusedBorderColor || this._defaultOptions.focusedBorderColor);
2565
2570
  this._customBorderCharsObj = options.customBorderChars;
2566
- this._customBorderChars = this._customBorderCharsObj ? borderCharsToArray(this._customBorderCharsObj) : undefined;
2567
- this.borderSides = getBorderSides(this._border);
2571
+ this._customBorderChars = this._customBorderCharsObj ? borderCharsToArray2(this._customBorderCharsObj) : undefined;
2572
+ this.borderSides = getBorderSides2(this._border);
2568
2573
  this.shouldFill = options.shouldFill ?? this._defaultOptions.shouldFill;
2569
2574
  this._title = options.title;
2570
- this._titleColor = options.titleColor ? parseColor(options.titleColor) : undefined;
2575
+ this._titleColor = options.titleColor ? parseColor2(options.titleColor) : undefined;
2571
2576
  this._titleAlignment = options.titleAlignment || this._defaultOptions.titleAlignment;
2572
2577
  this._bottomTitle = options.bottomTitle;
2573
2578
  this._bottomTitleAlignment = options.bottomTitleAlignment || this._defaultOptions.bottomTitleAlignment;
@@ -2580,7 +2585,7 @@ class BoxRenderable extends Renderable {
2580
2585
  initializeBorder() {
2581
2586
  if (this._border === false) {
2582
2587
  this._border = true;
2583
- this.borderSides = getBorderSides(this._border);
2588
+ this.borderSides = getBorderSides2(this._border);
2584
2589
  this.applyYogaBorders();
2585
2590
  }
2586
2591
  }
@@ -2589,14 +2594,14 @@ class BoxRenderable extends Renderable {
2589
2594
  }
2590
2595
  set customBorderChars(value) {
2591
2596
  this._customBorderCharsObj = value;
2592
- this._customBorderChars = value ? borderCharsToArray(value) : undefined;
2597
+ this._customBorderChars = value ? borderCharsToArray2(value) : undefined;
2593
2598
  this.requestRender();
2594
2599
  }
2595
2600
  get backgroundColor() {
2596
2601
  return this._backgroundColor;
2597
2602
  }
2598
2603
  set backgroundColor(value) {
2599
- const newColor = parseColor(value ?? this._defaultOptions.backgroundColor);
2604
+ const newColor = parseColor2(value ?? this._defaultOptions.backgroundColor);
2600
2605
  if (this._backgroundColor !== newColor) {
2601
2606
  this._backgroundColor = newColor;
2602
2607
  this.requestRender();
@@ -2608,7 +2613,7 @@ class BoxRenderable extends Renderable {
2608
2613
  set border(value) {
2609
2614
  if (this._border !== value) {
2610
2615
  this._border = value;
2611
- this.borderSides = getBorderSides(value);
2616
+ this.borderSides = getBorderSides2(value);
2612
2617
  this.applyYogaBorders();
2613
2618
  this.requestRender();
2614
2619
  }
@@ -2617,7 +2622,7 @@ class BoxRenderable extends Renderable {
2617
2622
  return this._borderStyle;
2618
2623
  }
2619
2624
  set borderStyle(value) {
2620
- const _value = parseBorderStyle(value, this._defaultOptions.borderStyle);
2625
+ const _value = parseBorderStyle2(value, this._defaultOptions.borderStyle);
2621
2626
  if (this._borderStyle !== _value || !this._border) {
2622
2627
  this._borderStyle = _value;
2623
2628
  this._customBorderChars = undefined;
@@ -2629,7 +2634,7 @@ class BoxRenderable extends Renderable {
2629
2634
  return this._borderColor;
2630
2635
  }
2631
2636
  set borderColor(value) {
2632
- const newColor = parseColor(value ?? this._defaultOptions.borderColor);
2637
+ const newColor = parseColor2(value ?? this._defaultOptions.borderColor);
2633
2638
  if (this._borderColor !== newColor) {
2634
2639
  this._borderColor = newColor;
2635
2640
  this.initializeBorder();
@@ -2640,7 +2645,7 @@ class BoxRenderable extends Renderable {
2640
2645
  return this._focusedBorderColor;
2641
2646
  }
2642
2647
  set focusedBorderColor(value) {
2643
- const newColor = parseColor(value ?? this._defaultOptions.focusedBorderColor);
2648
+ const newColor = parseColor2(value ?? this._defaultOptions.focusedBorderColor);
2644
2649
  if (this._focusedBorderColor !== newColor) {
2645
2650
  this._focusedBorderColor = newColor;
2646
2651
  this.initializeBorder();
@@ -2662,7 +2667,7 @@ class BoxRenderable extends Renderable {
2662
2667
  return this._titleColor;
2663
2668
  }
2664
2669
  set titleColor(value) {
2665
- const newColor = value ? parseColor(value) : undefined;
2670
+ const newColor = value ? parseColor2(value) : undefined;
2666
2671
  if (this._titleColor !== newColor) {
2667
2672
  this._titleColor = newColor;
2668
2673
  this.requestRender();
@@ -2780,7 +2785,7 @@ class BoxRenderable extends Renderable {
2780
2785
  }
2781
2786
 
2782
2787
  // src/renderables/TextBufferRenderable.ts
2783
- class TextBufferRenderable extends Renderable {
2788
+ class TextBufferRenderable2 extends Renderable2 {
2784
2789
  selectable = true;
2785
2790
  _defaultFg;
2786
2791
  _defaultBg;
@@ -2800,8 +2805,8 @@ class TextBufferRenderable extends Renderable {
2800
2805
  _textBufferSyntaxStyle;
2801
2806
  nativeRenderable = null;
2802
2807
  _defaultOptions = {
2803
- fg: RGBA.fromValues(1, 1, 1, 1),
2804
- bg: RGBA.fromValues(0, 0, 0, 0),
2808
+ fg: RGBA2.fromValues(1, 1, 1, 1),
2809
+ bg: RGBA2.fromValues(0, 0, 0, 0),
2805
2810
  selectionBg: undefined,
2806
2811
  selectionFg: undefined,
2807
2812
  selectable: true,
@@ -2813,20 +2818,20 @@ class TextBufferRenderable extends Renderable {
2813
2818
  };
2814
2819
  constructor(ctx, options) {
2815
2820
  super(ctx, options);
2816
- this._defaultFg = parseColor(options.fg ?? this._defaultOptions.fg);
2817
- this._defaultBg = parseColor(options.bg ?? this._defaultOptions.bg);
2821
+ this._defaultFg = parseColor2(options.fg ?? this._defaultOptions.fg);
2822
+ this._defaultBg = parseColor2(options.bg ?? this._defaultOptions.bg);
2818
2823
  this._defaultAttributes = options.attributes ?? this._defaultOptions.attributes;
2819
- this._selectionBg = options.selectionBg ? parseColor(options.selectionBg) : this._defaultOptions.selectionBg;
2820
- this._selectionFg = options.selectionFg ? parseColor(options.selectionFg) : this._defaultOptions.selectionFg;
2824
+ this._selectionBg = options.selectionBg ? parseColor2(options.selectionBg) : this._defaultOptions.selectionBg;
2825
+ this._selectionFg = options.selectionFg ? parseColor2(options.selectionFg) : this._defaultOptions.selectionFg;
2821
2826
  this.selectable = options.selectable ?? this._defaultOptions.selectable;
2822
2827
  this._wrapMode = options.wrapMode ?? this._defaultOptions.wrapMode;
2823
2828
  this._tabIndicator = options.tabIndicator ?? this._defaultOptions.tabIndicator;
2824
- this._tabIndicatorColor = options.tabIndicatorColor ? parseColor(options.tabIndicatorColor) : this._defaultOptions.tabIndicatorColor;
2829
+ this._tabIndicatorColor = options.tabIndicatorColor ? parseColor2(options.tabIndicatorColor) : this._defaultOptions.tabIndicatorColor;
2825
2830
  this._truncate = options.truncate ?? this._defaultOptions.truncate;
2826
- this.textBuffer = TextBuffer.create(this._ctx.widthMethod);
2827
- this.textBufferView = TextBufferView.create(this.textBuffer);
2831
+ this.textBuffer = TextBuffer2.create(this._ctx.widthMethod);
2832
+ this.textBufferView = TextBufferView2.create(this.textBuffer);
2828
2833
  this._firstLineOffset = ctx.claimFirstLineOffset?.(this) ?? 0;
2829
- this._textBufferSyntaxStyle = SyntaxStyle.create();
2834
+ this._textBufferSyntaxStyle = SyntaxStyle2.create();
2830
2835
  this.textBuffer.setSyntaxStyle(this._textBufferSyntaxStyle);
2831
2836
  this.textBufferView.setWrapMode(this._wrapMode);
2832
2837
  this.textBufferView.setFirstLineOffset(this._firstLineOffset);
@@ -2874,6 +2879,23 @@ class TextBufferRenderable extends Renderable {
2874
2879
  get lineInfo() {
2875
2880
  return this.textBufferView.logicalLineInfo;
2876
2881
  }
2882
+ getLineSources(startLine, lineCount) {
2883
+ if (this.needsLineInfoFallback(TextBufferRenderable2.prototype)) {
2884
+ return this.lineInfo.lineSources.slice(startLine, startLine + lineCount);
2885
+ }
2886
+ return this.textBufferView.getLineSources(startLine, lineCount);
2887
+ }
2888
+ needsLineInfoFallback(owner) {
2889
+ let prototype = this;
2890
+ while (prototype && prototype !== owner) {
2891
+ if (Object.hasOwn(prototype, "getLineSources"))
2892
+ return false;
2893
+ if (Object.hasOwn(prototype, "lineInfo"))
2894
+ return true;
2895
+ prototype = Object.getPrototypeOf(prototype);
2896
+ }
2897
+ return false;
2898
+ }
2877
2899
  get lineCount() {
2878
2900
  return this.textBuffer.getLineCount();
2879
2901
  }
@@ -2908,7 +2930,7 @@ class TextBufferRenderable extends Renderable {
2908
2930
  return this.lineInfo.lineWidthColsMax;
2909
2931
  }
2910
2932
  get scrollHeight() {
2911
- return this.lineInfo.lineStartCols.length;
2933
+ return this.virtualLineCount;
2912
2934
  }
2913
2935
  get maxScrollY() {
2914
2936
  return Math.max(0, this.scrollHeight - this.height);
@@ -2931,7 +2953,7 @@ class TextBufferRenderable extends Renderable {
2931
2953
  return this._defaultFg;
2932
2954
  }
2933
2955
  set fg(value) {
2934
- const newColor = parseColor(value ?? this._defaultOptions.fg);
2956
+ const newColor = parseColor2(value ?? this._defaultOptions.fg);
2935
2957
  if (this._defaultFg !== newColor) {
2936
2958
  this._defaultFg = newColor;
2937
2959
  this.textBuffer.setDefaultFg(this._defaultFg);
@@ -2943,7 +2965,7 @@ class TextBufferRenderable extends Renderable {
2943
2965
  return this._selectionBg;
2944
2966
  }
2945
2967
  set selectionBg(value) {
2946
- const newColor = value ? parseColor(value) : this._defaultOptions.selectionBg;
2968
+ const newColor = value ? parseColor2(value) : this._defaultOptions.selectionBg;
2947
2969
  if (this._selectionBg !== newColor) {
2948
2970
  this._selectionBg = newColor;
2949
2971
  if (this.lastLocalSelection) {
@@ -2956,7 +2978,7 @@ class TextBufferRenderable extends Renderable {
2956
2978
  return this._selectionFg;
2957
2979
  }
2958
2980
  set selectionFg(value) {
2959
- const newColor = value ? parseColor(value) : this._defaultOptions.selectionFg;
2981
+ const newColor = value ? parseColor2(value) : this._defaultOptions.selectionFg;
2960
2982
  if (this._selectionFg !== newColor) {
2961
2983
  this._selectionFg = newColor;
2962
2984
  if (this.lastLocalSelection) {
@@ -2969,7 +2991,7 @@ class TextBufferRenderable extends Renderable {
2969
2991
  return this._defaultBg;
2970
2992
  }
2971
2993
  set bg(value) {
2972
- const newColor = parseColor(value ?? this._defaultOptions.bg);
2994
+ const newColor = parseColor2(value ?? this._defaultOptions.bg);
2973
2995
  if (this._defaultBg !== newColor) {
2974
2996
  this._defaultBg = newColor;
2975
2997
  this.textBuffer.setDefaultBg(this._defaultBg);
@@ -3018,7 +3040,7 @@ class TextBufferRenderable extends Renderable {
3018
3040
  return this._tabIndicatorColor;
3019
3041
  }
3020
3042
  set tabIndicatorColor(value) {
3021
- const newColor = value ? parseColor(value) : undefined;
3043
+ const newColor = value ? parseColor2(value) : undefined;
3022
3044
  if (this._tabIndicatorColor !== newColor) {
3023
3045
  this._tabIndicatorColor = newColor;
3024
3046
  if (newColor !== undefined) {
@@ -3065,13 +3087,13 @@ class TextBufferRenderable extends Renderable {
3065
3087
  this.emit("line-info-change");
3066
3088
  }
3067
3089
  setupNativeRenderable() {
3068
- const lib = resolveRenderLib();
3090
+ const lib = resolveRenderLib2();
3069
3091
  const nativeRenderable = lib.createNativeRenderable();
3070
3092
  if (!lib.nativeRenderableAttachYogaNode(nativeRenderable, this.yogaNode.ptr)) {
3071
3093
  lib.destroyNativeRenderable(nativeRenderable);
3072
3094
  throw new Error("Failed to attach native renderable Yoga node");
3073
3095
  }
3074
- if (!lib.nativeRenderableSetMeasureTarget(nativeRenderable, NativeMeasureTargetKind.TextBufferView, this.textBufferView.ptr)) {
3096
+ if (!lib.nativeRenderableSetMeasureTarget(nativeRenderable, NativeMeasureTargetKind2.TextBufferView, this.textBufferView.ptr)) {
3075
3097
  lib.destroyNativeRenderable(nativeRenderable);
3076
3098
  throw new Error("Failed to attach text buffer native measure target");
3077
3099
  }
@@ -3085,7 +3107,7 @@ class TextBufferRenderable extends Renderable {
3085
3107
  return localX >= 0 && localX < this.width && localY >= 0 && localY < this.height;
3086
3108
  }
3087
3109
  onSelectionChanged(selection) {
3088
- const localSelection = convertGlobalToLocalSelection(selection, this.x, this.y);
3110
+ const localSelection = convertGlobalToLocalSelection2(selection, this.x, this.y);
3089
3111
  this.lastLocalSelection = localSelection;
3090
3112
  let changed;
3091
3113
  if (!localSelection?.isActive) {
@@ -3131,7 +3153,7 @@ class TextBufferRenderable extends Renderable {
3131
3153
  if (this.isDestroyed)
3132
3154
  return;
3133
3155
  if (this.nativeRenderable) {
3134
- resolveRenderLib().destroyNativeRenderable(this.nativeRenderable);
3156
+ resolveRenderLib2().destroyNativeRenderable(this.nativeRenderable);
3135
3157
  this.nativeRenderable = null;
3136
3158
  }
3137
3159
  this.textBuffer.setSyntaxStyle(null);
@@ -3146,7 +3168,7 @@ class TextBufferRenderable extends Renderable {
3146
3168
  }
3147
3169
 
3148
3170
  // src/renderables/Code.ts
3149
- class CodeRenderable extends TextBufferRenderable {
3171
+ class CodeRenderable2 extends TextBufferRenderable2 {
3150
3172
  _content;
3151
3173
  _filetype;
3152
3174
  _syntaxStyle;
@@ -3181,7 +3203,7 @@ class CodeRenderable extends TextBufferRenderable {
3181
3203
  this._content = options.content ?? this._contentDefaultOptions.content;
3182
3204
  this._filetype = options.filetype;
3183
3205
  this._syntaxStyle = options.syntaxStyle;
3184
- this._treeSitterClient = options.treeSitterClient ?? getTreeSitterClient();
3206
+ this._treeSitterClient = options.treeSitterClient ?? getTreeSitterClient2();
3185
3207
  this._conceal = options.conceal ?? this._contentDefaultOptions.conceal;
3186
3208
  this._drawUnstyledText = options.drawUnstyledText ?? this._contentDefaultOptions.drawUnstyledText;
3187
3209
  this._streaming = options.streaming ?? this._contentDefaultOptions.streaming;
@@ -3215,7 +3237,7 @@ class CodeRenderable extends TextBufferRenderable {
3215
3237
  this.requestRender();
3216
3238
  return;
3217
3239
  }
3218
- if (this._initialStyledText && this._drawUnstyledText) {
3240
+ if (value && this._initialStyledText && this._drawUnstyledText) {
3219
3241
  this.textBuffer.setStyledText(this._initialStyledText);
3220
3242
  } else {
3221
3243
  this.textBuffer.setText(value);
@@ -3224,6 +3246,14 @@ class CodeRenderable extends TextBufferRenderable {
3224
3246
  this.updateTextInfo();
3225
3247
  }
3226
3248
  }
3249
+ updateStreamingPreview(content, initialStyledText) {
3250
+ this._content = content;
3251
+ this._initialStyledText = initialStyledText;
3252
+ this.invalidateHighlights();
3253
+ this.textBuffer.setStyledText(initialStyledText);
3254
+ this.setRenderedLineSources(undefined);
3255
+ this.updateTextInfo();
3256
+ }
3227
3257
  get lineInfo() {
3228
3258
  if (!this._renderedLineSources)
3229
3259
  return super.lineInfo;
@@ -3237,6 +3267,14 @@ class CodeRenderable extends TextBufferRenderable {
3237
3267
  };
3238
3268
  return this._mappedLineInfo;
3239
3269
  }
3270
+ getLineSources(startLine, lineCount) {
3271
+ if (this.needsLineInfoFallback(CodeRenderable2.prototype)) {
3272
+ return this.lineInfo.lineSources.slice(startLine, startLine + lineCount);
3273
+ }
3274
+ const sources = this.textBufferView.getLineSources(startLine, lineCount);
3275
+ const renderedLineSources = this._renderedLineSources;
3276
+ return renderedLineSources ? sources.map((line) => renderedLineSources[line] ?? line) : sources;
3277
+ }
3240
3278
  get wrapMode() {
3241
3279
  return super.wrapMode;
3242
3280
  }
@@ -3295,6 +3333,10 @@ class CodeRenderable extends TextBufferRenderable {
3295
3333
  }
3296
3334
  set initialStyledText(value) {
3297
3335
  if (this._initialStyledText !== value) {
3336
+ if (value && this._streaming && this._drawUnstyledText && this._isHighlighting) {
3337
+ this.updateStreamingPreview(this._content, value);
3338
+ return;
3339
+ }
3298
3340
  this._initialStyledText = value;
3299
3341
  this.invalidateHighlights();
3300
3342
  }
@@ -3422,15 +3464,18 @@ class CodeRenderable extends TextBufferRenderable {
3422
3464
  }
3423
3465
  }
3424
3466
  if (highlights.length > 0 || this._onChunks || this._baseHighlight) {
3467
+ const sourceRanges = this._onChunks ? [] : undefined;
3425
3468
  const context = {
3426
3469
  content,
3427
3470
  filetype,
3428
3471
  syntaxStyle: this._syntaxStyle,
3429
- highlights
3472
+ highlights,
3473
+ sourceRanges
3430
3474
  };
3431
- let chunks = treeSitterToTextChunks(content, highlights, this._syntaxStyle, {
3475
+ let chunks = treeSitterToTextChunks2(content, highlights, this._syntaxStyle, {
3432
3476
  enabled: this._conceal,
3433
- baseHighlight: this._baseHighlight
3477
+ baseHighlight: this._baseHighlight,
3478
+ ranges: sourceRanges
3434
3479
  });
3435
3480
  const renderedLineSources = this._onChunks ? undefined : this.getConcealLinesSourceMap(content, highlights);
3436
3481
  chunks = await this.transformChunks(chunks, context);
@@ -3440,7 +3485,7 @@ class CodeRenderable extends TextBufferRenderable {
3440
3485
  }
3441
3486
  if (this.isDestroyed)
3442
3487
  return;
3443
- const styledText = new StyledText(chunks);
3488
+ const styledText = new StyledText2(chunks);
3444
3489
  this.textBuffer.setStyledText(styledText);
3445
3490
  this.setRenderedLineSources(renderedLineSources);
3446
3491
  } else {
@@ -3529,7 +3574,7 @@ class CodeRenderable extends TextBufferRenderable {
3529
3574
  getConcealLinesSourceMap(content, highlights) {
3530
3575
  if (!this._conceal || content.length === 0)
3531
3576
  return;
3532
- const concealLineRanges = CodeRenderable.getMergedConcealLineRanges(highlights);
3577
+ const concealLineRanges = CodeRenderable2.getMergedConcealLineRanges(highlights);
3533
3578
  if (concealLineRanges.length === 0)
3534
3579
  return;
3535
3580
  const lineSources = [];
@@ -3571,7 +3616,7 @@ class CodeRenderable extends TextBufferRenderable {
3571
3616
  break;
3572
3617
  lineStart = newlineOffset + 1;
3573
3618
  }
3574
- if (lineSources.length === 0 || CodeRenderable.isIdentityLineSources(lineSources))
3619
+ if (lineSources.length === 0 || CodeRenderable2.isIdentityLineSources(lineSources))
3575
3620
  return;
3576
3621
  return lineSources;
3577
3622
  }
@@ -3633,12 +3678,12 @@ class CodeRenderable extends TextBufferRenderable {
3633
3678
 
3634
3679
  // src/renderables/TextNode.ts
3635
3680
  var BrandedTextNodeRenderable = Symbol.for("@opentui/core/TextNodeRenderable");
3636
- function isTextNodeRenderable(obj) {
3681
+ function isTextNodeRenderable2(obj) {
3637
3682
  return !!obj?.[BrandedTextNodeRenderable];
3638
3683
  }
3639
3684
  function styledTextToTextNodes(styledText) {
3640
3685
  return styledText.chunks.map((chunk) => {
3641
- const node = new TextNodeRenderable({
3686
+ const node = new TextNodeRenderable2({
3642
3687
  fg: chunk.fg,
3643
3688
  bg: chunk.bg,
3644
3689
  attributes: chunk.attributes,
@@ -3649,7 +3694,7 @@ function styledTextToTextNodes(styledText) {
3649
3694
  });
3650
3695
  }
3651
3696
 
3652
- class TextNodeRenderable extends BaseRenderable {
3697
+ class TextNodeRenderable2 extends BaseRenderable2 {
3653
3698
  [BrandedTextNodeRenderable] = true;
3654
3699
  _fg;
3655
3700
  _bg;
@@ -3659,8 +3704,8 @@ class TextNodeRenderable extends BaseRenderable {
3659
3704
  parent = null;
3660
3705
  constructor(options) {
3661
3706
  super(options);
3662
- this._fg = options.fg ? parseColor(options.fg) : undefined;
3663
- this._bg = options.bg ? parseColor(options.bg) : undefined;
3707
+ this._fg = options.fg ? parseColor2(options.fg) : undefined;
3708
+ this._bg = options.bg ? parseColor2(options.bg) : undefined;
3664
3709
  this._attributes = options.attributes ?? 0;
3665
3710
  this._link = options.link;
3666
3711
  }
@@ -3669,12 +3714,12 @@ class TextNodeRenderable extends BaseRenderable {
3669
3714
  }
3670
3715
  set children(children) {
3671
3716
  for (const child of this._children) {
3672
- if (isTextNodeRenderable(child) && child.parent === this) {
3717
+ if (isTextNodeRenderable2(child) && child.parent === this) {
3673
3718
  child.parent = null;
3674
3719
  }
3675
3720
  }
3676
3721
  for (const child of children) {
3677
- if (isTextNodeRenderable(child)) {
3722
+ if (isTextNodeRenderable2(child)) {
3678
3723
  if (child.parent && child.parent !== this) {
3679
3724
  child.parent.remove(child);
3680
3725
  }
@@ -3700,14 +3745,14 @@ class TextNodeRenderable extends BaseRenderable {
3700
3745
  this.requestRender();
3701
3746
  return insertIndex;
3702
3747
  }
3703
- if (isTextNodeRenderable(obj)) {
3748
+ if (isTextNodeRenderable2(obj)) {
3704
3749
  const insertIndex = this.prepareChildInsert(obj, index);
3705
3750
  this._children.splice(insertIndex, 0, obj);
3706
3751
  obj.parent = this;
3707
3752
  this.requestRender();
3708
3753
  return insertIndex;
3709
3754
  }
3710
- if (isStyledText(obj)) {
3755
+ if (isStyledText2(obj)) {
3711
3756
  const textNodes = styledTextToTextNodes(obj);
3712
3757
  if (index !== undefined) {
3713
3758
  this._children.splice(index, 0, ...textNodes);
@@ -3739,10 +3784,10 @@ class TextNodeRenderable extends BaseRenderable {
3739
3784
  }
3740
3785
  replace(obj, index) {
3741
3786
  const existing = this._children[index];
3742
- if (isTextNodeRenderable(existing) && existing.parent === this) {
3787
+ if (isTextNodeRenderable2(existing) && existing.parent === this) {
3743
3788
  existing.parent = null;
3744
3789
  }
3745
- if (isTextNodeRenderable(obj)) {
3790
+ if (isTextNodeRenderable2(obj)) {
3746
3791
  if (obj.parent && obj.parent !== this) {
3747
3792
  obj.parent.remove(obj);
3748
3793
  } else if (obj.parent === this) {
@@ -3759,7 +3804,7 @@ class TextNodeRenderable extends BaseRenderable {
3759
3804
  this.requestRender();
3760
3805
  }
3761
3806
  insertBefore(child, anchorNode) {
3762
- if (!anchorNode || !isTextNodeRenderable(anchorNode)) {
3807
+ if (!anchorNode || !isTextNodeRenderable2(anchorNode)) {
3763
3808
  throw new Error("Anchor must be a TextNodeRenderable");
3764
3809
  }
3765
3810
  const anchorIndex = this._children.indexOf(anchorNode);
@@ -3769,13 +3814,13 @@ class TextNodeRenderable extends BaseRenderable {
3769
3814
  if (child === anchorNode) {
3770
3815
  return this;
3771
3816
  }
3772
- if (isTextNodeRenderable(child)) {
3817
+ if (isTextNodeRenderable2(child)) {
3773
3818
  this.add(child, anchorIndex);
3774
3819
  return this;
3775
3820
  }
3776
3821
  if (typeof child === "string") {
3777
3822
  this._children.splice(anchorIndex, 0, child);
3778
- } else if (isStyledText(child)) {
3823
+ } else if (isStyledText2(child)) {
3779
3824
  const textNodes = styledTextToTextNodes(child);
3780
3825
  this._children.splice(anchorIndex, 0, ...textNodes);
3781
3826
  textNodes.forEach((node) => node.parent = this);
@@ -3786,7 +3831,7 @@ class TextNodeRenderable extends BaseRenderable {
3786
3831
  return this;
3787
3832
  }
3788
3833
  remove(child) {
3789
- if (!isTextNodeRenderable(child)) {
3834
+ if (!isTextNodeRenderable2(child)) {
3790
3835
  throw new Error("remove expects a TextNodeRenderable child object");
3791
3836
  }
3792
3837
  const childIndex = this._children.indexOf(child);
@@ -3802,7 +3847,7 @@ class TextNodeRenderable extends BaseRenderable {
3802
3847
  }
3803
3848
  clear() {
3804
3849
  for (const child of this._children) {
3805
- if (isTextNodeRenderable(child) && child.parent === this) {
3850
+ if (isTextNodeRenderable2(child) && child.parent === this) {
3806
3851
  child.parent = null;
3807
3852
  }
3808
3853
  }
@@ -3843,12 +3888,12 @@ class TextNodeRenderable extends BaseRenderable {
3843
3888
  return chunks;
3844
3889
  }
3845
3890
  static fromString(text, options = {}) {
3846
- const node = new TextNodeRenderable(options);
3891
+ const node = new TextNodeRenderable2(options);
3847
3892
  node.add(text);
3848
3893
  return node;
3849
3894
  }
3850
3895
  static fromNodes(nodes, options = {}) {
3851
- const node = new TextNodeRenderable(options);
3896
+ const node = new TextNodeRenderable2(options);
3852
3897
  for (const childNode of nodes) {
3853
3898
  node.add(childNode);
3854
3899
  }
@@ -3871,7 +3916,7 @@ class TextNodeRenderable extends BaseRenderable {
3871
3916
  return this._children.find((child) => typeof child !== "string" && child.id === id);
3872
3917
  }
3873
3918
  getRenderableIndex(id) {
3874
- return this._children.findIndex((child) => isTextNodeRenderable(child) && child.id === id);
3919
+ return this._children.findIndex((child) => isTextNodeRenderable2(child) && child.id === id);
3875
3920
  }
3876
3921
  get fg() {
3877
3922
  return this._fg;
@@ -3882,7 +3927,7 @@ class TextNodeRenderable extends BaseRenderable {
3882
3927
  this.requestRender();
3883
3928
  return;
3884
3929
  }
3885
- this._fg = parseColor(fg);
3930
+ this._fg = parseColor2(fg);
3886
3931
  this.requestRender();
3887
3932
  }
3888
3933
  set bg(bg) {
@@ -3891,7 +3936,7 @@ class TextNodeRenderable extends BaseRenderable {
3891
3936
  this.requestRender();
3892
3937
  return;
3893
3938
  }
3894
- this._bg = parseColor(bg);
3939
+ this._bg = parseColor2(bg);
3895
3940
  this.requestRender();
3896
3941
  }
3897
3942
  get bg() {
@@ -3916,7 +3961,7 @@ class TextNodeRenderable extends BaseRenderable {
3916
3961
  }
3917
3962
  }
3918
3963
 
3919
- class RootTextNodeRenderable extends TextNodeRenderable {
3964
+ class RootTextNodeRenderable2 extends TextNodeRenderable2 {
3920
3965
  ctx;
3921
3966
  textParent;
3922
3967
  constructor(ctx, options, textParent) {
@@ -3931,7 +3976,7 @@ class RootTextNodeRenderable extends TextNodeRenderable {
3931
3976
  }
3932
3977
 
3933
3978
  // src/renderables/Text.ts
3934
- class TextRenderable extends TextBufferRenderable {
3979
+ class TextRenderable2 extends TextBufferRenderable2 {
3935
3980
  _text;
3936
3981
  _hasManualStyledText = false;
3937
3982
  rootTextNode;
@@ -3941,10 +3986,10 @@ class TextRenderable extends TextBufferRenderable {
3941
3986
  constructor(ctx, options) {
3942
3987
  super(ctx, options);
3943
3988
  const content = options.content ?? this._contentDefaultOptions.content;
3944
- const styledText = typeof content === "string" ? stringToStyledText(content) : content;
3989
+ const styledText = typeof content === "string" ? stringToStyledText2(content) : content;
3945
3990
  this._text = styledText;
3946
3991
  this._hasManualStyledText = options.content !== undefined && content !== "";
3947
- this.rootTextNode = new RootTextNodeRenderable(ctx, {
3992
+ this.rootTextNode = new RootTextNodeRenderable2(ctx, {
3948
3993
  id: `${this.id}-root`,
3949
3994
  fg: this._defaultFg,
3950
3995
  bg: this._defaultBg,
@@ -3968,7 +4013,7 @@ class TextRenderable extends TextBufferRenderable {
3968
4013
  }
3969
4014
  set content(value) {
3970
4015
  this._hasManualStyledText = true;
3971
- const styledText = typeof value === "string" ? stringToStyledText(value) : value;
4016
+ const styledText = typeof value === "string" ? stringToStyledText2(value) : value;
3972
4017
  if (this._text !== styledText) {
3973
4018
  this._text = styledText;
3974
4019
  this.updateTextBuffer(styledText);
@@ -3983,7 +4028,7 @@ class TextRenderable extends TextBufferRenderable {
3983
4028
  attributes: this._defaultAttributes,
3984
4029
  link: undefined
3985
4030
  });
3986
- this.textBuffer.setStyledText(new StyledText(chunks));
4031
+ this.textBuffer.setStyledText(new StyledText2(chunks));
3987
4032
  this.refreshLocalSelection();
3988
4033
  this.yogaNode.markDirty();
3989
4034
  }
@@ -4003,7 +4048,7 @@ class TextRenderable extends TextBufferRenderable {
4003
4048
  }
4004
4049
  clear() {
4005
4050
  this.rootTextNode.clear();
4006
- const emptyStyledText = stringToStyledText("");
4051
+ const emptyStyledText = stringToStyledText2("");
4007
4052
  this._text = emptyStyledText;
4008
4053
  this.updateTextBuffer(emptyStyledText);
4009
4054
  this.updateTextInfo();
@@ -4033,11 +4078,11 @@ function toNumber(value) {
4033
4078
  }
4034
4079
  var canThrowAcrossNativeCallback = typeof process !== "undefined" && typeof process.versions === "object" && process.versions !== null && typeof process.versions.bun === "string";
4035
4080
 
4036
- class NativeSpanFeed {
4081
+ class NativeSpanFeed2 {
4037
4082
  static create(options) {
4038
- const lib = resolveRenderLib();
4083
+ const lib = resolveRenderLib2();
4039
4084
  const streamPtr = lib.createNativeSpanFeed(options);
4040
- const stream = new NativeSpanFeed(streamPtr);
4085
+ const stream = new NativeSpanFeed2(streamPtr);
4041
4086
  lib.registerNativeSpanFeedStream(streamPtr, stream.eventHandler);
4042
4087
  const status = lib.attachNativeSpanFeed(streamPtr);
4043
4088
  if (status !== 0) {
@@ -4048,8 +4093,8 @@ class NativeSpanFeed {
4048
4093
  return stream;
4049
4094
  }
4050
4095
  static attach(streamPtr, _options) {
4051
- const lib = resolveRenderLib();
4052
- const stream = new NativeSpanFeed(streamPtr);
4096
+ const lib = resolveRenderLib2();
4097
+ const stream = new NativeSpanFeed2(streamPtr);
4053
4098
  lib.registerNativeSpanFeedStream(streamPtr, stream.eventHandler);
4054
4099
  const status = lib.attachNativeSpanFeed(streamPtr);
4055
4100
  if (status !== 0) {
@@ -4059,7 +4104,7 @@ class NativeSpanFeed {
4059
4104
  return stream;
4060
4105
  }
4061
4106
  streamPtr;
4062
- lib = resolveRenderLib();
4107
+ lib = resolveRenderLib2();
4063
4108
  eventHandler;
4064
4109
  chunkMap = new Map;
4065
4110
  chunkSizes = new Map;
@@ -4533,14 +4578,14 @@ function getCallerInfo() {
4533
4578
  const columnNumber = parseInt(match[4], 10) || 0;
4534
4579
  return { functionName, fullPath, fileName, lineNumber, columnNumber };
4535
4580
  }
4536
- var capture = singleton("ConsoleCapture", () => new Capture);
4537
- registerEnvVar({
4581
+ var capture2 = singleton("ConsoleCapture", () => new Capture);
4582
+ registerEnvVar2({
4538
4583
  name: "OTUI_USE_CONSOLE",
4539
4584
  description: "Whether to use the console. Will not capture console output if set to false.",
4540
4585
  type: "boolean",
4541
4586
  default: true
4542
4587
  });
4543
- registerEnvVar({
4588
+ registerEnvVar2({
4544
4589
  name: "SHOW_CONSOLE",
4545
4590
  description: "Show the console at startup if set to true.",
4546
4591
  type: "boolean",
@@ -4560,7 +4605,7 @@ class TerminalConsoleCache extends EventEmitter4 {
4560
4605
  super();
4561
4606
  }
4562
4607
  activate() {
4563
- if (!env.OTUI_USE_CONSOLE)
4608
+ if (!env2.OTUI_USE_CONSOLE)
4564
4609
  return;
4565
4610
  if (!this._originalConsole) {
4566
4611
  this._originalConsole = global.console;
@@ -4569,10 +4614,10 @@ class TerminalConsoleCache extends EventEmitter4 {
4569
4614
  this.overrideConsoleMethods();
4570
4615
  }
4571
4616
  setupConsoleCapture() {
4572
- if (!env.OTUI_USE_CONSOLE)
4617
+ if (!env2.OTUI_USE_CONSOLE)
4573
4618
  return;
4574
- const mockStdout = new CapturedWritableStream("stdout", capture);
4575
- const mockStderr = new CapturedWritableStream("stderr", capture);
4619
+ const mockStdout = new CapturedWritableStream("stdout", capture2);
4620
+ const mockStderr = new CapturedWritableStream("stderr", capture2);
4576
4621
  global.console = new Console({
4577
4622
  stdout: mockStdout,
4578
4623
  stderr: mockStderr,
@@ -4644,19 +4689,19 @@ class TerminalConsoleCache extends EventEmitter4 {
4644
4689
  }
4645
4690
  }
4646
4691
  var terminalConsoleCache = singleton("TerminalConsoleCache", () => {
4647
- const terminalConsoleCache2 = new TerminalConsoleCache;
4692
+ const terminalConsoleCache = new TerminalConsoleCache;
4648
4693
  process.on("exit", () => {
4649
- terminalConsoleCache2.destroy();
4694
+ terminalConsoleCache.destroy();
4650
4695
  });
4651
- return terminalConsoleCache2;
4696
+ return terminalConsoleCache;
4652
4697
  });
4653
- var ConsolePosition;
4654
- ((ConsolePosition2) => {
4655
- ConsolePosition2["TOP"] = "top";
4656
- ConsolePosition2["BOTTOM"] = "bottom";
4657
- ConsolePosition2["LEFT"] = "left";
4658
- ConsolePosition2["RIGHT"] = "right";
4659
- })(ConsolePosition ||= {});
4698
+ var ConsolePosition2;
4699
+ ((ConsolePosition) => {
4700
+ ConsolePosition["TOP"] = "top";
4701
+ ConsolePosition["BOTTOM"] = "bottom";
4702
+ ConsolePosition["LEFT"] = "left";
4703
+ ConsolePosition["RIGHT"] = "right";
4704
+ })(ConsolePosition2 ||= {});
4660
4705
  var defaultConsoleKeybindings = [
4661
4706
  { name: "up", action: "scroll-up" },
4662
4707
  { name: "down", action: "scroll-down" },
@@ -4679,10 +4724,10 @@ var DEFAULT_CONSOLE_OPTIONS = {
4679
4724
  colorError: "#FF0000",
4680
4725
  colorDebug: "#808080",
4681
4726
  colorDefault: "#FFFFFF",
4682
- backgroundColor: RGBA.fromValues(0.1, 0.1, 0.1, 0.7),
4727
+ backgroundColor: RGBA2.fromValues(0.1, 0.1, 0.1, 0.7),
4683
4728
  startInDebugMode: false,
4684
4729
  title: "Console",
4685
- titleBarColor: RGBA.fromValues(0.05, 0.05, 0.05, 0.7),
4730
+ titleBarColor: RGBA2.fromValues(0.05, 0.05, 0.05, 0.7),
4686
4731
  titleBarTextColor: "#FFFFFF",
4687
4732
  cursorColor: "#00A0FF",
4688
4733
  maxStoredLogs: 2000,
@@ -4690,12 +4735,12 @@ var DEFAULT_CONSOLE_OPTIONS = {
4690
4735
  onCopySelection: undefined,
4691
4736
  keyBindings: undefined,
4692
4737
  keyAliasMap: undefined,
4693
- selectionColor: RGBA.fromValues(0.3, 0.5, 0.8, 0.5),
4738
+ selectionColor: RGBA2.fromValues(0.3, 0.5, 0.8, 0.5),
4694
4739
  copyButtonColor: "#00A0FF"
4695
4740
  };
4696
4741
  var INDENT_WIDTH = 2;
4697
4742
 
4698
- class TerminalConsole extends EventEmitter4 {
4743
+ class TerminalConsole2 extends EventEmitter4 {
4699
4744
  isVisible = false;
4700
4745
  isFocused = false;
4701
4746
  renderer;
@@ -4764,23 +4809,23 @@ class TerminalConsole extends EventEmitter4 {
4764
4809
  constructor(renderer, options = {}) {
4765
4810
  super();
4766
4811
  this.renderer = renderer;
4767
- this.clock = options.clock ?? new SystemClock;
4812
+ this.clock = options.clock ?? new SystemClock2;
4768
4813
  this.options = { ...DEFAULT_CONSOLE_OPTIONS, ...options };
4769
4814
  this.keyHandler = this.handleKeyPress.bind(this);
4770
4815
  this._debugModeEnabled = this.options.startInDebugMode;
4771
4816
  terminalConsoleCache.setCollectCallerInfo(this._debugModeEnabled);
4772
- this._rgbaInfo = parseColor(this.options.colorInfo);
4773
- this._rgbaWarn = parseColor(this.options.colorWarn);
4774
- this._rgbaError = parseColor(this.options.colorError);
4775
- this._rgbaDebug = parseColor(this.options.colorDebug);
4776
- this._rgbaDefault = parseColor(this.options.colorDefault);
4777
- this.backgroundColor = parseColor(this.options.backgroundColor);
4778
- this._rgbaTitleBar = parseColor(this.options.titleBarColor);
4779
- this._rgbaTitleBarText = parseColor(this.options.titleBarTextColor || this.options.colorDefault);
4817
+ this._rgbaInfo = parseColor2(this.options.colorInfo);
4818
+ this._rgbaWarn = parseColor2(this.options.colorWarn);
4819
+ this._rgbaError = parseColor2(this.options.colorError);
4820
+ this._rgbaDebug = parseColor2(this.options.colorDebug);
4821
+ this._rgbaDefault = parseColor2(this.options.colorDefault);
4822
+ this.backgroundColor = parseColor2(this.options.backgroundColor);
4823
+ this._rgbaTitleBar = parseColor2(this.options.titleBarColor);
4824
+ this._rgbaTitleBarText = parseColor2(this.options.titleBarTextColor || this.options.colorDefault);
4780
4825
  this._title = this.options.title;
4781
- this._rgbaCursor = parseColor(this.options.cursorColor);
4782
- this._rgbaSelection = parseColor(this.options.selectionColor);
4783
- this._rgbaCopyButton = parseColor(this.options.copyButtonColor);
4826
+ this._rgbaCursor = parseColor2(this.options.cursorColor);
4827
+ this._rgbaSelection = parseColor2(this.options.selectionColor);
4828
+ this._rgbaCopyButton = parseColor2(this.options.copyButtonColor);
4784
4829
  this._keyAliasMap = mergeKeyAliases(defaultKeyAliases, options.keyAliasMap || {});
4785
4830
  this._keyBindings = options.keyBindings || [];
4786
4831
  this._mergedKeyBindings = mergeKeyBindings(defaultConsoleKeybindings, this._keyBindings);
@@ -4792,7 +4837,7 @@ class TerminalConsole extends EventEmitter4 {
4792
4837
  this._handleNewLog(logEntry);
4793
4838
  };
4794
4839
  terminalConsoleCache.on("entry", this._entryListener);
4795
- if (env.SHOW_CONSOLE) {
4840
+ if (env2.SHOW_CONSOLE) {
4796
4841
  this.show();
4797
4842
  }
4798
4843
  }
@@ -5051,7 +5096,7 @@ class TerminalConsole extends EventEmitter4 {
5051
5096
  this._processCachedLogs();
5052
5097
  terminalConsoleCache.setCachingEnabled(false);
5053
5098
  if (!this.frameBuffer) {
5054
- this.frameBuffer = OptimizedBuffer.create(this.consoleWidth, this.consoleHeight, this.renderer.widthMethod, {
5099
+ this.frameBuffer = OptimizedBuffer2.create(this.consoleWidth, this.consoleHeight, this.renderer.widthMethod, {
5055
5100
  respectAlpha: this.backgroundColor.a < 1,
5056
5101
  id: "console framebuffer"
5057
5102
  });
@@ -5098,7 +5143,7 @@ class TerminalConsole extends EventEmitter4 {
5098
5143
  const copyButtonX = this.consoleWidth - copyLabel.length - 1;
5099
5144
  if (copyButtonX >= 0) {
5100
5145
  const copyButtonEnabled = this.hasSelection();
5101
- const disabledColor = RGBA.fromInts(100, 100, 100, 255);
5146
+ const disabledColor = RGBA2.fromInts(100, 100, 100, 255);
5102
5147
  const copyColor = copyButtonEnabled ? this._rgbaCopyButton : disabledColor;
5103
5148
  this.frameBuffer.drawText(copyLabel, copyButtonX, 0, copyColor, this._rgbaTitleBar);
5104
5149
  this._copyButtonBounds = { x: copyButtonX, y: 0, width: copyLabel.length, height: 1 };
@@ -5487,10 +5532,10 @@ class TerminalConsole extends EventEmitter4 {
5487
5532
 
5488
5533
  // src/renderables/EditBufferRenderable.ts
5489
5534
  var BrandedEditBufferRenderable = Symbol.for("@opentui/core/EditBufferRenderable");
5490
- var EditBufferRenderableEvents;
5491
- ((EditBufferRenderableEvents2) => {
5492
- EditBufferRenderableEvents2["TRAITS_CHANGED"] = "traits-changed";
5493
- })(EditBufferRenderableEvents ||= {});
5535
+ var EditBufferRenderableEvents2;
5536
+ ((EditBufferRenderableEvents) => {
5537
+ EditBufferRenderableEvents["TRAITS_CHANGED"] = "traits-changed";
5538
+ })(EditBufferRenderableEvents2 ||= {});
5494
5539
  function sameCapture(a, b) {
5495
5540
  if (a === b)
5496
5541
  return true;
@@ -5503,11 +5548,11 @@ function sameCapture(a, b) {
5503
5548
  function sameTraits(a, b) {
5504
5549
  return a.suspend === b.suspend && a.status === b.status && sameCapture(a.capture, b.capture);
5505
5550
  }
5506
- function isEditBufferRenderable(obj) {
5551
+ function isEditBufferRenderable2(obj) {
5507
5552
  return !!(obj && typeof obj === "object" && (BrandedEditBufferRenderable in obj));
5508
5553
  }
5509
5554
 
5510
- class EditBufferRenderable extends Renderable {
5555
+ class EditBufferRenderable2 extends Renderable2 {
5511
5556
  [BrandedEditBufferRenderable] = true;
5512
5557
  _focusable = true;
5513
5558
  selectable = true;
@@ -5535,7 +5580,7 @@ class EditBufferRenderable extends Renderable {
5535
5580
  editorView;
5536
5581
  nativeRenderable = null;
5537
5582
  _defaultOptions = {
5538
- textColor: RGBA.fromValues(1, 1, 1, 1),
5583
+ textColor: RGBA2.fromValues(1, 1, 1, 1),
5539
5584
  backgroundColor: "transparent",
5540
5585
  selectionBg: undefined,
5541
5586
  selectionFg: undefined,
@@ -5545,7 +5590,7 @@ class EditBufferRenderable extends Renderable {
5545
5590
  scrollMargin: 0.2,
5546
5591
  scrollSpeed: 16,
5547
5592
  showCursor: true,
5548
- cursorColor: RGBA.fromValues(1, 1, 1, 1),
5593
+ cursorColor: RGBA2.fromValues(1, 1, 1, 1),
5549
5594
  cursorStyle: {
5550
5595
  style: "block",
5551
5596
  blinking: true
@@ -5555,22 +5600,22 @@ class EditBufferRenderable extends Renderable {
5555
5600
  };
5556
5601
  constructor(ctx, options) {
5557
5602
  super(ctx, options);
5558
- this._textColor = parseColor(options.textColor ?? this._defaultOptions.textColor);
5559
- this._backgroundColor = parseColor(options.backgroundColor ?? this._defaultOptions.backgroundColor);
5603
+ this._textColor = parseColor2(options.textColor ?? this._defaultOptions.textColor);
5604
+ this._backgroundColor = parseColor2(options.backgroundColor ?? this._defaultOptions.backgroundColor);
5560
5605
  this._defaultAttributes = options.attributes ?? this._defaultOptions.attributes;
5561
- this._selectionBg = options.selectionBg ? parseColor(options.selectionBg) : this._defaultOptions.selectionBg;
5562
- this._selectionFg = options.selectionFg ? parseColor(options.selectionFg) : this._defaultOptions.selectionFg;
5606
+ this._selectionBg = options.selectionBg ? parseColor2(options.selectionBg) : this._defaultOptions.selectionBg;
5607
+ this._selectionFg = options.selectionFg ? parseColor2(options.selectionFg) : this._defaultOptions.selectionFg;
5563
5608
  this.selectable = options.selectable ?? this._defaultOptions.selectable;
5564
5609
  this._wrapMode = options.wrapMode ?? this._defaultOptions.wrapMode;
5565
5610
  this._scrollMargin = options.scrollMargin ?? this._defaultOptions.scrollMargin;
5566
5611
  this._scrollSpeed = options.scrollSpeed ?? this._defaultOptions.scrollSpeed;
5567
5612
  this._showCursor = options.showCursor ?? this._defaultOptions.showCursor;
5568
- this._cursorColor = parseColor(options.cursorColor ?? this._defaultOptions.cursorColor);
5613
+ this._cursorColor = parseColor2(options.cursorColor ?? this._defaultOptions.cursorColor);
5569
5614
  this._cursorStyle = options.cursorStyle ?? this._defaultOptions.cursorStyle;
5570
5615
  this._tabIndicator = options.tabIndicator ?? this._defaultOptions.tabIndicator;
5571
- this._tabIndicatorColor = options.tabIndicatorColor ? parseColor(options.tabIndicatorColor) : this._defaultOptions.tabIndicatorColor;
5572
- this.editBuffer = EditBuffer.create(this._ctx.widthMethod);
5573
- this.editorView = EditorView.create(this.editBuffer, this.width || 80, this.height || 24);
5616
+ this._tabIndicatorColor = options.tabIndicatorColor ? parseColor2(options.tabIndicatorColor) : this._defaultOptions.tabIndicatorColor;
5617
+ this.editBuffer = EditBuffer2.create(this._ctx.widthMethod);
5618
+ this.editorView = EditorView2.create(this.editBuffer, this.width || 80, this.height || 24);
5574
5619
  this.editorView.setWrapMode(this._wrapMode);
5575
5620
  this.editorView.setScrollMargin(this._scrollMargin);
5576
5621
  if (options.selectionOccupancy === "boundary") {
@@ -5662,7 +5707,7 @@ class EditBufferRenderable extends Renderable {
5662
5707
  return this._textColor;
5663
5708
  }
5664
5709
  set textColor(value) {
5665
- const newColor = parseColor(value ?? this._defaultOptions.textColor);
5710
+ const newColor = parseColor2(value ?? this._defaultOptions.textColor);
5666
5711
  if (this._textColor !== newColor) {
5667
5712
  this._textColor = newColor;
5668
5713
  this.editBuffer.setDefaultFg(newColor);
@@ -5683,7 +5728,7 @@ class EditBufferRenderable extends Renderable {
5683
5728
  this.emit("traits-changed" /* TRAITS_CHANGED */, value, prev);
5684
5729
  }
5685
5730
  set selectionBg(value) {
5686
- const newColor = value ? parseColor(value) : this._defaultOptions.selectionBg;
5731
+ const newColor = value ? parseColor2(value) : this._defaultOptions.selectionBg;
5687
5732
  if (this._selectionBg !== newColor) {
5688
5733
  this._selectionBg = newColor;
5689
5734
  this.refreshSelectionStyle();
@@ -5694,7 +5739,7 @@ class EditBufferRenderable extends Renderable {
5694
5739
  return this._selectionFg;
5695
5740
  }
5696
5741
  set selectionFg(value) {
5697
- const newColor = value ? parseColor(value) : this._defaultOptions.selectionFg;
5742
+ const newColor = value ? parseColor2(value) : this._defaultOptions.selectionFg;
5698
5743
  if (this._selectionFg !== newColor) {
5699
5744
  this._selectionFg = newColor;
5700
5745
  this.refreshSelectionStyle();
@@ -5705,7 +5750,7 @@ class EditBufferRenderable extends Renderable {
5705
5750
  return this._backgroundColor;
5706
5751
  }
5707
5752
  set backgroundColor(value) {
5708
- const newColor = parseColor(value ?? this._defaultOptions.backgroundColor);
5753
+ const newColor = parseColor2(value ?? this._defaultOptions.backgroundColor);
5709
5754
  if (this._backgroundColor !== newColor) {
5710
5755
  this._backgroundColor = newColor;
5711
5756
  this.editBuffer.setDefaultBg(newColor);
@@ -5749,7 +5794,7 @@ class EditBufferRenderable extends Renderable {
5749
5794
  return this._cursorColor;
5750
5795
  }
5751
5796
  set cursorColor(value) {
5752
- const newColor = parseColor(value);
5797
+ const newColor = parseColor2(value);
5753
5798
  if (this._cursorColor !== newColor) {
5754
5799
  this._cursorColor = newColor;
5755
5800
  if (this._focused) {
@@ -5795,7 +5840,7 @@ class EditBufferRenderable extends Renderable {
5795
5840
  return this._tabIndicatorColor;
5796
5841
  }
5797
5842
  set tabIndicatorColor(value) {
5798
- const newColor = value ? parseColor(value) : undefined;
5843
+ const newColor = value ? parseColor2(value) : undefined;
5799
5844
  if (this._tabIndicatorColor !== newColor) {
5800
5845
  this._tabIndicatorColor = newColor;
5801
5846
  if (newColor !== undefined) {
@@ -5867,7 +5912,7 @@ class EditBufferRenderable extends Renderable {
5867
5912
  return localX >= 0 && localX < this.width && localY >= 0 && localY < this.height;
5868
5913
  }
5869
5914
  onSelectionChanged(selection) {
5870
- const localSelection = convertGlobalToLocalSelection(selection, this.x, this.y);
5915
+ const localSelection = convertGlobalToLocalSelection2(selection, this.x, this.y);
5871
5916
  this.lastLocalSelection = localSelection;
5872
5917
  const updateCursor = true;
5873
5918
  const followCursor = this._keyboardSelectionActive;
@@ -6239,13 +6284,13 @@ class EditBufferRenderable extends Renderable {
6239
6284
  return true;
6240
6285
  }
6241
6286
  setupNativeRenderable() {
6242
- const lib = resolveRenderLib();
6287
+ const lib = resolveRenderLib2();
6243
6288
  const nativeRenderable = lib.createNativeRenderable();
6244
6289
  if (!lib.nativeRenderableAttachYogaNode(nativeRenderable, this.yogaNode.ptr)) {
6245
6290
  lib.destroyNativeRenderable(nativeRenderable);
6246
6291
  throw new Error("Failed to attach native renderable Yoga node");
6247
6292
  }
6248
- if (!lib.nativeRenderableSetMeasureTarget(nativeRenderable, NativeMeasureTargetKind.EditorView, this.editorView.ptr)) {
6293
+ if (!lib.nativeRenderableSetMeasureTarget(nativeRenderable, NativeMeasureTargetKind2.EditorView, this.editorView.ptr)) {
6249
6294
  lib.destroyNativeRenderable(nativeRenderable);
6250
6295
  throw new Error("Failed to attach editor native measure target");
6251
6296
  }
@@ -6301,7 +6346,7 @@ class EditBufferRenderable extends Renderable {
6301
6346
  this.blur();
6302
6347
  }
6303
6348
  if (this.nativeRenderable) {
6304
- resolveRenderLib().destroyNativeRenderable(this.nativeRenderable);
6349
+ resolveRenderLib2().destroyNativeRenderable(this.nativeRenderable);
6305
6350
  this.nativeRenderable = null;
6306
6351
  }
6307
6352
  this.editorView.destroy();
@@ -6611,7 +6656,7 @@ function oscThemeColorToHex(r, g, b, hex6) {
6611
6656
  return "#000000";
6612
6657
  }
6613
6658
  function inferThemeModeFromBackgroundColor(color) {
6614
- const [r, g, b] = parseColor(color).toInts();
6659
+ const [r, g, b] = parseColor2(color).toInts();
6615
6660
  const brightness = (r * 299 + g * 587 + b * 114) / 1000;
6616
6661
  return brightness > 128 ? "light" : "dark";
6617
6662
  }
@@ -6743,43 +6788,43 @@ class RendererThemeMode {
6743
6788
  }
6744
6789
 
6745
6790
  // src/renderer.ts
6746
- registerEnvVar({
6791
+ registerEnvVar2({
6747
6792
  name: "OTUI_DUMP_CAPTURES",
6748
6793
  description: "Dump captured stdout and console caches when the renderer exit handler runs.",
6749
6794
  type: "boolean",
6750
6795
  default: false
6751
6796
  });
6752
- registerEnvVar({
6797
+ registerEnvVar2({
6753
6798
  name: "OTUI_NO_NATIVE_RENDER",
6754
6799
  description: "Skip the Zig/native frame renderer. Useful for debugging the render loop; split-footer stdout flushing may still write ANSI.",
6755
6800
  type: "boolean",
6756
6801
  default: false
6757
6802
  });
6758
- registerEnvVar({
6803
+ registerEnvVar2({
6759
6804
  name: "OTUI_USE_ALTERNATE_SCREEN",
6760
6805
  description: "When explicitly set, force screen mode selection: true=alternate-screen, false=main-screen.",
6761
6806
  type: "boolean",
6762
6807
  default: true
6763
6808
  });
6764
- registerEnvVar({
6809
+ registerEnvVar2({
6765
6810
  name: "OTUI_OVERRIDE_STDOUT",
6766
6811
  description: "When explicitly set, force stdout routing: false=passthrough, true=capture in split-footer mode.",
6767
6812
  type: "boolean",
6768
6813
  default: true
6769
6814
  });
6770
- registerEnvVar({
6815
+ registerEnvVar2({
6771
6816
  name: "OTUI_DEBUG",
6772
6817
  description: "Enable debug mode to capture all raw input for debugging purposes.",
6773
6818
  type: "boolean",
6774
6819
  default: false
6775
6820
  });
6776
- registerEnvVar({
6821
+ registerEnvVar2({
6777
6822
  name: "OTUI_STDIN_LOG",
6778
6823
  description: "Write the raw stdin byte stream to this file for debugging.",
6779
6824
  type: "string",
6780
6825
  default: ""
6781
6826
  });
6782
- registerEnvVar({
6827
+ registerEnvVar2({
6783
6828
  name: "OTUI_SHOW_STATS",
6784
6829
  description: "Show the debug overlay at startup.",
6785
6830
  type: "boolean",
@@ -6788,7 +6833,7 @@ registerEnvVar({
6788
6833
  var KITTY_IMAGE_TRANSPORTS = ["raw", "zlib", "file"];
6789
6834
  var DEFAULT_FOOTER_HEIGHT = 12;
6790
6835
  var MAX_SCROLLBACK_SURFACE_HEIGHT_PASSES = 4;
6791
- var TRANSPARENT_RGBA = RGBA.fromValues(0, 0, 0, 0);
6836
+ var TRANSPARENT_RGBA = RGBA2.fromValues(0, 0, 0, 0);
6792
6837
  var scrollbackSurfaceCounter = 0;
6793
6838
  function normalizeFooterHeight(footerHeight) {
6794
6839
  if (footerHeight === undefined) {
@@ -6806,12 +6851,12 @@ function normalizeFooterHeight(footerHeight) {
6806
6851
  function resolveModes(config) {
6807
6852
  let screenMode = config.screenMode ?? "alternate-screen";
6808
6853
  if (process.env.OTUI_USE_ALTERNATE_SCREEN !== undefined) {
6809
- screenMode = env.OTUI_USE_ALTERNATE_SCREEN ? "alternate-screen" : "main-screen";
6854
+ screenMode = env2.OTUI_USE_ALTERNATE_SCREEN ? "alternate-screen" : "main-screen";
6810
6855
  }
6811
6856
  const footerHeight = screenMode === "split-footer" ? normalizeFooterHeight(config.footerHeight) : DEFAULT_FOOTER_HEIGHT;
6812
6857
  let externalOutputMode = config.externalOutputMode ?? (screenMode === "split-footer" ? "capture-stdout" : "passthrough");
6813
6858
  if (process.env.OTUI_OVERRIDE_STDOUT !== undefined) {
6814
- externalOutputMode = env.OTUI_OVERRIDE_STDOUT && screenMode === "split-footer" ? "capture-stdout" : "passthrough";
6859
+ externalOutputMode = env2.OTUI_OVERRIDE_STDOUT && screenMode === "split-footer" ? "capture-stdout" : "passthrough";
6815
6860
  }
6816
6861
  if (externalOutputMode === "capture-stdout" && screenMode !== "split-footer") {
6817
6862
  throw new Error('externalOutputMode "capture-stdout" requires screenMode "split-footer"');
@@ -6841,9 +6886,9 @@ class ExternalOutputQueue {
6841
6886
  }
6842
6887
  const clampedLimit = Number.isFinite(limit) ? Math.max(1, Math.trunc(limit)) : this.commits.length;
6843
6888
  if (clampedLimit >= this.commits.length) {
6844
- const output2 = this.commits;
6889
+ const output = this.commits;
6845
6890
  this.commits = [];
6846
- return output2;
6891
+ return output;
6847
6892
  }
6848
6893
  const output = this.commits.slice(0, clampedLimit);
6849
6894
  this.commits = this.commits.slice(clampedLimit);
@@ -6884,8 +6929,8 @@ class ScrollbackSnapshotRenderContext extends EventEmitter5 {
6884
6929
  this.resolution = resolution;
6885
6930
  this.capabilities = capabilities;
6886
6931
  this.widthMethod = widthMethod;
6887
- this.keyInput = new KeyHandler;
6888
- this._internalKeyInput = new InternalKeyHandler;
6932
+ this.keyInput = new KeyHandler2;
6933
+ this._internalKeyInput = new InternalKeyHandler2;
6889
6934
  }
6890
6935
  addToHitGrid(_x, _y, _width, _height, _id) {}
6891
6936
  pushHitGridScissorRect(_x, _y, _width, _height) {}
@@ -6904,7 +6949,7 @@ class ScrollbackSnapshotRenderContext extends EventEmitter5 {
6904
6949
  get currentFocusedEditor() {
6905
6950
  if (!this.currentFocusedRenderable)
6906
6951
  return null;
6907
- if (!isEditBufferRenderable(this.currentFocusedRenderable))
6952
+ if (!isEditBufferRenderable2(this.currentFocusedRenderable))
6908
6953
  return null;
6909
6954
  return this.currentFocusedRenderable;
6910
6955
  }
@@ -6971,7 +7016,7 @@ var KITTY_FLAG_ALL_KEYS_AS_ESCAPES = 8;
6971
7016
  var KITTY_FLAG_REPORT_TEXT = 16;
6972
7017
  var DEFAULT_STDIN_PARSER_MAX_BUFFER_BYTES = 64 * 1024 * 1024;
6973
7018
  var NATIVE_PALETTE_QUERY_SIZE = 16;
6974
- function buildKittyKeyboardFlags(config) {
7019
+ function buildKittyKeyboardFlags2(config) {
6975
7020
  if (!config) {
6976
7021
  return 0;
6977
7022
  }
@@ -6994,7 +7039,7 @@ function buildKittyKeyboardFlags(config) {
6994
7039
  return flags;
6995
7040
  }
6996
7041
 
6997
- class MouseEvent {
7042
+ class MouseEvent2 {
6998
7043
  type;
6999
7044
  button;
7000
7045
  x;
@@ -7031,19 +7076,19 @@ class MouseEvent {
7031
7076
  this._defaultPrevented = true;
7032
7077
  }
7033
7078
  }
7034
- var MouseButton;
7035
- ((MouseButton2) => {
7036
- MouseButton2[MouseButton2["LEFT"] = 0] = "LEFT";
7037
- MouseButton2[MouseButton2["MIDDLE"] = 1] = "MIDDLE";
7038
- MouseButton2[MouseButton2["RIGHT"] = 2] = "RIGHT";
7039
- MouseButton2[MouseButton2["WHEEL_UP"] = 4] = "WHEEL_UP";
7040
- MouseButton2[MouseButton2["WHEEL_DOWN"] = 5] = "WHEEL_DOWN";
7041
- })(MouseButton ||= {});
7079
+ var MouseButton2;
7080
+ ((MouseButton) => {
7081
+ MouseButton[MouseButton["LEFT"] = 0] = "LEFT";
7082
+ MouseButton[MouseButton["MIDDLE"] = 1] = "MIDDLE";
7083
+ MouseButton[MouseButton["RIGHT"] = 2] = "RIGHT";
7084
+ MouseButton[MouseButton["WHEEL_UP"] = 4] = "WHEEL_UP";
7085
+ MouseButton[MouseButton["WHEEL_DOWN"] = 5] = "WHEEL_DOWN";
7086
+ })(MouseButton2 ||= {});
7042
7087
  var rendererTracker = singleton("RendererTracker", () => ({
7043
7088
  renderers: new Set,
7044
7089
  streamOwners: new WeakMap
7045
7090
  }));
7046
- async function createCliRenderer(config = {}) {
7091
+ async function createCliRenderer2(config = {}) {
7047
7092
  if (process.argv.includes("--delay-start")) {
7048
7093
  await new Promise((resolve) => setTimeout(resolve, 5000));
7049
7094
  }
@@ -7051,7 +7096,7 @@ async function createCliRenderer(config = {}) {
7051
7096
  const stdout = config.stdout ?? process.stdout;
7052
7097
  const width = stdout.columns || config.width || 80;
7053
7098
  const height = stdout.rows || config.height || 24;
7054
- const renderer = new CliRenderer(stdin, stdout, width, height, config);
7099
+ const renderer = new CliRenderer2(stdin, stdout, width, height, config);
7055
7100
  try {
7056
7101
  await renderer.setupTerminal();
7057
7102
  return renderer;
@@ -7064,37 +7109,37 @@ async function createCliRenderer(config = {}) {
7064
7109
  throw error;
7065
7110
  }
7066
7111
  }
7067
- var CliRenderEvents;
7068
- ((CliRenderEvents2) => {
7069
- CliRenderEvents2["RESIZE"] = "resize";
7070
- CliRenderEvents2["FRAME"] = "frame";
7071
- CliRenderEvents2["RENDER_ERROR"] = "render:error";
7072
- CliRenderEvents2["HANDLER_ERROR"] = "handler:error";
7073
- CliRenderEvents2["EXTERNAL_OUTPUT"] = "external_output";
7074
- CliRenderEvents2["FOCUS"] = "focus";
7075
- CliRenderEvents2["BLUR"] = "blur";
7076
- CliRenderEvents2["FOCUSED_RENDERABLE"] = "focused_renderable";
7077
- CliRenderEvents2["FOCUSED_EDITOR"] = "focused_editor";
7078
- CliRenderEvents2["THEME_MODE"] = "theme_mode";
7079
- CliRenderEvents2["PALETTE"] = "palette";
7080
- CliRenderEvents2["CAPABILITIES"] = "capabilities";
7081
- CliRenderEvents2["SELECTION"] = "selection";
7082
- CliRenderEvents2["DEBUG_OVERLAY_TOGGLE"] = "debugOverlay:toggle";
7083
- CliRenderEvents2["DESTROY"] = "destroy";
7084
- CliRenderEvents2["MEMORY_SNAPSHOT"] = "memory:snapshot";
7085
- })(CliRenderEvents ||= {});
7086
- var RendererControlState;
7087
- ((RendererControlState2) => {
7088
- RendererControlState2["IDLE"] = "idle";
7089
- RendererControlState2["AUTO_STARTED"] = "auto_started";
7090
- RendererControlState2["EXPLICIT_STARTED"] = "explicit_started";
7091
- RendererControlState2["EXPLICIT_PAUSED"] = "explicit_paused";
7092
- RendererControlState2["EXPLICIT_SUSPENDED"] = "explicit_suspended";
7093
- RendererControlState2["EXPLICIT_STOPPED"] = "explicit_stopped";
7094
- })(RendererControlState ||= {});
7112
+ var CliRenderEvents2;
7113
+ ((CliRenderEvents) => {
7114
+ CliRenderEvents["RESIZE"] = "resize";
7115
+ CliRenderEvents["FRAME"] = "frame";
7116
+ CliRenderEvents["RENDER_ERROR"] = "render:error";
7117
+ CliRenderEvents["HANDLER_ERROR"] = "handler:error";
7118
+ CliRenderEvents["EXTERNAL_OUTPUT"] = "external_output";
7119
+ CliRenderEvents["FOCUS"] = "focus";
7120
+ CliRenderEvents["BLUR"] = "blur";
7121
+ CliRenderEvents["FOCUSED_RENDERABLE"] = "focused_renderable";
7122
+ CliRenderEvents["FOCUSED_EDITOR"] = "focused_editor";
7123
+ CliRenderEvents["THEME_MODE"] = "theme_mode";
7124
+ CliRenderEvents["PALETTE"] = "palette";
7125
+ CliRenderEvents["CAPABILITIES"] = "capabilities";
7126
+ CliRenderEvents["SELECTION"] = "selection";
7127
+ CliRenderEvents["DEBUG_OVERLAY_TOGGLE"] = "debugOverlay:toggle";
7128
+ CliRenderEvents["DESTROY"] = "destroy";
7129
+ CliRenderEvents["MEMORY_SNAPSHOT"] = "memory:snapshot";
7130
+ })(CliRenderEvents2 ||= {});
7131
+ var RendererControlState2;
7132
+ ((RendererControlState) => {
7133
+ RendererControlState["IDLE"] = "idle";
7134
+ RendererControlState["AUTO_STARTED"] = "auto_started";
7135
+ RendererControlState["EXPLICIT_STARTED"] = "explicit_started";
7136
+ RendererControlState["EXPLICIT_PAUSED"] = "explicit_paused";
7137
+ RendererControlState["EXPLICIT_SUSPENDED"] = "explicit_suspended";
7138
+ RendererControlState["EXPLICIT_STOPPED"] = "explicit_stopped";
7139
+ })(RendererControlState2 ||= {});
7095
7140
  var CLICK_REPEAT_INTERVAL_MS = 500;
7096
7141
 
7097
- class CliRenderer extends EventEmitter5 {
7142
+ class CliRenderer2 extends EventEmitter5 {
7098
7143
  static animationFrameId = 0;
7099
7144
  lib;
7100
7145
  rendererPtr;
@@ -7129,7 +7174,7 @@ class CliRenderer extends EventEmitter5 {
7129
7174
  frameTimes = [];
7130
7175
  maxStatSamples = 300;
7131
7176
  postProcessFns = [];
7132
- backgroundColor = RGBA.fromInts(0, 0, 0, 0);
7177
+ backgroundColor = RGBA2.fromInts(0, 0, 0, 0);
7133
7178
  waitingForPixelResolution = false;
7134
7179
  pixelResolutionRequeryPending = false;
7135
7180
  clock;
@@ -7156,7 +7201,7 @@ class CliRenderer extends EventEmitter5 {
7156
7201
  frameCallbackTime: 0
7157
7202
  };
7158
7203
  debugOverlay = {
7159
- enabled: env.OTUI_SHOW_STATS,
7204
+ enabled: env2.OTUI_SHOW_STATS,
7160
7205
  corner: 3 /* bottomRight */
7161
7206
  };
7162
7207
  _console;
@@ -7241,8 +7286,8 @@ class CliRenderer extends EventEmitter5 {
7241
7286
  themeModeHandler;
7242
7287
  idleResolvers = [];
7243
7288
  _debugInputs = [];
7244
- _debugModeEnabled = env.OTUI_DEBUG;
7245
- stdinLogPath = env.OTUI_STDIN_LOG;
7289
+ _debugModeEnabled = env2.OTUI_DEBUG;
7290
+ stdinLogPath = env2.OTUI_STDIN_LOG;
7246
7291
  handleError = ((error) => {
7247
7292
  console.error(error);
7248
7293
  if (this._openConsoleOnError) {
@@ -7251,7 +7296,7 @@ class CliRenderer extends EventEmitter5 {
7251
7296
  }).bind(this);
7252
7297
  dumpOutputCache(optionalMessage = "") {
7253
7298
  const cachedLogs = this.console.getCachedLogs();
7254
- const capturedConsoleOutput = capture.claimOutput();
7299
+ const capturedConsoleOutput = capture2.claimOutput();
7255
7300
  const capturedExternalOutputCommits = this.externalOutputQueue.claim();
7256
7301
  let capturedExternalOutput = "";
7257
7302
  for (const commit of capturedExternalOutputCommits) {
@@ -7285,7 +7330,7 @@ Captured external output:
7285
7330
  }
7286
7331
  exitHandler = (() => {
7287
7332
  this.destroy();
7288
- if (env.OTUI_DUMP_CAPTURES) {
7333
+ if (env2.OTUI_DUMP_CAPTURES) {
7289
7334
  sleep(100).then(() => {
7290
7335
  this.dumpOutputCache(`=== CAPTURED OUTPUT ===
7291
7336
  `);
@@ -7310,7 +7355,7 @@ Captured external output:
7310
7355
  this.stdout = stdout;
7311
7356
  this._usesProcessStdout = stdout === process.stdout;
7312
7357
  this.realStdoutWrite = stdout.write;
7313
- const lib = resolveRenderLib();
7358
+ const lib = resolveRenderLib2();
7314
7359
  const useMemoryBufferedOutput = config.bufferedOutput === "memory";
7315
7360
  const useFeedOutput = !this._usesProcessStdout && !useMemoryBufferedOutput;
7316
7361
  const { screenMode, footerHeight, externalOutputMode } = resolveModes(config);
@@ -7329,7 +7374,7 @@ Captured external output:
7329
7374
  let feed = null;
7330
7375
  if (useFeedOutput) {
7331
7376
  try {
7332
- feed = NativeSpanFeed.create();
7377
+ feed = NativeSpanFeed2.create();
7333
7378
  } catch (error) {
7334
7379
  throw new Error(`Failed to allocate NativeSpanFeed for custom stdout: ${error instanceof Error ? error.message : String(error)}`);
7335
7380
  }
@@ -7356,7 +7401,7 @@ Captured external output:
7356
7401
  config.useThread = false;
7357
7402
  lib.setUseThread(rendererPtr, config.useThread);
7358
7403
  const kittyConfig = config.useKittyKeyboard ?? {};
7359
- const kittyFlags = buildKittyKeyboardFlags(kittyConfig);
7404
+ const kittyFlags = buildKittyKeyboardFlags2(kittyConfig);
7360
7405
  lib.setKittyKeyboardFlags(rendererPtr, kittyFlags);
7361
7406
  this._feed = feed;
7362
7407
  if (feed) {
@@ -7402,11 +7447,11 @@ Captured external output:
7402
7447
  "SIGBREAK",
7403
7448
  "SIGBUS"
7404
7449
  ];
7405
- this.clipboard = new Clipboard(this.lib, this.rendererPtr);
7450
+ this.clipboard = new Clipboard2(this.lib, this.rendererPtr);
7406
7451
  this.resizeDebounceDelay = config.debounceDelay || 100;
7407
7452
  this.targetFps = config.targetFps || 30;
7408
7453
  this.maxFps = config.maxFps || 60;
7409
- this.clock = config.clock ?? new SystemClock;
7454
+ this.clock = config.clock ?? new SystemClock2;
7410
7455
  this.themeModeState = new RendererThemeMode({
7411
7456
  queryThemeColors: () => {
7412
7457
  this.lib.queryThemeColors(this.rendererPtr);
@@ -7433,7 +7478,7 @@ Captured external output:
7433
7478
  this.currentRenderBuffer = this.lib.getCurrentBuffer(this.rendererPtr);
7434
7479
  this.postProcessFns = config.postProcessFns || [];
7435
7480
  this.prependedInputHandlers = config.prependInputHandlers || [];
7436
- this.root = new RootRenderable(this);
7481
+ this.root = new RootRenderable2(this);
7437
7482
  if (this.memorySnapshotInterval > 0) {
7438
7483
  this.startMemorySnapshotTimer();
7439
7484
  }
@@ -7444,7 +7489,7 @@ Captured external output:
7444
7489
  process.on("uncaughtException", this.handleError);
7445
7490
  process.on("unhandledRejection", this.handleError);
7446
7491
  const useKittyForParsing = kittyConfig !== null;
7447
- this._keyHandler = new InternalKeyHandler;
7492
+ this._keyHandler = new InternalKeyHandler2;
7448
7493
  this._keyHandler.on("keypress", (event) => {
7449
7494
  if (this.exitOnCtrlC && matchesKeyBinding(event, { name: "c", ctrl: true })) {
7450
7495
  process.nextTick(() => {
@@ -7455,7 +7500,7 @@ Captured external output:
7455
7500
  });
7456
7501
  this.addExitListeners();
7457
7502
  const stdinParserMaxBufferBytes = config.stdinParserMaxBufferBytes ?? DEFAULT_STDIN_PARSER_MAX_BUFFER_BYTES;
7458
- this.stdinParser = new StdinParser({
7503
+ this.stdinParser = new StdinParser2({
7459
7504
  timeoutMs: 20,
7460
7505
  maxPendingBytes: stdinParserMaxBufferBytes,
7461
7506
  armTimeouts: true,
@@ -7472,7 +7517,7 @@ Captured external output:
7472
7517
  },
7473
7518
  clock: this.clock
7474
7519
  });
7475
- this._console = new TerminalConsole(this, {
7520
+ this._console = new TerminalConsole2(this, {
7476
7521
  ...config.consoleOptions ?? {},
7477
7522
  clock: this.clock
7478
7523
  });
@@ -7486,7 +7531,7 @@ Captured external output:
7486
7531
  this._openConsoleOnError = config.openConsoleOnError ?? true;
7487
7532
  this._onDestroy = config.onDestroy;
7488
7533
  global.requestAnimationFrame = (callback) => {
7489
- const id = CliRenderer.animationFrameId++;
7534
+ const id = CliRenderer2.animationFrameId++;
7490
7535
  this.animationRequest.set(id, callback);
7491
7536
  this.requestLive();
7492
7537
  return id;
@@ -7500,7 +7545,7 @@ Captured external output:
7500
7545
  global.window = {};
7501
7546
  }
7502
7547
  global.window.requestAnimationFrame = requestAnimationFrame;
7503
- if (env.OTUI_NO_NATIVE_RENDER) {
7548
+ if (env2.OTUI_NO_NATIVE_RENDER) {
7504
7549
  this.renderNative = () => {
7505
7550
  if (this._splitHeight > 0) {
7506
7551
  this.flushStdoutCache(this._splitHeight);
@@ -7541,8 +7586,9 @@ Captured external output:
7541
7586
  removeExitListeners() {
7542
7587
  if (!this._exitListenersAdded || this.exitSignals.length === 0)
7543
7588
  return;
7589
+ const processEvents = process;
7544
7590
  this.exitSignals.forEach((signal) => {
7545
- process.removeListener(signal, this.exitHandler);
7591
+ processEvents.removeListener(signal, this.exitHandler);
7546
7592
  });
7547
7593
  this._exitListenersAdded = false;
7548
7594
  }
@@ -7564,7 +7610,7 @@ Captured external output:
7564
7610
  get currentFocusedEditor() {
7565
7611
  if (!this._currentFocusedRenderable)
7566
7612
  return null;
7567
- if (!isEditBufferRenderable(this._currentFocusedRenderable))
7613
+ if (!isEditBufferRenderable2(this._currentFocusedRenderable))
7568
7614
  return null;
7569
7615
  return this._currentFocusedRenderable;
7570
7616
  }
@@ -8058,8 +8104,8 @@ Captured external output:
8058
8104
  enumerable: true,
8059
8105
  configurable: true
8060
8106
  });
8061
- const internalRoot = new RootRenderable(renderContext);
8062
- const publicRoot = new BoxRenderable(renderContext, {
8107
+ const internalRoot = new RootRenderable2(renderContext);
8108
+ const publicRoot = new BoxRenderable2(renderContext, {
8063
8109
  id: `scrollback-surface-root-${surfaceId}`,
8064
8110
  position: "absolute",
8065
8111
  left: 0,
@@ -8082,12 +8128,16 @@ Captured external output:
8082
8128
  let surfaceDestroyed = false;
8083
8129
  let hasRendered = false;
8084
8130
  let nextCommitStartOnNewLine = startOnNewLine;
8085
- let backingBuffer = OptimizedBuffer.create(surfaceWidth, surfaceHeight, surfaceWidthMethod, {
8131
+ let backingBuffer = OptimizedBuffer2.create(surfaceWidth, surfaceHeight, surfaceWidthMethod, {
8086
8132
  id: `scrollback-surface-buffer-${surfaceId}`
8087
8133
  });
8088
8134
  const destroyListener = () => {
8089
8135
  destroySurface();
8090
8136
  };
8137
+ const capabilitiesListener = (capabilities) => {
8138
+ snapshotContext.capabilities = capabilities;
8139
+ renderContext.emit("capabilities" /* CAPABILITIES */, capabilities);
8140
+ };
8091
8141
  const assertNotDestroyed = () => {
8092
8142
  if (surfaceDestroyed) {
8093
8143
  throw new Error("ScrollbackSurface is destroyed");
@@ -8119,7 +8169,7 @@ Captured external output:
8119
8169
  };
8120
8170
  const collectPendingCodeRenderables = (node) => {
8121
8171
  const pending = [];
8122
- if (node instanceof CodeRenderable && node.isHighlighting) {
8172
+ if (node instanceof CodeRenderable2 && node.isHighlighting) {
8123
8173
  pending.push(node);
8124
8174
  }
8125
8175
  for (const child of node.getChildren()) {
@@ -8176,7 +8226,7 @@ Captured external output:
8176
8226
  let targetHeight = Math.max(1, surfaceHeight);
8177
8227
  if (surfaceWidthMethod !== widthMethod) {
8178
8228
  backingBuffer.destroy();
8179
- backingBuffer = OptimizedBuffer.create(width, targetHeight, widthMethod, {
8229
+ backingBuffer = OptimizedBuffer2.create(width, targetHeight, widthMethod, {
8180
8230
  id: `scrollback-surface-buffer-${surfaceId}`
8181
8231
  });
8182
8232
  } else {
@@ -8236,7 +8286,7 @@ Captured external output:
8236
8286
  return;
8237
8287
  }
8238
8288
  const rowCount = endRowExclusive - startRow;
8239
- const commitBuffer = OptimizedBuffer.create(surfaceWidth, rowCount, surfaceWidthMethod, {
8289
+ const commitBuffer = OptimizedBuffer2.create(surfaceWidth, rowCount, surfaceWidthMethod, {
8240
8290
  id: `scrollback-surface-commit-${surfaceId}`
8241
8291
  });
8242
8292
  try {
@@ -8259,6 +8309,7 @@ Captured external output:
8259
8309
  }
8260
8310
  surfaceDestroyed = true;
8261
8311
  renderer.off("destroy" /* DESTROY */, destroyListener);
8312
+ renderer.off("capabilities" /* CAPABILITIES */, capabilitiesListener);
8262
8313
  let destroyError = null;
8263
8314
  try {
8264
8315
  internalRoot.destroyRecursively();
@@ -8279,6 +8330,7 @@ Captured external output:
8279
8330
  }
8280
8331
  };
8281
8332
  renderer.on("destroy" /* DESTROY */, destroyListener);
8333
+ renderer.on("capabilities" /* CAPABILITIES */, capabilitiesListener);
8282
8334
  return {
8283
8335
  get renderContext() {
8284
8336
  return renderContext;
@@ -8325,8 +8377,8 @@ Captured external output:
8325
8377
  snapshotContext.width = snapshotWidth;
8326
8378
  snapshotContext.height = snapshotHeight;
8327
8379
  snapshotContext.widthMethod = this.widthMethod;
8328
- snapshotRoot = new RootRenderable(snapshotContext);
8329
- snapshotBuffer = OptimizedBuffer.create(snapshotWidth, snapshotHeight, this.widthMethod, {
8380
+ snapshotRoot = new RootRenderable2(snapshotContext);
8381
+ snapshotBuffer = OptimizedBuffer2.create(snapshotWidth, snapshotHeight, this.widthMethod, {
8330
8382
  id: "scrollback-snapshot-commit"
8331
8383
  });
8332
8384
  snapshotRoot.add(rootRenderable);
@@ -8485,8 +8537,8 @@ Captured external output:
8485
8537
  const lineCells = [...line];
8486
8538
  const rowColumns = Math.min(lineCells.length, maxWidth);
8487
8539
  const renderedLine = lineCells.slice(0, maxWidth).join("");
8488
- const snapshotRoot = new RootRenderable(snapshotContext);
8489
- const snapshotRenderable = new TextRenderable(snapshotContext, {
8540
+ const snapshotRoot = new RootRenderable2(snapshotContext);
8541
+ const snapshotRenderable = new TextRenderable2(snapshotContext, {
8490
8542
  id: "captured-stdout-snapshot",
8491
8543
  position: "absolute",
8492
8544
  left: 0,
@@ -8495,7 +8547,7 @@ Captured external output:
8495
8547
  height: 1,
8496
8548
  content: renderedLine
8497
8549
  });
8498
- const snapshotBuffer = OptimizedBuffer.create(Math.max(1, rowColumns), 1, this.widthMethod, {
8550
+ const snapshotBuffer = OptimizedBuffer2.create(Math.max(1, rowColumns), 1, this.widthMethod, {
8499
8551
  id: "captured-stdout-snapshot"
8500
8552
  });
8501
8553
  try {
@@ -9168,7 +9220,7 @@ Captured external output:
9168
9220
  this.startTerminalKeepAlive();
9169
9221
  }
9170
9222
  dispatchMouseEvent(target, attributes) {
9171
- const event = new MouseEvent(target, attributes);
9223
+ const event = new MouseEvent2(target, attributes);
9172
9224
  this.sendMouseEvent(target, event);
9173
9225
  if (this.autoFocus && event.type === "down" && event.button === 0 /* LEFT */ && !event.defaultPrevented) {
9174
9226
  let current = target;
@@ -9205,27 +9257,27 @@ Captured external output:
9205
9257
  if (this._console.visible) {
9206
9258
  const consoleBounds = this._console.bounds;
9207
9259
  if (mouseEvent.x >= consoleBounds.x && mouseEvent.x < consoleBounds.x + consoleBounds.width && mouseEvent.y >= consoleBounds.y && mouseEvent.y < consoleBounds.y + consoleBounds.height) {
9208
- const event2 = new MouseEvent(null, mouseEvent);
9209
- const handled = this._console.handleMouse(event2);
9260
+ const event = new MouseEvent2(null, mouseEvent);
9261
+ const handled = this._console.handleMouse(event);
9210
9262
  if (handled)
9211
9263
  return true;
9212
9264
  }
9213
9265
  }
9214
9266
  if (mouseEvent.type === "scroll") {
9215
- const maybeRenderableId2 = this.hitTest(mouseEvent.x, mouseEvent.y);
9216
- const maybeRenderable2 = Renderable.renderablesByNumber.get(maybeRenderableId2);
9267
+ const maybeRenderableId = this.hitTest(mouseEvent.x, mouseEvent.y);
9268
+ const maybeRenderable = Renderable2.renderablesByNumber.get(maybeRenderableId);
9217
9269
  const fallbackTarget = this._currentFocusedRenderable && !this._currentFocusedRenderable.isDestroyed && this._currentFocusedRenderable.focused ? this._currentFocusedRenderable : null;
9218
- const scrollTarget = maybeRenderable2 ?? fallbackTarget;
9270
+ const scrollTarget = maybeRenderable ?? fallbackTarget;
9219
9271
  if (scrollTarget) {
9220
- const event2 = new MouseEvent(scrollTarget, mouseEvent);
9221
- this.sendMouseEvent(scrollTarget, event2);
9272
+ const event = new MouseEvent2(scrollTarget, mouseEvent);
9273
+ this.sendMouseEvent(scrollTarget, event);
9222
9274
  }
9223
9275
  return true;
9224
9276
  }
9225
9277
  const maybeRenderableId = this.hitTest(mouseEvent.x, mouseEvent.y);
9226
9278
  const sameElement = maybeRenderableId === this.lastOverRenderableNum;
9227
9279
  this.lastOverRenderableNum = maybeRenderableId;
9228
- const maybeRenderable = Renderable.renderablesByNumber.get(maybeRenderableId);
9280
+ const maybeRenderable = Renderable2.renderablesByNumber.get(maybeRenderableId);
9229
9281
  if (mouseEvent.type === "down" && mouseEvent.button === 0 /* LEFT */ && !this.currentSelection?.isDragging && !mouseEvent.modifiers.ctrl) {
9230
9282
  const canStartSelection = Boolean(maybeRenderable && maybeRenderable.selectable && !maybeRenderable.isDestroyed && maybeRenderable.shouldStartSelection(mouseEvent.x, mouseEvent.y));
9231
9283
  if (canStartSelection && maybeRenderable) {
@@ -9237,21 +9289,21 @@ Captured external output:
9237
9289
  if (mouseEvent.type === "drag" && this.currentSelection?.isDragging) {
9238
9290
  this.updateSelection(maybeRenderable, mouseEvent.x, mouseEvent.y);
9239
9291
  if (maybeRenderable) {
9240
- const event2 = new MouseEvent(maybeRenderable, {
9292
+ const event = new MouseEvent2(maybeRenderable, {
9241
9293
  ...mouseEvent,
9242
9294
  isDragging: true
9243
9295
  });
9244
- this.sendMouseEvent(maybeRenderable, event2);
9296
+ this.sendMouseEvent(maybeRenderable, event);
9245
9297
  }
9246
9298
  return true;
9247
9299
  }
9248
9300
  if (mouseEvent.type === "up" && mouseEvent.button === 0 /* LEFT */ && this.currentSelection?.isDragging) {
9249
9301
  if (maybeRenderable) {
9250
- const event2 = new MouseEvent(maybeRenderable, {
9302
+ const event = new MouseEvent2(maybeRenderable, {
9251
9303
  ...mouseEvent,
9252
9304
  isDragging: true
9253
9305
  });
9254
- this.sendMouseEvent(maybeRenderable, event2);
9306
+ this.sendMouseEvent(maybeRenderable, event);
9255
9307
  }
9256
9308
  this.finishSelection();
9257
9309
  return true;
@@ -9265,41 +9317,41 @@ Captured external output:
9265
9317
  }
9266
9318
  if (!sameElement && (mouseEvent.type === "drag" || mouseEvent.type === "move")) {
9267
9319
  if (this.lastOverRenderable && this.lastOverRenderable !== this.capturedRenderable && !this.lastOverRenderable.isDestroyed) {
9268
- const event2 = new MouseEvent(this.lastOverRenderable, {
9320
+ const event = new MouseEvent2(this.lastOverRenderable, {
9269
9321
  ...mouseEvent,
9270
9322
  type: "out"
9271
9323
  });
9272
- this.sendMouseEvent(this.lastOverRenderable, event2);
9324
+ this.sendMouseEvent(this.lastOverRenderable, event);
9273
9325
  }
9274
9326
  this.lastOverRenderable = maybeRenderable;
9275
9327
  if (maybeRenderable) {
9276
- const event2 = new MouseEvent(maybeRenderable, {
9328
+ const event = new MouseEvent2(maybeRenderable, {
9277
9329
  ...mouseEvent,
9278
9330
  type: "over",
9279
9331
  source: this.capturedRenderable
9280
9332
  });
9281
- this.sendMouseEvent(maybeRenderable, event2);
9333
+ this.sendMouseEvent(maybeRenderable, event);
9282
9334
  }
9283
9335
  }
9284
9336
  if (this.capturedRenderable && mouseEvent.type !== "up") {
9285
- const event2 = new MouseEvent(this.capturedRenderable, mouseEvent);
9286
- this.sendMouseEvent(this.capturedRenderable, event2);
9337
+ const event = new MouseEvent2(this.capturedRenderable, mouseEvent);
9338
+ this.sendMouseEvent(this.capturedRenderable, event);
9287
9339
  return true;
9288
9340
  }
9289
9341
  if (this.capturedRenderable && mouseEvent.type === "up") {
9290
- const event2 = new MouseEvent(this.capturedRenderable, {
9342
+ const event = new MouseEvent2(this.capturedRenderable, {
9291
9343
  ...mouseEvent,
9292
9344
  type: "drag-end"
9293
9345
  });
9294
- this.sendMouseEvent(this.capturedRenderable, event2);
9295
- this.sendMouseEvent(this.capturedRenderable, new MouseEvent(this.capturedRenderable, mouseEvent));
9346
+ this.sendMouseEvent(this.capturedRenderable, event);
9347
+ this.sendMouseEvent(this.capturedRenderable, new MouseEvent2(this.capturedRenderable, mouseEvent));
9296
9348
  if (maybeRenderable) {
9297
- const event3 = new MouseEvent(maybeRenderable, {
9349
+ const event = new MouseEvent2(maybeRenderable, {
9298
9350
  ...mouseEvent,
9299
9351
  type: "drop",
9300
9352
  source: this.capturedRenderable
9301
9353
  });
9302
- this.sendMouseEvent(maybeRenderable, event3);
9354
+ this.sendMouseEvent(maybeRenderable, event);
9303
9355
  }
9304
9356
  this.lastOverRenderable = this.capturedRenderable;
9305
9357
  this.lastOverRenderableNum = this.capturedRenderable.num;
@@ -9329,7 +9381,7 @@ Captured external output:
9329
9381
  if (this.capturedRenderable)
9330
9382
  return;
9331
9383
  const hitId = this.hitTest(this._latestPointer.x, this._latestPointer.y);
9332
- const hitRenderable = Renderable.renderablesByNumber.get(hitId);
9384
+ const hitRenderable = Renderable2.renderablesByNumber.get(hitId);
9333
9385
  const lastOver = this.lastOverRenderable;
9334
9386
  if (lastOver?.num === hitId) {
9335
9387
  this.lastOverRenderableNum = hitId;
@@ -9343,13 +9395,13 @@ Captured external output:
9343
9395
  modifiers: this._lastPointerModifiers
9344
9396
  };
9345
9397
  if (lastOver && !lastOver.isDestroyed) {
9346
- const event = new MouseEvent(lastOver, { ...baseEvent, type: "out" });
9398
+ const event = new MouseEvent2(lastOver, { ...baseEvent, type: "out" });
9347
9399
  this.sendMouseEvent(lastOver, event);
9348
9400
  }
9349
9401
  this.lastOverRenderable = hitRenderable;
9350
9402
  this.lastOverRenderableNum = hitId;
9351
9403
  if (hitRenderable) {
9352
- const event = new MouseEvent(hitRenderable, {
9404
+ const event = new MouseEvent2(hitRenderable, {
9353
9405
  ...baseEvent,
9354
9406
  type: "over"
9355
9407
  });
@@ -9363,6 +9415,18 @@ Captured external output:
9363
9415
  hitTest(x, y) {
9364
9416
  return this.lib.checkHit(this.rendererPtr, x, y);
9365
9417
  }
9418
+ getLinkIdAt(x, y) {
9419
+ if (this._isDestroyed || !Number.isInteger(x) || !Number.isInteger(y))
9420
+ return 0;
9421
+ const buffer = this.currentRenderBuffer;
9422
+ if (x < 0 || y < 0 || x >= buffer.width || y >= buffer.height)
9423
+ return 0;
9424
+ return getLinkId2(buffer.buffers.attributes[y * buffer.width + x]);
9425
+ }
9426
+ getLinkAt(x, y) {
9427
+ const linkId = this.getLinkIdAt(x, y);
9428
+ return linkId === 0 ? null : this.currentRenderBuffer.lib.linkGetUrl(linkId) || null;
9429
+ }
9366
9430
  takeMemorySnapshot() {
9367
9431
  if (this._isDestroyed)
9368
9432
  return;
@@ -9477,7 +9541,7 @@ Captured external output:
9477
9541
  this.processResize(width, height);
9478
9542
  }
9479
9543
  setBackgroundColor(color) {
9480
- const parsedColor = parseColor(color);
9544
+ const parsedColor = parseColor2(color);
9481
9545
  this.lib.setBackgroundColor(this.rendererPtr, parsedColor);
9482
9546
  this.backgroundColor = parsedColor;
9483
9547
  this.nextRenderBuffer.clear(parsedColor);
@@ -9530,18 +9594,18 @@ Captured external output:
9530
9594
  this.lib.dumpOutputBuffer(this.rendererPtr, timestamp);
9531
9595
  }
9532
9596
  static setCursorPosition(renderer, x, y, visible = true) {
9533
- const lib = resolveRenderLib();
9597
+ const lib = resolveRenderLib2();
9534
9598
  lib.setCursorPosition(renderer.rendererPtr, x, y, visible);
9535
9599
  }
9536
9600
  static setCursorStyle(renderer, options) {
9537
- const lib = resolveRenderLib();
9601
+ const lib = resolveRenderLib2();
9538
9602
  lib.setCursorStyleOptions(renderer.rendererPtr, options);
9539
9603
  if (options.cursor !== undefined) {
9540
9604
  renderer._currentMousePointerStyle = options.cursor;
9541
9605
  }
9542
9606
  }
9543
9607
  static setCursorColor(renderer, color) {
9544
- const lib = resolveRenderLib();
9608
+ const lib = resolveRenderLib2();
9545
9609
  lib.setCursorColor(renderer.rendererPtr, color);
9546
9610
  }
9547
9611
  setCursorPosition(x, y, visible = true) {
@@ -9749,12 +9813,13 @@ Captured external output:
9749
9813
  this.stdout.off("error", this.kittyOutputErrorHandler);
9750
9814
  this.lib.cancelKittyImageTransport(this.rendererPtr, false);
9751
9815
  }
9816
+ const processEvents = process;
9752
9817
  if (this._usesProcessStdout) {
9753
- process.removeListener("SIGWINCH", this.sigwinchHandler);
9818
+ processEvents.removeListener("SIGWINCH", this.sigwinchHandler);
9754
9819
  }
9755
- process.removeListener("uncaughtException", this.handleError);
9756
- process.removeListener("unhandledRejection", this.handleError);
9757
- process.removeListener("warning", this.warningHandler);
9820
+ processEvents.removeListener("uncaughtException", this.handleError);
9821
+ processEvents.removeListener("unhandledRejection", this.handleError);
9822
+ processEvents.removeListener("warning", this.warningHandler);
9758
9823
  this.removeExitListeners();
9759
9824
  if (this.resizeTimeoutId !== null) {
9760
9825
  this.clock.clearTimeout(this.resizeTimeoutId);
@@ -9872,7 +9937,7 @@ Captured external output:
9872
9937
  }
9873
9938
  rendererTracker.renderers.delete(this);
9874
9939
  if (rendererTracker.renderers.size === 0) {
9875
- destroyTreeSitterClient().catch((error) => {
9940
+ destroyTreeSitterClient2().catch((error) => {
9876
9941
  console.error("Failed to destroy tree-sitter client:", error);
9877
9942
  });
9878
9943
  }
@@ -10150,7 +10215,7 @@ Captured external output:
10150
10215
  return;
10151
10216
  this.clearSelectionState();
10152
10217
  this.selectionContainers.push(renderable.parent || this.root);
10153
- this.currentSelection = new Selection(renderable, { x, y }, { x, y }, behavior);
10218
+ this.currentSelection = new Selection2(renderable, { x, y }, { x, y }, behavior);
10154
10219
  this.currentSelection.isStart = true;
10155
10220
  this.notifySelectablesOfSelectionChange();
10156
10221
  }
@@ -10192,7 +10257,7 @@ Captured external output:
10192
10257
  if (this.currentSelection?.isDragging) {
10193
10258
  const pointer = this._latestPointer;
10194
10259
  const maybeRenderableId = this.hitTest(pointer.x, pointer.y);
10195
- const maybeRenderable = Renderable.renderablesByNumber.get(maybeRenderableId);
10260
+ const maybeRenderable = Renderable2.renderablesByNumber.get(maybeRenderableId);
10196
10261
  this.updateSelection(maybeRenderable, pointer.x, pointer.y);
10197
10262
  }
10198
10263
  }
@@ -10273,7 +10338,7 @@ Captured external output:
10273
10338
  if (!this._paletteDetector) {
10274
10339
  const isTmux = Boolean(this.capabilities?.multiplexer === "tmux" || this.capabilities?.terminal?.name?.toLowerCase()?.includes("tmux"));
10275
10340
  const isLegacyTmux = this.capabilities?.terminal?.name?.toLowerCase()?.includes("tmux") && this.capabilities?.terminal?.version?.localeCompare("3.6") < 0;
10276
- this._paletteDetector = createTerminalPalette({
10341
+ this._paletteDetector = createTerminalPalette2({
10277
10342
  stdin: this.stdin,
10278
10343
  stdout: this.stdout,
10279
10344
  writeFn: (data) => this._isDestroyed ? false : this.writeOut(data),
@@ -10288,18 +10353,18 @@ Captured external output:
10288
10353
  return this._paletteDetector;
10289
10354
  }
10290
10355
  syncNativePaletteState(colors) {
10291
- const signature = buildTerminalPaletteSignature(colors);
10356
+ const signature = buildTerminalPaletteSignature2(colors);
10292
10357
  if (this._nativePaletteSignature !== signature) {
10293
10358
  this._paletteEpoch = this._paletteEpoch + 1 >>> 0;
10294
10359
  }
10295
10360
  this._nativePaletteSignature = signature;
10296
- const normalized = normalizeTerminalPalette(colors);
10361
+ const normalized = normalizeTerminalPalette2(colors);
10297
10362
  this.lib.rendererSetPaletteState(this.rendererPtr, normalized.palette, normalized.defaultForeground, normalized.defaultBackground, this._paletteEpoch);
10298
10363
  }
10299
10364
  emitPaletteChange(colors) {
10300
10365
  if (this.listenerCount("palette" /* PALETTE */) === 0)
10301
10366
  return;
10302
- const signature = buildTerminalPaletteSignature(colors);
10367
+ const signature = buildTerminalPaletteSignature2(colors);
10303
10368
  if (this._emittedPaletteSignature === signature)
10304
10369
  return;
10305
10370
  this._emittedPaletteSignature = signature;
@@ -10405,7 +10470,7 @@ Captured external output:
10405
10470
  }
10406
10471
  }
10407
10472
 
10408
- 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 };
10473
+ export { convertThemeToStyles2, SyntaxStyle2, h2, isVNode2, maybeMakeRenderable2, wrapWithDelegates2, instantiate2, delegate2, LayoutEvents2, RenderableEvents2, isRenderable2, BaseRenderable2, Renderable2, RootRenderable2, TextBufferView2, EditBuffer2, EditorView2, ANSI, BoxRenderable2, TextBufferRenderable2, CodeRenderable2, isTextNodeRenderable2, TextNodeRenderable2, RootTextNodeRenderable2, TextRenderable2, NativeSpanFeed2, defaultKeyAliases, mergeKeyAliases, mergeKeyBindings, getKeyBindingAction, buildKeyBindingsMap, capture2, ConsolePosition2, TerminalConsole2, getObjectsInViewport, EditBufferRenderableEvents2, isEditBufferRenderable2, EditBufferRenderable2, buildKittyKeyboardFlags2, MouseEvent2, MouseButton2, createCliRenderer2, CliRenderEvents2, RendererControlState2, CliRenderer2 };
10409
10474
 
10410
- //# debugId=E69D7F0A21FC1D2B64756E2164756E21
10411
- //# sourceMappingURL=chunk-node-6bg8r2m7.js.map
10475
+ //# debugId=EDE4817CFEF779F464756E2164756E21
10476
+ //# sourceMappingURL=chunk-node-54dhb2fr.js.map