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