footprint-explainable-ui 0.3.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.
- package/README.md +288 -0
- package/dist/flowchart.cjs +1512 -0
- package/dist/flowchart.cjs.map +1 -0
- package/dist/flowchart.d.cts +199 -0
- package/dist/flowchart.d.ts +199 -0
- package/dist/flowchart.js +1486 -0
- package/dist/flowchart.js.map +1 -0
- package/dist/index.cjs +1946 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +270 -0
- package/dist/index.d.ts +270 -0
- package/dist/index.js +1901 -0
- package/dist/index.js.map +1 -0
- package/package.json +63 -0
package/README.md
ADDED
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
# footprint-explainable-ui
|
|
2
|
+
|
|
3
|
+
Themeable React components for visualizing [FootPrint](https://github.com/sanjay1909/footPrint) pipeline execution — time-travel debugging, flowchart overlays, narrative traces, and scope diffs.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install footprint-explainable-ui
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Peer dependencies: `react >= 18`. For flowchart components, also install `@xyflow/react`.
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
### All-in-One Shell
|
|
16
|
+
|
|
17
|
+
The `ExplainableShell` gives you a tabbed UI (Result | Explainable | AI-Compatible) with time-travel controls, Gantt timeline, scope diffs, and progressive narrative — out of the box.
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
import { ExplainableShell, FootprintTheme, warmDark } from "footprint-explainable-ui";
|
|
21
|
+
|
|
22
|
+
function App({ snapshots, narrative, result }) {
|
|
23
|
+
return (
|
|
24
|
+
<FootprintTheme tokens={warmDark}>
|
|
25
|
+
<ExplainableShell
|
|
26
|
+
snapshots={snapshots}
|
|
27
|
+
narrative={narrative}
|
|
28
|
+
resultData={result}
|
|
29
|
+
logs={consoleLogs}
|
|
30
|
+
/>
|
|
31
|
+
</FootprintTheme>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Individual Components
|
|
37
|
+
|
|
38
|
+
Every component works standalone. Mix and match:
|
|
39
|
+
|
|
40
|
+
```tsx
|
|
41
|
+
import {
|
|
42
|
+
NarrativeTrace,
|
|
43
|
+
ScopeDiff,
|
|
44
|
+
GanttTimeline,
|
|
45
|
+
MemoryInspector,
|
|
46
|
+
TimeTravelControls,
|
|
47
|
+
ResultPanel,
|
|
48
|
+
} from "footprint-explainable-ui";
|
|
49
|
+
|
|
50
|
+
function MyDebugger({ snapshots }) {
|
|
51
|
+
const [idx, setIdx] = useState(0);
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<>
|
|
55
|
+
<TimeTravelControls
|
|
56
|
+
snapshots={snapshots}
|
|
57
|
+
selectedIndex={idx}
|
|
58
|
+
onIndexChange={setIdx}
|
|
59
|
+
/>
|
|
60
|
+
<MemoryInspector snapshots={snapshots} selectedIndex={idx} />
|
|
61
|
+
<ScopeDiff
|
|
62
|
+
previous={idx > 0 ? snapshots[idx - 1].memory : null}
|
|
63
|
+
current={snapshots[idx].memory}
|
|
64
|
+
hideUnchanged
|
|
65
|
+
/>
|
|
66
|
+
<GanttTimeline snapshots={snapshots} selectedIndex={idx} onSelect={setIdx} />
|
|
67
|
+
</>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Theming
|
|
73
|
+
|
|
74
|
+
### Option 1: ThemeProvider
|
|
75
|
+
|
|
76
|
+
Wrap your app with `FootprintTheme` and pass a preset or custom tokens:
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
import { FootprintTheme, warmDark, warmLight, coolDark } from "footprint-explainable-ui";
|
|
80
|
+
|
|
81
|
+
// Use a built-in preset
|
|
82
|
+
<FootprintTheme tokens={warmDark}>
|
|
83
|
+
<MyApp />
|
|
84
|
+
</FootprintTheme>
|
|
85
|
+
|
|
86
|
+
// Or customize
|
|
87
|
+
<FootprintTheme tokens={{
|
|
88
|
+
colors: {
|
|
89
|
+
primary: "#e91e63",
|
|
90
|
+
bgPrimary: "#121212",
|
|
91
|
+
textPrimary: "#ffffff",
|
|
92
|
+
},
|
|
93
|
+
radius: "12px",
|
|
94
|
+
}}>
|
|
95
|
+
<MyApp />
|
|
96
|
+
</FootprintTheme>
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Option 2: CSS Variables
|
|
100
|
+
|
|
101
|
+
Set `--fp-*` CSS variables directly — no provider needed:
|
|
102
|
+
|
|
103
|
+
```css
|
|
104
|
+
:root {
|
|
105
|
+
--fp-color-primary: #7c6cf0;
|
|
106
|
+
--fp-bg-primary: #1e1a2e;
|
|
107
|
+
--fp-bg-secondary: #2a2540;
|
|
108
|
+
--fp-text-primary: #f0e6d6;
|
|
109
|
+
--fp-border: #3a3455;
|
|
110
|
+
--fp-radius: 8px;
|
|
111
|
+
--fp-font-mono: 'JetBrains Mono', monospace;
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Built-in Presets
|
|
116
|
+
|
|
117
|
+
| Preset | Description |
|
|
118
|
+
|--------|-------------|
|
|
119
|
+
| `coolDark` | Default — indigo/slate dark theme |
|
|
120
|
+
| `warmDark` | Charcoal-purple with warm text |
|
|
121
|
+
| `warmLight` | Cream/peach light theme |
|
|
122
|
+
|
|
123
|
+
### Token Reference
|
|
124
|
+
|
|
125
|
+
```typescript
|
|
126
|
+
interface ThemeTokens {
|
|
127
|
+
colors?: {
|
|
128
|
+
primary?: string; // Accent color (buttons, highlights)
|
|
129
|
+
success?: string; // Completed stages
|
|
130
|
+
error?: string; // Error states
|
|
131
|
+
warning?: string; // Warnings
|
|
132
|
+
bgPrimary?: string; // Main background
|
|
133
|
+
bgSecondary?: string;// Panel/card background
|
|
134
|
+
bgTertiary?: string; // Hover/active background
|
|
135
|
+
textPrimary?: string;// Main text
|
|
136
|
+
textSecondary?: string;// Secondary text
|
|
137
|
+
textMuted?: string; // Dimmed text
|
|
138
|
+
border?: string; // Borders
|
|
139
|
+
};
|
|
140
|
+
radius?: string; // Border radius
|
|
141
|
+
fontFamily?: {
|
|
142
|
+
sans?: string; // UI text font
|
|
143
|
+
mono?: string; // Code/data font
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Size Variants
|
|
149
|
+
|
|
150
|
+
All components accept a `size` prop: `"compact"`, `"default"`, or `"detailed"`.
|
|
151
|
+
|
|
152
|
+
```tsx
|
|
153
|
+
<GanttTimeline snapshots={snapshots} size="compact" />
|
|
154
|
+
<MemoryInspector snapshots={snapshots} size="detailed" />
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Unstyled Mode
|
|
158
|
+
|
|
159
|
+
Strip all built-in styles and bring your own. Components render semantic `data-fp` attributes for CSS targeting:
|
|
160
|
+
|
|
161
|
+
```tsx
|
|
162
|
+
<NarrativeTrace narrative={lines} unstyled className="my-narrative" />
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
```css
|
|
166
|
+
[data-fp="narrative-header"] { font-weight: bold; }
|
|
167
|
+
[data-fp="narrative-step"] { padding-left: 2rem; }
|
|
168
|
+
[data-fp="narrative-group"][data-latest="true"] { background: highlight; }
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Components
|
|
172
|
+
|
|
173
|
+
| Component | Description |
|
|
174
|
+
|-----------|-------------|
|
|
175
|
+
| `ExplainableShell` | Tabbed container: Result / Explainable / AI-Compatible |
|
|
176
|
+
| `TimeTravelControls` | Play/pause, prev/next, tick-mark timeline |
|
|
177
|
+
| `NarrativeTrace` | Collapsible stage groups with progressive reveal |
|
|
178
|
+
| `NarrativeLog` | Simple timeline-style execution log |
|
|
179
|
+
| `ScopeDiff` | Side-by-side scope changes (added/changed/removed) |
|
|
180
|
+
| `ResultPanel` | Final pipeline output + console logs |
|
|
181
|
+
| `MemoryInspector` | Accumulated memory state viewer |
|
|
182
|
+
| `GanttTimeline` | Horizontal duration timeline |
|
|
183
|
+
| `SnapshotPanel` | All-in-one inspector (scrubber + memory + narrative + Gantt) |
|
|
184
|
+
|
|
185
|
+
### Flowchart Components (separate entry point)
|
|
186
|
+
|
|
187
|
+
Requires `@xyflow/react` as a peer dependency. Import from `footprint-explainable-ui/flowchart`:
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
npm install @xyflow/react
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
```tsx
|
|
194
|
+
import {
|
|
195
|
+
FlowchartView,
|
|
196
|
+
StageNode,
|
|
197
|
+
specToReactFlow,
|
|
198
|
+
TimeTravelDebugger,
|
|
199
|
+
} from "footprint-explainable-ui/flowchart";
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
| Export | Description |
|
|
203
|
+
|--------|-------------|
|
|
204
|
+
| `FlowchartView` | ReactFlow pipeline visualization with execution overlay |
|
|
205
|
+
| `StageNode` | Custom node with state-aware coloring, step badges, pulse rings |
|
|
206
|
+
| `specToReactFlow` | Convert pipeline spec → ReactFlow nodes/edges with path overlay |
|
|
207
|
+
| `TimeTravelDebugger` | Full debugger with flowchart + all panels |
|
|
208
|
+
|
|
209
|
+
### `specToReactFlow` — Pipeline Spec to Flowchart
|
|
210
|
+
|
|
211
|
+
Converts a `builder.toSpec()` structure into ReactFlow nodes and edges. Supports two modes:
|
|
212
|
+
|
|
213
|
+
```tsx
|
|
214
|
+
import { specToReactFlow } from "footprint-explainable-ui/flowchart";
|
|
215
|
+
import type { ExecutionOverlay } from "footprint-explainable-ui/flowchart";
|
|
216
|
+
|
|
217
|
+
// 1. Static flowchart (no execution state)
|
|
218
|
+
const { nodes, edges } = specToReactFlow(spec);
|
|
219
|
+
|
|
220
|
+
// 2. With execution overlay (Google Maps-style path)
|
|
221
|
+
const overlay: ExecutionOverlay = {
|
|
222
|
+
doneStages: new Set(["ReceiveApp", "PullCredit"]),
|
|
223
|
+
activeStage: "CalculateDTI",
|
|
224
|
+
executedStages: new Set(["ReceiveApp", "PullCredit", "CalculateDTI"]),
|
|
225
|
+
executionOrder: ["ReceiveApp", "PullCredit", "CalculateDTI"],
|
|
226
|
+
};
|
|
227
|
+
const { nodes, edges } = specToReactFlow(spec, overlay);
|
|
228
|
+
|
|
229
|
+
// 3. Custom edge colors (overrides theme defaults)
|
|
230
|
+
const { nodes, edges } = specToReactFlow(spec, overlay, {
|
|
231
|
+
edgeExecuted: "#00ff88",
|
|
232
|
+
edgeActive: "#ff6b6b",
|
|
233
|
+
});
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
Edge colors default to the library's theme tokens (`success` for executed, `primary` for active). Override per-call via the `colors` parameter.
|
|
237
|
+
|
|
238
|
+
### `StageNode` — Theme-Aware Node
|
|
239
|
+
|
|
240
|
+
`StageNode` reads all colors from `--fp-*` CSS variables:
|
|
241
|
+
- **Default state**: uses `--fp-bg-secondary` background, `--fp-text-primary` text
|
|
242
|
+
- **Active/done/error**: uses `--fp-color-primary` / `success` / `error` background
|
|
243
|
+
- **Step badge**: shows execution order number on executed nodes
|
|
244
|
+
- **Font**: uses `--fp-font-sans` for label text
|
|
245
|
+
|
|
246
|
+
Wrap your flowchart in `FootprintTheme` and the nodes match automatically:
|
|
247
|
+
|
|
248
|
+
```tsx
|
|
249
|
+
<FootprintTheme tokens={warmDark}>
|
|
250
|
+
<ReactFlow nodes={nodes} edges={edges} nodeTypes={{ stage: StageNode }} />
|
|
251
|
+
</FootprintTheme>
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
## Adapters
|
|
255
|
+
|
|
256
|
+
Convert FootPrint runtime snapshots to the `StageSnapshot[]` format:
|
|
257
|
+
|
|
258
|
+
```typescript
|
|
259
|
+
import { toVisualizationSnapshots } from "footprint-explainable-ui";
|
|
260
|
+
|
|
261
|
+
const executor = new FlowChartExecutor(pipeline);
|
|
262
|
+
await executor.run(scope);
|
|
263
|
+
|
|
264
|
+
const snapshots = toVisualizationSnapshots(executor.getSnapshot());
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
## Rendering in Different Contexts
|
|
268
|
+
|
|
269
|
+
The library is render-target agnostic. Use components in:
|
|
270
|
+
|
|
271
|
+
- **Inline content** — drop into any React layout
|
|
272
|
+
- **Modal/dialog** — wrap in your modal component
|
|
273
|
+
- **Sidebar panel** — use `size="compact"` for narrow panels
|
|
274
|
+
- **Full-page dashboard** — use `ExplainableShell` with all tabs
|
|
275
|
+
- **Embedded widget** — use `unstyled` mode + custom CSS
|
|
276
|
+
|
|
277
|
+
```tsx
|
|
278
|
+
// In a modal
|
|
279
|
+
<Dialog>
|
|
280
|
+
<ExplainableShell snapshots={snapshots} narrative={narrative} size="compact" />
|
|
281
|
+
</Dialog>
|
|
282
|
+
|
|
283
|
+
// In a sidebar
|
|
284
|
+
<aside style={{ width: 320 }}>
|
|
285
|
+
<NarrativeTrace narrative={narrative} size="compact" />
|
|
286
|
+
<GanttTimeline snapshots={snapshots} size="compact" />
|
|
287
|
+
</aside>
|
|
288
|
+
```
|