@popcorn245/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.
- package/explorer/capped.js +3 -2
- package/explorer/engine/feedback.js +49 -0
- package/explorer/engine/flow-ui.js +39 -0
- package/explorer/engine/fly.js +54 -0
- package/explorer/engine/hint.js +98 -0
- package/explorer/engine/keyboard.js +156 -0
- package/explorer/engine/layers.js +280 -0
- package/explorer/engine/layout.js +378 -0
- package/explorer/engine/map-style.js +552 -0
- package/explorer/engine/piece.js +142 -0
- package/explorer/engine/render.js +331 -0
- package/explorer/engine/search-status.js +59 -0
- package/explorer/engine/selection.js +42 -0
- package/explorer/engine/sheets.js +417 -0
- package/explorer/engine/strings.js +63 -0
- package/explorer/feedback.js +11 -45
- package/explorer/flow-build.js +88 -0
- package/explorer/flow-style.js +28 -0
- package/explorer/flows.js +11 -132
- package/explorer/fly.js +11 -43
- package/explorer/hint.js +15 -88
- package/explorer/index.html +40 -82
- package/explorer/input.js +197 -177
- package/explorer/instance-state.js +172 -0
- package/explorer/instance.js +267 -0
- package/explorer/keyboard.js +14 -206
- package/explorer/labels.js +3 -3
- package/explorer/layers.js +34 -445
- package/explorer/layout.js +14 -372
- package/explorer/main.js +4 -226
- package/explorer/map-style.js +27 -525
- package/explorer/mockups-model.js +3 -3
- package/explorer/page-pieces.js +66 -0
- package/explorer/page.js +223 -0
- package/explorer/panels.js +29 -409
- package/explorer/pieces/adopt-tokens.js +38 -0
- package/explorer/pieces/layers.js +325 -0
- package/explorer/pieces/map-stage.css +14 -0
- package/explorer/pieces/map.js +332 -0
- package/explorer/pieces/node-panel.js +536 -0
- package/explorer/pieces/search.js +454 -0
- package/explorer/proposal-model.js +1 -1
- package/explorer/proposal.js +1 -0
- package/explorer/render.js +37 -267
- package/explorer/renderer-canvas2d.js +4 -4
- package/explorer/renderer-webgl.js +21 -8
- package/explorer/renderer.js +12 -9
- package/explorer/scene.js +3 -2
- package/explorer/search-status.js +8 -47
- package/explorer/search.js +26 -324
- package/explorer/selection-view.js +17 -19
- package/explorer/sheets.js +31 -379
- package/explorer/state.js +38 -173
- package/explorer/strings.js +17 -60
- package/explorer/view.js +4 -5
- package/package.json +1 -1
|
@@ -0,0 +1,536 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module explorer/pieces/node-panel
|
|
3
|
+
*
|
|
4
|
+
* The node panel as a piece (spec 0011 D3): the side panel that opens when a node is selected, with what the node is and what the map knows
|
|
5
|
+
* about its data: the flows it is on, the tables a page reads and writes, the services behind an endpoint, the stack an app runs on, and for a
|
|
6
|
+
* cloud node (spec 0031) its plan, what breaks if it is down and who uses it, by when (cloud-model.js). A slide-over on a desktop, a bottom
|
|
7
|
+
* sheet on a phone (engine/sheets.js).
|
|
8
|
+
*
|
|
9
|
+
* mount(root, inst, options) -> { update, destroy, ... }
|
|
10
|
+
*
|
|
11
|
+
* The piece makes its own markup (`markup()`: the panel and the dim layer behind it on a phone) and puts it in `root`, or before the nodes
|
|
12
|
+
* `options.slots` names (`drawer`, `backdrop`). It follows the instance: `node:show` fills and opens it for a node, `node:close` closes it
|
|
13
|
+
* (engine/selection.js, which is how every selection reaches it), and it announces `node:painted`. What it needs of neighbours that may not be
|
|
14
|
+
* there it asks (instance.js): `live:section` (the live layer's block), `live:hydrate`, `forge:can-start` and `forge:start` (the Start a run
|
|
15
|
+
* button). Its buttons are its own: Close, Copy Spec, Start a run, a link to a node, Frame them. `destroy()` takes back every listener and timer
|
|
16
|
+
* and removes the elements.
|
|
17
|
+
*
|
|
18
|
+
* @param {ParentNode} root where the panel goes when `options.slots` names no place
|
|
19
|
+
* @param {ReturnType<typeof import('../instance.js').createInstance>} inst the instance; its map must be made (engine/render.js)
|
|
20
|
+
* @param {{ slots?: { drawer?: Node, backdrop?: Node } }} [options]
|
|
21
|
+
* @returns {{ update: (props?: { node?: object | null }) => void, destroy: () => void, show: Function, close: Function, repaintThreads: Function, copySpec: Function, startRun: Function, keepSelectedInView: Function, elements: Element[] }}
|
|
22
|
+
* `update({ node })` shows that node (or closes the panel for `null`) without selecting it; `update()` paints the open panel again from the
|
|
23
|
+
* instance's state (after the host changed the topology or the words).
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import { escapeHtml as escHtml } from '../../core/text.js';
|
|
27
|
+
import { flowSummary } from '../engine/flow-ui.js';
|
|
28
|
+
import { kindOfMark, fieldRows, MARK_WORDS } from '../proposal-model.js';
|
|
29
|
+
import { nodeMockupsHtml } from '../mockups-model.js';
|
|
30
|
+
import { collapseSheet, initSheets, isPhone, measureCovered, onCoveredChange, registerSheet, unregisterSheet, showSheet, onBackdrop } from '../engine/sheets.js';
|
|
31
|
+
import { panIntoView } from '../camera.js';
|
|
32
|
+
import { cloudPanelHtml } from '../cloud-model.js';
|
|
33
|
+
import { t } from '../engine/strings.js';
|
|
34
|
+
import { markStateAttr, markState } from '../corn-state.js';
|
|
35
|
+
import { fileUrl } from '../file-url.js';
|
|
36
|
+
import { capped, toggleCapped } from '../capped.js';
|
|
37
|
+
import { sayResult, clearResult, showResultIn, RESULT_MS } from '../engine/feedback.js';
|
|
38
|
+
import { activeSubgraph, connectedLine, farEnds, kindPanelWord, linesByKind } from '../selection-model.js';
|
|
39
|
+
import { reach } from '../selection-view.js';
|
|
40
|
+
import { announce, frameThem } from '../engine/keyboard.js';
|
|
41
|
+
import { selectNode, clearSelection } from '../engine/selection.js';
|
|
42
|
+
import { scopeOf, place, addParts } from '../engine/piece.js';
|
|
43
|
+
|
|
44
|
+
// ---------------------------------------------------------------------------
|
|
45
|
+
// Small HTML pieces shared by the sections below
|
|
46
|
+
// ---------------------------------------------------------------------------
|
|
47
|
+
const code = (s) => `<code class="hx-code">${escHtml(s)}</code>`;
|
|
48
|
+
const line = (body) => `<div class="hx-line">${body}</div>`;
|
|
49
|
+
/** The words a fact goes by in the panel: short nouns, whatever the longer sentence it was built from */
|
|
50
|
+
const FACT_KEYS = {
|
|
51
|
+
'Uses design tokens': 'Tokens', 'Loaded by the server per request': 'Loaded by', 'Domains served (Caddyfile → service)': 'Domains', 'Compose file': 'File',
|
|
52
|
+
'Baked pages': 'Baked', 'Reads tables': 'Reads', 'Writes tables': 'Writes', 'Self-hosted': 'Role', 'Pushes to (webhook)': 'Pushes to',
|
|
53
|
+
'Calls outside': 'Calls', 'Client modules': 'Modules', 'Data flows': 'Flows',
|
|
54
|
+
};
|
|
55
|
+
const FACT_COUNTED = /^(?:Defines )?\d+ (?:CSS )?(variable|service)\(s\)$/;
|
|
56
|
+
const factKey = (title) => {
|
|
57
|
+
const plain = title.replace(/:$/, '');
|
|
58
|
+
const counted = FACT_COUNTED.exec(plain);
|
|
59
|
+
if (counted) return counted[1] === 'service' ? 'Services' : plain.startsWith('Defines') ? 'Defines' : 'Variables';
|
|
60
|
+
return FACT_KEYS[plain] || plain;
|
|
61
|
+
};
|
|
62
|
+
/** One fact: its name, and what it says. A fact with nothing in it is not shown. */
|
|
63
|
+
const section = (title, rows) => (rows.length ? `<div class="hx-fact" data-corn="section"><div class="hx-fact-k">${escHtml(factKey(title))}</div><div class="hx-fact-v">${capped(rows)}</div></div>` : '');
|
|
64
|
+
const varList = (vars) => `<div class="hx-chips">${capped(vars.map((v) => `<code class="hx-var">${escHtml(v)}</code>`))}</div>`;
|
|
65
|
+
/** "Page", "Cloud", "Public web", "Service · timer": the kind of node, in words, with its finer kind (spec 0009 D5) after a dot. A kind is text, shown as text */
|
|
66
|
+
function typeWords(node) {
|
|
67
|
+
if (node.type === 'external' && node.kind) return node.kind === 'web' ? 'Public web' : 'Cloud';
|
|
68
|
+
const type = node.type.charAt(0).toUpperCase() + node.type.slice(1);
|
|
69
|
+
return typeof node.kind === 'string' && node.kind ? `${type} · ${node.kind}` : type;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** The host a node answers on, when it has one */
|
|
73
|
+
function hostOf(node) {
|
|
74
|
+
if (node.url) { try { return new URL(node.url).host; } catch { /* not a URL: no host */ } }
|
|
75
|
+
return node.host || '';
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** "Added by Checkout": the pill for a node the open proposal touches; '' for one it leaves alone */
|
|
79
|
+
export function diffPillWords(node, proposal) {
|
|
80
|
+
const mark = node && node.mark;
|
|
81
|
+
if (!mark || mark === 'none') return '';
|
|
82
|
+
if (mark === 'edit') return `${node.editOp === 'removed' ? 'Removed' : 'Added'} by your edit`;
|
|
83
|
+
const title = proposal && typeof proposal.title === 'string' ? proposal.title : '';
|
|
84
|
+
return title ? `${MARK_WORDS[mark] || mark} by ${title}` : `${MARK_WORDS[mark] || mark} by this proposal`;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** The most rows a kind's list shows before "and N more" */
|
|
88
|
+
export const LINES_CAP = 12;
|
|
89
|
+
|
|
90
|
+
/** The markup of the piece: the panel (a sheet in the dock on a phone) and the dim layer behind it. `drawer` and `backdrop` are the two places */
|
|
91
|
+
/** The markup of the piece: the panel (a sheet in the dock on a phone) and the dim layer behind it. `drawer` and `backdrop` are the two places */
|
|
92
|
+
export const markup = () => ({
|
|
93
|
+
drawer: '<aside id="spec-drawer" class="hx-drawer glass" aria-label="Node details" inert data-corn="node-panel">'
|
|
94
|
+
+ '<div class="hx-drawer-body">'
|
|
95
|
+
+ '<div class="hx-drawer-head">'
|
|
96
|
+
+ '<div class="hx-drawer-id">'
|
|
97
|
+
+ '<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>'
|
|
98
|
+
+ '<h2 id="drawer-title" class="hx-drawer-title" data-corn="node-title"><pop-button></h2>'
|
|
99
|
+
+ '</div>'
|
|
100
|
+
+ '<button type="button" class="hx-close" data-action="close-drawer" aria-label="Close" data-corn-kind="icon">✕</button>'
|
|
101
|
+
+ '</div>'
|
|
102
|
+
+ '<p id="drawer-description" class="hx-lead" hidden></p>'
|
|
103
|
+
+ '<div class="hx-block"><div id="drawer-meta-list" class="hx-meta"></div></div>'
|
|
104
|
+
+ '</div>'
|
|
105
|
+
+ '<div class="hx-drawer-foot" data-corn="node-foot">'
|
|
106
|
+
+ '<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>'
|
|
107
|
+
+ '<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>'
|
|
108
|
+
+ '<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>'
|
|
109
|
+
+ '<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>'
|
|
110
|
+
+ '<p id="copy-spec-result" class="hx-forge-result" data-corn="result" hidden></p>'
|
|
111
|
+
+ '</div>'
|
|
112
|
+
+ '</aside>',
|
|
113
|
+
backdrop: '<div id="drawer-backdrop" class="hx-backdrop" data-action="close-drawer" hidden data-corn="backdrop"></div>',
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
/** The timer that ends a copy's result; the instance's own, so a second panel does not end the first one's */
|
|
117
|
+
const copyState = (inst) => inst.slot('copy-spec', () => ({ timer: 0 }));
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Copies the selected node as JSON; the result is said under the button (`where`, a `data-corn="result"` element) and to a screen reader,
|
|
121
|
+
* and stays a few seconds.
|
|
122
|
+
*/
|
|
123
|
+
export async function copySpec(inst, where) {
|
|
124
|
+
const { state } = inst;
|
|
125
|
+
if (!state.selectedNode) return;
|
|
126
|
+
const mem = copyState(inst);
|
|
127
|
+
const text = JSON.stringify({ node: state.selectedNode }, null, 2);
|
|
128
|
+
clearTimeout(mem.timer);
|
|
129
|
+
clearResult(inst, 'copy-spec');
|
|
130
|
+
try {
|
|
131
|
+
await inst.win.navigator.clipboard.writeText(text);
|
|
132
|
+
sayResult(inst, 'copy-spec', `Copied the spec of ${state.selectedNode.label || state.selectedNode.id} to the clipboard.`, true);
|
|
133
|
+
} catch {
|
|
134
|
+
sayResult(inst, 'copy-spec', 'The browser did not allow copying, so nothing was copied. Allow clipboard access for this page, then press Copy Spec again.', false);
|
|
135
|
+
}
|
|
136
|
+
showResultIn(inst, where, 'copy-spec');
|
|
137
|
+
mem.timer = setTimeout(() => { clearResult(inst, 'copy-spec'); showResultIn(inst, where, 'copy-spec'); }, RESULT_MS);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* The sections of the panel, for an instance: they read its state and nothing else.
|
|
142
|
+
* @param {ReturnType<typeof import('../instance.js').createInstance>} inst
|
|
143
|
+
*/
|
|
144
|
+
function sectionsOf(inst) {
|
|
145
|
+
const { state } = inst;
|
|
146
|
+
const nodeById = (id) => state.nodes.find((n) => n.id === id);
|
|
147
|
+
const nameOf = (id) => (nodeById(id) || { label: id }).label;
|
|
148
|
+
const nm = (id) => `<span class="hx-name">${escHtml(nameOf(id))}</span>`;
|
|
149
|
+
const edgesOf = (kind, side, id) => state.edges.filter((e) => e.kind === kind && e[side] === id);
|
|
150
|
+
|
|
151
|
+
/** Table <-> page data: which keys a page's render reads, which forms write, what ROM re-bakes */
|
|
152
|
+
function dataSummary(node) {
|
|
153
|
+
const reads = state.edges.filter((e) => e.kind === 'reads');
|
|
154
|
+
const writes = state.edges.filter((e) => e.kind === 'writes');
|
|
155
|
+
const usesOut = state.edges.filter((e) => e.kind === 'uses' && e.from === node.id);
|
|
156
|
+
const extendsOut = state.edges.filter((e) => e.kind === 'extends' && e.from === node.id);
|
|
157
|
+
const common = section('Extends:', extendsOut.map((e) => line(nm(e.to))))
|
|
158
|
+
+ section('Uses design tokens:', usesOut.map((e) => line(`${nm(e.to)} · ${e.vars.length}${varList(e.vars)}`)))
|
|
159
|
+
+ (node.type !== 'token' && node.vars ? section(`Defines ${node.vars.length} CSS variable(s):`, [varList(node.vars)]) : '');
|
|
160
|
+
|
|
161
|
+
if (node.type === 'app') {
|
|
162
|
+
const served = node.deployed
|
|
163
|
+
? line(`${/^https?:\/\//.test(node.url) ? `<a data-corn="text-link" class="hx-link" href="${escHtml(node.url)}" target="_blank" rel="noreferrer">${escHtml(node.url)}</a>` : code(node.url)} → ${(node.upstreams || []).map(code).join(' ')}${node.stack ? ` <span class="hx-faint">[${escHtml(node.stack)}]</span>` : ''}`)
|
|
164
|
+
: line('Not deployed by any stack in this repo');
|
|
165
|
+
const runsOn = state.edges.filter((e) => e.kind === 'runs-on' && e.from === node.id)
|
|
166
|
+
.map((e) => line(`${nm(e.to)}${(e.mappings || []).map((m) => `<div class="hx-faint">${code(m.host)} → ${code(m.upstream)}${m.service ? ` = ${code(m.service)}` : ''}</div>`).join('')}`));
|
|
167
|
+
return section('Served:', [served])
|
|
168
|
+
+ section('Runs on:', runsOn)
|
|
169
|
+
+ section('Loaded by the server per request:', reads.filter((e) => e.to === node.id).map((e) => line(nm(e.from))))
|
|
170
|
+
+ common;
|
|
171
|
+
}
|
|
172
|
+
if (node.type === 'token') {
|
|
173
|
+
const users = state.edges.filter((e) => e.kind === 'uses' && e.to === node.id);
|
|
174
|
+
return section(`${node.vars.length} variable(s):`, [varList(node.vars)])
|
|
175
|
+
+ section('Used by:', users.map((e) => line(`${nm(e.from)} · ${escHtml(e.vars.join(' '))}`)));
|
|
176
|
+
}
|
|
177
|
+
if (['atom', 'molecule', 'core'].includes(node.type)) {
|
|
178
|
+
const pages = state.edges.filter((e) => e.dashed && e.to === node.id).map((e) => line(nm(e.from)));
|
|
179
|
+
return (node.table ? section('Record of:', [line(`${escHtml(node.model)} · table ${code(node.table)}`)]) : '')
|
|
180
|
+
+ section('Rendered by:', pages) + common;
|
|
181
|
+
}
|
|
182
|
+
if (node.type === 'stack') {
|
|
183
|
+
const served = state.edges.filter((e) => e.kind === 'runs-on' && e.to === node.id);
|
|
184
|
+
return section('Domains served (Caddyfile → service):', served.flatMap((e) => (e.mappings || []).map((m) => line(`<span class="hx-name">${escHtml(m.host)}</span> → ${code(m.upstream)}${m.service ? ` = ${code(m.service)}` : ''}`))))
|
|
185
|
+
+ section(`${(node.services || []).length} service(s):`, (node.services || []).map((s) => line(`<span class="hx-name">${escHtml(s.name)}</span>${s.image ? ` <span class="hx-faint">${escHtml(s.image)}</span>` : ''}${s.ports.length ? `<div>${s.ports.map(code).join(' ')}</div>` : ''}${s.volumes.length ? `<div class="hx-faint">${s.volumes.map(escHtml).join('<br>')}</div>` : ''}`)))
|
|
186
|
+
+ section('Compose file:', [line(code(node.file))]);
|
|
187
|
+
}
|
|
188
|
+
if (node.type === 'table') {
|
|
189
|
+
const readers = reads.filter((e) => e.from === node.id);
|
|
190
|
+
const writers = writes.filter((e) => e.to === node.id);
|
|
191
|
+
const baked = readers.filter((e) => (nodeById(e.to) || {}).render?.rom === 'bake');
|
|
192
|
+
return (node.model ? section('Model:', [line(escHtml(node.model))]) : '')
|
|
193
|
+
+ section('Read by:', readers.map((e) => line(`${nm(e.to)} · ${e.keys.map(code).join(' ')}`)))
|
|
194
|
+
+ section('Written by:', writers.map((e) => line(`${nm(e.from)} · ${escHtml(e.label)}`)))
|
|
195
|
+
+ (baked.length ? section('Baked pages:', [line(`a write here re-bakes <span class="hx-rom hx-bold">${baked.length}</span> file(s): ${baked.map((e) => escHtml(nameOf(e.to))).join(', ')}`)]) : '');
|
|
196
|
+
}
|
|
197
|
+
if (node.type === 'service') {
|
|
198
|
+
const row = (e, side) => `${nm(e[side])}${e.label && e.label !== 'imports' ? ` · ${escHtml(e.label)}` : ''}`;
|
|
199
|
+
// The summary is the first sentence of the description above: shown again only when the description does not hold it
|
|
200
|
+
const again = node.summary && !String(node.desc || '').includes(node.summary);
|
|
201
|
+
// The kind is in the badge ("Service · timer", typeWords): it has no row of its own
|
|
202
|
+
return (again ? section('Summary:', [line(`<span class="hx-faint">${escHtml(node.summary)}</span>`)]) : '')
|
|
203
|
+
+ section('Started by:', [...(node.triggers || []).map((t) => line(escHtml(t))), ...edgesOf('triggers', 'to', node.id).map((e) => line(row(e, 'from')))])
|
|
204
|
+
+ section('Jobs:', (node.jobs || []).map((j) => line(`${code(j.name)} · cron ${code(j.cron)}`)))
|
|
205
|
+
+ section('Runs:', edgesOf('triggers', 'from', node.id).map((e) => line(row(e, 'to'))))
|
|
206
|
+
+ section('Calls:', edgesOf('calls', 'from', node.id).map((e) => line(row(e, 'to'))))
|
|
207
|
+
+ section('Called by:', edgesOf('calls', 'to', node.id).map((e) => line(row(e, 'from'))))
|
|
208
|
+
+ section('Reads tables:', reads.filter((e) => e.to === node.id).map((e) => line(nm(e.from))))
|
|
209
|
+
+ section('Writes tables:', writes.filter((e) => e.from === node.id).map((e) => line(nm(e.to))))
|
|
210
|
+
+ section('Mechanisms:', (node.mechanisms || []).map((m) => line(escHtml(m))));
|
|
211
|
+
}
|
|
212
|
+
if (node.type === 'container' && node.selfHosted) {
|
|
213
|
+
// A self-hosted service is the container that runs it (spec 0031 section 3): what the API uses it for, who calls it, its webhook
|
|
214
|
+
const row = (e, side) => `${nm(e[side])}${e.label && e.label !== 'calls' ? ` · ${escHtml(e.label)}` : ''}`;
|
|
215
|
+
const into = state.edges.filter((e) => e.to === node.id && (e.kind === 'calls' || (e.kind === 'flow' && e.flow === 'api')));
|
|
216
|
+
const calledBy = (type) => into.filter((e) => nodeById(e.from)?.type === type).map((e) => line(row(e, 'from')));
|
|
217
|
+
const stackmates = new Set(state.nodes.filter((n) => n.type === 'container' && n.stack === node.stack).map((n) => n.id));
|
|
218
|
+
return section('Self-hosted:', [line(escHtml(node.summary || ''))])
|
|
219
|
+
+ section('Called by services:', calledBy('service'))
|
|
220
|
+
+ section('Called by endpoints:', calledBy('page'))
|
|
221
|
+
+ section('Called by apps:', calledBy('app'))
|
|
222
|
+
+ section('Pushes to (webhook):', state.edges.filter((e) => e.kind === 'delivers' && stackmates.has(e.from) && nodeById(e.to)?.type === 'page').map((e) => line(`${nm(e.to)}${e.from === node.id ? '' : ` <span class="hx-faint">from ${escHtml(nameOf(e.from))}</span>`}`)));
|
|
223
|
+
}
|
|
224
|
+
if (node.type === 'external' && node.kind) { // a cloud node or the public web (spec 0031 section 6)
|
|
225
|
+
return cloudPanelHtml(node, state.nodes, state.edges); // its File line is the registry
|
|
226
|
+
}
|
|
227
|
+
if (node.type === 'external') {
|
|
228
|
+
const calledBy = (type) => edgesOf('calls', 'to', node.id).filter((e) => nodeById(e.from)?.type === type);
|
|
229
|
+
return section('System:', [line(`${escHtml(node.summary || '')}${node.host ? `<div class="hx-faint">Runs here as ${code(node.host)}</div>` : '<div class="hx-faint">Not run by this stack</div>'}`)])
|
|
230
|
+
+ section('Client modules:', (node.modules || []).map((m) => line(code(m))))
|
|
231
|
+
+ section('Called by services:', calledBy('service').map((e) => line(nm(e.from))))
|
|
232
|
+
+ section('Called by endpoints:', calledBy('page').map((e) => line(nm(e.from))))
|
|
233
|
+
+ section('Pushes to (webhook):', edgesOf('delivers', 'from', node.id).map((e) => line(nm(e.to))));
|
|
234
|
+
}
|
|
235
|
+
if (node.type === 'page') {
|
|
236
|
+
const r = node.render;
|
|
237
|
+
const components = state.edges.filter((e) => e.dashed && e.from === node.id).map((e) => line(nm(e.to)));
|
|
238
|
+
return (node.methods ? section('Methods:', [line(node.methods.map(code).join(' '))]) : '')
|
|
239
|
+
+ (node.render_fn ? section('Rendered by:', [line(`${code(node.render_fn)} · ${escHtml(node.file)}`)]) : '')
|
|
240
|
+
+ section('Calls outside:', edgesOf('calls', 'from', node.id).map((e) => line(nm(e.to))))
|
|
241
|
+
+ section('Pushed to by:', edgesOf('delivers', 'to', node.id).map((e) => line(`${nm(e.from)} · ${escHtml(e.label)}`)))
|
|
242
|
+
+ section('Starts:', edgesOf('triggers', 'from', node.id).map((e) => line(`${nm(e.to)} · ${escHtml(e.label)}`)))
|
|
243
|
+
+ section('Renders:', components)
|
|
244
|
+
+ section('Reads:', reads.filter((e) => e.to === node.id).map((e) => line(`${nm(e.from)} · ${e.keys.map(code).join(' ')}`)))
|
|
245
|
+
+ section('Writes:', writes.filter((e) => e.from === node.id).map((e) => line(`${nm(e.to)} · ${escHtml(e.label)}`)))
|
|
246
|
+
+ (r ? section('Render:', [line(`today: ${code(r.now)} · ROM: ${r.rom === 'bake' ? '<span class="hx-rom hx-bold">bake</span>' : '<span class="hx-faint">skip (per request)</span>'}${r.note ? `<div class="hx-faint">${escHtml(r.note)}</div>` : ''}`)]) : '');
|
|
247
|
+
}
|
|
248
|
+
return '';
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/** "Threads": the threads whose text names the node (an idea, or a spec PR's conversation); each opens in the Work panel */
|
|
252
|
+
function threadsSection(node) {
|
|
253
|
+
const index = state.threadIndex;
|
|
254
|
+
if (!index) return '';
|
|
255
|
+
const threads = index.for(node.id);
|
|
256
|
+
// "Start a thread about this" shows whenever threads are on and a maintainer is signed in (the panel only sets `start` then)
|
|
257
|
+
const start = index.start ? `<button data-corn-kind="quiet" type="button" class="hx-btn hx-btn--quiet hx-textact" data-thread-start="${escHtml(node.id)}" aria-label="Start a thread about this: opens the New idea form for ${escHtml(index.forge())}, with this node mentioned">Start a thread about this</button>` : '';
|
|
258
|
+
if (!threads || !threads.length) return start;
|
|
259
|
+
const rows = threads.map((th) => {
|
|
260
|
+
const count = Number(th.comments) || 0;
|
|
261
|
+
return `<li><button type="button" class="hx-row hx-thread-open" data-thread-open="${escHtml(th.number)}" data-corn="row" aria-label="Open thread #${escHtml(th.number)}, ${escHtml(th.title)}, ${count} ${count === 1 ? 'comment' : 'comments'}, in the issues and pull requests panel"><span class="hx-row-title">${escHtml(th.title)}</span><span class="hx-row-meta">#${escHtml(th.number)} · ${count}</span></button></li>`;
|
|
262
|
+
});
|
|
263
|
+
return `<div class="hx-sec-block" data-corn="section"><h3 class="hx-sec-title">Threads</h3><ul class="hx-rows">${rows.join('')}</ul>${start}</div>`;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/** "In this proposal": the diff for a changed node as key/value rows (id, parent, edges +2; a change shows each field before and after) */
|
|
267
|
+
function diffSection(node) {
|
|
268
|
+
const kind = kindOfMark(node);
|
|
269
|
+
if (!diffPillWords(node, state.proposal)) return '';
|
|
270
|
+
const row = (k, v) => `<div class="hx-diff-k">${escHtml(k)}</div><div class="hx-diff-v">${v}</div>`;
|
|
271
|
+
const rows = [row('id', escHtml(node.id))];
|
|
272
|
+
const parent = state.edges.find((e) => !e.kind && !e.dashed && e.to === node.id);
|
|
273
|
+
if (parent) rows.push(row('parent', escHtml(parent.from)));
|
|
274
|
+
const touching = state.edges.filter((e) => e.from === node.id || e.to === node.id);
|
|
275
|
+
const added = touching.filter((e) => kindOfMark(e) === 'added').length;
|
|
276
|
+
const removed = touching.filter((e) => kindOfMark(e) === 'removed').length;
|
|
277
|
+
if (added || removed) rows.push(row('edges', escHtml([added ? `+${added}` : '', removed ? `−${removed}` : ''].filter(Boolean).join(' '))));
|
|
278
|
+
if (kind === 'changed') {
|
|
279
|
+
for (const r of fieldRows(node)) rows.push(row(r.field, `<span class="hx-change-before">${escHtml(r.before) || '<em>nothing</em>'}</span> <span aria-hidden="true">→</span><span class="hx-sr-only"> became </span> <span class="hx-change-after">${escHtml(r.after) || '<em>nothing</em>'}</span>`));
|
|
280
|
+
}
|
|
281
|
+
return `<div class="hx-sec-block" data-proposal-mark="${escHtml(node.mark)}" data-corn="section"><h3 class="hx-sec-title">In this proposal</h3>${node.why ? `<p class="hx-why">${escHtml(node.why)}</p>` : ''}<div class="hx-diff hx-diff--${escHtml(kind)}" data-corn="diff-block"${markStateAttr(node.mark)}>${rows.join('')}</div></div>`;
|
|
282
|
+
}
|
|
283
|
+
return { dataSummary, threadsSection, diffSection, nameOf, nodeById };
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/** Mounts the node panel; see the top of this file */
|
|
287
|
+
export function mount(root, inst, options = {}) {
|
|
288
|
+
const { state } = inst;
|
|
289
|
+
const scope = scopeOf(inst);
|
|
290
|
+
const sections = sectionsOf(inst);
|
|
291
|
+
const made = [
|
|
292
|
+
...place(inst, root, markup().drawer, options.slots, 'drawer'),
|
|
293
|
+
...place(inst, root, markup().backdrop, options.slots, 'backdrop'),
|
|
294
|
+
];
|
|
295
|
+
/** An element of this piece by id (the piece's own, whatever else the root holds) */
|
|
296
|
+
const own = (id) => {
|
|
297
|
+
for (const el of made) {
|
|
298
|
+
if (el.id === id) return el;
|
|
299
|
+
const found = el.querySelector(`[id="${id}"]`);
|
|
300
|
+
if (found) return found;
|
|
301
|
+
}
|
|
302
|
+
return null;
|
|
303
|
+
};
|
|
304
|
+
scope.keepParts(...made);
|
|
305
|
+
const drawer = own('spec-drawer');
|
|
306
|
+
const backdrop = own('drawer-backdrop');
|
|
307
|
+
let gone = false;
|
|
308
|
+
|
|
309
|
+
const litNow = () => activeSubgraph(state.selectedNode, inst.viewEdges(), { throughChildren: state.throughChildren, kind: state.selectedKind });
|
|
310
|
+
|
|
311
|
+
/** The panel's "Calls 12 · Reads 9" chips, the chosen kind's far ends, the switch, and the line that says how much is on screen, with Frame them */
|
|
312
|
+
function linesHtml(node) {
|
|
313
|
+
const sub = litNow();
|
|
314
|
+
if (!sub || !sub.kinds.size) return '';
|
|
315
|
+
const kinds = linesByKind(sub);
|
|
316
|
+
const chips = kinds.map(({ kind, count, word }) => `<button type="button" class="hx-lines-kind" data-corn="lines-kind" data-corn-kind="quiet" data-lines-kind="${escHtml(kind)}" data-focus-key="kind:${escHtml(kind)}" aria-pressed="${sub.kind === kind}">${escHtml(word)} <span class="hx-lines-count" data-corn="count">${count}</span></button>`).join('');
|
|
317
|
+
const open = sub.kind ? farEnds(sub, sub.kind).map((r) => `<button type="button" class="hx-linkbtn" data-corn="node-link" data-action="select-node" data-id="${escHtml(r.id)}"><span class="hx-sr-only">${r.out ? 'to ' : 'from '}</span><span aria-hidden="true">${r.out ? '→' : '←'}</span> ${escHtml(sections.nameOf(r.id))}</button>`) : [];
|
|
318
|
+
const list = open.length ? `<div class="hx-lines-list">${capped(open, LINES_CAP)}</div>` : '';
|
|
319
|
+
const hasChildren = activeSubgraph(node, inst.viewEdges(), { throughChildren: false }).childIds.size > 0;
|
|
320
|
+
const through = hasChildren ? `<label class="hx-lines-switch"><input type="checkbox" data-corn="lines-switch" data-lines-switch data-focus-key="switch"${state.throughChildren ? ' checked' : ''}> <span>${escHtml(t(inst, 'throughChildren'))}</span></label>` : '';
|
|
321
|
+
const { connected, off } = reach(inst);
|
|
322
|
+
return `<div class="hx-sec-block hx-lines" id="drawer-lines" data-corn="lines-by-kind"><h3 class="hx-sec-title">Lines</h3><div class="hx-chips" role="group" aria-label="Lit lines by kind">${chips}</div>${list}${through}<div class="hx-lines-reach"><span data-lines-reach>${escHtml(connectedLine(connected, off))}</span> <button type="button" data-corn="frame-button" data-corn-kind="secondary" class="hx-btn hx-btn--secondary" data-action="frame-selection" data-focus-key="frame">${escHtml(t(inst, 'frame'))}</button></div></div>`;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/** Draws the lines block again after a switch or a kind was chosen; the focus stays on the control that was used */
|
|
326
|
+
function paintLines() {
|
|
327
|
+
const box = own('drawer-lines');
|
|
328
|
+
if (!box || !state.selectedNode) return;
|
|
329
|
+
const active = inst.active();
|
|
330
|
+
const key = active && box.contains(active) ? active.dataset.focusKey : '';
|
|
331
|
+
const holder = inst.doc.createElement('div');
|
|
332
|
+
holder.innerHTML = linesHtml(state.selectedNode);
|
|
333
|
+
addParts(holder);
|
|
334
|
+
const next = holder.firstElementChild;
|
|
335
|
+
if (next) box.replaceWith(next); else box.remove();
|
|
336
|
+
if (key) { const again = own('drawer-lines'); const el = again && [...again.querySelectorAll('[data-focus-key]')].find((x) => x.dataset.focusKey === key); if (el) el.focus(); }
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/** One step through the panel's lines controls: a kind's chip lights that kind alone (the same chip again lights them all), the switch widens the set */
|
|
340
|
+
function onLinesClick(e) {
|
|
341
|
+
const chip = e.target.closest && e.target.closest('[data-lines-kind]');
|
|
342
|
+
if (!chip || !state.selectedNode) return false;
|
|
343
|
+
const kind = chip.dataset.linesKind;
|
|
344
|
+
state.selectedKind = state.selectedKind === kind ? null : kind;
|
|
345
|
+
inst.touchScene();
|
|
346
|
+
inst.map.render();
|
|
347
|
+
paintLines();
|
|
348
|
+
const sub = litNow();
|
|
349
|
+
announce(inst, sub && sub.kind ? `Showing ${kindPanelWord(sub.kind).toLowerCase()} only: ${sub.edges.length} ${sub.edges.length === 1 ? 'line' : 'lines'}` : 'Showing every kind of line');
|
|
350
|
+
return true;
|
|
351
|
+
}
|
|
352
|
+
function onLinesChange(e) {
|
|
353
|
+
const box = e.target.closest && e.target.closest('[data-lines-switch]');
|
|
354
|
+
if (!box || !state.selectedNode) return;
|
|
355
|
+
state.throughChildren = !!box.checked;
|
|
356
|
+
state.selectedKind = null; // the set changed under the chosen kind: it may not be in it
|
|
357
|
+
inst.touchScene();
|
|
358
|
+
inst.map.render();
|
|
359
|
+
paintLines();
|
|
360
|
+
const sub = litNow();
|
|
361
|
+
announce(inst, `${state.throughChildren ? 'Including' : 'Not including'} its children's lines: ${sub ? sub.connectedNodeIds.size - 1 : 0} connected`);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
const metaList = own('drawer-meta-list');
|
|
365
|
+
scope.listen(metaList, 'click', (e) => { if (!onLinesClick(e)) toggleCapped(e.target); });
|
|
366
|
+
scope.listen(metaList, 'change', onLinesChange);
|
|
367
|
+
|
|
368
|
+
/** Keeps "9 connected · 3 off screen" true as the camera moves (after every draw, while a node is selected and its panel is open) */
|
|
369
|
+
scope.own(inst.map.onPaint(() => {
|
|
370
|
+
if (!state.selectedNode) return;
|
|
371
|
+
const el = drawer.querySelector('[data-lines-reach]');
|
|
372
|
+
if (!el) return;
|
|
373
|
+
const { connected, off } = reach(inst);
|
|
374
|
+
const text = connectedLine(connected, off);
|
|
375
|
+
if (el.textContent !== text) el.textContent = text;
|
|
376
|
+
}));
|
|
377
|
+
|
|
378
|
+
/** Draws "Threads" again in the open panel (the list was just read, or the map changed); nothing else in the panel moves */
|
|
379
|
+
function repaintThreads() {
|
|
380
|
+
const box = own('drawer-threads');
|
|
381
|
+
if (!box || !state.selectedNode) return;
|
|
382
|
+
box.innerHTML = sections.threadsSection(state.selectedNode);
|
|
383
|
+
addParts(box);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/** Fills the panel for a node and opens it. The selection itself is the instance's (engine/selection.js); this is what is shown for it. */
|
|
387
|
+
function show(node, { frame = false } = {}) {
|
|
388
|
+
if (!node || gone) return;
|
|
389
|
+
const title = own('drawer-title');
|
|
390
|
+
title.textContent = node.tag ? `<${node.tag}>` : node.label;
|
|
391
|
+
title.classList.toggle('hx-mono', node.type === 'page' || !!node.tag); // a route or a tag reads as code
|
|
392
|
+
own('drawer-badge').textContent = typeWords(node);
|
|
393
|
+
const host = hostOf(node);
|
|
394
|
+
own('drawer-host').textContent = host ? ` · ${host}` : '';
|
|
395
|
+
const pill = diffPillWords(node, state.proposal);
|
|
396
|
+
const pillEl = own('drawer-diff');
|
|
397
|
+
pillEl.textContent = pill;
|
|
398
|
+
pillEl.hidden = !pill;
|
|
399
|
+
const pillState = markState(pill ? node.mark : ''); // added, changed, removed or edit
|
|
400
|
+
if (pillState) pillEl.dataset.cornState = pillState; else delete pillEl.dataset.cornState;
|
|
401
|
+
const lead = own('drawer-description');
|
|
402
|
+
lead.textContent = node.desc || '';
|
|
403
|
+
lead.hidden = !node.desc;
|
|
404
|
+
|
|
405
|
+
const facts = `${node.file ? section('File', [code(node.file)]) : ''}${flowSummary(inst, node)}${sections.dataSummary(node)}`;
|
|
406
|
+
const live = inst.ask('live:section', node) || '';
|
|
407
|
+
metaList.innerHTML = `${linesHtml(node)}${facts ? `<div class="hx-facts">${facts}</div>` : ''}
|
|
408
|
+
<div id="drawer-live">${live}</div>
|
|
409
|
+
${nodeMockupsHtml(state, node.id)}
|
|
410
|
+
<div id="drawer-threads">${sections.threadsSection(node)}</div>
|
|
411
|
+
${sections.diffSection(node)}`;
|
|
412
|
+
addParts(metaList);
|
|
413
|
+
if (state.threadIndex) state.threadIndex.ensure();
|
|
414
|
+
inst.emit('live:hydrate', own('drawer-live'));
|
|
415
|
+
|
|
416
|
+
// The actions: Open file (the node's file on the forge) is the primary one; with an address too, Open route is the quiet one.
|
|
417
|
+
// The proposal's head branch is not known here (the proposals list does not carry it): the file is at the default branch.
|
|
418
|
+
const fileBtn = own('drawer-file-btn');
|
|
419
|
+
const openBtn = own('drawer-open-btn');
|
|
420
|
+
const file = node.file && state.forge ? fileUrl(state.forge, node.file, state.forge.baseBranch) : null;
|
|
421
|
+
fileBtn.hidden = !file;
|
|
422
|
+
if (file) fileBtn.href = file; else fileBtn.removeAttribute('href');
|
|
423
|
+
const route = !!(node.url && /^https?:\/\//.test(node.url));
|
|
424
|
+
if (route) openBtn.href = node.url; else openBtn.removeAttribute('href');
|
|
425
|
+
openBtn.hidden = !route;
|
|
426
|
+
openBtn.className = file ? 'hx-btn hx-btn--quiet hx-foot-btn' : 'hx-open';
|
|
427
|
+
if (file) openBtn.dataset.cornKind = 'quiet'; else openBtn.dataset.cornKind = 'primary'; // the route is the primary action when there is no file
|
|
428
|
+
openBtn.textContent = `${t(inst, 'openRoute')} ↗`;
|
|
429
|
+
fileBtn.textContent = `${t(inst, 'openFile')} ↗`;
|
|
430
|
+
own('drawer-run-btn').hidden = !(state.proposalSlug && inst.ask('forge:can-start'));
|
|
431
|
+
|
|
432
|
+
drawer.classList.add('drawer-open');
|
|
433
|
+
drawer.inert = false; // closed, it waits off screen: inert, so Tab never reaches its buttons (MAP-02)
|
|
434
|
+
backdrop.hidden = false;
|
|
435
|
+
showSheet(inst, 'drawer'); // on a phone it takes Work's place (the node sheet and Work take turns), and comes back from away when its node is tapped again
|
|
436
|
+
if (!frame) keepSelectedInView(); // with `frame`, the selection flies the camera to the node once this returns (engine/selection.js)
|
|
437
|
+
inst.emit('node:painted', { node });
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* On a phone the node's sheet covers the bottom of the map (engine/sheets.js): when the selected node is under it, or
|
|
442
|
+
* gets covered as the sheet expands, pan the map (never zoom it) so the node is in the part still showing (F32)
|
|
443
|
+
*/
|
|
444
|
+
function keepSelectedInView() {
|
|
445
|
+
const node = state.selectedNode;
|
|
446
|
+
if (!node || !state.width || !isPhone(inst) || gone) return;
|
|
447
|
+
const covered = measureCovered(inst);
|
|
448
|
+
const next = panIntoView(state.camera, node, { left: 0, top: 0, right: state.width, bottom: state.height - covered }, node.r * state.camera.zoom + 16);
|
|
449
|
+
if (!next) return;
|
|
450
|
+
Object.assign(state.camera, next);
|
|
451
|
+
inst.map.render();
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
function close() {
|
|
455
|
+
drawer.classList.remove('drawer-open');
|
|
456
|
+
drawer.inert = true;
|
|
457
|
+
backdrop.hidden = true;
|
|
458
|
+
collapseSheet(inst, 'drawer'); // the next node opens as a peek on a phone
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/** Start a run: the Start dialog of the Work panel, on the proposal that is open */
|
|
462
|
+
function startRun() {
|
|
463
|
+
if (state.proposalSlug) inst.emit('forge:start', { slug: state.proposalSlug, returnTo: '#drawer-run-btn' });
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
scope.own(() => clearTimeout(copyState(inst).timer));
|
|
467
|
+
|
|
468
|
+
// The panel's own buttons
|
|
469
|
+
const ACTIONS = {
|
|
470
|
+
'close-drawer': () => clearSelection(inst, { source: 'tap' }),
|
|
471
|
+
'copy-spec': () => copySpec(inst, own('copy-spec-result')),
|
|
472
|
+
'start-run': () => startRun(),
|
|
473
|
+
'select-node': (el) => selectNode(inst, sections.nodeById(el.dataset.id), { frame: true, source: 'link' }), // a link or a list row: the camera follows (spec 0008 D6)
|
|
474
|
+
'frame-selection': () => frameThem(inst),
|
|
475
|
+
};
|
|
476
|
+
scope.listen(drawer, 'click', (e) => {
|
|
477
|
+
const target = e.target.closest && e.target.closest('[data-action]');
|
|
478
|
+
if (!target) return;
|
|
479
|
+
const action = ACTIONS[target.dataset.action];
|
|
480
|
+
if (action) action(target);
|
|
481
|
+
// The panel's ✕: the focus would be left on a hidden button, so it goes back to the map
|
|
482
|
+
if (target.dataset.action === 'close-drawer' && state.canvas) scope.timeout(() => state.canvas.focus(), 0);
|
|
483
|
+
});
|
|
484
|
+
// The dim layer behind the panel: on a phone a tap there folds the panel to its peek; elsewhere it closes it
|
|
485
|
+
scope.listen(backdrop, 'click', (e) => {
|
|
486
|
+
if (isPhone(inst)) { onBackdrop(inst, e); return; }
|
|
487
|
+
clearSelection(inst, { source: 'tap' });
|
|
488
|
+
}, true);
|
|
489
|
+
// Escape anywhere in the panel closes it, and the map has the focus again
|
|
490
|
+
scope.listen(drawer, 'keydown', (e) => {
|
|
491
|
+
if (e.key !== 'Escape' || e.defaultPrevented) return;
|
|
492
|
+
if (e.target.closest && e.target.closest('select, input, textarea')) return; // a field's own Escape first
|
|
493
|
+
e.preventDefault();
|
|
494
|
+
clearSelection(inst, { source: 'keyboard' });
|
|
495
|
+
if (state.canvas) state.canvas.focus();
|
|
496
|
+
announce(inst, 'Panel closed');
|
|
497
|
+
});
|
|
498
|
+
|
|
499
|
+
scope.on('node:show', ({ node, frame }) => show(node, { frame }));
|
|
500
|
+
scope.on('node:close', close);
|
|
501
|
+
// Enter on the map goes into the open panel: its title takes the focus, so a screen reader starts there and Tab goes on into it
|
|
502
|
+
scope.on('node:focus', () => {
|
|
503
|
+
const title = own('drawer-title');
|
|
504
|
+
if (!title) return;
|
|
505
|
+
title.setAttribute('tabindex', '-1');
|
|
506
|
+
title.focus();
|
|
507
|
+
});
|
|
508
|
+
scope.own(onCoveredChange(inst, () => keepSelectedInView()));
|
|
509
|
+
|
|
510
|
+
initSheets(inst);
|
|
511
|
+
registerSheet(inst, 'drawer', drawer, { stub: () => ({ title: (own('drawer-title') && own('drawer-title').textContent) || 'Node' }) });
|
|
512
|
+
scope.own(() => unregisterSheet(inst, 'drawer'));
|
|
513
|
+
|
|
514
|
+
// A node was selected before the panel came: it shows it
|
|
515
|
+
if (state.selectedNode) show(state.selectedNode, { frame: false });
|
|
516
|
+
|
|
517
|
+
scope.own(() => {
|
|
518
|
+
gone = true;
|
|
519
|
+
made.forEach((el) => el.remove());
|
|
520
|
+
});
|
|
521
|
+
|
|
522
|
+
return {
|
|
523
|
+
elements: made,
|
|
524
|
+
show,
|
|
525
|
+
close,
|
|
526
|
+
repaintThreads,
|
|
527
|
+
copySpec: () => copySpec(inst, own('copy-spec-result')),
|
|
528
|
+
startRun,
|
|
529
|
+
keepSelectedInView,
|
|
530
|
+
update(props) {
|
|
531
|
+
if (props && 'node' in props) { if (props.node) selectNode(inst, props.node, { source: 'api' }); else clearSelection(inst, { source: 'api' }); return; }
|
|
532
|
+
if (state.selectedNode && drawer.classList.contains('drawer-open')) show(state.selectedNode, { frame: false });
|
|
533
|
+
},
|
|
534
|
+
destroy: () => scope.destroy(),
|
|
535
|
+
};
|
|
536
|
+
}
|