@popcorn245/cornfield 0.40.0 → 0.42.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/core/contrast.js +1 -0
- package/core/map-tokens.js +3 -2
- package/core/strings.js +9 -0
- package/explorer/camera.js +1 -1
- package/explorer/cluster.js +26 -0
- package/explorer/decision-model.js +231 -0
- package/explorer/explorer.css +81 -6
- package/explorer/fly.js +48 -0
- package/explorer/forge-panel.js +28 -5
- package/explorer/index.html +18 -2
- package/explorer/input.js +16 -5
- package/explorer/keyboard.js +12 -22
- package/explorer/labels.js +239 -80
- package/explorer/layout.js +43 -15
- package/explorer/main.js +6 -25
- package/explorer/map-style.js +21 -8
- package/explorer/proposal-model.js +24 -0
- package/explorer/proposal.js +13 -6
- package/explorer/render.js +19 -1
- package/explorer/review-column.js +22 -4
- package/explorer/review.js +413 -44
- package/explorer/runs-model.js +1 -1
- package/explorer/scene.js +28 -36
- package/explorer/search-model.js +156 -0
- package/explorer/search-status.js +24 -13
- package/explorer/search.js +335 -0
- package/explorer/state.js +8 -0
- package/explorer/tokens.css +2 -0
- package/explorer/whatif.js +84 -7
- package/package.json +1 -1
- package/server/decision.js +117 -0
- package/server/proposal-pulls.js +1 -1
- package/server/proposals.js +58 -9
- package/server/server.js +19 -2
- package/server/submit-review.js +52 -7
package/explorer/index.html
CHANGED
|
@@ -118,7 +118,14 @@
|
|
|
118
118
|
<svg class="hx-search-icon" viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" aria-hidden="true" focusable="false"><circle cx="7" cy="7" r="4.5" /><path d="M10.5 10.5L14 14" /></svg>
|
|
119
119
|
<input type="text" id="node-search" class="hx-search-input" placeholder="Search..." data-corn-string-placeholder="searchPlaceholder" aria-label="Search nodes" aria-keyshortcuts="/" data-corn="search-input" />
|
|
120
120
|
<kbd class="hx-kbd" data-corn="search-key" aria-hidden="true">/</kbd>
|
|
121
|
+
<span id="search-steps" class="hx-search-steps" data-corn="search-steps" hidden>
|
|
122
|
+
<span id="search-count" class="hx-search-count" data-corn="search-count" aria-hidden="true"></span>
|
|
123
|
+
<button type="button" class="hx-search-btn" data-action="search-prev" aria-label="Previous match" title="Previous match (Shift+Enter)" data-corn-kind="icon"><svg viewBox="0 0 16 16" width="12" height="12" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M3.5 10.5L8 6l4.5 4.5" /></svg></button>
|
|
124
|
+
<button type="button" class="hx-search-btn" data-action="search-next" aria-label="Next match" title="Next match (Enter)" data-corn-kind="icon"><svg viewBox="0 0 16 16" width="12" height="12" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M3.5 5.5L8 10l4.5-4.5" /></svg></button>
|
|
125
|
+
<button type="button" class="hx-search-btn" data-action="clear-search" aria-label="Clear search" title="Clear search (Escape)" data-corn-kind="icon"><svg viewBox="0 0 16 16" width="12" height="12" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" aria-hidden="true" focusable="false"><path d="M4 4l8 8M12 4l-8 8" /></svg></button>
|
|
126
|
+
</span>
|
|
121
127
|
<div id="search-status" class="hx-search-status" role="status" aria-live="polite" data-corn="search-status"></div>
|
|
128
|
+
<div id="search-results" class="hx-search-results" data-corn="search-results" hidden></div>
|
|
122
129
|
</div>
|
|
123
130
|
|
|
124
131
|
<!-- The Work toggle (explorer/forge-panel.js): opens the Work panel; shown only when the config names a forge -->
|
|
@@ -126,6 +133,7 @@
|
|
|
126
133
|
<span data-corn-string="issuesAndPrs">Work</span>
|
|
127
134
|
<span id="forge-btn-lit" class="hx-forge-lit" data-corn="count" hidden></span>
|
|
128
135
|
<!-- What waits on you (explorer/waiting-model.js): specs to decide plus runs that need an answer; hidden at 0 and for anyone not signed in -->
|
|
136
|
+
<span id="forge-btn-dot" class="hx-runner-dot" aria-hidden="true" title="No runner online" hidden></span>
|
|
129
137
|
<span id="forge-btn-waiting" class="hx-waiting-badge" data-corn="waiting-badge" aria-hidden="true" hidden></span>
|
|
130
138
|
</button>
|
|
131
139
|
|
|
@@ -177,9 +185,15 @@
|
|
|
177
185
|
<!-- Mobile search bar -->
|
|
178
186
|
<div id="mobile-search-bar" class="hx-mobile-search glass-header" role="search" hidden data-corn="mobile-search">
|
|
179
187
|
<input type="text" id="mobile-node-search" class="hx-input hx-input--wide" placeholder="Search nodes, apps, components..." aria-label="Search nodes" data-corn="search-input" />
|
|
180
|
-
<button type="button" class="hx-textbtn" data-action="clear-search" aria-label="Clear search" data-corn-kind="quiet">✕</button>
|
|
181
188
|
<button type="button" class="hx-textbtn" data-action="close-mobile-search" data-corn-kind="quiet">Cancel</button>
|
|
189
|
+
<span id="mobile-search-steps" class="hx-search-steps" data-corn="search-steps" hidden>
|
|
190
|
+
<span id="mobile-search-count" class="hx-search-count" data-corn="search-count" aria-hidden="true"></span>
|
|
191
|
+
<button type="button" class="hx-search-btn" data-action="search-prev" aria-label="Previous match" title="Previous match (Shift+Enter)" data-corn-kind="icon"><svg viewBox="0 0 16 16" width="12" height="12" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M3.5 10.5L8 6l4.5 4.5" /></svg></button>
|
|
192
|
+
<button type="button" class="hx-search-btn" data-action="search-next" aria-label="Next match" title="Next match (Enter)" data-corn-kind="icon"><svg viewBox="0 0 16 16" width="12" height="12" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M3.5 5.5L8 10l4.5-4.5" /></svg></button>
|
|
193
|
+
<button type="button" class="hx-search-btn" data-action="clear-search" aria-label="Clear search" title="Clear search (Escape)" data-corn-kind="icon"><svg viewBox="0 0 16 16" width="12" height="12" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" aria-hidden="true" focusable="false"><path d="M4 4l8 8M12 4l-8 8" /></svg></button>
|
|
194
|
+
</span>
|
|
182
195
|
<div id="mobile-search-status" class="hx-search-status" role="status" aria-live="polite" data-corn="search-status"></div>
|
|
196
|
+
<div id="mobile-search-results" class="hx-search-results" data-corn="search-results" hidden></div>
|
|
183
197
|
</div>
|
|
184
198
|
|
|
185
199
|
<!-- The map -->
|
|
@@ -215,6 +229,8 @@
|
|
|
215
229
|
<button data-corn="compare-option" type="button" class="hx-seg-btn" data-action="proposal-view" data-view="after" aria-pressed="false" data-corn-string="after">After</button>
|
|
216
230
|
</div>
|
|
217
231
|
<div class="hx-proposal-tools">
|
|
232
|
+
<!-- Shown only while there are what-if edits: off, the map is the proposal as written; the edits are kept and still go with a review (whatif.js) -->
|
|
233
|
+
<button data-corn-kind="secondary" type="button" id="proposal-myedits" class="hx-btn" aria-pressed="true" data-peek-ok data-corn-string="myEdits" hidden>My edits</button>
|
|
218
234
|
<button data-corn-kind="secondary" type="button" id="proposal-edit" class="hx-btn" aria-expanded="false" aria-controls="whatif" title="Try a change: add a node or an edge, reword a scenario">Edit</button>
|
|
219
235
|
</div>
|
|
220
236
|
<div class="hx-proposal-more">
|
|
@@ -312,8 +328,8 @@
|
|
|
312
328
|
<!-- Agent runs (forge-panel.js, runs-model.js): shown on the Runs tab; each run's state, what it is about, links, and Stop -->
|
|
313
329
|
<section id="forge-runs" class="hx-forge-runs" aria-labelledby="forge-runs-title" hidden>
|
|
314
330
|
<h3 id="forge-runs-title" class="hx-forge-runs-title">Agent runs</h3>
|
|
315
|
-
<p id="forge-runs-status" class="hx-forge-meta hx-faint"></p>
|
|
316
331
|
<p id="forge-runs-runner" class="hx-forge-meta" hidden></p>
|
|
332
|
+
<p id="forge-runs-status" class="hx-forge-meta hx-faint"></p>
|
|
317
333
|
<p id="forge-runs-note" class="hx-forge-notice" hidden data-corn="notice"></p>
|
|
318
334
|
<p id="forge-runs-trigger" class="hx-forge-notice" hidden data-corn="notice"></p>
|
|
319
335
|
<div id="forge-runs-totals" data-corn="run-totals" role="group" aria-label="Tokens and cost the runners reported" hidden></div>
|
package/explorer/input.js
CHANGED
|
@@ -13,11 +13,14 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import { state, touchScene } from './state.js';
|
|
16
|
-
import { render, getSpatialIndex, queueFrameWork, screenToWorld, getMinZoom } from './render.js';
|
|
16
|
+
import { render, getSpatialIndex, queueFrameWork, screenToWorld, getMinZoom, setHoverNode, labelNodeAt, fitGraphToViewport, fitPadding } from './render.js';
|
|
17
|
+
import { clusterIds } from './cluster.js';
|
|
18
|
+
import { LANDMARK_TYPES } from './scene.js';
|
|
17
19
|
import { saveFreeformPositions } from './layout.js';
|
|
18
20
|
import { selectNode, closeDrawer } from './panels.js';
|
|
19
21
|
import { hitTestScreen } from './spatial.js';
|
|
20
22
|
import { zoomAbout, pinchStart, pinchCamera } from './camera.js';
|
|
23
|
+
import { stopFlight } from './fly.js';
|
|
21
24
|
|
|
22
25
|
let isDragging = false;
|
|
23
26
|
let dragNode = null;
|
|
@@ -71,6 +74,8 @@ function touchMid(e) {
|
|
|
71
74
|
|
|
72
75
|
function onPointerDown(e) {
|
|
73
76
|
downOnCanvas = true;
|
|
77
|
+
stopFlight(); // the hand takes the camera: a flight to a match ends where it is
|
|
78
|
+
setHoverNode(null); // a press starts a tap or a drag: the chip that named a node under the pointer goes
|
|
74
79
|
if (e.touches && e.touches.length === 2) {
|
|
75
80
|
pinch = pinchStart(state.camera, touchDistance(e), touchMid(e));
|
|
76
81
|
pendingPos = null;
|
|
@@ -124,7 +129,9 @@ function applyHover() {
|
|
|
124
129
|
const p = pendingHover;
|
|
125
130
|
pendingHover = null;
|
|
126
131
|
if (!p || isDragging || dragNode) return;
|
|
127
|
-
|
|
132
|
+
const over = findNodeAt(p.x, p.y, false);
|
|
133
|
+
setHover(!!over);
|
|
134
|
+
setHoverNode(over ? over.id : null); // a node with no label is named by a chip (labels.js)
|
|
128
135
|
}
|
|
129
136
|
|
|
130
137
|
function setHover(over) {
|
|
@@ -183,8 +190,11 @@ function onPointerUp(e) {
|
|
|
183
190
|
}
|
|
184
191
|
}
|
|
185
192
|
}
|
|
186
|
-
} else
|
|
187
|
-
|
|
193
|
+
} else {
|
|
194
|
+
// A cluster's title (its hub's label) is not a node to select: a click on it frames the cluster (spec 0008 D1)
|
|
195
|
+
const titled = topologyNode(labelNodeAt(p.x, p.y));
|
|
196
|
+
if (titled && LANDMARK_TYPES.includes(titled.type) && titled.id !== 'root') fitGraphToViewport(fitPadding(), clusterIds(titled.id, state.edges));
|
|
197
|
+
else if (state.selectedNode) closeDrawer(); // the background was clicked: back to the normal view
|
|
188
198
|
}
|
|
189
199
|
}
|
|
190
200
|
isDragging = false;
|
|
@@ -199,7 +209,7 @@ export function bindCanvasInput() {
|
|
|
199
209
|
const { canvas } = state;
|
|
200
210
|
canvas.addEventListener('mousedown', onPointerDown);
|
|
201
211
|
canvas.addEventListener('mousemove', onPointerMove);
|
|
202
|
-
canvas.addEventListener('mouseleave', () => { pendingHover = null; setHover(false); });
|
|
212
|
+
canvas.addEventListener('mouseleave', () => { pendingHover = null; setHover(false); setHoverNode(null); });
|
|
203
213
|
window.addEventListener('mouseup', onPointerUp);
|
|
204
214
|
|
|
205
215
|
canvas.addEventListener('touchstart', onPointerDown, { passive: false });
|
|
@@ -209,6 +219,7 @@ export function bindCanvasInput() {
|
|
|
209
219
|
|
|
210
220
|
canvas.addEventListener('wheel', (e) => {
|
|
211
221
|
e.preventDefault();
|
|
222
|
+
stopFlight();
|
|
212
223
|
const p = getPointerPos(e);
|
|
213
224
|
Object.assign(state.camera, zoomAbout(state.camera, e.deltaY < 0 ? 1.12 : 0.88, p.x, p.y, getMinZoom()));
|
|
214
225
|
render(); // a camera change is cheap; the draw is one per frame however many wheel events arrive
|
package/explorer/keyboard.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* Escape closes it, and in Freeform Alt+arrow moves the selected node;
|
|
11
11
|
* - `#map-announcer` (a polite live region) says where the keyboard landed: the node, its type, its
|
|
12
12
|
* connections, its place; the zoom; a search's hit;
|
|
13
|
-
* - Enter in the search box selects the
|
|
13
|
+
* - Enter in the search box selects the best match and goes on to the next (search.js); with a search on, N and P step through its matches;
|
|
14
14
|
* - the panel: Escape inside it closes it and gives the focus back to the map; it is `inert` while closed
|
|
15
15
|
* (panels.js), so its buttons are never tabbed to off screen;
|
|
16
16
|
* - the Layers menu says whether it is open (`aria-expanded`), and Escape closes it, back on its button;
|
|
@@ -24,6 +24,7 @@ import { selectNode, closeDrawer } from './panels.js';
|
|
|
24
24
|
import { saveFreeformPositions } from './layout.js';
|
|
25
25
|
import { closeLegendMenu } from './layers.js';
|
|
26
26
|
import * as K from './keyboard-model.js';
|
|
27
|
+
import { searchActive, stepMatch } from './search.js';
|
|
27
28
|
|
|
28
29
|
const $ = (id) => document.getElementById(id);
|
|
29
30
|
let wired = false;
|
|
@@ -42,17 +43,21 @@ export function announce(text) {
|
|
|
42
43
|
/** The visible nodes, in the order the keys step through them */
|
|
43
44
|
const stepOrder = () => K.readingOrder(state.nodes.filter((n) => isNodeVisible(n)));
|
|
44
45
|
|
|
45
|
-
/**
|
|
46
|
-
export function
|
|
47
|
-
const {
|
|
46
|
+
/** The camera that puts `node` in the middle of the part of the map not under the panels or a phone's sheets, at `zoom` (the current one by default) */
|
|
47
|
+
export function centreTarget(node, zoom = state.camera.zoom) {
|
|
48
|
+
const { width, height } = state;
|
|
48
49
|
const visibleHeight = Math.max(160, height - (state.coveredBottom || 0));
|
|
49
50
|
const panel = $('spec-drawer');
|
|
50
51
|
const visibleWidth = width >= 768 && panel && panel.classList.contains('drawer-open') ? Math.max(160, width - (panel.offsetWidth || 480)) : width;
|
|
51
52
|
// The issues and PRs panel slides in from the left (forge-panel.js)
|
|
52
53
|
const forge = $('forge-panel');
|
|
53
54
|
const left = width >= 768 && forge && forge.classList.contains('forge-open') ? Math.min(forge.offsetWidth || 400, visibleWidth - 160) : 0;
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
return { x: left + (visibleWidth - left) / 2 - node.x * zoom, y: visibleHeight / 2 - node.y * zoom, zoom };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Moves the camera so `node` is in the middle of the part of the map not under the panels or a phone's sheets */
|
|
59
|
+
export function centreOn(node) {
|
|
60
|
+
Object.assign(state.camera, centreTarget(node));
|
|
56
61
|
render();
|
|
57
62
|
}
|
|
58
63
|
|
|
@@ -108,6 +113,7 @@ function onMapKey(e) {
|
|
|
108
113
|
announce(`The whole map. ${K.zoomWords(camera.zoom)}`);
|
|
109
114
|
break;
|
|
110
115
|
case 'step': {
|
|
116
|
+
if (searchActive() && stepMatch(action.by)) break; // with a search on, N and P walk its matches (search.js)
|
|
111
117
|
const order = stepOrder();
|
|
112
118
|
land(K.stepFrom(order, state.selectedNode && state.selectedNode.id, action.by), order);
|
|
113
119
|
break;
|
|
@@ -147,18 +153,6 @@ function onPanelClick(e) {
|
|
|
147
153
|
if (close && state.canvas) setTimeout(() => state.canvas.focus(), 0);
|
|
148
154
|
}
|
|
149
155
|
|
|
150
|
-
/** Enter in a search box: the first visible node it matches is selected, like a click on it */
|
|
151
|
-
function onSearchKey(e) {
|
|
152
|
-
if (e.key !== 'Enter') return;
|
|
153
|
-
const q = e.target.value.trim().toLowerCase();
|
|
154
|
-
if (!q) return;
|
|
155
|
-
e.preventDefault();
|
|
156
|
-
const order = stepOrder();
|
|
157
|
-
const hit = order.find((n) => n.label.toLowerCase().includes(q));
|
|
158
|
-
if (!hit) { announce(`No node matches ${e.target.value.trim()}`); return; }
|
|
159
|
-
land(hit, order);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
156
|
/** Whether the key went to something that takes typing */
|
|
163
157
|
const typing = (el) => !!el && (el.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(el.tagName));
|
|
164
158
|
|
|
@@ -198,10 +192,6 @@ export function initKeyboard() {
|
|
|
198
192
|
drawer.addEventListener('keydown', onPanelKey);
|
|
199
193
|
drawer.addEventListener('click', onPanelClick);
|
|
200
194
|
}
|
|
201
|
-
for (const id of ['node-search', 'mobile-node-search']) {
|
|
202
|
-
const input = $(id);
|
|
203
|
-
if (input) input.addEventListener('keydown', onSearchKey);
|
|
204
|
-
}
|
|
205
195
|
document.addEventListener('keydown', onDocumentKey);
|
|
206
196
|
}
|
|
207
197
|
|