@cascadetui/core 0.1.7 → 0.1.9
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-9j6zba34.js} +104 -39
- package/{index-r7vqrd61.js.map → index-9j6zba34.js.map} +3 -3
- package/index.js +1 -1
- package/lib/object-pool.d.ts +55 -0
- package/package.json +7 -7
- package/renderer.d.ts +21 -0
- package/testing.js +1 -1
package/3d.js
CHANGED
|
@@ -16569,6 +16569,11 @@ class CliRenderer extends EventEmitter9 {
|
|
|
16569
16569
|
frameCount = 0;
|
|
16570
16570
|
lastFpsTime = 0;
|
|
16571
16571
|
currentFps = 0;
|
|
16572
|
+
fpsCache = new Map;
|
|
16573
|
+
frameDeltas = [];
|
|
16574
|
+
MAX_DELTA_SAMPLES = 10;
|
|
16575
|
+
lastHitGridCheck = 0;
|
|
16576
|
+
HIT_GRID_CHECK_INTERVAL = 16;
|
|
16572
16577
|
targetFrameTime = 1000 / this.targetFps;
|
|
16573
16578
|
minTargetFrameTime = 1000 / this.maxFps;
|
|
16574
16579
|
immediateRerenderRequested = false;
|
|
@@ -16786,12 +16791,12 @@ Captured output:
|
|
|
16786
16791
|
event.preventDefault();
|
|
16787
16792
|
return;
|
|
16788
16793
|
}
|
|
16789
|
-
|
|
16790
|
-
|
|
16791
|
-
|
|
16792
|
-
|
|
16793
|
-
|
|
16794
|
-
|
|
16794
|
+
if (this.exitOnCtrlC) {
|
|
16795
|
+
process.nextTick(() => {
|
|
16796
|
+
this.destroy();
|
|
16797
|
+
});
|
|
16798
|
+
return;
|
|
16799
|
+
}
|
|
16795
16800
|
}
|
|
16796
16801
|
});
|
|
16797
16802
|
this.addExitListeners();
|
|
@@ -17291,17 +17296,19 @@ Captured output:
|
|
|
17291
17296
|
mouseEvent.y -= this.renderOffset;
|
|
17292
17297
|
}
|
|
17293
17298
|
const clickCount = this.resolveClickCount(mouseEvent);
|
|
17294
|
-
const mouseEventWithClickCount = { ...mouseEvent, clickCount };
|
|
17295
|
-
this.
|
|
17296
|
-
|
|
17297
|
-
|
|
17298
|
-
|
|
17299
|
-
|
|
17300
|
-
|
|
17301
|
-
|
|
17302
|
-
|
|
17303
|
-
|
|
17304
|
-
|
|
17299
|
+
const mouseEventWithClickCount = mouseEvent.type === "down" ? { ...mouseEvent, clickCount } : mouseEvent;
|
|
17300
|
+
if (this.trace?.enabled || this.gatherStats) {
|
|
17301
|
+
this.recordRuntimeEvent("input:mouse", {
|
|
17302
|
+
type: mouseEvent.type,
|
|
17303
|
+
x: mouseEvent.x,
|
|
17304
|
+
y: mouseEvent.y,
|
|
17305
|
+
button: mouseEvent.button,
|
|
17306
|
+
clickCount,
|
|
17307
|
+
ctrl: mouseEvent.modifiers.ctrl,
|
|
17308
|
+
alt: mouseEvent.modifiers.alt,
|
|
17309
|
+
shift: mouseEvent.modifiers.shift
|
|
17310
|
+
});
|
|
17311
|
+
}
|
|
17305
17312
|
this._latestPointer.x = mouseEvent.x;
|
|
17306
17313
|
this._latestPointer.y = mouseEvent.y;
|
|
17307
17314
|
this._hasPointer = true;
|
|
@@ -17694,18 +17701,7 @@ Captured output:
|
|
|
17694
17701
|
return this.clipboard.copyToBestAvailable(text, target);
|
|
17695
17702
|
}
|
|
17696
17703
|
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;
|
|
17704
|
+
return this.copySelection();
|
|
17709
17705
|
}
|
|
17710
17706
|
clearClipboardOSC52(target) {
|
|
17711
17707
|
return this.clipboard.clearClipboardOSC52(target);
|
|
@@ -17764,6 +17760,58 @@ Captured output:
|
|
|
17764
17760
|
setFrameCallback(callback) {
|
|
17765
17761
|
this.frameCallbacks.push(callback);
|
|
17766
17762
|
}
|
|
17763
|
+
calculateFPS(frameCount, elapsedMs) {
|
|
17764
|
+
if (elapsedMs === 0)
|
|
17765
|
+
return 0;
|
|
17766
|
+
const key = `${Math.floor(frameCount / 10)}-${Math.floor(elapsedMs / 100)}`;
|
|
17767
|
+
if (this.fpsCache.has(key)) {
|
|
17768
|
+
return this.fpsCache.get(key);
|
|
17769
|
+
}
|
|
17770
|
+
const fps = frameCount * 1000 / elapsedMs;
|
|
17771
|
+
this.fpsCache.set(key, fps);
|
|
17772
|
+
if (this.fpsCache.size > 50) {
|
|
17773
|
+
const firstKey = this.fpsCache.keys().next().value;
|
|
17774
|
+
if (firstKey !== undefined) {
|
|
17775
|
+
this.fpsCache.delete(firstKey);
|
|
17776
|
+
}
|
|
17777
|
+
}
|
|
17778
|
+
return fps;
|
|
17779
|
+
}
|
|
17780
|
+
calculateDeltaTime(elapsed) {
|
|
17781
|
+
if (this.lastTime === 0) {
|
|
17782
|
+
this.frameDeltas = [];
|
|
17783
|
+
return Math.min(elapsed, 50);
|
|
17784
|
+
}
|
|
17785
|
+
this.frameDeltas.push(elapsed);
|
|
17786
|
+
if (this.frameDeltas.length > this.MAX_DELTA_SAMPLES) {
|
|
17787
|
+
this.frameDeltas.shift();
|
|
17788
|
+
}
|
|
17789
|
+
const avgDelta = this.frameDeltas.reduce((a, b) => a + b, 0) / this.frameDeltas.length;
|
|
17790
|
+
return Math.min(avgDelta, 50);
|
|
17791
|
+
}
|
|
17792
|
+
processAnimationCallbacks(callbacks, deltaTime) {
|
|
17793
|
+
if (callbacks.length === 0)
|
|
17794
|
+
return;
|
|
17795
|
+
const batchSize = 10;
|
|
17796
|
+
for (let i = 0;i < callbacks.length; i += batchSize) {
|
|
17797
|
+
const batch = callbacks.slice(i, i + batchSize);
|
|
17798
|
+
for (const callback of batch) {
|
|
17799
|
+
try {
|
|
17800
|
+
callback(deltaTime);
|
|
17801
|
+
this.dropLive();
|
|
17802
|
+
} catch (error) {
|
|
17803
|
+
console.error("Error in animation callback:", error);
|
|
17804
|
+
}
|
|
17805
|
+
}
|
|
17806
|
+
}
|
|
17807
|
+
}
|
|
17808
|
+
shouldCheckHitGridDirty(now) {
|
|
17809
|
+
if (now - this.lastHitGridCheck < this.HIT_GRID_CHECK_INTERVAL) {
|
|
17810
|
+
return false;
|
|
17811
|
+
}
|
|
17812
|
+
this.lastHitGridCheck = now;
|
|
17813
|
+
return true;
|
|
17814
|
+
}
|
|
17767
17815
|
removeFrameCallback(callback) {
|
|
17768
17816
|
this.frameCallbacks = this.frameCallbacks.filter((cb) => cb !== callback);
|
|
17769
17817
|
}
|
|
@@ -17965,11 +18013,11 @@ Captured output:
|
|
|
17965
18013
|
try {
|
|
17966
18014
|
const now = Date.now();
|
|
17967
18015
|
const elapsed = now - this.lastTime;
|
|
17968
|
-
const deltaTime = elapsed;
|
|
18016
|
+
const deltaTime = this.calculateDeltaTime(elapsed);
|
|
17969
18017
|
this.lastTime = now;
|
|
17970
18018
|
this.frameCount++;
|
|
17971
18019
|
if (now - this.lastFpsTime >= 1000) {
|
|
17972
|
-
this.currentFps = this.frameCount;
|
|
18020
|
+
this.currentFps = this.calculateFPS(this.frameCount, now - this.lastFpsTime);
|
|
17973
18021
|
this.frameCount = 0;
|
|
17974
18022
|
this.lastFpsTime = now;
|
|
17975
18023
|
}
|
|
@@ -17981,10 +18029,7 @@ Captured output:
|
|
|
17981
18029
|
const frameRequests = Array.from(this.animationRequest.values());
|
|
17982
18030
|
this.animationRequest.clear();
|
|
17983
18031
|
const animationRequestStart = performance.now();
|
|
17984
|
-
|
|
17985
|
-
callback(deltaTime);
|
|
17986
|
-
this.dropLive();
|
|
17987
|
-
}
|
|
18032
|
+
this.processAnimationCallbacks(frameRequests, deltaTime);
|
|
17988
18033
|
const animationRequestEnd = performance.now();
|
|
17989
18034
|
const animationRequestTime = animationRequestEnd - animationRequestStart;
|
|
17990
18035
|
const start = performance.now();
|
|
@@ -18011,8 +18056,10 @@ Captured output:
|
|
|
18011
18056
|
const nativeStart = traceEnabled ? trace.now() : 0;
|
|
18012
18057
|
this.renderNative();
|
|
18013
18058
|
const nativeMs = traceEnabled ? trace.now() - nativeStart : 0;
|
|
18014
|
-
if (this._useMouse && this.
|
|
18015
|
-
this.
|
|
18059
|
+
if (this._useMouse && this.shouldCheckHitGridDirty(overallStart)) {
|
|
18060
|
+
if (this.lib.getHitGridDirty(this.rendererPtr)) {
|
|
18061
|
+
this.recheckHoverState();
|
|
18062
|
+
}
|
|
18016
18063
|
}
|
|
18017
18064
|
const overallFrameTime = performance.now() - overallStart;
|
|
18018
18065
|
if (traceEnabled) {
|
|
@@ -18104,6 +18151,24 @@ Captured output:
|
|
|
18104
18151
|
getSelectionContainer() {
|
|
18105
18152
|
return this.selectionContainers.length > 0 ? this.selectionContainers[this.selectionContainers.length - 1] : null;
|
|
18106
18153
|
}
|
|
18154
|
+
getSelectedText() {
|
|
18155
|
+
return this.currentSelection?.getSelectedText() ?? null;
|
|
18156
|
+
}
|
|
18157
|
+
copySelection() {
|
|
18158
|
+
if (!this.currentSelection) {
|
|
18159
|
+
return false;
|
|
18160
|
+
}
|
|
18161
|
+
const selectedText = this.currentSelection.getSelectedText();
|
|
18162
|
+
if (!selectedText) {
|
|
18163
|
+
return false;
|
|
18164
|
+
}
|
|
18165
|
+
const success = this.copyToClipboard(selectedText);
|
|
18166
|
+
if (success) {
|
|
18167
|
+
this.clearSelection();
|
|
18168
|
+
this.requestRender();
|
|
18169
|
+
}
|
|
18170
|
+
return success;
|
|
18171
|
+
}
|
|
18107
18172
|
clearSelection() {
|
|
18108
18173
|
if (this.currentSelection) {
|
|
18109
18174
|
for (const renderable of this.currentSelection.touchedRenderables) {
|
|
@@ -18289,5 +18354,5 @@ Captured output:
|
|
|
18289
18354
|
|
|
18290
18355
|
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
18356
|
|
|
18292
|
-
//# debugId=
|
|
18293
|
-
//# sourceMappingURL=index-
|
|
18357
|
+
//# debugId=417D82C6F387312F64756E2164756E21
|
|
18358
|
+
//# sourceMappingURL=index-9j6zba34.js.map
|