cornfield 0.46.1 → 0.47.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/explorer/capped.js +3 -2
  2. package/explorer/engine/feedback.js +49 -0
  3. package/explorer/engine/flow-ui.js +39 -0
  4. package/explorer/engine/fly.js +54 -0
  5. package/explorer/engine/hint.js +98 -0
  6. package/explorer/engine/keyboard.js +156 -0
  7. package/explorer/engine/layers.js +280 -0
  8. package/explorer/engine/layout.js +378 -0
  9. package/explorer/engine/map-style.js +552 -0
  10. package/explorer/engine/piece.js +142 -0
  11. package/explorer/engine/render.js +331 -0
  12. package/explorer/engine/search-status.js +59 -0
  13. package/explorer/engine/selection.js +42 -0
  14. package/explorer/engine/sheets.js +417 -0
  15. package/explorer/engine/strings.js +63 -0
  16. package/explorer/feedback.js +11 -45
  17. package/explorer/flow-build.js +88 -0
  18. package/explorer/flow-style.js +28 -0
  19. package/explorer/flows.js +11 -132
  20. package/explorer/fly.js +11 -43
  21. package/explorer/hint.js +15 -88
  22. package/explorer/index.html +40 -82
  23. package/explorer/input.js +197 -177
  24. package/explorer/instance-state.js +172 -0
  25. package/explorer/instance.js +267 -0
  26. package/explorer/keyboard.js +14 -206
  27. package/explorer/labels.js +3 -3
  28. package/explorer/layers.js +34 -445
  29. package/explorer/layout.js +14 -372
  30. package/explorer/main.js +4 -226
  31. package/explorer/map-style.js +27 -525
  32. package/explorer/mockups-model.js +3 -3
  33. package/explorer/page-pieces.js +66 -0
  34. package/explorer/page.js +223 -0
  35. package/explorer/panels.js +29 -409
  36. package/explorer/pieces/adopt-tokens.js +38 -0
  37. package/explorer/pieces/layers.js +325 -0
  38. package/explorer/pieces/map-stage.css +14 -0
  39. package/explorer/pieces/map.js +332 -0
  40. package/explorer/pieces/node-panel.js +536 -0
  41. package/explorer/pieces/search.js +454 -0
  42. package/explorer/proposal-model.js +1 -1
  43. package/explorer/proposal.js +1 -0
  44. package/explorer/render.js +37 -267
  45. package/explorer/renderer-canvas2d.js +4 -4
  46. package/explorer/renderer-webgl.js +21 -8
  47. package/explorer/renderer.js +12 -9
  48. package/explorer/scene.js +3 -2
  49. package/explorer/search-status.js +8 -47
  50. package/explorer/search.js +26 -324
  51. package/explorer/selection-view.js +17 -19
  52. package/explorer/sheets.js +31 -379
  53. package/explorer/state.js +38 -173
  54. package/explorer/strings.js +17 -60
  55. package/explorer/view.js +4 -5
  56. package/package.json +1 -1
@@ -1,68 +1,25 @@
1
1
  /**
2
2
  * @module explorer/strings
3
3
  *
4
- * The words a repo may say in its own voice (core/strings.js is the table; `strings` in cornfield.config.js the overrides, which
5
- * `/cornfield/config.json` carries). Every overridable label is read through `t(key)`; the static markup in index.html marks what
6
- * to replace with `data-corn-string` attributes, which `applyStrings` fills once the config is in.
7
- *
8
- * data-corn-string="key" the element's text
9
- * data-corn-string-aria-label="key" its aria-label
10
- * data-corn-string-placeholder="key" its placeholder
11
- *
12
- * The rule for accessible names: a control's name is its visible label. When a key is overridden the visible text and the
13
- * aria-label carry the same words, and where a name adds a fixed target ("Stop run 7") only the label part is replaced
14
- * ("Halt run 7"). So a screen reader says what is on the screen.
15
- *
16
- * Values are only ever set through textContent and attributes, never as HTML, and a value that fails core/strings.js
17
- * `stringProblem` (not text, a line break, too long) is ignored here as well, whatever the server sent.
4
+ * A bridge (spec 0011 D2, step 4): the words now live on the instance (`inst.strings`, read with `t(inst, key)` from engine/strings.js).
5
+ * This file keeps the old names for the modules that are not yet on an instance, bound to the page's voice: `pageStrings`, the object the page
6
+ * instance's `strings` is (state.js hands it over), so the two are one. It imports nothing of the page's state, because pure models read the words
7
+ * through it (waiting-model.js) and the converted modules import those. It goes when the last caller (forge-panel.js, proposal.js, review.js,
8
+ * review-column.js, whatif.js, scenario-ui.js, runs-view.js, waiting-*.js, plugins.js) is converted.
18
9
  */
10
+ import * as S from './engine/strings.js';
19
11
 
20
- import { STRINGS, isStringKey, stringProblem } from '../core/strings.js';
21
-
22
- /** The overrides in force: key -> text */
23
- let overrides = {};
24
-
25
- /**
26
- * Takes the overrides the config carries (`config.strings`). Anything that is not a known key with good text is left out.
27
- * @param {unknown} strings
28
- */
29
- export function setStrings(strings) {
30
- overrides = {};
31
- if (!strings || typeof strings !== 'object' || Array.isArray(strings)) return;
32
- for (const [key, value] of Object.entries(strings)) if (isStringKey(key) && !stringProblem(value)) overrides[key] = value;
33
- }
12
+ /** The overrides in force on cornfield's page: key -> text */
13
+ export const pageStrings = {};
14
+ const voice = { strings: pageStrings, root: null };
34
15
 
16
+ /** Takes the overrides the config carries (`config.strings`) */
17
+ export const setStrings = (strings) => S.setStrings(voice, strings);
35
18
  /** Whether the config overrides this key */
36
- export const isOverridden = (key) => Object.hasOwn(overrides, key);
37
-
38
- /** The words for a key: the override, else the default. A key that is not in the table gives the key itself (a test keeps the code to the table). */
39
- export function t(key) {
40
- if (Object.hasOwn(overrides, key)) return overrides[key];
41
- return isStringKey(key) ? STRINGS[key] : String(key);
42
- }
43
-
44
- const TARGETS = [
45
- ['data-corn-string', (el, text) => { el.textContent = text; }],
46
- ['data-corn-string-aria-label', (el, text) => el.setAttribute('aria-label', text)],
47
- ['data-corn-string-placeholder', (el, text) => el.setAttribute('placeholder', text)],
48
- ];
49
-
50
- /**
51
- * Puts the overrides in the static markup. Only an overridden key touches its element, so what index.html says is what shows
52
- * without one.
53
- * @param {ParentNode} root
54
- */
55
- export function applyStrings(root) {
56
- if (!root || typeof root.querySelectorAll !== 'function') return;
57
- for (const [attr, set] of TARGETS) {
58
- for (const el of root.querySelectorAll(`[${attr}]`)) {
59
- const key = el.getAttribute(attr);
60
- if (isOverridden(key)) set(el, overrides[key]);
61
- }
62
- }
63
- }
64
-
19
+ export const isOverridden = (key) => S.isOverridden(voice, key);
20
+ /** The words for a key: the override, else the default */
21
+ export const t = (key) => S.t(voice, key);
22
+ /** Puts the overrides in the static markup under `root` */
23
+ export const applyStrings = (root) => S.applyStrings(voice, root);
65
24
  /** For tests: forget the overrides */
66
- export function resetStringsForTests() {
67
- overrides = {};
68
- }
25
+ export const resetStringsForTests = () => S.setStrings(voice, {});
package/explorer/view.js CHANGED
@@ -5,7 +5,7 @@
5
5
  * preset. A failed load is an error state on the page, with a retry, never a blank canvas.
6
6
  */
7
7
 
8
- import { state, touchScene } from './state.js';
8
+ import { state, touchScene, pageInstance } from './state.js';
9
9
  import { computeDegreeCentrality, layoutOrbit, computeLaneLayout } from './layout.js';
10
10
  import { buildDataFlow } from './flows.js';
11
11
  import { render, fitGraphToViewport, fitPadding, ensureFlowLoop } from './render.js';
@@ -16,6 +16,7 @@ import { measureParams } from './bench.js';
16
16
  import { mergeLive, placeLiveNodes } from './live-model.js';
17
17
  import { applyHouseLayout } from './house-model.js';
18
18
  import { syncHint } from './hint.js';
19
+ import { ensurePagePieces } from './page-pieces.js';
19
20
 
20
21
  const $ = (id) => document.getElementById(id);
21
22
 
@@ -162,9 +163,7 @@ export function syncViewUi() {
162
163
  if (map) map.setAttribute('aria-pressed', String(state.view !== 'dataflow' && state.view !== 'house'));
163
164
  const btn = $('preset-dataflow-btn');
164
165
  if (btn) btn.setAttribute('aria-pressed', String(preset));
165
- const layersBtn = $('legend-toggle-btn');
166
- if (layersBtn) layersBtn.classList.toggle('hx-layers-chip--dim', preset);
167
- const note = $('layers-preset-note');
168
- if (note) note.hidden = !preset;
166
+ ensurePagePieces(); // the Layers menu, if the page has its place
167
+ pageInstance().emit('view', state.view); // the Layers chip dims while the data-flow view is on (pieces/layers.js)
169
168
  syncHint(); // the hint's words for this view and pointer, and whether it shows (hint.js)
170
169
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cornfield",
3
- "version": "0.46.1",
3
+ "version": "0.47.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)",