cornfield 0.33.1 → 0.34.1
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 -1
- package/core/strings.js +1 -0
- package/explorer/camera.js +38 -5
- package/explorer/cloud-model.js +33 -50
- package/explorer/explorer.css +19 -24
- package/explorer/index.html +2 -0
- package/explorer/input.js +3 -3
- package/explorer/keyboard.js +2 -2
- package/explorer/layers.js +33 -9
- package/explorer/layout.js +113 -22
- package/explorer/main.js +4 -0
- package/explorer/panels.js +21 -2
- package/explorer/render.js +33 -5
- package/explorer/renderer-canvas2d.js +110 -18
- package/explorer/scene.js +2 -2
- package/explorer/search-status.js +41 -0
- package/explorer/tokens.css +0 -3
- package/explorer/whatif.js +22 -8
- package/package.json +1 -1
- package/server/compress.js +135 -0
- package/server/proxy.js +2 -0
- package/server/server.js +2 -0
package/core/contrast.js
CHANGED
|
@@ -348,7 +348,7 @@ const toText = (token, pct) => `color-mix(in srgb, var(${token}) ${pct}%, var(--
|
|
|
348
348
|
export const TEXT_TOKENS = Object.freeze(['--corn-text', '--corn-text-2', '--corn-text-3', '--corn-accent-text', '--corn-ok', '--corn-warn', '--corn-bad', '--corn-info', '--corn-added-text', '--corn-edit-text']);
|
|
349
349
|
/** The tinted backgrounds, with the text that sits on each */
|
|
350
350
|
export const SOFT_PAIRS = Object.freeze([
|
|
351
|
-
['--corn-ok', '--corn-ok-soft'],
|
|
351
|
+
['--corn-ok', '--corn-ok-soft'],
|
|
352
352
|
['--corn-accent-text', '--corn-accent-soft'], ['--corn-hue-orange-text', '--corn-hue-orange-soft'],
|
|
353
353
|
]);
|
|
354
354
|
/** Solid fills that carry `--corn-ground` as their text (a pressed data-flow button, a chip, the What-if toggle, the House chip) */
|
package/core/strings.js
CHANGED
package/explorer/camera.js
CHANGED
|
@@ -10,19 +10,27 @@
|
|
|
10
10
|
* @typedef {{ x: number, y: number, zoom: number }} Camera
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
+
/** The floor of a map that fits above it; a bigger map (or a smaller screen) needs a lower one: render.js `getMinZoom()` */
|
|
13
14
|
export const ZOOM_MIN = 0.25;
|
|
14
15
|
export const ZOOM_MAX = 3.0;
|
|
16
|
+
/** Whatever the map, never below this (a bounding box of nothing, a map of a million px) */
|
|
17
|
+
export const ZOOM_FLOOR = 0.005;
|
|
15
18
|
|
|
16
|
-
|
|
19
|
+
/** `min` is the floor for this map and screen (`getMinZoom()`); it never rises above the default floor */
|
|
20
|
+
export const clampZoom = (zoom, min = ZOOM_MIN) => Math.max(Math.max(ZOOM_FLOOR, Math.min(min, ZOOM_MIN)), Math.min(ZOOM_MAX, zoom));
|
|
21
|
+
|
|
22
|
+
/** Zooming out is never zooming in: below the floor already (the layers changed), a step out stays where it is */
|
|
23
|
+
const stepZoom = (from, to, min) => (to < from ? Math.min(from, clampZoom(to, min)) : clampZoom(to, min));
|
|
17
24
|
|
|
18
25
|
/**
|
|
19
26
|
* The camera after zooming by `factor` with the screen point (px, py) held still.
|
|
20
27
|
* @param {Camera} camera
|
|
21
28
|
* @param {number} factor
|
|
29
|
+
* @param {number} [min] the floor for this map
|
|
22
30
|
* @returns {Camera}
|
|
23
31
|
*/
|
|
24
|
-
export function zoomAbout(camera, factor, px, py) {
|
|
25
|
-
const zoom =
|
|
32
|
+
export function zoomAbout(camera, factor, px, py, min = ZOOM_MIN) {
|
|
33
|
+
const zoom = stepZoom(camera.zoom, camera.zoom * factor, min);
|
|
26
34
|
const wx = (px - camera.x) / camera.zoom; // the world point under the pointer
|
|
27
35
|
const wy = (py - camera.y) / camera.zoom;
|
|
28
36
|
return { x: px - wx * zoom, y: py - wy * zoom, zoom };
|
|
@@ -45,9 +53,34 @@ export const pinchStart = (camera, dist, mid) => ({ x: camera.x, y: camera.y, zo
|
|
|
45
53
|
* @param {{ x: number, y: number }} mid their middle now
|
|
46
54
|
* @returns {Camera}
|
|
47
55
|
*/
|
|
48
|
-
export function pinchCamera(start, dist, mid) {
|
|
49
|
-
const zoom =
|
|
56
|
+
export function pinchCamera(start, dist, mid, min = ZOOM_MIN) {
|
|
57
|
+
const zoom = stepZoom(start.zoom, start.zoom * (dist / start.dist), min);
|
|
50
58
|
const wx = (start.mid.x - start.x) / start.zoom;
|
|
51
59
|
const wy = (start.mid.y - start.y) / start.zoom;
|
|
52
60
|
return { x: mid.x - wx * zoom, y: mid.y - wy * zoom, zoom };
|
|
53
61
|
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The camera panned (never zoomed) so a world point is inside `box` (screen px), or null when it already is. A point
|
|
65
|
+
* outside is put in the middle of the box, on the axis it is outside of. `pad` is the room it needs from the edge
|
|
66
|
+
* (its disc and a little more); a box smaller than twice that is the centre only.
|
|
67
|
+
* @param {Camera} camera
|
|
68
|
+
* @param {{ x: number, y: number }} point world position
|
|
69
|
+
* @param {{ left: number, top: number, right: number, bottom: number }} box the part of the screen that shows the map
|
|
70
|
+
* @param {number} [pad]
|
|
71
|
+
* @returns {Camera|null}
|
|
72
|
+
*/
|
|
73
|
+
export function panIntoView(camera, point, box, pad = 0) {
|
|
74
|
+
const sx = camera.x + point.x * camera.zoom;
|
|
75
|
+
const sy = camera.y + point.y * camera.zoom;
|
|
76
|
+
const px = Math.min(pad, (box.right - box.left) / 2);
|
|
77
|
+
const py = Math.min(pad, (box.bottom - box.top) / 2);
|
|
78
|
+
const outX = sx < box.left + px || sx > box.right - px;
|
|
79
|
+
const outY = sy < box.top + py || sy > box.bottom - py;
|
|
80
|
+
if (!outX && !outY) return null;
|
|
81
|
+
return {
|
|
82
|
+
x: outX ? (box.left + box.right) / 2 - point.x * camera.zoom : camera.x,
|
|
83
|
+
y: outY ? (box.top + box.bottom) / 2 - point.y * camera.zoom : camera.y,
|
|
84
|
+
zoom: camera.zoom,
|
|
85
|
+
};
|
|
86
|
+
}
|
package/explorer/cloud-model.js
CHANGED
|
@@ -8,14 +8,15 @@
|
|
|
8
8
|
* (`legend`), in the panel (`title`, `color`). The one place these live: scene.js, the legend, the panel and
|
|
9
9
|
* the House view's Cloud band (CLOUD-08) all read them here; the outage colours (CLOUD-07) are `color`.
|
|
10
10
|
* - `externalLayer(node)`: the Layers key of an `external` node, `cloud` or `web` (the public web, spec D3).
|
|
11
|
-
* - `
|
|
12
|
-
* - `cloudPanelHtml(node, nodes, edges)`:
|
|
11
|
+
* - `planLabel`, `cloudUsedBy`: what the node panel shows of a cloud node, as data.
|
|
12
|
+
* - `cloudPanelHtml(node, nodes, edges)`: the node panel's facts for it, as HTML (panels.js puts them under the head).
|
|
13
13
|
*
|
|
14
14
|
* Nothing here reads an env var name, a token or a registry `match` list: a cloud node does not carry them, and
|
|
15
15
|
* the panel shows only the node's own fields and the labels of the edges into it (the registry's words).
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
import { escapeHtml as esc } from '../core/text.js';
|
|
19
|
+
import { capped } from './capped.js';
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* When an outage bites, in order of how soon. `dash` is the scene edge's dash (world units, like a proposal
|
|
@@ -44,12 +45,6 @@ export function planLabel(plan) {
|
|
|
44
45
|
return plan.note ? `${TIER_WORDS[plan.tier]} · ${plan.note}` : TIER_WORDS[plan.tier];
|
|
45
46
|
}
|
|
46
47
|
|
|
47
|
-
/** The kind and the roles, as the panel's badges: ['Cloud', 'runtime', 'account'], or ['Public web', 'not cloud'] */
|
|
48
|
-
export function cloudBadges(node) {
|
|
49
|
-
if (node.kind === 'web') return ['Public web', 'not cloud'];
|
|
50
|
-
return ['Cloud', ...(node.roles || [])];
|
|
51
|
-
}
|
|
52
|
-
|
|
53
48
|
/** What a user of a cloud service is called, one and many (`nounOf(type, n)`: the outage scenario's words too) */
|
|
54
49
|
const NOUNS = {
|
|
55
50
|
container: ['container', 'containers'], machine: ['machine', 'machines'], app: ['app', 'apps'],
|
|
@@ -92,60 +87,48 @@ export function cloudUsedBy(node, nodes, edges) {
|
|
|
92
87
|
return out;
|
|
93
88
|
}
|
|
94
89
|
|
|
95
|
-
/**
|
|
96
|
-
|
|
90
|
+
/** The fact names for the groups of users, short enough for the panel's key column (the long words are WHEN_STYLES `title`) */
|
|
91
|
+
const WHEN_KEYS = { run: 'Breaks now', deploy: 'Breaks on deploy', renew: 'Breaks on renewal' };
|
|
97
92
|
|
|
98
|
-
const
|
|
99
|
-
const
|
|
93
|
+
const fact = (key, rows) => (rows.length ? `<div class="hx-fact" data-corn="section"><div class="hx-fact-k">${esc(key)}</div><div class="hx-fact-v">${capped(rows)}</div></div>` : '');
|
|
94
|
+
const line = (body) => `<div class="hx-line">${body}</div>`;
|
|
100
95
|
const name = (label) => `<span class="hx-name">${esc(label)}</span>`;
|
|
101
96
|
|
|
102
|
-
|
|
97
|
+
/** One user of the node: its name, (browser) when the visitor's browser makes the call, the edge's labels, and what it is when the group mixes kinds */
|
|
98
|
+
function userRow(item, mixed) {
|
|
103
99
|
const browser = item.browser ? ' <span class="hx-cloud-browser">(browser)</span>' : '';
|
|
104
|
-
|
|
100
|
+
const bits = [mixed ? nounOf(item.type, 1) : '', item.via].filter(Boolean);
|
|
101
|
+
return line(`<span>${name(item.label)}${browser}${bits.length ? `<span class="hx-faint"> · ${esc(bits.join(' · '))}</span>` : ''}</span>`);
|
|
105
102
|
}
|
|
106
103
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const rows = t.items.map((i) => userRow(i, group.color)).join('');
|
|
110
|
-
if (t.items.length <= FOLD_AT) return rows;
|
|
111
|
-
return `<details class="hx-cloud-fold"><summary>${t.items.length} ${esc(nounOf(t.type, t.items.length))}</summary>${rows}</details>`;
|
|
112
|
-
}).join('');
|
|
113
|
-
return `<div class="hx-cloud-when hx-cloud-when--${group.when}">`
|
|
114
|
-
+ `<div class="hx-cloud-when-head"><span class="hx-swatch-line hx-swatch-when hx-swatch-when--${group.when}"></span>`
|
|
115
|
-
+ `<span class="hx-glyph" style="--glyph:${group.color}">${esc(group.title)}</span><span class="hx-count">${group.count}</span></div>${lists}</div>`;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/** The Play button (spec 0031 section 8, CLOUD-07): main.js plays outage-model.js `outageScenario` for the node */
|
|
119
|
-
const playButton = (node) => `<div class="hx-sec" data-corn="section"><button type="button" class="hx-btn hx-cloud-play" data-action="play-outage" data-id="${esc(node.id)}">▶ Play: ${esc(String(node.label || node.id))} is down</button></div>`;
|
|
104
|
+
/** The Play button (spec 0031 section 8, CLOUD-07): main.js plays outage-model.js `outageScenario` for the node. A quiet button under the facts. */
|
|
105
|
+
const playButton = (node) => `<button type="button" class="hx-btn hx-btn--quiet hx-cloud-play" data-action="play-outage" data-id="${esc(node.id)}">Play: ${esc(String(node.label || node.id))} is down</button>`;
|
|
120
106
|
|
|
121
107
|
/**
|
|
122
|
-
* The node panel's
|
|
123
|
-
*
|
|
124
|
-
*
|
|
108
|
+
* The node panel's facts for a cloud node (kind `cloud`) or the public web (kind `web`), in the node panel's key/value
|
|
109
|
+
* rows (the type and the name are the panel's head): Plan, Roles, If it's down, who uses it by when its outage bites
|
|
110
|
+
* (one fact per `when` that has any, long lists folded by capped.js), what it relies on itself (calls to other cloud
|
|
111
|
+
* nodes), the webhooks it sends, then a quiet Play button (a cloud node only). The caller adds the File line.
|
|
125
112
|
*/
|
|
126
113
|
export function cloudPanelHtml(node, nodes, edges) {
|
|
127
114
|
const byId = new Map(nodes.map((n) => [n.id, n]));
|
|
128
115
|
const label = (id) => String((byId.get(id) || { label: id }).label || id);
|
|
129
|
-
const
|
|
130
|
-
const
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
+ (tier && node.plan && node.plan.note ? `<div class="hx-faint hx-cloud-plan-note">${esc(node.plan.note)}</div>` : '');
|
|
136
|
-
|
|
137
|
-
const groups = cloudUsedBy(node, nodes, edges);
|
|
138
|
-
const usedBy = groups.length ? groups.map(groupHtml).join('') : '<div class="hx-faint">Nothing on the map uses it.</div>';
|
|
116
|
+
const web = node.kind === 'web'; // the public web: no plan, no roles, no Play
|
|
117
|
+
const roles = web ? [] : node.roles || [];
|
|
118
|
+
const used = cloudUsedBy(node, nodes, edges).map((g) => {
|
|
119
|
+
const mixed = g.types.length > 1;
|
|
120
|
+
return fact(WHEN_KEYS[g.when], g.types.flatMap((t) => t.items.map((i) => userRow(i, mixed))));
|
|
121
|
+
}).join('') || fact('Used by', [line('<span class="hx-faint">Nothing on the map uses it.</span>')]);
|
|
139
122
|
|
|
140
123
|
const relies = edges.filter((e) => e.kind === 'calls' && e.from === node.id && (byId.get(e.to) || {}).type === 'external')
|
|
141
|
-
.map((e) =>
|
|
142
|
-
const pushes = edges.filter((e) => e.kind === 'delivers' && e.from === node.id).map((e) =>
|
|
143
|
-
|
|
144
|
-
return
|
|
145
|
-
+
|
|
146
|
-
+
|
|
147
|
-
+
|
|
148
|
-
+ (
|
|
149
|
-
+ (
|
|
150
|
-
+ '
|
|
124
|
+
.map((e) => line(`<span>${name(label(e.to))}${e.label ? `<span class="hx-faint"> · ${esc(e.label)}</span>` : ''}</span>`));
|
|
125
|
+
const pushes = edges.filter((e) => e.kind === 'delivers' && e.from === node.id).map((e) => line(name(label(e.to))));
|
|
126
|
+
|
|
127
|
+
return (web ? '' : fact('Plan', [line(esc(planLabel(node.plan) || TIER_WORDS.unknown))]))
|
|
128
|
+
+ fact('Roles', roles.length ? [line(esc(roles.join(', ')))] : [])
|
|
129
|
+
+ fact('If it\'s down', [line(esc(node.breaks || 'Not described yet.'))])
|
|
130
|
+
+ used
|
|
131
|
+
+ fact('Relies on', relies)
|
|
132
|
+
+ fact('Pushes to', pushes)
|
|
133
|
+
+ (web ? '' : playButton(node)); // the public web is never down as a whole (spec D3)
|
|
151
134
|
}
|
package/explorer/explorer.css
CHANGED
|
@@ -66,7 +66,7 @@ h1, h2, h3, p { margin: 0; }
|
|
|
66
66
|
.hx-chips { display: flex; flex-wrap: wrap; gap: var(--corn-space-1); padding-top: var(--corn-space-1); }
|
|
67
67
|
.hx-pt { padding-top: var(--corn-space-3); }
|
|
68
68
|
/* Headings and titles take the display family (the same as the body unless a brand sets it) */
|
|
69
|
-
.hx-title, .hx-drawer-title, .hx-
|
|
69
|
+
.hx-title, .hx-drawer-title, .hx-menu-title, .hx-confirm-title, .hx-mockup-title { font-family: var(--corn-font-display); }
|
|
70
70
|
|
|
71
71
|
/* ==== the header (CF-41) ===============================================================================================
|
|
72
72
|
Left to right: the brand, the View switch (Map, Flow, House, Fit), the Layers chip, the live chip; at the right the search,
|
|
@@ -350,7 +350,6 @@ h1, h2, h3, p { margin: 0; }
|
|
|
350
350
|
.hx-lead { font-size: var(--corn-text-base); line-height: 1.5; color: var(--corn-text-2); }
|
|
351
351
|
|
|
352
352
|
.hx-block { display: flex; flex-direction: column; gap: var(--corn-space-3); }
|
|
353
|
-
.hx-block-title { font-size: var(--corn-text-sm); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--corn-text-2); }
|
|
354
353
|
.hx-meta { display: flex; flex-direction: column; gap: var(--corn-space-5); font-size: var(--corn-text-md); color: var(--corn-text-2); overflow-wrap: anywhere; }
|
|
355
354
|
.hx-meta > :empty { display: none; } /* no live data, no threads: no gap where they would be */
|
|
356
355
|
|
|
@@ -506,8 +505,7 @@ button.hx-proposal-item:focus-visible { outline: var(--corn-focus-width) solid v
|
|
|
506
505
|
.hx-whatif-target { font-size: var(--corn-text-xs); }
|
|
507
506
|
.hx-whatif-addstep { display: flex; flex-wrap: wrap; align-items: center; gap: var(--corn-space-2); margin-top: var(--corn-space-3); }
|
|
508
507
|
.hx-whatif-addstep .hx-whatif-field { flex: 1 1 220px; }
|
|
509
|
-
.hx-whatif-
|
|
510
|
-
.hx-whatif-edges { margin-top: var(--corn-space-3); color: var(--corn-text-2); }
|
|
508
|
+
.hx-whatif-edges { color: var(--corn-text-2); }
|
|
511
509
|
.hx-whatif-edges summary { cursor: pointer; }
|
|
512
510
|
.hx-whatif-edges .hx-whatif-list { margin-top: var(--corn-space-2); max-height: 200px; overflow: auto; }
|
|
513
511
|
#graph-canvas.is-drawing-edge { touch-action: none; }
|
|
@@ -701,24 +699,7 @@ button.hx-proposal-item:focus-visible { outline: var(--corn-focus-width) solid v
|
|
|
701
699
|
.hx-swatch-when--deploy { color: var(--corn-changed); background: repeating-linear-gradient(90deg, currentColor 0 5px, transparent 5px 8px); }
|
|
702
700
|
.hx-swatch-when--renew { color: var(--corn-edit); background: repeating-linear-gradient(90deg, currentColor 0 2px, transparent 2px 5px); }
|
|
703
701
|
.hx-swatch-when--plain { color: var(--corn-text-2); } /* the legend: the map draws every call in the calls colour, so only the pattern is the key */
|
|
704
|
-
.hx-cloud-
|
|
705
|
-
.hx-cloud-badge, .hx-cloud-plan { padding: calc(var(--corn-space-1) / 2) var(--corn-space-2); border-radius: var(--corn-radius-pill); border: var(--corn-border) solid color-mix(in srgb, var(--corn-text-3) 35%, transparent); background: color-mix(in srgb, var(--corn-text-3) 12%, transparent); color: var(--corn-text-2); font-family: var(--corn-font); font-size: var(--corn-text-2xs); font-weight: 600; }
|
|
706
|
-
.hx-cloud-badge--kind { border-color: color-mix(in srgb, var(--corn-info) 45%, transparent); background: var(--corn-info-soft); color: var(--corn-info); }
|
|
707
|
-
.hx-cloud-badge--web { border-color: color-mix(in srgb, var(--corn-text-2) 45%, transparent); background: color-mix(in srgb, var(--corn-text-2) 12%, transparent); color: var(--corn-text-2); }
|
|
708
|
-
.hx-cloud-plan { margin-left: auto; }
|
|
709
|
-
.hx-cloud-plan--free { border-color: color-mix(in srgb, var(--corn-ok) 45%, transparent); background: var(--corn-ok-soft); color: var(--corn-ok); }
|
|
710
|
-
.hx-cloud-plan--paid { border-color: color-mix(in srgb, var(--corn-warn) 50%, transparent); background: var(--corn-warn-soft); color: var(--corn-warn); }
|
|
711
|
-
.hx-cloud-plan--unknown { border-style: dashed; color: var(--corn-text-3); }
|
|
712
|
-
.hx-cloud-plan--off { border-color: color-mix(in srgb, var(--corn-bad) 45%, transparent); background: var(--corn-bad-soft); color: var(--corn-bad); }
|
|
713
|
-
.hx-cloud-plan-note { padding-top: calc(var(--corn-space-1) / 2); text-align: right; font-size: var(--corn-text-2xs); }
|
|
714
|
-
.hx-cloud-breaks { padding: var(--corn-space-1) 0 calc(var(--corn-space-1) / 2); color: var(--corn-text-2); font-family: var(--corn-font); line-height: 1.5; }
|
|
715
|
-
.hx-cloud-when { padding-top: var(--corn-space-1); }
|
|
716
|
-
.hx-cloud-when-head { display: flex; align-items: center; gap: var(--corn-space-2); padding: calc(var(--corn-space-1) / 2) 0; font-weight: 600; }
|
|
717
|
-
.hx-cloud-when-head .hx-swatch-when { flex: none; }
|
|
718
|
-
.hx-cloud-fold > summary { cursor: pointer; padding: calc(var(--corn-space-1) / 2) 0 calc(var(--corn-space-1) / 2) var(--corn-space-5); color: var(--corn-text-2); }
|
|
719
|
-
.hx-cloud-fold[open] > summary { color: var(--corn-text-2); }
|
|
720
|
-
.hx-cloud-browser { color: var(--corn-info); font-size: var(--corn-text-2xs); }
|
|
721
|
-
.hx-cloud-play { width: 100%; justify-content: center; } /* the cloud panel's "Play: X is down" (spec 0031 section 8) */
|
|
702
|
+
.hx-cloud-browser { color: var(--corn-text-3); font-size: var(--corn-text-sm); }
|
|
722
703
|
|
|
723
704
|
/* ---- a panel glyph (MAP-01) ----------------------------------------------------------------------
|
|
724
705
|
A panel glyph's colour comes from script (the flow or kind it stands for, --glyph): mixed with the text colour by
|
|
@@ -1008,13 +989,27 @@ a.hx-forge-row:hover, button.hx-forge-row:hover { background: var(--corn-surface
|
|
|
1008
989
|
/* a phone: the sheet's actions are full width at the foot, each a 44px target */
|
|
1009
990
|
.hx-drawer-foot { flex-direction: column; }
|
|
1010
991
|
.hx-drawer-foot .hx-open, .hx-foot-btn { min-height: 44px; }
|
|
1011
|
-
.hx-drawer .hx-row, .hx-drawer .hx-mockup-open, .hx-textact { min-height: 44px; }
|
|
992
|
+
.hx-drawer .hx-row, .hx-drawer .hx-mockup-open, .hx-textact, .hx-drawer .hx-whatif-drawer .hx-btn, .hx-drawer .hx-whatif-drawer select, .hx-drawer .hx-whatif-edges summary, .hx-cloud-play { min-height: 44px; }
|
|
1012
993
|
.hx-drawer .hx-close { width: 44px; height: 44px; }
|
|
1013
994
|
}
|
|
1014
|
-
.hx-drawer .hx-whatif-drawer { font-size: var(--corn-text-md); color: var(--corn-text-2); }
|
|
995
|
+
.hx-drawer .hx-whatif-drawer { align-items: flex-start; gap: var(--corn-space-2); font-size: var(--corn-text-md); color: var(--corn-text-2); }
|
|
996
|
+
.hx-whatif-drawer:focus { outline: none; } /* it only holds the focus between two paints */
|
|
997
|
+
.hx-drawer .hx-whatif-edgeto { display: flex; align-items: center; gap: var(--corn-space-2); align-self: stretch; }
|
|
998
|
+
.hx-drawer .hx-whatif-edgeto .hx-whatif-field { flex: 1; min-width: 0; }
|
|
1015
999
|
.hx-drawer .hx-whatif-drawer select { max-width: 100%; }
|
|
1000
|
+
.hx-drawer .hx-whatif-edges { align-self: stretch; }
|
|
1001
|
+
.hx-cloud-play { align-self: flex-start; } /* the cloud panel's "Play: X is down", a quiet button under the facts (spec 0031 section 8) */
|
|
1016
1002
|
.hx-drawer-foot .hx-btn--quiet { border-color: transparent; background: none; text-decoration: none; }
|
|
1017
1003
|
.hx-more { display: contents; }
|
|
1018
1004
|
.hx-more[hidden] { display: none; }
|
|
1019
1005
|
.hx-more-btn { display: block; margin-top: var(--corn-space-1); min-height: 0; padding: 0; font-size: var(--corn-text-sm); }
|
|
1020
1006
|
@media (max-width: 767px) { .hx-more-btn { min-height: 44px; } }
|
|
1007
|
+
|
|
1008
|
+
/* Search with no match (F24): one line under the field, a polite live region. Empty it takes no room. */
|
|
1009
|
+
.hx-search { position: relative; }
|
|
1010
|
+
.hx-search-status { position: absolute; top: calc(100% + var(--corn-space-2)); left: 0; right: 0; z-index: 40; padding: var(--corn-space-2) var(--corn-space-3); border-radius: var(--corn-radius-sm); border: var(--corn-border) solid var(--corn-line); background: var(--corn-surface-2); color: var(--corn-text); font-size: var(--corn-text-sm); overflow-wrap: anywhere; }
|
|
1011
|
+
.hx-search-status:empty { display: none; }
|
|
1012
|
+
.hx-mobile-search .hx-search-status { top: calc(100% - var(--corn-space-1)); left: var(--corn-space-3); right: var(--corn-space-3); }
|
|
1013
|
+
|
|
1014
|
+
/* The node panel's facts break at word boundaries only (F60): "hook" is never "hoo / k". A long path or name still wraps, at its slashes and dashes, and only as a last resort anywhere. */
|
|
1015
|
+
.hx-fact-v { overflow-wrap: break-word; word-break: normal; }
|
package/explorer/index.html
CHANGED
|
@@ -116,6 +116,7 @@
|
|
|
116
116
|
<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>
|
|
117
117
|
<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" />
|
|
118
118
|
<kbd class="hx-kbd" aria-hidden="true">/</kbd>
|
|
119
|
+
<div id="search-status" class="hx-search-status" role="status" aria-live="polite" data-corn="search-status"></div>
|
|
119
120
|
</div>
|
|
120
121
|
|
|
121
122
|
<!-- The Work toggle (explorer/forge-panel.js): opens the Work panel; shown only when the config names a forge -->
|
|
@@ -174,6 +175,7 @@
|
|
|
174
175
|
<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" />
|
|
175
176
|
<button type="button" class="hx-textbtn" data-action="clear-search" aria-label="Clear search" data-corn-kind="quiet">✕</button>
|
|
176
177
|
<button type="button" class="hx-textbtn" data-action="close-mobile-search" data-corn-kind="quiet">Cancel</button>
|
|
178
|
+
<div id="mobile-search-status" class="hx-search-status" role="status" aria-live="polite" data-corn="search-status"></div>
|
|
177
179
|
</div>
|
|
178
180
|
|
|
179
181
|
<!-- The map -->
|
package/explorer/input.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import { state, touchScene } from './state.js';
|
|
16
|
-
import { render, getSpatialIndex, queueFrameWork, screenToWorld } from './render.js';
|
|
16
|
+
import { render, getSpatialIndex, queueFrameWork, screenToWorld, getMinZoom } from './render.js';
|
|
17
17
|
import { saveFreeformPositions } from './layout.js';
|
|
18
18
|
import { selectNode, closeDrawer } from './panels.js';
|
|
19
19
|
import { hitTestScreen } from './spatial.js';
|
|
@@ -98,7 +98,7 @@ function onPointerDown(e) {
|
|
|
98
98
|
/** One frame's worth of pointer movement: the pinch, the node being dragged, or the pan, from the latest position */
|
|
99
99
|
function applyMoves() {
|
|
100
100
|
if (pendingPinch && pinch) {
|
|
101
|
-
Object.assign(state.camera, pinchCamera(pinch, pendingPinch.dist, pendingPinch.mid));
|
|
101
|
+
Object.assign(state.camera, pinchCamera(pinch, pendingPinch.dist, pendingPinch.mid, getMinZoom()));
|
|
102
102
|
}
|
|
103
103
|
pendingPinch = null;
|
|
104
104
|
|
|
@@ -210,7 +210,7 @@ export function bindCanvasInput() {
|
|
|
210
210
|
canvas.addEventListener('wheel', (e) => {
|
|
211
211
|
e.preventDefault();
|
|
212
212
|
const p = getPointerPos(e);
|
|
213
|
-
Object.assign(state.camera, zoomAbout(state.camera, e.deltaY < 0 ? 1.12 : 0.88, p.x, p.y));
|
|
213
|
+
Object.assign(state.camera, zoomAbout(state.camera, e.deltaY < 0 ? 1.12 : 0.88, p.x, p.y, getMinZoom()));
|
|
214
214
|
render(); // a camera change is cheap; the draw is one per frame however many wheel events arrive
|
|
215
215
|
}, { passive: false });
|
|
216
216
|
}
|
package/explorer/keyboard.js
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
import { state, touchScene } from './state.js';
|
|
21
|
-
import { render, fitGraphToViewport, fitPadding, isNodeVisible } from './render.js';
|
|
21
|
+
import { render, fitGraphToViewport, fitPadding, isNodeVisible, getMinZoom } from './render.js';
|
|
22
22
|
import { zoomAbout } from './camera.js';
|
|
23
23
|
import { selectNode, closeDrawer } from './panels.js';
|
|
24
24
|
import { saveFreeformPositions } from './layout.js';
|
|
@@ -99,7 +99,7 @@ function onMapKey(e) {
|
|
|
99
99
|
render();
|
|
100
100
|
break;
|
|
101
101
|
case 'zoom':
|
|
102
|
-
Object.assign(camera, zoomAbout(camera, action.factor, width / 2, height / 2));
|
|
102
|
+
Object.assign(camera, zoomAbout(camera, action.factor, width / 2, height / 2, getMinZoom()));
|
|
103
103
|
render();
|
|
104
104
|
announce(K.zoomWords(camera.zoom));
|
|
105
105
|
break;
|
package/explorer/layers.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* two layers by their kind (spec 0031): Cloud, and the Public web; the Cloud legend says what a call's `when` looks like.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { state, touchScene } from './state.js';
|
|
9
|
+
import { state, touchScene, escHtml } from './state.js';
|
|
10
10
|
import { render, ensureFlowLoop } from './render.js';
|
|
11
11
|
import { renderFlowLegend } from './flows.js';
|
|
12
12
|
import { layerOf } from './live-model.js';
|
|
@@ -23,6 +23,8 @@ export const LAYER_DEFS = [
|
|
|
23
23
|
{ key: 'token', label: 'Design Tokens', color: '#ec4899', desc: 'Pollen CSS' },
|
|
24
24
|
{ key: 'tool', label: 'Dev Tools', color: '#f43f5e', desc: 'Utilities' },
|
|
25
25
|
{ key: 'flow', label: 'Data Flow', color: '#fb923c', desc: 'Tiers & sync' },
|
|
26
|
+
{ key: 'core', label: 'Core', color: '#14b8a6', desc: 'The shared core: what the apps and packages are built on. Shows with Packages or Atoms' },
|
|
27
|
+
{ key: 'store', label: 'Stores', color: '#fb923c', desc: 'Storage tiers and the ends of the data flows. Shows with Data Flow' },
|
|
26
28
|
{ key: 'table', label: 'Tables', color: '#fde047', desc: 'SQLite tables, reads & writes' },
|
|
27
29
|
{ key: 'rom', label: 'ROM', color: '#f0abfc', desc: 'Render on Mutation' },
|
|
28
30
|
{ key: 'service', label: 'Services', color: '#84cc16', desc: 'API jobs, webhooks and hooks' },
|
|
@@ -62,12 +64,32 @@ export function closeLegendMenu() {
|
|
|
62
64
|
setLegendMenu(false);
|
|
63
65
|
}
|
|
64
66
|
|
|
65
|
-
/** The
|
|
67
|
+
/** The key of the row a node is under (the Layers menu has a row for every type on the map) */
|
|
68
|
+
const rowKey = (n) => (n.type === 'external' ? externalLayer(n) : layerOf(n.type));
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The rows: the defined ones, and one more for any node type on this map that none of them covers (a type a plugin or
|
|
72
|
+
* a newer sync adds), so every type present can be turned off. `root` is always shown and has no row.
|
|
73
|
+
*/
|
|
74
|
+
function layerRows() {
|
|
75
|
+
const known = new Set(LAYER_DEFS.map((l) => l.key));
|
|
76
|
+
const extra = [];
|
|
77
|
+
state.nodes.forEach((n) => {
|
|
78
|
+
const key = rowKey(n);
|
|
79
|
+
if (key === 'root' || known.has(key)) return;
|
|
80
|
+
known.add(key);
|
|
81
|
+
extra.push({ key, label: key.charAt(0).toUpperCase() + key.slice(1), color: '#94a3b8', desc: `Nodes of the type ${key}` });
|
|
82
|
+
});
|
|
83
|
+
return [...LAYER_DEFS, ...extra];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** The chip says how many layers are on: " · 13 of 20". An overlay (Runs in flight) is not a layer: it is not counted */
|
|
66
87
|
function paintCount() {
|
|
67
88
|
const el = document.getElementById('layers-count');
|
|
68
89
|
if (!el) return;
|
|
69
|
-
const
|
|
70
|
-
|
|
90
|
+
const layers = layerRows().filter((l) => !l.overlay);
|
|
91
|
+
const on = layers.filter((l) => state.activeLayers[l.key] !== false).length;
|
|
92
|
+
el.textContent = ` · ${on} of ${layers.length}`;
|
|
71
93
|
}
|
|
72
94
|
|
|
73
95
|
export function renderLayerToggles() {
|
|
@@ -75,22 +97,24 @@ export function renderLayerToggles() {
|
|
|
75
97
|
const container = document.getElementById('layer-toggles-container');
|
|
76
98
|
if (!container) return;
|
|
77
99
|
|
|
100
|
+
// Nodes by row. Data Flow has no nodes of its own: it counts its links, and says so; Runs in flight counts runs
|
|
78
101
|
const counts = {};
|
|
79
|
-
state.nodes.forEach((n) => { const key =
|
|
102
|
+
state.nodes.forEach((n) => { const key = rowKey(n); counts[key] = (counts[key] || 0) + 1; });
|
|
80
103
|
counts.flow = state.edges.filter((e) => e.kind === 'flow').length;
|
|
81
104
|
counts.runs = state.runsMap ? state.runsMap.flight.size : 0;
|
|
105
|
+
const unit = { flow: (n) => `${n} ${n === 1 ? 'link' : 'links'}`, runs: (n) => `${n} in flight` };
|
|
82
106
|
|
|
83
|
-
container.innerHTML =
|
|
107
|
+
container.innerHTML = layerRows().map((layer) => {
|
|
84
108
|
const on = state.activeLayers[layer.key] !== false;
|
|
85
109
|
const color = themed(layer.color, state.theme); // the dot is the colour the map draws on this ground
|
|
86
110
|
return `
|
|
87
|
-
<button type="button" class="hx-toggle-row${on ? '' : ' is-off'}" data-action="toggle-layer" data-layer="${layer.key}" aria-pressed="${on}" title="${layer.desc}" data-corn="row">
|
|
111
|
+
<button type="button" class="hx-toggle-row${on ? '' : ' is-off'}" data-action="toggle-layer" data-layer="${escHtml(layer.key)}" aria-pressed="${on}" title="${escHtml(layer.desc)}" data-corn="row">
|
|
88
112
|
<span class="hx-toggle-label">
|
|
89
113
|
<span class="hx-dot" style="background-color: ${color}; box-shadow: ${on && state.theme !== 'light' ? `0 0 8px ${color}90` : 'none'}"></span>
|
|
90
|
-
<span class="hx-toggle-name">${layer.label}</span>${layer.live ? '<span class="hx-live-tag">live</span>' : ''}
|
|
114
|
+
<span class="hx-toggle-name">${escHtml(layer.label)}</span>${layer.live ? '<span class="hx-live-tag">live</span>' : ''}
|
|
91
115
|
</span>
|
|
92
116
|
<span class="hx-toggle-meta">
|
|
93
|
-
<span class="hx-count">${counts[layer.key] || 0}</span>
|
|
117
|
+
<span class="hx-count">${(unit[layer.key] || String)(counts[layer.key] || 0)}</span>
|
|
94
118
|
<span class="hx-tick">${on ? '✓' : '—'}</span>
|
|
95
119
|
</span>
|
|
96
120
|
</button>`;
|