yadflow 4.10.0 → 4.11.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/CHANGELOG.md +97 -0
- package/README.md +12 -3
- package/bin/commands.mjs +5 -1
- package/bin/yad.mjs +109 -15
- package/cli/agent-guard-worker.mjs +13 -0
- package/cli/agent-guard.mjs +1053 -57
- package/cli/agent-rules.mjs +34 -3
- package/cli/argv-flags.mjs +2 -2
- package/cli/brain/vendor/LICENSE-graphology-library.txt +21 -0
- package/cli/brain/vendor/LICENSE-graphology.txt +21 -0
- package/cli/brain/vendor/LICENSE-sigma.txt +12 -0
- package/cli/brain/vendor/graphology-library.min.js +2 -0
- package/cli/brain/vendor/graphology.umd.min.js +2 -0
- package/cli/brain/vendor/sigma.min.js +1369 -0
- package/cli/brain/view/app.js +382 -0
- package/cli/brain/view/index.html +63 -0
- package/cli/brain/view/live.css +228 -0
- package/cli/brain/view/live.html +110 -0
- package/cli/brain/view/live.js +884 -0
- package/cli/brain/view/style.css +141 -0
- package/cli/brain-about.mjs +206 -0
- package/cli/brain-activity.mjs +285 -0
- package/cli/brain-skills.mjs +118 -0
- package/cli/brain-vendor.mjs +71 -0
- package/cli/brain-view.mjs +344 -0
- package/cli/brain.mjs +810 -0
- package/cli/ci-check.mjs +3 -3
- package/cli/doctor.mjs +80 -13
- package/cli/epic-state.mjs +93 -1
- package/cli/epic.mjs +15 -3
- package/cli/errors.mjs +2 -1
- package/cli/find-product.mjs +69 -15
- package/cli/foundation-publish.mjs +256 -0
- package/cli/gate.mjs +29 -3
- package/cli/git-read.mjs +38 -0
- package/cli/guard-stream.mjs +409 -0
- package/cli/hook.mjs +59 -9
- package/cli/issues-act.mjs +57 -13
- package/cli/issues-write.mjs +19 -6
- package/cli/issues.mjs +62 -23
- package/cli/lib.mjs +37 -2
- package/cli/local-page.mjs +138 -0
- package/cli/machine.mjs +1 -1
- package/cli/manifest.mjs +50 -0
- package/cli/map/view/app.js +712 -0
- package/cli/map/view/index.html +50 -0
- package/cli/map/view/style.css +142 -0
- package/cli/map-view.mjs +186 -0
- package/cli/map.mjs +637 -0
- package/cli/members.mjs +9 -15
- package/cli/next.mjs +1 -1
- package/cli/openpr.mjs +2 -2
- package/cli/plan.mjs +125 -0
- package/cli/platform.mjs +5 -5
- package/cli/product-index.mjs +1 -1
- package/cli/protection.mjs +32 -0
- package/cli/reconcile.mjs +8 -2
- package/cli/report.mjs +9 -3
- package/cli/reports-dir.mjs +391 -0
- package/cli/reports.mjs +65 -0
- package/cli/run-checks.mjs +5 -2
- package/cli/scan.mjs +1 -1
- package/cli/setup.mjs +30 -5
- package/cli/standup.mjs +87 -71
- package/cli/status.mjs +6 -5
- package/cli/test-agents-file.mjs +614 -8
- package/cli/test-brain-activity.mjs +753 -0
- package/cli/test-brain-view.mjs +381 -0
- package/cli/test-brain.mjs +795 -0
- package/cli/test-guide.mjs +211 -0
- package/cli/test-machine.mjs +59 -0
- package/cli/test-map.mjs +615 -0
- package/cli/test-reports.mjs +382 -0
- package/cli/test-run-checks.mjs +4 -0
- package/cli/test-worktree.mjs +24 -3
- package/cli/toolbox-connect.mjs +21 -6
- package/cli/toolbox.mjs +59 -4
- package/cli/update-commit.mjs +101 -9
- package/cli/usage.mjs +8 -4
- package/package.json +8 -4
- package/skills/yad-architecture/SKILL.md +22 -4
- package/skills/yad-change/SKILL.md +3 -1
- package/skills/yad-change/references/triage.md +2 -0
- package/skills/yad-checks/SKILL.md +2 -0
- package/skills/yad-checks/references/check-gates.md +8 -5
- package/skills/yad-checks/templates/checks/build-test-lint.sh +7 -0
- package/skills/yad-checks/templates/checks/install-deps.sh +6 -0
- package/skills/yad-checks/templates/checks/package-manager.sh +42 -0
- package/skills/yad-checks/templates/github/yad-checks.yml +3 -2
- package/skills/yad-checks/templates/gitlab/yad-checks.gitlab-ci.yml +3 -2
- package/skills/yad-checks/templates/hooks/yad-activity.mjs +238 -0
- package/skills/yad-connect-repos/SKILL.md +14 -0
- package/skills/yad-discovery/SKILL.md +11 -0
- package/skills/yad-discovery/references/foundation-schema.md +11 -0
- package/skills/yad-docs/templates/app/package-lock.json +18 -10
- package/skills/yad-docs/templates/app/package.json +6 -1
- package/skills/yad-epic/SKILL.md +3 -0
- package/skills/yad-epic/references/state-schema.md +35 -1
- package/skills/yad-guide/SKILL.md +4 -4
- package/skills/yad-implement/SKILL.md +76 -15
- package/skills/yad-issues/SKILL.md +2 -1
- package/skills/yad-pr-template/templates/checks/pr-template.sh +8 -4
- package/skills/yad-pr-template/templates/checks/pr-title.sh +8 -4
- package/skills/yad-spec/SKILL.md +19 -0
- package/skills/yad-stories/SKILL.md +22 -4
- package/skills/yad-stories/references/story-schema.md +1 -1
|
@@ -0,0 +1,712 @@
|
|
|
1
|
+
// yad map (E181) — the progress map page. Ported from the progress-map prototype: the same layout, motion
|
|
2
|
+
// and marks. Added in the same language: initials badges, the People lens, waiting rings, what moved, the
|
|
3
|
+
// single-person note. Every label is set with textContent; the data is read, never run.
|
|
4
|
+
(function () {
|
|
5
|
+
'use strict';
|
|
6
|
+
var $ = function (id) { return document.getElementById(id); };
|
|
7
|
+
|
|
8
|
+
// ---- loading: the data baked into the file, or asked of the local server --------------------------
|
|
9
|
+
function key() { return new URLSearchParams(location.search).get('t') || ''; }
|
|
10
|
+
function load() {
|
|
11
|
+
var inline = document.getElementById('yad-map-data');
|
|
12
|
+
if (inline) { try { return Promise.resolve(JSON.parse(inline.textContent)); } catch { return Promise.resolve(null); } }
|
|
13
|
+
return fetch('map.json?t=' + encodeURIComponent(key()), { cache: 'no-store' }).then(function (r) { return r.ok ? r.json() : null; }).catch(function () { return null; });
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
var current = null; // the running build: { stop() }
|
|
17
|
+
function show(D) {
|
|
18
|
+
if (current) current.stop();
|
|
19
|
+
if (!D || !Array.isArray(D.epics)) { document.body.classList.add('nodata'); return; }
|
|
20
|
+
document.body.classList.remove('nodata');
|
|
21
|
+
current = build(D);
|
|
22
|
+
}
|
|
23
|
+
load().then(show);
|
|
24
|
+
// --live: the server says the record changed; read it again and draw the new picture in place.
|
|
25
|
+
if (!document.getElementById('yad-map-data') && window.EventSource) {
|
|
26
|
+
try {
|
|
27
|
+
var es = new EventSource('events?t=' + encodeURIComponent(key()));
|
|
28
|
+
es.addEventListener('status', function (ev) { try { if (JSON.parse(ev.data).live) $('live').hidden = false; } catch { /* ignore */ } });
|
|
29
|
+
es.addEventListener('rebuilt', function () { load().then(function (D) { if (D) show(D); }); });
|
|
30
|
+
es.onerror = function () { $('live').hidden = true; };
|
|
31
|
+
} catch { /* no live stream */ }
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function build(D) {
|
|
35
|
+
var ac = new AbortController(), on = { signal: ac.signal }, alive = true;
|
|
36
|
+
// ───────────────────────────────────────────────────────── constants ──
|
|
37
|
+
var VIS = {
|
|
38
|
+
live: { short: 'In Production', label: 'In Production', rgb: '57,135,229', glow: '120,180,255' },
|
|
39
|
+
merged: { short: 'Waiting for release', label: 'Merged, waiting for release', rgb: '213,81,129', glow: '255,140,180' },
|
|
40
|
+
unver: { short: 'Shipped, unchecked', label: 'Shipped — release can’t be checked here', rgb: '213,81,129', glow: '255,140,180' },
|
|
41
|
+
active: { short: 'In progress', label: 'In progress', rgb: '201,133,0', glow: '255,196,77' },
|
|
42
|
+
planned: { short: 'Not started', label: 'Not started', rgb: '147,160,191', glow: '147,160,191' },
|
|
43
|
+
idle: { short: 'Idle ' + D.staleDays + '+ days', label: 'Idle ' + D.staleDays + '+ days, never merged', rgb: '91,102,128', glow: '91,102,128' },
|
|
44
|
+
};
|
|
45
|
+
var ORDER = ['live', 'merged', 'unver', 'active', 'planned', 'idle'];
|
|
46
|
+
var HUES = ['63,111,216', '47,158,143', '138,92,214', '192,86,125', '185,133,43', '75,155,209', '110,154,60', '199,106,59'];
|
|
47
|
+
// CLUSTER_GAP grows when there are people to show: the owner and waiting badges sit on a pill's top edge.
|
|
48
|
+
var R_RING = 74, XI = 172, BOW = 54, RH = 19, CLUSTER_GAP = (D.people && D.people.length) ? 19 : 13, STEP = 14, SPOKE_MAX = 12;
|
|
49
|
+
function el(tag, cls, text) { var e = document.createElement(tag); if (cls) e.className = cls; if (text != null) e.textContent = text; return e; }
|
|
50
|
+
var fmtDate = function (d) { return d ? new Date(d).toLocaleDateString(undefined, { day: 'numeric', month: 'short', year: 'numeric' }) : '—'; };
|
|
51
|
+
var ago = function (d) { if (!d) return ''; var n = Math.floor((Date.now() - Date.parse(d)) / 864e5); return n <= 0 ? 'today' : n === 1 ? 'yesterday' : n < 60 ? n + ' days ago' : Math.round(n / 30) + ' months ago'; };
|
|
52
|
+
var clip = function (s, n) { s = String(s || ''); return s.length > n ? s.slice(0, n - 1) + '…' : s; };
|
|
53
|
+
var liveRepos = D.repos.filter(function (r) { return r.available; });
|
|
54
|
+
var mainRepo = D.repos.find(function (r) { return r.available && r.productionBranch; }) || liveRepos[0] || null;
|
|
55
|
+
var waitRepos = liveRepos.filter(function (r) { return r.waitingCommits != null; });
|
|
56
|
+
var waitingTotal = waitRepos.reduce(function (s, r) { return s + r.waitingCommits; }, 0);
|
|
57
|
+
var visOf = function (o) { return (o.state === 'merged' && o.verified === false) ? 'unver' : o.state; };
|
|
58
|
+
|
|
59
|
+
// People: by key. A role list for each item, read from its `roles`.
|
|
60
|
+
var P = new Map((D.people || []).map(function (p) { return [p.key, p]; }));
|
|
61
|
+
var nameOf = function (k) { var p = P.get(k); return p ? p.name : null; };
|
|
62
|
+
var waitBy = new Map(); // epic -> [{ step, person }]
|
|
63
|
+
(D.waiting || []).forEach(function (w) { if (!waitBy.has(w.epic)) waitBy.set(w.epic, []); waitBy.get(w.epic).push(w); });
|
|
64
|
+
var moved = new Map((D.moved || []).map(function (m) { return [m.id, m]; }));
|
|
65
|
+
var onePerson = new Set((D.notes && D.notes.onePerson) || []);
|
|
66
|
+
function personKeys(n) {
|
|
67
|
+
var r = n.ref.roles || {}, out = [];
|
|
68
|
+
if (n.kind === 'story') { if (r.owner) out.push(r.owner); }
|
|
69
|
+
else if (n.kind === 'task') { if (r.builder) out.push(r.builder); out.push.apply(out, r.reviewers || []); }
|
|
70
|
+
else if (n.kind === 'branch') { if (r.builder) out.push(r.builder); }
|
|
71
|
+
else if (n.kind === 'cluster' && n.clusterKind === 'epic') {
|
|
72
|
+
if (r.owner) out.push(r.owner);
|
|
73
|
+
(r.stepOwners || []).forEach(function (x) { out.push(x.person); });
|
|
74
|
+
(r.approvers || []).forEach(function (x) { out.push(x.person); });
|
|
75
|
+
(waitBy.get(n.ref.id) || []).forEach(function (w) { if (w.person) out.push(w.person); });
|
|
76
|
+
}
|
|
77
|
+
return out;
|
|
78
|
+
}
|
|
79
|
+
function rolesOf(n, k) {
|
|
80
|
+
var r = n.ref.roles || {}, out = [];
|
|
81
|
+
if (r.owner === k || (r.stepOwners || []).some(function (x) { return x.person === k; })) out.push('owner');
|
|
82
|
+
if (r.builder === k) out.push('builder');
|
|
83
|
+
if ((r.reviewers || []).indexOf(k) >= 0) out.push('reviewer');
|
|
84
|
+
if ((r.approvers || []).some(function (x) { return x.person === k; })) out.push('approver');
|
|
85
|
+
return out;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// ─────────────────────────────────────────────────────────── model ──
|
|
89
|
+
var nodes = [], clusters = [];
|
|
90
|
+
var taskBranch = new Set(D.tasks.map(function (t) { return t.repo + ':' + t.branch; }));
|
|
91
|
+
var storyIds = new Set(D.stories.map(function (s) { return s.id; }));
|
|
92
|
+
function bead(kind, ref) {
|
|
93
|
+
var label = kind === 'story' ? ref.short : kind === 'task' ? ref.task : ref.name;
|
|
94
|
+
var n = { kind: kind, ref: ref, label: label, state: ref.state, vis: visOf(ref), r: kind === 'story' ? 6.2 : kind === 'task' ? 3.9 : 4.3, lit: true, mid: kind + ':' + ref.id };
|
|
95
|
+
n.people = personKeys(n);
|
|
96
|
+
n.search = [label, ref.id, ref.title, ref.branch, ref.repo, ref.story].concat(n.people.map(nameOf)).filter(Boolean).join(' ').toLowerCase();
|
|
97
|
+
return n;
|
|
98
|
+
}
|
|
99
|
+
var pyramid = function (arr, w) { var out = []; arr.slice().sort(function (a, b) { return w(b) - w(a); }).forEach(function (x, i) { if (i % 2) out.unshift(x); else out.push(x); }); return out; };
|
|
100
|
+
|
|
101
|
+
var groupClusters = [];
|
|
102
|
+
D.groups.forEach(function (g) {
|
|
103
|
+
var mine = D.branches.filter(function (b) { return b.group === g.id; })
|
|
104
|
+
.sort(function (a, b) { return ORDER.indexOf(a.state) - ORDER.indexOf(b.state) || String(b.date).localeCompare(String(a.date)); });
|
|
105
|
+
if (!mine.length) return;
|
|
106
|
+
var h = { kind: 'cluster', clusterKind: 'group', ref: g, label: g.label, state: null, vis: null, spokes: [], lit: true, people: [], mid: 'group:' + g.id };
|
|
107
|
+
var rows = Math.ceil(mine.length / SPOKE_MAX), per = Math.ceil(mine.length / rows);
|
|
108
|
+
for (var i = 0; i < mine.length; i += per) h.spokes.push(mine.slice(i, i + per).map(function (b) { return bead('branch', b); }));
|
|
109
|
+
h.search = g.label.toLowerCase();
|
|
110
|
+
groupClusters.push(h);
|
|
111
|
+
});
|
|
112
|
+
var epicClusters = [];
|
|
113
|
+
D.epics.forEach(function (e) {
|
|
114
|
+
var h = { kind: 'cluster', clusterKind: 'epic', ref: e, label: clip(e.label, 26), state: e.state, vis: e.state, spokes: [], lit: true, mid: 'epic:' + e.id };
|
|
115
|
+
D.stories.filter(function (x) { return x.epic === e.id; }).forEach(function (s) {
|
|
116
|
+
var row = [bead('story', s)];
|
|
117
|
+
D.tasks.filter(function (x) { return x.story === s.id; }).forEach(function (t) { row.push(bead('task', t)); });
|
|
118
|
+
D.branches.filter(function (x) { return x.story === s.id && !taskBranch.has(x.id); }).forEach(function (b) { row.push(bead('branch', b)); });
|
|
119
|
+
h.spokes.push(row);
|
|
120
|
+
});
|
|
121
|
+
var loose = D.branches.filter(function (b) { return b.epic === e.id && !taskBranch.has(b.id) && !(b.story && storyIds.has(b.story)); });
|
|
122
|
+
if (loose.length) h.spokes.push(loose.map(function (b) { return bead('branch', b); }));
|
|
123
|
+
h.people = personKeys(h);
|
|
124
|
+
h.search = [e.id, e.label, e.title, e.type].concat(h.people.map(nameOf)).filter(Boolean).join(' ').toLowerCase();
|
|
125
|
+
var waits = waitBy.get(e.id) || [];
|
|
126
|
+
h.waitFor = waits.find(function (w) { return w.person; }) || null;
|
|
127
|
+
epicClusters.push(h);
|
|
128
|
+
});
|
|
129
|
+
var longest = function (h) { return h.spokes.reduce(function (m, s) { return Math.max(m, s.length); }, 0) * 10 + h.spokes.length; };
|
|
130
|
+
clusters.push.apply(clusters, groupClusters.concat(epicClusters));
|
|
131
|
+
|
|
132
|
+
// ────────────────────────────────────────────────────────── layout ──
|
|
133
|
+
function cubic(a, b, c, d, n) { var pts = []; for (var i = 0; i <= n; i++) { var t = i / n, m = 1 - t, k0 = m * m * m, k1 = 3 * m * m * t, k2 = 3 * m * t * t, k3 = t * t * t; pts.push({ x: k0 * a.x + k1 * b.x + k2 * c.x + k3 * d.x, y: k0 * a.y + k1 * b.y + k2 * c.y + k3 * d.y }); } return pts; }
|
|
134
|
+
function polyline(pts) { var cum = new Float32Array(pts.length); for (var i = 1; i < pts.length; i++) cum[i] = cum[i - 1] + Math.hypot(pts[i].x - pts[i - 1].x, pts[i].y - pts[i - 1].y); return { pts: pts, cum: cum, len: cum[cum.length - 1] || 0 }; }
|
|
135
|
+
var trace = function (p, pts) { pts.forEach(function (q, k) { if (k) p.lineTo(q.x, q.y); else p.moveTo(q.x, q.y); }); };
|
|
136
|
+
var clamp1 = function (v) { return Math.max(-1, Math.min(1, v)); };
|
|
137
|
+
|
|
138
|
+
var core = { kind: 'core', x: 0, y: 0, r: 30, lit: true, label: 'Production', search: 'production', people: [], mid: 'core' };
|
|
139
|
+
var ring = { kind: 'ring', x: 0, y: -R_RING, lit: true, label: 'Development', search: 'development', people: [], mid: 'ring' };
|
|
140
|
+
var mctx = document.createElement('canvas').getContext('2d');
|
|
141
|
+
var CLUSTER_FONT = '600 12px system-ui, -apple-system, "Segoe UI", sans-serif';
|
|
142
|
+
var bbox = { x0: -120, y0: -R_RING - 22, x1: 120, y1: R_RING + 30 };
|
|
143
|
+
(function layout() {
|
|
144
|
+
mctx.font = CLUSTER_FONT;
|
|
145
|
+
clusters.forEach(function (h) {
|
|
146
|
+
var all = [].concat.apply([], h.spokes);
|
|
147
|
+
h.counts = {}; all.forEach(function (b) { h.counts[b.vis] = (h.counts[b.vis] || 0) + 1; });
|
|
148
|
+
h.total = all.length; h.block = Math.max(h.spokes.length, 1) * RH; h.h = 26;
|
|
149
|
+
h.frac = h.clusterKind === 'epic' ? (h.ref.storyCount ? h.ref.storiesShipped + '/' + h.ref.storyCount : '') : (h.counts.live || 0) + '/' + h.total;
|
|
150
|
+
h.w = Math.ceil(mctx.measureText(h.label).width + (h.frac ? mctx.measureText(h.frac).width + 10 : 0) + 34);
|
|
151
|
+
});
|
|
152
|
+
var height = function (list) { return list.reduce(function (s, h) { return s + h.block + CLUSTER_GAP; }, -CLUSTER_GAP); };
|
|
153
|
+
var left = groupClusters.slice(), right = [];
|
|
154
|
+
epicClusters.slice().sort(function (a, b) { return b.block - a.block; }).forEach(function (e) { (height(right) <= height(left) ? right : left).push(e); });
|
|
155
|
+
var weight = function (h) { return (h.clusterKind === 'group' ? 1e4 : 0) + longest(h); };
|
|
156
|
+
var wings = [[-1, pyramid(left, weight)], [1, pyramid(right, weight)]];
|
|
157
|
+
var maxW = Math.max.apply(null, clusters.map(function (h) { return h.w; }).concat([80])), XB = XI + maxW + 48;
|
|
158
|
+
var Y = Math.max(height(left), height(right), 200) / 2;
|
|
159
|
+
wings.forEach(function (wing) {
|
|
160
|
+
var sg = wing[0], list = wing[1], y = -height(list) / 2;
|
|
161
|
+
list.forEach(function (h) {
|
|
162
|
+
h.side = sg; h.y = y + h.block / 2;
|
|
163
|
+
var xin = XI - BOW * Math.pow(h.y / Y, 2); h.x = sg * (xin + h.w / 2);
|
|
164
|
+
var al = clamp1(h.y / Y) * 1.15, rp = { x: sg * R_RING * Math.cos(al), y: R_RING * Math.sin(al) };
|
|
165
|
+
var p0 = { x: sg * xin, y: h.y };
|
|
166
|
+
var trunk = cubic(p0, { x: sg * (xin - (xin - R_RING) * 0.55), y: h.y }, { x: rp.x + sg * Math.cos(al) * 52, y: rp.y + Math.sin(al) * 52 }, rp, 26);
|
|
167
|
+
h.trunk = new Path2D(); trace(h.trunk, trunk); h.links = new Path2D();
|
|
168
|
+
var out = { x: sg * (xin + h.w), y: h.y };
|
|
169
|
+
h.spokes.forEach(function (sp, j) {
|
|
170
|
+
var yb = y + (j + 0.5) * RH, fan = clamp1(yb / Y) * 0.3, d = { x: sg * Math.cos(fan), y: Math.sin(fan) };
|
|
171
|
+
var base = { x: sg * (XB - BOW * 0.6 * Math.pow(yb / Y, 2)), y: yb }, mx = (base.x + out.x) / 2;
|
|
172
|
+
var toCluster = cubic(base, { x: mx, y: base.y }, { x: mx, y: out.y }, out, 16);
|
|
173
|
+
trace(h.links, toCluster);
|
|
174
|
+
sp.forEach(function (b, i) {
|
|
175
|
+
b.x = base.x + d.x * i * STEP; b.y = base.y + d.y * i * STEP; b.cluster = h; b.spoke = sp; b.idx = i; b.side = sg;
|
|
176
|
+
if (i) { h.links.moveTo(sp[i - 1].x, sp[i - 1].y); h.links.lineTo(b.x, b.y); }
|
|
177
|
+
var back = []; for (var k = i; k >= 0; k--) back.push({ x: sp[k].x, y: sp[k].y });
|
|
178
|
+
var toPill = back.concat(toCluster.slice(1));
|
|
179
|
+
b.clusterAt = polyline(toPill).len;
|
|
180
|
+
var pts = toPill.concat(trunk);
|
|
181
|
+
if (b.state === 'live') pts.push({ x: 0, y: 0 });
|
|
182
|
+
b.path = polyline(pts);
|
|
183
|
+
nodes.push(b);
|
|
184
|
+
bbox.x0 = Math.min(bbox.x0, b.x - 14); bbox.x1 = Math.max(bbox.x1, b.x + 14); bbox.y0 = Math.min(bbox.y0, b.y - 14); bbox.y1 = Math.max(bbox.y1, b.y + 14);
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
bbox.y0 = Math.min(bbox.y0, h.y - 26); bbox.y1 = Math.max(bbox.y1, h.y + 26);
|
|
188
|
+
bbox.x0 = Math.min(bbox.x0, h.x - h.w / 2 - 10); bbox.x1 = Math.max(bbox.x1, h.x + h.w / 2 + 10);
|
|
189
|
+
nodes.push(h);
|
|
190
|
+
y += h.block + CLUSTER_GAP;
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
nodes.push(core, ring);
|
|
194
|
+
})();
|
|
195
|
+
var beads = nodes.filter(function (n) { return n.path; });
|
|
196
|
+
|
|
197
|
+
// ───────────────────────────────────────────────────────── canvases ──
|
|
198
|
+
var bg = $('bg'), fx = $('fx'), bctx = bg.getContext('2d'), ctx = fx.getContext('2d');
|
|
199
|
+
var cam = { x: 0, y: 0, k: 1 };
|
|
200
|
+
var W = 0, H = 0, DPR = 1, userMoved = false, dirty = true;
|
|
201
|
+
var focus = null, pinned = null, filterVis = null, query = '', anyDim = false, lastT = 0, person = null, roleFilter = null;
|
|
202
|
+
function fit() {
|
|
203
|
+
var top = document.querySelector('header').offsetHeight - 10, bot = document.querySelector('footer').offsetHeight + 22, pad = 14;
|
|
204
|
+
var bw = bbox.x1 - bbox.x0, bh = bbox.y1 - bbox.y0, room = W - (pinned && W > 900 ? 360 : 0);
|
|
205
|
+
cam.k = Math.max(0.35, Math.min((room - pad * 2) / bw, (H - top - bot) / bh, 1.8));
|
|
206
|
+
cam.x = room / 2 - (bbox.x0 + bbox.x1) / 2 * cam.k;
|
|
207
|
+
cam.y = top + (H - top - bot) / 2 - (bbox.y0 + bbox.y1) / 2 * cam.k;
|
|
208
|
+
userMoved = false; dirty = true;
|
|
209
|
+
}
|
|
210
|
+
function resize() {
|
|
211
|
+
DPR = Math.min(2, window.devicePixelRatio || 1); W = window.innerWidth; H = window.innerHeight;
|
|
212
|
+
[bg, fx].forEach(function (c) { c.width = Math.round(W * DPR); c.height = Math.round(H * DPR); });
|
|
213
|
+
if (!userMoved) fit();
|
|
214
|
+
dirty = true; drawBg(lastT);
|
|
215
|
+
}
|
|
216
|
+
function zoomAt(sx, sy, f) {
|
|
217
|
+
var k = Math.max(0.35, Math.min(5, cam.k * f)), wx = (sx - cam.x) / cam.k, wy = (sy - cam.y) / cam.k;
|
|
218
|
+
cam.k = k; cam.x = sx - wx * k; cam.y = sy - wy * k; userMoved = true; dirty = true;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// ────────────────────────────────────────────────────── background ──
|
|
222
|
+
// A slow field of dotted lines riding a wave. Decoration only; it carries no data.
|
|
223
|
+
function drawBg(t) {
|
|
224
|
+
var w = bg.width, h = bg.height, b = bctx;
|
|
225
|
+
var g = b.createLinearGradient(0, 0, 0, h); g.addColorStop(0, '#030613'); g.addColorStop(1, '#050c22');
|
|
226
|
+
b.fillStyle = g; b.fillRect(0, 0, w, h);
|
|
227
|
+
var S = Math.max(w, h) * 0.62, cx = w / 2, cy = h * 0.54, ca = Math.cos(-0.42), sa = Math.sin(-0.42);
|
|
228
|
+
var LINES = 60, DOTS = 150, bk = [[], [], [], [], []];
|
|
229
|
+
for (var i = 0; i < LINES; i++) {
|
|
230
|
+
var u = (i / (LINES - 1) - 0.5) * 3.1;
|
|
231
|
+
for (var j = 0; j < DOTS; j++) {
|
|
232
|
+
var v = (j / (DOTS - 1) - 0.5) * 2.7;
|
|
233
|
+
var z = Math.sin(u * 2.6 + t * 0.30) * Math.cos(v * 3.4 - t * 0.22) * 0.55 + Math.sin((u + v) * 4.6 + t * 0.42) * 0.3 + Math.sin(u * 8.3 - v * 6.1 + t * 0.7) * 0.1;
|
|
234
|
+
var x = cx + (u * ca - v * sa) * S + z * 9 * DPR, y = cy + (u * sa + v * ca) * S * 0.5 - z * S * 0.045;
|
|
235
|
+
if (x < -4 || x > w + 4 || y < -4 || y > h + 4) continue;
|
|
236
|
+
bk[Math.max(0, Math.min(4, ((z + 0.95) / 1.9 * 5) | 0))].push(x, y);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
var cols = ['rgba(18,44,140,.30)', 'rgba(26,66,186,.42)', 'rgba(42,100,224,.56)', 'rgba(88,148,246,.72)', 'rgba(168,208,255,.88)'];
|
|
240
|
+
for (var k = 0; k < 5; k++) { b.fillStyle = cols[k]; var a = bk[k], sz = (1.05 + k * 0.22) * DPR; for (var n = 0; n < a.length; n += 2) b.fillRect(a[n], a[n + 1], sz, sz); }
|
|
241
|
+
var vx = cam.x * DPR, vy = cam.y * DPR, vr = Math.max(w, h) * 0.5;
|
|
242
|
+
var vg = b.createRadialGradient(vx, vy, 0, vx, vy, vr); vg.addColorStop(0, 'rgba(3,6,19,.9)'); vg.addColorStop(0.55, 'rgba(3,6,19,.62)'); vg.addColorStop(1, 'rgba(3,6,19,0)');
|
|
243
|
+
b.fillStyle = vg; b.fillRect(0, 0, w, h);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// ───────────────────────────────────────────────────────── particles ──
|
|
247
|
+
var parts = [], motes = [], coreEnergy = 0;
|
|
248
|
+
var flowing = beads.filter(function (b) { return b.state === 'live' || b.state === 'merged'; });
|
|
249
|
+
var PERIOD = Math.max(2.6, flowing.length * 7.5 / 620);
|
|
250
|
+
flowing.forEach(function (b) { b.next = Math.random() * PERIOD; });
|
|
251
|
+
beads.forEach(function (b) { if (b.state === 'active') { b.next = Math.random() * 5; for (var i = 0; i < 3; i++) motes.push({ b: b, a: Math.random() * 6.28, w: (0.7 + Math.random() * 0.9) * (i % 2 ? 1 : -1), r: b.r + 4 + Math.random() * 5, ph: Math.random() * 6.28 }); } });
|
|
252
|
+
clusters.forEach(function (h) { if (h.state === 'active' && !h.spokes.length) for (var i = 0; i < 4; i++) motes.push({ b: h, a: Math.random() * 6.28, w: 0.5 + Math.random() * 0.6, r: 0, ph: Math.random() * 6.28, pill: true }); });
|
|
253
|
+
var waitingDots = waitingTotal ? Math.min(150, 14 + waitingTotal * 7) : 0;
|
|
254
|
+
var swarm = Array.from({ length: waitingDots }, function () { return { a: Math.random() * 6.28, w: 0.22 + Math.random() * 0.3, r: R_RING + (Math.random() - 0.5) * 11 }; });
|
|
255
|
+
function spawn(b, attempt) {
|
|
256
|
+
parts.push({ b: b, s: 0, seg: 0, v: 46 + Math.random() * 34, off: (Math.random() - 0.5) * 5, ph: Math.random() * 6.28, phase: 0, x: b.x, y: b.y, px: b.x, py: b.y, life: 0,
|
|
257
|
+
end: attempt ? b.clusterAt * (0.35 + Math.random() * 0.35) : b.path.len, attempt: attempt });
|
|
258
|
+
}
|
|
259
|
+
function place(p) {
|
|
260
|
+
var pts = p.b.path.pts, cum = p.b.path.cum, i = p.seg;
|
|
261
|
+
while (i < pts.length - 2 && cum[i + 1] < p.s) i++;
|
|
262
|
+
p.seg = i;
|
|
263
|
+
var a = pts[i], c = pts[i + 1] || a, d = (cum[i + 1] - cum[i]) || 1, f = Math.min(1, Math.max(0, (p.s - cum[i]) / d));
|
|
264
|
+
var tx = (c.x - a.x) / d, ty = (c.y - a.y) / d, squeeze = Math.min(1, (p.end - p.s) / 60 + 0.15);
|
|
265
|
+
var o = (p.off + Math.sin(p.s * 0.045 + p.ph) * 1.6) * (p.b.state === 'live' ? squeeze : 1);
|
|
266
|
+
p.px = p.x; p.py = p.y; p.x = a.x + (c.x - a.x) * f - ty * o; p.y = a.y + (c.y - a.y) * f + tx * o;
|
|
267
|
+
}
|
|
268
|
+
function update(dt) {
|
|
269
|
+
flowing.forEach(function (b) { b.next -= dt; if (b.next <= 0) { b.next = PERIOD * (0.55 + Math.random() * 0.9); spawn(b, false); } });
|
|
270
|
+
beads.forEach(function (b) { if (b.state === 'active') { b.next -= dt; if (b.next <= 0) { b.next = 3.5 + Math.random() * 4; spawn(b, true); } } });
|
|
271
|
+
for (var i = parts.length - 1; i >= 0; i--) {
|
|
272
|
+
var p = parts[i]; p.life += dt;
|
|
273
|
+
if (p.phase === 0) {
|
|
274
|
+
p.s += p.v * dt * (p.attempt ? 0.55 : 1);
|
|
275
|
+
if (p.s >= p.end) {
|
|
276
|
+
if (p.attempt) { parts.splice(i, 1); continue; }
|
|
277
|
+
if (p.b.state === 'live') { coreEnergy = Math.min(1.5, coreEnergy + 0.07); parts.splice(i, 1); continue; }
|
|
278
|
+
p.phase = 1; p.a = Math.atan2(p.y, p.x); p.r = R_RING + (Math.random() - 0.5) * 11; p.t = 4 + Math.random() * 5; p.w = 0.5 + Math.random() * 0.45;
|
|
279
|
+
} else place(p);
|
|
280
|
+
} else {
|
|
281
|
+
p.t -= dt; p.a += p.w * dt; p.px = p.x; p.py = p.y; p.x = Math.cos(p.a) * p.r; p.y = Math.sin(p.a) * p.r;
|
|
282
|
+
if (p.t <= 0) parts.splice(i, 1);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
motes.forEach(function (m) { m.a += m.w * dt; });
|
|
286
|
+
swarm.forEach(function (s) { s.a += s.w * dt; });
|
|
287
|
+
coreEnergy *= Math.pow(0.25, dt);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// ───────────────────────────────────────────────────────── drawing ──
|
|
291
|
+
function touches(n) {
|
|
292
|
+
if (!person) return true;
|
|
293
|
+
if (!roleFilter) return (n.people || []).indexOf(person) >= 0;
|
|
294
|
+
return rolesOf(n, person).indexOf(roleFilter) >= 0 || (n.kind === 'cluster' && (waitBy.get(n.ref.id) || []).some(function (w) { return w.person === person && roleFilter === 'owner'; }));
|
|
295
|
+
}
|
|
296
|
+
function relight() {
|
|
297
|
+
var f = focus || pinned, q = query.trim().toLowerCase();
|
|
298
|
+
anyDim = !!(f || filterVis || q || person);
|
|
299
|
+
nodes.forEach(function (n) { n.lit = !anyDim; });
|
|
300
|
+
if (f) {
|
|
301
|
+
f.lit = true;
|
|
302
|
+
if (f.path) { f.cluster.lit = true; core.lit = true; ring.lit = true; f.spoke.forEach(function (b) { if (b.idx <= f.idx) b.lit = true; }); }
|
|
303
|
+
else if (f.kind === 'cluster') { [].concat.apply([], f.spokes).forEach(function (b) { b.lit = true; }); core.lit = ring.lit = true; }
|
|
304
|
+
else if (f.kind === 'core') { ring.lit = true; nodes.forEach(function (n) { if (n.state === 'live') n.lit = true; }); }
|
|
305
|
+
else if (f.kind === 'ring') { nodes.forEach(function (n) { if (n.state === 'merged') n.lit = true; }); }
|
|
306
|
+
} else if (anyDim) {
|
|
307
|
+
nodes.forEach(function (n) {
|
|
308
|
+
var plain = n.kind !== 'core' && n.kind !== 'ring';
|
|
309
|
+
n.lit = (!filterVis || n.vis === filterVis) && (!q || (n.search || '').indexOf(q) >= 0) && touches(n) && (plain || (!q && !filterVis && !person));
|
|
310
|
+
});
|
|
311
|
+
core.lit = ring.lit = true;
|
|
312
|
+
}
|
|
313
|
+
clusters.forEach(function (h) { h.anyLit = h.lit || h.spokes.some(function (s) { return s.some(function (b) { return b.lit; }); }); });
|
|
314
|
+
dirty = true;
|
|
315
|
+
}
|
|
316
|
+
var rgba = function (v, a) { return 'rgba(' + VIS[v].rgb + ',' + a + ')'; };
|
|
317
|
+
function pill(x, y, w, h) { var r = h / 2; ctx.beginPath(); ctx.moveTo(x - w / 2 + r, y - r); ctx.lineTo(x + w / 2 - r, y - r); ctx.arc(x + w / 2 - r, y, r, -Math.PI / 2, Math.PI / 2); ctx.lineTo(x - w / 2 + r, y + r); ctx.arc(x - w / 2 + r, y, r, Math.PI / 2, Math.PI * 1.5); ctx.closePath(); }
|
|
318
|
+
function dot(x, y, r) { ctx.beginPath(); ctx.arc(x, y, r, 0, 6.2832); }
|
|
319
|
+
// A person's badge: their colour, their initials in white; a dashed amber ring when a gate waits on them.
|
|
320
|
+
function badge(k, x, y, r, a, waits, t) {
|
|
321
|
+
var p = P.get(k); if (!p) return;
|
|
322
|
+
if (waits) {
|
|
323
|
+
var pulse = 0.55 + 0.45 * Math.sin(t * 2.4);
|
|
324
|
+
ctx.lineWidth = 1.3; ctx.setLineDash([2.2, 1.8]); ctx.strokeStyle = 'rgba(255,196,77,' + (pulse * a) + ')'; dot(x, y, r + 2.6); ctx.stroke(); ctx.setLineDash([]);
|
|
325
|
+
}
|
|
326
|
+
ctx.fillStyle = 'rgba(4,8,22,' + a + ')'; dot(x, y, r + 1.1); ctx.fill();
|
|
327
|
+
ctx.fillStyle = 'rgba(' + HUES[p.hue % HUES.length] + ',' + a + ')'; dot(x, y, r); ctx.fill();
|
|
328
|
+
if (person === k) { ctx.lineWidth = 1.2; ctx.strokeStyle = 'rgba(235,242,255,' + a + ')'; dot(x, y, r + 1.6); ctx.stroke(); }
|
|
329
|
+
ctx.fillStyle = 'rgba(255,255,255,' + a + ')'; ctx.font = '700 ' + (r * 0.95).toFixed(1) + 'px system-ui, -apple-system, "Segoe UI", sans-serif';
|
|
330
|
+
ctx.textAlign = 'center'; ctx.textBaseline = 'middle'; ctx.fillText(p.initials, x, y + 0.3);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
function draw(t) {
|
|
334
|
+
ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.clearRect(0, 0, fx.width, fx.height);
|
|
335
|
+
ctx.setTransform(DPR * cam.k, 0, 0, DPR * cam.k, DPR * cam.x, DPR * cam.y);
|
|
336
|
+
ctx.lineCap = 'round'; ctx.lineJoin = 'round';
|
|
337
|
+
|
|
338
|
+
clusters.forEach(function (h) {
|
|
339
|
+
var a = anyDim ? (h.anyLit ? 1 : 0.16) : 1, live = h.counts.live || 0, wait = (h.counts.merged || 0) + (h.counts.unver || 0);
|
|
340
|
+
ctx.lineWidth = 1; ctx.strokeStyle = 'rgba(130,165,255,' + (0.2 * a) + ')'; ctx.stroke(h.links);
|
|
341
|
+
var share = h.total ? (live + wait) / h.total : 0, v = live >= wait && live ? 'live' : wait ? 'merged' : null;
|
|
342
|
+
ctx.lineWidth = 1.2 + Math.min(3.2, Math.log2(1 + live + wait) * 0.55);
|
|
343
|
+
ctx.strokeStyle = v ? rgba(v, (0.12 + 0.3 * share) * a) : 'rgba(130,165,255,' + (0.14 * a) + ')'; ctx.stroke(h.trunk);
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
var pulse = 1 + Math.sin(t * 1.4) * 0.04 + coreEnergy * 0.12;
|
|
347
|
+
ctx.lineWidth = 1.2; ctx.strokeStyle = 'rgba(150,180,255,' + (ring.lit ? 0.42 : 0.15) + ')'; dot(0, 0, R_RING); ctx.stroke();
|
|
348
|
+
ctx.lineWidth = 9; ctx.strokeStyle = 'rgba(120,150,255,' + (ring.lit ? 0.06 : 0.02) + ')'; dot(0, 0, R_RING); ctx.stroke();
|
|
349
|
+
var cg = ctx.createRadialGradient(0, 0, 0, 0, 0, 68 * pulse);
|
|
350
|
+
cg.addColorStop(0, 'rgba(235,245,255,' + (core.lit ? 1 : 0.4) + ')'); cg.addColorStop(0.22, 'rgba(120,180,255,' + (core.lit ? 0.95 : 0.3) + ')');
|
|
351
|
+
cg.addColorStop(0.5, 'rgba(57,135,229,.34)'); cg.addColorStop(1, 'rgba(57,135,229,0)');
|
|
352
|
+
ctx.fillStyle = cg; dot(0, 0, 68 * pulse); ctx.fill();
|
|
353
|
+
|
|
354
|
+
ctx.globalCompositeOperation = 'lighter';
|
|
355
|
+
['live', 'merged', 'active'].forEach(function (v) {
|
|
356
|
+
ctx.beginPath();
|
|
357
|
+
parts.forEach(function (p) { if (p.b.state !== v || (anyDim && !p.b.lit)) return; ctx.moveTo(p.px - (p.x - p.px) * 2.2, p.py - (p.y - p.py) * 2.2); ctx.lineTo(p.x, p.y); });
|
|
358
|
+
ctx.lineWidth = 1.5; ctx.strokeStyle = 'rgba(' + VIS[v].glow + ',' + (v === 'active' ? 0.5 : 0.78) + ')'; ctx.stroke();
|
|
359
|
+
ctx.fillStyle = 'rgba(' + VIS[v].glow + ',.95)'; ctx.beginPath();
|
|
360
|
+
parts.forEach(function (p) { if (p.b.state !== v || (anyDim && !p.b.lit)) return; ctx.moveTo(p.x + 1.3, p.y); ctx.arc(p.x, p.y, 1.3, 0, 6.2832); });
|
|
361
|
+
ctx.fill();
|
|
362
|
+
});
|
|
363
|
+
ctx.fillStyle = 'rgba(' + VIS.merged.glow + ',' + (ring.lit ? 0.8 : 0.25) + ')'; ctx.beginPath();
|
|
364
|
+
swarm.forEach(function (s) { var x = Math.cos(s.a) * s.r, y = Math.sin(s.a) * s.r; ctx.moveTo(x + 1.2, y); ctx.arc(x, y, 1.2, 0, 6.2832); });
|
|
365
|
+
ctx.fill();
|
|
366
|
+
ctx.fillStyle = 'rgba(' + VIS.active.glow + ',.85)'; ctx.beginPath();
|
|
367
|
+
motes.forEach(function (m) {
|
|
368
|
+
if (anyDim && !m.b.lit) return;
|
|
369
|
+
var rx = m.pill ? m.b.w / 2 + 5 : m.r + Math.sin(t * 1.3 + m.ph) * 1.6, ry = m.pill ? m.b.h / 2 + 5 : rx;
|
|
370
|
+
var x = m.b.x + Math.cos(m.a) * rx, y = m.b.y + Math.sin(m.a) * ry; ctx.moveTo(x + 1.1, y); ctx.arc(x, y, 1.1, 0, 6.2832);
|
|
371
|
+
});
|
|
372
|
+
ctx.fill();
|
|
373
|
+
ctx.globalCompositeOperation = 'source-over';
|
|
374
|
+
|
|
375
|
+
beads.forEach(function (n) {
|
|
376
|
+
var a = n.lit ? 1 : 0.16, v = n.vis, r = n.r;
|
|
377
|
+
if (n.kind === 'branch' && n.cluster.clusterKind === 'epic') {
|
|
378
|
+
ctx.beginPath(); ctx.moveTo(n.x, n.y - r - 1); ctx.lineTo(n.x + r + 1, n.y); ctx.lineTo(n.x, n.y + r + 1); ctx.lineTo(n.x - r - 1, n.y); ctx.closePath();
|
|
379
|
+
ctx.fillStyle = rgba(v, a); ctx.fill(); return;
|
|
380
|
+
}
|
|
381
|
+
if (v === 'live') { ctx.fillStyle = rgba(v, 0.2 * a); dot(n.x, n.y, r * 2.3); ctx.fill(); ctx.fillStyle = rgba(v, a); dot(n.x, n.y, r); ctx.fill(); ctx.fillStyle = 'rgba(215,232,255,' + (0.85 * a) + ')'; dot(n.x, n.y, r * 0.36); ctx.fill(); }
|
|
382
|
+
else if (v === 'merged') { ctx.fillStyle = rgba(v, a); dot(n.x, n.y, r); ctx.fill(); }
|
|
383
|
+
else if (v === 'unver') { ctx.lineWidth = 1.4; ctx.strokeStyle = rgba(v, a); dot(n.x, n.y, r - 0.6); ctx.stroke(); ctx.fillStyle = rgba(v, a); dot(n.x, n.y, Math.max(1.1, r * 0.38)); ctx.fill(); }
|
|
384
|
+
else if (v === 'active') { var kk = 0.5 + 0.5 * Math.sin(t * 2.2 + n.x); ctx.fillStyle = rgba(v, (0.16 + 0.14 * kk) * a); dot(n.x, n.y, r * (1.35 + 0.3 * kk) + 1.5); ctx.fill(); ctx.fillStyle = rgba(v, a); dot(n.x, n.y, r); ctx.fill(); }
|
|
385
|
+
else if (v === 'planned') { ctx.fillStyle = 'rgba(4,8,22,' + a + ')'; dot(n.x, n.y, r - 0.7); ctx.fill(); ctx.lineWidth = 1.4; ctx.strokeStyle = rgba(v, 0.9 * a); ctx.stroke(); }
|
|
386
|
+
else { ctx.fillStyle = rgba(v, a); dot(n.x, n.y, r * 0.72); ctx.fill(); }
|
|
387
|
+
});
|
|
388
|
+
// What moved since the last saved map: a white halo for the first seconds.
|
|
389
|
+
if (moved.size && t < 6) {
|
|
390
|
+
var fade = 1 - t / 6, ph = 0.5 + 0.5 * Math.sin(t * 5);
|
|
391
|
+
nodes.forEach(function (n) {
|
|
392
|
+
if (!moved.has(n.mid)) return;
|
|
393
|
+
ctx.lineWidth = 1.6; ctx.strokeStyle = 'rgba(255,255,255,' + (0.85 * fade * (0.5 + 0.5 * ph)) + ')';
|
|
394
|
+
if (n.path) { dot(n.x, n.y, n.r + 5 + ph * 2); ctx.stroke(); }
|
|
395
|
+
else if (n.kind === 'cluster') { pill(n.x, n.y, n.w + 8 + ph * 3, n.h + 8 + ph * 3); ctx.stroke(); }
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
var f = focus || pinned;
|
|
399
|
+
if (f && f.path) { ctx.lineWidth = 1.5; ctx.strokeStyle = 'rgba(235,242,255,.95)'; dot(f.x, f.y, f.r + 4); ctx.stroke(); }
|
|
400
|
+
|
|
401
|
+
ctx.font = '600 9.5px system-ui, -apple-system, "Segoe UI", sans-serif'; ctx.textBaseline = 'middle'; ctx.lineWidth = 3;
|
|
402
|
+
beads.forEach(function (n) {
|
|
403
|
+
if (n.kind !== 'story') return;
|
|
404
|
+
var a = n.lit ? 0.95 : 0.2, x = n.x - n.side * 11;
|
|
405
|
+
ctx.textAlign = n.side > 0 ? 'right' : 'left'; ctx.strokeStyle = 'rgba(4,8,22,' + a + ')'; ctx.strokeText(n.label, x, n.y + 0.5);
|
|
406
|
+
ctx.fillStyle = 'rgba(214,224,246,' + a + ')'; ctx.fillText(n.label, x, n.y + 0.5);
|
|
407
|
+
});
|
|
408
|
+
// Initials badges, once close enough to read: a story's owner on the bead's inner shoulder (the outer
|
|
409
|
+
// side is where its tasks and branches run, the story number sits further in).
|
|
410
|
+
var show = Math.max(0, Math.min(1, (cam.k - 0.7) / 0.2));
|
|
411
|
+
if (show > 0) beads.forEach(function (n) {
|
|
412
|
+
if (n.kind !== 'story' || !n.ref.roles || !n.ref.roles.owner) return;
|
|
413
|
+
badge(n.ref.roles.owner, n.x - n.side * 5.4, n.y - 5.6, 4.4, (n.lit ? 1 : 0.2) * show, false, t);
|
|
414
|
+
});
|
|
415
|
+
|
|
416
|
+
ctx.font = CLUSTER_FONT; ctx.textBaseline = 'middle';
|
|
417
|
+
clusters.forEach(function (h) {
|
|
418
|
+
var a = anyDim ? (h.anyLit ? 1 : 0.22) : 1, hot = f === h;
|
|
419
|
+
pill(h.x, h.y, h.w, h.h); ctx.fillStyle = 'rgba(7,13,34,' + (0.94 * a) + ')'; ctx.fill();
|
|
420
|
+
ctx.lineWidth = hot ? 2 : 1.2; ctx.strokeStyle = hot ? 'rgba(235,242,255,.95)' : h.vis ? rgba(h.vis, 0.95 * a) : 'rgba(150,180,255,' + (0.5 * a) + ')';
|
|
421
|
+
if (h.vis === 'planned') ctx.setLineDash([4, 3]); ctx.stroke(); ctx.setLineDash([]);
|
|
422
|
+
ctx.font = CLUSTER_FONT; ctx.textBaseline = 'middle';
|
|
423
|
+
ctx.textAlign = 'left'; ctx.fillStyle = 'rgba(234,240,255,' + a + ')'; ctx.fillText(h.label, h.x - h.w / 2 + 12, h.y + 0.5);
|
|
424
|
+
if (h.frac) { ctx.textAlign = 'right'; ctx.fillStyle = 'rgba(170,183,214,' + a + ')'; ctx.fillText(h.frac, h.x + h.w / 2 - 12, h.y + 0.5); }
|
|
425
|
+
if (h.total) {
|
|
426
|
+
var x = h.x - h.w / 2 + 12; var bw = h.w - 24, y = h.y + h.h / 2 + 4;
|
|
427
|
+
ORDER.forEach(function (v) { var c = h.counts[v]; if (!c) return; var w = Math.max(2.5, bw * c / h.total - 1.5); ctx.fillStyle = rgba(v, (v === 'planned' || v === 'idle' ? 0.55 : 0.95) * a); ctx.fillRect(x, y, w, 2.6); x += w + 1.5; });
|
|
428
|
+
}
|
|
429
|
+
if (h.clusterKind === 'epic' && show > 0) {
|
|
430
|
+
if (h.ref.roles && h.ref.roles.owner) badge(h.ref.roles.owner, h.x - h.w / 2 + 11, h.y - h.h / 2 - 1, 5.6, a * show, false, t);
|
|
431
|
+
if (h.waitFor) badge(h.waitFor.person, h.x + h.w / 2 - 11, h.y - h.h / 2 - 1, 5.6, a * show, true, t);
|
|
432
|
+
}
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
ctx.textAlign = 'center'; ctx.font = '700 10.5px system-ui, -apple-system, "Segoe UI", sans-serif';
|
|
436
|
+
ctx.fillStyle = 'rgba(234,240,255,' + (core.lit ? 0.96 : 0.4) + ')'; ctx.fillText('P R O D U C T I O N', 0, R_RING + 17);
|
|
437
|
+
ctx.font = '700 9.5px system-ui, -apple-system, "Segoe UI", sans-serif';
|
|
438
|
+
var rl = 'DEVELOPMENT' + (waitRepos.length ? ' · ' + waitingTotal + ' waiting' : '');
|
|
439
|
+
ring.w = ctx.measureText(rl).width + 20; ring.h = 18;
|
|
440
|
+
pill(ring.x, ring.y, ring.w, ring.h); ctx.fillStyle = 'rgba(7,13,34,.96)'; ctx.fill();
|
|
441
|
+
ctx.lineWidth = 1; ctx.strokeStyle = (focus || pinned) === ring ? 'rgba(235,242,255,.95)' : 'rgba(' + VIS.merged.rgb + ',' + (ring.lit ? 0.85 : 0.3) + ')'; ctx.stroke();
|
|
442
|
+
ctx.fillStyle = 'rgba(234,240,255,' + (ring.lit ? 0.95 : 0.4) + ')'; ctx.fillText(rl, ring.x, ring.y + 0.5);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
// ─────────────────────────────────────────────────────── describing ──
|
|
446
|
+
var stepWord = function (s) { return String(s || '').replace(/_/g, ' ').replace(/-/g, ' '); };
|
|
447
|
+
function describe(n) {
|
|
448
|
+
var d = { kind: '', title: '', vis: n.vis, stateText: '', desc: '', rows: [], who: [], note: '', notes: [], link: null, kids: [] };
|
|
449
|
+
var r = n.ref;
|
|
450
|
+
if (n.kind === 'core') {
|
|
451
|
+
d.kind = 'The goal'; d.title = 'Production'; d.vis = 'live'; d.stateText = 'What users get';
|
|
452
|
+
D.repos.filter(function (x) { return x.available && x.production; }).forEach(function (p) {
|
|
453
|
+
d.rows.push([p.name, 'branch “' + p.productionBranch + '”' + (p.productionGuessed ? ' (guessed — set map.production in product.json)' : '') + ', last updated ' + fmtDate(p.production.date) + ' (' + ago(p.production.date) + ')' + (nameOf(p.production.by) ? ' by ' + nameOf(p.production.by) : '')]);
|
|
454
|
+
});
|
|
455
|
+
var miss = D.repos.filter(function (x) { return !x.available; }).map(function (x) { return x.name; });
|
|
456
|
+
if (miss.length) d.note = 'Not on this machine, so not checked: ' + miss.join(', ') + '.';
|
|
457
|
+
d.kids = nodes.filter(function (x) { return x.path && x.state === 'live'; });
|
|
458
|
+
} else if (n.kind === 'ring') {
|
|
459
|
+
d.kind = 'The gate before Production'; d.title = 'Development'; d.vis = 'merged';
|
|
460
|
+
d.stateText = waitRepos.length ? waitingTotal + ' ' + (waitingTotal === 1 ? 'commit' : 'commits') + ' waiting for release' : 'Waiting room';
|
|
461
|
+
d.desc = 'Finished work lands here first. It reaches Production at the next release.';
|
|
462
|
+
D.repos.filter(function (x) { return x.available && x.integration; }).forEach(function (p) {
|
|
463
|
+
d.rows.push([p.name, 'branch “' + p.integrationBranch + '”' + (p.waitingCommits != null ? ', ' + p.waitingCommits + ' waiting' : '') + ', last change ' + fmtDate(p.integration.date) + ' (' + ago(p.integration.date) + ')' + (nameOf(p.integration.by) ? ' by ' + nameOf(p.integration.by) : '')]);
|
|
464
|
+
});
|
|
465
|
+
var direct = D.repos.filter(function (x) { return x.available && x.productionAhead; }).map(function (p) { return p.name + ' ' + p.productionAhead; });
|
|
466
|
+
if (direct.length) d.note = 'Production also holds commits that are not in Development (work merged straight to Production): ' + direct.join(', ') + '.';
|
|
467
|
+
d.kids = nodes.filter(function (x) { return x.path && x.state === 'merged'; });
|
|
468
|
+
} else if (n.kind === 'cluster' && n.clusterKind === 'epic') {
|
|
469
|
+
d.kind = 'Epic' + (r.type ? ' · ' + r.type : ''); d.title = r.id; d.stateText = r.stateLabel; d.desc = r.title || '';
|
|
470
|
+
var done = r.steps.filter(function (s) { return ['done', 'satisfied', 'skipped'].indexOf(s.status) >= 0; }).length;
|
|
471
|
+
d.rows.push(['Planning', r.steps.length ? done + ' of ' + r.steps.length + ' steps closed, now at “' + stepWord(r.currentStep) + '”' : '—']);
|
|
472
|
+
d.rows.push(['Stories', r.storyCount ? r.storiesShipped + ' of ' + r.storyCount + ' shipped' : 'none written yet']);
|
|
473
|
+
if (r.taskCount) d.rows.push(['Tasks shipped', String(r.taskCount)]);
|
|
474
|
+
if (r.repos && r.repos.length) d.rows.push(['Repos', r.repos.join(', ')]);
|
|
475
|
+
if (r.createdAt) d.rows.push(['Created', fmtDate(r.createdAt)]);
|
|
476
|
+
if (r.parent) d.rows.push(['Follows', r.parent]);
|
|
477
|
+
var ro = r.roles || {};
|
|
478
|
+
if (ro.owner) d.who.push(['Owner', [ro.owner]]);
|
|
479
|
+
var byStep = {};
|
|
480
|
+
(ro.stepOwners || []).forEach(function (x) { d.who.push(['Owns ' + stepWord(x.step), [x.person]]); });
|
|
481
|
+
(ro.approvers || []).forEach(function (x) { (byStep[x.step] = byStep[x.step] || []).push(x.person); });
|
|
482
|
+
Object.keys(byStep).forEach(function (s) { d.who.push(['Approved ' + stepWord(s).replace(/ review$/, ''), byStep[s]]); });
|
|
483
|
+
(waitBy.get(r.id) || []).forEach(function (w) { d.notes.push(['wait', 'Waiting for ' + (nameOf(w.person) || 'someone (no owner recorded)') + ' — ' + stepWord(w.step) + '.']); });
|
|
484
|
+
if (onePerson.has(r.id)) d.notes.push(['one', 'Every part of this epic so far is from one person.']);
|
|
485
|
+
if (!r.onMain) d.note = 'Still being written on branch “' + r.sourceBranch + '”; not in this checkout yet.';
|
|
486
|
+
d.kids = [].concat.apply([], n.spokes);
|
|
487
|
+
} else if (n.kind === 'cluster') {
|
|
488
|
+
d.kind = 'Branch group'; d.title = r.label; d.vis = null; d.desc = 'Branches that are not tied to an epic, grouped by their name.';
|
|
489
|
+
ORDER.forEach(function (v) { if (n.counts[v]) d.rows.push([VIS[v].label, String(n.counts[v])]); });
|
|
490
|
+
d.kids = [].concat.apply([], n.spokes);
|
|
491
|
+
} else if (n.kind === 'story') {
|
|
492
|
+
d.kind = 'Story'; d.title = r.id; d.stateText = r.stateLabel; d.desc = r.title || '';
|
|
493
|
+
if (r.roles && r.roles.owner) d.who.push(['Owner', [r.roles.owner]]);
|
|
494
|
+
if (r.repos.length) d.rows.push(['Repos', r.repos.join(', ')]);
|
|
495
|
+
Object.keys(r.build || {}).forEach(function (repo) { var b = r.build[repo]; var k = b.steps.filter(function (s) { return s.status === 'done'; }).length; d.rows.push(['Build · ' + repo, k + ' of ' + b.steps.length + ' steps done, at “' + stepWord(b.currentStep) + '”']); });
|
|
496
|
+
d.rows.push(['Tasks shipped', r.taskCount ? r.taskCount + ' (' + r.tasksLive + ' in Production)' : 'none yet']);
|
|
497
|
+
if (r.state === 'merged' && r.verified === false) d.note = 'Some of its code lives in a repo that is not on this machine, so Production could not be checked.';
|
|
498
|
+
d.kids = n.spoke.filter(function (b) { return b !== n; });
|
|
499
|
+
} else if (n.kind === 'task') {
|
|
500
|
+
d.kind = 'Task'; d.title = r.story + ' · ' + r.task;
|
|
501
|
+
d.stateText = r.state === 'live' ? (r.via ? 'In Production (delivered on its own branch)' : 'Shipped and in Production') : r.verified ? 'Shipped, waiting in Development for release' : 'Shipped (per yadflow record)';
|
|
502
|
+
d.rows.push(['Repo', r.repo]); if (r.branch) d.rows.push(['Branch', r.branch]);
|
|
503
|
+
if (r.shippedAt) d.rows.push(['Shipped', fmtDate(r.shippedAt) + ' (' + ago(r.shippedAt) + ')']);
|
|
504
|
+
if (r.roles && r.roles.builder) d.who.push(['Built by', [r.roles.builder]]);
|
|
505
|
+
if (r.roles && r.roles.reviewers.length) d.who.push(['Reviewed by', r.roles.reviewers]);
|
|
506
|
+
d.note = r.note || ''; if (/^https?:\/\//.test(r.pr || '')) d.link = { href: r.pr, text: 'Open the pull request' };
|
|
507
|
+
} else {
|
|
508
|
+
d.kind = 'Branch · ' + r.repo; d.title = r.name;
|
|
509
|
+
d.stateText = r.state === 'live' ? 'Merged into Production' : r.state === 'merged' ? 'Merged into Development, waiting for release'
|
|
510
|
+
: r.state === 'active' ? 'Not merged yet — ' + (r.ahead == null ? '?' : r.ahead) + ' ' + (r.ahead === 1 ? 'commit' : 'commits') + ' still to deliver' : 'Idle — no commits for ' + r.ageDays + ' days, never merged (' + (r.ahead == null ? '?' : r.ahead) + ' ' + (r.ahead === 1 ? 'commit' : 'commits') + ' left behind)';
|
|
511
|
+
d.rows.push(['Last commit', fmtDate(r.date) + ' (' + ago(r.date) + ')']);
|
|
512
|
+
if (r.roles && r.roles.builder) d.who.push(['Built by', [r.roles.builder]]);
|
|
513
|
+
if (r.epic) d.rows.push(['Epic', r.epic]);
|
|
514
|
+
}
|
|
515
|
+
var mv = moved.get(n.mid);
|
|
516
|
+
if (mv) d.notes.push(['one', mv.from ? 'Moved since ' + fmtDate(D.since) + ': ' + (VIS[mv.from] ? VIS[mv.from].short : mv.from) + ' → ' + (VIS[mv.to] ? VIS[mv.to].short : mv.to) + '.' : 'New since ' + fmtDate(D.since) + '.']);
|
|
517
|
+
return d;
|
|
518
|
+
}
|
|
519
|
+
function avatar(k) { var p = P.get(k); var a = el('span', 'av h' + (p ? p.hue % 8 : 0), p ? p.initials : '?'); a.setAttribute('aria-hidden', 'true'); return a; }
|
|
520
|
+
function fill(box, n, full) {
|
|
521
|
+
var d = describe(n); box.textContent = '';
|
|
522
|
+
box.append(el('div', 't-kind', d.kind), el('div', 't-title', d.title));
|
|
523
|
+
if (d.stateText) { var s = el('div', 't-state'); if (d.vis) s.append(el('span', 'mk ' + d.vis)); s.append(el('span', '', d.stateText)); box.append(s); }
|
|
524
|
+
if (d.desc) box.append(el('p', 't-desc', full ? d.desc : clip(d.desc, 150)));
|
|
525
|
+
if (d.rows.length || d.who.length) {
|
|
526
|
+
var dl = el('dl', 'rows');
|
|
527
|
+
d.who.forEach(function (w) { var dd = el('dd'); w[1].forEach(function (k) { var span = el('span', 'who'); span.append(avatar(k), el('span', '', nameOf(k) || '—')); dd.append(span); }); dl.append(el('dt', '', w[0]), dd); });
|
|
528
|
+
d.rows.forEach(function (row) { dl.append(el('dt', '', row[0]), el('dd', '', row[1])); });
|
|
529
|
+
box.append(dl);
|
|
530
|
+
}
|
|
531
|
+
if (d.note) box.append(el('p', 'note', d.note));
|
|
532
|
+
d.notes.forEach(function (x) { box.append(el('p', 'note ' + x[0], x[1])); });
|
|
533
|
+
if (!full) return;
|
|
534
|
+
if (d.link) { var p = el('p'), a = el('a', '', d.link.text); a.href = d.link.href; a.target = '_blank'; a.rel = 'noopener noreferrer'; p.append(a); box.append(p); }
|
|
535
|
+
if (d.kids.length) {
|
|
536
|
+
box.append(el('h2', '', 'Contains (' + d.kids.length + ')')); var ul = el('ul', 'kids');
|
|
537
|
+
d.kids.slice(0, 220).forEach(function (k) { var li = el('li'), b = el('button'); b.append(el('span', 'mk ' + k.vis), el('span', '', (k.kind === 'task' ? k.ref.story.replace(/^.*-(S\d+)$/, '$1') + ' ' : '') + k.label + (k.kind === 'story' && k.ref.title ? ' — ' + k.ref.title : ''))); b.title = describe(k).stateText; b.onclick = function () { pin(k); }; li.append(b); ul.append(li); });
|
|
538
|
+
box.append(ul);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
// ───────────────────────────────────────────────────── interaction ──
|
|
543
|
+
var tip = $('tip'), panel = $('panel');
|
|
544
|
+
function hit(sx, sy) {
|
|
545
|
+
var x = (sx - cam.x) / cam.k, y = (sy - cam.y) / cam.k, best = null, bd = Math.max(13, 11 / cam.k);
|
|
546
|
+
beads.forEach(function (n) { var dd = Math.hypot(n.x - x, n.y - y) - n.r; if (dd < bd) { bd = dd; best = n; } });
|
|
547
|
+
if (best && bd < 3) return best;
|
|
548
|
+
for (var i = 0; i < clusters.length; i++) { var h = clusters[i]; if (Math.abs(x - h.x) <= h.w / 2 + 2 && Math.abs(y - h.y) <= h.h / 2 + 4) return h; }
|
|
549
|
+
if (ring.w && Math.abs(x - ring.x) <= ring.w / 2 + 2 && Math.abs(y - ring.y) <= ring.h / 2 + 3) return ring;
|
|
550
|
+
if (best) return best;
|
|
551
|
+
if (Math.hypot(x, y) < 46 || (Math.abs(x) < 70 && Math.abs(y - R_RING - 17) < 9)) return core;
|
|
552
|
+
if (Math.abs(Math.hypot(x, y) - R_RING) < 7) return ring;
|
|
553
|
+
return null;
|
|
554
|
+
}
|
|
555
|
+
function showTip(n, sx, sy) {
|
|
556
|
+
if (!n) { tip.style.display = 'none'; return; }
|
|
557
|
+
fill(tip, n, false); tip.style.display = 'block';
|
|
558
|
+
var r = tip.getBoundingClientRect(), right = panel.style.display === 'block' ? 372 : 12;
|
|
559
|
+
tip.style.left = Math.max(8, Math.min(sx + 16, W - r.width - right)) + 'px';
|
|
560
|
+
tip.style.top = Math.max(8, sy + 18 + r.height > H - 8 ? sy - r.height - 14 : sy + 18) + 'px';
|
|
561
|
+
}
|
|
562
|
+
function pin(n) {
|
|
563
|
+
var was = !!pinned; pinned = n; panel.style.display = n ? 'block' : 'none';
|
|
564
|
+
if (was !== !!n && !userMoved) fit();
|
|
565
|
+
if (n) { fill(panel, n, true); var x = el('button', 'x', 'Close'); x.onclick = function () { pin(null); }; panel.prepend(x); panel.scrollTop = 0; }
|
|
566
|
+
relight();
|
|
567
|
+
}
|
|
568
|
+
var drag = null;
|
|
569
|
+
fx.addEventListener('pointerdown', function (e) { drag = { x: e.clientX, y: e.clientY, cx: cam.x, cy: cam.y, moved: false }; fx.setPointerCapture(e.pointerId); }, on);
|
|
570
|
+
fx.addEventListener('pointermove', function (e) {
|
|
571
|
+
if (drag) {
|
|
572
|
+
var dx = e.clientX - drag.x, dy = e.clientY - drag.y;
|
|
573
|
+
if (drag.moved || Math.hypot(dx, dy) > 4) { drag.moved = true; cam.x = drag.cx + dx; cam.y = drag.cy + dy; userMoved = true; dirty = true; fx.classList.add('drag'); showTip(null); }
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
576
|
+
var n = hit(e.clientX, e.clientY);
|
|
577
|
+
if (n !== focus) { focus = n; relight(); }
|
|
578
|
+
fx.classList.toggle('hot', !!n); showTip(n, e.clientX, e.clientY);
|
|
579
|
+
}, on);
|
|
580
|
+
fx.addEventListener('pointerup', function (e) { var d = drag; drag = null; fx.classList.remove('drag'); if (d && !d.moved) { focus = hit(e.clientX, e.clientY); pin(focus); showTip(null); } }, on);
|
|
581
|
+
fx.addEventListener('pointerleave', function () { if (!drag) { focus = null; relight(); showTip(null); } }, on);
|
|
582
|
+
fx.addEventListener('wheel', function (e) { e.preventDefault(); zoomAt(e.clientX, e.clientY, Math.exp(-e.deltaY * 0.0015)); showTip(null); }, { passive: false, signal: ac.signal });
|
|
583
|
+
fx.addEventListener('dblclick', fit, on);
|
|
584
|
+
$('bIn').addEventListener('click', function () { zoomAt(W / 2, H / 2, 1.3); }, on);
|
|
585
|
+
$('bOut').addEventListener('click', function () { zoomAt(W / 2, H / 2, 1 / 1.3); }, on);
|
|
586
|
+
$('bFit').addEventListener('click', fit, on);
|
|
587
|
+
var paused = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
588
|
+
var bPause = $('bPause');
|
|
589
|
+
var setPaused = function (p) { paused = p; bPause.setAttribute('aria-pressed', String(p)); bPause.textContent = p ? 'Play' : 'Pause'; };
|
|
590
|
+
bPause.addEventListener('click', function () { setPaused(!paused); }, on);
|
|
591
|
+
var q = $('q'); query = q.value;
|
|
592
|
+
q.addEventListener('input', function (e) { query = e.target.value; relight(); if (listOpen) renderList(); }, on);
|
|
593
|
+
window.addEventListener('keydown', function (e) { if (e.key === 'Escape') { if (listOpen) toggleList(false); else if (!$('people').hidden) togglePeople(false); else pin(null); } }, on);
|
|
594
|
+
window.addEventListener('resize', resize, on);
|
|
595
|
+
|
|
596
|
+
// ──────────────────────────────────────────────────── the People lens ──
|
|
597
|
+
var bPeople = $('bPeople'), pop = $('people'), plist = $('plist'), rolesBox = $('roles');
|
|
598
|
+
function togglePeople(open) { pop.hidden = !open; bPeople.setAttribute('aria-expanded', String(open)); }
|
|
599
|
+
bPeople.hidden = !(D.people && D.people.length);
|
|
600
|
+
bPeople.addEventListener('click', function () { togglePeople(pop.hidden); }, on);
|
|
601
|
+
$('pClear').addEventListener('click', function () { person = null; roleFilter = null; renderPeople(); relight(); }, on);
|
|
602
|
+
var ROLES = [['owner', 'Owner'], ['builder', 'Builder'], ['reviewer', 'Reviewer'], ['approver', 'Approver']];
|
|
603
|
+
function renderPeople() {
|
|
604
|
+
rolesBox.textContent = ''; plist.textContent = '';
|
|
605
|
+
ROLES.forEach(function (r) {
|
|
606
|
+
var b = el('button', '', r[1]); b.type = 'button'; b.setAttribute('aria-pressed', String(roleFilter === r[0]));
|
|
607
|
+
b.onclick = function () { roleFilter = roleFilter === r[0] ? null : r[0]; renderPeople(); relight(); };
|
|
608
|
+
rolesBox.append(b);
|
|
609
|
+
});
|
|
610
|
+
(D.people || []).filter(function (p) { return !roleFilter || p.roles.indexOf(roleFilter) >= 0; }).forEach(function (p) {
|
|
611
|
+
var li = el('li'), b = el('button'); b.type = 'button'; b.setAttribute('aria-pressed', String(person === p.key));
|
|
612
|
+
b.append(avatar(p.key), el('span', '', p.name + (p.ambiguous ? ' (matches more than one member)' : '')), el('span', 'role', p.roles.join(' · ')));
|
|
613
|
+
b.onclick = function () { person = person === p.key ? null : p.key; renderPeople(); relight(); };
|
|
614
|
+
li.append(b); plist.append(li);
|
|
615
|
+
});
|
|
616
|
+
}
|
|
617
|
+
renderPeople();
|
|
618
|
+
|
|
619
|
+
// ──────────────────────────────────────────────── header + legend ──
|
|
620
|
+
(function chrome() {
|
|
621
|
+
var when = function (d) { return d ? new Date(d).toLocaleString(undefined, { day: 'numeric', month: 'short', hour: '2-digit', minute: '2-digit' }) : 'unknown'; };
|
|
622
|
+
var name = D.product && D.product.name ? D.product.name : 'Product';
|
|
623
|
+
document.title = name + ' Progress Map';
|
|
624
|
+
$('title').textContent = name + ' · Road to Production';
|
|
625
|
+
var latest = liveRepos.map(function (r) { return r.fetchedAt; }).filter(Boolean).sort().pop() || (D.product && D.product.fetchedAt) || D.generatedAt;
|
|
626
|
+
$('asof').textContent = 'Hover for details · click to pin · data from ' + when(latest) + (D.product && D.product.behind ? ' · this checkout is ' + D.product.behind + ' behind origin' : '');
|
|
627
|
+
$('anon').hidden = !D.anonymous;
|
|
628
|
+
var mb = $('moved');
|
|
629
|
+
mb.hidden = !(D.moved && D.moved.length);
|
|
630
|
+
if (D.moved && D.moved.length) {
|
|
631
|
+
mb.textContent = D.moved.length + ' moved since ' + fmtDate(D.since);
|
|
632
|
+
mb.onclick = function () {
|
|
633
|
+
panel.style.display = 'block'; panel.textContent = '';
|
|
634
|
+
var x = el('button', 'x', 'Close'); x.onclick = function () { pin(null); };
|
|
635
|
+
panel.append(x, el('div', 't-kind', 'What moved'), el('div', 't-title', 'Since ' + fmtDate(D.since)));
|
|
636
|
+
var ul = el('ul', 'kids');
|
|
637
|
+
nodes.filter(function (n) { return moved.has(n.mid); }).forEach(function (n) { var li = el('li'), b = el('button'); b.append(el('span', 'mk ' + (n.vis || 'planned')), el('span', '', n.kind === 'cluster' ? n.ref.id : n.label + (n.kind === 'story' && n.ref.title ? ' — ' + n.ref.title : ''))); b.onclick = function () { pin(n); }; li.append(b); ul.append(li); });
|
|
638
|
+
panel.append(ul);
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
var tiles = $('tiles'); tiles.textContent = '';
|
|
642
|
+
var tile = function (k, v, small, s, segs) {
|
|
643
|
+
var t = el('div', 'tile glass'); t.append(el('div', 'k', k)); var vv = el('div', 'v', v); if (small) vv.append(' ', el('small', '', small)); t.append(vv);
|
|
644
|
+
if (segs) { var m = el('div', 'meter'); var tot = segs.reduce(function (a, x) { return a + x[1]; }, 0) || 1; segs.forEach(function (sg) { if (!sg[1]) return; var i = el('i'); i.style.flex = String(sg[1] / tot); i.style.background = 'rgb(' + VIS[sg[0]].rgb + ')'; i.title = VIS[sg[0]].label + ': ' + sg[1]; m.append(i); }); t.append(m); }
|
|
645
|
+
if (s) t.append(el('div', 's', s)); tiles.append(t);
|
|
646
|
+
};
|
|
647
|
+
var S = D.summary, cnt = function (list) { return ORDER.map(function (v) { return [v, list.filter(function (x) { return visOf(x) === v; }).length]; }); };
|
|
648
|
+
var WORD = { live: 'in Production', merged: 'waiting', unver: 'unchecked', active: 'in progress', planned: 'not started', idle: 'idle' };
|
|
649
|
+
var words = function (segs) { return segs.filter(function (x) { return x[1]; }).map(function (x) { return x[1] + ' ' + WORD[x[0]]; }).join(' · '); };
|
|
650
|
+
var segs = cnt(D.epics); tile('Epics', String(S.epics.total), '', words(segs), segs);
|
|
651
|
+
segs = cnt(D.stories); tile('Stories shipped', String(S.stories.shipped), 'of ' + S.stories.total, words(segs), segs);
|
|
652
|
+
segs = cnt(D.tasks); var tl = segs[0][1], un = D.tasks.filter(function (t) { return t.verified === false; }).length;
|
|
653
|
+
var gone = Array.from(new Set(D.tasks.filter(function (t) { return t.verified === false && !liveRepos.some(function (r) { return r.name === t.repo; }); }).map(function (t) { return t.repo; })));
|
|
654
|
+
tile('Shipped tasks in Production', String(tl), 'of ' + S.tasks.total, un ? (gone.length ? un + ' can’t be checked: ' + gone.join(', ') + ' isn’t on this machine' : un + ' can’t be checked yet (hover one to see why)') : words(segs), segs);
|
|
655
|
+
if (liveRepos.length) {
|
|
656
|
+
var one = liveRepos.length === 1; segs = cnt(D.branches);
|
|
657
|
+
var per = liveRepos.map(function (r) { var m = D.branches.filter(function (b) { return b.repo === r.name; }); return r.name + ' ' + m.filter(function (b) { return b.state === 'live'; }).length + '/' + m.length; }).join(' · ');
|
|
658
|
+
tile(one ? liveRepos[0].name + ' branches in Production' : 'Branches in Production', String(segs[0][1]), 'of ' + D.branches.length, one ? words(segs.slice(1)) : per, segs);
|
|
659
|
+
if (waitRepos.length) tile('Waiting in Development', String(waitingTotal), waitingTotal === 1 ? 'commit' : 'commits',
|
|
660
|
+
one ? (mainRepo && mainRepo.production ? 'Production last updated ' + fmtDate(mainRepo.production.date) : '') : waitRepos.map(function (r) { return r.name + ' ' + r.waitingCommits; }).join(' · '));
|
|
661
|
+
}
|
|
662
|
+
var lg = $('legend'); lg.textContent = '';
|
|
663
|
+
ORDER.forEach(function (v) {
|
|
664
|
+
var c = beads.filter(function (b) { return b.vis === v; }).length + clusters.filter(function (h) { return h.vis === v; }).length; if (!c) return;
|
|
665
|
+
var b = el('button'); b.setAttribute('aria-pressed', 'false'); b.title = VIS[v].label + ' — click to show only these';
|
|
666
|
+
b.append(el('span', 'mk ' + v), el('span', '', VIS[v].short), el('span', 'n', String(c)));
|
|
667
|
+
b.onclick = function () { filterVis = filterVis === v ? null : v; lg.querySelectorAll('button').forEach(function (x) { x.setAttribute('aria-pressed', String(x === b && !!filterVis)); }); relight(); if (listOpen) renderList(); };
|
|
668
|
+
lg.append(b);
|
|
669
|
+
});
|
|
670
|
+
})();
|
|
671
|
+
|
|
672
|
+
// ───────────────────────────────────────────────────────── list view ──
|
|
673
|
+
var listOpen = false, list = $('list');
|
|
674
|
+
function whoText(n) { return n.people.map(nameOf).filter(Boolean).filter(function (x, i, a) { return a.indexOf(x) === i; }).join(', '); }
|
|
675
|
+
function renderList() {
|
|
676
|
+
var qq = query.trim().toLowerCase(); list.textContent = '';
|
|
677
|
+
var bar = el('div', 'bar'), close = el('button', 'x', 'Back to map'); close.onclick = function () { toggleList(false); };
|
|
678
|
+
bar.append(el('h2', '', 'Everything on the map'), el('span', '', (filterVis ? VIS[filterVis].label + ' only. ' : '') + (qq ? 'Matching “' + qq + '”.' : '') + (person ? ' ' + nameOf(person) + ' only.' : '')), close); list.append(bar);
|
|
679
|
+
var tb = el('table'), hr = el('tr'); ['Item', 'Type', 'Status', 'Who', 'Last activity'].forEach(function (h) { hr.append(el('th', '', h)); }); tb.append(hr);
|
|
680
|
+
var shown = 0;
|
|
681
|
+
clusters.forEach(function (h) {
|
|
682
|
+
var rows = [].concat.apply([], h.spokes).filter(function (n) { return (!filterVis || n.vis === filterVis) && (!qq || n.search.indexOf(qq) >= 0 || h.search.indexOf(qq) >= 0) && touches(n); });
|
|
683
|
+
if (!rows.length && ((filterVis && h.vis !== filterVis) || (qq && h.search.indexOf(qq) < 0) || (person && !touches(h)))) return;
|
|
684
|
+
var dh = describe(h), tr = el('tr', 'cluster'), td = el('td'); if (h.vis) td.append(el('span', 'mk ' + h.vis)); td.append(h.clusterKind === 'epic' ? h.ref.id : h.label);
|
|
685
|
+
tr.append(td, el('td', '', dh.kind), el('td', '', dh.stateText || h.total + ' branches'), el('td', '', whoText(h)), el('td', '', h.ref.createdAt ? 'created ' + fmtDate(h.ref.createdAt) : '')); tb.append(tr);
|
|
686
|
+
rows.forEach(function (n) {
|
|
687
|
+
var d = describe(n), r = n.ref, row = el('tr'), c = el('td'); c.append(el('span', 'mk ' + n.vis), n.kind === 'story' ? r.id + ' — ' + clip(r.title || '', 90) : d.title);
|
|
688
|
+
var when = fmtDate(r.date || r.shippedAt);
|
|
689
|
+
row.append(c, el('td', '', d.kind.split(' · ')[0]), el('td', '', d.stateText), el('td', '', whoText(n)), el('td', '', when === '—' ? '' : when)); tb.append(row); shown++;
|
|
690
|
+
});
|
|
691
|
+
});
|
|
692
|
+
list.append(tb); if (!shown) list.append(el('p', '', 'Nothing matches.'));
|
|
693
|
+
}
|
|
694
|
+
function toggleList(o) { listOpen = o; list.style.display = o ? 'block' : 'none'; if (o) renderList(); }
|
|
695
|
+
$('bList').addEventListener('click', function () { toggleList(true); }, on);
|
|
696
|
+
|
|
697
|
+
// ───────────────────────────────────────────────────────────── loop ──
|
|
698
|
+
for (var i = 0; i < 420; i++) update(1 / 30);
|
|
699
|
+
setPaused(paused); resize(); relight();
|
|
700
|
+
var prev = performance.now(), frame = 0;
|
|
701
|
+
function tick(now) {
|
|
702
|
+
if (!alive) return;
|
|
703
|
+
var dt = Math.min(0.05, (now - prev) / 1000); prev = now;
|
|
704
|
+
if (!paused) { lastT += dt; update(dt); if (frame++ % 2 === 0) drawBg(lastT); draw(lastT); }
|
|
705
|
+
else if (dirty) { drawBg(lastT); draw(lastT); }
|
|
706
|
+
dirty = false; requestAnimationFrame(tick);
|
|
707
|
+
}
|
|
708
|
+
requestAnimationFrame(tick);
|
|
709
|
+
window.__map = { nodes: nodes, clusters: clusters, cam: cam, D: D };
|
|
710
|
+
return { stop: function () { alive = false; ac.abort(); pin(null); togglePeople(false); toggleList(false); } };
|
|
711
|
+
}
|
|
712
|
+
})();
|