@simon_he/vue-tui 1.1.6 → 1.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +1 -0
  2. package/dist/TAgentTerminalGraphic-B8-YZfuP.js +1198 -0
  3. package/dist/{TSelect-CMBOOFwK.js → TSelect-CCsjjCOr.js} +41 -12
  4. package/dist/{TTree-kk8ntrpg.js → TTree-3W5A2_EH.js} +4 -3
  5. package/dist/TVideo-D9AOiyq2.js +948 -0
  6. package/dist/agent.cjs +4926 -4364
  7. package/dist/agent.js +11 -9
  8. package/dist/{block-source-DByORvKG.js → block-source-BhvdZomx.js} +3 -3
  9. package/dist/cli.cjs +1 -1
  10. package/dist/cli.js +8 -1
  11. package/dist/core.js +2 -2
  12. package/dist/experimental/browser.cjs +3705 -0
  13. package/dist/experimental/browser.d.cts +3 -0
  14. package/dist/experimental/browser.d.ts +3 -0
  15. package/dist/experimental/browser.js +413 -0
  16. package/dist/experimental.cjs +1 -1
  17. package/dist/experimental.js +9 -947
  18. package/dist/{linkify-CL9wwnZN.js → frame-mailbox-DaTrfyaF.js} +2 -297
  19. package/dist/index.cjs +25 -8
  20. package/dist/index.js +6 -5
  21. package/dist/linkify-CklfA1vp.js +298 -0
  22. package/dist/markdown.cjs +4907 -4362
  23. package/dist/markdown.js +4 -4
  24. package/dist/{mermaid-CWy4wtCL.js → mermaid-D0ov4_A1.js} +3 -3
  25. package/dist/mermaid.cjs +1 -1
  26. package/dist/mermaid.js +4 -4
  27. package/dist/{path-suggest-Dndu4dTi.js → path-suggest-fPzRsgPv.js} +1 -1
  28. package/dist/renderer/terminal-graphics.d.ts +1 -1
  29. package/dist/{terminal-graphics-D6KErRBY.js → terminal-graphics-DpSL29OQ.js} +1 -1
  30. package/dist/{tlog-theme-DIrlCw6m.js → tlog-theme-BnILsD3n.js} +10 -1203
  31. package/dist/vue/browser/types.d.ts +52 -0
  32. package/dist/vue/components/TBrowser.d.ts +231 -0
  33. package/dist/vue/components/input/plugins/promptMentionPlugin.d.ts +3 -0
  34. package/dist/vue.cjs +25 -8
  35. package/dist/vue.js +8 -7
  36. package/package.json +16 -2
  37. /package/dist/{TMermaidText-wLnMMvVS.js → TMermaidText-C1akgJPU.js} +0 -0
  38. /package/dist/{math-image-BZhmfUeu.js → math-image-CcUpBnW0.js} +0 -0
  39. /package/dist/{path-mnSgEpCm.js → path-BI9W15Zt.js} +0 -0
  40. /package/dist/{wheel-scroll-DASkEZr-.js → wheel-scroll-CQ22Hcyj.js} +0 -0
@@ -1,12 +1,12 @@
1
1
  import { applyAnsiSgrStyle, parseAnsiSgr } from "./create-terminal-Db_-UGVQ.js";
2
2
  import { sanitizeTerminalHref } from "./hyperlink-clbb_ha_.js";
3
- import { EventZIndexContextKey, LayoutContextKey, RenderPlaneContextKey, RenderStackKey, TerminalGraphicsActivityKey, createCombinedTerminalGraphicsActivity, createTerminalGraphicsActivity, forEachTextCellSegment, formatInlineCellLine, intersectRect, normalizeCellRect, nowTerminalGraphicTraceTime, padEndByCells$1 as padEndByCells, recordTerminalGraphicTrace, sanitizeInlineText, sanitizeTextBlock, sliceByCells, sliceByCellsRange, spaces, textCellWidth$1 as textCellWidth, translateRect, useLayout, useRenderNode, useRenderStack, useTerminal, useTerminalNode, useVisibility, withTextWidthProvider, wrapByCells } from "./rect-JzWMJxxc.js";
4
- import { TView, TuiThemeContextKey, createFrameMailbox, defaultActiveStyle, linkifyTextSegments, tuiDefaultTheme } from "./linkify-CL9wwnZN.js";
3
+ import { EventZIndexContextKey, LayoutContextKey, RenderPlaneContextKey, RenderStackKey, TerminalGraphicsActivityKey, createCombinedTerminalGraphicsActivity, createTerminalGraphicsActivity, forEachTextCellSegment, formatInlineCellLine, intersectRect, normalizeCellRect, padEndByCells$1 as padEndByCells, sanitizeInlineText, sliceByCellsRange, spaces, textCellWidth$1 as textCellWidth, translateRect, useLayout, useRenderNode, useRenderStack, useTerminal, useTerminalNode, useVisibility, wrapByCells } from "./rect-JzWMJxxc.js";
4
+ import { TuiThemeContextKey, defaultActiveStyle, linkifyTextSegments, tuiDefaultTheme } from "./linkify-CklfA1vp.js";
5
5
  import { framePerfNow } from "./frame-perf-CHpWhbC4.js";
6
6
  import { terminalSelectionRowSpans, terminalSelectionVisibleRowSpans } from "./terminal-selection-4W1SJj4c.js";
7
- import { applyWheelScroll, createWheelScrollState, resetWheelScrollState } from "./wheel-scroll-DASkEZr-.js";
8
- import { canDrawTerminalGraphicRect, createKittyDeleteGraphicsSequence, createKittyPlacementSequence, getTerminalGraphicsOutput, getTerminalGraphicsOutputVersion, isSafeTerminalGraphicsSequence, isTerminalGraphicsProtocol, normalizeTerminalGraphicSize, sanitizeTerminalFallbackText, stableTerminalGraphicNumericId, subscribeTerminalGraphicsOutput } from "./terminal-graphics-D6KErRBY.js";
9
- import { computed, defineComponent, getCurrentInstance, h, inject, markRaw, onBeforeUnmount, provide, ref, shallowReactive, shallowRef, watch, watchEffect } from "vue";
7
+ import { TView, createFrameMailbox } from "./frame-mailbox-DaTrfyaF.js";
8
+ import { applyWheelScroll, createWheelScrollState, resetWheelScrollState } from "./wheel-scroll-CQ22Hcyj.js";
9
+ import { computed, defineComponent, getCurrentInstance, h, inject, onBeforeUnmount, provide, ref, shallowReactive, watch, watchEffect } from "vue";
10
10
 
11
11
  //#region src/vue/utils/row-scroll.ts
12
12
  function exposedRowsForDelta(y0, h$1, delta) {
@@ -783,1199 +783,6 @@ const TVirtualList = defineComponent({
783
783
  }
784
784
  });
785
785
 
786
- //#endregion
787
- //#region src/vue/components/TAgentTerminalGraphic.ts
788
- const NO_GRAPHICS_CAPABILITIES = Object.freeze({
789
- supported: false,
790
- kitty: false,
791
- iterm2: false,
792
- sixel: false,
793
- preferredProtocol: null,
794
- protocol: "unicode",
795
- candidates: [],
796
- stdoutIsTTY: false,
797
- insideTmux: false,
798
- insideScreen: false,
799
- insideZellij: false,
800
- multiplexer: null,
801
- passthrough: false,
802
- forced: false,
803
- reason: "no-terminal-graphics-output"
804
- });
805
- function splitTextOutput(value) {
806
- const normalized = sanitizeTextBlock(sanitizeTerminalFallbackText(value).replace(/\r\n?/g, "\n"));
807
- const lines = normalized.split("\n");
808
- return lines.length ? lines : [""];
809
- }
810
- function hasVisibleOutput(value) {
811
- return value.some((line) => line.trim().length > 0);
812
- }
813
- function errorMessage(error) {
814
- return error instanceof Error ? error.message : String(error);
815
- }
816
- function positiveInt(value) {
817
- const n = Math.floor(Number(value));
818
- return Number.isFinite(n) && n > 0 ? n : void 0;
819
- }
820
- function finiteInt(value) {
821
- const n = Math.floor(Number(value));
822
- return Number.isFinite(n) ? n : void 0;
823
- }
824
- function clampNumber(value, min, max) {
825
- return Math.max(min, Math.min(max, value));
826
- }
827
- function rectArea(rect) {
828
- return Math.max(0, rect.w) * Math.max(0, rect.h);
829
- }
830
- function sameRect(a, b) {
831
- return a.x === b.x && a.y === b.y && a.w === b.w && a.h === b.h;
832
- }
833
- function subtractRect(rect, cover) {
834
- const hit = intersectRect(rect, cover);
835
- if (!hit) return [rect];
836
- const out = [];
837
- const rectRight = rect.x + rect.w;
838
- const rectBottom = rect.y + rect.h;
839
- const hitRight = hit.x + hit.w;
840
- const hitBottom = hit.y + hit.h;
841
- if (hit.y > rect.y) out.push({
842
- x: rect.x,
843
- y: rect.y,
844
- w: rect.w,
845
- h: hit.y - rect.y
846
- });
847
- if (hitBottom < rectBottom) out.push({
848
- x: rect.x,
849
- y: hitBottom,
850
- w: rect.w,
851
- h: rectBottom - hitBottom
852
- });
853
- if (hit.x > rect.x) out.push({
854
- x: rect.x,
855
- y: hit.y,
856
- w: hit.x - rect.x,
857
- h: hit.h
858
- });
859
- if (hitRight < rectRight) out.push({
860
- x: hitRight,
861
- y: hit.y,
862
- w: rectRight - hitRight,
863
- h: hit.h
864
- });
865
- return out.filter((part) => part.w > 0 && part.h > 0);
866
- }
867
- function largestUncoveredRect(rect, covers) {
868
- let parts = [rect];
869
- for (const cover of covers) {
870
- parts = parts.flatMap((part) => subtractRect(part, cover));
871
- if (!parts.length) return null;
872
- }
873
- parts.sort((a, b) => rectArea(b) - rectArea(a) || a.y - b.y || a.x - b.x);
874
- return parts[0] ?? null;
875
- }
876
- function parseKittyClearControls(sequence) {
877
- const prefix = "\x1B_G";
878
- const terminator = "\x1B\\";
879
- if (!sequence.startsWith(prefix) || !sequence.endsWith(terminator)) return null;
880
- const body = sequence.slice(prefix.length, -terminator.length);
881
- if (body.includes(terminator) || body.includes("\x1B") || body.includes("\x07")) return null;
882
- const semicolon = body.indexOf(";");
883
- const rawControls = semicolon >= 0 ? body.slice(0, semicolon) : body;
884
- const controls = new Map();
885
- for (const part of rawControls.split(",")) {
886
- const eq = part.indexOf("=");
887
- if (eq <= 0) return null;
888
- controls.set(part.slice(0, eq), part.slice(eq + 1));
889
- }
890
- return controls;
891
- }
892
- function kittyClearTargetsComponent(sequence, imageId, placementId) {
893
- const controls = parseKittyClearControls(sequence);
894
- if (!controls) return false;
895
- const mode = controls.get("d");
896
- if (mode !== "i" && mode !== "I") return false;
897
- return controls.get("i") === String(imageId) && controls.get("p") === String(placementId);
898
- }
899
- function isSafeComponentClearSequence(sequence, protocol, imageId, placementId) {
900
- if (!isSafeTerminalGraphicsSequence(sequence, protocol, "clear")) return false;
901
- return protocol !== "kitty" || kittyClearTargetsComponent(sequence, imageId, placementId);
902
- }
903
- let textEncoder = null;
904
- function stringByteLength(value) {
905
- if (typeof TextEncoder !== "undefined") {
906
- textEncoder ?? (textEncoder = new TextEncoder());
907
- return textEncoder.encode(value).length;
908
- }
909
- let bytes = 0;
910
- for (let index = 0; index < value.length; index++) {
911
- const code = value.charCodeAt(index);
912
- if (code <= 127) bytes += 1;
913
- else if (code <= 2047) bytes += 2;
914
- else if (code >= 55296 && code <= 56319 && index + 1 < value.length) {
915
- bytes += 4;
916
- index++;
917
- } else bytes += 3;
918
- }
919
- return bytes;
920
- }
921
- function smallHash(input) {
922
- let hash = 2166136261;
923
- for (let i = 0; i < input.length; i++) {
924
- hash ^= input.charCodeAt(i);
925
- hash = Math.imul(hash, 16777619);
926
- }
927
- return (hash >>> 0).toString(36);
928
- }
929
- const tAgentTerminalGraphicProps = {
930
- x: {
931
- type: Number,
932
- required: true
933
- },
934
- y: {
935
- type: Number,
936
- required: true
937
- },
938
- w: {
939
- type: Number,
940
- required: true
941
- },
942
- h: {
943
- type: Number,
944
- default: void 0
945
- },
946
- zIndex: {
947
- type: Number,
948
- default: 0
949
- },
950
- content: {
951
- type: String,
952
- required: true
953
- },
954
- kind: {
955
- type: String,
956
- default: "image"
957
- },
958
- fallback: {
959
- type: String,
960
- default: void 0
961
- },
962
- style: {
963
- type: Object,
964
- default: void 0
965
- },
966
- loadingStyle: {
967
- type: Object,
968
- default: void 0
969
- },
970
- errorStyle: {
971
- type: Object,
972
- default: void 0
973
- },
974
- clear: {
975
- type: Boolean,
976
- default: true
977
- },
978
- final: {
979
- type: Boolean,
980
- default: true
981
- },
982
- streaming: {
983
- type: Boolean,
984
- default: false
985
- },
986
- renderer: {
987
- type: Function,
988
- default: void 0
989
- },
990
- loadingText: {
991
- type: String,
992
- default: "Rendering terminal graphic..."
993
- },
994
- deferRenderUntilVisible: {
995
- type: Boolean,
996
- default: true
997
- },
998
- suspendRawWhileScrolling: {
999
- type: Boolean,
1000
- default: true
1001
- },
1002
- suspendRenderWhileScrolling: {
1003
- type: Boolean,
1004
- default: true
1005
- },
1006
- scrolling: {
1007
- type: Boolean,
1008
- default: false
1009
- },
1010
- scrollVersion: {
1011
- type: Number,
1012
- default: 0
1013
- },
1014
- placementMoveWithoutClear: {
1015
- type: Boolean,
1016
- default: false
1017
- },
1018
- preserveRawWhileRendering: {
1019
- type: Boolean,
1020
- default: false
1021
- },
1022
- suspended: {
1023
- type: Boolean,
1024
- default: false
1025
- },
1026
- retainRawWhileCovered: {
1027
- type: Boolean,
1028
- default: false
1029
- },
1030
- ignoreRawCoverage: {
1031
- type: Boolean,
1032
- default: false
1033
- },
1034
- ignoreSamePlaneRawCoverage: {
1035
- type: Boolean,
1036
- default: false
1037
- },
1038
- cacheKey: {
1039
- type: String,
1040
- default: void 0
1041
- },
1042
- placementKey: {
1043
- type: String,
1044
- default: void 0
1045
- },
1046
- trace: {
1047
- type: Function,
1048
- default: void 0
1049
- }
1050
- };
1051
- function terminalDrawKey(current, rect, clearSequence, resizeSequence) {
1052
- return [
1053
- current.protocol,
1054
- rect.x,
1055
- rect.y,
1056
- rect.w,
1057
- rect.h,
1058
- current.sequenceHash,
1059
- clearSequence === current.clearSequence ? current.clearSequenceHash ?? "" : smallHash(clearSequence ?? ""),
1060
- resizeSequence === current.resizeSequence ? current.resizeSequenceHash ?? "" : smallHash(resizeSequence ?? "")
1061
- ].join(":");
1062
- }
1063
- const TAgentTerminalGraphic = defineComponent({
1064
- name: "TAgentTerminalGraphic",
1065
- props: tAgentTerminalGraphicProps,
1066
- setup(props) {
1067
- const instance = getCurrentInstance();
1068
- const { terminal, defaultStyle, scheduler, widthProvider, render } = useTerminal();
1069
- const layout = useLayout();
1070
- const { visible, rootProps } = useVisibility();
1071
- const graphicsActivity = inject(TerminalGraphicsActivityKey, null);
1072
- const status = shallowRef("idle");
1073
- const error = shallowRef("");
1074
- const graphic = shallowRef(null);
1075
- const documentVersion = shallowRef(0);
1076
- let builtOnce = false;
1077
- let renderVersion = 0;
1078
- let renderAbort = null;
1079
- let alive = true;
1080
- let lastRenderedContent = "";
1081
- let lastRenderRawVisible = false;
1082
- let lastRenderProtocol = null;
1083
- let lastRenderGraphicsOutputVersion = 0;
1084
- const rawIdSeed = props.placementKey ? `placement:${props.placementKey}` : props.cacheKey ? `cache:${props.cacheKey}` : `instance:${instance?.uid ?? "unknown"}`;
1085
- const rawId = `TAgentTerminalGraphic:${smallHash(rawIdSeed)}`;
1086
- const frameTaskId = `${rawId}:render`;
1087
- const lastDrawnGraphic = shallowRef(null);
1088
- const rawClearPendingRepaint = shallowRef(null);
1089
- const rawDrawRejectedKey = shallowRef(null);
1090
- const reservedTerminalGraphicSize = shallowRef(null);
1091
- const terminalSizeVersion = shallowRef(0);
1092
- const renderNodeId = shallowRef(null);
1093
- let lastRawSkipScrollKey = "";
1094
- let lastDeferTraceKey = "";
1095
- const isParentScrolling = computed(() => props.scrolling || Boolean(graphicsActivity?.scrolling.value));
1096
- const graphicsActivityVersion = computed(() => (graphicsActivity?.version.value ?? 0) + Math.floor(Number(props.scrollVersion ?? 0)));
1097
- const graphicsOutput = () => getTerminalGraphicsOutput(terminal);
1098
- const graphicsOutputVersion = shallowRef(getTerminalGraphicsOutputVersion(terminal));
1099
- const unsubscribeGraphicsOutput = subscribeTerminalGraphicsOutput(terminal, () => {
1100
- graphicsOutputVersion.value = getTerminalGraphicsOutputVersion(terminal);
1101
- });
1102
- const unsubscribeTerminalResize = terminal.on("resize", () => {
1103
- terminalSizeVersion.value++;
1104
- });
1105
- const fallbackText = () => props.fallback ?? (props.kind === "math" ? props.content : "");
1106
- const contentIdentity = computed(() => `${props.content.length}:${smallHash(props.content)}`);
1107
- const stableGraphicKey = computed(() => [
1108
- rawIdSeed,
1109
- props.cacheKey ?? "",
1110
- props.kind,
1111
- contentIdentity.value,
1112
- props.w,
1113
- props.h ?? "",
1114
- props.final ? "final" : "draft"
1115
- ].join(""));
1116
- const imageId = computed(() => stableTerminalGraphicNumericId(`image:${stableGraphicKey.value}`));
1117
- const placementId = computed(() => stableTerminalGraphicNumericId(`placement:${stableGraphicKey.value}`));
1118
- function rememberTerminalGraphicSize(current) {
1119
- if (current.type !== "terminal") return;
1120
- const rows = positiveInt(current.rows);
1121
- if (!rows) return;
1122
- reservedTerminalGraphicSize.value = {
1123
- key: stableGraphicKey.value,
1124
- rows
1125
- };
1126
- }
1127
- function bump() {
1128
- documentVersion.value++;
1129
- }
1130
- function currentCapabilities() {
1131
- return graphicsOutput()?.capabilities ?? NO_GRAPHICS_CAPABILITIES;
1132
- }
1133
- function trace(type, extra = {}) {
1134
- const capabilities = currentCapabilities();
1135
- try {
1136
- props.trace?.({
1137
- type,
1138
- id: rawId,
1139
- kind: props.kind,
1140
- protocol: capabilities.protocol,
1141
- contentHash: smallHash(props.content),
1142
- ...extra
1143
- });
1144
- } catch {}
1145
- const protocol = isTerminalGraphicsProtocol(capabilities.protocol) ? capabilities.protocol : void 0;
1146
- const key = props.cacheKey ?? smallHash(props.content);
1147
- if (type === "render-start") recordTerminalGraphicTrace({
1148
- type: "renderer-start",
1149
- id: rawId,
1150
- key,
1151
- protocol
1152
- });
1153
- else if (type === "render-end") recordTerminalGraphicTrace({
1154
- type: extra.reason ? "renderer-error" : "renderer-end",
1155
- id: rawId,
1156
- key,
1157
- protocol,
1158
- durationMs: extra.durationMs,
1159
- bytes: extra.sequenceBytes,
1160
- error: extra.reason
1161
- });
1162
- else if (type === "defer") recordTerminalGraphicTrace({
1163
- type: extra.reason === "scrolling" ? "skip-scrolling" : "skip-hidden",
1164
- id: rawId,
1165
- key,
1166
- protocol,
1167
- reason: extra.reason
1168
- });
1169
- else if (type === "raw-draw") {} else if (type === "render-abort") recordTerminalGraphicTrace({
1170
- type: "renderer-abort",
1171
- id: rawId,
1172
- key,
1173
- protocol,
1174
- reason: extra.reason
1175
- });
1176
- else if (type === "raw-clear") recordTerminalGraphicTrace({
1177
- type: "clear",
1178
- id: rawId,
1179
- key,
1180
- protocol
1181
- });
1182
- else if (type === "raw-skip-scroll") recordTerminalGraphicTrace({
1183
- type: "skip-scrolling",
1184
- id: rawId,
1185
- key,
1186
- protocol,
1187
- reason: extra.reason
1188
- });
1189
- }
1190
- function traceDeferOnce(reason) {
1191
- const key = [
1192
- reason,
1193
- graphicsActivityVersion.value,
1194
- stableGraphicKey.value
1195
- ].join(":");
1196
- if (lastDeferTraceKey === key) return;
1197
- lastDeferTraceKey = key;
1198
- trace("defer", { reason });
1199
- }
1200
- function abortCurrentRender(reason) {
1201
- if (!renderAbort) return;
1202
- renderAbort.abort();
1203
- renderAbort = null;
1204
- trace("render-abort", { reason });
1205
- }
1206
- function normalizeResult(result) {
1207
- if (result == null) return {
1208
- type: "text",
1209
- text: fallbackText()
1210
- };
1211
- if (typeof result === "string") return {
1212
- type: "text",
1213
- text: result
1214
- };
1215
- if (typeof result !== "object") return {
1216
- type: "text",
1217
- text: fallbackText()
1218
- };
1219
- if ("type" in result && result.type === "text") return {
1220
- type: "text",
1221
- text: result.text
1222
- };
1223
- const maybeRaw = result;
1224
- const isRawCandidate = maybeRaw.type === "sequence" || "sequence" in result || "protocol" in result;
1225
- if (!isRawCandidate && "text" in result) return {
1226
- type: "text",
1227
- text: result.text
1228
- };
1229
- const sequence = typeof maybeRaw.sequence === "string" ? maybeRaw.sequence : "";
1230
- const protocol = isTerminalGraphicsProtocol(maybeRaw.protocol) ? maybeRaw.protocol : null;
1231
- const fallback = typeof maybeRaw.fallback === "string" ? sanitizeTerminalFallbackText(maybeRaw.fallback) : fallbackText();
1232
- const fallbackFromProps = typeof maybeRaw.fallback !== "string";
1233
- if (!sequence || !protocol || !isSafeTerminalGraphicsSequence(sequence, protocol, "draw")) return {
1234
- type: "text",
1235
- text: fallback
1236
- };
1237
- const rawClear = typeof maybeRaw.clearSequence === "string" ? maybeRaw.clearSequence : void 0;
1238
- const clearSequence = rawClear && isSafeComponentClearSequence(rawClear, protocol, imageId.value, placementId.value) ? rawClear : void 0;
1239
- const rawResize = typeof maybeRaw.resizeSequence === "string" ? maybeRaw.resizeSequence : void 0;
1240
- const resizeSequence = rawResize && isSafeTerminalGraphicsSequence(rawResize, protocol, "draw") ? rawResize : void 0;
1241
- const declaredRows = positiveInt(maybeRaw.rows);
1242
- const declaredCols = positiveInt(maybeRaw.cols);
1243
- const sourceWidth = positiveInt(maybeRaw.sourceWidth);
1244
- const sourceHeight = positiveInt(maybeRaw.sourceHeight);
1245
- const zIndex = finiteInt(maybeRaw.zIndex);
1246
- const declaredSize = declaredRows == null ? null : normalizeTerminalGraphicSize(declaredCols ?? props.w, declaredRows);
1247
- return {
1248
- type: "terminal",
1249
- protocol,
1250
- sequence,
1251
- sequenceHash: smallHash(sequence),
1252
- sequenceBytes: stringByteLength(sequence),
1253
- fallback,
1254
- fallbackFromProps,
1255
- clearSequence,
1256
- clearSequenceHash: clearSequence ? smallHash(clearSequence) : void 0,
1257
- resizeSequence,
1258
- resizeSequenceHash: resizeSequence ? smallHash(resizeSequence) : void 0,
1259
- cols: declaredRows == null ? declaredCols : declaredSize?.width,
1260
- rows: declaredSize?.height,
1261
- sourceWidth,
1262
- sourceHeight,
1263
- zIndex
1264
- };
1265
- }
1266
- function defaultClearSequence(protocol) {
1267
- return protocol === "kitty" ? createKittyDeleteGraphicsSequence({
1268
- imageId: imageId.value,
1269
- placementId: placementId.value
1270
- }) : "";
1271
- }
1272
- function resolveClearSequence(current) {
1273
- if (current.clearSequence) return current.clearSequence;
1274
- const candidate = defaultClearSequence(current.protocol);
1275
- if (!candidate) return void 0;
1276
- return isSafeComponentClearSequence(candidate, current.protocol, imageId.value, placementId.value) ? candidate : void 0;
1277
- }
1278
- function resolveResizeSequence(current, rect, full) {
1279
- if (current.protocol !== "kitty") return current.resizeSequence;
1280
- const sourceWidth = positiveInt(current.sourceWidth);
1281
- const sourceHeight = positiveInt(current.sourceHeight);
1282
- if (!sourceWidth || !sourceHeight || full.w <= 0 || full.h <= 0) return current.resizeSequence;
1283
- const offsetX = Math.max(0, rect.x - full.x);
1284
- const offsetY = Math.max(0, rect.y - full.y);
1285
- const visibleW = Math.max(0, Math.min(rect.w, full.w - offsetX));
1286
- const visibleH = Math.max(0, Math.min(rect.h, full.h - offsetY));
1287
- const x0 = clampNumber(Math.floor(offsetX * sourceWidth / full.w), 0, sourceWidth - 1);
1288
- const y0 = clampNumber(Math.floor(offsetY * sourceHeight / full.h), 0, sourceHeight - 1);
1289
- const x1 = Math.max(x0 + 1, clampNumber(Math.ceil((offsetX + visibleW) * sourceWidth / full.w), 1, sourceWidth));
1290
- const y1 = Math.max(y0 + 1, clampNumber(Math.ceil((offsetY + visibleH) * sourceHeight / full.h), 1, sourceHeight));
1291
- return createKittyPlacementSequence({
1292
- imageId: imageId.value,
1293
- placementId: placementId.value,
1294
- columns: rect.w,
1295
- rows: rect.h,
1296
- sourceX: x0,
1297
- sourceY: y0,
1298
- sourceWidth: x1 - x0,
1299
- sourceHeight: y1 - y0,
1300
- zIndex: current.zIndex
1301
- });
1302
- }
1303
- function queueClearLastGraphic(options = {}) {
1304
- const previous = lastDrawnGraphic.value;
1305
- if (!previous) return false;
1306
- const output = graphicsOutput();
1307
- let accepted = false;
1308
- if (output?.clear && !previous.retainOnClear) try {
1309
- accepted = Boolean(output.clear(previous.id));
1310
- } catch {
1311
- accepted = false;
1312
- }
1313
- if (!accepted && output && previous.clearSequence) try {
1314
- accepted = output.queue({
1315
- id: previous.id,
1316
- x: previous.x,
1317
- y: previous.y,
1318
- w: previous.w,
1319
- h: previous.h,
1320
- protocol: previous.protocol,
1321
- sequence: previous.clearSequence,
1322
- deferFlush: true,
1323
- retainOnClear: previous.retainOnClear,
1324
- op: "clear"
1325
- });
1326
- } catch {
1327
- accepted = false;
1328
- }
1329
- if (accepted) {
1330
- if (options.markPendingRepaint ?? true) rawClearPendingRepaint.value = previous;
1331
- lastDrawnGraphic.value = null;
1332
- trace("raw-clear", {
1333
- x: previous.x,
1334
- y: previous.y,
1335
- w: previous.w,
1336
- h: previous.h
1337
- });
1338
- }
1339
- return accepted;
1340
- }
1341
- function queueDrawGraphic(output, current, rect, full = rect, options = {}) {
1342
- const clearSequence = resolveClearSequence(current);
1343
- const resizeSequence = resolveResizeSequence(current, rect, full);
1344
- const drawKey = terminalDrawKey(current, rect, clearSequence, resizeSequence);
1345
- const activePrevious = lastDrawnGraphic.value;
1346
- const retainedPrevious = rawClearPendingRepaint.value;
1347
- const previous = activePrevious ?? retainedPrevious;
1348
- const previousIsRetained = activePrevious == null && retainedPrevious != null;
1349
- const previousStillActive = previous ? typeof output.isActive === "function" ? output.isActive(previous.id) : true : false;
1350
- const preservePreviousForAtomicReplace = props.preserveRawWhileRendering && activePrevious != null && !previousIsRetained && previousStillActive;
1351
- if (!previousIsRetained && !options.force && previous?.drawKey === drawKey && previousStillActive) return false;
1352
- const canReusePlacementSequence = previousStillActive && previous?.protocol === current.protocol && previous.sequenceHash === current.sequenceHash && current.protocol === "kitty" && Boolean(resizeSequence);
1353
- const scrollVersion = Math.floor(Number(props.scrollVersion ?? 0));
1354
- const canMoveWithoutClear = canReusePlacementSequence && Boolean(options.placementMoveWithoutClear);
1355
- if (!previousIsRetained && previousStillActive && !resizeSequence && previous?.protocol === current.protocol && previous.sequenceHash === current.sequenceHash && previous.x === rect.x && previous.y === rect.y && rect.w <= previous.w && rect.h <= previous.h && (options.force || !sameRect(rect, full))) {
1356
- lastDrawnGraphic.value = {
1357
- ...previous,
1358
- w: rect.w,
1359
- h: rect.h,
1360
- clearSequence,
1361
- resizeSequence,
1362
- drawKey,
1363
- activityVersion: graphicsActivityVersion.value,
1364
- scrollVersion
1365
- };
1366
- lastRawSkipScrollKey = "";
1367
- return false;
1368
- }
1369
- if (previousStillActive && !previousIsRetained && !canReusePlacementSequence && !preservePreviousForAtomicReplace) {
1370
- if (!queueClearLastGraphic({ markPendingRepaint: false })) return false;
1371
- } else if (previous) {
1372
- if (!previousStillActive) {
1373
- lastDrawnGraphic.value = null;
1374
- rawClearPendingRepaint.value = null;
1375
- }
1376
- }
1377
- let accepted = false;
1378
- try {
1379
- accepted = output.queue({
1380
- id: rawId,
1381
- x: rect.x,
1382
- y: rect.y,
1383
- w: rect.w,
1384
- h: rect.h,
1385
- protocol: current.protocol,
1386
- sequence: canReusePlacementSequence && resizeSequence ? resizeSequence : current.sequence,
1387
- resizeSequence,
1388
- clearSequence,
1389
- retainOnClear: Boolean(props.cacheKey && resizeSequence),
1390
- resizeRedraw: canReusePlacementSequence,
1391
- placementMoveWithoutClear: canMoveWithoutClear,
1392
- allowTextOverlay: options.allowTextOverlay,
1393
- forceDraw: options.force,
1394
- deferFlush: options.deferFlush ?? true,
1395
- fallbackText: current.fallback
1396
- });
1397
- } catch {
1398
- accepted = false;
1399
- }
1400
- if (!accepted) {
1401
- if (preservePreviousForAtomicReplace) {
1402
- lastDrawnGraphic.value = activePrevious;
1403
- queueClearLastGraphic({ markPendingRepaint: false });
1404
- } else lastDrawnGraphic.value = null;
1405
- if (rawDrawRejectedKey.value !== drawKey) {
1406
- rawDrawRejectedKey.value = drawKey;
1407
- scheduler.invalidate({
1408
- priority: "low",
1409
- reason: "data"
1410
- });
1411
- }
1412
- return false;
1413
- }
1414
- rawDrawRejectedKey.value = null;
1415
- rawClearPendingRepaint.value = null;
1416
- lastDrawnGraphic.value = {
1417
- id: rawId,
1418
- x: rect.x,
1419
- y: rect.y,
1420
- w: rect.w,
1421
- h: rect.h,
1422
- protocol: current.protocol,
1423
- sequenceHash: current.sequenceHash,
1424
- clearSequence,
1425
- resizeSequence,
1426
- retainOnClear: Boolean(props.cacheKey && resizeSequence),
1427
- allowTextOverlay: Boolean(options.allowTextOverlay),
1428
- drawKey,
1429
- activityVersion: graphicsActivityVersion.value,
1430
- scrollVersion
1431
- };
1432
- lastRawSkipScrollKey = "";
1433
- return true;
1434
- }
1435
- function hasRetainedActiveRawGraphic() {
1436
- const output = graphicsOutput();
1437
- return Boolean(status.value === "loading" && !graphic.value && output && typeof output.isActive === "function" && output.isActive(rawId));
1438
- }
1439
- const showingInitialLoadingText = computed(() => status.value === "loading" && !graphic.value && !hasRetainedActiveRawGraphic());
1440
- const fullRect = computed(() => {
1441
- const current = graphic.value;
1442
- const reserved = reservedTerminalGraphicSize.value;
1443
- const reservedRows = current?.type === "terminal" ? void 0 : status.value === "idle" && reserved?.key === stableGraphicKey.value ? reserved.rows : void 0;
1444
- const textLines = current?.type === "text" ? splitTextOutput(current.text) : splitTextOutput(fallbackText());
1445
- const height = props.h ?? (current?.type === "terminal" ? current.rows : void 0) ?? reservedRows ?? Math.max(1, textLines.length);
1446
- return translateRect({
1447
- x: props.x,
1448
- y: props.y,
1449
- w: props.w,
1450
- h: height
1451
- }, layout.originX, layout.originY);
1452
- });
1453
- const absRect = computed(() => {
1454
- terminalSizeVersion.value;
1455
- const translated = fullRect.value;
1456
- const size = terminal.size();
1457
- const terminalClip = {
1458
- x: 0,
1459
- y: 0,
1460
- w: Math.max(0, Math.floor(size.cols)),
1461
- h: Math.max(0, Math.floor(size.rows))
1462
- };
1463
- const clip = layout.clipRect ? intersectRect(layout.clipRect, terminalClip) : terminalClip;
1464
- if (!clip) return {
1465
- x: 0,
1466
- y: 0,
1467
- w: 0,
1468
- h: 0
1469
- };
1470
- return intersectRect(translated, clip) ?? {
1471
- x: 0,
1472
- y: 0,
1473
- w: 0,
1474
- h: 0
1475
- };
1476
- });
1477
- const renderRect = computed(() => absRect.value);
1478
- function rawRectFitsTerminalViewport(rect) {
1479
- return canDrawTerminalGraphicRect(rect, terminal.size());
1480
- }
1481
- function rawCoveredByHigherRenderNode(rect = fullRect.value) {
1482
- if (props.retainRawWhileCovered) return false;
1483
- const id = renderNodeId.value;
1484
- return !props.ignoreRawCoverage && id != null && render.isRectCoveredByHigherNode(id, rect, { ignoreSamePlane: props.ignoreSamePlaneRawCoverage });
1485
- }
1486
- function retainedRawCoveredByHigherRenderNode(rect) {
1487
- if (!props.retainRawWhileCovered) return false;
1488
- const id = renderNodeId.value;
1489
- return Boolean(id != null && render.isRectCoveredByHigherNode(id, rect, { ignoreSamePlane: props.ignoreSamePlaneRawCoverage }));
1490
- }
1491
- function rawUncoveredRenderRect(rect) {
1492
- if (props.retainRawWhileCovered) return rect;
1493
- const id = renderNodeId.value;
1494
- if (id == null) return rect;
1495
- const covers = render.higherNodeCoverageRects(id, rect, { ignoreSamePlane: props.ignoreSamePlaneRawCoverage });
1496
- if (!covers.length) return rect;
1497
- if (!props.ignoreRawCoverage) return null;
1498
- return largestUncoveredRect(rect, covers);
1499
- }
1500
- const rawCanRender = computed(() => {
1501
- graphicsOutputVersion.value;
1502
- terminalSizeVersion.value;
1503
- const current = graphic.value;
1504
- const output = graphicsOutput();
1505
- const rect = absRect.value;
1506
- return current?.type === "terminal" && rawRectFitsTerminalViewport(rect) && Boolean(output?.capabilities.supported) && output?.capabilities.preferredProtocol === current.protocol;
1507
- });
1508
- const rawOutputCanRenderValue = computed(() => {
1509
- graphicsOutputVersion.value;
1510
- terminalSizeVersion.value;
1511
- return rawOutputCanRender();
1512
- });
1513
- const rawSuppressedByScroll = computed(() => props.suspended || props.suspendRawWhileScrolling && isParentScrolling.value);
1514
- const rawCanQueue = computed(() => rawCanRender.value && !rawSuppressedByScroll.value);
1515
- function traceRawSkipScrollOnce(reason) {
1516
- const r = absRect.value;
1517
- const key = [
1518
- reason,
1519
- graphicsActivityVersion.value,
1520
- stableGraphicKey.value,
1521
- r.x,
1522
- r.y,
1523
- r.w,
1524
- r.h
1525
- ].join(":");
1526
- if (lastRawSkipScrollKey === key) return;
1527
- lastRawSkipScrollKey = key;
1528
- trace("raw-skip-scroll", { reason });
1529
- }
1530
- function hasPaintableRect() {
1531
- const r = absRect.value;
1532
- return visible.value && r.w > 0 && r.h > 0;
1533
- }
1534
- function rawOutputCanRender() {
1535
- const output = graphicsOutput();
1536
- const rect = absRect.value;
1537
- return rawRectFitsTerminalViewport(rect) && Boolean(output?.capabilities.supported);
1538
- }
1539
- function renderDeferReason() {
1540
- if (props.suspended) return "suspended";
1541
- if (props.deferRenderUntilVisible && !hasPaintableRect()) return "not-visible";
1542
- if (props.suspendRenderWhileScrolling && isParentScrolling.value) return "scrolling";
1543
- return null;
1544
- }
1545
- function shouldDeferRender() {
1546
- return renderDeferReason() != null;
1547
- }
1548
- function shouldRerenderForGraphicsOutputChange() {
1549
- if (!props.renderer) return false;
1550
- if (!props.content.trim()) return false;
1551
- if (shouldDeferRender()) return false;
1552
- if (rawSuppressedByScroll.value) return false;
1553
- const protocol = currentCapabilities().protocol;
1554
- return lastRenderProtocol != null && (lastRenderProtocol !== protocol || lastRenderGraphicsOutputVersion !== graphicsOutputVersion.value);
1555
- }
1556
- function shouldRetryTemporaryRawFallback(rawCovered = rawCoveredByHigherRenderNode()) {
1557
- return Boolean(props.renderer) && props.content.trim().length > 0 && graphic.value?.type === "text" && status.value !== "loading" && !lastRenderRawVisible && rawOutputCanRenderValue.value && !rawSuppressedByScroll.value && !rawCovered;
1558
- }
1559
- function setDeferredFallback(content) {
1560
- graphic.value = {
1561
- type: "text",
1562
- text: content.trim() ? fallbackText() : ""
1563
- };
1564
- lastRenderedContent = content;
1565
- status.value = "idle";
1566
- error.value = "";
1567
- bump();
1568
- }
1569
- function resolveRendererContext(signal) {
1570
- const capabilities = currentCapabilities();
1571
- const visibleNow = hasPaintableRect();
1572
- const rawVisible = rawOutputCanRenderValue.value && !rawSuppressedByScroll.value && !rawCoveredByHigherRenderNode();
1573
- return {
1574
- kind: props.kind,
1575
- width: props.w,
1576
- height: props.h,
1577
- final: props.final,
1578
- streaming: props.streaming,
1579
- protocol: capabilities.protocol,
1580
- capabilities,
1581
- signal,
1582
- imageId: imageId.value,
1583
- placementId: placementId.value,
1584
- visible: visibleNow,
1585
- rawVisible,
1586
- scrolling: isParentScrolling.value,
1587
- cacheKey: props.cacheKey,
1588
- viewport: {
1589
- visible: visibleNow,
1590
- rawVisible,
1591
- scrolling: isParentScrolling.value,
1592
- rect: absRect.value,
1593
- fullRect: fullRect.value
1594
- }
1595
- };
1596
- }
1597
- async function renderNow(version) {
1598
- const protocol = currentCapabilities().protocol;
1599
- recordTerminalGraphicTrace({
1600
- type: "request",
1601
- id: rawId,
1602
- key: props.cacheKey ?? smallHash(props.content),
1603
- protocol: isTerminalGraphicsProtocol(protocol) ? protocol : void 0
1604
- });
1605
- const content = props.content;
1606
- if (!content.trim()) {
1607
- abortCurrentRender("superseded");
1608
- if (!alive || version !== renderVersion) return;
1609
- graphic.value = {
1610
- type: "text",
1611
- text: ""
1612
- };
1613
- lastRenderedContent = content;
1614
- status.value = "ready";
1615
- error.value = "";
1616
- bump();
1617
- return;
1618
- }
1619
- const renderer = props.renderer;
1620
- if (!renderer) {
1621
- abortCurrentRender("superseded");
1622
- if (!alive || version !== renderVersion) return;
1623
- graphic.value = {
1624
- type: "text",
1625
- text: fallbackText()
1626
- };
1627
- lastRenderedContent = content;
1628
- status.value = "ready";
1629
- error.value = "";
1630
- bump();
1631
- return;
1632
- }
1633
- const deferred = renderDeferReason();
1634
- if (deferred) {
1635
- abortCurrentRender(deferred);
1636
- if (!alive || version !== renderVersion) return;
1637
- setDeferredFallback(content);
1638
- traceDeferOnce(deferred);
1639
- return;
1640
- }
1641
- abortCurrentRender("superseded");
1642
- lastDeferTraceKey = "";
1643
- const abort = new AbortController();
1644
- renderAbort = abort;
1645
- const startedAt = nowTerminalGraphicTraceTime();
1646
- status.value = "loading";
1647
- error.value = "";
1648
- trace("render-start");
1649
- bump();
1650
- try {
1651
- const contextGraphicsOutputVersion = graphicsOutputVersion.value;
1652
- const context = resolveRendererContext(abort.signal);
1653
- lastRenderRawVisible = context.rawVisible;
1654
- lastRenderProtocol = context.protocol;
1655
- lastRenderGraphicsOutputVersion = contextGraphicsOutputVersion;
1656
- const result = await renderer(content, context);
1657
- if (abort.signal.aborted) return;
1658
- if (!alive || version !== renderVersion) return;
1659
- const normalized = normalizeResult(result);
1660
- rememberTerminalGraphicSize(normalized);
1661
- graphic.value = normalized;
1662
- lastRenderedContent = content;
1663
- status.value = "ready";
1664
- error.value = "";
1665
- trace("render-end", {
1666
- durationMs: nowTerminalGraphicTraceTime() - startedAt,
1667
- sequenceChars: normalized.type === "terminal" ? normalized.sequence.length : 0,
1668
- sequenceBytes: normalized.type === "terminal" ? normalized.sequenceBytes : 0
1669
- });
1670
- bump();
1671
- if (normalized.type === "terminal") scheduler.invalidate({
1672
- priority: "low",
1673
- reason: "data"
1674
- });
1675
- } catch (err) {
1676
- if (abort.signal.aborted) return;
1677
- if (!alive || version !== renderVersion) return;
1678
- graphic.value = {
1679
- type: "text",
1680
- text: fallbackText()
1681
- };
1682
- lastRenderedContent = content;
1683
- status.value = "ready";
1684
- error.value = errorMessage(err);
1685
- trace("render-end", {
1686
- durationMs: nowTerminalGraphicTraceTime() - startedAt,
1687
- reason: error.value
1688
- });
1689
- bump();
1690
- } finally {
1691
- if (renderAbort === abort) renderAbort = null;
1692
- }
1693
- }
1694
- function scheduleRender(options = {}) {
1695
- const version = ++renderVersion;
1696
- if (options.clearLastGraphic ?? !props.preserveRawWhileRendering) queueClearLastGraphic();
1697
- if (!builtOnce || !props.streaming) {
1698
- builtOnce = true;
1699
- renderNow(version);
1700
- return;
1701
- }
1702
- const accepted = scheduler.queueFrameTask({
1703
- id: frameTaskId,
1704
- reason: "stream",
1705
- priority: "low",
1706
- sync: false,
1707
- run: () => {
1708
- if (!alive) return;
1709
- if (version !== renderVersion) return;
1710
- renderNow(version);
1711
- }
1712
- });
1713
- if (accepted === false) renderNow(version);
1714
- }
1715
- watch([
1716
- () => props.content,
1717
- () => props.kind,
1718
- () => props.renderer,
1719
- () => props.w,
1720
- () => props.h,
1721
- () => props.streaming,
1722
- () => props.final,
1723
- () => props.deferRenderUntilVisible,
1724
- () => props.suspendRawWhileScrolling,
1725
- () => props.suspendRenderWhileScrolling,
1726
- () => props.scrolling,
1727
- () => props.preserveRawWhileRendering,
1728
- () => props.suspended,
1729
- () => props.retainRawWhileCovered,
1730
- () => props.ignoreRawCoverage,
1731
- () => props.ignoreSamePlaneRawCoverage,
1732
- () => props.cacheKey,
1733
- () => props.placementKey
1734
- ], () => {
1735
- scheduleRender();
1736
- }, { immediate: true });
1737
- watch(() => props.fallback, () => {
1738
- const current = graphic.value;
1739
- if (current?.type === "terminal") {
1740
- if (current.fallbackFromProps) {
1741
- graphic.value = {
1742
- ...current,
1743
- fallback: fallbackText()
1744
- };
1745
- bump();
1746
- scheduler.invalidate({
1747
- priority: "low",
1748
- reason: "data"
1749
- });
1750
- return;
1751
- }
1752
- scheduleRender({ clearLastGraphic: false });
1753
- return;
1754
- }
1755
- scheduleRender();
1756
- });
1757
- watch(() => [graphicsOutputVersion.value, rawOutputCanRenderValue.value], () => {
1758
- if (!props.renderer || !props.content.trim()) return;
1759
- if (graphic.value?.type === "terminal") return;
1760
- if (!rawOutputCanRenderValue.value || shouldDeferRender()) return;
1761
- scheduleRender({ clearLastGraphic: false });
1762
- });
1763
- watch(() => [
1764
- props.x,
1765
- props.y,
1766
- props.w,
1767
- props.h,
1768
- props.scrollVersion
1769
- ], () => {
1770
- if (graphic.value?.type === "terminal") {
1771
- scheduler.invalidate({
1772
- priority: "low",
1773
- reason: "data"
1774
- });
1775
- return;
1776
- }
1777
- if (props.kind !== "image" || status.value !== "loading" || !props.renderer) return;
1778
- scheduleRender({ clearLastGraphic: false });
1779
- }, { flush: "sync" });
1780
- onBeforeUnmount(() => {
1781
- alive = false;
1782
- renderVersion++;
1783
- unsubscribeTerminalResize();
1784
- unsubscribeGraphicsOutput();
1785
- abortCurrentRender("unmount");
1786
- scheduler.cancelFrameTask?.(frameTaskId);
1787
- queueClearLastGraphic();
1788
- });
1789
- function resolveDisplayLines(rawPlaceholderAllowed) {
1790
- if (showingInitialLoadingText.value) return splitTextOutput(props.loadingText);
1791
- const current = graphic.value;
1792
- if (!current) return splitTextOutput(fallbackText());
1793
- if (current.type === "terminal" && rawPlaceholderAllowed) {
1794
- const clearSequence = resolveClearSequence(current);
1795
- const drawKey = terminalDrawKey(current, absRect.value, clearSequence, resolveResizeSequence(current, absRect.value, fullRect.value));
1796
- if (rawDrawRejectedKey.value !== drawKey) return markRaw([""]);
1797
- }
1798
- const text = current.type === "terminal" ? current.fallback : current.text;
1799
- const lines = splitTextOutput(text);
1800
- return text.trim().length > 0 && !hasVisibleOutput(lines) ? splitTextOutput(fallbackText()) : lines;
1801
- }
1802
- const displayLines = computed(() => {
1803
- return resolveDisplayLines(rawCanQueue.value);
1804
- });
1805
- const currentStyle = computed(() => {
1806
- if (error.value) return props.errorStyle ?? props.style ?? defaultStyle.value;
1807
- if (showingInitialLoadingText.value) return props.loadingStyle ?? props.style ?? defaultStyle.value;
1808
- return props.style ?? defaultStyle.value;
1809
- });
1810
- const renderNode = useRenderNode(() => ({
1811
- zIndex: props.zIndex,
1812
- rect: visible.value ? renderRect.value : {
1813
- x: 0,
1814
- y: 0,
1815
- w: 0,
1816
- h: 0
1817
- },
1818
- deps: [
1819
- visible.value,
1820
- renderRect.value,
1821
- fullRect.value,
1822
- displayLines.value,
1823
- currentStyle.value,
1824
- props.clear,
1825
- status.value,
1826
- error.value,
1827
- documentVersion.value,
1828
- rawOutputCanRenderValue.value,
1829
- rawCanRender.value,
1830
- rawCanQueue.value,
1831
- rawClearPendingRepaint.value,
1832
- rawDrawRejectedKey.value,
1833
- rawSuppressedByScroll.value,
1834
- props.placementMoveWithoutClear,
1835
- props.retainRawWhileCovered,
1836
- isParentScrolling.value,
1837
- graphicsActivityVersion.value,
1838
- graphicsOutputVersion.value
1839
- ],
1840
- paint: (dirtyRows) => {
1841
- withTextWidthProvider(widthProvider, () => {
1842
- if (!visible.value) {
1843
- queueClearLastGraphic();
1844
- return;
1845
- }
1846
- const r = absRect.value;
1847
- const full = fullRect.value;
1848
- if (r.w <= 0 || r.h <= 0) {
1849
- queueClearLastGraphic();
1850
- return;
1851
- }
1852
- const style = currentStyle.value;
1853
- const dx = Math.max(0, Math.floor(r.x - full.x));
1854
- const fullY = Math.floor(full.y);
1855
- const current = graphic.value;
1856
- const output = graphicsOutput();
1857
- const retainedActiveRawGraphic = hasRetainedActiveRawGraphic();
1858
- const rawRectForPaint = rawUncoveredRenderRect(r);
1859
- const rawCoverageClipped = rawRectForPaint != null && props.ignoreRawCoverage && !sameRect(rawRectForPaint, r);
1860
- const rawCoveredForPaint = rawRectForPaint == null && rawCoveredByHigherRenderNode(r);
1861
- const rawCanQueueForPaint = current?.type === "terminal" && rawCanQueue.value && rawRectForPaint != null;
1862
- let preserveActiveRawGraphic = false;
1863
- let forceActiveRawRedraw = false;
1864
- let allowTextOverlay = false;
1865
- if (rawCanQueueForPaint && output) {
1866
- const previous = lastDrawnGraphic.value;
1867
- const previousStillActive = previous ? typeof output.isActive === "function" ? output.isActive(previous.id) : true : false;
1868
- if (previousStillActive && previous) {
1869
- const clearSequence = resolveClearSequence(current);
1870
- const resizeSequence = resolveResizeSequence(current, rawRectForPaint, full);
1871
- preserveActiveRawGraphic = rawClearPendingRepaint.value == null && previous.drawKey === terminalDrawKey(current, rawRectForPaint, clearSequence, resizeSequence);
1872
- allowTextOverlay = retainedRawCoveredByHigherRenderNode(r);
1873
- forceActiveRawRedraw = preserveActiveRawGraphic && (previous.activityVersion !== graphicsActivityVersion.value || previous.allowTextOverlay !== allowTextOverlay);
1874
- }
1875
- }
1876
- const preserveActiveRawGraphicForPaint = preserveActiveRawGraphic;
1877
- let out = rawCanQueueForPaint ? displayLines.value : resolveDisplayLines(false);
1878
- const clearingRawGraphic = rawClearPendingRepaint.value != null || lastDrawnGraphic.value != null && !preserveActiveRawGraphicForPaint;
1879
- const clearOwnedRegion = preserveActiveRawGraphicForPaint || retainedActiveRawGraphic ? false : props.clear || clearingRawGraphic || Boolean(rawCanQueueForPaint);
1880
- const blank = clearOwnedRegion ? spaces(r.w) : "";
1881
- const paintRow = (y) => {
1882
- if (y < r.y || y >= r.y + r.h) return;
1883
- const rowIndex = y - fullY;
1884
- if (rowIndex < 0 || rowIndex >= out.length) {
1885
- if (clearOwnedRegion) terminal.write(blank, {
1886
- x: r.x,
1887
- y,
1888
- style
1889
- });
1890
- return;
1891
- }
1892
- const src = out[rowIndex] ?? "";
1893
- const clipped = dx > 0 ? sliceByCellsRange(src, dx, dx + r.w) : sliceByCells(src, r.w);
1894
- const value = clearOwnedRegion ? padEndByCells(clipped, r.w) : clipped;
1895
- if (value || clearOwnedRegion) terminal.write(value, {
1896
- x: r.x,
1897
- y,
1898
- style
1899
- });
1900
- };
1901
- const paintRows = () => {
1902
- if (dirtyRows?.length) for (const y of dirtyRows) paintRow(y);
1903
- else for (let y = r.y; y < r.y + r.h; y++) paintRow(y);
1904
- };
1905
- paintRows();
1906
- if (current?.type === "terminal" && output?.capabilities.supported && output.capabilities.preferredProtocol === current.protocol && rawCanQueueForPaint) {
1907
- const drawKey = terminalDrawKey(current, rawRectForPaint, resolveClearSequence(current), resolveResizeSequence(current, rawRectForPaint, full));
1908
- const queued = queueDrawGraphic(output, current, rawRectForPaint, full, {
1909
- force: forceActiveRawRedraw,
1910
- deferFlush: preserveActiveRawGraphicForPaint,
1911
- placementMoveWithoutClear: props.placementMoveWithoutClear || rawCoverageClipped,
1912
- allowTextOverlay
1913
- });
1914
- if (queued) trace("raw-draw", {
1915
- sequenceChars: current.sequence.length,
1916
- sequenceBytes: current.sequenceBytes,
1917
- x: rawRectForPaint.x,
1918
- y: rawRectForPaint.y,
1919
- w: rawRectForPaint.w,
1920
- h: rawRectForPaint.h
1921
- });
1922
- else if (rawDrawRejectedKey.value === drawKey) {
1923
- out = resolveDisplayLines(false);
1924
- paintRows();
1925
- }
1926
- } else {
1927
- if (current?.type === "terminal" && rawSuppressedByScroll.value) traceRawSkipScrollOnce(isParentScrolling.value ? "scrolling" : "suspended");
1928
- queueClearLastGraphic({ markPendingRepaint: false });
1929
- if (!shouldDeferRender() && shouldRetryTemporaryRawFallback(rawCoveredForPaint)) scheduleRender({ clearLastGraphic: false });
1930
- }
1931
- if (clearingRawGraphic) rawClearPendingRepaint.value = null;
1932
- });
1933
- }
1934
- }));
1935
- watch(renderNode.id, (id) => {
1936
- renderNodeId.value = id;
1937
- }, { immediate: true });
1938
- watch([
1939
- visible,
1940
- rawOutputCanRenderValue,
1941
- rawCanRender,
1942
- rawCanQueue,
1943
- rawSuppressedByScroll,
1944
- isParentScrolling,
1945
- graphicsActivityVersion,
1946
- graphicsOutputVersion,
1947
- () => renderRect.value.x,
1948
- () => renderRect.value.y,
1949
- () => renderRect.value.w,
1950
- () => renderRect.value.h,
1951
- () => fullRect.value.x,
1952
- () => fullRect.value.y,
1953
- () => fullRect.value.w,
1954
- () => fullRect.value.h
1955
- ], () => {
1956
- if (!alive) return;
1957
- const deferred = renderDeferReason();
1958
- if (deferred) {
1959
- abortCurrentRender(deferred);
1960
- if (status.value === "loading" || !graphic.value || lastRenderedContent !== props.content) setDeferredFallback(props.content);
1961
- traceDeferOnce(deferred);
1962
- }
1963
- if (!visible.value || !rawCanQueue.value) queueClearLastGraphic();
1964
- const shouldRetryTemporaryFallback = shouldRetryTemporaryRawFallback();
1965
- const shouldRerenderForOutputChange = shouldRerenderForGraphicsOutputChange();
1966
- if (!shouldDeferRender() && (!graphic.value || status.value === "idle" || shouldRetryTemporaryFallback || shouldRerenderForOutputChange)) {
1967
- scheduleRender();
1968
- return;
1969
- }
1970
- scheduler.invalidate({
1971
- priority: "low",
1972
- reason: "data"
1973
- });
1974
- }, { flush: "post" });
1975
- return () => h("span", rootProps);
1976
- }
1977
- });
1978
-
1979
786
  //#endregion
1980
787
  //#region src/vue/transcript/layout.ts
1981
788
  function styleForAction(action) {
@@ -9250,7 +8057,7 @@ const TLogLinksPanel = defineComponent({
9250
8057
 
9251
8058
  //#endregion
9252
8059
  //#region src/vue/components/TLogVirtualSearchResults.ts
9253
- function sliceByCells$1(text, start, end) {
8060
+ function sliceByCells(text, start, end) {
9254
8061
  let cells = 0;
9255
8062
  let out = "";
9256
8063
  for (const ch of text) {
@@ -9266,9 +8073,9 @@ function formatItem$1(item, width, showLineNumbers) {
9266
8073
  if (!item) return "";
9267
8074
  const currentPrefix = item.current ? "*" : " ";
9268
8075
  const linePrefix = showLineNumbers ? `${String(item.absoluteLineIndex).padStart(5, " ")} ` : "";
9269
- const before = sliceByCells$1(item.text, 0, item.matchStartCell);
9270
- const match = sliceByCells$1(item.text, item.matchStartCell, item.matchEndCell);
9271
- const after = sliceByCells$1(item.text, item.matchEndCell, Number.MAX_SAFE_INTEGER);
8076
+ const before = sliceByCells(item.text, 0, item.matchStartCell);
8077
+ const match = sliceByCells(item.text, item.matchStartCell, item.matchEndCell);
8078
+ const after = sliceByCells(item.text, item.matchEndCell, Number.MAX_SAFE_INTEGER);
9272
8079
  const formatted = `${currentPrefix}${linePrefix}${before}[${match}]${after}`;
9273
8080
  return formatted.slice(0, Math.max(0, width));
9274
8081
  }
@@ -10916,4 +9723,4 @@ function resolveTLogMinimapTheme(theme) {
10916
9723
  }
10917
9724
 
10918
9725
  //#endregion
10919
- export { TAgentTerminalGraphic, TLogLinksPanel, TLogMinimap, TLogScrollbar, TLogSearchBar, TLogSearchPager, TLogSearchResults, TLogView, TLogVirtualLinksPanel, TLogVirtualSearchResults, TTranscriptView, TVirtualList, createAppendOnlyLogStore, createTLogDensityBucketsFromMarkers, createTLogLevelPlugin, createTLogLineMatcherPlugin, createTLogLinkActionPlugin, createTLogOsc8LinkPlugin, createTLogUrlPlugin, detectTLogUrls, dispatchTLogPluginLinkAction, getTLogPluginMetadata, handleTLogKeymapEvent, matchesTLogKeyBinding, parseTLogAnnotatedText, resolveTLogLinksPanelTheme, resolveTLogMinimapTheme, resolveTLogScrollbarTheme, resolveTLogSearchBarTheme, resolveTLogSearchPagerTheme, resolveTLogSearchResultsTheme, resolveTLogViewTheme, stripTLogAnsiText, tlogDarkPreset, tlogDarkTheme, tlogDefaultKeymap, tlogDefaultPreset, tlogDefaultTheme, tlogHighContrastKeymap, tlogHighContrastPreset, tlogHighContrastTheme, toTLogExternalLinkFromVisibleLink, useTLogLinkController, useTLogRetainedIndex, useTLogSearchController, useTLogSearchResultsPage, useTLogVirtualSearchResults };
9726
+ export { TLogLinksPanel, TLogMinimap, TLogScrollbar, TLogSearchBar, TLogSearchPager, TLogSearchResults, TLogView, TLogVirtualLinksPanel, TLogVirtualSearchResults, TTranscriptView, TVirtualList, createAppendOnlyLogStore, createTLogDensityBucketsFromMarkers, createTLogLevelPlugin, createTLogLineMatcherPlugin, createTLogLinkActionPlugin, createTLogOsc8LinkPlugin, createTLogUrlPlugin, detectTLogUrls, dispatchTLogPluginLinkAction, getTLogPluginMetadata, handleTLogKeymapEvent, matchesTLogKeyBinding, parseTLogAnnotatedText, resolveTLogLinksPanelTheme, resolveTLogMinimapTheme, resolveTLogScrollbarTheme, resolveTLogSearchBarTheme, resolveTLogSearchPagerTheme, resolveTLogSearchResultsTheme, resolveTLogViewTheme, stripTLogAnsiText, tlogDarkPreset, tlogDarkTheme, tlogDefaultKeymap, tlogDefaultPreset, tlogDefaultTheme, tlogHighContrastKeymap, tlogHighContrastPreset, tlogHighContrastTheme, toTLogExternalLinkFromVisibleLink, useTLogLinkController, useTLogRetainedIndex, useTLogSearchController, useTLogSearchResultsPage, useTLogVirtualSearchResults };