@cascadetui/core 0.1.10 → 0.1.12
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-2pvbxs43.js → index-kfh59ta6.js} +162 -12
- package/{index-2pvbxs43.js.map → index-kfh59ta6.js.map} +4 -4
- package/index.js +20 -8
- package/index.js.map +3 -3
- package/package.json +7 -7
- package/renderables/TextBufferRenderable.d.ts +2 -0
- package/renderer.d.ts +15 -0
- package/testing.js +1 -1
package/3d.js
CHANGED
|
@@ -10533,6 +10533,24 @@ registerEnvVar({
|
|
|
10533
10533
|
type: "boolean",
|
|
10534
10534
|
default: false
|
|
10535
10535
|
});
|
|
10536
|
+
registerEnvVar({
|
|
10537
|
+
name: "CASCADE_TRACE_FFI_SLOW_MS",
|
|
10538
|
+
description: "Log slow FFI calls (>= threshold, in ms).",
|
|
10539
|
+
type: "number",
|
|
10540
|
+
default: 0
|
|
10541
|
+
});
|
|
10542
|
+
registerEnvVar({
|
|
10543
|
+
name: "CASCADE_TRACE_FFI_MAX_SAMPLES",
|
|
10544
|
+
description: "Max timing samples to keep per FFI symbol when CASCADE_TRACE_FFI is enabled.",
|
|
10545
|
+
type: "number",
|
|
10546
|
+
default: 5000
|
|
10547
|
+
});
|
|
10548
|
+
registerEnvVar({
|
|
10549
|
+
name: "CASCADE_TRACE_FRAME_BREAKDOWN",
|
|
10550
|
+
description: "Enable detailed frame timing breakdown (yoga, render tree, native, stdout write)",
|
|
10551
|
+
type: "boolean",
|
|
10552
|
+
default: false
|
|
10553
|
+
});
|
|
10536
10554
|
registerEnvVar({
|
|
10537
10555
|
name: "CASCADE_FORCE_WCWIDTH",
|
|
10538
10556
|
description: "Use wcwidth for character width calculations",
|
|
@@ -11553,9 +11571,56 @@ function convertToDebugSymbols(symbols) {
|
|
|
11553
11571
|
if (env.CASCADE_DEBUG_FFI && !globalFFILogWriter) {
|
|
11554
11572
|
const now = new Date;
|
|
11555
11573
|
const timestamp = now.toISOString().replace(/[:.]/g, "-").replace(/T/, "_").split("Z")[0];
|
|
11556
|
-
const logFilePath = `
|
|
11574
|
+
const logFilePath = `ffi_cascade_debug_${timestamp}.log`;
|
|
11557
11575
|
globalFFILogWriter = Bun.file(logFilePath).writer();
|
|
11558
11576
|
}
|
|
11577
|
+
const slowThresholdMs = typeof env.CASCADE_TRACE_FFI_SLOW_MS === "number" ? env.CASCADE_TRACE_FFI_SLOW_MS : 0;
|
|
11578
|
+
const maxSamples = typeof env.CASCADE_TRACE_FFI_MAX_SAMPLES === "number" && env.CASCADE_TRACE_FFI_MAX_SAMPLES > 0 ? env.CASCADE_TRACE_FFI_MAX_SAMPLES : 5000;
|
|
11579
|
+
const formatArg = (arg) => {
|
|
11580
|
+
if (arg === null)
|
|
11581
|
+
return "null";
|
|
11582
|
+
if (arg === undefined)
|
|
11583
|
+
return "undefined";
|
|
11584
|
+
const t2 = typeof arg;
|
|
11585
|
+
if (t2 === "string")
|
|
11586
|
+
return JSON.stringify(arg.length > 200 ? arg.slice(0, 200) + "\u2026" : arg);
|
|
11587
|
+
if (t2 === "number" || t2 === "boolean" || t2 === "bigint")
|
|
11588
|
+
return String(arg);
|
|
11589
|
+
if (arg instanceof Uint8Array)
|
|
11590
|
+
return `Uint8Array(${arg.byteLength})`;
|
|
11591
|
+
if (arg instanceof ArrayBuffer)
|
|
11592
|
+
return `ArrayBuffer(${arg.byteLength})`;
|
|
11593
|
+
if (Array.isArray(arg))
|
|
11594
|
+
return `Array(${arg.length})`;
|
|
11595
|
+
if (t2 === "object") {
|
|
11596
|
+
const ctor = arg?.constructor?.name;
|
|
11597
|
+
if (ctor && ctor !== "Object")
|
|
11598
|
+
return ctor;
|
|
11599
|
+
try {
|
|
11600
|
+
const json = JSON.stringify(arg);
|
|
11601
|
+
if (typeof json === "string")
|
|
11602
|
+
return json.length > 200 ? json.slice(0, 200) + "\u2026" : json;
|
|
11603
|
+
} catch {
|
|
11604
|
+
return "Object";
|
|
11605
|
+
}
|
|
11606
|
+
return "Object";
|
|
11607
|
+
}
|
|
11608
|
+
return String(arg);
|
|
11609
|
+
};
|
|
11610
|
+
let slowWriter = null;
|
|
11611
|
+
const writeSlow = (line) => {
|
|
11612
|
+
if (slowThresholdMs <= 0)
|
|
11613
|
+
return;
|
|
11614
|
+
if (!slowWriter) {
|
|
11615
|
+
const now = new Date;
|
|
11616
|
+
const timestamp = now.toISOString().replace(/[:.]/g, "-").replace(/T/, "_").split("Z")[0];
|
|
11617
|
+
const slowFilePath = `ffi_cascade_slow_${timestamp}.log`;
|
|
11618
|
+
slowWriter = Bun.file(slowFilePath).writer();
|
|
11619
|
+
}
|
|
11620
|
+
const buffer = new TextEncoder().encode(line + `
|
|
11621
|
+
`);
|
|
11622
|
+
slowWriter.write(buffer);
|
|
11623
|
+
};
|
|
11559
11624
|
const debugSymbols = {};
|
|
11560
11625
|
let hasTracing = false;
|
|
11561
11626
|
Object.entries(symbols).forEach(([key, value]) => {
|
|
@@ -11592,7 +11657,16 @@ function convertToDebugSymbols(symbols) {
|
|
|
11592
11657
|
const start = performance.now();
|
|
11593
11658
|
const result = originalFunc(...args);
|
|
11594
11659
|
const end = performance.now();
|
|
11595
|
-
|
|
11660
|
+
const dt = end - start;
|
|
11661
|
+
const timings = globalTraceSymbols[key];
|
|
11662
|
+
timings.push(dt);
|
|
11663
|
+
if (timings.length > maxSamples) {
|
|
11664
|
+
timings.splice(0, timings.length - maxSamples);
|
|
11665
|
+
}
|
|
11666
|
+
if (slowThresholdMs > 0 && dt >= slowThresholdMs) {
|
|
11667
|
+
const argStr = args.map(formatArg).join(", ");
|
|
11668
|
+
writeSlow(`${new Date().toISOString()} ${key} ${dt.toFixed(2)}ms (${argStr})`);
|
|
11669
|
+
}
|
|
11596
11670
|
return result;
|
|
11597
11671
|
};
|
|
11598
11672
|
}
|
|
@@ -11605,6 +11679,9 @@ function convertToDebugSymbols(symbols) {
|
|
|
11605
11679
|
if (globalFFILogWriter) {
|
|
11606
11680
|
globalFFILogWriter.end();
|
|
11607
11681
|
}
|
|
11682
|
+
if (slowWriter) {
|
|
11683
|
+
slowWriter.end();
|
|
11684
|
+
}
|
|
11608
11685
|
} catch (e) {}
|
|
11609
11686
|
if (globalTraceSymbols) {
|
|
11610
11687
|
const allStats = [];
|
|
@@ -11676,7 +11753,7 @@ function convertToDebugSymbols(symbols) {
|
|
|
11676
11753
|
try {
|
|
11677
11754
|
const now = new Date;
|
|
11678
11755
|
const timestamp = now.toISOString().replace(/[:.]/g, "-").replace(/T/, "_").split("Z")[0];
|
|
11679
|
-
const traceFilePath = `
|
|
11756
|
+
const traceFilePath = `ffi_cascade_trace_${timestamp}.log`;
|
|
11680
11757
|
Bun.write(traceFilePath, output);
|
|
11681
11758
|
} catch (e) {
|
|
11682
11759
|
console.error("Failed to write FFI trace file:", e);
|
|
@@ -16593,6 +16670,9 @@ class CliRenderer extends EventEmitter9 {
|
|
|
16593
16670
|
renderTime: 0,
|
|
16594
16671
|
frameCallbackTime: 0
|
|
16595
16672
|
};
|
|
16673
|
+
frameBreakdownBuffer = [];
|
|
16674
|
+
frameBreakdownMaxSize = 100;
|
|
16675
|
+
traceFrameBreakdown = env.CASCADE_TRACE_FRAME_BREAKDOWN;
|
|
16596
16676
|
debugOverlay = {
|
|
16597
16677
|
enabled: env.CASCADE_SHOW_STATS,
|
|
16598
16678
|
corner: 3 /* bottomRight */
|
|
@@ -16650,6 +16730,7 @@ class CliRenderer extends EventEmitter9 {
|
|
|
16650
16730
|
_cachedPalette = null;
|
|
16651
16731
|
_paletteDetectionPromise = null;
|
|
16652
16732
|
_onDestroy;
|
|
16733
|
+
_destroyCallbacks = new Set;
|
|
16653
16734
|
_themeMode = null;
|
|
16654
16735
|
inputHandlers = [];
|
|
16655
16736
|
prependedInputHandlers = [];
|
|
@@ -17666,6 +17747,16 @@ Captured output:
|
|
|
17666
17747
|
if (this._logCrashReportsToConsole) {
|
|
17667
17748
|
console.error(this.formatCrashReportForConsole(report));
|
|
17668
17749
|
}
|
|
17750
|
+
if (this.traceFrameBreakdown && this.frameBreakdownBuffer.length > 0) {
|
|
17751
|
+
const breakdownDump = this.dumpFrameBreakdown();
|
|
17752
|
+
console.error(`
|
|
17753
|
+
` + breakdownDump);
|
|
17754
|
+
report.recentEvents.push({
|
|
17755
|
+
timestamp: report.timestamp,
|
|
17756
|
+
type: "crash:frame_breakdown",
|
|
17757
|
+
payload: { breakdown: breakdownDump }
|
|
17758
|
+
});
|
|
17759
|
+
}
|
|
17669
17760
|
this.emit("crash" /* CRASH */, report);
|
|
17670
17761
|
return report;
|
|
17671
17762
|
}
|
|
@@ -17925,11 +18016,42 @@ Captured output:
|
|
|
17925
18016
|
}
|
|
17926
18017
|
}
|
|
17927
18018
|
}
|
|
18019
|
+
onDestroy(cb) {
|
|
18020
|
+
if (this._isDestroyed) {
|
|
18021
|
+
queueMicrotask(() => {
|
|
18022
|
+
try {
|
|
18023
|
+
const r = cb();
|
|
18024
|
+
if (r && typeof r.then === "function") {
|
|
18025
|
+
r.catch(() => {});
|
|
18026
|
+
}
|
|
18027
|
+
} catch {}
|
|
18028
|
+
});
|
|
18029
|
+
return () => {};
|
|
18030
|
+
}
|
|
18031
|
+
this._destroyCallbacks.add(cb);
|
|
18032
|
+
return () => {
|
|
18033
|
+
this._destroyCallbacks.delete(cb);
|
|
18034
|
+
};
|
|
18035
|
+
}
|
|
17928
18036
|
destroy() {
|
|
17929
18037
|
if (this._isDestroyed)
|
|
17930
18038
|
return;
|
|
17931
18039
|
this._isDestroyed = true;
|
|
17932
18040
|
this._destroyPending = true;
|
|
18041
|
+
for (const cb of Array.from(this._destroyCallbacks)) {
|
|
18042
|
+
try {
|
|
18043
|
+
const r = cb();
|
|
18044
|
+
if (r && typeof r.then === "function") {
|
|
18045
|
+
r.catch(() => {});
|
|
18046
|
+
}
|
|
18047
|
+
} catch {}
|
|
18048
|
+
}
|
|
18049
|
+
this._destroyCallbacks.clear();
|
|
18050
|
+
if (this._onDestroy) {
|
|
18051
|
+
try {
|
|
18052
|
+
this._onDestroy();
|
|
18053
|
+
} catch {}
|
|
18054
|
+
}
|
|
17933
18055
|
if (this.rendering) {
|
|
17934
18056
|
if (this.destroyTimeoutId === null) {
|
|
17935
18057
|
this.destroyTimeoutId = setTimeout(() => {
|
|
@@ -18004,15 +18126,28 @@ Captured output:
|
|
|
18004
18126
|
this.stdin.removeListener("data", this.stdinListener);
|
|
18005
18127
|
this.lib.destroyRenderer(this.rendererPtr);
|
|
18006
18128
|
rendererTracker.removeRenderer(this);
|
|
18007
|
-
if (this._onDestroy) {
|
|
18008
|
-
try {
|
|
18009
|
-
this._onDestroy();
|
|
18010
|
-
} catch (e) {
|
|
18011
|
-
console.error("Error in onDestroy callback:", e instanceof Error ? e.stack : String(e));
|
|
18012
|
-
}
|
|
18013
|
-
}
|
|
18014
18129
|
this.resolveIdleIfNeeded();
|
|
18015
18130
|
}
|
|
18131
|
+
dumpFrameBreakdown() {
|
|
18132
|
+
if (this.frameBreakdownBuffer.length === 0) {
|
|
18133
|
+
return "No frame breakdown data recorded";
|
|
18134
|
+
}
|
|
18135
|
+
const lines = this.frameBreakdownBuffer.map((f, i) => {
|
|
18136
|
+
const time = new Date(f.timestamp).toISOString();
|
|
18137
|
+
return `[${i}] ${time} total=${f.totalMs.toFixed(2)}ms tree=${f.renderTreeMs.toFixed(2)}ms native=${f.nativeMs.toFixed(2)}ms callback=${f.frameCallbackMs.toFixed(2)}ms`;
|
|
18138
|
+
});
|
|
18139
|
+
const totals = this.frameBreakdownBuffer.map((f) => f.totalMs);
|
|
18140
|
+
const avgTotal = totals.reduce((a, b) => a + b, 0) / totals.length;
|
|
18141
|
+
const maxTotal = Math.max(...totals);
|
|
18142
|
+
const minTotal = Math.min(...totals);
|
|
18143
|
+
return [
|
|
18144
|
+
`=== Frame Breakdown (${this.frameBreakdownBuffer.length} frames) ===`,
|
|
18145
|
+
`Avg: ${avgTotal.toFixed(2)}ms, Max: ${maxTotal.toFixed(2)}ms, Min: ${minTotal.toFixed(2)}ms`,
|
|
18146
|
+
"",
|
|
18147
|
+
...lines
|
|
18148
|
+
].join(`
|
|
18149
|
+
`);
|
|
18150
|
+
}
|
|
18016
18151
|
startRenderLoop() {
|
|
18017
18152
|
if (!this._isRunning)
|
|
18018
18153
|
return;
|
|
@@ -18086,6 +18221,21 @@ Captured output:
|
|
|
18086
18221
|
}
|
|
18087
18222
|
}
|
|
18088
18223
|
const overallFrameTime = performance.now() - overallStart;
|
|
18224
|
+
if (this.traceFrameBreakdown) {
|
|
18225
|
+
const breakdown = {
|
|
18226
|
+
timestamp: Date.now(),
|
|
18227
|
+
yogaMs: 0,
|
|
18228
|
+
renderTreeMs,
|
|
18229
|
+
nativeMs,
|
|
18230
|
+
stdoutMs: 0,
|
|
18231
|
+
frameCallbackMs: this.renderStats.frameCallbackTime,
|
|
18232
|
+
totalMs: overallFrameTime
|
|
18233
|
+
};
|
|
18234
|
+
if (this.frameBreakdownBuffer.length >= this.frameBreakdownMaxSize) {
|
|
18235
|
+
this.frameBreakdownBuffer.shift();
|
|
18236
|
+
}
|
|
18237
|
+
this.frameBreakdownBuffer.push(breakdown);
|
|
18238
|
+
}
|
|
18089
18239
|
if (traceEnabled) {
|
|
18090
18240
|
trace.write(`trace.render.native ms=${nativeMs.toFixed(3)}`);
|
|
18091
18241
|
trace.write(`trace.render.pipeline treeMs=${renderTreeMs.toFixed(3)} postMs=${postProcessMs.toFixed(3)} nativeMs=${nativeMs.toFixed(3)} frameMs=${overallFrameTime.toFixed(3)} animMs=${animationRequestTime.toFixed(3)}`);
|
|
@@ -18396,5 +18546,5 @@ Captured output:
|
|
|
18396
18546
|
|
|
18397
18547
|
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 };
|
|
18398
18548
|
|
|
18399
|
-
//# debugId=
|
|
18400
|
-
//# sourceMappingURL=index-
|
|
18549
|
+
//# debugId=16C825532B5F27E664756E2164756E21
|
|
18550
|
+
//# sourceMappingURL=index-kfh59ta6.js.map
|