@simon_he/vue-tui 0.0.7 → 1.0.0-rc.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 (207) hide show
  1. package/README.md +222 -444
  2. package/dist/TSelect-BmSkar0D.js +8697 -0
  3. package/dist/ansi-palette-Bv5Vqr4k.js +1499 -0
  4. package/dist/ansi-styles.d.ts +200 -0
  5. package/dist/cli/headless-renderer.d.ts +29 -0
  6. package/dist/cli/input.d.ts +49 -0
  7. package/dist/cli/node-file-writers.d.ts +12 -0
  8. package/dist/cli/node-module.d.ts +2 -0
  9. package/dist/cli/parse-kitty.d.ts +2 -0
  10. package/dist/cli/parse-mouse.d.ts +2 -0
  11. package/dist/cli/parse-utils.d.ts +14 -0
  12. package/dist/cli/parse-xterm.d.ts +2 -0
  13. package/dist/cli/path-provider-types.d.ts +1 -0
  14. package/dist/cli/path-provider.d.ts +4 -0
  15. package/dist/cli/path-suggest-core.d.ts +1 -0
  16. package/dist/cli/path-suggest.d.ts +15 -0
  17. package/dist/cli/recording.d.ts +4 -0
  18. package/dist/cli/stdin-buffer.d.ts +33 -0
  19. package/dist/cli.cjs +10664 -0
  20. package/dist/cli.d.cts +22 -0
  21. package/dist/cli.d.ts +22 -0
  22. package/dist/cli.js +9521 -0
  23. package/dist/core/ansi/capability.d.ts +20 -0
  24. package/dist/core/ansi/colors.d.ts +41 -0
  25. package/dist/core/ansi/sgr.d.ts +7 -0
  26. package/dist/core/ansi/theme.d.ts +6 -0
  27. package/dist/core/ansi-palette.d.ts +14 -0
  28. package/dist/core/buffer/buffer.d.ts +54 -0
  29. package/dist/core/buffer/width.d.ts +4 -0
  30. package/dist/core/debug-logger.d.ts +18 -0
  31. package/dist/core/hyperlink.d.ts +9 -0
  32. package/dist/core/index.d.ts +4 -0
  33. package/dist/core/path-provider-types.d.ts +24 -0
  34. package/dist/core/path-suggest.d.ts +35 -0
  35. package/dist/core/render-plane.d.ts +3 -0
  36. package/dist/core/terminal/create-terminal.d.ts +7 -0
  37. package/dist/core/terminal/emitter.d.ts +7 -0
  38. package/dist/core/types.d.ts +107 -0
  39. package/dist/core.cjs +3072 -0
  40. package/dist/core.d.cts +14 -0
  41. package/dist/core.d.ts +14 -0
  42. package/dist/core.js +422 -0
  43. package/dist/create-terminal-app.d.ts +34 -0
  44. package/dist/dom-renderer-CDVQIcIL.js +1172 -0
  45. package/dist/events/index.d.ts +6 -0
  46. package/dist/events/manager/cli-event-manager.d.ts +22 -0
  47. package/dist/events/manager/event-manager.d.ts +30 -0
  48. package/dist/events/manager/selection-suppression.d.ts +3 -0
  49. package/dist/events/manager/types.d.ts +108 -0
  50. package/dist/events/recording.d.ts +44 -0
  51. package/dist/experimental.cjs +9380 -0
  52. package/dist/experimental.d.cts +39 -0
  53. package/dist/experimental.d.ts +39 -0
  54. package/dist/experimental.js +7624 -0
  55. package/dist/frame-perf-C-w8mjJL.js +98 -0
  56. package/dist/hyperlink-B5PD7a3Q.js +331 -0
  57. package/dist/index.cjs +12037 -16507
  58. package/dist/index.d.cts +13 -0
  59. package/dist/index.d.ts +13 -1353
  60. package/dist/index.js +13 -18738
  61. package/dist/markdown.cjs +21929 -0
  62. package/dist/markdown.d.cts +10 -0
  63. package/dist/markdown.d.ts +10 -0
  64. package/dist/markdown.js +1649 -0
  65. package/dist/observability/cli-latency-node.d.ts +3 -0
  66. package/dist/observability/cli-latency-types.d.ts +41 -0
  67. package/dist/observability/cli-latency.d.ts +3 -0
  68. package/dist/observability/frame-perf-store.d.ts +13 -0
  69. package/dist/observability/frame-perf.d.ts +40 -0
  70. package/dist/observability/trace.d.ts +40 -0
  71. package/dist/observability/tui-profiler.d.ts +33 -0
  72. package/dist/observability.cjs +99 -0
  73. package/dist/observability.d.cts +6 -0
  74. package/dist/observability.d.ts +6 -0
  75. package/dist/observability.js +3 -0
  76. package/dist/path-DDiSCXrQ.js +99 -0
  77. package/dist/path-suggest-0Q2BDsuj.js +274 -0
  78. package/dist/path-suggest-Dk9TRLh5.js +3 -0
  79. package/dist/{path-suggest-CZQYJIIg.js → path-suggest-bvR9SY6Q.js} +86 -18
  80. package/dist/renderer/capabilities.d.ts +13 -0
  81. package/dist/renderer/cli/index.d.ts +2 -0
  82. package/dist/renderer/cli/stdout-metrics.d.ts +18 -0
  83. package/dist/renderer/cli/stdout-renderer.d.ts +48 -0
  84. package/dist/renderer/dom/dom-renderer.d.ts +157 -0
  85. package/dist/renderer/dom/index.d.ts +2 -0
  86. package/dist/renderer/index.d.ts +2 -0
  87. package/dist/renderer-dom.cjs +1511 -0
  88. package/dist/renderer-dom.d.cts +4 -0
  89. package/dist/renderer-dom.d.ts +4 -0
  90. package/dist/renderer-dom.js +6 -0
  91. package/dist/runtime/index.d.ts +36 -0
  92. package/dist/runtime/osc52.d.ts +9 -0
  93. package/dist/runtime-DtrcQidD.js +1197 -0
  94. package/dist/runtime.cjs +1697 -0
  95. package/dist/runtime.d.cts +9 -0
  96. package/dist/runtime.d.ts +9 -0
  97. package/dist/runtime.js +4 -0
  98. package/dist/selection/terminal-selection.d.ts +122 -0
  99. package/dist/sgr-DMK2AvuT.js +304 -0
  100. package/dist/style-cache-i0ZABZRq.js +178 -0
  101. package/dist/terminal-selection-BCOh9jsL.js +329 -0
  102. package/dist/utils/env.d.ts +3 -0
  103. package/dist/utils/newlines.d.ts +1 -0
  104. package/dist/utils/path.d.ts +7 -0
  105. package/dist/utils/url-safety.d.ts +2 -0
  106. package/dist/vue/components/TAnchor.d.ts +108 -0
  107. package/dist/vue/components/TBox.d.ts +144 -0
  108. package/dist/vue/components/TDebugOverlay.d.ts +43 -0
  109. package/dist/vue/components/TDialog.d.ts +256 -0
  110. package/dist/vue/components/TFlow.d.ts +85 -0
  111. package/dist/vue/components/TInput.d.ts +554 -0
  112. package/dist/vue/components/TInputBox.d.ts +158 -0
  113. package/dist/vue/components/TJsonEditor.d.ts +165 -0
  114. package/dist/vue/components/TList.d.ts +119 -0
  115. package/dist/vue/components/TLogLinksPanel.d.ts +238 -0
  116. package/dist/vue/components/TLogMinimap.d.ts +263 -0
  117. package/dist/vue/components/TLogScrollbar.d.ts +236 -0
  118. package/dist/vue/components/TLogSearchBar.d.ts +267 -0
  119. package/dist/vue/components/TLogSearchPager.d.ts +162 -0
  120. package/dist/vue/components/TLogSearchResults.d.ts +200 -0
  121. package/dist/vue/components/TLogView.d.ts +502 -0
  122. package/dist/vue/components/TLogVirtualLinksPanel.d.ts +141 -0
  123. package/dist/vue/components/TLogVirtualSearchResults.d.ts +146 -0
  124. package/dist/vue/components/TMarkdownText.d.ts +134 -0
  125. package/dist/vue/components/TMultilineModal.d.ts +62 -0
  126. package/dist/vue/components/TPathPicker.d.ts +213 -0
  127. package/dist/vue/components/TRenderLayer.d.ts +16 -0
  128. package/dist/vue/components/TRenderPlane.d.ts +17 -0
  129. package/dist/vue/components/TSelect.d.ts +215 -0
  130. package/dist/vue/components/TText.d.ts +116 -0
  131. package/dist/vue/components/TTransition.d.ts +83 -0
  132. package/dist/vue/components/TView.d.ts +127 -0
  133. package/dist/vue/components/TVirtualList.d.ts +182 -0
  134. package/dist/vue/components/TVirtualMarkdown.d.ts +168 -0
  135. package/dist/vue/components/TerminalProvider.d.ts +195 -0
  136. package/dist/vue/components/input/host.d.ts +17 -0
  137. package/dist/vue/components/input/plugins/hostPlugin.d.ts +7 -0
  138. package/dist/vue/components/input/plugins/hostPlugin.node.d.ts +15 -0
  139. package/dist/vue/components/input/plugins/mentionUtils.d.ts +17 -0
  140. package/dist/vue/components/input/plugins/nodeMentionPathProvider.d.ts +2 -0
  141. package/dist/vue/components/input/plugins/promptMentionPlugin.d.ts +8 -0
  142. package/dist/vue/components/input/plugins/promptMentionState.d.ts +98 -0
  143. package/dist/vue/components/input/plugins/restrictText.d.ts +27 -0
  144. package/dist/vue/components/input/plugins/types.d.ts +90 -0
  145. package/dist/vue/components/input/utils/inlineText.d.ts +57 -0
  146. package/dist/vue/components/input/utils/inlineTextTokens.d.ts +34 -0
  147. package/dist/vue/components/input/utils/primitives.d.ts +3 -0
  148. package/dist/vue/components/input/utils/wordNavigation.d.ts +6 -0
  149. package/dist/vue/components/list/list-geometry.d.ts +16 -0
  150. package/dist/vue/components/list/list-paint.d.ts +1 -0
  151. package/dist/vue/components/list/scroll-state.d.ts +25 -0
  152. package/dist/vue/components/list/selection-state.d.ts +6 -0
  153. package/dist/vue/components/terminal-provider/copy-toast.d.ts +6 -0
  154. package/dist/vue/components/terminal-provider/portals.d.ts +17 -0
  155. package/dist/vue/components/terminal-provider/scheduler.d.ts +29 -0
  156. package/dist/vue/components/terminal-provider/selection-config.d.ts +15 -0
  157. package/dist/vue/components/terminal-provider/utils.d.ts +5 -0
  158. package/dist/vue/composables/use-layout.d.ts +2 -0
  159. package/dist/vue/composables/use-render-node.d.ts +19 -0
  160. package/dist/vue/composables/use-render-stack.d.ts +3 -0
  161. package/dist/vue/composables/use-runtime.d.ts +5 -0
  162. package/dist/vue/composables/use-terminal-node.d.ts +14 -0
  163. package/dist/vue/composables/use-terminal.d.ts +2 -0
  164. package/dist/vue/composables/use-visibility.d.ts +12 -0
  165. package/dist/vue/context.d.ts +153 -0
  166. package/dist/vue/index.d.ts +39 -0
  167. package/dist/vue/injection-key.d.ts +2 -0
  168. package/dist/vue/log/append-only-log-store.d.ts +2 -0
  169. package/dist/vue/log/tlog-keymap.d.ts +28 -0
  170. package/dist/vue/log/tlog-plugins.d.ts +144 -0
  171. package/dist/vue/log/tlog-session.d.ts +81 -0
  172. package/dist/vue/log/tlog-theme.d.ts +68 -0
  173. package/dist/vue/log/types.d.ts +43 -0
  174. package/dist/vue/log/use-tlog-link-controller.d.ts +31 -0
  175. package/dist/vue/log/use-tlog-retained-index.d.ts +26 -0
  176. package/dist/vue/log/use-tlog-search-controller.d.ts +51 -0
  177. package/dist/vue/log/use-tlog-search-results-page.d.ts +31 -0
  178. package/dist/vue/log/use-tlog-virtual-search-results.d.ts +22 -0
  179. package/dist/vue/markdown/ast.d.ts +3 -0
  180. package/dist/vue/markdown/block-source.d.ts +22 -0
  181. package/dist/vue/markdown/document.d.ts +18 -0
  182. package/dist/vue/markdown/layout.d.ts +16 -0
  183. package/dist/vue/markdown/parser.d.ts +11 -0
  184. package/dist/vue/markdown/render.d.ts +10 -0
  185. package/dist/vue/markdown/theme.d.ts +186 -0
  186. package/dist/vue/markdown/types.d.ts +47 -0
  187. package/dist/vue/render/context.d.ts +3 -0
  188. package/dist/vue/render/render-manager.d.ts +94 -0
  189. package/dist/vue/router/RouterView.d.ts +25 -0
  190. package/dist/vue/router/composables.d.ts +4 -0
  191. package/dist/vue/router/context.d.ts +4 -0
  192. package/dist/vue/router/router.d.ts +7 -0
  193. package/dist/vue/router/types.d.ts +29 -0
  194. package/dist/vue/scheduler/frame-mailbox.d.ts +55 -0
  195. package/dist/vue/scheduler/frame-scheduler.d.ts +51 -0
  196. package/dist/vue/utils/frame-task.d.ts +6 -0
  197. package/dist/vue/utils/rect.d.ts +4 -0
  198. package/dist/vue/utils/style-cache.d.ts +3 -0
  199. package/dist/vue/utils/text.d.ts +26 -0
  200. package/dist/vue/utils/wheel-scroll.d.ts +18 -0
  201. package/dist/vue.cjs +18882 -0
  202. package/dist/vue.d.cts +3 -0
  203. package/dist/vue.d.ts +3 -0
  204. package/dist/vue.js +3066 -0
  205. package/dist/wheel-scroll-B-WlFuNB.js +819 -0
  206. package/package.json +226 -58
  207. package/dist/path-suggest-DIMby3r0.js +0 -3
@@ -1,19 +1,34 @@
1
- import process from "node:process";
1
+ //#region src/cli/node-module.ts
2
+ function isNodeRuntime() {
3
+ var _proc$versions;
4
+ const proc = globalThis.process;
5
+ return typeof (proc === null || proc === void 0 || (_proc$versions = proc.versions) === null || _proc$versions === void 0 ? void 0 : _proc$versions.node) === "string";
6
+ }
7
+ function importNodeModule(specifier) {
8
+ if (!isNodeRuntime()) return Promise.resolve(null);
9
+ try {
10
+ const dynamicImport = new Function("specifier", "return import(specifier)");
11
+ return dynamicImport(specifier).catch(() => null);
12
+ } catch {
13
+ return Promise.resolve(null);
14
+ }
15
+ }
2
16
 
17
+ //#endregion
3
18
  //#region src/utils/path.ts
4
19
  function normalizeSeparators(input) {
5
- return input.replace(/\\/g, "/");
20
+ let out = "";
21
+ for (let i = 0; i < input.length; i++) {
22
+ const ch = input[i];
23
+ out += ch === "\\" ? "/" : ch;
24
+ }
25
+ return out;
6
26
  }
7
27
  function isAbsolutePath(path) {
8
28
  const p = normalizeSeparators(path);
9
29
  if (p.startsWith("/")) return true;
10
30
  return /^[A-Z]:\//i.test(p);
11
31
  }
12
- function stripTrailingSlash(path) {
13
- const p = normalizeSeparators(path);
14
- if (p === "/") return p;
15
- return p.replace(/\/+$/g, "");
16
- }
17
32
  function joinPath(base, next) {
18
33
  const a = normalizeSeparators(base);
19
34
  const b = normalizeSeparators(next);
@@ -57,10 +72,61 @@ function resolvePath(baseAbs, input) {
57
72
  }
58
73
 
59
74
  //#endregion
60
- //#region src/cli/path-suggest-core.ts
75
+ //#region src/core/path-suggest.ts
61
76
  function lower(s) {
62
77
  return s.toLowerCase();
63
78
  }
79
+ function normalizePathInputSeparators(input) {
80
+ let out = "";
81
+ for (let i = 0; i < input.length; i++) {
82
+ const ch = input[i];
83
+ if (ch === "\r") continue;
84
+ out += ch === "\\" ? "/" : ch;
85
+ }
86
+ return out;
87
+ }
88
+ function stripCarriageReturns(input) {
89
+ let out = "";
90
+ for (let i = 0; i < input.length; i++) {
91
+ const ch = input[i];
92
+ if (ch !== "\r") out += ch;
93
+ }
94
+ return out;
95
+ }
96
+ function stripLeadingDotSlash(input) {
97
+ let i = 0;
98
+ while (i + 1 < input.length && input.charCodeAt(i) === 46 && input.charCodeAt(i + 1) === 47) i += 2;
99
+ return i === 0 ? input : input.slice(i);
100
+ }
101
+ function stripLeadingSlashes(input) {
102
+ let i = 0;
103
+ while (i < input.length && input.charCodeAt(i) === 47) i++;
104
+ return i === 0 ? input : input.slice(i);
105
+ }
106
+ function stripTrailingSlashes(input) {
107
+ let end = input.length;
108
+ while (end > 0 && input.charCodeAt(end - 1) === 47) end--;
109
+ return end === input.length ? input : input.slice(0, end);
110
+ }
111
+ function collapseSlashes(input) {
112
+ let out = "";
113
+ let previousWasSlash = false;
114
+ for (let i = 0; i < input.length; i++) {
115
+ const ch = input[i];
116
+ const isSlash = ch === "/";
117
+ if (isSlash) {
118
+ if (!previousWasSlash) out += "/";
119
+ previousWasSlash = true;
120
+ continue;
121
+ }
122
+ out += ch;
123
+ previousWasSlash = false;
124
+ }
125
+ return out;
126
+ }
127
+ function normalizeRelativePathForIgnore(input) {
128
+ return stripTrailingSlashes(collapseSlashes(stripLeadingSlashes(stripLeadingDotSlash(normalizePathInputSeparators(input)))));
129
+ }
64
130
  function fuzzyScore(name, query) {
65
131
  const n = lower(name);
66
132
  const q = lower(query);
@@ -87,7 +153,7 @@ function fuzzyScore(name, query) {
87
153
  return 800 - gaps;
88
154
  }
89
155
  function parsePathQuery(rawInput) {
90
- const input = rawInput.replace(/\\/g, "/");
156
+ const input = normalizePathInputSeparators(rawInput);
91
157
  const lastSlash = input.lastIndexOf("/");
92
158
  if (lastSlash < 0) return {
93
159
  dirPrefix: "",
@@ -111,7 +177,7 @@ async function suggestPaths$1(options) {
111
177
  };
112
178
  }
113
179
  const workspaceAbs = normalizePath(rawWorkspace);
114
- const input = rawInput.replace(/\r/g, "").replace(/\\/g, "/");
180
+ const input = normalizePathInputSeparators(rawInput);
115
181
  const parsed = parsePathQuery(input);
116
182
  let dirPrefix = parsed.dirPrefix;
117
183
  let query = parsed.query;
@@ -181,7 +247,7 @@ async function suggestPaths$1(options) {
181
247
  }
182
248
  if (!allowHidden && !query && e.name.startsWith(".")) continue;
183
249
  const itemRelPath = currentRelPath ? `${currentRelPath}/${e.name}` : e.name;
184
- const normalizedRelPath = String(`${dirPrefix}${itemRelPath}`).replace(/\r/g, "").replace(/\\/g, "/").replace(/^(?:\.\/)+/g, "").replace(/^\/+/g, "").replace(/\/+/g, "/").replace(/\/+$/g, "");
250
+ const normalizedRelPath = normalizeRelativePathForIgnore(`${dirPrefix}${itemRelPath}`);
185
251
  const isDir = e.kind === "directory";
186
252
  if ((_options$shouldIgnore = options.shouldIgnore) === null || _options$shouldIgnore === void 0 ? void 0 : _options$shouldIgnore.call(options, {
187
253
  normalizedRelPath,
@@ -227,7 +293,7 @@ async function suggestPaths$1(options) {
227
293
  ok = false;
228
294
  }
229
295
  if (!ok && dirPrefix) {
230
- const fallbackQuery = input.replace(/\/+$/g, "");
296
+ const fallbackQuery = stripTrailingSlashes(input);
231
297
  dirPrefix = "";
232
298
  query = fallbackQuery;
233
299
  baseDirAbs = workspaceAbs;
@@ -258,7 +324,7 @@ async function suggestPaths$1(options) {
258
324
  };
259
325
  }
260
326
  function resolveUserPath$1(workspaceAbs, input, options) {
261
- const raw = (input ?? "").replace(/\r/g, "").trim();
327
+ const raw = stripCarriageReturns(input ?? "").trim();
262
328
  if (!raw) return resolvePath(normalizePath(workspaceAbs), ".");
263
329
  if (raw === "~" || raw.startsWith("~/")) {
264
330
  const home = String((options === null || options === void 0 ? void 0 : options.homeDir) ?? "").trim();
@@ -267,7 +333,7 @@ function resolveUserPath$1(workspaceAbs, input, options) {
267
333
  return resolvePath(normalizePath(home), rest);
268
334
  }
269
335
  }
270
- const normalized = raw.replace(/\\/g, "/");
336
+ const normalized = normalizePathInputSeparators(raw);
271
337
  if (isAbsolutePath(normalized)) return normalizePath(normalized);
272
338
  return resolvePath(normalizePath(workspaceAbs), normalized);
273
339
  }
@@ -286,7 +352,7 @@ const gitignoreRulesCache = new Map();
286
352
  const gitignoreRulesLoading = new Map();
287
353
  function isNodeLike() {
288
354
  var _proc$versions;
289
- const proc = process;
355
+ const proc = globalThis.process;
290
356
  return typeof (proc === null || proc === void 0 || (_proc$versions = proc.versions) === null || _proc$versions === void 0 ? void 0 : _proc$versions.node) === "string";
291
357
  }
292
358
  function loadGitignoreRulesAsync(workspaceAbs) {
@@ -294,7 +360,8 @@ function loadGitignoreRulesAsync(workspaceAbs) {
294
360
  return (async () => {
295
361
  if (!isNodeLike()) return EMPTY_GITIGNORE_RULES;
296
362
  try {
297
- const fs = await import("node:fs/promises");
363
+ const fs = await importNodeModule("node:fs/promises");
364
+ if (!fs) return EMPTY_GITIGNORE_RULES;
298
365
  const gitignoreAbs = resolvePath(key, ".gitignore");
299
366
  const content = await fs.readFile(gitignoreAbs, "utf8");
300
367
  return compileGitignoreRules(content);
@@ -465,9 +532,10 @@ async function suggestPaths(options) {
465
532
  });
466
533
  }
467
534
  function resolveUserPath(workspaceAbs, input) {
468
- const env = (process === null || process === void 0 ? void 0 : process.env) ?? {};
535
+ var _process;
536
+ const env = ((_process = globalThis.process) === null || _process === void 0 ? void 0 : _process.env) ?? {};
469
537
  return resolveUserPath$1(workspaceAbs, input, { homeDir: String(env.HOME || env.USERPROFILE || "") });
470
538
  }
471
539
 
472
540
  //#endregion
473
- export { isAbsolutePath, normalizePath, parsePathQuery, resolvePath, resolveUserPath, resolveUserPath$1, stripTrailingSlash, suggestPaths, suggestPaths$1 };
541
+ export { importNodeModule, isAbsolutePath, normalizePath, parsePathQuery, resolvePath, resolveUserPath, suggestPaths };
@@ -0,0 +1,13 @@
1
+ export type RendererCapabilities = Readonly<{
2
+ syncFlush: boolean;
3
+ scrollOperations: boolean;
4
+ domRows: boolean;
5
+ }>;
6
+ export type TerminalRendererLike = Readonly<{
7
+ capabilities: RendererCapabilities;
8
+ container?: HTMLElement;
9
+ debugStats?: unknown;
10
+ }>;
11
+ export declare const DOM_RENDERER_CAPABILITIES: RendererCapabilities;
12
+ export declare const HEADLESS_RENDERER_CAPABILITIES: RendererCapabilities;
13
+ export declare const STDOUT_RENDERER_CAPABILITIES: RendererCapabilities;
@@ -0,0 +1,2 @@
1
+ export type { StdoutRenderer } from "./stdout-renderer.js";
2
+ export { createStdoutRenderer } from "./stdout-renderer.js";
@@ -0,0 +1,18 @@
1
+ export type StdoutRendererWriteMode = "stream" | "sync" | "chunked";
2
+ export interface StdoutRendererMetrics {
3
+ lastFrameAt: number;
4
+ lastFrameBytes: number;
5
+ lastWriteMs: number;
6
+ writeEmaMs: number;
7
+ writeMode: StdoutRendererWriteMode;
8
+ fps: number;
9
+ bytesPerSec: number;
10
+ }
11
+ export declare function getStdoutRendererMetrics(): StdoutRendererMetrics;
12
+ export declare function recordStdoutFrame(info: Readonly<{
13
+ at: number;
14
+ bytes: number;
15
+ writeMs: number;
16
+ writeEmaMs: number;
17
+ writeMode: StdoutRendererWriteMode;
18
+ }>): void;
@@ -0,0 +1,48 @@
1
+ import type { Terminal } from "../../core/types.js";
2
+ import type { RendererCapabilities } from "../capabilities.js";
3
+ import type { ThemePalette } from "../../core/ansi-palette.js";
4
+ export type CliOutput = Readonly<{
5
+ write: (chunk: string) => unknown;
6
+ isTTY?: boolean;
7
+ }>;
8
+ export type StdoutRenderer = Readonly<{
9
+ capabilities: RendererCapabilities;
10
+ render: () => void;
11
+ dispose: () => void;
12
+ /** Move terminal cursor to specified cell position for IME input */
13
+ setCursor: (x: number, y: number) => void;
14
+ /** Show or hide the terminal cursor */
15
+ showCursor: (visible: boolean) => void;
16
+ /** Update default background without recreating the renderer. */
17
+ updateTheme?: (next: Readonly<{
18
+ defaultBg?: string | null;
19
+ palette?: ThemePalette | null;
20
+ }>) => void;
21
+ }>;
22
+ export type StdoutColorMode = "auto" | "truecolor" | "ansi256" | "ansi16" | "ansi8";
23
+ export type { ThemePalette } from "../../core/ansi-palette.js";
24
+ export declare function createStdoutRenderer(terminal: Terminal, options?: Readonly<{
25
+ output?: CliOutput;
26
+ clear?: boolean;
27
+ hideCursor?: boolean;
28
+ altScreen?: boolean;
29
+ /** Fallback background color when a cell has no explicit bg. `null` = transparent (terminal default). */
30
+ defaultBg?: string | null;
31
+ /** Optional ANSI-name palette used when emitting ansi256/truecolor sequences. */
32
+ palette?: ThemePalette | null;
33
+ /** Track TTY resize events (process.stdout 'resize') and call terminal.resize(). */
34
+ trackResize?: boolean;
35
+ /** Color mode for ANSI output (auto detects truecolor via env). */
36
+ colorMode?: StdoutColorMode;
37
+ /** Optional function to get IME cursor position, included in render output for atomic write */
38
+ getImeAnchor?: () => {
39
+ cellX: number;
40
+ cellY: number;
41
+ } | null;
42
+ /** Use DEC 2026 synchronized output mode (default: false for compatibility) */
43
+ useSyncOutput?: boolean;
44
+ allowFileUrls?: boolean;
45
+ profileFileWriter?: {
46
+ appendFileSync?: (path: string, data: string) => void;
47
+ };
48
+ }>): StdoutRenderer;
@@ -0,0 +1,157 @@
1
+ import type { TerminalRenderPlane } from "../../core/render-plane.js";
2
+ import type { Terminal } from "../../core/types.js";
3
+ import type { RendererCapabilities } from "../capabilities.js";
4
+ import type { ThemePalette } from "../../core/ansi-palette.js";
5
+ export type CellMetrics = Readonly<{
6
+ cellWidth: number;
7
+ cellHeight: number;
8
+ }>;
9
+ export type DomRendererAccessibilityRole = "application" | "region" | "textbox";
10
+ export type DomRendererAccessibilityOptions = Readonly<{
11
+ role?: DomRendererAccessibilityRole;
12
+ label?: string;
13
+ labelledBy?: string;
14
+ describedBy?: string;
15
+ live?: "off" | "polite" | "assertive";
16
+ multiline?: boolean;
17
+ readonly?: boolean;
18
+ }>;
19
+ export type DomRendererSyncFlushDecision = Readonly<{
20
+ performed: boolean;
21
+ deferredReason?: "budget";
22
+ rows: number;
23
+ planes: number;
24
+ cells: number;
25
+ maxRows: number;
26
+ maxCells: number;
27
+ }>;
28
+ export type DomRendererSyncFlushStats = Readonly<{
29
+ requested: number;
30
+ performed: number;
31
+ deferred: number;
32
+ last: DomRendererSyncFlushDecision | null;
33
+ }>;
34
+ export type DomRendererFlushSample = Readonly<{
35
+ mode: "sync" | "deferred";
36
+ startedAt: number;
37
+ durationMs: number;
38
+ planeRows: number;
39
+ planes: number;
40
+ }>;
41
+ export type DomRendererFlushStats = Readonly<{
42
+ count: number;
43
+ last: DomRendererFlushSample | null;
44
+ }>;
45
+ export type DomRendererRowRenderStats = Readonly<{
46
+ rows: number;
47
+ cacheHits: number;
48
+ rowKeyPrepassChecks: number;
49
+ rowKeyPrepassHits: number;
50
+ rowKeyPrepassMisses: number;
51
+ transparentBlankRows: number;
52
+ plainTextRows: number;
53
+ singleStyledRows: number;
54
+ segmentReuseRows: number;
55
+ fragmentRows: number;
56
+ spansCreated: number;
57
+ spansReused: number;
58
+ textNodeUpdates: number;
59
+ replaceChildren: number;
60
+ }>;
61
+ export type DomRendererRowRenderDebugStats = Readonly<{
62
+ total: DomRendererRowRenderStats;
63
+ lastFlush: DomRendererRowRenderStats | null;
64
+ }>;
65
+ export type DomRendererRowKeyPrepassMode = boolean | "auto";
66
+ export type DomRendererLinkConfig = Readonly<{
67
+ allowRelative?: boolean;
68
+ externalTarget?: "_blank" | "_self";
69
+ /**
70
+ * Defaults to -1 so terminal links do not enter the browser tab order.
71
+ * Set to 0 when the host explicitly wants native anchor keyboard focus.
72
+ */
73
+ tabIndex?: number;
74
+ /** `none` disables native anchor rendering for Style.href segments. */
75
+ activation?: "native" | "event" | "none";
76
+ onActivate?: (href: string, event: MouseEvent) => boolean | void;
77
+ }>;
78
+ export type DomRendererLinkOptions = boolean | DomRendererLinkConfig;
79
+ export type DomRendererRowKeyPrepassDecision = "forced-enabled" | "forced-disabled" | "sampling" | "enabled" | "disabled";
80
+ export type DomRendererRowKeyPrepassDebugStats = Readonly<{
81
+ mode: DomRendererRowKeyPrepassMode;
82
+ decision: DomRendererRowKeyPrepassDecision;
83
+ sampleRows: number;
84
+ sampleHits: number;
85
+ sampleMisses: number;
86
+ sampleHitRatio: number | null;
87
+ lastSampleRows: number;
88
+ lastSampleHitRatio: number | null;
89
+ }>;
90
+ export type DomRendererDebugStats = Readonly<{
91
+ syncFlush: DomRendererSyncFlushStats;
92
+ flush: DomRendererFlushStats;
93
+ rowRender: DomRendererRowRenderDebugStats;
94
+ rowKeyPrepass: DomRendererRowKeyPrepassDebugStats;
95
+ }>;
96
+ export interface DomRenderer {
97
+ readonly container: HTMLElement;
98
+ readonly capabilities: RendererCapabilities;
99
+ readonly debugStats: DomRendererDebugStats;
100
+ readonly metrics: CellMetrics;
101
+ dispose: () => void;
102
+ refresh: () => void;
103
+ updateTheme: (next: Readonly<{
104
+ palette?: ThemePalette | null;
105
+ }>) => void;
106
+ updateOptions: (next: Readonly<{
107
+ links?: DomRendererLinkOptions;
108
+ onLinkClick?: DomRendererOptions["onLinkClick"];
109
+ }>) => void;
110
+ setPlaneOffset: (plane: TerminalRenderPlane, offsetPx: number) => void;
111
+ setPlaneViewport: (plane: TerminalRenderPlane, viewport: Readonly<{
112
+ topPx: number;
113
+ heightPx: number;
114
+ }> | null) => void;
115
+ }
116
+ export interface DomRendererOptions {
117
+ /**
118
+ * Init-only. Changing this after renderer creation requires recreating the renderer.
119
+ * Browser accessibility contract for the renderer container.
120
+ * Pass false when the host owns the accessible wrapper.
121
+ */
122
+ accessibility?: false | DomRendererAccessibilityOptions;
123
+ /**
124
+ * Init-only. Changing this after renderer creation requires recreating the renderer.
125
+ * Maximum dirty row count allowed for same-call DOM flush when commit({ sync: true }).
126
+ * Larger updates are rAF-batched to avoid blocking the main thread.
127
+ */
128
+ syncFlushMaxRows?: number;
129
+ /**
130
+ * Init-only. Changing this after renderer creation requires recreating the renderer.
131
+ * Maximum estimated cell work for sync DOM flush: dirtyRows * cols * activePlanes.
132
+ */
133
+ syncFlushCellBudget?: number;
134
+ /**
135
+ * Init-only because renderer capabilities are frozen at creation time.
136
+ * Enables DOM line-node shifting for terminal scrollOperations.
137
+ */
138
+ enableScrollOperations?: boolean;
139
+ /**
140
+ * Runtime-updatable.
141
+ * Controls DOM anchor rendering for Style.href segments.
142
+ */
143
+ links?: DomRendererLinkOptions;
144
+ /** Runtime-updatable. */
145
+ onLinkClick?: (event: MouseEvent, href: string) => boolean | void;
146
+ /** Runtime-updatable ANSI-name palette exposed as DOM CSS variables. */
147
+ palette?: ThemePalette | null;
148
+ /**
149
+ * Init-only. Changing this after renderer creation requires recreating the renderer.
150
+ * Controls a key-only early bailout before row segment allocation.
151
+ * The normal row cache remains enabled regardless of this option.
152
+ * Defaults to "auto": sample cached-row hit ratio and keep prepass enabled only
153
+ * when it pays for itself.
154
+ */
155
+ enableRowKeyPrepass?: DomRendererRowKeyPrepassMode;
156
+ }
157
+ export declare function createDomRenderer(terminal: Terminal, container: HTMLElement, options?: DomRendererOptions): DomRenderer;
@@ -0,0 +1,2 @@
1
+ export type { DomRenderer, DomRendererOptions } from "./dom-renderer.js";
2
+ export { createDomRenderer } from "./dom-renderer.js";
@@ -0,0 +1,2 @@
1
+ export type { RendererCapabilities, TerminalRendererLike } from "./capabilities.js";
2
+ export { DOM_RENDERER_CAPABILITIES, HEADLESS_RENDERER_CAPABILITIES, STDOUT_RENDERER_CAPABILITIES, } from "./capabilities.js";