@opentui/core 0.1.54 → 0.1.55

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 CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  __export,
6
6
  __require,
7
7
  __toESM
8
- } from "./index-aedd54rx.js";
8
+ } from "./index-0razn4m6.js";
9
9
 
10
10
  // ../../node_modules/omggif/omggif.js
11
11
  var require_omggif = __commonJS((exports) => {
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 & 10);
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 & 10);
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) {
@@ -8907,15 +8911,15 @@ class TerminalPalette {
8907
8911
  writeFn;
8908
8912
  activeListeners = [];
8909
8913
  activeTimers = [];
8910
- inTmux;
8911
- constructor(stdin, stdout, writeFn, isTmux) {
8914
+ inLegacyTmux;
8915
+ constructor(stdin, stdout, writeFn, isLegacyTmux) {
8912
8916
  this.stdin = stdin;
8913
8917
  this.stdout = stdout;
8914
8918
  this.writeFn = writeFn || ((data) => stdout.write(data));
8915
- this.inTmux = isTmux ?? false;
8919
+ this.inLegacyTmux = isLegacyTmux ?? false;
8916
8920
  }
8917
8921
  writeOsc(osc) {
8918
- const data = this.inTmux ? wrapForTmux(osc) : osc;
8922
+ const data = this.inLegacyTmux ? wrapForTmux(osc) : osc;
8919
8923
  return this.writeFn(data);
8920
8924
  }
8921
8925
  cleanup() {
@@ -9152,8 +9156,8 @@ class TerminalPalette {
9152
9156
  };
9153
9157
  }
9154
9158
  }
9155
- function createTerminalPalette(stdin, stdout, writeFn, isTmux) {
9156
- return new TerminalPalette(stdin, stdout, writeFn, isTmux);
9159
+ function createTerminalPalette(stdin, stdout, writeFn, isLegacyTmux) {
9160
+ return new TerminalPalette(stdin, stdout, writeFn, isLegacyTmux);
9157
9161
  }
9158
9162
  // src/zig.ts
9159
9163
  import { dlopen, toArrayBuffer as toArrayBuffer4, JSCallback, ptr as ptr3 } from "bun:ffi";
@@ -12451,6 +12455,7 @@ class Renderable extends BaseRenderable {
12451
12455
  parent = null;
12452
12456
  childrenPrimarySortDirty = true;
12453
12457
  childrenSortedByPrimaryAxis = [];
12458
+ _shouldUpdateBefore = new Set;
12454
12459
  onLifecyclePass = null;
12455
12460
  renderBefore;
12456
12461
  renderAfter;
@@ -13154,6 +13159,7 @@ class Renderable extends BaseRenderable {
13154
13159
  this._childrenInLayoutOrder.push(renderable);
13155
13160
  this.yogaNode.insertChild(childLayoutNode, insertedIndex);
13156
13161
  this.childrenPrimarySortDirty = true;
13162
+ this._shouldUpdateBefore.add(renderable);
13157
13163
  this.requestRender();
13158
13164
  return insertedIndex;
13159
13165
  }
@@ -13206,6 +13212,7 @@ class Renderable extends BaseRenderable {
13206
13212
  const insertedIndex = Math.max(0, Math.min(anchorIndex, this._childrenInLayoutOrder.length));
13207
13213
  this._childrenInLayoutOrder.splice(insertedIndex, 0, renderable);
13208
13214
  this.yogaNode.insertChild(renderable.getLayoutNode(), insertedIndex);
13215
+ this._shouldUpdateBefore.add(renderable);
13209
13216
  this.requestRender();
13210
13217
  return insertedIndex;
13211
13218
  }
@@ -13255,6 +13262,14 @@ class Renderable extends BaseRenderable {
13255
13262
  if (this._isDestroyed)
13256
13263
  return;
13257
13264
  this.updateFromLayout();
13265
+ if (this._shouldUpdateBefore.size > 0) {
13266
+ for (const child of this._shouldUpdateBefore) {
13267
+ if (!child.isDestroyed) {
13268
+ child.updateFromLayout();
13269
+ }
13270
+ }
13271
+ this._shouldUpdateBefore.clear();
13272
+ }
13258
13273
  if (this._isDestroyed)
13259
13274
  return;
13260
13275
  renderList.push({ action: "render", renderable: this });
@@ -14645,6 +14660,7 @@ class CliRenderer extends EventEmitter9 {
14645
14660
  currentRenderBuffer;
14646
14661
  _isRunning = false;
14647
14662
  targetFps = 30;
14663
+ maxFps = 60;
14648
14664
  automaticMemorySnapshot = false;
14649
14665
  memorySnapshotInterval;
14650
14666
  memorySnapshotTimer = null;
@@ -14670,7 +14686,8 @@ class CliRenderer extends EventEmitter9 {
14670
14686
  frameCount = 0;
14671
14687
  lastFpsTime = 0;
14672
14688
  currentFps = 0;
14673
- targetFrameTime = 0;
14689
+ targetFrameTime = 1000 / this.targetFps;
14690
+ minTargetFrameTime = 1000 / this.maxFps;
14674
14691
  immediateRerenderRequested = false;
14675
14692
  updateScheduled = false;
14676
14693
  liveRequestCounter = 0;
@@ -14732,6 +14749,7 @@ class CliRenderer extends EventEmitter9 {
14732
14749
  _onDestroy;
14733
14750
  inputHandlers = [];
14734
14751
  prependedInputHandlers = [];
14752
+ idleResolvers = [];
14735
14753
  handleError = ((error) => {
14736
14754
  console.error(error);
14737
14755
  if (this._openConsoleOnError) {
@@ -14796,6 +14814,9 @@ Captured output:
14796
14814
  this.exitOnCtrlC = config.exitOnCtrlC === undefined ? true : config.exitOnCtrlC;
14797
14815
  this.resizeDebounceDelay = config.debounceDelay || 100;
14798
14816
  this.targetFps = config.targetFps || 30;
14817
+ this.maxFps = config.maxFps || 60;
14818
+ this.targetFrameTime = 1000 / this.targetFps;
14819
+ this.minTargetFrameTime = 1000 / this.maxFps;
14799
14820
  this.memorySnapshotInterval = config.memorySnapshotInterval ?? 0;
14800
14821
  this.gatherStats = config.gatherStats || false;
14801
14822
  this.maxStatSamples = config.maxStatSamples || 300;
@@ -14891,14 +14912,33 @@ Captured output:
14891
14912
  return this.realStdoutWrite.call(this.stdout, chunk, encoding, callback);
14892
14913
  }
14893
14914
  requestRender() {
14894
- if (!this.rendering && !this.updateScheduled && !this._isRunning && this._controlState !== "explicit_suspended" /* EXPLICIT_SUSPENDED */) {
14915
+ if (this._controlState === "explicit_suspended" /* EXPLICIT_SUSPENDED */) {
14916
+ return;
14917
+ }
14918
+ if (this._isRunning) {
14919
+ return;
14920
+ }
14921
+ if (this.rendering) {
14922
+ this.immediateRerenderRequested = true;
14923
+ return;
14924
+ }
14925
+ if (!this.updateScheduled && !this.renderTimeout) {
14895
14926
  this.updateScheduled = true;
14896
- process.nextTick(() => {
14897
- this.loop();
14898
- this.updateScheduled = false;
14899
- });
14927
+ const now = Date.now();
14928
+ const elapsed = now - this.lastTime;
14929
+ const delay = Math.max(this.minTargetFrameTime - elapsed, 0);
14930
+ if (delay === 0) {
14931
+ process.nextTick(() => this.activateFrame());
14932
+ return;
14933
+ }
14934
+ setTimeout(() => this.activateFrame(), delay);
14900
14935
  }
14901
14936
  }
14937
+ async activateFrame() {
14938
+ await this.loop();
14939
+ this.updateScheduled = false;
14940
+ this.resolveIdleIfNeeded();
14941
+ }
14902
14942
  get useConsole() {
14903
14943
  return this._useConsole;
14904
14944
  }
@@ -14913,6 +14953,26 @@ Captured output:
14913
14953
  get isRunning() {
14914
14954
  return this._isRunning;
14915
14955
  }
14956
+ isIdleNow() {
14957
+ return !this._isRunning && !this.rendering && !this.renderTimeout && !this.updateScheduled && !this.immediateRerenderRequested;
14958
+ }
14959
+ resolveIdleIfNeeded() {
14960
+ if (!this.isIdleNow())
14961
+ return;
14962
+ const resolvers = this.idleResolvers.splice(0);
14963
+ for (const resolve4 of resolvers) {
14964
+ resolve4();
14965
+ }
14966
+ }
14967
+ idle() {
14968
+ if (this._isDestroyed)
14969
+ return Promise.resolve();
14970
+ if (this.isIdleNow())
14971
+ return Promise.resolve();
14972
+ return new Promise((resolve4) => {
14973
+ this.idleResolvers.push(resolve4);
14974
+ });
14975
+ }
14916
14976
  get resolution() {
14917
14977
  return this._resolution;
14918
14978
  }
@@ -15515,6 +15575,9 @@ Captured output:
15515
15575
  clearTimeout(this.renderTimeout);
15516
15576
  this.renderTimeout = null;
15517
15577
  }
15578
+ if (!this.rendering) {
15579
+ this.resolveIdleIfNeeded();
15580
+ }
15518
15581
  }
15519
15582
  }
15520
15583
  destroy() {
@@ -15567,6 +15630,7 @@ Captured output:
15567
15630
  console.error("Error in onDestroy callback:", e instanceof Error ? e.stack : String(e));
15568
15631
  }
15569
15632
  }
15633
+ this.resolveIdleIfNeeded();
15570
15634
  }
15571
15635
  startRenderLoop() {
15572
15636
  if (!this._isRunning)
@@ -15575,12 +15639,12 @@ Captured output:
15575
15639
  this.frameCount = 0;
15576
15640
  this.lastFpsTime = this.lastTime;
15577
15641
  this.currentFps = 0;
15578
- this.targetFrameTime = 1000 / this.targetFps;
15579
15642
  this.loop();
15580
15643
  }
15581
15644
  async loop() {
15582
15645
  if (this.rendering || this._isDestroyed)
15583
15646
  return;
15647
+ this.renderTimeout = null;
15584
15648
  this.rendering = true;
15585
15649
  if (this.renderTimeout) {
15586
15650
  clearTimeout(this.renderTimeout);
@@ -15630,16 +15694,21 @@ Captured output:
15630
15694
  if (this.gatherStats) {
15631
15695
  this.collectStatSample(overallFrameTime);
15632
15696
  }
15633
- if (this._isRunning) {
15634
- const delay = Math.max(1, this.targetFrameTime - Math.floor(overallFrameTime));
15635
- this.renderTimeout = setTimeout(() => this.loop(), delay);
15697
+ if (this._isRunning || this.immediateRerenderRequested) {
15698
+ const targetFrameTime = this.immediateRerenderRequested ? this.minTargetFrameTime : this.targetFrameTime;
15699
+ const delay = Math.max(1, targetFrameTime - Math.floor(overallFrameTime));
15700
+ this.immediateRerenderRequested = false;
15701
+ this.renderTimeout = setTimeout(() => {
15702
+ this.renderTimeout = null;
15703
+ this.loop();
15704
+ }, delay);
15705
+ } else {
15706
+ clearTimeout(this.renderTimeout);
15707
+ this.renderTimeout = null;
15636
15708
  }
15637
15709
  }
15638
15710
  this.rendering = false;
15639
- if (this.immediateRerenderRequested) {
15640
- this.immediateRerenderRequested = false;
15641
- this.loop();
15642
- }
15711
+ this.resolveIdleIfNeeded();
15643
15712
  }
15644
15713
  intermediateRender() {
15645
15714
  this.immediateRerenderRequested = true;
@@ -15817,8 +15886,8 @@ Captured output:
15817
15886
  return this._paletteDetectionPromise;
15818
15887
  }
15819
15888
  if (!this._paletteDetector) {
15820
- const isTmux = this.capabilities?.terminal?.name?.toLowerCase()?.includes("tmux");
15821
- this._paletteDetector = createTerminalPalette(this.stdin, this.stdout, this.writeOut.bind(this), isTmux);
15889
+ const isLegacyTmux = this.capabilities?.terminal?.name?.toLowerCase()?.includes("tmux") && this.capabilities?.terminal?.version?.localeCompare("3.6") < 0;
15890
+ this._paletteDetector = createTerminalPalette(this.stdin, this.stdout, this.writeOut.bind(this), isLegacyTmux);
15822
15891
  }
15823
15892
  this._paletteDetectionPromise = this._paletteDetector.detect(options).then((result) => {
15824
15893
  this._cachedPalette = result;
@@ -15831,5 +15900,5 @@ Captured output:
15831
15900
 
15832
15901
  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
15902
 
15834
- //# debugId=CC37CF80C128F71F64756E2164756E21
15835
- //# sourceMappingURL=index-aedd54rx.js.map
15903
+ //# debugId=E61ED12D8C1C497964756E2164756E21
15904
+ //# sourceMappingURL=index-0razn4m6.js.map