cornfield 0.46.0 → 0.46.2

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 (62) hide show
  1. package/explorer/capped.js +3 -2
  2. package/explorer/engine/feedback.js +49 -0
  3. package/explorer/engine/flow-ui.js +39 -0
  4. package/explorer/engine/fly.js +54 -0
  5. package/explorer/engine/hint.js +97 -0
  6. package/explorer/engine/keyboard.js +156 -0
  7. package/explorer/engine/layers.js +280 -0
  8. package/explorer/engine/layout.js +378 -0
  9. package/explorer/engine/map-style.js +547 -0
  10. package/explorer/engine/piece.js +142 -0
  11. package/explorer/engine/render.js +331 -0
  12. package/explorer/engine/search-status.js +59 -0
  13. package/explorer/engine/selection.js +42 -0
  14. package/explorer/engine/sheets.js +417 -0
  15. package/explorer/engine/strings.js +63 -0
  16. package/explorer/feedback.js +11 -45
  17. package/explorer/flow-style.js +28 -0
  18. package/explorer/flows.js +10 -51
  19. package/explorer/fly.js +11 -43
  20. package/explorer/hint.js +15 -88
  21. package/explorer/index.html +38 -75
  22. package/explorer/input.js +190 -177
  23. package/explorer/instance-state.js +172 -0
  24. package/explorer/instance.js +267 -0
  25. package/explorer/keyboard.js +14 -206
  26. package/explorer/labels.js +3 -3
  27. package/explorer/layers.js +34 -445
  28. package/explorer/layout.js +14 -372
  29. package/explorer/main.js +4 -226
  30. package/explorer/map-style.js +27 -525
  31. package/explorer/mockups-model.js +3 -3
  32. package/explorer/page-pieces.js +61 -0
  33. package/explorer/page.js +232 -0
  34. package/explorer/panels.js +29 -409
  35. package/explorer/pieces/layers.js +325 -0
  36. package/explorer/pieces/node-panel.js +536 -0
  37. package/explorer/pieces/search.js +454 -0
  38. package/explorer/proposal-model.js +1 -1
  39. package/explorer/proposal.js +1 -0
  40. package/explorer/render.js +37 -267
  41. package/explorer/renderer-canvas2d.js +4 -4
  42. package/explorer/renderer-webgl.js +21 -8
  43. package/explorer/renderer.js +11 -9
  44. package/explorer/scene.js +3 -2
  45. package/explorer/search-status.js +8 -47
  46. package/explorer/search.js +26 -324
  47. package/explorer/selection-view.js +17 -19
  48. package/explorer/sheets.js +31 -379
  49. package/explorer/state.js +38 -173
  50. package/explorer/strings.js +17 -60
  51. package/explorer/view.js +4 -5
  52. package/package.json +1 -1
  53. package/server/agent-api.js +13 -6
  54. package/server/agent-runs.js +2 -1
  55. package/server/auth.js +1 -1
  56. package/server/forge-actions.js +34 -24
  57. package/server/forge-routes.js +3 -3
  58. package/server/lander.js +3 -2
  59. package/server/proposals.js +11 -3
  60. package/server/review-api.js +13 -8
  61. package/server/server.js +5 -4
  62. package/server/throttle.js +27 -0
package/explorer/input.js CHANGED
@@ -12,216 +12,229 @@
12
12
  * point under the pointer, or between two fingers, still (camera.js).
13
13
  */
14
14
 
15
- import { state, touchScene } from './state.js';
16
- import { render, getSpatialIndex, queueFrameWork, screenToWorld, getMinZoom, setHoverNode, labelNodeAt, fitGraphToViewport, fitPadding } from './render.js';
17
15
  import { clusterIds } from './cluster.js';
18
16
  import { LANDMARK_TYPES } from './scene.js';
19
- import { saveFreeformPositions } from './layout.js';
20
- import { selectNode, closeDrawer } from './panels.js';
17
+ import { saveFreeformPositions } from './engine/layout.js';
21
18
  import { hitTestScreen } from './spatial.js';
22
19
  import { zoomAbout, pinchStart, pinchCamera } from './camera.js';
23
- import { stopFlight } from './fly.js';
24
-
25
- let isDragging = false;
26
- let dragNode = null;
27
- let lastPos = { x: 0, y: 0 };
28
- let touchStartPos = { x: 0, y: 0 };
29
- let touchMoved = false;
30
- let pointerDownNode = null;
31
- let lastTapNode = null;
32
- let lastTapTime = 0;
33
- let pinch = null; // the start of a two-finger gesture (camera.js pinchStart)
34
- let downOnCanvas = false; // the press that is ending began on the map: a release elsewhere (a sheet's handle, a panel button) is not a tap on the background
35
-
36
- // What the pointer did since the last frame; applied once per frame by applyMoves
37
- let pendingPos = null;
38
- let pendingPinch = null;
39
- let pendingHover = null;
40
- let hovering = false;
41
- let restCursor = '';
42
-
43
- const canDragNodes = () => state.isFreeform && state.view === 'orbit';
44
-
45
- function getPointerPos(e) {
46
- const rect = state.canvas.getBoundingClientRect();
47
- const point = e.touches ? e.touches[0] : e;
48
- return { x: point.clientX - rect.left, y: point.clientY - rect.top };
49
- }
50
20
 
51
- // The topology node with this id (the grid answers with scene nodes, which are copies of the picture)
52
- let byId = { nodes: null, size: -1, map: null };
53
- function topologyNode(id) {
54
- if (byId.nodes !== state.nodes || byId.size !== state.nodes.length) {
55
- byId = { nodes: state.nodes, size: state.nodes.length, map: new Map(state.nodes.map((n) => [n.id, n])) };
21
+ /**
22
+ * Listens on the instance's map canvas and returns how to stop (`inst.destroy()` also does). What the map cannot do itself it says through the
23
+ * instance, for the page shell (or the host) to answer: `inst.emit('select', node)` (a tap on a node), `inst.emit('background')` (a tap on the bare
24
+ * map: back to the normal view) and `inst.emit('grab')` (a hand takes the camera, so a flight to a match ends where it is).
25
+ * @param {ReturnType<typeof import('./instance.js').createInstance>} inst
26
+ */
27
+ export function bindCanvasInput(inst) {
28
+ const { state } = inst;
29
+ const { render, getSpatialIndex, queueFrameWork, screenToWorld, getMinZoom, setHoverNode, labelNodeAt, fitGraphToViewport, fitPadding } = inst.map;
30
+ const selectNode = (node) => inst.emit('select', node);
31
+ const closeDrawer = () => inst.emit('background');
32
+ const stopFlight = () => inst.emit('grab');
33
+
34
+ let isDragging = false;
35
+ let dragNode = null;
36
+ let lastPos = { x: 0, y: 0 };
37
+ let touchStartPos = { x: 0, y: 0 };
38
+ let touchMoved = false;
39
+ let pointerDownNode = null;
40
+ let lastTapNode = null;
41
+ let lastTapTime = 0;
42
+ let pinch = null; // the start of a two-finger gesture (camera.js pinchStart)
43
+ let downOnCanvas = false; // the press that is ending began on the map: a release elsewhere (a sheet's handle, a panel button) is not a tap on the background
44
+
45
+ // What the pointer did since the last frame; applied once per frame by applyMoves
46
+ let pendingPos = null;
47
+ let pendingPinch = null;
48
+ let pendingHover = null;
49
+ let hovering = false;
50
+ let restCursor = '';
51
+
52
+ const canDragNodes = () => state.isFreeform && state.view === 'orbit';
53
+
54
+ function getPointerPos(e) {
55
+ const rect = state.canvas.getBoundingClientRect();
56
+ const point = e.touches ? e.touches[0] : e;
57
+ return { x: point.clientX - rect.left, y: point.clientY - rect.top };
56
58
  }
57
- return byId.map.get(id) || null;
58
- }
59
-
60
- /** The topmost visible node under a screen point (a finger gets a wider reach), or null */
61
- function findNodeAt(screenX, screenY, isTouch) {
62
- const hit = hitTestScreen(getSpatialIndex(), state.camera, screenX, screenY, isTouch);
63
- return hit ? topologyNode(hit.id) : null;
64
- }
65
59
 
66
- const touchDistance = (e) => Math.hypot(e.touches[0].clientX - e.touches[1].clientX, e.touches[0].clientY - e.touches[1].clientY);
67
- function touchMid(e) {
68
- const rect = state.canvas.getBoundingClientRect();
69
- return {
70
- x: (e.touches[0].clientX + e.touches[1].clientX) / 2 - rect.left,
71
- y: (e.touches[0].clientY + e.touches[1].clientY) / 2 - rect.top,
72
- };
73
- }
74
-
75
- function onPointerDown(e) {
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
79
- if (e.touches && e.touches.length === 2) {
80
- pinch = pinchStart(state.camera, touchDistance(e), touchMid(e));
81
- pendingPos = null;
82
- isDragging = false;
83
- dragNode = null;
84
- pointerDownNode = null;
85
- return;
60
+ // The topology node with this id (the grid answers with scene nodes, which are copies of the picture)
61
+ let byId = { nodes: null, size: -1, map: null };
62
+ function topologyNode(id) {
63
+ if (byId.nodes !== state.nodes || byId.size !== state.nodes.length) {
64
+ byId = { nodes: state.nodes, size: state.nodes.length, map: new Map(state.nodes.map((n) => [n.id, n])) };
65
+ }
66
+ return byId.map.get(id) || null;
86
67
  }
87
- const isTouch = !!(e.touches && e.touches.length > 0);
88
- const p = getPointerPos(e);
89
- touchStartPos = { x: p.x, y: p.y };
90
- touchMoved = false;
91
- pendingPos = null;
92
- pointerDownNode = findNodeAt(p.x, p.y, isTouch);
93
-
94
- if (canDragNodes() && pointerDownNode) {
95
- dragNode = pointerDownNode;
96
- if (e.cancelable) e.preventDefault();
97
- return;
68
+
69
+ /** The topmost visible node under a screen point (a finger gets a wider reach), or null */
70
+ function findNodeAt(screenX, screenY, isTouch) {
71
+ const hit = hitTestScreen(getSpatialIndex(), state.camera, screenX, screenY, isTouch);
72
+ return hit ? topologyNode(hit.id) : null;
98
73
  }
99
- isDragging = true; // otherwise the canvas pans
100
- lastPos = p;
101
- }
102
74
 
103
- /** One frame's worth of pointer movement: the pinch, the node being dragged, or the pan, from the latest position */
104
- function applyMoves() {
105
- if (pendingPinch && pinch) {
106
- Object.assign(state.camera, pinchCamera(pinch, pendingPinch.dist, pendingPinch.mid, getMinZoom()));
75
+ const touchDistance = (e) => Math.hypot(e.touches[0].clientX - e.touches[1].clientX, e.touches[0].clientY - e.touches[1].clientY);
76
+ function touchMid(e) {
77
+ const rect = state.canvas.getBoundingClientRect();
78
+ return {
79
+ x: (e.touches[0].clientX + e.touches[1].clientX) / 2 - rect.left,
80
+ y: (e.touches[0].clientY + e.touches[1].clientY) / 2 - rect.top,
81
+ };
107
82
  }
108
- pendingPinch = null;
109
-
110
- const p = pendingPos;
111
- pendingPos = null;
112
- if (!p) return;
113
- if (dragNode && canDragNodes()) {
114
- const world = screenToWorld(p.x, p.y);
115
- dragNode.x = world.x;
116
- dragNode.y = world.y;
117
- state.freeformPositions[dragNode.id] = { x: world.x, y: world.y };
118
- touchScene(); // positions changed: the next scene (and so the grid) is built once, from this frame's position
119
- saveFreeformPositions();
120
- } else if (isDragging) {
121
- state.camera.x += p.x - lastPos.x;
122
- state.camera.y += p.y - lastPos.y;
83
+
84
+ function onPointerDown(e) {
85
+ downOnCanvas = true;
86
+ stopFlight(); // the hand takes the camera: a flight to a match ends where it is
87
+ setHoverNode(null); // a press starts a tap or a drag: the chip that named a node under the pointer goes
88
+ if (e.touches && e.touches.length === 2) {
89
+ pinch = pinchStart(state.camera, touchDistance(e), touchMid(e));
90
+ pendingPos = null;
91
+ isDragging = false;
92
+ dragNode = null;
93
+ pointerDownNode = null;
94
+ return;
95
+ }
96
+ const isTouch = !!(e.touches && e.touches.length > 0);
97
+ const p = getPointerPos(e);
98
+ touchStartPos = { x: p.x, y: p.y };
99
+ touchMoved = false;
100
+ pendingPos = null;
101
+ pointerDownNode = findNodeAt(p.x, p.y, isTouch);
102
+
103
+ if (canDragNodes() && pointerDownNode) {
104
+ dragNode = pointerDownNode;
105
+ if (e.cancelable) e.preventDefault();
106
+ return;
107
+ }
108
+ isDragging = true; // otherwise the canvas pans
123
109
  lastPos = p;
124
110
  }
125
- }
126
111
 
127
- /** Hover: a pointer cursor over a node. It changes no picture, so it asks for no draw. */
128
- function applyHover() {
129
- const p = pendingHover;
130
- pendingHover = null;
131
- if (!p || isDragging || dragNode) return;
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)
135
- }
136
-
137
- function setHover(over) {
138
- if (over === hovering || !state.canvas) return;
139
- if (over) restCursor = state.canvas.style.cursor;
140
- hovering = over;
141
- state.canvas.style.cursor = over ? 'pointer' : restCursor;
142
- }
112
+ /** One frame's worth of pointer movement: the pinch, the node being dragged, or the pan, from the latest position */
113
+ function applyMoves() {
114
+ if (pendingPinch && pinch) {
115
+ Object.assign(state.camera, pinchCamera(pinch, pendingPinch.dist, pendingPinch.mid, getMinZoom()));
116
+ }
117
+ pendingPinch = null;
143
118
 
144
- function onPointerMove(e) {
145
- if (e.touches && e.touches.length === 2 && pinch) {
146
- if (e.cancelable) e.preventDefault();
147
- pendingPinch = { dist: touchDistance(e), mid: touchMid(e) };
148
- queueFrameWork(applyMoves);
149
- return;
119
+ const p = pendingPos;
120
+ pendingPos = null;
121
+ if (!p) return;
122
+ if (dragNode && canDragNodes()) {
123
+ const world = screenToWorld(p.x, p.y);
124
+ dragNode.x = world.x;
125
+ dragNode.y = world.y;
126
+ state.freeformPositions[dragNode.id] = { x: world.x, y: world.y };
127
+ inst.touchScene(); // positions changed: the next scene (and so the grid) is built once, from this frame's position
128
+ saveFreeformPositions(inst);
129
+ } else if (isDragging) {
130
+ state.camera.x += p.x - lastPos.x;
131
+ state.camera.y += p.y - lastPos.y;
132
+ lastPos = p;
133
+ }
150
134
  }
151
135
 
152
- const p = getPointerPos(e);
153
- if (Math.hypot(p.x - touchStartPos.x, p.y - touchStartPos.y) > 8) touchMoved = true;
136
+ /** Hover: a pointer cursor over a node. It changes no picture, so it asks for no draw. */
137
+ function applyHover() {
138
+ const p = pendingHover;
139
+ pendingHover = null;
140
+ if (!p || isDragging || dragNode) return;
141
+ const over = findNodeAt(p.x, p.y, false);
142
+ setHover(!!over);
143
+ setHoverNode(over ? over.id : null); // a node with no label is named by a chip (labels.js)
144
+ }
154
145
 
155
- if ((dragNode && canDragNodes()) || isDragging) {
156
- if (e.cancelable) e.preventDefault();
157
- pendingPos = p; // the latest position wins; the frame applies it
158
- queueFrameWork(applyMoves);
159
- return;
146
+ function setHover(over) {
147
+ if (over === hovering || !state.canvas) return;
148
+ if (over) restCursor = state.canvas.style.cursor;
149
+ hovering = over;
150
+ state.canvas.style.cursor = over ? 'pointer' : restCursor;
160
151
  }
161
- if (!e.touches) {
162
- pendingHover = p;
163
- queueFrameWork(applyHover, { draw: false });
152
+
153
+ function onPointerMove(e) {
154
+ if (e.touches && e.touches.length === 2 && pinch) {
155
+ if (e.cancelable) e.preventDefault();
156
+ pendingPinch = { dist: touchDistance(e), mid: touchMid(e) };
157
+ queueFrameWork(applyMoves);
158
+ return;
159
+ }
160
+
161
+ const p = getPointerPos(e);
162
+ if (Math.hypot(p.x - touchStartPos.x, p.y - touchStartPos.y) > 8) touchMoved = true;
163
+
164
+ if ((dragNode && canDragNodes()) || isDragging) {
165
+ if (e.cancelable) e.preventDefault();
166
+ pendingPos = p; // the latest position wins; the frame applies it
167
+ queueFrameWork(applyMoves);
168
+ return;
169
+ }
170
+ if (!e.touches) {
171
+ pendingHover = p;
172
+ queueFrameWork(applyHover, { draw: false });
173
+ }
164
174
  }
165
- }
166
175
 
167
- function onPointerUp(e) {
168
- applyMoves(); // the last position the pointer reached counts, even if no frame has run since
169
- const isTouch = !!(e.changedTouches && e.changedTouches.length > 0);
170
- const rect = state.canvas.getBoundingClientRect();
171
- const p = isTouch ? { x: e.changedTouches[0].clientX - rect.left, y: e.changedTouches[0].clientY - rect.top } : getPointerPos(e);
172
-
173
- // Only a touch or click that started and ended on the same node, without dragging, inspects it
174
- if (!touchMoved && downOnCanvas) {
175
- if (pointerDownNode) {
176
- const hitUp = findNodeAt(p.x, p.y, isTouch);
177
- if (hitUp && hitUp.id === pointerDownNode.id) {
178
- if (!canDragNodes()) {
179
- selectNode(pointerDownNode);
180
- } else {
181
- // Freeform: a double tap inspects, so dragging a node does not open the panel
182
- const now = Date.now();
183
- if (lastTapNode && lastTapNode.id === pointerDownNode.id && now - lastTapTime < 380) {
176
+ function onPointerUp(e) {
177
+ applyMoves(); // the last position the pointer reached counts, even if no frame has run since
178
+ const isTouch = !!(e.changedTouches && e.changedTouches.length > 0);
179
+ const rect = state.canvas.getBoundingClientRect();
180
+ const p = isTouch ? { x: e.changedTouches[0].clientX - rect.left, y: e.changedTouches[0].clientY - rect.top } : getPointerPos(e);
181
+
182
+ // Only a touch or click that started and ended on the same node, without dragging, inspects it
183
+ if (!touchMoved && downOnCanvas) {
184
+ if (pointerDownNode) {
185
+ const hitUp = findNodeAt(p.x, p.y, isTouch);
186
+ if (hitUp && hitUp.id === pointerDownNode.id) {
187
+ if (!canDragNodes()) {
184
188
  selectNode(pointerDownNode);
185
- lastTapNode = null;
186
- lastTapTime = 0;
187
189
  } else {
188
- lastTapNode = pointerDownNode;
189
- lastTapTime = now;
190
+ // Freeform: a double tap inspects, so dragging a node does not open the panel
191
+ const now = Date.now();
192
+ if (lastTapNode && lastTapNode.id === pointerDownNode.id && now - lastTapTime < 380) {
193
+ selectNode(pointerDownNode);
194
+ lastTapNode = null;
195
+ lastTapTime = 0;
196
+ } else {
197
+ lastTapNode = pointerDownNode;
198
+ lastTapTime = now;
199
+ }
190
200
  }
191
201
  }
202
+ } else {
203
+ // A cluster's title (its hub's label) is not a node to select: a click on it frames the cluster (spec 0008 D1)
204
+ const titled = topologyNode(labelNodeAt(p.x, p.y));
205
+ if (titled && LANDMARK_TYPES.includes(titled.type) && titled.id !== 'root') fitGraphToViewport(fitPadding(), clusterIds(titled.id, state.edges));
206
+ else if (state.selectedNode) closeDrawer(); // the background was clicked: back to the normal view
192
207
  }
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
198
208
  }
209
+ isDragging = false;
210
+ dragNode = null;
211
+ pointerDownNode = null;
212
+ pinch = null;
213
+ pendingPinch = null;
214
+ downOnCanvas = false;
199
215
  }
200
- isDragging = false;
201
- dragNode = null;
202
- pointerDownNode = null;
203
- pinch = null;
204
- pendingPinch = null;
205
- downOnCanvas = false;
206
- }
207
-
208
- export function bindCanvasInput() {
209
- const { canvas } = state;
210
- canvas.addEventListener('mousedown', onPointerDown);
211
- canvas.addEventListener('mousemove', onPointerMove);
212
- canvas.addEventListener('mouseleave', () => { pendingHover = null; setHover(false); setHoverNode(null); });
213
- window.addEventListener('mouseup', onPointerUp);
214
216
 
215
- canvas.addEventListener('touchstart', onPointerDown, { passive: false });
216
- canvas.addEventListener('touchmove', onPointerMove, { passive: false });
217
- window.addEventListener('touchend', onPointerUp, { passive: false });
218
- window.addEventListener('touchcancel', onPointerUp, { passive: false });
219
217
 
220
- canvas.addEventListener('wheel', (e) => {
218
+ const { canvas } = state;
219
+ const onWheel = (e) => {
221
220
  e.preventDefault();
222
221
  stopFlight();
223
222
  const p = getPointerPos(e);
224
223
  Object.assign(state.camera, zoomAbout(state.camera, e.deltaY < 0 ? 1.12 : 0.88, p.x, p.y, getMinZoom()));
225
224
  render(); // a camera change is cheap; the draw is one per frame however many wheel events arrive
226
- }, { passive: false });
225
+ };
226
+ // The press and the drag begin on the canvas; the release can end anywhere, so it is heard on the instance's root
227
+ const root = inst.root || canvas;
228
+ const stops = [
229
+ inst.listen(canvas, 'mousedown', onPointerDown),
230
+ inst.listen(canvas, 'mousemove', onPointerMove),
231
+ inst.listen(canvas, 'mouseleave', () => { pendingHover = null; setHover(false); setHoverNode(null); }),
232
+ inst.listen(root, 'mouseup', onPointerUp),
233
+ inst.listen(canvas, 'touchstart', onPointerDown, { passive: false }),
234
+ inst.listen(canvas, 'touchmove', onPointerMove, { passive: false }),
235
+ inst.listen(root, 'touchend', onPointerUp, { passive: false }),
236
+ inst.listen(root, 'touchcancel', onPointerUp, { passive: false }),
237
+ inst.listen(canvas, 'wheel', onWheel, { passive: false }),
238
+ ];
239
+ return () => stops.forEach((off) => off());
227
240
  }
@@ -0,0 +1,172 @@
1
+ /**
2
+ * @module explorer/instance-state
3
+ *
4
+ * What an instance holds: the explorer's state object, one per instance (instance.js `createInstance`). ES module bindings cannot be
5
+ * reassigned from another module, so everything that more than one module reads or writes lives here as a property: the topology,
6
+ * which layers are on, the camera, the selection, the view. cornfield's own page has one (explorer/state.js hands it to the modules
7
+ * that are not yet on an instance).
8
+ */
9
+
10
+ /** A new state object, as the explorer starts: nothing loaded, the default layers on */
11
+ export function createState() {
12
+ return {
13
+ /** The map canvas, and a 2d context used only to measure text (layout.js), set by the page shell before anything draws */
14
+ canvas: /** @type {HTMLCanvasElement|null} */ (null),
15
+ ctx: /** @type {CanvasRenderingContext2D|null} */ (null),
16
+ /** The transparent canvas stacked over `canvas` that draws every label (labels.js); null = no labels */
17
+ labelCanvas: /** @type {HTMLCanvasElement|null} */ (null),
18
+ width: 0,
19
+ height: 0,
20
+ /** Height (px) of the bottom of the map the phone's sheets cover (sheets.js); 0 on a desktop. The fit and the scenario camera leave it out. */
21
+ coveredBottom: 0,
22
+
23
+ /** topology.json: every node has x/y assigned by layout.js (the file stores no positions) */
24
+ nodes: [],
25
+ edges: [],
26
+
27
+ /** 'orbit' (the whole map), 'dataflow' (the preset: browser -> servers -> API -> tables -> services -> outside) or 'house' (the House preset, PHY-11) */
28
+ view: 'orbit',
29
+ /** What the data-flow preset shows, built by flows.js buildDataFlow() when the topology loads */
30
+ flow: null,
31
+ /** The orbital rings layout.js drew the positions on */
32
+ rings: { rings: [], clusters: [] },
33
+
34
+ /** 'dark' or 'light': the ground the map is drawn for (theme.js keeps it, from the system and the toggle); a change must `touchScene()` */
35
+ theme: 'dark',
36
+
37
+ camera: { x: 0, y: 0, zoom: 1 },
38
+ selectedNode: null,
39
+ /** The node panel's "Include its children's lines" switch (spec 0008 D5): off, a selection lights one hop; on, the children's neighbours too. Kept across selections */
40
+ throughChildren: false,
41
+ /** The edge kind the panel chose to light alone (selection-model.js), or null for every kind; a new selection clears it */
42
+ selectedKind: null,
43
+ /** The config's `forge` (`{ type, url, repo, baseBranch? }`), or null: where a node's file is opened (file-url.js) */
44
+ forge: null,
45
+ searchQuery: '',
46
+ /** The id of the search match the stepping is on (search.js), or null: the map draws its halo and places its label first of the matches */
47
+ searchCurrent: null,
48
+ /** The id of the node the pointer is on (input.js): a node with no label is named by a chip while it is */
49
+ hoverNodeId: null,
50
+
51
+ isFreeform: false,
52
+ freeformPositions: {},
53
+
54
+ /**
55
+ * Layer key -> on. The infra layer is its own view, so it starts off, and so do the physical world's
56
+ * (spec 0029): machines, containers, devices, the house and people. Turning one of the live ones on
57
+ * (live-model.js LIVE_LAYERS) is what first loads the live layer.
58
+ */
59
+ activeLayers: {
60
+ app: true, pkg: true, page: true, atom: true, molecule: true, token: true, tool: true,
61
+ flow: true, table: true, rom: true, service: true, cloud: true, web: true, stack: false,
62
+ machine: false, container: false, device: false, house: false, persona: false,
63
+ },
64
+
65
+ /**
66
+ * The project's own layers (spec 0009): `{ key, label, desc?, match }` in `add` order, as the config sent them (core/layers.js); a node is
67
+ * in the first one whose match it meets (explorer/layer-model.js). `layerOrder` is the config's `order`; `layerDefaults` what each layer is
68
+ * when the viewer has not touched it (layers.js `setProjectLayers`). Empty with no `layers` in the config: the menu is then the starting set.
69
+ */
70
+ projectLayers: [],
71
+ layerOrder: [],
72
+ layerDefaults: {},
73
+
74
+ /**
75
+ * The review of the open proposal, which narrows the map to the change (issue #232; explorer/layer-model.js `layersOf`): null with no proposal open,
76
+ * else `{ whole, manual, step, rev }`. `whole`: "Show the whole map" is on, the map is as Diff always was. `manual`: layers the reviewer turned on or
77
+ * off by hand in this review, `step`: the ones a playing scenario turned on (both `{ key: boolean }`). `rev` moves with each change.
78
+ * None of it is the viewer's: `activeLayers` and the saved choices (layers.js) are never written while it is set.
79
+ */
80
+ review: null,
81
+
82
+ /**
83
+ * The map as the last `setMap` (view.js) was handed it, before the live layer is laid in: the base
84
+ * copies, or a proposal applied over them. `nodes` and `edges` are these plus the live ones.
85
+ */
86
+ mapNodes: [],
87
+ mapEdges: [],
88
+
89
+ /**
90
+ * The live layer (live.js, spec 0029 section 4), in memory only and never stored anywhere: the
91
+ * runner's snapshot `{ status, answer, error, lastOkAt }` and what merging it found: `counts`
92
+ * (persona id -> accounts), `other` (accounts no persona counts), `linked` (node id -> its
93
+ * inventory item). null until a live layer is first turned on.
94
+ */
95
+ live: null,
96
+
97
+ /**
98
+ * The House view (house.js, house-model.js, spec 0029 section 7): its settings (`floor`, `phone`, `software`, the
99
+ * rooms opened past their "+N", the plugin's default plan) and what its last layout found (what it shows, its bands
100
+ * and tray, the fit, each thing's floor). null until the view is first opened.
101
+ */
102
+ house: null,
103
+
104
+ /**
105
+ * The map as topology.json holds it: never laid out, never changed. `nodes` and `edges` above are
106
+ * copies of these (or `applyProposal` of them while a proposal is open), which is what makes
107
+ * Before, After and closing a proposal exact.
108
+ */
109
+ baseNodes: [],
110
+ baseEdges: [],
111
+
112
+ /**
113
+ * The proposal open on the map (proposal.js, spec 0012 B2): the parsed file or null. While it is
114
+ * set, `nodes` and `edges` are `applyProposal(base, proposal)`: each carries `mark` (and `before`,
115
+ * `why` when changed or removed). `proposalView` is what scene.js shows of that: 'before' | 'diff' |
116
+ * 'after'. `proposalSource` is where it was found ('checkout' or a worktree name), `proposalSlug` its
117
+ * file name without `.json`, `proposalErrors` what `validateProposal` found against the base.
118
+ */
119
+ proposal: null,
120
+ proposalView: 'diff',
121
+ proposalSource: null,
122
+ /** The open proposal's file as the server sent it, its SHA-256 (X-Proposal-Sha256), or null: a review names it, so a push since is refused (spec 0007) */
123
+ proposalSha256: null,
124
+ proposalSlug: null,
125
+ proposalErrors: [],
126
+ /** Where each of the open proposal's mockups stands with the review, by position: 'approved' | 'changed' | 'unreviewed' | 'missing' (mockups.js; none read yet is empty) */
127
+ mockupStates: {},
128
+ /**
129
+ * The proposal the map is drawn from: `proposal` with what-if edits folded in (whatif.js, TOPO-11), or `proposal` itself
130
+ * when there are none; null with no proposal open. `proposal` is never changed: it is the robot's file.
131
+ */
132
+ effectiveProposal: null,
133
+ /** The maintainer's what-if edits to the open proposal, and what Undo took back (whatif-model.js): `{ edits, undone }` */
134
+ whatIf: { edits: [], undone: [] },
135
+ /** The My edits toggle is off: the map is drawn from the proposal as written, the edits are kept and still go with a review (whatif.js, spec 0007 D5) */
136
+ whatIfOff: false,
137
+ /** A marked edge picked on the map (nodes are `selectedNode`): the panel shows it, the scene does not change */
138
+ selectedEdge: null,
139
+
140
+ /**
141
+ * The scenario being played on the map: the player's snapshot (scenario.js `ScenarioSnapshot`:
142
+ * index, playing, done, visited, current, progress ...) or null. The ROM simulation's walk is one.
143
+ * scenario-ui.js owns it; scene.js lights it, and an outage's `down` its blast radius (outage-model.js).
144
+ */
145
+ scenario: null,
146
+
147
+ /**
148
+ * What the selected pull request lights (forge-panel.js, forge-panel-model.js `litFor`): `{ changed, failing }`, sets of
149
+ * node ids (the nodes its files are; the nodes of the tests a failing check names), or null with none selected.
150
+ */
151
+ forgeLit: null,
152
+
153
+ /**
154
+ * The runs on the map (explorer/runs-map.js): `{ flight: Map<nodeId, runId[]>, collide: Map<nodeId, runId[]>, runs }` for the open runs'
155
+ * nodes, or null when there are none. The map's marks over the nodes are drawn from it.
156
+ */
157
+ runsMap: null,
158
+
159
+ /**
160
+ * Which threads mention which nodes (forge-panel.js, docs/threads.md), for a node's panel: `{ for(nodeId) -> thread[] | null,
161
+ * ensure(), open(number) }`, or null when threads are off or there is no forge. `for` answers null until the list has been
162
+ * read; `ensure` reads it (once) and repaints the panel's "Threads"; `open` shows a thread in the issues and PRs panel.
163
+ */
164
+ threadIndex: null,
165
+
166
+ /**
167
+ * Changes whenever anything the scene is built from changes (scene.js). render.js rebuilds the
168
+ * scene only when this moved: never for a camera change or a packet frame.
169
+ */
170
+ sceneVersion: 0,
171
+ };
172
+ }