@opentui/core 0.1.54 → 0.1.56
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/Renderable.d.ts +1 -0
- package/{index-aedd54rx.js → index-rrt84m8j.js} +113 -31
- package/{index-aedd54rx.js.map → index-rrt84m8j.js.map} +10 -9
- package/index.js +5 -4
- package/index.js.map +4 -4
- package/lib/bunfs.d.ts +7 -0
- package/lib/terminal-palette.d.ts +3 -3
- package/package.json +7 -7
- package/parser.worker.js +17 -3
- package/parser.worker.js.map +6 -5
- package/renderer.d.ts +8 -0
- package/testing/mock-keys.d.ts +12 -0
- package/testing/test-recorder.d.ts +44 -0
- package/testing.d.ts +1 -0
- package/testing.js +69 -3
- package/testing.js.map +6 -5
package/3d.js
CHANGED
package/Renderable.d.ts
CHANGED
|
@@ -148,6 +148,7 @@ export declare abstract class Renderable extends BaseRenderable {
|
|
|
148
148
|
parent: Renderable | null;
|
|
149
149
|
private childrenPrimarySortDirty;
|
|
150
150
|
private childrenSortedByPrimaryAxis;
|
|
151
|
+
private _shouldUpdateBefore;
|
|
151
152
|
onLifecyclePass: (() => void) | null;
|
|
152
153
|
renderBefore?: (this: Renderable, buffer: OptimizedBuffer, deltaTime: number) => void;
|
|
153
154
|
renderAfter?: (this: Renderable, buffer: OptimizedBuffer, deltaTime: number) => void;
|
|
@@ -2242,9 +2242,11 @@ var parseKeypress = (s = "", options = {}) => {
|
|
|
2242
2242
|
const modifier = parseInt(modifyOtherKeysMatch[1], 10) - 1;
|
|
2243
2243
|
const charCode = parseInt(modifyOtherKeysMatch[2], 10);
|
|
2244
2244
|
key.ctrl = !!(modifier & 4);
|
|
2245
|
-
key.meta = !!(modifier &
|
|
2245
|
+
key.meta = !!(modifier & 2);
|
|
2246
2246
|
key.shift = !!(modifier & 1);
|
|
2247
2247
|
key.option = !!(modifier & 2);
|
|
2248
|
+
key.super = !!(modifier & 8);
|
|
2249
|
+
key.hyper = !!(modifier & 16);
|
|
2248
2250
|
if (charCode === 13) {
|
|
2249
2251
|
key.name = "return";
|
|
2250
2252
|
} else if (charCode === 27) {
|
|
@@ -2321,9 +2323,11 @@ var parseKeypress = (s = "", options = {}) => {
|
|
|
2321
2323
|
const code = [parts[1], parts[2], parts[4], parts[6]].filter(Boolean).join("");
|
|
2322
2324
|
const modifier = parseInt(parts[3] || parts[5] || "1", 10) - 1;
|
|
2323
2325
|
key.ctrl = !!(modifier & 4);
|
|
2324
|
-
key.meta = !!(modifier &
|
|
2326
|
+
key.meta = !!(modifier & 2);
|
|
2325
2327
|
key.shift = !!(modifier & 1);
|
|
2326
2328
|
key.option = !!(modifier & 2);
|
|
2329
|
+
key.super = !!(modifier & 8);
|
|
2330
|
+
key.hyper = !!(modifier & 16);
|
|
2327
2331
|
key.code = code;
|
|
2328
2332
|
const keyNameResult = keyName[code];
|
|
2329
2333
|
if (keyNameResult) {
|
|
@@ -7201,9 +7205,22 @@ function getParsers() {
|
|
|
7201
7205
|
}
|
|
7202
7206
|
|
|
7203
7207
|
// src/lib/tree-sitter/client.ts
|
|
7204
|
-
import { resolve as resolve2, isAbsolute } from "path";
|
|
7208
|
+
import { resolve as resolve2, isAbsolute, parse } from "path";
|
|
7205
7209
|
import { existsSync } from "fs";
|
|
7206
|
-
|
|
7210
|
+
|
|
7211
|
+
// src/lib/bunfs.ts
|
|
7212
|
+
import { basename, join } from "path";
|
|
7213
|
+
function isBunfsPath(path) {
|
|
7214
|
+
return path.includes("$bunfs") || /^B:[\\/]~BUN/i.test(path);
|
|
7215
|
+
}
|
|
7216
|
+
function getBunfsRootPath() {
|
|
7217
|
+
return process.platform === "win32" ? "B:\\~BUN\\root" : "/$bunfs/root";
|
|
7218
|
+
}
|
|
7219
|
+
function normalizeBunfsPath(fileName) {
|
|
7220
|
+
return join(getBunfsRootPath(), basename(fileName));
|
|
7221
|
+
}
|
|
7222
|
+
|
|
7223
|
+
// src/lib/tree-sitter/client.ts
|
|
7207
7224
|
registerEnvVar({
|
|
7208
7225
|
name: "OTUI_TREE_SITTER_WORKER_PATH",
|
|
7209
7226
|
description: "Path to the TreeSitter worker",
|
|
@@ -7325,8 +7342,8 @@ class TreeSitterClient extends EventEmitter3 {
|
|
|
7325
7342
|
if (isUrl(path)) {
|
|
7326
7343
|
return path;
|
|
7327
7344
|
}
|
|
7328
|
-
if (
|
|
7329
|
-
return
|
|
7345
|
+
if (isBunfsPath(path)) {
|
|
7346
|
+
return normalizeBunfsPath(parse(path).base);
|
|
7330
7347
|
}
|
|
7331
7348
|
if (!isAbsolute(path)) {
|
|
7332
7349
|
return resolve2(path);
|
|
@@ -8907,15 +8924,15 @@ class TerminalPalette {
|
|
|
8907
8924
|
writeFn;
|
|
8908
8925
|
activeListeners = [];
|
|
8909
8926
|
activeTimers = [];
|
|
8910
|
-
|
|
8911
|
-
constructor(stdin, stdout, writeFn,
|
|
8927
|
+
inLegacyTmux;
|
|
8928
|
+
constructor(stdin, stdout, writeFn, isLegacyTmux) {
|
|
8912
8929
|
this.stdin = stdin;
|
|
8913
8930
|
this.stdout = stdout;
|
|
8914
8931
|
this.writeFn = writeFn || ((data) => stdout.write(data));
|
|
8915
|
-
this.
|
|
8932
|
+
this.inLegacyTmux = isLegacyTmux ?? false;
|
|
8916
8933
|
}
|
|
8917
8934
|
writeOsc(osc) {
|
|
8918
|
-
const data = this.
|
|
8935
|
+
const data = this.inLegacyTmux ? wrapForTmux(osc) : osc;
|
|
8919
8936
|
return this.writeFn(data);
|
|
8920
8937
|
}
|
|
8921
8938
|
cleanup() {
|
|
@@ -9152,8 +9169,8 @@ class TerminalPalette {
|
|
|
9152
9169
|
};
|
|
9153
9170
|
}
|
|
9154
9171
|
}
|
|
9155
|
-
function createTerminalPalette(stdin, stdout, writeFn,
|
|
9156
|
-
return new TerminalPalette(stdin, stdout, writeFn,
|
|
9172
|
+
function createTerminalPalette(stdin, stdout, writeFn, isLegacyTmux) {
|
|
9173
|
+
return new TerminalPalette(stdin, stdout, writeFn, isLegacyTmux);
|
|
9157
9174
|
}
|
|
9158
9175
|
// src/zig.ts
|
|
9159
9176
|
import { dlopen, toArrayBuffer as toArrayBuffer4, JSCallback, ptr as ptr3 } from "bun:ffi";
|
|
@@ -10076,7 +10093,7 @@ var MeasureResultStruct = defineStruct([
|
|
|
10076
10093
|
// src/zig.ts
|
|
10077
10094
|
var module = await import(`@opentui/core-${process.platform}-${process.arch}/index.ts`);
|
|
10078
10095
|
var targetLibPath = module.default;
|
|
10079
|
-
if (
|
|
10096
|
+
if (isBunfsPath(targetLibPath)) {
|
|
10080
10097
|
targetLibPath = targetLibPath.replace("../", "");
|
|
10081
10098
|
}
|
|
10082
10099
|
if (!existsSync2(targetLibPath)) {
|
|
@@ -12451,6 +12468,7 @@ class Renderable extends BaseRenderable {
|
|
|
12451
12468
|
parent = null;
|
|
12452
12469
|
childrenPrimarySortDirty = true;
|
|
12453
12470
|
childrenSortedByPrimaryAxis = [];
|
|
12471
|
+
_shouldUpdateBefore = new Set;
|
|
12454
12472
|
onLifecyclePass = null;
|
|
12455
12473
|
renderBefore;
|
|
12456
12474
|
renderAfter;
|
|
@@ -13154,6 +13172,7 @@ class Renderable extends BaseRenderable {
|
|
|
13154
13172
|
this._childrenInLayoutOrder.push(renderable);
|
|
13155
13173
|
this.yogaNode.insertChild(childLayoutNode, insertedIndex);
|
|
13156
13174
|
this.childrenPrimarySortDirty = true;
|
|
13175
|
+
this._shouldUpdateBefore.add(renderable);
|
|
13157
13176
|
this.requestRender();
|
|
13158
13177
|
return insertedIndex;
|
|
13159
13178
|
}
|
|
@@ -13206,6 +13225,7 @@ class Renderable extends BaseRenderable {
|
|
|
13206
13225
|
const insertedIndex = Math.max(0, Math.min(anchorIndex, this._childrenInLayoutOrder.length));
|
|
13207
13226
|
this._childrenInLayoutOrder.splice(insertedIndex, 0, renderable);
|
|
13208
13227
|
this.yogaNode.insertChild(renderable.getLayoutNode(), insertedIndex);
|
|
13228
|
+
this._shouldUpdateBefore.add(renderable);
|
|
13209
13229
|
this.requestRender();
|
|
13210
13230
|
return insertedIndex;
|
|
13211
13231
|
}
|
|
@@ -13255,6 +13275,14 @@ class Renderable extends BaseRenderable {
|
|
|
13255
13275
|
if (this._isDestroyed)
|
|
13256
13276
|
return;
|
|
13257
13277
|
this.updateFromLayout();
|
|
13278
|
+
if (this._shouldUpdateBefore.size > 0) {
|
|
13279
|
+
for (const child of this._shouldUpdateBefore) {
|
|
13280
|
+
if (!child.isDestroyed) {
|
|
13281
|
+
child.updateFromLayout();
|
|
13282
|
+
}
|
|
13283
|
+
}
|
|
13284
|
+
this._shouldUpdateBefore.clear();
|
|
13285
|
+
}
|
|
13258
13286
|
if (this._isDestroyed)
|
|
13259
13287
|
return;
|
|
13260
13288
|
renderList.push({ action: "render", renderable: this });
|
|
@@ -14645,6 +14673,7 @@ class CliRenderer extends EventEmitter9 {
|
|
|
14645
14673
|
currentRenderBuffer;
|
|
14646
14674
|
_isRunning = false;
|
|
14647
14675
|
targetFps = 30;
|
|
14676
|
+
maxFps = 60;
|
|
14648
14677
|
automaticMemorySnapshot = false;
|
|
14649
14678
|
memorySnapshotInterval;
|
|
14650
14679
|
memorySnapshotTimer = null;
|
|
@@ -14670,7 +14699,8 @@ class CliRenderer extends EventEmitter9 {
|
|
|
14670
14699
|
frameCount = 0;
|
|
14671
14700
|
lastFpsTime = 0;
|
|
14672
14701
|
currentFps = 0;
|
|
14673
|
-
targetFrameTime =
|
|
14702
|
+
targetFrameTime = 1000 / this.targetFps;
|
|
14703
|
+
minTargetFrameTime = 1000 / this.maxFps;
|
|
14674
14704
|
immediateRerenderRequested = false;
|
|
14675
14705
|
updateScheduled = false;
|
|
14676
14706
|
liveRequestCounter = 0;
|
|
@@ -14732,6 +14762,7 @@ class CliRenderer extends EventEmitter9 {
|
|
|
14732
14762
|
_onDestroy;
|
|
14733
14763
|
inputHandlers = [];
|
|
14734
14764
|
prependedInputHandlers = [];
|
|
14765
|
+
idleResolvers = [];
|
|
14735
14766
|
handleError = ((error) => {
|
|
14736
14767
|
console.error(error);
|
|
14737
14768
|
if (this._openConsoleOnError) {
|
|
@@ -14796,6 +14827,9 @@ Captured output:
|
|
|
14796
14827
|
this.exitOnCtrlC = config.exitOnCtrlC === undefined ? true : config.exitOnCtrlC;
|
|
14797
14828
|
this.resizeDebounceDelay = config.debounceDelay || 100;
|
|
14798
14829
|
this.targetFps = config.targetFps || 30;
|
|
14830
|
+
this.maxFps = config.maxFps || 60;
|
|
14831
|
+
this.targetFrameTime = 1000 / this.targetFps;
|
|
14832
|
+
this.minTargetFrameTime = 1000 / this.maxFps;
|
|
14799
14833
|
this.memorySnapshotInterval = config.memorySnapshotInterval ?? 0;
|
|
14800
14834
|
this.gatherStats = config.gatherStats || false;
|
|
14801
14835
|
this.maxStatSamples = config.maxStatSamples || 300;
|
|
@@ -14891,14 +14925,33 @@ Captured output:
|
|
|
14891
14925
|
return this.realStdoutWrite.call(this.stdout, chunk, encoding, callback);
|
|
14892
14926
|
}
|
|
14893
14927
|
requestRender() {
|
|
14894
|
-
if (
|
|
14928
|
+
if (this._controlState === "explicit_suspended" /* EXPLICIT_SUSPENDED */) {
|
|
14929
|
+
return;
|
|
14930
|
+
}
|
|
14931
|
+
if (this._isRunning) {
|
|
14932
|
+
return;
|
|
14933
|
+
}
|
|
14934
|
+
if (this.rendering) {
|
|
14935
|
+
this.immediateRerenderRequested = true;
|
|
14936
|
+
return;
|
|
14937
|
+
}
|
|
14938
|
+
if (!this.updateScheduled && !this.renderTimeout) {
|
|
14895
14939
|
this.updateScheduled = true;
|
|
14896
|
-
|
|
14897
|
-
|
|
14898
|
-
|
|
14899
|
-
|
|
14940
|
+
const now = Date.now();
|
|
14941
|
+
const elapsed = now - this.lastTime;
|
|
14942
|
+
const delay = Math.max(this.minTargetFrameTime - elapsed, 0);
|
|
14943
|
+
if (delay === 0) {
|
|
14944
|
+
process.nextTick(() => this.activateFrame());
|
|
14945
|
+
return;
|
|
14946
|
+
}
|
|
14947
|
+
setTimeout(() => this.activateFrame(), delay);
|
|
14900
14948
|
}
|
|
14901
14949
|
}
|
|
14950
|
+
async activateFrame() {
|
|
14951
|
+
await this.loop();
|
|
14952
|
+
this.updateScheduled = false;
|
|
14953
|
+
this.resolveIdleIfNeeded();
|
|
14954
|
+
}
|
|
14902
14955
|
get useConsole() {
|
|
14903
14956
|
return this._useConsole;
|
|
14904
14957
|
}
|
|
@@ -14913,6 +14966,26 @@ Captured output:
|
|
|
14913
14966
|
get isRunning() {
|
|
14914
14967
|
return this._isRunning;
|
|
14915
14968
|
}
|
|
14969
|
+
isIdleNow() {
|
|
14970
|
+
return !this._isRunning && !this.rendering && !this.renderTimeout && !this.updateScheduled && !this.immediateRerenderRequested;
|
|
14971
|
+
}
|
|
14972
|
+
resolveIdleIfNeeded() {
|
|
14973
|
+
if (!this.isIdleNow())
|
|
14974
|
+
return;
|
|
14975
|
+
const resolvers = this.idleResolvers.splice(0);
|
|
14976
|
+
for (const resolve4 of resolvers) {
|
|
14977
|
+
resolve4();
|
|
14978
|
+
}
|
|
14979
|
+
}
|
|
14980
|
+
idle() {
|
|
14981
|
+
if (this._isDestroyed)
|
|
14982
|
+
return Promise.resolve();
|
|
14983
|
+
if (this.isIdleNow())
|
|
14984
|
+
return Promise.resolve();
|
|
14985
|
+
return new Promise((resolve4) => {
|
|
14986
|
+
this.idleResolvers.push(resolve4);
|
|
14987
|
+
});
|
|
14988
|
+
}
|
|
14916
14989
|
get resolution() {
|
|
14917
14990
|
return this._resolution;
|
|
14918
14991
|
}
|
|
@@ -15515,6 +15588,9 @@ Captured output:
|
|
|
15515
15588
|
clearTimeout(this.renderTimeout);
|
|
15516
15589
|
this.renderTimeout = null;
|
|
15517
15590
|
}
|
|
15591
|
+
if (!this.rendering) {
|
|
15592
|
+
this.resolveIdleIfNeeded();
|
|
15593
|
+
}
|
|
15518
15594
|
}
|
|
15519
15595
|
}
|
|
15520
15596
|
destroy() {
|
|
@@ -15567,6 +15643,7 @@ Captured output:
|
|
|
15567
15643
|
console.error("Error in onDestroy callback:", e instanceof Error ? e.stack : String(e));
|
|
15568
15644
|
}
|
|
15569
15645
|
}
|
|
15646
|
+
this.resolveIdleIfNeeded();
|
|
15570
15647
|
}
|
|
15571
15648
|
startRenderLoop() {
|
|
15572
15649
|
if (!this._isRunning)
|
|
@@ -15575,12 +15652,12 @@ Captured output:
|
|
|
15575
15652
|
this.frameCount = 0;
|
|
15576
15653
|
this.lastFpsTime = this.lastTime;
|
|
15577
15654
|
this.currentFps = 0;
|
|
15578
|
-
this.targetFrameTime = 1000 / this.targetFps;
|
|
15579
15655
|
this.loop();
|
|
15580
15656
|
}
|
|
15581
15657
|
async loop() {
|
|
15582
15658
|
if (this.rendering || this._isDestroyed)
|
|
15583
15659
|
return;
|
|
15660
|
+
this.renderTimeout = null;
|
|
15584
15661
|
this.rendering = true;
|
|
15585
15662
|
if (this.renderTimeout) {
|
|
15586
15663
|
clearTimeout(this.renderTimeout);
|
|
@@ -15630,16 +15707,21 @@ Captured output:
|
|
|
15630
15707
|
if (this.gatherStats) {
|
|
15631
15708
|
this.collectStatSample(overallFrameTime);
|
|
15632
15709
|
}
|
|
15633
|
-
if (this._isRunning) {
|
|
15634
|
-
const
|
|
15635
|
-
|
|
15710
|
+
if (this._isRunning || this.immediateRerenderRequested) {
|
|
15711
|
+
const targetFrameTime = this.immediateRerenderRequested ? this.minTargetFrameTime : this.targetFrameTime;
|
|
15712
|
+
const delay = Math.max(1, targetFrameTime - Math.floor(overallFrameTime));
|
|
15713
|
+
this.immediateRerenderRequested = false;
|
|
15714
|
+
this.renderTimeout = setTimeout(() => {
|
|
15715
|
+
this.renderTimeout = null;
|
|
15716
|
+
this.loop();
|
|
15717
|
+
}, delay);
|
|
15718
|
+
} else {
|
|
15719
|
+
clearTimeout(this.renderTimeout);
|
|
15720
|
+
this.renderTimeout = null;
|
|
15636
15721
|
}
|
|
15637
15722
|
}
|
|
15638
15723
|
this.rendering = false;
|
|
15639
|
-
|
|
15640
|
-
this.immediateRerenderRequested = false;
|
|
15641
|
-
this.loop();
|
|
15642
|
-
}
|
|
15724
|
+
this.resolveIdleIfNeeded();
|
|
15643
15725
|
}
|
|
15644
15726
|
intermediateRender() {
|
|
15645
15727
|
this.immediateRerenderRequested = true;
|
|
@@ -15817,8 +15899,8 @@ Captured output:
|
|
|
15817
15899
|
return this._paletteDetectionPromise;
|
|
15818
15900
|
}
|
|
15819
15901
|
if (!this._paletteDetector) {
|
|
15820
|
-
const
|
|
15821
|
-
this._paletteDetector = createTerminalPalette(this.stdin, this.stdout, this.writeOut.bind(this),
|
|
15902
|
+
const isLegacyTmux = this.capabilities?.terminal?.name?.toLowerCase()?.includes("tmux") && this.capabilities?.terminal?.version?.localeCompare("3.6") < 0;
|
|
15903
|
+
this._paletteDetector = createTerminalPalette(this.stdin, this.stdout, this.writeOut.bind(this), isLegacyTmux);
|
|
15822
15904
|
}
|
|
15823
15905
|
this._paletteDetectionPromise = this._paletteDetector.detect(options).then((result) => {
|
|
15824
15906
|
this._cachedPalette = result;
|
|
@@ -15831,5 +15913,5 @@ Captured output:
|
|
|
15831
15913
|
|
|
15832
15914
|
export { __toESM, __commonJS, __export, __require, Edge, Gutter, MeasureMode, exports_src, BorderChars, getBorderFromSides, getBorderSides, borderCharsToArray, BorderCharArrays, nonAlphanumericKeys, parseKeypress, KeyEvent, PasteEvent, KeyHandler, InternalKeyHandler, RGBA, hexToRgb, rgbToHex, hsvToRgb, parseColor, fonts, measureText, getCharacterPositions, coordinateToCharacterIndex, renderFontToFrameBuffer, TextAttributes, DebugOverlayCorner, createTextAttributes, 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, t, hastToStyledText, LinearScrollAccel, MacOSScrollAccel, StdinBuffer, parseAlign, 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, LogLevel2 as LogLevel, setRenderLibPath, resolveRenderLib, OptimizedBuffer, h, isVNode, maybeMakeRenderable, wrapWithDelegates, instantiate, delegate, isValidPercentage, LayoutEvents, RenderableEvents, isRenderable, BaseRenderable, Renderable, RootRenderable, ANSI, capture, ConsolePosition, TerminalConsole, getObjectsInViewport, MouseEvent, MouseButton, createCliRenderer, CliRenderEvents, RendererControlState, CliRenderer };
|
|
15833
15915
|
|
|
15834
|
-
//# debugId=
|
|
15835
|
-
//# sourceMappingURL=index-
|
|
15916
|
+
//# debugId=01E9CC866B57E71564756E2164756E21
|
|
15917
|
+
//# sourceMappingURL=index-rrt84m8j.js.map
|