@popcorn245/cornfield 0.50.0 → 0.51.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.
Files changed (67) hide show
  1. package/explorer/camera-frame.js +82 -0
  2. package/explorer/camera.js +7 -73
  3. package/explorer/check-model.js +3 -44
  4. package/explorer/cloud-model.js +2 -101
  5. package/explorer/cloud-panel.js +107 -0
  6. package/explorer/css/review.css +2 -0
  7. package/explorer/engine/connection.js +4 -1
  8. package/explorer/engine/map-rect.js +97 -0
  9. package/explorer/engine/player.js +2 -1
  10. package/explorer/engine/proposal.js +28 -7
  11. package/explorer/engine/server-load.js +64 -0
  12. package/explorer/engine/sheets.js +4 -86
  13. package/explorer/engine/source-address.js +58 -0
  14. package/explorer/engine/source.js +16 -45
  15. package/explorer/engine/theme-sheet.js +23 -1
  16. package/explorer/engine/topology.js +1 -1
  17. package/explorer/focus-room.js +1 -7
  18. package/explorer/focusables.js +1 -1
  19. package/explorer/forge-panel.js +36 -2630
  20. package/explorer/index.html +15 -147
  21. package/explorer/instance-state.js +0 -7
  22. package/explorer/instance.js +19 -2
  23. package/explorer/layer-model.js +1 -1
  24. package/explorer/outage-model.js +6 -76
  25. package/explorer/outage-scenario.js +83 -0
  26. package/explorer/page-pieces.js +21 -2
  27. package/explorer/page.js +3 -3
  28. package/explorer/panels.js +1 -5
  29. package/explorer/pieces/layers.js +1 -0
  30. package/explorer/pieces/node-panel.js +19 -8
  31. package/explorer/pieces/proposal.js +9 -0
  32. package/explorer/pieces/review-source.js +84 -0
  33. package/explorer/pieces/review.js +145 -12
  34. package/explorer/pieces/scope.js +23 -54
  35. package/explorer/pieces/status.js +5 -1
  36. package/explorer/pieces/work-agent.js +211 -0
  37. package/explorer/pieces/work-common.js +88 -0
  38. package/explorer/pieces/work-confirm.js +169 -0
  39. package/explorer/pieces/work-data.js +178 -0
  40. package/explorer/pieces/work-deploys.js +104 -0
  41. package/explorer/pieces/work-events.js +285 -0
  42. package/explorer/pieces/work-issues.js +43 -0
  43. package/explorer/pieces/work-markup.js +155 -0
  44. package/explorer/pieces/work-notes.js +177 -0
  45. package/explorer/pieces/work-paint.js +312 -0
  46. package/explorer/pieces/work-prs.js +253 -0
  47. package/explorer/pieces/work-runs.js +387 -0
  48. package/explorer/pieces/work-specs.js +71 -0
  49. package/explorer/pieces/work-threads.js +309 -0
  50. package/explorer/pieces/work.js +285 -0
  51. package/explorer/proposal-marks.js +220 -0
  52. package/explorer/proposal-model.js +23 -211
  53. package/explorer/proposal.js +1 -2
  54. package/explorer/runs-map.js +108 -103
  55. package/explorer/runs-view.js +8 -6
  56. package/explorer/scenario.js +2 -1
  57. package/explorer/scene.js +2 -2
  58. package/explorer/selection-model.js +2 -42
  59. package/explorer/selection-view.js +1 -1
  60. package/explorer/selection-words.js +52 -0
  61. package/explorer/strings.js +1 -1
  62. package/explorer/verdict-paint.js +51 -0
  63. package/explorer/waiting-model.js +12 -12
  64. package/explorer/waiting-view.js +6 -6
  65. package/package.json +1 -1
  66. package/explorer/feedback.js +0 -15
  67. package/explorer/waiting-line.js +0 -14
@@ -6,21 +6,19 @@
6
6
  * activeSubgraph(selected, edges, opts) the lit set: the node and everything ONE edge away, of any kind (its parent and children
7
7
  * included); `throughChildren` adds the children's neighbours (the wider set every
8
8
  * selection lit before 0.35); `kind` keeps only the lines of that kind
9
- * linesByKind(subgraph) "Calls 12 · Reads 9 · Owns 4": the lit lines counted by kind, in a fixed order
10
9
  * countOffScreen(ids, camera, rect) how many of the lit nodes are outside the part of the map nothing covers
11
10
  * selectionCamera(node, lit, rect, opts) where the camera goes when a selection comes from search, a list, a link or the keyboard:
12
11
  * the node and its lit set framed if that fits at zoom 0.5 or closer, else the node
13
12
  * centred at zoom 1. A click on the map never asks for it (panels.js)
14
13
  *
14
+ * What the node panel says of it (`linesByKind`: "Calls 12 · Reads 9 · Owns 4", `farEnds`, `connectedLine`, `kindPanelWord`) is selection-words.js's.
15
+ *
15
16
  * An edge's `kind` is project data: it only ever selects a word from `KIND_WORDS` or is shown as escaped text; it never builds a
16
17
  * selector or a token name.
17
18
  */
18
19
 
19
20
  import { frameNodes } from './camera.js';
20
21
 
21
- /** The kinds a line is drawn as, in the order the panel lists them */
22
- export const LINE_KINDS = ['ownership', 'usage', 'flow', 'reads', 'writes', 'calls', 'triggers', 'delivers', 'runs-on', 'uses', 'extends'];
23
-
24
22
  /** The words for a kind: the panel's plural ("Calls 12"), and the word on a lit edge ("calls") */
25
23
  export const KIND_WORDS = Object.freeze({
26
24
  ownership: { panel: 'Owns', edge: 'owns' },
@@ -40,8 +38,6 @@ export const KIND_WORDS = Object.freeze({
40
38
  export const edgeKindOf = (e) => e.kind || (e.dashed ? 'usage' : 'ownership');
41
39
  export const edgeKeyOf = (e) => `${e.from}->${e.to}`;
42
40
 
43
- /** A kind's panel word; a kind this table does not know (a project's own) is shown as the text it is */
44
- export const kindPanelWord = (kind) => (Object.hasOwn(KIND_WORDS, kind) ? KIND_WORDS[kind].panel : String(kind));
45
41
  export const kindEdgeWord = (kind) => (Object.hasOwn(KIND_WORDS, kind) ? KIND_WORDS[kind].edge : String(kind));
46
42
 
47
43
  /**
@@ -75,37 +71,6 @@ export function activeSubgraph(selected, edges, { throughChildren = false, kind
75
71
  return { connectedNodeIds, connectedEdgeKeys, childIds, selectedId: id, edges: shown, kinds, kind: filter, throughChildren };
76
72
  }
77
73
 
78
- /**
79
- * The lit lines counted by kind, in LINE_KINDS order (a kind of the project's own after them, by name).
80
- * @param {NonNullable<ReturnType<typeof activeSubgraph>>} sub
81
- * @returns {{kind: string, count: number, word: string}[]}
82
- */
83
- export function linesByKind(sub) {
84
- const rank = (k) => { const i = LINE_KINDS.indexOf(k); return i < 0 ? LINE_KINDS.length : i; };
85
- return [...sub.kinds.entries()]
86
- .sort((a, b) => rank(a[0]) - rank(b[0]) || (a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0))
87
- .map(([kind, count]) => ({ kind, count, word: kindPanelWord(kind) }));
88
- }
89
-
90
- /**
91
- * The lit lines of one kind, as the node at their far end: { node id, whether the line leaves the selection }, in map order.
92
- * @param {NonNullable<ReturnType<typeof activeSubgraph>>} sub
93
- * @param {string} kind
94
- */
95
- export function farEnds(sub, kind) {
96
- const rows = [];
97
- const seen = new Set();
98
- for (const e of sub.edges) {
99
- if (edgeKindOf(e) !== kind) continue;
100
- const out = e.from === sub.selectedId;
101
- const other = out ? e.to : e.from;
102
- if (seen.has(other)) continue;
103
- seen.add(other);
104
- rows.push({ id: other, out });
105
- }
106
- return rows;
107
- }
108
-
109
74
  /** The screen point of a world point */
110
75
  const screenOf = (camera, n) => ({ x: camera.x + n.x * camera.zoom, y: camera.y + n.y * camera.zoom });
111
76
 
@@ -143,8 +108,3 @@ export function selectionCamera(node, lit, rect, { padding = 40 } = {}) {
143
108
  if (fit && fit.zoom >= FRAME_MIN_ZOOM) return { ...fit, framed: true };
144
109
  return { x: rect.x + rect.width / 2 - node.x * CENTRE_ZOOM, y: rect.y + rect.height / 2 - node.y * CENTRE_ZOOM, zoom: CENTRE_ZOOM, framed: false };
145
110
  }
146
-
147
- /** The words that say how much of a selection is in view: "27 connected · 9 off screen" */
148
- export function connectedLine(connected, off) {
149
- return off > 0 ? `${connected} connected · ${off} off screen` : `${connected} connected · all on screen`;
150
- }
@@ -5,7 +5,7 @@
5
5
  * lights, how many of them are off screen, and the camera that frames them. "Frame them" in the node panel and the `F` key call
6
6
  * `frameSelection`; a selection that comes from search, a list, a link or the keyboard calls it too (engine/selection.js), and a click on the map never does.
7
7
  */
8
- import { visibleMapRect } from './engine/sheets.js';
8
+ import { visibleMapRect } from './engine/map-rect.js';
9
9
  import { flyTo } from './engine/fly.js';
10
10
  import { countOffScreen, selectionCamera } from './selection-model.js';
11
11
 
@@ -0,0 +1,52 @@
1
+ /**
2
+ * @module explorer/selection-words
3
+ *
4
+ * What the node panel says of a selection (spec 0008 D6): the kinds of its lit lines in the panel's order (`LINE_KINDS`, `linesByKind`), a kind's
5
+ * panel word (`kindPanelWord`, from selection-model.js's `KIND_WORDS`), the node at the far end of each line (`farEnds`) and how much of it is in
6
+ * view (`connectedLine`). The selection itself and where the camera goes for it are selection-model.js's: a map alone does not carry the panel's
7
+ * words (the components' size budget, spec 0011 D11). Pure: no DOM, no state.
8
+ */
9
+
10
+ import { KIND_WORDS, edgeKindOf } from './selection-model.js';
11
+
12
+ /** The kinds a line is drawn as, in the order the panel lists them */
13
+ export const LINE_KINDS = ['ownership', 'usage', 'flow', 'reads', 'writes', 'calls', 'triggers', 'delivers', 'runs-on', 'uses', 'extends'];
14
+
15
+ /** A kind's panel word; a kind this table does not know (a project's own) is shown as the text it is */
16
+ export const kindPanelWord = (kind) => (Object.hasOwn(KIND_WORDS, kind) ? KIND_WORDS[kind].panel : String(kind));
17
+
18
+ /**
19
+ * The lit lines counted by kind, in LINE_KINDS order (a kind of the project's own after them, by name).
20
+ * @param {NonNullable<ReturnType<typeof activeSubgraph>>} sub
21
+ * @returns {{kind: string, count: number, word: string}[]}
22
+ */
23
+ export function linesByKind(sub) {
24
+ const rank = (k) => { const i = LINE_KINDS.indexOf(k); return i < 0 ? LINE_KINDS.length : i; };
25
+ return [...sub.kinds.entries()]
26
+ .sort((a, b) => rank(a[0]) - rank(b[0]) || (a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0))
27
+ .map(([kind, count]) => ({ kind, count, word: kindPanelWord(kind) }));
28
+ }
29
+
30
+ /**
31
+ * The lit lines of one kind, as the node at their far end: { node id, whether the line leaves the selection }, in map order.
32
+ * @param {NonNullable<ReturnType<typeof activeSubgraph>>} sub
33
+ * @param {string} kind
34
+ */
35
+ export function farEnds(sub, kind) {
36
+ const rows = [];
37
+ const seen = new Set();
38
+ for (const e of sub.edges) {
39
+ if (edgeKindOf(e) !== kind) continue;
40
+ const out = e.from === sub.selectedId;
41
+ const other = out ? e.to : e.from;
42
+ if (seen.has(other)) continue;
43
+ seen.add(other);
44
+ rows.push({ id: other, out });
45
+ }
46
+ return rows;
47
+ }
48
+
49
+ /** The words that say how much of a selection is in view: "27 connected · 9 off screen" */
50
+ export function connectedLine(connected, off) {
51
+ return off > 0 ? `${connected} connected · ${off} off screen` : `${connected} connected · all on screen`;
52
+ }
@@ -4,7 +4,7 @@
4
4
  * A bridge (spec 0011 D2, step 4): the words now live on the instance (`inst.strings`, read with `t(inst, key)` from engine/strings.js).
5
5
  * This file keeps the old names for the modules that are not yet on an instance, bound to the page's voice: `pageStrings`, the object the page
6
6
  * instance's `strings` is (state.js hands it over), so the two are one. It imports nothing of the page's state, because pure models read the words
7
- * through it (waiting-model.js) and the converted modules import those. It goes when the last caller (forge-panel.js, proposal.js, review.js,
7
+ * through it (waiting-model.js) and the converted modules import those. It goes when the last caller (proposal.js, review.js,
8
8
  * review-column.js, whatif.js, scenario-ui.js, runs-view.js, waiting-*.js, plugins.js) is converted.
9
9
  */
10
10
  import * as S from './engine/strings.js';
@@ -0,0 +1,51 @@
1
+ /**
2
+ * @module explorer/verdict-paint
3
+ *
4
+ * A checked step's verdict on the map (spec 0005): the colours (`VERDICT_COLOR`) and `paintVerdict(scene, scn)`, which scene.js calls on a built
5
+ * scene. The checks themselves (what a step asks, the batches, the words) are check-model.js's, which re-exports these: a map alone imports this
6
+ * module and does not carry them (the components' size budget, spec 0011 D11). Pure: no DOM, no state.
7
+ */
8
+
9
+ /**
10
+ * The colours a checked step is drawn in, on its node or its edge. The red is brighter than a `writes`
11
+ * edge's own (#f87171), so a refused write reads as refused, not as a write.
12
+ */
13
+ export const VERDICT_COLOR = { allowed: '#4ade80', refused: '#ff2d55', mismatch: '#fbbf24' };
14
+ const VERDICT_GLOW = 18;
15
+ const VERDICT_EDGE_WIDTH = 4.5;
16
+
17
+ /** Whether a drawn edge is the one a step names: same ends and kind (and flow); no kind = an ownership or usage link (scene.js's rule) */
18
+ function isStepEdge(drawn, step) {
19
+ if (drawn.from !== step.from || drawn.to !== step.to) return false;
20
+ if (!step.kind) return drawn.kind === 'ownership' || drawn.kind === 'usage';
21
+ return drawn.kind === step.kind && (!step.flow || drawn.key.split('|')[2] === step.flow);
22
+ }
23
+
24
+ /**
25
+ * Colours the current step of a playing scenario by its verdict, in a built scene (after
26
+ * `emphasiseScenario`): red refused, green allowed, amber when `expect` disagrees; a step that was not
27
+ * checked keeps its colours. A refused edge's packet stops halfway: the write does not go through.
28
+ * Changes only `color`, `glow`, `glowColor`, `width` and the packet: never `mark`.
29
+ * @param {object} scene
30
+ * @param {{ done?: boolean, current: { node?: string, edge?: object }, verdict?: Verdict }} scn the player's snapshot, with the verdict check.js put on it
31
+ */
32
+ export function paintVerdict(scene, scn) {
33
+ const v = scn && scn.verdict;
34
+ if (!v || scn.done) return;
35
+ const color = v.mismatch ? VERDICT_COLOR.mismatch : VERDICT_COLOR[v.state];
36
+ if (!color) return;
37
+ const { node, edge } = scn.current;
38
+ if (node !== undefined) {
39
+ const n = scene.nodes.find((x) => x.id === node);
40
+ if (n) { n.color = color; n.glow = Math.max(n.glow || 0, VERDICT_GLOW); }
41
+ } else if (edge) {
42
+ scene.edges.forEach((e) => {
43
+ if (!isStepEdge(e, edge)) return;
44
+ e.color = color;
45
+ e.glowColor = color;
46
+ e.glow = Math.max(e.glow || 0, VERDICT_GLOW);
47
+ e.width = Math.max(e.width || 0, VERDICT_EDGE_WIDTH);
48
+ if (e.packet) e.packet = v.state === 'refused' && !v.mismatch ? { ...e.packet, color, glowColor: color, speed: 0, phase: 0.5 } : { ...e.packet, glowColor: color };
49
+ });
50
+ }
51
+ }
@@ -36,26 +36,26 @@ export const RUN_GROUPS = Object.freeze([
36
36
  ]);
37
37
 
38
38
  /** The words of a Specs group's header (a repo may say them in its own voice: `strings`) */
39
- export function specGroupTitle(key) {
39
+ export function specGroupTitle(key, say = t) {
40
40
  switch (key) {
41
- case 'decide': return t('toDecide');
42
- case 'agent': return t('withAgent');
43
- case 'approved': return t('approvedGroup');
44
- default: return t('drafts');
41
+ case 'decide': return say('toDecide');
42
+ case 'agent': return say('withAgent');
43
+ case 'approved': return say('approvedGroup');
44
+ default: return say('drafts');
45
45
  }
46
46
  }
47
47
 
48
48
  /** The words of a Runs group's header */
49
- export function runGroupTitle(key) {
49
+ export function runGroupTitle(key, say = t) {
50
50
  switch (key) {
51
- case 'needs': return t('needsYou');
52
- case 'motion': return t('inMotion');
53
- default: return t('finished');
51
+ case 'needs': return say('needsYou');
52
+ case 'motion': return say('inMotion');
53
+ default: return say('finished');
54
54
  }
55
55
  }
56
56
 
57
57
  /** The words of the proposal bar's button that goes to the run waiting on the proposal */
58
- export const answerWord = () => t('answer');
58
+ export const answerWord = (say = t) => say('answer');
59
59
 
60
60
  /** Drafts past this many rows are collapsed behind their header (D3) */
61
61
  export const DRAFTS_OPEN_MAX = 10;
@@ -230,10 +230,10 @@ export function waiting({ specs, runs } = {}) {
230
230
  }
231
231
 
232
232
  /** "3 waiting on you" (the Work button's name, spoken: "Work, 3 waiting on you"), or '' when nothing waits */
233
- export const waitingWords = (n) => (n > 0 ? `${n} ${t('waitingOnYou')}` : '');
233
+ export const waitingWords = (n, say = t) => (n > 0 ? `${n} ${say('waitingOnYou')}` : '');
234
234
 
235
235
  /** The Work button's accessible name: its label, then what waits ("Work, 3 waiting on you") */
236
- export const workButtonName = (label, n) => (n > 0 ? `${label}, ${waitingWords(n)}` : label);
236
+ export const workButtonName = (label, n, say = t) => (n > 0 ? `${label}, ${waitingWords(n, say)}` : label);
237
237
 
238
238
  /** What a group's header says: "To decide · 2", or "To decide · 2 of 6" while a search narrows it */
239
239
  export const groupCountWords = (g) => (g.shown === g.total ? String(g.total) : `${g.shown} of ${g.total}`);
@@ -5,7 +5,7 @@
5
5
  * headings. Pure: no DOM, no clock of its own. Every word from the forge is escaped (a row's own markup is proposal-model.js `specRowHtml`).
6
6
  */
7
7
 
8
- import { escHtml } from './state.js';
8
+ import { escapeHtml as escHtml } from '../core/text.js';
9
9
  import { specRowHtml } from './proposal-model.js';
10
10
  import { specGroupTitle, runGroupTitle, groupCountWords } from './waiting-model.js';
11
11
 
@@ -13,12 +13,12 @@ import { specGroupTitle, runGroupTitle, groupCountWords } from './waiting-model.
13
13
  * The Specs tab's groups, each a heading with its count and its rows. Drafts past ten rows are folded behind a button on the header
14
14
  * (`draftsOpen` says whether the person opened it). With a search, a group's count reads "2 of 6".
15
15
  * @param {ReturnType<import('./waiting-model.js').specGroups>} groups
16
- * @param {{ current?: { slug: string, source: string } | null, nowMs?: number, draftsOpen?: boolean | null }} [opts]
16
+ * @param {{ current?: { slug: string, source: string } | null, nowMs?: number, draftsOpen?: boolean | null, say?: (key: string) => string }} [opts]
17
17
  */
18
- export function specGroupsHtml(groups, { current = null, nowMs = Date.now(), draftsOpen = null } = {}) {
18
+ export function specGroupsHtml(groups, { current = null, nowMs = Date.now(), draftsOpen = null, say } = {}) {
19
19
  return groups.map((g) => {
20
20
  const id = `spec-group-${g.key}`;
21
- const words = `${specGroupTitle(g.key)} · ${groupCountWords(g)}`;
21
+ const words = `${specGroupTitle(g.key, say)} · ${groupCountWords(g)}`;
22
22
  const foldable = g.key === 'drafts' && g.total > 10 && g.shown === g.total; // not while a search narrows it: then it is open
23
23
  const folded = foldable && (draftsOpen === null ? g.collapsed : !draftsOpen);
24
24
  const title = foldable
@@ -31,7 +31,7 @@ export function specGroupsHtml(groups, { current = null, nowMs = Date.now(), dra
31
31
  }
32
32
 
33
33
  /** The heading that starts a group of the Runs list: "Needs you · 1". It is an item of the flat list (a run's card is never moved into a section) */
34
- export function runGroupHeadingHtml(g) {
34
+ export function runGroupHeadingHtml(g, say) {
35
35
  const id = `run-group-${g.key}`;
36
- return `<li class="hx-run-heading" data-key="${id}" data-corn="run-group" data-group="${escHtml(g.key)}"><h4 class="hx-forge-gtitle" id="${id}">${escHtml(`${runGroupTitle(g.key)} · ${g.count}`)}</h4></li>`;
36
+ return `<li class="hx-run-heading" data-key="${id}" data-corn="run-group" data-group="${escHtml(g.key)}"><h4 class="hx-forge-gtitle" id="${id}">${escHtml(`${runGroupTitle(g.key, say)} · ${g.count}`)}</h4></li>`;
37
37
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@popcorn245/cornfield",
3
- "version": "0.50.0",
3
+ "version": "0.51.0",
4
4
  "description": "A self-hostable dev dashboard with the topology map at its centre: proposals on the map, scenarios, outages and what-if edits, for any repo.",
5
5
  "license": "MIT",
6
6
  "author": "popcorn245 (https://github.com/popcorn245)",
@@ -1,15 +0,0 @@
1
- /**
2
- * @module explorer/feedback
3
- *
4
- * A bridge (spec 0011 D2, step 4): the results of actions now live on the instance (engine/feedback.js). This file keeps the old names for the
5
- * modules that are not yet on an instance (forge-panel.js), bound to the page's instance. It goes when forge-panel.js is converted.
6
- */
7
- import { pageInstance } from './state.js';
8
- import * as F from './engine/feedback.js';
9
-
10
- export { RESULT_MS } from './engine/feedback.js';
11
- export const sayResult = (key, text, ok = true) => F.sayResult(pageInstance(), key, text, ok);
12
- export const resultOf = (key) => F.resultOf(pageInstance(), key);
13
- export const clearResult = (key) => F.clearResult(pageInstance(), key);
14
- export const showResultIn = (el, key) => F.showResultIn(pageInstance(), el, key);
15
- export const resetFeedbackForTests = () => F.resetFeedback(pageInstance());
@@ -1,14 +0,0 @@
1
- /**
2
- * @module explorer/waiting-line
3
- *
4
- * A bridge (spec 0011 D3, step 5): the one line under the proposal bar's buttons when a run is waiting on the open proposal (spec 0010 D2) is part of the
5
- * proposal's bar (pieces/proposal.js). This file keeps the old names for the Work panel, bound to the page's instance.
6
- */
7
-
8
- import { pageInstance } from './state.js';
9
- import { ensurePagePieces } from './page-pieces.js';
10
-
11
- /** Shows the line for `run` (the run waiting on the open proposal), or hides it for null; `key` is what the line is about (the proposal), so a run is said once for it */
12
- export function paintWaitingLine(run, key) { ensurePagePieces(); pageInstance().emit('proposal:waiting', { run, key }); }
13
- /** For tests: forget the line */
14
- export function resetWaitingLineForTests() { pageInstance().emit('proposal:waiting-reset'); }