@tuicomponents/graph 0.1.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/index.cjs +505 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +319 -0
- package/dist/index.d.ts +319 -0
- package/dist/index.js +478 -0
- package/dist/index.js.map +1 -0
- package/package.json +51 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import * as zod from 'zod';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { BaseTuiComponent, ComponentMetadata, RenderContext, RenderResult, TuiTheme } from '@tuicomponents/core';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Style options for graph line characters.
|
|
7
|
+
*/
|
|
8
|
+
declare const graphStyleSchema: z.ZodEnum<["ascii", "unicode"]>;
|
|
9
|
+
type GraphStyle = z.infer<typeof graphStyleSchema>;
|
|
10
|
+
/**
|
|
11
|
+
* Schema for a single node in the graph.
|
|
12
|
+
*/
|
|
13
|
+
declare const graphNodeSchema: z.ZodObject<{
|
|
14
|
+
/**
|
|
15
|
+
* Unique identifier for this node.
|
|
16
|
+
*/
|
|
17
|
+
id: z.ZodString;
|
|
18
|
+
/**
|
|
19
|
+
* Display label for the node (e.g., commit message).
|
|
20
|
+
*/
|
|
21
|
+
label: z.ZodString;
|
|
22
|
+
/**
|
|
23
|
+
* IDs of parent nodes (empty for root nodes).
|
|
24
|
+
*/
|
|
25
|
+
parents: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
26
|
+
/**
|
|
27
|
+
* Optional ref names (branch/tag names) to display.
|
|
28
|
+
*/
|
|
29
|
+
refs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
30
|
+
/**
|
|
31
|
+
* Whether this node should be highlighted.
|
|
32
|
+
*/
|
|
33
|
+
highlight: z.ZodOptional<z.ZodBoolean>;
|
|
34
|
+
/**
|
|
35
|
+
* Custom character to represent this node (overrides global nodeChar).
|
|
36
|
+
*/
|
|
37
|
+
nodeChar: z.ZodOptional<z.ZodString>;
|
|
38
|
+
}, "strip", z.ZodTypeAny, {
|
|
39
|
+
id: string;
|
|
40
|
+
label: string;
|
|
41
|
+
parents: string[];
|
|
42
|
+
refs?: string[] | undefined;
|
|
43
|
+
highlight?: boolean | undefined;
|
|
44
|
+
nodeChar?: string | undefined;
|
|
45
|
+
}, {
|
|
46
|
+
id: string;
|
|
47
|
+
label: string;
|
|
48
|
+
parents?: string[] | undefined;
|
|
49
|
+
refs?: string[] | undefined;
|
|
50
|
+
highlight?: boolean | undefined;
|
|
51
|
+
nodeChar?: string | undefined;
|
|
52
|
+
}>;
|
|
53
|
+
type GraphNode = z.infer<typeof graphNodeSchema>;
|
|
54
|
+
/**
|
|
55
|
+
* Schema for graph component input.
|
|
56
|
+
*/
|
|
57
|
+
declare const graphInputSchema: z.ZodObject<{
|
|
58
|
+
/**
|
|
59
|
+
* Array of nodes in topological order (newest/most recent first).
|
|
60
|
+
*/
|
|
61
|
+
nodes: z.ZodArray<z.ZodObject<{
|
|
62
|
+
/**
|
|
63
|
+
* Unique identifier for this node.
|
|
64
|
+
*/
|
|
65
|
+
id: z.ZodString;
|
|
66
|
+
/**
|
|
67
|
+
* Display label for the node (e.g., commit message).
|
|
68
|
+
*/
|
|
69
|
+
label: z.ZodString;
|
|
70
|
+
/**
|
|
71
|
+
* IDs of parent nodes (empty for root nodes).
|
|
72
|
+
*/
|
|
73
|
+
parents: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
74
|
+
/**
|
|
75
|
+
* Optional ref names (branch/tag names) to display.
|
|
76
|
+
*/
|
|
77
|
+
refs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
78
|
+
/**
|
|
79
|
+
* Whether this node should be highlighted.
|
|
80
|
+
*/
|
|
81
|
+
highlight: z.ZodOptional<z.ZodBoolean>;
|
|
82
|
+
/**
|
|
83
|
+
* Custom character to represent this node (overrides global nodeChar).
|
|
84
|
+
*/
|
|
85
|
+
nodeChar: z.ZodOptional<z.ZodString>;
|
|
86
|
+
}, "strip", z.ZodTypeAny, {
|
|
87
|
+
id: string;
|
|
88
|
+
label: string;
|
|
89
|
+
parents: string[];
|
|
90
|
+
refs?: string[] | undefined;
|
|
91
|
+
highlight?: boolean | undefined;
|
|
92
|
+
nodeChar?: string | undefined;
|
|
93
|
+
}, {
|
|
94
|
+
id: string;
|
|
95
|
+
label: string;
|
|
96
|
+
parents?: string[] | undefined;
|
|
97
|
+
refs?: string[] | undefined;
|
|
98
|
+
highlight?: boolean | undefined;
|
|
99
|
+
nodeChar?: string | undefined;
|
|
100
|
+
}>, "many">;
|
|
101
|
+
/**
|
|
102
|
+
* Style for graph characters.
|
|
103
|
+
* @default "unicode"
|
|
104
|
+
*/
|
|
105
|
+
style: z.ZodDefault<z.ZodEnum<["ascii", "unicode"]>>;
|
|
106
|
+
/**
|
|
107
|
+
* Maximum width for labels (truncated if longer).
|
|
108
|
+
* @default 50
|
|
109
|
+
*/
|
|
110
|
+
labelWidth: z.ZodDefault<z.ZodNumber>;
|
|
111
|
+
/**
|
|
112
|
+
* Whether to show refs (branch/tag names).
|
|
113
|
+
* @default true
|
|
114
|
+
*/
|
|
115
|
+
showRefs: z.ZodDefault<z.ZodBoolean>;
|
|
116
|
+
/**
|
|
117
|
+
* Gap between graph and label.
|
|
118
|
+
* @default 1
|
|
119
|
+
*/
|
|
120
|
+
labelGap: z.ZodDefault<z.ZodNumber>;
|
|
121
|
+
/**
|
|
122
|
+
* Custom character to represent nodes (can be overridden per-node).
|
|
123
|
+
* If not specified, uses the default for the style (● for unicode, * for ascii).
|
|
124
|
+
*/
|
|
125
|
+
nodeChar: z.ZodOptional<z.ZodString>;
|
|
126
|
+
}, "strip", z.ZodTypeAny, {
|
|
127
|
+
nodes: {
|
|
128
|
+
id: string;
|
|
129
|
+
label: string;
|
|
130
|
+
parents: string[];
|
|
131
|
+
refs?: string[] | undefined;
|
|
132
|
+
highlight?: boolean | undefined;
|
|
133
|
+
nodeChar?: string | undefined;
|
|
134
|
+
}[];
|
|
135
|
+
style: "ascii" | "unicode";
|
|
136
|
+
labelWidth: number;
|
|
137
|
+
showRefs: boolean;
|
|
138
|
+
labelGap: number;
|
|
139
|
+
nodeChar?: string | undefined;
|
|
140
|
+
}, {
|
|
141
|
+
nodes: {
|
|
142
|
+
id: string;
|
|
143
|
+
label: string;
|
|
144
|
+
parents?: string[] | undefined;
|
|
145
|
+
refs?: string[] | undefined;
|
|
146
|
+
highlight?: boolean | undefined;
|
|
147
|
+
nodeChar?: string | undefined;
|
|
148
|
+
}[];
|
|
149
|
+
nodeChar?: string | undefined;
|
|
150
|
+
style?: "ascii" | "unicode" | undefined;
|
|
151
|
+
labelWidth?: number | undefined;
|
|
152
|
+
showRefs?: boolean | undefined;
|
|
153
|
+
labelGap?: number | undefined;
|
|
154
|
+
}>;
|
|
155
|
+
type GraphInput = z.input<typeof graphInputSchema>;
|
|
156
|
+
type GraphInputWithDefaults = z.output<typeof graphInputSchema>;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Graph component for rendering DAG visualizations (git log style).
|
|
160
|
+
*/
|
|
161
|
+
declare class GraphComponent extends BaseTuiComponent<GraphInput, typeof graphInputSchema> {
|
|
162
|
+
readonly metadata: ComponentMetadata<GraphInput>;
|
|
163
|
+
readonly schema: zod.ZodObject<{
|
|
164
|
+
nodes: zod.ZodArray<zod.ZodObject<{
|
|
165
|
+
id: zod.ZodString;
|
|
166
|
+
label: zod.ZodString;
|
|
167
|
+
parents: zod.ZodDefault<zod.ZodArray<zod.ZodString, "many">>;
|
|
168
|
+
refs: zod.ZodOptional<zod.ZodArray<zod.ZodString, "many">>;
|
|
169
|
+
highlight: zod.ZodOptional<zod.ZodBoolean>;
|
|
170
|
+
nodeChar: zod.ZodOptional<zod.ZodString>;
|
|
171
|
+
}, "strip", zod.ZodTypeAny, {
|
|
172
|
+
id: string;
|
|
173
|
+
label: string;
|
|
174
|
+
parents: string[];
|
|
175
|
+
refs?: string[] | undefined;
|
|
176
|
+
highlight?: boolean | undefined;
|
|
177
|
+
nodeChar?: string | undefined;
|
|
178
|
+
}, {
|
|
179
|
+
id: string;
|
|
180
|
+
label: string;
|
|
181
|
+
parents?: string[] | undefined;
|
|
182
|
+
refs?: string[] | undefined;
|
|
183
|
+
highlight?: boolean | undefined;
|
|
184
|
+
nodeChar?: string | undefined;
|
|
185
|
+
}>, "many">;
|
|
186
|
+
style: zod.ZodDefault<zod.ZodEnum<["ascii", "unicode"]>>;
|
|
187
|
+
labelWidth: zod.ZodDefault<zod.ZodNumber>;
|
|
188
|
+
showRefs: zod.ZodDefault<zod.ZodBoolean>;
|
|
189
|
+
labelGap: zod.ZodDefault<zod.ZodNumber>;
|
|
190
|
+
nodeChar: zod.ZodOptional<zod.ZodString>;
|
|
191
|
+
}, "strip", zod.ZodTypeAny, {
|
|
192
|
+
nodes: {
|
|
193
|
+
id: string;
|
|
194
|
+
label: string;
|
|
195
|
+
parents: string[];
|
|
196
|
+
refs?: string[] | undefined;
|
|
197
|
+
highlight?: boolean | undefined;
|
|
198
|
+
nodeChar?: string | undefined;
|
|
199
|
+
}[];
|
|
200
|
+
style: "ascii" | "unicode";
|
|
201
|
+
labelWidth: number;
|
|
202
|
+
showRefs: boolean;
|
|
203
|
+
labelGap: number;
|
|
204
|
+
nodeChar?: string | undefined;
|
|
205
|
+
}, {
|
|
206
|
+
nodes: {
|
|
207
|
+
id: string;
|
|
208
|
+
label: string;
|
|
209
|
+
parents?: string[] | undefined;
|
|
210
|
+
refs?: string[] | undefined;
|
|
211
|
+
highlight?: boolean | undefined;
|
|
212
|
+
nodeChar?: string | undefined;
|
|
213
|
+
}[];
|
|
214
|
+
nodeChar?: string | undefined;
|
|
215
|
+
style?: "ascii" | "unicode" | undefined;
|
|
216
|
+
labelWidth?: number | undefined;
|
|
217
|
+
showRefs?: boolean | undefined;
|
|
218
|
+
labelGap?: number | undefined;
|
|
219
|
+
}>;
|
|
220
|
+
/**
|
|
221
|
+
* Override getJsonSchema to use direct schema generation.
|
|
222
|
+
*/
|
|
223
|
+
getJsonSchema(): object;
|
|
224
|
+
render(input: GraphInput, context: RenderContext): RenderResult;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Factory function to create a graph component.
|
|
228
|
+
*/
|
|
229
|
+
declare function createGraph(): GraphComponent;
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Characters used for graph rendering.
|
|
233
|
+
*/
|
|
234
|
+
interface GraphChars {
|
|
235
|
+
/** Node marker */
|
|
236
|
+
node: string;
|
|
237
|
+
/** Vertical line */
|
|
238
|
+
vertical: string;
|
|
239
|
+
/** Horizontal line */
|
|
240
|
+
horizontal: string;
|
|
241
|
+
/** Left branch (fork going down-right) */
|
|
242
|
+
branchLeft: string;
|
|
243
|
+
/** Right branch (fork going down-left) */
|
|
244
|
+
branchRight: string;
|
|
245
|
+
/** Merge point (multiple lines converging) */
|
|
246
|
+
merge: string;
|
|
247
|
+
/** Down and right corner */
|
|
248
|
+
cornerDownRight: string;
|
|
249
|
+
/** Down and left corner */
|
|
250
|
+
cornerDownLeft: string;
|
|
251
|
+
/** Diagonal going down-right */
|
|
252
|
+
diagonalRight: string;
|
|
253
|
+
/** Diagonal going down-left */
|
|
254
|
+
diagonalLeft: string;
|
|
255
|
+
/** Space for alignment */
|
|
256
|
+
space: string;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Get graph characters for a given style.
|
|
260
|
+
*/
|
|
261
|
+
declare function getGraphChars(style: GraphStyle): GraphChars;
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Layout information for a single node.
|
|
265
|
+
*/
|
|
266
|
+
interface NodeLayout {
|
|
267
|
+
/** The original node */
|
|
268
|
+
node: GraphNode;
|
|
269
|
+
/** Column index for this node (0-based) */
|
|
270
|
+
column: number;
|
|
271
|
+
/** Graph portion of this row (before label) */
|
|
272
|
+
graphLine: string;
|
|
273
|
+
/** Continuation lines between this node and the next */
|
|
274
|
+
continuationLines: string[];
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Pre-computed layout for the entire graph.
|
|
278
|
+
*/
|
|
279
|
+
interface GraphLayout {
|
|
280
|
+
/** Layout for each node */
|
|
281
|
+
nodes: NodeLayout[];
|
|
282
|
+
/** Maximum number of columns used */
|
|
283
|
+
maxColumns: number;
|
|
284
|
+
/** Width of the graph portion (in characters) */
|
|
285
|
+
graphWidth: number;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Compute the layout for a graph.
|
|
289
|
+
*
|
|
290
|
+
* Uses a column-sweep algorithm optimized for newest-first processing order,
|
|
291
|
+
* producing git log --graph style output.
|
|
292
|
+
*
|
|
293
|
+
* @param input - Validated graph input with defaults applied
|
|
294
|
+
* @param chars - Character set to use
|
|
295
|
+
* @returns Computed layout ready for rendering
|
|
296
|
+
*/
|
|
297
|
+
declare function computeGraphLayout(input: GraphInputWithDefaults, chars: GraphChars): GraphLayout;
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Render a graph using ANSI escape codes for rich terminal output.
|
|
301
|
+
*
|
|
302
|
+
* @param layout - Pre-computed graph layout
|
|
303
|
+
* @param input - Original input with defaults
|
|
304
|
+
* @param theme - Optional theme for colors
|
|
305
|
+
* @returns ANSI-formatted graph string
|
|
306
|
+
*/
|
|
307
|
+
declare function renderGraphAnsi(layout: GraphLayout, input: GraphInputWithDefaults, theme?: TuiTheme): string;
|
|
308
|
+
/**
|
|
309
|
+
* Render a graph using markdown-friendly output.
|
|
310
|
+
*
|
|
311
|
+
* Uses anchored lines to prevent whitespace collapse in markdown renderers.
|
|
312
|
+
*
|
|
313
|
+
* @param layout - Pre-computed graph layout
|
|
314
|
+
* @param input - Original input with defaults
|
|
315
|
+
* @returns Markdown-friendly graph string
|
|
316
|
+
*/
|
|
317
|
+
declare function renderGraphMarkdown(layout: GraphLayout, input: GraphInputWithDefaults): string;
|
|
318
|
+
|
|
319
|
+
export { type GraphChars, GraphComponent, type GraphInput, type GraphInputWithDefaults, type GraphLayout, type GraphNode, type GraphStyle, type NodeLayout, computeGraphLayout, createGraph, getGraphChars, graphInputSchema, graphNodeSchema, graphStyleSchema, renderGraphAnsi, renderGraphMarkdown };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import * as zod from 'zod';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { BaseTuiComponent, ComponentMetadata, RenderContext, RenderResult, TuiTheme } from '@tuicomponents/core';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Style options for graph line characters.
|
|
7
|
+
*/
|
|
8
|
+
declare const graphStyleSchema: z.ZodEnum<["ascii", "unicode"]>;
|
|
9
|
+
type GraphStyle = z.infer<typeof graphStyleSchema>;
|
|
10
|
+
/**
|
|
11
|
+
* Schema for a single node in the graph.
|
|
12
|
+
*/
|
|
13
|
+
declare const graphNodeSchema: z.ZodObject<{
|
|
14
|
+
/**
|
|
15
|
+
* Unique identifier for this node.
|
|
16
|
+
*/
|
|
17
|
+
id: z.ZodString;
|
|
18
|
+
/**
|
|
19
|
+
* Display label for the node (e.g., commit message).
|
|
20
|
+
*/
|
|
21
|
+
label: z.ZodString;
|
|
22
|
+
/**
|
|
23
|
+
* IDs of parent nodes (empty for root nodes).
|
|
24
|
+
*/
|
|
25
|
+
parents: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
26
|
+
/**
|
|
27
|
+
* Optional ref names (branch/tag names) to display.
|
|
28
|
+
*/
|
|
29
|
+
refs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
30
|
+
/**
|
|
31
|
+
* Whether this node should be highlighted.
|
|
32
|
+
*/
|
|
33
|
+
highlight: z.ZodOptional<z.ZodBoolean>;
|
|
34
|
+
/**
|
|
35
|
+
* Custom character to represent this node (overrides global nodeChar).
|
|
36
|
+
*/
|
|
37
|
+
nodeChar: z.ZodOptional<z.ZodString>;
|
|
38
|
+
}, "strip", z.ZodTypeAny, {
|
|
39
|
+
id: string;
|
|
40
|
+
label: string;
|
|
41
|
+
parents: string[];
|
|
42
|
+
refs?: string[] | undefined;
|
|
43
|
+
highlight?: boolean | undefined;
|
|
44
|
+
nodeChar?: string | undefined;
|
|
45
|
+
}, {
|
|
46
|
+
id: string;
|
|
47
|
+
label: string;
|
|
48
|
+
parents?: string[] | undefined;
|
|
49
|
+
refs?: string[] | undefined;
|
|
50
|
+
highlight?: boolean | undefined;
|
|
51
|
+
nodeChar?: string | undefined;
|
|
52
|
+
}>;
|
|
53
|
+
type GraphNode = z.infer<typeof graphNodeSchema>;
|
|
54
|
+
/**
|
|
55
|
+
* Schema for graph component input.
|
|
56
|
+
*/
|
|
57
|
+
declare const graphInputSchema: z.ZodObject<{
|
|
58
|
+
/**
|
|
59
|
+
* Array of nodes in topological order (newest/most recent first).
|
|
60
|
+
*/
|
|
61
|
+
nodes: z.ZodArray<z.ZodObject<{
|
|
62
|
+
/**
|
|
63
|
+
* Unique identifier for this node.
|
|
64
|
+
*/
|
|
65
|
+
id: z.ZodString;
|
|
66
|
+
/**
|
|
67
|
+
* Display label for the node (e.g., commit message).
|
|
68
|
+
*/
|
|
69
|
+
label: z.ZodString;
|
|
70
|
+
/**
|
|
71
|
+
* IDs of parent nodes (empty for root nodes).
|
|
72
|
+
*/
|
|
73
|
+
parents: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
74
|
+
/**
|
|
75
|
+
* Optional ref names (branch/tag names) to display.
|
|
76
|
+
*/
|
|
77
|
+
refs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
78
|
+
/**
|
|
79
|
+
* Whether this node should be highlighted.
|
|
80
|
+
*/
|
|
81
|
+
highlight: z.ZodOptional<z.ZodBoolean>;
|
|
82
|
+
/**
|
|
83
|
+
* Custom character to represent this node (overrides global nodeChar).
|
|
84
|
+
*/
|
|
85
|
+
nodeChar: z.ZodOptional<z.ZodString>;
|
|
86
|
+
}, "strip", z.ZodTypeAny, {
|
|
87
|
+
id: string;
|
|
88
|
+
label: string;
|
|
89
|
+
parents: string[];
|
|
90
|
+
refs?: string[] | undefined;
|
|
91
|
+
highlight?: boolean | undefined;
|
|
92
|
+
nodeChar?: string | undefined;
|
|
93
|
+
}, {
|
|
94
|
+
id: string;
|
|
95
|
+
label: string;
|
|
96
|
+
parents?: string[] | undefined;
|
|
97
|
+
refs?: string[] | undefined;
|
|
98
|
+
highlight?: boolean | undefined;
|
|
99
|
+
nodeChar?: string | undefined;
|
|
100
|
+
}>, "many">;
|
|
101
|
+
/**
|
|
102
|
+
* Style for graph characters.
|
|
103
|
+
* @default "unicode"
|
|
104
|
+
*/
|
|
105
|
+
style: z.ZodDefault<z.ZodEnum<["ascii", "unicode"]>>;
|
|
106
|
+
/**
|
|
107
|
+
* Maximum width for labels (truncated if longer).
|
|
108
|
+
* @default 50
|
|
109
|
+
*/
|
|
110
|
+
labelWidth: z.ZodDefault<z.ZodNumber>;
|
|
111
|
+
/**
|
|
112
|
+
* Whether to show refs (branch/tag names).
|
|
113
|
+
* @default true
|
|
114
|
+
*/
|
|
115
|
+
showRefs: z.ZodDefault<z.ZodBoolean>;
|
|
116
|
+
/**
|
|
117
|
+
* Gap between graph and label.
|
|
118
|
+
* @default 1
|
|
119
|
+
*/
|
|
120
|
+
labelGap: z.ZodDefault<z.ZodNumber>;
|
|
121
|
+
/**
|
|
122
|
+
* Custom character to represent nodes (can be overridden per-node).
|
|
123
|
+
* If not specified, uses the default for the style (● for unicode, * for ascii).
|
|
124
|
+
*/
|
|
125
|
+
nodeChar: z.ZodOptional<z.ZodString>;
|
|
126
|
+
}, "strip", z.ZodTypeAny, {
|
|
127
|
+
nodes: {
|
|
128
|
+
id: string;
|
|
129
|
+
label: string;
|
|
130
|
+
parents: string[];
|
|
131
|
+
refs?: string[] | undefined;
|
|
132
|
+
highlight?: boolean | undefined;
|
|
133
|
+
nodeChar?: string | undefined;
|
|
134
|
+
}[];
|
|
135
|
+
style: "ascii" | "unicode";
|
|
136
|
+
labelWidth: number;
|
|
137
|
+
showRefs: boolean;
|
|
138
|
+
labelGap: number;
|
|
139
|
+
nodeChar?: string | undefined;
|
|
140
|
+
}, {
|
|
141
|
+
nodes: {
|
|
142
|
+
id: string;
|
|
143
|
+
label: string;
|
|
144
|
+
parents?: string[] | undefined;
|
|
145
|
+
refs?: string[] | undefined;
|
|
146
|
+
highlight?: boolean | undefined;
|
|
147
|
+
nodeChar?: string | undefined;
|
|
148
|
+
}[];
|
|
149
|
+
nodeChar?: string | undefined;
|
|
150
|
+
style?: "ascii" | "unicode" | undefined;
|
|
151
|
+
labelWidth?: number | undefined;
|
|
152
|
+
showRefs?: boolean | undefined;
|
|
153
|
+
labelGap?: number | undefined;
|
|
154
|
+
}>;
|
|
155
|
+
type GraphInput = z.input<typeof graphInputSchema>;
|
|
156
|
+
type GraphInputWithDefaults = z.output<typeof graphInputSchema>;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Graph component for rendering DAG visualizations (git log style).
|
|
160
|
+
*/
|
|
161
|
+
declare class GraphComponent extends BaseTuiComponent<GraphInput, typeof graphInputSchema> {
|
|
162
|
+
readonly metadata: ComponentMetadata<GraphInput>;
|
|
163
|
+
readonly schema: zod.ZodObject<{
|
|
164
|
+
nodes: zod.ZodArray<zod.ZodObject<{
|
|
165
|
+
id: zod.ZodString;
|
|
166
|
+
label: zod.ZodString;
|
|
167
|
+
parents: zod.ZodDefault<zod.ZodArray<zod.ZodString, "many">>;
|
|
168
|
+
refs: zod.ZodOptional<zod.ZodArray<zod.ZodString, "many">>;
|
|
169
|
+
highlight: zod.ZodOptional<zod.ZodBoolean>;
|
|
170
|
+
nodeChar: zod.ZodOptional<zod.ZodString>;
|
|
171
|
+
}, "strip", zod.ZodTypeAny, {
|
|
172
|
+
id: string;
|
|
173
|
+
label: string;
|
|
174
|
+
parents: string[];
|
|
175
|
+
refs?: string[] | undefined;
|
|
176
|
+
highlight?: boolean | undefined;
|
|
177
|
+
nodeChar?: string | undefined;
|
|
178
|
+
}, {
|
|
179
|
+
id: string;
|
|
180
|
+
label: string;
|
|
181
|
+
parents?: string[] | undefined;
|
|
182
|
+
refs?: string[] | undefined;
|
|
183
|
+
highlight?: boolean | undefined;
|
|
184
|
+
nodeChar?: string | undefined;
|
|
185
|
+
}>, "many">;
|
|
186
|
+
style: zod.ZodDefault<zod.ZodEnum<["ascii", "unicode"]>>;
|
|
187
|
+
labelWidth: zod.ZodDefault<zod.ZodNumber>;
|
|
188
|
+
showRefs: zod.ZodDefault<zod.ZodBoolean>;
|
|
189
|
+
labelGap: zod.ZodDefault<zod.ZodNumber>;
|
|
190
|
+
nodeChar: zod.ZodOptional<zod.ZodString>;
|
|
191
|
+
}, "strip", zod.ZodTypeAny, {
|
|
192
|
+
nodes: {
|
|
193
|
+
id: string;
|
|
194
|
+
label: string;
|
|
195
|
+
parents: string[];
|
|
196
|
+
refs?: string[] | undefined;
|
|
197
|
+
highlight?: boolean | undefined;
|
|
198
|
+
nodeChar?: string | undefined;
|
|
199
|
+
}[];
|
|
200
|
+
style: "ascii" | "unicode";
|
|
201
|
+
labelWidth: number;
|
|
202
|
+
showRefs: boolean;
|
|
203
|
+
labelGap: number;
|
|
204
|
+
nodeChar?: string | undefined;
|
|
205
|
+
}, {
|
|
206
|
+
nodes: {
|
|
207
|
+
id: string;
|
|
208
|
+
label: string;
|
|
209
|
+
parents?: string[] | undefined;
|
|
210
|
+
refs?: string[] | undefined;
|
|
211
|
+
highlight?: boolean | undefined;
|
|
212
|
+
nodeChar?: string | undefined;
|
|
213
|
+
}[];
|
|
214
|
+
nodeChar?: string | undefined;
|
|
215
|
+
style?: "ascii" | "unicode" | undefined;
|
|
216
|
+
labelWidth?: number | undefined;
|
|
217
|
+
showRefs?: boolean | undefined;
|
|
218
|
+
labelGap?: number | undefined;
|
|
219
|
+
}>;
|
|
220
|
+
/**
|
|
221
|
+
* Override getJsonSchema to use direct schema generation.
|
|
222
|
+
*/
|
|
223
|
+
getJsonSchema(): object;
|
|
224
|
+
render(input: GraphInput, context: RenderContext): RenderResult;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Factory function to create a graph component.
|
|
228
|
+
*/
|
|
229
|
+
declare function createGraph(): GraphComponent;
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Characters used for graph rendering.
|
|
233
|
+
*/
|
|
234
|
+
interface GraphChars {
|
|
235
|
+
/** Node marker */
|
|
236
|
+
node: string;
|
|
237
|
+
/** Vertical line */
|
|
238
|
+
vertical: string;
|
|
239
|
+
/** Horizontal line */
|
|
240
|
+
horizontal: string;
|
|
241
|
+
/** Left branch (fork going down-right) */
|
|
242
|
+
branchLeft: string;
|
|
243
|
+
/** Right branch (fork going down-left) */
|
|
244
|
+
branchRight: string;
|
|
245
|
+
/** Merge point (multiple lines converging) */
|
|
246
|
+
merge: string;
|
|
247
|
+
/** Down and right corner */
|
|
248
|
+
cornerDownRight: string;
|
|
249
|
+
/** Down and left corner */
|
|
250
|
+
cornerDownLeft: string;
|
|
251
|
+
/** Diagonal going down-right */
|
|
252
|
+
diagonalRight: string;
|
|
253
|
+
/** Diagonal going down-left */
|
|
254
|
+
diagonalLeft: string;
|
|
255
|
+
/** Space for alignment */
|
|
256
|
+
space: string;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Get graph characters for a given style.
|
|
260
|
+
*/
|
|
261
|
+
declare function getGraphChars(style: GraphStyle): GraphChars;
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Layout information for a single node.
|
|
265
|
+
*/
|
|
266
|
+
interface NodeLayout {
|
|
267
|
+
/** The original node */
|
|
268
|
+
node: GraphNode;
|
|
269
|
+
/** Column index for this node (0-based) */
|
|
270
|
+
column: number;
|
|
271
|
+
/** Graph portion of this row (before label) */
|
|
272
|
+
graphLine: string;
|
|
273
|
+
/** Continuation lines between this node and the next */
|
|
274
|
+
continuationLines: string[];
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Pre-computed layout for the entire graph.
|
|
278
|
+
*/
|
|
279
|
+
interface GraphLayout {
|
|
280
|
+
/** Layout for each node */
|
|
281
|
+
nodes: NodeLayout[];
|
|
282
|
+
/** Maximum number of columns used */
|
|
283
|
+
maxColumns: number;
|
|
284
|
+
/** Width of the graph portion (in characters) */
|
|
285
|
+
graphWidth: number;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Compute the layout for a graph.
|
|
289
|
+
*
|
|
290
|
+
* Uses a column-sweep algorithm optimized for newest-first processing order,
|
|
291
|
+
* producing git log --graph style output.
|
|
292
|
+
*
|
|
293
|
+
* @param input - Validated graph input with defaults applied
|
|
294
|
+
* @param chars - Character set to use
|
|
295
|
+
* @returns Computed layout ready for rendering
|
|
296
|
+
*/
|
|
297
|
+
declare function computeGraphLayout(input: GraphInputWithDefaults, chars: GraphChars): GraphLayout;
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Render a graph using ANSI escape codes for rich terminal output.
|
|
301
|
+
*
|
|
302
|
+
* @param layout - Pre-computed graph layout
|
|
303
|
+
* @param input - Original input with defaults
|
|
304
|
+
* @param theme - Optional theme for colors
|
|
305
|
+
* @returns ANSI-formatted graph string
|
|
306
|
+
*/
|
|
307
|
+
declare function renderGraphAnsi(layout: GraphLayout, input: GraphInputWithDefaults, theme?: TuiTheme): string;
|
|
308
|
+
/**
|
|
309
|
+
* Render a graph using markdown-friendly output.
|
|
310
|
+
*
|
|
311
|
+
* Uses anchored lines to prevent whitespace collapse in markdown renderers.
|
|
312
|
+
*
|
|
313
|
+
* @param layout - Pre-computed graph layout
|
|
314
|
+
* @param input - Original input with defaults
|
|
315
|
+
* @returns Markdown-friendly graph string
|
|
316
|
+
*/
|
|
317
|
+
declare function renderGraphMarkdown(layout: GraphLayout, input: GraphInputWithDefaults): string;
|
|
318
|
+
|
|
319
|
+
export { type GraphChars, GraphComponent, type GraphInput, type GraphInputWithDefaults, type GraphLayout, type GraphNode, type GraphStyle, type NodeLayout, computeGraphLayout, createGraph, getGraphChars, graphInputSchema, graphNodeSchema, graphStyleSchema, renderGraphAnsi, renderGraphMarkdown };
|