@opentui/core 0.1.19-snapshot5-5ed8b651 → 0.1.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/3d.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  __export,
6
6
  __require,
7
7
  __toESM
8
- } from "./index-grak7z0n.js";
8
+ } from "./index-23dkhv32.js";
9
9
 
10
10
  // ../../node_modules/omggif/omggif.js
11
11
  var require_omggif = __commonJS((exports) => {
package/Renderable.d.ts CHANGED
@@ -25,7 +25,10 @@ export interface Position {
25
25
  bottom?: number | "auto" | `${number}%`;
26
26
  left?: number | "auto" | `${number}%`;
27
27
  }
28
- export interface LayoutOptions {
28
+ export interface BaseRenderableOptions {
29
+ id?: string;
30
+ }
31
+ export interface LayoutOptions extends BaseRenderableOptions {
29
32
  flexGrow?: number;
30
33
  flexShrink?: number;
31
34
  flexDirection?: FlexDirectionString;
@@ -56,8 +59,7 @@ export interface LayoutOptions {
56
59
  paddingLeft?: number | `${number}%`;
57
60
  enableLayout?: boolean;
58
61
  }
59
- export interface RenderableOptions<T extends Renderable = Renderable> extends Partial<LayoutOptions> {
60
- id?: string;
62
+ export interface RenderableOptions<T extends BaseRenderable = BaseRenderable> extends Partial<LayoutOptions> {
61
63
  width?: number | "auto" | `${number}%`;
62
64
  height?: number | "auto" | `${number}%`;
63
65
  zIndex?: number;
@@ -89,12 +91,25 @@ export declare function isDimensionType(value: any): value is number | "auto" |
89
91
  export declare function isFlexBasisType(value: any): value is number | "auto" | undefined;
90
92
  export declare function isSizeType(value: any): value is number | `${number}%` | undefined;
91
93
  export declare function isRenderable(obj: any): obj is Renderable;
92
- export declare abstract class Renderable extends EventEmitter {
94
+ export declare abstract class BaseRenderable extends EventEmitter {
93
95
  [BrandedRenderable]: boolean;
94
96
  private static renderableNumber;
95
- static renderablesByNumber: Map<number, Renderable>;
96
97
  readonly id: string;
97
98
  readonly num: number;
99
+ protected _dirty: boolean;
100
+ constructor(options: BaseRenderableOptions);
101
+ abstract add(obj: BaseRenderable | unknown, index?: number): number;
102
+ abstract remove(id: string): void;
103
+ abstract getChildren(): BaseRenderable[];
104
+ abstract getChildrenCount(): number;
105
+ abstract getRenderable(id: string): BaseRenderable | undefined;
106
+ abstract requestRender(): void;
107
+ get isDirty(): boolean;
108
+ protected markClean(): void;
109
+ protected markDirty(): void;
110
+ }
111
+ export declare abstract class Renderable extends BaseRenderable {
112
+ static renderablesByNumber: Map<number, Renderable>;
98
113
  private _isDestroyed;
99
114
  protected _ctx: RenderContext;
100
115
  protected _translateX: number;
@@ -110,7 +125,6 @@ export declare abstract class Renderable extends EventEmitter {
110
125
  selectable: boolean;
111
126
  protected buffered: boolean;
112
127
  protected frameBuffer: OptimizedBuffer | null;
113
- private _dirty;
114
128
  protected focusable: boolean;
115
129
  protected _focused: boolean;
116
130
  protected keyHandler: KeyHandler;
@@ -149,9 +163,7 @@ export declare abstract class Renderable extends EventEmitter {
149
163
  set live(value: boolean);
150
164
  protected propagateLiveCount(delta: number): void;
151
165
  handleKeyPress?(key: ParsedKey | string): boolean;
152
- protected get isDirty(): boolean;
153
166
  findDescendantById(id: string): Renderable | undefined;
154
- private markClean;
155
167
  requestRender(): void;
156
168
  get translateX(): number;
157
169
  set translateX(value: number);
@@ -215,8 +227,8 @@ export declare abstract class Renderable extends EventEmitter {
215
227
  protected createFrameBuffer(): void;
216
228
  protected onResize(width: number, height: number): void;
217
229
  private replaceParent;
218
- add(obj: Renderable | VNode<any, any[]>, index?: number): number;
219
- insertBefore(obj: Renderable | VNode<any, any[]>, anchor?: Renderable): number;
230
+ add(obj: Renderable | VNode<any, any[]> | unknown, index?: number): number;
231
+ insertBefore(obj: Renderable | VNode<any, any[]> | unknown, anchor?: Renderable | unknown): number;
220
232
  getRenderable(id: string): Renderable | undefined;
221
233
  remove(id: string): void;
222
234
  protected onRemove(): void;
@@ -3938,64 +3938,76 @@ function createTextAttributes({
3938
3938
  }
3939
3939
 
3940
3940
  // src/lib/styled-text.ts
3941
- var textEncoder = new TextEncoder;
3941
+ var BrandedStyledText = Symbol.for("@opentui/core/StyledText");
3942
+ function isStyledText(obj) {
3943
+ return obj && obj[BrandedStyledText];
3944
+ }
3942
3945
 
3943
3946
  class StyledText {
3947
+ [BrandedStyledText] = true;
3944
3948
  chunks;
3949
+ textRenderable;
3945
3950
  constructor(chunks) {
3946
3951
  this.chunks = chunks;
3947
3952
  }
3948
- static _createInstance(chunks) {
3949
- const newInstance = Object.create(StyledText.prototype);
3950
- newInstance.chunks = chunks;
3951
- return newInstance;
3953
+ mount(textRenderable) {
3954
+ this.textRenderable = textRenderable;
3952
3955
  }
3953
3956
  insert(chunk, index) {
3954
3957
  const originalLength = this.chunks.length;
3955
- let newChunks;
3956
- if (index === undefined || index === originalLength) {
3957
- newChunks = [...this.chunks, chunk];
3958
- } else {
3959
- newChunks = [...this.chunks.slice(0, index), chunk, ...this.chunks.slice(index)];
3958
+ if (this.textRenderable) {
3959
+ this.textRenderable.insertChunk(chunk, index ?? originalLength);
3960
+ let newChunks;
3961
+ if (index === undefined || index === originalLength) {
3962
+ newChunks = [...this.chunks, chunk];
3963
+ } else {
3964
+ newChunks = [...this.chunks.slice(0, index), chunk, ...this.chunks.slice(index)];
3965
+ }
3966
+ this.chunks = newChunks;
3960
3967
  }
3961
- return StyledText._createInstance(newChunks);
3968
+ return this;
3962
3969
  }
3963
3970
  remove(chunk) {
3964
- const originalLength = this.chunks.length;
3965
- const index = this.chunks.indexOf(chunk);
3966
- if (index === -1)
3967
- return this;
3968
- let newChunks;
3969
- if (index === originalLength - 1) {
3970
- newChunks = this.chunks.slice(0, -1);
3971
- } else {
3972
- newChunks = [...this.chunks.slice(0, index), ...this.chunks.slice(index + 1)];
3971
+ if (this.textRenderable) {
3972
+ this.textRenderable.removeChunk(chunk);
3973
+ const originalLength = this.chunks.length;
3974
+ const index = this.chunks.indexOf(chunk);
3975
+ if (index === -1)
3976
+ return this;
3977
+ let newChunks;
3978
+ if (index === originalLength - 1) {
3979
+ newChunks = this.chunks.slice(0, -1);
3980
+ } else {
3981
+ newChunks = [...this.chunks.slice(0, index), ...this.chunks.slice(index + 1)];
3982
+ }
3983
+ this.chunks = newChunks;
3973
3984
  }
3974
- return StyledText._createInstance(newChunks);
3985
+ return this;
3975
3986
  }
3976
3987
  replace(chunk, oldChunk) {
3977
- const index = this.chunks.indexOf(oldChunk);
3978
- if (index === -1)
3979
- return this;
3980
- let newChunks;
3981
- if (index === this.chunks.length - 1) {
3982
- newChunks = [...this.chunks.slice(0, -1), chunk];
3983
- } else {
3984
- newChunks = [...this.chunks.slice(0, index), chunk, ...this.chunks.slice(index + 1)];
3988
+ if (this.textRenderable) {
3989
+ this.textRenderable.replaceChunk(chunk, oldChunk);
3990
+ const index = this.chunks.indexOf(oldChunk);
3991
+ if (index === -1)
3992
+ return this;
3993
+ let newChunks;
3994
+ if (index === this.chunks.length - 1) {
3995
+ newChunks = [...this.chunks.slice(0, -1), chunk];
3996
+ } else {
3997
+ newChunks = [...this.chunks.slice(0, index), chunk, ...this.chunks.slice(index + 1)];
3998
+ }
3999
+ this.chunks = newChunks;
3985
4000
  }
3986
- return StyledText._createInstance(newChunks);
4001
+ return this;
3987
4002
  }
3988
4003
  }
3989
4004
  function stringToStyledText(content) {
3990
- const textEncoder2 = new TextEncoder;
3991
4005
  const chunk = {
3992
4006
  __isChunk: true,
3993
- text: textEncoder2.encode(content),
3994
- plainText: content
4007
+ text: content
3995
4008
  };
3996
4009
  return new StyledText([chunk]);
3997
4010
  }
3998
- var templateCache = new WeakMap;
3999
4011
  function applyStyle(input, style) {
4000
4012
  if (typeof input === "object" && "__isChunk" in input) {
4001
4013
  const existingChunk = input;
@@ -4006,21 +4018,18 @@ function applyStyle(input, style) {
4006
4018
  return {
4007
4019
  __isChunk: true,
4008
4020
  text: existingChunk.text,
4009
- plainText: existingChunk.plainText,
4010
4021
  fg,
4011
4022
  bg,
4012
4023
  attributes: mergedAttrs
4013
4024
  };
4014
4025
  } else {
4015
4026
  const plainTextStr = String(input);
4016
- const text = textEncoder.encode(plainTextStr);
4017
4027
  const fg = style.fg ? parseColor(style.fg) : undefined;
4018
4028
  const bg = style.bg ? parseColor(style.bg) : undefined;
4019
4029
  const attributes = createTextAttributes(style);
4020
4030
  return {
4021
4031
  __isChunk: true,
4022
- text,
4023
- plainText: plainTextStr,
4032
+ text: plainTextStr,
4024
4033
  fg,
4025
4034
  bg,
4026
4035
  attributes
@@ -4060,15 +4069,14 @@ var reverse = (input) => applyStyle(input, { reverse: true });
4060
4069
  var blink = (input) => applyStyle(input, { blink: true });
4061
4070
  var fg = (color) => (input) => applyStyle(input, { fg: color });
4062
4071
  var bg = (color) => (input) => applyStyle(input, { bg: color });
4063
- function tn(strings, ...values) {
4072
+ function t(strings, ...values) {
4064
4073
  const chunks = [];
4065
4074
  for (let i = 0;i < strings.length; i++) {
4066
4075
  const raw = strings[i];
4067
4076
  if (raw) {
4068
4077
  chunks.push({
4069
4078
  __isChunk: true,
4070
- text: textEncoder.encode(raw),
4071
- plainText: raw,
4079
+ text: raw,
4072
4080
  attributes: 0
4073
4081
  });
4074
4082
  }
@@ -4079,48 +4087,7 @@ function tn(strings, ...values) {
4079
4087
  const plainTextStr = String(val);
4080
4088
  chunks.push({
4081
4089
  __isChunk: true,
4082
- text: textEncoder.encode(plainTextStr),
4083
- plainText: plainTextStr,
4084
- attributes: 0
4085
- });
4086
- }
4087
- }
4088
- return new StyledText(chunks);
4089
- }
4090
- function t(strings, ...values) {
4091
- let cachedStringChunks = templateCache.get(strings);
4092
- if (!cachedStringChunks) {
4093
- cachedStringChunks = [];
4094
- for (let i = 0;i < strings.length; i++) {
4095
- const raw = strings[i];
4096
- if (raw) {
4097
- cachedStringChunks.push({
4098
- __isChunk: true,
4099
- text: textEncoder.encode(raw),
4100
- plainText: raw,
4101
- attributes: 0
4102
- });
4103
- } else {
4104
- cachedStringChunks.push(null);
4105
- }
4106
- }
4107
- templateCache.set(strings, cachedStringChunks);
4108
- }
4109
- const chunks = [];
4110
- for (let i = 0;i < strings.length; i++) {
4111
- const stringChunk = cachedStringChunks[i];
4112
- if (stringChunk) {
4113
- chunks.push(stringChunk);
4114
- }
4115
- const val = values[i];
4116
- if (typeof val === "object" && "__isChunk" in val) {
4117
- chunks.push(val);
4118
- } else if (val !== undefined) {
4119
- const plainTextStr = String(val);
4120
- chunks.push({
4121
- __isChunk: true,
4122
- text: textEncoder.encode(plainTextStr),
4123
- plainText: plainTextStr,
4090
+ text: plainTextStr,
4124
4091
  attributes: 0
4125
4092
  });
4126
4093
  }
@@ -4180,7 +4147,6 @@ class SyntaxStyle {
4180
4147
  return this.mergedStyleCache.size;
4181
4148
  }
4182
4149
  }
4183
- var textEncoder2 = new TextEncoder;
4184
4150
  function hastToTextChunks(node, syntaxStyle, parentStyles = []) {
4185
4151
  const chunks = [];
4186
4152
  if (node.type === "text") {
@@ -4188,8 +4154,7 @@ function hastToTextChunks(node, syntaxStyle, parentStyles = []) {
4188
4154
  const mergedStyle = syntaxStyle.mergeStyles(...stylesToMerge);
4189
4155
  chunks.push({
4190
4156
  __isChunk: true,
4191
- text: textEncoder2.encode(node.value),
4192
- plainText: node.value,
4157
+ text: node.value,
4193
4158
  fg: mergedStyle.fg,
4194
4159
  bg: mergedStyle.bg,
4195
4160
  attributes: mergedStyle.attributes
@@ -5171,6 +5136,10 @@ function getOpenTUILib(libPath) {
5171
5136
  args: ["ptr", "ptr", "usize"],
5172
5137
  returns: "usize"
5173
5138
  },
5139
+ textBufferGetPlainText: {
5140
+ args: ["ptr", "ptr", "usize"],
5141
+ returns: "usize"
5142
+ },
5174
5143
  textBufferSetLocalSelection: {
5175
5144
  args: ["ptr", "i32", "i32", "i32", "i32", "ptr", "ptr"],
5176
5145
  returns: "bool"
@@ -5179,6 +5148,26 @@ function getOpenTUILib(libPath) {
5179
5148
  args: ["ptr"],
5180
5149
  returns: "void"
5181
5150
  },
5151
+ textBufferInsertChunkGroup: {
5152
+ args: ["ptr", "usize", "ptr", "u32", "ptr", "ptr", "u8"],
5153
+ returns: "u32"
5154
+ },
5155
+ textBufferRemoveChunkGroup: {
5156
+ args: ["ptr", "usize"],
5157
+ returns: "u32"
5158
+ },
5159
+ textBufferReplaceChunkGroup: {
5160
+ args: ["ptr", "usize", "ptr", "u32", "ptr", "ptr", "u8"],
5161
+ returns: "u32"
5162
+ },
5163
+ textBufferGetChunkGroupCount: {
5164
+ args: ["ptr"],
5165
+ returns: "usize"
5166
+ },
5167
+ getArenaAllocatedBytes: {
5168
+ args: [],
5169
+ returns: "usize"
5170
+ },
5182
5171
  bufferDrawTextBuffer: {
5183
5172
  args: ["ptr", "ptr", "i32", "i32", "i32", "i32", "u32", "u32", "bool"],
5184
5173
  returns: "void"
@@ -5546,6 +5535,10 @@ class FFIRenderLib {
5546
5535
  const result = this.opentui.symbols.textBufferGetSelectedText(buffer, outPtr, maxLen);
5547
5536
  return typeof result === "bigint" ? Number(result) : result;
5548
5537
  }
5538
+ textBufferGetPlainText(buffer, outPtr, maxLen) {
5539
+ const result = this.opentui.symbols.textBufferGetPlainText(buffer, outPtr, maxLen);
5540
+ return typeof result === "bigint" ? Number(result) : result;
5541
+ }
5549
5542
  getSelectedTextBytes(buffer, maxLength) {
5550
5543
  const outBuffer = new Uint8Array(maxLength);
5551
5544
  const actualLen = this.textBufferGetSelectedText(buffer, ptr(outBuffer), maxLength);
@@ -5554,6 +5547,14 @@ class FFIRenderLib {
5554
5547
  }
5555
5548
  return outBuffer.slice(0, actualLen);
5556
5549
  }
5550
+ getPlainTextBytes(buffer, maxLength) {
5551
+ const outBuffer = new Uint8Array(maxLength);
5552
+ const actualLen = this.textBufferGetPlainText(buffer, ptr(outBuffer), maxLength);
5553
+ if (actualLen === 0) {
5554
+ return null;
5555
+ }
5556
+ return outBuffer.slice(0, actualLen);
5557
+ }
5557
5558
  textBufferSetLocalSelection(buffer, anchorX, anchorY, focusX, focusY, bgColor, fgColor) {
5558
5559
  const bg2 = bgColor ? bgColor.buffer : null;
5559
5560
  const fg2 = fgColor ? fgColor.buffer : null;
@@ -5562,6 +5563,29 @@ class FFIRenderLib {
5562
5563
  textBufferResetLocalSelection(buffer) {
5563
5564
  this.opentui.symbols.textBufferResetLocalSelection(buffer);
5564
5565
  }
5566
+ textBufferInsertChunkGroup(buffer, index, textBytes, fg2, bg2, attributes) {
5567
+ const fgPtr = fg2 ? fg2.buffer : null;
5568
+ const bgPtr = bg2 ? bg2.buffer : null;
5569
+ const attr = attributes ?? 255;
5570
+ return this.opentui.symbols.textBufferInsertChunkGroup(buffer, index, textBytes, textBytes.length, fgPtr, bgPtr, attr);
5571
+ }
5572
+ textBufferRemoveChunkGroup(buffer, index) {
5573
+ return this.opentui.symbols.textBufferRemoveChunkGroup(buffer, index);
5574
+ }
5575
+ textBufferReplaceChunkGroup(buffer, index, textBytes, fg2, bg2, attributes) {
5576
+ const fgPtr = fg2 ? fg2.buffer : null;
5577
+ const bgPtr = bg2 ? bg2.buffer : null;
5578
+ const attr = attributes ?? 255;
5579
+ return this.opentui.symbols.textBufferReplaceChunkGroup(buffer, index, textBytes, textBytes.length, fgPtr, bgPtr, attr);
5580
+ }
5581
+ textBufferGetChunkGroupCount(buffer) {
5582
+ const result = this.opentui.symbols.textBufferGetChunkGroupCount(buffer);
5583
+ return typeof result === "bigint" ? Number(result) : result;
5584
+ }
5585
+ getArenaAllocatedBytes() {
5586
+ const result = this.opentui.symbols.getArenaAllocatedBytes();
5587
+ return typeof result === "bigint" ? Number(result) : result;
5588
+ }
5565
5589
  textBufferGetLineInfo(buffer) {
5566
5590
  const lineCount = this.textBufferGetLineCount(buffer);
5567
5591
  if (lineCount === 0) {
@@ -5661,7 +5685,8 @@ class TextBuffer {
5661
5685
  this._length = 0;
5662
5686
  this._lineInfo = undefined;
5663
5687
  for (const chunk of text.chunks) {
5664
- const result = this.lib.textBufferWriteChunk(this.bufferPtr, chunk.text, chunk.fg || null, chunk.bg || null, chunk.attributes ?? null);
5688
+ const textBytes = this.lib.encoder.encode(chunk.text);
5689
+ const result = this.lib.textBufferWriteChunk(this.bufferPtr, textBytes, chunk.fg || null, chunk.bg || null, chunk.attributes ?? null);
5665
5690
  if (result & 1) {
5666
5691
  this._capacity = this.lib.textBufferGetCapacity(this.bufferPtr);
5667
5692
  }
@@ -5693,11 +5718,19 @@ class TextBuffer {
5693
5718
  getSelectedText() {
5694
5719
  if (this._length === 0)
5695
5720
  return "";
5696
- const selectedBytes = this.lib.getSelectedTextBytes(this.bufferPtr, this._length);
5721
+ const selectedBytes = this.lib.getSelectedTextBytes(this.bufferPtr, this.length * 4);
5697
5722
  if (!selectedBytes)
5698
5723
  return "";
5699
5724
  return this.lib.decoder.decode(selectedBytes);
5700
5725
  }
5726
+ getPlainText() {
5727
+ if (this._length === 0)
5728
+ return "";
5729
+ const plainBytes = this.lib.getPlainTextBytes(this.bufferPtr, this.length * 4);
5730
+ if (!plainBytes)
5731
+ return "";
5732
+ return this.lib.decoder.decode(plainBytes);
5733
+ }
5701
5734
  get lineInfo() {
5702
5735
  if (!this._lineInfo) {
5703
5736
  this._lineInfo = this.lib.textBufferGetLineInfo(this.bufferPtr);
@@ -5722,6 +5755,29 @@ class TextBuffer {
5722
5755
  hasSelection() {
5723
5756
  return this.getSelection() !== null;
5724
5757
  }
5758
+ insertChunkGroup(index, text, fg2, bg2, attributes) {
5759
+ const textBytes = this.lib.encoder.encode(text);
5760
+ this.insertEncodedChunkGroup(index, textBytes, fg2, bg2, attributes);
5761
+ }
5762
+ insertEncodedChunkGroup(index, textBytes, fg2, bg2, attributes) {
5763
+ this._length = this.lib.textBufferInsertChunkGroup(this.bufferPtr, index, textBytes, fg2 || null, bg2 || null, attributes ?? null);
5764
+ this._lineInfo = undefined;
5765
+ }
5766
+ removeChunkGroup(index) {
5767
+ this._length = this.lib.textBufferRemoveChunkGroup(this.bufferPtr, index);
5768
+ this._lineInfo = undefined;
5769
+ }
5770
+ replaceChunkGroup(index, text, fg2, bg2, attributes) {
5771
+ const textBytes = this.lib.encoder.encode(text);
5772
+ this.replaceEncodedChunkGroup(index, textBytes, fg2, bg2, attributes);
5773
+ }
5774
+ replaceEncodedChunkGroup(index, textBytes, fg2, bg2, attributes) {
5775
+ this._length = this.lib.textBufferReplaceChunkGroup(this.bufferPtr, index, textBytes, fg2 || null, bg2 || null, attributes ?? null);
5776
+ this._lineInfo = undefined;
5777
+ }
5778
+ get chunkGroupCount() {
5779
+ return this.lib.textBufferGetChunkGroupCount(this.bufferPtr);
5780
+ }
5725
5781
  destroy() {
5726
5782
  this.lib.destroyTextBuffer(this.bufferPtr);
5727
5783
  }
@@ -5817,12 +5873,30 @@ function isRenderable(obj) {
5817
5873
  return !!obj?.[BrandedRenderable];
5818
5874
  }
5819
5875
 
5820
- class Renderable extends EventEmitter3 {
5876
+ class BaseRenderable extends EventEmitter3 {
5821
5877
  [BrandedRenderable] = true;
5822
5878
  static renderableNumber = 1;
5823
- static renderablesByNumber = new Map;
5824
5879
  id;
5825
5880
  num;
5881
+ _dirty = false;
5882
+ constructor(options) {
5883
+ super();
5884
+ this.num = BaseRenderable.renderableNumber++;
5885
+ this.id = options.id ?? `renderable-${this.num}`;
5886
+ }
5887
+ get isDirty() {
5888
+ return this._dirty;
5889
+ }
5890
+ markClean() {
5891
+ this._dirty = false;
5892
+ }
5893
+ markDirty() {
5894
+ this._dirty = true;
5895
+ }
5896
+ }
5897
+
5898
+ class Renderable extends BaseRenderable {
5899
+ static renderablesByNumber = new Map;
5826
5900
  _isDestroyed = false;
5827
5901
  _ctx;
5828
5902
  _translateX = 0;
@@ -5838,7 +5912,6 @@ class Renderable extends EventEmitter3 {
5838
5912
  selectable = false;
5839
5913
  buffered;
5840
5914
  frameBuffer = null;
5841
- _dirty = false;
5842
5915
  focusable = false;
5843
5916
  _focused = false;
5844
5917
  keyHandler = getKeyHandler();
@@ -5862,9 +5935,7 @@ class Renderable extends EventEmitter3 {
5862
5935
  renderBefore;
5863
5936
  renderAfter;
5864
5937
  constructor(ctx, options) {
5865
- super();
5866
- this.num = Renderable.renderableNumber++;
5867
- this.id = options.id ?? `renderable-${this.num}`;
5938
+ super(options);
5868
5939
  this._ctx = ctx;
5869
5940
  Renderable.renderablesByNumber.set(this.num, this);
5870
5941
  validateOptions(this.id, options);
@@ -5974,9 +6045,6 @@ class Renderable extends EventEmitter3 {
5974
6045
  this._liveCount += delta;
5975
6046
  this.parent?.propagateLiveCount(delta);
5976
6047
  }
5977
- get isDirty() {
5978
- return this._dirty;
5979
- }
5980
6048
  findDescendantById(id) {
5981
6049
  for (const child of this.renderableArray) {
5982
6050
  if (child.id === id)
@@ -5987,11 +6055,8 @@ class Renderable extends EventEmitter3 {
5987
6055
  }
5988
6056
  return;
5989
6057
  }
5990
- markClean() {
5991
- this._dirty = false;
5992
- }
5993
6058
  requestRender() {
5994
- this._dirty = true;
6059
+ this.markDirty();
5995
6060
  this._ctx.requestRender();
5996
6061
  }
5997
6062
  get translateX() {
@@ -6597,6 +6662,9 @@ class Renderable extends EventEmitter3 {
6597
6662
  if (!anchor) {
6598
6663
  return this.add(renderable);
6599
6664
  }
6665
+ if (!isRenderable(anchor)) {
6666
+ throw new Error("Anchor must be a Renderable");
6667
+ }
6600
6668
  if (!this.renderableMap.has(anchor.id)) {
6601
6669
  throw new Error("Anchor does not exist");
6602
6670
  }
@@ -6714,10 +6782,10 @@ class Renderable extends EventEmitter3 {
6714
6782
  this.layoutNode.destroy();
6715
6783
  }
6716
6784
  destroyRecursively() {
6717
- this.destroy();
6718
6785
  for (const child of this.renderableArray) {
6719
6786
  child.destroyRecursively();
6720
6787
  }
6788
+ this.destroy();
6721
6789
  }
6722
6790
  destroySelf() {}
6723
6791
  processMouseEvent(event) {
@@ -7976,6 +8044,7 @@ Error details:
7976
8044
  global.requestAnimationFrame = (callback) => {
7977
8045
  const id = CliRenderer.animationFrameId++;
7978
8046
  this.animationRequest.set(id, callback);
8047
+ this.requestLive();
7979
8048
  return id;
7980
8049
  };
7981
8050
  global.cancelAnimationFrame = (handle) => {
@@ -8586,7 +8655,10 @@ Error details:
8586
8655
  const frameRequests = Array.from(this.animationRequest.values());
8587
8656
  this.animationRequest.clear();
8588
8657
  const animationRequestStart = performance.now();
8589
- frameRequests.forEach((callback) => callback(deltaTime));
8658
+ frameRequests.forEach((callback) => {
8659
+ callback(deltaTime);
8660
+ this.dropLive();
8661
+ });
8590
8662
  const animationRequestEnd = performance.now();
8591
8663
  const animationRequestTime = animationRequestEnd - animationRequestStart;
8592
8664
  const start = performance.now();
@@ -8771,7 +8843,7 @@ Error details:
8771
8843
  }
8772
8844
  }
8773
8845
 
8774
- export { __toESM, __commonJS, __export, __require, Edge, Gutter, MeasureMode, BorderChars, getBorderFromSides, getBorderSides, borderCharsToArray, BorderCharArrays, TrackedNode, createTrackedNode, nonAlphanumericKeys, parseKeypress, KeyHandler, getKeyHandler, RGBA, hexToRgb, rgbToHex, hsvToRgb, parseColor, fonts, measureText, getCharacterPositions, coordinateToCharacterIndex, renderFontToFrameBuffer, TextAttributes, DebugOverlayCorner, createTextAttributes, StyledText, stringToStyledText, black, red, green, yellow, blue, magenta, cyan, white, brightBlack, brightRed, brightGreen, brightYellow, brightBlue, brightMagenta, brightCyan, brightWhite, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, bold, italic, underline, strikethrough, dim, reverse, blink, fg, bg, tn, t, SyntaxStyle, hastToStyledText, parseAlign, parseBoxSizing, parseDimension, parseDirection, parseDisplay, parseEdge, parseFlexDirection, parseGutter, parseJustify, parseLogLevel, parseMeasureMode, parseOverflow, parsePositionType, parseUnit, parseWrap, MouseParser, Selection, convertGlobalToLocalSelection, ASCIIFontSelectionHelper, TextBuffer, LogLevel2 as LogLevel, setRenderLibPath, resolveRenderLib, OptimizedBuffer, h, isVNode, maybeMakeRenderable, wrapWithDelegates, instantiate, delegate, LayoutEvents, RenderableEvents, isValidPercentage, isMarginType, isPaddingType, isPositionType, isPositionTypeType, isOverflowType, isDimensionType, isFlexBasisType, isSizeType, isRenderable, Renderable, RootRenderable, capture, ConsolePosition, TerminalConsole, MouseEvent, MouseButton, createCliRenderer, CliRenderEvents, CliRenderer };
8846
+ export { __toESM, __commonJS, __export, __require, Edge, Gutter, MeasureMode, BorderChars, getBorderFromSides, getBorderSides, borderCharsToArray, BorderCharArrays, TrackedNode, createTrackedNode, nonAlphanumericKeys, parseKeypress, KeyHandler, getKeyHandler, RGBA, hexToRgb, rgbToHex, hsvToRgb, parseColor, fonts, measureText, getCharacterPositions, coordinateToCharacterIndex, renderFontToFrameBuffer, TextAttributes, DebugOverlayCorner, createTextAttributes, isStyledText, StyledText, stringToStyledText, black, red, green, yellow, blue, magenta, cyan, white, brightBlack, brightRed, brightGreen, brightYellow, brightBlue, brightMagenta, brightCyan, brightWhite, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, bold, italic, underline, strikethrough, dim, reverse, blink, fg, bg, t, SyntaxStyle, hastToStyledText, parseAlign, parseBoxSizing, parseDimension, parseDirection, parseDisplay, parseEdge, parseFlexDirection, parseGutter, parseJustify, parseLogLevel, parseMeasureMode, parseOverflow, parsePositionType, parseUnit, parseWrap, MouseParser, Selection, convertGlobalToLocalSelection, ASCIIFontSelectionHelper, TextBuffer, LogLevel2 as LogLevel, setRenderLibPath, resolveRenderLib, OptimizedBuffer, h, isVNode, maybeMakeRenderable, wrapWithDelegates, instantiate, delegate, LayoutEvents, RenderableEvents, isValidPercentage, isMarginType, isPaddingType, isPositionType, isPositionTypeType, isOverflowType, isDimensionType, isFlexBasisType, isSizeType, isRenderable, BaseRenderable, Renderable, RootRenderable, capture, ConsolePosition, TerminalConsole, MouseEvent, MouseButton, createCliRenderer, CliRenderEvents, CliRenderer };
8775
8847
 
8776
- //# debugId=5CD4CD088CC2988464756E2164756E21
8777
- //# sourceMappingURL=index-grak7z0n.js.map
8848
+ //# debugId=8BB772CB4E9B00D664756E2164756E21
8849
+ //# sourceMappingURL=index-23dkhv32.js.map