@simon_he/vue-tui 1.1.2 → 1.1.4

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 (52) hide show
  1. package/dist/{TMermaidText-frVr8Ysb.js → TMermaidText-wLnMMvVS.js} +1 -1
  2. package/dist/{TSelect-tJ87rKPM.js → TSelect-CMBOOFwK.js} +4 -4
  3. package/dist/{TTree-CGdE-CYu.js → TTree-kk8ntrpg.js} +6 -5
  4. package/dist/agent/mermaid.d.cts +2 -2
  5. package/dist/agent/mermaid.d.ts +2 -2
  6. package/dist/agent.cjs +3896 -13616
  7. package/dist/agent.js +25 -82
  8. package/dist/{block-source-CrlmaBM5.js → block-source-D3YGTErb.js} +447 -326
  9. package/dist/cli.cjs +52 -15
  10. package/dist/cli.js +69 -14
  11. package/dist/core.js +3 -3
  12. package/dist/{hyperlink-_1FAj7Wq.js → create-terminal-Db_-UGVQ.js} +474 -102
  13. package/dist/{dom-renderer-DXx8fWzD.js → dom-renderer-BfwAEQMf.js} +3 -2
  14. package/dist/experimental.cjs +99 -66
  15. package/dist/experimental.js +20 -74
  16. package/dist/hyperlink-clbb_ha_.js +100 -0
  17. package/dist/index.js +8 -8
  18. package/dist/{linkify-D68T7rdW.js → linkify-CL9wwnZN.js} +2 -2
  19. package/dist/markdown.cjs +3376 -13056
  20. package/dist/markdown.d.cts +4 -0
  21. package/dist/markdown.d.ts +4 -0
  22. package/dist/markdown.js +79 -8
  23. package/dist/math-image-BZhmfUeu.js +308 -0
  24. package/dist/mermaid-uEfRItDe.js +1205 -0
  25. package/dist/mermaid.cjs +1089 -3
  26. package/dist/mermaid.d.cts +4 -0
  27. package/dist/mermaid.d.ts +4 -0
  28. package/dist/mermaid.js +7 -5
  29. package/dist/{rect-DUpeDfBg.js → rect-JzWMJxxc.js} +1 -1
  30. package/dist/renderer/cli/stdout-renderer.d.ts +44 -0
  31. package/dist/renderer/terminal-graphics.d.ts +44 -0
  32. package/dist/renderer-dom.js +4 -4
  33. package/dist/{terminal-graphics-Bbe83wSr.js → terminal-graphics-DWZrl3oh.js} +85 -2
  34. package/dist/{tlog-theme-Bul2Na3u.js → tlog-theme-DqnF_zNe.js} +5 -4
  35. package/dist/vue/components/TAgentTerminalGraphic.d.ts +1 -1
  36. package/dist/vue/components/TMarkdownText.d.ts +70 -2
  37. package/dist/vue/components/TMermaidImage.d.ts +733 -0
  38. package/dist/vue/components/TMermaidText.d.ts +2 -2
  39. package/dist/vue/components/TVirtualMarkdown.d.ts +70 -2
  40. package/dist/vue/markdown/ast.d.ts +5 -0
  41. package/dist/vue/markdown/document.d.ts +3 -0
  42. package/dist/vue/markdown/math-image.d.ts +68 -0
  43. package/dist/vue/markdown/math.d.ts +2 -0
  44. package/dist/vue/markdown/theme.d.ts +12 -0
  45. package/dist/vue/markdown/types.d.ts +12 -2
  46. package/dist/vue/mermaid/beautiful-mermaid.d.ts +4 -4
  47. package/dist/vue/mermaid/mermaid-image.d.ts +65 -0
  48. package/dist/vue.js +9 -9
  49. package/package.json +20 -3
  50. package/dist/mermaid-BNhM1jAZ.js +0 -123
  51. package/dist/width-GqllnV8C.js +0 -474
  52. /package/dist/{ansi-palette-CH6jc2Z7.js → ansi-palette-BHF1rN7R.js} +0 -0
package/dist/cli.cjs CHANGED
@@ -7869,7 +7869,28 @@ function createStdoutRenderer(terminal, options) {
7869
7869
  let output = (options == null ? void 0 : options.output) ?? import_node_process6.default.stdout;
7870
7870
  if (!output)
7871
7871
  throw new Error("createStdoutRenderer requires a Node stdout-like output");
7872
- let out = output, outputFd = Number(out.fd), canUseSyncStdout = (options == null ? void 0 : options.output) == null && Number.isInteger(outputFd) && outputFd === 1, fingerprintOwner = Symbol("stdout-renderer"), ownsFingerprintFn = !1, fingerprintTerminal = terminal, canInstallTerminalFingerprintFn = () => typeof fingerprintTerminal.setFingerprintFn == "function" && typeof fingerprintTerminal.getRowFingerprints == "function", outputIsTTY = !!out.isTTY, outputAllowsOsc8Links = out.isTTY !== !1, clear = (options == null ? void 0 : options.clear) ?? !0, hideCursor = (options == null ? void 0 : options.hideCursor) ?? !0, altScreen = (options == null ? void 0 : options.altScreen) ?? outputIsTTY, keepLineWrapDisabled = altScreen && outputIsTTY, defaultBg = (options == null ? void 0 : options.defaultBg) == null || (options == null ? void 0 : options.defaultBg) === "transparent" ? void 0 : (options == null ? void 0 : options.defaultBg) ?? "black", palette = (options == null ? void 0 : options.palette) ?? null, trackResize = (options == null ? void 0 : options.trackResize) ?? !0, getImeAnchor = options == null ? void 0 : options.getImeAnchor, allowFileUrls = (options == null ? void 0 : options.allowFileUrls) ?? !1, cliLatency = getCliLatencyProfiler(), profiler = createTuiProfiler("stdout-renderer", {
7872
+ let out = output, outputFd = Number(out.fd), canUseSyncStdout = (options == null ? void 0 : options.output) == null && Number.isInteger(outputFd) && outputFd === 1, fingerprintOwner = Symbol("stdout-renderer"), ownsFingerprintFn = !1, fingerprintTerminal = terminal, canInstallTerminalFingerprintFn = () => typeof fingerprintTerminal.setFingerprintFn == "function" && typeof fingerprintTerminal.getRowFingerprints == "function", outputIsTTY = !!out.isTTY, outputAllowsOsc8Links = out.isTTY !== !1, clear = (options == null ? void 0 : options.clear) ?? !0, hideCursor = (options == null ? void 0 : options.hideCursor) ?? !0, altScreen = (options == null ? void 0 : options.altScreen) ?? outputIsTTY, keepLineWrapDisabled = altScreen && outputIsTTY, defaultBg = (options == null ? void 0 : options.defaultBg) == null || (options == null ? void 0 : options.defaultBg) === "transparent" ? void 0 : (options == null ? void 0 : options.defaultBg) ?? "black", palette = (options == null ? void 0 : options.palette) ?? null, trackResize = (options == null ? void 0 : options.trackResize) ?? !0, getImeAnchor = options == null ? void 0 : options.getImeAnchor, anchorMode = (options == null ? void 0 : options.anchor) === "bottom" ? "bottom" : "top", screenRowsFn = typeof (options == null ? void 0 : options.screenRows) == "function" ? options.screenRows : void 0, rawBarGap = Math.floor(Number((options == null ? void 0 : options.barGap) ?? 0)), barGap = Number.isFinite(rawBarGap) ? Math.max(0, rawBarGap) : 0, rowOffset = 0, scrollRegionBottom = 0, bottomRegionInitialized = !1, resolveScreenRows = () => {
7873
+ var _a2;
7874
+ let rows = 0;
7875
+ if (screenRowsFn) {
7876
+ let v = Math.floor(Number(screenRowsFn()));
7877
+ Number.isFinite(v) && v > 0 && (rows = v);
7878
+ }
7879
+ if (!rows) {
7880
+ let v = Math.floor(Number(out.rows));
7881
+ Number.isFinite(v) && v > 0 && (rows = v);
7882
+ }
7883
+ if (!rows) {
7884
+ let v = Math.floor(Number((_a2 = import_node_process6.default.stdout) == null ? void 0 : _a2.rows));
7885
+ Number.isFinite(v) && v > 0 && (rows = v);
7886
+ }
7887
+ return rows;
7888
+ }, computeRowOffset = (bufferRows) => {
7889
+ if (anchorMode !== "bottom")
7890
+ return 0;
7891
+ let offset = resolveScreenRows() - bufferRows;
7892
+ return Number.isFinite(offset) && offset > 0 ? offset : 0;
7893
+ }, allowFileUrls = (options == null ? void 0 : options.allowFileUrls) ?? !1, cliLatency = getCliLatencyProfiler(), profiler = createTuiProfiler("stdout-renderer", {
7873
7894
  fileWriter: (options == null ? void 0 : options.profileFileWriter) ?? nodeProfilerFileWriter,
7874
7895
  defaultLogDest: "file",
7875
7896
  defaultLogPath: defaultVueTuiProfileLogPath()
@@ -8426,7 +8447,7 @@ function createStdoutRenderer(terminal, options) {
8426
8447
  function clearGraphicRect(rect) {
8427
8448
  let blank = " ".repeat(Math.max(0, rect.w)), out2 = "";
8428
8449
  for (let row = 0; row < rect.h; row++)
8429
- out2 += `\x1B[${rect.y + row + 1};${rect.x + 1}H${blank}`;
8450
+ out2 += `\x1B[${rect.y + row + 1 + rowOffset};${rect.x + 1}H${blank}`;
8430
8451
  return out2;
8431
8452
  }
8432
8453
  function sameGraphicRect(a, b) {
@@ -8887,7 +8908,7 @@ function createStdoutRenderer(terminal, options) {
8887
8908
  let start = rowCursorToCol1.length;
8888
8909
  rowCursorToCol1.length = rows, rowClearToEol.length = rows;
8889
8910
  for (let y = start; y < rows; y++)
8890
- rowCursorToCol1[y] = `\x1B[${y + 1};1H`, rowClearToEol[y] = `\x1B[${y + 1};1H\x1B[K`;
8911
+ rowCursorToCol1[y] = `\x1B[${y + 1 + rowOffset};1H`, rowClearToEol[y] = `\x1B[${y + 1 + rowOffset};1H\x1B[K`;
8891
8912
  }, rowHasNonDefaultBlankCell = (sourceFP, sourceTextIds, sourceHrefIds, y, cols) => {
8892
8913
  if (!fpCols || y < 0 || y >= fpRows)
8893
8914
  return !1;
@@ -9106,6 +9127,21 @@ function createStdoutRenderer(terminal, options) {
9106
9127
  `doRender state: size=${size.cols}x${size.rows}, dirtyRows=${(dirtyRows == null ? void 0 : dirtyRows.length) ?? "null"}, scrollOps=${(scrollOperations == null ? void 0 : scrollOperations.length) ?? 0}, rowsOnlyBaseline=${rowsOnlyResizeBaseline ? "true" : "false"}, allowGraphicsOnlyWithoutBaseline=${allowGraphicsOnlyWithoutBaseline ? "true" : "false"}, activeGraphics=${activeGraphics.size}, pendingGraphics=${graphicsToRender.length}, pendingGraphicClears=${graphicsClearsToRender.length}`
9107
9128
  );
9108
9129
  let terminalGraphicsBlockScrollRegions = !1;
9130
+ if (anchorMode === "bottom") {
9131
+ dirtyRows = null, scrollOperations = null;
9132
+ let nextRowOffset = computeRowOffset(size.rows);
9133
+ nextRowOffset !== rowOffset && (rowOffset = nextRowOffset, rowCursorToCol1.length = 0, rowClearToEol.length = 0);
9134
+ let nextRegionBottom = Math.max(1, nextRowOffset - barGap);
9135
+ if (outputIsTTY && !bottomRegionInitialized) {
9136
+ let screenRows = resolveScreenRows();
9137
+ if (screenRows > 0 && nextRowOffset > 0) {
9138
+ let reservedRows = Math.max(0, screenRows - nextRegionBottom), scrollCount = Math.min(screenRows, reservedRows + 1);
9139
+ out.write(`\x1B[r\x1B[${screenRows};1H${`
9140
+ `.repeat(scrollCount)}`), bottomRegionInitialized = !0;
9141
+ }
9142
+ }
9143
+ outputIsTTY && nextRegionBottom !== scrollRegionBottom && (scrollRegionBottom = nextRegionBottom, out.write(`\x1B[1;${nextRegionBottom}r`));
9144
+ }
9109
9145
  ensureRowEscapes(Math.max(size.rows, lastRenderedRows)), ensureFingerprints(size.cols, size.rows);
9110
9146
  let bgSeq = openBg(defaultBg), bgOnlyStyle = { bg: defaultBg }, bgKey = styleKeyFromParts({ bg: defaultBg }), blankFP = cellFingerprintFromStyleKey(" ", bgKey);
9111
9147
  if (rowsOnlyResizeBaseline && rowsOnlyResizeBaseline.cols === size.cols) {
@@ -9276,7 +9312,7 @@ function createStdoutRenderer(terminal, options) {
9276
9312
  }
9277
9313
  })(), fpPrevValid && rowsToRender && (currentFP.set(prevFP), currentHrefIds.set(prevHrefIds), currentTextIds.set(prevTextIds));
9278
9314
  let frameHasTerminalGraphics = activeGraphics.size > 0 || graphicsClearsToRender.length > 0 || graphicsToRender.length > 0, useFrameSyncOutput = useSyncOutput || isGhostty && frameHasTerminalGraphics, frameParts = [];
9279
- frameParts.push(useFrameSyncOutput ? SYNC_START : ""), frameParts.push(allowGraphicsOnlyWithoutBaseline || keepLineWrapDisabled ? "" : "\x1B[?7l"), frameParts.push(SGR_RESET, bgSeq), hideCursor && !getImeAnchor && frameParts.push(CURSOR_HOME);
9315
+ frameParts.push(useFrameSyncOutput ? SYNC_START : ""), frameParts.push(allowGraphicsOnlyWithoutBaseline || keepLineWrapDisabled ? "" : "\x1B[?7l"), frameParts.push(SGR_RESET, bgSeq), hideCursor && !getImeAnchor && frameParts.push(rowOffset > 0 ? `\x1B[${rowOffset + 1}H` : CURSOR_HOME);
9280
9316
  let lastRenderedY = -1, lastRenderWasFullRow = !1, hasFrameOutput = !1, activeStyleKey = null, activeStyle = {
9281
9317
  fg: null,
9282
9318
  bg: defaultBg,
@@ -9316,11 +9352,11 @@ function createStdoutRenderer(terminal, options) {
9316
9352
  hasFrameOutput = !0;
9317
9353
  let pushCursorFixAfterCell = (parts, cellX, cell) => {
9318
9354
  let afterX = cellX + (cell.width ?? 1);
9319
- afterX >= size.cols || parts.push(`\x1B[${y + 1};${afterX + 1}H`);
9355
+ afterX >= size.cols || parts.push(`\x1B[${y + 1 + rowOffset};${afterX + 1}H`);
9320
9356
  };
9321
9357
  disableCursorPos || (closeActiveHrefBeforeCursorMove(), spanStart === 0 && lastRenderWasFullRow && y === lastRenderedY + 1 ? frameParts.push(`\r
9322
9358
  `) : frameParts.push(
9323
- spanStart === 0 ? rowCursorToCol1[y] : `\x1B[${y + 1};${spanStart + 1}H`
9359
+ spanStart === 0 ? rowCursorToCol1[y] : `\x1B[${y + 1 + rowOffset};${spanStart + 1}H`
9324
9360
  ));
9325
9361
  let currentKey = null, currentStyle = null, currentTextParts = rowTextPartsScratch;
9326
9362
  currentTextParts.length = 0;
@@ -9666,7 +9702,7 @@ function createStdoutRenderer(terminal, options) {
9666
9702
  fingerprintRow(row, y, size.cols), renderRowPreservingTerminalGraphics(y, row);
9667
9703
  }
9668
9704
  }
9669
- if (!rowsToRender && lastRenderedRows > size.rows && !rowsOnlyResizeBaseline) {
9705
+ if (!rowsToRender && lastRenderedRows > size.rows && !rowsOnlyResizeBaseline && anchorMode !== "bottom") {
9670
9706
  let extraRows = lastRenderedRows - size.rows;
9671
9707
  activeStyleKey !== bgKey && (frameParts.push(SGR_RESET, bgSeq), activeStyleKey = bgKey);
9672
9708
  for (let i = 0; i < extraRows; i++)
@@ -9688,7 +9724,7 @@ function createStdoutRenderer(terminal, options) {
9688
9724
  let erase = `\x1B[${Math.max(0, rect.w)}X`, clearStyle = bgSeq, out2 = "";
9689
9725
  for (let row = 0; row < rect.h; row++) {
9690
9726
  let y = rect.y + row, spans = terminalGraphicTextPreserveSpans.get(y), preservedGraphicSpan = !(overlayTouchedRowSet != null && overlayTouchedRowSet.has(y)) && !!(spans != null && spans.some((span) => span.start < rect.x + rect.w && span.end > rect.x));
9691
- (!rowsToRender || rowWasPaintedByTextRenderer(y)) && !preservedGraphicSpan || (out2 += `\x1B[${y + 1};${rect.x + 1}H${clearStyle}${erase}${SGR_RESET}`);
9727
+ (!rowsToRender || rowWasPaintedByTextRenderer(y)) && !preservedGraphicSpan || (out2 += `\x1B[${y + 1 + rowOffset};${rect.x + 1}H${clearStyle}${erase}${SGR_RESET}`);
9692
9728
  }
9693
9729
  return out2;
9694
9730
  }, commitTerminalGraphicsState = null, restoreTerminalGraphicsAfterWriteFailure = null, terminalGraphicsMetrics = null;
@@ -9708,7 +9744,7 @@ function createStdoutRenderer(terminal, options) {
9708
9744
  return !1;
9709
9745
  let cell = rect ? { x: rect.x, y: rect.y } : clampCellToViewport(fallbackCell, size);
9710
9746
  return frameParts.push(
9711
- countGraphicsBytes(`\x1B[${cell.y + 1};${cell.x + 1}H`),
9747
+ countGraphicsBytes(`\x1B[${cell.y + 1 + rowOffset};${cell.x + 1}H`),
9712
9748
  countGraphicsBytes(maybeWrapTerminalGraphic(sequence)),
9713
9749
  countGraphicsBytes(SGR_RESET)
9714
9750
  ), !0;
@@ -9854,14 +9890,14 @@ function createStdoutRenderer(terminal, options) {
9854
9890
  let anchor = getImeAnchor();
9855
9891
  if (anchor) {
9856
9892
  let { x, y } = clampCellToViewport(anchor, size);
9857
- (hasFrameOutput || x !== lastCursorX || y !== lastCursorY) && (hasFrameOutput = !0, emittedCursorPos = { x, y }, closeActiveHrefBeforeCursorMove(), frameParts.push(`\x1B[${y + 1};${x + 1}H`));
9893
+ (hasFrameOutput || x !== lastCursorX || y !== lastCursorY) && (hasFrameOutput = !0, emittedCursorPos = { x, y }, closeActiveHrefBeforeCursorMove(), frameParts.push(`\x1B[${y + 1 + rowOffset};${x + 1}H`));
9858
9894
  }
9859
9895
  }
9860
9896
  if (!hasFrameOutput) {
9861
9897
  commitRenderBaseline(), isDebugEnabled() && getDebugLog().render(" No-op frame skipped"), cliLatency == null || cliLatency.recordStdoutNoOutput();
9862
9898
  return;
9863
9899
  }
9864
- enableOsc8Links && activeStyle.href && frameParts.push(OSC8_CLOSE), frameParts.push(SGR_RESET), hideCursor && !getImeAnchor && frameParts.push(CURSOR_HOME), frameParts.push(allowGraphicsOnlyWithoutBaseline || keepLineWrapDisabled ? "" : "\x1B[?7h"), frameParts.push(useFrameSyncOutput ? SYNC_END : "");
9900
+ enableOsc8Links && activeStyle.href && frameParts.push(OSC8_CLOSE), frameParts.push(SGR_RESET), hideCursor && !getImeAnchor && frameParts.push(rowOffset > 0 ? `\x1B[${rowOffset + 1}H` : CURSOR_HOME), frameParts.push(allowGraphicsOnlyWithoutBaseline || keepLineWrapDisabled ? "" : "\x1B[?7h"), frameParts.push(useFrameSyncOutput ? SYNC_END : "");
9865
9901
  let frame = frameParts.join(""), frameBytes = import_node_buffer3.Buffer.byteLength(frame, "utf8");
9866
9902
  if (profiler && profiler.recordRender({
9867
9903
  durationMs: profiler.now() - renderStart,
@@ -10172,7 +10208,7 @@ function createStdoutRenderer(terminal, options) {
10172
10208
  rowsOnlyResizeRepaintTimer = null, repaintRowsAfterRowsOnlyResize();
10173
10209
  }, ROWS_ONLY_RESIZE_REPAINT_DELAY_MS);
10174
10210
  }
10175
- altScreen && outputIsTTY && out.write("\x1B[?1049h"), keepLineWrapDisabled && out.write("\x1B[?7l"), hideCursor && out.write("\x1B[?25l"), clear && out.write(`${SGR_RESET}${openBg(defaultBg)}\x1B[2J\x1B[H${SGR_RESET}`);
10211
+ altScreen && outputIsTTY && out.write("\x1B[?1049h"), keepLineWrapDisabled && out.write("\x1B[?7l"), hideCursor && out.write("\x1B[?25l"), clear && anchorMode !== "bottom" && out.write(`${SGR_RESET}${openBg(defaultBg)}\x1B[2J\x1B[H${SGR_RESET}`);
10176
10212
  let off = terminal.on("commit", ({ dirtyRows, scrollOperations, sync }) => {
10177
10213
  if (suppressNextResizeCommitRender)
10178
10214
  return;
@@ -10225,7 +10261,7 @@ function createStdoutRenderer(terminal, options) {
10225
10261
  { cellX: x, cellY: y },
10226
10262
  { cols: size.cols, rows: size.rows }
10227
10263
  );
10228
- out.write(`\x1B[${cy + 1};${cx + 1}H`), lastCursorX = cx, lastCursorY = cy;
10264
+ out.write(`\x1B[${cy + 1 + rowOffset};${cx + 1}H`), lastCursorX = cx, lastCursorY = cy;
10229
10265
  }
10230
10266
  function showCursor(visible) {
10231
10267
  disposed || out.write(visible ? "\x1B[?25h" : "\x1B[?25l");
@@ -10244,7 +10280,7 @@ function createStdoutRenderer(terminal, options) {
10244
10280
  if (visibleRect && (clearParts.push(clearGraphicRect(visibleRect)), wroteClear = !0), active.clearSequence && (visibleRect || !clearSequenceNeedsVisibleCell(active.clearSequence, active.protocol))) {
10245
10281
  let cell = visibleRect ? { x: visibleRect.x, y: visibleRect.y } : clampCellToViewport({ cellX: active.x, cellY: active.y }, size);
10246
10282
  clearParts.push(
10247
- `\x1B[${cell.y + 1};${cell.x + 1}H`,
10283
+ `\x1B[${cell.y + 1 + rowOffset};${cell.x + 1}H`,
10248
10284
  maybeWrapTerminalGraphic(active.clearSequence)
10249
10285
  ), wroteClear = !0;
10250
10286
  }
@@ -10274,7 +10310,7 @@ function createStdoutRenderer(terminal, options) {
10274
10310
  } catch {
10275
10311
  }
10276
10312
  try {
10277
- keepLineWrapDisabled && out.write("\x1B[?7h"), hideCursor && out.write("\x1B[?25h"), altScreen && outputIsTTY && out.write("\x1B[?1049l");
10313
+ keepLineWrapDisabled && out.write("\x1B[?7h"), hideCursor && out.write("\x1B[?25h"), altScreen && outputIsTTY && out.write("\x1B[?1049l"), anchorMode === "bottom" && outputIsTTY && scrollRegionBottom > 0 && out.write("\x1B[r");
10278
10314
  } catch (err) {
10279
10315
  disposeError == null && (disposeError = err);
10280
10316
  }
@@ -10285,6 +10321,7 @@ function createStdoutRenderer(terminal, options) {
10285
10321
  capabilities: STDOUT_RENDERER_CAPABILITIES,
10286
10322
  graphicsCapabilities,
10287
10323
  render,
10324
+ forceRender: () => render(void 0, !0),
10288
10325
  dispose,
10289
10326
  setCursor,
10290
10327
  showCursor,
package/dist/cli.js CHANGED
@@ -9919,6 +9919,35 @@ function createStdoutRenderer(terminal, options) {
9919
9919
  let palette = (options === null || options === void 0 ? void 0 : options.palette) ?? null;
9920
9920
  const trackResize = (options === null || options === void 0 ? void 0 : options.trackResize) ?? true;
9921
9921
  const getImeAnchor = options === null || options === void 0 ? void 0 : options.getImeAnchor;
9922
+ const anchorMode = (options === null || options === void 0 ? void 0 : options.anchor) === "bottom" ? "bottom" : "top";
9923
+ const screenRowsFn = typeof (options === null || options === void 0 ? void 0 : options.screenRows) === "function" ? options.screenRows : void 0;
9924
+ const rawBarGap = Math.floor(Number((options === null || options === void 0 ? void 0 : options.barGap) ?? 0));
9925
+ const barGap = Number.isFinite(rawBarGap) ? Math.max(0, rawBarGap) : 0;
9926
+ let rowOffset = 0;
9927
+ let scrollRegionBottom = 0;
9928
+ let bottomRegionInitialized = false;
9929
+ const resolveScreenRows = () => {
9930
+ let rows = 0;
9931
+ if (screenRowsFn) {
9932
+ const v = Math.floor(Number(screenRowsFn()));
9933
+ if (Number.isFinite(v) && v > 0) rows = v;
9934
+ }
9935
+ if (!rows) {
9936
+ const v = Math.floor(Number(out.rows));
9937
+ if (Number.isFinite(v) && v > 0) rows = v;
9938
+ }
9939
+ if (!rows) {
9940
+ var _stdout;
9941
+ const v = Math.floor(Number((_stdout = process.stdout) === null || _stdout === void 0 ? void 0 : _stdout.rows));
9942
+ if (Number.isFinite(v) && v > 0) rows = v;
9943
+ }
9944
+ return rows;
9945
+ };
9946
+ const computeRowOffset = (bufferRows) => {
9947
+ if (anchorMode !== "bottom") return 0;
9948
+ const offset = resolveScreenRows() - bufferRows;
9949
+ return Number.isFinite(offset) && offset > 0 ? offset : 0;
9950
+ };
9922
9951
  const allowFileUrls = (options === null || options === void 0 ? void 0 : options.allowFileUrls) ?? false;
9923
9952
  const cliLatency = getCliLatencyProfiler();
9924
9953
  const profiler = createTuiProfiler("stdout-renderer", {
@@ -10617,7 +10646,7 @@ function createStdoutRenderer(terminal, options) {
10617
10646
  function clearGraphicRect(rect) {
10618
10647
  const blank = " ".repeat(Math.max(0, rect.w));
10619
10648
  let out$1 = "";
10620
- for (let row = 0; row < rect.h; row++) out$1 += `\u001B[${rect.y + row + 1};${rect.x + 1}H${blank}`;
10649
+ for (let row = 0; row < rect.h; row++) out$1 += `\u001B[${rect.y + row + 1 + rowOffset};${rect.x + 1}H${blank}`;
10621
10650
  return out$1;
10622
10651
  }
10623
10652
  function sameGraphicRect(a, b) {
@@ -11238,8 +11267,8 @@ function createStdoutRenderer(terminal, options) {
11238
11267
  rowCursorToCol1.length = rows;
11239
11268
  rowClearToEol.length = rows;
11240
11269
  for (let y = start; y < rows; y++) {
11241
- rowCursorToCol1[y] = `\u001B[${y + 1};1H`;
11242
- rowClearToEol[y] = `\u001B[${y + 1};1H\u001B[K`;
11270
+ rowCursorToCol1[y] = `\u001B[${y + 1 + rowOffset};1H`;
11271
+ rowClearToEol[y] = `\u001B[${y + 1 + rowOffset};1H\u001B[K`;
11243
11272
  }
11244
11273
  };
11245
11274
  const rowHasNonDefaultBlankCell = (sourceFP, sourceTextIds, sourceHrefIds, y, cols) => {
@@ -11549,6 +11578,30 @@ function createStdoutRenderer(terminal, options) {
11549
11578
  allowNextGraphicsOnlyRenderWithoutBaseline = false;
11550
11579
  if (isDebugEnabled()) getDebugLog().render(`doRender state: size=${size.cols}x${size.rows}, dirtyRows=${(dirtyRows === null || dirtyRows === void 0 ? void 0 : dirtyRows.length) ?? "null"}, scrollOps=${(scrollOperations === null || scrollOperations === void 0 ? void 0 : scrollOperations.length) ?? 0}, rowsOnlyBaseline=${rowsOnlyResizeBaseline ? "true" : "false"}, allowGraphicsOnlyWithoutBaseline=${allowGraphicsOnlyWithoutBaseline ? "true" : "false"}, activeGraphics=${activeGraphics.size}, pendingGraphics=${graphicsToRender.length}, pendingGraphicClears=${graphicsClearsToRender.length}`);
11551
11580
  let terminalGraphicsBlockScrollRegions = false;
11581
+ if (anchorMode === "bottom") {
11582
+ dirtyRows = null;
11583
+ scrollOperations = null;
11584
+ const nextRowOffset = computeRowOffset(size.rows);
11585
+ if (nextRowOffset !== rowOffset) {
11586
+ rowOffset = nextRowOffset;
11587
+ rowCursorToCol1.length = 0;
11588
+ rowClearToEol.length = 0;
11589
+ }
11590
+ const nextRegionBottom = Math.max(1, nextRowOffset - barGap);
11591
+ if (outputIsTTY && !bottomRegionInitialized) {
11592
+ const screenRows = resolveScreenRows();
11593
+ if (screenRows > 0 && nextRowOffset > 0) {
11594
+ const reservedRows = Math.max(0, screenRows - nextRegionBottom);
11595
+ const scrollCount = Math.min(screenRows, reservedRows + 1);
11596
+ out.write(`\u001B[r\u001B[${screenRows};1H${"\n".repeat(scrollCount)}`);
11597
+ bottomRegionInitialized = true;
11598
+ }
11599
+ }
11600
+ if (outputIsTTY && nextRegionBottom !== scrollRegionBottom) {
11601
+ scrollRegionBottom = nextRegionBottom;
11602
+ out.write(`\u001B[1;${nextRegionBottom}r`);
11603
+ }
11604
+ }
11552
11605
  ensureRowEscapes(Math.max(size.rows, lastRenderedRows));
11553
11606
  ensureFingerprints(size.cols, size.rows);
11554
11607
  const bgSeq = openBg(defaultBg);
@@ -11806,7 +11859,7 @@ function createStdoutRenderer(terminal, options) {
11806
11859
  frameParts.push(useFrameSyncOutput ? SYNC_START : "");
11807
11860
  frameParts.push(allowGraphicsOnlyWithoutBaseline || keepLineWrapDisabled ? "" : "\x1B[?7l");
11808
11861
  frameParts.push(SGR_RESET, bgSeq);
11809
- if (hideCursor && !getImeAnchor) frameParts.push(CURSOR_HOME);
11862
+ if (hideCursor && !getImeAnchor) frameParts.push(rowOffset > 0 ? `\u001B[${rowOffset + 1}H` : CURSOR_HOME);
11810
11863
  let lastRenderedY = -1;
11811
11864
  let lastRenderWasFullRow = false;
11812
11865
  let hasFrameOutput = false;
@@ -11876,12 +11929,12 @@ function createStdoutRenderer(terminal, options) {
11876
11929
  const pushCursorFixAfterCell = (parts, cellX, cell) => {
11877
11930
  const afterX = cellX + (cell.width ?? 1);
11878
11931
  if (afterX >= size.cols) return;
11879
- parts.push(`\u001B[${y + 1};${afterX + 1}H`);
11932
+ parts.push(`\u001B[${y + 1 + rowOffset};${afterX + 1}H`);
11880
11933
  };
11881
11934
  if (!disableCursorPos) {
11882
11935
  closeActiveHrefBeforeCursorMove();
11883
11936
  if (spanStart === 0 && lastRenderWasFullRow && y === lastRenderedY + 1) frameParts.push("\r\n");
11884
- else frameParts.push(spanStart === 0 ? rowCursorToCol1[y] : `\u001B[${y + 1};${spanStart + 1}H`);
11937
+ else frameParts.push(spanStart === 0 ? rowCursorToCol1[y] : `\u001B[${y + 1 + rowOffset};${spanStart + 1}H`);
11885
11938
  }
11886
11939
  let currentKey = null;
11887
11940
  let currentStyle = null;
@@ -12313,7 +12366,7 @@ function createStdoutRenderer(terminal, options) {
12313
12366
  renderDirtySpans(y, row, spans, rewriteTail);
12314
12367
  }
12315
12368
  }
12316
- if (!rowsToRender && lastRenderedRows > size.rows && !rowsOnlyResizeBaseline) {
12369
+ if (!rowsToRender && lastRenderedRows > size.rows && !rowsOnlyResizeBaseline && anchorMode !== "bottom") {
12317
12370
  const extraRows = lastRenderedRows - size.rows;
12318
12371
  if (activeStyleKey !== bgKey) {
12319
12372
  frameParts.push(SGR_RESET, bgSeq);
@@ -12364,7 +12417,7 @@ function createStdoutRenderer(terminal, options) {
12364
12417
  const spans = terminalGraphicTextPreserveSpans.get(y);
12365
12418
  const preservedGraphicSpan = !(overlayTouchedRowSet === null || overlayTouchedRowSet === void 0 ? void 0 : overlayTouchedRowSet.has(y)) && Boolean(spans === null || spans === void 0 ? void 0 : spans.some((span) => span.start < rect.x + rect.w && span.end > rect.x));
12366
12419
  if ((!rowsToRender || rowWasPaintedByTextRenderer(y)) && !preservedGraphicSpan) continue;
12367
- out$1 += `\u001B[${y + 1};${rect.x + 1}H${clearStyle}${erase}${SGR_RESET}`;
12420
+ out$1 += `\u001B[${y + 1 + rowOffset};${rect.x + 1}H${clearStyle}${erase}${SGR_RESET}`;
12368
12421
  }
12369
12422
  return out$1;
12370
12423
  };
@@ -12410,7 +12463,7 @@ function createStdoutRenderer(terminal, options) {
12410
12463
  x: rect.x,
12411
12464
  y: rect.y
12412
12465
  } : clampCellToViewport(fallbackCell, size);
12413
- frameParts.push(countGraphicsBytes(`\u001B[${cell.y + 1};${cell.x + 1}H`), countGraphicsBytes(maybeWrapTerminalGraphic(sequence)), countGraphicsBytes(SGR_RESET));
12466
+ frameParts.push(countGraphicsBytes(`\u001B[${cell.y + 1 + rowOffset};${cell.x + 1}H`), countGraphicsBytes(maybeWrapTerminalGraphic(sequence)), countGraphicsBytes(SGR_RESET));
12414
12467
  return true;
12415
12468
  };
12416
12469
  const appendActiveGraphicProtocolClear = (active, rect) => {
@@ -12586,7 +12639,7 @@ function createStdoutRenderer(terminal, options) {
12586
12639
  y
12587
12640
  };
12588
12641
  closeActiveHrefBeforeCursorMove();
12589
- frameParts.push(`\u001B[${y + 1};${x + 1}H`);
12642
+ frameParts.push(`\u001B[${y + 1 + rowOffset};${x + 1}H`);
12590
12643
  }
12591
12644
  }
12592
12645
  }
@@ -12598,7 +12651,7 @@ function createStdoutRenderer(terminal, options) {
12598
12651
  }
12599
12652
  if (enableOsc8Links && activeStyle.href) frameParts.push(OSC8_CLOSE);
12600
12653
  frameParts.push(SGR_RESET);
12601
- if (hideCursor && !getImeAnchor) frameParts.push(CURSOR_HOME);
12654
+ if (hideCursor && !getImeAnchor) frameParts.push(rowOffset > 0 ? `\u001B[${rowOffset + 1}H` : CURSOR_HOME);
12602
12655
  frameParts.push(allowGraphicsOnlyWithoutBaseline || keepLineWrapDisabled ? "" : "\x1B[?7h");
12603
12656
  frameParts.push(useFrameSyncOutput ? SYNC_END : "");
12604
12657
  const frame = frameParts.join("");
@@ -13039,7 +13092,7 @@ function createStdoutRenderer(terminal, options) {
13039
13092
  if (altScreen && outputIsTTY) out.write("\x1B[?1049h");
13040
13093
  if (keepLineWrapDisabled) out.write("\x1B[?7l");
13041
13094
  if (hideCursor) out.write("\x1B[?25l");
13042
- if (clear) out.write(`${SGR_RESET}${openBg(defaultBg)}\u001B[2J\u001B[H${SGR_RESET}`);
13095
+ if (clear && anchorMode !== "bottom") out.write(`${SGR_RESET}${openBg(defaultBg)}\u001B[2J\u001B[H${SGR_RESET}`);
13043
13096
  const off = terminal.on("commit", ({ dirtyRows, scrollOperations, sync }) => {
13044
13097
  if (suppressNextResizeCommitRender) return;
13045
13098
  const deferRowsOnlyResizeCommit = rowsOnlyResizeRepaintTimer && (dirtyRows == null || dirtyRows.length >= terminal.size().rows);
@@ -13121,7 +13174,7 @@ function createStdoutRenderer(terminal, options) {
13121
13174
  cols: size.cols,
13122
13175
  rows: size.rows
13123
13176
  });
13124
- out.write(`\u001B[${cy + 1};${cx + 1}H`);
13177
+ out.write(`\u001B[${cy + 1 + rowOffset};${cx + 1}H`);
13125
13178
  lastCursorX = cx;
13126
13179
  lastCursorY = cy;
13127
13180
  }
@@ -13175,7 +13228,7 @@ function createStdoutRenderer(terminal, options) {
13175
13228
  cellX: active.x,
13176
13229
  cellY: active.y
13177
13230
  }, size);
13178
- clearParts.push(`\u001B[${cell.y + 1};${cell.x + 1}H`, maybeWrapTerminalGraphic(active.clearSequence));
13231
+ clearParts.push(`\u001B[${cell.y + 1 + rowOffset};${cell.x + 1}H`, maybeWrapTerminalGraphic(active.clearSequence));
13179
13232
  wroteClear = true;
13180
13233
  }
13181
13234
  if (wroteClear) terminalGraphicsClears++;
@@ -13211,6 +13264,7 @@ function createStdoutRenderer(terminal, options) {
13211
13264
  if (keepLineWrapDisabled) out.write("\x1B[?7h");
13212
13265
  if (hideCursor) out.write("\x1B[?25h");
13213
13266
  if (altScreen && outputIsTTY) out.write("\x1B[?1049l");
13267
+ if (anchorMode === "bottom" && outputIsTTY && scrollRegionBottom > 0) out.write("\x1B[r");
13214
13268
  } catch (err) {
13215
13269
  if (disposeError == null) disposeError = err;
13216
13270
  }
@@ -13237,6 +13291,7 @@ function createStdoutRenderer(terminal, options) {
13237
13291
  capabilities: STDOUT_RENDERER_CAPABILITIES,
13238
13292
  graphicsCapabilities,
13239
13293
  render,
13294
+ forceRender: () => render(void 0, true),
13240
13295
  dispose,
13241
13296
  setCursor,
13242
13297
  showCursor,
package/dist/core.js CHANGED
@@ -1,6 +1,6 @@
1
- import { TERMINAL_RENDER_PLANES, createTerminal, isSafeRelativeHref, parseAnsiSgr, sanitizeDomHref, sanitizeTerminalHref } from "./hyperlink-_1FAj7Wq.js";
2
- import { charCellWidth } from "./width-GqllnV8C.js";
3
- import { ansiColorRgb } from "./ansi-palette-CH6jc2Z7.js";
1
+ import { TERMINAL_RENDER_PLANES, charCellWidth, createTerminal, parseAnsiSgr } from "./create-terminal-Db_-UGVQ.js";
2
+ import { ansiColorRgb } from "./ansi-palette-BHF1rN7R.js";
3
+ import { isSafeRelativeHref, sanitizeDomHref, sanitizeTerminalHref } from "./hyperlink-clbb_ha_.js";
4
4
  import { firstNonEmptyEnv } from "./env-Cl8qmNFN.js";
5
5
  import { normalizeNewlines } from "./path-mnSgEpCm.js";
6
6
  import { parsePathQuery, resolveUserPath, suggestParentHint, suggestPaths } from "./path-suggest-Dndu4dTi.js";