@xmoon76/dsh-pi-tui 0.5.3 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +174 -150
- package/README.md +118 -103
- package/cordis.patch.yml +54 -2
- package/dist/builtins.mjs +2 -2
- package/dist/client-bootstrap-F5DHFI9t.mjs +5576 -0
- package/dist/context-summary-DAisTA_7.mjs +8557 -0
- package/dist/dispose-cause-CNFuUnjR.mjs +24 -0
- package/dist/entry-control-DvSrndWd.mjs +111 -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-CcuMY4n2.mjs} +722 -324
- package/dist/extensions.d.mts +2 -2
- package/dist/extensions.mjs +1 -1
- package/dist/host-bootstrap-DAgKknbY.mjs +119 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +45243 -27018
- package/dist/local-client.mjs +323 -0
- package/dist/local-host.mjs +176 -0
- package/dist/{performance-host-BJT6scGF.mjs → performance-host-CcDJjjVA.mjs} +1 -1
- package/dist/performance-host.mjs +1 -1
- package/dist/{performance-view-jvvd8Jn7.mjs → performance-view-CfGvLZyD.mjs} +1 -1
- package/dist/{public-types-gZi3iFNh.d.mts → public-types-Dgf1bDke.d.mts} +3 -3
- package/dist/runtime-status-0lp9CM0V.mjs +1923 -0
- package/dist/{runtime-BtPH-UUb.mjs → runtime-vc4mdr-R.mjs} +1395 -1088
- package/dist/{session-BZLxhrPQ.mjs → session-tdJHLnJR.mjs} +3329 -281
- package/dist/{startup-D5Xu8diR.mjs → startup-JaVZoTIl.mjs} +54 -13
- package/dist/startup.d.mts +2 -1
- package/dist/startup.mjs +1 -1
- package/dist/{terminal-progress-source-BlmksrSD.mjs → terminal-progress-source-xor3vakJ.mjs} +102 -46
- 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 +132 -113
- package/dist/context-summary-CxUpNkA9.mjs +0 -2951
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
|
|
2
|
-
import { n as TUI_STARTUP_SERVICE } from "./startup-
|
|
2
|
+
import { n as TUI_STARTUP_SERVICE } from "./startup-JaVZoTIl.mjs";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import * as fs from "node:fs";
|
|
5
5
|
import { readFileSync } from "node:fs";
|
|
@@ -2810,7 +2810,7 @@ function detectCapabilitiesFromEnvironment(tmuxForwardsHyperlink) {
|
|
|
2810
2810
|
trueColor: hasTrueColorHint,
|
|
2811
2811
|
hyperlinks: true
|
|
2812
2812
|
};
|
|
2813
|
-
if (process.env.KITTY_WINDOW_ID || termProgram === "kitty") return {
|
|
2813
|
+
if (process.env.KITTY_WINDOW_ID || termProgram === "kitty" || termProgram === "tern") return {
|
|
2814
2814
|
images: "kitty",
|
|
2815
2815
|
trueColor: true,
|
|
2816
2816
|
hyperlinks: true
|
|
@@ -2893,6 +2893,97 @@ function setCapabilities(caps) {
|
|
|
2893
2893
|
}
|
|
2894
2894
|
const KITTY_PREFIX = "\x1B_G";
|
|
2895
2895
|
const ITERM2_PREFIX = "\x1B]1337;File=";
|
|
2896
|
+
/** The Kitty Unicode placeholder base character (Supplementary PUA, plane 16). */
|
|
2897
|
+
const KITTY_VIRTUAL_PLACEHOLDER = "";
|
|
2898
|
+
/** The virtual backend's component bound; a larger placement is not a managed A image. */
|
|
2899
|
+
const KITTY_VIRTUAL_MAX_CELLS = 297;
|
|
2900
|
+
function positiveIntegerControl(controls, key) {
|
|
2901
|
+
const value = controls[key];
|
|
2902
|
+
if (value === void 0 || value === "") return void 0;
|
|
2903
|
+
const parsed = Number(value);
|
|
2904
|
+
return Number.isInteger(parsed) && parsed > 0 ? parsed : void 0;
|
|
2905
|
+
}
|
|
2906
|
+
/**
|
|
2907
|
+
* Read one managed Unicode-placeholder placement anchor from a source line.
|
|
2908
|
+
*
|
|
2909
|
+
* This is a stateless parser for the virtual backend's ONE first-row anchor; it
|
|
2910
|
+
* does not synthesize geometry or touch the Native metadata table. A line whose
|
|
2911
|
+
* first Kitty APC is not exactly `a=p,U=1,q=2` with valid 1..297 `c`/`r` is not
|
|
2912
|
+
* a virtual anchor. The returned `sequence` is the exact source substring the
|
|
2913
|
+
* layout seam may move without rewriting any byte.
|
|
2914
|
+
*/
|
|
2915
|
+
function getKittyVirtualPlacementAnchor(line) {
|
|
2916
|
+
const start = line.indexOf(KITTY_PREFIX);
|
|
2917
|
+
if (start === -1) return void 0;
|
|
2918
|
+
const end = line.indexOf("\x1B\\", start + 3);
|
|
2919
|
+
if (end === -1) return void 0;
|
|
2920
|
+
const body = line.slice(start + 3, end);
|
|
2921
|
+
const separator = body.indexOf(";");
|
|
2922
|
+
if (separator === -1) return void 0;
|
|
2923
|
+
const controls = {};
|
|
2924
|
+
for (const part of body.slice(0, separator).split(",")) {
|
|
2925
|
+
const equals = part.indexOf("=");
|
|
2926
|
+
if (equals <= 0) continue;
|
|
2927
|
+
controls[part.slice(0, equals)] = part.slice(equals + 1);
|
|
2928
|
+
}
|
|
2929
|
+
if (controls.a !== "p" || controls.U !== "1" || controls.q !== "2") return void 0;
|
|
2930
|
+
const imageId = positiveIntegerControl(controls, "i");
|
|
2931
|
+
const placementId = positiveIntegerControl(controls, "p");
|
|
2932
|
+
const columns = positiveIntegerControl(controls, "c");
|
|
2933
|
+
const rows = positiveIntegerControl(controls, "r");
|
|
2934
|
+
if (imageId === void 0 || placementId === void 0) return void 0;
|
|
2935
|
+
if (columns === void 0 || rows === void 0) return void 0;
|
|
2936
|
+
if (columns > KITTY_VIRTUAL_MAX_CELLS || rows > KITTY_VIRTUAL_MAX_CELLS) return void 0;
|
|
2937
|
+
return {
|
|
2938
|
+
sequence: line.slice(start, end + 2),
|
|
2939
|
+
imageId,
|
|
2940
|
+
placementId,
|
|
2941
|
+
columns,
|
|
2942
|
+
rows
|
|
2943
|
+
};
|
|
2944
|
+
}
|
|
2945
|
+
const MANAGED_KITTY_VIRTUAL_MARKER_TERMINATOR = "\x1B\\";
|
|
2946
|
+
/**
|
|
2947
|
+
* Read the private provenance marker at the start of a source line. The marker
|
|
2948
|
+
* is NOT a Kitty graphics command and is never written to a real terminal; it
|
|
2949
|
+
* only says that the adjacent `a=p,U=1` anchor was produced by the managed
|
|
2950
|
+
* component for the same Core handle. A malformed prefix returns undefined; the
|
|
2951
|
+
* layout caller treats a line that starts with the prefix but does not parse as
|
|
2952
|
+
* an implementation error and refuses to paint it.
|
|
2953
|
+
*/
|
|
2954
|
+
function getManagedKittyVirtualMarker(line) {
|
|
2955
|
+
if (!line.startsWith("\x1B_pi:tmux-image:v1:i=")) return void 0;
|
|
2956
|
+
const end = line.indexOf(MANAGED_KITTY_VIRTUAL_MARKER_TERMINATOR, 21);
|
|
2957
|
+
if (end === -1) return void 0;
|
|
2958
|
+
const match = /^(\d{1,10}),p=(\d{1,10})$/.exec(line.slice(21, end));
|
|
2959
|
+
if (match === null) return void 0;
|
|
2960
|
+
const imageId = Number(match[1]);
|
|
2961
|
+
const placementId = Number(match[2]);
|
|
2962
|
+
if (!Number.isSafeInteger(imageId) || imageId < 1 || imageId > 4294967295) return void 0;
|
|
2963
|
+
if (!Number.isSafeInteger(placementId) || placementId < 1 || placementId > 4294967295) return void 0;
|
|
2964
|
+
return {
|
|
2965
|
+
sequence: line.slice(0, end + 2),
|
|
2966
|
+
imageId,
|
|
2967
|
+
placementId
|
|
2968
|
+
};
|
|
2969
|
+
}
|
|
2970
|
+
/** Whether the line carries at least one real Unicode placeholder cell. */
|
|
2971
|
+
function isKittyVirtualPlaceholderLine(line) {
|
|
2972
|
+
return line.includes(KITTY_VIRTUAL_PLACEHOLDER);
|
|
2973
|
+
}
|
|
2974
|
+
/**
|
|
2975
|
+
* Whether a placeholder row's own colors name the same image/placement as an
|
|
2976
|
+
* existing virtual anchor. This is a validation of EXISTING identity bytes, not
|
|
2977
|
+
* a geometry reconstruction: the anchor's `i`/`p` stay authoritative and the
|
|
2978
|
+
* row must already be a real placeholder line.
|
|
2979
|
+
*/
|
|
2980
|
+
function matchesKittyVirtualPlaceholderIdentity(line, imageId, placementId) {
|
|
2981
|
+
const foreground = /\x1b\[38;2;(\d{1,3});(\d{1,3});(\d{1,3})m/.exec(line);
|
|
2982
|
+
const underline = /\x1b\[58:2::(\d{1,3}):(\d{1,3}):(\d{1,3})m/.exec(line);
|
|
2983
|
+
if (foreground === null || underline === null) return false;
|
|
2984
|
+
const rgb = (match) => (Number(match[1]) & 255) << 16 | (Number(match[2]) & 255) << 8 | Number(match[3]) & 255;
|
|
2985
|
+
return rgb(foreground) === (imageId & 16777215) && rgb(underline) === (placementId & 16777215);
|
|
2986
|
+
}
|
|
2896
2987
|
function isImageLine(line) {
|
|
2897
2988
|
if (line.startsWith(KITTY_PREFIX) || line.startsWith(ITERM2_PREFIX)) return true;
|
|
2898
2989
|
return line.includes(KITTY_PREFIX) || line.includes(ITERM2_PREFIX);
|
|
@@ -3398,6 +3489,22 @@ function parseSizeValue(value, referenceSize) {
|
|
|
3398
3489
|
const match = value.match(/^(\d+(?:\.\d+)?)%$/);
|
|
3399
3490
|
if (match) return Math.floor(referenceSize * parseFloat(match[1]) / 100);
|
|
3400
3491
|
}
|
|
3492
|
+
/** The half-open content rectangle of one painted overlay placement after its
|
|
3493
|
+
* declared chrome insets, or undefined when it has no selectable cell
|
|
3494
|
+
* (dsh-pi-tui divergence X068). */
|
|
3495
|
+
function overlayTextSelectionRect(layout, insets) {
|
|
3496
|
+
const minX = layout.col + Math.max(0, Math.floor(insets.left));
|
|
3497
|
+
const maxX = layout.col + layout.width - Math.max(0, Math.floor(insets.right));
|
|
3498
|
+
const minY = layout.row + Math.max(0, Math.floor(insets.top));
|
|
3499
|
+
const maxY = layout.row + layout.height - Math.max(0, Math.floor(insets.bottom));
|
|
3500
|
+
if (maxX <= minX || maxY <= minY) return void 0;
|
|
3501
|
+
return {
|
|
3502
|
+
minX,
|
|
3503
|
+
maxX,
|
|
3504
|
+
minY,
|
|
3505
|
+
maxY
|
|
3506
|
+
};
|
|
3507
|
+
}
|
|
3401
3508
|
/**
|
|
3402
3509
|
* Container - a component that contains other components
|
|
3403
3510
|
*/
|
|
@@ -3605,6 +3712,59 @@ var TuiBase = class TuiBase extends Container {
|
|
|
3605
3712
|
get hasOverlayEntries() {
|
|
3606
3713
|
return this.overlayStack.length > 0;
|
|
3607
3714
|
}
|
|
3715
|
+
/**
|
|
3716
|
+
* The text-selection region an unconsumed press at one screen cell would
|
|
3717
|
+
* start, resolved from the LAST PAINTED overlay placement (dsh-pi-tui
|
|
3718
|
+
* divergence X068), or undefined when that cell is not selectable content.
|
|
3719
|
+
*
|
|
3720
|
+
* The TOPMOST painted overlay that opted in with `textSelectionInsets` wins;
|
|
3721
|
+
* an ordinary overlay above it keeps upstream's opaque block (the caller
|
|
3722
|
+
* only reaches this after the overlay dispatch found no consumer). The
|
|
3723
|
+
* region is the painted placement minus the declared insets, as a half-open
|
|
3724
|
+
* cell rectangle, and is refused when either inner dimension is < 1.
|
|
3725
|
+
*/
|
|
3726
|
+
overlayTextSelectionRegionAt(x, y) {
|
|
3727
|
+
for (let index = this.renderedOverlayLayouts.length - 1; index >= 0; index--) {
|
|
3728
|
+
const layout = this.renderedOverlayLayouts[index];
|
|
3729
|
+
const insets = layout.entry.options?.textSelectionInsets;
|
|
3730
|
+
if (insets === void 0 || !this.overlayStack.includes(layout.entry) || !this.isOverlayVisible(layout.entry)) continue;
|
|
3731
|
+
if (x < layout.col || x >= layout.col + layout.width || y < layout.row || y >= layout.row + layout.height) continue;
|
|
3732
|
+
const rect = overlayTextSelectionRect(layout, insets);
|
|
3733
|
+
if (rect === void 0) return void 0;
|
|
3734
|
+
if (x < rect.minX || x >= rect.maxX || y < rect.minY || y >= rect.maxY) return void 0;
|
|
3735
|
+
return {
|
|
3736
|
+
entry: layout.entry,
|
|
3737
|
+
rect,
|
|
3738
|
+
placement: {
|
|
3739
|
+
col: layout.col,
|
|
3740
|
+
row: layout.row,
|
|
3741
|
+
width: layout.width,
|
|
3742
|
+
height: layout.height
|
|
3743
|
+
}
|
|
3744
|
+
};
|
|
3745
|
+
}
|
|
3746
|
+
}
|
|
3747
|
+
/**
|
|
3748
|
+
* Whether a captured overlay text-selection region still describes the
|
|
3749
|
+
* CURRENT paint: the entry is still a mounted, visible overlay, its painted
|
|
3750
|
+
* placement is byte-identical, and no other visible overlay paints above it
|
|
3751
|
+
* (dsh-pi-tui divergence X068). A resize/remount, a hide/close, or a newer
|
|
3752
|
+
* modal therefore retires the region instead of letting a stale selection
|
|
3753
|
+
* land on the new frame.
|
|
3754
|
+
*/
|
|
3755
|
+
isOverlayTextSelectionRegionLive(region) {
|
|
3756
|
+
if (!this.overlayStack.includes(region.entry) || !this.isOverlayVisible(region.entry)) return false;
|
|
3757
|
+
for (const entry of this.overlayStack) if (entry !== region.entry && entry.focusOrder > region.entry.focusOrder && this.isOverlayVisible(entry)) return false;
|
|
3758
|
+
for (let index = this.renderedOverlayLayouts.length - 1; index >= 0; index--) {
|
|
3759
|
+
const layout = this.renderedOverlayLayouts[index];
|
|
3760
|
+
if (layout.entry !== region.entry) {
|
|
3761
|
+
if (this.isOverlayVisible(layout.entry)) return false;
|
|
3762
|
+
continue;
|
|
3763
|
+
}
|
|
3764
|
+
return layout.col === region.placement.col && layout.row === region.placement.row && layout.width === region.placement.width && layout.height === region.placement.height;
|
|
3765
|
+
}
|
|
3766
|
+
return false;
|
|
3767
|
+
}
|
|
3608
3768
|
/** Whether a component is still a mounted, visible overlay. Subclasses
|
|
3609
3769
|
* (TuiAltScreen) revalidate gesture targets against this before
|
|
3610
3770
|
* dispatching pointer events. (dsh-pi-tui divergence X018 hardening.) */
|
|
@@ -4023,11 +4183,22 @@ var TuiBase = class TuiBase extends Container {
|
|
|
4023
4183
|
this.stopped = true;
|
|
4024
4184
|
this.cancelRenderTimer();
|
|
4025
4185
|
this.settleBackgroundProbe(void 0);
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4186
|
+
const failures = [];
|
|
4187
|
+
const attempt = (step) => {
|
|
4188
|
+
try {
|
|
4189
|
+
step();
|
|
4190
|
+
} catch (error) {
|
|
4191
|
+
failures.push(error);
|
|
4192
|
+
}
|
|
4193
|
+
};
|
|
4194
|
+
attempt(() => {
|
|
4195
|
+
if (this.terminalColorSchemeNotificationsEnabled) this.terminal.write("\x1B[?2031l");
|
|
4196
|
+
});
|
|
4197
|
+
attempt(() => this.beforeTerminalStop(options));
|
|
4198
|
+
attempt(() => this.terminal.showCursor());
|
|
4199
|
+
attempt(() => this.terminal.stop());
|
|
4200
|
+
attempt(() => this.afterTerminalStop(options));
|
|
4201
|
+
if (failures.length > 0) throw failures[0];
|
|
4031
4202
|
}
|
|
4032
4203
|
renderNow(force = false) {
|
|
4033
4204
|
if (force) this.resetRenderState();
|
|
@@ -4430,199 +4601,6 @@ var TuiBase = class TuiBase extends Container {
|
|
|
4430
4601
|
return promise;
|
|
4431
4602
|
}
|
|
4432
4603
|
};
|
|
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
4604
|
const TUI_KEYBINDINGS = {
|
|
4627
4605
|
"tui.editor.cursorUp": {
|
|
4628
4606
|
defaultKeys: "up",
|
|
@@ -5065,6 +5043,15 @@ var UndoStack = class {
|
|
|
5065
5043
|
clear() {
|
|
5066
5044
|
this.stack.length = 0;
|
|
5067
5045
|
}
|
|
5046
|
+
/**
|
|
5047
|
+
* Transform every snapshot in place while preserving the stack order.
|
|
5048
|
+
* Narrow internal primitive used by Editor.retireDraftImageFromUndo() to
|
|
5049
|
+
* trim a retired image occurrence from older snapshots; this is not a
|
|
5050
|
+
* generic public UndoStack API.
|
|
5051
|
+
*/
|
|
5052
|
+
transformSnapshots(transform) {
|
|
5053
|
+
this.stack = this.stack.map(transform);
|
|
5054
|
+
}
|
|
5068
5055
|
get length() {
|
|
5069
5056
|
return this.stack.length;
|
|
5070
5057
|
}
|
|
@@ -5332,6 +5319,23 @@ function isPasteMarker(segment) {
|
|
|
5332
5319
|
*/
|
|
5333
5320
|
const MAX_PASTE_STORED_CHARS = 262144;
|
|
5334
5321
|
/**
|
|
5322
|
+
* The canonical draft-image placeholder grammar
|
|
5323
|
+
* (`[image #<id> (<width>×<height>)]`). The Editor never resolves these
|
|
5324
|
+
* tokens — the host owns the draft store — but its narrow Undo
|
|
5325
|
+
* image-reference observation must only report CANONICAL tokens, never
|
|
5326
|
+
* arbitrary user text that happens to mention an image.
|
|
5327
|
+
* (dsh-pi-tui divergence X064.)
|
|
5328
|
+
*/
|
|
5329
|
+
const DRAFT_IMAGE_PLACEHOLDER_REGEX = /\[image #\d+ \(\d+×\d+\)\]/g;
|
|
5330
|
+
/**
|
|
5331
|
+
* Upper bound for the paste-body image-reference cache. The cache exists only
|
|
5332
|
+
* to avoid rescanning a stored paste body during undo-snapshot pushes; it must
|
|
5333
|
+
* never become a second long-lived owner of historical paste bodies. Only
|
|
5334
|
+
* bodies that actually contain a canonical image placeholder are cached, and
|
|
5335
|
+
* the few most recently used ones are kept (X064).
|
|
5336
|
+
*/
|
|
5337
|
+
const MAX_PASTE_IMAGE_CACHE_ENTRIES = 8;
|
|
5338
|
+
/**
|
|
5335
5339
|
* A segmenter that wraps Intl.Segmenter and merges graphemes that fall
|
|
5336
5340
|
* within paste markers into single atomic segments. This makes cursor
|
|
5337
5341
|
* movement, deletion, word-wrap, etc. treat paste markers as single units.
|
|
@@ -5498,7 +5502,7 @@ function createScrollBorder(direction, hiddenLineCount, width) {
|
|
|
5498
5502
|
const ellipsis = "...".slice(0, availableWidth);
|
|
5499
5503
|
return sliceByColumn(indicator, 0, availableWidth - visibleWidth(ellipsis), true) + ellipsis;
|
|
5500
5504
|
}
|
|
5501
|
-
var Editor = class {
|
|
5505
|
+
var Editor = class Editor {
|
|
5502
5506
|
state = {
|
|
5503
5507
|
lines: [""],
|
|
5504
5508
|
cursorLine: 0,
|
|
@@ -5565,7 +5569,29 @@ var Editor = class {
|
|
|
5565
5569
|
preferredVisualCol = null;
|
|
5566
5570
|
snappedFromCursorCol = null;
|
|
5567
5571
|
undoStack = new UndoStack();
|
|
5572
|
+
/** How many current Undo snapshots reference each canonical draft-image
|
|
5573
|
+
* placeholder (raw document lines AND stored paste bodies). Maintained
|
|
5574
|
+
* incrementally on push/pop/clear/trim so the host can reconcile its
|
|
5575
|
+
* undo-retention leases without re-scanning paste bodies per keystroke
|
|
5576
|
+
* (X064). */
|
|
5577
|
+
undoImageRefCounts = /* @__PURE__ */ new Map();
|
|
5578
|
+
/** Canonical placeholders contained in one stored paste body, cached by
|
|
5579
|
+
* (paste id, body identity): paste bodies are immutable strings, so an
|
|
5580
|
+
* unchanged body never needs another scan (X064). */
|
|
5581
|
+
pasteImagePlaceholders = /* @__PURE__ */ new Map();
|
|
5568
5582
|
onSubmit;
|
|
5583
|
+
/** Called with the submitted text immediately BEFORE the draft/undo clear.
|
|
5584
|
+
* The host reserves submission-time resources first and returns a ONE-SHOT
|
|
5585
|
+
* release: it runs in a finally after the synchronous clear + onSubmit
|
|
5586
|
+
* dispatch (on success and on throw), so the business owner can take over
|
|
5587
|
+
* in the same call stack. A throw aborts the submit BEFORE any clear.
|
|
5588
|
+
* (X064.) */
|
|
5589
|
+
onBeforeSubmitClear;
|
|
5590
|
+
/** The draft/undo clear RETIRED this editor's Undo history: no snapshot can
|
|
5591
|
+
* restore an earlier draft any more. Fired after `undoStack.clear()` and
|
|
5592
|
+
* before `onChange("")`, so the host releases its undo-retention leases
|
|
5593
|
+
* while the clear is still synchronous. (X064.) */
|
|
5594
|
+
onUndoHistoryRetired;
|
|
5569
5595
|
onChange;
|
|
5570
5596
|
/** The Down-admission's editor-owned facts MAY have changed (dsh-pi-tui
|
|
5571
5597
|
* divergence X063 — the admission is a visual-line + transient-mode
|
|
@@ -6316,7 +6342,34 @@ var Editor = class {
|
|
|
6316
6342
|
* (dsh-pi-tui divergence X023.)
|
|
6317
6343
|
*/
|
|
6318
6344
|
setTextAndCursor(text, cursor) {
|
|
6345
|
+
this.installTextAndCursor(this.normalizeText(text), cursor);
|
|
6346
|
+
}
|
|
6347
|
+
/**
|
|
6348
|
+
* Replace the WHOLE document and cursor as ONE real, undoable edit:
|
|
6349
|
+
* cancel autocomplete/history browsing, push the pre-edit snapshot
|
|
6350
|
+
* (document + paste registry), install the replacement (pruning paste
|
|
6351
|
+
* entries whose markers vanished), and fire onChange. The host uses this
|
|
6352
|
+
* for the composer preview image removal: unlike setTextAndCursor(), a
|
|
6353
|
+
* following Undo restores exactly the removed text. (dsh-pi-tui
|
|
6354
|
+
* divergence X064.)
|
|
6355
|
+
*/
|
|
6356
|
+
replaceTextUndoable(text, cursor) {
|
|
6319
6357
|
const normalized = this.normalizeText(text);
|
|
6358
|
+
if (normalized === this.getText()) {
|
|
6359
|
+
this.installTextAndCursor(normalized, cursor);
|
|
6360
|
+
return;
|
|
6361
|
+
}
|
|
6362
|
+
this.cancelAutocomplete();
|
|
6363
|
+
this.lastAction = null;
|
|
6364
|
+
this.exitHistoryBrowsing();
|
|
6365
|
+
this.pushUndoSnapshot();
|
|
6366
|
+
this.installTextAndCursor(normalized, cursor);
|
|
6367
|
+
if (this.onChange) this.onChange(this.getText());
|
|
6368
|
+
}
|
|
6369
|
+
/** Install a normalized document + cursor and prune orphaned paste
|
|
6370
|
+
* entries. Deliberately does not push undo or fire onChange; the
|
|
6371
|
+
* callers own those semantics. */
|
|
6372
|
+
installTextAndCursor(normalized, cursor) {
|
|
6320
6373
|
this.state.lines = normalized.split("\n");
|
|
6321
6374
|
const requestedLine = Number.isFinite(cursor.line) ? Math.floor(cursor.line) : 0;
|
|
6322
6375
|
const line = Math.max(0, Math.min(requestedLine, this.state.lines.length - 1));
|
|
@@ -6469,8 +6522,24 @@ var Editor = class {
|
|
|
6469
6522
|
return this.state.cursorCol > 0 && currentLine[this.state.cursorCol - 1] === "\\";
|
|
6470
6523
|
}
|
|
6471
6524
|
submitValue() {
|
|
6472
|
-
this.cancelAutocomplete();
|
|
6473
6525
|
const result = this.expandPasteMarkersSinglePass(this.state.lines.join("\n")).text.trim();
|
|
6526
|
+
const release = this.onBeforeSubmitClear?.(result);
|
|
6527
|
+
try {
|
|
6528
|
+
this.clearDraftAfterSubmit();
|
|
6529
|
+
if (this.onSubmit) this.onSubmit(result);
|
|
6530
|
+
} finally {
|
|
6531
|
+
release?.();
|
|
6532
|
+
}
|
|
6533
|
+
}
|
|
6534
|
+
/**
|
|
6535
|
+
* Clear the submitted draft and its Undo history WITHOUT firing onSubmit.
|
|
6536
|
+
* Extracted from submitValue() so host-owned accelerated/plugin submission
|
|
6537
|
+
* paths clear exactly like a normal Enter submit (dsh-pi-tui divergence
|
|
6538
|
+
* X064): this retires the undoStack, while setText("") pushes another
|
|
6539
|
+
* snapshot. The caller owns the submit event.
|
|
6540
|
+
*/
|
|
6541
|
+
clearDraftAfterSubmit() {
|
|
6542
|
+
this.cancelAutocomplete();
|
|
6474
6543
|
this.state = {
|
|
6475
6544
|
lines: [""],
|
|
6476
6545
|
cursorLine: 0,
|
|
@@ -6481,9 +6550,123 @@ var Editor = class {
|
|
|
6481
6550
|
this.exitHistoryBrowsing();
|
|
6482
6551
|
this.scrollOffset = 0;
|
|
6483
6552
|
this.undoStack.clear();
|
|
6553
|
+
this.undoImageRefCounts.clear();
|
|
6554
|
+
this.pasteImagePlaceholders.clear();
|
|
6484
6555
|
this.lastAction = null;
|
|
6556
|
+
this.onUndoHistoryRetired?.();
|
|
6485
6557
|
if (this.onChange) this.onChange("");
|
|
6486
|
-
|
|
6558
|
+
}
|
|
6559
|
+
/**
|
|
6560
|
+
* Every canonical draft-image placeholder still referenced by SOME Undo
|
|
6561
|
+
* snapshot (raw document lines or stored paste bodies). This is the narrow
|
|
6562
|
+
* observation seam the host bases its undo-retention leases on; it reports
|
|
6563
|
+
* only canonical tokens and is O(1) — the per-snapshot reference counts are
|
|
6564
|
+
* maintained incrementally, so normal editing never rescans paste bodies.
|
|
6565
|
+
* (dsh-pi-tui divergence X064.)
|
|
6566
|
+
*/
|
|
6567
|
+
undoImagePlaceholders() {
|
|
6568
|
+
return new Set(this.undoImageRefCounts.keys());
|
|
6569
|
+
}
|
|
6570
|
+
/**
|
|
6571
|
+
* Retire one draft-image placeholder from the Undo snapshots after its
|
|
6572
|
+
* retained bytes were evicted by the bounded undo-retention budget (X064).
|
|
6573
|
+
* The occurrence is TRIMMED from every snapshot that contains it (raw text
|
|
6574
|
+
* or stored paste body) instead of dropping the whole snapshot: the rest of
|
|
6575
|
+
* that snapshot — including a newer still-retained image — stays undoable,
|
|
6576
|
+
* while the evicted image can never be restored. Deliberately narrow: no
|
|
6577
|
+
* generic UndoStack API is exposed, and the caller must have verified the
|
|
6578
|
+
* placeholder is not in the live draft and has no in-flight submission pin.
|
|
6579
|
+
*/
|
|
6580
|
+
retireDraftImageFromUndo(placeholder) {
|
|
6581
|
+
if (!placeholder.startsWith("[image #")) return;
|
|
6582
|
+
this.undoStack.transformSnapshots((snapshot) => {
|
|
6583
|
+
let changed = false;
|
|
6584
|
+
const lines = snapshot.state.lines.map((line) => {
|
|
6585
|
+
if (!line.includes(placeholder)) return line;
|
|
6586
|
+
changed = true;
|
|
6587
|
+
return line.replaceAll(placeholder, "");
|
|
6588
|
+
});
|
|
6589
|
+
let pastes = snapshot.pastes;
|
|
6590
|
+
for (const [id, body] of snapshot.pastes) {
|
|
6591
|
+
if (!body.includes(placeholder)) continue;
|
|
6592
|
+
if (!changed) {
|
|
6593
|
+
pastes = new Map(snapshot.pastes);
|
|
6594
|
+
changed = true;
|
|
6595
|
+
}
|
|
6596
|
+
pastes.set(id, body.replaceAll(placeholder, ""));
|
|
6597
|
+
}
|
|
6598
|
+
if (!changed) return snapshot;
|
|
6599
|
+
const cursorLine = snapshot.state.cursorLine;
|
|
6600
|
+
const cursorCol = Math.min(snapshot.state.cursorCol, lines[cursorLine]?.length ?? 0);
|
|
6601
|
+
return {
|
|
6602
|
+
state: {
|
|
6603
|
+
...snapshot.state,
|
|
6604
|
+
lines,
|
|
6605
|
+
cursorCol
|
|
6606
|
+
},
|
|
6607
|
+
pastes,
|
|
6608
|
+
pasteCounter: snapshot.pasteCounter
|
|
6609
|
+
};
|
|
6610
|
+
});
|
|
6611
|
+
this.undoImageRefCounts.delete(placeholder);
|
|
6612
|
+
}
|
|
6613
|
+
/** Canonical placeholders inside one text slice (cheap substring precheck). */
|
|
6614
|
+
static imagePlaceholdersIn(text) {
|
|
6615
|
+
if (!text.includes("[image #")) return [];
|
|
6616
|
+
return text.match(DRAFT_IMAGE_PLACEHOLDER_REGEX) ?? [];
|
|
6617
|
+
}
|
|
6618
|
+
/** Union of the canonical placeholders one document references. */
|
|
6619
|
+
documentImagePlaceholders(lines) {
|
|
6620
|
+
const found = /* @__PURE__ */ new Set();
|
|
6621
|
+
for (const line of lines) for (const placeholder of Editor.imagePlaceholdersIn(line)) found.add(placeholder);
|
|
6622
|
+
return [...found];
|
|
6623
|
+
}
|
|
6624
|
+
/** Union of the canonical placeholders a paste registry references. Only
|
|
6625
|
+
* bodies that CONTAIN a canonical token are cached, and the cache is
|
|
6626
|
+
* bounded and most-recently-used ordered, so ordinary large pastes and
|
|
6627
|
+
* retired paste bodies cannot accumulate here (X064). */
|
|
6628
|
+
pasteRegistryImagePlaceholders(pastes) {
|
|
6629
|
+
const found = /* @__PURE__ */ new Set();
|
|
6630
|
+
for (const [id, body] of pastes) {
|
|
6631
|
+
let placeholders;
|
|
6632
|
+
const cached = this.pasteImagePlaceholders.get(id);
|
|
6633
|
+
if (cached !== void 0 && cached.body === body) {
|
|
6634
|
+
placeholders = cached.placeholders;
|
|
6635
|
+
this.pasteImagePlaceholders.delete(id);
|
|
6636
|
+
this.pasteImagePlaceholders.set(id, cached);
|
|
6637
|
+
} else {
|
|
6638
|
+
placeholders = Editor.imagePlaceholdersIn(body);
|
|
6639
|
+
if (placeholders.length === 0) this.pasteImagePlaceholders.delete(id);
|
|
6640
|
+
else {
|
|
6641
|
+
this.pasteImagePlaceholders.set(id, {
|
|
6642
|
+
body,
|
|
6643
|
+
placeholders
|
|
6644
|
+
});
|
|
6645
|
+
while (this.pasteImagePlaceholders.size > MAX_PASTE_IMAGE_CACHE_ENTRIES) {
|
|
6646
|
+
const oldest = this.pasteImagePlaceholders.keys().next().value;
|
|
6647
|
+
if (oldest === void 0) break;
|
|
6648
|
+
this.pasteImagePlaceholders.delete(oldest);
|
|
6649
|
+
}
|
|
6650
|
+
}
|
|
6651
|
+
}
|
|
6652
|
+
for (const placeholder of placeholders) found.add(placeholder);
|
|
6653
|
+
}
|
|
6654
|
+
return [...found];
|
|
6655
|
+
}
|
|
6656
|
+
/** The image placeholders the CURRENT document + paste registry reference. */
|
|
6657
|
+
liveImagePlaceholders() {
|
|
6658
|
+
return [...this.documentImagePlaceholders(this.state.lines), ...this.pasteRegistryImagePlaceholders(this.pastes)];
|
|
6659
|
+
}
|
|
6660
|
+
addUndoImageRefs(placeholders) {
|
|
6661
|
+
for (const placeholder of placeholders) this.undoImageRefCounts.set(placeholder, (this.undoImageRefCounts.get(placeholder) ?? 0) + 1);
|
|
6662
|
+
}
|
|
6663
|
+
removeUndoImageRefs(placeholders) {
|
|
6664
|
+
for (const placeholder of placeholders) {
|
|
6665
|
+
const count = this.undoImageRefCounts.get(placeholder);
|
|
6666
|
+
if (count === void 0) continue;
|
|
6667
|
+
if (count <= 1) this.undoImageRefCounts.delete(placeholder);
|
|
6668
|
+
else this.undoImageRefCounts.set(placeholder, count - 1);
|
|
6669
|
+
}
|
|
6487
6670
|
}
|
|
6488
6671
|
handleBackspace() {
|
|
6489
6672
|
this.exitHistoryBrowsing();
|
|
@@ -6971,6 +7154,7 @@ var Editor = class {
|
|
|
6971
7154
|
if (this.onChange) this.onChange(this.getText());
|
|
6972
7155
|
}
|
|
6973
7156
|
pushUndoSnapshot() {
|
|
7157
|
+
const placeholders = this.liveImagePlaceholders();
|
|
6974
7158
|
this.undoStack.push({
|
|
6975
7159
|
state: {
|
|
6976
7160
|
lines: [...this.state.lines],
|
|
@@ -6980,11 +7164,13 @@ var Editor = class {
|
|
|
6980
7164
|
pastes: new Map(this.pastes),
|
|
6981
7165
|
pasteCounter: this.pasteCounter
|
|
6982
7166
|
});
|
|
7167
|
+
this.addUndoImageRefs(placeholders);
|
|
6983
7168
|
}
|
|
6984
7169
|
undo() {
|
|
6985
7170
|
this.exitHistoryBrowsing();
|
|
6986
7171
|
const snapshot = this.undoStack.pop();
|
|
6987
7172
|
if (!snapshot) return;
|
|
7173
|
+
this.removeUndoImageRefs([...this.documentImagePlaceholders(snapshot.state.lines), ...this.pasteRegistryImagePlaceholders(snapshot.pastes)]);
|
|
6988
7174
|
Object.assign(this.state, snapshot.state);
|
|
6989
7175
|
this.state.lines = [...snapshot.state.lines];
|
|
6990
7176
|
this.pastes = new Map(snapshot.pastes);
|
|
@@ -11793,15 +11979,63 @@ function paintScrollbar(box, screen, totalWidth) {
|
|
|
11793
11979
|
screen[row] = replaceScrollbarCell(screen[row] ?? "", geometry.column, totalWidth, replacement, box.scrollView.scrollbar !== "always");
|
|
11794
11980
|
}
|
|
11795
11981
|
}
|
|
11982
|
+
/** The managed virtual image row bound; only this window may be scanned. */
|
|
11983
|
+
const MAX_RELOCATABLE_VIRTUAL_ROWS = 297;
|
|
11984
|
+
/**
|
|
11985
|
+
* Preserve ONE managed virtual placement whose anchor line is vertically
|
|
11986
|
+
* clipped above this box's visible range. The only legal relocation target is
|
|
11987
|
+
* the first really visible placeholder row of the SAME image block. The
|
|
11988
|
+
* anchor bytes are reused verbatim; this helper invents no geometry, id or
|
|
11989
|
+
* extra row. It scans at most the 297-row component bound above the first
|
|
11990
|
+
* visible source line, so a viewport scroll never scans the whole transcript.
|
|
11991
|
+
*/
|
|
11992
|
+
function findRelocatedVirtualAnchor(box, firstRow, lastRow) {
|
|
11993
|
+
if (box.lines === void 0 || firstRow >= lastRow) return void 0;
|
|
11994
|
+
const offset = box.lineOffset ?? 0;
|
|
11995
|
+
const firstSource = offset + firstRow - box.rect.y;
|
|
11996
|
+
const lastSource = offset + lastRow - 1 - box.rect.y;
|
|
11997
|
+
if (firstSource <= 0 || firstSource > lastSource) return void 0;
|
|
11998
|
+
const firstLine = box.lines[firstSource];
|
|
11999
|
+
if (firstLine === void 0 || isImageLine(firstLine) || !isKittyVirtualPlaceholderLine(firstLine)) return void 0;
|
|
12000
|
+
const scanStart = Math.max(0, firstSource - MAX_RELOCATABLE_VIRTUAL_ROWS);
|
|
12001
|
+
for (let index = firstSource - 1; index >= scanStart; index--) {
|
|
12002
|
+
const line = box.lines[index];
|
|
12003
|
+
if (line === void 0) continue;
|
|
12004
|
+
const marker = getManagedKittyVirtualMarker(line);
|
|
12005
|
+
if (marker === void 0) {
|
|
12006
|
+
if (line.startsWith("\x1B_pi:tmux-image:v1:i=")) throw new Error("managed kitty virtual marker is malformed");
|
|
12007
|
+
continue;
|
|
12008
|
+
}
|
|
12009
|
+
const anchor = getKittyVirtualPlacementAnchor(line.slice(marker.sequence.length));
|
|
12010
|
+
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");
|
|
12011
|
+
if (!isKittyVirtualPlaceholderLine(line)) continue;
|
|
12012
|
+
if (index + anchor.rows - 1 < firstSource) continue;
|
|
12013
|
+
if (!matchesKittyVirtualPlaceholderIdentity(firstLine, anchor.imageId, anchor.placementId)) continue;
|
|
12014
|
+
return {
|
|
12015
|
+
sourceIndex: firstSource,
|
|
12016
|
+
sequence: anchor.sequence
|
|
12017
|
+
};
|
|
12018
|
+
}
|
|
12019
|
+
}
|
|
11796
12020
|
function paintBox(box, screen, totalWidth) {
|
|
11797
12021
|
if (box.lines) {
|
|
11798
12022
|
const offset = box.lineOffset ?? 0;
|
|
11799
12023
|
const firstRow = Math.max(box.rect.y, box.clip.y, 0);
|
|
11800
12024
|
const lastRow = Math.min(box.rect.y + box.rect.height, box.clip.y + box.clip.height, screen.length);
|
|
12025
|
+
const relocated = findRelocatedVirtualAnchor(box, firstRow, lastRow);
|
|
11801
12026
|
for (let row = firstRow; row < lastRow; row++) {
|
|
11802
|
-
const
|
|
12027
|
+
const sourceIndex = offset + row - box.rect.y;
|
|
12028
|
+
const sourceLine = box.lines[sourceIndex];
|
|
11803
12029
|
if (sourceLine === void 0) continue;
|
|
11804
12030
|
let line = sourceLine.replace(OSC133_ZONE_PREFIX$1, "");
|
|
12031
|
+
if (line.startsWith("\x1B_pi:tmux-image:v1:i=")) {
|
|
12032
|
+
const marker = getManagedKittyVirtualMarker(line);
|
|
12033
|
+
if (marker === void 0) throw new Error("managed kitty virtual marker is malformed");
|
|
12034
|
+
const anchor = getKittyVirtualPlacementAnchor(line.slice(marker.sequence.length));
|
|
12035
|
+
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");
|
|
12036
|
+
line = line.slice(marker.sequence.length);
|
|
12037
|
+
}
|
|
12038
|
+
if (relocated !== void 0 && sourceIndex === relocated.sourceIndex) line = relocated.sequence + line;
|
|
11805
12039
|
const imageMetadata = getKittyImageMetadata(line);
|
|
11806
12040
|
if (imageMetadata) {
|
|
11807
12041
|
const clipBottom = Math.min(screen.length, box.clip.y + box.clip.height);
|
|
@@ -11998,6 +12232,8 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
11998
12232
|
flashes;
|
|
11999
12233
|
altScreenActive = false;
|
|
12000
12234
|
imageProtocol = null;
|
|
12235
|
+
/** Per-instance protocol selection; never mutates the process-wide cache. */
|
|
12236
|
+
imageProtocolOverride;
|
|
12001
12237
|
savedCapabilities;
|
|
12002
12238
|
uploadedKittyImages = /* @__PURE__ */ new Map();
|
|
12003
12239
|
selectionAnchor;
|
|
@@ -12018,6 +12254,12 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
12018
12254
|
* the press (a structural repaint between press and release) must not
|
|
12019
12255
|
* receive it. (dsh-pi-tui divergence X018 hardening.) */
|
|
12020
12256
|
selectionPressDispatchComponents;
|
|
12257
|
+
/** The overlay-owned selection region of the CURRENT gesture, when the press
|
|
12258
|
+
* started inside an overlay that opted into `textSelectionInsets`
|
|
12259
|
+
* (dsh-pi-tui divergence X068). A discardable latch, never a second
|
|
12260
|
+
* selection: {@link selectionAnchor}/{@link selectionFocus} remain the one
|
|
12261
|
+
* range, and this only bounds and revalidates it. */
|
|
12262
|
+
overlaySelectionOrigin;
|
|
12021
12263
|
scrollbarDrag;
|
|
12022
12264
|
scrollbarHover;
|
|
12023
12265
|
scrollToEndIndicatorRect;
|
|
@@ -12067,6 +12309,7 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
12067
12309
|
this.flashes = new AltScreenFlashContainer(() => this.requestRender());
|
|
12068
12310
|
this.wheelScroll = new WheelScrollAccelerator(options.wheelScrollLines ?? 1);
|
|
12069
12311
|
this.mouseEnabled = options.mouse ?? true;
|
|
12312
|
+
this.imageProtocolOverride = options.imageProtocolOverride;
|
|
12070
12313
|
this.searchMatchStyle = options.searchMatchStyle ?? ((text) => `\x1b[4m${text}\x1b[24m`);
|
|
12071
12314
|
this.searchCurrentMatchStyle = options.searchCurrentMatchStyle ?? ((text) => `\x1b[1;7m${text}\x1b[22;27m`);
|
|
12072
12315
|
this.searchNavigationButtonStyle = options.searchNavigationButtonStyle ?? ((text) => text);
|
|
@@ -12125,10 +12368,21 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
12125
12368
|
if (!text) return false;
|
|
12126
12369
|
return this.copyTextToClipboard(text);
|
|
12127
12370
|
}
|
|
12128
|
-
/**
|
|
12129
|
-
|
|
12371
|
+
/**
|
|
12372
|
+
* Drop the text selection and multi-click history, e.g. before the host
|
|
12373
|
+
* replaces the transcript.
|
|
12374
|
+
*
|
|
12375
|
+
* `preserveClickHistory` (dsh-pi-tui divergence X068) keeps the multi-click
|
|
12376
|
+
* window alive for a repaint that does NOT replace the corpus — the host
|
|
12377
|
+
* repainting an overlay's own content while the user is mid gesture. The
|
|
12378
|
+
* selection range still dies (its cells name the frame being replaced), but
|
|
12379
|
+
* dropping `lastClick` there would turn every double-click into two single
|
|
12380
|
+
* clicks, because the first click's own disclosure repaint runs through the
|
|
12381
|
+
* same host callback.
|
|
12382
|
+
*/
|
|
12383
|
+
resetTextSelection(options) {
|
|
12130
12384
|
this.clearTextSelection();
|
|
12131
|
-
this.lastClick = void 0;
|
|
12385
|
+
if (options?.preserveClickHistory !== true) this.lastClick = void 0;
|
|
12132
12386
|
}
|
|
12133
12387
|
/** The lines of the last rendered frame, one per terminal row, as written to the terminal. */
|
|
12134
12388
|
getScreenLines() {
|
|
@@ -12179,7 +12433,7 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
12179
12433
|
this.flashes.dispose();
|
|
12180
12434
|
this.altScreenActive = true;
|
|
12181
12435
|
const capabilities = getCapabilities();
|
|
12182
|
-
this.imageProtocol = capabilities.images;
|
|
12436
|
+
this.imageProtocol = this.imageProtocolOverride !== void 0 ? this.imageProtocolOverride : capabilities.images;
|
|
12183
12437
|
this.uploadedKittyImages.clear();
|
|
12184
12438
|
if (capabilities.images === "iterm2") {
|
|
12185
12439
|
this.savedCapabilities = capabilities;
|
|
@@ -12194,6 +12448,7 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
12194
12448
|
this.selectionFocus = void 0;
|
|
12195
12449
|
this.selectionGranularity = "character";
|
|
12196
12450
|
this.selectionInitialRange = void 0;
|
|
12451
|
+
this.overlaySelectionOrigin = void 0;
|
|
12197
12452
|
this.lastClick = void 0;
|
|
12198
12453
|
this.pressedUrl = void 0;
|
|
12199
12454
|
this.selectionDragged = false;
|
|
@@ -12208,6 +12463,7 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
12208
12463
|
this.closeSearch();
|
|
12209
12464
|
this.stopSelectionAutoScroll();
|
|
12210
12465
|
this.selectionPressActive = false;
|
|
12466
|
+
if (this.overlaySelectionOrigin !== void 0) this.clearTextSelection();
|
|
12211
12467
|
this.stopScrollbarHover();
|
|
12212
12468
|
this.stopScrollbarDrag();
|
|
12213
12469
|
this.clearComponentMouseGesture();
|
|
@@ -12533,7 +12789,8 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
12533
12789
|
}
|
|
12534
12790
|
handleViewportInput(data) {
|
|
12535
12791
|
if (data === FOCUS_OUT) {
|
|
12536
|
-
const
|
|
12792
|
+
const hadOverlaySelection = this.overlaySelectionOrigin !== void 0;
|
|
12793
|
+
const hadActiveSelection = this.selectionPressActive || hadOverlaySelection;
|
|
12537
12794
|
const hadNonEmptyActiveSelection = hadActiveSelection && this.getSelectionBounds() !== void 0;
|
|
12538
12795
|
this.selectionPressActive = false;
|
|
12539
12796
|
this.stopSelectionAutoScroll();
|
|
@@ -12550,6 +12807,7 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
12550
12807
|
this.selectionFocus = void 0;
|
|
12551
12808
|
this.selectionGranularity = "character";
|
|
12552
12809
|
this.selectionInitialRange = void 0;
|
|
12810
|
+
this.overlaySelectionOrigin = void 0;
|
|
12553
12811
|
if (hadNonEmptyActiveSelection) this.requestRender();
|
|
12554
12812
|
}
|
|
12555
12813
|
this.lastClick = void 0;
|
|
@@ -12745,6 +13003,7 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
12745
13003
|
this.selectionFocus = void 0;
|
|
12746
13004
|
this.selectionGranularity = "character";
|
|
12747
13005
|
this.selectionInitialRange = void 0;
|
|
13006
|
+
this.overlaySelectionOrigin = void 0;
|
|
12748
13007
|
this.pressedUrl = void 0;
|
|
12749
13008
|
this.selectionDragged = false;
|
|
12750
13009
|
this.selectionPressDispatchComponents = void 0;
|
|
@@ -12811,6 +13070,10 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
12811
13070
|
return;
|
|
12812
13071
|
}
|
|
12813
13072
|
}
|
|
13073
|
+
if (this.overlaySelectionOrigin !== void 0 && this.selectionPressActive) {
|
|
13074
|
+
this.handleSelectionMouseEvent(raw);
|
|
13075
|
+
return;
|
|
13076
|
+
}
|
|
12814
13077
|
if (this.handleSearchMouseEvent(raw)) return;
|
|
12815
13078
|
const overlay = this.dispatchMouseToOverlay(event);
|
|
12816
13079
|
if (!overlay.hit) {
|
|
@@ -12846,6 +13109,13 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
12846
13109
|
return;
|
|
12847
13110
|
}
|
|
12848
13111
|
if (overlay.hit) {
|
|
13112
|
+
if (type === "press") {
|
|
13113
|
+
const region = this.overlayTextSelectionRegionAt(raw.x, raw.y);
|
|
13114
|
+
if (region !== void 0) {
|
|
13115
|
+
this.handleSelectionMouseEvent(raw, region);
|
|
13116
|
+
return;
|
|
13117
|
+
}
|
|
13118
|
+
}
|
|
12849
13119
|
if (this.selectionPressActive) this.clearTextSelection();
|
|
12850
13120
|
if (this.scrollbarDrag !== void 0) this.stopScrollbarDrag();
|
|
12851
13121
|
return;
|
|
@@ -12986,6 +13256,7 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
12986
13256
|
this.selectionFocus = void 0;
|
|
12987
13257
|
this.selectionGranularity = "character";
|
|
12988
13258
|
this.selectionInitialRange = void 0;
|
|
13259
|
+
this.overlaySelectionOrigin = void 0;
|
|
12989
13260
|
this.lastClick = void 0;
|
|
12990
13261
|
this.pressedUrl = void 0;
|
|
12991
13262
|
this.selectionDragged = false;
|
|
@@ -13025,9 +13296,28 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
13025
13296
|
const point = this.getScrollSelectionPoint(scrollView, event.x, event.y);
|
|
13026
13297
|
if (point) return point;
|
|
13027
13298
|
}
|
|
13028
|
-
return {
|
|
13299
|
+
return this.clampSelectionPoint({
|
|
13029
13300
|
row: Math.max(0, Math.min(this.terminal.rows - 1, event.y)),
|
|
13030
13301
|
col: Math.max(0, Math.min(this.terminal.columns - 1, event.x))
|
|
13302
|
+
});
|
|
13303
|
+
}
|
|
13304
|
+
/**
|
|
13305
|
+
* Clip one selection point into the captured overlay region, if any
|
|
13306
|
+
* (dsh-pi-tui divergence X068). A drag that leaves the region maps to its
|
|
13307
|
+
* nearest cell (the last visible cell for an exclusive boundary point), so
|
|
13308
|
+
* neither the highlight nor the copied text can ever reach the frame chrome
|
|
13309
|
+
* or the background behind the modal.
|
|
13310
|
+
*/
|
|
13311
|
+
clampSelectionPoint(point) {
|
|
13312
|
+
const region = this.overlaySelectionOrigin;
|
|
13313
|
+
if (region === void 0) return point;
|
|
13314
|
+
const { rect } = region;
|
|
13315
|
+
const row = Math.max(rect.minY, Math.min(rect.maxY - 1, point.row));
|
|
13316
|
+
const maxCol = point.boundary === true ? rect.maxX : rect.maxX - 1;
|
|
13317
|
+
return {
|
|
13318
|
+
...point,
|
|
13319
|
+
row,
|
|
13320
|
+
col: Math.max(rect.minX, Math.min(maxCol, point.col))
|
|
13031
13321
|
};
|
|
13032
13322
|
}
|
|
13033
13323
|
getSelectionSourceLine(point) {
|
|
@@ -13060,28 +13350,31 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
13060
13350
|
for (let index = clickedSegmentIndex; index > 0 && canJoin(segments[index - 1], segments[index]); index--) selectionStart = segments[index - 1].start;
|
|
13061
13351
|
for (let index = clickedSegmentIndex; index < segments.length - 1 && canJoin(segments[index], segments[index + 1]); index++) selectionEnd = segments[index + 1].end;
|
|
13062
13352
|
return {
|
|
13063
|
-
start: {
|
|
13353
|
+
start: this.clampSelectionPoint({
|
|
13064
13354
|
...point,
|
|
13065
13355
|
col: selectionStart
|
|
13066
|
-
},
|
|
13067
|
-
end: {
|
|
13356
|
+
}),
|
|
13357
|
+
end: this.clampSelectionPoint({
|
|
13068
13358
|
...point,
|
|
13069
13359
|
col: selectionEnd,
|
|
13070
13360
|
boundary: true
|
|
13071
|
-
}
|
|
13361
|
+
})
|
|
13072
13362
|
};
|
|
13073
13363
|
}
|
|
13074
13364
|
getLineSelection(point) {
|
|
13365
|
+
const region = this.overlaySelectionOrigin;
|
|
13366
|
+
const start = region?.rect.minX ?? 0;
|
|
13367
|
+
const end = region?.rect.maxX ?? visibleWidth(this.getSelectionSourceLine(point));
|
|
13075
13368
|
return {
|
|
13076
|
-
start: {
|
|
13369
|
+
start: this.clampSelectionPoint({
|
|
13077
13370
|
...point,
|
|
13078
|
-
col:
|
|
13079
|
-
},
|
|
13080
|
-
end: {
|
|
13371
|
+
col: start
|
|
13372
|
+
}),
|
|
13373
|
+
end: this.clampSelectionPoint({
|
|
13081
13374
|
...point,
|
|
13082
|
-
col:
|
|
13375
|
+
col: end,
|
|
13083
13376
|
boundary: true
|
|
13084
|
-
}
|
|
13377
|
+
})
|
|
13085
13378
|
};
|
|
13086
13379
|
}
|
|
13087
13380
|
updateSelectionFocus(point) {
|
|
@@ -13164,9 +13457,13 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
13164
13457
|
this.selectionAutoScrollDirection = 0;
|
|
13165
13458
|
this.selectionDragPointer = void 0;
|
|
13166
13459
|
}
|
|
13167
|
-
handleSelectionMouseEvent(event) {
|
|
13460
|
+
handleSelectionMouseEvent(event, overlayOrigin) {
|
|
13168
13461
|
const button = event.button & 3;
|
|
13169
13462
|
if (button !== 0 && !(event.release && button === 3)) return;
|
|
13463
|
+
if (overlayOrigin === void 0 && this.overlaySelectionOrigin !== void 0 && !this.isOverlayTextSelectionRegionLive(this.overlaySelectionOrigin)) {
|
|
13464
|
+
this.clearTextSelection();
|
|
13465
|
+
return;
|
|
13466
|
+
}
|
|
13170
13467
|
const anchorScrollView = this.selectionAnchor?.scrollView;
|
|
13171
13468
|
const point = this.getSelectionPoint(event, anchorScrollView);
|
|
13172
13469
|
if (event.release) {
|
|
@@ -13226,6 +13523,7 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
13226
13523
|
}
|
|
13227
13524
|
this.stopSelectionAutoScroll();
|
|
13228
13525
|
this.selectionPressActive = true;
|
|
13526
|
+
this.overlaySelectionOrigin = overlayOrigin;
|
|
13229
13527
|
this.selectionPressDispatchComponents = new Set(this.lastMouseDispatchComponents);
|
|
13230
13528
|
this.onCellPress?.(event.x, event.y);
|
|
13231
13529
|
const scrollView = !this.hasBlockingOverlay() && this.currentLayout ? getScrollViewsAt(this.currentLayout, event.x, event.y)[0] : void 0;
|
|
@@ -13238,7 +13536,7 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
13238
13536
|
this.selectionAnchor = range?.start ?? anchor;
|
|
13239
13537
|
this.selectionFocus = range?.end ?? anchor;
|
|
13240
13538
|
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)));
|
|
13539
|
+
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
13540
|
this.requestRender();
|
|
13243
13541
|
}
|
|
13244
13542
|
getSelectionBounds() {
|
|
@@ -13268,6 +13566,14 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
13268
13566
|
getActiveSelectionText() {
|
|
13269
13567
|
const selection = this.getSelectionBounds();
|
|
13270
13568
|
if (!selection) return void 0;
|
|
13569
|
+
const region = this.overlaySelectionOrigin;
|
|
13570
|
+
if (region !== void 0) {
|
|
13571
|
+
if (!this.isOverlayTextSelectionRegionLive(region)) {
|
|
13572
|
+
this.clearTextSelection();
|
|
13573
|
+
return;
|
|
13574
|
+
}
|
|
13575
|
+
return this.getOverlaySelectionText(selection, region);
|
|
13576
|
+
}
|
|
13271
13577
|
let sourceLines = this.previousScreen;
|
|
13272
13578
|
if (selection.start.scrollView) {
|
|
13273
13579
|
if (!this.currentLayout) return void 0;
|
|
@@ -13285,6 +13591,28 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
13285
13591
|
const text = lines.join("\n");
|
|
13286
13592
|
return text.length === 0 ? void 0 : text;
|
|
13287
13593
|
}
|
|
13594
|
+
/**
|
|
13595
|
+
* The visible text of one overlay-owned selection (dsh-pi-tui divergence
|
|
13596
|
+
* X068): each row is sliced to the capture's column range inside the overlay
|
|
13597
|
+
* content rectangle, terminal sequences are stripped and real spaces and
|
|
13598
|
+
* indentation are PRESERVED. The transcript branch's `trimEnd` and its 1-3
|
|
13599
|
+
* cell bullet-strip (X024) are deliberately not applied: file content and
|
|
13600
|
+
* paths must copy exactly as painted.
|
|
13601
|
+
*/
|
|
13602
|
+
getOverlaySelectionText(selection, region) {
|
|
13603
|
+
const lines = [];
|
|
13604
|
+
for (let row = selection.start.row; row <= selection.end.row; row++) {
|
|
13605
|
+
const line = this.previousScreen[row] ?? "";
|
|
13606
|
+
const columns = this.getSelectionColumns(line, row, selection, region.rect.minX, region.rect.maxX);
|
|
13607
|
+
if (columns.end <= columns.start) {
|
|
13608
|
+
lines.push("");
|
|
13609
|
+
continue;
|
|
13610
|
+
}
|
|
13611
|
+
lines.push(stripTerminalSequences(sliceByColumn(line, columns.start, columns.end - columns.start, true)));
|
|
13612
|
+
}
|
|
13613
|
+
const text = lines.join("\n");
|
|
13614
|
+
return text.length === 0 ? void 0 : text;
|
|
13615
|
+
}
|
|
13288
13616
|
async copySelectionToClipboard() {
|
|
13289
13617
|
const text = this.getActiveSelectionText();
|
|
13290
13618
|
if (!text) return false;
|
|
@@ -13402,6 +13730,13 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
13402
13730
|
let maxRow = screen.length - 1;
|
|
13403
13731
|
let minColumn = 0;
|
|
13404
13732
|
let maxColumn = this.terminal.columns;
|
|
13733
|
+
const region = this.overlaySelectionOrigin;
|
|
13734
|
+
if (region !== void 0) {
|
|
13735
|
+
minRow = Math.max(minRow, region.rect.minY);
|
|
13736
|
+
maxRow = Math.min(maxRow, region.rect.maxY - 1);
|
|
13737
|
+
minColumn = Math.max(minColumn, region.rect.minX);
|
|
13738
|
+
maxColumn = Math.min(maxColumn, region.rect.maxX);
|
|
13739
|
+
}
|
|
13405
13740
|
if (selection.start.scrollView) {
|
|
13406
13741
|
if (!layout) return screen;
|
|
13407
13742
|
const box = getScrollViewBox(layout, selection.start.scrollView);
|
|
@@ -13490,6 +13825,7 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
13490
13825
|
screen = this.compositeScrollToEndIndicator(screen, nextLayout, width);
|
|
13491
13826
|
screen = this.compositeOverlays(screen, width, height);
|
|
13492
13827
|
if (screen.length > height) screen = screen.slice(screen.length - height);
|
|
13828
|
+
if (this.overlaySelectionOrigin !== void 0 && !this.isOverlayTextSelectionRegionLive(this.overlaySelectionOrigin)) this.clearTextSelection();
|
|
13493
13829
|
screen = this.applySelection(screen, nextLayout);
|
|
13494
13830
|
screen = this.compositeFlashes(screen, width, height);
|
|
13495
13831
|
const cursorPos = this.extractCursorPosition(screen, height);
|
|
@@ -14532,6 +14868,30 @@ const APP_KEYBINDINGS = {
|
|
|
14532
14868
|
scope: "global",
|
|
14533
14869
|
configurable: true
|
|
14534
14870
|
},
|
|
14871
|
+
"app.visual.selectNext": {
|
|
14872
|
+
id: "app.visual.selectNext",
|
|
14873
|
+
defaultKeys: ["alt+v"],
|
|
14874
|
+
description: "Select the next published visual",
|
|
14875
|
+
category: "Transcript",
|
|
14876
|
+
scope: "global",
|
|
14877
|
+
configurable: true
|
|
14878
|
+
},
|
|
14879
|
+
"app.visual.copySelected": {
|
|
14880
|
+
id: "app.visual.copySelected",
|
|
14881
|
+
defaultKeys: ["alt+c"],
|
|
14882
|
+
description: "Copy the selected published visual",
|
|
14883
|
+
category: "Transcript",
|
|
14884
|
+
scope: "global",
|
|
14885
|
+
configurable: true
|
|
14886
|
+
},
|
|
14887
|
+
"app.visual.openSelected": {
|
|
14888
|
+
id: "app.visual.openSelected",
|
|
14889
|
+
defaultKeys: ["alt+o"],
|
|
14890
|
+
description: "Open the selected SVG visual in the viewer",
|
|
14891
|
+
category: "Transcript",
|
|
14892
|
+
scope: "global",
|
|
14893
|
+
configurable: true
|
|
14894
|
+
},
|
|
14535
14895
|
"app.editor.external": {
|
|
14536
14896
|
id: "app.editor.external",
|
|
14537
14897
|
defaultKeys: ["ctrl+g"],
|
|
@@ -14861,6 +15221,9 @@ const VIEWER_BLOCKED_PARENT_ACTIONS = /* @__PURE__ */ new Set([
|
|
|
14861
15221
|
"app.input.dequeue",
|
|
14862
15222
|
"app.permission.cycle",
|
|
14863
15223
|
"app.transcript.search",
|
|
15224
|
+
"app.visual.selectNext",
|
|
15225
|
+
"app.visual.copySelected",
|
|
15226
|
+
"app.visual.openSelected",
|
|
14864
15227
|
"app.exit.request",
|
|
14865
15228
|
"app.editor.external",
|
|
14866
15229
|
"app.todo.toggle",
|
|
@@ -15349,13 +15712,13 @@ var ExtensionLedger = class {
|
|
|
15349
15712
|
disposeAll() {
|
|
15350
15713
|
for (const registration of [...this.registrations.values()]) if (!registration.disposed) this.disposeRegistration(registration);
|
|
15351
15714
|
}
|
|
15352
|
-
/** The health snapshot (M11
|
|
15715
|
+
/** The health snapshot (M11 Plugin Manager diagnostics; recorded since M1). */
|
|
15353
15716
|
healthSnapshot() {
|
|
15354
15717
|
return this.health.snapshot();
|
|
15355
15718
|
}
|
|
15356
15719
|
/** Track a NON-ledger contribution's health slot (P1-08: renderers and
|
|
15357
15720
|
* editors live in their own registries, not the ledger — their health
|
|
15358
|
-
* must still be observable
|
|
15721
|
+
* must still be observable in Plugin Manager diagnostics). Idempotent per (slot, owner, id). */
|
|
15359
15722
|
trackHealth(slot, id, owner) {
|
|
15360
15723
|
this.health.track(slot, id, owner);
|
|
15361
15724
|
}
|
|
@@ -15551,7 +15914,10 @@ const SESSIONLESS_COMMANDS = /* @__PURE__ */ new Set([
|
|
|
15551
15914
|
"keybindings",
|
|
15552
15915
|
"plugins",
|
|
15553
15916
|
"quit",
|
|
15554
|
-
"statusline"
|
|
15917
|
+
"statusline",
|
|
15918
|
+
"status",
|
|
15919
|
+
"view-image",
|
|
15920
|
+
"deliverables"
|
|
15555
15921
|
]);
|
|
15556
15922
|
/**
|
|
15557
15923
|
* The LOCAL-execute command set (PR5 v2 §1C-6 narrows its semantic role):
|
|
@@ -15610,6 +15976,8 @@ const LOCAL_COMMANDS = /* @__PURE__ */ new Set([
|
|
|
15610
15976
|
"title",
|
|
15611
15977
|
"transcript",
|
|
15612
15978
|
"yolo",
|
|
15979
|
+
"view-image",
|
|
15980
|
+
"deliverables",
|
|
15613
15981
|
"statusline"
|
|
15614
15982
|
]);
|
|
15615
15983
|
/**
|
|
@@ -15908,12 +16276,12 @@ var AdvancedInputRegistry = class {
|
|
|
15908
16276
|
disposeAll() {
|
|
15909
16277
|
for (const record of [...this.records.values()]) if (!record.disposed) this.disposeRecord(record);
|
|
15910
16278
|
}
|
|
15911
|
-
/** Whether any capture is live (
|
|
16279
|
+
/** Whether any capture is live (Plugin Manager diagnostics). */
|
|
15912
16280
|
hasAny() {
|
|
15913
16281
|
for (const record of this.records.values()) if (!record.disposed) return true;
|
|
15914
16282
|
return false;
|
|
15915
16283
|
}
|
|
15916
|
-
/** An immutable snapshot (
|
|
16284
|
+
/** An immutable snapshot (Plugin Manager diagnostics). */
|
|
15917
16285
|
snapshot() {
|
|
15918
16286
|
return {
|
|
15919
16287
|
captures: [...this.records.values()].filter((record) => !record.disposed).sort((left, right) => left.priority - right.priority || left.id.localeCompare(right.id)).map((record) => ({
|
|
@@ -16055,7 +16423,7 @@ var UnstableInputRegistry = class {
|
|
|
16055
16423
|
disposeAll() {
|
|
16056
16424
|
for (const record of [...this.records.values()]) if (!record.disposed) this.disposeRecord(record);
|
|
16057
16425
|
}
|
|
16058
|
-
/** Whether any capture is live (
|
|
16426
|
+
/** Whether any capture is live (Plugin Manager diagnostics). */
|
|
16059
16427
|
hasAny() {
|
|
16060
16428
|
for (const record of this.records.values()) if (!record.disposed) return true;
|
|
16061
16429
|
return false;
|
|
@@ -16067,7 +16435,7 @@ var UnstableInputRegistry = class {
|
|
|
16067
16435
|
revisionOf() {
|
|
16068
16436
|
return this.revision;
|
|
16069
16437
|
}
|
|
16070
|
-
/** An immutable snapshot (
|
|
16438
|
+
/** An immutable snapshot (Plugin Manager diagnostics). */
|
|
16071
16439
|
snapshot() {
|
|
16072
16440
|
return {
|
|
16073
16441
|
captures: [...this.records.values()].filter((record) => !record.disposed).sort((left, right) => left.priority - right.priority || left.id.localeCompare(right.id)).map((record) => ({
|
|
@@ -16180,7 +16548,7 @@ var CommandBridge = class {
|
|
|
16180
16548
|
if (this.contributions.has(spec.id)) throw new Error(`duplicate command contribution id "${spec.id}" (owner "${this.contributions.get(spec.id)?.owner}")`);
|
|
16181
16549
|
if (spec.name === "") throw new Error("command contribution name must not be empty");
|
|
16182
16550
|
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/
|
|
16551
|
+
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
16552
|
for (const hostName of this.staticCatalog) {
|
|
16185
16553
|
if (hostName === spec.name) return {
|
|
16186
16554
|
kind: "conflict",
|
|
@@ -16463,7 +16831,7 @@ var ThemeRegistry = class ThemeRegistry {
|
|
|
16463
16831
|
selectableValues() {
|
|
16464
16832
|
return [...this.records.values()].filter((record) => !record.disposed).map((record) => ThemeRegistry.selectableValueOf(record)).sort((left, right) => left.localeCompare(right));
|
|
16465
16833
|
}
|
|
16466
|
-
/** The display NAMES (sorted — diagnostics
|
|
16834
|
+
/** The display NAMES (sorted — diagnostics counts; never a
|
|
16467
16835
|
* selection identity). */
|
|
16468
16836
|
names() {
|
|
16469
16837
|
return [...this.records.values()].filter((record) => !record.disposed).map((record) => record.name).sort((left, right) => left.localeCompare(right));
|
|
@@ -16496,12 +16864,12 @@ var ThemeRegistry = class ThemeRegistry {
|
|
|
16496
16864
|
const record = this.byName(name);
|
|
16497
16865
|
return record === void 0 ? void 0 : ThemeRegistry.selectableValueOf(record);
|
|
16498
16866
|
}
|
|
16499
|
-
/** Whether any theme is live (
|
|
16867
|
+
/** Whether any theme is live (Plugin Manager diagnostics). */
|
|
16500
16868
|
hasAny() {
|
|
16501
16869
|
for (const record of this.records.values()) if (!record.disposed) return true;
|
|
16502
16870
|
return false;
|
|
16503
16871
|
}
|
|
16504
|
-
/** An immutable snapshot (
|
|
16872
|
+
/** An immutable snapshot (Plugin Manager diagnostics). */
|
|
16505
16873
|
snapshot() {
|
|
16506
16874
|
return {
|
|
16507
16875
|
themes: [...this.records.values()].filter((record) => !record.disposed).sort((left, right) => left.name.localeCompare(right.name)).map((record) => ({
|
|
@@ -16621,12 +16989,12 @@ var AutocompleteRegistry = class {
|
|
|
16621
16989
|
if (this.activeController === controller) this.activeController = void 0;
|
|
16622
16990
|
}
|
|
16623
16991
|
}
|
|
16624
|
-
/** Whether any provider is live (
|
|
16992
|
+
/** Whether any provider is live (Plugin Manager diagnostics). */
|
|
16625
16993
|
hasAny() {
|
|
16626
16994
|
for (const record of this.records.values()) if (!record.disposed) return true;
|
|
16627
16995
|
return false;
|
|
16628
16996
|
}
|
|
16629
|
-
/** An immutable snapshot (
|
|
16997
|
+
/** An immutable snapshot (Plugin Manager diagnostics). */
|
|
16630
16998
|
snapshot() {
|
|
16631
16999
|
return {
|
|
16632
17000
|
providers: [...this.records.values()].filter((record) => !record.disposed).sort((left, right) => left.id.localeCompare(right.id)).map((record) => ({
|
|
@@ -16649,6 +17017,8 @@ var AutocompleteRegistry = class {
|
|
|
16649
17017
|
var SettingsRegistry = class {
|
|
16650
17018
|
records = /* @__PURE__ */ new Map();
|
|
16651
17019
|
revision = 0;
|
|
17020
|
+
/** The per-registration token source (see {@link SettingRecord.registrationToken}). */
|
|
17021
|
+
nextRegistrationToken = 0;
|
|
16652
17022
|
onInvalidate;
|
|
16653
17023
|
constructor(onInvalidate = () => {}) {
|
|
16654
17024
|
this.onInvalidate = onInvalidate;
|
|
@@ -16662,24 +17032,30 @@ var SettingsRegistry = class {
|
|
|
16662
17032
|
register(contribution, owner) {
|
|
16663
17033
|
if (this.records.has(contribution.id)) throw new Error(`duplicate settings row id "${contribution.id}"`);
|
|
16664
17034
|
if (contribution.label === "") throw new Error("settings row label must not be empty");
|
|
16665
|
-
this.
|
|
17035
|
+
this.nextRegistrationToken += 1;
|
|
17036
|
+
const record = {
|
|
16666
17037
|
id: contribution.id,
|
|
16667
17038
|
label: contribution.label,
|
|
16668
17039
|
description: contribution.description,
|
|
16669
17040
|
values: contribution.values ?? [],
|
|
16670
17041
|
order: contribution.order ?? 0,
|
|
16671
17042
|
owner,
|
|
17043
|
+
registrationToken: this.nextRegistrationToken,
|
|
16672
17044
|
currentValue: contribution.currentValue,
|
|
16673
17045
|
applyEpoch: 0,
|
|
16674
17046
|
onChange: contribution.onChange,
|
|
16675
17047
|
disposed: false
|
|
16676
|
-
}
|
|
17048
|
+
};
|
|
17049
|
+
this.records.set(contribution.id, record);
|
|
16677
17050
|
this.revision += 1;
|
|
16678
17051
|
this.onInvalidate();
|
|
16679
17052
|
return {
|
|
16680
17053
|
id: contribution.id,
|
|
16681
|
-
setValue: (value) =>
|
|
16682
|
-
|
|
17054
|
+
setValue: (value) => {
|
|
17055
|
+
if (this.records.get(contribution.id) !== record) return;
|
|
17056
|
+
this.setValue(contribution.id, value);
|
|
17057
|
+
},
|
|
17058
|
+
dispose: () => this.disposeRecord(record)
|
|
16683
17059
|
};
|
|
16684
17060
|
}
|
|
16685
17061
|
/** Update one row's current value (live panel refresh). */
|
|
@@ -16693,15 +17069,21 @@ var SettingsRegistry = class {
|
|
|
16693
17069
|
/** Remove one row by id (idempotent). */
|
|
16694
17070
|
dispose(id) {
|
|
16695
17071
|
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();
|
|
17072
|
+
if (record !== void 0) this.disposeRecord(record);
|
|
16701
17073
|
}
|
|
16702
17074
|
/** Dispose every row owned by one fiber (owner unload). */
|
|
16703
17075
|
disposeOwner(owner) {
|
|
16704
|
-
for (const
|
|
17076
|
+
for (const record of [...this.records.values()]) if (record.owner === owner) this.disposeRecord(record);
|
|
17077
|
+
}
|
|
17078
|
+
/** Remove ONE record by its captured identity: a disposed record or an id
|
|
17079
|
+
* now owned by a NEWER registration is inert (a late fiber teardown must
|
|
17080
|
+
* never unload the replacement). */
|
|
17081
|
+
disposeRecord(record) {
|
|
17082
|
+
if (record.disposed || this.records.get(record.id) !== record) return;
|
|
17083
|
+
record.disposed = true;
|
|
17084
|
+
this.records.delete(record.id);
|
|
17085
|
+
this.revision += 1;
|
|
17086
|
+
this.onInvalidate();
|
|
16705
17087
|
}
|
|
16706
17088
|
/** The owning fiber of one setting id (the health bridge resolves
|
|
16707
17089
|
* owners here — the runner never passes owners around). */
|
|
@@ -16716,8 +17098,18 @@ var SettingsRegistry = class {
|
|
|
16716
17098
|
* plugin REJECTION (a real failure: record health, revert, notify) from
|
|
16717
17099
|
* a STALE or GONE result (a newer apply superseded this one, or the row
|
|
16718
17100
|
* was disposed mid-apply: the plugin never refused — recording a
|
|
16719
|
-
* failure would be a false alarm; the review's P2).
|
|
16720
|
-
|
|
17101
|
+
* failure would be a false alarm; the review's P2).
|
|
17102
|
+
*
|
|
17103
|
+
* C2-R6: `expectedRegistrationToken` (used ONLY by this concrete registry's
|
|
17104
|
+
* protected settings consumer) fences a confirmation to the registration it
|
|
17105
|
+
* was made for. A mismatched token is `gone` BEFORE any callback runs, so a
|
|
17106
|
+
* same-id replacement never receives an old choice; the original two-argument
|
|
17107
|
+
* call sites keep their semantics unchanged. */
|
|
17108
|
+
applyDetailed(id, value, expectedRegistrationToken) {
|
|
17109
|
+
if (expectedRegistrationToken !== void 0) {
|
|
17110
|
+
const record = this.records.get(id);
|
|
17111
|
+
if (record === void 0 || record.disposed || record.registrationToken !== expectedRegistrationToken) return Promise.resolve("gone");
|
|
17112
|
+
}
|
|
16721
17113
|
return this.applyInternal(id, value);
|
|
16722
17114
|
}
|
|
16723
17115
|
/** Apply a value change to one row; returns whether the change was
|
|
@@ -16753,12 +17145,12 @@ var SettingsRegistry = class {
|
|
|
16753
17145
|
this.onInvalidate();
|
|
16754
17146
|
return "accepted";
|
|
16755
17147
|
}
|
|
16756
|
-
/** Whether any row is live (
|
|
17148
|
+
/** Whether any row is live (Plugin Manager diagnostics). */
|
|
16757
17149
|
hasAny() {
|
|
16758
17150
|
for (const record of this.records.values()) if (!record.disposed) return true;
|
|
16759
17151
|
return false;
|
|
16760
17152
|
}
|
|
16761
|
-
/** An immutable snapshot (
|
|
17153
|
+
/** An immutable snapshot (Plugin Manager diagnostics). */
|
|
16762
17154
|
snapshot() {
|
|
16763
17155
|
return {
|
|
16764
17156
|
rows: this.rows().map((record) => ({
|
|
@@ -17120,7 +17512,7 @@ var KeybindingRegistry = class {
|
|
|
17120
17512
|
if (keyEquals(record.key, canonical)) return record.id;
|
|
17121
17513
|
}
|
|
17122
17514
|
}
|
|
17123
|
-
/** An immutable snapshot (
|
|
17515
|
+
/** An immutable snapshot (Plugin Manager diagnostics). */
|
|
17124
17516
|
snapshot() {
|
|
17125
17517
|
return {
|
|
17126
17518
|
bindings: [...this.records.values()].filter((record) => !record.disposed).sort((left, right) => left.id.localeCompare(right.id)).map((record) => ({
|
|
@@ -17133,7 +17525,7 @@ var KeybindingRegistry = class {
|
|
|
17133
17525
|
revision: this.revision
|
|
17134
17526
|
};
|
|
17135
17527
|
}
|
|
17136
|
-
/** Whether any binding is live (
|
|
17528
|
+
/** Whether any binding is live (Plugin Manager diagnostics). */
|
|
17137
17529
|
hasAny() {
|
|
17138
17530
|
for (const record of this.records.values()) if (!record.disposed) return true;
|
|
17139
17531
|
return false;
|
|
@@ -17301,7 +17693,7 @@ var RendererRegistry = class {
|
|
|
17301
17693
|
} catch {}
|
|
17302
17694
|
}
|
|
17303
17695
|
}
|
|
17304
|
-
/** Whether any renderer is live (
|
|
17696
|
+
/** Whether any renderer is live (Plugin Manager diagnostics). */
|
|
17305
17697
|
hasAny() {
|
|
17306
17698
|
for (const record of this.messageRenderers.values()) if (!record.disposed) return true;
|
|
17307
17699
|
for (const record of this.toolRenderers.values()) if (!record.disposed) return true;
|
|
@@ -17313,7 +17705,7 @@ var RendererRegistry = class {
|
|
|
17313
17705
|
revisionOf() {
|
|
17314
17706
|
return this.revision;
|
|
17315
17707
|
}
|
|
17316
|
-
/** An immutable snapshot (
|
|
17708
|
+
/** An immutable snapshot (Plugin Manager diagnostics). */
|
|
17317
17709
|
snapshot() {
|
|
17318
17710
|
return {
|
|
17319
17711
|
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 +17806,12 @@ var EditorRegistry = class {
|
|
|
17414
17806
|
}
|
|
17415
17807
|
return best;
|
|
17416
17808
|
}
|
|
17417
|
-
/** Whether any editor is live (
|
|
17809
|
+
/** Whether any editor is live (Plugin Manager diagnostics). */
|
|
17418
17810
|
hasAny() {
|
|
17419
17811
|
for (const record of this.records.values()) if (!record.disposed) return true;
|
|
17420
17812
|
return false;
|
|
17421
17813
|
}
|
|
17422
|
-
/** An immutable snapshot (
|
|
17814
|
+
/** An immutable snapshot (Plugin Manager diagnostics). */
|
|
17423
17815
|
snapshot() {
|
|
17424
17816
|
return {
|
|
17425
17817
|
editors: [...this.records.values()].filter((record) => !record.disposed).sort((left, right) => left.priority - right.priority || left.id.localeCompare(right.id)).map((record) => ({
|
|
@@ -17927,34 +18319,28 @@ var PiTuiExtensionServiceImpl = class PiTuiExtensionServiceImpl extends Service
|
|
|
17927
18319
|
const selectableValue = ThemeRegistry.selectableValue(stableOwner, contribution.id);
|
|
17928
18320
|
const handle = this.themes.register(contribution, owner, stableOwner);
|
|
17929
18321
|
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();
|
|
18322
|
+
let released = false;
|
|
18323
|
+
const cleanup = () => {
|
|
18324
|
+
if (released) return;
|
|
18325
|
+
released = true;
|
|
17942
18326
|
this.untrackRegistryHealth("theme", contribution.id, owner);
|
|
18327
|
+
handle.dispose();
|
|
17943
18328
|
this.themeUnloadedHook?.({
|
|
17944
18329
|
selectableValue,
|
|
17945
18330
|
name: contribution.name
|
|
17946
18331
|
});
|
|
18332
|
+
};
|
|
18333
|
+
let dispose;
|
|
18334
|
+
try {
|
|
18335
|
+
dispose = caller.fiber.effect(() => cleanup, "piTuiExtensions.registerTheme()");
|
|
18336
|
+
} catch (error) {
|
|
18337
|
+
cleanup();
|
|
17947
18338
|
throw error;
|
|
17948
18339
|
}
|
|
17949
18340
|
return {
|
|
17950
18341
|
id: handle.id,
|
|
17951
18342
|
dispose: () => {
|
|
17952
|
-
|
|
17953
|
-
this.untrackRegistryHealth("theme", contribution.id, owner);
|
|
17954
|
-
this.themeUnloadedHook?.({
|
|
17955
|
-
selectableValue,
|
|
17956
|
-
name: contribution.name
|
|
17957
|
-
});
|
|
18343
|
+
cleanup();
|
|
17958
18344
|
dispose();
|
|
17959
18345
|
}
|
|
17960
18346
|
};
|
|
@@ -18021,22 +18407,24 @@ var PiTuiExtensionServiceImpl = class PiTuiExtensionServiceImpl extends Service
|
|
|
18021
18407
|
this.recordOwnerEntry(owner, caller.fiber);
|
|
18022
18408
|
const handle = this.autocomplete.register(contribution, owner);
|
|
18023
18409
|
this.trackRegistryHealth("autocomplete", contribution.id, owner);
|
|
18410
|
+
let released = false;
|
|
18411
|
+
const cleanup = () => {
|
|
18412
|
+
if (released) return;
|
|
18413
|
+
released = true;
|
|
18414
|
+
this.untrackRegistryHealth("autocomplete", contribution.id, owner);
|
|
18415
|
+
handle.dispose();
|
|
18416
|
+
};
|
|
18024
18417
|
let dispose;
|
|
18025
18418
|
try {
|
|
18026
|
-
dispose = caller.fiber.effect(() => ()
|
|
18027
|
-
handle.dispose();
|
|
18028
|
-
this.untrackRegistryHealth("autocomplete", contribution.id, owner);
|
|
18029
|
-
}, "piTuiExtensions.registerAutocomplete()");
|
|
18419
|
+
dispose = caller.fiber.effect(() => cleanup, "piTuiExtensions.registerAutocomplete()");
|
|
18030
18420
|
} catch (error) {
|
|
18031
|
-
|
|
18032
|
-
this.untrackRegistryHealth("autocomplete", contribution.id, owner);
|
|
18421
|
+
cleanup();
|
|
18033
18422
|
throw error;
|
|
18034
18423
|
}
|
|
18035
18424
|
return {
|
|
18036
18425
|
id: handle.id,
|
|
18037
18426
|
dispose: () => {
|
|
18038
|
-
|
|
18039
|
-
this.untrackRegistryHealth("autocomplete", contribution.id, owner);
|
|
18427
|
+
cleanup();
|
|
18040
18428
|
dispose();
|
|
18041
18429
|
}
|
|
18042
18430
|
};
|
|
@@ -18051,23 +18439,25 @@ var PiTuiExtensionServiceImpl = class PiTuiExtensionServiceImpl extends Service
|
|
|
18051
18439
|
this.recordOwnerEntry(owner, caller.fiber);
|
|
18052
18440
|
const handle = this.settings.register(contribution, owner);
|
|
18053
18441
|
this.trackRegistryHealth("setting", contribution.id, owner);
|
|
18442
|
+
let released = false;
|
|
18443
|
+
const cleanup = () => {
|
|
18444
|
+
if (released) return;
|
|
18445
|
+
released = true;
|
|
18446
|
+
handle.dispose();
|
|
18447
|
+
this.untrackRegistryHealth("setting", contribution.id, owner);
|
|
18448
|
+
};
|
|
18054
18449
|
let dispose;
|
|
18055
18450
|
try {
|
|
18056
|
-
dispose = caller.fiber.effect(() => ()
|
|
18057
|
-
handle.dispose();
|
|
18058
|
-
this.untrackRegistryHealth("setting", contribution.id, owner);
|
|
18059
|
-
}, "piTuiExtensions.registerSetting()");
|
|
18451
|
+
dispose = caller.fiber.effect(() => cleanup, "piTuiExtensions.registerSetting()");
|
|
18060
18452
|
} catch (error) {
|
|
18061
|
-
|
|
18062
|
-
this.untrackRegistryHealth("setting", contribution.id, owner);
|
|
18453
|
+
cleanup();
|
|
18063
18454
|
throw error;
|
|
18064
18455
|
}
|
|
18065
18456
|
return {
|
|
18066
18457
|
id: handle.id,
|
|
18067
18458
|
setValue: (value) => handle.setValue(value),
|
|
18068
18459
|
dispose: () => {
|
|
18069
|
-
|
|
18070
|
-
this.untrackRegistryHealth("setting", contribution.id, owner);
|
|
18460
|
+
cleanup();
|
|
18071
18461
|
dispose();
|
|
18072
18462
|
}
|
|
18073
18463
|
};
|
|
@@ -18085,22 +18475,24 @@ var PiTuiExtensionServiceImpl = class PiTuiExtensionServiceImpl extends Service
|
|
|
18085
18475
|
this.recordOwnerEntry(owner, caller.fiber);
|
|
18086
18476
|
const handle = this.keybindings.register(contribution, owner);
|
|
18087
18477
|
this.trackRegistryHealth("keybinding", contribution.id, owner);
|
|
18478
|
+
let released = false;
|
|
18479
|
+
const cleanup = () => {
|
|
18480
|
+
if (released) return;
|
|
18481
|
+
released = true;
|
|
18482
|
+
this.untrackRegistryHealth("keybinding", contribution.id, owner);
|
|
18483
|
+
handle.dispose();
|
|
18484
|
+
};
|
|
18088
18485
|
let dispose;
|
|
18089
18486
|
try {
|
|
18090
|
-
dispose = caller.fiber.effect(() => ()
|
|
18091
|
-
handle.dispose();
|
|
18092
|
-
this.untrackRegistryHealth("keybinding", contribution.id, owner);
|
|
18093
|
-
}, "piTuiExtensions.registerKeybinding()");
|
|
18487
|
+
dispose = caller.fiber.effect(() => cleanup, "piTuiExtensions.registerKeybinding()");
|
|
18094
18488
|
} catch (error) {
|
|
18095
|
-
|
|
18096
|
-
this.untrackRegistryHealth("keybinding", contribution.id, owner);
|
|
18489
|
+
cleanup();
|
|
18097
18490
|
throw error;
|
|
18098
18491
|
}
|
|
18099
18492
|
return {
|
|
18100
18493
|
id: handle.id,
|
|
18101
18494
|
dispose: () => {
|
|
18102
|
-
|
|
18103
|
-
this.untrackRegistryHealth("keybinding", contribution.id, owner);
|
|
18495
|
+
cleanup();
|
|
18104
18496
|
dispose();
|
|
18105
18497
|
}
|
|
18106
18498
|
};
|
|
@@ -18115,23 +18507,25 @@ var PiTuiExtensionServiceImpl = class PiTuiExtensionServiceImpl extends Service
|
|
|
18115
18507
|
const owner = `${caller.fiber.uid}:${caller.fiber.name}`;
|
|
18116
18508
|
this.recordOwnerEntry(owner, caller.fiber);
|
|
18117
18509
|
const handle = this.renderers.registerMessageRenderer(contribution, owner);
|
|
18118
|
-
this.
|
|
18510
|
+
this.trackRegistryHealth("transcript.message.renderer", contribution.id, owner);
|
|
18511
|
+
let released = false;
|
|
18512
|
+
const cleanup = () => {
|
|
18513
|
+
if (released) return;
|
|
18514
|
+
released = true;
|
|
18515
|
+
this.untrackRegistryHealth("transcript.message.renderer", contribution.id, owner);
|
|
18516
|
+
handle.dispose();
|
|
18517
|
+
};
|
|
18119
18518
|
let dispose;
|
|
18120
18519
|
try {
|
|
18121
|
-
dispose = caller.fiber.effect(() => ()
|
|
18122
|
-
handle.dispose();
|
|
18123
|
-
this.ledger.untrackHealth("transcript.message.renderer", contribution.id, owner);
|
|
18124
|
-
}, "piTuiExtensions.registerMessageRenderer()");
|
|
18520
|
+
dispose = caller.fiber.effect(() => cleanup, "piTuiExtensions.registerMessageRenderer()");
|
|
18125
18521
|
} catch (error) {
|
|
18126
|
-
|
|
18127
|
-
this.ledger.untrackHealth("transcript.message.renderer", contribution.id, owner);
|
|
18522
|
+
cleanup();
|
|
18128
18523
|
throw error;
|
|
18129
18524
|
}
|
|
18130
18525
|
return {
|
|
18131
18526
|
id: handle.id,
|
|
18132
18527
|
dispose: () => {
|
|
18133
|
-
|
|
18134
|
-
this.ledger.untrackHealth("transcript.message.renderer", contribution.id, owner);
|
|
18528
|
+
cleanup();
|
|
18135
18529
|
dispose();
|
|
18136
18530
|
}
|
|
18137
18531
|
};
|
|
@@ -18145,23 +18539,25 @@ var PiTuiExtensionServiceImpl = class PiTuiExtensionServiceImpl extends Service
|
|
|
18145
18539
|
const owner = `${caller.fiber.uid}:${caller.fiber.name}`;
|
|
18146
18540
|
this.recordOwnerEntry(owner, caller.fiber);
|
|
18147
18541
|
const handle = this.renderers.registerToolRenderer(contribution, owner);
|
|
18148
|
-
this.
|
|
18542
|
+
this.trackRegistryHealth("transcript.tool.renderer", contribution.id, owner);
|
|
18543
|
+
let released = false;
|
|
18544
|
+
const cleanup = () => {
|
|
18545
|
+
if (released) return;
|
|
18546
|
+
released = true;
|
|
18547
|
+
this.untrackRegistryHealth("transcript.tool.renderer", contribution.id, owner);
|
|
18548
|
+
handle.dispose();
|
|
18549
|
+
};
|
|
18149
18550
|
let dispose;
|
|
18150
18551
|
try {
|
|
18151
|
-
dispose = caller.fiber.effect(() => ()
|
|
18152
|
-
handle.dispose();
|
|
18153
|
-
this.ledger.untrackHealth("transcript.tool.renderer", contribution.id, owner);
|
|
18154
|
-
}, "piTuiExtensions.registerToolRenderer()");
|
|
18552
|
+
dispose = caller.fiber.effect(() => cleanup, "piTuiExtensions.registerToolRenderer()");
|
|
18155
18553
|
} catch (error) {
|
|
18156
|
-
|
|
18157
|
-
this.ledger.untrackHealth("transcript.tool.renderer", contribution.id, owner);
|
|
18554
|
+
cleanup();
|
|
18158
18555
|
throw error;
|
|
18159
18556
|
}
|
|
18160
18557
|
return {
|
|
18161
18558
|
id: handle.id,
|
|
18162
18559
|
dispose: () => {
|
|
18163
|
-
|
|
18164
|
-
this.ledger.untrackHealth("transcript.tool.renderer", contribution.id, owner);
|
|
18560
|
+
cleanup();
|
|
18165
18561
|
dispose();
|
|
18166
18562
|
}
|
|
18167
18563
|
};
|
|
@@ -18239,22 +18635,24 @@ var PiTuiExtensionServiceImpl = class PiTuiExtensionServiceImpl extends Service
|
|
|
18239
18635
|
this.recordOwnerEntry(owner, caller.fiber);
|
|
18240
18636
|
const handle = this.editors.register(contribution, owner);
|
|
18241
18637
|
this.trackRegistryHealth("editor", contribution.id, owner);
|
|
18638
|
+
let released = false;
|
|
18639
|
+
const cleanup = () => {
|
|
18640
|
+
if (released) return;
|
|
18641
|
+
released = true;
|
|
18642
|
+
this.untrackRegistryHealth("editor", contribution.id, owner);
|
|
18643
|
+
handle.dispose();
|
|
18644
|
+
};
|
|
18242
18645
|
let dispose;
|
|
18243
18646
|
try {
|
|
18244
|
-
dispose = caller.fiber.effect(() => ()
|
|
18245
|
-
handle.dispose();
|
|
18246
|
-
this.untrackRegistryHealth("editor", contribution.id, owner);
|
|
18247
|
-
}, "piTuiExtensions.registerEditor()");
|
|
18647
|
+
dispose = caller.fiber.effect(() => cleanup, "piTuiExtensions.registerEditor()");
|
|
18248
18648
|
} catch (error) {
|
|
18249
|
-
|
|
18250
|
-
this.untrackRegistryHealth("editor", contribution.id, owner);
|
|
18649
|
+
cleanup();
|
|
18251
18650
|
throw error;
|
|
18252
18651
|
}
|
|
18253
18652
|
return {
|
|
18254
18653
|
id: handle.id,
|
|
18255
18654
|
dispose: () => {
|
|
18256
|
-
|
|
18257
|
-
this.untrackRegistryHealth("editor", contribution.id, owner);
|
|
18655
|
+
cleanup();
|
|
18258
18656
|
dispose();
|
|
18259
18657
|
}
|
|
18260
18658
|
};
|
|
@@ -18824,4 +19222,4 @@ function apply(ctx) {
|
|
|
18824
19222
|
new PiTuiExtensionServiceImpl(ctx, packageVersion(), () => {}, HOST_COMMAND_CATALOG);
|
|
18825
19223
|
}
|
|
18826
19224
|
//#endregion
|
|
18827
|
-
export {
|
|
19225
|
+
export { fuzzyFilter as $, isValidKeyId as A, MouseRegion as B, isTerminalAmbiguousKeyId as C, canonicalizeKeyId as D, VIEWER_BLOCKED_PARENT_ACTIONS as E, HStack as F, Text as G, ScrollView as H, Image as I, VStack as J, TuiAltScreen as K, Input as L, CombinedAutocompleteProvider as M, Container as N, isRuntimeBindableKeyId as O, Editor as P, findAltScreenSearchMatches as Q, Key as R, isPhysicalEscapeAction as S, APP_KEYBINDINGS as T, SettingsList as U, ProcessTerminal as V, Spacer as W, decodePrintableKey as X, decodeKittyPrintable as Y, dispatchMouseEvent as Z, normalizeSkillInvocation as _, parseFooterLayout as _t, PI_TUI_EXTENSIONS_SERVICE as a, isFocusable as at, DEFAULT_LEADER_TIMEOUT_MS as b, InvalidateBatcher as c, matchesKey as ct, SESSIONLESS_COMMANDS as d, sliceByColumn as dt, getCapabilities as et, classifyCommandLine as f, stripTerminalSequences as ft, isPlainExitPrompt as g, isFooterLayout as gt, isLocalCommandLine as h, wrapTextWithAnsi as ht, name as i, imageFallback as it, AltScreenSearchIndex as j, isTextProducingKeyId as k, HOST_COMMAND_CATALOG as l, parseKey as lt, isBareCommandLine as m, visibleWidth as mt, extensions_exports as n, getGraphemeSegmenter as nt, API_VERSION as o, isKeyRelease as ot, commandIsLocalForAttachments as p, truncateToWidth as pt, TuiMainScreen as q, inject as r, getKeybindings as rt, describeKey as s, isKeyRepeat as st, apply as t, getCellDimensions as tt, LOCAL_COMMANDS as u, registerKittyImageMetadata as ut, shouldConsumeAdvertisedMiss as v, resolveCommandFooterFallback as vt, parseUserKeybindings as w, isEditorSubmitPreSubmitKey as x, normalizeInputEvent as y, stripControlChars as yt, Markdown as z };
|