@cascadetui/core 0.1.10 → 0.1.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.
package/index.js CHANGED
@@ -153,7 +153,7 @@ import {
153
153
  white,
154
154
  wrapWithDelegates,
155
155
  yellow
156
- } from "./index-2pvbxs43.js";
156
+ } from "./index-gv8mtakv.js";
157
157
  // src/text-buffer-view.ts
158
158
  class TextBufferView {
159
159
  lib;
@@ -2768,6 +2768,8 @@ class TextBufferRenderable extends Renderable {
2768
2768
  _lastMeasureReset = 0;
2769
2769
  static MEASURE_RESET_INTERVAL_MS = 1000;
2770
2770
  static MAX_MEASURE_CALLS_PER_INTERVAL = 100;
2771
+ _lastYogaMeasureKey = null;
2772
+ _lastYogaMeasureResult = null;
2771
2773
  textBuffer;
2772
2774
  textBufferView;
2773
2775
  _textBufferSyntaxStyle;
@@ -3053,10 +3055,10 @@ class TextBufferRenderable extends Renderable {
3053
3055
  this._measureCallCount++;
3054
3056
  if (this._measureCallCount > TextBufferRenderable.MAX_MEASURE_CALLS_PER_INTERVAL) {
3055
3057
  console.warn(`[Cascade] Measure loop detected on ${this.id}, returning cached dimensions`);
3056
- return {
3057
- width: Math.max(1, this.width),
3058
- height: Math.max(1, this.height)
3059
- };
3058
+ if (this._lastYogaMeasureResult) {
3059
+ return this._lastYogaMeasureResult;
3060
+ }
3061
+ return { width: 1, height: 1 };
3060
3062
  }
3061
3063
  let effectiveWidth;
3062
3064
  if (widthMode === MeasureMode.Undefined || isNaN(width)) {
@@ -3065,19 +3067,29 @@ class TextBufferRenderable extends Renderable {
3065
3067
  effectiveWidth = width;
3066
3068
  }
3067
3069
  const effectiveHeight = isNaN(height) ? 1 : height;
3070
+ const yogaKey = `${Math.floor(effectiveWidth)}:${widthMode}:${Math.floor(effectiveHeight)}:${heightMode}:${this._wrapMode}`;
3071
+ if (this._lastYogaMeasureKey === yogaKey && this._lastYogaMeasureResult) {
3072
+ return this._lastYogaMeasureResult;
3073
+ }
3068
3074
  const measureResult = this.textBufferView.measureForDimensions(Math.floor(effectiveWidth), Math.floor(effectiveHeight));
3069
3075
  const measuredWidth = measureResult ? Math.max(1, measureResult.maxWidth) : 1;
3070
3076
  const measuredHeight = measureResult ? Math.max(1, measureResult.lineCount) : 1;
3071
3077
  if (widthMode === MeasureMode.AtMost && this._positionType !== "absolute") {
3072
- return {
3078
+ const result2 = {
3073
3079
  width: Math.min(effectiveWidth, measuredWidth),
3074
3080
  height: Math.min(effectiveHeight, measuredHeight)
3075
3081
  };
3082
+ this._lastYogaMeasureKey = yogaKey;
3083
+ this._lastYogaMeasureResult = result2;
3084
+ return result2;
3076
3085
  }
3077
- return {
3086
+ const result = {
3078
3087
  width: measuredWidth,
3079
3088
  height: measuredHeight
3080
3089
  };
3090
+ this._lastYogaMeasureKey = yogaKey;
3091
+ this._lastYogaMeasureResult = result;
3092
+ return result;
3081
3093
  };
3082
3094
  this.yogaNode.setMeasureFunc(measureFunc);
3083
3095
  }
@@ -12442,5 +12454,5 @@ export {
12442
12454
  ASCIIFont
12443
12455
  };
12444
12456
 
12445
- //# debugId=D5FCF66CD1AA657064756E2164756E21
12457
+ //# debugId=0313087C41FF161A64756E2164756E21
12446
12458
  //# sourceMappingURL=index.js.map