@popcorn245/cornfield 0.52.1 → 0.53.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/core/strings.js CHANGED
@@ -123,6 +123,8 @@ export const STRINGS = Object.freeze({
123
123
  needsScope: 'This needs a corn-scope around it, with a corn-map in it',
124
124
  needsMap: 'This needs a corn-map in the same corn-scope',
125
125
  waitingForMap: 'Waiting for the map',
126
+ // The review's sections as tags (corn-proposal, corn-changes, corn-decision): a scope holds one of each
127
+ secondSection: 'This scope already has one of these',
126
128
  });
127
129
 
128
130
  /** The longest a value may be, in characters */
@@ -185,4 +185,6 @@
185
185
  /* The title of a panel: the Work panel, the node panel, the proposal bar, a detail in the Work panel and a dialog are one style. A node's name is long and
186
186
  often a path, so it wraps (overflow-wrap) in this size rather than being set larger than the panel's own words. */
187
187
  .hx-drawer-title { font-size: var(--corn-text-lg); font-weight: 700; line-height: 1.25; letter-spacing: normal; }
188
- .hx-drawer-head { min-height: var(--corn-panel-head-height); }
188
+ /* The head never shrinks: the body is a flex column that scrolls, and a short box (a panel in a host's 200px place, a short window) would squash the head to its
189
+ min-height, laying a title that wraps, or a kicker that does ("Added by" a proposal), over the line under it */
190
+ .hx-drawer-head { min-height: var(--corn-panel-head-height); flex-shrink: 0; }
@@ -136,6 +136,8 @@ export const newReasons = (reasons, answered) => reasons.filter((r) => !answered
136
136
  * cornfield server to send a review to (pieces/review.js with no `base`). Cornfield's own page always names its proposal, so it never says this.
137
137
  */
138
138
  export const NOTHING_TO_DECIDE = 'Shown to read only: there is no cornfield server here to send an approval or a send back to.';
139
+ /** What the foot says for a proposal with no name in a scope that has a server (`<corn-decision>`): it is shown, but nothing can be decided on it */
140
+ export const NAMELESS_PROPOSAL = 'Shown to read only: this proposal has no name, so there is nothing to send an approval or a send back about.';
139
141
 
140
142
  /**
141
143
  * The line above Approve and what a press of it does, from the facts and the page's own state.
@@ -81,17 +81,19 @@ export function visibleMapRect(inst) {
81
81
  if (isPhone(inst)) covers.bottom = measureCovered(inst) + 8;
82
82
  else if (canvas && typeof canvas.getBoundingClientRect === 'function') {
83
83
  const c = canvas.getBoundingClientRect();
84
- const bar = inst.el('proposal-bar');
85
- if (shown(bar)) covers.top = Math.max(0, bar.getBoundingClientRect().bottom - c.top) + 8;
84
+ // What lies over the map in this instance's own layout (cornfield's page, a review) answers for itself: the proposal bar, the review column and the scenario
85
+ // player each say where their edge is, the node panel its width. In a scope the pieces sit beside the map, not over it, and none answers
86
+ const bar = inst.ask('proposal:covers');
87
+ if (bar) covers.top = Math.max(0, bar.bottom - c.top) + 8;
86
88
  const panel = inst.ask('panel:covers'); // the node panel, when it slides over the map: its width, not its box (it slides in)
87
89
  if (panel && panel.right) covers.right = panel.right;
88
90
  const forge = inst.el('forge-panel');
89
91
  if (shown(forge) && forge.classList.contains('forge-open')) covers.left = forge.offsetWidth;
90
92
  // the review column (review-column.js) is docked on the left under the bar: its right edge is what it covers, past the Work panel's when both are open
91
- const column = inst.el('review-column');
92
- if (shown(column)) covers.left = Math.max(covers.left, Math.max(0, column.getBoundingClientRect().right - c.left) + 8);
93
- const player = inst.root ? inst.root.querySelector('.hx-player') : null;
94
- if (shown(player)) covers.bottom = Math.max(0, c.bottom - player.getBoundingClientRect().top) + 8;
93
+ const column = inst.ask('changes:covers');
94
+ if (column) covers.left = Math.max(covers.left, Math.max(0, column.right - c.left) + 8);
95
+ const player = inst.ask('player:covers');
96
+ if (player) covers.bottom = Math.max(0, c.bottom - player.top) + 8;
95
97
  }
96
98
  return freeRect(state.width || 0, state.height || 0, covers);
97
99
  }
@@ -97,8 +97,11 @@ export function demoScenario(nodes, edges) {
97
97
  * @param {ReturnType<import('../instance.js').createInstance>} inst
98
98
  * @param {ReturnType<typeof import('./piece.js').scopeOf>} scope the piece's own end: every listener, observer and the frame client go with it
99
99
  * @param {ReturnType<typeof import('./checks.js').createChecks>} checks
100
+ * @param {{ seat?: Element, hear?: EventTarget }} [where] where the piece that owns the player has put it, when that is not the page's or the review's layout (`<corn-changes>`):
101
+ * `seat` is the element the bar goes in (it is a part of that piece, not a sheet or a bar over the map), `hear` the root whose keys are the player's (Space, the arrows, Escape).
102
+ * Without it the bar lies over the map's bottom, or is a sheet in the dock (the dock's owner seats it: `player:seat`), and the instance's root hears
100
103
  */
101
- export function createScenarioPlayer(inst, scope, checks) {
104
+ export function createScenarioPlayer(inst, scope, checks, where = {}) {
102
105
  const { state } = inst;
103
106
  let player = null;
104
107
  let bar = null;
@@ -121,7 +124,8 @@ export function createScenarioPlayer(inst, scope, checks) {
121
124
  let barOffs = [];
122
125
  const notify = (snap) => { for (const fn of [...listeners]) fn(snap); inst.emit('scenario:player', snap); };
123
126
 
124
- const stage = () => (state.canvas ? state.canvas.parentElement : null);
127
+ const stage = () => (where.seat || (state.canvas ? state.canvas.parentElement : null));
128
+ const hear = where.hear || inst.root;
125
129
  const render = () => inst.map.render();
126
130
 
127
131
  // ---------------------------------------------------------------------------
@@ -353,12 +357,13 @@ export function createScenarioPlayer(inst, scope, checks) {
353
357
  menu.addEventListener('change', onSpeed);
354
358
  barOffs.push(() => { here.removeEventListener('click', onBarClick); menu.removeEventListener('change', onSpeed); });
355
359
  // On a phone the bar is a sheet in the dock, above the node panel; it opens as a peek (one row) and the others fold, so the map shows
356
- const dock = inst.el('sheet-dock');
357
- const drawer = inst.el('spec-drawer');
358
- if (dock && drawer && drawer.parentElement === dock) dock.insertBefore(bar, drawer);
359
- else (dock || area).appendChild(bar);
360
- registerSheet(inst, 'player', bar);
361
- collapseAllSheets(inst);
360
+ if (where.seat) area.appendChild(bar); // a part of the piece's own box: no sheet, nothing over the map
361
+ else {
362
+ // On a phone the bar is a sheet in the dock, above the node panel; the dock's owner seats it (engine/sheets.js), else it lies over the map's bottom
363
+ if (inst.ask('player:seat', bar) !== true) area.appendChild(bar);
364
+ registerSheet(inst, 'player', bar);
365
+ collapseAllSheets(inst);
366
+ }
362
367
  // The bar grows once it has more to say (a step's check, its As row): the step it framed would now be under it, so it is followed again
363
368
  const RO = inst.win && inst.win.ResizeObserver;
364
369
  if (typeof RO === 'function') {
@@ -439,10 +444,11 @@ export function createScenarioPlayer(inst, scope, checks) {
439
444
  // ---------------------------------------------------------------------------
440
445
  /** A menu or dialog that has its own Escape: the layers menu, the toolbar's ⋯ menu, a dialog */
441
446
  function otherPopupOpen() {
442
- return !!inst.root.querySelector('#legend-dropdown:not([hidden]), #proposal-more-menu:not([hidden]), [data-corn="dialog-scrim"]:not([hidden]), .hx-mockup-dialog');
447
+ if (inst.ask('popup:open') === true) return true; // the Layers menu, the bar's ⋯ menu: whoever owns one says so
448
+ return !!inst.root.querySelector('[data-corn="dialog-scrim"]:not([hidden]), .hx-mockup-dialog');
443
449
  }
444
450
 
445
- scope.listen(inst.root, 'keydown', (e) => {
451
+ scope.listen(hear, 'keydown', (e) => {
446
452
  if (e.key === 'Escape' && !e.defaultPrevented && !e.ctrlKey && !e.metaKey && !e.altKey) {
447
453
  if (player && !typingIn(e.target) && !otherPopupOpen()) { e.preventDefault(); stop(); return; } // Escape closes the scenario; focus goes back to Play
448
454
  }
@@ -454,7 +460,7 @@ export function createScenarioPlayer(inst, scope, checks) {
454
460
  act(action);
455
461
  });
456
462
  // Some browsers press a focused button on the key's release, so a space the player took must not reach it
457
- scope.listen(inst.root, 'keyup', (e) => {
463
+ scope.listen(hear, 'keyup', (e) => {
458
464
  if (player && (e.key === ' ' || e.code === 'Space') && !typingIn(e.target)) e.preventDefault();
459
465
  });
460
466
  // A sheet that opened or closed changes what the map shows: keep the step in view
@@ -360,6 +360,14 @@ export function initSheets(inst) {
360
360
  }
361
361
  if (!S.documentWired) {
362
362
  S.documentWired = true;
363
+ // The scenario player's bar is a sheet in the dock, above the node panel's drawer (the dock's own children): the dock's owner seats it
364
+ inst.on('player:seat', (bar) => {
365
+ const dock = S.dock;
366
+ if (!dock || !dock.isConnected) return undefined;
367
+ const drawer = [...dock.children].find((child) => child.classList.contains('hx-drawer'));
368
+ if (drawer) dock.insertBefore(bar, drawer); else dock.appendChild(bar);
369
+ return true;
370
+ });
363
371
  for (const type of ['pointerdown', 'touchstart', 'mousedown']) inst.listen(inst.root, type, (e) => onMapDown(inst, e), { passive: true, capture: true });
364
372
  inst.listen(inst.root, 'keydown', (e) => onEscape(inst, e), true);
365
373
  onPhoneChange(inst, () => { collapseAllSheets(inst); measureCovered(inst); });
@@ -65,6 +65,8 @@
65
65
  * announce text what a screen reader is told (engine/keyboard.js `announce`; the piece that owns a live region writes it: `announce:write`)
66
66
  * root:changed (none) the primary root moved (`attach`) or a root joined or left (engine/roots.js): what listens on every root puts itself right
67
67
  * map:ready (none) the map piece is mounted and has its topology (pieces/map.js); map:gone: it ended. The pieces around it (pieces/around.js) mount and unmount with it
68
+ * map:topology (none) the map piece installed a base map (a topology the host handed in, or the server's); map:canvas: its canvas was replaced (another renderer). What holds a
69
+ * proposal over the map (pieces/scope-proposal.js) lays it over the new base, and binds the new canvas
68
70
  * search:status text what the search's own live region says (engine/search-status.js; pieces/search.js writes it)
69
71
  *
70
72
  * What a piece is asked to do (`emit`ted to it):
@@ -89,11 +91,17 @@
89
91
  * scenario:clear (none) (emit) a selection ends a playing scenario
90
92
  * proposal:effective proposal -> proposal the proposal the map is drawn from (the what-if editor's, with its edits in); proposal:before-close -> false keeps it open
91
93
  * proposal:specs-list (none) -> false there is no list of specs to open here (the review in another app): a bad link's ways leave the button out
94
+ * proposal:covers (none) -> { bottom }, changes:covers (none) -> { right }, player:covers (none) -> { top } where the proposal bar, the review column and the scenario player lie over the map, in
95
+ * client px (engine/map-rect.js): the map frames into what is left. A piece in a box of its own lies over nothing and answers none. popup:open (none) -> true:
96
+ * a menu that has its own Escape is open (the Layers menu, the bar's ⋯ menu: the player's Escape leaves it alone)
97
+ * proposal:seat-column { column, phone } -> true the bar seats the review column: under it, or in its body on a phone (pieces/proposal.js); proposal:bar-bottom (none) -> px,
98
+ * how far down the bar reaches, and proposal:bar-resize (emit): the bar's height changed, so the column starts under it again
99
+ * player:seat bar -> true the dock's owner (engine/sheets.js) seats the scenario player's bar as a sheet above the node panel's
92
100
  * threads:index nodeId -> { threads: thread[] | null, forge: string, start: true } | undefined the Work panel's list of the threads that mention a node, for the node panel's "Threads"; `threads` is null until the list was read; no answer: no Threads section
93
101
  * threads:ensure (none) (emit) the node panel was filled: the Work panel reads the threads list once; threads:changed: it was read, or the map changed, so the node panel draws "Threads" again
94
102
  * work:on (none) -> boolean whether the Work panel has started (a piece mounted after it asks rather than waits for `work:available`)
95
103
  * work:answer { run } (emit) "Answer" on the proposal bar's line: the Work panel opens on Runs at that run, its reply field focused
96
- * work:open-specs (none) -> true the Work panel's Specs tab opened for a bad link's way on; map:set { nodes, edges } -> true the page laid the map out from these
104
+ * work:open-specs (none) -> true the Work panel's Specs tab opened for a bad link's way on; map:set { nodes, edges } -> true the page (or the review, or a scope's map: pieces/map.js) laid the map out from these
97
105
  * changes:opened-line title -> string, changes:played-line -> string what the review column says of an opening, and how many scenarios were played
98
106
  * whatif:edits -> edits[], whatif:form -> { name } | null, whatif:describe -> string[] what the decision asks of the what-if editor
99
107
  *
@@ -11,7 +11,9 @@
11
11
  * root the shadow root of the tag
12
12
  * inst the scope's instance, or null: no scope around the tag, so a private instance with no map, which this says (`needsScope`)
13
13
  * options tokens (the default `--corn-*` CSS text), piece (the options the piece is mounted with), initial (its first `update`), noMap (the `strings` key said
14
- * while there is no map: `needsMap`, or the panel's own empty state), onSearch ({ query, current }, the instance's `search` event)
14
+ * while there is no map: `needsMap`, or the panel's own empty state), onSearch ({ query, current }, the instance's `search` event),
15
+ * exclusive (a name: the piece holds state of its own, so a scope holds one of it; see below), signIn ({ during: string[], clear: string }: the instance's
16
+ * `auth` events whose `during` is listed put the scope's sign-in card in this tag's own root, and the event `clear` takes it away)
15
17
  *
16
18
  * What it does so that three roots can share one instance:
17
19
  * - the root joins the instance (`joinRoot`, engine/roots.js): its keys and its focus are the instance's, so `/` pressed on the map reaches the search and a click in the
@@ -20,7 +22,10 @@
20
22
  * - the piece mounts when the instance has a map with nodes (`map:ready`, then the `scene` its data brings) and ends when it has none (`map:gone`): the
21
23
  * pieces read the map's camera, scene and visibility, so with none they say what they need in its place (`needsMap`), and while the map waits on its
22
24
  * server (loading, signed out, offline: the map's own card says which) that they wait for it (`waitingForMap`). Tags can come in any order;
23
- * - it has a live region of its own, said in only when no map has one (`announce:fallback`): a panel or a search beside no map still speaks.
25
+ * - it has a live region of its own, said in only when no map has one (`announce:fallback`): a panel or a search beside no map still speaks;
26
+ * - an `exclusive` piece (the proposal's bar, the change list with its player, the decision) is one per scope: each has a state of its own (a hold, a
27
+ * note, a playing scenario, a line that is said once), which two could not share. The first to join holds the name; a second says `secondSection` in its own
28
+ * place, tells the scope (`piece:refused`, which is `cornError` `second-section`), and takes over when the first leaves.
24
29
  * Nothing here reads the page: no `document`, no id of a neighbour. It never throws for a missing scope or map.
25
30
  */
26
31
 
@@ -46,11 +51,12 @@ function adoptTokens(root, css) {
46
51
  * @param {{ mount: Function }} piece
47
52
  * @param {ShadowRoot|Element} root
48
53
  * @param {ReturnType<typeof createInstance>|null} inst
49
- * @param {{ tokens?: string, piece?: object, initial?: object, noMap?: string, onSearch?: (d: { query: string, current: string | null }) => void }} [options]
54
+ * @param {{ tokens?: string, piece?: object, initial?: object, noMap?: string, onSearch?: (d: { query: string, current: string | null }) => void, exclusive?: string, signIn?: { during: string[], clear: string } }} [options]
50
55
  */
51
56
  export function mountAround(piece, root, inst, options = {}) {
52
57
  const ownsInstance = !inst;
53
58
  if (ownsInstance) inst = createInstance({ root });
59
+ const exclusive = typeof options.exclusive === 'string' ? options.exclusive : '';
54
60
  const info = scopeInfo(inst);
55
61
  const scope = scopeOf(inst);
56
62
  adoptTokens(root, options.tokens);
@@ -62,8 +68,14 @@ export function mountAround(piece, root, inst, options = {}) {
62
68
  scope.on('announce:fallback', (text) => { say(text); return true; });
63
69
  scope.own(() => region.remove());
64
70
 
71
+ /** Who holds each exclusive name in this instance (this call is the token) */
72
+ const holders = exclusive ? inst.slot('exclusive', () => new Map()) : null;
73
+ const token = {};
74
+ const second = () => !!holders && holders.has(exclusive) && holders.get(exclusive) !== token;
75
+ const takeName = () => { if (!holders) return true; if (second()) return false; holders.set(exclusive, token); return true; };
65
76
  let real = null;
66
77
  let note = [];
78
+ let told = false;
67
79
  let pending = { ...(options.initial || {}) };
68
80
  let ended = false;
69
81
 
@@ -73,13 +85,18 @@ export function mountAround(piece, root, inst, options = {}) {
73
85
  const hasMap = () => !!inst.map && inst.state.nodes.length > 0;
74
86
  const showNote = (gone = false) => {
75
87
  if (ended) return;
76
- const words = !info ? t(inst, 'needsScope') : options.noMap === 'nodePanelEmpty' ? t(inst, 'nodePanelEmpty') : inst.map && !gone ? t(inst, 'waitingForMap') : t(inst, 'needsMap');
88
+ const words = second() ? t(inst, 'secondSection') : !info ? t(inst, 'needsScope') : options.noMap === 'nodePanelEmpty' ? t(inst, 'nodePanelEmpty') : inst.map && !gone ? t(inst, 'waitingForMap') : t(inst, 'needsMap');
77
89
  if (note.length && note[0].textContent === words) return;
78
90
  dropNote();
79
91
  note = place(inst, root, `<p class="hx-needs" data-corn="empty">${escapeHtml(words)}</p>`, null, 'needs');
80
92
  };
81
93
  const mountReal = () => {
82
94
  if (real || ended) return;
95
+ if (!takeName()) {
96
+ showNote();
97
+ if (!told) { told = true; inst.emit('piece:refused', { piece: exclusive, reason: 'second-section', message: `A scope holds one ${exclusive}.` }); }
98
+ return;
99
+ }
83
100
  if (!hasMap()) { showNote(); return; }
84
101
  dropNote();
85
102
  real = piece.mount(root, inst, { ...(options.piece || {}), inline: true, phone: false });
@@ -88,9 +105,18 @@ export function mountAround(piece, root, inst, options = {}) {
88
105
  const unmountReal = () => { if (real) { real.destroy(); real = null; } };
89
106
 
90
107
  scope.on('map:ready', mountReal);
108
+ scope.on('exclusive:released', (d) => { if (d && d.name === exclusive) mountReal(); }); // the one that held the name left: this one may have it
91
109
  scope.on('scene', () => { if (!real) mountReal(); }); // the map's data came (its server answered, or the host handed it in)
92
110
  scope.on('map:gone', () => { unmountReal(); showNote(true); }); // (said while the map ends: the instance may still hold it)
93
111
  if (options.onSearch) scope.on('search', (d) => options.onSearch(d));
112
+ // A refusal for want of a sign-in, said where the person is working (the scope says it once to the host: `cornAuth`)
113
+ if (options.signIn && info && info.mountStatus) {
114
+ const [slot] = place(inst, root, '<div class="hx-signin-slot"></div>', null, 'signin');
115
+ const card = info.mountStatus(slot, inst, { follow: false });
116
+ scope.on('auth', ({ status, during }) => { if (options.signIn.during.includes(during)) card.show({ state: 'sign-in', status, signIn: info.signIn() }); });
117
+ scope.on(options.signIn.clear, () => card.clear());
118
+ scope.own(() => { card.destroy(); slot.remove(); });
119
+ }
94
120
  mountReal();
95
121
 
96
122
  return {
@@ -107,7 +133,10 @@ export function mountAround(piece, root, inst, options = {}) {
107
133
  ended = true;
108
134
  unmountReal();
109
135
  dropNote();
136
+ const held = holders && holders.get(exclusive) === token;
137
+ if (held) holders.delete(exclusive);
110
138
  scope.destroy();
139
+ if (held && !inst.ended) inst.emit('exclusive:released', { name: exclusive });
111
140
  if (ownsInstance) inst.destroy();
112
141
  },
113
142
  };
@@ -30,7 +30,10 @@
30
30
  *
31
31
  * @param {ParentNode} root where the column goes when `options.slots` names no place
32
32
  * @param {ReturnType<typeof import('../instance.js').createInstance>} inst the instance; its map must be made (engine/render.js)
33
- * @param {{ slots?: { column?: Node }, checker?: object | null }} [options] `checker`: a plugin's checker for the scenarios' permission checks (none: "Not checked")
33
+ * @param {{ slots?: { column?: Node }, checker?: object | null, inline?: boolean }} [options] `checker`: a plugin's checker for the scenarios' permission checks (none: "Not checked").
34
+ * `inline` is the piece in a box and a root of its own (`<corn-changes>`, pieces/around.js): the column fills the box (no panel docked beside the map, no phone sheet and no
35
+ * tabs: both lists, one under the other, scroll inside it), the player's bar is its last part, not a bar over the map's bottom, and its keys are this root's. What lies
36
+ * over the map is none of its business: it answers no `*:covers`, and chooses a step without closing a node panel
34
37
  * @returns {{ update: (props?: { checker?: object | null }) => void, destroy: () => void, playScenario: Function, stopScenario: Function, getPlayer: Function, elements: Element[] }}
35
38
  * `update({ checker })` hands over the checker; `update()` draws the lists again.
36
39
  */
@@ -55,13 +58,13 @@ const PLAYER_BESIDE_PANEL = 1360;
55
58
  const asList = (v) => (Array.isArray(v) ? v : []);
56
59
 
57
60
  /** The markup of the piece: the column. `column` is its one place; it keeps a place of its own for the decision's foot */
58
- export const markup = () => ({
61
+ export const markup = ({ inline = false } = {}) => ({
59
62
  column: '<aside id="review-column" class="hx-review-column glass" aria-label="Review" data-corn="review-column" hidden>'
60
63
  + '<div class="hx-rc-scroll">'
61
64
  + '<p id="proposal-summary" class="hx-proposal-summary" hidden></p>'
62
65
  + '<div id="review-lists" class="hx-rc-lists"></div>'
63
66
  + '</div>'
64
- + '<!--corn-piece:decision/foot-->'
67
+ + (inline ? '<div class="hx-player-seat"></div>' : '<!--corn-piece:decision/foot-->') // a box of its own has no foot: the decision is a tag of its own
65
68
  + '</aside>',
66
69
  });
67
70
 
@@ -77,7 +80,10 @@ function changeRowHtml(r) {
77
80
  export function mount(root, inst, options = {}) {
78
81
  const { state } = inst;
79
82
  const scope = scopeOf(inst);
80
- const made = place(inst, root, markup().column, options.slots, 'column');
83
+ const inline = !!options.inline;
84
+ /** Whether the layout is a phone's: the window's width on cornfield's page, the box's in a review. A box of its own never has the phone's sheets: its narrowness is the CSS's alone */
85
+ const phone = () => !inline && isPhone(inst);
86
+ const made = place(inst, root, markup({ inline }).column, options.slots, 'column');
81
87
  /** An element of this piece by id */
82
88
  const own = (id) => {
83
89
  for (const el of made) {
@@ -92,7 +98,7 @@ export function mount(root, inst, options = {}) {
92
98
  let gone = false;
93
99
 
94
100
  const checks = createChecks(inst, { checker: options.checker });
95
- const player = createScenarioPlayer(inst, scope, checks);
101
+ const player = createScenarioPlayer(inst, scope, checks, inline ? { seat: col.querySelector('.hx-player-seat'), hear: root } : {});
96
102
  scope.own(() => checks.close());
97
103
 
98
104
  /** What the column shows apart from the proposal: the scenario whose steps are open, the phone's tab, the PR head the record is keyed by */
@@ -220,17 +226,17 @@ export function mount(root, inst, options = {}) {
220
226
  const rows = everyRow.filter((r) => r.mark !== 'edit');
221
227
  const mine = everyRow.filter((r) => r.mark === 'edit'); // "Your edits · 1": the first group, not the last row
222
228
  const list = model();
223
- const phone = isPhone(inst);
229
+ const narrow = phone();
224
230
  // the phone's tab: the reviewer's last choice, or Scenarios when there are any; a proposal with none opens on its changes
225
231
  if (ui.tabFor !== proposalKey()) { ui.tabFor = proposalKey(); ui.tabNow = list.total ? (ui.tab || 'scenarios') : 'changes'; }
226
232
  const tab = ui.tabNow || 'changes';
227
233
  const personas = state.nodes.some((n) => n.type === 'persona');
228
234
 
229
- const tabs = `<div class="hx-rc-tabs" role="tablist" aria-label="Review" data-corn="tabs"${phone ? '' : ' hidden'}>`
235
+ const tabs = `<div class="hx-rc-tabs" role="tablist" aria-label="Review" data-corn="tabs"${narrow ? '' : ' hidden'}>`
230
236
  + `<button type="button" role="tab" id="rc-tab-changes" class="hx-rc-tab" data-corn="tab" data-action="review-tab" data-tab="changes" aria-selected="${tab === 'changes'}" aria-controls="rc-changes" tabindex="${tab === 'changes' ? 0 : -1}">${escHtml(t(inst, 'changes'))} · ${rows.length}</button>`
231
237
  + `<button type="button" role="tab" id="rc-tab-scenarios" class="hx-rc-tab" data-corn="tab" data-action="review-tab" data-tab="scenarios" aria-selected="${tab === 'scenarios'}" aria-controls="rc-scenarios" tabindex="${tab === 'scenarios' ? 0 : -1}">${escHtml(t(inst, 'scenarios'))} · ${list.total}</button></div>`;
232
238
 
233
- const changes = `<section id="rc-changes" class="hx-rc-section" data-corn="proposal-changes"${phone ? ` role="tabpanel" aria-labelledby="rc-tab-changes"${tab === 'changes' ? '' : ' hidden'}` : ' aria-labelledby="rc-changes-h"'}>`
239
+ const changes = `<section id="rc-changes" class="hx-rc-section" data-corn="proposal-changes"${narrow ? ` role="tabpanel" aria-labelledby="rc-tab-changes"${tab === 'changes' ? '' : ' hidden'}` : ' aria-labelledby="rc-changes-h"'}>`
234
240
  + `<h3 id="rc-changes-h" class="hx-rc-h" tabindex="-1">${countHeading(t(inst, 'changes'), rows.length)}</h3>`
235
241
  + (mine.length ? `<h4 class="hx-rc-sub">${countHeading(t(inst, 'yourEdits'), mine.length)}</h4><ul class="hx-change-list">${mine.map(changeRowHtml).join('')}</ul>` : '')
236
242
  + (rows.length ? `<ul class="hx-change-list">${rows.map(changeRowHtml).join('')}</ul>` : '<p class="hx-faint hx-rc-empty">This proposal changes nothing on the map.</p>')
@@ -243,7 +249,7 @@ export function mount(root, inst, options = {}) {
243
249
  if (!personas) body += `<p class="hx-faint hx-rc-note">This map has no personas (topology.personas.json), so every scenario is listed under ${escHtml(t(inst, 'anyone'))}.</p>`;
244
250
  if (list.coverage) body += `<p class="hx-rc-coverage" data-corn="notice">${escHtml(t(inst, 'notInAnyScenario'))}: ${list.notInAny.map(escHtml).join(', ')}</p>`;
245
251
  }
246
- const scenarios = `<section id="rc-scenarios" class="hx-rc-section" data-corn="scenario-list"${phone ? ` role="tabpanel" aria-labelledby="rc-tab-scenarios"${tab === 'scenarios' ? '' : ' hidden'}` : ' aria-labelledby="rc-scenarios-h"'}>`
252
+ const scenarios = `<section id="rc-scenarios" class="hx-rc-section" data-corn="scenario-list"${narrow ? ` role="tabpanel" aria-labelledby="rc-tab-scenarios"${tab === 'scenarios' ? '' : ' hidden'}` : ' aria-labelledby="rc-scenarios-h"'}>`
247
253
  + `<h3 id="rc-scenarios-h" class="hx-rc-h" tabindex="-1">${countHeading(t(inst, 'personasAndScenarios'), list.total)}</h3><div class="hx-rc-sbody">${body}</div></section>`;
248
254
  return `${tabs}${changes}${scenarios}`;
249
255
  }
@@ -253,20 +259,15 @@ export function mount(root, inst, options = {}) {
253
259
  // ---------------------------------------------------------------------------
254
260
  /** Where the column goes: after the proposal bar in the dock from 768px, at the end of the sheet's body on a phone */
255
261
  function mountColumn() {
256
- const dock = inst.el('sheet-dock');
257
- const body = inst.el('proposal-body');
258
- if (isPhone(inst) && body) { if (col.parentElement !== body) body.appendChild(col); } else if (dock) {
259
- const bar = inst.el('proposal-bar');
260
- if (bar && col.parentElement !== dock) bar.after(col);
261
- }
262
+ if (!inline) inst.ask('proposal:seat-column', { column: col, phone: phone() }); // the bar seats it (pieces/proposal.js): nobody answering leaves it where it is
262
263
  return col;
263
264
  }
264
265
 
265
266
  /** The column starts under the bar, whatever height the bar has (the counts wrap, the edit controls open): from 768px; a phone's has no place of its own */
266
267
  function placeColumn() {
267
- const bar = inst.el('proposal-bar');
268
- if (!bar || isPhone(inst) || bar.hidden) return;
269
- col.style.setProperty('--hx-column-top', `${Math.round(bar.offsetTop + bar.offsetHeight + 8)}px`);
268
+ if (inline || phone()) return;
269
+ const bottom = inst.ask('proposal:bar-bottom');
270
+ if (typeof bottom === 'number') col.style.setProperty('--hx-column-top', `${bottom}px`);
270
271
  }
271
272
 
272
273
  /** Draws the column for the open proposal, or hides it when none is open */
@@ -288,7 +289,7 @@ export function mount(root, inst, options = {}) {
288
289
  function shareRoom() {
289
290
  const lists = own('review-lists');
290
291
  const sc = own('rc-scenarios');
291
- if (!lists || !sc || col.hidden || isPhone(inst)) return;
292
+ if (!lists || !sc || col.hidden || phone()) return;
292
293
  const h = lists.clientHeight;
293
294
  if (!h) return;
294
295
  const gap = parseFloat(inst.win.getComputedStyle(lists).rowGap) || 0;
@@ -356,10 +357,9 @@ export function mount(root, inst, options = {}) {
356
357
  function chooseStep(sc, index) {
357
358
  ui.open = sc.id;
358
359
  // Under 1360px the column, the node panel and the player bar do not fit side by side: the node panel closes, the player takes its room
359
- const drawer = inst.el('spec-drawer');
360
360
  const stage = state.canvas && state.canvas.parentElement;
361
- if (!isPhone(inst) && drawer && drawer.classList.contains('drawer-open') && stage && stage.clientWidth < PLAYER_BESIDE_PANEL) clearSelection(inst, { source: 'api' });
362
- player.play(sc, { autoplay: false, step: index, focus: isPhone(inst) });
361
+ if (!inline && !phone() && inst.ask('panel:covers') && stage && stage.clientWidth < PLAYER_BESIDE_PANEL) clearSelection(inst, { source: 'api' }); // a slide-over node panel is open (it answers `panel:covers`)
362
+ player.play(sc, { autoplay: false, step: index, focus: phone() });
363
363
  repaint();
364
364
  }
365
365
 
@@ -375,7 +375,7 @@ export function mount(root, inst, options = {}) {
375
375
  /** The counts' parts open their section: the switch moves to it on a phone; from 768px it scrolls into view and takes the focus */
376
376
  function showSection(which) {
377
377
  if (!state.proposal) return;
378
- if (isPhone(inst)) { showTab(which); expandSheet(inst, 'proposal'); }
378
+ if (phone()) { showTab(which); expandSheet(inst, 'proposal'); }
379
379
  const section = own(which === 'scenarios' ? 'rc-scenarios' : 'rc-changes');
380
380
  const heading = own(which === 'scenarios' ? 'rc-scenarios-h' : 'rc-changes-h');
381
381
  if (section && typeof section.scrollIntoView === 'function') section.scrollIntoView({ block: 'start' });
@@ -426,7 +426,7 @@ export function mount(root, inst, options = {}) {
426
426
  function stepToFocus() {
427
427
  const at = ui.lastStep;
428
428
  if (!at) return null;
429
- if (isPhone(inst)) expandSheet(inst, 'proposal');
429
+ if (phone()) expandSheet(inst, 'proposal');
430
430
  const lists = own('review-lists');
431
431
  return lists ? lists.querySelector(`[data-action="scenario-step"][data-scenario-index="${at.index}"][data-step-index="${at.step}"]`) : null;
432
432
  }
@@ -451,9 +451,15 @@ export function mount(root, inst, options = {}) {
451
451
  scope.on('changes:show', (which) => showSection(which));
452
452
  const RO = inst.win && inst.win.ResizeObserver;
453
453
  const watch = (el, fn) => { if (el && typeof RO === 'function') { const ro = new RO(fn); ro.observe(el); scope.own(() => ro.disconnect()); } };
454
- watch(inst.el('proposal-bar'), () => placeColumn());
454
+ scope.on('proposal:bar-resize', () => placeColumn()); // the bar's height changed (the counts wrap, a line comes): the column starts under it
455
455
  watch(col, () => shareRoom()); // the window's height changed
456
- scope.own(onPhoneChange(inst, () => { if (state.proposal) renderColumn(); })); // the window's width, or the box's where the review has one (engine/sheets.js)
456
+ if (!inline) {
457
+ scope.own(onPhoneChange(inst, () => { if (state.proposal) renderColumn(); })); // the window's width, or the box's where the review has one (engine/sheets.js)
458
+ // What the column and the player cover of the map: the map frames a step into what is left (engine/map-rect.js)
459
+ const shown = (el) => !!el && !el.hidden && el.isConnected;
460
+ scope.on('changes:covers', () => (shown(col) ? { right: col.getBoundingClientRect().right } : undefined));
461
+ scope.on('player:covers', () => { const bar = player.bar(); return shown(bar) ? { top: bar.getBoundingClientRect().top } : undefined; });
462
+ }
457
463
 
458
464
  scope.own(() => {
459
465
  gone = true;
@@ -42,7 +42,9 @@
42
42
  *
43
43
  * @param {ParentNode} root where the foot goes when `options.slots` names no place
44
44
  * @param {ReturnType<typeof import('../instance.js').createInstance>} inst the instance
45
- * @param {{ slots?: { foot?: Node }, now?: () => number }} [options] `now`: the clock the times shown are read from (a test winds it)
45
+ * @param {{ slots?: { foot?: Node }, now?: () => number, unnamed?: string, inline?: boolean }} [options] `now`: the clock the times shown are read from (a test winds it).
46
+ * `inline` is the piece in a box and a root of its own (`<corn-decision>`, pieces/around.js): no phone sheet to open for the note, and the Escape that takes a
47
+ * question back or ends a hold is heard in this root, where the focus is
46
48
  * @returns {{ update: (props?: object) => void, destroy: () => void, sendReview: Function, loadFacts: Function, elements: Element[] }}
47
49
  * `update()` reads the proposal that is open again (the host changed it); nothing else is taken
48
50
  */
@@ -50,7 +52,7 @@
50
52
  import { expandSheet, isPhone } from '../engine/sheets.js';
51
53
  import { reviewParts, sendBackProblem, reviewBody, editsHint, isReviewable } from '../review-model.js';
52
54
  import {
53
- HOLD_MS, decide, askReasons, askWords, newReasons, sendBackLine, sendBackDecision, refusalWords, holdWords, holdStartWords, holdCancelledWords, editsSentWords,
55
+ HOLD_MS, NAMELESS_PROPOSAL, decide, askReasons, askWords, newReasons, sendBackLine, sendBackDecision, refusalWords, holdWords, holdStartWords, holdCancelledWords, editsSentWords,
54
56
  } from '../decision-model.js';
55
57
  import { pullNumberOf } from '../proposal-model.js';
56
58
  import { announce } from '../engine/keyboard.js';
@@ -101,8 +103,12 @@ export function mount(root, inst, options = {}) {
101
103
  const { state } = inst;
102
104
  const scope = scopeOf(inst);
103
105
  const now = typeof options.now === 'function' ? options.now : () => Date.now();
106
+ const inline = !!options.inline;
107
+ const phone = () => !inline && isPhone(inst);
108
+ /** What hears the Escape and the held key's repeats: the instance's root, or the box's own root */
109
+ const hear = inline ? root : inst.root;
104
110
  /** What the foot says in place of its buttons for a proposal with no name, which nothing can be decided on (the review piece's, with no server); none: the page's */
105
- const unnamed = typeof options.unnamed === 'string' && options.unnamed ? options.unnamed : '';
111
+ const unnamed = typeof options.unnamed === 'string' && options.unnamed ? options.unnamed : inline ? NAMELESS_PROPOSAL : '';
106
112
  const get = credentialed(inst);
107
113
  const made = place(inst, root, markup().foot, options.slots, 'foot');
108
114
  scope.keepParts(...made);
@@ -260,11 +266,11 @@ export function mount(root, inst, options = {}) {
260
266
  ui.noting = true;
261
267
  ui.message = '';
262
268
  paint();
263
- if (isPhone(inst)) expandSheet(inst, 'proposal');
269
+ if (phone()) expandSheet(inst, 'proposal');
264
270
  q('#review-note').focus();
265
271
  // On a phone the keyboard is about to take half the screen: the note and the button that sends it stay in view above it
266
272
  const send = button('notes');
267
- if (isPhone(inst) && send && typeof send.scrollIntoView === 'function') send.scrollIntoView({ block: 'nearest' });
273
+ if (phone() && send && typeof send.scrollIntoView === 'function') send.scrollIntoView({ block: 'nearest' });
268
274
  }
269
275
 
270
276
  /** Cancel: the field closes, what was typed goes, and focus goes back to Send back */
@@ -283,6 +289,7 @@ export function mount(root, inst, options = {}) {
283
289
  function onBar({ open }) {
284
290
  const key = open ? keyOf() : null;
285
291
  rootEl.hidden = !(key || (open && unnamed));
292
+ if (inline) foot.hidden = !open; // in a box of its own there is no column to hide with no proposal open: the foot is the box
286
293
  if (key === ui.key) { paint(); return; }
287
294
  if (ui.hold) stopHold(open ? 'other' : 'closed', { quiet: false });
288
295
  ui.key = key;
@@ -421,7 +428,7 @@ export function mount(root, inst, options = {}) {
421
428
  ui.message = problem;
422
429
  ui.noting = true; // the refusal is about the note: show it
423
430
  paint();
424
- if (isPhone(inst)) expandSheet(inst, 'proposal');
431
+ if (phone()) expandSheet(inst, 'proposal');
425
432
  q('#review-note').focus();
426
433
  return;
427
434
  }
@@ -544,7 +551,7 @@ export function mount(root, inst, options = {}) {
544
551
  ui.message = problem;
545
552
  ui.noting = true; // the refusal is about the note: show it
546
553
  paint();
547
- if (isPhone(inst)) expandSheet(inst, 'proposal');
554
+ if (phone()) expandSheet(inst, 'proposal');
548
555
  noteEl.focus();
549
556
  return false;
550
557
  }
@@ -624,7 +631,7 @@ export function mount(root, inst, options = {}) {
624
631
  });
625
632
  scope.listen(rootEl, 'keydown', (e) => { if (e.key === 'Escape' && ui.noting && !ui.asking && !ui.hold) { e.stopPropagation(); closeNote(); } });
626
633
  // Escape takes an open question back, or ends a hold, before anything else on the page hears it; a held key's repeats do nothing here
627
- scope.listen(inst.root, 'keydown', (e) => {
634
+ scope.listen(hear, 'keydown', (e) => {
628
635
  // A key held down repeats: its repeats are not more decisions (Enter held on Approve would answer its own question, then undo the hold)
629
636
  if (e.repeat && (e.key === 'Enter' || e.key === ' ') && e.target && e.target.closest && e.target.closest('#review-decision [data-review], #review-decision [data-review-undo]')) { e.preventDefault(); e.stopPropagation(); return; }
630
637
  if (e.key !== 'Escape' || !ui.key) return;
@@ -312,6 +312,7 @@ export function mount(root, inst, options = {}) {
312
312
 
313
313
  // -- following the instance ------------------------------------------------------------------------------------------------------
314
314
  scope.on('layers:present', () => true); // the map's keys know there is a menu to turn a layer on in
315
+ scope.on('popup:open', () => (!menu.hidden ? true : undefined)); // the scenario player's Escape leaves a menu that has its own
315
316
  scope.on('layers:redraw', renderLayerToggles);
316
317
  scope.on('theme', renderLayerToggles); // the dots and the legends are drawn in the theme's colours
317
318
  scope.on('view', syncView);
@@ -45,7 +45,7 @@
45
45
  import { createInstance } from '../instance.js';
46
46
  import { createMap } from '../engine/render.js';
47
47
  import { mapStyleOf } from '../engine/map-style.js';
48
- import { layoutMap, setTopology as installTopology } from '../engine/topology.js';
48
+ import { layoutMap, setMap, setTopology as installTopology } from '../engine/topology.js';
49
49
  import { initKeyboard, resetKeyboard, speaker } from '../engine/keyboard.js';
50
50
  import { selectNode, clearSelection } from '../engine/selection.js';
51
51
  import { stopFlight } from '../engine/fly.js';
@@ -181,6 +181,9 @@ function mountOn(root, inst, options, privateScope) {
181
181
  const scope = scopeOf(inst);
182
182
  scope.own(releaseRoot);
183
183
  if (privateScope) scope.own(() => privateScope.destroy());
184
+ // In a scope, a proposal the scope holds (pieces/scope-proposal.js) is laid out on this map's own layout: nodes that were there keep their place (the review
185
+ // and cornfield's page answer for their own maps)
186
+ if (info) scope.on('map:set', ({ nodes, edges }) => { setMap(inst, nodes, edges); return true; });
184
187
  const rendererOf = (v) => (v === 'canvas2d' ? 'canvas2d' : 'auto');
185
188
  const themeOf = (v) => (v === 'light' || v === 'dark' ? v : 'auto');
186
189
  const current = { renderer: rendererOf(options.renderer), theme: themeOf(options.theme), topology: undefined };
@@ -329,6 +332,7 @@ function mountOn(root, inst, options, privateScope) {
329
332
  if (asked) selectNode(inst, asked, { source: 'api' });
330
333
  map.render();
331
334
  map.ensureFlowLoop();
335
+ inst.emit('map:topology'); // a proposal held over the map (pieces/scope-proposal.js) is laid over the new base
332
336
  }
333
337
 
334
338
  function setView(view) {
@@ -355,6 +359,7 @@ function mountOn(root, inst, options, privateScope) {
355
359
  installRenderer();
356
360
  map.resize();
357
361
  if (hadFocus) next.focus();
362
+ inst.emit('map:canvas'); // a click on an edge is heard on the new canvas (pieces/scope-proposal.js)
358
363
  }
359
364
 
360
365
  /**
@@ -13,8 +13,10 @@
13
13
  *
14
14
  * @param {ParentNode} root where the elements go when `options.slots` names no place
15
15
  * @param {ReturnType<typeof import('../instance.js').createInstance>} inst the instance; its map must be made (engine/render.js)
16
- * @param {{ slots?: { bar?: Node, menu?: Node }, edit?: boolean }} [options] `edit: false` leaves out the what-if editor's two buttons (My edits, Edit):
17
- * a host without the editor has nothing to put behind them
16
+ * @param {{ slots?: { bar?: Node, menu?: Node }, edit?: boolean, inline?: boolean }} [options] `edit: false` leaves out the what-if editor's two buttons (My edits, Edit):
17
+ * a host without the editor has nothing to put behind them. `inline` is the piece in a box of its own, in a root of its own (`<corn-proposal>`, pieces/around.js): the
18
+ * bar is a block that fills the box, not a panel over the map: no phone sheet, no Proposals menu, no what-if buttons, its keys and clicks are its own root's, and the picking of an
19
+ * edge on the map is the scope's (pieces/scope-proposal.js), whose proposal this is
18
20
  * @returns {{ update: (props?: { proposal?: string | object | null, source?: string | null, view?: string, slug?: string | null, sha256?: string | null }) => Promise<boolean> | void, destroy: () => void, elements: Element[], renderBar: Function, paintWaitingLine: Function, toggleMenu: Function, closeMenu: Function }}
19
21
  * `update({ proposal })` opens a proposal: a slug (fetched through `inst.fetch`, with `source` to name the copy), or the proposal itself (nothing is fetched:
20
22
  * `slug`, `source` and `sha256` name it); `null` closes it. `update({ view })` switches Before, Diff or After. `update()` draws the bar again.
@@ -122,11 +124,14 @@ export function proposalRowHtml(entry, current) {
122
124
  export function mount(root, inst, options = {}) {
123
125
  const { state } = inst;
124
126
  const scope = scopeOf(inst);
125
- const html = markup({ edit: options.edit !== false });
127
+ const inline = !!options.inline;
128
+ const html = markup({ edit: options.edit !== false && !inline });
126
129
  const made = [
127
130
  ...place(inst, root, html.bar, options.slots, 'bar'),
128
- ...place(inst, root, html.menu, options.slots, 'menu'),
131
+ ...(inline ? [] : place(inst, root, html.menu, options.slots, 'menu')),
129
132
  ];
133
+ /** What hears the clicks and keys of this piece: the instance's root, which holds the Work panel's Specs list too (cornfield's page), or the box's own root */
134
+ const hear = inline ? root : inst.root;
130
135
  /** An element of this piece by id (the piece's own, whatever else the root holds) */
131
136
  const own = (id) => {
132
137
  for (const el of made) {
@@ -203,7 +208,7 @@ export function mount(root, inst, options = {}) {
203
208
  // ---------------------------------------------------------------------------
204
209
  function renderBar({ open = !!state.proposal } = {}) {
205
210
  bar.hidden = !open;
206
- if (!open) { closeMore(); toggleMode(false); collapseSheet(inst, 'proposal'); return; }
211
+ if (!open) { closeMore(); toggleMode(false); if (!inline) collapseSheet(inst, 'proposal'); return; }
207
212
 
208
213
  bar.classList.remove('is-error');
209
214
  own('proposal-message').hidden = true;
@@ -336,12 +341,15 @@ export function mount(root, inst, options = {}) {
336
341
  const menuOpen = () => { const menu = own('proposal-menu'); return !!menu && !menu.hidden; };
337
342
 
338
343
  function closeMenu() {
339
- own('proposal-menu').hidden = true;
344
+ const menu = own('proposal-menu');
345
+ if (!menu) return; // a bar in a box of its own has no Proposals menu
346
+ menu.hidden = true;
340
347
  own('proposal-btn').setAttribute('aria-expanded', 'false');
341
348
  }
342
349
 
343
350
  async function toggleMenu() {
344
351
  const menu = own('proposal-menu');
352
+ if (!menu) return undefined;
345
353
  if (menuOpen()) return closeMenu();
346
354
  menu.hidden = false;
347
355
  own('proposal-btn').setAttribute('aria-expanded', 'true');
@@ -351,6 +359,7 @@ export function mount(root, inst, options = {}) {
351
359
 
352
360
  function renderMenu(loading = false) {
353
361
  const menu = own('proposal-menu');
362
+ if (!menu) return;
354
363
  const { entries: listing, problem: listingProblem, forgeProblem } = proposalListing(inst);
355
364
  const current = state.proposal ? { slug: state.proposalSlug, source: state.proposalSource } : null;
356
365
  let body;
@@ -391,7 +400,7 @@ export function mount(root, inst, options = {}) {
391
400
  const ACTIONS = {
392
401
  'toggle-proposals-menu': () => toggleMenu(),
393
402
  'open-proposal': (el) => openProposal(inst, el.dataset.slug, el.dataset.source || null),
394
- 'close-proposal': () => closeProposal(inst),
403
+ 'close-proposal': () => { closeProposal(inst); if (inline && state.canvas) state.canvas.focus(); }, // the bar is gone with the proposal: the focus goes to the map, never to the page
395
404
  'proposal-whole': () => { setWholeMap(inst, !(state.review && state.review.whole)); drawBar(inst); }, // "Show the whole map": announced by engine/layers.js, the focus stays on the switch
396
405
  'proposal-view': (el) => { setProposalView(inst, el.dataset.view); toggleMode(false); },
397
406
  'toggle-proposal-mode': () => toggleMode(),
@@ -402,7 +411,7 @@ export function mount(root, inst, options = {}) {
402
411
  };
403
412
 
404
413
  // The root hears every control: the bar's, the menu's and a row of the Work panel's Specs list (`open-proposal`), as the document did
405
- scope.listen(inst.root, 'click', (e) => {
414
+ scope.listen(hear, 'click', (e) => {
406
415
  const target = e.target.closest ? e.target.closest('[data-action]') : null;
407
416
  const action = target && Object.hasOwn(ACTIONS, target.dataset.action) && ACTIONS[target.dataset.action];
408
417
  if (action) action(target);
@@ -412,6 +421,10 @@ export function mount(root, inst, options = {}) {
412
421
  const wrap = own('proposal-wrap');
413
422
  if (menuOpen() && wrap && !wrap.contains(e.target) && !(target && target.dataset.action === 'proposal-way')) closeMenu(); // (a bad link's Specs list opens it from outside)
414
423
  });
424
+ // In a box of its own the root hears only the bar's clicks: a click anywhere else in the page (the map, the host's own page, another section) closes the ⋯ menu
425
+ // too, as it does on cornfield's page. The open menu holds the focus (on an item), and such a click takes it out of the bar: the menu closes when the focus
426
+ // leaves the bar (to nothing, or to anything outside it), which holds in a host's closed shadow root too and needs no listener on the page
427
+ if (inline) scope.listen(bar, 'focusout', (e) => { if (moreOpen() && !(e.relatedTarget && bar.contains(e.relatedTarget))) closeMore(); });
415
428
  // Answer, on the bar's line (a run waits on this proposal): the Work panel opens on that run with its reply field focused (work:answer)
416
429
  scope.listen(bar, 'click', (e) => {
417
430
  const go = e.target.closest && e.target.closest('[data-waiting-answer]');
@@ -421,7 +434,7 @@ export function mount(root, inst, options = {}) {
421
434
  const proposalsEntry = (workOn) => { const wrap = own('proposal-wrap'); if (wrap) wrap.hidden = !!workOn; };
422
435
  scope.on('work:available', ({ on }) => proposalsEntry(on));
423
436
  if (inst.ask('work:on')) proposalsEntry(true); // the Work panel started before this piece was mounted: it said so to nobody
424
- scope.listen(inst.root, 'keydown', (e) => {
437
+ scope.listen(hear, 'keydown', (e) => {
425
438
  if (e.key === 'Escape' && menuOpen()) closeMenu();
426
439
  onMoreKey(e);
427
440
  });
@@ -450,11 +463,25 @@ export function mount(root, inst, options = {}) {
450
463
  scope.on('proposal:waiting', ({ run, key }) => paintWaitingLine(run, key));
451
464
  scope.on('proposal:waiting-reset', () => { waitingSaid = null; waitingEl = null; });
452
465
  scope.on('proposal', ({ change }) => { if (change === 'opened') closeMenu(); });
453
- scope.own(bindEdgePicking(inst, (target, type, fn) => scope.listen(target, type, fn)));
454
-
455
- initSheets(inst);
456
- registerSheet(inst, 'proposal', bar, { stub: () => ({ title: (own('proposal-title') && own('proposal-title').textContent) || 'Proposal' }) });
457
- scope.own(() => unregisterSheet(inst, 'proposal'));
466
+ if (!inline) {
467
+ scope.own(bindEdgePicking(inst, (target, type, fn) => scope.listen(target, type, fn)));
468
+ initSheets(inst);
469
+ registerSheet(inst, 'proposal', bar, { stub: () => ({ title: (own('proposal-title') && own('proposal-title').textContent) || 'Proposal' }) });
470
+ scope.own(() => unregisterSheet(inst, 'proposal'));
471
+ // What the bar answers its neighbours in a box of one root: the part of the map it covers (the map frames into what is left), where the review column
472
+ // goes (under it, or in its body on a phone), and how far down it reaches (the column starts there)
473
+ scope.on('proposal:covers', () => (bar.hidden || !bar.isConnected ? undefined : { bottom: bar.getBoundingClientRect().bottom }));
474
+ scope.on('proposal:bar-bottom', () => (bar.hidden ? undefined : Math.round(bar.offsetTop + bar.offsetHeight + 8)));
475
+ scope.on('proposal:seat-column', ({ column, phone }) => {
476
+ const body = own('proposal-body');
477
+ if (phone && body) { if (column.parentElement !== body) body.appendChild(column); return true; }
478
+ if (bar.parentElement && column.parentElement !== bar.parentElement) bar.after(column);
479
+ return true;
480
+ });
481
+ const RO = inst.win && inst.win.ResizeObserver;
482
+ if (typeof RO === 'function') { const ro = new RO(() => inst.emit('proposal:bar-resize')); ro.observe(bar); scope.own(() => ro.disconnect()); }
483
+ }
484
+ scope.on('popup:open', () => (moreOpen() ? true : undefined)); // the player's Escape leaves a menu that has its own
458
485
 
459
486
  scope.own(() => {
460
487
  gone = true;
@@ -7,14 +7,14 @@
7
7
  * `<corn-scope>`, or the first time a map has a `src` (pieces/map.js imports them then, as a chunk of the package's own).
8
8
  *
9
9
  * const join = joinScope(el, onChange) -> { inst, scope, leave } (a piece's shell calls it for the scope around it, if any)
10
- * scopeInfo(inst) -> { theme, serverTheme, host, source, mountStatus } for a scope's instance, else null
10
+ * scopeInfo(inst) -> { theme, serverTheme, host, source, mountStatus, signIn } for a scope's instance, else null (`signIn()`: the server's sign-in, back to the page)
11
11
  */
12
12
 
13
13
  export const REQUEST = 'corn-scope-request';
14
14
  export const CHANGED = 'corn-scope-changed';
15
15
 
16
16
  /** What a piece may ask a scope for, per instance: set when a scope makes the instance */
17
- export const infoOf = (inst) => inst.slot('scope', () => ({ theme: 'auto', serverTheme: null, host: null, source: null, mountStatus: null }));
17
+ export const infoOf = (inst) => inst.slot('scope', () => ({ theme: 'auto', serverTheme: null, host: null, source: null, mountStatus: null, signIn: () => '' }));
18
18
  /**
19
19
  * The scope's side of an instance, or null for a private one: its `theme`, its server theme (to adopt into a root), its element, its source (the
20
20
  * load: engine/source.js) and how a piece shows the load's states (pieces/status.js `mount`)
@@ -0,0 +1,158 @@
1
+ /**
2
+ * @module explorer/pieces/scope-proposal
3
+ *
4
+ * The proposal a `<corn-scope>` holds for every piece in it (spec 0011 D4, D5, D6): the sketch puts `proposal` (and `source` and `view`) on the scope, so
5
+ * the review's sections (`<corn-proposal>`, `<corn-changes>`, `<corn-decision>`) and the map beside them follow one proposal. This is the same opening
6
+ * `corn-review` does in its one root (pieces/review.js `applyProposal`), on the scope's instance and with no piece of its own: it asks the engine
7
+ * (engine/proposal.js: `GET /proposals/<name>.json` through `credentialed`, so the session goes only to the server's own origin), and the pieces that
8
+ * are there draw what the instance says (`proposal:draw`, `proposal:bar`). It is a chunk of its own, loaded the first time a scope has a proposal:
9
+ * a scope or a map that never has one does not carry it.
10
+ *
11
+ * const held = holdProposal(inst, options) -> { update, sync, destroy }
12
+ *
13
+ * Options (and what `update(next)` takes, only the keys present):
14
+ * proposal a name (read from the server), the proposal object (shown for reading: a decision needs the name), or null: closes it. Held while
15
+ * there is no map with nodes to lay it over, and opened when there is (a map that comes later, or is put back: `map:ready`, `map:topology`)
16
+ * source which copy of it: `checkout`, `pull/31`, a worktree; none: the server answers with the first it lists
17
+ * view `before`, `diff` or `after`
18
+ * blocked the scope's `src` is not an address: a name is asked of nobody (the scope says so)
19
+ * pageUrl () => the page's address, for the sign-in's way back
20
+ * onNavigate ({ proposal, source, view, change }) the open proposal or its view changed: what cornfield's own page puts in its address bar (the host decides what
21
+ * to do with it); `change`: 'opened' | 'view' | 'closed'. Said once, whoever changed it: a host's property, a button on the bar, a way on from a bad link
22
+ * onDecision ({ outcome, proposal, source, open, review }) the server took a review; once, after its answer, whichever `<corn-decision>` was pressed
23
+ * onAuth ({ status, signIn, during }) a read or a press was refused for want of a sign-in (`during`: 'proposal', 'facts', 'review', 'send', 'landing')
24
+ * onError ({ kind: 'proposal', message }) the proposal asked for did not open
25
+ *
26
+ * What it does for the pieces besides opening: it answers `proposal:specs-list` (there is no list of specs to open in another app's page), and it hears a click on an edge of the map (engine/proposal.js
27
+ * `bindEdgePicking`, on the map's canvas) so that a marked edge opens in the node panel whether or not a `<corn-proposal>` is there. It reads no address and
28
+ * writes none.
29
+ */
30
+
31
+ import { openProposal, showProposal, closeProposal, setProposalView, rebuildProposalMap, bindEdgePicking, setMessage } from '../engine/proposal.js';
32
+ import { scopeOf } from '../engine/piece.js';
33
+ import { signInUrl } from '../engine/source-address.js';
34
+ import { PROPOSAL_VIEWS, isProposalName, notANameWords } from '../proposal-model.js';
35
+
36
+ /**
37
+ * @param {ReturnType<typeof import('../instance.js').createInstance>} inst the scope's instance
38
+ * @param {object} [options] see the top of this file
39
+ */
40
+ export function holdProposal(inst, options = {}) {
41
+ const { state } = inst;
42
+ const scope = scopeOf(inst);
43
+ let ended = false;
44
+ /** What the host asked for; `shown` is the key of the proposal this has opened (or is opening), so a repeat of the same ask opens nothing again */
45
+ const current = { proposal: null, source: null, view: null, shown: null };
46
+ const hasMap = () => !!inst.map && state.nodes.length > 0;
47
+ const blocked = !!options.blocked;
48
+ /** No server to ask (no `src`): a name is never asked of the page's own origin in its place, as the review's is not */
49
+ const serverless = () => !inst.base;
50
+
51
+ /** Opens, shows or closes what the host asked for, once there is a map to lay it over */
52
+ function sync() {
53
+ if (ended) return undefined;
54
+ const wanted = current.proposal;
55
+ if (wanted === null || wanted === undefined || wanted === '') {
56
+ current.shown = null;
57
+ if (state.proposal && inst.map) closeProposal(inst);
58
+ return undefined;
59
+ }
60
+ if (!hasMap()) return undefined; // a proposal is laid over a map: it opens when there is one
61
+ const view = current.view;
62
+ if (typeof wanted === 'string' && blocked) return undefined; // there is no server to ask (the scope says why)
63
+ if (typeof wanted === 'string' && serverless()) {
64
+ const key = `${wanted}\u0000${current.source || ''}`;
65
+ if (current.shown === key) return undefined;
66
+ current.shown = key;
67
+ const message = isProposalName(wanted) ? `${wanted} cannot be opened here: there is no cornfield server to read it from (the scope has no src).` : notANameWords(wanted);
68
+ setMessage(inst, message, true, []);
69
+ inst.emit('proposal:failed', { slug: wanted, source: current.source, status: 0, notFound: false, message });
70
+ return undefined;
71
+ }
72
+ if (typeof wanted === 'string') {
73
+ // The proposal that is open already, asked for again by its name (a host that heard `cornNavigate` and set what it said): nothing opens again
74
+ if (state.proposal && state.proposalSlug === wanted && (!current.source || current.source === state.proposalSource)) {
75
+ current.shown = `${wanted}\u0000${current.source || ''}`;
76
+ if (PROPOSAL_VIEWS.includes(view) && state.proposalView !== view) setProposalView(inst, view, { quiet: true });
77
+ return undefined;
78
+ }
79
+ const key = `${wanted}\u0000${current.source || ''}`;
80
+ if (current.shown === key) return undefined; // asked already: open, opening, or said why not
81
+ current.shown = key;
82
+ return openProposal(inst, wanted, current.source).then((ok) => {
83
+ if (ok && !ended && current.shown === key && PROPOSAL_VIEWS.includes(view) && state.proposalView !== view) setProposalView(inst, view, { quiet: true });
84
+ return ok;
85
+ });
86
+ }
87
+ if (current.shown === wanted && state.proposal) return undefined;
88
+ current.shown = wanted;
89
+ const source = current.source || null;
90
+ showProposal(inst, wanted, { slug: null, source, pinSource: !!source, view: PROPOSAL_VIEWS.includes(view) ? view : 'diff', sha256: null });
91
+ return undefined;
92
+ }
93
+
94
+ // -- what the pieces need of whoever holds the proposal -------------------------------------------------------------------------------
95
+ // (`map:set`, laying the proposal's nodes out beside the map's, is the scope's map's own answer: pieces/map.js)
96
+ scope.on('proposal:specs-list', () => false);
97
+
98
+ // -- the map comes, changes its data, or is put back ------------------------------------------------------------------------------------
99
+ let stopEdges = () => {};
100
+ const bindEdges = () => {
101
+ stopEdges();
102
+ stopEdges = inst.map && state.canvas ? bindEdgePicking(inst, (target, type, fn) => scope.listen(target, type, fn)) : () => {};
103
+ };
104
+ scope.own(() => stopEdges());
105
+ scope.on('map:ready', () => { bindEdges(); sync(); });
106
+ scope.on('map:canvas', bindEdges);
107
+ scope.on('map:gone', () => { stopEdges(); stopEdges = () => {}; });
108
+ scope.on('map:topology', () => {
109
+ // A new base map: an open proposal is laid over it again, as the review does; a proposal still waiting for a map opens
110
+ if (state.proposal && inst.map) rebuildProposalMap(inst, undefined, { fit: true });
111
+ sync();
112
+ });
113
+
114
+ // -- what a host hears --------------------------------------------------------------------------------------------------------------------
115
+ scope.on('proposal', ({ change, slug, source, pinSource, view }) => {
116
+ // The reviewer's own act (the bar's Close or View, a way on from a bad link) is the host's property too: asked for again it opens nothing
117
+ if (change === 'closed') { current.proposal = null; current.shown = null; } else if (change === 'opened' && slug) {
118
+ current.proposal = slug;
119
+ if (pinSource) current.source = source;
120
+ current.shown = `${slug}\u0000${current.source || ''}`;
121
+ }
122
+ if (view) current.view = view;
123
+ if (options.onNavigate) options.onNavigate({ proposal: slug, source: pinSource ? source : null, view: change === 'closed' ? null : view, change });
124
+ });
125
+ const signInOf = () => (inst.base ? signInUrl(inst.base, typeof options.pageUrl === 'function' ? options.pageUrl() : '') : '');
126
+ /** The facts are read again every half minute: a sign-in that is still needed is said once, not every time (a press, or a decision taken, is said each time) */
127
+ let factsRefused = '';
128
+ scope.on('auth', ({ status, during }) => {
129
+ if (during === 'facts') { if (factsRefused === `${status}`) return; factsRefused = `${status}`; } else factsRefused = '';
130
+ if (options.onAuth) options.onAuth({ status, signIn: signInOf(), during });
131
+ });
132
+ scope.on('decision', ({ outcome, review, slug, source, open }) => {
133
+ factsRefused = '';
134
+ if (options.onDecision) options.onDecision({ outcome, proposal: slug, source, open, review });
135
+ });
136
+ scope.on('proposal:failed', ({ message }) => { if (options.onError) options.onError({ kind: 'proposal', message }); });
137
+
138
+ const held = {
139
+ /** Takes the keys that changed; returns a promise of whether the proposal opened, when a name was fetched */
140
+ update(next = {}) {
141
+ if (ended) return undefined;
142
+ let asked = false;
143
+ if ('source' in next && (next.source || null) !== current.source) { current.source = next.source || null; asked = true; }
144
+ if ('proposal' in next && (next.proposal ?? null) !== current.proposal) { current.proposal = next.proposal ?? null; current.shown = null; asked = true; }
145
+ if ('view' in next && PROPOSAL_VIEWS.includes(next.view) && next.view !== current.view) {
146
+ current.view = next.view;
147
+ if (state.proposal && !asked) setProposalView(inst, next.view, { quiet: true }); // a reviewer's own choice is the same value: nothing changes
148
+ }
149
+ return asked ? sync() : undefined;
150
+ },
151
+ sync,
152
+ destroy() { if (ended) return; ended = true; scope.destroy(); },
153
+ };
154
+ held.update({ proposal: options.proposal, source: options.source, view: options.view });
155
+ bindEdges();
156
+ sync();
157
+ return held;
158
+ }
@@ -25,6 +25,12 @@
25
25
  * A second map in a scope is refused (the engine holds one map per instance); when the map that has the scope leaves, the first refused map that
26
26
  * is still in the page is told to ask again, and takes it.
27
27
  *
28
+ * THE PROPOSAL. A scope with a `proposal` (a name, or the object) holds it for every piece in it, with `source` and `view` (pieces/scope-proposal.js, a chunk of its own,
29
+ * loaded the first time a scope has one): the map narrows to it, `<corn-proposal>`, `<corn-changes>` and `<corn-decision>` show and decide it. What the reviewer
30
+ * does (the bar's Close and Before, Diff or After, a way on from a bad link) is the instance's, and it is told to the host once as `onNavigate`; a decision as
31
+ * `onDecision`; a refused read or press as `onAuth` with `during`. The scope, not one of the sections, says them: the proposal is the scope's, whatever number of
32
+ * sections (none, or two) are in it, and it is the one place `cornAuth` and `cornError` already come from.
33
+ *
28
34
  * It reads no `location`: the page's address is a function the shell passes in (`pageUrl`), used for the sign-in's way back and to name the
29
35
  * origin a "not listed" message asks the server to list. It never navigates the window.
30
36
  */
@@ -32,6 +38,7 @@
32
38
  import { createInstance } from '../instance.js';
33
39
  import { adoptDefaultTokens } from './adopt-tokens.js';
34
40
  import { parseSource } from '../engine/source.js';
41
+ import { signInUrl } from '../engine/source-address.js';
35
42
  import { connectServer } from '../engine/server-load.js';
36
43
  import { keepLayersIn } from '../engine/layers.js';
37
44
  import { mount as mountStatus } from './status.js';
@@ -55,9 +62,15 @@ const THEMES = ['light', 'dark', 'auto'];
55
62
  * @param {(detail: { status: number, signIn: string }) => void} [options.onAuth] the server wants a sign-in
56
63
  * @param {(detail: { kind: 'not-listed' | 'offline' | 'server' | 'address' | 'version' | 'theme' | 'second-map', message?: string }) => void} [options.onError]
57
64
  * @param {() => void} [options.onReady] the scope has its data (loaded, or handed in)
65
+ * @param {string | object | null} [options.proposal] @param {string | null} [options.source] @param {'before'|'diff'|'after'|null} [options.view] the proposal the scope holds
66
+ * @param {(detail: { proposal: string | null, source: string | null, view: 'before' | 'diff' | 'after' | null, change: 'opened' | 'view' | 'closed' }) => void} [options.onNavigate] the open proposal or its view changed
67
+ * @param {(detail: { outcome: 'approved' | 'notes', proposal: string | null, source: string | null, open: boolean, review: any }) => void} [options.onDecision] the server took a review
58
68
  */
59
69
  export function mountScope(host, options = {}) {
60
- const props = { src: options.src, theme: options.theme, useTheme: !!options.useTheme, topology: options.topology, config: options.config, strings: options.strings };
70
+ const props = {
71
+ src: options.src, theme: options.theme, useTheme: !!options.useTheme, topology: options.topology, config: options.config, strings: options.strings,
72
+ proposal: options.proposal ?? null, source: options.source ?? null, view: options.view ?? null,
73
+ };
61
74
  const pageUrl = options.pageUrl || (() => '');
62
75
  /** The pieces that took this scope's answer, by their element: what is told when the instance changes */
63
76
  const handles = new Set();
@@ -68,6 +81,9 @@ export function mountScope(host, options = {}) {
68
81
  let serverLink = null;
69
82
  let readyFired = false;
70
83
  let ended = false;
84
+ /** The proposal the instance holds (pieces/scope-proposal.js), once there is one to hold; null before that, and for an instance that has none */
85
+ let held = null;
86
+ let holdLoading = false;
71
87
 
72
88
  // -- the answer to a piece ---------------------------------------------------------------------------------------------------------------
73
89
  const answer = (event) => {
@@ -123,6 +139,7 @@ export function mountScope(host, options = {}) {
123
139
  source = link.source;
124
140
  info.source = source;
125
141
  info.mountStatus = mountStatus;
142
+ info.signIn = () => (mine.base ? signInUrl(mine.base, pageUrl()) : ''); // the server's sign-in, back to this page: a section that is refused shows the card with it
126
143
  readyFired = false;
127
144
  // A second map waits: when the one that has the instance's root gives it back, the first that waits and is still in the page asks again
128
145
  // (after the leaving map has finished ending, so the two never hold the instance's state at once)
@@ -143,6 +160,48 @@ export function mountScope(host, options = {}) {
143
160
  if (parsed && !parsed.ok) source.say({ state: 'address', problem: parsed.problem });
144
161
  source.provide({ topology: props.topology || undefined, config: props.config || undefined, strings: props.strings || undefined });
145
162
  if (parsed && parsed.ok) source.load();
163
+ held = null;
164
+ holdLoading = false;
165
+ holdProposal();
166
+ }
167
+
168
+ /**
169
+ * The proposal's keys a host changed, handed over together once its script has run: a host sets `source` and then `proposal` (or `proposal` and then `view`)
170
+ * one after the other, and each alone would open the wrong thing first (the old proposal under the new source: a read of a copy that does not exist, a
171
+ * `cornError` for it, and a line in the bar)
172
+ */
173
+ let asking = null;
174
+ function askHeld(asked) {
175
+ if (asking) { Object.assign(asking, asked); return; }
176
+ asking = { ...asked };
177
+ queueMicrotask(() => {
178
+ const keys = asking;
179
+ asking = null;
180
+ if (ended) return;
181
+ if (held) held.update(keys); else holdProposal();
182
+ });
183
+ }
184
+
185
+ /** Makes the instance hold the proposal when the scope has one (the first time: the chunk is loaded); a scope with none loads nothing */
186
+ function holdProposal() {
187
+ if (ended || held || holdLoading || props.proposal === null || props.proposal === undefined || props.proposal === '') return;
188
+ holdLoading = true;
189
+ const mine = inst;
190
+ const blocked = props.src !== undefined && props.src !== null && props.src !== '' && !parseSource(props.src).ok;
191
+ import('./scope-proposal.js').then(({ holdProposal: hold }) => {
192
+ holdLoading = false;
193
+ if (ended || inst !== mine || held) return;
194
+ held = hold(mine, {
195
+ proposal: props.proposal, source: props.source, view: props.view, blocked, pageUrl,
196
+ onNavigate: (detail) => { if (options.onNavigate) options.onNavigate(detail); },
197
+ onDecision: (detail) => { if (options.onDecision) options.onDecision(detail); },
198
+ onAuth: (detail) => { if (options.onAuth) options.onAuth(detail); },
199
+ onError: (detail) => { if (options.onError) options.onError(detail); },
200
+ });
201
+ }, (err) => {
202
+ holdLoading = false;
203
+ if (!ended && options.onError) options.onError({ kind: 'offline', message: `the scope's proposal loader did not load: ${err && err.message ? err.message : err}` });
204
+ });
146
205
  }
147
206
 
148
207
  function release() {
@@ -181,6 +240,10 @@ export function mountScope(host, options = {}) {
181
240
  const hand = {};
182
241
  for (const key of ['topology', 'config', 'strings']) if (key in next && next[key] !== props[key]) { props[key] = next[key]; hand[key] = next[key] === undefined ? null : next[key]; }
183
242
  if (Object.keys(hand).length) source.provide(hand);
243
+ // The proposal: the keys that changed go to what holds it (loaded now, if this is the scope's first)
244
+ const asked = {};
245
+ for (const key of ['proposal', 'source', 'view']) if (key in next && (next[key] ?? null) !== props[key]) { props[key] = next[key] ?? null; asked[key] = props[key]; }
246
+ if (Object.keys(asked).length) askHeld(asked);
184
247
  },
185
248
  destroy() {
186
249
  if (ended) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@popcorn245/cornfield",
3
- "version": "0.52.1",
3
+ "version": "0.53.0",
4
4
  "description": "A self-hostable dev dashboard with the topology map at its centre: proposals on the map, scenarios, outages and what-if edits, for any repo.",
5
5
  "license": "MIT",
6
6
  "author": "popcorn245 (https://github.com/popcorn245)",