@xmoon76/dsh-pi-tui 0.5.6 → 0.5.8
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/LICENSE +33 -0
- package/README.en.md +103 -814
- package/README.md +102 -711
- package/cordis.patch.yml +186 -0
- package/dist/acp-preferences.d.mts +29 -0
- package/dist/acp-preferences.mjs +15 -0
- package/dist/{bootstrap-DQ4YPL-7.mjs → bootstrap-CMIjGyuk.mjs} +33515 -7587
- package/dist/builtins.mjs +3 -3
- package/dist/{client-bootstrap-Cr1JCaF5.mjs → client-bootstrap-BjGPc-DM.mjs} +4637 -492
- package/dist/client-extension-loader-probe-BUw7q8bJ.mjs +119 -0
- package/dist/command-trust-DChWUamk.mjs +406 -0
- package/dist/daemon-launcher-Dult7Jxv.mjs +1932 -0
- package/dist/daemon-launcher.d.mts +159 -0
- package/dist/daemon-launcher.mjs +2 -0
- package/dist/diagnostics-D5jwc-q1.d.mts +11 -0
- package/dist/{dist-CIsR7cz4.mjs → dist-BFgC-5tL.mjs} +938 -487
- package/dist/entry-control-DjNsE3I0.mjs +190 -0
- package/dist/extension/advanced.d.mts +1 -1
- package/dist/extension/unstable.d.mts +1 -1
- package/dist/extension-config-probe-BDdvutkG.mjs +95 -0
- package/dist/extension-config.d.mts +29 -0
- package/dist/extension-config.mjs +22 -0
- package/dist/{extensions-Bp0L37lP.mjs → extensions-B4uLpSTv.mjs} +1109 -100
- package/dist/{extensions-Bte3XOt5.d.mts → extensions-C8eAM0gX.d.mts} +1 -1
- package/dist/extensions.d.mts +2 -2
- package/dist/extensions.mjs +1 -1
- package/dist/{host-bootstrap-DilsvA6f.mjs → host-bootstrap-MVxks641.mjs} +129 -24
- package/dist/{host-foundation-probe--5jtvHVe.mjs → host-foundation-probe-DMNTmNrH.mjs} +2 -2
- package/dist/host-runtime.d.mts +11 -5
- package/dist/host-runtime.mjs +4171 -920
- package/dist/index.d.mts +86 -174
- package/dist/index.mjs +38087 -9967
- package/dist/local-acp-listener-B65J0Bx4.mjs +3115 -0
- package/dist/local-client.mjs +1158 -59
- package/dist/local-daemon-control-C14q9KnD.mjs +1588 -0
- package/dist/local-daemon-control-TCnERL7n.mjs +1424 -0
- package/dist/local-discovery-DOSsCh9q.mjs +2883 -0
- package/dist/local-discovery-egN4_gsQ.mjs +2 -0
- package/dist/local-discovery-uOBfFq5j.mjs +2764 -0
- package/dist/local-host.mjs +812 -89
- package/dist/local-profile-daemon-admin-BmQSdzT0.mjs +210 -0
- package/dist/local-scope-DamiMqPd.mjs +1340 -0
- package/dist/{local-transport-BVwFYq_Y.mjs → local-transport-Iwo0mtu3.mjs} +313 -38
- package/dist/local-web-control-DMrjwCkl.mjs +454 -0
- package/dist/local-workspace-object-D06GL0UO.mjs +248 -0
- package/dist/native/darwin/prebuilds/darwin-arm64/darwin-platform.node +0 -0
- package/dist/native/darwin/prebuilds/darwin-x64/darwin-platform.node +0 -0
- package/dist/open-CmOBxSjN.mjs +63 -0
- package/dist/persisted-setting-probe-DWZLtWoB.mjs +145 -0
- package/dist/pi-tui-acp-access-contract-BdLwduU6.mjs +75 -0
- package/dist/pi-tui-remote-contribution-Do8ECrUy.mjs +1492 -0
- package/dist/pi-tui-terminal-progress-contract-B3RoEzjK.mjs +146 -0
- package/dist/preferences.d.mts +17 -0
- package/dist/preferences.mjs +20 -0
- package/dist/preset-BcWqOtY7.mjs +46 -0
- package/dist/profile-preferences-migration-BfUGdPZx.mjs +500 -0
- package/dist/profile-preferences-migration-CThz4rHH.mjs +2 -0
- package/dist/prompt-sections-DUKmWb8g.mjs +2232 -0
- package/dist/prompt-sections-DXmjB58H.mjs +634 -0
- package/dist/{public-types-Dgf1bDke.d.mts → public-types-C1YgFtwC.d.mts} +56 -3
- package/dist/row-id-DPbyt9Nn.mjs +24 -0
- package/dist/{runtime-status-Cj1nFOdS.mjs → runtime-status-v-FTnWcD.mjs} +49 -3
- package/dist/schema-BTGYn8_X.d.mts +54 -0
- package/dist/schema-qE_P09zJ.mjs +124 -0
- package/dist/{session-BKGXyh80.mjs → session-C6tSs86s.mjs} +9672 -7270
- package/dist/{session-CPt_U8_f.mjs → session-CstInGIA.mjs} +9674 -7273
- package/dist/startup-CarQxWwi.d.mts +213 -0
- package/dist/{startup-7BYWuvBU.mjs → startup-EG5UqIcd.mjs} +341 -26
- package/dist/startup.d.mts +2 -99
- package/dist/startup.mjs +2 -2
- package/dist/{terminal-progress-source-DrqQhtT8.mjs → terminal-progress-source-CpfpQO_h.mjs} +2038 -67
- package/dist/{pasted-path-range-CMnxuGPx.mjs → transcript-view-C1YtJ49Y.mjs} +11590 -6718
- package/dist/{pasted-path-range-r6qzV_tC.mjs → transcript-view-CuJYWkhp.mjs} +12296 -6923
- package/dist/version-B9yC7bBk.mjs +83 -0
- package/dist/visual-tools.d.mts +1 -1
- package/dist/visual-tools.mjs +1 -1
- package/dist/web-preferences.d.mts +1 -1
- package/dist/{web-roster-CjqnUXNk.mjs → web-roster-Dis7BhrA.mjs} +63 -3
- package/generated/dsh-presets/cordis.patch.yml +4 -2
- package/generated/dsh-presets/ptc.patch.yml +4 -0
- package/generated/dsh-presets/standard.patch.yml +7 -0
- package/generated/web-access/cordis.patch.yml +239 -0
- package/package.json +217 -170
- package/dist/entry-control-DnduyDiw.mjs +0 -92
- package/dist/local-discovery-C9VMjc0K.mjs +0 -759
- package/dist/local-discovery-CDaQHA_R.mjs +0 -2
- package/dist/pi-tui-remote-contribution-B0EQsP0N.mjs +0 -85
- package/dist/pi-tui-terminal-progress-contract-CdBH9j78.mjs +0 -70
- package/dist/pi-tui-terminal-progress-contract-MLXZ-i3t.mjs +0 -905
- package/dist/version-a-eF-QER.mjs +0 -80
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { t as parseFooterCommandConfig } from "./command-trust-DChWUamk.mjs";
|
|
1
2
|
import { createRequire } from "node:module";
|
|
2
3
|
import * as fs from "node:fs";
|
|
3
4
|
import * as path from "node:path";
|
|
4
5
|
import { dirname, isAbsolute, join } from "node:path";
|
|
5
6
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
6
|
-
import { execSync } from "node:child_process";
|
|
7
7
|
import * as os from "node:os";
|
|
8
8
|
import { homedir } from "node:os";
|
|
9
|
+
import { execSync } from "node:child_process";
|
|
9
10
|
import { Marked, Tokenizer } from "marked";
|
|
10
11
|
import { spawn as spawn$1 } from "child_process";
|
|
11
12
|
import { readdirSync as readdirSync$1, statSync as statSync$1 } from "fs";
|
|
@@ -15,411 +16,6 @@ import { eastAsianWidth } from "get-east-asian-width";
|
|
|
15
16
|
import { performance as performance$1 } from "node:perf_hooks";
|
|
16
17
|
import markedCjkFriendly from "marked-cjk-friendly";
|
|
17
18
|
import { EventEmitter } from "events";
|
|
18
|
-
//#region src/domain/footer/layout.ts
|
|
19
|
-
/** The per-id default `Hide in TSP` value (Owner-frozen): the three items
|
|
20
|
-
* that a capable TSP composer already carries are hidden by default; every
|
|
21
|
-
* other item keeps the historical TSP behavior. This is the EDITOR default
|
|
22
|
-
* (a capability shortage must never turn the editor's On into Off). */
|
|
23
|
-
function defaultHideInTsp(id) {
|
|
24
|
-
return id === "permission-preset" || id === "model" || id === "reasoning";
|
|
25
|
-
}
|
|
26
|
-
/** The ONE TSP effective-visibility decision for one placement. An explicit
|
|
27
|
-
* user boolean always wins; otherwise the three default-On ids hide only
|
|
28
|
-
* when their corresponding composer control is actually available (so the
|
|
29
|
-
* permission state never disappears on an old client without the control),
|
|
30
|
-
* and every other id stays visible. */
|
|
31
|
-
function hideFooterRefInTsp(ref, affordances) {
|
|
32
|
-
if (ref.hideInTsp !== void 0) return ref.hideInTsp;
|
|
33
|
-
if (!defaultHideInTsp(ref.id)) return false;
|
|
34
|
-
switch (ref.id) {
|
|
35
|
-
case "permission-preset": return affordances.permission;
|
|
36
|
-
case "model": return affordances.model;
|
|
37
|
-
case "reasoning": return affordances.reasoning;
|
|
38
|
-
default: return false;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
/** The semantic tone vocabulary a layout may reference. */
|
|
42
|
-
const TONES$1 = /* @__PURE__ */ new Set([
|
|
43
|
-
"primary",
|
|
44
|
-
"accent",
|
|
45
|
-
"text",
|
|
46
|
-
"textStrong",
|
|
47
|
-
"textDim",
|
|
48
|
-
"textMuted",
|
|
49
|
-
"border",
|
|
50
|
-
"success",
|
|
51
|
-
"warning",
|
|
52
|
-
"error",
|
|
53
|
-
"roleUser",
|
|
54
|
-
"shellMode"
|
|
55
|
-
]);
|
|
56
|
-
const MAX_ROWS = 2;
|
|
57
|
-
const MAX_SEPARATOR_LENGTH = 8;
|
|
58
|
-
const MAX_PREFIX_SUFFIX_LENGTH = 16;
|
|
59
|
-
const MAX_IMPORTANCE = 1e3;
|
|
60
|
-
function isRecord(value) {
|
|
61
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
62
|
-
}
|
|
63
|
-
/** Terminal control characters (C0, DEL and C1): a layout is display
|
|
64
|
-
* decoration — ESC/OSC/CSI sequences must never reach the terminal through
|
|
65
|
-
* an id/prefix/suffix/separator (a project-supplied layout could otherwise
|
|
66
|
-
* inject title/clipboard/cursor/screen sequences — including through the
|
|
67
|
-
* configurator's unknown-id label fallback, which renders a raw id). */
|
|
68
|
-
const CONTROL_CHARS$1 = /[\u0000-\u001f\u007f-\u009f]/;
|
|
69
|
-
/** The GLOBAL form, used only for stripping (a non-global replace removes
|
|
70
|
-
* just the FIRST control character — the `.test()` callers above must
|
|
71
|
-
* keep the non-global regex: a global one is stateful across calls). */
|
|
72
|
-
const CONTROL_CHARS_GLOBAL = /[\u0000-\u001f\u007f-\u009f]/g;
|
|
73
|
-
/** Strip EVERY terminal control character from display text (the
|
|
74
|
-
* configurator's unknown-item label fallback: a raw id must never carry
|
|
75
|
-
* ESC/OSC/C0 into the panel — the parser already rejects such ids, this
|
|
76
|
-
* is defense in depth for any other id source). */
|
|
77
|
-
function stripControlChars(text) {
|
|
78
|
-
return text.replace(CONTROL_CHARS_GLOBAL, "");
|
|
79
|
-
}
|
|
80
|
-
/** Narrow a parse result onto the error arm (the ref type has no kind). */
|
|
81
|
-
function isError(value) {
|
|
82
|
-
return value.kind === "error";
|
|
83
|
-
}
|
|
84
|
-
function parseItemRef(input, index) {
|
|
85
|
-
if (!isRecord(input)) return {
|
|
86
|
-
kind: "error",
|
|
87
|
-
message: `item ${index}: expected an object`
|
|
88
|
-
};
|
|
89
|
-
const id = input.id;
|
|
90
|
-
if (typeof id !== "string" || id.trim() === "") return {
|
|
91
|
-
kind: "error",
|
|
92
|
-
message: `item ${index}: id must be a non-empty string`
|
|
93
|
-
};
|
|
94
|
-
if (CONTROL_CHARS$1.test(id)) return {
|
|
95
|
-
kind: "error",
|
|
96
|
-
message: `item ${index}: id must not contain terminal control characters`
|
|
97
|
-
};
|
|
98
|
-
const ref = { id };
|
|
99
|
-
if (input.format !== void 0) {
|
|
100
|
-
if (typeof input.format !== "string") return {
|
|
101
|
-
kind: "error",
|
|
102
|
-
message: `item ${index}: format must be a string`
|
|
103
|
-
};
|
|
104
|
-
ref.format = input.format;
|
|
105
|
-
}
|
|
106
|
-
if (input.tone !== void 0) {
|
|
107
|
-
if (typeof input.tone !== "string" || input.tone !== "auto" && !TONES$1.has(input.tone)) return {
|
|
108
|
-
kind: "error",
|
|
109
|
-
message: `item ${index}: unknown tone "${String(input.tone)}"`
|
|
110
|
-
};
|
|
111
|
-
ref.tone = input.tone;
|
|
112
|
-
}
|
|
113
|
-
if (input.prefix !== void 0) {
|
|
114
|
-
if (typeof input.prefix !== "string" || input.prefix.length > MAX_PREFIX_SUFFIX_LENGTH) return {
|
|
115
|
-
kind: "error",
|
|
116
|
-
message: `item ${index}: prefix must be a string of at most ${MAX_PREFIX_SUFFIX_LENGTH} chars`
|
|
117
|
-
};
|
|
118
|
-
if (CONTROL_CHARS$1.test(input.prefix)) return {
|
|
119
|
-
kind: "error",
|
|
120
|
-
message: `item ${index}: prefix must not contain terminal control characters`
|
|
121
|
-
};
|
|
122
|
-
ref.prefix = input.prefix;
|
|
123
|
-
}
|
|
124
|
-
if (input.suffix !== void 0) {
|
|
125
|
-
if (typeof input.suffix !== "string" || input.suffix.length > MAX_PREFIX_SUFFIX_LENGTH) return {
|
|
126
|
-
kind: "error",
|
|
127
|
-
message: `item ${index}: suffix must be a string of at most ${MAX_PREFIX_SUFFIX_LENGTH} chars`
|
|
128
|
-
};
|
|
129
|
-
if (CONTROL_CHARS$1.test(input.suffix)) return {
|
|
130
|
-
kind: "error",
|
|
131
|
-
message: `item ${index}: suffix must not contain terminal control characters`
|
|
132
|
-
};
|
|
133
|
-
ref.suffix = input.suffix;
|
|
134
|
-
}
|
|
135
|
-
if (input.importance !== void 0) {
|
|
136
|
-
if (typeof input.importance !== "number" || !Number.isFinite(input.importance) || input.importance < 0 || input.importance > MAX_IMPORTANCE) return {
|
|
137
|
-
kind: "error",
|
|
138
|
-
message: `item ${index}: importance must be a number in 0..${MAX_IMPORTANCE}`
|
|
139
|
-
};
|
|
140
|
-
ref.importance = input.importance;
|
|
141
|
-
}
|
|
142
|
-
if (input.hideInTsp !== void 0) {
|
|
143
|
-
if (typeof input.hideInTsp !== "boolean") return {
|
|
144
|
-
kind: "error",
|
|
145
|
-
message: `item ${index}: hideInTsp must be a boolean`
|
|
146
|
-
};
|
|
147
|
-
ref.hideInTsp = input.hideInTsp;
|
|
148
|
-
}
|
|
149
|
-
return ref;
|
|
150
|
-
}
|
|
151
|
-
function parseRow(input, index) {
|
|
152
|
-
if (!isRecord(input)) return {
|
|
153
|
-
kind: "error",
|
|
154
|
-
message: `row ${index}: expected an object`
|
|
155
|
-
};
|
|
156
|
-
const leftInput = input.left === void 0 ? [] : input.left;
|
|
157
|
-
const rightInput = input.right === void 0 ? [] : input.right;
|
|
158
|
-
if (!Array.isArray(leftInput) || !Array.isArray(rightInput)) return {
|
|
159
|
-
kind: "error",
|
|
160
|
-
message: `row ${index}: left/right must be arrays`
|
|
161
|
-
};
|
|
162
|
-
if (leftInput.length + rightInput.length > 32) return {
|
|
163
|
-
kind: "error",
|
|
164
|
-
message: `row ${index}: more than 32 items`
|
|
165
|
-
};
|
|
166
|
-
const left = [];
|
|
167
|
-
for (let i = 0; i < leftInput.length; i += 1) {
|
|
168
|
-
const item = parseItemRef(leftInput[i], i);
|
|
169
|
-
if (isError(item)) return item;
|
|
170
|
-
left.push(item);
|
|
171
|
-
}
|
|
172
|
-
const right = [];
|
|
173
|
-
for (let i = 0; i < rightInput.length; i += 1) {
|
|
174
|
-
const item = parseItemRef(rightInput[i], i);
|
|
175
|
-
if (isError(item)) return item;
|
|
176
|
-
right.push(item);
|
|
177
|
-
}
|
|
178
|
-
const row = {
|
|
179
|
-
left,
|
|
180
|
-
right
|
|
181
|
-
};
|
|
182
|
-
if (input.separator !== void 0) {
|
|
183
|
-
if (!isRecord(input.separator)) return {
|
|
184
|
-
kind: "error",
|
|
185
|
-
message: `row ${index}: separator must be an object`
|
|
186
|
-
};
|
|
187
|
-
const text = input.separator.text;
|
|
188
|
-
if (text === void 0) {} else if (typeof text !== "string" || text.length > MAX_SEPARATOR_LENGTH) return {
|
|
189
|
-
kind: "error",
|
|
190
|
-
message: `row ${index}: separator text must be a string of at most ${MAX_SEPARATOR_LENGTH} chars`
|
|
191
|
-
};
|
|
192
|
-
else {
|
|
193
|
-
if (CONTROL_CHARS$1.test(text)) return {
|
|
194
|
-
kind: "error",
|
|
195
|
-
message: `row ${index}: separator text must not contain terminal control characters`
|
|
196
|
-
};
|
|
197
|
-
row.separator = { text };
|
|
198
|
-
if (input.separator.tone !== void 0) {
|
|
199
|
-
if (typeof input.separator.tone !== "string" || !TONES$1.has(input.separator.tone)) return {
|
|
200
|
-
kind: "error",
|
|
201
|
-
message: `row ${index}: unknown separator tone "${String(input.separator.tone)}"`
|
|
202
|
-
};
|
|
203
|
-
row.separator.tone = input.separator.tone;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
return row;
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Parse and validate a persisted footerLayout value.
|
|
211
|
-
* @param input - the raw settings value (unknown — never trusted).
|
|
212
|
-
* @returns the validated layout or a fail-soft error.
|
|
213
|
-
*/
|
|
214
|
-
function parseFooterLayout(input) {
|
|
215
|
-
if (!isRecord(input)) return {
|
|
216
|
-
kind: "error",
|
|
217
|
-
message: "footerLayout must be an object"
|
|
218
|
-
};
|
|
219
|
-
if (input.schemaVersion !== 1) return {
|
|
220
|
-
kind: "error",
|
|
221
|
-
message: `unsupported footerLayout schemaVersion ${String(input.schemaVersion)}`
|
|
222
|
-
};
|
|
223
|
-
if (!Array.isArray(input.rows)) return {
|
|
224
|
-
kind: "error",
|
|
225
|
-
message: "footerLayout.rows must be an array"
|
|
226
|
-
};
|
|
227
|
-
if (input.rows.length < 1 || input.rows.length > MAX_ROWS) return {
|
|
228
|
-
kind: "error",
|
|
229
|
-
message: `footerLayout must have 1..${MAX_ROWS} rows`
|
|
230
|
-
};
|
|
231
|
-
const rows = [];
|
|
232
|
-
for (let i = 0; i < input.rows.length; i += 1) {
|
|
233
|
-
const row = parseRow(input.rows[i], i);
|
|
234
|
-
if (isError(row)) return row;
|
|
235
|
-
rows.push(row);
|
|
236
|
-
}
|
|
237
|
-
return {
|
|
238
|
-
schemaVersion: 1,
|
|
239
|
-
rows
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
/** Whether a parsed value is a valid layout (not an error). */
|
|
243
|
-
function isFooterLayout(value) {
|
|
244
|
-
return !isError(value);
|
|
245
|
-
}
|
|
246
|
-
/** M5: resolve the command surface's native fallback from the PERSISTED
|
|
247
|
-
* document. The resolution is explicit and restart-proof: 'compact' keeps
|
|
248
|
-
* the compact preset; 'custom' uses the persisted custom layout (an
|
|
249
|
-
* invalid one degrades to the builtin default — the APPLY side then
|
|
250
|
-
* resets to the full preset); 'default' (or an absent field — existing
|
|
251
|
-
* documents predate the field) resolves to the builtin default, which the
|
|
252
|
-
* apply side restores EXPLICITLY (never "whatever the memory holds").
|
|
253
|
-
* Never reads in-memory state. */
|
|
254
|
-
function resolveCommandFooterFallback(doc) {
|
|
255
|
-
if (doc?.footerFallbackMode === "compact") return {
|
|
256
|
-
mode: "compact",
|
|
257
|
-
layout: void 0
|
|
258
|
-
};
|
|
259
|
-
if (doc?.footerFallbackMode === "custom") {
|
|
260
|
-
const parsed = parseFooterLayout(doc.footerLayout);
|
|
261
|
-
return {
|
|
262
|
-
mode: "custom",
|
|
263
|
-
layout: isFooterLayout(parsed) ? parsed : void 0
|
|
264
|
-
};
|
|
265
|
-
}
|
|
266
|
-
return {
|
|
267
|
-
mode: "default",
|
|
268
|
-
layout: void 0
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
//#endregion
|
|
272
|
-
//#region src/domain/footer/command-config.ts
|
|
273
|
-
/** The timeout ceiling. */
|
|
274
|
-
const MAX_COMMAND_TIMEOUT_MS = 1e3;
|
|
275
|
-
/** The minimum refresh interval (plan §17.7). */
|
|
276
|
-
const MIN_COMMAND_REFRESH_MS = 1e3;
|
|
277
|
-
//#endregion
|
|
278
|
-
//#region src/domain/footer/command-trust.ts
|
|
279
|
-
/**
|
|
280
|
-
* The footer command TRUST GATE (plan §17.4): a repository/project config
|
|
281
|
-
* must NEVER silently trigger arbitrary shell execution. The command is
|
|
282
|
-
* read ONLY from the settings descriptor's USER layer (the stored
|
|
283
|
-
* document's user section) — never from the merged/resolved value, which
|
|
284
|
-
* a project layer could influence. When the user layer cannot prove the
|
|
285
|
-
* command, command mode is disabled and the native layout applies.
|
|
286
|
-
* @module @xmoon76/dsh-pi-tui/domain/footer/command-trust
|
|
287
|
-
*/
|
|
288
|
-
/** Validate the persisted footerCommand value (bounds per plan §17.3). */
|
|
289
|
-
function parseFooterCommandConfig(input) {
|
|
290
|
-
if (typeof input !== "object" || input === null) return void 0;
|
|
291
|
-
const raw = input;
|
|
292
|
-
if (raw.schemaVersion !== 1) return void 0;
|
|
293
|
-
if (typeof raw.command !== "string" || raw.command.trim() === "") return void 0;
|
|
294
|
-
if (/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/.test(raw.command)) return void 0;
|
|
295
|
-
const timeoutMs = raw.timeoutMs === void 0 ? 300 : typeof raw.timeoutMs === "number" && Number.isFinite(raw.timeoutMs) ? Math.min(Math.max(1, raw.timeoutMs), MAX_COMMAND_TIMEOUT_MS) : 300;
|
|
296
|
-
const refreshIntervalMs = raw.refreshIntervalMs === void 0 ? MIN_COMMAND_REFRESH_MS : typeof raw.refreshIntervalMs === "number" && Number.isFinite(raw.refreshIntervalMs) ? Math.max(MIN_COMMAND_REFRESH_MS, raw.refreshIntervalMs) : MIN_COMMAND_REFRESH_MS;
|
|
297
|
-
const maxRows = raw.maxRows === void 0 ? 1 : typeof raw.maxRows === "number" && Number.isFinite(raw.maxRows) ? Math.min(Math.max(1, Math.floor(raw.maxRows)), 2) : 1;
|
|
298
|
-
return {
|
|
299
|
-
command: raw.command,
|
|
300
|
-
timeoutMs,
|
|
301
|
-
refreshIntervalMs,
|
|
302
|
-
maxRows
|
|
303
|
-
};
|
|
304
|
-
}
|
|
305
|
-
/**
|
|
306
|
-
* Resolve the TRUSTED command config: the footerCommand value must be
|
|
307
|
-
* present in the USER layer of the tui-app settings descriptor. A
|
|
308
|
-
* merged/project-supplied value is refused (undefined = command mode
|
|
309
|
-
* disabled, native fallback, diagnostic warning).
|
|
310
|
-
* @param descriptors - the settings provider's describe() output.
|
|
311
|
-
* @param namespace - the tui-app settings/profile Config namespace value.
|
|
312
|
-
* @returns the validated config, or undefined when untrusted/invalid.
|
|
313
|
-
*/
|
|
314
|
-
function resolveTrustedFooterCommand(descriptors, namespace) {
|
|
315
|
-
if (descriptors === void 0) return void 0;
|
|
316
|
-
const descriptor = descriptors.find((entry) => entry.ns === namespace);
|
|
317
|
-
if (descriptor === void 0) return void 0;
|
|
318
|
-
const user = descriptor.user;
|
|
319
|
-
if (typeof user !== "object" || user === null) return void 0;
|
|
320
|
-
const raw = user.footerCommand;
|
|
321
|
-
return parseFooterCommandConfig(raw);
|
|
322
|
-
}
|
|
323
|
-
/**
|
|
324
|
-
* Resolve the USER layer's declared footer mode. Command mode must be
|
|
325
|
-
* user-layer-owned as well: a project can flip the MERGED `footer:
|
|
326
|
-
* command`, but the gate never lets a project config silently trigger the
|
|
327
|
-
* user's command — the user layer must declare the command mode too.
|
|
328
|
-
* @returns the user layer's footer value, or undefined when absent.
|
|
329
|
-
*/
|
|
330
|
-
function resolveUserLayerFooterMode(descriptors, namespace) {
|
|
331
|
-
if (descriptors === void 0) return void 0;
|
|
332
|
-
const descriptor = descriptors.find((entry) => entry.ns === namespace);
|
|
333
|
-
if (descriptor === void 0) return void 0;
|
|
334
|
-
const user = descriptor.user;
|
|
335
|
-
if (typeof user !== "object" || user === null) return void 0;
|
|
336
|
-
const mode = user.footer;
|
|
337
|
-
return typeof mode === "string" ? mode : void 0;
|
|
338
|
-
}
|
|
339
|
-
/**
|
|
340
|
-
* Resolve the USER layer's declared custom layout (PR D activation trust):
|
|
341
|
-
* the layout whose refs MAY authorize custom command items — but only
|
|
342
|
-
* while the USER layer itself declares footer: custom (see
|
|
343
|
-
* resolveUserCommandItemActivationIds). A project can supply a MERGED
|
|
344
|
-
* `footerLayout` for rendering, but it can never activate a dormant USER
|
|
345
|
-
* command — the same principle as the command-mode gate above: the user
|
|
346
|
-
* layer must own the layout that decides what executes.
|
|
347
|
-
* @returns the validated USER-layer layout, or undefined when absent or
|
|
348
|
-
* invalid (an invalid user layout authorizes nothing — fail-safe).
|
|
349
|
-
*/
|
|
350
|
-
function resolveUserLayerFooterLayout(descriptors, namespace) {
|
|
351
|
-
if (descriptors === void 0) return void 0;
|
|
352
|
-
const descriptor = descriptors.find((entry) => entry.ns === namespace);
|
|
353
|
-
if (descriptor === void 0) return void 0;
|
|
354
|
-
const user = descriptor.user;
|
|
355
|
-
if (typeof user !== "object" || user === null) return void 0;
|
|
356
|
-
const layout = user.footerLayout;
|
|
357
|
-
const parsed = parseFooterLayout(layout);
|
|
358
|
-
return isFooterLayout(parsed) ? parsed : void 0;
|
|
359
|
-
}
|
|
360
|
-
/**
|
|
361
|
-
* Resolve the USER layer's declared footerFallbackMode (the native mode
|
|
362
|
-
* the user's own command-mode fallback restores).
|
|
363
|
-
*/
|
|
364
|
-
function resolveUserLayerFooterFallbackMode(descriptors, namespace) {
|
|
365
|
-
if (descriptors === void 0) return void 0;
|
|
366
|
-
const descriptor = descriptors.find((entry) => entry.ns === namespace);
|
|
367
|
-
if (descriptor === void 0) return void 0;
|
|
368
|
-
const user = descriptor.user;
|
|
369
|
-
if (typeof user !== "object" || user === null) return void 0;
|
|
370
|
-
const mode = user.footerFallbackMode;
|
|
371
|
-
return typeof mode === "string" ? mode : void 0;
|
|
372
|
-
}
|
|
373
|
-
/** The shared empty authorization set. */
|
|
374
|
-
const EMPTY_IDS = /* @__PURE__ */ new Set();
|
|
375
|
-
/** Every item id a layout references (the authorization projection). */
|
|
376
|
-
function layoutRefIds(layout) {
|
|
377
|
-
const ids = /* @__PURE__ */ new Set();
|
|
378
|
-
for (const row of layout.rows) {
|
|
379
|
-
for (const ref of row.left) ids.add(ref.id);
|
|
380
|
-
for (const ref of row.right) ids.add(ref.id);
|
|
381
|
-
}
|
|
382
|
-
return ids;
|
|
383
|
-
}
|
|
384
|
-
/**
|
|
385
|
-
* The ids the USER layer AUTHORIZES for custom command item execution
|
|
386
|
-
* (PR D activation trust, mode-gated): the USER custom layout's refs, but
|
|
387
|
-
* ONLY while the USER layer itself declares `footer: custom`. A stale
|
|
388
|
-
* leftover layout under `footer: default/compact` (the /settings switch
|
|
389
|
-
* deliberately keeps the old layout) authorizes NOTHING — a project
|
|
390
|
-
* flipping the MERGED mode to custom can never resurrect a dormant USER
|
|
391
|
-
* command. `footer: command` authorizes nothing while the whole-footer
|
|
392
|
-
* command surface runs (the caller suspends per-item runners); the native
|
|
393
|
-
* fallback case uses resolveUserCommandItemFallbackActivationIds.
|
|
394
|
-
*/
|
|
395
|
-
function resolveUserCommandItemActivationIds(descriptors, namespace) {
|
|
396
|
-
if (resolveUserLayerFooterMode(descriptors, namespace) !== "custom") return EMPTY_IDS;
|
|
397
|
-
const layout = resolveUserLayerFooterLayout(descriptors, namespace);
|
|
398
|
-
return layout === void 0 ? EMPTY_IDS : layoutRefIds(layout);
|
|
399
|
-
}
|
|
400
|
-
/**
|
|
401
|
-
* The ids authorized for the native FALLBACK surface (a merged
|
|
402
|
-
* `footer: command` the USER layer does not own). The FULL semantic is
|
|
403
|
-
* encoded HERE so no caller can forget the outer mode gate:
|
|
404
|
-
*
|
|
405
|
-
* USER footer === 'command'
|
|
406
|
-
* && USER footerFallbackMode === 'custom'
|
|
407
|
-
* && valid USER footerLayout
|
|
408
|
-
* → the layout's refs
|
|
409
|
-
* otherwise → empty
|
|
410
|
-
*
|
|
411
|
-
* A USER who never opted into command mode (footer: default/compact)
|
|
412
|
-
* authorizes NOTHING even with stale fallback metadata; a PROJECT
|
|
413
|
-
* forcing the merged command mode can never turn it into execution
|
|
414
|
-
* authorization.
|
|
415
|
-
*/
|
|
416
|
-
function resolveUserCommandItemFallbackActivationIds(descriptors, namespace) {
|
|
417
|
-
if (resolveUserLayerFooterMode(descriptors, namespace) !== "command") return EMPTY_IDS;
|
|
418
|
-
if (resolveUserLayerFooterFallbackMode(descriptors, namespace) !== "custom") return EMPTY_IDS;
|
|
419
|
-
const layout = resolveUserLayerFooterLayout(descriptors, namespace);
|
|
420
|
-
return layout === void 0 ? EMPTY_IDS : layoutRefIds(layout);
|
|
421
|
-
}
|
|
422
|
-
//#endregion
|
|
423
19
|
//#region src/domain/footer/custom-items.ts
|
|
424
20
|
/**
|
|
425
21
|
* User-owned custom footer item definitions (PR C + PR D), neutral half
|
|
@@ -3441,10 +3037,6 @@ function getCapabilities() {
|
|
|
3441
3037
|
}
|
|
3442
3038
|
return cachedCapabilities;
|
|
3443
3039
|
}
|
|
3444
|
-
/** Override the cached capabilities. Useful in tests to exercise both code paths. */
|
|
3445
|
-
function setCapabilities(caps) {
|
|
3446
|
-
cachedCapabilities = caps;
|
|
3447
|
-
}
|
|
3448
3040
|
const KITTY_PREFIX = "\x1B_G";
|
|
3449
3041
|
const ITERM2_PREFIX = "\x1B]1337;File=";
|
|
3450
3042
|
/** The Kitty Unicode placeholder base character (Supplementary PUA, plane 16). */
|
|
@@ -3585,6 +3177,21 @@ function deleteKittyImage(imageId) {
|
|
|
3585
3177
|
return `\x1b_Ga=d,d=I,i=${imageId},q=2\x1b\\`;
|
|
3586
3178
|
}
|
|
3587
3179
|
/**
|
|
3180
|
+
* Delete Kitty image placements while keeping the uploaded image data resident
|
|
3181
|
+
* (lowercase `d=i`).
|
|
3182
|
+
*
|
|
3183
|
+
* With a `placementId`, ONLY that placement is removed (the protocol contract:
|
|
3184
|
+
* `a=d,d=i,i=<id>,p=<placement>`). Without one, every placement of the image
|
|
3185
|
+
* id is removed — still data-retaining, so it is never a destructive delete.
|
|
3186
|
+
*
|
|
3187
|
+
* The Screen uses this when a line yields only for a frame — a visible overlay
|
|
3188
|
+
* preemption (X077) — so the block can be placed again without a new
|
|
3189
|
+
* transmission and an image the Screen does not own never loses its data.
|
|
3190
|
+
*/
|
|
3191
|
+
function deleteKittyImagePlacement(imageId, placementId) {
|
|
3192
|
+
return `\x1b_Ga=d,d=i,i=${imageId}${placementId === void 0 ? "" : `,p=${placementId}`},q=2\x1b\\`;
|
|
3193
|
+
}
|
|
3194
|
+
/**
|
|
3588
3195
|
* Delete all visible Kitty graphics images.
|
|
3589
3196
|
* Uses uppercase 'A' to also free the image data.
|
|
3590
3197
|
*/
|
|
@@ -4233,6 +3840,47 @@ function compositeTuiLine(baseLine, overlayLine, startCol, overlayWidth, totalWi
|
|
|
4233
3840
|
const result = base.before + " ".repeat(beforePad) + SEGMENT_RESET + overlay.text + " ".repeat(overlayPad) + SEGMENT_RESET + base.after + " ".repeat(afterPad);
|
|
4234
3841
|
return visibleWidth(result) <= totalWidth ? result : sliceByColumn(result, 0, totalWidth, true);
|
|
4235
3842
|
}
|
|
3843
|
+
/**
|
|
3844
|
+
* The rows and image id one line's FIRST Kitty APC paints as a device layer,
|
|
3845
|
+
* or undefined when the line is not a Native Kitty placement anchor (X077).
|
|
3846
|
+
*
|
|
3847
|
+
* `a=p` is the managed placement shape and `a=T` the vendored `Image`'s inline
|
|
3848
|
+
* transmit-and-display sibling; every other action (upload, query, delete) is
|
|
3849
|
+
* not a placement. `U=1` is excluded: its pixels belong to the visible
|
|
3850
|
+
* placeholder cells, so a writer-side placement delete cannot remove it.
|
|
3851
|
+
*/
|
|
3852
|
+
/** The cell rows one Direct iTerm2 (OSC 1337) inline image paints above and
|
|
3853
|
+
* including its anchor line. The fork `Image` renders `rows - 1` blank lines
|
|
3854
|
+
* followed by `<cursorUp><OSC 1337 payload>`, so the anchor's own prefix is
|
|
3855
|
+
* the only height authority. Returns undefined for every other line.
|
|
3856
|
+
* (dsh-pi-tui divergence X080.) */
|
|
3857
|
+
function iterm2ImageBlockRows(line) {
|
|
3858
|
+
if (!line.includes("\x1B]1337;File=")) return void 0;
|
|
3859
|
+
const up = /^\x1b\[(\d{1,4})A/.exec(line)?.[1];
|
|
3860
|
+
const offset = up === void 0 ? 0 : Number.parseInt(up, 10);
|
|
3861
|
+
if (!Number.isInteger(offset) || offset < 0 || offset > 4096) return void 0;
|
|
3862
|
+
return offset + 1;
|
|
3863
|
+
}
|
|
3864
|
+
function nativeKittyBlock(line) {
|
|
3865
|
+
const controls = /\x1b_G([^;]*);/.exec(line)?.[1];
|
|
3866
|
+
if (controls === void 0) return void 0;
|
|
3867
|
+
const action = /(?:^|,)a=([A-Za-z])(?:,|$)/.exec(controls)?.[1];
|
|
3868
|
+
if (action !== "p" && action !== "T") return void 0;
|
|
3869
|
+
if (/(?:^|,)U=1(?:,|$)/.test(controls)) return void 0;
|
|
3870
|
+
const idText = /(?:^|,)i=(\d{1,10})(?:,|$)/.exec(controls)?.[1];
|
|
3871
|
+
const placementText = /(?:^|,)p=(\d{1,10})(?:,|$)/.exec(controls)?.[1];
|
|
3872
|
+
const positive = (text) => {
|
|
3873
|
+
if (text === void 0) return void 0;
|
|
3874
|
+
const value = Number.parseInt(text, 10);
|
|
3875
|
+
return Number.isInteger(value) && value > 0 && value <= 4294967295 ? value : void 0;
|
|
3876
|
+
};
|
|
3877
|
+
return {
|
|
3878
|
+
rows: getKittyImagePlacementRows(line) ?? 1,
|
|
3879
|
+
action,
|
|
3880
|
+
imageId: positive(idText),
|
|
3881
|
+
placementId: positive(placementText)
|
|
3882
|
+
};
|
|
3883
|
+
}
|
|
4236
3884
|
const VIEWPORT_TUI = Symbol.for("@earendil-works/pi-tui/viewport");
|
|
4237
3885
|
var TuiBase = class TuiBase extends Container {
|
|
4238
3886
|
terminal;
|
|
@@ -4277,6 +3925,14 @@ var TuiBase = class TuiBase extends Container {
|
|
|
4277
3925
|
* gesture-liveness check reads the CURRENT painted placement of a
|
|
4278
3926
|
* retained target). */
|
|
4279
3927
|
renderedOverlayLayouts = [];
|
|
3928
|
+
/**
|
|
3929
|
+
* The Native Kitty image ids THIS frame's projection preempted for a
|
|
3930
|
+
* visible overlay (X077). They are a per-frame fact, never durable state:
|
|
3931
|
+
* the Main Screen must remove only their placement and keep the data
|
|
3932
|
+
* resident, because the block is expected back the moment the overlay
|
|
3933
|
+
* closes and a foreign occurrence cannot re-transmit its own upload.
|
|
3934
|
+
*/
|
|
3935
|
+
preemptedKittyImageIds = /* @__PURE__ */ new Set();
|
|
4280
3936
|
get hasOverlayEntries() {
|
|
4281
3937
|
return this.overlayStack.length > 0;
|
|
4282
3938
|
}
|
|
@@ -5108,6 +4764,7 @@ var TuiBase = class TuiBase extends Container {
|
|
|
5108
4764
|
compositeOverlays(lines, termWidth, termHeight) {
|
|
5109
4765
|
if (this.overlayStack.length === 0) {
|
|
5110
4766
|
this.renderedOverlayLayouts = [];
|
|
4767
|
+
this.preemptedKittyImageIds = /* @__PURE__ */ new Set();
|
|
5111
4768
|
return lines;
|
|
5112
4769
|
}
|
|
5113
4770
|
const result = [...lines];
|
|
@@ -5147,6 +4804,30 @@ var TuiBase = class TuiBase extends Container {
|
|
|
5147
4804
|
const workingHeight = Math.max(result.length, termHeight, minLinesNeeded);
|
|
5148
4805
|
while (result.length < workingHeight) result.push("");
|
|
5149
4806
|
const viewportStart = Math.max(0, workingHeight - termHeight);
|
|
4807
|
+
const preempted = /* @__PURE__ */ new Set();
|
|
4808
|
+
if (rendered.length > 0) for (let row = viewportStart; row < result.length; row++) {
|
|
4809
|
+
const block = nativeKittyBlock(result[row] ?? "");
|
|
4810
|
+
if (block === void 0) continue;
|
|
4811
|
+
const first = row - viewportStart;
|
|
4812
|
+
const last = first + block.rows - 1;
|
|
4813
|
+
if (!rendered.some(({ overlayLines, row: overlayRow }) => overlayLines.length > 0 && overlayRow <= last && overlayRow + overlayLines.length - 1 >= first)) continue;
|
|
4814
|
+
if (block.action === "T") {
|
|
4815
|
+
result[row] = "";
|
|
4816
|
+
continue;
|
|
4817
|
+
}
|
|
4818
|
+
if (block.imageId === void 0 || block.placementId === void 0) continue;
|
|
4819
|
+
preempted.add(block.imageId);
|
|
4820
|
+
result[row] = "";
|
|
4821
|
+
}
|
|
4822
|
+
this.preemptedKittyImageIds = preempted;
|
|
4823
|
+
if (rendered.length > 0 && getCapabilities().images === "iterm2") for (let row = viewportStart; row < result.length; row++) {
|
|
4824
|
+
const rows = iterm2ImageBlockRows(result[row] ?? "");
|
|
4825
|
+
if (rows === void 0) continue;
|
|
4826
|
+
const first = row - viewportStart - (rows - 1);
|
|
4827
|
+
const last = row - viewportStart;
|
|
4828
|
+
if (!rendered.some(({ overlayLines, row: overlayRow }) => overlayLines.length > 0 && overlayRow <= last && overlayRow + overlayLines.length - 1 >= first)) continue;
|
|
4829
|
+
for (let target = row - (rows - 1); target <= row; target++) if (target >= 0) result[target] = "";
|
|
4830
|
+
}
|
|
5150
4831
|
for (const { overlayLines, row, col, w } of rendered) for (let i = 0; i < overlayLines.length; i++) {
|
|
5151
4832
|
const idx = viewportStart + row + i;
|
|
5152
4833
|
if (idx >= 0 && idx < result.length) {
|
|
@@ -5883,7 +5564,10 @@ var SelectList = class {
|
|
|
5883
5564
|
const delta = event.wheelDelta < 0 ? -1 : 1;
|
|
5884
5565
|
const previousIndex = this.selectedIndex;
|
|
5885
5566
|
this.selectedIndex = Math.max(0, Math.min(this.filteredItems.length - 1, this.selectedIndex + delta));
|
|
5886
|
-
if (this.selectedIndex !== previousIndex)
|
|
5567
|
+
if (this.selectedIndex !== previousIndex) {
|
|
5568
|
+
this.mousePressedItem = void 0;
|
|
5569
|
+
this.notifySelectionChange();
|
|
5570
|
+
}
|
|
5887
5571
|
return {
|
|
5888
5572
|
handled: true,
|
|
5889
5573
|
render: this.selectedIndex !== previousIndex
|
|
@@ -10153,6 +9837,228 @@ function trimPartialClosingFences(tokens) {
|
|
|
10153
9837
|
if (!marker || !lastLine || lastLine.length >= marker.length || lastLine !== marker[0]?.repeat(lastLine.length)) return;
|
|
10154
9838
|
token.text = token.text.slice(0, -lastLine.length).replace(/\n$/, "");
|
|
10155
9839
|
}
|
|
9840
|
+
/** Proof-mode zero-width boundary sentinels. They exist only in the disposable
|
|
9841
|
+
* rows of one `proveSourceSpan()` call and are always stripped before the proof
|
|
9842
|
+
* output is compared with the normal render. */
|
|
9843
|
+
const PROOF_OPEN = "";
|
|
9844
|
+
const PROOF_CLOSE = "";
|
|
9845
|
+
const proofSegmenter = getGraphemeSegmenter();
|
|
9846
|
+
function isGraphemeBoundary(text, index) {
|
|
9847
|
+
if (index <= 0 || index >= text.length) return true;
|
|
9848
|
+
for (const segment of proofSegmenter.segment(text)) if (segment.index === index) return true;
|
|
9849
|
+
return false;
|
|
9850
|
+
}
|
|
9851
|
+
/** Project a component-source offset onto the TAB-normalized source the parser sees. */
|
|
9852
|
+
function projectTabOffset(text, index) {
|
|
9853
|
+
let projected = index;
|
|
9854
|
+
for (let position = 0; position < index; position++) if (text.charCodeAt(position) === 9) projected += 2;
|
|
9855
|
+
return projected;
|
|
9856
|
+
}
|
|
9857
|
+
/** Remove the zero-width proof sentinels from one row without changing columns. */
|
|
9858
|
+
function stripProofSentinels(line) {
|
|
9859
|
+
if (!line.includes(PROOF_OPEN) && !line.includes(PROOF_CLOSE)) return line;
|
|
9860
|
+
return line.split(PROOF_OPEN).join("").split(PROOF_CLOSE).join("");
|
|
9861
|
+
}
|
|
9862
|
+
/**
|
|
9863
|
+
* Build a view of `content` against the raw text a block tokenizer produced it from. `content` lines are
|
|
9864
|
+
* prefixes-removed suffixes of the raw lines (blockquote markers, list indentation, code fences), so every line
|
|
9865
|
+
* must line up exactly; anything else is refused instead of guessed.
|
|
9866
|
+
* `offsets[viewIndex]` is the offset inside `raw` of the content character at `viewIndex`.
|
|
9867
|
+
*/
|
|
9868
|
+
function buildLineView(raw, content) {
|
|
9869
|
+
if (raw === content) {
|
|
9870
|
+
const offsets = new Array(content.length);
|
|
9871
|
+
for (let index = 0; index < content.length; index++) offsets[index] = index;
|
|
9872
|
+
return {
|
|
9873
|
+
text: content,
|
|
9874
|
+
offsets
|
|
9875
|
+
};
|
|
9876
|
+
}
|
|
9877
|
+
const rawLines = raw.split("\n");
|
|
9878
|
+
const contentLines = content.split("\n");
|
|
9879
|
+
if (contentLines.length > rawLines.length) return;
|
|
9880
|
+
const offsets = new Array(content.length);
|
|
9881
|
+
let viewIndex = 0;
|
|
9882
|
+
let rawLineStart = 0;
|
|
9883
|
+
for (let line = 0; line < contentLines.length; line++) {
|
|
9884
|
+
const rawLine = rawLines[line];
|
|
9885
|
+
const contentLine = contentLines[line];
|
|
9886
|
+
if (rawLine === void 0 || !rawLine.endsWith(contentLine)) return;
|
|
9887
|
+
const prefix = rawLine.length - contentLine.length;
|
|
9888
|
+
for (let index = 0; index < contentLine.length; index++) {
|
|
9889
|
+
offsets[viewIndex] = rawLineStart + prefix + index;
|
|
9890
|
+
viewIndex += 1;
|
|
9891
|
+
}
|
|
9892
|
+
if (line < contentLines.length - 1) {
|
|
9893
|
+
offsets[viewIndex] = rawLineStart + rawLine.length;
|
|
9894
|
+
viewIndex += 1;
|
|
9895
|
+
}
|
|
9896
|
+
rawLineStart += rawLine.length + 1;
|
|
9897
|
+
}
|
|
9898
|
+
return viewIndex === content.length ? {
|
|
9899
|
+
text: content,
|
|
9900
|
+
offsets
|
|
9901
|
+
} : void 0;
|
|
9902
|
+
}
|
|
9903
|
+
/** Absolute offset of a raw-relative offset, using the token's per-line mapping. */
|
|
9904
|
+
function absoluteFromRawOffset(origin, raw, rawOffset) {
|
|
9905
|
+
for (let line = 0; line < raw.length; line++) {
|
|
9906
|
+
const lineStart = origin.rawLineStarts[line];
|
|
9907
|
+
const lineEnd = lineStart + raw[line].length;
|
|
9908
|
+
if (rawOffset >= lineStart && rawOffset <= lineEnd) return origin.lineStarts[line] + (rawOffset - lineStart);
|
|
9909
|
+
}
|
|
9910
|
+
}
|
|
9911
|
+
/** Slice the visible columns `[startCol, endCol)` of an ANSI-stripped string. */
|
|
9912
|
+
function visibleColumnSlice(visible, startCol, endCol) {
|
|
9913
|
+
if (startCol < 0 || endCol < startCol) return;
|
|
9914
|
+
let column = 0;
|
|
9915
|
+
let startIndex = -1;
|
|
9916
|
+
let endIndex = -1;
|
|
9917
|
+
for (const { segment, index } of proofSegmenter.segment(visible)) {
|
|
9918
|
+
if (column === startCol && startIndex < 0) startIndex = index;
|
|
9919
|
+
if (column === endCol) {
|
|
9920
|
+
endIndex = index;
|
|
9921
|
+
break;
|
|
9922
|
+
}
|
|
9923
|
+
column += visibleWidth(segment);
|
|
9924
|
+
if (column > endCol) return;
|
|
9925
|
+
}
|
|
9926
|
+
if (startIndex < 0 && column === startCol) startIndex = visible.length;
|
|
9927
|
+
if (endIndex < 0 && column === endCol) endIndex = visible.length;
|
|
9928
|
+
if (startIndex < 0 || endIndex < 0) return;
|
|
9929
|
+
return visible.slice(startIndex, endIndex);
|
|
9930
|
+
}
|
|
9931
|
+
/** Every grapheme-boundary column of an ANSI-stripped visible string. */
|
|
9932
|
+
function visibleColumnBoundaries(visible) {
|
|
9933
|
+
const boundaries = [0];
|
|
9934
|
+
let column = 0;
|
|
9935
|
+
for (const { segment } of proofSegmenter.segment(visible)) {
|
|
9936
|
+
column += visibleWidth(segment);
|
|
9937
|
+
boundaries.push(column);
|
|
9938
|
+
}
|
|
9939
|
+
return boundaries;
|
|
9940
|
+
}
|
|
9941
|
+
/** The direct child tokens of one token, in rendering order. */
|
|
9942
|
+
function childTokensOf(token) {
|
|
9943
|
+
if (token.type === "list") return token.items;
|
|
9944
|
+
if (token.type === "table") {
|
|
9945
|
+
const table = token;
|
|
9946
|
+
const children = [];
|
|
9947
|
+
for (const cell of [...table.header, ...table.rows.flat()]) children.push(...cell.tokens ?? []);
|
|
9948
|
+
return children;
|
|
9949
|
+
}
|
|
9950
|
+
const generic = token;
|
|
9951
|
+
return generic.tokens === void 0 ? [] : [...generic.tokens];
|
|
9952
|
+
}
|
|
9953
|
+
/** Visible content of one proof row: sentinels and terminal sequences removed, trailing padding dropped. */
|
|
9954
|
+
function proofRowContent(line) {
|
|
9955
|
+
return stripTerminalSequences(stripProofSentinels(line)).trimEnd();
|
|
9956
|
+
}
|
|
9957
|
+
/**
|
|
9958
|
+
* Recover the ONE sentinel-wrapped painted range from a proof render. A range may span several wrapped rows: the
|
|
9959
|
+
* first row contributes its tail, every further row contributes its content after the layout prefix, and the last
|
|
9960
|
+
* row ends exactly at the closing sentinel. The prefix width of continuation rows is not assumed: it is the one
|
|
9961
|
+
* boundary width that reconstructs `expected` exactly, and an ambiguous reconstruction is refused.
|
|
9962
|
+
*/
|
|
9963
|
+
function recoverProofSegments(rows, expected) {
|
|
9964
|
+
let openRow = -1;
|
|
9965
|
+
let openIndex = -1;
|
|
9966
|
+
let closeRow = -1;
|
|
9967
|
+
let closeIndex = -1;
|
|
9968
|
+
for (let row = 0; row < rows.length; row++) {
|
|
9969
|
+
const line = rows[row];
|
|
9970
|
+
let cursor = 0;
|
|
9971
|
+
while (cursor <= line.length) {
|
|
9972
|
+
const open = line.indexOf(PROOF_OPEN, cursor);
|
|
9973
|
+
const close = line.indexOf(PROOF_CLOSE, cursor);
|
|
9974
|
+
if (open < 0 && close < 0) break;
|
|
9975
|
+
if (open >= 0 && (close < 0 || open < close)) {
|
|
9976
|
+
if (openRow >= 0) return { failure: "REFLOW" };
|
|
9977
|
+
openRow = row;
|
|
9978
|
+
openIndex = open;
|
|
9979
|
+
cursor = open + 1;
|
|
9980
|
+
continue;
|
|
9981
|
+
}
|
|
9982
|
+
if (closeRow >= 0 || openRow < 0) return { failure: "REFLOW" };
|
|
9983
|
+
closeRow = row;
|
|
9984
|
+
closeIndex = close;
|
|
9985
|
+
cursor = close + 1;
|
|
9986
|
+
}
|
|
9987
|
+
}
|
|
9988
|
+
if (openRow < 0 || closeRow < 0) return { failure: "REFLOW" };
|
|
9989
|
+
const openCol = visibleWidth(rows[openRow].slice(0, openIndex));
|
|
9990
|
+
const closeCol = visibleWidth(rows[closeRow].slice(0, closeIndex));
|
|
9991
|
+
if (openRow === closeRow) {
|
|
9992
|
+
const chunk = visibleColumnSlice(proofRowContent(rows[openRow]), openCol, closeCol);
|
|
9993
|
+
if (chunk === void 0) return { failure: "REFLOW" };
|
|
9994
|
+
if (chunk.length === 0 || chunk !== expected) return { failure: "RENDER_EQUIVALENCE" };
|
|
9995
|
+
return {
|
|
9996
|
+
segments: [{
|
|
9997
|
+
row: openRow,
|
|
9998
|
+
startCol: openCol,
|
|
9999
|
+
endCol: openCol + visibleWidth(chunk)
|
|
10000
|
+
}],
|
|
10001
|
+
collected: chunk
|
|
10002
|
+
};
|
|
10003
|
+
}
|
|
10004
|
+
const startVisible = proofRowContent(rows[openRow]);
|
|
10005
|
+
if (visibleWidth(startVisible) <= openCol) return { failure: "REFLOW" };
|
|
10006
|
+
const continuationTexts = [];
|
|
10007
|
+
for (let row = openRow + 1; row <= closeRow; row++) continuationTexts.push(proofRowContent(rows[row]));
|
|
10008
|
+
const closeVisible = continuationTexts[continuationTexts.length - 1];
|
|
10009
|
+
const contentEnds = visibleColumnBoundaries(startVisible).filter((column) => column > openCol);
|
|
10010
|
+
const prefixWidths = visibleColumnBoundaries(closeVisible).filter((column) => column < closeCol);
|
|
10011
|
+
const candidates = [];
|
|
10012
|
+
const seen = /* @__PURE__ */ new Set();
|
|
10013
|
+
for (const prefixWidth of prefixWidths) for (const contentEnd of contentEnds) {
|
|
10014
|
+
if (contentEnd <= prefixWidth) continue;
|
|
10015
|
+
const startChunk = visibleColumnSlice(startVisible, openCol, contentEnd);
|
|
10016
|
+
if (startChunk === void 0 || !expected.startsWith(startChunk)) continue;
|
|
10017
|
+
let left = expected.slice(startChunk.length);
|
|
10018
|
+
let valid = true;
|
|
10019
|
+
const segments = [];
|
|
10020
|
+
if (visibleWidth(startChunk) > 0) segments.push({
|
|
10021
|
+
row: openRow,
|
|
10022
|
+
startCol: openCol,
|
|
10023
|
+
endCol: openCol + visibleWidth(startChunk)
|
|
10024
|
+
});
|
|
10025
|
+
for (let index = 0; index < continuationTexts.length - 1; index++) {
|
|
10026
|
+
const visible = continuationTexts[index];
|
|
10027
|
+
if (visibleWidth(visible) < contentEnd) {
|
|
10028
|
+
valid = false;
|
|
10029
|
+
break;
|
|
10030
|
+
}
|
|
10031
|
+
const chunk = visibleColumnSlice(visible, prefixWidth, contentEnd);
|
|
10032
|
+
if (chunk === void 0 || chunk.length === 0 || !left.startsWith(chunk)) {
|
|
10033
|
+
valid = false;
|
|
10034
|
+
break;
|
|
10035
|
+
}
|
|
10036
|
+
left = left.slice(chunk.length);
|
|
10037
|
+
segments.push({
|
|
10038
|
+
row: openRow + 1 + index,
|
|
10039
|
+
startCol: prefixWidth,
|
|
10040
|
+
endCol: prefixWidth + visibleWidth(chunk)
|
|
10041
|
+
});
|
|
10042
|
+
}
|
|
10043
|
+
if (!valid) continue;
|
|
10044
|
+
const closeChunk = visibleColumnSlice(closeVisible, prefixWidth, closeCol);
|
|
10045
|
+
if (closeChunk === void 0 || closeChunk.length === 0 || closeChunk !== left) continue;
|
|
10046
|
+
segments.push({
|
|
10047
|
+
row: closeRow,
|
|
10048
|
+
startCol: prefixWidth,
|
|
10049
|
+
endCol: closeCol
|
|
10050
|
+
});
|
|
10051
|
+
const signature = segments.map((segment) => `${segment.row}:${segment.startCol}-${segment.endCol}`).join(",");
|
|
10052
|
+
if (seen.has(signature)) continue;
|
|
10053
|
+
seen.add(signature);
|
|
10054
|
+
candidates.push(segments);
|
|
10055
|
+
}
|
|
10056
|
+
if (candidates.length !== 1) return { failure: "REFLOW" };
|
|
10057
|
+
return {
|
|
10058
|
+
segments: candidates[0],
|
|
10059
|
+
collected: expected
|
|
10060
|
+
};
|
|
10061
|
+
}
|
|
10156
10062
|
const markdownParser = new Marked();
|
|
10157
10063
|
markdownParser.setOptions({ tokenizer: new MarkdownTokenizer() });
|
|
10158
10064
|
markdownParser.use({
|
|
@@ -10170,9 +10076,12 @@ var Markdown = class {
|
|
|
10170
10076
|
cachedText;
|
|
10171
10077
|
cachedWidth;
|
|
10172
10078
|
cachedLines;
|
|
10079
|
+
cachedCapabilities;
|
|
10173
10080
|
cachedTokens;
|
|
10174
10081
|
blocks;
|
|
10175
10082
|
blockHighlightedCode;
|
|
10083
|
+
proofState;
|
|
10084
|
+
primingProofBlocks = false;
|
|
10176
10085
|
constructor(text, paddingX, paddingY, theme, defaultTextStyle, options) {
|
|
10177
10086
|
this.text = text;
|
|
10178
10087
|
this.paddingX = paddingX;
|
|
@@ -10194,18 +10103,152 @@ var Markdown = class {
|
|
|
10194
10103
|
this.cachedText = void 0;
|
|
10195
10104
|
this.cachedWidth = void 0;
|
|
10196
10105
|
this.cachedLines = void 0;
|
|
10106
|
+
this.cachedCapabilities = void 0;
|
|
10197
10107
|
}
|
|
10198
10108
|
render(width) {
|
|
10199
10109
|
if (this.cachedLines && this.cachedText === this.text && this.cachedWidth === width) return this.cachedLines;
|
|
10110
|
+
const result = this.renderLines(width, false);
|
|
10111
|
+
this.cachedText = this.text;
|
|
10112
|
+
this.cachedWidth = width;
|
|
10113
|
+
this.cachedLines = result;
|
|
10114
|
+
this.cachedCapabilities = getCapabilities().hyperlinks;
|
|
10115
|
+
return result;
|
|
10116
|
+
}
|
|
10117
|
+
/**
|
|
10118
|
+
* Prove ONE source-local UTF-16 range against THIS component's own current source and the painted cells of
|
|
10119
|
+
* `render(width)`. The proof render runs the same parser and renderer and injects zero-width sentinels only into
|
|
10120
|
+
* the emitted text of the target token; it is accepted only when the proof rows, with the sentinels removed, are
|
|
10121
|
+
* byte-identical to the normal render. The normal render and block caches are never written by a proof.
|
|
10122
|
+
*/
|
|
10123
|
+
proveSourceSpan(range, width) {
|
|
10124
|
+
if (!Number.isInteger(range.start) || !Number.isInteger(range.end) || range.start < 0 || range.end <= range.start || range.end > this.text.length) return {
|
|
10125
|
+
kind: "UNPROVEN",
|
|
10126
|
+
reason: "SOURCE_PROJECTION"
|
|
10127
|
+
};
|
|
10128
|
+
if (this.text.includes(PROOF_OPEN) || this.text.includes(PROOF_CLOSE)) return {
|
|
10129
|
+
kind: "UNPROVEN",
|
|
10130
|
+
reason: "SOURCE_PROJECTION"
|
|
10131
|
+
};
|
|
10132
|
+
const hyperlinks = getCapabilities().hyperlinks;
|
|
10133
|
+
if (this.cachedLines !== void 0 && this.cachedText === this.text && this.cachedWidth === width && this.cachedCapabilities !== void 0 && this.cachedCapabilities !== hyperlinks) return {
|
|
10134
|
+
kind: "UNPROVEN",
|
|
10135
|
+
reason: "STALE_RENDER"
|
|
10136
|
+
};
|
|
10137
|
+
const cacheWasWarm = this.cachedLines !== void 0 && this.cachedText === this.text && this.cachedWidth === width;
|
|
10138
|
+
this.primingProofBlocks = true;
|
|
10139
|
+
let normalRows;
|
|
10140
|
+
try {
|
|
10141
|
+
normalRows = this.render(width);
|
|
10142
|
+
} finally {
|
|
10143
|
+
this.primingProofBlocks = false;
|
|
10144
|
+
}
|
|
10145
|
+
const cachedBlocks = this.blocks?.deref();
|
|
10146
|
+
if (cacheWasWarm && (cachedBlocks === void 0 || cachedBlocks.size === 0)) this.primeProofBlocks(width);
|
|
10147
|
+
const state = {
|
|
10148
|
+
request: {
|
|
10149
|
+
start: projectTabOffset(this.text, range.start),
|
|
10150
|
+
end: projectTabOffset(this.text, range.end)
|
|
10151
|
+
},
|
|
10152
|
+
origin: void 0,
|
|
10153
|
+
located: [],
|
|
10154
|
+
mappingFailure: void 0,
|
|
10155
|
+
sourceProjectionFailure: false,
|
|
10156
|
+
hrefCandidates: [],
|
|
10157
|
+
hrefTarget: void 0,
|
|
10158
|
+
wrappedLeaves: 0,
|
|
10159
|
+
suppressWrapping: false
|
|
10160
|
+
};
|
|
10161
|
+
this.proofState = state;
|
|
10162
|
+
let proofRows;
|
|
10163
|
+
try {
|
|
10164
|
+
proofRows = this.renderLines(width, true);
|
|
10165
|
+
} finally {
|
|
10166
|
+
this.proofState = void 0;
|
|
10167
|
+
}
|
|
10168
|
+
if (state.sourceProjectionFailure) return {
|
|
10169
|
+
kind: "UNPROVEN",
|
|
10170
|
+
reason: "SOURCE_PROJECTION"
|
|
10171
|
+
};
|
|
10172
|
+
if (state.mappingFailure !== void 0) return {
|
|
10173
|
+
kind: "UNPROVEN",
|
|
10174
|
+
reason: "TOKEN_ORIGIN"
|
|
10175
|
+
};
|
|
10176
|
+
if (proofRows.length !== normalRows.length) return {
|
|
10177
|
+
kind: "UNPROVEN",
|
|
10178
|
+
reason: "RENDER_EQUIVALENCE"
|
|
10179
|
+
};
|
|
10180
|
+
let sentinelRows = 0;
|
|
10181
|
+
for (let row = 0; row < proofRows.length; row++) {
|
|
10182
|
+
const proofRow = proofRows[row];
|
|
10183
|
+
if (proofRow.includes(PROOF_OPEN) || proofRow.includes(PROOF_CLOSE)) sentinelRows += 1;
|
|
10184
|
+
if (stripProofSentinels(proofRow) !== normalRows[row]) return {
|
|
10185
|
+
kind: "UNPROVEN",
|
|
10186
|
+
reason: "RENDER_EQUIVALENCE"
|
|
10187
|
+
};
|
|
10188
|
+
}
|
|
10189
|
+
if (sentinelRows === 0) {
|
|
10190
|
+
const request = state.request;
|
|
10191
|
+
if (state.hrefCandidates.some((candidate) => request.start >= candidate.start && request.end <= candidate.end)) return {
|
|
10192
|
+
kind: "NOT_PAINTED",
|
|
10193
|
+
reason: "HIDDEN_LINK_TARGET"
|
|
10194
|
+
};
|
|
10195
|
+
if (this.isMarkupOnlyRange(state)) return {
|
|
10196
|
+
kind: "NOT_PAINTED",
|
|
10197
|
+
reason: "MARKUP_ONLY"
|
|
10198
|
+
};
|
|
10199
|
+
return {
|
|
10200
|
+
kind: "UNPROVEN",
|
|
10201
|
+
reason: "TOKEN_ORIGIN"
|
|
10202
|
+
};
|
|
10203
|
+
}
|
|
10204
|
+
if (state.wrappedLeaves !== 1) return {
|
|
10205
|
+
kind: "UNPROVEN",
|
|
10206
|
+
reason: "TOKEN_ORIGIN"
|
|
10207
|
+
};
|
|
10208
|
+
const expected = this.text.slice(range.start, range.end);
|
|
10209
|
+
if (expected.includes("\n")) return {
|
|
10210
|
+
kind: "UNPROVEN",
|
|
10211
|
+
reason: "REFLOW"
|
|
10212
|
+
};
|
|
10213
|
+
const recovered = recoverProofSegments(proofRows, expected);
|
|
10214
|
+
if ("failure" in recovered) return {
|
|
10215
|
+
kind: "UNPROVEN",
|
|
10216
|
+
reason: recovered.failure
|
|
10217
|
+
};
|
|
10218
|
+
if (recovered.segments.length === 0) return {
|
|
10219
|
+
kind: "UNPROVEN",
|
|
10220
|
+
reason: "SOURCE_PROJECTION"
|
|
10221
|
+
};
|
|
10222
|
+
for (const segment of recovered.segments) {
|
|
10223
|
+
const normalRow = normalRows[segment.row];
|
|
10224
|
+
if (normalRow === void 0) return {
|
|
10225
|
+
kind: "UNPROVEN",
|
|
10226
|
+
reason: "RENDER_EQUIVALENCE"
|
|
10227
|
+
};
|
|
10228
|
+
if (segment.startCol < 0 || segment.endCol <= segment.startCol) return {
|
|
10229
|
+
kind: "UNPROVEN",
|
|
10230
|
+
reason: "REFLOW"
|
|
10231
|
+
};
|
|
10232
|
+
if (segment.endCol > visibleWidth(normalRow)) return {
|
|
10233
|
+
kind: "UNPROVEN",
|
|
10234
|
+
reason: "RENDER_EQUIVALENCE"
|
|
10235
|
+
};
|
|
10236
|
+
}
|
|
10237
|
+
return {
|
|
10238
|
+
kind: "PROVEN",
|
|
10239
|
+
segments: recovered.segments
|
|
10240
|
+
};
|
|
10241
|
+
}
|
|
10242
|
+
renderLines(width, proofMode) {
|
|
10200
10243
|
const contentWidth = Math.max(1, width - this.paddingX * 2);
|
|
10201
10244
|
const text = this.options.transform?.(this.text, contentWidth) ?? this.text;
|
|
10245
|
+
if (proofMode && text !== this.text) {
|
|
10246
|
+
const state = this.proofState;
|
|
10247
|
+
if (state !== void 0) state.sourceProjectionFailure = true;
|
|
10248
|
+
}
|
|
10202
10249
|
if (!text || text.trim() === "") {
|
|
10203
|
-
this.blocks = void 0;
|
|
10204
|
-
|
|
10205
|
-
this.cachedText = this.text;
|
|
10206
|
-
this.cachedWidth = width;
|
|
10207
|
-
this.cachedLines = result;
|
|
10208
|
-
return result;
|
|
10250
|
+
if (!proofMode) this.blocks = void 0;
|
|
10251
|
+
return [];
|
|
10209
10252
|
}
|
|
10210
10253
|
const normalizedText = text.replace(/\t/g, " ");
|
|
10211
10254
|
const cached = this.cachedTokens?.deref();
|
|
@@ -10213,27 +10256,30 @@ var Markdown = class {
|
|
|
10213
10256
|
if (!tokens) {
|
|
10214
10257
|
tokens = markdownParser.lexer(normalizedText);
|
|
10215
10258
|
trimPartialClosingFences(tokens);
|
|
10216
|
-
this.cachedTokens = new WeakRef({
|
|
10259
|
+
if (!proofMode) this.cachedTokens = new WeakRef({
|
|
10217
10260
|
source: normalizedText,
|
|
10218
10261
|
tokens
|
|
10219
10262
|
});
|
|
10220
10263
|
}
|
|
10264
|
+
if (proofMode) this.prepareProof(normalizedText, tokens);
|
|
10221
10265
|
const reuseBlocks = Object.keys(tokens.links).length === 0;
|
|
10222
10266
|
const previousBlocks = this.blocks?.deref();
|
|
10223
10267
|
const blocks = /* @__PURE__ */ new Map();
|
|
10224
|
-
this.blocks = new WeakRef(blocks);
|
|
10268
|
+
if (!proofMode) this.blocks = new WeakRef(blocks);
|
|
10225
10269
|
const contentLines = [];
|
|
10226
10270
|
for (let i = 0; i < tokens.length; i++) {
|
|
10227
10271
|
const token = tokens[i];
|
|
10228
10272
|
const nextTokenType = tokens[i + 1]?.type;
|
|
10229
|
-
const
|
|
10273
|
+
const proofTarget = proofMode && (this.proofIntersects(token) || this.proofNeedsHrefFallback(token));
|
|
10274
|
+
const key = proofTarget ? `${token.raw}\0proof` : token.raw;
|
|
10275
|
+
const block = ((proofMode || reuseBlocks) && !proofTarget ? blocks.get(key) ?? previousBlocks?.get(key) : void 0) ?? {
|
|
10230
10276
|
width: -1,
|
|
10231
10277
|
nextTokenType,
|
|
10232
10278
|
lines: [],
|
|
10233
10279
|
highlightedCode: /* @__PURE__ */ new Map()
|
|
10234
10280
|
};
|
|
10235
10281
|
if (block.width !== width || block.nextTokenType !== nextTokenType) this.renderBlock(block, token, nextTokenType, width, contentWidth);
|
|
10236
|
-
if (reuseBlocks) blocks.set(
|
|
10282
|
+
if (reuseBlocks || this.primingProofBlocks) blocks.set(key, block);
|
|
10237
10283
|
for (const line of block.lines) contentLines.push(line);
|
|
10238
10284
|
}
|
|
10239
10285
|
const bgFn = this.defaultTextStyle?.bgColor;
|
|
@@ -10245,11 +10291,370 @@ var Markdown = class {
|
|
|
10245
10291
|
}
|
|
10246
10292
|
flattenLines(emptyLines);
|
|
10247
10293
|
const result = emptyLines.concat(contentLines, emptyLines);
|
|
10248
|
-
this.cachedText = this.text;
|
|
10249
|
-
this.cachedWidth = width;
|
|
10250
|
-
this.cachedLines = result;
|
|
10251
10294
|
return result.length > 0 ? result : [""];
|
|
10252
10295
|
}
|
|
10296
|
+
/**
|
|
10297
|
+
* Fill the normal block cache for this exact source/width with a normal-mode render, without touching the cached
|
|
10298
|
+
* normal rows. Only a proof calls this; the cached blocks are ordinary normal blocks (no sentinel).
|
|
10299
|
+
*/
|
|
10300
|
+
primeProofBlocks(width) {
|
|
10301
|
+
const previous = this.primingProofBlocks;
|
|
10302
|
+
this.primingProofBlocks = true;
|
|
10303
|
+
try {
|
|
10304
|
+
this.renderLines(width, false);
|
|
10305
|
+
} finally {
|
|
10306
|
+
this.primingProofBlocks = previous;
|
|
10307
|
+
}
|
|
10308
|
+
}
|
|
10309
|
+
/** Whether this token owns a link that prints the fallback destination the request targets. */
|
|
10310
|
+
proofNeedsHrefFallback(token) {
|
|
10311
|
+
const state = this.proofState;
|
|
10312
|
+
if (state === void 0 || state.hrefTarget === void 0) return false;
|
|
10313
|
+
const href = state.hrefTarget.href;
|
|
10314
|
+
const pending = [token];
|
|
10315
|
+
while (pending.length > 0) {
|
|
10316
|
+
const current = pending.pop();
|
|
10317
|
+
if (current.type === "link" && current.href === href) return true;
|
|
10318
|
+
pending.push(...childTokensOf(current));
|
|
10319
|
+
}
|
|
10320
|
+
return false;
|
|
10321
|
+
}
|
|
10322
|
+
/** Whether the requested range intersects one token's own source span. */
|
|
10323
|
+
proofIntersects(token) {
|
|
10324
|
+
const state = this.proofState;
|
|
10325
|
+
if (state === void 0) return false;
|
|
10326
|
+
const origin = state.origin?.get(token);
|
|
10327
|
+
if (origin === void 0) return false;
|
|
10328
|
+
return state.request.start < origin.end && state.request.end > origin.start;
|
|
10329
|
+
}
|
|
10330
|
+
proofFail(reason) {
|
|
10331
|
+
const state = this.proofState;
|
|
10332
|
+
if (state !== void 0) state.mappingFailure ??= reason;
|
|
10333
|
+
}
|
|
10334
|
+
/**
|
|
10335
|
+
* Map every token of the ACTUAL token tree to its absolute source span. Structural `indexOf` is only a candidate
|
|
10336
|
+
* locator: child spans must stay ordered inside their parent and every stripped block view must line up line by
|
|
10337
|
+
* line, or the mapping fails closed.
|
|
10338
|
+
*/
|
|
10339
|
+
prepareProof(normalizedText, tokens) {
|
|
10340
|
+
const state = this.proofState;
|
|
10341
|
+
if (state === void 0 || state.sourceProjectionFailure) return;
|
|
10342
|
+
const origin = /* @__PURE__ */ new WeakMap();
|
|
10343
|
+
const located = [];
|
|
10344
|
+
state.origin = origin;
|
|
10345
|
+
state.located = located;
|
|
10346
|
+
const register = (token, raw, coordToAbsolute, startCoordinate) => {
|
|
10347
|
+
const rawLines = raw.split("\n");
|
|
10348
|
+
const rawLineStarts = [];
|
|
10349
|
+
const lineStarts = [];
|
|
10350
|
+
let rawOffset = 0;
|
|
10351
|
+
for (const rawLine of rawLines) {
|
|
10352
|
+
rawLineStarts.push(rawOffset);
|
|
10353
|
+
const absolute = coordToAbsolute(startCoordinate + rawOffset);
|
|
10354
|
+
if (absolute === void 0) {
|
|
10355
|
+
state.mappingFailure ??= "token-line-unmapped";
|
|
10356
|
+
return;
|
|
10357
|
+
}
|
|
10358
|
+
lineStarts.push(absolute);
|
|
10359
|
+
rawOffset += rawLine.length + 1;
|
|
10360
|
+
}
|
|
10361
|
+
const lastLine = rawLines[rawLines.length - 1] ?? "";
|
|
10362
|
+
const entry = {
|
|
10363
|
+
start: lineStarts[0] ?? 0,
|
|
10364
|
+
end: (lineStarts[lineStarts.length - 1] ?? 0) + lastLine.length,
|
|
10365
|
+
lineStarts,
|
|
10366
|
+
rawLineStarts
|
|
10367
|
+
};
|
|
10368
|
+
origin.set(token, entry);
|
|
10369
|
+
located.push({
|
|
10370
|
+
token,
|
|
10371
|
+
origin: entry
|
|
10372
|
+
});
|
|
10373
|
+
locateChildren(token, raw, coordToAbsolute, startCoordinate);
|
|
10374
|
+
};
|
|
10375
|
+
const locateChildren = (token, raw, coordToAbsolute, startCoordinate) => {
|
|
10376
|
+
const children = childTokensOf(token);
|
|
10377
|
+
if (children.length === 0) return;
|
|
10378
|
+
const stripped = token.type === "blockquote" || token.type === "list_item";
|
|
10379
|
+
let view;
|
|
10380
|
+
if (stripped) {
|
|
10381
|
+
const content = token.text;
|
|
10382
|
+
if (typeof content !== "string") {
|
|
10383
|
+
state.mappingFailure ??= "stripped-block-content";
|
|
10384
|
+
return;
|
|
10385
|
+
}
|
|
10386
|
+
view = buildLineView(raw, content);
|
|
10387
|
+
if (view === void 0) {
|
|
10388
|
+
state.mappingFailure ??= "stripped-block-view";
|
|
10389
|
+
return;
|
|
10390
|
+
}
|
|
10391
|
+
}
|
|
10392
|
+
const childToAbsolute = (coordinate) => {
|
|
10393
|
+
if (view === void 0) return coordToAbsolute(startCoordinate + coordinate);
|
|
10394
|
+
const rawOffset = view.offsets[coordinate];
|
|
10395
|
+
return rawOffset === void 0 ? void 0 : coordToAbsolute(startCoordinate + rawOffset);
|
|
10396
|
+
};
|
|
10397
|
+
const childText = view === void 0 ? raw : view.text;
|
|
10398
|
+
let cursor = 0;
|
|
10399
|
+
for (const child of children) {
|
|
10400
|
+
const childRaw = typeof child.raw === "string" ? child.raw : "";
|
|
10401
|
+
if (childRaw === "") continue;
|
|
10402
|
+
const index = childText.indexOf(childRaw, cursor);
|
|
10403
|
+
if (index < 0) {
|
|
10404
|
+
state.mappingFailure ??= "child-raw-lookup";
|
|
10405
|
+
continue;
|
|
10406
|
+
}
|
|
10407
|
+
cursor = index + childRaw.length;
|
|
10408
|
+
register(child, childRaw, childToAbsolute, index);
|
|
10409
|
+
}
|
|
10410
|
+
};
|
|
10411
|
+
let topCursor = 0;
|
|
10412
|
+
for (const token of tokens) {
|
|
10413
|
+
const raw = typeof token.raw === "string" ? token.raw : "";
|
|
10414
|
+
if (raw === "") continue;
|
|
10415
|
+
const index = normalizedText.indexOf(raw, topCursor);
|
|
10416
|
+
if (index < 0) {
|
|
10417
|
+
state.mappingFailure ??= "top-token-raw-lookup";
|
|
10418
|
+
continue;
|
|
10419
|
+
}
|
|
10420
|
+
topCursor = index + raw.length;
|
|
10421
|
+
register(token, raw, (coordinate) => coordinate, index);
|
|
10422
|
+
}
|
|
10423
|
+
const request = state.request;
|
|
10424
|
+
const hyperlinks = getCapabilities().hyperlinks;
|
|
10425
|
+
for (const locatedToken of located) {
|
|
10426
|
+
const token = locatedToken.token;
|
|
10427
|
+
if (token.type !== "link" && token.type !== "def") continue;
|
|
10428
|
+
const href = token.href;
|
|
10429
|
+
if (typeof href !== "string" || href.length === 0) continue;
|
|
10430
|
+
const rawLines = token.raw.split("\n");
|
|
10431
|
+
let index = token.raw.indexOf(href);
|
|
10432
|
+
while (index >= 0) {
|
|
10433
|
+
const absolute = absoluteFromRawOffset(locatedToken.origin, rawLines, index);
|
|
10434
|
+
const absoluteEnd = absoluteFromRawOffset(locatedToken.origin, rawLines, index + href.length);
|
|
10435
|
+
if (absolute !== void 0 && absoluteEnd === absolute + href.length) {
|
|
10436
|
+
if (request.start >= absolute && request.end <= absoluteEnd) {
|
|
10437
|
+
if (hyperlinks) state.hrefCandidates.push({
|
|
10438
|
+
start: absolute,
|
|
10439
|
+
end: absoluteEnd
|
|
10440
|
+
});
|
|
10441
|
+
else {
|
|
10442
|
+
const start = request.start - absolute;
|
|
10443
|
+
const end = request.end - absolute;
|
|
10444
|
+
if (isGraphemeBoundary(href, start) && isGraphemeBoundary(href, end)) state.hrefTarget = {
|
|
10445
|
+
href,
|
|
10446
|
+
start,
|
|
10447
|
+
end
|
|
10448
|
+
};
|
|
10449
|
+
else state.mappingFailure ??= "href-grapheme-split";
|
|
10450
|
+
}
|
|
10451
|
+
break;
|
|
10452
|
+
}
|
|
10453
|
+
}
|
|
10454
|
+
index = token.raw.indexOf(href, index + 1);
|
|
10455
|
+
}
|
|
10456
|
+
}
|
|
10457
|
+
}
|
|
10458
|
+
/**
|
|
10459
|
+
* Wrap the emitted text of ONE leaf whose raw-to-emitted identity covers the request. `rawOffset` is where the
|
|
10460
|
+
* emitted text starts inside the token raw (codespans and escapes print a sub-range of their raw). Anything that
|
|
10461
|
+
* does not line up with a single source line fails closed; a request in the markup part of the leaf is left alone.
|
|
10462
|
+
*/
|
|
10463
|
+
proofWrap(token, emitted, rawOffset = 0) {
|
|
10464
|
+
const state = this.proofState;
|
|
10465
|
+
if (state === void 0 || state.suppressWrapping) return emitted;
|
|
10466
|
+
const origin = state.origin?.get(token);
|
|
10467
|
+
if (origin === void 0) return emitted;
|
|
10468
|
+
const request = state.request;
|
|
10469
|
+
if (request.end <= origin.start || request.start >= origin.end) return emitted;
|
|
10470
|
+
const raw = token.raw;
|
|
10471
|
+
if (raw.slice(rawOffset, rawOffset + emitted.length) !== emitted) {
|
|
10472
|
+
state.mappingFailure ??= "leaf-raw-text-mismatch";
|
|
10473
|
+
return emitted;
|
|
10474
|
+
}
|
|
10475
|
+
const rawLines = raw.split("\n");
|
|
10476
|
+
let line = -1;
|
|
10477
|
+
for (let index = 0; index < rawLines.length; index++) {
|
|
10478
|
+
const lineStart = origin.lineStarts[index] ?? origin.start;
|
|
10479
|
+
const lineEnd = lineStart + rawLines[index].length;
|
|
10480
|
+
if (request.start >= lineEnd || request.end <= lineStart) continue;
|
|
10481
|
+
if (request.start >= lineStart && request.end <= lineEnd) {
|
|
10482
|
+
line = index;
|
|
10483
|
+
break;
|
|
10484
|
+
}
|
|
10485
|
+
state.mappingFailure ??= "request-crosses-line";
|
|
10486
|
+
return emitted;
|
|
10487
|
+
}
|
|
10488
|
+
if (line < 0) return emitted;
|
|
10489
|
+
const lineStart = origin.lineStarts[line] ?? origin.start;
|
|
10490
|
+
const emittedStart = origin.rawLineStarts[line] + (request.start - lineStart) - rawOffset;
|
|
10491
|
+
const emittedEnd = emittedStart + (request.end - request.start);
|
|
10492
|
+
if (emittedEnd <= 0 || emittedStart >= emitted.length) return emitted;
|
|
10493
|
+
if (emittedStart < 0 || emittedEnd > emitted.length) {
|
|
10494
|
+
state.mappingFailure ??= "request-crosses-leaf";
|
|
10495
|
+
return emitted;
|
|
10496
|
+
}
|
|
10497
|
+
if (!isGraphemeBoundary(emitted, emittedStart) || !isGraphemeBoundary(emitted, emittedEnd)) {
|
|
10498
|
+
state.mappingFailure ??= "grapheme-split";
|
|
10499
|
+
return emitted;
|
|
10500
|
+
}
|
|
10501
|
+
state.wrappedLeaves += 1;
|
|
10502
|
+
if (state.wrappedLeaves > 1) state.mappingFailure ??= "request-spans-multiple-leaves";
|
|
10503
|
+
return emitted.slice(0, emittedStart) + PROOF_OPEN + emitted.slice(emittedStart, emittedEnd) + PROOF_CLOSE + emitted.slice(emittedEnd);
|
|
10504
|
+
}
|
|
10505
|
+
/**
|
|
10506
|
+
* Print a link's fallback destination. When the request targets this exact destination, the printed fallback IS
|
|
10507
|
+
* the painted form of that source range, so it receives the proof sentinels.
|
|
10508
|
+
*/
|
|
10509
|
+
printedHref(token) {
|
|
10510
|
+
const state = this.proofState;
|
|
10511
|
+
const href = token.href;
|
|
10512
|
+
if (state === void 0 || state.suppressWrapping || state.hrefTarget === void 0) return href;
|
|
10513
|
+
const target = state.hrefTarget;
|
|
10514
|
+
if (target.href !== href) return href;
|
|
10515
|
+
state.wrappedLeaves += 1;
|
|
10516
|
+
if (state.wrappedLeaves > 1) state.mappingFailure ??= "request-spans-multiple-leaves";
|
|
10517
|
+
return href.slice(0, target.start) + PROOF_OPEN + href.slice(target.start, target.end) + PROOF_CLOSE + href.slice(target.end);
|
|
10518
|
+
}
|
|
10519
|
+
/** Wrap a rendered (possibly transformed) leaf only when its output is a direct source sub-range. */
|
|
10520
|
+
proofWrapRendered(token, emitted, pending) {
|
|
10521
|
+
const state = this.proofState;
|
|
10522
|
+
if (state === void 0 || state.suppressWrapping) return emitted;
|
|
10523
|
+
const origin = state.origin?.get(token);
|
|
10524
|
+
if (origin === void 0) return emitted;
|
|
10525
|
+
const request = state.request;
|
|
10526
|
+
if (request.end <= origin.start || request.start >= origin.end) return emitted;
|
|
10527
|
+
if (pending) {
|
|
10528
|
+
state.mappingFailure ??= "pending-math";
|
|
10529
|
+
return emitted;
|
|
10530
|
+
}
|
|
10531
|
+
const index = token.raw.indexOf(emitted);
|
|
10532
|
+
if (index < 0 || token.raw.indexOf(emitted, index + 1) >= 0) {
|
|
10533
|
+
state.mappingFailure ??= "rendered-text-not-in-source";
|
|
10534
|
+
return emitted;
|
|
10535
|
+
}
|
|
10536
|
+
return this.proofWrap(token, emitted, index);
|
|
10537
|
+
}
|
|
10538
|
+
/** Resolve the single source line/piece a code-block request maps to, inside the fence content only. */
|
|
10539
|
+
proofCodeTrace(token) {
|
|
10540
|
+
const state = this.proofState;
|
|
10541
|
+
if (state === void 0) return;
|
|
10542
|
+
const origin = state.origin?.get(token);
|
|
10543
|
+
if (origin === void 0) return;
|
|
10544
|
+
const request = state.request;
|
|
10545
|
+
if (request.end <= origin.start || request.start >= origin.end) return;
|
|
10546
|
+
const raw = token.raw;
|
|
10547
|
+
const firstNewline = raw.indexOf("\n");
|
|
10548
|
+
if (firstNewline < 0) {
|
|
10549
|
+
state.mappingFailure ??= "code-without-content";
|
|
10550
|
+
return;
|
|
10551
|
+
}
|
|
10552
|
+
const contentBase = absoluteFromRawOffset(origin, raw.split("\n"), firstNewline + 1);
|
|
10553
|
+
if (contentBase === void 0) {
|
|
10554
|
+
state.mappingFailure ??= "code-source-offset";
|
|
10555
|
+
return;
|
|
10556
|
+
}
|
|
10557
|
+
const codeText = token.text;
|
|
10558
|
+
const view = buildLineView(raw.slice(firstNewline + 1), codeText);
|
|
10559
|
+
if (view === void 0) {
|
|
10560
|
+
state.mappingFailure ??= "code-source-mismatch";
|
|
10561
|
+
return;
|
|
10562
|
+
}
|
|
10563
|
+
const codeLines = codeText.split("\n");
|
|
10564
|
+
let lineIndex = 0;
|
|
10565
|
+
for (let line = 0; line < codeLines.length; line++) {
|
|
10566
|
+
const absolute = contentBase + (view.offsets[lineIndex] ?? view.text.length);
|
|
10567
|
+
const lineEnd = absolute + codeLines[line].length;
|
|
10568
|
+
if (request.start >= lineEnd || request.end <= absolute) {
|
|
10569
|
+
lineIndex += codeLines[line].length + 1;
|
|
10570
|
+
continue;
|
|
10571
|
+
}
|
|
10572
|
+
if (request.start < absolute || request.end > lineEnd) {
|
|
10573
|
+
state.mappingFailure ??= "code-request-crosses-line";
|
|
10574
|
+
return;
|
|
10575
|
+
}
|
|
10576
|
+
return {
|
|
10577
|
+
lineIndex: line,
|
|
10578
|
+
start: request.start - absolute,
|
|
10579
|
+
end: request.end - absolute
|
|
10580
|
+
};
|
|
10581
|
+
}
|
|
10582
|
+
state.mappingFailure ??= "code-fence-or-gap";
|
|
10583
|
+
}
|
|
10584
|
+
/** Insert the proof sentinels into an already styled line whose visible text IS the source line. */
|
|
10585
|
+
insertProofRange(styled, sourceLine, start, end, mismatchReason) {
|
|
10586
|
+
if (stripTerminalSequences(styled) !== sourceLine || start < 0 || end > sourceLine.length || start >= end) {
|
|
10587
|
+
this.proofFail(mismatchReason);
|
|
10588
|
+
return styled;
|
|
10589
|
+
}
|
|
10590
|
+
if (!isGraphemeBoundary(sourceLine, start) || !isGraphemeBoundary(sourceLine, end)) {
|
|
10591
|
+
this.proofFail("grapheme-split");
|
|
10592
|
+
return styled;
|
|
10593
|
+
}
|
|
10594
|
+
let result = "";
|
|
10595
|
+
let plainIndex = 0;
|
|
10596
|
+
let index = 0;
|
|
10597
|
+
while (index < styled.length) {
|
|
10598
|
+
const ansi = extractAnsiCode(styled, index);
|
|
10599
|
+
if (ansi !== null) {
|
|
10600
|
+
result += ansi.code;
|
|
10601
|
+
index += ansi.length;
|
|
10602
|
+
continue;
|
|
10603
|
+
}
|
|
10604
|
+
if (plainIndex === start) result += PROOF_OPEN;
|
|
10605
|
+
if (plainIndex === end) result += PROOF_CLOSE;
|
|
10606
|
+
result += styled[index];
|
|
10607
|
+
plainIndex += 1;
|
|
10608
|
+
index += 1;
|
|
10609
|
+
}
|
|
10610
|
+
if (plainIndex !== sourceLine.length) {
|
|
10611
|
+
this.proofFail(mismatchReason);
|
|
10612
|
+
return styled;
|
|
10613
|
+
}
|
|
10614
|
+
if (plainIndex === end) result += PROOF_CLOSE;
|
|
10615
|
+
const state = this.proofState;
|
|
10616
|
+
if (state !== void 0) {
|
|
10617
|
+
state.wrappedLeaves += 1;
|
|
10618
|
+
if (state.wrappedLeaves > 1) state.mappingFailure ??= "request-spans-multiple-leaves";
|
|
10619
|
+
}
|
|
10620
|
+
return result;
|
|
10621
|
+
}
|
|
10622
|
+
/** Mark a non-inline block leaf the proof seam never traces as an explicit failure. */
|
|
10623
|
+
proofUnsupported(token) {
|
|
10624
|
+
if (token.type === "def" || token.type === "space") return;
|
|
10625
|
+
const state = this.proofState;
|
|
10626
|
+
if (state === void 0) return;
|
|
10627
|
+
const origin = state.origin?.get(token);
|
|
10628
|
+
if (origin === void 0) return;
|
|
10629
|
+
const request = state.request;
|
|
10630
|
+
if (request.start < origin.end && request.end > origin.start) state.mappingFailure ??= "unsupported-block-leaf";
|
|
10631
|
+
}
|
|
10632
|
+
/** A request fully inside the markup delimiters of an inline wrapper is parser-proven markup only. */
|
|
10633
|
+
isMarkupOnlyRange(state) {
|
|
10634
|
+
const wrappers = /* @__PURE__ */ new Set([
|
|
10635
|
+
"strong",
|
|
10636
|
+
"em",
|
|
10637
|
+
"del",
|
|
10638
|
+
"link",
|
|
10639
|
+
"codespan"
|
|
10640
|
+
]);
|
|
10641
|
+
const request = state.request;
|
|
10642
|
+
for (const { token, origin } of state.located) {
|
|
10643
|
+
if (!wrappers.has(token.type)) continue;
|
|
10644
|
+
if (request.start < origin.start || request.end > origin.end) continue;
|
|
10645
|
+
let painted = false;
|
|
10646
|
+
for (const other of state.located) {
|
|
10647
|
+
if (other.token === token) continue;
|
|
10648
|
+
if (other.origin.start < origin.start || other.origin.end > origin.end) continue;
|
|
10649
|
+
if (other.origin.start <= request.start && other.origin.end >= request.end) {
|
|
10650
|
+
painted = true;
|
|
10651
|
+
break;
|
|
10652
|
+
}
|
|
10653
|
+
}
|
|
10654
|
+
if (!painted) return true;
|
|
10655
|
+
}
|
|
10656
|
+
return false;
|
|
10657
|
+
}
|
|
10253
10658
|
/** Render one top-level block to output lines: wrapped, with margins, and padded or backgrounded to the width. */
|
|
10254
10659
|
renderBlock(block, token, nextTokenType, width, contentWidth) {
|
|
10255
10660
|
this.blockHighlightedCode = block.highlightedCode;
|
|
@@ -10351,13 +10756,16 @@ var Markdown = class {
|
|
|
10351
10756
|
const latexToken = token;
|
|
10352
10757
|
let rendered = !latexToken.pending && this.options.renderLatex !== false ? renderLatex(latexToken.text, { display: true }) : void 0;
|
|
10353
10758
|
if (rendered === void 0 || rendered.split("\n").some((line) => visibleWidth(line) > width)) rendered = latexToken.raw.trim();
|
|
10354
|
-
|
|
10759
|
+
const tracedRendered = this.proofWrapRendered(token, rendered, latexToken.pending === true);
|
|
10760
|
+
for (const line of tracedRendered.split("\n")) lines.push(this.applyDefaultStyle(line));
|
|
10355
10761
|
if (nextTokenType && nextTokenType !== "space") lines.push("");
|
|
10356
10762
|
break;
|
|
10357
10763
|
}
|
|
10358
10764
|
case "code": {
|
|
10359
10765
|
const indent = this.theme.codeBlockIndent ?? " ";
|
|
10766
|
+
const trace = this.proofCodeTrace(token);
|
|
10360
10767
|
lines.push(this.theme.codeBlockBorder(`\`\`\`${token.lang || ""}`));
|
|
10768
|
+
const codeLines = token.text.split("\n");
|
|
10361
10769
|
if (this.theme.highlightCode) {
|
|
10362
10770
|
const key = `${token.lang ?? ""}\0${token.text}`;
|
|
10363
10771
|
let highlighted = this.blockHighlightedCode?.get(key);
|
|
@@ -10365,10 +10773,16 @@ var Markdown = class {
|
|
|
10365
10773
|
highlighted = this.theme.highlightCode(token.text, token.lang);
|
|
10366
10774
|
this.blockHighlightedCode?.set(key, highlighted);
|
|
10367
10775
|
}
|
|
10368
|
-
|
|
10369
|
-
|
|
10370
|
-
|
|
10371
|
-
|
|
10776
|
+
if (trace !== void 0 && highlighted.length !== codeLines.length) this.proofFail("code-highlight-line-count");
|
|
10777
|
+
for (let index = 0; index < highlighted.length; index++) {
|
|
10778
|
+
let hlLine = highlighted[index];
|
|
10779
|
+
if (trace !== void 0 && highlighted.length === codeLines.length && trace.lineIndex === index) hlLine = this.insertProofRange(hlLine, codeLines[index], trace.start, trace.end, "code-highlight-mismatch");
|
|
10780
|
+
lines.push(`${indent}${hlLine}`);
|
|
10781
|
+
}
|
|
10782
|
+
} else for (let index = 0; index < codeLines.length; index++) {
|
|
10783
|
+
let codeLine = this.theme.codeBlock(codeLines[index]);
|
|
10784
|
+
if (trace !== void 0 && trace.lineIndex === index) codeLine = this.insertProofRange(codeLine, codeLines[index], trace.start, trace.end, "code-style-mismatch");
|
|
10785
|
+
lines.push(`${indent}${codeLine}`);
|
|
10372
10786
|
}
|
|
10373
10787
|
lines.push(this.theme.codeBlockBorder("```"));
|
|
10374
10788
|
if (nextTokenType && nextTokenType !== "space") lines.push("");
|
|
@@ -10422,12 +10836,15 @@ var Markdown = class {
|
|
|
10422
10836
|
if (nextTokenType && nextTokenType !== "space") lines.push("");
|
|
10423
10837
|
break;
|
|
10424
10838
|
case "html":
|
|
10839
|
+
this.proofUnsupported(token);
|
|
10425
10840
|
if ("raw" in token && typeof token.raw === "string") lines.push(this.applyDefaultStyle(token.raw.trim()));
|
|
10426
10841
|
break;
|
|
10427
10842
|
case "space":
|
|
10428
10843
|
lines.push("");
|
|
10429
10844
|
break;
|
|
10430
|
-
default:
|
|
10845
|
+
default:
|
|
10846
|
+
this.proofUnsupported(token);
|
|
10847
|
+
if ("text" in token && typeof token.text === "string") lines.push(token.text);
|
|
10431
10848
|
}
|
|
10432
10849
|
return lines;
|
|
10433
10850
|
}
|
|
@@ -10442,15 +10859,17 @@ var Markdown = class {
|
|
|
10442
10859
|
case "latex": {
|
|
10443
10860
|
const latexToken = token;
|
|
10444
10861
|
const rendered = !latexToken.pending && this.options.renderLatex !== false ? renderLatex(latexToken.text) ?? latexToken.raw : latexToken.raw;
|
|
10445
|
-
result += applyTextWithNewlines(rendered);
|
|
10862
|
+
result += applyTextWithNewlines(this.proofWrapRendered(token, rendered, latexToken.pending === true));
|
|
10446
10863
|
break;
|
|
10447
10864
|
}
|
|
10448
|
-
case "escape":
|
|
10449
|
-
|
|
10865
|
+
case "escape": {
|
|
10866
|
+
const escaped = this.options.preserveBackslashEscapes ? token.raw : token.text;
|
|
10867
|
+
result += applyTextWithNewlines(this.proofWrap(token, escaped, Math.max(0, token.raw.indexOf(escaped))));
|
|
10450
10868
|
break;
|
|
10869
|
+
}
|
|
10451
10870
|
case "text":
|
|
10452
10871
|
if (token.tokens && token.tokens.length > 0) result += this.renderInlineTokens(token.tokens, resolvedStyleContext);
|
|
10453
|
-
else result += applyTextWithNewlines(token.text);
|
|
10872
|
+
else result += applyTextWithNewlines(this.proofWrap(token, token.text));
|
|
10454
10873
|
break;
|
|
10455
10874
|
case "paragraph":
|
|
10456
10875
|
result += this.renderInlineTokens(token.tokens || [], resolvedStyleContext);
|
|
@@ -10466,7 +10885,7 @@ var Markdown = class {
|
|
|
10466
10885
|
break;
|
|
10467
10886
|
}
|
|
10468
10887
|
case "codespan":
|
|
10469
|
-
result += this.theme.code(token.text) + stylePrefix;
|
|
10888
|
+
result += this.theme.code(this.proofWrap(token, token.text, Math.max(0, token.raw.indexOf(token.text)))) + stylePrefix;
|
|
10470
10889
|
break;
|
|
10471
10890
|
case "link": {
|
|
10472
10891
|
const linkText = this.renderInlineTokens(token.tokens || [], resolvedStyleContext);
|
|
@@ -10475,7 +10894,7 @@ var Markdown = class {
|
|
|
10475
10894
|
else {
|
|
10476
10895
|
const hrefForComparison = token.href.startsWith("mailto:") ? token.href.slice(7) : token.href;
|
|
10477
10896
|
if (token.text === token.href || token.text === hrefForComparison) result += styledLink + stylePrefix;
|
|
10478
|
-
else result += styledLink + this.theme.linkUrl(` (${token
|
|
10897
|
+
else result += styledLink + this.theme.linkUrl(` (${this.printedHref(token)})`) + stylePrefix;
|
|
10479
10898
|
}
|
|
10480
10899
|
break;
|
|
10481
10900
|
}
|
|
@@ -10488,9 +10907,9 @@ var Markdown = class {
|
|
|
10488
10907
|
break;
|
|
10489
10908
|
}
|
|
10490
10909
|
case "html":
|
|
10491
|
-
if ("raw" in token && typeof token.raw === "string") result += applyTextWithNewlines(token.raw);
|
|
10910
|
+
if ("raw" in token && typeof token.raw === "string") result += applyTextWithNewlines(this.proofWrap(token, token.raw));
|
|
10492
10911
|
break;
|
|
10493
|
-
default: if ("text" in token && typeof token.text === "string") result += applyTextWithNewlines(token.text);
|
|
10912
|
+
default: if ("text" in token && typeof token.text === "string") result += applyTextWithNewlines(this.proofWrap(token, token.text));
|
|
10494
10913
|
}
|
|
10495
10914
|
while (stylePrefix && result.endsWith(stylePrefix)) result = result.slice(0, -stylePrefix.length);
|
|
10496
10915
|
return result;
|
|
@@ -10576,15 +10995,21 @@ var Markdown = class {
|
|
|
10576
10995
|
const maxUnbrokenWordWidth = 30;
|
|
10577
10996
|
const naturalWidths = [];
|
|
10578
10997
|
const minWordWidths = [];
|
|
10579
|
-
|
|
10580
|
-
|
|
10581
|
-
|
|
10582
|
-
|
|
10583
|
-
|
|
10584
|
-
|
|
10585
|
-
|
|
10586
|
-
|
|
10587
|
-
|
|
10998
|
+
const proofState = this.proofState;
|
|
10999
|
+
if (proofState !== void 0) proofState.suppressWrapping = true;
|
|
11000
|
+
try {
|
|
11001
|
+
for (let i = 0; i < numCols; i++) {
|
|
11002
|
+
const headerText = this.renderInlineTokens(token.header[i].tokens || [], styleContext);
|
|
11003
|
+
naturalWidths[i] = visibleWidth(headerText);
|
|
11004
|
+
minWordWidths[i] = Math.max(1, this.getLongestWordWidth(headerText, maxUnbrokenWordWidth));
|
|
11005
|
+
}
|
|
11006
|
+
for (const row of token.rows) for (let i = 0; i < row.length; i++) {
|
|
11007
|
+
const cellText = this.renderInlineTokens(row[i].tokens || [], styleContext);
|
|
11008
|
+
naturalWidths[i] = Math.max(naturalWidths[i] || 0, visibleWidth(cellText));
|
|
11009
|
+
minWordWidths[i] = Math.max(minWordWidths[i] || 1, this.getLongestWordWidth(cellText, maxUnbrokenWordWidth));
|
|
11010
|
+
}
|
|
11011
|
+
} finally {
|
|
11012
|
+
if (proofState !== void 0) proofState.suppressWrapping = false;
|
|
10588
11013
|
}
|
|
10589
11014
|
let minColumnWidths = minWordWidths;
|
|
10590
11015
|
let minCellsWidth = minColumnWidths.reduce((a, b) => a + b, 0);
|
|
@@ -13125,7 +13550,6 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
13125
13550
|
imageProtocol = null;
|
|
13126
13551
|
/** Per-instance protocol selection; never mutates the process-wide cache. */
|
|
13127
13552
|
imageProtocolOverride;
|
|
13128
|
-
savedCapabilities;
|
|
13129
13553
|
uploadedKittyImages = /* @__PURE__ */ new Map();
|
|
13130
13554
|
/**
|
|
13131
13555
|
* Per-row trusted SIXEL block height of the LAST painted frame (X074).
|
|
@@ -13334,14 +13758,6 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
13334
13758
|
const capabilities = getCapabilities();
|
|
13335
13759
|
this.imageProtocol = this.imageProtocolOverride !== void 0 ? this.imageProtocolOverride : capabilities.images;
|
|
13336
13760
|
this.uploadedKittyImages.clear();
|
|
13337
|
-
if (capabilities.images === "iterm2") {
|
|
13338
|
-
this.savedCapabilities = capabilities;
|
|
13339
|
-
setCapabilities({
|
|
13340
|
-
...capabilities,
|
|
13341
|
-
images: null
|
|
13342
|
-
});
|
|
13343
|
-
this.invalidate();
|
|
13344
|
-
}
|
|
13345
13761
|
this.lastDocument = [];
|
|
13346
13762
|
this.selectionAnchor = void 0;
|
|
13347
13763
|
this.selectionFocus = void 0;
|
|
@@ -13388,10 +13804,6 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
13388
13804
|
buffer += `\x1b[0m${ENABLE_AUTOWRAP}\r\n\x1b[?25h${END_SYNCHRONIZED_OUTPUT}`;
|
|
13389
13805
|
this.terminal.write(buffer);
|
|
13390
13806
|
}
|
|
13391
|
-
if (this.savedCapabilities) {
|
|
13392
|
-
setCapabilities(this.savedCapabilities);
|
|
13393
|
-
this.savedCapabilities = void 0;
|
|
13394
|
-
}
|
|
13395
13807
|
}
|
|
13396
13808
|
getExitRestorePrefix() {
|
|
13397
13809
|
const prefix = super.getExitRestorePrefix();
|
|
@@ -14961,6 +15373,7 @@ function parseKittyImageHeader(line) {
|
|
|
14961
15373
|
const paramsEnd = line.indexOf(";", paramsStart);
|
|
14962
15374
|
if (paramsEnd === -1) return void 0;
|
|
14963
15375
|
const ids = [];
|
|
15376
|
+
const placementIds = [];
|
|
14964
15377
|
let rows = 1;
|
|
14965
15378
|
for (const param of line.slice(paramsStart, paramsEnd).split(",")) {
|
|
14966
15379
|
const [key, value] = param.split("=", 2);
|
|
@@ -14968,10 +15381,12 @@ function parseKittyImageHeader(line) {
|
|
|
14968
15381
|
const numberValue = Number(value);
|
|
14969
15382
|
if (!Number.isInteger(numberValue) || numberValue <= 0 || numberValue > 4294967295) continue;
|
|
14970
15383
|
if (key === "i") ids.push(numberValue);
|
|
15384
|
+
else if (key === "p") placementIds.push(numberValue);
|
|
14971
15385
|
else if (key === "r") rows = numberValue;
|
|
14972
15386
|
}
|
|
14973
15387
|
return {
|
|
14974
15388
|
ids,
|
|
15389
|
+
placementIds,
|
|
14975
15390
|
rows
|
|
14976
15391
|
};
|
|
14977
15392
|
}
|
|
@@ -14981,6 +15396,15 @@ function extractKittyImageIds(line) {
|
|
|
14981
15396
|
function extractKittyImageRows(line) {
|
|
14982
15397
|
return parseKittyImageHeader(line)?.rows ?? 1;
|
|
14983
15398
|
}
|
|
15399
|
+
/** The explicit placement id of one image line, or undefined when it has none. */
|
|
15400
|
+
function extractKittyPlacementId(line) {
|
|
15401
|
+
return parseKittyImageHeader(line)?.placementIds[0];
|
|
15402
|
+
}
|
|
15403
|
+
/** Whether a line is the same explicit image placement (same image and placement id). */
|
|
15404
|
+
function isSameKittyPlacement(line, imageId, placementId) {
|
|
15405
|
+
const header = parseKittyImageHeader(line);
|
|
15406
|
+
return header !== void 0 && header.ids.includes(imageId) && header.placementIds.includes(placementId);
|
|
15407
|
+
}
|
|
14984
15408
|
function isTermuxSession() {
|
|
14985
15409
|
return Boolean(process.env.TERMUX_VERSION);
|
|
14986
15410
|
}
|
|
@@ -15081,6 +15505,19 @@ var TuiMainScreen = class extends TuiBase {
|
|
|
15081
15505
|
for (const lineIds of lineImageIds) for (const id of lineIds) ids.add(id);
|
|
15082
15506
|
return ids;
|
|
15083
15507
|
}
|
|
15508
|
+
/**
|
|
15509
|
+
* Rows the clamped diff skipped (above the viewport) are committed
|
|
15510
|
+
* scrollback: the terminal still holds their previous text and image state,
|
|
15511
|
+
* so every incremental commit must keep the previous caches for that prefix
|
|
15512
|
+
* instead of claiming the new frame's values were rendered — including the
|
|
15513
|
+
* image-id metadata the kitty cleanup record is built from. A later full
|
|
15514
|
+
* render reprocesses those rows from their current raw, repaints them, and
|
|
15515
|
+
* deletes exactly the images the model still holds. (dsh-pi-tui divergence
|
|
15516
|
+
* X078.)
|
|
15517
|
+
*/
|
|
15518
|
+
mergeSkippedPrefix(previous, next, skipRows) {
|
|
15519
|
+
return skipRows > 0 ? [...previous.slice(0, skipRows), ...next.slice(skipRows)] : next;
|
|
15520
|
+
}
|
|
15084
15521
|
deleteKittyImages(ids) {
|
|
15085
15522
|
let buffer = "";
|
|
15086
15523
|
for (const id of ids) buffer += deleteKittyImage(id);
|
|
@@ -15276,12 +15713,24 @@ var TuiMainScreen = class extends TuiBase {
|
|
|
15276
15713
|
lastChanged: expandedLastChanged
|
|
15277
15714
|
};
|
|
15278
15715
|
}
|
|
15279
|
-
deleteChangedKittyImages(firstChanged, lastChanged) {
|
|
15716
|
+
deleteChangedKittyImages(firstChanged, lastChanged, newLines) {
|
|
15280
15717
|
if (firstChanged < 0 || lastChanged < firstChanged) return "";
|
|
15281
15718
|
const ids = /* @__PURE__ */ new Set();
|
|
15719
|
+
let buffer = "";
|
|
15282
15720
|
const maxLine = Math.min(lastChanged, this.previousLines.length - 1);
|
|
15283
|
-
for (let i = firstChanged; i <= maxLine; i++)
|
|
15284
|
-
|
|
15721
|
+
for (let i = firstChanged; i <= maxLine; i++) {
|
|
15722
|
+
const previousLine = this.previousLines[i] ?? "";
|
|
15723
|
+
const newLine = newLines[i] ?? "";
|
|
15724
|
+
for (const id of this.previousLineImageIds[i] ?? EMPTY_IMAGE_IDS) {
|
|
15725
|
+
const placementId = extractKittyPlacementId(previousLine);
|
|
15726
|
+
if (placementId !== void 0 && (this.preemptedKittyImageIds.has(id) || isSameKittyPlacement(newLine, id, placementId))) {
|
|
15727
|
+
buffer += deleteKittyImagePlacement(id, placementId);
|
|
15728
|
+
continue;
|
|
15729
|
+
}
|
|
15730
|
+
ids.add(id);
|
|
15731
|
+
}
|
|
15732
|
+
}
|
|
15733
|
+
return buffer + this.deleteKittyImages(ids);
|
|
15285
15734
|
}
|
|
15286
15735
|
/**
|
|
15287
15736
|
* Drop the DCS of every trusted SIXEL block that a visible overlay paints
|
|
@@ -15365,6 +15814,7 @@ var TuiMainScreen = class extends TuiBase {
|
|
|
15365
15814
|
return targetRow - viewportTop - currentScreenRow;
|
|
15366
15815
|
};
|
|
15367
15816
|
let rawLines = this.resolveFakeCursors(this.render(width).map((line) => line.replace(OSC133_ZONE_PREFIX, "")));
|
|
15817
|
+
this.preemptedKittyImageIds = /* @__PURE__ */ new Set();
|
|
15368
15818
|
if (this.hasOverlayEntries) {
|
|
15369
15819
|
rawLines = this.compositeOverlays(rawLines, width, height);
|
|
15370
15820
|
this.suppressOverlayCoveredSixelBlocks(rawLines);
|
|
@@ -15479,7 +15929,8 @@ var TuiMainScreen = class extends TuiBase {
|
|
|
15479
15929
|
let firstChanged = -1;
|
|
15480
15930
|
let lastChanged = -1;
|
|
15481
15931
|
const maxLines = Math.max(newLines.length, this.previousLines.length);
|
|
15482
|
-
|
|
15932
|
+
const diffScanStart = heightChanged ? 0 : prevViewportTop;
|
|
15933
|
+
for (let i = diffScanStart; i < maxLines; i++) if ((i < this.previousLines.length ? this.previousLines[i] : "") !== (i < newLines.length ? newLines[i] : "")) {
|
|
15483
15934
|
if (firstChanged === -1) firstChanged = i;
|
|
15484
15935
|
lastChanged = i;
|
|
15485
15936
|
}
|
|
@@ -15498,20 +15949,20 @@ var TuiMainScreen = class extends TuiBase {
|
|
|
15498
15949
|
this.positionHardwareCursor(cursorPos, newLines.length);
|
|
15499
15950
|
this.previousViewportTop = prevViewportTop;
|
|
15500
15951
|
this.previousHeight = height;
|
|
15501
|
-
this.previousRawLines = rawLines;
|
|
15502
|
-
this.previousLineImageIds = lineImageIds;
|
|
15503
|
-
this.previousLineImageRows = lineImageRows;
|
|
15504
|
-
this.previousLineSixelRows = lineSixelRows;
|
|
15952
|
+
this.previousRawLines = this.mergeSkippedPrefix(this.previousRawLines, rawLines, diffScanStart);
|
|
15953
|
+
this.previousLineImageIds = this.mergeSkippedPrefix(this.previousLineImageIds, lineImageIds, diffScanStart);
|
|
15954
|
+
this.previousLineImageRows = this.mergeSkippedPrefix(this.previousLineImageRows, lineImageRows, diffScanStart);
|
|
15955
|
+
this.previousLineSixelRows = this.mergeSkippedPrefix(this.previousLineSixelRows, lineSixelRows, diffScanStart);
|
|
15505
15956
|
return;
|
|
15506
15957
|
}
|
|
15507
15958
|
if (firstChanged >= newLines.length) {
|
|
15508
15959
|
if (this.previousLines.length > newLines.length) {
|
|
15509
15960
|
const output = new BoundedTerminalWriter((data) => this.terminal.write(data));
|
|
15510
15961
|
output.append("\x1B[?2026h");
|
|
15511
|
-
output.append(this.deleteChangedKittyImages(firstChanged, lastChanged));
|
|
15962
|
+
output.append(this.deleteChangedKittyImages(firstChanged, lastChanged, newLines));
|
|
15512
15963
|
const targetRow = Math.max(0, newLines.length - 1);
|
|
15513
|
-
if (
|
|
15514
|
-
logRedraw(`deleted lines moved viewport up (${
|
|
15964
|
+
if (frameViewportTop < prevViewportTop) {
|
|
15965
|
+
logRedraw(`deleted lines moved viewport up (${frameViewportTop} < ${prevViewportTop})`);
|
|
15515
15966
|
fullRender(true);
|
|
15516
15967
|
return;
|
|
15517
15968
|
}
|
|
@@ -15540,25 +15991,25 @@ var TuiMainScreen = class extends TuiBase {
|
|
|
15540
15991
|
this.hardwareCursorRow = targetRow;
|
|
15541
15992
|
}
|
|
15542
15993
|
this.positionHardwareCursor(cursorPos, newLines.length);
|
|
15543
|
-
this.previousLines = newLines;
|
|
15544
|
-
this.previousRawLines = rawLines;
|
|
15545
|
-
this.previousLineImageIds = lineImageIds;
|
|
15546
|
-
this.previousLineImageRows = lineImageRows;
|
|
15547
|
-
this.previousLineSixelRows = lineSixelRows;
|
|
15548
|
-
this.previousKittyImageIds = this.unionKittyImageIds(
|
|
15994
|
+
this.previousLines = this.mergeSkippedPrefix(this.previousLines, newLines, diffScanStart);
|
|
15995
|
+
this.previousRawLines = this.mergeSkippedPrefix(this.previousRawLines, rawLines, diffScanStart);
|
|
15996
|
+
this.previousLineImageIds = this.mergeSkippedPrefix(this.previousLineImageIds, lineImageIds, diffScanStart);
|
|
15997
|
+
this.previousLineImageRows = this.mergeSkippedPrefix(this.previousLineImageRows, lineImageRows, diffScanStart);
|
|
15998
|
+
this.previousLineSixelRows = this.mergeSkippedPrefix(this.previousLineSixelRows, lineSixelRows, diffScanStart);
|
|
15999
|
+
this.previousKittyImageIds = this.unionKittyImageIds(this.previousLineImageIds);
|
|
15549
16000
|
this.previousWidth = width;
|
|
15550
16001
|
this.previousHeight = height;
|
|
15551
16002
|
this.previousViewportTop = prevViewportTop;
|
|
15552
16003
|
return;
|
|
15553
16004
|
}
|
|
15554
|
-
if (firstChanged < prevViewportTop) {
|
|
15555
|
-
logRedraw(`firstChanged < viewportTop (${firstChanged} < ${prevViewportTop})`);
|
|
16005
|
+
if (firstChanged < prevViewportTop || frameViewportTop < prevViewportTop) {
|
|
16006
|
+
logRedraw(firstChanged < prevViewportTop ? `firstChanged < viewportTop (${firstChanged} < ${prevViewportTop})` : `viewport would move up (${frameViewportTop} < ${prevViewportTop})`);
|
|
15556
16007
|
fullRender(true);
|
|
15557
16008
|
return;
|
|
15558
16009
|
}
|
|
15559
16010
|
const output = new BoundedTerminalWriter((data) => this.terminal.write(data));
|
|
15560
16011
|
output.append("\x1B[?2026h");
|
|
15561
|
-
output.append(this.deleteChangedKittyImages(firstChanged, lastChanged));
|
|
16012
|
+
output.append(this.deleteChangedKittyImages(firstChanged, lastChanged, newLines));
|
|
15562
16013
|
const prevViewportBottom = prevViewportTop + height - 1;
|
|
15563
16014
|
const moveTargetRow = appendStart ? firstChanged - 1 : firstChanged;
|
|
15564
16015
|
if (moveTargetRow > prevViewportBottom) {
|
|
@@ -15681,12 +16132,12 @@ var TuiMainScreen = class extends TuiBase {
|
|
|
15681
16132
|
this.maxLinesRendered = Math.max(this.maxLinesRendered, newLines.length);
|
|
15682
16133
|
this.previousViewportTop = Math.max(prevViewportTop, finalCursorRow - height + 1);
|
|
15683
16134
|
this.positionHardwareCursor(cursorPos, newLines.length);
|
|
15684
|
-
this.previousLines = newLines;
|
|
15685
|
-
this.previousRawLines = rawLines;
|
|
15686
|
-
this.previousLineImageIds = lineImageIds;
|
|
15687
|
-
this.previousLineImageRows = lineImageRows;
|
|
15688
|
-
this.previousLineSixelRows = lineSixelRows;
|
|
15689
|
-
this.previousKittyImageIds = this.unionKittyImageIds(
|
|
16135
|
+
this.previousLines = this.mergeSkippedPrefix(this.previousLines, newLines, diffScanStart);
|
|
16136
|
+
this.previousRawLines = this.mergeSkippedPrefix(this.previousRawLines, rawLines, diffScanStart);
|
|
16137
|
+
this.previousLineImageIds = this.mergeSkippedPrefix(this.previousLineImageIds, lineImageIds, diffScanStart);
|
|
16138
|
+
this.previousLineImageRows = this.mergeSkippedPrefix(this.previousLineImageRows, lineImageRows, diffScanStart);
|
|
16139
|
+
this.previousLineSixelRows = this.mergeSkippedPrefix(this.previousLineSixelRows, lineSixelRows, diffScanStart);
|
|
16140
|
+
this.previousKittyImageIds = this.unionKittyImageIds(this.previousLineImageIds);
|
|
15690
16141
|
this.previousWidth = width;
|
|
15691
16142
|
this.previousHeight = height;
|
|
15692
16143
|
}
|
|
@@ -15714,4 +16165,4 @@ var TuiMainScreen = class extends TuiBase {
|
|
|
15714
16165
|
}
|
|
15715
16166
|
};
|
|
15716
16167
|
//#endregion
|
|
15717
|
-
export {
|
|
16168
|
+
export { parseFooterCustomItems as $, imageFallback as A, truncateToWidth as B, findAltScreenSearchMatches as C, getGraphemeSegmenter as D, getCellDimensions as E, parseKey as F, activeFooterItemIds as G, wrapTextWithAnsi as H, registerKittyImageMetadata as I, customItemName as J, customCommandConfigOf as K, renderFakeCursor as L, isKeyRelease as M, isKeyRepeat as N, getKeybindings as O, matchesKey as P, parseFooterCustomItem as Q, sliceByColumn as R, dispatchMouseEvent as S, getCapabilities as T, CUSTOM_FOOTER_ITEM_PREFIX as U, visibleWidth as V, DEFAULT_CUSTOM_COMMAND_REFRESH_MS as W, effectiveCustomCommandTimeoutMs as X, effectiveCustomCommandRefreshMs as Y, executableCommandItemIds as Z, TuiAltScreen as _, Editor as a, decodeKittyPrintable as b, Input as c, MouseRegion as d, ProcessTerminal as f, Text as g, Spacer as h, Container as i, isFocusable as j, getOsc8LinkAtColumn as k, Key as l, SettingsList as m, CURSOR_MARKER as n, HStack as o, ScrollView as p, customItemId as q, CombinedAutocompleteProvider as r, Image as s, AltScreenSearchIndex as t, Markdown as u, TuiMainScreen as v, fuzzyFilter as w, decodePrintableKey as x, VStack as y, stripTerminalSequences as z };
|