@simon_he/vue-tui 1.0.2 → 1.1.0

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 (125) hide show
  1. package/README.md +84 -26
  2. package/dist/TMermaidText-frVr8Ysb.js +885 -0
  3. package/dist/{TSelect-DR0FomSu.js → TSelect-tJ87rKPM.js} +59 -242
  4. package/dist/{TTree-kzhlB5P0.js → TTree-CGdE-CYu.js} +138 -102
  5. package/dist/agent/mermaid.cjs +2 -0
  6. package/dist/agent/mermaid.d.cts +2 -0
  7. package/dist/agent/mermaid.d.ts +2 -0
  8. package/dist/agent/mermaid.js +1 -0
  9. package/dist/agent.cjs +31188 -24907
  10. package/dist/agent.d.cts +11 -1
  11. package/dist/agent.d.ts +11 -1
  12. package/dist/agent.js +516 -11
  13. package/dist/{block-source-CKUOnkgT.js → block-source-CrlmaBM5.js} +1039 -66
  14. package/dist/cli/input.d.ts +8 -0
  15. package/dist/cli/stdin-buffer.d.ts +1 -1
  16. package/dist/cli/video/ffmpeg-frame-source.d.ts +10 -0
  17. package/dist/cli/video/png-frame-parser.d.ts +4 -0
  18. package/dist/cli/video/raw-frame-parser.d.ts +1 -0
  19. package/dist/cli/video/yt-dlp-frame-source.d.ts +11 -0
  20. package/dist/cli.cjs +5146 -6767
  21. package/dist/cli.d.cts +5 -1
  22. package/dist/cli.d.ts +5 -1
  23. package/dist/cli.js +2869 -154
  24. package/dist/core/buffer/eaw-ranges-unicode-17.d.ts +14 -0
  25. package/dist/core/perf/instrumentation-noop.d.ts +48 -0
  26. package/dist/core/perf/instrumentation.d.ts +136 -0
  27. package/dist/core/terminal/create-terminal.d.ts +1 -0
  28. package/dist/core.cjs +843 -1469
  29. package/dist/core.js +4 -5
  30. package/dist/create-terminal-app.d.ts +24 -1
  31. package/dist/debug-logger-CmsGI4of.js +74 -0
  32. package/dist/{dom-renderer-BniJSQyX.js → dom-renderer-DXx8fWzD.js} +2 -3
  33. package/dist/experimental/3d/bun/contributor-avatar-atlas.d.ts +12 -0
  34. package/dist/experimental/3d/bun/png.d.ts +1 -0
  35. package/dist/experimental/3d/bun/terminal-badge-scene.d.ts +11 -0
  36. package/dist/experimental/3d/bun/terminal-badge.wgsl.d.ts +1 -0
  37. package/dist/experimental/3d/bun/webgpu-renderer.d.ts +26 -0
  38. package/dist/experimental/3d/bun.cjs +7271 -0
  39. package/dist/experimental/3d/bun.d.cts +4 -0
  40. package/dist/experimental/3d/bun.d.ts +4 -0
  41. package/dist/experimental/3d/bun.js +7390 -0
  42. package/dist/experimental/video/node.cjs +497 -0
  43. package/dist/experimental/video/node.d.cts +4 -0
  44. package/dist/experimental/video/node.d.ts +4 -0
  45. package/dist/experimental/video/node.js +610 -0
  46. package/dist/experimental.cjs +6876 -6192
  47. package/dist/experimental.d.cts +7 -0
  48. package/dist/experimental.d.ts +7 -0
  49. package/dist/experimental.js +3005 -9
  50. package/dist/frame-perf-CHpWhbC4.js +111 -0
  51. package/dist/{create-terminal-DBFNYr8f.js → hyperlink-_1FAj7Wq.js} +440 -13
  52. package/dist/index.cjs +5017 -10339
  53. package/dist/index.js +14 -13
  54. package/dist/{linkify-D_gzn9Xq.js → linkify-D68T7rdW.js} +193 -3
  55. package/dist/markdown.cjs +21295 -12691
  56. package/dist/markdown.d.cts +1 -1
  57. package/dist/markdown.d.ts +1 -1
  58. package/dist/markdown.js +211 -51
  59. package/dist/mermaid-BNhM1jAZ.js +123 -0
  60. package/dist/mermaid.cjs +1707 -0
  61. package/dist/mermaid.d.cts +3 -0
  62. package/dist/mermaid.d.ts +3 -0
  63. package/dist/mermaid.js +6 -0
  64. package/dist/observability/frame-perf-store.d.ts +2 -1
  65. package/dist/observability/frame-perf.d.ts +33 -0
  66. package/dist/observability.cjs +106 -107
  67. package/dist/observability.d.cts +2 -2
  68. package/dist/observability.d.ts +2 -2
  69. package/dist/observability.js +3 -3
  70. package/dist/{wheel-scroll-vBRaQ7p-.js → rect-DUpeDfBg.js} +253 -117
  71. package/dist/renderer/cli/stdout-metrics.d.ts +10 -0
  72. package/dist/renderer/cli/stdout-renderer.d.ts +3 -0
  73. package/dist/renderer/terminal-graphic-render-queue.d.ts +50 -0
  74. package/dist/renderer/terminal-graphics-trace.d.ts +53 -0
  75. package/dist/renderer/terminal-graphics.d.ts +147 -0
  76. package/dist/renderer-dom.cjs +364 -903
  77. package/dist/renderer-dom.js +4 -5
  78. package/dist/runtime/index.d.ts +2 -0
  79. package/dist/{runtime-rfcZCyJq.js → runtime-Byf8XXOT.js} +28 -15
  80. package/dist/runtime.cjs +427 -889
  81. package/dist/runtime.js +2 -2
  82. package/dist/terminal-graphics-Bbe83wSr.js +597 -0
  83. package/dist/{terminal-selection-DBinO6p5.js → terminal-selection-4W1SJj4c.js} +4 -1
  84. package/dist/{tlog-theme-CvLFNMwk.js → tlog-theme-Bul2Na3u.js} +1237 -12
  85. package/dist/{trace-CjzYeIxN.js → trace-Bh8WnoMo.js} +5 -0
  86. package/dist/vue/agent/create-png-terminal-graphic-renderer.d.ts +19 -0
  87. package/dist/vue/components/T3DViewport.d.ts +473 -0
  88. package/dist/vue/components/TAgentTerminalGraphic.d.ts +494 -0
  89. package/dist/vue/components/TCharts.d.ts +1121 -0
  90. package/dist/vue/components/TFeedback.d.ts +1 -1
  91. package/dist/vue/components/TFlex.d.ts +389 -0
  92. package/dist/vue/components/TForm.d.ts +4 -4
  93. package/dist/vue/components/TLogSearchBar.d.ts +3 -3
  94. package/dist/vue/components/TLogSearchPager.d.ts +2 -2
  95. package/dist/vue/components/TMarkdownText.d.ts +162 -4
  96. package/dist/vue/components/TMermaidText.d.ts +900 -0
  97. package/dist/vue/components/TVideo.d.ts +291 -0
  98. package/dist/vue/components/TVirtualList.d.ts +9 -0
  99. package/dist/vue/components/TVirtualMarkdown.d.ts +170 -9
  100. package/dist/vue/components/TVirtualRows.d.ts +9 -0
  101. package/dist/vue/components/TerminalProvider.d.ts +2 -0
  102. package/dist/vue/context.d.ts +24 -0
  103. package/dist/vue/index.d.ts +5 -0
  104. package/dist/vue/layout/flex.d.ts +67 -0
  105. package/dist/vue/markdown/ast.d.ts +5 -2
  106. package/dist/vue/markdown/document.d.ts +5 -0
  107. package/dist/vue/markdown/image-actions.d.ts +14 -0
  108. package/dist/vue/markdown/image.d.ts +11 -0
  109. package/dist/vue/markdown/link-actions.d.ts +14 -0
  110. package/dist/vue/markdown/math-actions.d.ts +14 -0
  111. package/dist/vue/markdown/math.d.ts +6 -0
  112. package/dist/vue/markdown/render.d.ts +28 -0
  113. package/dist/vue/markdown/types.d.ts +78 -0
  114. package/dist/vue/mermaid/beautiful-mermaid.d.ts +1436 -0
  115. package/dist/vue/render/render-manager.d.ts +7 -0
  116. package/dist/vue/video/types.d.ts +39 -0
  117. package/dist/vue.cjs +7207 -12437
  118. package/dist/vue.js +704 -38
  119. package/dist/wheel-scroll-DASkEZr-.js +106 -0
  120. package/dist/{hyperlink-Bn02UXJb.js → width-GqllnV8C.js} +166 -111
  121. package/package.json +119 -14
  122. package/dist/frame-perf-C6Xfg85O.js +0 -24
  123. package/dist/sgr-BmzxEjAO.js +0 -304
  124. /package/dist/{ansi-palette-CNXqFciC.js → ansi-palette-CH6jc2Z7.js} +0 -0
  125. /package/dist/{path-suggest-BNqcuE3-.js → path-suggest-Dndu4dTi.js} +0 -0
@@ -5,17 +5,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
6
  var __export = (target, all) => {
7
7
  for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
8
+ __defProp(target, name, { get: all[name], enumerable: !0 });
9
+ }, __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from == "object" || typeof from == "function")
12
11
  for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
12
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
13
  return to;
17
14
  };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
19
16
 
20
17
  // src/renderer-dom.ts
21
18
  var renderer_dom_exports = {};
@@ -27,19 +24,17 @@ module.exports = __toCommonJS(renderer_dom_exports);
27
24
 
28
25
  // src/renderer/capabilities.ts
29
26
  var DOM_RENDERER_CAPABILITIES = Object.freeze({
30
- syncFlush: true,
31
- scrollOperations: true,
32
- domRows: true
33
- });
34
- var HEADLESS_RENDERER_CAPABILITIES = Object.freeze({
35
- syncFlush: false,
36
- scrollOperations: true,
37
- domRows: false
38
- });
39
- var STDOUT_RENDERER_CAPABILITIES = Object.freeze({
40
- syncFlush: true,
41
- scrollOperations: true,
42
- domRows: false
27
+ syncFlush: !0,
28
+ scrollOperations: !0,
29
+ domRows: !0
30
+ }), HEADLESS_RENDERER_CAPABILITIES = Object.freeze({
31
+ syncFlush: !1,
32
+ scrollOperations: !0,
33
+ domRows: !1
34
+ }), STDOUT_RENDERER_CAPABILITIES = Object.freeze({
35
+ syncFlush: !0,
36
+ scrollOperations: !0,
37
+ domRows: !1
43
38
  });
44
39
 
45
40
  // src/core/ansi-palette.ts
@@ -62,15 +57,12 @@ var ANSI_PALETTE_HEX = Object.freeze({
62
57
  whiteBright: "#ffffff"
63
58
  });
64
59
  function ansiHexToRgb(hex) {
65
- const h = hex.startsWith("#") ? hex.slice(1) : hex;
60
+ let h = hex.startsWith("#") ? hex.slice(1) : hex;
66
61
  if (h.length !== 6)
67
- return void 0;
68
- const r = Number.parseInt(h.slice(0, 2), 16);
69
- const g = Number.parseInt(h.slice(2, 4), 16);
70
- const b = Number.parseInt(h.slice(4, 6), 16);
71
- if (!Number.isFinite(r) || !Number.isFinite(g) || !Number.isFinite(b))
72
- return void 0;
73
- return { r, g, b };
62
+ return;
63
+ let r = Number.parseInt(h.slice(0, 2), 16), g = Number.parseInt(h.slice(2, 4), 16), b = Number.parseInt(h.slice(4, 6), 16);
64
+ if (!(!Number.isFinite(r) || !Number.isFinite(g) || !Number.isFinite(b)))
65
+ return { r, g, b };
74
66
  }
75
67
  var ANSI_PALETTE_RGB = Object.freeze(
76
68
  Object.fromEntries(
@@ -78,21 +70,19 @@ var ANSI_PALETTE_RGB = Object.freeze(
78
70
  )
79
71
  );
80
72
  function isAnsiColorName(name) {
81
- return typeof name === "string" && Object.prototype.hasOwnProperty.call(ANSI_PALETTE_HEX, name);
73
+ return typeof name == "string" && Object.prototype.hasOwnProperty.call(ANSI_PALETTE_HEX, name);
82
74
  }
83
75
  function ansiColorHex(name, palette) {
84
76
  if (!isAnsiColorName(name))
85
- return void 0;
86
- const custom = palette?.[name];
87
- if (custom && ansiHexToRgb(custom))
88
- return custom;
89
- return ANSI_PALETTE_HEX[name];
77
+ return;
78
+ let custom = palette?.[name];
79
+ return custom && ansiHexToRgb(custom) ? custom : ANSI_PALETTE_HEX[name];
90
80
  }
91
81
  function ansiCssVar(name) {
92
82
  return `var(--vt-color-${name})`;
93
83
  }
94
84
  function installAnsiPaletteCssVars(container, palette) {
95
- for (const [name, hex] of Object.entries(ANSI_PALETTE_HEX))
85
+ for (let [name, hex] of Object.entries(ANSI_PALETTE_HEX))
96
86
  container.style.setProperty(`--vt-color-${name}`, ansiColorHex(name, palette) ?? hex);
97
87
  }
98
88
 
@@ -100,58 +90,46 @@ function installAnsiPaletteCssVars(container, palette) {
100
90
  var ENCODED_ASCII_CONTROL_RE = /%(?:0[0-9a-f]|1[0-9a-f]|7f)/i;
101
91
  function hasControlCodePoint(value) {
102
92
  for (let i = 0; i < value.length; i++) {
103
- const code = value.charCodeAt(i);
93
+ let code = value.charCodeAt(i);
104
94
  if (code <= 31 || code >= 127 && code <= 159)
105
- return true;
95
+ return !0;
106
96
  }
107
- return false;
97
+ return !1;
108
98
  }
109
99
  function hasEncodedControl(value) {
110
100
  let current = String(value ?? "");
111
101
  for (let depth = 0; depth < 3; depth++) {
112
102
  if (ENCODED_ASCII_CONTROL_RE.test(current))
113
- return true;
103
+ return !0;
114
104
  let decoded;
115
105
  try {
116
106
  decoded = decodeURIComponent(current);
117
107
  } catch {
118
- return true;
108
+ return !0;
119
109
  }
120
110
  if (hasControlCodePoint(decoded))
121
- return true;
111
+ return !0;
122
112
  if (decoded === current)
123
- return false;
113
+ return !1;
124
114
  current = decoded;
125
115
  }
126
116
  return ENCODED_ASCII_CONTROL_RE.test(current) || hasControlCodePoint(current);
127
117
  }
128
118
 
129
119
  // src/core/hyperlink.ts
130
- var SCHEME_RE = /^[a-z][a-z0-9+.-]*:/i;
131
- var BLOCKED_SCHEME_RE = /^(?:javascript|data|vbscript):/i;
132
- var SAFE_RELATIVE_HREF_RE = /^(?:[A-Za-z0-9._~!$&()*+,;=:@/?#-]|%[0-9A-Fa-f]{2})+$/u;
120
+ var SCHEME_RE = /^[a-z][a-z0-9+.-]*:/i, BLOCKED_SCHEME_RE = /^(?:javascript|data|vbscript):/i, SAFE_RELATIVE_HREF_RE = /^(?:[A-Za-z0-9._~!$&()*+,;=:@/?#-]|%[0-9A-Fa-f]{2})+$/u;
133
121
  function normalizeRawHref(value) {
134
- if (typeof value !== "string")
135
- return null;
136
- const raw = value.trim();
137
- if (!raw)
122
+ if (typeof value != "string")
138
123
  return null;
139
- if (raw !== value)
124
+ let raw = value.trim();
125
+ if (!raw || raw !== value)
140
126
  return null;
141
127
  for (let i = 0; i < value.length; i++) {
142
- const code = value.charCodeAt(i);
128
+ let code = value.charCodeAt(i);
143
129
  if (code <= 31 || code >= 127 && code <= 159)
144
130
  return null;
145
131
  }
146
- if (/\s/u.test(raw))
147
- return null;
148
- if (raw.startsWith("//"))
149
- return null;
150
- if (BLOCKED_SCHEME_RE.test(raw))
151
- return null;
152
- if (hasEncodedControl(raw))
153
- return null;
154
- return raw;
132
+ return /\s/u.test(raw) || raw.startsWith("//") || BLOCKED_SCHEME_RE.test(raw) || hasEncodedControl(raw) ? null : raw;
155
133
  }
156
134
  function hrefScheme(raw) {
157
135
  return raw.match(SCHEME_RE)?.[0].toLowerCase() ?? null;
@@ -166,50 +144,24 @@ function parseSafeAbsoluteUrl(raw) {
166
144
  }
167
145
  }
168
146
  function sanitizeAbsoluteHref(raw, options = {}) {
169
- const url = parseSafeAbsoluteUrl(raw);
170
- if (!url)
171
- return null;
172
- if (url.protocol === "http:" || url.protocol === "https:") {
173
- if (!/^https?:\/\//i.test(raw))
174
- return null;
175
- return options.preserveHttpHref ? raw : url.toString();
176
- }
177
- if (url.protocol === "mailto:")
178
- return raw;
179
- return null;
147
+ let url = parseSafeAbsoluteUrl(raw);
148
+ return url ? url.protocol === "http:" || url.protocol === "https:" ? /^https?:\/\//i.test(raw) ? options.preserveHttpHref ? raw : url.toString() : null : url.protocol === "mailto:" ? raw : null : null;
180
149
  }
181
150
  function isSafeNormalizedRelativeHref(raw) {
182
- if (raw.includes("\\"))
183
- return false;
184
- if (raw.startsWith("//"))
185
- return false;
186
- if (SCHEME_RE.test(raw))
187
- return false;
188
- if (hasEncodedControl(raw))
189
- return false;
190
- if (!SAFE_RELATIVE_HREF_RE.test(raw))
191
- return false;
192
- return raw.startsWith("#") || raw.startsWith("?") || raw.startsWith("/") || raw.startsWith("./") || raw.startsWith("../") || /^[A-Za-z0-9._~-]/u.test(raw);
151
+ return raw.includes("\\") || raw.startsWith("//") || SCHEME_RE.test(raw) || hasEncodedControl(raw) || !SAFE_RELATIVE_HREF_RE.test(raw) ? !1 : raw.startsWith("#") || raw.startsWith("?") || raw.startsWith("/") || raw.startsWith("./") || raw.startsWith("../") || /^[A-Za-z0-9._~-]/u.test(raw);
193
152
  }
194
153
  function sanitizeDomHref(value, options = {}) {
195
- const raw = normalizeRawHref(value);
196
- if (!raw)
197
- return null;
198
- const scheme = hrefScheme(raw);
199
- if (!scheme) {
200
- return options.allowRelative !== false && isSafeNormalizedRelativeHref(raw) ? raw : null;
201
- }
202
- return sanitizeAbsoluteHref(raw);
154
+ let raw = normalizeRawHref(value);
155
+ return raw ? hrefScheme(raw) ? sanitizeAbsoluteHref(raw) : options.allowRelative !== !1 && isSafeNormalizedRelativeHref(raw) ? raw : null : null;
203
156
  }
204
157
 
205
158
  // src/core/render-plane.ts
206
159
  var TERMINAL_RENDER_PLANES = ["default", "transcript", "chrome", "overlay"];
207
160
 
208
161
  // src/core/terminal/create-terminal.ts
209
- var TERMINAL_PLANE_INTERNALS = Symbol.for("@simon_he/vue-tui:v1:terminal-plane-internals");
162
+ var TERMINAL_PLANE_INTERNALS = Symbol.for("@simon_he/vue-tui:v1:terminal-plane-internals"), TERMINAL_ROOT = Symbol.for("@simon_he/vue-tui:v1:terminal-root");
210
163
  function getPlaneTerminal(terminal, plane) {
211
- const internals = terminal[TERMINAL_PLANE_INTERNALS];
212
- return internals?.getPlaneTerminal(plane) ?? terminal;
164
+ return terminal[TERMINAL_PLANE_INTERNALS]?.getPlaneTerminal(plane) ?? terminal;
213
165
  }
214
166
 
215
167
  // src/renderer/dom/dom-renderer.ts
@@ -225,13 +177,7 @@ var DEFAULT_FONT_FAMILY = [
225
177
  '"Liberation Mono"',
226
178
  '"Courier New"',
227
179
  "monospace"
228
- ].join(", ");
229
- var DEFAULT_SYNC_FLUSH_MAX_ROWS = 32;
230
- var DEFAULT_SYNC_FLUSH_CELL_BUDGET = 4096;
231
- var PREPASS_SAMPLE_ROWS = 512;
232
- var PREPASS_ENABLE_HIT_RATIO = 0.5;
233
- var PREPASS_DISABLE_HIT_RATIO = 0.25;
234
- var ACCESSIBILITY_ATTRS = [
180
+ ].join(", "), DEFAULT_SYNC_FLUSH_MAX_ROWS = 32, DEFAULT_SYNC_FLUSH_CELL_BUDGET = 4096, PREPASS_SAMPLE_ROWS = 512, PREPASS_ENABLE_HIT_RATIO = 0.5, PREPASS_DISABLE_HIT_RATIO = 0.25, ACCESSIBILITY_ATTRS = [
235
181
  "role",
236
182
  "aria-label",
237
183
  "aria-labelledby",
@@ -262,46 +208,19 @@ function freezeRowStats(stats) {
262
208
  return Object.freeze({ ...stats });
263
209
  }
264
210
  function addRowStats(target, source) {
265
- target.rows += source.rows;
266
- target.cacheHits += source.cacheHits;
267
- target.rowKeyPrepassChecks += source.rowKeyPrepassChecks;
268
- target.rowKeyPrepassHits += source.rowKeyPrepassHits;
269
- target.rowKeyPrepassMisses += source.rowKeyPrepassMisses;
270
- target.transparentBlankRows += source.transparentBlankRows;
271
- target.plainTextRows += source.plainTextRows;
272
- target.singleStyledRows += source.singleStyledRows;
273
- target.segmentReuseRows += source.segmentReuseRows;
274
- target.fragmentRows += source.fragmentRows;
275
- target.spansCreated += source.spansCreated;
276
- target.spansReused += source.spansReused;
277
- target.textNodeUpdates += source.textNodeUpdates;
278
- target.replaceChildren += source.replaceChildren;
211
+ target.rows += source.rows, target.cacheHits += source.cacheHits, target.rowKeyPrepassChecks += source.rowKeyPrepassChecks, target.rowKeyPrepassHits += source.rowKeyPrepassHits, target.rowKeyPrepassMisses += source.rowKeyPrepassMisses, target.transparentBlankRows += source.transparentBlankRows, target.plainTextRows += source.plainTextRows, target.singleStyledRows += source.singleStyledRows, target.segmentReuseRows += source.segmentReuseRows, target.fragmentRows += source.fragmentRows, target.spansCreated += source.spansCreated, target.spansReused += source.spansReused, target.textNodeUpdates += source.textNodeUpdates, target.replaceChildren += source.replaceChildren;
279
212
  }
280
213
  function applyAccessibilityOptions(container, options) {
281
- if (options === false)
214
+ if (options === !1)
282
215
  return;
283
- for (const attr of ACCESSIBILITY_ATTRS)
216
+ for (let attr of ACCESSIBILITY_ATTRS)
284
217
  container.removeAttribute(attr);
285
- const role = options?.role ?? "application";
286
- container.setAttribute("role", role);
287
- container.setAttribute("aria-live", options?.live ?? "off");
288
- if (options?.labelledBy) {
289
- container.setAttribute("aria-labelledby", options.labelledBy);
290
- } else {
291
- container.setAttribute("aria-label", options?.label ?? "Terminal");
292
- }
293
- if (options?.describedBy)
294
- container.setAttribute("aria-describedby", options.describedBy);
295
- if (role === "textbox" || options?.multiline != null) {
296
- container.setAttribute("aria-multiline", String(options?.multiline ?? true));
297
- }
298
- if (role === "textbox" || options?.readonly != null) {
299
- container.setAttribute("aria-readonly", String(options?.readonly ?? true));
300
- }
218
+ let role = options?.role ?? "application";
219
+ container.setAttribute("role", role), container.setAttribute("aria-live", options?.live ?? "off"), options?.labelledBy ? container.setAttribute("aria-labelledby", options.labelledBy) : container.setAttribute("aria-label", options?.label ?? "Terminal"), options?.describedBy && container.setAttribute("aria-describedby", options.describedBy), (role === "textbox" || options?.multiline != null) && container.setAttribute("aria-multiline", String(options?.multiline ?? !0)), (role === "textbox" || options?.readonly != null) && container.setAttribute("aria-readonly", String(options?.readonly ?? !0));
301
220
  }
302
221
  function visualStyleKey(style, linkOptions) {
303
- const href = renderableHref(style, linkOptions) ?? "";
304
- const key = [
222
+ let href = renderableHref(style, linkOptions) ?? "";
223
+ return [
305
224
  style.fg ?? "",
306
225
  style.bg ?? "",
307
226
  style.bold ? "1" : "0",
@@ -311,178 +230,94 @@ function visualStyleKey(style, linkOptions) {
311
230
  style.inverse ? "1" : "0",
312
231
  href
313
232
  ].join("|");
314
- return key;
315
233
  }
316
234
  function resolveColorHex(color, palette) {
317
- if (!color)
318
- return void 0;
319
- if (color === "transparent")
320
- return void 0;
321
- if (color.startsWith("#"))
322
- return color;
323
- return ansiColorHex(color, palette);
235
+ if (color && color !== "transparent")
236
+ return color.startsWith("#") ? color : ansiColorHex(color, palette);
324
237
  }
325
238
  function resolveColorCss(color) {
326
- if (!color)
327
- return void 0;
328
- if (color === "transparent")
329
- return void 0;
330
- if (color.startsWith("#"))
331
- return color;
332
- if (!isAnsiColorName(color))
333
- return void 0;
334
- return ansiCssVar(color);
239
+ if (color && color !== "transparent") {
240
+ if (color.startsWith("#"))
241
+ return color;
242
+ if (isAnsiColorName(color))
243
+ return ansiCssVar(color);
244
+ }
335
245
  }
336
246
  function parseColorToRgb(color) {
337
247
  if (color.startsWith("#")) {
338
- const hex = color.slice(1);
248
+ let hex = color.slice(1);
339
249
  if (hex.length === 3) {
340
- const r = Number.parseInt(hex[0] + hex[0], 16);
341
- const g = Number.parseInt(hex[1] + hex[1], 16);
342
- const b = Number.parseInt(hex[2] + hex[2], 16);
250
+ let r = Number.parseInt(hex[0] + hex[0], 16), g = Number.parseInt(hex[1] + hex[1], 16), b = Number.parseInt(hex[2] + hex[2], 16);
343
251
  return Number.isFinite(r) && Number.isFinite(g) && Number.isFinite(b) ? { r, g, b } : null;
344
252
  }
345
253
  if (hex.length === 6) {
346
- const r = Number.parseInt(hex.slice(0, 2), 16);
347
- const g = Number.parseInt(hex.slice(2, 4), 16);
348
- const b = Number.parseInt(hex.slice(4, 6), 16);
254
+ let r = Number.parseInt(hex.slice(0, 2), 16), g = Number.parseInt(hex.slice(2, 4), 16), b = Number.parseInt(hex.slice(4, 6), 16);
349
255
  return Number.isFinite(r) && Number.isFinite(g) && Number.isFinite(b) ? { r, g, b } : null;
350
256
  }
351
257
  }
352
- const m = color.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);
258
+ let m = color.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);
353
259
  if (m) {
354
- const r = Number.parseInt(m[1], 10);
355
- const g = Number.parseInt(m[2], 10);
356
- const b = Number.parseInt(m[3], 10);
260
+ let r = Number.parseInt(m[1], 10), g = Number.parseInt(m[2], 10), b = Number.parseInt(m[3], 10);
357
261
  return { r, g, b };
358
262
  }
359
263
  return null;
360
264
  }
361
265
  function luminance({ r, g, b }) {
362
- const srgb = [r, g, b].map((v) => {
363
- const c = v / 255;
266
+ let srgb = [r, g, b].map((v) => {
267
+ let c = v / 255;
364
268
  return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
365
269
  });
366
270
  return 0.2126 * srgb[0] + 0.7152 * srgb[1] + 0.0722 * srgb[2];
367
271
  }
368
272
  function contrastText(bgColor) {
369
- const rgb = parseColorToRgb(bgColor);
370
- if (!rgb)
371
- return "#111827";
372
- return luminance(rgb) > 0.6 ? "#111827" : "#e5e7eb";
273
+ let rgb = parseColorToRgb(bgColor);
274
+ return rgb ? luminance(rgb) > 0.6 ? "#111827" : "#e5e7eb" : "#111827";
373
275
  }
374
276
  function applyStyle(span, style, palette) {
375
- const fgHex = resolveColorHex(style.fg, palette);
376
- const bgHex = resolveColorHex(style.bg, palette);
377
- const fgCss = resolveColorCss(style.fg);
378
- const bgCss = resolveColorCss(style.bg);
379
- const effectiveFg = style.inverse ? bgCss : fgCss;
380
- const effectiveBg = style.inverse ? fgCss : bgCss;
381
- const effectiveFgHex = style.inverse ? bgHex : fgHex;
382
- const effectiveBgHex = style.inverse ? fgHex : bgHex;
383
- if (span.tagName === "A") {
384
- span.style.pointerEvents = "auto";
385
- span.style.cursor = "pointer";
386
- span.style.color = "inherit";
387
- span.style.textDecoration = "inherit";
388
- }
389
- if (effectiveFg) {
390
- span.style.color = effectiveFg;
391
- if (!span.style.color && effectiveFgHex)
392
- span.style.color = effectiveFgHex;
393
- }
394
- if (effectiveBg) {
395
- span.style.backgroundColor = effectiveBg;
396
- if (!span.style.backgroundColor && effectiveBgHex)
397
- span.style.backgroundColor = effectiveBgHex;
398
- }
399
- if (!effectiveFg && style.inverse && effectiveBg && effectiveBgHex)
400
- span.style.color = contrastText(effectiveBgHex);
401
- if (style.bold)
402
- span.style.fontWeight = "700";
403
- if (style.italic)
404
- span.style.fontStyle = "italic";
405
- if (style.dim)
406
- span.style.opacity = "0.75";
407
- if (style.underline)
408
- span.style.textDecoration = "underline";
277
+ let fgHex = resolveColorHex(style.fg, palette), bgHex = resolveColorHex(style.bg, palette), fgCss = resolveColorCss(style.fg), bgCss = resolveColorCss(style.bg), effectiveFg = style.inverse ? bgCss : fgCss, effectiveBg = style.inverse ? fgCss : bgCss, effectiveFgHex = style.inverse ? bgHex : fgHex, effectiveBgHex = style.inverse ? fgHex : bgHex;
278
+ span.tagName === "A" && (span.style.pointerEvents = "auto", span.style.cursor = "pointer", span.style.color = "inherit", span.style.textDecoration = "inherit"), effectiveFg && (span.style.color = effectiveFg, !span.style.color && effectiveFgHex && (span.style.color = effectiveFgHex)), effectiveBg && (span.style.backgroundColor = effectiveBg, !span.style.backgroundColor && effectiveBgHex && (span.style.backgroundColor = effectiveBgHex)), !effectiveFg && style.inverse && effectiveBg && effectiveBgHex && (span.style.color = contrastText(effectiveBgHex)), style.bold && (span.style.fontWeight = "700"), style.italic && (span.style.fontStyle = "italic"), style.dim && (span.style.opacity = "0.75"), style.underline && (span.style.textDecoration = "underline");
409
279
  }
410
280
  function measureCell(container) {
411
- const probe = container.ownerDocument.createElement("span");
412
- probe.textContent = "M";
413
- probe.style.position = "absolute";
414
- probe.style.visibility = "hidden";
415
- probe.style.whiteSpace = "pre";
416
- container.appendChild(probe);
417
- const rect = probe.getBoundingClientRect();
418
- probe.remove();
419
- return {
281
+ let probe = container.ownerDocument.createElement("span");
282
+ probe.textContent = "M", probe.style.position = "absolute", probe.style.visibility = "hidden", probe.style.whiteSpace = "pre", container.appendChild(probe);
283
+ let rect = probe.getBoundingClientRect();
284
+ return probe.remove(), {
420
285
  cellWidth: Math.max(1, rect.width),
421
286
  cellHeight: Math.max(1, rect.height)
422
287
  };
423
288
  }
424
289
  function measureCharWidth(container, ch) {
425
- const probe = container.ownerDocument.createElement("span");
426
- probe.textContent = ch;
427
- probe.style.position = "absolute";
428
- probe.style.visibility = "hidden";
429
- probe.style.whiteSpace = "pre";
430
- container.appendChild(probe);
431
- const rect = probe.getBoundingClientRect();
432
- probe.remove();
433
- return Math.max(0, rect.width);
290
+ let probe = container.ownerDocument.createElement("span");
291
+ probe.textContent = ch, probe.style.position = "absolute", probe.style.visibility = "hidden", probe.style.whiteSpace = "pre", container.appendChild(probe);
292
+ let rect = probe.getBoundingClientRect();
293
+ return probe.remove(), Math.max(0, rect.width);
434
294
  }
435
295
  function formatRowSegmentKeyPart(key, text, cols, wide) {
436
296
  return `${key}:${text}:${cols}:${wide ? 1 : 0}`;
437
297
  }
438
298
  function formatSingleRowKey(key, text, cols, wide, style, linkOptions) {
439
- const plain = isPlainVisualStyle(style, linkOptions);
440
- const hasRenderableHref = renderableHref(style, linkOptions) != null;
441
- if (!wide && plain)
442
- return `p:${text}:${cols}`;
443
- if (!wide && !hasRenderableHref && !plain)
444
- return `s:${key}:${text}:${cols}`;
445
- return `1:${formatRowSegmentKeyPart(key, text, cols, wide)}`;
299
+ let plain = isPlainVisualStyle(style, linkOptions), hasRenderableHref = renderableHref(style, linkOptions) != null;
300
+ return !wide && plain ? `p:${text}:${cols}` : !wide && !hasRenderableHref && !plain ? `s:${key}:${text}:${cols}` : `1:${formatRowSegmentKeyPart(key, text, cols, wide)}`;
446
301
  }
447
302
  function computeRowSegmentsWithKey(terminal, y, linkOptions) {
448
- const cells = terminal.getRow(y);
449
- let currentKey = null;
450
- let currentStyle = null;
451
- let currentText = "";
452
- let currentCols = 0;
453
- let currentWide = false;
454
- const segments = [];
455
- let keyBody = "";
456
- let segmentCount = 0;
303
+ let cells = terminal.getRow(y), currentKey = null, currentStyle = null, currentText = "", currentCols = 0, currentWide = !1, segments = [], keyBody = "", segmentCount = 0;
457
304
  function pushSegment(segment) {
458
305
  if (segmentCount === 1) {
459
- const first = segments[0];
306
+ let first = segments[0];
460
307
  keyBody += `|${formatRowSegmentKeyPart(first.key, first.text, first.cols, first.wide)}`;
461
308
  }
462
- segments.push(segment);
463
- segmentCount++;
464
- if (segmentCount > 1)
465
- keyBody += `|${formatRowSegmentKeyPart(segment.key, segment.text, segment.cols, segment.wide)}`;
309
+ segments.push(segment), segmentCount++, segmentCount > 1 && (keyBody += `|${formatRowSegmentKeyPart(segment.key, segment.text, segment.cols, segment.wide)}`);
466
310
  }
467
- for (const cell of cells) {
311
+ for (let cell of cells) {
468
312
  if (cell.continuation)
469
313
  continue;
470
- const ch = cell.ch || " ";
471
- const cols = cell.width || 1;
472
- const wide = cols === 2;
473
- const nextStyle = cell.style;
474
- const key = nextStyle === currentStyle && currentKey != null ? currentKey : visualStyleKey(nextStyle, linkOptions);
314
+ let ch = cell.ch || " ", cols = cell.width || 1, wide = cols === 2, nextStyle = cell.style, key = nextStyle === currentStyle && currentKey != null ? currentKey : visualStyleKey(nextStyle, linkOptions);
475
315
  if (currentKey == null) {
476
- currentKey = key;
477
- currentStyle = nextStyle;
478
- currentText = ch;
479
- currentCols = cols;
480
- currentWide = wide;
316
+ currentKey = key, currentStyle = nextStyle, currentText = ch, currentCols = cols, currentWide = wide;
481
317
  continue;
482
318
  }
483
319
  if (key === currentKey && wide === currentWide) {
484
- currentText += ch;
485
- currentCols += cols;
320
+ currentText += ch, currentCols += cols;
486
321
  continue;
487
322
  }
488
323
  pushSegment({
@@ -491,26 +326,18 @@ function computeRowSegmentsWithKey(terminal, y, linkOptions) {
491
326
  wide: currentWide,
492
327
  style: currentStyle,
493
328
  key: currentKey
494
- });
495
- currentKey = key;
496
- currentStyle = nextStyle;
497
- currentText = ch;
498
- currentCols = cols;
499
- currentWide = wide;
500
- }
501
- if (currentKey != null) {
502
- pushSegment({
503
- text: currentText,
504
- cols: currentCols,
505
- wide: currentWide,
506
- style: currentStyle,
507
- key: currentKey
508
- });
509
- }
510
- if (segmentCount === 0)
329
+ }), currentKey = key, currentStyle = nextStyle, currentText = ch, currentCols = cols, currentWide = wide;
330
+ }
331
+ if (currentKey != null && pushSegment({
332
+ text: currentText,
333
+ cols: currentCols,
334
+ wide: currentWide,
335
+ style: currentStyle,
336
+ key: currentKey
337
+ }), segmentCount === 0)
511
338
  return { segments, key: "0" };
512
339
  if (segmentCount === 1) {
513
- const s = segments[0];
340
+ let s = segments[0];
514
341
  return {
515
342
  segments,
516
343
  key: formatSingleRowKey(s.key, s.text, s.cols, s.wide, s.style, linkOptions)
@@ -519,78 +346,33 @@ function computeRowSegmentsWithKey(terminal, y, linkOptions) {
519
346
  return { segments, key: `${segmentCount}${keyBody}` };
520
347
  }
521
348
  function computeRowKey(terminal, y, linkOptions) {
522
- const cells = terminal.getRow(y);
523
- let currentKey = null;
524
- let currentStyle = null;
525
- let currentText = "";
526
- let currentCols = 0;
527
- let currentWide = false;
528
- let firstKey = "";
529
- let firstStyle = null;
530
- let firstText = "";
531
- let firstCols = 0;
532
- let firstWide = false;
533
- let keyBody = "";
534
- let segmentCount = 0;
349
+ let cells = terminal.getRow(y), currentKey = null, currentStyle = null, currentText = "", currentCols = 0, currentWide = !1, firstKey = "", firstStyle = null, firstText = "", firstCols = 0, firstWide = !1, keyBody = "", segmentCount = 0;
535
350
  function pushSegment(key, text, cols, wide, style) {
536
- if (segmentCount === 0) {
537
- firstKey = key;
538
- firstStyle = style;
539
- firstText = text;
540
- firstCols = cols;
541
- firstWide = wide;
542
- } else {
543
- if (segmentCount === 1)
544
- keyBody += `|${formatRowSegmentKeyPart(firstKey, firstText, firstCols, firstWide)}`;
545
- keyBody += `|${formatRowSegmentKeyPart(key, text, cols, wide)}`;
546
- }
547
- segmentCount++;
351
+ segmentCount === 0 ? (firstKey = key, firstStyle = style, firstText = text, firstCols = cols, firstWide = wide) : (segmentCount === 1 && (keyBody += `|${formatRowSegmentKeyPart(firstKey, firstText, firstCols, firstWide)}`), keyBody += `|${formatRowSegmentKeyPart(key, text, cols, wide)}`), segmentCount++;
548
352
  }
549
- for (const cell of cells) {
353
+ for (let cell of cells) {
550
354
  if (cell.continuation)
551
355
  continue;
552
- const ch = cell.ch || " ";
553
- const cols = cell.width || 1;
554
- const wide = cols === 2;
555
- const nextStyle = cell.style;
556
- const key = nextStyle === currentStyle && currentKey != null ? currentKey : visualStyleKey(nextStyle, linkOptions);
356
+ let ch = cell.ch || " ", cols = cell.width || 1, wide = cols === 2, nextStyle = cell.style, key = nextStyle === currentStyle && currentKey != null ? currentKey : visualStyleKey(nextStyle, linkOptions);
557
357
  if (currentKey == null) {
558
- currentKey = key;
559
- currentStyle = nextStyle;
560
- currentText = ch;
561
- currentCols = cols;
562
- currentWide = wide;
358
+ currentKey = key, currentStyle = nextStyle, currentText = ch, currentCols = cols, currentWide = wide;
563
359
  continue;
564
360
  }
565
361
  if (key === currentKey && wide === currentWide) {
566
- currentText += ch;
567
- currentCols += cols;
362
+ currentText += ch, currentCols += cols;
568
363
  continue;
569
364
  }
570
- pushSegment(currentKey, currentText, currentCols, currentWide, currentStyle);
571
- currentKey = key;
572
- currentStyle = nextStyle;
573
- currentText = ch;
574
- currentCols = cols;
575
- currentWide = wide;
365
+ pushSegment(currentKey, currentText, currentCols, currentWide, currentStyle), currentKey = key, currentStyle = nextStyle, currentText = ch, currentCols = cols, currentWide = wide;
576
366
  }
577
- if (currentKey != null)
578
- pushSegment(currentKey, currentText, currentCols, currentWide, currentStyle);
579
- if (segmentCount === 0)
580
- return "0";
581
- if (segmentCount === 1)
582
- return formatSingleRowKey(firstKey, firstText, firstCols, firstWide, firstStyle, linkOptions);
583
- return `${segmentCount}${keyBody}`;
367
+ return currentKey != null && pushSegment(currentKey, currentText, currentCols, currentWide, currentStyle), segmentCount === 0 ? "0" : segmentCount === 1 ? formatSingleRowKey(firstKey, firstText, firstCols, firstWide, firstStyle, linkOptions) : `${segmentCount}${keyBody}`;
584
368
  }
585
369
  var rowCache = /* @__PURE__ */ new WeakMap();
586
370
  function nowMs() {
587
- const p = globalThis.performance;
588
- if (p && typeof p.now === "function")
589
- return p.now();
590
- return Date.now();
371
+ let p = globalThis.performance;
372
+ return p && typeof p.now == "function" ? p.now() : Date.now();
591
373
  }
592
374
  function isPlainVisualStyle(style, linkOptions) {
593
- const hasRenderableHref = renderableHref(style, linkOptions) != null;
375
+ let hasRenderableHref = renderableHref(style, linkOptions) != null;
594
376
  return !style.fg && !style.bg && !style.bold && !style.dim && !style.italic && !style.underline && !style.inverse && !hasRenderableHref;
595
377
  }
596
378
  function isTransparentBlankRow(segments, linkOptions) {
@@ -600,34 +382,25 @@ function isPlainTextRow(segments, linkOptions) {
600
382
  return segments.length === 1 && !segments[0].wide && isPlainVisualStyle(segments[0].style, linkOptions);
601
383
  }
602
384
  function normalizeLinkOptions(value) {
603
- if (value === true)
385
+ if (value === !0)
604
386
  return {};
605
- if (value === false || value == null)
606
- return false;
607
- const activation = value.activation ?? (typeof value.onActivate === "function" ? "event" : "native");
608
- if (activation === "event" && typeof value.onActivate !== "function") {
609
- return { ...value, activation: "native" };
610
- }
611
- return { ...value, activation };
387
+ if (value === !1 || value == null)
388
+ return !1;
389
+ let activation = value.activation ?? (typeof value.onActivate == "function" ? "event" : "native");
390
+ return activation === "event" && typeof value.onActivate != "function" ? { ...value, activation: "native" } : { ...value, activation };
612
391
  }
613
392
  function linkOptionsKey(options) {
614
- if (!options)
615
- return "disabled";
616
- return JSON.stringify({
617
- allowRelative: options.allowRelative !== false,
393
+ return options ? JSON.stringify({
394
+ allowRelative: options.allowRelative !== !1,
618
395
  externalTarget: options.externalTarget ?? "_blank",
619
396
  tabIndex: options.tabIndex ?? -1,
620
397
  activation: options.activation ?? "native",
621
- hasOnActivate: typeof options.onActivate === "function"
622
- });
398
+ hasOnActivate: typeof options.onActivate == "function"
399
+ }) : "disabled";
623
400
  }
624
401
  function renderableHref(style, linkOptions) {
625
- if (!linkOptions)
626
- return null;
627
- if (linkOptions.activation === "none")
628
- return null;
629
- return sanitizeDomHref(style.href, {
630
- allowRelative: linkOptions.allowRelative !== false
402
+ return !linkOptions || linkOptions.activation === "none" ? null : sanitizeDomHref(style.href, {
403
+ allowRelative: linkOptions.allowRelative !== !1
631
404
  });
632
405
  }
633
406
  function isSingleStyledTextRow(segments, linkOptions) {
@@ -637,253 +410,137 @@ function canReuseSegmentSpans(segments, linkOptions) {
637
410
  return segments.length > 1 && segments.every((segment) => !segment.wide && !renderableHref(segment.style, linkOptions));
638
411
  }
639
412
  function resetSpanStyle(span) {
640
- span.removeAttribute("style");
641
- if (span.tagName === "A") {
642
- span.removeAttribute("href");
643
- span.removeAttribute("target");
644
- span.removeAttribute("rel");
645
- delete span.dataset.vtHref;
646
- }
413
+ span.removeAttribute("style"), span.tagName === "A" && (span.removeAttribute("href"), span.removeAttribute("target"), span.removeAttribute("rel"), delete span.dataset.vtHref);
647
414
  }
648
415
  function createSegmentElement(doc, style, options) {
649
- const linkOptions = options.links;
416
+ let linkOptions = options.links;
650
417
  if (!linkOptions)
651
418
  return doc.createElement("span");
652
- const href = renderableHref(style, linkOptions);
419
+ let href = renderableHref(style, linkOptions);
653
420
  if (!href)
654
421
  return doc.createElement("span");
655
- const anchor = doc.createElement("a");
656
- anchor.href = href;
657
- anchor.dataset.vtHref = href;
658
- const protocol = href.match(/^[a-z][a-z0-9+.-]*:/i)?.[0].toLowerCase() ?? null;
659
- if (protocol === "http:" || protocol === "https:") {
660
- anchor.target = linkOptions.externalTarget ?? "_blank";
661
- anchor.rel = "noopener noreferrer";
662
- }
663
- anchor.tabIndex = linkOptions.tabIndex ?? -1;
664
- anchor.draggable = false;
665
- anchor.addEventListener("pointerdown", options.onAnchorPointerDown);
666
- anchor.addEventListener("click", options.onAnchorClick);
667
- return anchor;
422
+ let anchor = doc.createElement("a");
423
+ anchor.href = href, anchor.dataset.vtHref = href;
424
+ let protocol = href.match(/^[a-z][a-z0-9+.-]*:/i)?.[0].toLowerCase() ?? null;
425
+ return (protocol === "http:" || protocol === "https:") && (anchor.target = linkOptions.externalTarget ?? "_blank", anchor.rel = "noopener noreferrer"), anchor.tabIndex = linkOptions.tabIndex ?? -1, anchor.draggable = !1, anchor.addEventListener("pointerdown", options.onAnchorPointerDown), anchor.addEventListener("click", options.onAnchorClick), anchor;
668
426
  }
669
427
  function isSpanNode(node, lineEl) {
670
- const SpanCtor = lineEl.ownerDocument.defaultView?.HTMLSpanElement ?? globalThis.HTMLSpanElement;
671
- return typeof SpanCtor === "function" && node instanceof SpanCtor;
428
+ let SpanCtor = lineEl.ownerDocument.defaultView?.HTMLSpanElement ?? globalThis.HTMLSpanElement;
429
+ return typeof SpanCtor == "function" && node instanceof SpanCtor;
672
430
  }
673
431
  function textNodeType(lineEl) {
674
432
  return lineEl.ownerDocument.defaultView?.Node.TEXT_NODE ?? 3;
675
433
  }
676
434
  function tryUpdateSegmentSpans(lineEl, segments, metrics, palette) {
677
435
  if (lineEl.childNodes.length !== segments.length)
678
- return false;
436
+ return !1;
679
437
  for (let i = 0; i < segments.length; i++) {
680
- const node = lineEl.childNodes[i];
681
- if (!isSpanNode(node, lineEl))
682
- return false;
683
- if (node.dataset.vtFastRow !== "segment")
684
- return false;
685
- if (node.dataset.vtSegmentIndex !== String(i))
686
- return false;
438
+ let node = lineEl.childNodes[i];
439
+ if (!isSpanNode(node, lineEl) || node.dataset.vtFastRow !== "segment" || node.dataset.vtSegmentIndex !== String(i))
440
+ return !1;
687
441
  }
688
442
  for (let i = 0; i < segments.length; i++) {
689
- const span = lineEl.childNodes[i];
690
- const seg = segments[i];
691
- span.textContent = seg.text;
692
- resetSpanStyle(span);
693
- span.style.cssText = `display:inline-block;width:${seg.cols * metrics.cellWidth}px;height:${metrics.cellHeight}px;overflow:hidden;white-space:pre;vertical-align:top`;
694
- applyStyle(span, seg.style, palette);
443
+ let span = lineEl.childNodes[i], seg = segments[i];
444
+ span.textContent = seg.text, resetSpanStyle(span), span.style.cssText = `display:inline-block;width:${seg.cols * metrics.cellWidth}px;height:${metrics.cellHeight}px;overflow:hidden;white-space:pre;vertical-align:top`, applyStyle(span, seg.style, palette);
695
445
  }
696
- return true;
446
+ return !0;
697
447
  }
698
448
  function renderRow(terminal, metrics, wideScaleX, y, lineEl, stats, enableRowKeyPrepass, palette, linkOptions, onAnchorClick, onAnchorPointerDown, linkVersion) {
699
449
  stats.rows++;
700
- const doc = lineEl.ownerDocument;
701
- const rowModeKey = `links:${linkVersion}`;
702
- const cachedKey = rowCache.get(lineEl);
450
+ let doc = lineEl.ownerDocument, rowModeKey = `links:${linkVersion}`, cachedKey = rowCache.get(lineEl);
703
451
  if (enableRowKeyPrepass && cachedKey != null) {
704
452
  stats.rowKeyPrepassChecks++;
705
- const prepassKey = `${rowModeKey}|${computeRowKey(terminal, y, linkOptions)}`;
453
+ let prepassKey = `${rowModeKey}|${computeRowKey(terminal, y, linkOptions)}`;
706
454
  if (cachedKey === prepassKey) {
707
- stats.rowKeyPrepassHits++;
708
- stats.cacheHits++;
455
+ stats.rowKeyPrepassHits++, stats.cacheHits++;
709
456
  return;
710
457
  }
711
458
  stats.rowKeyPrepassMisses++;
712
459
  }
713
- const { segments, key } = computeRowSegmentsWithKey(terminal, y, linkOptions);
714
- const newKey = `${rowModeKey}|${key}`;
460
+ let { segments, key } = computeRowSegmentsWithKey(terminal, y, linkOptions), newKey = `${rowModeKey}|${key}`;
715
461
  if (cachedKey === newKey) {
716
462
  stats.cacheHits++;
717
463
  return;
718
464
  }
719
- rowCache.set(lineEl, newKey);
720
- if (isTransparentBlankRow(segments, linkOptions)) {
721
- stats.transparentBlankRows++;
722
- stats.replaceChildren++;
723
- lineEl.replaceChildren();
465
+ if (rowCache.set(lineEl, newKey), isTransparentBlankRow(segments, linkOptions)) {
466
+ stats.transparentBlankRows++, stats.replaceChildren++, lineEl.replaceChildren();
724
467
  return;
725
468
  }
726
469
  if (isPlainTextRow(segments, linkOptions)) {
727
- stats.plainTextRows++;
728
- stats.textNodeUpdates++;
729
- const text = segments[0].text;
730
- const firstChild = lineEl.firstChild;
731
- if (lineEl.childNodes.length === 1 && firstChild?.nodeType === textNodeType(lineEl)) {
732
- firstChild.nodeValue = text;
733
- } else {
734
- lineEl.textContent = text;
735
- }
470
+ stats.plainTextRows++, stats.textNodeUpdates++;
471
+ let text = segments[0].text, firstChild = lineEl.firstChild;
472
+ lineEl.childNodes.length === 1 && firstChild?.nodeType === textNodeType(lineEl) ? firstChild.nodeValue = text : lineEl.textContent = text;
736
473
  return;
737
474
  }
738
475
  if (isSingleStyledTextRow(segments, linkOptions)) {
739
- const seg = segments[0];
740
- const firstChild = lineEl.firstChild;
741
- let span;
742
- if (lineEl.childNodes.length === 1 && isSpanNode(firstChild, lineEl) && firstChild.dataset.vtFastRow === "styled") {
743
- span = firstChild;
744
- stats.spansReused++;
745
- } else {
746
- span = createSegmentElement(doc, seg.style, {
747
- links: linkOptions,
748
- onAnchorClick,
749
- onAnchorPointerDown
750
- });
751
- span.dataset.vtFastRow = "styled";
752
- stats.spansCreated++;
753
- stats.replaceChildren++;
754
- lineEl.replaceChildren(span);
755
- }
756
- stats.singleStyledRows++;
757
- span.textContent = seg.text;
758
- resetSpanStyle(span);
759
- span.style.cssText = `display:inline-block;width:${seg.cols * metrics.cellWidth}px;height:${metrics.cellHeight}px;overflow:hidden;white-space:pre;vertical-align:top`;
760
- applyStyle(span, seg.style, palette);
476
+ let seg = segments[0], firstChild = lineEl.firstChild, span;
477
+ lineEl.childNodes.length === 1 && isSpanNode(firstChild, lineEl) && firstChild.dataset.vtFastRow === "styled" ? (span = firstChild, stats.spansReused++) : (span = createSegmentElement(doc, seg.style, {
478
+ links: linkOptions,
479
+ onAnchorClick,
480
+ onAnchorPointerDown
481
+ }), span.dataset.vtFastRow = "styled", stats.spansCreated++, stats.replaceChildren++, lineEl.replaceChildren(span)), stats.singleStyledRows++, span.textContent = seg.text, resetSpanStyle(span), span.style.cssText = `display:inline-block;width:${seg.cols * metrics.cellWidth}px;height:${metrics.cellHeight}px;overflow:hidden;white-space:pre;vertical-align:top`, applyStyle(span, seg.style, palette);
761
482
  return;
762
483
  }
763
- const canReuseSpans = canReuseSegmentSpans(segments, linkOptions);
484
+ let canReuseSpans = canReuseSegmentSpans(segments, linkOptions);
764
485
  if (canReuseSpans && tryUpdateSegmentSpans(lineEl, segments, metrics, palette)) {
765
- stats.segmentReuseRows++;
766
- stats.spansReused += segments.length;
486
+ stats.segmentReuseRows++, stats.spansReused += segments.length;
767
487
  return;
768
488
  }
769
- stats.fragmentRows++;
770
- stats.spansCreated += segments.length;
771
- stats.replaceChildren++;
772
- const fragment = doc.createDocumentFragment();
489
+ stats.fragmentRows++, stats.spansCreated += segments.length, stats.replaceChildren++;
490
+ let fragment = doc.createDocumentFragment();
773
491
  for (let i = 0; i < segments.length; i++) {
774
- const seg = segments[i];
775
- const span = createSegmentElement(doc, seg.style, {
492
+ let seg = segments[i], span = createSegmentElement(doc, seg.style, {
776
493
  links: linkOptions,
777
494
  onAnchorClick,
778
495
  onAnchorPointerDown
779
496
  });
780
- if (canReuseSpans) {
781
- span.dataset.vtFastRow = "segment";
782
- span.dataset.vtSegmentIndex = String(i);
783
- }
784
- if (seg.wide && wideScaleX > 1.01) {
785
- const inner = doc.createElement("span");
786
- inner.textContent = seg.text;
787
- inner.style.cssText = `display:inline-block;white-space:pre;transform:scaleX(${wideScaleX});transform-origin:left`;
788
- span.appendChild(inner);
789
- } else {
497
+ if (canReuseSpans && (span.dataset.vtFastRow = "segment", span.dataset.vtSegmentIndex = String(i)), seg.wide && wideScaleX > 1.01) {
498
+ let inner = doc.createElement("span");
499
+ inner.textContent = seg.text, inner.style.cssText = `display:inline-block;white-space:pre;transform:scaleX(${wideScaleX});transform-origin:left`, span.appendChild(inner);
500
+ } else
790
501
  span.textContent = seg.text;
791
- }
792
- span.style.cssText = `display:inline-block;width:${seg.cols * metrics.cellWidth}px;height:${metrics.cellHeight}px;overflow:hidden;white-space:pre;vertical-align:top`;
793
- applyStyle(span, seg.style, palette);
794
- fragment.appendChild(span);
502
+ span.style.cssText = `display:inline-block;width:${seg.cols * metrics.cellWidth}px;height:${metrics.cellHeight}px;overflow:hidden;white-space:pre;vertical-align:top`, applyStyle(span, seg.style, palette), fragment.appendChild(span);
795
503
  }
796
504
  lineEl.replaceChildren(fragment);
797
505
  }
798
506
  function createDomRenderer(terminal, container, options = {}) {
799
- const doc = container.ownerDocument;
800
- let rendererLinkOptions = normalizeLinkOptions(options.links);
801
- let rendererOnLinkClick = options.onLinkClick;
802
- let rendererLinkOptionsKey = linkOptionsKey(rendererLinkOptions);
803
- let rendererLinkVersion = 0;
804
- const onAnchorClick = (event) => {
805
- const anchor = event.currentTarget;
806
- const href = anchor.dataset.vtHref;
507
+ let doc = container.ownerDocument, rendererLinkOptions = normalizeLinkOptions(options.links), rendererOnLinkClick = options.onLinkClick, rendererLinkOptionsKey = linkOptionsKey(rendererLinkOptions), rendererLinkVersion = 0, onAnchorClick = (event) => {
508
+ let href = event.currentTarget.dataset.vtHref;
807
509
  if (!href || !rendererLinkOptions)
808
510
  return;
809
- const linkClickResult = rendererOnLinkClick?.(event, href);
810
- if (linkClickResult === false) {
511
+ if (rendererOnLinkClick?.(event, href) === !1) {
811
512
  event.preventDefault();
812
513
  return;
813
514
  }
814
515
  if (rendererLinkOptions.activation === "event") {
815
- event.preventDefault();
816
- const activateResult = rendererLinkOptions.onActivate?.(href, event);
817
- if (activateResult === false)
818
- event.preventDefault();
516
+ event.preventDefault(), rendererLinkOptions.onActivate?.(href, event) === !1 && event.preventDefault();
819
517
  return;
820
518
  }
519
+ }, onAnchorPointerDown = () => {
520
+ if (!(!rendererLinkOptions || rendererLinkOptions.activation !== "event"))
521
+ try {
522
+ container.focus({ preventScroll: !0 });
523
+ } catch {
524
+ container.focus();
525
+ }
821
526
  };
822
- const onAnchorPointerDown = () => {
823
- if (!rendererLinkOptions || rendererLinkOptions.activation !== "event")
824
- return;
825
- try {
826
- container.focus({ preventScroll: true });
827
- } catch {
828
- container.focus();
829
- }
830
- };
831
- container.style.fontFamily = DEFAULT_FONT_FAMILY;
832
- container.style.whiteSpace = "pre";
833
- container.style.display = "inline-block";
834
- container.style.overflow = "hidden";
835
- container.style.position = "relative";
836
- container.style.userSelect = "text";
837
- container.style.outline = "none";
838
- container.style.contain = "layout style";
839
- if (options.accessibility !== false && !container.hasAttribute("tabindex")) {
840
- container.tabIndex = 0;
841
- }
842
- applyAccessibilityOptions(container, options.accessibility);
527
+ container.style.fontFamily = DEFAULT_FONT_FAMILY, container.style.whiteSpace = "pre", container.style.display = "inline-block", container.style.overflow = "hidden", container.style.position = "relative", container.style.userSelect = "text", container.style.outline = "none", container.style.contain = "layout style", options.accessibility !== !1 && !container.hasAttribute("tabindex") && (container.tabIndex = 0), applyAccessibilityOptions(container, options.accessibility);
843
528
  let palette = options.palette ?? null;
844
529
  installAnsiPaletteCssVars(container, palette);
845
- let metrics = measureCell(container);
846
- let wideScaleX = 1;
847
- const planeLayers = /* @__PURE__ */ new Map();
848
- let raf = 0;
849
- const pending = /* @__PURE__ */ new Map();
850
- let disposed = false;
851
- const syncFlushMaxRows = Math.max(
530
+ let metrics = measureCell(container), wideScaleX = 1, planeLayers = /* @__PURE__ */ new Map(), raf = 0, pending = /* @__PURE__ */ new Map(), disposed = !1, syncFlushMaxRows = Math.max(
852
531
  0,
853
532
  Math.floor(options.syncFlushMaxRows ?? DEFAULT_SYNC_FLUSH_MAX_ROWS)
854
- );
855
- const syncFlushCellBudget = Math.max(
533
+ ), syncFlushCellBudget = Math.max(
856
534
  0,
857
535
  Math.floor(options.syncFlushCellBudget ?? DEFAULT_SYNC_FLUSH_CELL_BUDGET)
858
- );
859
- const rowKeyPrepassMode = options.enableRowKeyPrepass ?? "auto";
860
- const capabilities = Object.freeze({
536
+ ), rowKeyPrepassMode = options.enableRowKeyPrepass ?? "auto", capabilities = Object.freeze({
861
537
  ...DOM_RENDERER_CAPABILITIES,
862
- scrollOperations: options.enableScrollOperations !== false
863
- });
864
- let syncFlushRequested = 0;
865
- let syncFlushPerformed = 0;
866
- let syncFlushDeferred = 0;
867
- let lastSyncFlushDecision = null;
868
- let domFlushCount = 0;
869
- let lastDomFlush = null;
870
- const rowRenderTotal = createEmptyRowStats();
871
- let lastRowRenderStats = null;
872
- let rowKeyPrepassAutoReady = false;
873
- let rowKeyPrepassAutoDecision = "sampling";
874
- let rowKeyPrepassSampleRows = 0;
875
- let rowKeyPrepassSampleHits = 0;
876
- let rowKeyPrepassSampleMisses = 0;
877
- let rowKeyPrepassLastSampleRows = 0;
878
- let rowKeyPrepassLastSampleHitRatio = null;
538
+ scrollOperations: options.enableScrollOperations !== !1
539
+ }), syncFlushRequested = 0, syncFlushPerformed = 0, syncFlushDeferred = 0, lastSyncFlushDecision = null, domFlushCount = 0, lastDomFlush = null, rowRenderTotal = createEmptyRowStats(), lastRowRenderStats = null, rowKeyPrepassAutoReady = !1, rowKeyPrepassAutoDecision = "sampling", rowKeyPrepassSampleRows = 0, rowKeyPrepassSampleHits = 0, rowKeyPrepassSampleMisses = 0, rowKeyPrepassLastSampleRows = 0, rowKeyPrepassLastSampleHitRatio = null;
879
540
  function rowKeyPrepassDecision() {
880
- if (rowKeyPrepassMode === true)
881
- return "forced-enabled";
882
- if (rowKeyPrepassMode === false)
883
- return "forced-disabled";
884
- return rowKeyPrepassAutoDecision;
541
+ return rowKeyPrepassMode === !0 ? "forced-enabled" : rowKeyPrepassMode === !1 ? "forced-disabled" : rowKeyPrepassAutoDecision;
885
542
  }
886
- const debugStats = {
543
+ let debugStats = {
887
544
  get syncFlush() {
888
545
  return {
889
546
  requested: syncFlushRequested,
@@ -905,7 +562,7 @@ function createDomRenderer(terminal, container, options = {}) {
905
562
  };
906
563
  },
907
564
  get rowKeyPrepass() {
908
- const sampleHitRatio = rowKeyPrepassSampleRows > 0 ? rowKeyPrepassSampleHits / rowKeyPrepassSampleRows : null;
565
+ let sampleHitRatio = rowKeyPrepassSampleRows > 0 ? rowKeyPrepassSampleHits / rowKeyPrepassSampleRows : null;
909
566
  return {
910
567
  mode: rowKeyPrepassMode,
911
568
  decision: rowKeyPrepassDecision(),
@@ -919,93 +576,50 @@ function createDomRenderer(terminal, container, options = {}) {
919
576
  }
920
577
  };
921
578
  function shouldUseRowKeyPrepass() {
922
- if (rowKeyPrepassMode === true)
923
- return true;
924
- if (rowKeyPrepassMode === false)
925
- return false;
926
- return rowKeyPrepassAutoReady && rowKeyPrepassAutoDecision !== "disabled";
579
+ return rowKeyPrepassMode === !0 ? !0 : rowKeyPrepassMode === !1 ? !1 : rowKeyPrepassAutoReady && rowKeyPrepassAutoDecision !== "disabled";
927
580
  }
928
581
  function recordRowKeyPrepassAutoStats(stats) {
929
- if (rowKeyPrepassMode !== "auto")
930
- return;
931
- if (stats.rowKeyPrepassChecks === 0)
932
- return;
933
- rowKeyPrepassSampleRows += stats.rowKeyPrepassChecks;
934
- rowKeyPrepassSampleHits += stats.rowKeyPrepassHits;
935
- rowKeyPrepassSampleMisses += stats.rowKeyPrepassMisses;
936
- if (rowKeyPrepassSampleRows < PREPASS_SAMPLE_ROWS)
582
+ if (rowKeyPrepassMode !== "auto" || stats.rowKeyPrepassChecks === 0 || (rowKeyPrepassSampleRows += stats.rowKeyPrepassChecks, rowKeyPrepassSampleHits += stats.rowKeyPrepassHits, rowKeyPrepassSampleMisses += stats.rowKeyPrepassMisses, rowKeyPrepassSampleRows < PREPASS_SAMPLE_ROWS))
937
583
  return;
938
- const hitRatio = rowKeyPrepassSampleHits / rowKeyPrepassSampleRows;
939
- rowKeyPrepassLastSampleRows = rowKeyPrepassSampleRows;
940
- rowKeyPrepassLastSampleHitRatio = hitRatio;
941
- if (rowKeyPrepassAutoDecision === "enabled") {
942
- if (hitRatio < PREPASS_DISABLE_HIT_RATIO)
943
- rowKeyPrepassAutoDecision = "disabled";
944
- } else if (hitRatio >= PREPASS_ENABLE_HIT_RATIO) {
945
- rowKeyPrepassAutoDecision = "enabled";
946
- } else {
947
- rowKeyPrepassAutoDecision = "disabled";
948
- }
949
- rowKeyPrepassSampleRows = 0;
950
- rowKeyPrepassSampleHits = 0;
951
- rowKeyPrepassSampleMisses = 0;
584
+ let hitRatio = rowKeyPrepassSampleHits / rowKeyPrepassSampleRows;
585
+ rowKeyPrepassLastSampleRows = rowKeyPrepassSampleRows, rowKeyPrepassLastSampleHitRatio = hitRatio, rowKeyPrepassAutoDecision === "enabled" ? hitRatio < PREPASS_DISABLE_HIT_RATIO && (rowKeyPrepassAutoDecision = "disabled") : hitRatio >= PREPASS_ENABLE_HIT_RATIO ? rowKeyPrepassAutoDecision = "enabled" : rowKeyPrepassAutoDecision = "disabled", rowKeyPrepassSampleRows = 0, rowKeyPrepassSampleHits = 0, rowKeyPrepassSampleMisses = 0;
952
586
  }
953
587
  function recordRowRenderStats(stats) {
954
- if (stats.rows === 0)
955
- return;
956
- addRowStats(rowRenderTotal, stats);
957
- lastRowRenderStats = freezeRowStats(stats);
588
+ stats.rows !== 0 && (addRowStats(rowRenderTotal, stats), lastRowRenderStats = freezeRowStats(stats));
958
589
  }
959
590
  function applyPlaneOffset(plane, offsetPx) {
960
- const layer = planeLayers.get(plane);
591
+ let layer = planeLayers.get(plane);
961
592
  if (!layer)
962
593
  return;
963
- const next = Number.isFinite(offsetPx) ? offsetPx : 0;
964
- if (layer.offsetPx === next)
965
- return;
966
- layer.offsetPx = next;
967
- layer.contentEl.style.transform = next ? `translateY(${next}px)` : "translateY(0px)";
594
+ let next = Number.isFinite(offsetPx) ? offsetPx : 0;
595
+ layer.offsetPx !== next && (layer.offsetPx = next, layer.contentEl.style.transform = next ? `translateY(${next}px)` : "translateY(0px)");
968
596
  }
969
597
  function applyPlaneViewport(plane, viewport) {
970
- const layer = planeLayers.get(plane);
598
+ let layer = planeLayers.get(plane);
971
599
  if (!layer)
972
600
  return;
973
- const totalHeight = terminal.size().rows * metrics.cellHeight;
601
+ let totalHeight = terminal.size().rows * metrics.cellHeight;
974
602
  if (!viewport) {
975
- layer.viewportTopPx = 0;
976
- layer.viewportHeightPx = null;
977
- layer.el.style.clipPath = "none";
603
+ layer.viewportTopPx = 0, layer.viewportHeightPx = null, layer.el.style.clipPath = "none";
978
604
  return;
979
605
  }
980
- const topPx = Math.max(0, Math.min(totalHeight, Math.floor(viewport.topPx)));
981
- const heightPx = Math.max(0, Math.min(totalHeight - topPx, Math.floor(viewport.heightPx)));
982
- layer.viewportTopPx = topPx;
983
- layer.viewportHeightPx = heightPx;
984
- if (topPx === 0 && heightPx >= totalHeight) {
606
+ let topPx = Math.max(0, Math.min(totalHeight, Math.floor(viewport.topPx))), heightPx = Math.max(0, Math.min(totalHeight - topPx, Math.floor(viewport.heightPx)));
607
+ if (layer.viewportTopPx = topPx, layer.viewportHeightPx = heightPx, topPx === 0 && heightPx >= totalHeight) {
985
608
  layer.el.style.clipPath = "none";
986
609
  return;
987
610
  }
988
- const bottomPx = Math.max(0, totalHeight - topPx - heightPx);
611
+ let bottomPx = Math.max(0, totalHeight - topPx - heightPx);
989
612
  layer.el.style.clipPath = `inset(${topPx}px 0px ${bottomPx}px 0px)`;
990
613
  }
991
614
  function rebuildLines() {
992
- const { rows, cols } = terminal.size();
993
- container.style.width = `${cols * metrics.cellWidth}px`;
994
- container.style.height = `${rows * metrics.cellHeight}px`;
995
- const fragment = doc.createDocumentFragment();
615
+ let { rows, cols } = terminal.size();
616
+ container.style.width = `${cols * metrics.cellWidth}px`, container.style.height = `${rows * metrics.cellHeight}px`;
617
+ let fragment = doc.createDocumentFragment();
996
618
  for (let i = 0; i < TERMINAL_RENDER_PLANES.length; i++) {
997
- const plane = TERMINAL_RENDER_PLANES[i];
998
- const planeTerminal = getPlaneTerminal(terminal, plane);
999
- let layer = planeLayers.get(plane);
619
+ let plane = TERMINAL_RENDER_PLANES[i], planeTerminal = getPlaneTerminal(terminal, plane), layer = planeLayers.get(plane);
1000
620
  if (!layer) {
1001
- const el = doc.createElement("div");
1002
- const contentEl = doc.createElement("div");
1003
- el.dataset.vtPlane = plane;
1004
- el.style.pointerEvents = "none";
1005
- contentEl.style.position = "absolute";
1006
- contentEl.style.left = "0";
1007
- contentEl.style.top = "0";
1008
- layer = {
621
+ let el = doc.createElement("div"), contentEl = doc.createElement("div");
622
+ el.dataset.vtPlane = plane, el.style.pointerEvents = "none", contentEl.style.position = "absolute", contentEl.style.left = "0", contentEl.style.top = "0", layer = {
1009
623
  el,
1010
624
  contentEl,
1011
625
  lines: [],
@@ -1013,142 +627,97 @@ function createDomRenderer(terminal, container, options = {}) {
1013
627
  terminal: planeTerminal,
1014
628
  viewportTopPx: 0,
1015
629
  viewportHeightPx: null
1016
- };
1017
- planeLayers.set(plane, layer);
630
+ }, planeLayers.set(plane, layer);
1018
631
  }
1019
- layer.terminal = planeTerminal;
1020
- layer.el.style.position = "absolute";
1021
- layer.el.style.left = "0";
1022
- layer.el.style.top = "0";
1023
- layer.el.style.width = `${cols * metrics.cellWidth}px`;
1024
- layer.el.style.height = `${rows * metrics.cellHeight}px`;
1025
- layer.el.style.overflow = "hidden";
1026
- layer.el.style.zIndex = String(i);
1027
- layer.contentEl.style.width = `${cols * metrics.cellWidth}px`;
1028
- layer.contentEl.style.height = `${rows * metrics.cellHeight}px`;
1029
- applyPlaneOffset(plane, layer.offsetPx);
1030
- applyPlaneViewport(
632
+ layer.terminal = planeTerminal, layer.el.style.position = "absolute", layer.el.style.left = "0", layer.el.style.top = "0", layer.el.style.width = `${cols * metrics.cellWidth}px`, layer.el.style.height = `${rows * metrics.cellHeight}px`, layer.el.style.overflow = "hidden", layer.el.style.zIndex = String(i), layer.contentEl.style.width = `${cols * metrics.cellWidth}px`, layer.contentEl.style.height = `${rows * metrics.cellHeight}px`, applyPlaneOffset(plane, layer.offsetPx), applyPlaneViewport(
1031
633
  plane,
1032
634
  layer.viewportHeightPx == null ? null : {
1033
635
  topPx: layer.viewportTopPx,
1034
636
  heightPx: layer.viewportHeightPx
1035
637
  }
1036
638
  );
1037
- const lineFragment = doc.createDocumentFragment();
639
+ let lineFragment = doc.createDocumentFragment();
1038
640
  layer.lines = Array.from({ length: rows }, () => {
1039
- const line = doc.createElement("div");
1040
- line.style.cssText = `height:${metrics.cellHeight}px;width:${cols * metrics.cellWidth}px;overflow:hidden;contain:layout style`;
1041
- lineFragment.appendChild(line);
1042
- return line;
1043
- });
1044
- layer.contentEl.replaceChildren(lineFragment);
1045
- layer.el.replaceChildren(layer.contentEl);
1046
- fragment.appendChild(layer.el);
641
+ let line = doc.createElement("div");
642
+ return line.style.cssText = `height:${metrics.cellHeight}px;width:${cols * metrics.cellWidth}px;overflow:hidden;contain:layout style`, lineFragment.appendChild(line), line;
643
+ }), layer.contentEl.replaceChildren(lineFragment), layer.el.replaceChildren(layer.contentEl), fragment.appendChild(layer.el);
1047
644
  }
1048
645
  container.replaceChildren(fragment);
1049
646
  }
1050
647
  function refresh() {
1051
- cancelPendingRaf();
1052
- clearPendingRows();
1053
- metrics = measureCell(container);
1054
- const wideW = measureCharWidth(container, "\u4E2D");
1055
- wideScaleX = wideW > 0 ? Math.max(1, Math.min(2, metrics.cellWidth * 2 / wideW)) : 1;
1056
- rebuildLines();
1057
- const size = terminal.size();
1058
- const rowStats = createEmptyRowStats();
1059
- for (const plane of TERMINAL_RENDER_PLANES) {
1060
- const layer = planeLayers.get(plane);
1061
- if (!layer)
1062
- continue;
1063
- for (let y = 0; y < size.rows; y++)
1064
- renderRow(
1065
- layer.terminal,
1066
- metrics,
1067
- wideScaleX,
1068
- y,
1069
- layer.lines[y],
1070
- rowStats,
1071
- shouldUseRowKeyPrepass(),
1072
- palette,
1073
- rendererLinkOptions,
1074
- onAnchorClick,
1075
- onAnchorPointerDown,
1076
- rendererLinkVersion
1077
- );
648
+ cancelPendingRaf(), clearPendingRows(), metrics = measureCell(container);
649
+ let wideW = measureCharWidth(container, "\u4E2D");
650
+ wideScaleX = wideW > 0 ? Math.max(1, Math.min(2, metrics.cellWidth * 2 / wideW)) : 1, rebuildLines();
651
+ let size = terminal.size(), rowStats = createEmptyRowStats();
652
+ for (let plane of TERMINAL_RENDER_PLANES) {
653
+ let layer = planeLayers.get(plane);
654
+ if (layer)
655
+ for (let y = 0; y < size.rows; y++)
656
+ renderRow(
657
+ layer.terminal,
658
+ metrics,
659
+ wideScaleX,
660
+ y,
661
+ layer.lines[y],
662
+ rowStats,
663
+ shouldUseRowKeyPrepass(),
664
+ palette,
665
+ rendererLinkOptions,
666
+ onAnchorClick,
667
+ onAnchorPointerDown,
668
+ rendererLinkVersion
669
+ );
1078
670
  }
1079
- recordRowKeyPrepassAutoStats(rowStats);
1080
- recordRowRenderStats(rowStats);
671
+ recordRowKeyPrepassAutoStats(rowStats), recordRowRenderStats(rowStats);
1081
672
  }
1082
- const pendingRowCountsByPlane = /* @__PURE__ */ new Map();
1083
- let pendingTotalRowCount = 0;
1084
- let lastSyncFlushWarnAt = 0;
673
+ let pendingRowCountsByPlane = /* @__PURE__ */ new Map(), pendingTotalRowCount = 0, lastSyncFlushWarnAt = 0;
1085
674
  function cancelPendingRaf() {
1086
- if (raf > 0)
1087
- cancelAnimationFrame(raf);
1088
- raf = 0;
675
+ raf > 0 && cancelAnimationFrame(raf), raf = 0;
1089
676
  }
1090
677
  function clearPendingRows() {
1091
- pending.clear();
1092
- pendingRowCountsByPlane.clear();
1093
- pendingTotalRowCount = 0;
678
+ pending.clear(), pendingRowCountsByPlane.clear(), pendingTotalRowCount = 0;
1094
679
  }
1095
680
  function addPendingRow(plane, rows, y) {
1096
- if (rows.has(y))
1097
- return;
1098
- rows.add(y);
1099
- pendingTotalRowCount++;
1100
- pendingRowCountsByPlane.set(plane, (pendingRowCountsByPlane.get(plane) ?? 0) + 1);
681
+ rows.has(y) || (rows.add(y), pendingTotalRowCount++, pendingRowCountsByPlane.set(plane, (pendingRowCountsByPlane.get(plane) ?? 0) + 1));
1101
682
  }
1102
683
  function deletePendingRow(plane, rows, y) {
1103
684
  if (!rows.delete(y))
1104
685
  return;
1105
686
  pendingTotalRowCount--;
1106
- const nextCount = (pendingRowCountsByPlane.get(plane) ?? 1) - 1;
1107
- if (nextCount > 0)
1108
- pendingRowCountsByPlane.set(plane, nextCount);
1109
- else
1110
- pendingRowCountsByPlane.delete(plane);
687
+ let nextCount = (pendingRowCountsByPlane.get(plane) ?? 1) - 1;
688
+ nextCount > 0 ? pendingRowCountsByPlane.set(plane, nextCount) : pendingRowCountsByPlane.delete(plane);
1111
689
  }
1112
690
  function hasPendingRowsInRange(plane, startY, endY) {
1113
- const rows = pending.get(plane);
691
+ let rows = pending.get(plane);
1114
692
  if (!rows?.size)
1115
- return false;
1116
- for (const y of rows) {
693
+ return !1;
694
+ for (let y of rows)
1117
695
  if (y >= startY && y < endY)
1118
- return true;
1119
- }
1120
- return false;
696
+ return !0;
697
+ return !1;
1121
698
  }
1122
699
  function addPendingRowRange(plane, startY, endY) {
1123
700
  let rows = pending.get(plane);
1124
- if (!rows) {
1125
- rows = /* @__PURE__ */ new Set();
1126
- pending.set(plane, rows);
1127
- }
701
+ rows || (rows = /* @__PURE__ */ new Set(), pending.set(plane, rows));
1128
702
  for (let y = startY; y < endY; y++)
1129
703
  addPendingRow(plane, rows, y);
1130
704
  }
1131
705
  function invalidateRowCacheRange(layer, startY, endY) {
1132
706
  for (let y = startY; y < endY; y++) {
1133
- const line = layer.lines[y];
1134
- if (line)
1135
- rowCache.delete(line);
707
+ let line = layer.lines[y];
708
+ line && rowCache.delete(line);
1136
709
  }
1137
710
  }
1138
711
  function reorderLayerDomRows(layer, startY, endY) {
1139
- const before = layer.lines[endY] ?? null;
1140
- const fragment = layer.contentEl.ownerDocument.createDocumentFragment();
712
+ let before = layer.lines[endY] ?? null, fragment = layer.contentEl.ownerDocument.createDocumentFragment();
1141
713
  for (let y = startY; y < endY; y++) {
1142
- const line = layer.lines[y];
1143
- if (line)
1144
- fragment.appendChild(line);
714
+ let line = layer.lines[y];
715
+ line && fragment.appendChild(line);
1145
716
  }
1146
717
  layer.contentEl.insertBefore(fragment, before);
1147
718
  }
1148
719
  function scrollOperationRange(op) {
1149
- const { rows } = terminal.size();
1150
- const startY = Math.max(0, Math.min(rows, Math.floor(op.startY)));
1151
- const endY = Math.max(0, Math.min(rows, Math.floor(op.endY)));
720
+ let { rows } = terminal.size(), startY = Math.max(0, Math.min(rows, Math.floor(op.startY))), endY = Math.max(0, Math.min(rows, Math.floor(op.endY)));
1152
721
  return { startY, endY };
1153
722
  }
1154
723
  function addFallbackRows(rows, startY, endY) {
@@ -1160,88 +729,66 @@ function createDomRenderer(terminal, container, options = {}) {
1160
729
  return null;
1161
730
  if (!b.length)
1162
731
  return a;
1163
- const rows = new Set(a);
1164
- for (const y of b)
732
+ let rows = new Set(a);
733
+ for (let y of b)
1165
734
  rows.add(y);
1166
735
  return Array.from(rows).sort((left, right) => left - right);
1167
736
  }
1168
737
  function invalidateAndRepaintScrollRange(plane, layer, startY, endY) {
1169
- invalidateRowCacheRange(layer, startY, endY);
1170
- addPendingRowRange(plane, startY, endY);
738
+ invalidateRowCacheRange(layer, startY, endY), addPendingRowRange(plane, startY, endY);
1171
739
  }
1172
740
  function applyScrollOperationToLayer(layer, op) {
1173
- const { startY, endY } = scrollOperationRange(op);
1174
- const delta = Math.trunc(op.delta);
1175
- const height = endY - startY;
1176
- const region = layer.lines.slice(startY, endY);
1177
- const nextRegion = delta > 0 ? [...region.slice(delta), ...region.slice(0, delta)] : [...region.slice(height + delta), ...region.slice(0, height + delta)];
741
+ let { startY, endY } = scrollOperationRange(op), delta = Math.trunc(op.delta), height = endY - startY, region = layer.lines.slice(startY, endY), nextRegion = delta > 0 ? [...region.slice(delta), ...region.slice(0, delta)] : [...region.slice(height + delta), ...region.slice(0, height + delta)];
1178
742
  for (let i = 0; i < height; i++) {
1179
- const line = nextRegion[i];
1180
- if (!line)
1181
- continue;
1182
- layer.lines[startY + i] = line;
1183
- rowCache.delete(line);
743
+ let line = nextRegion[i];
744
+ line && (layer.lines[startY + i] = line, rowCache.delete(line));
1184
745
  }
1185
746
  reorderLayerDomRows(layer, startY, endY);
1186
747
  }
1187
748
  function canApplyScrollOperations(planes, operations) {
1188
749
  if (!capabilities.scrollOperations || planes.length !== 1 || !operations?.length)
1189
- return false;
1190
- const plane = planes[0];
1191
- const layer = planeLayers.get(plane);
1192
- if (!layer)
1193
- return false;
1194
- for (const op of operations) {
1195
- const { startY, endY } = scrollOperationRange(op);
1196
- const delta = Math.trunc(op.delta);
1197
- const height = endY - startY;
1198
- if (height <= 0 || delta === 0 || Math.abs(delta) >= height)
1199
- return false;
1200
- if (hasPendingRowsInRange(plane, startY, endY))
1201
- return false;
750
+ return !1;
751
+ let plane = planes[0];
752
+ if (!planeLayers.get(plane))
753
+ return !1;
754
+ for (let op of operations) {
755
+ let { startY, endY } = scrollOperationRange(op), delta = Math.trunc(op.delta), height = endY - startY;
756
+ if (height <= 0 || delta === 0 || Math.abs(delta) >= height || hasPendingRowsInRange(plane, startY, endY))
757
+ return !1;
1202
758
  }
1203
- return true;
759
+ return !0;
1204
760
  }
1205
761
  function applyScrollOperations(planes, operations) {
1206
- if (!operations?.length)
1207
- return;
1208
- for (const plane of planes) {
1209
- const layer = planeLayers.get(plane);
1210
- if (!layer)
1211
- continue;
1212
- for (const op of operations)
1213
- applyScrollOperationToLayer(layer, op);
1214
- }
762
+ if (operations?.length)
763
+ for (let plane of planes) {
764
+ let layer = planeLayers.get(plane);
765
+ if (layer)
766
+ for (let op of operations)
767
+ applyScrollOperationToLayer(layer, op);
768
+ }
1215
769
  }
1216
770
  function markScrollOperationRangesPending(planes, operations) {
1217
771
  if (!operations?.length)
1218
772
  return [];
1219
- const fallbackRows = /* @__PURE__ */ new Set();
1220
- for (const plane of planes) {
1221
- const layer = planeLayers.get(plane);
1222
- if (!layer)
1223
- continue;
1224
- for (const op of operations) {
1225
- const { startY, endY } = scrollOperationRange(op);
1226
- invalidateAndRepaintScrollRange(plane, layer, startY, endY);
1227
- addFallbackRows(fallbackRows, startY, endY);
1228
- }
773
+ let fallbackRows = /* @__PURE__ */ new Set();
774
+ for (let plane of planes) {
775
+ let layer = planeLayers.get(plane);
776
+ if (layer)
777
+ for (let op of operations) {
778
+ let { startY, endY } = scrollOperationRange(op);
779
+ invalidateAndRepaintScrollRange(plane, layer, startY, endY), addFallbackRows(fallbackRows, startY, endY);
780
+ }
1229
781
  }
1230
782
  return Array.from(fallbackRows).sort((a, b) => a - b);
1231
783
  }
1232
784
  function estimateSyncFlushWork(scope) {
1233
- const size = terminal.size();
1234
- const rowCount = scope.rows == null ? size.rows : scope.rows.length;
1235
- const planeCount = scope.planes.length || TERMINAL_RENDER_PLANES.length;
1236
- const cellWork = rowCount * size.cols * planeCount;
785
+ let size = terminal.size(), rowCount = scope.rows == null ? size.rows : scope.rows.length, planeCount = scope.planes.length || TERMINAL_RENDER_PLANES.length, cellWork = rowCount * size.cols * planeCount;
1237
786
  return { rowCount, planeCount, cellWork };
1238
787
  }
1239
788
  function estimateScrollOperationWork(planes, operations) {
1240
- const size = terminal.size();
1241
- const planeCount = planes.length || TERMINAL_RENDER_PLANES.length;
1242
- let rowCount = 0;
1243
- for (const op of operations ?? []) {
1244
- const { startY, endY } = scrollOperationRange(op);
789
+ let size = terminal.size(), planeCount = planes.length || TERMINAL_RENDER_PLANES.length, rowCount = 0;
790
+ for (let op of operations ?? []) {
791
+ let { startY, endY } = scrollOperationRange(op);
1245
792
  rowCount += Math.max(0, endY - startY);
1246
793
  }
1247
794
  return { rowCount, planeCount, cellWork: rowCount * size.cols * planeCount };
@@ -1254,12 +801,7 @@ function createDomRenderer(terminal, container, options = {}) {
1254
801
  };
1255
802
  }
1256
803
  function recordSyncFlushDecision(work, performed, deferredReason) {
1257
- syncFlushRequested++;
1258
- if (performed)
1259
- syncFlushPerformed++;
1260
- else
1261
- syncFlushDeferred++;
1262
- lastSyncFlushDecision = {
804
+ syncFlushRequested++, performed ? syncFlushPerformed++ : syncFlushDeferred++, lastSyncFlushDecision = {
1263
805
  performed,
1264
806
  deferredReason,
1265
807
  rows: work.rowCount,
@@ -1270,213 +812,138 @@ function createDomRenderer(terminal, container, options = {}) {
1270
812
  };
1271
813
  }
1272
814
  function recordLargeSyncFlush(work) {
1273
- if (!globalThis.__VT_DEBUG_PERF__)
1274
- return;
1275
- if (work.rowCount <= syncFlushMaxRows && work.cellWork <= syncFlushCellBudget)
815
+ if (!globalThis.__VT_DEBUG_PERF__ || work.rowCount <= syncFlushMaxRows && work.cellWork <= syncFlushCellBudget)
1276
816
  return;
1277
- const size = terminal.size();
1278
- const now = Date.now();
1279
- if (now - lastSyncFlushWarnAt < 1e3)
1280
- return;
1281
- lastSyncFlushWarnAt = now;
1282
- console.warn(
817
+ let size = terminal.size(), now = Date.now();
818
+ now - lastSyncFlushWarnAt < 1e3 || (lastSyncFlushWarnAt = now, console.warn(
1283
819
  `[vue-tui] sync DOM flush request deferred to rAF: rows=${work.rowCount} maxRows=${syncFlushMaxRows} cols=${size.cols} planes=${work.planeCount} cells=${work.cellWork} maxCells=${syncFlushCellBudget}`
1284
- );
820
+ ));
1285
821
  }
1286
822
  function shouldSyncFlush(work) {
1287
823
  return work.rowCount <= syncFlushMaxRows && work.cellWork <= syncFlushCellBudget;
1288
824
  }
1289
825
  function scopeWillDrainAllPending(scope) {
1290
826
  if (pendingTotalRowCount === 0)
1291
- return true;
827
+ return !0;
1292
828
  if (scope.rows !== null && pendingTotalRowCount > scope.rows.length * scope.planes.length)
1293
- return false;
1294
- const scopePlanes = new Set(scope.planes);
1295
- for (const plane of pendingRowCountsByPlane.keys()) {
829
+ return !1;
830
+ let scopePlanes = new Set(scope.planes);
831
+ for (let plane of pendingRowCountsByPlane.keys())
1296
832
  if (!scopePlanes.has(plane))
1297
- return false;
1298
- }
833
+ return !1;
1299
834
  if (scope.rows === null)
1300
- return true;
1301
- const scopeRows = new Set(scope.rows);
1302
- for (const [plane, rows] of pending) {
1303
- if (!scopePlanes.has(plane))
1304
- return false;
1305
- if (rows.size > scopeRows.size)
1306
- return false;
1307
- for (const y of rows) {
835
+ return !0;
836
+ let scopeRows = new Set(scope.rows);
837
+ for (let [plane, rows] of pending) {
838
+ if (!scopePlanes.has(plane) || rows.size > scopeRows.size)
839
+ return !1;
840
+ for (let y of rows)
1308
841
  if (!scopeRows.has(y))
1309
- return false;
1310
- }
842
+ return !1;
1311
843
  }
1312
- return true;
844
+ return !0;
1313
845
  }
1314
846
  function flushPending(scope, options2) {
1315
- if (options2?.clearRaf !== false)
1316
- raf = 0;
1317
- if (disposed)
847
+ if (options2?.clearRaf !== !1 && (raf = 0), disposed)
1318
848
  return;
1319
- const startedAt = nowMs();
1320
- const planesToFlush = scope?.planes ?? TERMINAL_RENDER_PLANES;
1321
- let flushedRows = 0;
1322
- const rowStats = createEmptyRowStats();
1323
- const useRowKeyPrepass = shouldUseRowKeyPrepass();
1324
- for (const plane of planesToFlush) {
1325
- const layer = planeLayers.get(plane);
1326
- const rows = pending.get(plane);
849
+ let startedAt = nowMs(), planesToFlush = scope?.planes ?? TERMINAL_RENDER_PLANES, flushedRows = 0, rowStats = createEmptyRowStats(), useRowKeyPrepass = shouldUseRowKeyPrepass();
850
+ for (let plane of planesToFlush) {
851
+ let layer = planeLayers.get(plane), rows = pending.get(plane);
1327
852
  if (!layer || !rows?.size)
1328
853
  continue;
1329
- const flushRow = (y) => {
854
+ let flushRow = (y) => {
1330
855
  if (!rows.has(y))
1331
856
  return;
1332
- const line = layer.lines[y];
1333
- if (line)
1334
- renderRow(
1335
- layer.terminal,
1336
- metrics,
1337
- wideScaleX,
1338
- y,
1339
- line,
1340
- rowStats,
1341
- useRowKeyPrepass,
1342
- palette,
1343
- rendererLinkOptions,
1344
- onAnchorClick,
1345
- onAnchorPointerDown,
1346
- rendererLinkVersion
1347
- );
1348
- deletePendingRow(plane, rows, y);
1349
- flushedRows++;
857
+ let line = layer.lines[y];
858
+ line && renderRow(
859
+ layer.terminal,
860
+ metrics,
861
+ wideScaleX,
862
+ y,
863
+ line,
864
+ rowStats,
865
+ useRowKeyPrepass,
866
+ palette,
867
+ rendererLinkOptions,
868
+ onAnchorClick,
869
+ onAnchorPointerDown,
870
+ rendererLinkVersion
871
+ ), deletePendingRow(plane, rows, y), flushedRows++;
1350
872
  };
1351
- if (scope?.rows == null) {
1352
- for (const y of rows)
873
+ if (scope?.rows == null)
874
+ for (let y of rows)
1353
875
  flushRow(y);
1354
- } else {
1355
- for (const y of scope.rows)
876
+ else
877
+ for (let y of scope.rows)
1356
878
  flushRow(y);
1357
- }
1358
- if (rows.size === 0)
1359
- pending.delete(plane);
1360
- }
1361
- if (flushedRows > 0) {
1362
- recordRowKeyPrepassAutoStats(rowStats);
1363
- recordRowRenderStats(rowStats);
1364
- rowKeyPrepassAutoReady = true;
1365
- domFlushCount++;
1366
- lastDomFlush = {
1367
- mode: options2?.mode ?? "deferred",
1368
- startedAt,
1369
- durationMs: nowMs() - startedAt,
1370
- planeRows: flushedRows,
1371
- planes: planesToFlush.length
1372
- };
879
+ rows.size === 0 && pending.delete(plane);
1373
880
  }
1374
- if (pending.size > 0)
1375
- scheduleRafIfNeeded();
881
+ flushedRows > 0 && (recordRowKeyPrepassAutoStats(rowStats), recordRowRenderStats(rowStats), rowKeyPrepassAutoReady = !0, domFlushCount++, lastDomFlush = {
882
+ mode: options2?.mode ?? "deferred",
883
+ startedAt,
884
+ durationMs: nowMs() - startedAt,
885
+ planeRows: flushedRows,
886
+ planes: planesToFlush.length
887
+ }), pending.size > 0 && scheduleRafIfNeeded();
1376
888
  }
1377
889
  function scheduleRafIfNeeded() {
1378
890
  if (raf || disposed)
1379
891
  return;
1380
892
  raf = -1;
1381
- const id = requestAnimationFrame(() => {
893
+ let id = requestAnimationFrame(() => {
1382
894
  flushPending(void 0, { mode: "deferred" });
1383
895
  });
1384
- if (raf === -1)
1385
- raf = id;
896
+ raf === -1 && (raf = id);
1386
897
  }
1387
- const offCommit = terminal.on("commit", ({ dirtyRows, planes, sync, scrollOperations }) => {
1388
- const activePlanes = planes?.length ? planes : TERMINAL_RENDER_PLANES;
1389
- const dirtyCommitRows = dirtyRows === null ? null : [...dirtyRows];
1390
- const initialSyncWork = estimateSyncFlushWork({
898
+ let offCommit = terminal.on("commit", ({ dirtyRows, planes, sync, scrollOperations }) => {
899
+ let activePlanes = planes?.length ? planes : TERMINAL_RENDER_PLANES, dirtyCommitRows = dirtyRows === null ? null : [...dirtyRows], initialSyncWork = estimateSyncFlushWork({
1391
900
  planes: activePlanes,
1392
901
  rows: dirtyCommitRows
1393
- });
1394
- const scrollWork = estimateScrollOperationWork(activePlanes, scrollOperations);
1395
- const combinedSyncWork = combineSyncFlushWork(initialSyncWork, scrollWork);
1396
- const shouldApplyScrollOperations = Boolean(sync) && shouldSyncFlush(combinedSyncWork) && canApplyScrollOperations(activePlanes, scrollOperations);
1397
- const fallbackRows = shouldApplyScrollOperations ? [] : markScrollOperationRangesPending(activePlanes, scrollOperations);
1398
- if (shouldApplyScrollOperations)
1399
- applyScrollOperations(activePlanes, scrollOperations);
1400
- const commitRows = unionRows(dirtyCommitRows, fallbackRows);
902
+ }), scrollWork = estimateScrollOperationWork(activePlanes, scrollOperations), combinedSyncWork = combineSyncFlushWork(initialSyncWork, scrollWork), shouldApplyScrollOperations = !!sync && shouldSyncFlush(combinedSyncWork) && canApplyScrollOperations(activePlanes, scrollOperations), fallbackRows = shouldApplyScrollOperations ? [] : markScrollOperationRangesPending(activePlanes, scrollOperations);
903
+ shouldApplyScrollOperations && applyScrollOperations(activePlanes, scrollOperations);
904
+ let commitRows = unionRows(dirtyCommitRows, fallbackRows);
1401
905
  if (dirtyRows === null) {
1402
- const size = terminal.size();
1403
- for (const plane of activePlanes) {
906
+ let size = terminal.size();
907
+ for (let plane of activePlanes) {
1404
908
  let rows = pending.get(plane);
1405
- if (!rows) {
1406
- rows = /* @__PURE__ */ new Set();
1407
- pending.set(plane, rows);
1408
- }
909
+ rows || (rows = /* @__PURE__ */ new Set(), pending.set(plane, rows));
1409
910
  for (let y = 0; y < size.rows; y++)
1410
911
  addPendingRow(plane, rows, y);
1411
912
  }
1412
- } else {
1413
- for (const plane of activePlanes) {
913
+ } else
914
+ for (let plane of activePlanes) {
1414
915
  let rows = pending.get(plane);
1415
- if (!rows) {
1416
- rows = /* @__PURE__ */ new Set();
1417
- pending.set(plane, rows);
1418
- }
1419
- for (const y of commitRows ?? dirtyRows)
916
+ rows || (rows = /* @__PURE__ */ new Set(), pending.set(plane, rows));
917
+ for (let y of commitRows ?? dirtyRows)
1420
918
  addPendingRow(plane, rows, y);
1421
919
  }
1422
- }
1423
920
  if (sync) {
1424
- const scope = { planes: activePlanes, rows: commitRows };
1425
- const syncWork = estimateSyncFlushWork(scope);
1426
- recordLargeSyncFlush(syncWork);
1427
- if (!shouldSyncFlush(syncWork)) {
1428
- recordSyncFlushDecision(syncWork, false, "budget");
1429
- scheduleRafIfNeeded();
921
+ let scope = { planes: activePlanes, rows: commitRows }, syncWork = estimateSyncFlushWork(scope);
922
+ if (recordLargeSyncFlush(syncWork), !shouldSyncFlush(syncWork)) {
923
+ recordSyncFlushDecision(syncWork, !1, "budget"), scheduleRafIfNeeded();
1430
924
  return;
1431
925
  }
1432
- recordSyncFlushDecision(syncWork, true);
1433
- const drainedAll = scopeWillDrainAllPending(scope);
1434
- if (raf > 0 && drainedAll) {
1435
- cancelAnimationFrame(raf);
1436
- raf = 0;
1437
- }
1438
- flushPending(scope, { clearRaf: drainedAll, mode: "sync" });
1439
- if (!drainedAll)
1440
- scheduleRafIfNeeded();
1441
- } else if (!raf) {
1442
- scheduleRafIfNeeded();
1443
- }
1444
- });
1445
- const offResize = terminal.on("resize", () => {
926
+ recordSyncFlushDecision(syncWork, !0);
927
+ let drainedAll = scopeWillDrainAllPending(scope);
928
+ raf > 0 && drainedAll && (cancelAnimationFrame(raf), raf = 0), flushPending(scope, { clearRaf: drainedAll, mode: "sync" }), drainedAll || scheduleRafIfNeeded();
929
+ } else
930
+ raf || scheduleRafIfNeeded();
931
+ }), offResize = terminal.on("resize", () => {
1446
932
  refresh();
1447
933
  });
1448
934
  function updateTheme(next) {
1449
935
  if (disposed)
1450
936
  return;
1451
- let changed = false;
1452
- if ("palette" in next) {
1453
- palette = next.palette ?? null;
1454
- installAnsiPaletteCssVars(container, palette);
1455
- changed = true;
1456
- }
1457
- if (changed)
1458
- refresh();
937
+ let changed = !1;
938
+ "palette" in next && (palette = next.palette ?? null, installAnsiPaletteCssVars(container, palette), changed = !0), changed && refresh();
1459
939
  }
1460
940
  function updateOptions(next) {
1461
- if (disposed)
941
+ if (disposed || (Object.prototype.hasOwnProperty.call(next, "onLinkClick") && (rendererOnLinkClick = next.onLinkClick), !Object.prototype.hasOwnProperty.call(next, "links")))
1462
942
  return;
1463
- if (Object.prototype.hasOwnProperty.call(next, "onLinkClick")) {
1464
- rendererOnLinkClick = next.onLinkClick;
1465
- }
1466
- if (!Object.prototype.hasOwnProperty.call(next, "links"))
1467
- return;
1468
- const normalized = normalizeLinkOptions(next.links);
1469
- const nextKey = linkOptionsKey(normalized);
1470
- rendererLinkOptions = normalized;
1471
- if (nextKey === rendererLinkOptionsKey)
1472
- return;
1473
- rendererLinkOptionsKey = nextKey;
1474
- rendererLinkVersion++;
1475
- refresh();
943
+ let normalized = normalizeLinkOptions(next.links), nextKey = linkOptionsKey(normalized);
944
+ rendererLinkOptions = normalized, nextKey !== rendererLinkOptionsKey && (rendererLinkOptionsKey = nextKey, rendererLinkVersion++, refresh());
1476
945
  }
1477
- refresh();
1478
- terminal.commit();
1479
- return {
946
+ return refresh(), terminal.commit(), {
1480
947
  container,
1481
948
  capabilities,
1482
949
  debugStats,
@@ -1487,13 +954,7 @@ function createDomRenderer(terminal, container, options = {}) {
1487
954
  updateTheme,
1488
955
  updateOptions,
1489
956
  dispose() {
1490
- disposed = true;
1491
- offCommit();
1492
- offResize();
1493
- cancelPendingRaf();
1494
- clearPendingRows();
1495
- planeLayers.clear();
1496
- container.replaceChildren();
957
+ disposed = !0, offCommit(), offResize(), cancelPendingRaf(), clearPendingRows(), planeLayers.clear(), container.replaceChildren();
1497
958
  },
1498
959
  setPlaneOffset(plane, offsetPx) {
1499
960
  applyPlaneOffset(plane, offsetPx);