@opentui/core 0.4.5 → 0.5.0

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.
Files changed (43) hide show
  1. package/README.md +4 -4
  2. package/Renderable.d.ts +3 -0
  3. package/audio.d.ts +202 -1
  4. package/buffer.d.ts +3 -0
  5. package/{chunk-bun-t2myhmwd.js → chunk-bun-ctxxvhwz.js} +1181 -147
  6. package/chunk-bun-ctxxvhwz.js.map +62 -0
  7. package/{chunk-bun-tkm837n2.js → chunk-bun-v3e63tzw.js} +147 -37
  8. package/chunk-bun-v3e63tzw.js.map +32 -0
  9. package/{chunk-node-51kpf0mz.js → chunk-node-1j69hr31.js} +147 -37
  10. package/chunk-node-1j69hr31.js.map +32 -0
  11. package/{chunk-node-q0cwyvm9.js → chunk-node-savhj5rp.js} +1181 -147
  12. package/chunk-node-savhj5rp.js.map +61 -0
  13. package/image.d.ts +105 -0
  14. package/index.bun.js +2131 -89
  15. package/index.bun.js.map +6 -4
  16. package/index.d.ts +1 -0
  17. package/index.node.js +2131 -89
  18. package/index.node.js.map +7 -3
  19. package/lib/env.d.ts +1 -0
  20. package/lib/stdin-parser.d.ts +5 -0
  21. package/node-assets.js +5 -2
  22. package/node-assets.js.map +3 -3
  23. package/package.json +10 -10
  24. package/parser.worker.js +5 -2
  25. package/parser.worker.js.map +3 -3
  26. package/platform/ffi.d.ts +2 -0
  27. package/renderables/Image.d.ts +44 -0
  28. package/renderables/index.d.ts +1 -0
  29. package/renderer.d.ts +14 -0
  30. package/testing.bun.js +4 -3
  31. package/testing.bun.js.map +3 -3
  32. package/testing.js +4 -3
  33. package/testing.js.map +3 -3
  34. package/text-buffer-view.d.ts +2 -5
  35. package/types.d.ts +8 -0
  36. package/yoga.bun.js +1 -1
  37. package/yoga.js +1 -1
  38. package/zig-structs.d.ts +45 -24
  39. package/zig.d.ts +70 -7
  40. package/chunk-bun-t2myhmwd.js.map +0 -62
  41. package/chunk-bun-tkm837n2.js.map +0 -32
  42. package/chunk-node-51kpf0mz.js.map +0 -32
  43. package/chunk-node-q0cwyvm9.js.map +0 -61
@@ -41,7 +41,7 @@ import {
41
41
  toArrayBuffer,
42
42
  treeSitterToTextChunks,
43
43
  yoga_default
44
- } from "./chunk-bun-t2myhmwd.js";
44
+ } from "./chunk-bun-ctxxvhwz.js";
45
45
 
46
46
  // src/Renderable.ts
47
47
  import { EventEmitter } from "events";
@@ -1257,6 +1257,7 @@ class Renderable extends BaseRenderable {
1257
1257
  }
1258
1258
  destroySelf() {}
1259
1259
  processMouseEvent(event) {
1260
+ event.currentTarget = this;
1260
1261
  this._mouseListener?.call(this, event);
1261
1262
  this._mouseListeners[event.type]?.call(this, event);
1262
1263
  this.onMouseEvent(event);
@@ -1365,6 +1366,7 @@ class Renderable extends BaseRenderable {
1365
1366
 
1366
1367
  class RootRenderable extends Renderable {
1367
1368
  renderList = [];
1369
+ _currentRenderable;
1368
1370
  appliedLayoutGeneration = -1;
1369
1371
  appliedRenderListRevision = -1;
1370
1372
  renderListReusable = false;
@@ -1386,7 +1388,16 @@ class RootRenderable extends Renderable {
1386
1388
  this.yogaNode.setFlexDirection(0 /* Column */);
1387
1389
  this.calculateLayout();
1388
1390
  }
1391
+ get currentRenderable() {
1392
+ return this._currentRenderable;
1393
+ }
1394
+ takeCurrentRenderable() {
1395
+ const renderable = this._currentRenderable;
1396
+ this._currentRenderable = undefined;
1397
+ return renderable;
1398
+ }
1389
1399
  render(buffer, deltaTime) {
1400
+ this._currentRenderable = undefined;
1390
1401
  if (!this.visible)
1391
1402
  return;
1392
1403
  for (const renderable of this._ctx.getLifecyclePasses()) {
@@ -1415,7 +1426,9 @@ class RootRenderable extends Renderable {
1415
1426
  switch (command.action) {
1416
1427
  case "render":
1417
1428
  if (!command.renderable.isDestroyed) {
1429
+ this._currentRenderable = command.renderable;
1418
1430
  command.renderable.render(buffer, deltaTime);
1431
+ this._currentRenderable = undefined;
1419
1432
  }
1420
1433
  break;
1421
1434
  case "pushScissorRect":
@@ -6268,6 +6281,9 @@ class EditBufferRenderable extends Renderable {
6268
6281
  }
6269
6282
  }
6270
6283
 
6284
+ // src/renderer.ts
6285
+ import { appendFileSync, writeFileSync } from "fs";
6286
+
6271
6287
  // src/ansi.ts
6272
6288
  var ANSI = {
6273
6289
  switchToAlternateScreen: "\x1B[?1049h",
@@ -6445,10 +6461,11 @@ function isPixelResolutionResponse(sequence) {
6445
6461
  function parsePixelResolution(sequence) {
6446
6462
  const match = sequence.match(/\x1b\[4;(\d+);(\d+)t/);
6447
6463
  if (match) {
6448
- return {
6449
- width: parseInt(match[2]),
6450
- height: parseInt(match[1])
6451
- };
6464
+ const width = Number(match[2]);
6465
+ const height = Number(match[1]);
6466
+ if (!Number.isSafeInteger(width) || !Number.isSafeInteger(height) || width > 2147483647 || height > 2147483647)
6467
+ return null;
6468
+ return { width, height };
6452
6469
  }
6453
6470
  return null;
6454
6471
  }
@@ -6632,6 +6649,12 @@ registerEnvVar({
6632
6649
  type: "boolean",
6633
6650
  default: false
6634
6651
  });
6652
+ registerEnvVar({
6653
+ name: "OTUI_STDIN_LOG",
6654
+ description: "Write the raw stdin byte stream to this file for debugging.",
6655
+ type: "string",
6656
+ default: ""
6657
+ });
6635
6658
  registerEnvVar({
6636
6659
  name: "OTUI_SHOW_STATS",
6637
6660
  description: "Show the debug overlay at startup.",
@@ -6716,18 +6739,25 @@ var CHAR_FLAG_MASK = 3221225472 >>> 0;
6716
6739
  class ScrollbackSnapshotRenderContext extends EventEmitter5 {
6717
6740
  width;
6718
6741
  height;
6742
+ terminalWidth;
6743
+ terminalHeight;
6744
+ resolution;
6719
6745
  frameId = 0;
6720
6746
  widthMethod;
6721
- capabilities = null;
6747
+ capabilities;
6722
6748
  hasSelection = false;
6723
6749
  currentFocusedRenderable = null;
6724
6750
  keyInput;
6725
6751
  _internalKeyInput;
6726
6752
  lifecyclePasses = new Set;
6727
- constructor(width, height, widthMethod) {
6753
+ constructor(width, height, widthMethod, terminalWidth = width, terminalHeight = height, resolution = null, capabilities = null) {
6728
6754
  super();
6729
6755
  this.width = width;
6730
6756
  this.height = height;
6757
+ this.terminalWidth = terminalWidth;
6758
+ this.terminalHeight = terminalHeight;
6759
+ this.resolution = resolution;
6760
+ this.capabilities = capabilities;
6731
6761
  this.widthMethod = widthMethod;
6732
6762
  this.keyInput = new KeyHandler;
6733
6763
  this._internalKeyInput = new InternalKeyHandler;
@@ -6782,6 +6812,7 @@ var DEFAULT_FORWARDED_ENV_KEYS = [
6782
6812
  "ZELLIJ_PANE_ID",
6783
6813
  "TERM",
6784
6814
  "OPENTUI_GRAPHICS",
6815
+ "OPENTUI_IMAGE_PROTOCOL",
6785
6816
  "TERM_PROGRAM",
6786
6817
  "TERM_PROGRAM_VERSION",
6787
6818
  "TERM_FEATURES",
@@ -6842,6 +6873,7 @@ class MouseEvent {
6842
6873
  modifiers;
6843
6874
  scroll;
6844
6875
  target;
6876
+ currentTarget = null;
6845
6877
  isDragging;
6846
6878
  _propagationStopped = false;
6847
6879
  _defaultPrevented = false;
@@ -6906,6 +6938,8 @@ var CliRenderEvents;
6906
6938
  ((CliRenderEvents2) => {
6907
6939
  CliRenderEvents2["RESIZE"] = "resize";
6908
6940
  CliRenderEvents2["FRAME"] = "frame";
6941
+ CliRenderEvents2["RENDER_ERROR"] = "render:error";
6942
+ CliRenderEvents2["HANDLER_ERROR"] = "handler:error";
6909
6943
  CliRenderEvents2["EXTERNAL_OUTPUT"] = "external_output";
6910
6944
  CliRenderEvents2["FOCUS"] = "focus";
6911
6945
  CliRenderEvents2["BLUR"] = "blur";
@@ -6966,6 +7000,7 @@ class CliRenderer extends EventEmitter5 {
6966
7000
  postProcessFns = [];
6967
7001
  backgroundColor = RGBA.fromInts(0, 0, 0, 0);
6968
7002
  waitingForPixelResolution = false;
7003
+ pixelResolutionRequeryPending = false;
6969
7004
  clock;
6970
7005
  rendering = false;
6971
7006
  renderingNative = false;
@@ -7070,6 +7105,7 @@ class CliRenderer extends EventEmitter5 {
7070
7105
  idleResolvers = [];
7071
7106
  _debugInputs = [];
7072
7107
  _debugModeEnabled = env.OTUI_DEBUG;
7108
+ stdinLogPath = env.OTUI_STDIN_LOG;
7073
7109
  handleError = ((error) => {
7074
7110
  console.error(error);
7075
7111
  if (this._openConsoleOnError) {
@@ -7803,7 +7839,7 @@ Captured external output:
7803
7839
  const startOnNewLine = options.startOnNewLine ?? true;
7804
7840
  const tailColumn = renderer.getPendingSplitTailColumn();
7805
7841
  const firstLineOffset = !startOnNewLine && tailColumn > 0 && tailColumn < renderer.width ? tailColumn : 0;
7806
- const snapshotContext = new ScrollbackSnapshotRenderContext(renderer.width, 1, renderer.widthMethod);
7842
+ const snapshotContext = new ScrollbackSnapshotRenderContext(renderer.width, 1, renderer.widthMethod, renderer._terminalWidth, renderer._terminalHeight, renderer.resolution, renderer.capabilities);
7807
7843
  let firstLineOffsetOwner = null;
7808
7844
  const renderContext = Object.create(snapshotContext);
7809
7845
  Object.defineProperty(renderContext, "claimFirstLineOffset", {
@@ -7837,6 +7873,10 @@ Captured external output:
7837
7873
  let surfaceWidth = renderer.width;
7838
7874
  let surfaceHeight = 1;
7839
7875
  let surfaceWidthMethod = renderer.widthMethod;
7876
+ let surfaceTerminalWidth = renderer._terminalWidth;
7877
+ let surfaceTerminalHeight = renderer._terminalHeight;
7878
+ let surfaceResolutionWidth = renderer.resolution?.width ?? null;
7879
+ let surfaceResolutionHeight = renderer.resolution?.height ?? null;
7840
7880
  let surfaceDestroyed = false;
7841
7881
  let hasRendered = false;
7842
7882
  let nextCommitStartOnNewLine = startOnNewLine;
@@ -7857,7 +7897,7 @@ Captured external output:
7857
7897
  }
7858
7898
  };
7859
7899
  const assertGeometryStillCurrent = () => {
7860
- if (renderer.width !== surfaceWidth || renderer.widthMethod !== surfaceWidthMethod) {
7900
+ if (renderer.width !== surfaceWidth || renderer.widthMethod !== surfaceWidthMethod || renderer._terminalWidth !== surfaceTerminalWidth || renderer._terminalHeight !== surfaceTerminalHeight || (renderer.resolution?.width ?? null) !== surfaceResolutionWidth || (renderer.resolution?.height ?? null) !== surfaceResolutionHeight) {
7861
7901
  throw new Error("ScrollbackSurface.commitRows requires render() after renderer geometry changes");
7862
7902
  }
7863
7903
  };
@@ -7918,6 +7958,10 @@ Captured external output:
7918
7958
  const widthMethod = renderer.widthMethod;
7919
7959
  snapshotContext.width = width;
7920
7960
  snapshotContext.widthMethod = widthMethod;
7961
+ snapshotContext.terminalWidth = renderer._terminalWidth;
7962
+ snapshotContext.terminalHeight = renderer._terminalHeight;
7963
+ snapshotContext.resolution = renderer.resolution;
7964
+ snapshotContext.capabilities = renderer.capabilities;
7921
7965
  publicRoot.width = width;
7922
7966
  const renderPass = (height) => {
7923
7967
  snapshotContext.height = height;
@@ -7943,6 +7987,10 @@ Captured external output:
7943
7987
  surfaceWidth = width;
7944
7988
  surfaceHeight = measuredHeight;
7945
7989
  surfaceWidthMethod = widthMethod;
7990
+ surfaceTerminalWidth = renderer._terminalWidth;
7991
+ surfaceTerminalHeight = renderer._terminalHeight;
7992
+ surfaceResolutionWidth = renderer.resolution?.width ?? null;
7993
+ surfaceResolutionHeight = renderer.resolution?.height ?? null;
7946
7994
  hasRendered = true;
7947
7995
  return;
7948
7996
  }
@@ -7952,6 +8000,10 @@ Captured external output:
7952
8000
  surfaceWidth = width;
7953
8001
  surfaceHeight = targetHeight;
7954
8002
  surfaceWidthMethod = widthMethod;
8003
+ surfaceTerminalWidth = renderer._terminalWidth;
8004
+ surfaceTerminalHeight = renderer._terminalHeight;
8005
+ surfaceResolutionWidth = renderer.resolution?.width ?? null;
8006
+ surfaceResolutionHeight = renderer.resolution?.height ?? null;
7955
8007
  hasRendered = true;
7956
8008
  };
7957
8009
  const settleSurface = async (timeoutMs = 2000) => {
@@ -8051,7 +8103,7 @@ Captured external output:
8051
8103
  if (this._screenMode !== "split-footer" || this._externalOutputMode !== "capture-stdout") {
8052
8104
  throw new Error('writeToScrollback requires screenMode "split-footer" and externalOutputMode "capture-stdout"');
8053
8105
  }
8054
- const snapshotContext = new ScrollbackSnapshotRenderContext(this.width, this.height, this.widthMethod);
8106
+ const snapshotContext = new ScrollbackSnapshotRenderContext(this.width, this.height, this.widthMethod, this._terminalWidth, this._terminalHeight, this.resolution, this.capabilities);
8055
8107
  const snapshot = write({
8056
8108
  width: this.width,
8057
8109
  widthMethod: this.widthMethod,
@@ -8226,7 +8278,7 @@ Captured external output:
8226
8278
  }
8227
8279
  }
8228
8280
  createStdoutSnapshotCommit(line, trailingNewline) {
8229
- const snapshotContext = new ScrollbackSnapshotRenderContext(this.width, 1, this.widthMethod);
8281
+ const snapshotContext = new ScrollbackSnapshotRenderContext(this.width, 1, this.widthMethod, this._terminalWidth, this._terminalHeight, this.resolution, this.capabilities);
8230
8282
  const maxWidth = Math.max(1, this.width);
8231
8283
  const lineCells = [...line];
8232
8284
  const rowColumns = Math.min(lineCells.length, maxWidth);
@@ -8310,6 +8362,7 @@ Captured external output:
8310
8362
  let acceptedCommits = 0;
8311
8363
  let nativeBackpressured = false;
8312
8364
  let nativeFailed = false;
8365
+ let nextRenderOffset = this.renderOffset;
8313
8366
  for (const [index, commit] of commits.entries()) {
8314
8367
  const forceCommit = forceFooterRepaint && index === lastCommitIndex;
8315
8368
  const beginFrame = index === 0;
@@ -8323,14 +8376,10 @@ Captured external output:
8323
8376
  nativeFailed = true;
8324
8377
  break;
8325
8378
  }
8326
- this.renderOffset = nativeResult.renderOffset;
8327
- this.recordSplitCommit(commit);
8379
+ nextRenderOffset = nativeResult.renderOffset;
8328
8380
  hasCommittedOutput = true;
8329
8381
  acceptedCommits++;
8330
8382
  }
8331
- if (acceptedCommits > 0) {
8332
- this.externalOutputQueue.drop(acceptedCommits);
8333
- }
8334
8383
  if (nativeFailed) {
8335
8384
  return this.reportNativeRenderFailure();
8336
8385
  }
@@ -8338,6 +8387,12 @@ Captured external output:
8338
8387
  this.scheduleRenderAfterFeedIdle();
8339
8388
  return "backpressured";
8340
8389
  }
8390
+ if (acceptedCommits > 0) {
8391
+ this.renderOffset = nextRenderOffset;
8392
+ for (const commit of commits.slice(0, acceptedCommits))
8393
+ this.recordSplitCommit(commit);
8394
+ this.externalOutputQueue.drop(acceptedCommits);
8395
+ }
8341
8396
  if (!hasCommittedOutput) {
8342
8397
  const nativeResult = this.lib.repaintSplitFooter(this.rendererPtr, this.getSplitPinnedRenderOffset(), forceFooterRepaint);
8343
8398
  if (nativeResult.status === NATIVE_RENDER_STATUS_SKIPPED) {
@@ -8709,6 +8764,9 @@ Captured external output:
8709
8764
  const data = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
8710
8765
  if (!this.stdinParser)
8711
8766
  return;
8767
+ if (this.stdinLogPath) {
8768
+ appendFileSync(this.stdinLogPath, data);
8769
+ }
8712
8770
  try {
8713
8771
  this.stdinParser.push(data);
8714
8772
  this.drainStdinParser();
@@ -8815,6 +8873,12 @@ Captured external output:
8815
8873
  });
8816
8874
  }
8817
8875
  handleStdinEvent(event) {
8876
+ if (this._controlState === "explicit_suspended" /* EXPLICIT_SUSPENDED */) {
8877
+ if (event.type === "response" && isPixelResolutionResponse(event.sequence)) {
8878
+ this.dispatchSequenceHandlers(event.sequence);
8879
+ }
8880
+ return;
8881
+ }
8818
8882
  switch (event.type) {
8819
8883
  case "key":
8820
8884
  if (this.dispatchSequenceHandlers(event.raw)) {
@@ -8858,16 +8922,25 @@ Captured external output:
8858
8922
  }
8859
8923
  }
8860
8924
  setupInput() {
8925
+ if (this.stdinLogPath) {
8926
+ writeFileSync(this.stdinLogPath, Buffer.alloc(0), { mode: 384 });
8927
+ }
8861
8928
  for (const handler of this.prependedInputHandlers) {
8862
8929
  this.addInputHandler(handler);
8863
8930
  }
8864
8931
  this.addInputHandler((sequence) => {
8865
8932
  if (isPixelResolutionResponse(sequence) && this.waitingForPixelResolution) {
8933
+ this.waitingForPixelResolution = false;
8934
+ if (this.pixelResolutionRequeryPending) {
8935
+ this.updateStdinParserProtocolContext({ pixelResolutionQueryActive: false });
8936
+ this.queryPixelResolution();
8937
+ return true;
8938
+ }
8866
8939
  const resolution = parsePixelResolution(sequence);
8867
8940
  if (resolution) {
8868
8941
  this._resolution = resolution;
8942
+ this.requestRender();
8869
8943
  }
8870
- this.waitingForPixelResolution = false;
8871
8944
  this.updateStdinParserProtocolContext({ pixelResolutionQueryActive: false }, true);
8872
8945
  return true;
8873
8946
  }
@@ -8884,7 +8957,7 @@ Captured external output:
8884
8957
  }
8885
8958
  dispatchMouseEvent(target, attributes) {
8886
8959
  const event = new MouseEvent(target, attributes);
8887
- target.processMouseEvent(event);
8960
+ this.sendMouseEvent(target, event);
8888
8961
  if (this.autoFocus && event.type === "down" && event.button === 0 /* LEFT */ && !event.defaultPrevented) {
8889
8962
  let current = target;
8890
8963
  while (current) {
@@ -8897,6 +8970,15 @@ Captured external output:
8897
8970
  }
8898
8971
  return event;
8899
8972
  }
8973
+ sendMouseEvent(target, event) {
8974
+ try {
8975
+ target.processMouseEvent(event);
8976
+ } catch (error) {
8977
+ const handled = this.emit("handler:error" /* HANDLER_ERROR */, { error, event });
8978
+ if (!handled)
8979
+ console.error("Error in mouse handler:", error);
8980
+ }
8981
+ }
8900
8982
  processSingleMouseEvent(mouseEvent) {
8901
8983
  if (this._splitHeight > 0) {
8902
8984
  if (mouseEvent.y < this.renderOffset) {
@@ -8924,7 +9006,7 @@ Captured external output:
8924
9006
  const scrollTarget = maybeRenderable2 ?? fallbackTarget;
8925
9007
  if (scrollTarget) {
8926
9008
  const event2 = new MouseEvent(scrollTarget, mouseEvent);
8927
- scrollTarget.processMouseEvent(event2);
9009
+ this.sendMouseEvent(scrollTarget, event2);
8928
9010
  }
8929
9011
  return true;
8930
9012
  }
@@ -8947,7 +9029,7 @@ Captured external output:
8947
9029
  ...mouseEvent,
8948
9030
  isDragging: true
8949
9031
  });
8950
- maybeRenderable.processMouseEvent(event2);
9032
+ this.sendMouseEvent(maybeRenderable, event2);
8951
9033
  }
8952
9034
  return true;
8953
9035
  }
@@ -8957,7 +9039,7 @@ Captured external output:
8957
9039
  ...mouseEvent,
8958
9040
  isDragging: true
8959
9041
  });
8960
- maybeRenderable.processMouseEvent(event2);
9042
+ this.sendMouseEvent(maybeRenderable, event2);
8961
9043
  }
8962
9044
  this.finishSelection();
8963
9045
  return true;
@@ -8975,7 +9057,7 @@ Captured external output:
8975
9057
  ...mouseEvent,
8976
9058
  type: "out"
8977
9059
  });
8978
- this.lastOverRenderable.processMouseEvent(event2);
9060
+ this.sendMouseEvent(this.lastOverRenderable, event2);
8979
9061
  }
8980
9062
  this.lastOverRenderable = maybeRenderable;
8981
9063
  if (maybeRenderable) {
@@ -8984,12 +9066,12 @@ Captured external output:
8984
9066
  type: "over",
8985
9067
  source: this.capturedRenderable
8986
9068
  });
8987
- maybeRenderable.processMouseEvent(event2);
9069
+ this.sendMouseEvent(maybeRenderable, event2);
8988
9070
  }
8989
9071
  }
8990
9072
  if (this.capturedRenderable && mouseEvent.type !== "up") {
8991
9073
  const event2 = new MouseEvent(this.capturedRenderable, mouseEvent);
8992
- this.capturedRenderable.processMouseEvent(event2);
9074
+ this.sendMouseEvent(this.capturedRenderable, event2);
8993
9075
  return true;
8994
9076
  }
8995
9077
  if (this.capturedRenderable && mouseEvent.type === "up") {
@@ -8997,15 +9079,15 @@ Captured external output:
8997
9079
  ...mouseEvent,
8998
9080
  type: "drag-end"
8999
9081
  });
9000
- this.capturedRenderable.processMouseEvent(event2);
9001
- this.capturedRenderable.processMouseEvent(new MouseEvent(this.capturedRenderable, mouseEvent));
9082
+ this.sendMouseEvent(this.capturedRenderable, event2);
9083
+ this.sendMouseEvent(this.capturedRenderable, new MouseEvent(this.capturedRenderable, mouseEvent));
9002
9084
  if (maybeRenderable) {
9003
9085
  const event3 = new MouseEvent(maybeRenderable, {
9004
9086
  ...mouseEvent,
9005
9087
  type: "drop",
9006
9088
  source: this.capturedRenderable
9007
9089
  });
9008
- maybeRenderable.processMouseEvent(event3);
9090
+ this.sendMouseEvent(maybeRenderable, event3);
9009
9091
  }
9010
9092
  this.lastOverRenderable = this.capturedRenderable;
9011
9093
  this.lastOverRenderableNum = this.capturedRenderable.num;
@@ -9050,7 +9132,7 @@ Captured external output:
9050
9132
  };
9051
9133
  if (lastOver && !lastOver.isDestroyed) {
9052
9134
  const event = new MouseEvent(lastOver, { ...baseEvent, type: "out" });
9053
- lastOver.processMouseEvent(event);
9135
+ this.sendMouseEvent(lastOver, event);
9054
9136
  }
9055
9137
  this.lastOverRenderable = hitRenderable;
9056
9138
  this.lastOverRenderableNum = hitId;
@@ -9059,7 +9141,7 @@ Captured external output:
9059
9141
  ...baseEvent,
9060
9142
  type: "over"
9061
9143
  });
9062
- hitRenderable.processMouseEvent(event);
9144
+ this.sendMouseEvent(hitRenderable, event);
9063
9145
  }
9064
9146
  }
9065
9147
  setMousePointer(style) {
@@ -9119,6 +9201,10 @@ Captured external output:
9119
9201
  }, this.resizeDebounceDelay);
9120
9202
  }
9121
9203
  queryPixelResolution() {
9204
+ this.pixelResolutionRequeryPending = true;
9205
+ if (this._controlState === "explicit_suspended" /* EXPLICIT_SUSPENDED */ || this.waitingForPixelResolution)
9206
+ return;
9207
+ this.pixelResolutionRequeryPending = false;
9122
9208
  this.waitingForPixelResolution = true;
9123
9209
  this.updateStdinParserProtocolContext({ pixelResolutionQueryActive: true });
9124
9210
  this.lib.queryPixelResolution(this.rendererPtr);
@@ -9136,6 +9222,7 @@ Captured external output:
9136
9222
  const visiblePreviousSplitHeight = pendingSplitFooterTransition?.sourceHeight ?? previousGeometry.effectiveFooterHeight;
9137
9223
  this._terminalWidth = width;
9138
9224
  this._terminalHeight = height;
9225
+ this._resolution = null;
9139
9226
  this.queryPixelResolution();
9140
9227
  this.setCapturedRenderable(undefined);
9141
9228
  this.stdinParser?.resetMouseState();
@@ -9328,14 +9415,16 @@ Captured external output:
9328
9415
  this._suspendedMouseEnabled = this._useMouse;
9329
9416
  this.disableMouse();
9330
9417
  this.removeExitListeners();
9331
- this.waitingForPixelResolution = false;
9332
9418
  this.updateStdinParserProtocolContext({
9333
9419
  privateCapabilityRepliesActive: false,
9334
- pixelResolutionQueryActive: false,
9420
+ pixelResolutionQueryActive: this.waitingForPixelResolution,
9335
9421
  explicitWidthCprActive: false,
9336
9422
  startupCursorCprActive: false
9337
9423
  });
9338
- this.stdinParser?.reset();
9424
+ if (this.stdinParser?.hasPendingPixelResolutionResponse())
9425
+ this.stdinParser.pausePendingTimeout();
9426
+ else
9427
+ this.stdinParser?.reset();
9339
9428
  this.stdin.removeListener("data", this.stdinListener);
9340
9429
  this.themeModeState.cancelRefresh();
9341
9430
  this.lib.suspendRenderer(this.rendererPtr);
@@ -9348,7 +9437,13 @@ Captured external output:
9348
9437
  if (this.stdin.setRawMode) {
9349
9438
  this.stdin.setRawMode(true);
9350
9439
  }
9351
- while (this.stdin.read() !== null) {}
9440
+ let drained;
9441
+ while ((drained = this.stdin.read()) !== null)
9442
+ this.stdinListener(drained);
9443
+ if (this.stdinParser?.hasPendingPixelResolutionResponse())
9444
+ this.stdinParser.pausePendingTimeout();
9445
+ else
9446
+ this.stdinParser?.reset();
9352
9447
  this.stdin.on("data", this.stdinListener);
9353
9448
  this.stdin.resume();
9354
9449
  this.addExitListeners();
@@ -9373,6 +9468,9 @@ Captured external output:
9373
9468
  }
9374
9469
  this.forceFullRepaintRequested = true;
9375
9470
  this._controlState = this._previousControlState;
9471
+ if (this.pixelResolutionRequeryPending)
9472
+ this.queryPixelResolution();
9473
+ this.stdinParser?.resumePendingTimeout();
9376
9474
  if (this._previousControlState === "auto_started" /* AUTO_STARTED */ || this._previousControlState === "explicit_started" /* EXPLICIT_STARTED */) {
9377
9475
  this.internalStart();
9378
9476
  } else {
@@ -9453,6 +9551,7 @@ Captured external output:
9453
9551
  this.themeModeState.cancelRefresh();
9454
9552
  this._isRunning = false;
9455
9553
  this.waitingForPixelResolution = false;
9554
+ this.pixelResolutionRequeryPending = false;
9456
9555
  this.updateStdinParserProtocolContext({
9457
9556
  privateCapabilityRepliesActive: false,
9458
9557
  pixelResolutionQueryActive: false,
@@ -9587,12 +9686,12 @@ Captured external output:
9587
9686
  async loop() {
9588
9687
  if (this.rendering || this._isDestroyed)
9589
9688
  return;
9590
- this.renderTimeout = null;
9591
- this.rendering = true;
9592
9689
  if (this.renderTimeout) {
9593
9690
  this.clock.clearTimeout(this.renderTimeout);
9594
9691
  this.renderTimeout = null;
9595
9692
  }
9693
+ this.rendering = true;
9694
+ let renderFailed = false;
9596
9695
  try {
9597
9696
  this._frameId++;
9598
9697
  const now = this.normalizeClockTime(this.clock.now(), this.lastTime);
@@ -9685,11 +9784,22 @@ Captured external output:
9685
9784
  this.renderTimeout = null;
9686
9785
  }
9687
9786
  }
9787
+ } catch (error) {
9788
+ renderFailed = true;
9789
+ const renderError = error instanceof Error ? error : new Error(String(error));
9790
+ const event = { error: renderError, renderable: this.root.takeCurrentRenderable() };
9791
+ const handled = this.emit("render:error" /* RENDER_ERROR */, event);
9792
+ if (!handled)
9793
+ this.handleError(renderError);
9688
9794
  } finally {
9689
9795
  this.rendering = false;
9690
9796
  if (this._destroyPending) {
9691
9797
  this.finalizeDestroy();
9692
9798
  }
9799
+ if (renderFailed && (this._isRunning || this.immediateRerenderRequested) && !this._isDestroyed) {
9800
+ this.immediateRerenderRequested = false;
9801
+ this.scheduleRenderTimer();
9802
+ }
9693
9803
  this.resolveIdleIfNeeded();
9694
9804
  }
9695
9805
  }
@@ -10043,5 +10153,5 @@ Captured external output:
10043
10153
 
10044
10154
  export { h, isVNode, maybeMakeRenderable, wrapWithDelegates, instantiate, delegate, LayoutEvents, RenderableEvents, isRenderable, BaseRenderable, Renderable, RootRenderable, TextBufferView, EditBuffer, EditorView, convertThemeToStyles, SyntaxStyle, ANSI, BoxRenderable, TextBufferRenderable, CodeRenderable, isTextNodeRenderable, TextNodeRenderable, RootTextNodeRenderable, TextRenderable, NativeSpanFeed, defaultKeyAliases, mergeKeyAliases, mergeKeyBindings, getKeyBindingAction, buildKeyBindingsMap, capture, ConsolePosition, TerminalConsole, getObjectsInViewport, EditBufferRenderableEvents, isEditBufferRenderable, EditBufferRenderable, buildKittyKeyboardFlags, MouseEvent, MouseButton, createCliRenderer, CliRenderEvents, RendererControlState, CliRenderer };
10045
10155
 
10046
- //# debugId=E9CA53B9C2D4F00B64756E2164756E21
10047
- //# sourceMappingURL=chunk-bun-tkm837n2.js.map
10156
+ //# debugId=0B8AB9B3E8D95E9A64756E2164756E21
10157
+ //# sourceMappingURL=chunk-bun-v3e63tzw.js.map