@opentui/core 0.1.5 → 0.1.6

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
@@ -33976,6 +33976,18 @@ function parseJustify(value) {
33976
33976
  return Justify.FlexStart;
33977
33977
  }
33978
33978
  }
33979
+ function parsePositionType(value) {
33980
+ switch (value.toLowerCase()) {
33981
+ case "static":
33982
+ return PositionType.Static;
33983
+ case "relative":
33984
+ return PositionType.Relative;
33985
+ case "absolute":
33986
+ return PositionType.Absolute;
33987
+ default:
33988
+ return PositionType.Static;
33989
+ }
33990
+ }
33979
33991
 
33980
33992
  // src/Renderable.ts
33981
33993
  var renderableNumber = 1;
@@ -34286,8 +34298,8 @@ class Renderable extends EventEmitter3 {
34286
34298
  this.layoutNode.setHeight(options.height);
34287
34299
  }
34288
34300
  this._positionType = options.position ?? "relative";
34289
- if (this._positionType === "absolute") {
34290
- node.setPositionType(PositionType.Absolute);
34301
+ if (this._positionType !== "relative") {
34302
+ node.setPositionType(parsePositionType(this._positionType));
34291
34303
  }
34292
34304
  const hasPositionProps = options.top !== undefined || options.right !== undefined || options.bottom !== undefined || options.left !== undefined;
34293
34305
  if (hasPositionProps) {
@@ -34346,6 +34358,14 @@ class Renderable extends EventEmitter3 {
34346
34358
  node.setPadding(Edge2.Left, options.paddingLeft);
34347
34359
  }
34348
34360
  }
34361
+ set position(positionType) {
34362
+ if (this._positionType === positionType)
34363
+ return;
34364
+ this._positionType = positionType;
34365
+ this.layoutNode.yogaNode.setPositionType(parsePositionType(positionType));
34366
+ this.needsUpdate();
34367
+ this._yogaPerformancePositionUpdated = true;
34368
+ }
34349
34369
  setPosition(position) {
34350
34370
  this._position = { ...this._position, ...position };
34351
34371
  this.updateYogaPosition(position);
@@ -35553,6 +35573,77 @@ var BorderCharArrays = {
35553
35573
  rounded: borderCharsToArray(BorderChars.rounded),
35554
35574
  heavy: borderCharsToArray(BorderChars.heavy)
35555
35575
  };
35576
+ // src/lib/styled-text.ts
35577
+ var textEncoder = new TextEncoder;
35578
+
35579
+ class StyledText {
35580
+ chunks;
35581
+ _plainText = "";
35582
+ constructor(chunks) {
35583
+ this.chunks = chunks;
35584
+ for (let i = 0;i < chunks.length; i++) {
35585
+ this._plainText += chunks[i].plainText;
35586
+ }
35587
+ }
35588
+ toString() {
35589
+ return this._plainText;
35590
+ }
35591
+ _chunksToPlainText() {
35592
+ this._plainText = "";
35593
+ for (const chunk of this.chunks) {
35594
+ this._plainText += chunk.plainText;
35595
+ }
35596
+ }
35597
+ insert(chunk, index) {
35598
+ const originalLength = this.chunks.length;
35599
+ if (index === undefined) {
35600
+ this.chunks.push(chunk);
35601
+ } else {
35602
+ this.chunks.splice(index, 0, chunk);
35603
+ }
35604
+ if (index === undefined || index === originalLength) {
35605
+ this._plainText += chunk.plainText;
35606
+ } else {
35607
+ this._chunksToPlainText();
35608
+ }
35609
+ }
35610
+ remove(chunk) {
35611
+ const originalLength = this.chunks.length;
35612
+ const index = this.chunks.indexOf(chunk);
35613
+ if (index === -1)
35614
+ return;
35615
+ this.chunks.splice(index, 1);
35616
+ if (index === originalLength - 1) {
35617
+ this._plainText = this._plainText.slice(0, this._plainText.length - chunk.plainText.length);
35618
+ } else {
35619
+ this._chunksToPlainText();
35620
+ }
35621
+ }
35622
+ replace(chunk, oldChunk) {
35623
+ const index = this.chunks.indexOf(oldChunk);
35624
+ if (index === -1)
35625
+ return;
35626
+ this.chunks.splice(index, 1, chunk);
35627
+ if (index === this.chunks.length - 1) {
35628
+ this._plainText = this._plainText.slice(0, this._plainText.length - oldChunk.plainText.length) + chunk.plainText;
35629
+ } else {
35630
+ this._chunksToPlainText();
35631
+ }
35632
+ }
35633
+ }
35634
+ function stringToStyledText(content) {
35635
+ const textEncoder2 = new TextEncoder;
35636
+ const chunk = {
35637
+ __isChunk: true,
35638
+ text: textEncoder2.encode(content),
35639
+ plainText: content
35640
+ };
35641
+ return new StyledText([chunk]);
35642
+ }
35643
+ var templateCache = new WeakMap;
35644
+
35645
+ // src/lib/hast-styled-text.ts
35646
+ var textEncoder2 = new TextEncoder;
35556
35647
  // src/buffer.ts
35557
35648
  var fbIdCounter = 0;
35558
35649
  function isRGBAWithAlpha(color) {
@@ -35933,35 +36024,6 @@ class TimelineEngine {
35933
36024
  }
35934
36025
  }
35935
36026
  var engine = new TimelineEngine;
35936
- // src/lib/styled-text.ts
35937
- var textEncoder = new TextEncoder;
35938
-
35939
- class StyledText {
35940
- chunks;
35941
- _length;
35942
- _plainText;
35943
- constructor(chunks, length, plainText) {
35944
- this.chunks = chunks;
35945
- this._length = length;
35946
- this._plainText = plainText;
35947
- }
35948
- toString() {
35949
- return this._plainText;
35950
- }
35951
- get length() {
35952
- return this._length;
35953
- }
35954
- }
35955
- function stringToStyledText(content) {
35956
- const textEncoder2 = new TextEncoder;
35957
- const chunk = {
35958
- __isChunk: true,
35959
- text: textEncoder2.encode(content),
35960
- plainText: content
35961
- };
35962
- return new StyledText([chunk], content.length, content);
35963
- }
35964
- var templateCache = new WeakMap;
35965
36027
  // src/lib/selection.ts
35966
36028
  class Selection {
35967
36029
  _anchor;
@@ -37866,8 +37928,6 @@ class TextRenderable extends Renderable {
37866
37928
  set content(value) {
37867
37929
  this._text = typeof value === "string" ? stringToStyledText(value) : value;
37868
37930
  this.updateTextInfo();
37869
- this.setupMeasureFunc();
37870
- this.needsUpdate();
37871
37931
  }
37872
37932
  get fg() {
37873
37933
  return this._defaultFg;
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 opentui
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/Renderable.d.ts CHANGED
@@ -126,6 +126,7 @@ export declare abstract class Renderable extends EventEmitter {
126
126
  private ensureZIndexSorted;
127
127
  private setupYogaProperties;
128
128
  private setupMarginAndPadding;
129
+ set position(positionType: PositionTypeString);
129
130
  setPosition(position: Position): void;
130
131
  private updateYogaPosition;
131
132
  set flexGrow(grow: number);
package/index.d.ts CHANGED
@@ -12,3 +12,4 @@ export * from "./lib/selection";
12
12
  export * from "./renderer";
13
13
  export * from "./renderables";
14
14
  export * from "./zig";
15
+ export * from "./console";