@popcorn245/cornfield 0.48.0 → 0.50.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 (42) hide show
  1. package/core/strings.js +14 -0
  2. package/explorer/check.js +7 -227
  3. package/explorer/connection.js +3 -3
  4. package/explorer/css/review.css +49 -0
  5. package/explorer/decision-model.js +6 -0
  6. package/explorer/engine/checks.js +252 -0
  7. package/explorer/engine/connection.js +36 -0
  8. package/explorer/engine/layers.js +1 -0
  9. package/explorer/engine/layout.js +8 -3
  10. package/explorer/engine/player.js +489 -0
  11. package/explorer/engine/proposal.js +373 -0
  12. package/explorer/engine/render.js +1 -0
  13. package/explorer/engine/sheets.js +40 -7
  14. package/explorer/engine/source.js +315 -0
  15. package/explorer/engine/theme-sheet.js +444 -0
  16. package/explorer/engine/topology.js +126 -0
  17. package/explorer/index.html +6 -59
  18. package/explorer/instance.js +87 -7
  19. package/explorer/page-address.js +59 -0
  20. package/explorer/page-pieces.js +33 -5
  21. package/explorer/page.js +20 -20
  22. package/explorer/panels.js +1 -3
  23. package/explorer/pieces/changes.js +495 -0
  24. package/explorer/pieces/decision.js +664 -0
  25. package/explorer/pieces/layers.js +4 -0
  26. package/explorer/pieces/map.js +117 -25
  27. package/explorer/pieces/node-panel.js +34 -1
  28. package/explorer/pieces/proposal.js +488 -0
  29. package/explorer/pieces/review.js +280 -0
  30. package/explorer/pieces/scope-link.js +50 -0
  31. package/explorer/pieces/scope.js +247 -0
  32. package/explorer/pieces/status.css +24 -0
  33. package/explorer/pieces/status.js +144 -0
  34. package/explorer/plugins.js +0 -10
  35. package/explorer/proposal.js +64 -697
  36. package/explorer/review-column.js +24 -439
  37. package/explorer/review.js +27 -673
  38. package/explorer/scenario-ui.js +32 -478
  39. package/explorer/sheets.js +8 -7
  40. package/explorer/view.js +12 -64
  41. package/explorer/waiting-line.js +7 -50
  42. package/package.json +1 -1
package/explorer/view.js CHANGED
@@ -6,10 +6,11 @@
6
6
  */
7
7
 
8
8
  import { state, touchScene, pageInstance } from './state.js';
9
- import { computeDegreeCentrality, layoutOrbit, computeLaneLayout } from './layout.js';
9
+ import { computeDegreeCentrality } from './layout.js';
10
+ import { layoutMap } from './engine/topology.js';
10
11
  import { buildDataFlow } from './flows.js';
11
12
  import { render, fitGraphToViewport, fitPadding, ensureFlowLoop } from './render.js';
12
- import { orderAddedLast, pinLanes, placeAddedNodes } from './proposal-model.js';
13
+ import { orderAddedLast } from './proposal-model.js';
13
14
  import { renderLayerToggles } from './layers.js';
14
15
  import { clearScenario } from './scenario-ui.js';
15
16
  import { measureParams } from './bench.js';
@@ -17,6 +18,7 @@ import { mergeLive, placeLiveNodes } from './live-model.js';
17
18
  import { applyHouseLayout } from './house-model.js';
18
19
  import { syncHint } from './hint.js';
19
20
  import { ensurePagePieces } from './page-pieces.js';
21
+ import { TOPOLOGY_PATH, fetchTopology } from './engine/source.js';
20
22
 
21
23
  const $ = (id) => document.getElementById(id);
22
24
 
@@ -35,11 +37,8 @@ export async function loadTopology() {
35
37
  try {
36
38
  // /?fixture=5k measures on the generated topology (bench.js, core/fixture.js)
37
39
  const { fixtureUrl } = measureParams(window.location.search);
38
- const url = fixtureUrl || '/topology.json';
39
- const res = await fetch(url + (url.includes('?') ? '&v=' : '?v=') + Date.now());
40
- if (!res.ok) throw new Error(`GET ${url} answered ${res.status} ${res.statusText}`.trim());
41
- const data = await res.json();
42
- if (!Array.isArray(data.nodes) || data.nodes.length === 0) throw new Error(`${url} has no nodes`);
40
+ const url = fixtureUrl || TOPOLOGY_PATH;
41
+ const data = await fetchTopology(pageInstance(), url); // engine/source.js: the same read a scope makes, here of the page's own origin
43
42
  // The base stays as the file holds it; the map works on copies (the layout writes positions on them)
44
43
  state.baseNodes = data.nodes;
45
44
  state.baseEdges = Array.isArray(data.edges) ? data.edges : [];
@@ -82,64 +81,10 @@ export function setMap(nodes, edges) {
82
81
  renderLayerToggles();
83
82
  }
84
83
 
84
+ /** Where the nodes sit: the House view's plan here (house-model.js, PHY-11), every other view the engine's one layout (engine/topology.js `layoutMap`) */
85
85
  function applyLayout() {
86
- computeDegreeCentrality(); // node sizes: by degree on the full map ...
87
- if (state.view === 'house') { applyHouseLayout(state); return; } // the House view (house-model.js, PHY-11): the plan, its bands and tray
88
- if (state.view === 'dataflow') {
89
- state.flow.tiers.forEach((t) => t.nodes.forEach((n) => { n.r = Math.min(n.r, 13); })); // ... all small in the lanes
90
- if (!(state.proposal && laneLayoutAround())) computeLaneLayout(state.flow);
91
- } else if (state.proposal || state.nodes.some((n) => n.live)) {
92
- layoutOrbitAround(); // the code map keeps its places; what a proposal adds and the live layer are placed beside it
93
- } else {
94
- layoutOrbit();
95
- }
96
- }
97
-
98
- /**
99
- * The data-flow lanes while a proposal is open: the base map is laid out on its own and pinned, and
100
- * the added nodes take free cells (pinLanes). False when that cannot be done, and the lanes are laid out afresh.
101
- */
102
- function laneLayoutAround() {
103
- const applied = { nodes: state.nodes, edges: state.edges };
104
- const laid = state.baseNodes.map((n) => ({ ...n }));
105
- state.nodes = laid;
106
- state.edges = state.baseEdges;
107
- computeDegreeCentrality();
108
- const baseFlow = buildDataFlow(laid, state.baseEdges);
109
- baseFlow.tiers.forEach((t) => t.nodes.forEach((n) => { n.r = Math.min(n.r, 13); }));
110
- computeLaneLayout(baseFlow);
111
- state.nodes = applied.nodes;
112
- state.edges = applied.edges;
113
- const pinned = pinLanes(state.flow, baseFlow);
114
- touchScene();
115
- return pinned;
116
- }
117
-
118
- /**
119
- * The orbit layout while a proposal is open: the base map is laid out on its own, exactly as it is
120
- * with no proposal, and the nodes that were there keep those places and sizes; only the added ones
121
- * are placed, next to their parent (placeAddedNodes). So opening a proposal, switching between
122
- * Before, Diff and After, and closing it never move a node that was already on the map.
123
- */
124
- function layoutOrbitAround() {
125
- const applied = { nodes: state.nodes, edges: state.edges };
126
- const laid = state.baseNodes.map((n) => ({ ...n }));
127
- state.nodes = laid;
128
- state.edges = state.baseEdges;
129
- computeDegreeCentrality();
130
- layoutOrbit(); // also sets the rings
131
- const at = new Map(laid.map((n) => [n.id, n]));
132
-
133
- state.nodes = applied.nodes;
134
- state.edges = applied.edges;
135
- computeDegreeCentrality();
136
- state.nodes.forEach((n) => {
137
- const was = at.get(n.id);
138
- if (was) { n.x = was.x; n.y = was.y; n.r = was.r; }
139
- });
140
- placeAddedNodes(state.nodes, state.edges);
141
- placeLiveNodes(state.nodes, state.edges);
142
- touchScene();
86
+ if (state.view === 'house') { computeDegreeCentrality(); applyHouseLayout(state); return; }
87
+ layoutMap(pageInstance(), { placeLive: placeLiveNodes }); // the live layer is the page's (live-model.js): the engine places it with this
143
88
  }
144
89
 
145
90
  /** Switches between 'orbit' and 'dataflow'; the camera refits and the preset button follows */
@@ -167,3 +112,6 @@ export function syncViewUi() {
167
112
  pageInstance().emit('view', state.view); // the Layers chip dims while the data-flow view is on (pieces/layers.js)
168
113
  syncHint(); // the hint's words for this view and pointer, and whether it shows (hint.js)
169
114
  }
115
+
116
+ // The proposal asks the page to lay the map out again from the nodes and edges it hands over (engine/proposal.js): this module is not on an instance yet
117
+ pageInstance().on('map:set', ({ nodes, edges }) => { setMap(nodes, edges); return true; });
@@ -1,57 +1,14 @@
1
1
  /**
2
2
  * @module explorer/waiting-line
3
3
  *
4
- * The one line under the proposal bar's buttons when a run is waiting on the open proposal (spec 0010 D2): "A run is waiting on you: Plan
5
- * ready: approve to build, … · Answer". Answer opens Work on Runs at that run with its reply field focused (forge-panel.js). The line is its
6
- * own element, added after the bar's head once, so the bar's own markup is not touched. The runner's words are set as text, never as HTML.
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.
7
6
  */
8
7
 
9
- import { waitingLineWords } from './waiting-model.js';
10
- import { t } from './strings.js';
11
- import { announce } from './keyboard.js';
12
-
13
- let line = null;
14
- let saidFor = null;
15
-
16
- /** The line, made on first use and kept after the bar's head; null when the bar is not on the page */
17
- function mount() {
18
- const body = document.getElementById('proposal-body');
19
- if (!body) return null;
20
- if (line && line.isConnected) return line;
21
- line = document.createElement('p');
22
- line.className = 'hx-waiting-line';
23
- line.dataset.corn = 'waiting-line';
24
- line.dataset.cornState = 'waiting';
25
- line.hidden = true;
26
- line.innerHTML = '<span data-waiting-words></span> <button type="button" class="hx-btn hx-forge-act" data-waiting-answer data-peek-ok data-corn-kind="secondary"></button>';
27
- const head = body.querySelector('.hx-proposal-head');
28
- if (head) head.after(line); else body.append(line);
29
- return line;
30
- }
31
-
32
- /**
33
- * Shows the line for `run` (the run waiting on the open proposal), or hides it for null. The first time a run is shown for a proposal it is said
34
- * through the live region once; a repaint of the same run says nothing.
35
- * @param {{ runId: string, report?: { note?: string } | null } | null} run
36
- * @param {string | null} key what the line is about (the proposal), so a run is announced once for it
37
- */
38
- export function paintWaitingLine(run, key) {
39
- const el = mount();
40
- if (!el) return;
41
- el.hidden = !run;
42
- if (!run) { saidFor = null; return; }
43
- const words = waitingLineWords(run);
44
- el.querySelector('[data-waiting-words]').textContent = words;
45
- const button = el.querySelector('[data-waiting-answer]');
46
- button.textContent = t('answer');
47
- button.dataset.waitingAnswer = run.runId;
48
- button.setAttribute('aria-label', `${t('answer')}: ${words}`);
49
- const said = `${key}|${run.runId}`;
50
- if (saidFor !== said) { saidFor = said; announce(words); }
51
- }
8
+ import { pageInstance } from './state.js';
9
+ import { ensurePagePieces } from './page-pieces.js';
52
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 }); }
53
13
  /** For tests: forget the line */
54
- export function resetWaitingLineForTests() {
55
- line = null;
56
- saidFor = null;
57
- }
14
+ export function resetWaitingLineForTests() { pageInstance().emit('proposal:waiting-reset'); }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@popcorn245/cornfield",
3
- "version": "0.48.0",
3
+ "version": "0.50.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)",