@popcorn245/cornfield 0.39.0 → 0.40.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.
@@ -32,6 +32,7 @@ import { checksVersion, closeChecks, decorateSnapshot, openChecks, paintChecks }
32
32
  import { blastRadius, outageLayers, outageScenario } from './outage-model.js';
33
33
  import { toggleLayer, LAYER_DEFS } from './layers.js';
34
34
  import { externalLayer } from './cloud-model.js';
35
+ import { projectLayerKey, shownByProposal } from './layer-model.js';
35
36
  import { announce } from './keyboard.js';
36
37
  import { t } from './strings.js';
37
38
  import { currentStepSentence } from './scenario-list-model.js';
@@ -145,7 +146,9 @@ export function layersHiding(node) {
145
146
  if (!node || state.view === 'dataflow' || state.view === 'house') return [];
146
147
  const on = (key) => state.activeLayers[key] !== false;
147
148
  const t = node.type;
148
- if (t === 'root') return [];
149
+ if (t === 'root' || shownByProposal(state, node)) return []; // a proposal's own nodes are drawn whatever their layer says (spec 0009 D3)
150
+ const project = projectLayerKey(state, node); // a project layer that takes the node decides alone (spec 0009 D3), as scene.js layerShows has it
151
+ if (project) return on(project) ? [] : [project];
149
152
  if (t === 'core') return [...(on('core') ? [] : ['core']), ...(state.activeLayers.pkg || state.activeLayers.atom ? [] : ['pkg'])];
150
153
  if (t === 'store') return ['flow', 'store'].filter((k) => !on(k));
151
154
  if (t === 'rom') return ['rom', 'flow'].filter((k) => !on(k));
@@ -167,7 +170,7 @@ function showStepLayers(scenario) {
167
170
  for (const id of stepNodeIds(scenario)) for (const key of layersHiding(byId.get(id))) if (!keys.includes(key)) keys.push(key);
168
171
  if (!keys.length) return;
169
172
  for (const key of keys) { if (key === 'pkg') state.activeLayers.pkg = false; toggleLayer(key); }
170
- const names = keys.map((key) => (LAYER_DEFS.find((l) => l.key === key) || { label: key }).label);
173
+ const names = keys.map((key) => (LAYER_DEFS.find((l) => l.key === key) || (state.projectLayers || []).find((l) => l.key === key) || { label: key }).label);
171
174
  announce(`Turned on ${names.length > 1 ? `${names.slice(0, -1).join(', ')} and ${names[names.length - 1]}` : names[0]} to show this scenario's steps.`);
172
175
  }
173
176
 
package/explorer/scene.js CHANGED
@@ -163,6 +163,7 @@ import { beforeOf, markIn, showsEdge, showsNode, touchedIds } from './proposal-m
163
163
  import { decorateHouseScene, houseEdgeStyle, houseShowsNode, houseViewEdges } from './house-model.js';
164
164
  import { paintVerdict } from './check-model.js';
165
165
  import { externalLayer, whenDash } from './cloud-model.js';
166
+ import { lettersOf, projectLayerKey, shownByProposal } from './layer-model.js';
166
167
  import { outageFor, paintOutage } from './outage-model.js';
167
168
  import { paintForge } from './forge-panel-model.js';
168
169
  import { lightColor, lightenScene, parseColor } from './theme-model.js';
@@ -238,11 +239,18 @@ export const PROPOSAL_DIM_ALPHA = 0.28;
238
239
  // Visibility and focus (moved unchanged from render.js)
239
240
  // ---------------------------------------------------------------------------
240
241
  export function isNodeVisible(state, node) {
241
- const { activeLayers } = state;
242
242
  if (state.proposal && !showsNode(state.proposalView || 'diff', node)) return false; // Before hides what is added, After what is removed
243
243
  if (state.view === 'dataflow') return !!state.flow && state.flow.ids.has(node.id);
244
244
  if (state.view === 'house') return houseShowsNode(state, node); // the House view (spec 0029, PHY-11) draws its own set: house-model.js
245
245
  if (node.type === 'root') return true;
246
+ return layerShows(state, node) || shownByProposal(state, node); // a proposal's own nodes are drawn whatever their layer says (spec 0009 D3)
247
+ }
248
+
249
+ /** Whether the Layers menu has the node's layer on: a project layer that takes it decides alone, else its starting layer, with the rules each type has */
250
+ export function layerShows(state, node) {
251
+ const { activeLayers } = state;
252
+ const project = projectLayerKey(state, node);
253
+ if (project) return activeLayers[project] !== false;
246
254
  if (node.type === 'core') return (activeLayers.pkg || activeLayers.atom) && activeLayers.core !== false; // its own row in Layers, and Packages or Atoms
247
255
  if (node.type === 'store') return activeLayers.flow !== false && activeLayers.store !== false; // its own row, and Data Flow
248
256
  if (node.type === 'rom') return activeLayers.rom !== false && activeLayers.flow !== false;
@@ -567,9 +575,15 @@ function buildNodes(state, subgraph) {
567
575
  if (focus && !focus.touched.has(node.id)) alpha = Math.min(alpha, PROPOSAL_DIM_ALPHA);
568
576
  if (look) alpha *= gone ? MARK.removed.alpha : look.alpha;
569
577
  const big = shown.type === 'root' || shown.type === 'app';
578
+ // A finer kind (spec 0009): its letters, drawn in the node's core by the renderers (kind-letters.js), and the project layer that takes the node
579
+ const letters = lettersOf(state, shown);
580
+ const layer = projectLayerKey(state, shown);
570
581
 
571
582
  out.push({
572
583
  id: node.id, type: shown.type, group: groupOf(shown),
584
+ ...(typeof shown.kind === 'string' && shown.kind ? { kind: shown.kind } : {}),
585
+ ...(letters ? { letters } : {}),
586
+ ...(layer ? { layer } : {}),
573
587
  x: node.x, y: node.y, r: shown.r, color: shown.color,
574
588
  alpha,
575
589
  glow: connected && alpha >= 0.5 ? (big ? 15 : 9) : 0,
@@ -545,7 +545,7 @@ flat out float v_alpha;
545
545
  void main() {
546
546
  vec2 centre = u_cam.xy + a_geom.xy * u_cam.z;
547
547
  vec2 pos = centre + a_corner * (a_geom.z * 0.5 * u_cam.z);
548
- v_uv = vec2(a_corner.x * 0.5 + 0.5, 0.5 - a_corner.y * 0.5);
548
+ v_uv = vec2(a_corner.x * 0.5 + 0.5, a_corner.y * 0.5 + 0.5); // screen y runs down and an image's first row is its top, so the corner below the centre reads the last row
549
549
  v_alpha = a_geom.w;
550
550
  gl_Position = toClip(pos);
551
551
  }
package/explorer/state.js CHANGED
@@ -54,6 +54,15 @@ export const state = {
54
54
  machine: false, container: false, device: false, house: false, persona: false,
55
55
  },
56
56
 
57
+ /**
58
+ * The project's own layers (spec 0009): `{ key, label, desc?, match }` in `add` order, as the config sent them (core/layers.js); a node is
59
+ * in the first one whose match it meets (explorer/layer-model.js). `layerOrder` is the config's `order`; `layerDefaults` what each layer is
60
+ * when the viewer has not touched it (layers.js `setProjectLayers`). Empty with no `layers` in the config: the menu is then the starting set.
61
+ */
62
+ projectLayers: [],
63
+ layerOrder: [],
64
+ layerDefaults: {},
65
+
57
66
  /**
58
67
  * The map as the last `setMap` (view.js) was handed it, before the live layer is laid in: the base
59
68
  * copies, or a proposal applied over them. `nodes` and `edges` are these plus the live ones.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@popcorn245/cornfield",
3
- "version": "0.39.0",
3
+ "version": "0.40.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)",
package/server/server.js CHANGED
@@ -57,6 +57,7 @@ import { browserSources, BUILTIN_SOURCES, parseDuration, specPollMs, triggersOf,
57
57
  import { CLOUD_FILE } from '../core/cloud.js';
58
58
  import { BRAND_SVG_CSP, MANIFEST_PATH, appNameOf, brandAssetFile, brandImages, clientBrand, manifestOf } from '../core/brand.js';
59
59
  import { clientStrings } from '../core/strings.js';
60
+ import { clientLayers } from '../core/layers.js';
60
61
  import { MAX_THEME_ASSET_BYTES, MAX_THEME_BYTES, THEME_ASSET_PREFIX, THEME_NAME, THEME_SVG_CSP, clientTheme, cssProblems, cssUrls, fontOrigins, themeAssetFile, themeAssetPath, themeUrlTarget } from '../core/theme.js';
61
62
  import { decodePath, inside, notFound, sendFile } from './files.js';
62
63
  import { serveProposals } from './proposals.js';
@@ -81,7 +82,7 @@ import { compressResponse } from './compress.js';
81
82
  export const CORNFIELD_DIR = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
82
83
  const EXPLORER_DIR = path.join(CORNFIELD_DIR, 'explorer');
83
84
  /** The pure core modules the explorer imports (no Node built-ins, no files): the only ones of core/ served */
84
- export const BROWSER_CORE = ['schema.js', 'proposal.js', 'personas.js', 'cloud.js', 'text.js', 'mentions.js', 'color.js', 'strings.js'];
85
+ export const BROWSER_CORE = ['schema.js', 'proposal.js', 'personas.js', 'cloud.js', 'text.js', 'mentions.js', 'color.js', 'strings.js', 'layers.js'];
85
86
  /** The explorer files the sign-in pages load: cornfield's tokens, their own stylesheet and the script that applies Light or Dark. Served without a session. */
86
87
  const SIGN_IN_FILES = new Set(['/explorer/tokens.css', '/explorer/sign-in.css', '/explorer/theme-boot.js']);
87
88
  /** cornfield's own browser sources, by request path */
@@ -252,6 +253,8 @@ export function clientConfig(config, signIn = false) {
252
253
  brand: clientBrand(config.brand, PKG.homepage),
253
254
  // Only the labels the config overrides, as text (core/strings.js); the defaults are in the browser
254
255
  strings: clientStrings(config.strings),
256
+ // The project's own layers, as plain data of the known keys (core/layers.js; docs/config.md#layers)
257
+ layers: clientLayers(config.layers),
255
258
  forge: config.forge ? { type: config.forge.type, url: config.forge.url || (config.forge.type === 'github' ? 'https://github.com' : null), repo: config.forge.repo, mergeMethod: config.forge.mergeMethod || 'merge', ...(config.forge.baseBranch ? { baseBranch: config.forge.baseBranch } : {}), ...(config.approveLands ? { approveLands: true } : {}) } : null,
256
259
  // Threads (docs/threads.md): the idea label, or false when `threads: false` turns the Threads tab off
257
260
  threads: config.threads === false ? false : { label: ideaLabel(config) },