@brett_lamy/ui 5.15.0 → 5.15.1

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 (118) hide show
  1. package/dist/components/call-stack.d.ts +26 -0
  2. package/dist/components/call-stack.d.ts.map +1 -0
  3. package/dist/components/call-stack.js +236 -0
  4. package/dist/components/code-editor-window.d.ts +191 -0
  5. package/dist/components/code-editor-window.d.ts.map +1 -0
  6. package/dist/components/code-editor-window.js +1474 -0
  7. package/dist/components/code-editor.d.ts +213 -0
  8. package/dist/components/code-editor.d.ts.map +1 -0
  9. package/dist/components/code-editor.js +484 -0
  10. package/dist/components/file-upload.d.ts +1 -1
  11. package/dist/components/file-upload.d.ts.map +1 -1
  12. package/dist/components/file-upload.js +1 -1
  13. package/dist/components/filter-input.d.ts +1 -1
  14. package/dist/components/filter-input.d.ts.map +1 -1
  15. package/dist/components/filter-input.js +1 -1
  16. package/dist/components/filter.d.ts +1 -1
  17. package/dist/components/filter.d.ts.map +1 -1
  18. package/dist/components/filter.js +1 -1
  19. package/dist/components/log-list.d.ts +95 -0
  20. package/dist/components/log-list.d.ts.map +1 -0
  21. package/dist/components/log-list.js +549 -0
  22. package/dist/components/object-tree.d.ts +30 -0
  23. package/dist/components/object-tree.d.ts.map +1 -0
  24. package/dist/components/object-tree.js +415 -0
  25. package/dist/components/object-value.d.ts +13 -0
  26. package/dist/components/object-value.d.ts.map +1 -0
  27. package/dist/components/object-value.js +69 -0
  28. package/dist/components/request-table.d.ts +78 -0
  29. package/dist/components/request-table.d.ts.map +1 -0
  30. package/dist/components/request-table.js +697 -0
  31. package/dist/components/spreadsheet.d.ts +1 -1
  32. package/dist/components/spreadsheet.d.ts.map +1 -1
  33. package/dist/components/spreadsheet.js +1 -1
  34. package/dist/components/syntax-highlighting.d.ts +45 -77
  35. package/dist/components/syntax-highlighting.d.ts.map +1 -1
  36. package/dist/components/syntax-highlighting.js +36 -275
  37. package/dist/components/terminal.d.ts +62 -0
  38. package/dist/components/terminal.d.ts.map +1 -0
  39. package/dist/components/terminal.js +172 -0
  40. package/dist/components/trace-timeline.d.ts +97 -0
  41. package/dist/components/trace-timeline.d.ts.map +1 -0
  42. package/dist/components/trace-timeline.js +850 -0
  43. package/dist/components/tree.d.ts.map +1 -1
  44. package/dist/components/tree.js +99 -91
  45. package/dist/components/video-preview.d.ts +1 -1
  46. package/dist/components/video-preview.d.ts.map +1 -1
  47. package/dist/components/video-preview.js +1 -1
  48. package/dist/components/video-timeline.d.ts +1 -1
  49. package/dist/components/video-timeline.d.ts.map +1 -1
  50. package/dist/components/video-timeline.js +1 -1
  51. package/dist/components/workspace.d.ts.map +1 -1
  52. package/dist/components/workspace.js +1 -1
  53. package/dist/index.css +1 -1
  54. package/dist/index.d.ts +45 -11
  55. package/dist/index.d.ts.map +1 -1
  56. package/dist/index.js +119 -100
  57. package/dist/lib/call-stack-model.d.ts +75 -0
  58. package/dist/lib/call-stack-model.d.ts.map +1 -0
  59. package/dist/lib/call-stack-model.js +114 -0
  60. package/dist/lib/code-document.d.ts +229 -0
  61. package/dist/lib/code-document.d.ts.map +1 -0
  62. package/dist/lib/code-document.js +727 -0
  63. package/dist/lib/code-editor-gpu.d.ts +9 -0
  64. package/dist/lib/code-editor-gpu.d.ts.map +1 -0
  65. package/dist/lib/code-editor-gpu.js +23 -0
  66. package/dist/lib/code-editor-model.d.ts +371 -0
  67. package/dist/lib/code-editor-model.d.ts.map +1 -0
  68. package/dist/lib/code-editor-model.js +1105 -0
  69. package/dist/lib/{file-upload.d.ts → file-upload-model.d.ts} +1 -1
  70. package/dist/lib/file-upload-model.d.ts.map +1 -0
  71. package/dist/lib/{file-upload.js → file-upload-model.js} +1 -1
  72. package/dist/lib/{filter.d.ts → filter-model.d.ts} +1 -1
  73. package/dist/lib/filter-model.d.ts.map +1 -0
  74. package/dist/lib/{filter.js → filter-model.js} +1 -1
  75. package/dist/lib/filter-query.d.ts +1 -1
  76. package/dist/lib/filter-query.d.ts.map +1 -1
  77. package/dist/lib/filter-query.js +1 -1
  78. package/dist/lib/log-list-model.d.ts +132 -0
  79. package/dist/lib/log-list-model.d.ts.map +1 -0
  80. package/dist/lib/log-list-model.js +214 -0
  81. package/dist/lib/log-list-window.d.ts +121 -0
  82. package/dist/lib/log-list-window.d.ts.map +1 -0
  83. package/dist/lib/log-list-window.js +245 -0
  84. package/dist/lib/object-tree-model.d.ts +162 -0
  85. package/dist/lib/object-tree-model.d.ts.map +1 -0
  86. package/dist/lib/object-tree-model.js +347 -0
  87. package/dist/lib/object-tree-value.d.ts +139 -0
  88. package/dist/lib/object-tree-value.d.ts.map +1 -0
  89. package/dist/lib/object-tree-value.js +410 -0
  90. package/dist/lib/request-table-model.d.ts +85 -0
  91. package/dist/lib/request-table-model.d.ts.map +1 -0
  92. package/dist/lib/request-table-model.js +105 -0
  93. package/dist/lib/{spreadsheet.d.ts → spreadsheet-model.d.ts} +1 -1
  94. package/dist/lib/spreadsheet-model.d.ts.map +1 -0
  95. package/dist/lib/{spreadsheet.js → spreadsheet-model.js} +1 -1
  96. package/dist/lib/syntax.d.ts +19 -7
  97. package/dist/lib/syntax.d.ts.map +1 -1
  98. package/dist/lib/syntax.js +54 -50
  99. package/dist/lib/terminal-line.d.ts +155 -0
  100. package/dist/lib/terminal-line.d.ts.map +1 -0
  101. package/dist/lib/terminal-line.js +463 -0
  102. package/dist/lib/trace-timeline-draw.d.ts +109 -0
  103. package/dist/lib/trace-timeline-draw.d.ts.map +1 -0
  104. package/dist/lib/trace-timeline-draw.js +252 -0
  105. package/dist/lib/trace-timeline-model.d.ts +324 -0
  106. package/dist/lib/trace-timeline-model.d.ts.map +1 -0
  107. package/dist/lib/trace-timeline-model.js +510 -0
  108. package/dist/lib/video-render.d.ts +1 -1
  109. package/dist/lib/video-render.d.ts.map +1 -1
  110. package/dist/lib/video-render.js +1 -1
  111. package/dist/lib/{video-timeline.d.ts → video-timeline-model.d.ts} +1 -1
  112. package/dist/lib/video-timeline-model.d.ts.map +1 -0
  113. package/dist/lib/{video-timeline.js → video-timeline-model.js} +1 -1
  114. package/package.json +4 -1
  115. package/dist/lib/file-upload.d.ts.map +0 -1
  116. package/dist/lib/filter.d.ts.map +0 -1
  117. package/dist/lib/spreadsheet.d.ts.map +0 -1
  118. package/dist/lib/video-timeline.d.ts.map +0 -1
@@ -1,42 +1,46 @@
1
1
  import { navigatorGpu as e, probeWebGPU as t, webgpuProbeResult as n } from "./webgpu.js";
2
2
  //#region src/lib/syntax.ts
3
- var r = "unknown";
4
- function i(t = "auto") {
5
- return t === "fallback" || r === "unavailable" || n() === "none" || t === "auto" && n() === "software" ? !1 : !!e();
3
+ function r(e) {
4
+ let t = e.type && e.type !== "plain" ? `bl-tok bl-tok-${e.type}` : "";
5
+ return e.className ? t ? `${t} ${e.className}` : e.className : t;
6
6
  }
7
- var a = 256, o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
8
- function c(e, t) {
7
+ var i = "unknown";
8
+ function a(t = "auto") {
9
+ return t === "fallback" || i === "unavailable" || n() === "none" || t === "auto" && n() === "software" ? !1 : !!e();
10
+ }
11
+ var o = 256, s = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map();
12
+ function l(e, t) {
9
13
  let n = e.get(t);
10
14
  return n && (e.delete(t), e.set(t, n)), n;
11
15
  }
12
- function l(e, t, n) {
13
- e.set(t, n), e.size > a && e.delete(e.keys().next().value);
16
+ function u(e, t, n) {
17
+ e.set(t, n), e.size > o && e.delete(e.keys().next().value);
14
18
  }
15
- function u(e, t = "auto") {
16
- return t === "fallback" ? c(s, e) : c(o, e) ?? (i(t) ? void 0 : c(s, e));
19
+ function d(e, t = "auto") {
20
+ return t === "fallback" ? l(c, e) : l(s, e) ?? (a(t) ? void 0 : l(c, e));
17
21
  }
18
- var d = /* @__PURE__ */ new Set([
22
+ var f = /* @__PURE__ */ new Set([
19
23
  "keyword",
20
24
  "type",
21
25
  "function",
22
26
  "constant"
23
- ]), f = "=<>!+-*/%&|^~?:.", p = "()[]{};,", m = (e) => e === " " || e === " " || e === "\n" || e === "\r" || e === "\f" || e === "\v", h = (e) => !!e && !m(e) && !f.includes(e) && !p.includes(e);
24
- function g(e, t) {
27
+ ]), p = "=<>!+-*/%&|^~?:.", m = "()[]{};,", h = (e) => e === " " || e === " " || e === "\n" || e === "\r" || e === "\f" || e === "\v", g = (e) => !!e && !h(e) && !p.includes(e) && !m.includes(e);
28
+ function _(e, t) {
25
29
  let n = e[t];
26
- if (m(n)) return "space";
27
- if (p.includes(n)) return "punct";
28
- if (!f.includes(n)) return "word";
30
+ if (h(n)) return "space";
31
+ if (m.includes(n)) return "punct";
32
+ if (!p.includes(n)) return "word";
29
33
  if (n === "-") {
30
- if (h(e[t - 1]) && h(e[t + 1])) return "word";
34
+ if (g(e[t - 1]) && g(e[t + 1])) return "word";
31
35
  let n = t;
32
36
  for (; e[n - 1] === "-";) n--;
33
37
  let r = t;
34
38
  for (; e[r] === "-";) r++;
35
- if (n === 0 && h(e[r])) return "word";
39
+ if (n === 0 && g(e[r])) return "word";
36
40
  }
37
41
  return "op";
38
42
  }
39
- function _(e, t) {
43
+ function v(e, t) {
40
44
  let n = [], r = 0, i = (e, t, i) => {
41
45
  if (t = Math.max(t, r), i <= t || (r = i, e === "plain")) return;
42
46
  let a = n[n.length - 1];
@@ -47,27 +51,27 @@ function _(e, t) {
47
51
  });
48
52
  }, a = t.every((e, n) => n === 0 || t[n - 1].start <= e.start) ? t : [...t].sort((e, t) => e.start - t.start);
49
53
  for (let t of a) {
50
- if (!d.has(t.type)) {
54
+ if (!f.has(t.type)) {
51
55
  i(t.type, t.start, t.end);
52
56
  continue;
53
57
  }
54
58
  let n = e.slice(t.start, t.end), r = 0;
55
59
  for (; r < n.length;) {
56
- let e = g(n, r), a = r + 1;
57
- for (; a < n.length && g(n, a) === e;) a++;
60
+ let e = _(n, r), a = r + 1;
61
+ for (; a < n.length && _(n, a) === e;) a++;
58
62
  let o = n.slice(r, a), s = /^(<\/?|\/?>)$/.test(o) && /[A-Za-z]/.test(n);
59
63
  i(e === "word" ? t.type : e === "op" && o !== "." && o !== ":" && !s ? "operator" : "plain", t.start + r, t.start + a), r = a;
60
64
  }
61
65
  }
62
66
  return n;
63
67
  }
64
- var v = null, y = () => v ??= import("gpu-lexer").then((e) => e.parse), b = Promise.resolve(), x = /* @__PURE__ */ new Map(), S = 65536;
65
- async function C(e) {
66
- let t = await y();
67
- if (e.length <= S) return _(e, await t(e));
68
+ var y = null, b = () => y ??= import("gpu-lexer").then((e) => e.parse), x = Promise.resolve(), S = /* @__PURE__ */ new Map(), C = 65536;
69
+ async function w(e) {
70
+ let t = await b();
71
+ if (e.length <= C) return v(e, await t(e));
68
72
  let n = [], r = 0;
69
73
  for (; r < e.length;) {
70
- let i = Math.min(e.length, r + S);
74
+ let i = Math.min(e.length, r + C);
71
75
  if (i < e.length) {
72
76
  let t = e.lastIndexOf("\n", i);
73
77
  t > r && (i = t + 1);
@@ -79,45 +83,45 @@ async function C(e) {
79
83
  });
80
84
  r = i;
81
85
  }
82
- return _(e, n);
86
+ return v(e, n);
83
87
  }
84
- function w(e) {
85
- return b = b.then(() => C(e).then((e) => (r = "ready", {
88
+ function T(e) {
89
+ return x = x.then(() => w(e).then((e) => (i = "ready", {
86
90
  spans: e,
87
91
  highlighter: "gpu"
88
- }), (t) => (r !== "ready" && /unavailable/i.test(String(t)) && (r = "unavailable"), E(e))));
92
+ }), (t) => (i !== "ready" && /unavailable/i.test(String(t)) && (i = "unavailable"), D(e))));
89
93
  }
90
- function T(e, n = "auto") {
91
- let r = u(e, n);
94
+ function E(e, n = "auto") {
95
+ let r = d(e, n);
92
96
  if (r) return Promise.resolve(r);
93
- if (!i(n)) return Promise.resolve(E(e));
94
- let a = n + "\0" + e, s = x.get(a);
95
- if (s) return s;
96
- let c = t().then(() => i(n) ? w(e) : E(e)).then((t) => (x.delete(a), t.highlighter === "gpu" && l(o, e, t), t));
97
- return x.set(a, c), c;
97
+ if (!a(n)) return Promise.resolve(D(e));
98
+ let i = n + "\0" + e, o = S.get(i);
99
+ if (o) return o;
100
+ let c = t().then(() => a(n) ? T(e) : D(e)).then((t) => (S.delete(i), t.highlighter === "gpu" && u(s, e, t), t));
101
+ return S.set(i, c), c;
98
102
  }
99
- function E(e) {
100
- let t = c(s, e);
103
+ function D(e) {
104
+ let t = l(c, e);
101
105
  if (t) return t;
102
106
  let n = {
103
- spans: _(e, A(e)),
107
+ spans: v(e, j(e)),
104
108
  highlighter: "fallback"
105
109
  };
106
- return l(s, e, n), n;
110
+ return u(c, e, n), n;
107
111
  }
108
- var D = new Set("as async await break case catch class const continue def default delete do elif else enum export extends fn for from func function go if impl implements import in instanceof interface let match mod module mut new package pass private protected pub public raise readonly return static struct super switch then this throw trait try type typeof use var void where while with yield fi done esac local echo".split(" ")), O = new Set("true false null undefined nil None True False NaN Infinity self".split(" ")), k = /(\/\/[^\n]*|#(?=[ \t!]|$)[^\n]*|\/\*[\s\S]*?(?:\*\/|$)|<!--[\s\S]*?(?:-->|$))|("(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?|`(?:[^`\\]|\\.)*`?)|(\b(?:0[xob][\da-f_]+|\d[\d_]*(?:\.\d+)?(?:e[+-]?\d+)?)\b)|([A-Za-z_$][\w$]*)|(\?\.(?!\d)|\.{2,3}|::|[=<>!+\-*/%&|^~?:]*[=<>!+\-*/%&|^~?][=<>!+\-*/%&|^~?:]*)/gi;
109
- function A(e) {
112
+ var O = new Set("as async await break case catch class const continue def default delete do elif else enum export extends fn for from func function go if impl implements import in instanceof interface let match mod module mut new package pass private protected pub public raise readonly return static struct super switch then this throw trait try type typeof use var void where while with yield fi done esac local echo".split(" ")), k = new Set("true false null undefined nil None True False NaN Infinity self".split(" ")), A = /(\/\/[^\n]*|#(?=[ \t!]|$)[^\n]*|\/\*[\s\S]*?(?:\*\/|$)|<!--[\s\S]*?(?:-->|$))|("(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?|`(?:[^`\\]|\\.)*`?)|(\b(?:0[xob][\da-f_]+|\d[\d_]*(?:\.\d+)?(?:e[+-]?\d+)?)\b)|([A-Za-z_$][\w$]*)|(\?\.(?!\d)|\.{2,3}|::|[=<>!+\-*/%&|^~?:]*[=<>!+\-*/%&|^~?][=<>!+\-*/%&|^~?:]*)/gi;
113
+ function j(e) {
110
114
  let t = [];
111
- k.lastIndex = 0;
115
+ A.lastIndex = 0;
112
116
  let n;
113
- for (; n = k.exec(e);) {
117
+ for (; n = A.exec(e);) {
114
118
  let r = n.index, i = r + n[0].length, a = "plain";
115
119
  if (n[1]) a = "comment";
116
120
  else if (n[2]) a = "string";
117
121
  else if (n[3]) a = "number";
118
122
  else if (n[4]) {
119
123
  let t = n[4];
120
- a = D.has(t) ? "keyword" : O.has(t) ? "constant" : /^\s*\(/.test(e.slice(i, i + 8)) ? "function" : /^[A-Z][a-z]/.test(t) ? "type" : "plain";
124
+ a = O.has(t) ? "keyword" : k.has(t) ? "constant" : /^\s*\(/.test(e.slice(i, i + 8)) ? "function" : /^[A-Z][a-z]/.test(t) ? "type" : "plain";
121
125
  } else n[5] && (a = "operator");
122
126
  a !== "plain" && t.push({
123
127
  type: a,
@@ -127,7 +131,7 @@ function A(e) {
127
131
  }
128
132
  return t;
129
133
  }
130
- function j(e, t) {
134
+ function M(e, t) {
131
135
  let n = e.endsWith("\n") ? e.slice(0, -1) : e, r = [[]], i = (e, t) => {
132
136
  let n = 0;
133
137
  for (let i = t.indexOf("\n"); i !== -1; i = t.indexOf("\n", n)) i > n && r[r.length - 1].push({
@@ -147,7 +151,7 @@ function j(e, t) {
147
151
  }
148
152
  return a < n.length && i("plain", n.slice(a)), r;
149
153
  }
150
- function M(e) {
154
+ function N(e) {
151
155
  let t = (e.split("/").pop() ?? e).toLowerCase();
152
156
  if (t === "dockerfile") return "dockerfile";
153
157
  if (t === "makefile") return "makefile";
@@ -171,7 +175,7 @@ function M(e) {
171
175
  patch: "diff"
172
176
  }[n] ?? (n || "text");
173
177
  }
174
- var N = /* @__PURE__ */ new Set([
178
+ var P = /* @__PURE__ */ new Set([
175
179
  "text",
176
180
  "txt",
177
181
  "plaintext",
@@ -179,4 +183,4 @@ var N = /* @__PURE__ */ new Set([
179
183
  "none"
180
184
  ]);
181
185
  //#endregion
182
- export { N as PLAIN_LANGUAGES, E as fallbackResult, A as fallbackSpans, M as languageFromPath, T as lexSyntax, _ as normalizeSpans, u as peekSyntax, t as probeWebGPU, j as tokenizeLines, i as webgpuSupported };
186
+ export { P as PLAIN_LANGUAGES, r as codeTokenClass, D as fallbackResult, j as fallbackSpans, N as languageFromPath, E as lexSyntax, v as normalizeSpans, d as peekSyntax, t as probeWebGPU, M as tokenizeLines, a as webgpuSupported };
@@ -0,0 +1,155 @@
1
+ export interface LineState {
2
+ /** The line being edited. */
3
+ readonly line: string;
4
+ /** The cursor, in UTF-16 units into `line`, always on a grapheme boundary. */
5
+ readonly cursor: number;
6
+ /** Submitted lines, oldest first. */
7
+ readonly history: readonly string[];
8
+ /** The history entry being shown, or null when editing a new line. */
9
+ readonly browsing: number | null;
10
+ /** The unfinished line, set aside while browsing history. */
11
+ readonly draft: string;
12
+ /** What Ctrl-U, Ctrl-K and Ctrl-W last removed; Ctrl-Y puts it back. */
13
+ readonly killed: string;
14
+ }
15
+ export declare const MAX_HISTORY = 1000;
16
+ export declare function createLineState(history?: readonly string[]): LineState;
17
+ export declare const stripAnsi: (text: string) => string;
18
+ /** How many terminal cells a grapheme takes: 0 (combining), 1 or 2 (CJK, emoji). */
19
+ export declare function cellWidth(grapheme: string): number;
20
+ /** How many terminal cells a string takes on one row, ignoring escape sequences. */
21
+ export declare function textWidth(text: string): number;
22
+ export interface CellPosition {
23
+ row: number;
24
+ /** May equal the width: the terminal is holding the cursor on the last cell until the next character wraps it. */
25
+ col: number;
26
+ }
27
+ /** Where the cursor ends up after writing `text` from `from` in a terminal `cols` wide. */
28
+ export declare function advance(from: CellPosition, text: string, cols: number): CellPosition;
29
+ /** Splits terminal input into keys: one escape sequence, one control character or one run of text each. */
30
+ export declare function readKeys(data: string): string[];
31
+ export type LineEvent =
32
+ /** Enter: the line was accepted (and recorded in history). */
33
+ {
34
+ type: 'submit';
35
+ line: string;
36
+ }
37
+ /** Ctrl-C at the prompt, with the line it threw away. */
38
+ | {
39
+ type: 'interrupt';
40
+ line: string;
41
+ }
42
+ /** Ctrl-D on an empty line. */
43
+ | {
44
+ type: 'eof';
45
+ }
46
+ /** Ctrl-L. */
47
+ | {
48
+ type: 'clear';
49
+ }
50
+ /** Tab. */
51
+ | {
52
+ type: 'complete';
53
+ };
54
+ export interface LineStep {
55
+ state: LineState;
56
+ event?: LineEvent;
57
+ }
58
+ /** One key: the next state, and what happened if the line is done with. Keys it doesn't know change nothing. */
59
+ export declare function applyKey(state: LineState, key: string): LineStep;
60
+ export interface RenderedLine {
61
+ /** Escape sequences that replace what's on screen with the prompt and line, leaving the cursor in place. */
62
+ output: string;
63
+ /** The row the cursor ends on, counted from the prompt's first row. Pass it back as `fromRow` next time. */
64
+ row: number;
65
+ }
66
+ /** The sequences that clear a drawn prompt and line, leaving the cursor where its first row starts. */
67
+ export declare const eraseLine: (fromRow: number) => string;
68
+ /** Redraws the whole prompt and line. Redrawing, rather than patching, is what keeps a line that wraps right: cursor
69
+ * movement doesn't cross rows on its own, and a narrow window wraps most lines. */
70
+ export declare function renderLine(prompt: string, line: string, cursor: number, cols: number, fromRow?: number): RenderedLine;
71
+ /** The whitespace-separated word the cursor is at the end of. */
72
+ export declare function wordAtCursor(line: string, cursor: number): {
73
+ from: number;
74
+ word: string;
75
+ };
76
+ export interface CompletionStep {
77
+ state: LineState;
78
+ /** There was nothing to add and several candidates: show these. */
79
+ list?: readonly string[];
80
+ }
81
+ /** Applies candidates for the word at the cursor: the only match in full (with a space, unless it's a folder), else as
82
+ * much as they share, else the list of them. */
83
+ export declare function applyCompletion(state: LineState, candidates: readonly string[]): CompletionStep;
84
+ /** Lays items out in columns that fit `cols`, down then across, the way `ls` does. */
85
+ export declare function formatColumns(items: readonly string[], cols: number): string;
86
+ /** A PTY turns a program's `\n` into `\r\n`; with no PTY, something has to. */
87
+ export declare const toTerminalNewlines: (text: string) => string;
88
+ /** Drops the oldest output to stay within `max` characters, from a line start where there is one. */
89
+ export declare function trimTranscript(text: string, max: number): string;
90
+ /** What a command gets. */
91
+ export interface TerminalCommandIO {
92
+ /** Prints to the terminal; `\n` becomes a line break. */
93
+ write: (data: string) => void;
94
+ /** Aborted by Ctrl-C. */
95
+ signal: AbortSignal;
96
+ /** Keys typed while the command runs, other than Ctrl-C. Returns a function that stops listening. Keys nobody is
97
+ * listening for wait, as they do in a terminal's buffer: for a listener, or else for the next prompt. */
98
+ onInput: (listener: (data: string) => void) => () => void;
99
+ /** Clears the screen and the scrollback. */
100
+ clear: () => void;
101
+ cols: number;
102
+ rows: number;
103
+ }
104
+ export type TerminalCommandHandler = (line: string, io: TerminalCommandIO) => void | number | Promise<void | number>;
105
+ /** Candidates for the word at the cursor, each a whole replacement for it. A folder ends in `/`. */
106
+ export type TerminalCompleter = (context: {
107
+ word: string;
108
+ line: string;
109
+ cursor: number;
110
+ }) => readonly string[] | Promise<readonly string[]>;
111
+ export interface TerminalShellOptions {
112
+ /** The prompt, redrawn each time it shows. One row, and it may carry colors. Default `$ `. */
113
+ prompt?: string | (() => string);
114
+ onCommand: TerminalCommandHandler;
115
+ complete?: TerminalCompleter;
116
+ /** Ctrl-D on an empty line. */
117
+ onEof?: () => void;
118
+ /** Lines the up arrow starts with, oldest first. */
119
+ history?: readonly string[];
120
+ /** Printed once, before the first prompt. */
121
+ greeting?: string;
122
+ /** How much output to keep for a terminal that attaches later, in characters. Default 1,000,000. */
123
+ maxTranscript?: number;
124
+ }
125
+ export interface TerminalSink {
126
+ write: (data: string) => void;
127
+ }
128
+ export interface TerminalShell {
129
+ /** Starts drawing on a terminal: the output so far, then the prompt. Returns a function that detaches it. */
130
+ attach: (sink: TerminalSink, size?: {
131
+ cols: number;
132
+ rows: number;
133
+ }) => () => void;
134
+ /** What the terminal's user typed. */
135
+ input: (data: string) => void;
136
+ /** Runs a line as if it had been typed, after whatever is running now. */
137
+ run: (line: string) => void;
138
+ /** Prints above the prompt, without disturbing the line being edited. */
139
+ write: (data: string) => void;
140
+ /** Redraws the prompt, after whatever it shows has changed. */
141
+ refreshPrompt: () => void;
142
+ resize: (cols: number, rows: number) => void;
143
+ clear: () => void;
144
+ /** Aborts what is running and stops drawing. */
145
+ dispose: () => void;
146
+ readonly busy: boolean;
147
+ /** The line being edited. */
148
+ readonly line: string;
149
+ readonly history: readonly string[];
150
+ /** Called when `busy` changes. Returns a function that stops listening. */
151
+ subscribe: (listener: () => void) => () => void;
152
+ }
153
+ /** A prompt, a line editor and one running command at a time. See the top of this file. */
154
+ export declare function createTerminalShell(options: TerminalShellOptions): TerminalShell;
155
+ //# sourceMappingURL=terminal-line.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"terminal-line.d.ts","sourceRoot":"","sources":["../../src/lib/terminal-line.ts"],"names":[],"mappings":"AAiBA,MAAM,WAAW,SAAS;IACxB,6BAA6B;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,8EAA8E;IAC9E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,qCAAqC;IACrC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,sEAAsE;IACtE,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,6DAA6D;IAC7D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,wEAAwE;IACxE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,eAAO,MAAM,WAAW,OAAO,CAAC;AAEhC,wBAAgB,eAAe,CAAC,OAAO,GAAE,SAAS,MAAM,EAAO,GAAG,SAAS,CAE1E;AA4BD,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,WAA2B,CAAC;AAOlE,oF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