@cascadetui/core 0.1.9 → 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/3d.js +1 -1
- package/{index-9j6zba34.js → index-gv8mtakv.js} +172 -5
- package/{index-9j6zba34.js.map → index-gv8mtakv.js.map} +4 -4
- package/index.js +33 -4
- package/index.js.map +3 -3
- package/package.json +7 -7
- package/renderables/TextBufferRenderable.d.ts +6 -0
- package/renderer.d.ts +14 -0
- package/testing.js +1 -1
package/index.js
CHANGED
|
@@ -153,7 +153,7 @@ import {
|
|
|
153
153
|
white,
|
|
154
154
|
wrapWithDelegates,
|
|
155
155
|
yellow
|
|
156
|
-
} from "./index-
|
|
156
|
+
} from "./index-gv8mtakv.js";
|
|
157
157
|
// src/text-buffer-view.ts
|
|
158
158
|
class TextBufferView {
|
|
159
159
|
lib;
|
|
@@ -2764,6 +2764,12 @@ class TextBufferRenderable extends Renderable {
|
|
|
2764
2764
|
_scrollX = 0;
|
|
2765
2765
|
_scrollY = 0;
|
|
2766
2766
|
_truncate = false;
|
|
2767
|
+
_measureCallCount = 0;
|
|
2768
|
+
_lastMeasureReset = 0;
|
|
2769
|
+
static MEASURE_RESET_INTERVAL_MS = 1000;
|
|
2770
|
+
static MAX_MEASURE_CALLS_PER_INTERVAL = 100;
|
|
2771
|
+
_lastYogaMeasureKey = null;
|
|
2772
|
+
_lastYogaMeasureResult = null;
|
|
2767
2773
|
textBuffer;
|
|
2768
2774
|
textBufferView;
|
|
2769
2775
|
_textBufferSyntaxStyle;
|
|
@@ -3041,6 +3047,19 @@ class TextBufferRenderable extends Renderable {
|
|
|
3041
3047
|
}
|
|
3042
3048
|
setupMeasureFunc() {
|
|
3043
3049
|
const measureFunc = (width, widthMode, height, heightMode) => {
|
|
3050
|
+
const now = Date.now();
|
|
3051
|
+
if (now - this._lastMeasureReset > TextBufferRenderable.MEASURE_RESET_INTERVAL_MS) {
|
|
3052
|
+
this._measureCallCount = 0;
|
|
3053
|
+
this._lastMeasureReset = now;
|
|
3054
|
+
}
|
|
3055
|
+
this._measureCallCount++;
|
|
3056
|
+
if (this._measureCallCount > TextBufferRenderable.MAX_MEASURE_CALLS_PER_INTERVAL) {
|
|
3057
|
+
console.warn(`[Cascade] Measure loop detected on ${this.id}, returning cached dimensions`);
|
|
3058
|
+
if (this._lastYogaMeasureResult) {
|
|
3059
|
+
return this._lastYogaMeasureResult;
|
|
3060
|
+
}
|
|
3061
|
+
return { width: 1, height: 1 };
|
|
3062
|
+
}
|
|
3044
3063
|
let effectiveWidth;
|
|
3045
3064
|
if (widthMode === MeasureMode.Undefined || isNaN(width)) {
|
|
3046
3065
|
effectiveWidth = 0;
|
|
@@ -3048,19 +3067,29 @@ class TextBufferRenderable extends Renderable {
|
|
|
3048
3067
|
effectiveWidth = width;
|
|
3049
3068
|
}
|
|
3050
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
|
+
}
|
|
3051
3074
|
const measureResult = this.textBufferView.measureForDimensions(Math.floor(effectiveWidth), Math.floor(effectiveHeight));
|
|
3052
3075
|
const measuredWidth = measureResult ? Math.max(1, measureResult.maxWidth) : 1;
|
|
3053
3076
|
const measuredHeight = measureResult ? Math.max(1, measureResult.lineCount) : 1;
|
|
3054
3077
|
if (widthMode === MeasureMode.AtMost && this._positionType !== "absolute") {
|
|
3055
|
-
|
|
3078
|
+
const result2 = {
|
|
3056
3079
|
width: Math.min(effectiveWidth, measuredWidth),
|
|
3057
3080
|
height: Math.min(effectiveHeight, measuredHeight)
|
|
3058
3081
|
};
|
|
3082
|
+
this._lastYogaMeasureKey = yogaKey;
|
|
3083
|
+
this._lastYogaMeasureResult = result2;
|
|
3084
|
+
return result2;
|
|
3059
3085
|
}
|
|
3060
|
-
|
|
3086
|
+
const result = {
|
|
3061
3087
|
width: measuredWidth,
|
|
3062
3088
|
height: measuredHeight
|
|
3063
3089
|
};
|
|
3090
|
+
this._lastYogaMeasureKey = yogaKey;
|
|
3091
|
+
this._lastYogaMeasureResult = result;
|
|
3092
|
+
return result;
|
|
3064
3093
|
};
|
|
3065
3094
|
this.yogaNode.setMeasureFunc(measureFunc);
|
|
3066
3095
|
}
|
|
@@ -12425,5 +12454,5 @@ export {
|
|
|
12425
12454
|
ASCIIFont
|
|
12426
12455
|
};
|
|
12427
12456
|
|
|
12428
|
-
//# debugId=
|
|
12457
|
+
//# debugId=0313087C41FF161A64756E2164756E21
|
|
12429
12458
|
//# sourceMappingURL=index.js.map
|