@cascadetui/core 0.1.8 → 0.1.10
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-r7vqrd61.js → index-2pvbxs43.js} +146 -39
- package/{index-r7vqrd61.js.map → index-2pvbxs43.js.map} +3 -3
- package/index.js +19 -2
- package/index.js.map +3 -3
- package/lib/object-pool.d.ts +55 -0
- package/package.json +7 -7
- package/renderables/TextBufferRenderable.d.ts +4 -0
- package/renderer.d.ts +27 -0
- package/testing.js +1 -1
package/3d.js
CHANGED
|
@@ -16537,6 +16537,8 @@ class CliRenderer extends EventEmitter9 {
|
|
|
16537
16537
|
_isDestroyed = false;
|
|
16538
16538
|
_destroyPending = false;
|
|
16539
16539
|
_destroyFinalized = false;
|
|
16540
|
+
destroyTimeoutId = null;
|
|
16541
|
+
destroyTimeoutMs = 100;
|
|
16540
16542
|
nextRenderBuffer;
|
|
16541
16543
|
currentRenderBuffer;
|
|
16542
16544
|
_isRunning = false;
|
|
@@ -16569,10 +16571,19 @@ class CliRenderer extends EventEmitter9 {
|
|
|
16569
16571
|
frameCount = 0;
|
|
16570
16572
|
lastFpsTime = 0;
|
|
16571
16573
|
currentFps = 0;
|
|
16574
|
+
fpsCache = new Map;
|
|
16575
|
+
frameDeltas = [];
|
|
16576
|
+
MAX_DELTA_SAMPLES = 10;
|
|
16577
|
+
lastHitGridCheck = 0;
|
|
16578
|
+
HIT_GRID_CHECK_INTERVAL = 16;
|
|
16572
16579
|
targetFrameTime = 1000 / this.targetFps;
|
|
16573
16580
|
minTargetFrameTime = 1000 / this.maxFps;
|
|
16574
16581
|
immediateRerenderRequested = false;
|
|
16575
16582
|
updateScheduled = false;
|
|
16583
|
+
consecutiveImmediateRerenders = 0;
|
|
16584
|
+
lastImmediateRerenderTime = 0;
|
|
16585
|
+
maxConsecutiveImmediateRerenders = 10;
|
|
16586
|
+
immediateRerenderResetMs = 1000;
|
|
16576
16587
|
liveRequestCounter = 0;
|
|
16577
16588
|
_controlState = "idle" /* IDLE */;
|
|
16578
16589
|
frameCallbacks = [];
|
|
@@ -16786,12 +16797,12 @@ Captured output:
|
|
|
16786
16797
|
event.preventDefault();
|
|
16787
16798
|
return;
|
|
16788
16799
|
}
|
|
16789
|
-
|
|
16790
|
-
|
|
16791
|
-
|
|
16792
|
-
|
|
16793
|
-
|
|
16794
|
-
|
|
16800
|
+
if (this.exitOnCtrlC) {
|
|
16801
|
+
process.nextTick(() => {
|
|
16802
|
+
this.destroy();
|
|
16803
|
+
});
|
|
16804
|
+
return;
|
|
16805
|
+
}
|
|
16795
16806
|
}
|
|
16796
16807
|
});
|
|
16797
16808
|
this.addExitListeners();
|
|
@@ -17291,17 +17302,19 @@ Captured output:
|
|
|
17291
17302
|
mouseEvent.y -= this.renderOffset;
|
|
17292
17303
|
}
|
|
17293
17304
|
const clickCount = this.resolveClickCount(mouseEvent);
|
|
17294
|
-
const mouseEventWithClickCount = { ...mouseEvent, clickCount };
|
|
17295
|
-
this.
|
|
17296
|
-
|
|
17297
|
-
|
|
17298
|
-
|
|
17299
|
-
|
|
17300
|
-
|
|
17301
|
-
|
|
17302
|
-
|
|
17303
|
-
|
|
17304
|
-
|
|
17305
|
+
const mouseEventWithClickCount = mouseEvent.type === "down" ? { ...mouseEvent, clickCount } : mouseEvent;
|
|
17306
|
+
if (this.trace?.enabled || this.gatherStats) {
|
|
17307
|
+
this.recordRuntimeEvent("input:mouse", {
|
|
17308
|
+
type: mouseEvent.type,
|
|
17309
|
+
x: mouseEvent.x,
|
|
17310
|
+
y: mouseEvent.y,
|
|
17311
|
+
button: mouseEvent.button,
|
|
17312
|
+
clickCount,
|
|
17313
|
+
ctrl: mouseEvent.modifiers.ctrl,
|
|
17314
|
+
alt: mouseEvent.modifiers.alt,
|
|
17315
|
+
shift: mouseEvent.modifiers.shift
|
|
17316
|
+
});
|
|
17317
|
+
}
|
|
17305
17318
|
this._latestPointer.x = mouseEvent.x;
|
|
17306
17319
|
this._latestPointer.y = mouseEvent.y;
|
|
17307
17320
|
this._hasPointer = true;
|
|
@@ -17694,18 +17707,7 @@ Captured output:
|
|
|
17694
17707
|
return this.clipboard.copyToBestAvailable(text, target);
|
|
17695
17708
|
}
|
|
17696
17709
|
copyActiveSelectionToClipboard() {
|
|
17697
|
-
|
|
17698
|
-
if (!selection2) {
|
|
17699
|
-
return false;
|
|
17700
|
-
}
|
|
17701
|
-
const selectedText = selection2.getSelectedText();
|
|
17702
|
-
if (!selectedText) {
|
|
17703
|
-
return false;
|
|
17704
|
-
}
|
|
17705
|
-
this.copyToClipboard(selectedText);
|
|
17706
|
-
this.clearSelection();
|
|
17707
|
-
this.requestRender();
|
|
17708
|
-
return true;
|
|
17710
|
+
return this.copySelection();
|
|
17709
17711
|
}
|
|
17710
17712
|
clearClipboardOSC52(target) {
|
|
17711
17713
|
return this.clipboard.clearClipboardOSC52(target);
|
|
@@ -17764,6 +17766,58 @@ Captured output:
|
|
|
17764
17766
|
setFrameCallback(callback) {
|
|
17765
17767
|
this.frameCallbacks.push(callback);
|
|
17766
17768
|
}
|
|
17769
|
+
calculateFPS(frameCount, elapsedMs) {
|
|
17770
|
+
if (elapsedMs === 0)
|
|
17771
|
+
return 0;
|
|
17772
|
+
const key = `${Math.floor(frameCount / 10)}-${Math.floor(elapsedMs / 100)}`;
|
|
17773
|
+
if (this.fpsCache.has(key)) {
|
|
17774
|
+
return this.fpsCache.get(key);
|
|
17775
|
+
}
|
|
17776
|
+
const fps = frameCount * 1000 / elapsedMs;
|
|
17777
|
+
this.fpsCache.set(key, fps);
|
|
17778
|
+
if (this.fpsCache.size > 50) {
|
|
17779
|
+
const firstKey = this.fpsCache.keys().next().value;
|
|
17780
|
+
if (firstKey !== undefined) {
|
|
17781
|
+
this.fpsCache.delete(firstKey);
|
|
17782
|
+
}
|
|
17783
|
+
}
|
|
17784
|
+
return fps;
|
|
17785
|
+
}
|
|
17786
|
+
calculateDeltaTime(elapsed) {
|
|
17787
|
+
if (this.lastTime === 0) {
|
|
17788
|
+
this.frameDeltas = [];
|
|
17789
|
+
return Math.min(elapsed, 50);
|
|
17790
|
+
}
|
|
17791
|
+
this.frameDeltas.push(elapsed);
|
|
17792
|
+
if (this.frameDeltas.length > this.MAX_DELTA_SAMPLES) {
|
|
17793
|
+
this.frameDeltas.shift();
|
|
17794
|
+
}
|
|
17795
|
+
const avgDelta = this.frameDeltas.reduce((a, b) => a + b, 0) / this.frameDeltas.length;
|
|
17796
|
+
return Math.min(avgDelta, 50);
|
|
17797
|
+
}
|
|
17798
|
+
processAnimationCallbacks(callbacks, deltaTime) {
|
|
17799
|
+
if (callbacks.length === 0)
|
|
17800
|
+
return;
|
|
17801
|
+
const batchSize = 10;
|
|
17802
|
+
for (let i = 0;i < callbacks.length; i += batchSize) {
|
|
17803
|
+
const batch = callbacks.slice(i, i + batchSize);
|
|
17804
|
+
for (const callback of batch) {
|
|
17805
|
+
try {
|
|
17806
|
+
callback(deltaTime);
|
|
17807
|
+
this.dropLive();
|
|
17808
|
+
} catch (error) {
|
|
17809
|
+
console.error("Error in animation callback:", error);
|
|
17810
|
+
}
|
|
17811
|
+
}
|
|
17812
|
+
}
|
|
17813
|
+
}
|
|
17814
|
+
shouldCheckHitGridDirty(now) {
|
|
17815
|
+
if (now - this.lastHitGridCheck < this.HIT_GRID_CHECK_INTERVAL) {
|
|
17816
|
+
return false;
|
|
17817
|
+
}
|
|
17818
|
+
this.lastHitGridCheck = now;
|
|
17819
|
+
return true;
|
|
17820
|
+
}
|
|
17767
17821
|
removeFrameCallback(callback) {
|
|
17768
17822
|
this.frameCallbacks = this.frameCallbacks.filter((cb) => cb !== callback);
|
|
17769
17823
|
}
|
|
@@ -17877,6 +17931,14 @@ Captured output:
|
|
|
17877
17931
|
this._isDestroyed = true;
|
|
17878
17932
|
this._destroyPending = true;
|
|
17879
17933
|
if (this.rendering) {
|
|
17934
|
+
if (this.destroyTimeoutId === null) {
|
|
17935
|
+
this.destroyTimeoutId = setTimeout(() => {
|
|
17936
|
+
this.destroyTimeoutId = null;
|
|
17937
|
+
if (this._destroyPending && !this._destroyFinalized && !this.renderingNative) {
|
|
17938
|
+
this.finalizeDestroy();
|
|
17939
|
+
}
|
|
17940
|
+
}, this.destroyTimeoutMs);
|
|
17941
|
+
}
|
|
17880
17942
|
return;
|
|
17881
17943
|
}
|
|
17882
17944
|
this.finalizeDestroy();
|
|
@@ -17886,6 +17948,10 @@ Captured output:
|
|
|
17886
17948
|
return;
|
|
17887
17949
|
this._destroyFinalized = true;
|
|
17888
17950
|
this._destroyPending = false;
|
|
17951
|
+
if (this.destroyTimeoutId !== null) {
|
|
17952
|
+
clearTimeout(this.destroyTimeoutId);
|
|
17953
|
+
this.destroyTimeoutId = null;
|
|
17954
|
+
}
|
|
17889
17955
|
process.removeListener("SIGWINCH", this.sigwinchHandler);
|
|
17890
17956
|
process.removeListener("uncaughtException", this.uncaughtExceptionHandler);
|
|
17891
17957
|
process.removeListener("unhandledRejection", this.unhandledRejectionHandler);
|
|
@@ -17916,6 +17982,9 @@ Captured output:
|
|
|
17916
17982
|
this.renderTimeout = null;
|
|
17917
17983
|
}
|
|
17918
17984
|
this._isRunning = false;
|
|
17985
|
+
this.rendering = false;
|
|
17986
|
+
this.updateScheduled = false;
|
|
17987
|
+
this.immediateRerenderRequested = false;
|
|
17919
17988
|
this.waitingForPixelResolution = false;
|
|
17920
17989
|
this.setCapturedRenderable(undefined);
|
|
17921
17990
|
try {
|
|
@@ -17965,11 +18034,11 @@ Captured output:
|
|
|
17965
18034
|
try {
|
|
17966
18035
|
const now = Date.now();
|
|
17967
18036
|
const elapsed = now - this.lastTime;
|
|
17968
|
-
const deltaTime = elapsed;
|
|
18037
|
+
const deltaTime = this.calculateDeltaTime(elapsed);
|
|
17969
18038
|
this.lastTime = now;
|
|
17970
18039
|
this.frameCount++;
|
|
17971
18040
|
if (now - this.lastFpsTime >= 1000) {
|
|
17972
|
-
this.currentFps = this.frameCount;
|
|
18041
|
+
this.currentFps = this.calculateFPS(this.frameCount, now - this.lastFpsTime);
|
|
17973
18042
|
this.frameCount = 0;
|
|
17974
18043
|
this.lastFpsTime = now;
|
|
17975
18044
|
}
|
|
@@ -17981,10 +18050,7 @@ Captured output:
|
|
|
17981
18050
|
const frameRequests = Array.from(this.animationRequest.values());
|
|
17982
18051
|
this.animationRequest.clear();
|
|
17983
18052
|
const animationRequestStart = performance.now();
|
|
17984
|
-
|
|
17985
|
-
callback(deltaTime);
|
|
17986
|
-
this.dropLive();
|
|
17987
|
-
}
|
|
18053
|
+
this.processAnimationCallbacks(frameRequests, deltaTime);
|
|
17988
18054
|
const animationRequestEnd = performance.now();
|
|
17989
18055
|
const animationRequestTime = animationRequestEnd - animationRequestStart;
|
|
17990
18056
|
const start = performance.now();
|
|
@@ -17998,6 +18064,9 @@ Captured output:
|
|
|
17998
18064
|
}
|
|
17999
18065
|
const end = performance.now();
|
|
18000
18066
|
this.renderStats.frameCallbackTime = end - start;
|
|
18067
|
+
if (this._destroyPending) {
|
|
18068
|
+
return;
|
|
18069
|
+
}
|
|
18001
18070
|
const renderTreeStart = traceEnabled ? trace.now() : 0;
|
|
18002
18071
|
this.root.render(this.nextRenderBuffer, deltaTime);
|
|
18003
18072
|
const renderTreeMs = traceEnabled ? trace.now() - renderTreeStart : 0;
|
|
@@ -18011,8 +18080,10 @@ Captured output:
|
|
|
18011
18080
|
const nativeStart = traceEnabled ? trace.now() : 0;
|
|
18012
18081
|
this.renderNative();
|
|
18013
18082
|
const nativeMs = traceEnabled ? trace.now() - nativeStart : 0;
|
|
18014
|
-
if (this._useMouse && this.
|
|
18015
|
-
this.
|
|
18083
|
+
if (this._useMouse && this.shouldCheckHitGridDirty(overallStart)) {
|
|
18084
|
+
if (this.lib.getHitGridDirty(this.rendererPtr)) {
|
|
18085
|
+
this.recheckHoverState();
|
|
18086
|
+
}
|
|
18016
18087
|
}
|
|
18017
18088
|
const overallFrameTime = performance.now() - overallStart;
|
|
18018
18089
|
if (traceEnabled) {
|
|
@@ -18024,6 +18095,24 @@ Captured output:
|
|
|
18024
18095
|
this.collectStatSample(overallFrameTime);
|
|
18025
18096
|
}
|
|
18026
18097
|
if (this._isRunning || this.immediateRerenderRequested) {
|
|
18098
|
+
const now2 = Date.now();
|
|
18099
|
+
if (this.immediateRerenderRequested) {
|
|
18100
|
+
if (now2 - this.lastImmediateRerenderTime > this.immediateRerenderResetMs) {
|
|
18101
|
+
this.consecutiveImmediateRerenders = 0;
|
|
18102
|
+
}
|
|
18103
|
+
this.consecutiveImmediateRerenders++;
|
|
18104
|
+
this.lastImmediateRerenderTime = now2;
|
|
18105
|
+
if (this.consecutiveImmediateRerenders > this.maxConsecutiveImmediateRerenders) {
|
|
18106
|
+
console.warn(`[Cascade] Too many consecutive immediate re-renders (${this.consecutiveImmediateRerenders}), forcing delay`);
|
|
18107
|
+
this.consecutiveImmediateRerenders = 0;
|
|
18108
|
+
this.immediateRerenderRequested = false;
|
|
18109
|
+
this.renderTimeout = setTimeout(() => {
|
|
18110
|
+
this.renderTimeout = null;
|
|
18111
|
+
this.loop();
|
|
18112
|
+
}, 100);
|
|
18113
|
+
return;
|
|
18114
|
+
}
|
|
18115
|
+
}
|
|
18027
18116
|
const targetFrameTime = this.immediateRerenderRequested ? this.minTargetFrameTime : this.targetFrameTime;
|
|
18028
18117
|
const delay = Math.max(1, targetFrameTime - Math.floor(overallFrameTime));
|
|
18029
18118
|
this.immediateRerenderRequested = false;
|
|
@@ -18104,6 +18193,24 @@ Captured output:
|
|
|
18104
18193
|
getSelectionContainer() {
|
|
18105
18194
|
return this.selectionContainers.length > 0 ? this.selectionContainers[this.selectionContainers.length - 1] : null;
|
|
18106
18195
|
}
|
|
18196
|
+
getSelectedText() {
|
|
18197
|
+
return this.currentSelection?.getSelectedText() ?? null;
|
|
18198
|
+
}
|
|
18199
|
+
copySelection() {
|
|
18200
|
+
if (!this.currentSelection) {
|
|
18201
|
+
return false;
|
|
18202
|
+
}
|
|
18203
|
+
const selectedText = this.currentSelection.getSelectedText();
|
|
18204
|
+
if (!selectedText) {
|
|
18205
|
+
return false;
|
|
18206
|
+
}
|
|
18207
|
+
const success = this.copyToClipboard(selectedText);
|
|
18208
|
+
if (success) {
|
|
18209
|
+
this.clearSelection();
|
|
18210
|
+
this.requestRender();
|
|
18211
|
+
}
|
|
18212
|
+
return success;
|
|
18213
|
+
}
|
|
18107
18214
|
clearSelection() {
|
|
18108
18215
|
if (this.currentSelection) {
|
|
18109
18216
|
for (const renderable of this.currentSelection.touchedRenderables) {
|
|
@@ -18289,5 +18396,5 @@ Captured output:
|
|
|
18289
18396
|
|
|
18290
18397
|
export { __toESM, __commonJS, __export, __require, Edge, Gutter, MeasureMode, exports_src, isValidBorderStyle, parseBorderStyle, BorderChars, getBorderFromSides, getBorderSides, borderCharsToArray, BorderCharArrays, nonAlphanumericKeys, parseKeypress, KeyEvent, PasteEvent, KeyHandler, InternalKeyHandler, RGBA, hexToRgb, rgbToHex, hsvToRgb, parseColor, fonts, measureText, getCharacterPositions, coordinateToCharacterIndex, renderFontToFrameBuffer, TextAttributes, ATTRIBUTE_BASE_BITS, ATTRIBUTE_BASE_MASK, getBaseAttributes, DebugOverlayCorner, createTextAttributes, attributesWithLink, getLinkId, visualizeRenderableTree, 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, link, t, hastToStyledText, LinearScrollAccel, MacOSScrollAccel, StdinBuffer, parseAlign, parseAlignItems, parseBoxSizing, parseDimension, parseDirection, parseDisplay, parseEdge, parseFlexDirection, parseGutter, parseJustify, parseLogLevel, parseMeasureMode, parseOverflow, parsePositionType, parseUnit, parseWrap, MouseParser, Selection, convertGlobalToLocalSelection, ASCIIFontSelectionHelper, envRegistry, registerEnvVar, clearEnvCache, generateEnvMarkdown, generateEnvColored, env, treeSitterToTextChunks, treeSitterToStyledText, addDefaultParsers, TreeSitterClient, DataPathsManager, getDataPaths, extToFiletype, pathToFiletype, main, getTreeSitterClient, ExtmarksController, createExtmarksController, TerminalPalette, createTerminalPalette, TextBuffer, SpanInfoStruct, LogLevel2 as LogLevel, setRenderLibPath, resolveRenderLib, OptimizedBuffer, h, isVNode, maybeMakeRenderable, wrapWithDelegates, instantiate, delegate, isValidPercentage, LayoutEvents, RenderableEvents, isRenderable, BaseRenderable, Renderable, RootRenderable, ANSI, defaultKeyAliases, mergeKeyAliases, mergeKeyBindings, getKeyBindingKey, buildKeyBindingsMap, capture, ConsolePosition, TerminalConsole, getObjectsInViewport, buildKittyKeyboardFlags, MouseEvent, MouseButton, createCliRenderer, CliRenderEvents, RendererControlState, CliRenderer };
|
|
18291
18398
|
|
|
18292
|
-
//# debugId=
|
|
18293
|
-
//# sourceMappingURL=index-
|
|
18399
|
+
//# debugId=5A054962FAF3B29C64756E2164756E21
|
|
18400
|
+
//# sourceMappingURL=index-2pvbxs43.js.map
|