@chengchenccc/tui 0.1.1-rc.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.
- package/dist/autocomplete.d.ts +56 -0
- package/dist/autocomplete.d.ts.map +1 -0
- package/dist/autocomplete.js +647 -0
- package/dist/components/box.d.ts +22 -0
- package/dist/components/box.d.ts.map +1 -0
- package/dist/components/box.js +103 -0
- package/dist/components/card.d.ts +33 -0
- package/dist/components/card.d.ts.map +1 -0
- package/dist/components/card.js +49 -0
- package/dist/components/editor.d.ts +257 -0
- package/dist/components/editor.d.ts.map +1 -0
- package/dist/components/editor.js +1980 -0
- package/dist/components/input.d.ts +37 -0
- package/dist/components/input.d.ts.map +1 -0
- package/dist/components/input.js +389 -0
- package/dist/components/loader.d.ts +33 -0
- package/dist/components/loader.d.ts.map +1 -0
- package/dist/components/loader.js +100 -0
- package/dist/components/markdown.d.ts +108 -0
- package/dist/components/markdown.d.ts.map +1 -0
- package/dist/components/markdown.js +847 -0
- package/dist/components/markdown.test.d.ts +2 -0
- package/dist/components/markdown.test.d.ts.map +1 -0
- package/dist/components/markdown.test.js +81 -0
- package/dist/components/output-block.d.ts +44 -0
- package/dist/components/output-block.d.ts.map +1 -0
- package/dist/components/output-block.js +131 -0
- package/dist/components/select-list.d.ts +50 -0
- package/dist/components/select-list.d.ts.map +1 -0
- package/dist/components/select-list.js +166 -0
- package/dist/components/spacer.d.ts +12 -0
- package/dist/components/spacer.d.ts.map +1 -0
- package/dist/components/spacer.js +22 -0
- package/dist/components/statusline.d.ts +30 -0
- package/dist/components/statusline.d.ts.map +1 -0
- package/dist/components/statusline.js +46 -0
- package/dist/components/text.d.ts +19 -0
- package/dist/components/text.d.ts.map +1 -0
- package/dist/components/text.js +90 -0
- package/dist/components/truncated-text.d.ts +13 -0
- package/dist/components/truncated-text.d.ts.map +1 -0
- package/dist/components/truncated-text.js +50 -0
- package/dist/editor-component.d.ts +39 -0
- package/dist/editor-component.d.ts.map +1 -0
- package/dist/editor-component.js +1 -0
- package/dist/fuzzy.d.ts +16 -0
- package/dist/fuzzy.d.ts.map +1 -0
- package/dist/fuzzy.js +109 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/keybindings.d.ts +193 -0
- package/dist/keybindings.d.ts.map +1 -0
- package/dist/keybindings.js +191 -0
- package/dist/keys.d.ts +184 -0
- package/dist/keys.d.ts.map +1 -0
- package/dist/keys.js +1191 -0
- package/dist/kill-ring.d.ts +28 -0
- package/dist/kill-ring.d.ts.map +1 -0
- package/dist/kill-ring.js +43 -0
- package/dist/mermaid.d.ts +23 -0
- package/dist/mermaid.d.ts.map +1 -0
- package/dist/mermaid.js +77 -0
- package/dist/mouse.d.ts +40 -0
- package/dist/mouse.d.ts.map +1 -0
- package/dist/mouse.js +39 -0
- package/dist/mouse.test.d.ts +2 -0
- package/dist/mouse.test.d.ts.map +1 -0
- package/dist/mouse.test.js +36 -0
- package/dist/native-modifiers.d.ts +3 -0
- package/dist/native-modifiers.d.ts.map +1 -0
- package/dist/native-modifiers.js +52 -0
- package/dist/stdin-buffer.d.ts +50 -0
- package/dist/stdin-buffer.d.ts.map +1 -0
- package/dist/stdin-buffer.js +360 -0
- package/dist/terminal-colors.d.ts +10 -0
- package/dist/terminal-colors.d.ts.map +1 -0
- package/dist/terminal-colors.js +58 -0
- package/dist/terminal-image.d.ts +90 -0
- package/dist/terminal-image.d.ts.map +1 -0
- package/dist/terminal-image.js +375 -0
- package/dist/terminal.d.ts +110 -0
- package/dist/terminal.d.ts.map +1 -0
- package/dist/terminal.js +432 -0
- package/dist/tui-scrollback.test.d.ts +2 -0
- package/dist/tui-scrollback.test.d.ts.map +1 -0
- package/dist/tui-scrollback.test.js +51 -0
- package/dist/tui.d.ts +330 -0
- package/dist/tui.d.ts.map +1 -0
- package/dist/tui.js +1568 -0
- package/dist/undo-stack.d.ts +17 -0
- package/dist/undo-stack.d.ts.map +1 -0
- package/dist/undo-stack.js +24 -0
- package/dist/utils.d.ts +85 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +1066 -0
- package/dist/vendor/mermaid-ascii/ascii/ansi.d.ts +42 -0
- package/dist/vendor/mermaid-ascii/ascii/ansi.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/ansi.js +361 -0
- package/dist/vendor/mermaid-ascii/ascii/canvas.d.ts +90 -0
- package/dist/vendor/mermaid-ascii/ascii/canvas.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/canvas.js +414 -0
- package/dist/vendor/mermaid-ascii/ascii/class-diagram.d.ts +8 -0
- package/dist/vendor/mermaid-ascii/ascii/class-diagram.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/class-diagram.js +623 -0
- package/dist/vendor/mermaid-ascii/ascii/converter.d.ts +13 -0
- package/dist/vendor/mermaid-ascii/ascii/converter.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/converter.js +233 -0
- package/dist/vendor/mermaid-ascii/ascii/draw.d.ts +67 -0
- package/dist/vendor/mermaid-ascii/ascii/draw.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/draw.js +1313 -0
- package/dist/vendor/mermaid-ascii/ascii/edge-bundling.d.ts +49 -0
- package/dist/vendor/mermaid-ascii/ascii/edge-bundling.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/edge-bundling.js +289 -0
- package/dist/vendor/mermaid-ascii/ascii/edge-routing.d.ts +44 -0
- package/dist/vendor/mermaid-ascii/ascii/edge-routing.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/edge-routing.js +302 -0
- package/dist/vendor/mermaid-ascii/ascii/er-diagram.d.ts +8 -0
- package/dist/vendor/mermaid-ascii/ascii/er-diagram.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/er-diagram.js +380 -0
- package/dist/vendor/mermaid-ascii/ascii/grid.d.ts +57 -0
- package/dist/vendor/mermaid-ascii/ascii/grid.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/grid.js +516 -0
- package/dist/vendor/mermaid-ascii/ascii/index.d.ts +66 -0
- package/dist/vendor/mermaid-ascii/ascii/index.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/index.js +133 -0
- package/dist/vendor/mermaid-ascii/ascii/multiline-utils.d.ts +28 -0
- package/dist/vendor/mermaid-ascii/ascii/multiline-utils.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/multiline-utils.js +60 -0
- package/dist/vendor/mermaid-ascii/ascii/pathfinder.d.ts +18 -0
- package/dist/vendor/mermaid-ascii/ascii/pathfinder.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/pathfinder.js +224 -0
- package/dist/vendor/mermaid-ascii/ascii/sequence.d.ts +8 -0
- package/dist/vendor/mermaid-ascii/ascii/sequence.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/sequence.js +416 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/circle.d.ts +12 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/circle.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/circle.js +22 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/corners.d.ts +35 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/corners.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/corners.js +91 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/diamond.d.ts +12 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/diamond.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/diamond.js +22 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/hexagon.d.ts +12 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/hexagon.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/hexagon.js +22 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/index.d.ts +27 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/index.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/index.js +66 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/rectangle.d.ts +32 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/rectangle.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/rectangle.js +149 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/rounded.d.ts +12 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/rounded.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/rounded.js +22 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/special.d.ts +60 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/special.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/special.js +253 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/stadium.d.ts +18 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/stadium.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/stadium.js +103 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/state.d.ts +31 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/state.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/state.js +167 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/types.d.ts +56 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/types.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/types.js +4 -0
- package/dist/vendor/mermaid-ascii/ascii/types.d.ts +207 -0
- package/dist/vendor/mermaid-ascii/ascii/types.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/types.js +39 -0
- package/dist/vendor/mermaid-ascii/ascii/validate.d.ts +52 -0
- package/dist/vendor/mermaid-ascii/ascii/validate.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/validate.js +97 -0
- package/dist/vendor/mermaid-ascii/ascii/xychart.d.ts +3 -0
- package/dist/vendor/mermaid-ascii/ascii/xychart.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/xychart.js +719 -0
- package/dist/vendor/mermaid-ascii/class/parser.d.ts +7 -0
- package/dist/vendor/mermaid-ascii/class/parser.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/class/parser.js +265 -0
- package/dist/vendor/mermaid-ascii/class/types.d.ts +103 -0
- package/dist/vendor/mermaid-ascii/class/types.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/class/types.js +7 -0
- package/dist/vendor/mermaid-ascii/er/parser.d.ts +7 -0
- package/dist/vendor/mermaid-ascii/er/parser.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/er/parser.js +162 -0
- package/dist/vendor/mermaid-ascii/er/types.d.ts +77 -0
- package/dist/vendor/mermaid-ascii/er/types.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/er/types.js +7 -0
- package/dist/vendor/mermaid-ascii/index.d.ts +2 -0
- package/dist/vendor/mermaid-ascii/index.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/index.js +13 -0
- package/dist/vendor/mermaid-ascii/multiline-utils.d.ts +10 -0
- package/dist/vendor/mermaid-ascii/multiline-utils.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/multiline-utils.js +29 -0
- package/dist/vendor/mermaid-ascii/parser.d.ts +8 -0
- package/dist/vendor/mermaid-ascii/parser.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/parser.js +558 -0
- package/dist/vendor/mermaid-ascii/sequence/parser.d.ts +7 -0
- package/dist/vendor/mermaid-ascii/sequence/parser.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/sequence/parser.js +182 -0
- package/dist/vendor/mermaid-ascii/sequence/types.d.ts +131 -0
- package/dist/vendor/mermaid-ascii/sequence/types.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/sequence/types.js +7 -0
- package/dist/vendor/mermaid-ascii/text-metrics.d.ts +24 -0
- package/dist/vendor/mermaid-ascii/text-metrics.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/text-metrics.js +69 -0
- package/dist/vendor/mermaid-ascii/types.d.ts +115 -0
- package/dist/vendor/mermaid-ascii/types.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/types.js +4 -0
- package/dist/vendor/mermaid-ascii/xychart/colors.d.ts +26 -0
- package/dist/vendor/mermaid-ascii/xychart/colors.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/xychart/colors.js +145 -0
- package/dist/vendor/mermaid-ascii/xychart/parser.d.ts +7 -0
- package/dist/vendor/mermaid-ascii/xychart/parser.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/xychart/parser.js +105 -0
- package/dist/vendor/mermaid-ascii/xychart/types.d.ts +146 -0
- package/dist/vendor/mermaid-ascii/xychart/types.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/xychart/types.js +8 -0
- package/dist/virtual-terminal.d.ts +80 -0
- package/dist/virtual-terminal.d.ts.map +1 -0
- package/dist/virtual-terminal.js +284 -0
- package/dist/word-navigation.d.ts +25 -0
- package/dist/word-navigation.d.ts.map +1 -0
- package/dist/word-navigation.js +97 -0
- package/package.json +38 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ring buffer for Emacs-style kill/yank operations.
|
|
3
|
+
*
|
|
4
|
+
* Tracks killed (deleted) text entries. Consecutive kills can accumulate
|
|
5
|
+
* into a single entry. Supports yank (paste most recent) and yank-pop
|
|
6
|
+
* (cycle through older entries).
|
|
7
|
+
*/
|
|
8
|
+
export declare class KillRing {
|
|
9
|
+
private ring;
|
|
10
|
+
/**
|
|
11
|
+
* Add text to the kill ring.
|
|
12
|
+
*
|
|
13
|
+
* @param text - The killed text to add
|
|
14
|
+
* @param opts - Push options
|
|
15
|
+
* @param opts.prepend - If accumulating, prepend (backward deletion) or append (forward deletion)
|
|
16
|
+
* @param opts.accumulate - Merge with the most recent entry instead of creating a new one
|
|
17
|
+
*/
|
|
18
|
+
push(text: string, opts: {
|
|
19
|
+
prepend: boolean;
|
|
20
|
+
accumulate?: boolean;
|
|
21
|
+
}): void;
|
|
22
|
+
/** Get most recent entry without modifying the ring. */
|
|
23
|
+
peek(): string | undefined;
|
|
24
|
+
/** Move last entry to front (for yank-pop cycling). */
|
|
25
|
+
rotate(): void;
|
|
26
|
+
get length(): number;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=kill-ring.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kill-ring.d.ts","sourceRoot":"","sources":["../src/kill-ring.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,qBAAa,QAAQ;IACnB,OAAO,CAAC,IAAI,CAAgB;IAE5B;;;;;;;OAOG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,UAAU,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI;IAW1E,wDAAwD;IACxD,IAAI,IAAI,MAAM,GAAG,SAAS;IAI1B,uDAAuD;IACvD,MAAM,IAAI,IAAI;IAOd,IAAI,MAAM,IAAI,MAAM,CAEnB;CACF"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ring buffer for Emacs-style kill/yank operations.
|
|
3
|
+
*
|
|
4
|
+
* Tracks killed (deleted) text entries. Consecutive kills can accumulate
|
|
5
|
+
* into a single entry. Supports yank (paste most recent) and yank-pop
|
|
6
|
+
* (cycle through older entries).
|
|
7
|
+
*/
|
|
8
|
+
export class KillRing {
|
|
9
|
+
ring = [];
|
|
10
|
+
/**
|
|
11
|
+
* Add text to the kill ring.
|
|
12
|
+
*
|
|
13
|
+
* @param text - The killed text to add
|
|
14
|
+
* @param opts - Push options
|
|
15
|
+
* @param opts.prepend - If accumulating, prepend (backward deletion) or append (forward deletion)
|
|
16
|
+
* @param opts.accumulate - Merge with the most recent entry instead of creating a new one
|
|
17
|
+
*/
|
|
18
|
+
push(text, opts) {
|
|
19
|
+
if (!text)
|
|
20
|
+
return;
|
|
21
|
+
if (opts.accumulate && this.ring.length > 0) {
|
|
22
|
+
const last = this.ring.pop();
|
|
23
|
+
this.ring.push(opts.prepend ? text + last : last + text);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
this.ring.push(text);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/** Get most recent entry without modifying the ring. */
|
|
30
|
+
peek() {
|
|
31
|
+
return this.ring.length > 0 ? this.ring[this.ring.length - 1] : undefined;
|
|
32
|
+
}
|
|
33
|
+
/** Move last entry to front (for yank-pop cycling). */
|
|
34
|
+
rotate() {
|
|
35
|
+
if (this.ring.length > 1) {
|
|
36
|
+
const last = this.ring.pop();
|
|
37
|
+
this.ring.unshift(last);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
get length() {
|
|
41
|
+
return this.ring.length;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mermaid ASCII rendering helper (omp mermaid-cache equivalent).
|
|
3
|
+
*
|
|
4
|
+
* The vendored `beautiful-mermaid` fork supports a `direction` override, so a
|
|
5
|
+
* wide diagram can be re-laid-out top-down (or left-right) to fit a terminal
|
|
6
|
+
* width. We memoize renders by source + options + direction and only choose a
|
|
7
|
+
* forced direction when the base layout overflows the requested maxWidth.
|
|
8
|
+
*/
|
|
9
|
+
import { type AsciiRenderOptions } from "./vendor/mermaid-ascii/index.ts";
|
|
10
|
+
export type { AsciiRenderOptions as MermaidAsciiRenderOptions };
|
|
11
|
+
export declare function renderMermaidAsciiSafe(source: string, options?: AsciiRenderOptions): string | null;
|
|
12
|
+
export interface MermaidResolveOptions extends AsciiRenderOptions {
|
|
13
|
+
/** Maximum display width (terminal columns) the diagram should occupy. */
|
|
14
|
+
maxWidth?: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Resolve mermaid ASCII for a fenced block.
|
|
18
|
+
* Returns null on failure, memoizing failures to avoid repeated work.
|
|
19
|
+
*/
|
|
20
|
+
export declare function resolveMermaidAscii(source: string, options?: MermaidResolveOptions): string | null;
|
|
21
|
+
/** Clear the mermaid cache (used on session reset). */
|
|
22
|
+
export declare function clearMermaidCache(): void;
|
|
23
|
+
//# sourceMappingURL=mermaid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mermaid.d.ts","sourceRoot":"","sources":["../src/mermaid.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,KAAK,kBAAkB,EAAsB,MAAM,iCAAiC,CAAC;AAE9F,YAAY,EAAE,kBAAkB,IAAI,yBAAyB,EAAE,CAAC;AA+BhE,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,kBAAkB,GAC3B,MAAM,GAAG,IAAI,CAMf;AAED,MAAM,WAAW,qBAAsB,SAAQ,kBAAkB;IAC/D,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,qBAAqB,GAC9B,MAAM,GAAG,IAAI,CA4Bf;AAED,uDAAuD;AACvD,wBAAgB,iBAAiB,IAAI,IAAI,CAExC"}
|
package/dist/mermaid.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mermaid ASCII rendering helper (omp mermaid-cache equivalent).
|
|
3
|
+
*
|
|
4
|
+
* The vendored `beautiful-mermaid` fork supports a `direction` override, so a
|
|
5
|
+
* wide diagram can be re-laid-out top-down (or left-right) to fit a terminal
|
|
6
|
+
* width. We memoize renders by source + options + direction and only choose a
|
|
7
|
+
* forced direction when the base layout overflows the requested maxWidth.
|
|
8
|
+
*/
|
|
9
|
+
import { renderMermaidASCII } from "./vendor/mermaid-ascii/index.js";
|
|
10
|
+
/** Memoized renders (and failures), keyed on source + options + direction. */
|
|
11
|
+
const cache = new Map();
|
|
12
|
+
/** Widest rendered row in display columns (Bun wcwidth-style). */
|
|
13
|
+
function asciiDisplayWidth(ascii) {
|
|
14
|
+
let max = 0;
|
|
15
|
+
for (const line of ascii.split("\n")) {
|
|
16
|
+
const width = Bun.stringWidth(line);
|
|
17
|
+
if (width > max)
|
|
18
|
+
max = width;
|
|
19
|
+
}
|
|
20
|
+
return max;
|
|
21
|
+
}
|
|
22
|
+
function renderVariant(source, baseOptions, baseKey, direction) {
|
|
23
|
+
const key = `${baseKey}\x00${direction ?? ""}\x00${source}`;
|
|
24
|
+
const cached = cache.get(key);
|
|
25
|
+
if (cached !== undefined)
|
|
26
|
+
return cached;
|
|
27
|
+
const options = direction ? { ...baseOptions, direction } : baseOptions;
|
|
28
|
+
const ascii = renderMermaidAsciiSafe(source, options);
|
|
29
|
+
cache.set(key, ascii);
|
|
30
|
+
return ascii;
|
|
31
|
+
}
|
|
32
|
+
export function renderMermaidAsciiSafe(source, options) {
|
|
33
|
+
try {
|
|
34
|
+
return renderMermaidASCII(source, options);
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Resolve mermaid ASCII for a fenced block.
|
|
42
|
+
* Returns null on failure, memoizing failures to avoid repeated work.
|
|
43
|
+
*/
|
|
44
|
+
export function resolveMermaidAscii(source, options) {
|
|
45
|
+
const normalized = source.replace(/\r\n?/g, "\n").trim();
|
|
46
|
+
if (!normalized)
|
|
47
|
+
return null;
|
|
48
|
+
const { maxWidth, ...rest } = options ?? {};
|
|
49
|
+
const baseOptions = { colorMode: "none", ...rest };
|
|
50
|
+
const baseKey = JSON.stringify(baseOptions);
|
|
51
|
+
const base = renderVariant(normalized, baseOptions, baseKey, null);
|
|
52
|
+
if (base === null)
|
|
53
|
+
return null;
|
|
54
|
+
if (maxWidth === undefined)
|
|
55
|
+
return base;
|
|
56
|
+
let best = base;
|
|
57
|
+
let bestWidth = asciiDisplayWidth(base);
|
|
58
|
+
if (bestWidth <= maxWidth)
|
|
59
|
+
return base;
|
|
60
|
+
// As-authored layout overflows. Render both forced orientations and keep the
|
|
61
|
+
// narrowest; clipping at the call site handles any residual overflow.
|
|
62
|
+
for (const direction of ["TD", "LR"]) {
|
|
63
|
+
const variant = renderVariant(normalized, baseOptions, baseKey, direction);
|
|
64
|
+
if (variant === null)
|
|
65
|
+
continue;
|
|
66
|
+
const variantWidth = asciiDisplayWidth(variant);
|
|
67
|
+
if (variantWidth < bestWidth) {
|
|
68
|
+
best = variant;
|
|
69
|
+
bestWidth = variantWidth;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return best;
|
|
73
|
+
}
|
|
74
|
+
/** Clear the mermaid cache (used on session reset). */
|
|
75
|
+
export function clearMermaidCache() {
|
|
76
|
+
cache.clear();
|
|
77
|
+
}
|
package/dist/mouse.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** SGR mouse report parsing (`\x1b[<button;col;rowM` / `…m`).
|
|
2
|
+
*
|
|
3
|
+
* Mouse tracking (modes 1000 + 1006) is enabled by the APPLICATION (oma
|
|
4
|
+
* enables it for the whole session so the wheel can scroll the transcript —
|
|
5
|
+
* our TUI keeps no native-scrollback copy of history). Consumers get 0-based
|
|
6
|
+
* col/row for direct indexing into rendered lines.
|
|
7
|
+
*
|
|
8
|
+
* ponytail: wheel-only consumer for now; click/hover routing (pi's
|
|
9
|
+
* SelectListMouseTarget helpers) can be ported when an overlay needs it.
|
|
10
|
+
*
|
|
11
|
+
* Ported from pi's packages/tui/src/mouse.ts. */
|
|
12
|
+
/** A decoded SGR mouse report. */
|
|
13
|
+
export interface SgrMouseEvent {
|
|
14
|
+
/** Raw button code (bit 32 = motion, bit 64 = wheel, low bits = button). */
|
|
15
|
+
button: number;
|
|
16
|
+
/** 0-based column of the event. */
|
|
17
|
+
col: number;
|
|
18
|
+
/** 0-based row of the event. */
|
|
19
|
+
row: number;
|
|
20
|
+
/** True for a release report (`m` suffix). */
|
|
21
|
+
release: boolean;
|
|
22
|
+
/** Wheel direction: -1 up, 1 down, null when not a wheel event. */
|
|
23
|
+
wheel: -1 | 1 | null;
|
|
24
|
+
/** True when the pointer moved (hover or drag) rather than clicked. */
|
|
25
|
+
motion: boolean;
|
|
26
|
+
/** True for a left-button press (not motion, not release, not wheel). */
|
|
27
|
+
leftClick: boolean;
|
|
28
|
+
}
|
|
29
|
+
/** Decode an SGR mouse report, or return null when `data` is not one.
|
|
30
|
+
* Callers on hot keypress paths should pre-check `data.startsWith("\x1b[<")`
|
|
31
|
+
* before paying for the regex. */
|
|
32
|
+
export declare function parseSgrMouse(data: string): SgrMouseEvent | null;
|
|
33
|
+
/** Handler invoked with a decoded SGR event; returning `false` reports unhandled. */
|
|
34
|
+
export type SgrMouseHandler = (event: SgrMouseEvent) => boolean | undefined;
|
|
35
|
+
/** Decode an SGR mouse report and forward it to `handler`. Returns `false`
|
|
36
|
+
* when `data` is not an SGR mouse report (or fails to parse), so callers can
|
|
37
|
+
* fall through to other input handling. Centralizes the repeated
|
|
38
|
+
* `data.startsWith("\x1b[<")` + `parseSgrMouse()` pattern. */
|
|
39
|
+
export declare function routeSgrMouseInput(data: string, handler: SgrMouseHandler): boolean;
|
|
40
|
+
//# sourceMappingURL=mouse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mouse.d.ts","sourceRoot":"","sources":["../src/mouse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;iDAUiD;AAEjD,kCAAkC;AAClC,MAAM,WAAW,aAAa;IAC5B,4EAA4E;IAC5E,MAAM,EAAE,MAAM,CAAC;IACf,mCAAmC;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,gCAAgC;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,8CAA8C;IAC9C,OAAO,EAAE,OAAO,CAAC;IACjB,mEAAmE;IACnE,KAAK,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;IACrB,uEAAuE;IACvE,MAAM,EAAE,OAAO,CAAC;IAChB,yEAAyE;IACzE,SAAS,EAAE,OAAO,CAAC;CACpB;AAED;;mCAEmC;AACnC,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAWhE;AAED,qFAAqF;AACrF,MAAM,MAAM,eAAe,GAAG,CAAC,KAAK,EAAE,aAAa,KAAK,OAAO,GAAG,SAAS,CAAC;AAE5E;;;+DAG+D;AAC/D,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAKlF"}
|
package/dist/mouse.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** SGR mouse report parsing (`\x1b[<button;col;rowM` / `…m`).
|
|
2
|
+
*
|
|
3
|
+
* Mouse tracking (modes 1000 + 1006) is enabled by the APPLICATION (oma
|
|
4
|
+
* enables it for the whole session so the wheel can scroll the transcript —
|
|
5
|
+
* our TUI keeps no native-scrollback copy of history). Consumers get 0-based
|
|
6
|
+
* col/row for direct indexing into rendered lines.
|
|
7
|
+
*
|
|
8
|
+
* ponytail: wheel-only consumer for now; click/hover routing (pi's
|
|
9
|
+
* SelectListMouseTarget helpers) can be ported when an overlay needs it.
|
|
10
|
+
*
|
|
11
|
+
* Ported from pi's packages/tui/src/mouse.ts. */
|
|
12
|
+
/** Decode an SGR mouse report, or return null when `data` is not one.
|
|
13
|
+
* Callers on hot keypress paths should pre-check `data.startsWith("\x1b[<")`
|
|
14
|
+
* before paying for the regex. */
|
|
15
|
+
export function parseSgrMouse(data) {
|
|
16
|
+
const match = /^\x1b\[<(\d+);(\d+);(\d+)([Mm])$/.exec(data);
|
|
17
|
+
if (!match)
|
|
18
|
+
return null;
|
|
19
|
+
const button = Number(match[1]);
|
|
20
|
+
const col = Number(match[2]) - 1;
|
|
21
|
+
const row = Number(match[3]) - 1;
|
|
22
|
+
const release = match[4] === "m";
|
|
23
|
+
const wheel = button & 64 ? (button & 1 ? 1 : -1) : null;
|
|
24
|
+
const motion = (button & 32) !== 0 && wheel === null;
|
|
25
|
+
const leftClick = !release && wheel === null && !motion && (button & 3) === 0;
|
|
26
|
+
return { button, col, row, release, wheel, motion, leftClick };
|
|
27
|
+
}
|
|
28
|
+
/** Decode an SGR mouse report and forward it to `handler`. Returns `false`
|
|
29
|
+
* when `data` is not an SGR mouse report (or fails to parse), so callers can
|
|
30
|
+
* fall through to other input handling. Centralizes the repeated
|
|
31
|
+
* `data.startsWith("\x1b[<")` + `parseSgrMouse()` pattern. */
|
|
32
|
+
export function routeSgrMouseInput(data, handler) {
|
|
33
|
+
if (!data.startsWith("\x1b[<"))
|
|
34
|
+
return false;
|
|
35
|
+
const event = parseSgrMouse(data);
|
|
36
|
+
if (!event)
|
|
37
|
+
return false;
|
|
38
|
+
return handler(event) !== false;
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mouse.test.d.ts","sourceRoot":"","sources":["../src/mouse.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { parseSgrMouse, routeSgrMouseInput } from "./mouse.js";
|
|
3
|
+
describe("parseSgrMouse", () => {
|
|
4
|
+
test("wheel up (button 64) and wheel down (button 65)", () => {
|
|
5
|
+
const up = parseSgrMouse("\x1b[<64;10;5M");
|
|
6
|
+
expect(up).toMatchObject({ button: 64, col: 9, row: 4, wheel: -1, release: false });
|
|
7
|
+
const down = parseSgrMouse("\x1b[<65;1;1M");
|
|
8
|
+
expect(down).toMatchObject({ button: 65, wheel: 1, col: 0, row: 0 });
|
|
9
|
+
});
|
|
10
|
+
test("left click press vs release vs motion", () => {
|
|
11
|
+
expect(parseSgrMouse("\x1b[<0;3;3M")).toMatchObject({ leftClick: true, motion: false });
|
|
12
|
+
expect(parseSgrMouse("\x1b[<0;3;3m")).toMatchObject({ release: true, leftClick: false });
|
|
13
|
+
expect(parseSgrMouse("\x1b[<32;3;3M")).toMatchObject({ motion: true, leftClick: false });
|
|
14
|
+
});
|
|
15
|
+
test("non-mouse input returns null", () => {
|
|
16
|
+
expect(parseSgrMouse("\x1b[A")).toBeNull();
|
|
17
|
+
expect(parseSgrMouse("\x1b[5~")).toBeNull();
|
|
18
|
+
expect(parseSgrMouse("x")).toBeNull();
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
describe("routeSgrMouseInput", () => {
|
|
22
|
+
test("routes wheel and reports consumed; falls through on other input", () => {
|
|
23
|
+
const wheels = [];
|
|
24
|
+
const consumed = routeSgrMouseInput("\x1b[<64;1;1M", (event) => {
|
|
25
|
+
if (event.wheel)
|
|
26
|
+
wheels.push(event.wheel);
|
|
27
|
+
return true;
|
|
28
|
+
});
|
|
29
|
+
expect(consumed).toBe(true);
|
|
30
|
+
// Not an SGR report: handler must not run.
|
|
31
|
+
expect(routeSgrMouseInput("\x1b[5~", () => {
|
|
32
|
+
wheels.push(99);
|
|
33
|
+
})).toBe(false);
|
|
34
|
+
expect(wheels).toEqual([-1]);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-modifiers.d.ts","sourceRoot":"","sources":["../src/native-modifiers.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;AAkDrE,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAQjE"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
const cjsRequire = createRequire(import.meta.url);
|
|
5
|
+
let nativeModifiersHelper;
|
|
6
|
+
function isNativeModifiersHelper(value) {
|
|
7
|
+
if (typeof value !== "object" || value === null)
|
|
8
|
+
return false;
|
|
9
|
+
const candidate = value.isModifierPressed;
|
|
10
|
+
return typeof candidate === "function";
|
|
11
|
+
}
|
|
12
|
+
function loadNativeModifiersHelper() {
|
|
13
|
+
if (nativeModifiersHelper !== undefined)
|
|
14
|
+
return nativeModifiersHelper ?? undefined;
|
|
15
|
+
nativeModifiersHelper = null;
|
|
16
|
+
if (process.platform !== "darwin")
|
|
17
|
+
return undefined;
|
|
18
|
+
const arch = process.arch;
|
|
19
|
+
if (arch !== "x64" && arch !== "arm64")
|
|
20
|
+
return undefined;
|
|
21
|
+
const moduleDir = path.dirname(fileURLToPath(import.meta.url));
|
|
22
|
+
const nativePath = path.join("native", "darwin", "prebuilds", `darwin-${arch}`, "darwin-modifiers.node");
|
|
23
|
+
const candidates = [
|
|
24
|
+
path.join(moduleDir, "..", nativePath),
|
|
25
|
+
path.join(moduleDir, nativePath),
|
|
26
|
+
path.join(path.dirname(process.execPath), nativePath),
|
|
27
|
+
];
|
|
28
|
+
for (const modulePath of candidates) {
|
|
29
|
+
try {
|
|
30
|
+
const helper = cjsRequire(modulePath);
|
|
31
|
+
if (isNativeModifiersHelper(helper)) {
|
|
32
|
+
nativeModifiersHelper = helper;
|
|
33
|
+
return helper;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
// Try the next possible packaging location.
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
export function isNativeModifierPressed(key) {
|
|
43
|
+
const helper = loadNativeModifiersHelper();
|
|
44
|
+
if (!helper)
|
|
45
|
+
return false;
|
|
46
|
+
try {
|
|
47
|
+
return helper.isModifierPressed(key) === true;
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StdinBuffer buffers input and emits complete sequences.
|
|
3
|
+
*
|
|
4
|
+
* This is necessary because stdin data events can arrive in partial chunks,
|
|
5
|
+
* especially for escape sequences like mouse events. Without buffering,
|
|
6
|
+
* partial sequences can be misinterpreted as regular keypresses.
|
|
7
|
+
*
|
|
8
|
+
* For example, the mouse SGR sequence `\x1b[<35;20;5m` might arrive as:
|
|
9
|
+
* - Event 1: `\x1b`
|
|
10
|
+
* - Event 2: `[<35`
|
|
11
|
+
* - Event 3: `;20;5m`
|
|
12
|
+
*
|
|
13
|
+
* The buffer accumulates these until a complete sequence is detected.
|
|
14
|
+
* Call the `process()` method to feed input data.
|
|
15
|
+
*
|
|
16
|
+
* Based on code from OpenTUI (https://github.com/anomalyco/opentui)
|
|
17
|
+
* MIT License - Copyright (c) 2025 opentui
|
|
18
|
+
*/
|
|
19
|
+
import { EventEmitter } from "events";
|
|
20
|
+
export type StdinBufferOptions = {
|
|
21
|
+
/**
|
|
22
|
+
* Maximum time to wait for sequence completion (default: 10ms)
|
|
23
|
+
* After this time, the buffer is flushed even if incomplete
|
|
24
|
+
*/
|
|
25
|
+
timeout?: number;
|
|
26
|
+
};
|
|
27
|
+
export type StdinBufferEventMap = {
|
|
28
|
+
data: [string];
|
|
29
|
+
paste: [string];
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Buffers stdin input and emits complete sequences via the 'data' event.
|
|
33
|
+
* Handles partial escape sequences that arrive across multiple chunks.
|
|
34
|
+
*/
|
|
35
|
+
export declare class StdinBuffer extends EventEmitter<StdinBufferEventMap> {
|
|
36
|
+
private buffer;
|
|
37
|
+
private timeout;
|
|
38
|
+
private readonly timeoutMs;
|
|
39
|
+
private pasteMode;
|
|
40
|
+
private pasteBuffer;
|
|
41
|
+
private pendingKittyPrintableCodepoint;
|
|
42
|
+
constructor(options?: StdinBufferOptions);
|
|
43
|
+
process(data: string | Buffer): void;
|
|
44
|
+
private emitDataSequence;
|
|
45
|
+
flush(): string[];
|
|
46
|
+
clear(): void;
|
|
47
|
+
getBuffer(): string;
|
|
48
|
+
destroy(): void;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=stdin-buffer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stdin-buffer.d.ts","sourceRoot":"","sources":["../src/stdin-buffer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAgPtC,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC;IACf,KAAK,EAAE,CAAC,MAAM,CAAC,CAAC;CACjB,CAAC;AAEF;;;GAGG;AACH,qBAAa,WAAY,SAAQ,YAAY,CAAC,mBAAmB,CAAC;IAChE,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,OAAO,CAA8C;IAC7D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,8BAA8B,CAAqB;gBAE/C,OAAO,GAAE,kBAAuB;IAKrC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAsG3C,OAAO,CAAC,gBAAgB;IAWxB,KAAK,IAAI,MAAM,EAAE;IAgBjB,KAAK,IAAI,IAAI;IAWb,SAAS,IAAI,MAAM;IAInB,OAAO,IAAI,IAAI;CAGhB"}
|