@xmoon76/dsh-pi-tui 0.5.3 → 0.5.5
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/README.en.md +195 -150
- package/README.md +137 -103
- package/cordis.patch.yml +54 -2
- package/dist/application-runtime-CbBO4bY-.mjs +6860 -0
- package/dist/bootstrap-DLOydLLj.mjs +108410 -0
- package/dist/builtins.mjs +2 -3
- package/dist/client-bootstrap-DwSFzcTW.mjs +872 -0
- package/dist/context-summary-Bz0AGXa1.mjs +12027 -0
- package/dist/context-summary-D9mhxPXL.mjs +10015 -0
- package/dist/custom-items-CKrOBCox.mjs +655 -0
- package/dist/disposal-BYBbEpVY.mjs +54 -0
- package/dist/dispose-cause-BzcXo4hu.mjs +123 -0
- package/dist/dispose-cause-CNFuUnjR.mjs +24 -0
- package/dist/dist-C7QMk0ws.mjs +15431 -0
- package/dist/entry-control-DnduyDiw.mjs +92 -0
- package/dist/extension/advanced.d.mts +1 -1
- package/dist/extension/unstable.d.mts +1 -1
- package/dist/{extensions-DzpBiiYb.d.mts → extensions-Bte3XOt5.d.mts} +1 -1
- package/dist/{extensions-a-rxanjw.mjs → extensions-pcFiH7Qe.mjs} +1498 -410
- package/dist/extensions.d.mts +2 -2
- package/dist/extensions.mjs +1 -1
- package/dist/host-bootstrap-CKdfLkNS.mjs +188 -0
- package/dist/host-foundation-probe-CYHsbAw6.mjs +143 -0
- package/dist/host-prerequisites-9JBTtVNu.mjs +36 -0
- package/dist/host-runtime.d.mts +26 -0
- package/dist/host-runtime.mjs +450 -0
- package/dist/index.d.mts +9 -2
- package/dist/index.mjs +45779 -24480
- package/dist/local-client.mjs +1816 -0
- package/dist/local-discovery-CXnLT4GF.mjs +755 -0
- package/dist/local-discovery-DVFFpfBG.mjs +2 -0
- package/dist/local-host.mjs +1025 -0
- package/dist/local-transport-C9aonplC.mjs +513 -0
- package/dist/performance-host.d.mts +2 -2
- package/dist/performance-host.mjs +258 -1
- package/dist/{performance-view-jvvd8Jn7.mjs → performance-view-CfGvLZyD.mjs} +1 -1
- package/dist/pi-tui-remote-contribution-DRk6Tl3J.mjs +78 -0
- package/dist/pi-tui-terminal-progress-contract-CdBH9j78.mjs +70 -0
- package/dist/pi-tui-terminal-progress-contract-XTQKj-WW.mjs +905 -0
- package/dist/{public-types-gZi3iFNh.d.mts → public-types-Dgf1bDke.d.mts} +3 -3
- package/dist/{runtime-BtPH-UUb.mjs → runtime-Bh5OsftD.mjs} +1311 -1024
- package/dist/runtime-C5ROZqFj.mjs +2 -0
- package/dist/runtime-status-0lp9CM0V.mjs +1923 -0
- package/dist/session-4keoXjk0.mjs +10869 -0
- package/dist/session-B2zqv4wr.mjs +10869 -0
- package/dist/{startup-D5Xu8diR.mjs → startup-Ct2UUjUL.mjs} +55 -13
- package/dist/startup.d.mts +2 -1
- package/dist/startup.mjs +1 -1
- package/dist/terminal-progress-source-BhufrZ74.mjs +6000 -0
- package/dist/terminal-progress-source-CsBinCJ_.mjs +965 -0
- package/dist/visual-tools.d.mts +62 -0
- package/dist/visual-tools.mjs +556 -0
- package/generated/dsh-presets/README.md +1 -1
- package/package.json +145 -117
- package/dist/context-summary-CxUpNkA9.mjs +0 -2951
- package/dist/performance-host-BJT6scGF.mjs +0 -266
- package/dist/rolldown-runtime-8H4AJuhK.mjs +0 -14
- package/dist/session-BZLxhrPQ.mjs +0 -5697
- package/dist/terminal-progress-source-BlmksrSD.mjs +0 -2200
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as TUI_STARTUP_SERVICE } from "./startup-D5Xu8diR.mjs";
|
|
1
|
+
import { n as TUI_STARTUP_SERVICE } from "./startup-Ct2UUjUL.mjs";
|
|
3
2
|
import { createRequire } from "node:module";
|
|
4
3
|
import * as fs from "node:fs";
|
|
5
4
|
import { readFileSync } from "node:fs";
|
|
@@ -19,7 +18,41 @@ import { performance as performance$1 } from "node:perf_hooks";
|
|
|
19
18
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
20
19
|
import { EventEmitter } from "events";
|
|
21
20
|
import { Service } from "@deepseek-ai/cordis";
|
|
21
|
+
//#region \0rolldown/runtime.js
|
|
22
|
+
var __defProp = Object.defineProperty;
|
|
23
|
+
var __exportAll = (all, no_symbols) => {
|
|
24
|
+
let target = {};
|
|
25
|
+
for (var name in all) __defProp(target, name, {
|
|
26
|
+
get: all[name],
|
|
27
|
+
enumerable: true
|
|
28
|
+
});
|
|
29
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
//#endregion
|
|
22
33
|
//#region src/domain/footer/layout.ts
|
|
34
|
+
/** The per-id default `Hide in TSP` value (Owner-frozen): the three items
|
|
35
|
+
* that a capable TSP composer already carries are hidden by default; every
|
|
36
|
+
* other item keeps the historical TSP behavior. This is the EDITOR default
|
|
37
|
+
* (a capability shortage must never turn the editor's On into Off). */
|
|
38
|
+
function defaultHideInTsp(id) {
|
|
39
|
+
return id === "permission-preset" || id === "model" || id === "reasoning";
|
|
40
|
+
}
|
|
41
|
+
/** The ONE TSP effective-visibility decision for one placement. An explicit
|
|
42
|
+
* user boolean always wins; otherwise the three default-On ids hide only
|
|
43
|
+
* when their corresponding composer control is actually available (so the
|
|
44
|
+
* permission state never disappears on an old client without the control),
|
|
45
|
+
* and every other id stays visible. */
|
|
46
|
+
function hideFooterRefInTsp(ref, affordances) {
|
|
47
|
+
if (ref.hideInTsp !== void 0) return ref.hideInTsp;
|
|
48
|
+
if (!defaultHideInTsp(ref.id)) return false;
|
|
49
|
+
switch (ref.id) {
|
|
50
|
+
case "permission-preset": return affordances.permission;
|
|
51
|
+
case "model": return affordances.model;
|
|
52
|
+
case "reasoning": return affordances.reasoning;
|
|
53
|
+
default: return false;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
23
56
|
/** The semantic tone vocabulary a layout may reference. */
|
|
24
57
|
const TONES = /* @__PURE__ */ new Set([
|
|
25
58
|
"primary",
|
|
@@ -121,6 +154,13 @@ function parseItemRef(input, index) {
|
|
|
121
154
|
};
|
|
122
155
|
ref.importance = input.importance;
|
|
123
156
|
}
|
|
157
|
+
if (input.hideInTsp !== void 0) {
|
|
158
|
+
if (typeof input.hideInTsp !== "boolean") return {
|
|
159
|
+
kind: "error",
|
|
160
|
+
message: `item ${index}: hideInTsp must be a boolean`
|
|
161
|
+
};
|
|
162
|
+
ref.hideInTsp = input.hideInTsp;
|
|
163
|
+
}
|
|
124
164
|
return ref;
|
|
125
165
|
}
|
|
126
166
|
function parseRow(input, index) {
|
|
@@ -2810,7 +2850,7 @@ function detectCapabilitiesFromEnvironment(tmuxForwardsHyperlink) {
|
|
|
2810
2850
|
trueColor: hasTrueColorHint,
|
|
2811
2851
|
hyperlinks: true
|
|
2812
2852
|
};
|
|
2813
|
-
if (process.env.KITTY_WINDOW_ID || termProgram === "kitty") return {
|
|
2853
|
+
if (process.env.KITTY_WINDOW_ID || termProgram === "kitty" || termProgram === "tern") return {
|
|
2814
2854
|
images: "kitty",
|
|
2815
2855
|
trueColor: true,
|
|
2816
2856
|
hyperlinks: true
|
|
@@ -2893,6 +2933,97 @@ function setCapabilities(caps) {
|
|
|
2893
2933
|
}
|
|
2894
2934
|
const KITTY_PREFIX = "\x1B_G";
|
|
2895
2935
|
const ITERM2_PREFIX = "\x1B]1337;File=";
|
|
2936
|
+
/** The Kitty Unicode placeholder base character (Supplementary PUA, plane 16). */
|
|
2937
|
+
const KITTY_VIRTUAL_PLACEHOLDER = "";
|
|
2938
|
+
/** The virtual backend's component bound; a larger placement is not a managed A image. */
|
|
2939
|
+
const KITTY_VIRTUAL_MAX_CELLS = 297;
|
|
2940
|
+
function positiveIntegerControl(controls, key) {
|
|
2941
|
+
const value = controls[key];
|
|
2942
|
+
if (value === void 0 || value === "") return void 0;
|
|
2943
|
+
const parsed = Number(value);
|
|
2944
|
+
return Number.isInteger(parsed) && parsed > 0 ? parsed : void 0;
|
|
2945
|
+
}
|
|
2946
|
+
/**
|
|
2947
|
+
* Read one managed Unicode-placeholder placement anchor from a source line.
|
|
2948
|
+
*
|
|
2949
|
+
* This is a stateless parser for the virtual backend's ONE first-row anchor; it
|
|
2950
|
+
* does not synthesize geometry or touch the Native metadata table. A line whose
|
|
2951
|
+
* first Kitty APC is not exactly `a=p,U=1,q=2` with valid 1..297 `c`/`r` is not
|
|
2952
|
+
* a virtual anchor. The returned `sequence` is the exact source substring the
|
|
2953
|
+
* layout seam may move without rewriting any byte.
|
|
2954
|
+
*/
|
|
2955
|
+
function getKittyVirtualPlacementAnchor(line) {
|
|
2956
|
+
const start = line.indexOf(KITTY_PREFIX);
|
|
2957
|
+
if (start === -1) return void 0;
|
|
2958
|
+
const end = line.indexOf("\x1B\\", start + 3);
|
|
2959
|
+
if (end === -1) return void 0;
|
|
2960
|
+
const body = line.slice(start + 3, end);
|
|
2961
|
+
const separator = body.indexOf(";");
|
|
2962
|
+
if (separator === -1) return void 0;
|
|
2963
|
+
const controls = {};
|
|
2964
|
+
for (const part of body.slice(0, separator).split(",")) {
|
|
2965
|
+
const equals = part.indexOf("=");
|
|
2966
|
+
if (equals <= 0) continue;
|
|
2967
|
+
controls[part.slice(0, equals)] = part.slice(equals + 1);
|
|
2968
|
+
}
|
|
2969
|
+
if (controls.a !== "p" || controls.U !== "1" || controls.q !== "2") return void 0;
|
|
2970
|
+
const imageId = positiveIntegerControl(controls, "i");
|
|
2971
|
+
const placementId = positiveIntegerControl(controls, "p");
|
|
2972
|
+
const columns = positiveIntegerControl(controls, "c");
|
|
2973
|
+
const rows = positiveIntegerControl(controls, "r");
|
|
2974
|
+
if (imageId === void 0 || placementId === void 0) return void 0;
|
|
2975
|
+
if (columns === void 0 || rows === void 0) return void 0;
|
|
2976
|
+
if (columns > KITTY_VIRTUAL_MAX_CELLS || rows > KITTY_VIRTUAL_MAX_CELLS) return void 0;
|
|
2977
|
+
return {
|
|
2978
|
+
sequence: line.slice(start, end + 2),
|
|
2979
|
+
imageId,
|
|
2980
|
+
placementId,
|
|
2981
|
+
columns,
|
|
2982
|
+
rows
|
|
2983
|
+
};
|
|
2984
|
+
}
|
|
2985
|
+
const MANAGED_KITTY_VIRTUAL_MARKER_TERMINATOR = "\x1B\\";
|
|
2986
|
+
/**
|
|
2987
|
+
* Read the private provenance marker at the start of a source line. The marker
|
|
2988
|
+
* is NOT a Kitty graphics command and is never written to a real terminal; it
|
|
2989
|
+
* only says that the adjacent `a=p,U=1` anchor was produced by the managed
|
|
2990
|
+
* component for the same Core handle. A malformed prefix returns undefined; the
|
|
2991
|
+
* layout caller treats a line that starts with the prefix but does not parse as
|
|
2992
|
+
* an implementation error and refuses to paint it.
|
|
2993
|
+
*/
|
|
2994
|
+
function getManagedKittyVirtualMarker(line) {
|
|
2995
|
+
if (!line.startsWith("\x1B_pi:tmux-image:v1:i=")) return void 0;
|
|
2996
|
+
const end = line.indexOf(MANAGED_KITTY_VIRTUAL_MARKER_TERMINATOR, 21);
|
|
2997
|
+
if (end === -1) return void 0;
|
|
2998
|
+
const match = /^(\d{1,10}),p=(\d{1,10})$/.exec(line.slice(21, end));
|
|
2999
|
+
if (match === null) return void 0;
|
|
3000
|
+
const imageId = Number(match[1]);
|
|
3001
|
+
const placementId = Number(match[2]);
|
|
3002
|
+
if (!Number.isSafeInteger(imageId) || imageId < 1 || imageId > 4294967295) return void 0;
|
|
3003
|
+
if (!Number.isSafeInteger(placementId) || placementId < 1 || placementId > 4294967295) return void 0;
|
|
3004
|
+
return {
|
|
3005
|
+
sequence: line.slice(0, end + 2),
|
|
3006
|
+
imageId,
|
|
3007
|
+
placementId
|
|
3008
|
+
};
|
|
3009
|
+
}
|
|
3010
|
+
/** Whether the line carries at least one real Unicode placeholder cell. */
|
|
3011
|
+
function isKittyVirtualPlaceholderLine(line) {
|
|
3012
|
+
return line.includes(KITTY_VIRTUAL_PLACEHOLDER);
|
|
3013
|
+
}
|
|
3014
|
+
/**
|
|
3015
|
+
* Whether a placeholder row's own colors name the same image/placement as an
|
|
3016
|
+
* existing virtual anchor. This is a validation of EXISTING identity bytes, not
|
|
3017
|
+
* a geometry reconstruction: the anchor's `i`/`p` stay authoritative and the
|
|
3018
|
+
* row must already be a real placeholder line.
|
|
3019
|
+
*/
|
|
3020
|
+
function matchesKittyVirtualPlaceholderIdentity(line, imageId, placementId) {
|
|
3021
|
+
const foreground = /\x1b\[38;2;(\d{1,3});(\d{1,3});(\d{1,3})m/.exec(line);
|
|
3022
|
+
const underline = /\x1b\[58:2::(\d{1,3}):(\d{1,3}):(\d{1,3})m/.exec(line);
|
|
3023
|
+
if (foreground === null || underline === null) return false;
|
|
3024
|
+
const rgb = (match) => (Number(match[1]) & 255) << 16 | (Number(match[2]) & 255) << 8 | Number(match[3]) & 255;
|
|
3025
|
+
return rgb(foreground) === (imageId & 16777215) && rgb(underline) === (placementId & 16777215);
|
|
3026
|
+
}
|
|
2896
3027
|
function isImageLine(line) {
|
|
2897
3028
|
if (line.startsWith(KITTY_PREFIX) || line.startsWith(ITERM2_PREFIX)) return true;
|
|
2898
3029
|
return line.includes(KITTY_PREFIX) || line.includes(ITERM2_PREFIX);
|
|
@@ -3398,6 +3529,22 @@ function parseSizeValue(value, referenceSize) {
|
|
|
3398
3529
|
const match = value.match(/^(\d+(?:\.\d+)?)%$/);
|
|
3399
3530
|
if (match) return Math.floor(referenceSize * parseFloat(match[1]) / 100);
|
|
3400
3531
|
}
|
|
3532
|
+
/** The half-open content rectangle of one painted overlay placement after its
|
|
3533
|
+
* declared chrome insets, or undefined when it has no selectable cell
|
|
3534
|
+
* (dsh-pi-tui divergence X068). */
|
|
3535
|
+
function overlayTextSelectionRect(layout, insets) {
|
|
3536
|
+
const minX = layout.col + Math.max(0, Math.floor(insets.left));
|
|
3537
|
+
const maxX = layout.col + layout.width - Math.max(0, Math.floor(insets.right));
|
|
3538
|
+
const minY = layout.row + Math.max(0, Math.floor(insets.top));
|
|
3539
|
+
const maxY = layout.row + layout.height - Math.max(0, Math.floor(insets.bottom));
|
|
3540
|
+
if (maxX <= minX || maxY <= minY) return void 0;
|
|
3541
|
+
return {
|
|
3542
|
+
minX,
|
|
3543
|
+
maxX,
|
|
3544
|
+
minY,
|
|
3545
|
+
maxY
|
|
3546
|
+
};
|
|
3547
|
+
}
|
|
3401
3548
|
/**
|
|
3402
3549
|
* Container - a component that contains other components
|
|
3403
3550
|
*/
|
|
@@ -3605,6 +3752,59 @@ var TuiBase = class TuiBase extends Container {
|
|
|
3605
3752
|
get hasOverlayEntries() {
|
|
3606
3753
|
return this.overlayStack.length > 0;
|
|
3607
3754
|
}
|
|
3755
|
+
/**
|
|
3756
|
+
* The text-selection region an unconsumed press at one screen cell would
|
|
3757
|
+
* start, resolved from the LAST PAINTED overlay placement (dsh-pi-tui
|
|
3758
|
+
* divergence X068), or undefined when that cell is not selectable content.
|
|
3759
|
+
*
|
|
3760
|
+
* The TOPMOST painted overlay that opted in with `textSelectionInsets` wins;
|
|
3761
|
+
* an ordinary overlay above it keeps upstream's opaque block (the caller
|
|
3762
|
+
* only reaches this after the overlay dispatch found no consumer). The
|
|
3763
|
+
* region is the painted placement minus the declared insets, as a half-open
|
|
3764
|
+
* cell rectangle, and is refused when either inner dimension is < 1.
|
|
3765
|
+
*/
|
|
3766
|
+
overlayTextSelectionRegionAt(x, y) {
|
|
3767
|
+
for (let index = this.renderedOverlayLayouts.length - 1; index >= 0; index--) {
|
|
3768
|
+
const layout = this.renderedOverlayLayouts[index];
|
|
3769
|
+
const insets = layout.entry.options?.textSelectionInsets;
|
|
3770
|
+
if (insets === void 0 || !this.overlayStack.includes(layout.entry) || !this.isOverlayVisible(layout.entry)) continue;
|
|
3771
|
+
if (x < layout.col || x >= layout.col + layout.width || y < layout.row || y >= layout.row + layout.height) continue;
|
|
3772
|
+
const rect = overlayTextSelectionRect(layout, insets);
|
|
3773
|
+
if (rect === void 0) return void 0;
|
|
3774
|
+
if (x < rect.minX || x >= rect.maxX || y < rect.minY || y >= rect.maxY) return void 0;
|
|
3775
|
+
return {
|
|
3776
|
+
entry: layout.entry,
|
|
3777
|
+
rect,
|
|
3778
|
+
placement: {
|
|
3779
|
+
col: layout.col,
|
|
3780
|
+
row: layout.row,
|
|
3781
|
+
width: layout.width,
|
|
3782
|
+
height: layout.height
|
|
3783
|
+
}
|
|
3784
|
+
};
|
|
3785
|
+
}
|
|
3786
|
+
}
|
|
3787
|
+
/**
|
|
3788
|
+
* Whether a captured overlay text-selection region still describes the
|
|
3789
|
+
* CURRENT paint: the entry is still a mounted, visible overlay, its painted
|
|
3790
|
+
* placement is byte-identical, and no other visible overlay paints above it
|
|
3791
|
+
* (dsh-pi-tui divergence X068). A resize/remount, a hide/close, or a newer
|
|
3792
|
+
* modal therefore retires the region instead of letting a stale selection
|
|
3793
|
+
* land on the new frame.
|
|
3794
|
+
*/
|
|
3795
|
+
isOverlayTextSelectionRegionLive(region) {
|
|
3796
|
+
if (!this.overlayStack.includes(region.entry) || !this.isOverlayVisible(region.entry)) return false;
|
|
3797
|
+
for (const entry of this.overlayStack) if (entry !== region.entry && entry.focusOrder > region.entry.focusOrder && this.isOverlayVisible(entry)) return false;
|
|
3798
|
+
for (let index = this.renderedOverlayLayouts.length - 1; index >= 0; index--) {
|
|
3799
|
+
const layout = this.renderedOverlayLayouts[index];
|
|
3800
|
+
if (layout.entry !== region.entry) {
|
|
3801
|
+
if (this.isOverlayVisible(layout.entry)) return false;
|
|
3802
|
+
continue;
|
|
3803
|
+
}
|
|
3804
|
+
return layout.col === region.placement.col && layout.row === region.placement.row && layout.width === region.placement.width && layout.height === region.placement.height;
|
|
3805
|
+
}
|
|
3806
|
+
return false;
|
|
3807
|
+
}
|
|
3608
3808
|
/** Whether a component is still a mounted, visible overlay. Subclasses
|
|
3609
3809
|
* (TuiAltScreen) revalidate gesture targets against this before
|
|
3610
3810
|
* dispatching pointer events. (dsh-pi-tui divergence X018 hardening.) */
|
|
@@ -3637,12 +3837,65 @@ var TuiBase = class TuiBase extends Container {
|
|
|
3637
3837
|
return component.mouseLayout;
|
|
3638
3838
|
}
|
|
3639
3839
|
overlayFocusRestore = { status: "inactive" };
|
|
3640
|
-
|
|
3840
|
+
/**
|
|
3841
|
+
* The Client-local SIXEL trust port (X072), or undefined for every other
|
|
3842
|
+
* terminal. A Screen never parses a DCS itself: it asks this port, which
|
|
3843
|
+
* only recognizes rasters its own owner encoded.
|
|
3844
|
+
*/
|
|
3845
|
+
sixelScreen;
|
|
3846
|
+
/** Whether `start()` has brought the terminal up (only then may a query go out). */
|
|
3847
|
+
terminalStarted = false;
|
|
3848
|
+
/** Observers of this screen's ONE real `CSI 6;h;w t` parse (X072). */
|
|
3849
|
+
cellSizeListeners = /* @__PURE__ */ new Set();
|
|
3850
|
+
constructor(terminal, showHardwareCursor, logDirectory, sixelScreen) {
|
|
3641
3851
|
super();
|
|
3642
3852
|
this.terminal = terminal;
|
|
3643
3853
|
this.logDirectory = logDirectory;
|
|
3854
|
+
this.sixelScreen = sixelScreen;
|
|
3644
3855
|
if (showHardwareCursor !== void 0) this.showHardwareCursor = showHardwareCursor;
|
|
3645
3856
|
}
|
|
3857
|
+
/**
|
|
3858
|
+
* Whether this line must be treated as an IMAGE by the physical Screen
|
|
3859
|
+
* (X072): a legacy Kitty/iTerm2 placement, or an exact DCS the Client-local
|
|
3860
|
+
* SIXEL owner registered.
|
|
3861
|
+
*
|
|
3862
|
+
* This is a trust question, not a syntax question. A DCS that is not in the
|
|
3863
|
+
* owner's registry stays ordinary text and goes through the normal
|
|
3864
|
+
* normalization/truncation path, so an arbitrary `ESC P…q…ESC \` from a tool
|
|
3865
|
+
* result can never be promoted to a device command.
|
|
3866
|
+
*/
|
|
3867
|
+
isRenderableImageLine(line) {
|
|
3868
|
+
return isImageLine(line) || this.sixelScreen?.footprint(line) !== void 0 || this.sixelScreen?.candidate(line) !== void 0;
|
|
3869
|
+
}
|
|
3870
|
+
/** The registered SIXEL footprint of a trusted anchor line, if any (X072). */
|
|
3871
|
+
sixelFootprint(line) {
|
|
3872
|
+
return this.sixelScreen?.footprint(line);
|
|
3873
|
+
}
|
|
3874
|
+
/**
|
|
3875
|
+
* Observe every real cell-size reply this screen parses, or return the
|
|
3876
|
+
* current value immediately when it is already known (X072).
|
|
3877
|
+
*
|
|
3878
|
+
* There is ONE parser (`consumeCellSizeResponse`); observers never see a
|
|
3879
|
+
* query they issued, only the terminal's actual `CSI 6;h;w t` answer.
|
|
3880
|
+
*/
|
|
3881
|
+
onCellSizeObserved(listener) {
|
|
3882
|
+
this.cellSizeListeners.add(listener);
|
|
3883
|
+
return () => {
|
|
3884
|
+
this.cellSizeListeners.delete(listener);
|
|
3885
|
+
};
|
|
3886
|
+
}
|
|
3887
|
+
/**
|
|
3888
|
+
* Ask the terminal for its cell size in device pixels (`CSI 16t`, answered as
|
|
3889
|
+
* `CSI 6;h;w t`) on behalf of a consumer that needs REAL geometry (X072).
|
|
3890
|
+
*
|
|
3891
|
+
* Unlike the startup probe this refuses before `start()`: a query written to
|
|
3892
|
+
* a terminal this screen does not own yet would be answered into the input
|
|
3893
|
+
* stream of whoever does.
|
|
3894
|
+
*/
|
|
3895
|
+
queryCellSizeForSixel() {
|
|
3896
|
+
if (!this.terminalStarted) return;
|
|
3897
|
+
this.terminal.write("\x1B[16t");
|
|
3898
|
+
}
|
|
3646
3899
|
resetRenderState() {}
|
|
3647
3900
|
beforeTerminalStart() {}
|
|
3648
3901
|
afterTerminalStart() {}
|
|
@@ -3989,6 +4242,7 @@ var TuiBase = class TuiBase extends Container {
|
|
|
3989
4242
|
this.stopped = false;
|
|
3990
4243
|
this.beforeTerminalStart();
|
|
3991
4244
|
this.terminal.start((data) => this.handleTerminalInput(data), () => this.requestRender());
|
|
4245
|
+
this.terminalStarted = true;
|
|
3992
4246
|
this.afterTerminalStart();
|
|
3993
4247
|
this.terminal.hideCursor();
|
|
3994
4248
|
if (this.terminalColorSchemeNotificationsEnabled) this.terminal.write("\x1B[?2031h");
|
|
@@ -4021,13 +4275,25 @@ var TuiBase = class TuiBase extends Container {
|
|
|
4021
4275
|
}
|
|
4022
4276
|
stop(options = {}) {
|
|
4023
4277
|
this.stopped = true;
|
|
4278
|
+
this.terminalStarted = false;
|
|
4024
4279
|
this.cancelRenderTimer();
|
|
4025
4280
|
this.settleBackgroundProbe(void 0);
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4281
|
+
const failures = [];
|
|
4282
|
+
const attempt = (step) => {
|
|
4283
|
+
try {
|
|
4284
|
+
step();
|
|
4285
|
+
} catch (error) {
|
|
4286
|
+
failures.push(error);
|
|
4287
|
+
}
|
|
4288
|
+
};
|
|
4289
|
+
attempt(() => {
|
|
4290
|
+
if (this.terminalColorSchemeNotificationsEnabled) this.terminal.write("\x1B[?2031l");
|
|
4291
|
+
});
|
|
4292
|
+
attempt(() => this.beforeTerminalStop(options));
|
|
4293
|
+
attempt(() => this.terminal.showCursor());
|
|
4294
|
+
attempt(() => this.terminal.stop());
|
|
4295
|
+
attempt(() => this.afterTerminalStop(options));
|
|
4296
|
+
if (failures.length > 0) throw failures[0];
|
|
4031
4297
|
}
|
|
4032
4298
|
renderNow(force = false) {
|
|
4033
4299
|
if (force) this.resetRenderState();
|
|
@@ -4192,6 +4458,10 @@ var TuiBase = class TuiBase extends Container {
|
|
|
4192
4458
|
widthPx,
|
|
4193
4459
|
heightPx
|
|
4194
4460
|
});
|
|
4461
|
+
for (const listener of this.cellSizeListeners) listener({
|
|
4462
|
+
widthPx,
|
|
4463
|
+
heightPx
|
|
4464
|
+
});
|
|
4195
4465
|
this.invalidate();
|
|
4196
4466
|
this.requestRender();
|
|
4197
4467
|
return true;
|
|
@@ -4341,14 +4611,38 @@ var TuiBase = class TuiBase extends Container {
|
|
|
4341
4611
|
const reset = SEGMENT_RESET;
|
|
4342
4612
|
for (let i = 0; i < lines.length; i++) {
|
|
4343
4613
|
const line = lines[i];
|
|
4344
|
-
if (!
|
|
4614
|
+
if (!this.isRenderableImageLine(line)) lines[i] = normalizeTerminalOutput(line) + reset;
|
|
4345
4615
|
}
|
|
4346
4616
|
return lines;
|
|
4347
4617
|
}
|
|
4348
4618
|
compositeLineAt(baseLine, overlayLine, startCol, overlayWidth, totalWidth) {
|
|
4619
|
+
if (this.sixelScreen?.footprint(baseLine) !== void 0 || this.sixelScreen?.candidate(baseLine) !== void 0) return compositeTuiLine("", overlayLine, startCol, overlayWidth, totalWidth);
|
|
4349
4620
|
return compositeTuiLine(baseLine, overlayLine, startCol, overlayWidth, totalWidth);
|
|
4350
4621
|
}
|
|
4351
4622
|
/**
|
|
4623
|
+
* The absolute line range a visible overlay painted on this frame (X072).
|
|
4624
|
+
*
|
|
4625
|
+
* Overlay placements are viewport-relative, exactly like the compositor's own
|
|
4626
|
+
* `workingHeight - termHeight` origin, so the mapping is derived from the same
|
|
4627
|
+
* inputs instead of being guessed by the caller.
|
|
4628
|
+
*/
|
|
4629
|
+
overlayPaintedLineRange(overlayRow, overlayHeight, totalLines) {
|
|
4630
|
+
const first = Math.max(0, totalLines - this.terminal.rows) + overlayRow;
|
|
4631
|
+
return {
|
|
4632
|
+
first,
|
|
4633
|
+
last: first + overlayHeight - 1
|
|
4634
|
+
};
|
|
4635
|
+
}
|
|
4636
|
+
/** Whether a visible overlay painted any cell on any of these absolute lines. */
|
|
4637
|
+
linesCoveredByOverlay(firstLine, lastLine, totalLines) {
|
|
4638
|
+
for (const layout of this.renderedOverlayLayouts) {
|
|
4639
|
+
const range = this.overlayPaintedLineRange(layout.row, layout.height, totalLines);
|
|
4640
|
+
if (range.last < firstLine || range.first > lastLine) continue;
|
|
4641
|
+
return true;
|
|
4642
|
+
}
|
|
4643
|
+
return false;
|
|
4644
|
+
}
|
|
4645
|
+
/**
|
|
4352
4646
|
* Find and extract cursor position from rendered lines.
|
|
4353
4647
|
* Searches for CURSOR_MARKER, calculates its position, and strips it from the output.
|
|
4354
4648
|
* Only scans the bottom terminal height lines (visible viewport).
|
|
@@ -4430,199 +4724,6 @@ var TuiBase = class TuiBase extends Container {
|
|
|
4430
4724
|
return promise;
|
|
4431
4725
|
}
|
|
4432
4726
|
};
|
|
4433
|
-
/**
|
|
4434
|
-
* Box component - a container that applies padding and background to all children
|
|
4435
|
-
*/
|
|
4436
|
-
var Box = class {
|
|
4437
|
-
children = [];
|
|
4438
|
-
paddingX;
|
|
4439
|
-
paddingY;
|
|
4440
|
-
bgFn;
|
|
4441
|
-
/** The child the last mouse press focused (dsh-pi-tui divergence
|
|
4442
|
-
* X051): focus/input forward to THIS child only — never broadcast to
|
|
4443
|
-
* all children. */
|
|
4444
|
-
focusedChild;
|
|
4445
|
-
/**
|
|
4446
|
-
* Focusable (dsh-pi-tui divergence X051): a Box used as an overlay
|
|
4447
|
-
* root (showOverlay accepts any Component) must forward the focused
|
|
4448
|
-
* flag to the child the mouse press hit — the overlay focus state
|
|
4449
|
-
* tracks the mounted root, so without forwarding an Input inside a
|
|
4450
|
-
* plain Box root never receives focused=true (no IME cursor).
|
|
4451
|
-
*/
|
|
4452
|
-
get focused() {
|
|
4453
|
-
const child = this.liveFocusedChild();
|
|
4454
|
-
return child !== void 0 && isFocusable(child) && child.focused;
|
|
4455
|
-
}
|
|
4456
|
-
set focused(value) {
|
|
4457
|
-
const child = this.liveFocusedChild();
|
|
4458
|
-
if (child !== void 0 && isFocusable(child)) child.focused = value;
|
|
4459
|
-
}
|
|
4460
|
-
/** Transparent input forwarding (dsh-pi-tui divergence X051): a Box
|
|
4461
|
-
* overlay root must reach the interactive child the mouse press
|
|
4462
|
-
* focused. */
|
|
4463
|
-
handleInput(data) {
|
|
4464
|
-
this.liveFocusedChild()?.handleInput?.(data);
|
|
4465
|
-
}
|
|
4466
|
-
/** Transparent key-release capability (dsh-pi-tui divergence X051): a
|
|
4467
|
-
* Box that becomes the keyboard focus owner must forward the child's
|
|
4468
|
-
* wantsKeyRelease, or the TUI filters Kitty key releases before they
|
|
4469
|
-
* reach the child. (Mirrors MouseRegion.) */
|
|
4470
|
-
get wantsKeyRelease() {
|
|
4471
|
-
return this.liveFocusedChild()?.wantsKeyRelease;
|
|
4472
|
-
}
|
|
4473
|
-
/** The focused child is only valid while it is still a LIVE direct
|
|
4474
|
-
* child: a subclass/caller may replace `children` directly (the
|
|
4475
|
-
* public structural mutation contract), and keyboard input / the
|
|
4476
|
-
* focused flag / wantsKeyRelease must never reach a detached child.
|
|
4477
|
-
* The reference is dropped until a new mouse press names a new focus
|
|
4478
|
-
* owner — replacement never silently transfers focus to the new
|
|
4479
|
-
* child, and re-mounting the old child later can never resurrect the
|
|
4480
|
-
* stale identity. The detached child's focused flag is cleared too
|
|
4481
|
-
* (IME/hardware-cursor state must not survive a detach). (dsh-pi-tui
|
|
4482
|
-
* divergence X051 hardening.) */
|
|
4483
|
-
liveFocusedChild() {
|
|
4484
|
-
const child = this.focusedChild;
|
|
4485
|
-
if (child !== void 0 && this.children.includes(child)) return child;
|
|
4486
|
-
this.clearFocusedChild();
|
|
4487
|
-
}
|
|
4488
|
-
/** Drop the focused-child reference and clear the child's focused
|
|
4489
|
-
* flag (IME/hardware-cursor state must not survive a detach — a
|
|
4490
|
-
* removed child re-mounted elsewhere must not keep CURSOR_MARKER).
|
|
4491
|
-
* (dsh-pi-tui divergence X051 hardening.) */
|
|
4492
|
-
clearFocusedChild() {
|
|
4493
|
-
const child = this.focusedChild;
|
|
4494
|
-
if (child !== void 0 && isFocusable(child)) child.focused = false;
|
|
4495
|
-
this.focusedChild = void 0;
|
|
4496
|
-
}
|
|
4497
|
-
cache;
|
|
4498
|
-
mouseLayout;
|
|
4499
|
-
constructor(paddingX = 1, paddingY = 1, bgFn) {
|
|
4500
|
-
this.paddingX = paddingX;
|
|
4501
|
-
this.paddingY = paddingY;
|
|
4502
|
-
this.bgFn = bgFn;
|
|
4503
|
-
}
|
|
4504
|
-
/** The box's padding (the TuiAltScreen painted-placement liveness
|
|
4505
|
-
* check re-derives a nested child's painted origin from it).
|
|
4506
|
-
* (dsh-pi-tui divergence X018 hardening.) */
|
|
4507
|
-
getPadding() {
|
|
4508
|
-
return {
|
|
4509
|
-
x: this.paddingX,
|
|
4510
|
-
y: this.paddingY
|
|
4511
|
-
};
|
|
4512
|
-
}
|
|
4513
|
-
addChild(component) {
|
|
4514
|
-
this.children.push(component);
|
|
4515
|
-
this.invalidateCache();
|
|
4516
|
-
}
|
|
4517
|
-
removeChild(component) {
|
|
4518
|
-
const index = this.children.indexOf(component);
|
|
4519
|
-
if (index !== -1) {
|
|
4520
|
-
this.children.splice(index, 1);
|
|
4521
|
-
if (this.focusedChild === component) this.clearFocusedChild();
|
|
4522
|
-
this.invalidateCache();
|
|
4523
|
-
component.dispose?.();
|
|
4524
|
-
}
|
|
4525
|
-
}
|
|
4526
|
-
clear() {
|
|
4527
|
-
const children = this.children;
|
|
4528
|
-
this.children = [];
|
|
4529
|
-
this.clearFocusedChild();
|
|
4530
|
-
this.invalidateCache();
|
|
4531
|
-
for (const child of children) child.dispose?.();
|
|
4532
|
-
}
|
|
4533
|
-
/**
|
|
4534
|
-
* Release every child (dsh-pi-tui divergence X007): a Box nested under
|
|
4535
|
-
* a Container/overlay must forward disposal — without this, only
|
|
4536
|
-
* box.removeChild/clear released children and a parent-owned Box
|
|
4537
|
-
* leaked its resource-owning subtree.
|
|
4538
|
-
*/
|
|
4539
|
-
dispose() {
|
|
4540
|
-
this.clear();
|
|
4541
|
-
}
|
|
4542
|
-
setBgFn(bgFn) {
|
|
4543
|
-
this.bgFn = bgFn;
|
|
4544
|
-
}
|
|
4545
|
-
setPaddingX(paddingX) {
|
|
4546
|
-
this.paddingX = paddingX;
|
|
4547
|
-
this.invalidateCache();
|
|
4548
|
-
}
|
|
4549
|
-
invalidateCache() {
|
|
4550
|
-
this.cache = void 0;
|
|
4551
|
-
}
|
|
4552
|
-
matchCache(width, childLines, bgSample) {
|
|
4553
|
-
const cache = this.cache;
|
|
4554
|
-
return !!cache && cache.width === width && cache.bgSample === bgSample && cache.childLines.length === childLines.length && cache.childLines.every((line, i) => line === childLines[i]);
|
|
4555
|
-
}
|
|
4556
|
-
invalidate() {
|
|
4557
|
-
this.invalidateCache();
|
|
4558
|
-
for (const child of this.children) child.invalidate?.();
|
|
4559
|
-
}
|
|
4560
|
-
handleMouse(event) {
|
|
4561
|
-
const contentWidth = Math.max(1, event.width - this.paddingX * 2);
|
|
4562
|
-
const contentY = event.y - this.paddingY;
|
|
4563
|
-
const contentX = event.x - this.paddingX;
|
|
4564
|
-
if (contentY < 0 || contentX < 0 || contentX >= contentWidth) return void 0;
|
|
4565
|
-
const cached = this.mouseLayout;
|
|
4566
|
-
if (!(cached !== void 0 && cached.width === contentWidth && cached.children.length === this.children.length && cached.children.every((entry, index) => entry.component === this.children[index]))) return void 0;
|
|
4567
|
-
const mouseChildren = cached.children;
|
|
4568
|
-
let childY = 0;
|
|
4569
|
-
for (const { component: child, height: childHeight } of mouseChildren) {
|
|
4570
|
-
if (contentY >= childY && contentY < childY + childHeight) {
|
|
4571
|
-
const result = dispatchMouseEvent(child, {
|
|
4572
|
-
...event,
|
|
4573
|
-
x: contentX,
|
|
4574
|
-
y: contentY - childY,
|
|
4575
|
-
width: contentWidth,
|
|
4576
|
-
height: childHeight
|
|
4577
|
-
});
|
|
4578
|
-
if (result?.focus) this.focusedChild = child;
|
|
4579
|
-
return result;
|
|
4580
|
-
}
|
|
4581
|
-
childY += childHeight;
|
|
4582
|
-
}
|
|
4583
|
-
}
|
|
4584
|
-
render(width) {
|
|
4585
|
-
this.liveFocusedChild();
|
|
4586
|
-
if (this.children.length === 0) return [];
|
|
4587
|
-
const contentWidth = Math.max(1, width - this.paddingX * 2);
|
|
4588
|
-
const leftPad = " ".repeat(this.paddingX);
|
|
4589
|
-
const childLines = [];
|
|
4590
|
-
const mouseChildren = [];
|
|
4591
|
-
for (const child of this.children) {
|
|
4592
|
-
const lines = child.render(contentWidth);
|
|
4593
|
-
mouseChildren.push({
|
|
4594
|
-
component: child,
|
|
4595
|
-
height: lines.length
|
|
4596
|
-
});
|
|
4597
|
-
for (const line of lines) childLines.push(line);
|
|
4598
|
-
}
|
|
4599
|
-
this.mouseLayout = {
|
|
4600
|
-
width: contentWidth,
|
|
4601
|
-
children: mouseChildren
|
|
4602
|
-
};
|
|
4603
|
-
if (childLines.length === 0) return [];
|
|
4604
|
-
const bgSample = this.bgFn ? this.bgFn("test") : void 0;
|
|
4605
|
-
if (this.matchCache(width, childLines, bgSample)) return this.cache.lines;
|
|
4606
|
-
const result = [];
|
|
4607
|
-
for (let i = 0; i < this.paddingY; i++) result.push(this.applyBg("", width));
|
|
4608
|
-
for (const line of childLines) result.push(this.applyBg(leftPad + line, width));
|
|
4609
|
-
for (let i = 0; i < this.paddingY; i++) result.push(this.applyBg("", width));
|
|
4610
|
-
flattenLines(result);
|
|
4611
|
-
this.cache = {
|
|
4612
|
-
childLines,
|
|
4613
|
-
width,
|
|
4614
|
-
bgSample,
|
|
4615
|
-
lines: result
|
|
4616
|
-
};
|
|
4617
|
-
return result;
|
|
4618
|
-
}
|
|
4619
|
-
applyBg(line, width) {
|
|
4620
|
-
const visLen = visibleWidth(line);
|
|
4621
|
-
const padNeeded = Math.max(0, width - visLen);
|
|
4622
|
-
const padded = line + " ".repeat(padNeeded);
|
|
4623
|
-
return this.bgFn ? this.bgFn(padded) : padded;
|
|
4624
|
-
}
|
|
4625
|
-
};
|
|
4626
4727
|
const TUI_KEYBINDINGS = {
|
|
4627
4728
|
"tui.editor.cursorUp": {
|
|
4628
4729
|
defaultKeys: "up",
|
|
@@ -5065,6 +5166,15 @@ var UndoStack = class {
|
|
|
5065
5166
|
clear() {
|
|
5066
5167
|
this.stack.length = 0;
|
|
5067
5168
|
}
|
|
5169
|
+
/**
|
|
5170
|
+
* Transform every snapshot in place while preserving the stack order.
|
|
5171
|
+
* Narrow internal primitive used by Editor.retireDraftImageFromUndo() to
|
|
5172
|
+
* trim a retired image occurrence from older snapshots; this is not a
|
|
5173
|
+
* generic public UndoStack API.
|
|
5174
|
+
*/
|
|
5175
|
+
transformSnapshots(transform) {
|
|
5176
|
+
this.stack = this.stack.map(transform);
|
|
5177
|
+
}
|
|
5068
5178
|
get length() {
|
|
5069
5179
|
return this.stack.length;
|
|
5070
5180
|
}
|
|
@@ -5332,6 +5442,23 @@ function isPasteMarker(segment) {
|
|
|
5332
5442
|
*/
|
|
5333
5443
|
const MAX_PASTE_STORED_CHARS = 262144;
|
|
5334
5444
|
/**
|
|
5445
|
+
* The canonical draft-image placeholder grammar
|
|
5446
|
+
* (`[image #<id> (<width>×<height>)]`). The Editor never resolves these
|
|
5447
|
+
* tokens — the host owns the draft store — but its narrow Undo
|
|
5448
|
+
* image-reference observation must only report CANONICAL tokens, never
|
|
5449
|
+
* arbitrary user text that happens to mention an image.
|
|
5450
|
+
* (dsh-pi-tui divergence X064.)
|
|
5451
|
+
*/
|
|
5452
|
+
const DRAFT_IMAGE_PLACEHOLDER_REGEX = /\[image #\d+ \(\d+×\d+\)\]/g;
|
|
5453
|
+
/**
|
|
5454
|
+
* Upper bound for the paste-body image-reference cache. The cache exists only
|
|
5455
|
+
* to avoid rescanning a stored paste body during undo-snapshot pushes; it must
|
|
5456
|
+
* never become a second long-lived owner of historical paste bodies. Only
|
|
5457
|
+
* bodies that actually contain a canonical image placeholder are cached, and
|
|
5458
|
+
* the few most recently used ones are kept (X064).
|
|
5459
|
+
*/
|
|
5460
|
+
const MAX_PASTE_IMAGE_CACHE_ENTRIES = 8;
|
|
5461
|
+
/**
|
|
5335
5462
|
* A segmenter that wraps Intl.Segmenter and merges graphemes that fall
|
|
5336
5463
|
* within paste markers into single atomic segments. This makes cursor
|
|
5337
5464
|
* movement, deletion, word-wrap, etc. treat paste markers as single units.
|
|
@@ -5498,7 +5625,7 @@ function createScrollBorder(direction, hiddenLineCount, width) {
|
|
|
5498
5625
|
const ellipsis = "...".slice(0, availableWidth);
|
|
5499
5626
|
return sliceByColumn(indicator, 0, availableWidth - visibleWidth(ellipsis), true) + ellipsis;
|
|
5500
5627
|
}
|
|
5501
|
-
var Editor = class {
|
|
5628
|
+
var Editor = class Editor {
|
|
5502
5629
|
state = {
|
|
5503
5630
|
lines: [""],
|
|
5504
5631
|
cursorLine: 0,
|
|
@@ -5565,7 +5692,29 @@ var Editor = class {
|
|
|
5565
5692
|
preferredVisualCol = null;
|
|
5566
5693
|
snappedFromCursorCol = null;
|
|
5567
5694
|
undoStack = new UndoStack();
|
|
5695
|
+
/** How many current Undo snapshots reference each canonical draft-image
|
|
5696
|
+
* placeholder (raw document lines AND stored paste bodies). Maintained
|
|
5697
|
+
* incrementally on push/pop/clear/trim so the host can reconcile its
|
|
5698
|
+
* undo-retention leases without re-scanning paste bodies per keystroke
|
|
5699
|
+
* (X064). */
|
|
5700
|
+
undoImageRefCounts = /* @__PURE__ */ new Map();
|
|
5701
|
+
/** Canonical placeholders contained in one stored paste body, cached by
|
|
5702
|
+
* (paste id, body identity): paste bodies are immutable strings, so an
|
|
5703
|
+
* unchanged body never needs another scan (X064). */
|
|
5704
|
+
pasteImagePlaceholders = /* @__PURE__ */ new Map();
|
|
5568
5705
|
onSubmit;
|
|
5706
|
+
/** Called with the submitted text immediately BEFORE the draft/undo clear.
|
|
5707
|
+
* The host reserves submission-time resources first and returns a ONE-SHOT
|
|
5708
|
+
* release: it runs in a finally after the synchronous clear + onSubmit
|
|
5709
|
+
* dispatch (on success and on throw), so the business owner can take over
|
|
5710
|
+
* in the same call stack. A throw aborts the submit BEFORE any clear.
|
|
5711
|
+
* (X064.) */
|
|
5712
|
+
onBeforeSubmitClear;
|
|
5713
|
+
/** The draft/undo clear RETIRED this editor's Undo history: no snapshot can
|
|
5714
|
+
* restore an earlier draft any more. Fired after `undoStack.clear()` and
|
|
5715
|
+
* before `onChange("")`, so the host releases its undo-retention leases
|
|
5716
|
+
* while the clear is still synchronous. (X064.) */
|
|
5717
|
+
onUndoHistoryRetired;
|
|
5569
5718
|
onChange;
|
|
5570
5719
|
/** The Down-admission's editor-owned facts MAY have changed (dsh-pi-tui
|
|
5571
5720
|
* divergence X063 — the admission is a visual-line + transient-mode
|
|
@@ -6316,7 +6465,34 @@ var Editor = class {
|
|
|
6316
6465
|
* (dsh-pi-tui divergence X023.)
|
|
6317
6466
|
*/
|
|
6318
6467
|
setTextAndCursor(text, cursor) {
|
|
6468
|
+
this.installTextAndCursor(this.normalizeText(text), cursor);
|
|
6469
|
+
}
|
|
6470
|
+
/**
|
|
6471
|
+
* Replace the WHOLE document and cursor as ONE real, undoable edit:
|
|
6472
|
+
* cancel autocomplete/history browsing, push the pre-edit snapshot
|
|
6473
|
+
* (document + paste registry), install the replacement (pruning paste
|
|
6474
|
+
* entries whose markers vanished), and fire onChange. The host uses this
|
|
6475
|
+
* for the composer preview image removal: unlike setTextAndCursor(), a
|
|
6476
|
+
* following Undo restores exactly the removed text. (dsh-pi-tui
|
|
6477
|
+
* divergence X064.)
|
|
6478
|
+
*/
|
|
6479
|
+
replaceTextUndoable(text, cursor) {
|
|
6319
6480
|
const normalized = this.normalizeText(text);
|
|
6481
|
+
if (normalized === this.getText()) {
|
|
6482
|
+
this.installTextAndCursor(normalized, cursor);
|
|
6483
|
+
return;
|
|
6484
|
+
}
|
|
6485
|
+
this.cancelAutocomplete();
|
|
6486
|
+
this.lastAction = null;
|
|
6487
|
+
this.exitHistoryBrowsing();
|
|
6488
|
+
this.pushUndoSnapshot();
|
|
6489
|
+
this.installTextAndCursor(normalized, cursor);
|
|
6490
|
+
if (this.onChange) this.onChange(this.getText());
|
|
6491
|
+
}
|
|
6492
|
+
/** Install a normalized document + cursor and prune orphaned paste
|
|
6493
|
+
* entries. Deliberately does not push undo or fire onChange; the
|
|
6494
|
+
* callers own those semantics. */
|
|
6495
|
+
installTextAndCursor(normalized, cursor) {
|
|
6320
6496
|
this.state.lines = normalized.split("\n");
|
|
6321
6497
|
const requestedLine = Number.isFinite(cursor.line) ? Math.floor(cursor.line) : 0;
|
|
6322
6498
|
const line = Math.max(0, Math.min(requestedLine, this.state.lines.length - 1));
|
|
@@ -6469,8 +6645,24 @@ var Editor = class {
|
|
|
6469
6645
|
return this.state.cursorCol > 0 && currentLine[this.state.cursorCol - 1] === "\\";
|
|
6470
6646
|
}
|
|
6471
6647
|
submitValue() {
|
|
6472
|
-
this.cancelAutocomplete();
|
|
6473
6648
|
const result = this.expandPasteMarkersSinglePass(this.state.lines.join("\n")).text.trim();
|
|
6649
|
+
const release = this.onBeforeSubmitClear?.(result);
|
|
6650
|
+
try {
|
|
6651
|
+
this.clearDraftAfterSubmit();
|
|
6652
|
+
if (this.onSubmit) this.onSubmit(result);
|
|
6653
|
+
} finally {
|
|
6654
|
+
release?.();
|
|
6655
|
+
}
|
|
6656
|
+
}
|
|
6657
|
+
/**
|
|
6658
|
+
* Clear the submitted draft and its Undo history WITHOUT firing onSubmit.
|
|
6659
|
+
* Extracted from submitValue() so host-owned accelerated/plugin submission
|
|
6660
|
+
* paths clear exactly like a normal Enter submit (dsh-pi-tui divergence
|
|
6661
|
+
* X064): this retires the undoStack, while setText("") pushes another
|
|
6662
|
+
* snapshot. The caller owns the submit event.
|
|
6663
|
+
*/
|
|
6664
|
+
clearDraftAfterSubmit() {
|
|
6665
|
+
this.cancelAutocomplete();
|
|
6474
6666
|
this.state = {
|
|
6475
6667
|
lines: [""],
|
|
6476
6668
|
cursorLine: 0,
|
|
@@ -6481,31 +6673,145 @@ var Editor = class {
|
|
|
6481
6673
|
this.exitHistoryBrowsing();
|
|
6482
6674
|
this.scrollOffset = 0;
|
|
6483
6675
|
this.undoStack.clear();
|
|
6676
|
+
this.undoImageRefCounts.clear();
|
|
6677
|
+
this.pasteImagePlaceholders.clear();
|
|
6484
6678
|
this.lastAction = null;
|
|
6679
|
+
this.onUndoHistoryRetired?.();
|
|
6485
6680
|
if (this.onChange) this.onChange("");
|
|
6486
|
-
if (this.onSubmit) this.onSubmit(result);
|
|
6487
6681
|
}
|
|
6488
|
-
|
|
6489
|
-
|
|
6490
|
-
|
|
6491
|
-
|
|
6492
|
-
|
|
6493
|
-
|
|
6494
|
-
|
|
6495
|
-
|
|
6496
|
-
|
|
6497
|
-
|
|
6498
|
-
|
|
6499
|
-
|
|
6500
|
-
|
|
6501
|
-
|
|
6502
|
-
|
|
6503
|
-
|
|
6504
|
-
|
|
6505
|
-
|
|
6506
|
-
|
|
6507
|
-
|
|
6508
|
-
|
|
6682
|
+
/**
|
|
6683
|
+
* Every canonical draft-image placeholder still referenced by SOME Undo
|
|
6684
|
+
* snapshot (raw document lines or stored paste bodies). This is the narrow
|
|
6685
|
+
* observation seam the host bases its undo-retention leases on; it reports
|
|
6686
|
+
* only canonical tokens and is O(1) — the per-snapshot reference counts are
|
|
6687
|
+
* maintained incrementally, so normal editing never rescans paste bodies.
|
|
6688
|
+
* (dsh-pi-tui divergence X064.)
|
|
6689
|
+
*/
|
|
6690
|
+
undoImagePlaceholders() {
|
|
6691
|
+
return new Set(this.undoImageRefCounts.keys());
|
|
6692
|
+
}
|
|
6693
|
+
/**
|
|
6694
|
+
* Retire one draft-image placeholder from the Undo snapshots after its
|
|
6695
|
+
* retained bytes were evicted by the bounded undo-retention budget (X064).
|
|
6696
|
+
* The occurrence is TRIMMED from every snapshot that contains it (raw text
|
|
6697
|
+
* or stored paste body) instead of dropping the whole snapshot: the rest of
|
|
6698
|
+
* that snapshot — including a newer still-retained image — stays undoable,
|
|
6699
|
+
* while the evicted image can never be restored. Deliberately narrow: no
|
|
6700
|
+
* generic UndoStack API is exposed, and the caller must have verified the
|
|
6701
|
+
* placeholder is not in the live draft and has no in-flight submission pin.
|
|
6702
|
+
*/
|
|
6703
|
+
retireDraftImageFromUndo(placeholder) {
|
|
6704
|
+
if (!placeholder.startsWith("[image #")) return;
|
|
6705
|
+
this.undoStack.transformSnapshots((snapshot) => {
|
|
6706
|
+
let changed = false;
|
|
6707
|
+
const lines = snapshot.state.lines.map((line) => {
|
|
6708
|
+
if (!line.includes(placeholder)) return line;
|
|
6709
|
+
changed = true;
|
|
6710
|
+
return line.replaceAll(placeholder, "");
|
|
6711
|
+
});
|
|
6712
|
+
let pastes = snapshot.pastes;
|
|
6713
|
+
for (const [id, body] of snapshot.pastes) {
|
|
6714
|
+
if (!body.includes(placeholder)) continue;
|
|
6715
|
+
if (!changed) {
|
|
6716
|
+
pastes = new Map(snapshot.pastes);
|
|
6717
|
+
changed = true;
|
|
6718
|
+
}
|
|
6719
|
+
pastes.set(id, body.replaceAll(placeholder, ""));
|
|
6720
|
+
}
|
|
6721
|
+
if (!changed) return snapshot;
|
|
6722
|
+
const cursorLine = snapshot.state.cursorLine;
|
|
6723
|
+
const cursorCol = Math.min(snapshot.state.cursorCol, lines[cursorLine]?.length ?? 0);
|
|
6724
|
+
return {
|
|
6725
|
+
state: {
|
|
6726
|
+
...snapshot.state,
|
|
6727
|
+
lines,
|
|
6728
|
+
cursorCol
|
|
6729
|
+
},
|
|
6730
|
+
pastes,
|
|
6731
|
+
pasteCounter: snapshot.pasteCounter
|
|
6732
|
+
};
|
|
6733
|
+
});
|
|
6734
|
+
this.undoImageRefCounts.delete(placeholder);
|
|
6735
|
+
}
|
|
6736
|
+
/** Canonical placeholders inside one text slice (cheap substring precheck). */
|
|
6737
|
+
static imagePlaceholdersIn(text) {
|
|
6738
|
+
if (!text.includes("[image #")) return [];
|
|
6739
|
+
return text.match(DRAFT_IMAGE_PLACEHOLDER_REGEX) ?? [];
|
|
6740
|
+
}
|
|
6741
|
+
/** Union of the canonical placeholders one document references. */
|
|
6742
|
+
documentImagePlaceholders(lines) {
|
|
6743
|
+
const found = /* @__PURE__ */ new Set();
|
|
6744
|
+
for (const line of lines) for (const placeholder of Editor.imagePlaceholdersIn(line)) found.add(placeholder);
|
|
6745
|
+
return [...found];
|
|
6746
|
+
}
|
|
6747
|
+
/** Union of the canonical placeholders a paste registry references. Only
|
|
6748
|
+
* bodies that CONTAIN a canonical token are cached, and the cache is
|
|
6749
|
+
* bounded and most-recently-used ordered, so ordinary large pastes and
|
|
6750
|
+
* retired paste bodies cannot accumulate here (X064). */
|
|
6751
|
+
pasteRegistryImagePlaceholders(pastes) {
|
|
6752
|
+
const found = /* @__PURE__ */ new Set();
|
|
6753
|
+
for (const [id, body] of pastes) {
|
|
6754
|
+
let placeholders;
|
|
6755
|
+
const cached = this.pasteImagePlaceholders.get(id);
|
|
6756
|
+
if (cached !== void 0 && cached.body === body) {
|
|
6757
|
+
placeholders = cached.placeholders;
|
|
6758
|
+
this.pasteImagePlaceholders.delete(id);
|
|
6759
|
+
this.pasteImagePlaceholders.set(id, cached);
|
|
6760
|
+
} else {
|
|
6761
|
+
placeholders = Editor.imagePlaceholdersIn(body);
|
|
6762
|
+
if (placeholders.length === 0) this.pasteImagePlaceholders.delete(id);
|
|
6763
|
+
else {
|
|
6764
|
+
this.pasteImagePlaceholders.set(id, {
|
|
6765
|
+
body,
|
|
6766
|
+
placeholders
|
|
6767
|
+
});
|
|
6768
|
+
while (this.pasteImagePlaceholders.size > MAX_PASTE_IMAGE_CACHE_ENTRIES) {
|
|
6769
|
+
const oldest = this.pasteImagePlaceholders.keys().next().value;
|
|
6770
|
+
if (oldest === void 0) break;
|
|
6771
|
+
this.pasteImagePlaceholders.delete(oldest);
|
|
6772
|
+
}
|
|
6773
|
+
}
|
|
6774
|
+
}
|
|
6775
|
+
for (const placeholder of placeholders) found.add(placeholder);
|
|
6776
|
+
}
|
|
6777
|
+
return [...found];
|
|
6778
|
+
}
|
|
6779
|
+
/** The image placeholders the CURRENT document + paste registry reference. */
|
|
6780
|
+
liveImagePlaceholders() {
|
|
6781
|
+
return [...this.documentImagePlaceholders(this.state.lines), ...this.pasteRegistryImagePlaceholders(this.pastes)];
|
|
6782
|
+
}
|
|
6783
|
+
addUndoImageRefs(placeholders) {
|
|
6784
|
+
for (const placeholder of placeholders) this.undoImageRefCounts.set(placeholder, (this.undoImageRefCounts.get(placeholder) ?? 0) + 1);
|
|
6785
|
+
}
|
|
6786
|
+
removeUndoImageRefs(placeholders) {
|
|
6787
|
+
for (const placeholder of placeholders) {
|
|
6788
|
+
const count = this.undoImageRefCounts.get(placeholder);
|
|
6789
|
+
if (count === void 0) continue;
|
|
6790
|
+
if (count <= 1) this.undoImageRefCounts.delete(placeholder);
|
|
6791
|
+
else this.undoImageRefCounts.set(placeholder, count - 1);
|
|
6792
|
+
}
|
|
6793
|
+
}
|
|
6794
|
+
handleBackspace() {
|
|
6795
|
+
this.exitHistoryBrowsing();
|
|
6796
|
+
this.lastAction = null;
|
|
6797
|
+
if (this.state.cursorCol > 0) {
|
|
6798
|
+
this.pushUndoSnapshot();
|
|
6799
|
+
let line = this.state.lines[this.state.cursorLine] || "";
|
|
6800
|
+
const beforeCursor = line.slice(0, this.state.cursorCol);
|
|
6801
|
+
const graphemes = [...this.segment(beforeCursor, "grapheme")];
|
|
6802
|
+
const lastGrapheme = graphemes[graphemes.length - 1];
|
|
6803
|
+
const graphemeLength = lastGrapheme ? lastGrapheme.segment.length : 1;
|
|
6804
|
+
const isPastedSegmented = PASTE_MARKER_SINGLE.exec(lastGrapheme.segment);
|
|
6805
|
+
if (isPastedSegmented) {
|
|
6806
|
+
const targetId = Number(isPastedSegmented[1]);
|
|
6807
|
+
this.pastes.delete(targetId);
|
|
6808
|
+
this.pasteCounter--;
|
|
6809
|
+
const higherIds = [...this.pastes.keys()].filter((id) => id > targetId).sort((a, b) => a - b);
|
|
6810
|
+
for (const id of higherIds) {
|
|
6811
|
+
this.pastes.set(id - 1, this.pastes.get(id));
|
|
6812
|
+
this.pastes.delete(id);
|
|
6813
|
+
}
|
|
6814
|
+
this.state.lines = this.state.lines.map((line) => line.replace(PASTE_MARKER_REGEX, (fullMatch, idGroup, suffixGroup) => {
|
|
6509
6815
|
const x = Number(idGroup);
|
|
6510
6816
|
if (x <= targetId) return fullMatch;
|
|
6511
6817
|
return `[paste #${x - 1}${suffixGroup}]`;
|
|
@@ -6971,6 +7277,7 @@ var Editor = class {
|
|
|
6971
7277
|
if (this.onChange) this.onChange(this.getText());
|
|
6972
7278
|
}
|
|
6973
7279
|
pushUndoSnapshot() {
|
|
7280
|
+
const placeholders = this.liveImagePlaceholders();
|
|
6974
7281
|
this.undoStack.push({
|
|
6975
7282
|
state: {
|
|
6976
7283
|
lines: [...this.state.lines],
|
|
@@ -6980,11 +7287,13 @@ var Editor = class {
|
|
|
6980
7287
|
pastes: new Map(this.pastes),
|
|
6981
7288
|
pasteCounter: this.pasteCounter
|
|
6982
7289
|
});
|
|
7290
|
+
this.addUndoImageRefs(placeholders);
|
|
6983
7291
|
}
|
|
6984
7292
|
undo() {
|
|
6985
7293
|
this.exitHistoryBrowsing();
|
|
6986
7294
|
const snapshot = this.undoStack.pop();
|
|
6987
7295
|
if (!snapshot) return;
|
|
7296
|
+
this.removeUndoImageRefs([...this.documentImagePlaceholders(snapshot.state.lines), ...this.pasteRegistryImagePlaceholders(snapshot.pastes)]);
|
|
6988
7297
|
Object.assign(this.state, snapshot.state);
|
|
6989
7298
|
this.state.lines = [...snapshot.state.lines];
|
|
6990
7299
|
this.pastes = new Map(snapshot.pastes);
|
|
@@ -10843,6 +11152,18 @@ function parseKeyboardProtocolNegotiationSequence(sequence) {
|
|
|
10843
11152
|
function isKeyboardProtocolNegotiationSequencePrefix(sequence) {
|
|
10844
11153
|
return sequence === "\x1B[" || /^\x1b\[\?[\d;]*$/.test(sequence);
|
|
10845
11154
|
}
|
|
11155
|
+
/**
|
|
11156
|
+
* Whether a complete PRIMARY device-attributes reply (`CSI ? ... c`) declares
|
|
11157
|
+
* the SIXEL attribute (`4`), or `undefined` when this is not a primary DA1.
|
|
11158
|
+
*
|
|
11159
|
+
* Parameters are compared as whole tokens: a substring test would wrongly
|
|
11160
|
+
* accept `14`, `42` or `24` as evidence of SIXEL support (X071).
|
|
11161
|
+
*/
|
|
11162
|
+
function primaryDeviceAttributesDeclareSixel(sequence) {
|
|
11163
|
+
const match = /^\x1b\[\?([\d;]*)c$/.exec(sequence);
|
|
11164
|
+
if (!match) return void 0;
|
|
11165
|
+
return match[1].split(";").some((token) => token !== "" && Number.parseInt(token, 10) === 4);
|
|
11166
|
+
}
|
|
10846
11167
|
function isAppleTerminalSession() {
|
|
10847
11168
|
return process.platform === "darwin" && process.env.TERM_PROGRAM === "Apple_Terminal";
|
|
10848
11169
|
}
|
|
@@ -10905,6 +11226,14 @@ var ProcessTerminal = class {
|
|
|
10905
11226
|
pendingKeyboardProtocolDeviceAttributes = 0;
|
|
10906
11227
|
keyboardProtocolNegotiationBuffer = "";
|
|
10907
11228
|
keyboardProtocolBufferFlushTimer;
|
|
11229
|
+
/** Passive DA1 SIXEL observers (X071). One store; no reply replay buffer. */
|
|
11230
|
+
sixelObservers = /* @__PURE__ */ new Set();
|
|
11231
|
+
/**
|
|
11232
|
+
* Last observed primary-DA1 SIXEL answer for the PHYSICAL terminal this
|
|
11233
|
+
* instance represents (X071). Survives `stop()` and `start()`: the same
|
|
11234
|
+
* hardware cannot un-learn the capability between a Main and an Alt screen.
|
|
11235
|
+
*/
|
|
11236
|
+
lastObservedSixel = void 0;
|
|
10908
11237
|
stdinBuffer;
|
|
10909
11238
|
stdinDataHandler;
|
|
10910
11239
|
progressInterval;
|
|
@@ -10989,6 +11318,7 @@ var ProcessTerminal = class {
|
|
|
10989
11318
|
this.scheduleKeyboardProtocolNegotiationBufferFlush();
|
|
10990
11319
|
return;
|
|
10991
11320
|
}
|
|
11321
|
+
if (negotiation?.parsed.type === "device-attributes") this.observeSixelDeviceAttributes(negotiation.sequence);
|
|
10992
11322
|
if (negotiation && this.handleKeyboardProtocolNegotiationSequence(negotiation.parsed)) return;
|
|
10993
11323
|
this.forwardInputSequence(negotiation?.sequence ?? sequence);
|
|
10994
11324
|
});
|
|
@@ -11029,6 +11359,33 @@ var ProcessTerminal = class {
|
|
|
11029
11359
|
process.stdout.write(`${KITTY_KEYBOARD_PROTOCOL_QUERY}${programStatusQuery}${DEVICE_ATTRIBUTES_QUERY}`);
|
|
11030
11360
|
this.writeProgramStatus();
|
|
11031
11361
|
}
|
|
11362
|
+
/**
|
|
11363
|
+
* Passive DA1 observation; see `Terminal.onSixelSupport` (X071). The
|
|
11364
|
+
* registration is committed BEFORE any synchronous delivery so a listener
|
|
11365
|
+
* that unsubscribes itself (or disposes its owner) inside the callback
|
|
11366
|
+
* observes the already-committed state.
|
|
11367
|
+
*/
|
|
11368
|
+
onSixelSupport(listener) {
|
|
11369
|
+
this.sixelObservers.add(listener);
|
|
11370
|
+
const known = this.lastObservedSixel;
|
|
11371
|
+
if (known !== void 0) listener(known);
|
|
11372
|
+
return () => {
|
|
11373
|
+
this.sixelObservers.delete(listener);
|
|
11374
|
+
};
|
|
11375
|
+
}
|
|
11376
|
+
/**
|
|
11377
|
+
* Record the SIXEL attribute of one COMPLETE primary DA1 reply (X071).
|
|
11378
|
+
*
|
|
11379
|
+
* Called before the keyboard-negotiation sentinel may consume the same
|
|
11380
|
+
* reply. A repeated identical answer does not notify again.
|
|
11381
|
+
*/
|
|
11382
|
+
observeSixelDeviceAttributes(sequence) {
|
|
11383
|
+
const supported = primaryDeviceAttributesDeclareSixel(sequence);
|
|
11384
|
+
if (supported === void 0) return;
|
|
11385
|
+
if (this.lastObservedSixel === supported) return;
|
|
11386
|
+
this.lastObservedSixel = supported;
|
|
11387
|
+
for (const listener of [...this.sixelObservers]) listener(supported);
|
|
11388
|
+
}
|
|
11032
11389
|
handleKeyboardProtocolNegotiationSequence(negotiationSequence) {
|
|
11033
11390
|
this.clearKeyboardProtocolNegotiationBuffer();
|
|
11034
11391
|
if (negotiationSequence.type === "device-attributes") {
|
|
@@ -11553,6 +11910,8 @@ var AltScreenFlashContainer = class {
|
|
|
11553
11910
|
}
|
|
11554
11911
|
};
|
|
11555
11912
|
const OSC133_ZONE_PREFIX$1 = /^(?:\x1b\]133;[ABC](?:\x07|\x1b\\))+/;
|
|
11913
|
+
/** The largest number of image body rows an upward crop search may cross (X074). */
|
|
11914
|
+
const MAX_SIXEL_CROP_SCAN_ROWS = 12;
|
|
11556
11915
|
function intersect(a, b) {
|
|
11557
11916
|
const x = Math.max(a.x, b.x);
|
|
11558
11917
|
const y = Math.max(a.y, b.y);
|
|
@@ -11783,25 +12142,119 @@ function getScrollbarGeometry(box, includeHiddenAuto = false) {
|
|
|
11783
12142
|
maxScrollTop
|
|
11784
12143
|
};
|
|
11785
12144
|
}
|
|
11786
|
-
function paintScrollbar(box, screen, totalWidth) {
|
|
12145
|
+
function paintScrollbar(box, screen, totalWidth, sixelScreen) {
|
|
11787
12146
|
const geometry = getScrollbarGeometry(box);
|
|
11788
12147
|
if (!geometry || !box.scrollView) return;
|
|
11789
12148
|
for (let offset = 0; offset < geometry.trackHeight; offset++) {
|
|
11790
12149
|
const row = geometry.trackTop + offset;
|
|
11791
12150
|
if (row < box.clip.y || row >= box.clip.y + box.clip.height || row < 0 || row >= screen.length) continue;
|
|
11792
12151
|
const replacement = row >= geometry.thumbTop && row < geometry.thumbTop + geometry.thumbHeight ? box.scrollView.scrollbarThumbStyle(box.scrollView.isScrollbarActive ? "█" : "┃") : box.scrollView.scrollbarTrackStyle("│");
|
|
11793
|
-
|
|
12152
|
+
const line = screen[row] ?? "";
|
|
12153
|
+
const footprint = sixelScreen?.footprint(line);
|
|
12154
|
+
if (footprint !== void 0 && footprint.columns <= geometry.column) continue;
|
|
12155
|
+
screen[row] = replaceScrollbarCell(footprint === void 0 ? line : "", geometry.column, totalWidth, replacement, box.scrollView.scrollbar !== "always");
|
|
11794
12156
|
}
|
|
11795
12157
|
}
|
|
11796
|
-
|
|
12158
|
+
/** The managed virtual image row bound; only this window may be scanned. */
|
|
12159
|
+
const MAX_RELOCATABLE_VIRTUAL_ROWS = 297;
|
|
12160
|
+
/**
|
|
12161
|
+
* Preserve ONE managed virtual placement whose anchor line is vertically
|
|
12162
|
+
* clipped above this box's visible range. The only legal relocation target is
|
|
12163
|
+
* the first really visible placeholder row of the SAME image block. The
|
|
12164
|
+
* anchor bytes are reused verbatim; this helper invents no geometry, id or
|
|
12165
|
+
* extra row. It scans at most the 297-row component bound above the first
|
|
12166
|
+
* visible source line, so a viewport scroll never scans the whole transcript.
|
|
12167
|
+
*/
|
|
12168
|
+
function findRelocatedVirtualAnchor(box, firstRow, lastRow) {
|
|
12169
|
+
if (box.lines === void 0 || firstRow >= lastRow) return void 0;
|
|
12170
|
+
const offset = box.lineOffset ?? 0;
|
|
12171
|
+
const firstSource = offset + firstRow - box.rect.y;
|
|
12172
|
+
const lastSource = offset + lastRow - 1 - box.rect.y;
|
|
12173
|
+
if (firstSource <= 0 || firstSource > lastSource) return void 0;
|
|
12174
|
+
const firstLine = box.lines[firstSource];
|
|
12175
|
+
if (firstLine === void 0 || isImageLine(firstLine) || !isKittyVirtualPlaceholderLine(firstLine)) return void 0;
|
|
12176
|
+
const scanStart = Math.max(0, firstSource - MAX_RELOCATABLE_VIRTUAL_ROWS);
|
|
12177
|
+
for (let index = firstSource - 1; index >= scanStart; index--) {
|
|
12178
|
+
const line = box.lines[index];
|
|
12179
|
+
if (line === void 0) continue;
|
|
12180
|
+
const marker = getManagedKittyVirtualMarker(line);
|
|
12181
|
+
if (marker === void 0) {
|
|
12182
|
+
if (line.startsWith("\x1B_pi:tmux-image:v1:i=")) throw new Error("managed kitty virtual marker is malformed");
|
|
12183
|
+
continue;
|
|
12184
|
+
}
|
|
12185
|
+
const anchor = getKittyVirtualPlacementAnchor(line.slice(marker.sequence.length));
|
|
12186
|
+
if (anchor === void 0 || anchor.imageId !== marker.imageId || anchor.placementId !== marker.placementId) throw new Error("managed kitty virtual marker does not match its placement anchor");
|
|
12187
|
+
if (!isKittyVirtualPlaceholderLine(line)) continue;
|
|
12188
|
+
if (index + anchor.rows - 1 < firstSource) continue;
|
|
12189
|
+
if (!matchesKittyVirtualPlaceholderIdentity(firstLine, anchor.imageId, anchor.placementId)) continue;
|
|
12190
|
+
return {
|
|
12191
|
+
sourceIndex: firstSource,
|
|
12192
|
+
sequence: anchor.sequence
|
|
12193
|
+
};
|
|
12194
|
+
}
|
|
12195
|
+
}
|
|
12196
|
+
function sixelBlock(line, port) {
|
|
12197
|
+
if (port === void 0) return void 0;
|
|
12198
|
+
const candidate = port.candidate(line);
|
|
12199
|
+
if (candidate !== void 0) return {
|
|
12200
|
+
kind: "candidate",
|
|
12201
|
+
rows: candidate.layoutRows,
|
|
12202
|
+
fallback: candidate.fallback
|
|
12203
|
+
};
|
|
12204
|
+
const footprint = port.footprint(line);
|
|
12205
|
+
if (footprint !== void 0) return {
|
|
12206
|
+
kind: "dcs",
|
|
12207
|
+
rows: footprint.rows
|
|
12208
|
+
};
|
|
12209
|
+
}
|
|
12210
|
+
function paintBox(box, screen, totalWidth, context) {
|
|
12211
|
+
const sixelScreen = context.sixelScreen;
|
|
11797
12212
|
if (box.lines) {
|
|
11798
12213
|
const offset = box.lineOffset ?? 0;
|
|
11799
12214
|
const firstRow = Math.max(box.rect.y, box.clip.y, 0);
|
|
11800
12215
|
const lastRow = Math.min(box.rect.y + box.rect.height, box.clip.y + box.clip.height, screen.length);
|
|
12216
|
+
const relocated = findRelocatedVirtualAnchor(box, firstRow, lastRow);
|
|
11801
12217
|
for (let row = firstRow; row < lastRow; row++) {
|
|
11802
|
-
const
|
|
12218
|
+
const sourceIndex = offset + row - box.rect.y;
|
|
12219
|
+
const sourceLine = box.lines[sourceIndex];
|
|
11803
12220
|
if (sourceLine === void 0) continue;
|
|
11804
12221
|
let line = sourceLine.replace(OSC133_ZONE_PREFIX$1, "");
|
|
12222
|
+
if (line.startsWith("\x1B_pi:tmux-image:v1:i=")) {
|
|
12223
|
+
const marker = getManagedKittyVirtualMarker(line);
|
|
12224
|
+
if (marker === void 0) throw new Error("managed kitty virtual marker is malformed");
|
|
12225
|
+
const anchor = getKittyVirtualPlacementAnchor(line.slice(marker.sequence.length));
|
|
12226
|
+
if (anchor === void 0 || anchor.imageId !== marker.imageId || anchor.placementId !== marker.placementId) throw new Error("managed kitty virtual marker does not match its placement anchor");
|
|
12227
|
+
line = line.slice(marker.sequence.length);
|
|
12228
|
+
}
|
|
12229
|
+
if (relocated !== void 0 && sourceIndex === relocated.sourceIndex) line = relocated.sequence + line;
|
|
12230
|
+
const block = sixelBlock(line, sixelScreen);
|
|
12231
|
+
if (block !== void 0) {
|
|
12232
|
+
const fullWidthCell = box.rect.x === 0 && box.rect.width >= totalWidth;
|
|
12233
|
+
const clipBottom = Math.min(screen.length, box.clip.y + box.clip.height);
|
|
12234
|
+
const visibleRows = Math.min(block.rows, clipBottom - row);
|
|
12235
|
+
const scrollbar = box.scrollView === void 0 ? void 0 : getScrollbarGeometry(box);
|
|
12236
|
+
const scrollbarClaimsRow = scrollbar !== void 0 && row <= scrollbar.trackTop + scrollbar.trackHeight - 1 && row + visibleRows - 1 >= scrollbar.trackTop;
|
|
12237
|
+
if (block.kind === "candidate") {
|
|
12238
|
+
if (fullWidthCell && visibleRows > 0 && !scrollbarClaimsRow) {
|
|
12239
|
+
context.sixelDemands.push({
|
|
12240
|
+
line,
|
|
12241
|
+
cropTopRows: 0,
|
|
12242
|
+
visibleRows,
|
|
12243
|
+
physicalRow: row
|
|
12244
|
+
});
|
|
12245
|
+
screen[row] = sixelScreen?.materialize(line, 0, visibleRows) ?? block.fallback;
|
|
12246
|
+
} else screen[row] = block.fallback;
|
|
12247
|
+
continue;
|
|
12248
|
+
}
|
|
12249
|
+
if (fullWidthCell && visibleRows > 0) {
|
|
12250
|
+
if (visibleRows >= block.rows) screen[row] = line;
|
|
12251
|
+
else {
|
|
12252
|
+
const cropped = sixelScreen?.crop(line, 0, visibleRows);
|
|
12253
|
+
screen[row] = cropped ?? "";
|
|
12254
|
+
}
|
|
12255
|
+
}
|
|
12256
|
+
continue;
|
|
12257
|
+
}
|
|
11805
12258
|
const imageMetadata = getKittyImageMetadata(line);
|
|
11806
12259
|
if (imageMetadata) {
|
|
11807
12260
|
const clipBottom = Math.min(screen.length, box.clip.y + box.clip.height);
|
|
@@ -11812,23 +12265,47 @@ function paintBox(box, screen, totalWidth) {
|
|
|
11812
12265
|
else screen[row] = compositeTuiLine(screen[row] ?? "", line, box.rect.x, box.rect.width, totalWidth);
|
|
11813
12266
|
}
|
|
11814
12267
|
}
|
|
11815
|
-
for (const child of box.children) paintBox(child, screen, totalWidth);
|
|
11816
|
-
if (box.scrollView && box.scrollContentLines && box.scrollView.scrollTop > 0 && box.rect.height > 0)
|
|
11817
|
-
const
|
|
11818
|
-
|
|
11819
|
-
|
|
11820
|
-
const
|
|
11821
|
-
if (
|
|
11822
|
-
const
|
|
11823
|
-
|
|
12268
|
+
for (const child of box.children) paintBox(child, screen, totalWidth, context);
|
|
12269
|
+
if (box.scrollView && box.scrollContentLines && box.scrollView.scrollTop > 0 && box.rect.height > 0) {
|
|
12270
|
+
const scanFloor = Math.max(0, box.scrollView.scrollTop - MAX_SIXEL_CROP_SCAN_ROWS);
|
|
12271
|
+
for (let imageRow = box.scrollView.scrollTop - 1; imageRow >= 0; imageRow--) {
|
|
12272
|
+
const imageLine = box.scrollContentLines[imageRow] ?? "";
|
|
12273
|
+
const block = sixelBlock(imageLine, sixelScreen);
|
|
12274
|
+
if (block !== void 0) {
|
|
12275
|
+
const hiddenRows = box.scrollView.scrollTop - imageRow;
|
|
12276
|
+
const visibleRows = Math.min(box.rect.height, block.rows - hiddenRows);
|
|
12277
|
+
if (hiddenRows < block.rows && visibleRows > 0 && box.rect.x === 0 && box.rect.width >= totalWidth) {
|
|
12278
|
+
if (block.kind === "candidate") {
|
|
12279
|
+
context.sixelDemands.push({
|
|
12280
|
+
line: imageLine,
|
|
12281
|
+
cropTopRows: hiddenRows,
|
|
12282
|
+
visibleRows,
|
|
12283
|
+
physicalRow: box.rect.y
|
|
12284
|
+
});
|
|
12285
|
+
screen[box.rect.y] = sixelScreen?.materialize(imageLine, hiddenRows, visibleRows) ?? block.fallback;
|
|
12286
|
+
} else {
|
|
12287
|
+
const cropped = sixelScreen?.crop(imageLine, hiddenRows, visibleRows);
|
|
12288
|
+
if (cropped !== void 0) screen[box.rect.y] = cropped;
|
|
12289
|
+
}
|
|
12290
|
+
}
|
|
12291
|
+
break;
|
|
11824
12292
|
}
|
|
11825
|
-
|
|
12293
|
+
const metadata = getKittyImageMetadata(imageLine);
|
|
12294
|
+
if (metadata) {
|
|
12295
|
+
const hiddenRows = box.scrollView.scrollTop - imageRow;
|
|
12296
|
+
if (hiddenRows < metadata.rows) {
|
|
12297
|
+
const cropped = cropKittyImageLine(imageLine, hiddenRows, Math.min(box.rect.height, metadata.rows - hiddenRows));
|
|
12298
|
+
if (box.rect.x === 0 && box.rect.width >= totalWidth) screen[box.rect.y] = cropped;
|
|
12299
|
+
}
|
|
12300
|
+
break;
|
|
12301
|
+
}
|
|
12302
|
+
if (imageLine !== "") break;
|
|
12303
|
+
if (sixelScreen !== void 0 && imageRow <= scanFloor) break;
|
|
11826
12304
|
}
|
|
11827
|
-
if (imageLine !== "") break;
|
|
11828
12305
|
}
|
|
11829
|
-
paintScrollbar(box, screen, totalWidth);
|
|
12306
|
+
paintScrollbar(box, screen, totalWidth, sixelScreen);
|
|
11830
12307
|
}
|
|
11831
|
-
function renderLayoutFrame(root, width, height, requestRender) {
|
|
12308
|
+
function renderLayoutFrame(root, width, height, requestRender, sixelScreen) {
|
|
11832
12309
|
const safeWidth = Math.max(1, Math.floor(width));
|
|
11833
12310
|
const safeHeight = Math.max(1, Math.floor(height));
|
|
11834
12311
|
const context = {
|
|
@@ -11839,7 +12316,9 @@ function renderLayoutFrame(root, width, height, requestRender) {
|
|
|
11839
12316
|
renderCache: /* @__PURE__ */ new Map(),
|
|
11840
12317
|
maxWidthCache: /* @__PURE__ */ new Map(),
|
|
11841
12318
|
requestRender,
|
|
11842
|
-
primaryScrollView: void 0
|
|
12319
|
+
primaryScrollView: void 0,
|
|
12320
|
+
sixelScreen,
|
|
12321
|
+
sixelDemands: []
|
|
11843
12322
|
};
|
|
11844
12323
|
const rootBox = layoutComponent(context, root, 0, 0, safeWidth, safeHeight, {
|
|
11845
12324
|
x: 0,
|
|
@@ -11848,12 +12327,13 @@ function renderLayoutFrame(root, width, height, requestRender) {
|
|
|
11848
12327
|
height: safeHeight
|
|
11849
12328
|
});
|
|
11850
12329
|
const lines = Array.from({ length: safeHeight }, () => "");
|
|
11851
|
-
paintBox(rootBox, lines, safeWidth);
|
|
12330
|
+
paintBox(rootBox, lines, safeWidth, context);
|
|
11852
12331
|
return {
|
|
11853
12332
|
root: rootBox,
|
|
11854
12333
|
width: safeWidth,
|
|
11855
12334
|
height: safeHeight,
|
|
11856
12335
|
lines,
|
|
12336
|
+
sixelDemands: context.sixelDemands,
|
|
11857
12337
|
...context.primaryScrollView === void 0 ? {} : { primaryScrollView: context.primaryScrollView }
|
|
11858
12338
|
};
|
|
11859
12339
|
}
|
|
@@ -11998,8 +12478,18 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
11998
12478
|
flashes;
|
|
11999
12479
|
altScreenActive = false;
|
|
12000
12480
|
imageProtocol = null;
|
|
12481
|
+
/** Per-instance protocol selection; never mutates the process-wide cache. */
|
|
12482
|
+
imageProtocolOverride;
|
|
12001
12483
|
savedCapabilities;
|
|
12002
12484
|
uploadedKittyImages = /* @__PURE__ */ new Map();
|
|
12485
|
+
/**
|
|
12486
|
+
* Per-row trusted SIXEL block height of the LAST painted frame (X074).
|
|
12487
|
+
*
|
|
12488
|
+
* Cached instead of re-derived from the line: the previous anchor is a
|
|
12489
|
+
* registered DCS only while its owner lives, and a disposed raster must still
|
|
12490
|
+
* have its whole footprint erased.
|
|
12491
|
+
*/
|
|
12492
|
+
previousSixelRows = [];
|
|
12003
12493
|
selectionAnchor;
|
|
12004
12494
|
selectionFocus;
|
|
12005
12495
|
selectionGranularity = "character";
|
|
@@ -12018,6 +12508,12 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
12018
12508
|
* the press (a structural repaint between press and release) must not
|
|
12019
12509
|
* receive it. (dsh-pi-tui divergence X018 hardening.) */
|
|
12020
12510
|
selectionPressDispatchComponents;
|
|
12511
|
+
/** The overlay-owned selection region of the CURRENT gesture, when the press
|
|
12512
|
+
* started inside an overlay that opted into `textSelectionInsets`
|
|
12513
|
+
* (dsh-pi-tui divergence X068). A discardable latch, never a second
|
|
12514
|
+
* selection: {@link selectionAnchor}/{@link selectionFocus} remain the one
|
|
12515
|
+
* range, and this only bounds and revalidates it. */
|
|
12516
|
+
overlaySelectionOrigin;
|
|
12021
12517
|
scrollbarDrag;
|
|
12022
12518
|
scrollbarHover;
|
|
12023
12519
|
scrollToEndIndicatorRect;
|
|
@@ -12052,7 +12548,7 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
12052
12548
|
onBeforeViewportInput;
|
|
12053
12549
|
scrollbarBoundaryNotified;
|
|
12054
12550
|
constructor(terminal, showHardwareCursor, logDirectory, options = {}) {
|
|
12055
|
-
super(terminal, showHardwareCursor, logDirectory);
|
|
12551
|
+
super(terminal, showHardwareCursor, logDirectory, options.sixelScreen);
|
|
12056
12552
|
this.implicitDocument = {
|
|
12057
12553
|
render: (width) => super.render(width),
|
|
12058
12554
|
handleMouse: (event) => super.handleMouse(event),
|
|
@@ -12067,6 +12563,7 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
12067
12563
|
this.flashes = new AltScreenFlashContainer(() => this.requestRender());
|
|
12068
12564
|
this.wheelScroll = new WheelScrollAccelerator(options.wheelScrollLines ?? 1);
|
|
12069
12565
|
this.mouseEnabled = options.mouse ?? true;
|
|
12566
|
+
this.imageProtocolOverride = options.imageProtocolOverride;
|
|
12070
12567
|
this.searchMatchStyle = options.searchMatchStyle ?? ((text) => `\x1b[4m${text}\x1b[24m`);
|
|
12071
12568
|
this.searchCurrentMatchStyle = options.searchCurrentMatchStyle ?? ((text) => `\x1b[1;7m${text}\x1b[22;27m`);
|
|
12072
12569
|
this.searchNavigationButtonStyle = options.searchNavigationButtonStyle ?? ((text) => text);
|
|
@@ -12125,10 +12622,21 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
12125
12622
|
if (!text) return false;
|
|
12126
12623
|
return this.copyTextToClipboard(text);
|
|
12127
12624
|
}
|
|
12128
|
-
/**
|
|
12129
|
-
|
|
12625
|
+
/**
|
|
12626
|
+
* Drop the text selection and multi-click history, e.g. before the host
|
|
12627
|
+
* replaces the transcript.
|
|
12628
|
+
*
|
|
12629
|
+
* `preserveClickHistory` (dsh-pi-tui divergence X068) keeps the multi-click
|
|
12630
|
+
* window alive for a repaint that does NOT replace the corpus — the host
|
|
12631
|
+
* repainting an overlay's own content while the user is mid gesture. The
|
|
12632
|
+
* selection range still dies (its cells name the frame being replaced), but
|
|
12633
|
+
* dropping `lastClick` there would turn every double-click into two single
|
|
12634
|
+
* clicks, because the first click's own disclosure repaint runs through the
|
|
12635
|
+
* same host callback.
|
|
12636
|
+
*/
|
|
12637
|
+
resetTextSelection(options) {
|
|
12130
12638
|
this.clearTextSelection();
|
|
12131
|
-
this.lastClick = void 0;
|
|
12639
|
+
if (options?.preserveClickHistory !== true) this.lastClick = void 0;
|
|
12132
12640
|
}
|
|
12133
12641
|
/** The lines of the last rendered frame, one per terminal row, as written to the terminal. */
|
|
12134
12642
|
getScreenLines() {
|
|
@@ -12179,7 +12687,7 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
12179
12687
|
this.flashes.dispose();
|
|
12180
12688
|
this.altScreenActive = true;
|
|
12181
12689
|
const capabilities = getCapabilities();
|
|
12182
|
-
this.imageProtocol = capabilities.images;
|
|
12690
|
+
this.imageProtocol = this.imageProtocolOverride !== void 0 ? this.imageProtocolOverride : capabilities.images;
|
|
12183
12691
|
this.uploadedKittyImages.clear();
|
|
12184
12692
|
if (capabilities.images === "iterm2") {
|
|
12185
12693
|
this.savedCapabilities = capabilities;
|
|
@@ -12194,6 +12702,7 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
12194
12702
|
this.selectionFocus = void 0;
|
|
12195
12703
|
this.selectionGranularity = "character";
|
|
12196
12704
|
this.selectionInitialRange = void 0;
|
|
12705
|
+
this.overlaySelectionOrigin = void 0;
|
|
12197
12706
|
this.lastClick = void 0;
|
|
12198
12707
|
this.pressedUrl = void 0;
|
|
12199
12708
|
this.selectionDragged = false;
|
|
@@ -12208,6 +12717,7 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
12208
12717
|
this.closeSearch();
|
|
12209
12718
|
this.stopSelectionAutoScroll();
|
|
12210
12719
|
this.selectionPressActive = false;
|
|
12720
|
+
if (this.overlaySelectionOrigin !== void 0) this.clearTextSelection();
|
|
12211
12721
|
this.stopScrollbarHover();
|
|
12212
12722
|
this.stopScrollbarDrag();
|
|
12213
12723
|
this.clearComponentMouseGesture();
|
|
@@ -12223,8 +12733,8 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
12223
12733
|
if (options.preserveScreen) this.terminal.write(`${BEGIN_SYNCHRONIZED_OUTPUT}${EXIT_ALT_SCREEN}\x1b[?25h${END_SYNCHRONIZED_OUTPUT}`);
|
|
12224
12734
|
else {
|
|
12225
12735
|
const width = Math.max(1, this.terminal.columns);
|
|
12226
|
-
const documentLines = this.render(width).map((line) => line.replace(OSC133_ZONE_PREFIX, ""));
|
|
12227
|
-
this.lastDocument = this.applyLineResets(documentLines.map((line) => line.replaceAll(CURSOR_MARKER, ""))).map((line) => isImageLine(line) || visibleWidth(line) <= width ? line : sliceByColumn(line, 0, width, true));
|
|
12736
|
+
const documentLines = this.render(width).map((line) => line.replace(OSC133_ZONE_PREFIX, "")).map((line) => this.sixelScreen?.candidate(line)?.fallback ?? line);
|
|
12737
|
+
this.lastDocument = this.applyLineResets(documentLines.map((line) => line.replaceAll(CURSOR_MARKER, ""))).map((line) => this.sixelFootprint(line) !== void 0 ? "" : isImageLine(line) || visibleWidth(line) <= width ? line : sliceByColumn(line, 0, width, true));
|
|
12228
12738
|
let buffer = `${BEGIN_SYNCHRONIZED_OUTPUT}${EXIT_ALT_SCREEN}${DISABLE_AUTOWRAP}`;
|
|
12229
12739
|
for (let row = 0; row < this.lastDocument.length; row++) {
|
|
12230
12740
|
if (row > 0) buffer += "\r\n";
|
|
@@ -12283,10 +12793,75 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
12283
12793
|
}
|
|
12284
12794
|
resetRenderState() {
|
|
12285
12795
|
this.previousScreen = [];
|
|
12796
|
+
this.previousSixelRows = [];
|
|
12286
12797
|
this.previousScreenWidth = 0;
|
|
12287
12798
|
this.previousScreenHeight = 0;
|
|
12288
12799
|
this.currentLayout = void 0;
|
|
12289
12800
|
}
|
|
12801
|
+
/**
|
|
12802
|
+
* Per-row trusted SIXEL block heights for this frame, dropping any block a
|
|
12803
|
+
* visible overlay paints over (X074).
|
|
12804
|
+
*
|
|
12805
|
+
* The raster is ONE command covering its whole footprint and it is written
|
|
12806
|
+
* LAST, so a per-row decision would either cover the overlay text or leave
|
|
12807
|
+
* half a picture. Such a block yields this frame; its identity row above stays
|
|
12808
|
+
* on screen and the block returns when the overlay is gone (the anchor line
|
|
12809
|
+
* changes, so the next frame re-enters the changed range).
|
|
12810
|
+
*/
|
|
12811
|
+
/**
|
|
12812
|
+
* Report this frame's physical SIXEL set after the write (X074).
|
|
12813
|
+
*
|
|
12814
|
+
* `sixelDemands` is the final layout's visible set; a block that materialized
|
|
12815
|
+
* is retained with its exact DCS (emitted only when this frame really wrote
|
|
12816
|
+
* that row), while a granted-but-unready block has no DCS and simply keeps
|
|
12817
|
+
* its grant for the owner to task the lane.
|
|
12818
|
+
*/
|
|
12819
|
+
commitSixelFrame(frame, screen, changedRows, repainted) {
|
|
12820
|
+
const port = this.sixelScreen;
|
|
12821
|
+
if (port === void 0) return;
|
|
12822
|
+
const retained = [];
|
|
12823
|
+
for (const demand of frame.sixelDemands) {
|
|
12824
|
+
const row = demand.physicalRow;
|
|
12825
|
+
const line = screen[row] ?? "";
|
|
12826
|
+
const footprint = port.footprint(line);
|
|
12827
|
+
if (footprint === void 0) continue;
|
|
12828
|
+
retained.push({
|
|
12829
|
+
row,
|
|
12830
|
+
line: demand.line,
|
|
12831
|
+
dcs: line,
|
|
12832
|
+
cropTopRows: demand.cropTopRows,
|
|
12833
|
+
visibleRows: footprint.rows,
|
|
12834
|
+
emitted: repainted || changedRows[row] !== false
|
|
12835
|
+
});
|
|
12836
|
+
}
|
|
12837
|
+
retained.sort((left, right) => right.row - left.row);
|
|
12838
|
+
port.framePainted(this, retained.map(({ line, dcs, cropTopRows, visibleRows, emitted }) => ({
|
|
12839
|
+
line,
|
|
12840
|
+
dcs,
|
|
12841
|
+
cropTopRows,
|
|
12842
|
+
visibleRows,
|
|
12843
|
+
emitted
|
|
12844
|
+
})));
|
|
12845
|
+
}
|
|
12846
|
+
prepareSixelRows(screen) {
|
|
12847
|
+
const rows = new Array(screen.length).fill(0);
|
|
12848
|
+
let any = false;
|
|
12849
|
+
for (let row = 0; row < screen.length; row++) {
|
|
12850
|
+
const footprint = this.sixelFootprint(screen[row] ?? "");
|
|
12851
|
+
if (footprint === void 0) continue;
|
|
12852
|
+
rows[row] = footprint.rows;
|
|
12853
|
+
any = true;
|
|
12854
|
+
}
|
|
12855
|
+
if (!any) return rows;
|
|
12856
|
+
if (this.hasOverlayEntries) for (let row = 0; row < rows.length; row++) {
|
|
12857
|
+
const height = rows[row] ?? 0;
|
|
12858
|
+
if (height === 0) continue;
|
|
12859
|
+
if (!this.linesCoveredByOverlay(row, row + height - 1, screen.length)) continue;
|
|
12860
|
+
screen[row] = "";
|
|
12861
|
+
rows[row] = 0;
|
|
12862
|
+
}
|
|
12863
|
+
return rows;
|
|
12864
|
+
}
|
|
12290
12865
|
scrollBy(lines) {
|
|
12291
12866
|
this.getPrimaryScrollView().scrollBy(lines);
|
|
12292
12867
|
this.requestRender();
|
|
@@ -12393,7 +12968,9 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
12393
12968
|
return false;
|
|
12394
12969
|
}
|
|
12395
12970
|
const shouldRevealSelection = search.selectionMode !== "retain";
|
|
12396
|
-
const
|
|
12971
|
+
const isEmptyImageRow = (line) => this.sixelFootprint(line) !== void 0 || this.sixelScreen?.candidate(line) !== void 0;
|
|
12972
|
+
const corpus = lines.some(isEmptyImageRow) ? lines.map((line) => isEmptyImageRow(line) ? "" : line) : lines;
|
|
12973
|
+
const result = search.index.search(corpus, search.query);
|
|
12397
12974
|
const matches = result.matches;
|
|
12398
12975
|
search.matches = matches;
|
|
12399
12976
|
if (!result.changed && search.selectionMode === "retain") return false;
|
|
@@ -12533,7 +13110,8 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
12533
13110
|
}
|
|
12534
13111
|
handleViewportInput(data) {
|
|
12535
13112
|
if (data === FOCUS_OUT) {
|
|
12536
|
-
const
|
|
13113
|
+
const hadOverlaySelection = this.overlaySelectionOrigin !== void 0;
|
|
13114
|
+
const hadActiveSelection = this.selectionPressActive || hadOverlaySelection;
|
|
12537
13115
|
const hadNonEmptyActiveSelection = hadActiveSelection && this.getSelectionBounds() !== void 0;
|
|
12538
13116
|
this.selectionPressActive = false;
|
|
12539
13117
|
this.stopSelectionAutoScroll();
|
|
@@ -12550,6 +13128,7 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
12550
13128
|
this.selectionFocus = void 0;
|
|
12551
13129
|
this.selectionGranularity = "character";
|
|
12552
13130
|
this.selectionInitialRange = void 0;
|
|
13131
|
+
this.overlaySelectionOrigin = void 0;
|
|
12553
13132
|
if (hadNonEmptyActiveSelection) this.requestRender();
|
|
12554
13133
|
}
|
|
12555
13134
|
this.lastClick = void 0;
|
|
@@ -12745,6 +13324,7 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
12745
13324
|
this.selectionFocus = void 0;
|
|
12746
13325
|
this.selectionGranularity = "character";
|
|
12747
13326
|
this.selectionInitialRange = void 0;
|
|
13327
|
+
this.overlaySelectionOrigin = void 0;
|
|
12748
13328
|
this.pressedUrl = void 0;
|
|
12749
13329
|
this.selectionDragged = false;
|
|
12750
13330
|
this.selectionPressDispatchComponents = void 0;
|
|
@@ -12811,6 +13391,10 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
12811
13391
|
return;
|
|
12812
13392
|
}
|
|
12813
13393
|
}
|
|
13394
|
+
if (this.overlaySelectionOrigin !== void 0 && this.selectionPressActive) {
|
|
13395
|
+
this.handleSelectionMouseEvent(raw);
|
|
13396
|
+
return;
|
|
13397
|
+
}
|
|
12814
13398
|
if (this.handleSearchMouseEvent(raw)) return;
|
|
12815
13399
|
const overlay = this.dispatchMouseToOverlay(event);
|
|
12816
13400
|
if (!overlay.hit) {
|
|
@@ -12846,6 +13430,13 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
12846
13430
|
return;
|
|
12847
13431
|
}
|
|
12848
13432
|
if (overlay.hit) {
|
|
13433
|
+
if (type === "press") {
|
|
13434
|
+
const region = this.overlayTextSelectionRegionAt(raw.x, raw.y);
|
|
13435
|
+
if (region !== void 0) {
|
|
13436
|
+
this.handleSelectionMouseEvent(raw, region);
|
|
13437
|
+
return;
|
|
13438
|
+
}
|
|
13439
|
+
}
|
|
12849
13440
|
if (this.selectionPressActive) this.clearTextSelection();
|
|
12850
13441
|
if (this.scrollbarDrag !== void 0) this.stopScrollbarDrag();
|
|
12851
13442
|
return;
|
|
@@ -12986,6 +13577,7 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
12986
13577
|
this.selectionFocus = void 0;
|
|
12987
13578
|
this.selectionGranularity = "character";
|
|
12988
13579
|
this.selectionInitialRange = void 0;
|
|
13580
|
+
this.overlaySelectionOrigin = void 0;
|
|
12989
13581
|
this.lastClick = void 0;
|
|
12990
13582
|
this.pressedUrl = void 0;
|
|
12991
13583
|
this.selectionDragged = false;
|
|
@@ -13025,9 +13617,28 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
13025
13617
|
const point = this.getScrollSelectionPoint(scrollView, event.x, event.y);
|
|
13026
13618
|
if (point) return point;
|
|
13027
13619
|
}
|
|
13028
|
-
return {
|
|
13620
|
+
return this.clampSelectionPoint({
|
|
13029
13621
|
row: Math.max(0, Math.min(this.terminal.rows - 1, event.y)),
|
|
13030
13622
|
col: Math.max(0, Math.min(this.terminal.columns - 1, event.x))
|
|
13623
|
+
});
|
|
13624
|
+
}
|
|
13625
|
+
/**
|
|
13626
|
+
* Clip one selection point into the captured overlay region, if any
|
|
13627
|
+
* (dsh-pi-tui divergence X068). A drag that leaves the region maps to its
|
|
13628
|
+
* nearest cell (the last visible cell for an exclusive boundary point), so
|
|
13629
|
+
* neither the highlight nor the copied text can ever reach the frame chrome
|
|
13630
|
+
* or the background behind the modal.
|
|
13631
|
+
*/
|
|
13632
|
+
clampSelectionPoint(point) {
|
|
13633
|
+
const region = this.overlaySelectionOrigin;
|
|
13634
|
+
if (region === void 0) return point;
|
|
13635
|
+
const { rect } = region;
|
|
13636
|
+
const row = Math.max(rect.minY, Math.min(rect.maxY - 1, point.row));
|
|
13637
|
+
const maxCol = point.boundary === true ? rect.maxX : rect.maxX - 1;
|
|
13638
|
+
return {
|
|
13639
|
+
...point,
|
|
13640
|
+
row,
|
|
13641
|
+
col: Math.max(rect.minX, Math.min(maxCol, point.col))
|
|
13031
13642
|
};
|
|
13032
13643
|
}
|
|
13033
13644
|
getSelectionSourceLine(point) {
|
|
@@ -13060,28 +13671,31 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
13060
13671
|
for (let index = clickedSegmentIndex; index > 0 && canJoin(segments[index - 1], segments[index]); index--) selectionStart = segments[index - 1].start;
|
|
13061
13672
|
for (let index = clickedSegmentIndex; index < segments.length - 1 && canJoin(segments[index], segments[index + 1]); index++) selectionEnd = segments[index + 1].end;
|
|
13062
13673
|
return {
|
|
13063
|
-
start: {
|
|
13674
|
+
start: this.clampSelectionPoint({
|
|
13064
13675
|
...point,
|
|
13065
13676
|
col: selectionStart
|
|
13066
|
-
},
|
|
13067
|
-
end: {
|
|
13677
|
+
}),
|
|
13678
|
+
end: this.clampSelectionPoint({
|
|
13068
13679
|
...point,
|
|
13069
13680
|
col: selectionEnd,
|
|
13070
13681
|
boundary: true
|
|
13071
|
-
}
|
|
13682
|
+
})
|
|
13072
13683
|
};
|
|
13073
13684
|
}
|
|
13074
13685
|
getLineSelection(point) {
|
|
13686
|
+
const region = this.overlaySelectionOrigin;
|
|
13687
|
+
const start = region?.rect.minX ?? 0;
|
|
13688
|
+
const end = region?.rect.maxX ?? visibleWidth(this.getSelectionSourceLine(point));
|
|
13075
13689
|
return {
|
|
13076
|
-
start: {
|
|
13690
|
+
start: this.clampSelectionPoint({
|
|
13077
13691
|
...point,
|
|
13078
|
-
col:
|
|
13079
|
-
},
|
|
13080
|
-
end: {
|
|
13692
|
+
col: start
|
|
13693
|
+
}),
|
|
13694
|
+
end: this.clampSelectionPoint({
|
|
13081
13695
|
...point,
|
|
13082
|
-
col:
|
|
13696
|
+
col: end,
|
|
13083
13697
|
boundary: true
|
|
13084
|
-
}
|
|
13698
|
+
})
|
|
13085
13699
|
};
|
|
13086
13700
|
}
|
|
13087
13701
|
updateSelectionFocus(point) {
|
|
@@ -13164,9 +13778,13 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
13164
13778
|
this.selectionAutoScrollDirection = 0;
|
|
13165
13779
|
this.selectionDragPointer = void 0;
|
|
13166
13780
|
}
|
|
13167
|
-
handleSelectionMouseEvent(event) {
|
|
13781
|
+
handleSelectionMouseEvent(event, overlayOrigin) {
|
|
13168
13782
|
const button = event.button & 3;
|
|
13169
13783
|
if (button !== 0 && !(event.release && button === 3)) return;
|
|
13784
|
+
if (overlayOrigin === void 0 && this.overlaySelectionOrigin !== void 0 && !this.isOverlayTextSelectionRegionLive(this.overlaySelectionOrigin)) {
|
|
13785
|
+
this.clearTextSelection();
|
|
13786
|
+
return;
|
|
13787
|
+
}
|
|
13170
13788
|
const anchorScrollView = this.selectionAnchor?.scrollView;
|
|
13171
13789
|
const point = this.getSelectionPoint(event, anchorScrollView);
|
|
13172
13790
|
if (event.release) {
|
|
@@ -13226,6 +13844,7 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
13226
13844
|
}
|
|
13227
13845
|
this.stopSelectionAutoScroll();
|
|
13228
13846
|
this.selectionPressActive = true;
|
|
13847
|
+
this.overlaySelectionOrigin = overlayOrigin;
|
|
13229
13848
|
this.selectionPressDispatchComponents = new Set(this.lastMouseDispatchComponents);
|
|
13230
13849
|
this.onCellPress?.(event.x, event.y);
|
|
13231
13850
|
const scrollView = !this.hasBlockingOverlay() && this.currentLayout ? getScrollViewsAt(this.currentLayout, event.x, event.y)[0] : void 0;
|
|
@@ -13238,7 +13857,7 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
13238
13857
|
this.selectionAnchor = range?.start ?? anchor;
|
|
13239
13858
|
this.selectionFocus = range?.end ?? anchor;
|
|
13240
13859
|
this.selectionDragged = false;
|
|
13241
|
-
this.pressedUrl = range ? void 0 : getOsc8LinkAtColumn(this.previousScreen[Math.max(0, Math.min(this.terminal.rows - 1, event.y))] ?? "", Math.max(0, Math.min(this.terminal.columns - 1, event.x)));
|
|
13860
|
+
this.pressedUrl = range || overlayOrigin !== void 0 ? void 0 : getOsc8LinkAtColumn(this.previousScreen[Math.max(0, Math.min(this.terminal.rows - 1, event.y))] ?? "", Math.max(0, Math.min(this.terminal.columns - 1, event.x)));
|
|
13242
13861
|
this.requestRender();
|
|
13243
13862
|
}
|
|
13244
13863
|
getSelectionBounds() {
|
|
@@ -13268,6 +13887,14 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
13268
13887
|
getActiveSelectionText() {
|
|
13269
13888
|
const selection = this.getSelectionBounds();
|
|
13270
13889
|
if (!selection) return void 0;
|
|
13890
|
+
const region = this.overlaySelectionOrigin;
|
|
13891
|
+
if (region !== void 0) {
|
|
13892
|
+
if (!this.isOverlayTextSelectionRegionLive(region)) {
|
|
13893
|
+
this.clearTextSelection();
|
|
13894
|
+
return;
|
|
13895
|
+
}
|
|
13896
|
+
return this.getOverlaySelectionText(selection, region);
|
|
13897
|
+
}
|
|
13271
13898
|
let sourceLines = this.previousScreen;
|
|
13272
13899
|
if (selection.start.scrollView) {
|
|
13273
13900
|
if (!this.currentLayout) return void 0;
|
|
@@ -13278,6 +13905,10 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
13278
13905
|
const lines = [];
|
|
13279
13906
|
for (let row = selection.start.row; row <= selection.end.row; row++) {
|
|
13280
13907
|
const line = sourceLines[row] ?? "";
|
|
13908
|
+
if (this.isRenderableImageLine(line)) {
|
|
13909
|
+
lines.push("");
|
|
13910
|
+
continue;
|
|
13911
|
+
}
|
|
13281
13912
|
const columns = this.getSelectionColumns(line, row, selection);
|
|
13282
13913
|
const sliced = stripTerminalSequences(sliceByColumn(line, columns.start, Math.max(0, columns.end - columns.start), true)).trimEnd();
|
|
13283
13914
|
lines.push(columns.start === 0 ? sliced.replace(/^ {1,3}/, "") : sliced);
|
|
@@ -13285,6 +13916,28 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
13285
13916
|
const text = lines.join("\n");
|
|
13286
13917
|
return text.length === 0 ? void 0 : text;
|
|
13287
13918
|
}
|
|
13919
|
+
/**
|
|
13920
|
+
* The visible text of one overlay-owned selection (dsh-pi-tui divergence
|
|
13921
|
+
* X068): each row is sliced to the capture's column range inside the overlay
|
|
13922
|
+
* content rectangle, terminal sequences are stripped and real spaces and
|
|
13923
|
+
* indentation are PRESERVED. The transcript branch's `trimEnd` and its 1-3
|
|
13924
|
+
* cell bullet-strip (X024) are deliberately not applied: file content and
|
|
13925
|
+
* paths must copy exactly as painted.
|
|
13926
|
+
*/
|
|
13927
|
+
getOverlaySelectionText(selection, region) {
|
|
13928
|
+
const lines = [];
|
|
13929
|
+
for (let row = selection.start.row; row <= selection.end.row; row++) {
|
|
13930
|
+
const line = this.previousScreen[row] ?? "";
|
|
13931
|
+
const columns = this.getSelectionColumns(line, row, selection, region.rect.minX, region.rect.maxX);
|
|
13932
|
+
if (columns.end <= columns.start) {
|
|
13933
|
+
lines.push("");
|
|
13934
|
+
continue;
|
|
13935
|
+
}
|
|
13936
|
+
lines.push(stripTerminalSequences(sliceByColumn(line, columns.start, columns.end - columns.start, true)));
|
|
13937
|
+
}
|
|
13938
|
+
const text = lines.join("\n");
|
|
13939
|
+
return text.length === 0 ? void 0 : text;
|
|
13940
|
+
}
|
|
13288
13941
|
async copySelectionToClipboard() {
|
|
13289
13942
|
const text = this.getActiveSelectionText();
|
|
13290
13943
|
if (!text) return false;
|
|
@@ -13363,7 +14016,7 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
13363
14016
|
const result = [...screen];
|
|
13364
14017
|
for (const [row, ranges] of rangesByRow) {
|
|
13365
14018
|
let line = result[row] ?? "";
|
|
13366
|
-
if (
|
|
14019
|
+
if (this.isRenderableImageLine(line)) continue;
|
|
13367
14020
|
const lineWidth = visibleWidth(line);
|
|
13368
14021
|
for (const range of ranges.sort((a, b) => b.startCol - a.startCol)) {
|
|
13369
14022
|
const startCol = Math.min(range.startCol, lineWidth);
|
|
@@ -13402,6 +14055,13 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
13402
14055
|
let maxRow = screen.length - 1;
|
|
13403
14056
|
let minColumn = 0;
|
|
13404
14057
|
let maxColumn = this.terminal.columns;
|
|
14058
|
+
const region = this.overlaySelectionOrigin;
|
|
14059
|
+
if (region !== void 0) {
|
|
14060
|
+
minRow = Math.max(minRow, region.rect.minY);
|
|
14061
|
+
maxRow = Math.min(maxRow, region.rect.maxY - 1);
|
|
14062
|
+
minColumn = Math.max(minColumn, region.rect.minX);
|
|
14063
|
+
maxColumn = Math.min(maxColumn, region.rect.maxX);
|
|
14064
|
+
}
|
|
13405
14065
|
if (selection.start.scrollView) {
|
|
13406
14066
|
if (!layout) return screen;
|
|
13407
14067
|
const box = getScrollViewBox(layout, selection.start.scrollView);
|
|
@@ -13424,7 +14084,7 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
13424
14084
|
};
|
|
13425
14085
|
}
|
|
13426
14086
|
return screen.map((line, row) => {
|
|
13427
|
-
if (row < minRow || row > maxRow || row < screenSelection.start.row || row > screenSelection.end.row ||
|
|
14087
|
+
if (row < minRow || row > maxRow || row < screenSelection.start.row || row > screenSelection.end.row || this.isRenderableImageLine(line)) return line;
|
|
13428
14088
|
const lineWidth = visibleWidth(line);
|
|
13429
14089
|
const columns = this.getSelectionColumns(line, row, screenSelection, minColumn, maxColumn);
|
|
13430
14090
|
if (columns.end <= columns.start) return line;
|
|
@@ -13447,7 +14107,7 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
13447
14107
|
const clip = box?.clip;
|
|
13448
14108
|
if (!clip || clip.width <= 0 || clip.height <= 0) return screen;
|
|
13449
14109
|
const row = clip.y + clip.height - 1;
|
|
13450
|
-
if (row >= screen.length ||
|
|
14110
|
+
if (row >= screen.length || this.isRenderableImageLine(screen[row] ?? "")) return screen;
|
|
13451
14111
|
const scrollbarColumn = box ? getScrollbarGeometry(box)?.column : void 0;
|
|
13452
14112
|
const label = truncateToWidth(this.scrollToEndIndicator(), clip.width, "");
|
|
13453
14113
|
const labelWidth = visibleWidth(label);
|
|
@@ -13474,6 +14134,7 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
13474
14134
|
const line = flashLines[row];
|
|
13475
14135
|
const flashWidth = visibleWidth(line);
|
|
13476
14136
|
if (flashWidth === 0) continue;
|
|
14137
|
+
if (this.isRenderableImageLine(result[row] ?? "")) continue;
|
|
13477
14138
|
result[row] = compositeTuiLine(result[row] ?? "", line, width - flashWidth, flashWidth, width);
|
|
13478
14139
|
}
|
|
13479
14140
|
return result;
|
|
@@ -13483,23 +14144,38 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
13483
14144
|
const width = Math.max(1, this.terminal.columns);
|
|
13484
14145
|
const height = Math.max(1, this.terminal.rows);
|
|
13485
14146
|
const root = this.layoutRoot ?? this.implicitScrollView;
|
|
13486
|
-
let nextLayout = renderLayoutFrame(root, width, height, () => this.requestRender());
|
|
13487
|
-
if (this.refreshSearch(nextLayout)) nextLayout = renderLayoutFrame(root, width, height, () => this.requestRender());
|
|
14147
|
+
let nextLayout = renderLayoutFrame(root, width, height, () => this.requestRender(), this.sixelScreen);
|
|
14148
|
+
if (this.refreshSearch(nextLayout)) nextLayout = renderLayoutFrame(root, width, height, () => this.requestRender(), this.sixelScreen);
|
|
14149
|
+
if (this.sixelScreen !== void 0) {
|
|
14150
|
+
if (this.sixelScreen.reconcileVisible(this, nextLayout.sixelDemands)) nextLayout = renderLayoutFrame(root, width, height, () => this.requestRender(), this.sixelScreen);
|
|
14151
|
+
}
|
|
13488
14152
|
let screen = nextLayout.lines.map((line) => line.replace(OSC133_ZONE_PREFIX, ""));
|
|
13489
14153
|
screen = this.applySearchHighlights(screen, nextLayout);
|
|
13490
14154
|
screen = this.compositeScrollToEndIndicator(screen, nextLayout, width);
|
|
13491
14155
|
screen = this.compositeOverlays(screen, width, height);
|
|
13492
14156
|
if (screen.length > height) screen = screen.slice(screen.length - height);
|
|
14157
|
+
if (this.overlaySelectionOrigin !== void 0 && !this.isOverlayTextSelectionRegionLive(this.overlaySelectionOrigin)) this.clearTextSelection();
|
|
13493
14158
|
screen = this.applySelection(screen, nextLayout);
|
|
13494
14159
|
screen = this.compositeFlashes(screen, width, height);
|
|
14160
|
+
const sixelRows = this.prepareSixelRows(screen);
|
|
14161
|
+
if (this.sixelScreen !== void 0) {
|
|
14162
|
+
const paintedDemands = nextLayout.sixelDemands.filter((demand) => !this.linesCoveredByOverlay(demand.physicalRow, demand.physicalRow + demand.visibleRows - 1, screen.length));
|
|
14163
|
+
if (paintedDemands.length !== nextLayout.sixelDemands.length) this.sixelScreen.reconcileVisible(this, paintedDemands);
|
|
14164
|
+
}
|
|
13495
14165
|
const cursorPos = this.extractCursorPosition(screen, height);
|
|
13496
14166
|
screen = this.applyLineResets(screen).map((line) => {
|
|
13497
|
-
if (
|
|
14167
|
+
if (this.isRenderableImageLine(line) || visibleWidth(line) <= width) return line;
|
|
13498
14168
|
return sliceByColumn(line, 0, width, true);
|
|
13499
14169
|
});
|
|
13500
14170
|
const fullRedraw = this.previousScreen.length === 0 || this.previousScreenWidth !== width || this.previousScreenHeight !== height;
|
|
13501
14171
|
const changedRows = screen.map((line, row) => line !== this.previousScreen[row]);
|
|
13502
|
-
const imageAnchorsNeedRedraw = screen.some((line, row) => changedRows[row] && (
|
|
14172
|
+
const imageAnchorsNeedRedraw = screen.some((line, row) => changedRows[row] && (this.isRenderableImageLine(line) || this.isRenderableImageLine(this.previousScreen[row] ?? "")));
|
|
14173
|
+
const sixelCoveredRows = /* @__PURE__ */ new Set();
|
|
14174
|
+
for (const declared of [this.previousSixelRows, sixelRows]) for (let row = 0; row < declared.length; row++) {
|
|
14175
|
+
const rows = declared[row] ?? 0;
|
|
14176
|
+
for (let offset = 0; offset < rows; offset++) sixelCoveredRows.add(row + offset);
|
|
14177
|
+
}
|
|
14178
|
+
const sixelNeedRedraw = changedRows.some((changed, row) => changed && (sixelCoveredRows.has(row) || (sixelRows[row] ?? 0) > 0));
|
|
13503
14179
|
const isWezTerm = Boolean(process.env.WEZTERM_PANE) || process.env.TERM_PROGRAM?.toLowerCase() === "wezterm";
|
|
13504
14180
|
const imageCellsNeedRedraw = !imageAnchorsNeedRedraw && isWezTerm && this.imageProtocol === "kitty" && changedRows.some(Boolean) && screen.some((line, row) => {
|
|
13505
14181
|
const placementRows = getKittyImagePlacementRows(line);
|
|
@@ -13539,9 +14215,21 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
13539
14215
|
if (!isImageLine(preparedKittyScreen.lines[row] ?? "")) continue;
|
|
13540
14216
|
buffer += `\x1b[${row + 1};1H${preparedKittyScreen.lines[row] ?? ""}`;
|
|
13541
14217
|
}
|
|
13542
|
-
} else
|
|
13543
|
-
if (
|
|
13544
|
-
|
|
14218
|
+
} else {
|
|
14219
|
+
if (sixelNeedRedraw) for (const row of [...sixelCoveredRows].sort((left, right) => left - right)) {
|
|
14220
|
+
if (row < 0 || row >= height) continue;
|
|
14221
|
+
buffer += `\x1b[${row + 1};1H\x1b[2K`;
|
|
14222
|
+
}
|
|
14223
|
+
for (let row = 0; row < height; row++) {
|
|
14224
|
+
const clearedBySixel = sixelNeedRedraw && sixelCoveredRows.has(row);
|
|
14225
|
+
if (!fullRedraw && !imagesNeedRedraw && !clearedBySixel && screen[row] === this.previousScreen[row]) continue;
|
|
14226
|
+
if ((sixelRows[row] ?? 0) > 0) continue;
|
|
14227
|
+
buffer += `\x1b[${row + 1};1H\x1b[2K${preparedKittyScreen.lines[row] ?? ""}`;
|
|
14228
|
+
}
|
|
14229
|
+
if (fullRedraw || sixelNeedRedraw) for (let row = 0; row < height; row++) {
|
|
14230
|
+
if ((sixelRows[row] ?? 0) === 0) continue;
|
|
14231
|
+
buffer += `\x1b[${row + 1};1H${screen[row]}`;
|
|
14232
|
+
}
|
|
13545
14233
|
}
|
|
13546
14234
|
if (cursorPos) {
|
|
13547
14235
|
buffer += `\x1b[${cursorPos.row + 1};${Math.min(width, cursorPos.col) + 1}H`;
|
|
@@ -13549,7 +14237,9 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
13549
14237
|
} else buffer += "\x1B[?25l";
|
|
13550
14238
|
buffer += END_SYNCHRONIZED_OUTPUT;
|
|
13551
14239
|
this.terminal.write(buffer);
|
|
14240
|
+
this.commitSixelFrame(nextLayout, screen, changedRows, fullRedraw || sixelNeedRedraw);
|
|
13552
14241
|
this.previousScreen = screen;
|
|
14242
|
+
this.previousSixelRows = sixelRows;
|
|
13553
14243
|
this.previousScreenWidth = width;
|
|
13554
14244
|
this.previousScreenHeight = height;
|
|
13555
14245
|
this.currentLayout = nextLayout;
|
|
@@ -13653,12 +14343,36 @@ var TuiMainScreen = class extends TuiBase {
|
|
|
13653
14343
|
/** Per-line kitty image ids of the previous frame, aligned with previousRawLines. */
|
|
13654
14344
|
previousLineImageIds = [];
|
|
13655
14345
|
previousKittyImageIds = /* @__PURE__ */ new Set();
|
|
14346
|
+
/**
|
|
14347
|
+
* Declared image rows of the previous frame, aligned with
|
|
14348
|
+
* {@link previousLines}: a Kitty `r=`/registered placement row count, or a
|
|
14349
|
+
* trusted SIXEL footprint. Cached instead of re-deriving from the line,
|
|
14350
|
+
* because a raster whose component was disposed is no longer registered —
|
|
14351
|
+
* the OLD block must still be erased (X073).
|
|
14352
|
+
*/
|
|
14353
|
+
previousLineImageRows = [];
|
|
14354
|
+
/**
|
|
14355
|
+
* Per-line TRUSTED SIXEL footprint height of the previous frame (0 = no
|
|
14356
|
+
* SIXEL block). Unlike the Kitty row count this is exact, so it never has to
|
|
14357
|
+
* be re-derived by scanning blank body rows — a scan would collapse under an
|
|
14358
|
+
* overlay or a text row that landed inside the block. (X073.)
|
|
14359
|
+
*/
|
|
14360
|
+
previousLineSixelRows = [];
|
|
13656
14361
|
previousWidth = 0;
|
|
13657
14362
|
previousHeight = 0;
|
|
13658
14363
|
cursorRow = 0;
|
|
13659
14364
|
hardwareCursorRow = 0;
|
|
13660
14365
|
maxLinesRendered = 0;
|
|
13661
14366
|
previousViewportTop = 0;
|
|
14367
|
+
/** Per-row token -> DCS the current frame materialized (X073). */
|
|
14368
|
+
sixelFrameRasters = /* @__PURE__ */ new Map();
|
|
14369
|
+
/**
|
|
14370
|
+
* @param sixelScreen - the Client-local SIXEL trust port (X072). Absent for
|
|
14371
|
+
* every non-SIXEL terminal, and then this screen is byte-for-byte upstream.
|
|
14372
|
+
*/
|
|
14373
|
+
constructor(terminal, showHardwareCursor, logDirectory, sixelScreen) {
|
|
14374
|
+
super(terminal, showHardwareCursor, logDirectory, sixelScreen);
|
|
14375
|
+
}
|
|
13662
14376
|
captureRenderState() {
|
|
13663
14377
|
return {
|
|
13664
14378
|
previousLines: [...this.previousLines],
|
|
@@ -13671,9 +14385,11 @@ var TuiMainScreen = class extends TuiBase {
|
|
|
13671
14385
|
};
|
|
13672
14386
|
}
|
|
13673
14387
|
restoreRenderState(state) {
|
|
13674
|
-
this.previousLines = state.previousLines.map((line) =>
|
|
14388
|
+
this.previousLines = state.previousLines.map((line) => this.isRenderableImageLine(line) ? "" : line);
|
|
13675
14389
|
this.previousRawLines = [];
|
|
13676
14390
|
this.previousLineImageIds = [];
|
|
14391
|
+
this.previousLineImageRows = [];
|
|
14392
|
+
this.previousLineSixelRows = [];
|
|
13677
14393
|
this.previousKittyImageIds = /* @__PURE__ */ new Set();
|
|
13678
14394
|
this.previousWidth = state.previousWidth;
|
|
13679
14395
|
this.previousHeight = state.previousHeight;
|
|
@@ -13686,6 +14402,8 @@ var TuiMainScreen = class extends TuiBase {
|
|
|
13686
14402
|
this.previousLines = [];
|
|
13687
14403
|
this.previousRawLines = [];
|
|
13688
14404
|
this.previousLineImageIds = [];
|
|
14405
|
+
this.previousLineImageRows = [];
|
|
14406
|
+
this.previousLineSixelRows = [];
|
|
13689
14407
|
this.previousWidth = -1;
|
|
13690
14408
|
this.previousHeight = -1;
|
|
13691
14409
|
this.cursorRow = 0;
|
|
@@ -13711,33 +14429,191 @@ var TuiMainScreen = class extends TuiBase {
|
|
|
13711
14429
|
for (const id of ids) buffer += deleteKittyImage(id);
|
|
13712
14430
|
return buffer;
|
|
13713
14431
|
}
|
|
13714
|
-
|
|
13715
|
-
|
|
14432
|
+
/**
|
|
14433
|
+
* Project the frame's candidate markers into what this Screen may write.
|
|
14434
|
+
*
|
|
14435
|
+
* The component tree only ever emits an inert candidate marker per block; the
|
|
14436
|
+
* final viewport decides which occurrences are granted residency. Rows above
|
|
14437
|
+
* the viewport keep their previous physical line when the SAME occurrence is
|
|
14438
|
+
* still there: a residency-only change must not rewrite committed scrollback
|
|
14439
|
+
* (a rewrite above the viewport would force `fullRender(true)` and `3J`).
|
|
14440
|
+
*/
|
|
14441
|
+
projectSixelCandidates(rawLines, height, viewportTop, width, reconcile) {
|
|
14442
|
+
const port = this.sixelScreen;
|
|
14443
|
+
const lines = [...rawLines];
|
|
14444
|
+
const rasters = /* @__PURE__ */ new Map();
|
|
14445
|
+
const preserved = /* @__PURE__ */ new Set();
|
|
14446
|
+
if (port === void 0) return {
|
|
14447
|
+
lines,
|
|
14448
|
+
rasters,
|
|
14449
|
+
preserved,
|
|
14450
|
+
recompose: false
|
|
14451
|
+
};
|
|
14452
|
+
const visible = [];
|
|
14453
|
+
for (let row = viewportTop; row < Math.min(rawLines.length, viewportTop + height); row += 1) {
|
|
14454
|
+
const info = port.candidate(rawLines[row] ?? "");
|
|
14455
|
+
if (info === void 0) continue;
|
|
14456
|
+
const visibleRows = Math.min(info.layoutRows, viewportTop + height - row);
|
|
14457
|
+
if (visibleRows <= 0) continue;
|
|
14458
|
+
visible.push({
|
|
14459
|
+
row,
|
|
14460
|
+
fallback: info.fallback,
|
|
14461
|
+
cropTopRows: 0,
|
|
14462
|
+
visibleRows
|
|
14463
|
+
});
|
|
14464
|
+
}
|
|
14465
|
+
visible.sort((left, right) => right.row - left.row);
|
|
14466
|
+
if (reconcile) {
|
|
14467
|
+
if (port.reconcileVisible(this, visible.map((entry) => ({
|
|
14468
|
+
line: rawLines[entry.row],
|
|
14469
|
+
cropTopRows: entry.cropTopRows,
|
|
14470
|
+
visibleRows: entry.visibleRows,
|
|
14471
|
+
physicalRow: entry.row
|
|
14472
|
+
})))) return {
|
|
14473
|
+
lines,
|
|
14474
|
+
rasters,
|
|
14475
|
+
preserved,
|
|
14476
|
+
recompose: true
|
|
14477
|
+
};
|
|
14478
|
+
}
|
|
14479
|
+
for (const entry of visible) {
|
|
14480
|
+
const token = rawLines[entry.row];
|
|
14481
|
+
const dcs = port.materialize(token, entry.cropTopRows, entry.visibleRows);
|
|
14482
|
+
if (dcs === void 0) {
|
|
14483
|
+
lines[entry.row] = entry.fallback;
|
|
14484
|
+
continue;
|
|
14485
|
+
}
|
|
14486
|
+
lines[entry.row] = dcs;
|
|
14487
|
+
const footprint = port.footprint(dcs);
|
|
14488
|
+
rasters.set(entry.row, {
|
|
14489
|
+
line: token,
|
|
14490
|
+
dcs,
|
|
14491
|
+
cropTopRows: entry.cropTopRows,
|
|
14492
|
+
visibleRows: footprint?.rows ?? entry.visibleRows
|
|
14493
|
+
});
|
|
14494
|
+
}
|
|
14495
|
+
for (let row = 0; row < viewportTop && row < rawLines.length; row += 1) {
|
|
14496
|
+
const token = rawLines[row] ?? "";
|
|
14497
|
+
const info = port.candidate(token);
|
|
14498
|
+
if (info === void 0) continue;
|
|
14499
|
+
const previous = this.previousLines[row] ?? "";
|
|
14500
|
+
if (this.previousRawLines[row] === token && this.sixelFootprint(previous) !== void 0) {
|
|
14501
|
+
lines[row] = previous;
|
|
14502
|
+
preserved.add(row);
|
|
14503
|
+
} else if (this.previousRawLines[row] === token) {
|
|
14504
|
+
let fallback = info.fallback;
|
|
14505
|
+
if (visibleWidth(fallback) > width) fallback = sliceByColumn(fallback, 0, width, true);
|
|
14506
|
+
fallback = normalizeTerminalOutput(fallback) + SEGMENT_RESET;
|
|
14507
|
+
this.previousLines[row] = fallback;
|
|
14508
|
+
this.previousLineSixelRows[row] = 0;
|
|
14509
|
+
this.previousLineImageRows[row] = 0;
|
|
14510
|
+
this.previousLineImageIds[row] = [];
|
|
14511
|
+
lines[row] = fallback;
|
|
14512
|
+
preserved.add(row);
|
|
14513
|
+
} else lines[row] = info.fallback;
|
|
14514
|
+
}
|
|
14515
|
+
return {
|
|
14516
|
+
lines,
|
|
14517
|
+
rasters,
|
|
14518
|
+
preserved,
|
|
14519
|
+
recompose: false
|
|
14520
|
+
};
|
|
14521
|
+
}
|
|
14522
|
+
/**
|
|
14523
|
+
* Report the frame's physical raster set to the owner after a real write.
|
|
14524
|
+
*
|
|
14525
|
+
* `emitted` rasters are the ones this frame materialized; a row the diff kept
|
|
14526
|
+
* (byte-identical to the previous frame) still shows its old pixels and pins
|
|
14527
|
+
* its occurrence. Rows above the viewport are never reported: their pixels are
|
|
14528
|
+
* native scrollback, not a frame reference.
|
|
14529
|
+
*/
|
|
14530
|
+
commitSixelFrame(frameLines, viewportTop, height) {
|
|
14531
|
+
const port = this.sixelScreen;
|
|
14532
|
+
if (port === void 0) return;
|
|
14533
|
+
const retained = [];
|
|
14534
|
+
for (const row of [...this.sixelFrameRasters.keys()].sort((left, right) => right - left)) {
|
|
14535
|
+
const raster = this.sixelFrameRasters.get(row);
|
|
14536
|
+
if (row < viewportTop || row >= viewportTop + height) continue;
|
|
14537
|
+
retained.push({
|
|
14538
|
+
...raster,
|
|
14539
|
+
emitted: true
|
|
14540
|
+
});
|
|
14541
|
+
}
|
|
14542
|
+
const last = Math.min(frameLines.length, viewportTop + height) - 1;
|
|
14543
|
+
for (let row = last; row >= viewportTop; row -= 1) {
|
|
14544
|
+
if (this.sixelFrameRasters.has(row)) continue;
|
|
14545
|
+
const token = this.previousRawLines[row];
|
|
14546
|
+
if (token === void 0 || port.candidate(token) === void 0) continue;
|
|
14547
|
+
const previous = this.previousLines[row];
|
|
14548
|
+
if (previous === void 0 || previous !== frameLines[row]) continue;
|
|
14549
|
+
const footprint = port.footprint(previous);
|
|
14550
|
+
if (footprint === void 0) continue;
|
|
14551
|
+
retained.push({
|
|
14552
|
+
line: token,
|
|
14553
|
+
dcs: previous,
|
|
14554
|
+
cropTopRows: 0,
|
|
14555
|
+
visibleRows: footprint.rows,
|
|
14556
|
+
emitted: false
|
|
14557
|
+
});
|
|
14558
|
+
}
|
|
14559
|
+
this.sixelFrameRasters = /* @__PURE__ */ new Map();
|
|
14560
|
+
port.framePainted(this, retained);
|
|
14561
|
+
}
|
|
14562
|
+
/**
|
|
14563
|
+
* The image rows one line DECLARES: a Kitty `r=`/registered placement, or a
|
|
14564
|
+
* trusted SIXEL footprint. `0` for a non-image line, so callers can decide
|
|
14565
|
+
* "is an image" and "how tall" from one number.
|
|
14566
|
+
*/
|
|
14567
|
+
declaredImageRows(line) {
|
|
14568
|
+
const candidate = this.sixelScreen?.candidate(line);
|
|
14569
|
+
if (candidate !== void 0) return candidate.layoutRows;
|
|
14570
|
+
const footprint = this.sixelFootprint(line);
|
|
14571
|
+
if (footprint !== void 0) return footprint.rows;
|
|
14572
|
+
return isImageLine(line) ? extractKittyImageRows(line) : 0;
|
|
14573
|
+
}
|
|
14574
|
+
/** The trusted SIXEL footprint height of one line, or 0 when it is not a
|
|
14575
|
+
* registered raster. */
|
|
14576
|
+
sixelBlockRows(line) {
|
|
14577
|
+
const candidate = this.sixelScreen?.candidate(line);
|
|
14578
|
+
if (candidate !== void 0) return candidate.layoutRows;
|
|
14579
|
+
return this.sixelFootprint(line)?.rows ?? 0;
|
|
14580
|
+
}
|
|
14581
|
+
/**
|
|
14582
|
+
* The rows an image block really occupies in `lines`, starting at `index`.
|
|
14583
|
+
*
|
|
14584
|
+
* `declared` is the per-line declared row count of the SAME frame (cached for
|
|
14585
|
+
* the previous frame), so a raster that is no longer registered still
|
|
14586
|
+
* reports its real old height. The scan stops at the first body row another
|
|
14587
|
+
* image owns or at the first row with cell content.
|
|
14588
|
+
*/
|
|
14589
|
+
getImageReservedRows(lines, declared, sixel, index, maxIndex = lines.length - 1) {
|
|
14590
|
+
const rows = declared[index] ?? 0;
|
|
13716
14591
|
if (rows <= 1) return 1;
|
|
13717
14592
|
const maxRows = Math.min(rows, maxIndex - index + 1, lines.length - index);
|
|
14593
|
+
if ((sixel[index] ?? 0) > 0) return maxRows;
|
|
13718
14594
|
let reservedRows = 1;
|
|
13719
14595
|
while (reservedRows < maxRows) {
|
|
13720
14596
|
const line = lines[index + reservedRows] ?? "";
|
|
13721
|
-
if (
|
|
14597
|
+
if ((declared[index + reservedRows] ?? 0) > 0 || visibleWidth(line) > 0) break;
|
|
13722
14598
|
reservedRows++;
|
|
13723
14599
|
}
|
|
13724
14600
|
return reservedRows;
|
|
13725
14601
|
}
|
|
13726
|
-
|
|
14602
|
+
expandChangedRangeForImages(firstChanged, lastChanged, newLines, newLineImageRows, newLineSixelRows) {
|
|
13727
14603
|
let expandedFirstChanged = firstChanged;
|
|
13728
14604
|
let expandedLastChanged = lastChanged;
|
|
13729
|
-
const expandForLines = (lines,
|
|
14605
|
+
const expandForLines = (lines, declared, sixel) => {
|
|
13730
14606
|
for (let i = 0; i < lines.length; i++) {
|
|
13731
|
-
if ((
|
|
13732
|
-
const blockEnd = i + this.
|
|
14607
|
+
if ((declared[i] ?? 0) === 0) continue;
|
|
14608
|
+
const blockEnd = i + this.getImageReservedRows(lines, declared, sixel, i) - 1;
|
|
13733
14609
|
if (i >= firstChanged || i <= lastChanged && blockEnd >= firstChanged) {
|
|
13734
14610
|
expandedFirstChanged = Math.min(expandedFirstChanged, i);
|
|
13735
14611
|
expandedLastChanged = Math.max(expandedLastChanged, blockEnd);
|
|
13736
14612
|
}
|
|
13737
14613
|
}
|
|
13738
14614
|
};
|
|
13739
|
-
expandForLines(this.previousLines, this.
|
|
13740
|
-
expandForLines(newLines,
|
|
14615
|
+
expandForLines(this.previousLines, this.previousLineImageRows, this.previousLineSixelRows);
|
|
14616
|
+
expandForLines(newLines, newLineImageRows, newLineSixelRows);
|
|
13741
14617
|
return {
|
|
13742
14618
|
firstChanged: expandedFirstChanged,
|
|
13743
14619
|
lastChanged: expandedLastChanged
|
|
@@ -13750,6 +14626,73 @@ var TuiMainScreen = class extends TuiBase {
|
|
|
13750
14626
|
for (let i = firstChanged; i <= maxLine; i++) for (const id of this.previousLineImageIds[i] ?? EMPTY_IMAGE_IDS) ids.add(id);
|
|
13751
14627
|
return this.deleteKittyImages(ids);
|
|
13752
14628
|
}
|
|
14629
|
+
/**
|
|
14630
|
+
* Drop the DCS of every trusted SIXEL block that a visible overlay paints
|
|
14631
|
+
* over (X073).
|
|
14632
|
+
*
|
|
14633
|
+
* One raster is one command covering its whole footprint, so "clear only the
|
|
14634
|
+
* row the overlay touched" is impossible: the pixels would either cover the
|
|
14635
|
+
* overlay text or leave a ghost. The block therefore yields this frame — the
|
|
14636
|
+
* component's own identity row above it still names the attachment — and the
|
|
14637
|
+
* next frame after the overlay closes restores it, because the anchor line
|
|
14638
|
+
* changes and the block re-enters the changed range.
|
|
14639
|
+
*/
|
|
14640
|
+
suppressOverlayCoveredSixelBlocks(lines) {
|
|
14641
|
+
for (let i = 0; i < lines.length; i++) {
|
|
14642
|
+
const rows = this.sixelBlockRows(lines[i] ?? "");
|
|
14643
|
+
if (rows === 0) continue;
|
|
14644
|
+
if (!this.linesCoveredByOverlay(i, i + rows - 1, lines.length)) continue;
|
|
14645
|
+
lines[i] = "";
|
|
14646
|
+
}
|
|
14647
|
+
}
|
|
14648
|
+
/**
|
|
14649
|
+
* Write every deferred trusted SIXEL anchor at its own absolute row, then
|
|
14650
|
+
* leave the cursor on `finalCursorRow`.
|
|
14651
|
+
*
|
|
14652
|
+
* `CSI 999A` (cursor up, clamped at the top margin) is the one deterministic
|
|
14653
|
+
* origin the main screen has: it cannot scroll and it lands on the physical
|
|
14654
|
+
* top row, which this screen's bookkeeping maps to buffer row `viewportTop`.
|
|
14655
|
+
* From there a bounded `CSI nB` reaches any visible row exactly. Each DCS is
|
|
14656
|
+
* wrapped in DECSC/DECRC because its post-command cursor position is
|
|
14657
|
+
* terminal-defined, never assumed to be zero.
|
|
14658
|
+
*
|
|
14659
|
+
* Returns false when an anchor is not inside the painted viewport; the caller
|
|
14660
|
+
* then falls back to a full redraw instead of painting outside it.
|
|
14661
|
+
*/
|
|
14662
|
+
writeDeferredSixelAnchors(output, anchors, lines, viewportTop, height, finalCursorRow) {
|
|
14663
|
+
for (const anchor of anchors) {
|
|
14664
|
+
const screenRow = anchor - viewportTop;
|
|
14665
|
+
if (screenRow < 0 || screenRow >= height) return false;
|
|
14666
|
+
output.append("\x1B[999A");
|
|
14667
|
+
if (screenRow > 0) output.append(`\x1b[${screenRow}B`);
|
|
14668
|
+
output.append("\x1B7");
|
|
14669
|
+
output.append(lines[anchor] ?? "");
|
|
14670
|
+
output.append("\x1B8");
|
|
14671
|
+
}
|
|
14672
|
+
const endScreenRow = Math.max(0, Math.min(height - 1, finalCursorRow - viewportTop));
|
|
14673
|
+
output.append("\x1B[999A");
|
|
14674
|
+
if (endScreenRow > 0) output.append(`\x1b[${endScreenRow}B`);
|
|
14675
|
+
output.append("\r");
|
|
14676
|
+
return true;
|
|
14677
|
+
}
|
|
14678
|
+
/**
|
|
14679
|
+
* Write one image anchor at the cursor's current row.
|
|
14680
|
+
*
|
|
14681
|
+
* A Kitty placement leaves the cursor where it was; a SIXEL DCS does not, and
|
|
14682
|
+
* its post-command position is terminal-defined. The anchor is therefore
|
|
14683
|
+
* SAVED before the command and RESTORED after it (DECSC/DECRC), and the
|
|
14684
|
+
* caller then moves the cursor explicitly — "the DCS left it at 0" is never
|
|
14685
|
+
* assumed. (dsh-pi-tui divergence X073.)
|
|
14686
|
+
*/
|
|
14687
|
+
appendImageCommand(output, line, sixel) {
|
|
14688
|
+
if (!sixel) {
|
|
14689
|
+
output.append(line);
|
|
14690
|
+
return;
|
|
14691
|
+
}
|
|
14692
|
+
output.append("\x1B7");
|
|
14693
|
+
output.append(line);
|
|
14694
|
+
output.append("\x1B8");
|
|
14695
|
+
}
|
|
13753
14696
|
doRender() {
|
|
13754
14697
|
if (this.stopped) return;
|
|
13755
14698
|
const width = this.terminal.columns;
|
|
@@ -13764,29 +14707,46 @@ var TuiMainScreen = class extends TuiBase {
|
|
|
13764
14707
|
const currentScreenRow = hardwareCursorRow - prevViewportTop;
|
|
13765
14708
|
return targetRow - viewportTop - currentScreenRow;
|
|
13766
14709
|
};
|
|
13767
|
-
let
|
|
13768
|
-
if (this.hasOverlayEntries)
|
|
14710
|
+
let rawLines = this.render(width);
|
|
14711
|
+
if (this.hasOverlayEntries) {
|
|
14712
|
+
rawLines = this.compositeOverlays(rawLines, width, height);
|
|
14713
|
+
this.suppressOverlayCoveredSixelBlocks(rawLines);
|
|
14714
|
+
}
|
|
14715
|
+
const frameViewportTop = Math.max(0, rawLines.length - height);
|
|
14716
|
+
let projection = this.projectSixelCandidates(rawLines, height, frameViewportTop, width, true);
|
|
14717
|
+
if (projection.recompose) projection = this.projectSixelCandidates(rawLines, height, frameViewportTop, width, false);
|
|
14718
|
+
this.sixelFrameRasters = projection.rasters;
|
|
14719
|
+
const preservedRows = projection.preserved;
|
|
14720
|
+
let newLines = projection.lines;
|
|
13769
14721
|
const cursorPos = this.extractCursorPosition(newLines, height);
|
|
13770
|
-
const rawLines = newLines;
|
|
13771
14722
|
const reuseProcessed = !widthChanged && this.previousRawLines.length > 0;
|
|
13772
|
-
const processedLines = new Array(
|
|
13773
|
-
const lineImageIds = new Array(
|
|
13774
|
-
|
|
13775
|
-
|
|
13776
|
-
|
|
14723
|
+
const processedLines = new Array(newLines.length);
|
|
14724
|
+
const lineImageIds = new Array(newLines.length);
|
|
14725
|
+
const lineImageRows = new Array(newLines.length);
|
|
14726
|
+
const lineSixelRows = new Array(newLines.length);
|
|
14727
|
+
for (let i = 0; i < newLines.length; i++) {
|
|
14728
|
+
const marker = rawLines[i] ?? "";
|
|
14729
|
+
const isCandidate = this.sixelScreen?.candidate(marker) !== void 0;
|
|
14730
|
+
if (preservedRows.has(i) || !isCandidate && reuseProcessed && marker === this.previousRawLines[i]) {
|
|
13777
14731
|
processedLines[i] = this.previousLines[i];
|
|
13778
14732
|
lineImageIds[i] = this.previousLineImageIds[i];
|
|
14733
|
+
lineImageRows[i] = this.previousLineImageRows[i];
|
|
14734
|
+
lineSixelRows[i] = this.previousLineSixelRows[i];
|
|
13779
14735
|
continue;
|
|
13780
14736
|
}
|
|
13781
|
-
let line =
|
|
14737
|
+
let line = newLines[i];
|
|
13782
14738
|
let imageIds = EMPTY_IMAGE_IDS;
|
|
13783
|
-
|
|
14739
|
+
const sixelRows = this.sixelBlockRows(line);
|
|
14740
|
+
const declaredImageRows = this.declaredImageRows(line);
|
|
14741
|
+
if (declaredImageRows > 0) imageIds = extractKittyImageIds(line);
|
|
13784
14742
|
else {
|
|
13785
14743
|
if ((asciiVisibleWidthEarlyExit(line, width) ?? visibleWidth(line)) > width) line = sliceByColumn(line, 0, width, true);
|
|
13786
14744
|
line = normalizeTerminalOutput(line) + SEGMENT_RESET;
|
|
13787
14745
|
}
|
|
13788
14746
|
processedLines[i] = line;
|
|
13789
14747
|
lineImageIds[i] = imageIds;
|
|
14748
|
+
lineImageRows[i] = declaredImageRows;
|
|
14749
|
+
lineSixelRows[i] = sixelRows;
|
|
13790
14750
|
}
|
|
13791
14751
|
newLines = processedLines;
|
|
13792
14752
|
const fullRender = (clear) => {
|
|
@@ -13800,19 +14760,21 @@ var TuiMainScreen = class extends TuiBase {
|
|
|
13800
14760
|
for (let i = 0; i < newLines.length; i++) {
|
|
13801
14761
|
if (i > 0) output.append("\r\n");
|
|
13802
14762
|
const line = newLines[i];
|
|
13803
|
-
const
|
|
14763
|
+
const isSixel = (lineSixelRows[i] ?? 0) > 0;
|
|
14764
|
+
const imageReservedRows = isSixel || isImageLine(line) ? this.getImageReservedRows(newLines, lineImageRows, lineSixelRows, i) : 1;
|
|
13804
14765
|
if (imageReservedRows > 1 && imageReservedRows <= height) {
|
|
13805
14766
|
for (let row = 1; row < imageReservedRows; row++) output.append("\r\n");
|
|
13806
14767
|
output.append(`\x1b[${imageReservedRows - 1}A`);
|
|
13807
|
-
|
|
14768
|
+
this.appendImageCommand(output, line, isSixel);
|
|
13808
14769
|
output.append(`\x1b[${imageReservedRows - 1}B`);
|
|
13809
14770
|
i += imageReservedRows - 1;
|
|
13810
14771
|
continue;
|
|
13811
14772
|
}
|
|
13812
|
-
|
|
14773
|
+
this.appendImageCommand(output, line, isSixel);
|
|
13813
14774
|
}
|
|
13814
14775
|
output.append("\x1B[?2026l");
|
|
13815
14776
|
output.flush();
|
|
14777
|
+
this.commitSixelFrame(newLines, frameViewportTop, height);
|
|
13816
14778
|
this.cursorRow = Math.max(0, newLines.length - 1);
|
|
13817
14779
|
this.hardwareCursorRow = this.cursorRow;
|
|
13818
14780
|
if (clear) this.maxLinesRendered = newLines.length;
|
|
@@ -13823,6 +14785,8 @@ var TuiMainScreen = class extends TuiBase {
|
|
|
13823
14785
|
this.previousLines = newLines;
|
|
13824
14786
|
this.previousRawLines = rawLines;
|
|
13825
14787
|
this.previousLineImageIds = lineImageIds;
|
|
14788
|
+
this.previousLineImageRows = lineImageRows;
|
|
14789
|
+
this.previousLineSixelRows = lineSixelRows;
|
|
13826
14790
|
this.previousKittyImageIds = this.unionKittyImageIds(lineImageIds);
|
|
13827
14791
|
this.previousWidth = width;
|
|
13828
14792
|
this.previousHeight = height;
|
|
@@ -13868,7 +14832,7 @@ var TuiMainScreen = class extends TuiBase {
|
|
|
13868
14832
|
lastChanged = newLines.length - 1;
|
|
13869
14833
|
}
|
|
13870
14834
|
if (firstChanged !== -1) {
|
|
13871
|
-
const expandedRange = this.
|
|
14835
|
+
const expandedRange = this.expandChangedRangeForImages(firstChanged, lastChanged, newLines, lineImageRows, lineSixelRows);
|
|
13872
14836
|
firstChanged = expandedRange.firstChanged;
|
|
13873
14837
|
lastChanged = expandedRange.lastChanged;
|
|
13874
14838
|
}
|
|
@@ -13879,6 +14843,8 @@ var TuiMainScreen = class extends TuiBase {
|
|
|
13879
14843
|
this.previousHeight = height;
|
|
13880
14844
|
this.previousRawLines = rawLines;
|
|
13881
14845
|
this.previousLineImageIds = lineImageIds;
|
|
14846
|
+
this.previousLineImageRows = lineImageRows;
|
|
14847
|
+
this.previousLineSixelRows = lineSixelRows;
|
|
13882
14848
|
return;
|
|
13883
14849
|
}
|
|
13884
14850
|
if (firstChanged >= newLines.length) {
|
|
@@ -13912,6 +14878,7 @@ var TuiMainScreen = class extends TuiBase {
|
|
|
13912
14878
|
if (moveBack > 0) output.append(`\x1b[${moveBack}A`);
|
|
13913
14879
|
output.append("\x1B[?2026l");
|
|
13914
14880
|
output.flush();
|
|
14881
|
+
this.commitSixelFrame(newLines, frameViewportTop, height);
|
|
13915
14882
|
this.cursorRow = targetRow;
|
|
13916
14883
|
this.hardwareCursorRow = targetRow;
|
|
13917
14884
|
}
|
|
@@ -13919,6 +14886,8 @@ var TuiMainScreen = class extends TuiBase {
|
|
|
13919
14886
|
this.previousLines = newLines;
|
|
13920
14887
|
this.previousRawLines = rawLines;
|
|
13921
14888
|
this.previousLineImageIds = lineImageIds;
|
|
14889
|
+
this.previousLineImageRows = lineImageRows;
|
|
14890
|
+
this.previousLineSixelRows = lineSixelRows;
|
|
13922
14891
|
this.previousKittyImageIds = this.unionKittyImageIds(lineImageIds);
|
|
13923
14892
|
this.previousWidth = width;
|
|
13924
14893
|
this.previousHeight = height;
|
|
@@ -13950,22 +14919,25 @@ var TuiMainScreen = class extends TuiBase {
|
|
|
13950
14919
|
else if (lineDiff < 0) output.append(`\x1b[${-lineDiff}A`);
|
|
13951
14920
|
output.append(appendStart ? "\r\n" : "\r");
|
|
13952
14921
|
const renderEnd = Math.min(lastChanged, newLines.length - 1);
|
|
14922
|
+
const deferredSixelAnchors = [];
|
|
13953
14923
|
for (let i = firstChanged; i <= renderEnd; i++) {
|
|
13954
14924
|
if (i > firstChanged) output.append("\r\n");
|
|
13955
14925
|
const line = newLines[i];
|
|
13956
|
-
const
|
|
13957
|
-
const
|
|
14926
|
+
const isSixel = (lineSixelRows[i] ?? 0) > 0;
|
|
14927
|
+
const isImage = isSixel || isImageLine(line);
|
|
14928
|
+
const imageReservedRows = isImage ? this.getImageReservedRows(newLines, lineImageRows, lineSixelRows, i, renderEnd) : 1;
|
|
13958
14929
|
if (imageReservedRows > 1) {
|
|
13959
14930
|
const imageStartScreenRow = i - viewportTop;
|
|
13960
14931
|
if (imageStartScreenRow < 0 || imageStartScreenRow + imageReservedRows > height) {
|
|
13961
|
-
logRedraw(`
|
|
14932
|
+
logRedraw(`image pre-clear would scroll (${imageStartScreenRow} + ${imageReservedRows} > ${height})`);
|
|
13962
14933
|
fullRender(true);
|
|
13963
14934
|
return;
|
|
13964
14935
|
}
|
|
13965
14936
|
output.append("\x1B[2K");
|
|
13966
14937
|
for (let row = 1; row < imageReservedRows; row++) output.append("\r\n\x1B[2K");
|
|
13967
14938
|
output.append(`\x1b[${imageReservedRows - 1}A`);
|
|
13968
|
-
|
|
14939
|
+
if (isSixel) deferredSixelAnchors.push(i);
|
|
14940
|
+
else output.append(line);
|
|
13969
14941
|
output.append(`\x1b[${imageReservedRows - 1}B`);
|
|
13970
14942
|
i += imageReservedRows - 1;
|
|
13971
14943
|
continue;
|
|
@@ -13995,7 +14967,8 @@ var TuiMainScreen = class extends TuiBase {
|
|
|
13995
14967
|
].join("\n");
|
|
13996
14968
|
throw new Error(errorMsg);
|
|
13997
14969
|
}
|
|
13998
|
-
|
|
14970
|
+
if (isSixel) deferredSixelAnchors.push(i);
|
|
14971
|
+
else output.append(line);
|
|
13999
14972
|
}
|
|
14000
14973
|
let finalCursorRow = renderEnd;
|
|
14001
14974
|
if (this.previousLines.length > newLines.length) {
|
|
@@ -14008,6 +14981,13 @@ var TuiMainScreen = class extends TuiBase {
|
|
|
14008
14981
|
for (let i = newLines.length; i < this.previousLines.length; i++) output.append("\r\n\x1B[2K");
|
|
14009
14982
|
output.append(`\x1b[${extraLines}A`);
|
|
14010
14983
|
}
|
|
14984
|
+
if (deferredSixelAnchors.length > 0) {
|
|
14985
|
+
if (!this.writeDeferredSixelAnchors(output, deferredSixelAnchors, newLines, viewportTop, height, finalCursorRow)) {
|
|
14986
|
+
logRedraw("deferred SIXEL anchor is not inside the painted viewport");
|
|
14987
|
+
fullRender(true);
|
|
14988
|
+
return;
|
|
14989
|
+
}
|
|
14990
|
+
}
|
|
14011
14991
|
output.append("\x1B[?2026l");
|
|
14012
14992
|
if (process.env.PI_TUI_DEBUG === "1") {
|
|
14013
14993
|
const debugDir = "/tmp/tui";
|
|
@@ -14038,6 +15018,7 @@ var TuiMainScreen = class extends TuiBase {
|
|
|
14038
15018
|
fs.writeFileSync(debugPath, debugData);
|
|
14039
15019
|
}
|
|
14040
15020
|
output.flush();
|
|
15021
|
+
this.commitSixelFrame(newLines, frameViewportTop, height);
|
|
14041
15022
|
this.cursorRow = Math.max(0, newLines.length - 1);
|
|
14042
15023
|
this.hardwareCursorRow = finalCursorRow;
|
|
14043
15024
|
this.maxLinesRendered = Math.max(this.maxLinesRendered, newLines.length);
|
|
@@ -14046,6 +15027,8 @@ var TuiMainScreen = class extends TuiBase {
|
|
|
14046
15027
|
this.previousLines = newLines;
|
|
14047
15028
|
this.previousRawLines = rawLines;
|
|
14048
15029
|
this.previousLineImageIds = lineImageIds;
|
|
15030
|
+
this.previousLineImageRows = lineImageRows;
|
|
15031
|
+
this.previousLineSixelRows = lineSixelRows;
|
|
14049
15032
|
this.previousKittyImageIds = this.unionKittyImageIds(lineImageIds);
|
|
14050
15033
|
this.previousWidth = width;
|
|
14051
15034
|
this.previousHeight = height;
|
|
@@ -14532,6 +15515,30 @@ const APP_KEYBINDINGS = {
|
|
|
14532
15515
|
scope: "global",
|
|
14533
15516
|
configurable: true
|
|
14534
15517
|
},
|
|
15518
|
+
"app.visual.selectNext": {
|
|
15519
|
+
id: "app.visual.selectNext",
|
|
15520
|
+
defaultKeys: ["alt+v"],
|
|
15521
|
+
description: "Select the next published visual",
|
|
15522
|
+
category: "Transcript",
|
|
15523
|
+
scope: "global",
|
|
15524
|
+
configurable: true
|
|
15525
|
+
},
|
|
15526
|
+
"app.visual.copySelected": {
|
|
15527
|
+
id: "app.visual.copySelected",
|
|
15528
|
+
defaultKeys: ["alt+c"],
|
|
15529
|
+
description: "Copy the selected published visual",
|
|
15530
|
+
category: "Transcript",
|
|
15531
|
+
scope: "global",
|
|
15532
|
+
configurable: true
|
|
15533
|
+
},
|
|
15534
|
+
"app.visual.openSelected": {
|
|
15535
|
+
id: "app.visual.openSelected",
|
|
15536
|
+
defaultKeys: ["alt+o"],
|
|
15537
|
+
description: "Open the selected SVG visual in the viewer",
|
|
15538
|
+
category: "Transcript",
|
|
15539
|
+
scope: "global",
|
|
15540
|
+
configurable: true
|
|
15541
|
+
},
|
|
14535
15542
|
"app.editor.external": {
|
|
14536
15543
|
id: "app.editor.external",
|
|
14537
15544
|
defaultKeys: ["ctrl+g"],
|
|
@@ -14861,6 +15868,9 @@ const VIEWER_BLOCKED_PARENT_ACTIONS = /* @__PURE__ */ new Set([
|
|
|
14861
15868
|
"app.input.dequeue",
|
|
14862
15869
|
"app.permission.cycle",
|
|
14863
15870
|
"app.transcript.search",
|
|
15871
|
+
"app.visual.selectNext",
|
|
15872
|
+
"app.visual.copySelected",
|
|
15873
|
+
"app.visual.openSelected",
|
|
14864
15874
|
"app.exit.request",
|
|
14865
15875
|
"app.editor.external",
|
|
14866
15876
|
"app.todo.toggle",
|
|
@@ -15349,13 +16359,13 @@ var ExtensionLedger = class {
|
|
|
15349
16359
|
disposeAll() {
|
|
15350
16360
|
for (const registration of [...this.registrations.values()]) if (!registration.disposed) this.disposeRegistration(registration);
|
|
15351
16361
|
}
|
|
15352
|
-
/** The health snapshot (M11
|
|
16362
|
+
/** The health snapshot (M11 Plugin Manager diagnostics; recorded since M1). */
|
|
15353
16363
|
healthSnapshot() {
|
|
15354
16364
|
return this.health.snapshot();
|
|
15355
16365
|
}
|
|
15356
16366
|
/** Track a NON-ledger contribution's health slot (P1-08: renderers and
|
|
15357
16367
|
* editors live in their own registries, not the ledger — their health
|
|
15358
|
-
* must still be observable
|
|
16368
|
+
* must still be observable in Plugin Manager diagnostics). Idempotent per (slot, owner, id). */
|
|
15359
16369
|
trackHealth(slot, id, owner) {
|
|
15360
16370
|
this.health.track(slot, id, owner);
|
|
15361
16371
|
}
|
|
@@ -15551,7 +16561,11 @@ const SESSIONLESS_COMMANDS = /* @__PURE__ */ new Set([
|
|
|
15551
16561
|
"keybindings",
|
|
15552
16562
|
"plugins",
|
|
15553
16563
|
"quit",
|
|
15554
|
-
"statusline"
|
|
16564
|
+
"statusline",
|
|
16565
|
+
"status",
|
|
16566
|
+
"view-image",
|
|
16567
|
+
"deliverables",
|
|
16568
|
+
"reload-client"
|
|
15555
16569
|
]);
|
|
15556
16570
|
/**
|
|
15557
16571
|
* The LOCAL-execute command set (PR5 v2 §1C-6 narrows its semantic role):
|
|
@@ -15610,7 +16624,10 @@ const LOCAL_COMMANDS = /* @__PURE__ */ new Set([
|
|
|
15610
16624
|
"title",
|
|
15611
16625
|
"transcript",
|
|
15612
16626
|
"yolo",
|
|
15613
|
-
"
|
|
16627
|
+
"view-image",
|
|
16628
|
+
"deliverables",
|
|
16629
|
+
"statusline",
|
|
16630
|
+
"reload-client"
|
|
15614
16631
|
]);
|
|
15615
16632
|
/**
|
|
15616
16633
|
* The STATIC host-owned command catalog (P1-04): the ownership sets
|
|
@@ -15790,6 +16807,47 @@ function shouldConsumeAdvertisedMiss(execution, wasAdvertised) {
|
|
|
15790
16807
|
function isPlainExitPrompt(text) {
|
|
15791
16808
|
return text.trim() === "exit";
|
|
15792
16809
|
}
|
|
16810
|
+
/**
|
|
16811
|
+
* The TUI-local commands whose OWN handler performs no persistent Host write
|
|
16812
|
+
* (they read/browse/stage locally, open a read-only panel, or are the reload
|
|
16813
|
+
* command itself). Their execution never holds the accepted-command reload
|
|
16814
|
+
* lifetime — a `/reload` catalog/settings refresh or `/exit` must not block a
|
|
16815
|
+
* manual Client reload.
|
|
16816
|
+
*
|
|
16817
|
+
* Every OTHER local command is treated as a potential persisted writer
|
|
16818
|
+
* (fail-safe): its accepted execution — including the asynchronous preparation
|
|
16819
|
+
* that precedes a configuration write — keeps the Client reload gate closed
|
|
16820
|
+
* until the handler settles. A new write-capable local command is therefore
|
|
16821
|
+
* protected by default instead of requiring an addition to this set.
|
|
16822
|
+
*/
|
|
16823
|
+
const READ_ONLY_LOCAL_COMMANDS = /* @__PURE__ */ new Set([
|
|
16824
|
+
"reload-client",
|
|
16825
|
+
"reload",
|
|
16826
|
+
"exit",
|
|
16827
|
+
"quit",
|
|
16828
|
+
"help",
|
|
16829
|
+
"keybindings",
|
|
16830
|
+
"copy",
|
|
16831
|
+
"attach",
|
|
16832
|
+
"image",
|
|
16833
|
+
"export",
|
|
16834
|
+
"transcript",
|
|
16835
|
+
"deliverables",
|
|
16836
|
+
"view-image",
|
|
16837
|
+
"sessions",
|
|
16838
|
+
"resume",
|
|
16839
|
+
"search",
|
|
16840
|
+
"tasks"
|
|
16841
|
+
]);
|
|
16842
|
+
/**
|
|
16843
|
+
* Whether one TUI-local command may perform a persistent Host write during its
|
|
16844
|
+
* own handler execution. Fail-safe: anything not explicitly read-only is
|
|
16845
|
+
* treated as a possible writer.
|
|
16846
|
+
* @param name - the local command name (bare token).
|
|
16847
|
+
*/
|
|
16848
|
+
function localCommandMayWrite(name) {
|
|
16849
|
+
return !READ_ONLY_LOCAL_COMMANDS.has(name);
|
|
16850
|
+
}
|
|
15793
16851
|
//#endregion
|
|
15794
16852
|
//#region src/extension/internal/batcher.ts
|
|
15795
16853
|
/** Coalescing invalidate dispatcher. `flush()` is idempotent per tick. */
|
|
@@ -15908,12 +16966,12 @@ var AdvancedInputRegistry = class {
|
|
|
15908
16966
|
disposeAll() {
|
|
15909
16967
|
for (const record of [...this.records.values()]) if (!record.disposed) this.disposeRecord(record);
|
|
15910
16968
|
}
|
|
15911
|
-
/** Whether any capture is live (
|
|
16969
|
+
/** Whether any capture is live (Plugin Manager diagnostics). */
|
|
15912
16970
|
hasAny() {
|
|
15913
16971
|
for (const record of this.records.values()) if (!record.disposed) return true;
|
|
15914
16972
|
return false;
|
|
15915
16973
|
}
|
|
15916
|
-
/** An immutable snapshot (
|
|
16974
|
+
/** An immutable snapshot (Plugin Manager diagnostics). */
|
|
15917
16975
|
snapshot() {
|
|
15918
16976
|
return {
|
|
15919
16977
|
captures: [...this.records.values()].filter((record) => !record.disposed).sort((left, right) => left.priority - right.priority || left.id.localeCompare(right.id)).map((record) => ({
|
|
@@ -16055,7 +17113,7 @@ var UnstableInputRegistry = class {
|
|
|
16055
17113
|
disposeAll() {
|
|
16056
17114
|
for (const record of [...this.records.values()]) if (!record.disposed) this.disposeRecord(record);
|
|
16057
17115
|
}
|
|
16058
|
-
/** Whether any capture is live (
|
|
17116
|
+
/** Whether any capture is live (Plugin Manager diagnostics). */
|
|
16059
17117
|
hasAny() {
|
|
16060
17118
|
for (const record of this.records.values()) if (!record.disposed) return true;
|
|
16061
17119
|
return false;
|
|
@@ -16067,7 +17125,7 @@ var UnstableInputRegistry = class {
|
|
|
16067
17125
|
revisionOf() {
|
|
16068
17126
|
return this.revision;
|
|
16069
17127
|
}
|
|
16070
|
-
/** An immutable snapshot (
|
|
17128
|
+
/** An immutable snapshot (Plugin Manager diagnostics). */
|
|
16071
17129
|
snapshot() {
|
|
16072
17130
|
return {
|
|
16073
17131
|
captures: [...this.records.values()].filter((record) => !record.disposed).sort((left, right) => left.priority - right.priority || left.id.localeCompare(right.id)).map((record) => ({
|
|
@@ -16180,7 +17238,7 @@ var CommandBridge = class {
|
|
|
16180
17238
|
if (this.contributions.has(spec.id)) throw new Error(`duplicate command contribution id "${spec.id}" (owner "${this.contributions.get(spec.id)?.owner}")`);
|
|
16181
17239
|
if (spec.name === "") throw new Error("command contribution name must not be empty");
|
|
16182
17240
|
if (typeof spec.handler !== "function") throw new Error(`command contribution "${spec.name}" must declare its handler (the client behavior)`);
|
|
16183
|
-
if ("execution" in spec) throw new Error(`command contribution "${spec.name}" declares the removed 'execution' ownership metadata — a contribution is a client-owned command now; drop 'execution' and declare 'handler' (see docs/
|
|
17241
|
+
if ("execution" in spec) throw new Error(`command contribution "${spec.name}" declares the removed 'execution' ownership metadata — a contribution is a client-owned command now; drop 'execution' and declare 'handler' (see docs/extensions/stable.md)`);
|
|
16184
17242
|
for (const hostName of this.staticCatalog) {
|
|
16185
17243
|
if (hostName === spec.name) return {
|
|
16186
17244
|
kind: "conflict",
|
|
@@ -16463,7 +17521,7 @@ var ThemeRegistry = class ThemeRegistry {
|
|
|
16463
17521
|
selectableValues() {
|
|
16464
17522
|
return [...this.records.values()].filter((record) => !record.disposed).map((record) => ThemeRegistry.selectableValueOf(record)).sort((left, right) => left.localeCompare(right));
|
|
16465
17523
|
}
|
|
16466
|
-
/** The display NAMES (sorted — diagnostics
|
|
17524
|
+
/** The display NAMES (sorted — diagnostics counts; never a
|
|
16467
17525
|
* selection identity). */
|
|
16468
17526
|
names() {
|
|
16469
17527
|
return [...this.records.values()].filter((record) => !record.disposed).map((record) => record.name).sort((left, right) => left.localeCompare(right));
|
|
@@ -16496,12 +17554,12 @@ var ThemeRegistry = class ThemeRegistry {
|
|
|
16496
17554
|
const record = this.byName(name);
|
|
16497
17555
|
return record === void 0 ? void 0 : ThemeRegistry.selectableValueOf(record);
|
|
16498
17556
|
}
|
|
16499
|
-
/** Whether any theme is live (
|
|
17557
|
+
/** Whether any theme is live (Plugin Manager diagnostics). */
|
|
16500
17558
|
hasAny() {
|
|
16501
17559
|
for (const record of this.records.values()) if (!record.disposed) return true;
|
|
16502
17560
|
return false;
|
|
16503
17561
|
}
|
|
16504
|
-
/** An immutable snapshot (
|
|
17562
|
+
/** An immutable snapshot (Plugin Manager diagnostics). */
|
|
16505
17563
|
snapshot() {
|
|
16506
17564
|
return {
|
|
16507
17565
|
themes: [...this.records.values()].filter((record) => !record.disposed).sort((left, right) => left.name.localeCompare(right.name)).map((record) => ({
|
|
@@ -16621,12 +17679,12 @@ var AutocompleteRegistry = class {
|
|
|
16621
17679
|
if (this.activeController === controller) this.activeController = void 0;
|
|
16622
17680
|
}
|
|
16623
17681
|
}
|
|
16624
|
-
/** Whether any provider is live (
|
|
17682
|
+
/** Whether any provider is live (Plugin Manager diagnostics). */
|
|
16625
17683
|
hasAny() {
|
|
16626
17684
|
for (const record of this.records.values()) if (!record.disposed) return true;
|
|
16627
17685
|
return false;
|
|
16628
17686
|
}
|
|
16629
|
-
/** An immutable snapshot (
|
|
17687
|
+
/** An immutable snapshot (Plugin Manager diagnostics). */
|
|
16630
17688
|
snapshot() {
|
|
16631
17689
|
return {
|
|
16632
17690
|
providers: [...this.records.values()].filter((record) => !record.disposed).sort((left, right) => left.id.localeCompare(right.id)).map((record) => ({
|
|
@@ -16649,6 +17707,8 @@ var AutocompleteRegistry = class {
|
|
|
16649
17707
|
var SettingsRegistry = class {
|
|
16650
17708
|
records = /* @__PURE__ */ new Map();
|
|
16651
17709
|
revision = 0;
|
|
17710
|
+
/** The per-registration token source (see {@link SettingRecord.registrationToken}). */
|
|
17711
|
+
nextRegistrationToken = 0;
|
|
16652
17712
|
onInvalidate;
|
|
16653
17713
|
constructor(onInvalidate = () => {}) {
|
|
16654
17714
|
this.onInvalidate = onInvalidate;
|
|
@@ -16662,24 +17722,30 @@ var SettingsRegistry = class {
|
|
|
16662
17722
|
register(contribution, owner) {
|
|
16663
17723
|
if (this.records.has(contribution.id)) throw new Error(`duplicate settings row id "${contribution.id}"`);
|
|
16664
17724
|
if (contribution.label === "") throw new Error("settings row label must not be empty");
|
|
16665
|
-
this.
|
|
17725
|
+
this.nextRegistrationToken += 1;
|
|
17726
|
+
const record = {
|
|
16666
17727
|
id: contribution.id,
|
|
16667
17728
|
label: contribution.label,
|
|
16668
17729
|
description: contribution.description,
|
|
16669
17730
|
values: contribution.values ?? [],
|
|
16670
17731
|
order: contribution.order ?? 0,
|
|
16671
17732
|
owner,
|
|
17733
|
+
registrationToken: this.nextRegistrationToken,
|
|
16672
17734
|
currentValue: contribution.currentValue,
|
|
16673
17735
|
applyEpoch: 0,
|
|
16674
17736
|
onChange: contribution.onChange,
|
|
16675
17737
|
disposed: false
|
|
16676
|
-
}
|
|
17738
|
+
};
|
|
17739
|
+
this.records.set(contribution.id, record);
|
|
16677
17740
|
this.revision += 1;
|
|
16678
17741
|
this.onInvalidate();
|
|
16679
17742
|
return {
|
|
16680
17743
|
id: contribution.id,
|
|
16681
|
-
setValue: (value) =>
|
|
16682
|
-
|
|
17744
|
+
setValue: (value) => {
|
|
17745
|
+
if (this.records.get(contribution.id) !== record) return;
|
|
17746
|
+
this.setValue(contribution.id, value);
|
|
17747
|
+
},
|
|
17748
|
+
dispose: () => this.disposeRecord(record)
|
|
16683
17749
|
};
|
|
16684
17750
|
}
|
|
16685
17751
|
/** Update one row's current value (live panel refresh). */
|
|
@@ -16693,15 +17759,21 @@ var SettingsRegistry = class {
|
|
|
16693
17759
|
/** Remove one row by id (idempotent). */
|
|
16694
17760
|
dispose(id) {
|
|
16695
17761
|
const record = this.records.get(id);
|
|
16696
|
-
if (record
|
|
16697
|
-
record.disposed = true;
|
|
16698
|
-
this.records.delete(id);
|
|
16699
|
-
this.revision += 1;
|
|
16700
|
-
this.onInvalidate();
|
|
17762
|
+
if (record !== void 0) this.disposeRecord(record);
|
|
16701
17763
|
}
|
|
16702
17764
|
/** Dispose every row owned by one fiber (owner unload). */
|
|
16703
17765
|
disposeOwner(owner) {
|
|
16704
|
-
for (const
|
|
17766
|
+
for (const record of [...this.records.values()]) if (record.owner === owner) this.disposeRecord(record);
|
|
17767
|
+
}
|
|
17768
|
+
/** Remove ONE record by its captured identity: a disposed record or an id
|
|
17769
|
+
* now owned by a NEWER registration is inert (a late fiber teardown must
|
|
17770
|
+
* never unload the replacement). */
|
|
17771
|
+
disposeRecord(record) {
|
|
17772
|
+
if (record.disposed || this.records.get(record.id) !== record) return;
|
|
17773
|
+
record.disposed = true;
|
|
17774
|
+
this.records.delete(record.id);
|
|
17775
|
+
this.revision += 1;
|
|
17776
|
+
this.onInvalidate();
|
|
16705
17777
|
}
|
|
16706
17778
|
/** The owning fiber of one setting id (the health bridge resolves
|
|
16707
17779
|
* owners here — the runner never passes owners around). */
|
|
@@ -16716,8 +17788,18 @@ var SettingsRegistry = class {
|
|
|
16716
17788
|
* plugin REJECTION (a real failure: record health, revert, notify) from
|
|
16717
17789
|
* a STALE or GONE result (a newer apply superseded this one, or the row
|
|
16718
17790
|
* was disposed mid-apply: the plugin never refused — recording a
|
|
16719
|
-
* failure would be a false alarm; the review's P2).
|
|
16720
|
-
|
|
17791
|
+
* failure would be a false alarm; the review's P2).
|
|
17792
|
+
*
|
|
17793
|
+
* C2-R6: `expectedRegistrationToken` (used ONLY by this concrete registry's
|
|
17794
|
+
* protected settings consumer) fences a confirmation to the registration it
|
|
17795
|
+
* was made for. A mismatched token is `gone` BEFORE any callback runs, so a
|
|
17796
|
+
* same-id replacement never receives an old choice; the original two-argument
|
|
17797
|
+
* call sites keep their semantics unchanged. */
|
|
17798
|
+
applyDetailed(id, value, expectedRegistrationToken) {
|
|
17799
|
+
if (expectedRegistrationToken !== void 0) {
|
|
17800
|
+
const record = this.records.get(id);
|
|
17801
|
+
if (record === void 0 || record.disposed || record.registrationToken !== expectedRegistrationToken) return Promise.resolve("gone");
|
|
17802
|
+
}
|
|
16721
17803
|
return this.applyInternal(id, value);
|
|
16722
17804
|
}
|
|
16723
17805
|
/** Apply a value change to one row; returns whether the change was
|
|
@@ -16753,12 +17835,12 @@ var SettingsRegistry = class {
|
|
|
16753
17835
|
this.onInvalidate();
|
|
16754
17836
|
return "accepted";
|
|
16755
17837
|
}
|
|
16756
|
-
/** Whether any row is live (
|
|
17838
|
+
/** Whether any row is live (Plugin Manager diagnostics). */
|
|
16757
17839
|
hasAny() {
|
|
16758
17840
|
for (const record of this.records.values()) if (!record.disposed) return true;
|
|
16759
17841
|
return false;
|
|
16760
17842
|
}
|
|
16761
|
-
/** An immutable snapshot (
|
|
17843
|
+
/** An immutable snapshot (Plugin Manager diagnostics). */
|
|
16762
17844
|
snapshot() {
|
|
16763
17845
|
return {
|
|
16764
17846
|
rows: this.rows().map((record) => ({
|
|
@@ -17120,7 +18202,7 @@ var KeybindingRegistry = class {
|
|
|
17120
18202
|
if (keyEquals(record.key, canonical)) return record.id;
|
|
17121
18203
|
}
|
|
17122
18204
|
}
|
|
17123
|
-
/** An immutable snapshot (
|
|
18205
|
+
/** An immutable snapshot (Plugin Manager diagnostics). */
|
|
17124
18206
|
snapshot() {
|
|
17125
18207
|
return {
|
|
17126
18208
|
bindings: [...this.records.values()].filter((record) => !record.disposed).sort((left, right) => left.id.localeCompare(right.id)).map((record) => ({
|
|
@@ -17133,7 +18215,7 @@ var KeybindingRegistry = class {
|
|
|
17133
18215
|
revision: this.revision
|
|
17134
18216
|
};
|
|
17135
18217
|
}
|
|
17136
|
-
/** Whether any binding is live (
|
|
18218
|
+
/** Whether any binding is live (Plugin Manager diagnostics). */
|
|
17137
18219
|
hasAny() {
|
|
17138
18220
|
for (const record of this.records.values()) if (!record.disposed) return true;
|
|
17139
18221
|
return false;
|
|
@@ -17301,7 +18383,7 @@ var RendererRegistry = class {
|
|
|
17301
18383
|
} catch {}
|
|
17302
18384
|
}
|
|
17303
18385
|
}
|
|
17304
|
-
/** Whether any renderer is live (
|
|
18386
|
+
/** Whether any renderer is live (Plugin Manager diagnostics). */
|
|
17305
18387
|
hasAny() {
|
|
17306
18388
|
for (const record of this.messageRenderers.values()) if (!record.disposed) return true;
|
|
17307
18389
|
for (const record of this.toolRenderers.values()) if (!record.disposed) return true;
|
|
@@ -17313,7 +18395,7 @@ var RendererRegistry = class {
|
|
|
17313
18395
|
revisionOf() {
|
|
17314
18396
|
return this.revision;
|
|
17315
18397
|
}
|
|
17316
|
-
/** An immutable snapshot (
|
|
18398
|
+
/** An immutable snapshot (Plugin Manager diagnostics). */
|
|
17317
18399
|
snapshot() {
|
|
17318
18400
|
return {
|
|
17319
18401
|
messageRenderers: [...this.messageRenderers.values()].filter((record) => !record.disposed).sort((left, right) => left.order - right.order || (left.id < right.id ? -1 : left.id > right.id ? 1 : 0)).map((record) => ({
|
|
@@ -17414,12 +18496,12 @@ var EditorRegistry = class {
|
|
|
17414
18496
|
}
|
|
17415
18497
|
return best;
|
|
17416
18498
|
}
|
|
17417
|
-
/** Whether any editor is live (
|
|
18499
|
+
/** Whether any editor is live (Plugin Manager diagnostics). */
|
|
17418
18500
|
hasAny() {
|
|
17419
18501
|
for (const record of this.records.values()) if (!record.disposed) return true;
|
|
17420
18502
|
return false;
|
|
17421
18503
|
}
|
|
17422
|
-
/** An immutable snapshot (
|
|
18504
|
+
/** An immutable snapshot (Plugin Manager diagnostics). */
|
|
17423
18505
|
snapshot() {
|
|
17424
18506
|
return {
|
|
17425
18507
|
editors: [...this.records.values()].filter((record) => !record.disposed).sort((left, right) => left.priority - right.priority || left.id.localeCompare(right.id)).map((record) => ({
|
|
@@ -17927,34 +19009,28 @@ var PiTuiExtensionServiceImpl = class PiTuiExtensionServiceImpl extends Service
|
|
|
17927
19009
|
const selectableValue = ThemeRegistry.selectableValue(stableOwner, contribution.id);
|
|
17928
19010
|
const handle = this.themes.register(contribution, owner, stableOwner);
|
|
17929
19011
|
this.trackRegistryHealth("theme", contribution.id, owner);
|
|
17930
|
-
let
|
|
17931
|
-
|
|
17932
|
-
|
|
17933
|
-
|
|
17934
|
-
this.untrackRegistryHealth("theme", contribution.id, owner);
|
|
17935
|
-
this.themeUnloadedHook?.({
|
|
17936
|
-
selectableValue,
|
|
17937
|
-
name: contribution.name
|
|
17938
|
-
});
|
|
17939
|
-
}, "piTuiExtensions.registerTheme()");
|
|
17940
|
-
} catch (error) {
|
|
17941
|
-
handle.dispose();
|
|
19012
|
+
let released = false;
|
|
19013
|
+
const cleanup = () => {
|
|
19014
|
+
if (released) return;
|
|
19015
|
+
released = true;
|
|
17942
19016
|
this.untrackRegistryHealth("theme", contribution.id, owner);
|
|
19017
|
+
handle.dispose();
|
|
17943
19018
|
this.themeUnloadedHook?.({
|
|
17944
19019
|
selectableValue,
|
|
17945
19020
|
name: contribution.name
|
|
17946
19021
|
});
|
|
19022
|
+
};
|
|
19023
|
+
let dispose;
|
|
19024
|
+
try {
|
|
19025
|
+
dispose = caller.fiber.effect(() => cleanup, "piTuiExtensions.registerTheme()");
|
|
19026
|
+
} catch (error) {
|
|
19027
|
+
cleanup();
|
|
17947
19028
|
throw error;
|
|
17948
19029
|
}
|
|
17949
19030
|
return {
|
|
17950
19031
|
id: handle.id,
|
|
17951
19032
|
dispose: () => {
|
|
17952
|
-
|
|
17953
|
-
this.untrackRegistryHealth("theme", contribution.id, owner);
|
|
17954
|
-
this.themeUnloadedHook?.({
|
|
17955
|
-
selectableValue,
|
|
17956
|
-
name: contribution.name
|
|
17957
|
-
});
|
|
19033
|
+
cleanup();
|
|
17958
19034
|
dispose();
|
|
17959
19035
|
}
|
|
17960
19036
|
};
|
|
@@ -18021,22 +19097,24 @@ var PiTuiExtensionServiceImpl = class PiTuiExtensionServiceImpl extends Service
|
|
|
18021
19097
|
this.recordOwnerEntry(owner, caller.fiber);
|
|
18022
19098
|
const handle = this.autocomplete.register(contribution, owner);
|
|
18023
19099
|
this.trackRegistryHealth("autocomplete", contribution.id, owner);
|
|
19100
|
+
let released = false;
|
|
19101
|
+
const cleanup = () => {
|
|
19102
|
+
if (released) return;
|
|
19103
|
+
released = true;
|
|
19104
|
+
this.untrackRegistryHealth("autocomplete", contribution.id, owner);
|
|
19105
|
+
handle.dispose();
|
|
19106
|
+
};
|
|
18024
19107
|
let dispose;
|
|
18025
19108
|
try {
|
|
18026
|
-
dispose = caller.fiber.effect(() => ()
|
|
18027
|
-
handle.dispose();
|
|
18028
|
-
this.untrackRegistryHealth("autocomplete", contribution.id, owner);
|
|
18029
|
-
}, "piTuiExtensions.registerAutocomplete()");
|
|
19109
|
+
dispose = caller.fiber.effect(() => cleanup, "piTuiExtensions.registerAutocomplete()");
|
|
18030
19110
|
} catch (error) {
|
|
18031
|
-
|
|
18032
|
-
this.untrackRegistryHealth("autocomplete", contribution.id, owner);
|
|
19111
|
+
cleanup();
|
|
18033
19112
|
throw error;
|
|
18034
19113
|
}
|
|
18035
19114
|
return {
|
|
18036
19115
|
id: handle.id,
|
|
18037
19116
|
dispose: () => {
|
|
18038
|
-
|
|
18039
|
-
this.untrackRegistryHealth("autocomplete", contribution.id, owner);
|
|
19117
|
+
cleanup();
|
|
18040
19118
|
dispose();
|
|
18041
19119
|
}
|
|
18042
19120
|
};
|
|
@@ -18051,23 +19129,25 @@ var PiTuiExtensionServiceImpl = class PiTuiExtensionServiceImpl extends Service
|
|
|
18051
19129
|
this.recordOwnerEntry(owner, caller.fiber);
|
|
18052
19130
|
const handle = this.settings.register(contribution, owner);
|
|
18053
19131
|
this.trackRegistryHealth("setting", contribution.id, owner);
|
|
19132
|
+
let released = false;
|
|
19133
|
+
const cleanup = () => {
|
|
19134
|
+
if (released) return;
|
|
19135
|
+
released = true;
|
|
19136
|
+
handle.dispose();
|
|
19137
|
+
this.untrackRegistryHealth("setting", contribution.id, owner);
|
|
19138
|
+
};
|
|
18054
19139
|
let dispose;
|
|
18055
19140
|
try {
|
|
18056
|
-
dispose = caller.fiber.effect(() => ()
|
|
18057
|
-
handle.dispose();
|
|
18058
|
-
this.untrackRegistryHealth("setting", contribution.id, owner);
|
|
18059
|
-
}, "piTuiExtensions.registerSetting()");
|
|
19141
|
+
dispose = caller.fiber.effect(() => cleanup, "piTuiExtensions.registerSetting()");
|
|
18060
19142
|
} catch (error) {
|
|
18061
|
-
|
|
18062
|
-
this.untrackRegistryHealth("setting", contribution.id, owner);
|
|
19143
|
+
cleanup();
|
|
18063
19144
|
throw error;
|
|
18064
19145
|
}
|
|
18065
19146
|
return {
|
|
18066
19147
|
id: handle.id,
|
|
18067
19148
|
setValue: (value) => handle.setValue(value),
|
|
18068
19149
|
dispose: () => {
|
|
18069
|
-
|
|
18070
|
-
this.untrackRegistryHealth("setting", contribution.id, owner);
|
|
19150
|
+
cleanup();
|
|
18071
19151
|
dispose();
|
|
18072
19152
|
}
|
|
18073
19153
|
};
|
|
@@ -18085,22 +19165,24 @@ var PiTuiExtensionServiceImpl = class PiTuiExtensionServiceImpl extends Service
|
|
|
18085
19165
|
this.recordOwnerEntry(owner, caller.fiber);
|
|
18086
19166
|
const handle = this.keybindings.register(contribution, owner);
|
|
18087
19167
|
this.trackRegistryHealth("keybinding", contribution.id, owner);
|
|
19168
|
+
let released = false;
|
|
19169
|
+
const cleanup = () => {
|
|
19170
|
+
if (released) return;
|
|
19171
|
+
released = true;
|
|
19172
|
+
this.untrackRegistryHealth("keybinding", contribution.id, owner);
|
|
19173
|
+
handle.dispose();
|
|
19174
|
+
};
|
|
18088
19175
|
let dispose;
|
|
18089
19176
|
try {
|
|
18090
|
-
dispose = caller.fiber.effect(() => ()
|
|
18091
|
-
handle.dispose();
|
|
18092
|
-
this.untrackRegistryHealth("keybinding", contribution.id, owner);
|
|
18093
|
-
}, "piTuiExtensions.registerKeybinding()");
|
|
19177
|
+
dispose = caller.fiber.effect(() => cleanup, "piTuiExtensions.registerKeybinding()");
|
|
18094
19178
|
} catch (error) {
|
|
18095
|
-
|
|
18096
|
-
this.untrackRegistryHealth("keybinding", contribution.id, owner);
|
|
19179
|
+
cleanup();
|
|
18097
19180
|
throw error;
|
|
18098
19181
|
}
|
|
18099
19182
|
return {
|
|
18100
19183
|
id: handle.id,
|
|
18101
19184
|
dispose: () => {
|
|
18102
|
-
|
|
18103
|
-
this.untrackRegistryHealth("keybinding", contribution.id, owner);
|
|
19185
|
+
cleanup();
|
|
18104
19186
|
dispose();
|
|
18105
19187
|
}
|
|
18106
19188
|
};
|
|
@@ -18115,23 +19197,25 @@ var PiTuiExtensionServiceImpl = class PiTuiExtensionServiceImpl extends Service
|
|
|
18115
19197
|
const owner = `${caller.fiber.uid}:${caller.fiber.name}`;
|
|
18116
19198
|
this.recordOwnerEntry(owner, caller.fiber);
|
|
18117
19199
|
const handle = this.renderers.registerMessageRenderer(contribution, owner);
|
|
18118
|
-
this.
|
|
19200
|
+
this.trackRegistryHealth("transcript.message.renderer", contribution.id, owner);
|
|
19201
|
+
let released = false;
|
|
19202
|
+
const cleanup = () => {
|
|
19203
|
+
if (released) return;
|
|
19204
|
+
released = true;
|
|
19205
|
+
this.untrackRegistryHealth("transcript.message.renderer", contribution.id, owner);
|
|
19206
|
+
handle.dispose();
|
|
19207
|
+
};
|
|
18119
19208
|
let dispose;
|
|
18120
19209
|
try {
|
|
18121
|
-
dispose = caller.fiber.effect(() => ()
|
|
18122
|
-
handle.dispose();
|
|
18123
|
-
this.ledger.untrackHealth("transcript.message.renderer", contribution.id, owner);
|
|
18124
|
-
}, "piTuiExtensions.registerMessageRenderer()");
|
|
19210
|
+
dispose = caller.fiber.effect(() => cleanup, "piTuiExtensions.registerMessageRenderer()");
|
|
18125
19211
|
} catch (error) {
|
|
18126
|
-
|
|
18127
|
-
this.ledger.untrackHealth("transcript.message.renderer", contribution.id, owner);
|
|
19212
|
+
cleanup();
|
|
18128
19213
|
throw error;
|
|
18129
19214
|
}
|
|
18130
19215
|
return {
|
|
18131
19216
|
id: handle.id,
|
|
18132
19217
|
dispose: () => {
|
|
18133
|
-
|
|
18134
|
-
this.ledger.untrackHealth("transcript.message.renderer", contribution.id, owner);
|
|
19218
|
+
cleanup();
|
|
18135
19219
|
dispose();
|
|
18136
19220
|
}
|
|
18137
19221
|
};
|
|
@@ -18145,23 +19229,25 @@ var PiTuiExtensionServiceImpl = class PiTuiExtensionServiceImpl extends Service
|
|
|
18145
19229
|
const owner = `${caller.fiber.uid}:${caller.fiber.name}`;
|
|
18146
19230
|
this.recordOwnerEntry(owner, caller.fiber);
|
|
18147
19231
|
const handle = this.renderers.registerToolRenderer(contribution, owner);
|
|
18148
|
-
this.
|
|
19232
|
+
this.trackRegistryHealth("transcript.tool.renderer", contribution.id, owner);
|
|
19233
|
+
let released = false;
|
|
19234
|
+
const cleanup = () => {
|
|
19235
|
+
if (released) return;
|
|
19236
|
+
released = true;
|
|
19237
|
+
this.untrackRegistryHealth("transcript.tool.renderer", contribution.id, owner);
|
|
19238
|
+
handle.dispose();
|
|
19239
|
+
};
|
|
18149
19240
|
let dispose;
|
|
18150
19241
|
try {
|
|
18151
|
-
dispose = caller.fiber.effect(() => ()
|
|
18152
|
-
handle.dispose();
|
|
18153
|
-
this.ledger.untrackHealth("transcript.tool.renderer", contribution.id, owner);
|
|
18154
|
-
}, "piTuiExtensions.registerToolRenderer()");
|
|
19242
|
+
dispose = caller.fiber.effect(() => cleanup, "piTuiExtensions.registerToolRenderer()");
|
|
18155
19243
|
} catch (error) {
|
|
18156
|
-
|
|
18157
|
-
this.ledger.untrackHealth("transcript.tool.renderer", contribution.id, owner);
|
|
19244
|
+
cleanup();
|
|
18158
19245
|
throw error;
|
|
18159
19246
|
}
|
|
18160
19247
|
return {
|
|
18161
19248
|
id: handle.id,
|
|
18162
19249
|
dispose: () => {
|
|
18163
|
-
|
|
18164
|
-
this.ledger.untrackHealth("transcript.tool.renderer", contribution.id, owner);
|
|
19250
|
+
cleanup();
|
|
18165
19251
|
dispose();
|
|
18166
19252
|
}
|
|
18167
19253
|
};
|
|
@@ -18239,22 +19325,24 @@ var PiTuiExtensionServiceImpl = class PiTuiExtensionServiceImpl extends Service
|
|
|
18239
19325
|
this.recordOwnerEntry(owner, caller.fiber);
|
|
18240
19326
|
const handle = this.editors.register(contribution, owner);
|
|
18241
19327
|
this.trackRegistryHealth("editor", contribution.id, owner);
|
|
19328
|
+
let released = false;
|
|
19329
|
+
const cleanup = () => {
|
|
19330
|
+
if (released) return;
|
|
19331
|
+
released = true;
|
|
19332
|
+
this.untrackRegistryHealth("editor", contribution.id, owner);
|
|
19333
|
+
handle.dispose();
|
|
19334
|
+
};
|
|
18242
19335
|
let dispose;
|
|
18243
19336
|
try {
|
|
18244
|
-
dispose = caller.fiber.effect(() => ()
|
|
18245
|
-
handle.dispose();
|
|
18246
|
-
this.untrackRegistryHealth("editor", contribution.id, owner);
|
|
18247
|
-
}, "piTuiExtensions.registerEditor()");
|
|
19337
|
+
dispose = caller.fiber.effect(() => cleanup, "piTuiExtensions.registerEditor()");
|
|
18248
19338
|
} catch (error) {
|
|
18249
|
-
|
|
18250
|
-
this.untrackRegistryHealth("editor", contribution.id, owner);
|
|
19339
|
+
cleanup();
|
|
18251
19340
|
throw error;
|
|
18252
19341
|
}
|
|
18253
19342
|
return {
|
|
18254
19343
|
id: handle.id,
|
|
18255
19344
|
dispose: () => {
|
|
18256
|
-
|
|
18257
|
-
this.untrackRegistryHealth("editor", contribution.id, owner);
|
|
19345
|
+
cleanup();
|
|
18258
19346
|
dispose();
|
|
18259
19347
|
}
|
|
18260
19348
|
};
|
|
@@ -18824,4 +19912,4 @@ function apply(ctx) {
|
|
|
18824
19912
|
new PiTuiExtensionServiceImpl(ctx, packageVersion(), () => {}, HOST_COMMAND_CATALOG);
|
|
18825
19913
|
}
|
|
18826
19914
|
//#endregion
|
|
18827
|
-
export { findAltScreenSearchMatches as $,
|
|
19915
|
+
export { findAltScreenSearchMatches as $, isTextProducingKeyId as A, Markdown as B, isPhysicalEscapeAction as C, __exportAll as Ct, VIEWER_BLOCKED_PARENT_ACTIONS as D, APP_KEYBINDINGS as E, Editor as F, Spacer as G, ProcessTerminal as H, HStack as I, TuiMainScreen as J, Text as K, Image as L, AltScreenSearchIndex as M, CombinedAutocompleteProvider as N, canonicalizeKeyId as O, Container as P, dispatchMouseEvent as Q, Input as R, isEditorSubmitPreSubmitKey as S, stripControlChars as St, parseUserKeybindings as T, ScrollView as U, MouseRegion as V, SettingsList as W, decodeKittyPrintable as X, VStack as Y, decodePrintableKey as Z, localCommandMayWrite as _, defaultHideInTsp as _t, PI_TUI_EXTENSIONS_SERVICE as a, imageFallback as at, normalizeInputEvent as b, parseFooterLayout as bt, InvalidateBatcher as c, isKeyRepeat as ct, SESSIONLESS_COMMANDS as d, registerKittyImageMetadata as dt, fuzzyFilter as et, classifyCommandLine as f, sliceByColumn as ft, isPlainExitPrompt as g, wrapTextWithAnsi as gt, isLocalCommandLine as h, visibleWidth as ht, name as i, getKeybindings as it, isValidKeyId as j, isRuntimeBindableKeyId as k, HOST_COMMAND_CATALOG as l, matchesKey as lt, isBareCommandLine as m, truncateToWidth as mt, extensions_exports as n, getCellDimensions as nt, API_VERSION as o, isFocusable as ot, commandIsLocalForAttachments as p, stripTerminalSequences as pt, TuiAltScreen as q, inject as r, getGraphemeSegmenter as rt, describeKey as s, isKeyRelease as st, apply as t, getCapabilities as tt, LOCAL_COMMANDS as u, parseKey as ut, normalizeSkillInvocation as v, hideFooterRefInTsp as vt, isTerminalAmbiguousKeyId as w, DEFAULT_LEADER_TIMEOUT_MS as x, resolveCommandFooterFallback as xt, shouldConsumeAdvertisedMiss as y, isFooterLayout as yt, Key as z };
|