@xera-ai/core 0.9.7 → 0.9.8
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/bin/templates/LICENSE-vis-network.txt +2 -0
- package/dist/bin/templates/graph.css +298 -44
- package/dist/bin/templates/graph.html.template +24 -12
- package/dist/bin/templates/graph.js +273 -56
- package/dist/bin/templates/vis-network.min.js +3 -24976
- package/package.json +3 -3
- package/src/graph/templates/LICENSE-vis-network.txt +2 -0
- package/src/graph/templates/graph.css +298 -44
- package/src/graph/templates/graph.html.template +24 -12
- package/src/graph/templates/graph.js +273 -56
- package/src/graph/templates/vis-network.min.js +3 -24976
|
@@ -1,101 +1,318 @@
|
|
|
1
1
|
(() => {
|
|
2
|
-
var data = window.__GRAPH__ || { nodes: [], edges: [] };
|
|
2
|
+
var data = window.__GRAPH__ || { nodes: [], edges: [], stats: {} };
|
|
3
3
|
var container = document.getElementById('canvas');
|
|
4
4
|
if (!container || typeof vis === 'undefined') {
|
|
5
|
-
|
|
6
|
-
'<p style="padding:
|
|
5
|
+
container.innerHTML =
|
|
6
|
+
'<p style="padding:40px;color:#4b5563;font-size:13px">Failed to load vis-network.</p>';
|
|
7
7
|
return;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
var
|
|
10
|
+
// ── Populate stats chips ─────────────────────────────
|
|
11
|
+
var statsBar = document.getElementById('stats-bar');
|
|
12
|
+
var s = data.stats || {};
|
|
13
|
+
var chips = [
|
|
14
|
+
{ label: `${s.tickets ?? 0} tickets`, color: '#3b82f6' },
|
|
15
|
+
{ label: `${s.scenarios ?? 0} scenarios`, color: '#3fb950' },
|
|
16
|
+
{ label: `${s.poms ?? 0} POMs`, color: '#e3b341' },
|
|
17
|
+
{ label: `${s.edges ?? 0} edges`, color: '#475569' },
|
|
18
|
+
];
|
|
19
|
+
if (s.failures) chips.splice(2, 0, { label: `${s.failures} failures`, color: '#f85149' });
|
|
20
|
+
chips.forEach((c) => {
|
|
21
|
+
var el = document.createElement('div');
|
|
22
|
+
el.className = 'stat-chip';
|
|
23
|
+
el.innerHTML = `<span class="dot" style="background:${c.color}"></span>${c.label}`;
|
|
24
|
+
statsBar.appendChild(el);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// ── Active filter labels ─────────────────────────────
|
|
28
|
+
['pass', 'fail', 'p0'].forEach((key) => {
|
|
29
|
+
var label = document.getElementById(`label-${key}`);
|
|
30
|
+
var cb = document.getElementById(`filter-${key}`);
|
|
31
|
+
if (cb.checked) label.classList.add('active');
|
|
32
|
+
cb.addEventListener('change', () => {
|
|
33
|
+
label.classList.toggle('active', cb.checked);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// ── Node visual enhancement ──────────────────────────
|
|
38
|
+
function trunc(str, n) {
|
|
39
|
+
return str && str.length > n ? `${str.slice(0, n - 1)}…` : str;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
var NODE_STYLES = {
|
|
43
|
+
Ticket: {
|
|
44
|
+
shape: 'dot',
|
|
45
|
+
sizeBase: 20,
|
|
46
|
+
color: {
|
|
47
|
+
background: '#112240',
|
|
48
|
+
border: '#4d94ff',
|
|
49
|
+
highlight: { background: '#1a3a6e', border: '#82b4ff' },
|
|
50
|
+
hover: { background: '#152d5a', border: '#5fa3ff' },
|
|
51
|
+
},
|
|
52
|
+
font: { size: 12, color: '#93c5fd', strokeWidth: 3, strokeColor: '#050810', bold: true },
|
|
53
|
+
borderWidth: 2,
|
|
54
|
+
},
|
|
55
|
+
Scenario: {
|
|
56
|
+
shape: 'box',
|
|
57
|
+
sizeBase: 10,
|
|
58
|
+
color: {
|
|
59
|
+
background: '#0a2218',
|
|
60
|
+
border: '#2ea44f',
|
|
61
|
+
highlight: { background: '#0d3320', border: '#3fb950' },
|
|
62
|
+
hover: { background: '#0d2a1a', border: '#3fb950' },
|
|
63
|
+
},
|
|
64
|
+
font: { size: 10, color: '#86efac', strokeWidth: 2, strokeColor: '#050810' },
|
|
65
|
+
borderWidth: 1.5,
|
|
66
|
+
},
|
|
67
|
+
'Scenario-fail': {
|
|
68
|
+
shape: 'box',
|
|
69
|
+
sizeBase: 10,
|
|
70
|
+
color: {
|
|
71
|
+
background: '#2d1214',
|
|
72
|
+
border: '#cf3939',
|
|
73
|
+
highlight: { background: '#3d1515', border: '#f85149' },
|
|
74
|
+
hover: { background: '#3a1416', border: '#f85149' },
|
|
75
|
+
},
|
|
76
|
+
font: { size: 10, color: '#fca5a5', strokeWidth: 2, strokeColor: '#050810' },
|
|
77
|
+
borderWidth: 1.5,
|
|
78
|
+
},
|
|
79
|
+
POM: {
|
|
80
|
+
shape: 'diamond',
|
|
81
|
+
sizeBase: 16,
|
|
82
|
+
color: {
|
|
83
|
+
background: '#2a1e0a',
|
|
84
|
+
border: '#c99a20',
|
|
85
|
+
highlight: { background: '#3d2c0d', border: '#e3b341' },
|
|
86
|
+
hover: { background: '#332410', border: '#e3b341' },
|
|
87
|
+
},
|
|
88
|
+
font: { size: 11, color: '#fde68a', strokeWidth: 2, strokeColor: '#050810' },
|
|
89
|
+
borderWidth: 2,
|
|
90
|
+
},
|
|
91
|
+
Area: {
|
|
92
|
+
shape: 'hexagon',
|
|
93
|
+
sizeBase: 14,
|
|
94
|
+
color: {
|
|
95
|
+
background: '#1a2035',
|
|
96
|
+
border: '#4b5563',
|
|
97
|
+
highlight: { background: '#232d47', border: '#6b7280' },
|
|
98
|
+
hover: { background: '#1e2840', border: '#6b7280' },
|
|
99
|
+
},
|
|
100
|
+
font: { size: 10, color: '#9ca3af', strokeWidth: 2, strokeColor: '#050810' },
|
|
101
|
+
borderWidth: 1.5,
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
var nodeData = data.nodes.map((n) => {
|
|
106
|
+
var styleKey = n.group === 'Scenario' && n.color === '#EF4444' ? 'Scenario-fail' : n.group;
|
|
107
|
+
var style = NODE_STYLES[styleKey] || {};
|
|
108
|
+
var mapped = Object.assign({}, n, {
|
|
109
|
+
label: trunc(n.label, 30),
|
|
110
|
+
shape: style.shape ?? n.shape,
|
|
111
|
+
size: (style.sizeBase ?? 12) + (n.size ?? 12) * 0.4,
|
|
112
|
+
color: style.color ?? n.color,
|
|
113
|
+
font: style.font,
|
|
114
|
+
borderWidth: style.borderWidth ?? 1.5,
|
|
115
|
+
shadow: { enabled: true, color: 'rgba(0,0,0,.6)', size: 10, x: 0, y: 3 },
|
|
116
|
+
margin: n.group === 'Scenario' ? 6 : undefined,
|
|
117
|
+
});
|
|
118
|
+
delete mapped.group;
|
|
119
|
+
return mapped;
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
// ── Edge enhancement ─────────────────────────────────
|
|
123
|
+
var edgeData = data.edges.map((e) => {
|
|
124
|
+
var isTests = e.label === 'tests';
|
|
125
|
+
return Object.assign({}, e, {
|
|
126
|
+
color: {
|
|
127
|
+
color: isTests ? '#1e3a6e' : '#1e2d3d',
|
|
128
|
+
highlight: isTests ? '#3b82f6' : '#60a5fa',
|
|
129
|
+
hover: isTests ? '#2563eb' : '#60a5fa',
|
|
130
|
+
opacity: 0.8,
|
|
131
|
+
},
|
|
132
|
+
width: isTests ? 1.5 : 1,
|
|
133
|
+
dashes: !isTests,
|
|
134
|
+
font: {
|
|
135
|
+
size: 8,
|
|
136
|
+
color: '#2d3f5f',
|
|
137
|
+
strokeWidth: 0,
|
|
138
|
+
align: 'middle',
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
var nodes = new vis.DataSet(nodeData);
|
|
144
|
+
var edges = new vis.DataSet(edgeData);
|
|
145
|
+
|
|
146
|
+
// ── Network init ─────────────────────────────────────
|
|
12
147
|
var network = new vis.Network(
|
|
13
148
|
container,
|
|
14
|
-
{ nodes
|
|
149
|
+
{ nodes, edges },
|
|
15
150
|
{
|
|
16
|
-
physics: {
|
|
17
|
-
|
|
151
|
+
physics: {
|
|
152
|
+
barnesHut: {
|
|
153
|
+
gravitationalConstant: -10000,
|
|
154
|
+
centralGravity: 0.15,
|
|
155
|
+
springLength: 160,
|
|
156
|
+
springConstant: 0.025,
|
|
157
|
+
damping: 0.18,
|
|
158
|
+
avoidOverlap: 0.5,
|
|
159
|
+
},
|
|
160
|
+
stabilization: { iterations: 400, updateInterval: 20 },
|
|
161
|
+
},
|
|
162
|
+
interaction: {
|
|
163
|
+
hover: true,
|
|
164
|
+
navigationButtons: false,
|
|
165
|
+
keyboard: { enabled: true, speed: { x: 10, y: 10, zoom: 0.05 } },
|
|
166
|
+
tooltipDelay: 200,
|
|
167
|
+
zoomSpeed: 0.8,
|
|
168
|
+
},
|
|
18
169
|
edges: {
|
|
19
|
-
smooth: { type: '
|
|
20
|
-
|
|
170
|
+
smooth: { type: 'curvedCW', forceDirection: 'none', roundness: 0.2 },
|
|
171
|
+
arrows: { to: { enabled: true, scaleFactor: 0.5, type: 'arrow' } },
|
|
172
|
+
selectionWidth: 2,
|
|
173
|
+
},
|
|
174
|
+
nodes: {
|
|
175
|
+
chosen: true,
|
|
21
176
|
},
|
|
22
|
-
nodes: { font: { size: 11, color: '#1F2937' } },
|
|
23
177
|
},
|
|
24
178
|
);
|
|
25
179
|
|
|
180
|
+
// ── Progress bar ─────────────────────────────────────
|
|
181
|
+
var progressBar = document.getElementById('progress-bar');
|
|
182
|
+
network.on('stabilizationProgress', (p) => {
|
|
183
|
+
progressBar.style.width = `${Math.round((p.iterations / p.total) * 100)}%`;
|
|
184
|
+
});
|
|
185
|
+
network.once('stabilizationIterationsDone', () => {
|
|
186
|
+
progressBar.style.width = '100%';
|
|
187
|
+
setTimeout(() => {
|
|
188
|
+
progressBar.style.transition = 'opacity .4s';
|
|
189
|
+
progressBar.style.opacity = '0';
|
|
190
|
+
}, 300);
|
|
191
|
+
network.fit({ animation: { duration: 500, easingFunction: 'easeInOutQuad' } });
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
// ── Side panel ───────────────────────────────────────
|
|
26
195
|
var sidepanel = document.getElementById('sidepanel');
|
|
27
196
|
var spTitle = document.getElementById('sp-title');
|
|
197
|
+
var spGroup = document.getElementById('sp-group');
|
|
28
198
|
var spDesc = document.getElementById('sp-desc');
|
|
29
199
|
var spActions = document.getElementById('sp-actions');
|
|
30
200
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
var
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
201
|
+
function showPanel(nodeId) {
|
|
202
|
+
var orig = data.nodes.find((n) => n.id === nodeId);
|
|
203
|
+
if (!orig) return;
|
|
204
|
+
|
|
205
|
+
var isFail = orig.group === 'Scenario' && orig.color === '#EF4444';
|
|
206
|
+
var badgeClass =
|
|
207
|
+
orig.group === 'Ticket'
|
|
208
|
+
? 'ticket'
|
|
209
|
+
: orig.group === 'POM'
|
|
210
|
+
? 'pom'
|
|
211
|
+
: isFail
|
|
212
|
+
? 'scenario-fail'
|
|
213
|
+
: 'scenario';
|
|
214
|
+
|
|
215
|
+
spGroup.className = `sp-group-badge ${badgeClass}`;
|
|
216
|
+
spGroup.textContent = isFail ? 'Scenario · fail' : orig.group;
|
|
217
|
+
spTitle.textContent = orig.title
|
|
218
|
+
? orig.title.replace(/^[A-Z]+-\d+\s*[—–-]\s*/, '')
|
|
219
|
+
: orig.label;
|
|
220
|
+
spDesc.textContent = orig.title || '';
|
|
40
221
|
spActions.innerHTML = '';
|
|
41
222
|
var btn = null;
|
|
42
|
-
|
|
223
|
+
|
|
224
|
+
if (orig.group === 'Ticket') {
|
|
43
225
|
btn = document.createElement('button');
|
|
44
|
-
btn.textContent =
|
|
226
|
+
btn.textContent = `Copy /xera-impact ${nodeId}`;
|
|
45
227
|
btn.onclick = () => {
|
|
46
228
|
navigator.clipboard?.writeText(`/xera-impact ${nodeId}`);
|
|
229
|
+
btn.textContent = '✓ Copied!';
|
|
230
|
+
btn.classList.add('copied');
|
|
231
|
+
setTimeout(() => {
|
|
232
|
+
btn.textContent = `Copy /xera-impact ${nodeId}`;
|
|
233
|
+
btn.classList.remove('copied');
|
|
234
|
+
}, 1800);
|
|
47
235
|
};
|
|
48
236
|
spActions.appendChild(btn);
|
|
49
237
|
}
|
|
238
|
+
|
|
50
239
|
sidepanel.classList.remove('hidden');
|
|
240
|
+
}
|
|
51
241
|
|
|
52
|
-
|
|
53
|
-
var
|
|
54
|
-
var
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
242
|
+
function dimOthers(nodeId) {
|
|
243
|
+
var hop1 = new Set(network.getConnectedNodes(nodeId));
|
|
244
|
+
var hop2 = new Set();
|
|
245
|
+
for (const id of hop1) {
|
|
246
|
+
for (const x of network.getConnectedNodes(id)) {
|
|
247
|
+
hop2.add(x);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
var keep = new Set([nodeId, ...hop1, ...hop2]);
|
|
251
|
+
for (const n of nodes.get()) {
|
|
252
|
+
nodes.update({ id: n.id, opacity: keep.has(n.id) ? 1 : 0.1 });
|
|
253
|
+
}
|
|
254
|
+
for (const e of edges.get()) {
|
|
255
|
+
const visible = keep.has(e.from) && keep.has(e.to);
|
|
256
|
+
edges.update({
|
|
257
|
+
id: e.id,
|
|
258
|
+
color: Object.assign({}, e.color, { opacity: visible ? 0.8 : 0.06 }),
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
}
|
|
64
262
|
|
|
65
|
-
|
|
66
|
-
nodes.
|
|
263
|
+
function resetView() {
|
|
264
|
+
for (const n of nodes.get()) {
|
|
67
265
|
nodes.update({ id: n.id, opacity: 1 });
|
|
68
|
-
}
|
|
266
|
+
}
|
|
267
|
+
for (const e of edges.get()) {
|
|
268
|
+
edges.update({ id: e.id, color: Object.assign({}, e.color, { opacity: 0.8 }) });
|
|
269
|
+
}
|
|
69
270
|
sidepanel.classList.add('hidden');
|
|
70
|
-
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
network.on('click', (params) => {
|
|
274
|
+
if (params.nodes.length === 0) {
|
|
275
|
+
resetView();
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
showPanel(params.nodes[0]);
|
|
279
|
+
dimOthers(params.nodes[0]);
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
// ── Controls ─────────────────────────────────────────
|
|
283
|
+
document.getElementById('reset-btn').onclick = () => {
|
|
284
|
+
resetView();
|
|
285
|
+
network.fit({ animation: { duration: 350, easingFunction: 'easeInOutQuad' } });
|
|
71
286
|
};
|
|
72
287
|
|
|
73
288
|
document.getElementById('search').oninput = (e) => {
|
|
74
|
-
|
|
289
|
+
const q = e.target.value.toLowerCase();
|
|
75
290
|
if (!q) {
|
|
76
|
-
|
|
77
|
-
nodes.update({ id: n.id, opacity: 1 });
|
|
78
|
-
});
|
|
291
|
+
resetView();
|
|
79
292
|
return;
|
|
80
293
|
}
|
|
81
|
-
nodes.
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
294
|
+
for (const n of nodes.get()) {
|
|
295
|
+
const orig = data.nodes.find((x) => x.id === n.id);
|
|
296
|
+
const hit =
|
|
297
|
+
String(n.id).toLowerCase().includes(q) ||
|
|
298
|
+
(orig?.label ?? '').toLowerCase().includes(q) ||
|
|
299
|
+
(orig?.title ?? '').toLowerCase().includes(q);
|
|
300
|
+
nodes.update({ id: n.id, opacity: hit ? 1 : 0.08 });
|
|
301
|
+
}
|
|
86
302
|
};
|
|
87
303
|
|
|
88
304
|
['filter-pass', 'filter-fail', 'filter-p0'].forEach((id) => {
|
|
89
305
|
document.getElementById(id).onchange = () => {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
nodes.
|
|
93
|
-
if (n.group !== 'Scenario')
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
306
|
+
const pass = document.getElementById('filter-pass').checked;
|
|
307
|
+
const fail = document.getElementById('filter-fail').checked;
|
|
308
|
+
for (const n of nodes.get()) {
|
|
309
|
+
if (n.group !== 'Scenario') continue;
|
|
310
|
+
const orig = data.nodes.find((x) => x.id === n.id);
|
|
311
|
+
const isPass = orig?.color === '#10B981';
|
|
312
|
+
const isFail = orig?.color === '#EF4444';
|
|
313
|
+
const hidden = (isPass && !pass) || (isFail && !fail);
|
|
314
|
+
nodes.update({ id: n.id, hidden });
|
|
315
|
+
}
|
|
99
316
|
};
|
|
100
317
|
});
|
|
101
318
|
})();
|