cornfield 0.46.1 → 0.47.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 (56) 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 +98 -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 +552 -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-build.js +88 -0
  18. package/explorer/flow-style.js +28 -0
  19. package/explorer/flows.js +11 -132
  20. package/explorer/fly.js +11 -43
  21. package/explorer/hint.js +15 -88
  22. package/explorer/index.html +40 -82
  23. package/explorer/input.js +197 -177
  24. package/explorer/instance-state.js +172 -0
  25. package/explorer/instance.js +267 -0
  26. package/explorer/keyboard.js +14 -206
  27. package/explorer/labels.js +3 -3
  28. package/explorer/layers.js +34 -445
  29. package/explorer/layout.js +14 -372
  30. package/explorer/main.js +4 -226
  31. package/explorer/map-style.js +27 -525
  32. package/explorer/mockups-model.js +3 -3
  33. package/explorer/page-pieces.js +66 -0
  34. package/explorer/page.js +223 -0
  35. package/explorer/panels.js +29 -409
  36. package/explorer/pieces/adopt-tokens.js +38 -0
  37. package/explorer/pieces/layers.js +325 -0
  38. package/explorer/pieces/map-stage.css +14 -0
  39. package/explorer/pieces/map.js +332 -0
  40. package/explorer/pieces/node-panel.js +536 -0
  41. package/explorer/pieces/search.js +454 -0
  42. package/explorer/proposal-model.js +1 -1
  43. package/explorer/proposal.js +1 -0
  44. package/explorer/render.js +37 -267
  45. package/explorer/renderer-canvas2d.js +4 -4
  46. package/explorer/renderer-webgl.js +21 -8
  47. package/explorer/renderer.js +12 -9
  48. package/explorer/scene.js +3 -2
  49. package/explorer/search-status.js +8 -47
  50. package/explorer/search.js +26 -324
  51. package/explorer/selection-view.js +17 -19
  52. package/explorer/sheets.js +31 -379
  53. package/explorer/state.js +38 -173
  54. package/explorer/strings.js +17 -60
  55. package/explorer/view.js +4 -5
  56. package/package.json +1 -1
package/explorer/flows.js CHANGED
@@ -1,10 +1,11 @@
1
1
  /**
2
2
  * @module explorer/flows
3
3
  *
4
- * Data flow on the map:
4
+ * Data flow on the map (a bridge for the legend and the panel's block, which live on the instance in engine/flow-ui.js; they go from here
5
+ * when the last module that is not on an instance stops calling them):
5
6
  * - how a flow edge is styled (its colour and label per kind; scene.js turns that into the curve,
6
7
  * arrowhead and packet a renderer draws),
7
- * - the legend and the "Data flows" block of a node's panel, and
8
+ * - the legend and the "Data flows" block of a node's panel (engine/flow-ui.js), and
8
9
  * - the data-flow preset: the same topology folded into six tiers, left to right,
9
10
  * browser -> app servers -> API -> tables -> services -> outside systems.
10
11
  *
@@ -12,32 +13,11 @@
12
13
  * today, dashed = proposed. Other edge kinds (reads, writes, calls, ...) are styled by kind.
13
14
  */
14
15
 
15
- import { state, nameOf, escHtml } from './state.js';
16
- import { themed } from './theme-model.js';
17
- import { capped } from './capped.js';
18
- import { layersOf } from './layer-model.js';
16
+ import { pageInstance } from './state.js';
17
+ import { FLOW_STYLES } from './flow-style.js';
18
+ import * as F from './engine/flow-ui.js';
19
19
 
20
- export const FLOW_STYLES = {
21
- outbox: { color: '#f59e0b', label: 'Outbox → API (writes)' },
22
- changes: { color: '#22d3ee', label: 'Change stream (reads back)' },
23
- trigger: { color: '#a3e635', label: 'Trigger → audit_log (seq)' },
24
- sync: { color: '#fb7185', label: 'Background sync (external)' },
25
- model: { color: '#c084fc', label: 'Model classes feed a tier' },
26
- rom: { color: '#f0abfc', label: 'ROM: change → re-bake → serve' },
27
- read: { color: '#93c5fd', label: 'Server reads rows over HTTP' },
28
- api: { color: '#38bdf8', label: 'App calls the API (derived from its code)' },
29
- build: { color: '#d6d3d1', label: 'Build script writes files' },
30
- reads: { color: '#fde047', label: 'Table → page (render reads)' },
31
- writes: { color: '#f87171', label: 'Page → table (form / action)' },
32
- uses: { color: '#f472b6', label: 'Stylesheet uses design tokens' },
33
- extends: { color: '#5eead4', label: 'Component extends a base class' },
34
- calls: { color: '#fb7185', label: 'Calls (service → service, outside system)' },
35
- triggers: { color: '#a3e635', label: 'Triggers (cron, webhook, store change)' },
36
- delivers: { color: '#94a3b8', label: 'Outside system → webhook endpoint' },
37
- 'runs-on': { color: '#a8a29e', label: 'App → the stack that serves its domain' },
38
- };
39
-
40
- export const flowStyleOf = (edge) => FLOW_STYLES[edge.kind === 'flow' ? edge.flow : edge.kind] || FLOW_STYLES.sync;
20
+ export { FLOW_STYLES, flowStyleOf } from './flow-style.js';
41
21
 
42
22
  export const flowReduceMotion = typeof window !== 'undefined' && !!(window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches);
43
23
 
@@ -45,111 +25,10 @@ export const flowReduceMotion = typeof window !== 'undefined' && !!(window.match
45
25
  // The data-flow preset
46
26
  // ---------------------------------------------------------------------------
47
27
 
48
- /**
49
- * Folds the topology into the six tiers of the preset. A page is lifted to the app that owns
50
- * it (the API's endpoints become the API), edges are lifted with them and de-duplicated, and
51
- * only what stays inside the tiers is kept:
52
- * browser the stores that live in the visitor's browser (`tier: 'browser'` on a store, or the id `store-idb`)
53
- * servers the apps whose pages read or write rows
54
- * API the apps that own endpoints (pages with `methods`)
55
- * tables SQLite, the audit_log changefeed and every table
56
- * services the API's jobs, hooks and webhook handlers
57
- * outside the systems the API reaches: cloud nodes and the self-hosted containers
58
- * @returns {{ tiers: {key:string,title:string,note:string,nodes:object[]}[], ids: Set<string>, edges: object[] }}
59
- */
60
- export function buildDataFlow(nodes, edges) {
61
- const byId = new Map(nodes.map((n) => [n.id, n]));
62
- const owner = new Map();
63
- edges.forEach((e) => {
64
- if (!e.kind && !e.dashed && byId.get(e.from)?.type === 'app' && byId.get(e.to)?.type === 'page') owner.set(e.to, e.from);
65
- });
66
- // A self-hosted service is the container that runs it (spec 0031 section 3, CLOUD-03): it stands in the
67
- // Outside tier, and the worker of its stack that sends its webhook (nextcloud-webhooks) is drawn as it
68
- const hosted = nodes.filter((n) => n.type === 'container' && n.selfHosted);
69
- const sender = new Map();
70
- edges.forEach((e) => {
71
- const from = byId.get(e.from);
72
- if (e.kind !== 'delivers' || from?.type !== 'container' || from.selfHosted || byId.get(e.to)?.type !== 'page') return;
73
- const same = hosted.filter((h) => h.stack === from.stack);
74
- if (same.length === 1) sender.set(from.id, same[0].id);
75
- });
76
- const lift = (id) => (byId.get(id)?.type === 'page' ? owner.get(id) || id : sender.get(id) || id);
77
-
78
- // The API tier: every app that owns an endpoint (a page with methods)
79
- const apis = new Set([...owner].filter(([page]) => Array.isArray(byId.get(page)?.methods) && byId.get(page).methods.length).map(([, app]) => app));
80
- const isBrowserStore = (n) => n.type === 'store' && (n.tier === 'browser' || n.id === 'store-idb');
81
- const withRows = new Set();
82
- edges.forEach((e) => {
83
- if (e.kind === 'reads' || e.kind === 'writes') {
84
- const page = e.kind === 'reads' ? e.to : e.from;
85
- if (byId.get(page)?.type === 'page') withRows.add(lift(page));
86
- }
87
- });
88
- // An app whose own code calls the API (or publishes through an outside system) has a derived `api` flow, rows or not
89
- edges.forEach((e) => {
90
- if (e.kind === 'flow' && e.flow === 'api' && byId.get(e.from)?.type === 'app') withRows.add(e.from);
91
- });
92
- const apiFlowPairs = new Set(edges.filter((e) => e.kind === 'flow' && e.flow === 'api').map((e) => `${lift(e.from)}|${lift(e.to)}`));
93
-
94
- const pick = (pred) => nodes.filter(pred).sort((a, b) => String(a.label).localeCompare(String(b.label)));
95
- const tiers = [
96
- { key: 'browser', title: 'Browser', note: 'saved on the device first', nodes: pick(isBrowserStore) },
97
- { key: 'servers', title: 'App servers', note: 'pages, no-JS forms', nodes: pick((n) => n.type === 'app' && !apis.has(n.id) && withRows.has(n.id)) },
98
- { key: 'api', title: 'API', note: 'where the endpoints are', nodes: pick((n) => apis.has(n.id)) },
99
- { key: 'tables', title: 'Tables', note: 'stores and tables', nodes: [...pick((n) => n.type === 'store' && !isBrowserStore(n)), ...pick((n) => n.type === 'table')] },
100
- { key: 'services', title: 'Services', note: 'jobs, hooks, webhooks', nodes: pick((n) => n.type === 'service') },
101
- { key: 'outside', title: 'Outside', note: 'systems the API reaches', nodes: [...pick((n) => n.type === 'external'), ...pick((n) => n.type === 'container' && n.selfHosted)] },
102
- ];
103
- const ids = new Set(tiers.flatMap((t) => t.nodes.map((n) => n.id)));
104
-
105
- const out = [];
106
- const seen = new Set();
107
- const add = (e, from, to) => {
108
- if (from === to || !ids.has(from) || !ids.has(to)) return;
109
- const key = `${from}|${to}|${e.kind}|${e.flow || ''}`;
110
- if (seen.has(key)) return;
111
- seen.add(key);
112
- out.push({ ...e, from, to, status: e.status || 'live', phase: undefined });
113
- };
114
- edges.forEach((e) => {
115
- // A publisher page's `calls` edge to an outside system is the app's `api` flow already
116
- if (e.kind === 'calls' && apiFlowPairs.has(`${lift(e.from)}|${lift(e.to)}`)) return;
117
- // What a container pulls or calls itself (its image registry, its own cloud services) is not the API's data flow
118
- if (e.kind === 'calls' && byId.get(e.from)?.type === 'container') return;
119
- if (e.kind === 'flow' || ['calls', 'triggers', 'delivers'].includes(e.kind)) return add(e, lift(e.from), lift(e.to));
120
- if (e.kind === 'reads' || e.kind === 'writes') {
121
- const page = e.kind === 'reads' ? e.to : e.from;
122
- // A page of an app server reaches its rows through the API: only the API's own endpoints and the services touch a table here
123
- if (byId.get(page)?.type === 'page' && !apis.has(lift(page))) return;
124
- return add(e, lift(e.from), lift(e.to));
125
- }
126
- });
127
- return { tiers, ids, edges: out };
128
- }
28
+ export { buildDataFlow } from './flow-build.js';
129
29
 
130
30
  // ---------------------------------------------------------------------------
131
- // Legend and the panel's "Data flows" block
31
+ // Legend and the panel's "Data flows" block (engine/flow-ui.js, on an instance)
132
32
  // ---------------------------------------------------------------------------
133
- export function renderFlowLegend() {
134
- const el = document.getElementById('flow-legend');
135
- if (!el) return;
136
- const activeLayers = layersOf(state);
137
- if (activeLayers.flow === false && activeLayers.table === false) { el.innerHTML = ''; el.hidden = true; return; }
138
- el.hidden = false;
139
- const row = (swatch, text) => `<div class="hx-legend-row"><span class="hx-legend-swatch">${swatch}</span><span>${text}</span></div>`;
140
- el.innerHTML = `
141
- <div class="hx-menu-section" data-corn="menu-section">
142
- <div class="hx-menu-title" data-corn="menu-title">
143
- <span>Data Flow</span>
144
- </div>
145
- ${Object.values(FLOW_STYLES).map((s) => row(`<span data-corn="swatch" class="hx-swatch-line" style="background:${themed(s.color, state.theme)}"></span>`, s.label)).join('')}
146
- </div>`;
147
- }
148
-
149
- export function flowSummary(node) {
150
- const flows = state.edges.filter((e) => e.kind === 'flow' && (e.from === node.id || e.to === node.id));
151
- const fact = (key, list, out) => (list.length
152
- ? `<div class="hx-fact" data-corn="section"><div class="hx-fact-k">${key}</div><div class="hx-fact-v">${capped(list.map((e) => `<div class="hx-line"><span><span class="hx-name">${escHtml(nameOf(out ? e.to : e.from))}</span> · ${escHtml(e.label)}${e.status === 'live' ? '' : ' <span class="hx-warn">(proposed)</span>'}</span></div>`))}</div></div>`
153
- : '');
154
- return fact('Sends to', flows.filter((e) => e.from === node.id), true) + fact('Gets from', flows.filter((e) => e.to === node.id && e.from !== node.id), false);
155
- }
33
+ export const renderFlowLegend = () => F.renderFlowLegend(pageInstance());
34
+ export const flowSummary = (node) => F.flowSummary(pageInstance(), node);
package/explorer/fly.js CHANGED
@@ -1,48 +1,16 @@
1
1
  /**
2
2
  * @module explorer/fly
3
3
  *
4
- * The camera flying to a place: a short glide to `{ x, y, zoom }`, as the scenario player's steps do, so a match chosen in a search
5
- * is not a jump the eye has to find again. Under reduced motion the camera jumps. A new flight replaces the one in the air, and a
6
- * hand on the map (a pan, a wheel) is not fought: `stopFlight()` ends it (input.js calls it when the pointer takes the camera).
7
- * It is a frame client of render.js's loop, so it asks for frames only while it flies.
4
+ * A bridge (spec 0011 D2, step 4): the camera's flight now lives in engine/fly.js, one per instance. This file keeps the old names for the
5
+ * modules that are not yet on an instance (page.js). It goes when page.js is converted.
8
6
  */
7
+ import { pageInstance } from './state.js';
8
+ import { pageMap } from './render.js';
9
+ import * as F from './engine/fly.js';
9
10
 
10
- import { state } from './state.js';
11
- import { render, ensureFlowLoop, addFrameClient } from './render.js';
12
- import { flowReduceMotion } from './flows.js';
13
-
14
- /** How quickly the camera closes on the target: the time constant of the glide (ms) */
15
- export const FLY_MS = 120;
16
- let glide = null; // { to: {x, y, zoom}, last: nowMs|null }
17
-
18
- /** Flies the camera to `target` (jumps there when motion is reduced) */
19
- export function flyTo(target) {
20
- if (!target) return;
21
- if (flowReduceMotion || !state.width) { Object.assign(state.camera, target); glide = null; render(); return; }
22
- glide = { to: { ...target }, last: null };
23
- ensureFlowLoop();
24
- }
25
-
26
- /** Ends a flight where it is */
27
- export function stopFlight() { glide = null; }
28
-
29
- /** Whether the camera is in the air */
30
- export const flying = () => !!glide;
31
-
32
- /** One frame of the glide (exported so a test can be the loop) */
33
- export function tickFlight(now) {
34
- if (!glide) return;
35
- const dt = glide.last === null ? 16 : Math.min(now - glide.last, 100);
36
- glide.last = now;
37
- const k = 1 - Math.exp(-dt / FLY_MS);
38
- const cam = state.camera;
39
- cam.x += (glide.to.x - cam.x) * k;
40
- cam.y += (glide.to.y - cam.y) * k;
41
- cam.zoom += (glide.to.zoom - cam.zoom) * k;
42
- if (Math.abs(glide.to.x - cam.x) < 0.5 && Math.abs(glide.to.y - cam.y) < 0.5 && Math.abs(glide.to.zoom - cam.zoom) < 0.002) {
43
- Object.assign(cam, glide.to);
44
- glide = null;
45
- }
46
- }
47
-
48
- addFrameClient({ wants: flying, tick: tickFlight });
11
+ export { FLY_MS } from './engine/fly.js';
12
+ const page = () => { pageMap(); return pageInstance(); }; // the flight joins the page map's loop, so the map is there first
13
+ export const flyTo = (target) => F.flyTo(page(), target);
14
+ export const stopFlight = () => F.stopFlight(page());
15
+ export const flying = () => F.flying(page());
16
+ export const tickFlight = (now) => F.tickFlight(page(), now);
package/explorer/hint.js CHANGED
@@ -1,92 +1,19 @@
1
1
  /**
2
2
  * @module explorer/hint
3
3
  *
4
- * The hint at the map's corner ("Click a node for what it is"; CF review F56). Three rules:
5
- * - its words follow the pointer: `hintInspect` / `hintDrag` for a mouse or a trackpad, `hintInspectTouch` / `hintDragTouch` where the
6
- * main pointer is coarse (a finger). A repo that sets only `hintInspect` (or `hintDrag`) gets its words on both;
7
- * - it goes once the person has selected a node, for the rest of the session (sessionStorage; the Flow view's own description stays,
8
- * since it says what Flow is, not how to use the map);
9
- * - it is never shown over an open proposal, a node panel, the Work panel or a sheet.
10
- * The icon is `[data-corn="hint-icon"]`, so a theme can restyle or replace it.
4
+ * A bridge (spec 0011 D2, step 4): the hint at the map's corner now lives in engine/hint.js, one per instance. This file keeps the old names for
5
+ * the modules that are not yet on an instance (page.js, view.js), bound to the page's instance. It goes when view.js and page.js are converted.
11
6
  */
12
-
13
- import { state } from './state.js';
14
- import { isOverridden, t } from './strings.js';
15
-
16
- export const HINT_STORAGE_KEY = 'cornfield:hint-done';
17
-
18
- const $ = (id) => document.getElementById(id);
19
-
20
- /** Whether the main pointer is a finger (`(pointer: coarse)`) */
21
- export function coarsePointer(win = typeof window !== 'undefined' ? window : null) {
22
- try { return !!(win && win.matchMedia && win.matchMedia('(pointer: coarse)').matches); } catch { return false; }
23
- }
24
-
25
- /** The words by the pointer: the Touch ones on a finger, unless the repo set only the plain key (then its words serve both) */
26
- export function hintWords(plain, touch, coarse) {
27
- return coarse && (touch.set || !plain.set) ? touch.text : plain.text;
28
- }
29
-
30
- /** The hint for the view in force */
31
- export function hintText(coarse = coarsePointer()) {
32
- if (state.view === 'dataflow') return t('hintDataFlow');
33
- return state.isFreeform
34
- ? hintWords({ text: t('hintDrag'), set: isOverridden('hintDrag') }, { text: t('hintDragTouch'), set: isOverridden('hintDragTouch') }, coarse)
35
- : hintWords({ text: t('hintInspect'), set: isOverridden('hintInspect') }, { text: t('hintInspectTouch'), set: isOverridden('hintInspectTouch') }, coarse);
36
- }
37
-
38
- let dismissed = false;
39
- try { dismissed = window.sessionStorage.getItem(HINT_STORAGE_KEY) === '1'; } catch { dismissed = false; }
40
-
41
- /** Remembers that a node was selected: the hint is not shown again this session */
42
- export function dismissHint() {
43
- if (dismissed) return;
44
- dismissed = true;
45
- try { window.sessionStorage.setItem(HINT_STORAGE_KEY, '1'); } catch { /* storage blocked: it holds for this page load */ }
46
- syncHint();
47
- }
48
-
49
- /** For tests: the hint is new again */
50
- export function resetHintForTests() {
51
- dismissed = false;
52
- try { window.sessionStorage.removeItem(HINT_STORAGE_KEY); } catch { /* none */ }
53
- }
54
-
55
- /** What covers the map: an open proposal, the node panel, the Work panel, a sheet of the dock */
56
- export function mapCovered(doc = document) {
57
- const open = (sel) => doc.querySelector(sel);
58
- const bar = open('#proposal-bar');
59
- if (bar && !bar.hidden) return true;
60
- const drawer = open('#spec-drawer');
61
- if (drawer && drawer.classList.contains('drawer-open')) return true;
62
- const work = open('#forge-panel');
63
- if (work && work.classList.contains('forge-open')) return true;
64
- return !!doc.querySelector('[data-corn="scenario-player"]'); // a scenario is playing (a sheet on a phone)
65
- }
66
-
67
- /** Words, and whether it shows, for the state of the page now */
68
- export function syncHint() {
69
- const text = $('instruction-badge-text');
70
- const words = hintText();
71
- if (text && text.textContent !== words) text.textContent = words;
72
- const hint = text && text.closest('[data-corn="hint"]');
73
- if (!hint) return;
74
- const hide = mapCovered() || (dismissed && state.view !== 'dataflow');
75
- if (hint.hidden !== hide) hint.hidden = hide;
76
- }
77
-
78
- /** Keeps the hint right as panels open and close, and as the pointer kind changes. Returns how to stop. */
79
- export function watchHint(doc = document) {
80
- const win = doc.defaultView;
81
- const stops = [];
82
- const stage = doc.querySelector('[data-corn="stage"]') || doc.body;
83
- if (win && win.MutationObserver && stage) {
84
- const mo = new win.MutationObserver(syncHint);
85
- mo.observe(stage, { attributes: true, attributeFilter: ['class', 'hidden', 'inert'], childList: true, subtree: true });
86
- stops.push(() => mo.disconnect());
87
- }
88
- const media = win && win.matchMedia ? win.matchMedia('(pointer: coarse)') : null;
89
- if (media && media.addEventListener) { media.addEventListener('change', syncHint); stops.push(() => media.removeEventListener('change', syncHint)); }
90
- syncHint();
91
- return () => stops.forEach((fn) => fn());
92
- }
7
+ import { pageInstance } from './state.js';
8
+ import * as H from './engine/hint.js';
9
+
10
+ export { HINT_STORAGE_KEY, hintWords } from './engine/hint.js';
11
+ export const coarsePointer = (win = typeof window !== 'undefined' ? window : null) => H.coarsePointer(win);
12
+ export const hintText = (coarse) => H.hintText(pageInstance(), coarse);
13
+ export const dismissHint = () => H.dismissHint(pageInstance());
14
+ export const resetHintForTests = () => H.resetHint(pageInstance());
15
+ /** @param {Document} [doc] kept for the old signature: the page instance is over the document */
16
+ export const mapCovered = (doc) => H.mapCovered(doc && doc !== pageInstance().root ? { el: (id) => doc.getElementById(id), root: doc } : pageInstance());
17
+ export const syncHint = () => H.syncHint(pageInstance());
18
+ /** @param {Document} [doc] kept for the old signature */
19
+ export const watchHint = () => H.watchHint(pageInstance());
@@ -44,45 +44,41 @@
44
44
  </button>
45
45
  </div>
46
46
 
47
- <!-- The Layers chip: how many of the layers are on; it opens the layers menu. On a phone it sits on the map, top left -->
47
+ <!-- The Layers chip: how many of the layers are on; it opens the layers menu. On a phone it sits on the map, top left. It is a piece (explorer/pieces/layers.js): page.js mounts it here. Until then a stand-in (its markup without ids) holds its place, so the first paint has the chip and nothing moves when the piece comes; test/explorer/page-pieces.test.js keeps the two the same -->
48
+ <!--corn-placeholder:layers/menu-->
48
49
  <div class="hx-menu-wrap hx-layers">
49
- <button type="button" id="legend-toggle-btn" class="hx-layers-chip" data-action="toggle-layers-menu" aria-expanded="false" aria-controls="legend-dropdown" data-corn="layers-button"><span data-corn-string="layers">Layers</span><span id="layers-count" class="hx-layers-count" data-corn="count"></span></button>
50
-
51
- <!-- Interactive section toggles and the legend -->
52
- <div id="legend-dropdown" class="hx-menu glass" hidden data-corn="layers-menu">
53
- <div class="hx-menu-title hx-menu-head" data-corn="menu-title">
50
+ <button type="button" class="hx-layers-chip" data-action="toggle-layers-menu" aria-expanded="false" data-corn="layers-button" part="layers-button"><span data-corn-string="layers">Layers</span><span class="hx-layers-count" data-corn="count" part="count"></span></button>
51
+ <div class="hx-menu glass" hidden data-corn="layers-menu" part="layers-menu">
52
+ <div class="hx-menu-title hx-menu-head" data-corn="menu-title" part="menu-title">
54
53
  <span>Section Toggles</span>
55
54
  <span class="hx-menu-links">
56
- <button type="button" class="hx-textbtn hx-textbtn--accent" data-action="layers-all" data-corn="layers-all" data-corn-kind="quiet" data-corn-string="layersAll">All</button>
55
+ <button type="button" class="hx-textbtn hx-textbtn--accent" data-action="layers-all" data-corn="layers-all" part="layers-all" data-corn-kind="quiet" data-corn-string="layersAll">All</button>
57
56
  <span class="hx-faint">•</span>
58
- <button type="button" class="hx-textbtn" data-action="layers-none" data-corn="layers-none" data-corn-kind="quiet" data-corn-string="layersNone">None</button>
57
+ <button type="button" class="hx-textbtn" data-action="layers-none" data-corn="layers-none" part="layers-none" data-corn-kind="quiet" data-corn-string="layersNone">None</button>
59
58
  </span>
60
59
  </div>
61
60
  <div class="hx-menu-body">
62
- <p id="layers-preset-note" class="hx-note" data-corn="notice" hidden>The data-flow view shows its own tiers and ignores these toggles. Switch it off to use them.</p>
63
- <div id="layer-toggles-container" class="hx-toggles"></div>
64
- <div id="flow-legend" hidden></div>
65
- <div id="edge-key" class="hx-menu-section" data-corn="legend-key"></div>
66
- <div id="cloud-legend" class="hx-menu-section" data-corn="menu-section" hidden></div>
67
-
68
- <!-- What the marks of agent runs mean, while there are runs on the map (runs-map.js) -->
69
- <div id="runs-legend" class="hx-menu-section" data-corn="menu-section" hidden>
70
- <div class="hx-menu-title" data-corn="menu-title"><span>Agent runs</span></div>
61
+ <p class="hx-note" data-corn="notice" part="notice" hidden>The data-flow view shows its own tiers and ignores these toggles. Switch it off to use them.</p>
62
+ <div class="hx-toggles"></div>
63
+ <div hidden></div>
64
+ <div class="hx-menu-section" data-corn="legend-key" part="legend-key"></div>
65
+ <div class="hx-menu-section" data-corn="menu-section" part="menu-section" hidden></div>
66
+ <div class="hx-menu-section" data-corn="menu-section" part="menu-section" hidden>
67
+ <div class="hx-menu-title" data-corn="menu-title" part="menu-title"><span>Agent runs</span></div>
71
68
  <div class="hx-legend-row"><span class="hx-run-swatch hx-run-swatch--flight" aria-hidden="true"></span><span>In flight: a pulsing ring (still under reduced motion)</span></div>
72
69
  <div class="hx-legend-row"><span class="hx-run-swatch hx-run-swatch--collision" aria-hidden="true"></span><span>Collision: dashed ring, ⚠ and the words, where two open runs change one node</span></div>
73
70
  </div>
74
-
75
- <!-- What a proposal's marks mean, while one is open (proposal.js) -->
76
- <div id="proposal-legend" class="hx-menu-section" data-corn="menu-section" hidden>
77
- <div class="hx-menu-title" data-corn="menu-title"><span>Proposal marks</span></div>
78
- <div class="hx-legend-row"><span class="hx-mark-dot hx-mark-dot--added" data-corn="mark-dot" data-corn-state="added"></span><span>Added: dashed ring</span></div>
79
- <div class="hx-legend-row"><span class="hx-mark-dot hx-mark-dot--changed" data-corn="mark-dot" data-corn-state="changed"></span><span>Changed: solid ring</span></div>
80
- <div class="hx-legend-row"><span class="hx-mark-dot hx-mark-dot--removed" data-corn="mark-dot" data-corn-state="removed"></span><span>Removed: faded ring, label struck through</span></div>
81
- <div class="hx-legend-row"><span class="hx-mark-dot hx-mark-dot--edit" data-corn="mark-dot" data-corn-state="edit"></span><span>Your edit: dotted ring, long-dashed line</span></div>
71
+ <div class="hx-menu-section" data-corn="menu-section" part="menu-section" hidden>
72
+ <div class="hx-menu-title" data-corn="menu-title" part="menu-title"><span>Proposal marks</span></div>
73
+ <div class="hx-legend-row"><span class="hx-mark-dot hx-mark-dot--added" data-corn="mark-dot" part="mark-dot" data-corn-state="added"></span><span>Added: dashed ring</span></div>
74
+ <div class="hx-legend-row"><span class="hx-mark-dot hx-mark-dot--changed" data-corn="mark-dot" part="mark-dot" data-corn-state="changed"></span><span>Changed: solid ring</span></div>
75
+ <div class="hx-legend-row"><span class="hx-mark-dot hx-mark-dot--removed" data-corn="mark-dot" part="mark-dot" data-corn-state="removed"></span><span>Removed: faded ring, label struck through</span></div>
76
+ <div class="hx-legend-row"><span class="hx-mark-dot hx-mark-dot--edit" data-corn="mark-dot" part="mark-dot" data-corn-state="edit"></span><span>Your edit: dotted ring, long-dashed line</span></div>
77
+ </div>
82
78
  </div>
83
- </div><!-- .hx-menu-body: the rows scroll, the title with All and None stays (spec 0009 D8) -->
84
79
  </div>
85
80
  </div>
81
+ <!--corn-piece:layers/menu-->
86
82
 
87
83
  <!-- The live layer's chip (explorer/live.js, spec 0029): shown once a live layer is on; a dot on a phone, its line on tap -->
88
84
  <div id="live-wrap" class="hx-menu-wrap hx-live" data-tone="idle" hidden>
@@ -95,24 +91,26 @@
95
91
  </div>
96
92
 
97
93
  <div class="hx-header-right">
98
- <!-- Search: a field with its key hint on a desktop; an icon that opens the search bar on a phone -->
99
- <button type="button" id="mobile-search-toggle" class="hx-hdr-icon hx-only-mobile" data-corn="mobile-search-button" data-action="toggle-mobile-search" aria-label="Open Search" title="Search nodes" data-corn-kind="icon">
94
+ <!-- Search: a field with its key hint on a desktop; an icon that opens the search bar on a phone. It is a piece (explorer/pieces/search.js): page.js mounts it here, in place of the stand-in below (as the Layers chip's) -->
95
+ <!--corn-placeholder:search/field-->
96
+ <button type="button" class="hx-hdr-icon hx-only-mobile" data-corn="mobile-search-button" part="mobile-search-button" data-action="toggle-mobile-search" aria-label="Open Search" title="Search nodes" data-corn-kind="icon">
100
97
  <svg viewBox="0 0 16 16" width="18" height="18" 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>
101
98
  </button>
102
99
 
103
- <div class="hx-search" role="search" data-corn="search">
100
+ <div class="hx-search" role="search" data-corn="search" part="search">
104
101
  <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>
105
- <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" />
106
- <kbd class="hx-kbd" data-corn="search-key" aria-hidden="true">/</kbd>
107
- <span id="search-steps" class="hx-search-steps" data-corn="search-steps" hidden>
108
- <span id="search-count" class="hx-search-count" data-corn="search-count" aria-hidden="true"></span>
102
+ <input type="text" class="hx-search-input" placeholder="Search..." data-corn-string-placeholder="searchPlaceholder" aria-label="Search nodes" aria-keyshortcuts="/" data-corn="search-input" part="search-input" />
103
+ <kbd class="hx-kbd" data-corn="search-key" part="search-key" aria-hidden="true">/</kbd>
104
+ <span class="hx-search-steps" data-corn="search-steps" part="search-steps" hidden>
105
+ <span class="hx-search-count" data-corn="search-count" part="search-count" aria-hidden="true"></span>
109
106
  <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>
110
107
  <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>
111
108
  <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>
112
109
  </span>
113
- <div id="search-status" class="hx-search-status" role="status" aria-live="polite" data-corn="search-status"></div>
114
- <div id="search-results" class="hx-search-results" data-corn="search-results" hidden></div>
110
+ <div class="hx-search-status" role="status" aria-live="polite" data-corn="search-status" part="search-status"></div>
111
+ <div class="hx-search-results" data-corn="search-results" part="search-results" hidden></div>
115
112
  </div>
113
+ <!--corn-piece:search/field-->
116
114
 
117
115
  <!-- The Work toggle (explorer/forge-panel.js): opens the Work panel; shown only when the config names a forge -->
118
116
  <button type="button" id="forge-btn" class="hx-work" data-action="toggle-forge" aria-expanded="false" aria-controls="forge-panel" aria-label="Work" data-corn-string-aria-label="issuesAndPrs" title="Issues, pull requests and deploys: a pull request lights the nodes it changes, a deploy the nodes it restarted" hidden data-corn="forge-button">
@@ -168,29 +166,13 @@
168
166
  </div>
169
167
  </header>
170
168
 
171
- <!-- Mobile search bar -->
172
- <div id="mobile-search-bar" class="hx-mobile-search glass-header" role="search" hidden data-corn="mobile-search">
173
- <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" />
174
- <button type="button" class="hx-textbtn" data-action="close-mobile-search" data-corn-kind="quiet">Cancel</button>
175
- <span id="mobile-search-steps" class="hx-search-steps" data-corn="search-steps" hidden>
176
- <span id="mobile-search-count" class="hx-search-count" data-corn="search-count" aria-hidden="true"></span>
177
- <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>
178
- <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>
179
- <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>
180
- </span>
181
- <div id="mobile-search-status" class="hx-search-status" role="status" aria-live="polite" data-corn="search-status"></div>
182
- <div id="mobile-search-results" class="hx-search-results" data-corn="search-results" hidden></div>
183
- </div>
169
+ <!-- Mobile search bar: part of the search piece, which mounts it here -->
170
+ <!--corn-piece:search/bar-->
184
171
 
185
172
  <!-- The map -->
186
173
  <div class="hx-stage" role="main" data-corn="stage">
187
- <!-- The map takes the keyboard when it has the focus (keyboard.js): its keys are below, read out with its name -->
188
- <canvas id="graph-canvas" tabindex="0" role="application" aria-roledescription="map" aria-label="Topology map" aria-describedby="map-keys-help" data-corn="map-canvas"></canvas>
189
- <p id="map-keys-help" class="hx-sr-only">Arrow keys pan, plus and minus zoom, 0 fits the map. N and P select the next and the previous node, Home and End the first and the last. F frames the selected node and what it lights. Enter goes to the selected node's panel, Escape closes it. In Freeform, Alt and an arrow moves the selected node.</p>
190
- <!-- What the keyboard landed on, said by a screen reader (keyboard.js) -->
191
- <p id="map-announcer" class="hx-sr-only" role="status" aria-live="polite"></p>
192
- <!-- Every label, drawn on its own transparent canvas over the map (explorer/labels.js); the map canvas still gets the pointer -->
193
- <canvas id="label-canvas" aria-hidden="true" data-corn="label-canvas"></canvas>
174
+ <!-- The map: its canvas (focusable, its keys read out with its name), the help for its keys, the announcer the keyboard speaks in and the canvas its labels are drawn on, made here by explorer/pieces/map.js -->
175
+ <!--corn-piece:map/stage-->
194
176
  <!-- The nodes agent runs are changing, marked over the map (explorer/runs-map.js): a picture; the Runs view says the same in words -->
195
177
  <div id="run-overlay" class="hx-run-overlay" aria-hidden="true" hidden data-corn="run-overlay"></div>
196
178
 
@@ -352,32 +334,8 @@
352
334
  </div>
353
335
  </aside>
354
336
 
355
- <!-- Node panel: a slide-over on desktop, a bottom sheet on mobile -->
356
- <aside id="spec-drawer" class="hx-drawer glass" aria-label="Node details" inert data-corn="node-panel">
357
- <div class="hx-drawer-body">
358
- <div class="hx-drawer-head">
359
- <div class="hx-drawer-id">
360
- <p class="hx-kicker"><span id="drawer-badge" data-corn="badge">Atom</span><span id="drawer-host" data-corn="node-host"></span><span id="drawer-diff" class="hx-diffpill" data-corn="diff-pill" hidden></span></p>
361
- <h2 id="drawer-title" class="hx-drawer-title" data-corn="node-title">&lt;pop-button&gt;</h2>
362
- </div>
363
- <button type="button" class="hx-close" data-action="close-drawer" aria-label="Close" data-corn-kind="icon">✕</button>
364
- </div>
365
-
366
- <p id="drawer-description" class="hx-lead" hidden></p>
367
-
368
- <div class="hx-block">
369
- <div id="drawer-meta-list" class="hx-meta"></div>
370
- </div>
371
- </div>
372
-
373
- <div class="hx-drawer-foot" data-corn="node-foot">
374
- <a data-corn="open-link" id="drawer-file-btn" data-corn-kind="primary" class="hx-open" href="#" target="_blank" rel="noreferrer" hidden>Open file ↗</a>
375
- <a data-corn="open-link" id="drawer-open-btn" data-corn-kind="primary" class="hx-open" href="#" target="_blank" rel="noreferrer" hidden>Open route ↗</a>
376
- <button data-corn-kind="secondary" type="button" id="drawer-run-btn" class="hx-btn hx-foot-btn" data-action="start-run" data-corn-string="startRun" hidden>Start a run</button>
377
- <button data-corn-kind="quiet" type="button" class="hx-btn hx-btn--quiet hx-foot-btn" data-action="copy-spec" data-corn-string="copySpec">Copy Spec</button>
378
- <p id="copy-spec-result" class="hx-forge-result" data-corn="result" hidden></p>
379
- </div>
380
- </aside>
337
+ <!-- Node panel: a slide-over on desktop, a bottom sheet on mobile. It is a piece (explorer/pieces/node-panel.js): page.js mounts it here -->
338
+ <!--corn-piece:node-panel/drawer-->
381
339
  </div>
382
340
 
383
341
  <div class="hx-hint glass" data-corn="hint">
@@ -394,7 +352,7 @@
394
352
  <button type="button" class="hx-btn hx-btn--active" data-action="retry" data-corn-kind="primary" data-corn-string="retry">Retry</button>
395
353
  </div>
396
354
 
397
- <div id="drawer-backdrop" class="hx-backdrop" data-action="close-drawer" hidden data-corn="backdrop"></div>
355
+ <!--corn-piece:node-panel/backdrop-->
398
356
 
399
357
  </div>
400
358