structured-context-map-views 0.3.1 → 0.4.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.
@@ -1,232 +1,11 @@
1
+ import { i as treeLinks, n as buildLandscape, o as filterAnnotations, r as buildTree, s as worstSeverity, t as buildXYPlot } from "./projection-GaO0MCbR.js";
1
2
  import { a as resolveRegions, i as resolveParameterValues } from "./definition-Cft28YUA.js";
2
3
  import { createContext, useCallback, useContext, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
3
4
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
- //#region src/core/annotations.ts
5
- /**
6
- * Attach validation results to the nodes of `graph`, by node id. Results that can't be attached are
7
- * returned in `unattached` for the host to surface: global-scope rules (no node), and nodes that
8
- * aren't in the graph, which includes every node that failed its schema.
9
- */
10
- function annotationsFrom(input, graph) {
11
- const annotations = /* @__PURE__ */ new Map();
12
- const unattached = [];
13
- const add = (nodeId, annotation, location) => {
14
- if (nodeId !== void 0 && graph.nodes.has(nodeId)) annotations.set(nodeId, [...annotations.get(nodeId) ?? [], annotation]);
15
- else unattached.push({
16
- ...annotation,
17
- nodeId,
18
- ...location && { location }
19
- });
20
- };
21
- for (const { nodeId, source, issues } of input.nodeErrors ?? []) for (const issue of issues) add(nodeId, {
22
- severity: "error",
23
- source: "schema",
24
- message: issue.message
25
- }, source);
26
- for (const { nodeId, description } of input.hierarchyViolations ?? []) add(nodeId, {
27
- severity: "error",
28
- source: "hierarchy",
29
- message: description
30
- });
31
- for (const { nodeId, description, severity, ruleId } of input.ruleViolations ?? []) add(nodeId, {
32
- severity,
33
- source: "rule",
34
- message: description,
35
- ruleId
36
- });
37
- return {
38
- annotations,
39
- unattached
40
- };
41
- }
42
- var RANK = {
43
- error: 0,
44
- warning: 1,
45
- info: 2
46
- };
47
- /** The most serious severity among annotations, or undefined if there are none. */
48
- function worstSeverity(annotations) {
49
- return annotations.reduce((worst, { severity }) => worst === void 0 || RANK[severity] < RANK[worst] ? severity : worst, void 0);
50
- }
51
- /**
52
- * The annotations a map view shows: those at `level` or more serious, from `sources`. `off` shows none.
53
- * Nodes left with no annotations are dropped from the index.
54
- */
55
- function filterAnnotations(index, level, sources) {
56
- if (level === "off") return /* @__PURE__ */ new Map();
57
- const filtered = /* @__PURE__ */ new Map();
58
- for (const [id, annotations] of index) {
59
- const kept = annotations.filter((a) => RANK[a.severity] <= RANK[level] && sources.includes(a.source));
60
- if (kept.length > 0) filtered.set(id, kept);
61
- }
62
- return filtered;
63
- }
64
5
  /** The annotations a map view shows, already narrowed by its validation settings. Read by node cards. */
65
6
  var AnnotationsContext = createContext(/* @__PURE__ */ new Map());
66
7
  var useAnnotations = () => useContext(AnnotationsContext);
67
8
  //#endregion
68
- //#region src/core/graph.ts
69
- var NONE = [];
70
- /**
71
- * Edges to a node's parents, in the order the node declares them. A graph narrowed by a filter keeps
72
- * edges to parents outside it; those are left out.
73
- */
74
- function parentEdges(graph, id) {
75
- return (graph.parentEdges.get(id) ?? NONE).filter((edge) => graph.nodes.has(edge.parent));
76
- }
77
- /** Edges to a node's children, in graph order of the children. */
78
- function childEdges(graph, id) {
79
- return graph.childEdges.get(id) ?? NONE;
80
- }
81
- /** Every edge whose parent and child are both in the graph. */
82
- function edgesWithin(graph) {
83
- return [...graph.nodes.keys()].flatMap((id) => parentEdges(graph, id));
84
- }
85
- /** Whether an edge belongs to the given hierarchy (as opposed to a relationship or another hierarchy). */
86
- function isHierarchyEdge(edge, hierarchy) {
87
- return hierarchy !== void 0 && edge.kind === "hierarchy" && edge.hierarchy === hierarchy.name;
88
- }
89
- //#endregion
90
- //#region src/core/occurrence.ts
91
- /**
92
- * Path-based key for one occurrence of a node: region, then the steps from the outermost
93
- * container down to the node. Unique within a map view even when a node appears several times.
94
- * Hosts can render several map views at once, so layouts scope keys to the map view instance.
95
- */
96
- function occurrenceKey(regionId, path) {
97
- return JSON.stringify([regionId, ...path]);
98
- }
99
- //#endregion
100
- //#region src/core/landscape.ts
101
- /**
102
- * Lay a space out as nested containers following the layout's grouping levels.
103
- *
104
- * Adjacent node levels are joined by any edge between their types, in either direction, or only
105
- * edges from `edge.field`. A `via` chain joins them through the skipped types. A field level
106
- * splits the next node level by that field's values. A node reached from several containers
107
- * appears in each, in full: the levels are finite, so repeating contents can't recurse.
108
- */
109
- function buildLandscape(graph, regionId, layout) {
110
- const levels = layout.group;
111
- const order = new Map([...graph.nodes.keys()].map((title, i) => [title, i]));
112
- const first = /* @__PURE__ */ new Map();
113
- const occurrenceFor = (candidate, levelIdx, path) => {
114
- const { node } = candidate;
115
- const nodePath = [...path, node.id];
116
- const key = occurrenceKey(regionId, nodePath);
117
- const repeatOf = first.get(node.id);
118
- if (repeatOf === void 0) first.set(node.id, key);
119
- return {
120
- key,
121
- level: levelIdx,
122
- item: {
123
- kind: "node",
124
- node
125
- },
126
- via: candidate.via,
127
- ...repeatOf !== void 0 && { repeatOf },
128
- children: place(levelIdx + 1, node, [], nodePath)
129
- };
130
- };
131
- /** Occurrences for level `levelIdx` inside `anchor`, the nearest enclosing node. */
132
- const place = (levelIdx, anchor, filters, path) => {
133
- const level = levels[levelIdx];
134
- if (level === void 0) return [];
135
- if (isTypeLevel(level)) return candidates(level, anchor, filters).map((c) => occurrenceFor(c, levelIdx, path));
136
- const nodeLevel = levels.slice(levelIdx).find(isTypeLevel);
137
- return distinctValues(candidates(nodeLevel, anchor, filters).map((c) => c.node), level.field).map((value) => {
138
- const valuePath = [...path, [level.field, value]];
139
- return {
140
- key: occurrenceKey(regionId, valuePath),
141
- level: levelIdx,
142
- item: {
143
- kind: "value",
144
- field: level.field,
145
- value
146
- },
147
- via: [],
148
- children: place(levelIdx + 1, anchor, [...filters, {
149
- field: level.field,
150
- value
151
- }], valuePath)
152
- };
153
- });
154
- };
155
- /** Nodes of a type level joined to `anchor` (all of the type at the top) and matching the filters. */
156
- const candidates = (level, anchor, filters) => {
157
- return (anchor === void 0 ? ofType(level.type).map((node) => ({
158
- node,
159
- via: []
160
- })) : walkChain(anchor, level.via ?? [], level.type, level.edge?.field)).filter(({ node }) => filters.every((f) => hasValue(node, f)));
161
- };
162
- const ofType = (type) => [...graph.nodes.values()].filter((node) => node.resolvedType === type);
163
- /** Neighbours of a node with the given type, across edges in either direction, in space order. */
164
- const neighbours = (title, type, field) => {
165
- return [.../* @__PURE__ */ new Set([...childEdges(graph, title).filter((e) => field === void 0 || e.field === field).map((e) => e.child), ...parentEdges(graph, title).filter((e) => field === void 0 || e.field === field).map((e) => e.parent)])].map((t) => graph.nodes.get(t)).filter((node) => node.resolvedType === type).sort((a, b) => order.get(a.id) - order.get(b.id));
166
- };
167
- /**
168
- * Follow edges from `anchor` through each `via` type to `target`, keeping the skipped nodes on
169
- * the way to each target node. Several chains to one target merge into one candidate.
170
- */
171
- const walkChain = (anchor, via, target, field) => {
172
- let frontier = [{
173
- node: anchor,
174
- trail: []
175
- }];
176
- for (const type of via) frontier = frontier.flatMap(({ node, trail }) => neighbours(node.id, type, void 0).map((next) => ({
177
- node: next,
178
- trail: [...trail, next]
179
- })));
180
- const byTitle = /* @__PURE__ */ new Map();
181
- for (const { node, trail } of frontier) for (const next of neighbours(node.id, target, field)) {
182
- const candidate = byTitle.get(next.id) ?? {
183
- node: next,
184
- via: via.map((type) => ({
185
- type,
186
- nodes: []
187
- }))
188
- };
189
- trail.forEach((skipped, i) => {
190
- const step = candidate.via[i];
191
- if (!step.nodes.includes(skipped)) step.nodes.push(skipped);
192
- });
193
- byTitle.set(next.id, candidate);
194
- }
195
- return [...byTitle.values()].sort((a, b) => order.get(a.node.id) - order.get(b.node.id));
196
- };
197
- const groups = place(0, void 0, [], []);
198
- const ungrouped = [];
199
- levels.forEach((level, levelIdx) => {
200
- if (levelIdx === 0 || !isTypeLevel(level)) return;
201
- for (const node of ofType(level.type)) if (!first.has(node.id)) ungrouped.push(occurrenceFor({
202
- node,
203
- via: []
204
- }, levelIdx, [null]));
205
- });
206
- return {
207
- groups,
208
- ungrouped
209
- };
210
- }
211
- function isTypeLevel(level) {
212
- return "type" in level;
213
- }
214
- /** A field's values as group labels: strings, an entry per array item, `null` when empty. */
215
- function valuesOf(node, field) {
216
- const raw = node.schemaData[field];
217
- const list = (Array.isArray(raw) ? raw : [raw]).filter((v) => v !== void 0 && v !== null && v !== "");
218
- return list.length === 0 ? [null] : list.map((v) => typeof v === "object" ? JSON.stringify(v) : String(v));
219
- }
220
- /** Distinct values in first-seen order, with the empty group last. */
221
- function distinctValues(nodes, field) {
222
- const values = new Set(nodes.flatMap((node) => valuesOf(node, field)));
223
- const present = [...values].filter((v) => v !== null);
224
- return values.has(null) ? [...present, null] : present;
225
- }
226
- function hasValue(node, { field, value }) {
227
- return valuesOf(node, field).includes(value);
228
- }
229
- //#endregion
230
9
  //#region src/layouts/NodeCard.tsx
231
10
  /**
232
11
  * A clickable node, drawn as a card (title plus selected fields) or a compact shape with a
@@ -442,82 +221,6 @@ function displayValue(value) {
442
221
  return value.replace(/^\[\[([^\]|]+)(\|[^\]]*)?\]\]$/, "$1");
443
222
  }
444
223
  //#endregion
445
- //#region src/core/tree.ts
446
- /**
447
- * Lay a space out as a tree over its hierarchy.
448
- *
449
- * Roots are root-type nodes with no hierarchy parent. Traversal is depth-first in space order,
450
- * so a node's primary occurrence is under the parent reached first. Under its other parents a
451
- * node is either repeated without its subtree (`repeat`), or left out and linked by a cross-edge
452
- * (`cross-edge`). Either way traversal stops there, which also keeps cycles from recursing.
453
- */
454
- function buildTree(graph, regionId, dag = "repeat") {
455
- const { hierarchy } = graph;
456
- const levelTypes = new Set(hierarchy?.levels.map((level) => level.type));
457
- const rootType = hierarchy?.levels[0]?.type;
458
- const primary = /* @__PURE__ */ new Map();
459
- const pendingCross = [];
460
- const hierarchyParents = (title) => parentEdges(graph, title).filter((edge) => isHierarchyEdge(edge, hierarchy));
461
- const visit = (node, path) => {
462
- const nodePath = [...path, node.id];
463
- const key = occurrenceKey(regionId, nodePath);
464
- primary.set(node.id, key);
465
- const childTitles = new Set(childEdges(graph, node.id).filter((edge) => isHierarchyEdge(edge, hierarchy)).map((edge) => edge.child));
466
- const children = [];
467
- for (const title of childTitles) {
468
- const child = graph.nodes.get(title);
469
- const repeatOf = primary.get(title);
470
- if (repeatOf === void 0) children.push(visit(child, nodePath));
471
- else if (dag === "repeat") children.push({
472
- key: occurrenceKey(regionId, [...nodePath, title]),
473
- node: child,
474
- children: [],
475
- repeatOf
476
- });
477
- else pendingCross.push({
478
- from: key,
479
- child: title
480
- });
481
- }
482
- return {
483
- key,
484
- node,
485
- children
486
- };
487
- };
488
- const levelNodes = [...graph.nodes.values()].filter((node) => levelTypes.has(node.resolvedType));
489
- const unparented = levelNodes.filter((node) => hierarchyParents(node.id).length === 0);
490
- const roots = unparented.filter((node) => node.resolvedType === rootType).map((node) => visit(node, []));
491
- const orphans = unparented.filter((node) => node.resolvedType !== rootType).map((node) => visit(node, []));
492
- for (const node of levelNodes) if (!primary.has(node.id)) orphans.push(visit(node, []));
493
- return {
494
- roots,
495
- orphans,
496
- primary,
497
- crossLinks: pendingCross.map(({ from, child }) => ({
498
- from,
499
- to: primary.get(child),
500
- kind: "cross"
501
- }))
502
- };
503
- }
504
- /** Parent → child pairs of occurrence keys: one per rendered parent-child link, then cross-links. */
505
- function treeLinks(tree) {
506
- const links = [];
507
- const walk = (occurrence) => {
508
- for (const child of occurrence.children) {
509
- links.push({
510
- from: occurrence.key,
511
- to: child.key,
512
- kind: "tree"
513
- });
514
- walk(child);
515
- }
516
- };
517
- for (const root of [...tree.roots, ...tree.orphans]) walk(root);
518
- return [...links, ...tree.crossLinks];
519
- }
520
- //#endregion
521
224
  //#region src/layouts/EdgeOverlay.tsx
522
225
  /**
523
226
  * SVG layer drawing connectors between rendered occurrences.
@@ -660,89 +363,6 @@ function Branches({ orientation, nested = false, children }) {
660
363
  });
661
364
  }
662
365
  //#endregion
663
- //#region src/core/xy.ts
664
- /**
665
- * Position nodes by two numeric fields. Every node of a plotted type appears once: on the plot
666
- * when both its values are numbers inside the axes' domains, otherwise in `unplaced` with the
667
- * reason. Positions are normalised; layouts decide the plot's size.
668
- */
669
- function buildXYPlot(graph, regionId, layout) {
670
- const { x, y } = layout;
671
- const nodes = [...graph.nodes.values()];
672
- const types = new Set(layout.types.length > 0 ? layout.types : nodes.filter((n) => isNumber(n.schemaData[x.field]) || isNumber(n.schemaData[y.field])).map((n) => n.resolvedType));
673
- const plotted = nodes.filter((n) => types.has(n.resolvedType));
674
- const domains = {
675
- x: domainOf(x, plotted),
676
- y: domainOf(y, plotted)
677
- };
678
- const points = [];
679
- const unplaced = [];
680
- for (const node of plotted) {
681
- const key = occurrenceKey(regionId, [node.id]);
682
- const px = position(node, x, domains.x);
683
- const py = position(node, y, domains.y);
684
- if (typeof px === "number" && typeof py === "number") points.push({
685
- key,
686
- node,
687
- x: px,
688
- y: py
689
- });
690
- else unplaced.push({
691
- key,
692
- node,
693
- reasons: [px, py].filter((r) => typeof r === "string")
694
- });
695
- }
696
- const keys = new Map(points.map((p) => [p.node.id, p.key]));
697
- const fields = new Set(layout.edgeFields);
698
- const links = edgesWithin(graph).filter((e) => keys.has(e.parent) && keys.has(e.child) && (fields.size === 0 || fields.has(e.field))).map((e) => ({
699
- from: keys.get(e.parent),
700
- to: keys.get(e.child),
701
- field: e.field,
702
- hierarchy: isHierarchyEdge(e, graph.hierarchy),
703
- lane: 0
704
- }));
705
- assignLanes(links);
706
- return {
707
- points,
708
- unplaced,
709
- links,
710
- domains
711
- };
712
- }
713
- function isNumber(value) {
714
- return typeof value === "number" && Number.isFinite(value);
715
- }
716
- /** The axis's fixed domain, or the range of plotted values (widened when they're all equal). */
717
- function domainOf(axis, nodes) {
718
- if (Array.isArray(axis.domain)) return [axis.domain[0], axis.domain[1]];
719
- const values = nodes.map((n) => n.schemaData[axis.field]).filter(isNumber);
720
- if (values.length === 0) return [0, 1];
721
- const min = Math.min(...values);
722
- const max = Math.max(...values);
723
- return min === max ? [min - 1, max + 1] : [min, max];
724
- }
725
- /** The node's normalised position on the axis, or why it has none. */
726
- function position(node, axis, [min, max]) {
727
- const value = node.schemaData[axis.field];
728
- if (value === void 0 || value === null) return `no ${axis.field}`;
729
- if (!isNumber(value)) return `${axis.field} is not a number`;
730
- if (value < min || value > max) return `${axis.field} ${value} is outside ${min}–${max}`;
731
- const t = (value - min) / (max - min);
732
- return axis.direction === "descending" ? 1 - t : t;
733
- }
734
- /** Spread links joining the same pair of nodes (in either direction) into lanes around 0. */
735
- function assignLanes(links) {
736
- const byPair = /* @__PURE__ */ new Map();
737
- for (const link of links) {
738
- const pair = [link.from, link.to].sort().join("\n");
739
- byPair.set(pair, [...byPair.get(pair) ?? [], link]);
740
- }
741
- for (const group of byPair.values()) group.forEach((link, i) => {
742
- link.lane = i - (group.length - 1) / 2;
743
- });
744
- }
745
- //#endregion
746
366
  //#region src/layouts/XYLayout.tsx
747
367
  /**
748
368
  * Nodes positioned by two numeric fields, with straight connectors between them. Positions are
@@ -1042,6 +662,6 @@ function ParameterControls({ definition, values, onChange }) {
1042
662
  });
1043
663
  }
1044
664
  //#endregion
1045
- export { SelectParameterInput as a, annotationsFrom as c, ParameterInput as i, worstSeverity as l, useParameterControls as n, ToggleParameterInput as o, MultiSelectParameterInput as r, MapView as s, ParameterControls as t };
665
+ export { SelectParameterInput as a, ParameterInput as i, useParameterControls as n, ToggleParameterInput as o, MultiSelectParameterInput as r, MapView as s, ParameterControls as t };
1046
666
 
1047
- //# sourceMappingURL=ParameterControls-BsdG5GDk.js.map
667
+ //# sourceMappingURL=ParameterControls-eKRxNr1P.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ParameterControls-eKRxNr1P.js","names":["_Fragment"],"sources":["../src/layouts/annotations-context.ts","../src/layouts/NodeCard.tsx","../src/layouts/LandscapeLayout.tsx","../src/layouts/EdgeOverlay.tsx","../src/layouts/TreeLayout.tsx","../src/layouts/XYLayout.tsx","../src/layouts/MapView.tsx","../src/layouts/ParameterInputs.tsx","../src/layouts/useParameterControls.ts","../src/layouts/ParameterControls.tsx"],"sourcesContent":["import { createContext, useContext } from 'react';\nimport type { AnnotationIndex } from '../core/annotations';\n\nconst NONE: AnnotationIndex = new Map();\n\n/** The annotations a map view shows, already narrowed by its validation settings. Read by node cards. */\nexport const AnnotationsContext = createContext<AnnotationIndex>(NONE);\n\nexport const useAnnotations = () => useContext(AnnotationsContext);\n","import type { SpaceNode } from 'structured-context/api';\nimport { type NodeAnnotation, type Severity, worstSeverity } from '../core/annotations';\nimport type { NodesConfig } from '../core/definition';\nimport { useAnnotations } from './annotations-context';\n\ntype Props = {\n node: SpaceNode;\n /** The node's subtree is rendered at another occurrence. */\n repeat: boolean;\n nodes: NodesConfig;\n onSelect?: (node: SpaceNode) => void;\n};\n\n/**\n * A clickable node, drawn as a card (title plus selected fields) or a compact shape with a\n * tooltip. Deliberately a `div` with button semantics rather than a `<button>`: hosts style\n * native form controls globally (Obsidian fixes button height and disables wrapping).\n */\nexport function NodeCard({ node, repeat, nodes, onSelect }: Props) {\n const select = () => onSelect?.(node);\n const annotations = useAnnotations().get(node.id);\n const label = `${node.resolvedType}: ${node.title}${repeat ? ' (shown in full elsewhere)' : ''}${annotationsLabel(annotations)}`;\n const onKeyDown = (e: React.KeyboardEvent) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n select();\n }\n };\n const border = repeat ? 'mv:border-dashed mv:border-muted/60 mv:opacity-75' : 'mv:border-edge';\n\n if (nodes.style === 'shape') {\n // 24px: the minimum target size for pointer input (WCAG 2.2 AA). The type's initial is the\n // visible cue; the full type and title are in the tooltip and accessible name.\n return (\n // biome-ignore lint/a11y/useSemanticElements: a native button inherits host button styles.\n <div\n role=\"button\"\n tabIndex={0}\n title={label}\n data-node-id={node.id}\n onClick={select}\n onKeyDown={onKeyDown}\n aria-label={label}\n className={`mv:relative mv:flex mv:size-6 mv:cursor-pointer mv:items-center mv:justify-center mv:rounded-full mv:border-2 mv:bg-card mv:text-[0.65rem] mv:font-semibold mv:uppercase mv:text-muted mv:hover:border-accent mv:focus-visible:outline-2 mv:focus-visible:outline-accent ${border}`}\n >\n <span aria-hidden=\"true\">{node.resolvedType.charAt(0)}</span>\n <AnnotationBadge annotations={annotations} />\n </div>\n );\n }\n\n const fields = nodes.fields\n .map((field) => [field, formatValue(node.schemaData[field])] as const)\n .filter(([, value]) => value !== undefined);\n\n return (\n // biome-ignore lint/a11y/useSemanticElements: a native button inherits host button styles.\n <div\n role=\"button\"\n tabIndex={0}\n title={label}\n data-node-id={node.id}\n onClick={select}\n onKeyDown={onKeyDown}\n className={`mv:relative mv:w-44 mv:cursor-pointer mv:rounded-md mv:border mv:bg-card mv:px-2.5 mv:py-1.5 mv:text-left mv:shadow-sm mv:hover:border-accent mv:focus-visible:outline-2 mv:focus-visible:outline-accent ${border}`}\n >\n <span className=\"mv:block mv:text-[0.65rem] mv:uppercase mv:tracking-wide mv:text-muted\">\n {node.resolvedType}\n {repeat && ' · repeat'}\n </span>\n <span className=\"mv:block mv:text-sm mv:leading-snug\">{node.title}</span>\n {fields.length > 0 && (\n <dl className=\"mv:m-0 mv:mt-1 mv:text-xs mv:text-muted\">\n {fields.map(([field, value]) => (\n <div key={field} className=\"mv:flex mv:gap-1\">\n <dt className=\"mv:shrink-0\">{field}:</dt>\n <dd className=\"mv:m-0 mv:truncate mv:text-ink\">{value}</dd>\n </div>\n ))}\n </dl>\n )}\n <AnnotationBadge annotations={annotations} />\n </div>\n );\n}\n\nconst BADGE: Record<Severity, string> = {\n error: 'mv:bg-error',\n warning: 'mv:bg-warning',\n info: 'mv:bg-info',\n};\n\n/** A count of the node's validation results in the corner, coloured by the most serious. Decorative: the count is in the card's label. */\nfunction AnnotationBadge({ annotations }: { annotations: readonly NodeAnnotation[] | undefined }) {\n const worst = annotations && worstSeverity(annotations);\n if (!annotations || !worst) return null;\n return (\n <span\n aria-hidden=\"true\"\n className={`mv:absolute mv:-top-1.5 mv:-right-1.5 mv:flex mv:h-4 mv:min-w-4 mv:items-center mv:justify-center mv:rounded-full mv:px-1 mv:text-[0.6rem] mv:font-semibold mv:text-white ${BADGE[worst]}`}\n >\n {annotations.length}\n </span>\n );\n}\n\nfunction annotationsLabel(annotations: readonly NodeAnnotation[] | undefined): string {\n const worst = annotations && worstSeverity(annotations);\n if (!annotations || !worst) return '';\n return ` (${annotations.length} validation ${annotations.length === 1 ? 'result' : 'results'}, most serious: ${worst})`;\n}\n\nfunction formatValue(value: unknown): string | undefined {\n if (value === undefined || value === null || value === '') return undefined;\n if (Array.isArray(value)) return value.map(String).join(', ');\n if (typeof value === 'object') return JSON.stringify(value);\n return String(value);\n}\n","import { useMemo } from 'react';\nimport type { SpaceNode } from 'structured-context/api';\nimport type { LandscapeLayoutConfig, Orientation } from '../core/definition';\nimport { buildLandscape, type LandscapeOccurrence } from '../core/landscape';\nimport { NodeCard } from './NodeCard';\nimport type { LayoutProps } from './TreeLayout';\n\n/**\n * Nested containers following the layout's grouping levels; the last level is drawn as nodes.\n * Flexbox does the nesting and wrapping. Containment shows the grouping edges, so no connectors\n * are drawn. PROTOTYPE: `edges.show` has no effect here; other edges aren't drawn yet.\n */\nexport function LandscapeLayout({ graph, region, instanceId, onNodeSelect }: LayoutProps<LandscapeLayoutConfig>) {\n const { layout } = region;\n const landscape = useMemo(() => buildLandscape(graph, region.id, layout), [graph, region.id, layout]);\n const last = layout.group.length - 1;\n\n const breadcrumb = (occurrence: LandscapeOccurrence) => {\n const level = layout.group[occurrence.level];\n if (!level || !('type' in level) || level.intermediate !== 'breadcrumb') return null;\n const steps = occurrence.via.filter((step) => step.nodes.length > 0);\n if (steps.length === 0) return null;\n return (\n <span className=\"mv:block mv:max-w-44 mv:text-[0.65rem] mv:leading-tight mv:text-muted\">\n via {steps.map((step) => step.nodes.map((n) => n.title).join(', ')).join(' › ')}\n </span>\n );\n };\n\n const render = (occurrence: LandscapeOccurrence, direction: Orientation): React.ReactNode => {\n const repeat = occurrence.repeatOf !== undefined;\n const marker = { 'data-occurrence': `${instanceId}${occurrence.key}` };\n\n if (occurrence.item.kind === 'node' && occurrence.level === last) {\n return (\n <li key={occurrence.key} {...marker} className=\"mv:flex mv:flex-col mv:gap-0.5\">\n <NodeCard node={occurrence.item.node} repeat={repeat} nodes={region.nodes} onSelect={onNodeSelect} />\n {breadcrumb(occurrence)}\n </li>\n );\n }\n\n // Containers alternate direction with depth; a container of nodes wraps them.\n const inner: Orientation = direction === 'horizontal' ? 'vertical' : 'horizontal';\n const holdsNodes = occurrence.level + 1 === last;\n return (\n <li\n key={occurrence.key}\n {...marker}\n className={`mv:flex mv:flex-col mv:gap-2 mv:rounded-lg mv:border mv:bg-surface mv:p-2 ${repeat ? 'mv:border-dashed mv:border-muted/60' : 'mv:border-edge'}`}\n >\n {occurrence.item.kind === 'node' ? (\n <ContainerHeading node={occurrence.item.node} repeat={repeat} onSelect={onNodeSelect}>\n {breadcrumb(occurrence)}\n </ContainerHeading>\n ) : (\n <span className=\"mv:text-xs mv:font-semibold mv:text-muted\">\n {occurrence.item.field}: {occurrence.item.value === null ? '(none)' : displayValue(occurrence.item.value)}\n </span>\n )}\n <Items direction={holdsNodes ? 'wrap' : inner}>\n {occurrence.children.map((child) => render(child, inner))}\n </Items>\n </li>\n );\n };\n\n const top = layout.orientation;\n return (\n <div className=\"mv:w-max mv:min-w-full mv:p-4\">\n <Items direction={last === 0 ? 'wrap' : top}>\n {landscape.groups.map((group) => render(group, top))}\n {landscape.ungrouped.length > 0 && (\n <li className=\"mv:flex mv:flex-col mv:gap-2 mv:rounded-lg mv:border mv:border-dashed mv:border-edge mv:p-2\">\n <span className=\"mv:text-xs mv:font-semibold mv:text-muted\">Ungrouped</span>\n <Items direction=\"wrap\">{landscape.ungrouped.map((o) => render(o, top))}</Items>\n </li>\n )}\n </Items>\n </div>\n );\n}\n\nfunction Items({ direction, children }: { direction: Orientation | 'wrap'; children: React.ReactNode }) {\n const layout = {\n horizontal: 'mv:flex-row mv:items-start mv:gap-3',\n vertical: 'mv:flex-col mv:items-stretch mv:gap-2',\n wrap: 'mv:max-w-[36rem] mv:flex-row mv:flex-wrap mv:items-start mv:gap-2',\n }[direction];\n return <ul className={`mv:m-0 mv:flex mv:list-none mv:p-0 ${layout}`}>{children}</ul>;\n}\n\n/** A container's node: type and title, selectable like a card. */\nfunction ContainerHeading({\n node,\n repeat,\n onSelect,\n children,\n}: {\n node: SpaceNode;\n repeat: boolean;\n onSelect?: (node: SpaceNode) => void;\n children?: React.ReactNode;\n}) {\n const select = () => onSelect?.(node);\n return (\n // biome-ignore lint/a11y/useSemanticElements: a native button inherits host button styles.\n <div\n role=\"button\"\n tabIndex={0}\n title={`${node.resolvedType}: ${node.title}${repeat ? ' (also shown elsewhere)' : ''}`}\n onClick={select}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n select();\n }\n }}\n className=\"mv:cursor-pointer mv:rounded mv:px-1 mv:hover:text-accent mv:focus-visible:outline-2 mv:focus-visible:outline-accent\"\n >\n <span className=\"mv:block mv:text-[0.65rem] mv:uppercase mv:tracking-wide mv:text-muted\">\n {node.resolvedType}\n {repeat && ' · repeat'}\n </span>\n <span className=\"mv:block mv:text-sm mv:font-semibold mv:leading-snug\">{node.title}</span>\n {children}\n </div>\n );\n}\n\n/** Field values that are wikilinks show as the linked title. */\nfunction displayValue(value: string): string {\n return value.replace(/^\\[\\[([^\\]|]+)(\\|[^\\]]*)?\\]\\]$/, '$1');\n}\n","import { useLayoutEffect, useState } from 'react';\nimport type { Orientation } from '../core/definition';\n\n/**\n * A connector between two occurrences. `cross` links (e.g. extra parents) are drawn dashed.\n * `id` tells apart several links between the same occurrences; straight links between the same\n * pair are drawn side by side, `lane` apart (0: on the line between centres).\n */\nexport type Link = { from: string; to: string; kind?: 'tree' | 'cross'; id?: string; lane?: number };\n\ntype Props = {\n links: readonly Link[];\n /** Rendered element of each occurrence, by occurrence key. */\n elements: ReadonlyMap<string, HTMLElement>;\n /**\n * Positioned element the overlay covers; coordinates are relative to it. Passed as an element,\n * not a ref: the overlay sits inside it, and React runs a child's layout effects before\n * attaching the parent's ref.\n */\n container: HTMLElement | null;\n /** Curves leaving along the tree's orientation, or straight lines between centres (drawn under the nodes). */\n routing: Orientation | 'straight';\n};\n\ntype Drawn = { key: string; d: string; cross: boolean };\n\n/**\n * SVG layer drawing connectors between rendered occurrences.\n *\n * Measures occurrence elements after layout and redraws when the container or any occurrence\n * resizes, so it follows embedded panes that resize independently of the window, and reflows\n * such as late font loads. The SVG fills the container instead of being sized from it, so it\n * never holds the container open after the layout shrinks.\n */\nexport function EdgeOverlay({ links, elements, container, routing }: Props) {\n const [paths, setPaths] = useState<Drawn[]>([]);\n\n useLayoutEffect(() => {\n if (!container) return;\n\n const measure = () => {\n const origin = container.getBoundingClientRect();\n const paths: Drawn[] = [];\n for (const { from, to, kind, id, lane = 0 } of links) {\n const a = elements.get(from)?.getBoundingClientRect();\n const b = elements.get(to)?.getBoundingClientRect();\n if (!a || !b) continue;\n paths.push({\n key: `${from}→${to}${id ?? ''}`,\n d: routing === 'straight' ? line(a, b, origin, lane) : connector(a, b, origin, routing),\n cross: kind === 'cross',\n });\n }\n setPaths(paths);\n };\n\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(container);\n for (const element of elements.values()) observer.observe(element);\n return () => observer.disconnect();\n }, [links, elements, container, routing]);\n\n return (\n <svg\n aria-hidden=\"true\"\n className=\"mv:pointer-events-none mv:absolute mv:inset-0 mv:h-full mv:w-full mv:overflow-visible\"\n >\n {paths.map(({ key, d, cross }) => (\n <path\n key={key}\n d={d}\n className={`mv:fill-none ${cross ? 'mv:stroke-accent/60' : 'mv:stroke-muted/50'}`}\n strokeWidth={1.5}\n strokeDasharray={cross ? '4 3' : undefined}\n />\n ))}\n </svg>\n );\n}\n\n/** Cubic curve from the parent's trailing edge to the child's leading edge. */\nfunction connector(a: DOMRect, b: DOMRect, origin: DOMRect, orientation: Orientation): string {\n if (orientation === 'vertical') {\n const x1 = a.left + a.width / 2 - origin.left;\n const y1 = a.bottom - origin.top;\n const x2 = b.left + b.width / 2 - origin.left;\n const y2 = b.top - origin.top;\n const my = (y1 + y2) / 2;\n return `M${x1},${y1} C${x1},${my} ${x2},${my} ${x2},${y2}`;\n }\n const x1 = a.right - origin.left;\n const y1 = a.top + a.height / 2 - origin.top;\n const x2 = b.left - origin.left;\n const y2 = b.top + b.height / 2 - origin.top;\n const mx = (x1 + x2) / 2;\n return `M${x1},${y1} C${mx},${y1} ${mx},${y2} ${x2},${y2}`;\n}\n\n/** Pixels between parallel straight links. */\nconst LANE_GAP = 6;\n\n/**\n * Straight line between centres, shifted sideways by its lane; the layout draws nodes over the\n * overlay to hide the ends. The shift is relative to a fixed orientation of the pair, so links in\n * opposite directions between the same nodes still separate.\n */\nfunction line(a: DOMRect, b: DOMRect, origin: DOMRect, lane: number): string {\n const x1 = a.left + a.width / 2 - origin.left;\n const y1 = a.top + a.height / 2 - origin.top;\n const x2 = b.left + b.width / 2 - origin.left;\n const y2 = b.top + b.height / 2 - origin.top;\n const flip = x1 < x2 || (x1 === x2 && y1 < y2) ? 1 : -1;\n const length = Math.hypot(x2 - x1, y2 - y1) || 1;\n const dx = (-(y2 - y1) / length) * lane * LANE_GAP * flip;\n const dy = ((x2 - x1) / length) * lane * LANE_GAP * flip;\n return `M${x1 + dx},${y1 + dy} L${x2 + dx},${y2 + dy}`;\n}\n","import { useCallback, useMemo, useRef, useState } from 'react';\nimport type { SpaceGraph, SpaceNode } from 'structured-context/api';\nimport type { LayoutConfig, Orientation, Region, TreeLayoutConfig } from '../core/definition';\nimport { buildTree, type TreeOccurrence, treeLinks } from '../core/tree';\nimport { EdgeOverlay } from './EdgeOverlay';\nimport { NodeCard } from './NodeCard';\n\nexport type LayoutProps<L extends LayoutConfig = LayoutConfig> = {\n graph: SpaceGraph;\n /** The region with parameter values applied, narrowed to the layout's own settings. */\n region: Region & { layout: L };\n /** Scopes occurrence ids when several map views render in one document. */\n instanceId: string;\n onNodeSelect?: (node: SpaceNode) => void;\n};\n\n/**\n * Tree over the schema's hierarchy. Flexbox does the branching; the SVG overlay draws connectors.\n */\nexport function TreeLayout({ graph, region, instanceId, onNodeSelect }: LayoutProps<TreeLayoutConfig>) {\n const { orientation, dag } = region.layout;\n const tree = useMemo(() => buildTree(graph, region.id, dag), [graph, region.id, dag]);\n const links = useMemo(() => (region.edges.show ? treeLinks(tree) : []), [tree, region.edges.show]);\n\n const [container, setContainer] = useState<HTMLDivElement | null>(null);\n // Filled by ref callbacks during commit, read by the overlay's layout effect afterwards.\n const elements = useRef(new Map<string, HTMLElement>()).current;\n const register = useCallback(\n (key: string) => (el: HTMLElement | null) => {\n if (el) elements.set(key, el);\n else elements.delete(key);\n },\n [elements],\n );\n\n const branch = (occurrence: TreeOccurrence) => (\n <li\n key={occurrence.key}\n className={`mv:flex mv:items-center ${orientation === 'vertical' ? 'mv:flex-col' : 'mv:flex-row'}`}\n >\n <div ref={register(occurrence.key)} data-occurrence={`${instanceId}${occurrence.key}`}>\n <NodeCard\n node={occurrence.node}\n repeat={occurrence.repeatOf !== undefined}\n nodes={region.nodes}\n onSelect={onNodeSelect}\n />\n </div>\n {occurrence.children.length > 0 && (\n <Branches orientation={orientation} nested>\n {occurrence.children.map(branch)}\n </Branches>\n )}\n </li>\n );\n\n return (\n <div ref={setContainer} className=\"mv:relative mv:w-max mv:min-w-full mv:p-4\">\n <Branches orientation={orientation}>{[...tree.roots, ...tree.orphans].map(branch)}</Branches>\n <EdgeOverlay links={links} elements={elements} container={container} routing={orientation} />\n </div>\n );\n}\n\nfunction Branches({\n orientation,\n nested = false,\n children,\n}: {\n orientation: Orientation;\n nested?: boolean;\n children: React.ReactNode;\n}) {\n // Siblings run across the main axis; nested branches leave a gap for connectors.\n const layout =\n orientation === 'vertical'\n ? `mv:flex-row mv:items-start mv:justify-center mv:gap-3 ${nested ? 'mv:pt-10' : ''}`\n : `mv:flex-col mv:items-start mv:justify-center mv:gap-2 ${nested ? 'mv:pl-14' : ''}`;\n return <ul className={`mv:m-0 mv:flex mv:list-none mv:p-0 ${layout}`}>{children}</ul>;\n}\n","import { useCallback, useMemo, useRef, useState } from 'react';\nimport type { AxisConfig, XYLayoutConfig } from '../core/definition';\nimport { buildXYPlot } from '../core/xy';\nimport { EdgeOverlay } from './EdgeOverlay';\nimport { NodeCard } from './NodeCard';\nimport type { LayoutProps } from './TreeLayout';\n\n/**\n * Nodes positioned by two numeric fields, with straight connectors between them. Positions are\n * percentages of the plot area, which fills the container (scrolling below a minimum size). Nodes that can't be\n * placed are listed under the plot with the reason.\n * PROTOTYPE: labels may overlap where nodes sit close together; no collision handling.\n */\nexport function XYLayout({ graph, region, instanceId, onNodeSelect }: LayoutProps<XYLayoutConfig>) {\n const { layout } = region;\n const plot = useMemo(() => buildXYPlot(graph, region.id, layout), [graph, region.id, layout]);\n // Relationship edges (flows, pipelines) are dashed, to tell them from the value chain.\n const links = useMemo(\n () =>\n region.edges.show\n ? plot.links.map(({ from, to, field, hierarchy, lane }) => ({\n from,\n to,\n id: field,\n lane,\n kind: hierarchy ? ('tree' as const) : ('cross' as const),\n }))\n : [],\n [plot, region.edges.show],\n );\n const shape = region.nodes.style === 'shape';\n\n const [container, setContainer] = useState<HTMLDivElement | null>(null);\n const elements = useRef(new Map<string, HTMLElement>()).current;\n const register = useCallback(\n (key: string) => (el: HTMLElement | null) => {\n if (el) elements.set(key, el);\n else elements.delete(key);\n },\n [elements],\n );\n\n return (\n <div className=\"mv:box-border mv:flex mv:h-full mv:min-h-[28rem] mv:min-w-[36rem] mv:flex-col mv:gap-4 mv:p-4\">\n <div className=\"mv:grid mv:min-h-0 mv:flex-1 mv:grid-cols-[auto_1fr] mv:grid-rows-[1fr_auto] mv:gap-1\">\n <AxisTitle axis={layout.y} domain={plot.domains.y} vertical />\n <div ref={setContainer} className=\"mv:relative mv:border-b mv:border-l mv:border-edge\">\n {/* Before the nodes, so the opaque nodes cover the ends of the lines. */}\n <EdgeOverlay links={links} elements={elements} container={container} routing=\"straight\" />\n {/* Inset, so nodes at the ends of a domain stay inside the plot. */}\n <div className=\"mv:absolute mv:inset-8\">\n {plot.points.map((point) => (\n <div\n key={point.key}\n data-occurrence={`${instanceId}${point.key}`}\n className={`mv:absolute mv:flex mv:items-center mv:gap-1 ${shape ? 'mv:-translate-x-3 mv:translate-y-3' : 'mv:-translate-x-1/2 mv:translate-y-1/2'}`}\n style={{ left: `${point.x * 100}%`, bottom: `${point.y * 100}%` }}\n >\n <div ref={register(point.key)}>\n <NodeCard node={point.node} repeat={false} nodes={region.nodes} onSelect={onNodeSelect} />\n </div>\n {shape && (\n <span className=\"mv:whitespace-nowrap mv:rounded mv:bg-surface/80 mv:px-0.5 mv:text-xs\">\n {point.node.title}\n </span>\n )}\n </div>\n ))}\n </div>\n </div>\n <div />\n <AxisTitle axis={layout.x} domain={plot.domains.x} />\n </div>\n\n {plot.unplaced.length > 0 && (\n <section className=\"mv:flex mv:flex-col mv:gap-2\">\n <span className=\"mv:text-xs mv:font-semibold mv:text-muted\">Not plotted</span>\n <ul className=\"mv:m-0 mv:flex mv:list-none mv:flex-wrap mv:gap-3 mv:p-0\">\n {plot.unplaced.map(({ key, node, reasons }) => (\n <li key={key} data-occurrence={`${instanceId}${key}`} className=\"mv:flex mv:items-center mv:gap-1\">\n <NodeCard node={node} repeat={false} nodes={region.nodes} onSelect={onNodeSelect} />\n <span className=\"mv:text-xs\">\n {shape && `${node.title} `}\n <span className=\"mv:text-muted\">({reasons.join('; ')})</span>\n </span>\n </li>\n ))}\n </ul>\n </section>\n )}\n </div>\n );\n}\n\n/** Axis title with the values at each end, in drawing order. */\nfunction AxisTitle({\n axis,\n domain: [min, max],\n vertical = false,\n}: {\n axis: AxisConfig;\n domain: readonly [number, number];\n vertical?: boolean;\n}) {\n const [start, end] = axis.direction === 'descending' ? [max, min] : [min, max];\n return (\n <div\n className={`mv:flex mv:items-center mv:justify-between mv:gap-2 mv:text-xs mv:text-muted ${vertical ? 'mv:flex-col-reverse mv:py-8' : 'mv:px-8'}`}\n >\n <span>{format(start)}</span>\n <span className={`mv:font-semibold ${vertical ? 'mv:[writing-mode:vertical-rl] mv:rotate-180' : ''}`}>\n {axis.label ?? axis.field}\n </span>\n <span>{format(end)}</span>\n </div>\n );\n}\n\nfunction format(value: number): string {\n return Number.isInteger(value) ? String(value) : value.toPrecision(3).replace(/\\.?0+$/, '');\n}\n","import { useId, useMemo } from 'react';\nimport type { SpaceGraph, SpaceNode } from 'structured-context/api';\nimport { type AnnotationIndex, filterAnnotations } from '../core/annotations';\nimport { type MapViewDefinition, type ParameterValues, type Region, resolveRegions } from '../core/definition';\nimport { AnnotationsContext } from './annotations-context';\nimport { LandscapeLayout } from './LandscapeLayout';\nimport { type LayoutProps, TreeLayout } from './TreeLayout';\nimport { XYLayout } from './XYLayout';\n\ntype Props = {\n definition: MapViewDefinition;\n graph: SpaceGraph;\n /** Current parameter values (host-owned session state); missing values use defaults. */\n values?: ParameterValues;\n /**\n * Validation results by node (see `annotationsFrom`). Which of them show, and at what severity, is\n * the region's `nodes.validation` setting; with none supplied, nothing is drawn.\n */\n annotations?: AnnotationIndex;\n onNodeSelect?: (node: SpaceNode) => void;\n};\n\nconst EMPTY: AnnotationIndex = new Map();\n\n/** Renders a map view definition against a space. Sizes to its container and scrolls within it. */\nexport function MapView({ definition, graph, values, annotations, onNodeSelect }: Props) {\n const instanceId = useId();\n const regions = useMemo(() => resolveRegions(definition, values), [definition, values]);\n // PROTOTYPE: only the first region is rendered. Arranging several regions is undesigned (#8).\n const region = regions[0]!;\n const props = { graph, instanceId, onNodeSelect };\n const { validation, validationSources } = region.nodes;\n const visibleAnnotations = useMemo(\n () => (annotations ? filterAnnotations(annotations, validation, validationSources) : EMPTY),\n [annotations, validation, validationSources],\n );\n\n return (\n <AnnotationsContext.Provider value={visibleAnnotations}>\n <div className=\"mv:h-full mv:w-full mv:overflow-auto mv:bg-surface mv:text-ink\">{layoutFor(region, props)}</div>\n </AnnotationsContext.Provider>\n );\n}\n\nfunction layoutFor(region: Region, props: Omit<LayoutProps, 'region'>) {\n const { layout } = region;\n switch (layout.type) {\n case 'tree':\n return <TreeLayout {...props} region={{ ...region, layout }} />;\n case 'landscape':\n return <LandscapeLayout {...props} region={{ ...region, layout }} />;\n case 'xy':\n return <XYLayout {...props} region={{ ...region, layout }} />;\n }\n}\n","import { useId } from 'react';\nimport type { Parameter, ParameterControl } from '../core/definition';\n\ntype InputProps<Kind extends ParameterControl['kind']> = {\n parameter: Parameter & { control: Extract<ParameterControl, { kind: Kind }> };\n value: unknown;\n onChange: (value: unknown) => void;\n};\n\nconst same = (a: unknown, b: unknown) => JSON.stringify(a) === JSON.stringify(b);\n\n/** A checkbox for a boolean parameter, labelled with the parameter's title. */\nexport function ToggleParameterInput({ parameter, value, onChange }: InputProps<'toggle'>) {\n const id = useId();\n return (\n <>\n <input id={id} type=\"checkbox\" checked={value === true} onChange={(e) => onChange(e.target.checked)} />\n <label htmlFor={id}>{parameter.title}</label>\n </>\n );\n}\n\n/** A dropdown for a parameter with one of several options. */\nexport function SelectParameterInput({ parameter, value, onChange }: InputProps<'select'>) {\n const id = useId();\n return (\n <>\n <label htmlFor={id} className=\"mv:text-muted\">\n {parameter.title}\n </label>\n <select id={id} value={JSON.stringify(value)} onChange={(e) => onChange(JSON.parse(e.target.value))}>\n {parameter.control.options.map((option) => (\n <option key={JSON.stringify(option)} value={JSON.stringify(option)}>\n {String(option)}\n </option>\n ))}\n </select>\n </>\n );\n}\n\n/** A checkbox group for a parameter taking any subset of its options. */\nexport function MultiSelectParameterInput({ parameter, value, onChange }: InputProps<'multiselect'>) {\n const { options } = parameter.control;\n const selected = Array.isArray(value) ? value : [];\n return (\n <fieldset className=\"mv:m-0 mv:flex mv:flex-wrap mv:items-center mv:gap-2 mv:border-0 mv:p-0\">\n <legend className=\"mv:float-left mv:mr-1.5 mv:p-0 mv:text-muted\">{parameter.title}</legend>\n {options.map((option) => {\n const checked = selected.some((v) => same(v, option));\n return (\n <label key={JSON.stringify(option)} className=\"mv:flex mv:items-center mv:gap-1\">\n <input\n type=\"checkbox\"\n checked={checked}\n onChange={() =>\n // Keep the options' order rather than the order of clicks.\n onChange(options.filter((o) => (o === option ? !checked : selected.some((v) => same(v, o)))))\n }\n />\n {String(option)}\n </label>\n );\n })}\n </fieldset>\n );\n}\n\n/** The input matching a parameter's control kind. */\nexport function ParameterInput({\n parameter,\n value,\n onChange,\n}: Omit<InputProps<ParameterControl['kind']>, 'parameter'> & { parameter: Parameter }) {\n const { control } = parameter;\n switch (control.kind) {\n case 'toggle':\n return <ToggleParameterInput parameter={{ ...parameter, control }} value={value} onChange={onChange} />;\n case 'select':\n return <SelectParameterInput parameter={{ ...parameter, control }} value={value} onChange={onChange} />;\n case 'multiselect':\n return <MultiSelectParameterInput parameter={{ ...parameter, control }} value={value} onChange={onChange} />;\n }\n}\n","import { useMemo } from 'react';\nimport {\n type MapViewDefinition,\n type Parameter,\n type ParameterValues,\n resolveParameterValues,\n} from '../core/definition';\n\n/** One parameter with its current value and a setter, ready for a host to lay out. */\nexport type ParameterControlState = {\n parameter: Parameter;\n /** The value in effect: the host's value, else the default, matching what renders. */\n value: unknown;\n setValue: (value: unknown) => void;\n};\n\n/**\n * The state behind a map view's parameter controls, with no markup, for hosts that lay the controls\n * out themselves. Pair each entry with `ParameterInput`, or with one of the typed inputs.\n */\nexport function useParameterControls(\n definition: MapViewDefinition,\n values: ParameterValues,\n onChange: (name: string, value: unknown) => void,\n): ParameterControlState[] {\n const resolved = useMemo(() => resolveParameterValues(definition, values), [definition, values]);\n return definition.parameters.map((parameter) => ({\n parameter,\n value: resolved[parameter.name],\n setValue: (value) => onChange(parameter.name, value),\n }));\n}\n","import type { MapViewDefinition, ParameterValues } from '../core/definition';\nimport { ParameterInput } from './ParameterInputs';\nimport { useParameterControls } from './useParameterControls';\n\ntype Props = {\n definition: MapViewDefinition;\n /** Host-owned values; missing or stale ones show as the default, matching what renders. */\n values: ParameterValues;\n onChange: (name: string, value: unknown) => void;\n};\n\n/**\n * Default layout for a map view's parameter controls: a wrapping row. Hosts wanting their own layout\n * use `useParameterControls` with `ParameterInput` (or the typed inputs) instead.\n */\nexport function ParameterControls({ definition, values, onChange }: Props) {\n const controls = useParameterControls(definition, values, onChange);\n if (controls.length === 0) return null;\n return (\n <div className=\"mv:flex mv:flex-wrap mv:items-center mv:gap-x-4 mv:gap-y-2 mv:text-sm\">\n {controls.map(({ parameter, value, setValue }) => (\n <div key={parameter.name} className=\"mv:flex mv:items-center mv:gap-1.5\" title={parameter.description}>\n <ParameterInput parameter={parameter} value={value} onChange={setValue} />\n </div>\n ))}\n </div>\n );\n}\n"],"mappings":";;;;;AAMA,IAAa,qBAAqB,8BAA+B,IAH/B,IAG+B,CAAI;AAErE,IAAa,uBAAuB,WAAW,kBAAkB;;;;;;;;ACUjE,SAAgB,SAAS,EAAE,MAAM,QAAQ,OAAO,YAAmB;CACjE,MAAM,eAAe,WAAW,IAAI;CACpC,MAAM,cAAc,eAAe,CAAC,CAAC,IAAI,KAAK,EAAE;CAChD,MAAM,QAAQ,GAAG,KAAK,aAAa,IAAI,KAAK,QAAQ,SAAS,+BAA+B,KAAK,iBAAiB,WAAW;CAC7H,MAAM,aAAa,MAA2B;EAC5C,IAAI,EAAE,QAAQ,WAAW,EAAE,QAAQ,KAAK;GACtC,EAAE,eAAe;GACjB,OAAO;EACT;CACF;CACA,MAAM,SAAS,SAAS,sDAAsD;CAE9E,IAAI,MAAM,UAAU,SAGlB,OAEE,qBAAC,OAAD;EACE,MAAK;EACL,UAAU;EACV,OAAO;EACP,gBAAc,KAAK;EACnB,SAAS;EACE;EACX,cAAY;EACZ,WAAW,4QAA4Q;EARzR,UAAA,CAUE,oBAAC,QAAD;GAAM,eAAY;GAAQ,UAAA,KAAK,aAAa,OAAO,CAAC;EAAQ,CAAA,GAC5D,oBAAC,iBAAD,EAA8B,YAAc,CAAA,CACzC;;CAIT,MAAM,SAAS,MAAM,OAClB,KAAK,UAAU,CAAC,OAAO,YAAY,KAAK,WAAW,MAAM,CAAC,CAAU,CAAC,CACrE,QAAQ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G,KAAK,eACH,OAAO,oBAAC,2BAAD;GAA2B,WAAW;IAAE,GAAG;IAAW;GAAQ;GAAU;GAAiB;EAAW,CAAA;CAC/G;AACF;;;;;;;AC/DA,SAAgB,qBACd,YACA,QACA,UACyB;CACzB,MAAM,WAAW,cAAc,uBAAuB,YAAY,MAAM,GAAG,CAAC,YAAY,MAAM,CAAC;CAC/F,OAAO,WAAW,WAAW,KAAK,eAAe;EAC/C;EACA,OAAO,SAAS,UAAU;EAC1B,WAAW,UAAU,SAAS,UAAU,MAAM,KAAK;CACrD,EAAE;AACJ;;;;;;;AChBA,SAAgB,kBAAkB,EAAE,YAAY,QAAQ,YAAmB;CACzE,MAAM,WAAW,qBAAqB,YAAY,QAAQ,QAAQ;CAClE,IAAI,SAAS,WAAW,GAAG,OAAO;CAClC,OACE,oBAAC,OAAD;EAAK,WAAU;EACZ,UAAA,SAAS,KAAK,EAAE,WAAW,OAAO,eACjC,oBAAC,OAAD;GAA0B,WAAU;GAAqC,OAAO,UAAU;GACxF,UAAA,oBAAC,gBAAD;IAA2B;IAAkB;IAAO,UAAU;GAAW,CAAA;EACtE,GAFK,UAAU,IAEf,CACN;CACE,CAAA;AAET"}
@@ -598,4 +598,4 @@ body { background: var(--art-ground); color: var(--mv-color-ink); }
598
598
  </style>
599
599
  <div id="root"></div>
600
600
  <script type="importmap">{"imports":{"structured-context/browser":"https://cdn.jsdelivr.net/npm/structured-context@0.21.0/dist/browser.js/+esm","react":"https://cdn.jsdelivr.net/npm/react@19.3.0/+esm","react/jsx-runtime":"https://cdn.jsdelivr.net/npm/react@19.3.0/jsx-runtime/+esm","react-dom":"https://cdn.jsdelivr.net/npm/react-dom@19.3.0/+esm","react-dom/client":"https://cdn.jsdelivr.net/npm/react-dom@19.3.0/client/+esm","ajv/dist/2020":"https://cdn.jsdelivr.net/npm/ajv@8.20.0/dist/2020.js/+esm","json5":"https://cdn.jsdelivr.net/npm/json5@2.2.3/+esm","https://cdn.jsdelivr.net/npm/react@%5E19.3.0/+esm":"https://cdn.jsdelivr.net/npm/react@19.3.0/+esm"}}</script>
601
- <script type="module" src="https://cdn.jsdelivr.net/npm/structured-context-map-views@0.3.1/dist/artifact.js"></script>
601
+ <script type="module" src="https://cdn.jsdelivr.net/npm/structured-context-map-views@0.4.0/dist/artifact.js"></script>
package/dist/artifact.js CHANGED
@@ -1,4 +1,5 @@
1
- import { c as annotationsFrom, s as MapView, t as ParameterControls } from "./ParameterControls-BsdG5GDk.js";
1
+ import { a as annotationsFrom } from "./projection-GaO0MCbR.js";
2
+ import { s as MapView, t as ParameterControls } from "./ParameterControls-eKRxNr1P.js";
2
3
  import { useEffect, useMemo, useRef, useState } from "react";
3
4
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
5
  import { createRoot } from "react-dom/client";
@@ -1 +1 @@
1
- {"version":3,"file":"artifact.js","names":["_Fragment"],"sources":["../src/artifact/load.ts","../src/artifact/main.tsx"],"sourcesContent":["import type { spaceGraphFrom } from 'structured-context/browser';\nimport type { ValidationInput } from '../core/annotations';\nimport type { MapViewDefinition } from '../core/definition';\n\n/** A space as the artifact's db holds it: the `export` command's document with its parts as JSON strings. */\nexport type LoadedSpace = {\n name: string;\n schemaId: string | undefined;\n graph: Parameters<typeof spaceGraphFrom>[0];\n validation: ValidationInput;\n definitions: MapViewDefinition[];\n};\n\nconst SPACES = 'spaces';\nconst TIMEOUT_MS = 10_000;\n\ntype Db = {\n collection(path: string): { get(): Promise<{ docs: { id: string; data(): Record<string, unknown> | undefined }[] }> };\n};\n\n/** Every space written to the artifact's `spaces` collection. Rejects with a message fit to show the viewer. */\nexport async function loadSpaces(): Promise<LoadedSpace[]> {\n const claude = (window as unknown as { claude?: { use(name: string): Promise<unknown> } }).claude;\n const db = (claude ? await claude.use('db') : null) as Db | null;\n if (!db) throw new Error('This page needs the artifact database, which is not available to this viewer.');\n\n let timer: ReturnType<typeof setTimeout> | undefined;\n const timeout = new Promise<never>((_, reject) => {\n timer = setTimeout(() => reject(new Error('Reading the artifact database timed out.')), TIMEOUT_MS);\n });\n const snapshot = await Promise.race([db.collection(SPACES).get(), timeout]).finally(() => clearTimeout(timer));\n const spaces = snapshot.docs.flatMap((doc) => {\n const data = doc.data();\n return data ? [toSpace(doc.id, data)] : [];\n });\n if (spaces.length === 0)\n throw new Error(`Nothing to show yet: no space has been written to \"${SPACES}\" in the artifact database.`);\n return spaces;\n}\n\nfunction toSpace(name: string, data: Record<string, unknown>): LoadedSpace {\n const json = (field: string) => {\n const value = data[field];\n if (typeof value !== 'string') throw new Error(`Space \"${name}\": missing \"${field}\" in the artifact database.`);\n return JSON.parse(value);\n };\n return {\n name,\n schemaId: typeof data.schemaId === 'string' ? data.schemaId : undefined,\n graph: json('graph'),\n validation: json('validation'),\n definitions: json('definitions'),\n };\n}\n","import { useEffect, useMemo, useRef, useState } from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { spaceGraphFrom } from 'structured-context/browser';\nimport { annotationsFrom } from '../core/annotations';\nimport type { MapViewDefinition, ParameterValues } from '../core/definition';\nimport { MapView } from '../layouts/MapView';\nimport { ParameterControls } from '../layouts/ParameterControls';\nimport { type LoadedSpace, loadSpaces } from './load';\n\n/**\n * The host for a Claude artifact: renders the spaces the publishing agent wrote to the artifact's\n * db (the `export` command's document, one per space) with the parameter controls and a panel of\n * validation messages. It reads nothing else and ships as `dist/artifact.js`; `dist/artifact.html`\n * is the page that loads it. See docs/architecture.md.\n */\n\ntype State = { status: 'loading' } | { status: 'error'; message: string } | { status: 'ready'; spaces: LoadedSpace[] };\n\nfunction App() {\n const [state, setState] = useState<State>({ status: 'loading' });\n useEffect(() => {\n loadSpaces().then(\n (spaces) => setState({ status: 'ready', spaces }),\n (err) => setState({ status: 'error', message: err instanceof Error ? err.message : String(err) }),\n );\n }, []);\n if (state.status === 'loading') return <p className=\"art-message\">Loading from the artifact database…</p>;\n if (state.status === 'error') return <p className=\"art-message\">{state.message}</p>;\n return <Viewer spaces={state.spaces} />;\n}\n\nfunction Viewer({ spaces }: { spaces: LoadedSpace[] }) {\n const [spaceName, setSpaceName] = useState(spaces[0]!.name);\n const space = spaces.find((s) => s.name === spaceName)!;\n const [viewId, setViewId] = useState(space.definitions[0]?.id);\n const definition = space.definitions.find((d) => d.id === viewId) ?? space.definitions[0];\n const [values, setValues] = useState<ParameterValues>({});\n const [selectedId, setSelectedId] = useState<string>();\n\n const graph = useMemo(() => spaceGraphFrom(space.graph), [space]);\n const annotated = useMemo(() => annotationsFrom(space.validation, graph), [space, graph]);\n const mapRef = useNodeLabels(graph, definition);\n\n if (!definition) return <p className=\"art-message\">No map views apply to the schema of \"{space.name}\".</p>;\n const selected = selectedId ? graph.nodes.get(selectedId as never) : undefined;\n const results = selected ? (annotated.annotations.get(selected.id as never) ?? []) : [];\n\n return (\n <div className=\"art-root\">\n <header className=\"art-bar\">\n {spaces.length > 1 && (\n <select\n aria-label=\"Space\"\n value={spaceName}\n onChange={(e) => {\n const next = spaces.find((s) => s.name === e.target.value)!;\n setSpaceName(next.name);\n setViewId(next.definitions[0]?.id);\n setValues({});\n setSelectedId(undefined);\n }}\n >\n {spaces.map((s) => (\n <option key={s.name} value={s.name}>\n {s.name}\n </option>\n ))}\n </select>\n )}\n {space.definitions.length > 1 && (\n <select\n aria-label=\"Map view\"\n value={definition.id}\n onChange={(e) => {\n setViewId(e.target.value);\n setValues({});\n }}\n >\n {space.definitions.map((d) => (\n <option key={d.id} value={d.id}>\n {d.title}\n </option>\n ))}\n </select>\n )}\n <ParameterControls\n definition={definition}\n values={values}\n onChange={(name, value) => setValues((prev) => ({ ...prev, [name]: value }))}\n />\n </header>\n <div className=\"art-body\">\n <div className=\"art-map\" ref={mapRef}>\n <MapView\n definition={definition}\n graph={graph}\n values={values}\n annotations={annotated.annotations}\n onNodeSelect={(node) => setSelectedId(node.id)}\n />\n </div>\n {(selected || annotated.unattached.length > 0) && (\n <aside className=\"art-panel\" aria-label=\"Validation results\">\n {selected && (\n <section>\n <button type=\"button\" className=\"art-close\" aria-label=\"Close\" onClick={() => setSelectedId(undefined)}>\n ×\n </button>\n <p className=\"art-type\">{selected.resolvedType}</p>\n <h2>{selected.title}</h2>\n {results.length > 0 && (\n <>\n <h3>Validation</h3>\n <Results items={results} />\n </>\n )}\n <Fields data={selected.schemaData} />\n {selected.content && (\n <>\n <h3>Content</h3>\n <p className=\"art-content\">{selected.content}</p>\n </>\n )}\n {selected.source && <p className=\"art-muted\">{selected.source.file}</p>}\n </section>\n )}\n {annotated.unattached.length > 0 && (\n <section>\n <h3>Not on a node ({annotated.unattached.length})</h3>\n <Results items={annotated.unattached} />\n </section>\n )}\n </aside>\n )}\n </div>\n </div>\n );\n}\n\nconst SKIPPED_FIELDS = new Set(['title', 'type', 'content']);\nconst isEmpty = (v: unknown) => v === undefined || v === null || v === '' || (Array.isArray(v) && v.length === 0);\nconst asText = (v: unknown): string =>\n Array.isArray(v) ? v.map(asText).join(', ') : v !== null && typeof v === 'object' ? JSON.stringify(v) : String(v);\n\n/** The node's fields as a list; the title, type and body are shown elsewhere. */\nfunction Fields({ data }: { data: Record<string, unknown> }) {\n const fields = Object.entries(data).filter(([name, value]) => !SKIPPED_FIELDS.has(name) && !isEmpty(value));\n if (fields.length === 0) return null;\n return (\n <>\n <h3>Fields</h3>\n <dl className=\"art-fields\">\n {fields.map(([name, value]) => (\n <div key={name}>\n <dt>{name}</dt>\n <dd>{asText(value)}</dd>\n </div>\n ))}\n </dl>\n </>\n );\n}\n\nfunction Results({\n items,\n}: {\n items: readonly { severity: string; source: string; ruleId?: string; message: string; nodeId?: string }[];\n}) {\n return (\n <ul className=\"art-results\">\n {items.map((a, i) => (\n // biome-ignore lint/suspicious/noArrayIndexKey: a static list with no stable identity beyond position.\n <li key={i}>\n <span className={`art-severity art-${a.severity}`}>{a.severity}</span>{' '}\n <span className=\"art-muted\">{a.ruleId ? `${a.source} · ${a.ruleId}` : a.source}</span>\n {a.nodeId && <span className=\"art-muted\"> · {a.nodeId}</span>}\n <div>{a.message}</div>\n </li>\n ))}\n </ul>\n );\n}\n\n/**\n * Names each card for the viewer's comment mode, which reads the location of a comment from the\n * element's accessible name, which the viewer cuts at about 45 characters. Node ids are long (a file\n * and heading), so the name leads with the node's position in the stored graph, then its title and the\n * view: `[<index>] <title> · <view>`. An agent reading the comment takes `graph.nodes[<index>]` from the\n * db and checks the title.\n */\nfunction useNodeLabels(graph: ReturnType<typeof spaceGraphFrom>, definition: MapViewDefinition | undefined) {\n const ref = useRef<HTMLDivElement>(null);\n useEffect(() => {\n const root = ref.current;\n if (!root || !definition) return;\n const positions = new Map([...graph.nodes.keys()].map((id, index) => [id as string, index]));\n const view = definition.id.slice(definition.id.lastIndexOf('/') + 1);\n const stamp = () => {\n for (const card of root.querySelectorAll<HTMLElement>('[data-node-id]')) {\n const node = graph.nodes.get(card.dataset.nodeId as never);\n if (node) card.setAttribute('aria-label', `[${positions.get(node.id as string)}] ${node.title} · ${view}`);\n }\n };\n stamp();\n const observer = new MutationObserver(stamp);\n observer.observe(root, { childList: true, subtree: true });\n return () => observer.disconnect();\n }, [graph, definition]);\n return ref;\n}\n\ncreateRoot(document.getElementById('root')!).render(<App />);\n"],"mappings":";;;;;;AAaA,IAAM,SAAS;AACf,IAAM,aAAa;;AAOnB,eAAsB,aAAqC;CACzD,MAAM,SAAU,OAA2E;CAC3F,MAAM,KAAM,SAAS,MAAM,OAAO,IAAI,IAAI,IAAI;CAC9C,IAAI,CAAC,IAAI,MAAM,IAAI,MAAM,+EAA+E;CAExG,IAAI;CACJ,MAAM,UAAU,IAAI,SAAgB,GAAG,WAAW;EAChD,QAAQ,iBAAiB,uBAAO,IAAI,MAAM,0CAA0C,CAAC,GAAG,UAAU;CACpG,CAAC;CAED,MAAM,UAAS,MADQ,QAAQ,KAAK,CAAC,GAAG,WAAW,MAAM,CAAC,CAAC,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,cAAc,aAAa,KAAK,CAAC,EAAA,CACrF,KAAK,SAAS,QAAQ;EAC5C,MAAM,OAAO,IAAI,KA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T;AAEA,WAAW,SAAS,eAAe,MAAM,CAAE,CAAC,CAAC,OAAO,oBAAC,KAAD,CAAM,CAAA,CAAC"}
1
+ {"version":3,"file":"artifact.js","names":["_Fragment"],"sources":["../src/artifact/load.ts","../src/artifact/main.tsx"],"sourcesContent":["import type { spaceGraphFrom } from 'structured-context/browser';\nimport type { ValidationInput } from '../core/annotations';\nimport type { MapViewDefinition } from '../core/definition';\n\n/** A space as the artifact's db holds it: the `export` command's document with its parts as JSON strings. */\nexport type LoadedSpace = {\n name: string;\n schemaId: string | undefined;\n graph: Parameters<typeof spaceGraphFrom>[0];\n validation: ValidationInput;\n definitions: MapViewDefinition[];\n};\n\nconst SPACES = 'spaces';\nconst TIMEOUT_MS = 10_000;\n\ntype Db = {\n collection(path: string): { get(): Promise<{ docs: { id: string; data(): Record<string, unknown> | undefined }[] }> };\n};\n\n/** Every space written to the artifact's `spaces` collection. Rejects with a message fit to show the viewer. */\nexport async function loadSpaces(): Promise<LoadedSpace[]> {\n const claude = (window as unknown as { claude?: { use(name: string): Promise<unknown> } }).claude;\n const db = (claude ? await claude.use('db') : null) as Db | null;\n if (!db) throw new Error('This page needs the artifact database, which is not available to this viewer.');\n\n let timer: ReturnType<typeof setTimeout> | undefined;\n const timeout = new Promise<never>((_, reject) => {\n timer = setTimeout(() => reject(new Error('Reading the artifact database timed out.')), TIMEOUT_MS);\n });\n const snapshot = await Promise.race([db.collection(SPACES).get(), timeout]).finally(() => clearTimeout(timer));\n const spaces = snapshot.docs.flatMap((doc) => {\n const data = doc.data();\n return data ? [toSpace(doc.id, data)] : [];\n });\n if (spaces.length === 0)\n throw new Error(`Nothing to show yet: no space has been written to \"${SPACES}\" in the artifact database.`);\n return spaces;\n}\n\nfunction toSpace(name: string, data: Record<string, unknown>): LoadedSpace {\n const json = (field: string) => {\n const value = data[field];\n if (typeof value !== 'string') throw new Error(`Space \"${name}\": missing \"${field}\" in the artifact database.`);\n return JSON.parse(value);\n };\n return {\n name,\n schemaId: typeof data.schemaId === 'string' ? data.schemaId : undefined,\n graph: json('graph'),\n validation: json('validation'),\n definitions: json('definitions'),\n };\n}\n","import { useEffect, useMemo, useRef, useState } from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { spaceGraphFrom } from 'structured-context/browser';\nimport { annotationsFrom } from '../core/annotations';\nimport type { MapViewDefinition, ParameterValues } from '../core/definition';\nimport { MapView } from '../layouts/MapView';\nimport { ParameterControls } from '../layouts/ParameterControls';\nimport { type LoadedSpace, loadSpaces } from './load';\n\n/**\n * The host for a Claude artifact: renders the spaces the publishing agent wrote to the artifact's\n * db (the `export` command's document, one per space) with the parameter controls and a panel of\n * validation messages. It reads nothing else and ships as `dist/artifact.js`; `dist/artifact.html`\n * is the page that loads it. See docs/architecture.md.\n */\n\ntype State = { status: 'loading' } | { status: 'error'; message: string } | { status: 'ready'; spaces: LoadedSpace[] };\n\nfunction App() {\n const [state, setState] = useState<State>({ status: 'loading' });\n useEffect(() => {\n loadSpaces().then(\n (spaces) => setState({ status: 'ready', spaces }),\n (err) => setState({ status: 'error', message: err instanceof Error ? err.message : String(err) }),\n );\n }, []);\n if (state.status === 'loading') return <p className=\"art-message\">Loading from the artifact database…</p>;\n if (state.status === 'error') return <p className=\"art-message\">{state.message}</p>;\n return <Viewer spaces={state.spaces} />;\n}\n\nfunction Viewer({ spaces }: { spaces: LoadedSpace[] }) {\n const [spaceName, setSpaceName] = useState(spaces[0]!.name);\n const space = spaces.find((s) => s.name === spaceName)!;\n const [viewId, setViewId] = useState(space.definitions[0]?.id);\n const definition = space.definitions.find((d) => d.id === viewId) ?? space.definitions[0];\n const [values, setValues] = useState<ParameterValues>({});\n const [selectedId, setSelectedId] = useState<string>();\n\n const graph = useMemo(() => spaceGraphFrom(space.graph), [space]);\n const annotated = useMemo(() => annotationsFrom(space.validation, graph), [space, graph]);\n const mapRef = useNodeLabels(graph, definition);\n\n if (!definition) return <p className=\"art-message\">No map views apply to the schema of \"{space.name}\".</p>;\n const selected = selectedId ? graph.nodes.get(selectedId as never) : undefined;\n const results = selected ? (annotated.annotations.get(selected.id as never) ?? []) : [];\n\n return (\n <div className=\"art-root\">\n <header className=\"art-bar\">\n {spaces.length > 1 && (\n <select\n aria-label=\"Space\"\n value={spaceName}\n onChange={(e) => {\n const next = spaces.find((s) => s.name === e.target.value)!;\n setSpaceName(next.name);\n setViewId(next.definitions[0]?.id);\n setValues({});\n setSelectedId(undefined);\n }}\n >\n {spaces.map((s) => (\n <option key={s.name} value={s.name}>\n {s.name}\n </option>\n ))}\n </select>\n )}\n {space.definitions.length > 1 && (\n <select\n aria-label=\"Map view\"\n value={definition.id}\n onChange={(e) => {\n setViewId(e.target.value);\n setValues({});\n }}\n >\n {space.definitions.map((d) => (\n <option key={d.id} value={d.id}>\n {d.title}\n </option>\n ))}\n </select>\n )}\n <ParameterControls\n definition={definition}\n values={values}\n onChange={(name, value) => setValues((prev) => ({ ...prev, [name]: value }))}\n />\n </header>\n <div className=\"art-body\">\n <div className=\"art-map\" ref={mapRef}>\n <MapView\n definition={definition}\n graph={graph}\n values={values}\n annotations={annotated.annotations}\n onNodeSelect={(node) => setSelectedId(node.id)}\n />\n </div>\n {(selected || annotated.unattached.length > 0) && (\n <aside className=\"art-panel\" aria-label=\"Validation results\">\n {selected && (\n <section>\n <button type=\"button\" className=\"art-close\" aria-label=\"Close\" onClick={() => setSelectedId(undefined)}>\n ×\n </button>\n <p className=\"art-type\">{selected.resolvedType}</p>\n <h2>{selected.title}</h2>\n {results.length > 0 && (\n <>\n <h3>Validation</h3>\n <Results items={results} />\n </>\n )}\n <Fields data={selected.schemaData} />\n {selected.content && (\n <>\n <h3>Content</h3>\n <p className=\"art-content\">{selected.content}</p>\n </>\n )}\n {selected.source && <p className=\"art-muted\">{selected.source.file}</p>}\n </section>\n )}\n {annotated.unattached.length > 0 && (\n <section>\n <h3>Not on a node ({annotated.unattached.length})</h3>\n <Results items={annotated.unattached} />\n </section>\n )}\n </aside>\n )}\n </div>\n </div>\n );\n}\n\nconst SKIPPED_FIELDS = new Set(['title', 'type', 'content']);\nconst isEmpty = (v: unknown) => v === undefined || v === null || v === '' || (Array.isArray(v) && v.length === 0);\nconst asText = (v: unknown): string =>\n Array.isArray(v) ? v.map(asText).join(', ') : v !== null && typeof v === 'object' ? JSON.stringify(v) : String(v);\n\n/** The node's fields as a list; the title, type and body are shown elsewhere. */\nfunction Fields({ data }: { data: Record<string, unknown> }) {\n const fields = Object.entries(data).filter(([name, value]) => !SKIPPED_FIELDS.has(name) && !isEmpty(value));\n if (fields.length === 0) return null;\n return (\n <>\n <h3>Fields</h3>\n <dl className=\"art-fields\">\n {fields.map(([name, value]) => (\n <div key={name}>\n <dt>{name}</dt>\n <dd>{asText(value)}</dd>\n </div>\n ))}\n </dl>\n </>\n );\n}\n\nfunction Results({\n items,\n}: {\n items: readonly { severity: string; source: string; ruleId?: string; message: string; nodeId?: string }[];\n}) {\n return (\n <ul className=\"art-results\">\n {items.map((a, i) => (\n // biome-ignore lint/suspicious/noArrayIndexKey: a static list with no stable identity beyond position.\n <li key={i}>\n <span className={`art-severity art-${a.severity}`}>{a.severity}</span>{' '}\n <span className=\"art-muted\">{a.ruleId ? `${a.source} · ${a.ruleId}` : a.source}</span>\n {a.nodeId && <span className=\"art-muted\"> · {a.nodeId}</span>}\n <div>{a.message}</div>\n </li>\n ))}\n </ul>\n );\n}\n\n/**\n * Names each card for the viewer's comment mode, which reads the location of a comment from the\n * element's accessible name, which the viewer cuts at about 45 characters. Node ids are long (a file\n * and heading), so the name leads with the node's position in the stored graph, then its title and the\n * view: `[<index>] <title> · <view>`. An agent reading the comment takes `graph.nodes[<index>]` from the\n * db and checks the title.\n */\nfunction useNodeLabels(graph: ReturnType<typeof spaceGraphFrom>, definition: MapViewDefinition | undefined) {\n const ref = useRef<HTMLDivElement>(null);\n useEffect(() => {\n const root = ref.current;\n if (!root || !definition) return;\n const positions = new Map([...graph.nodes.keys()].map((id, index) => [id as string, index]));\n const view = definition.id.slice(definition.id.lastIndexOf('/') + 1);\n const stamp = () => {\n for (const card of root.querySelectorAll<HTMLElement>('[data-node-id]')) {\n const node = graph.nodes.get(card.dataset.nodeId as never);\n if (node) card.setAttribute('aria-label', `[${positions.get(node.id as string)}] ${node.title} · ${view}`);\n }\n };\n stamp();\n const observer = new MutationObserver(stamp);\n observer.observe(root, { childList: true, subtree: true });\n return () => observer.disconnect();\n }, [graph, definition]);\n return ref;\n}\n\ncreateRoot(document.getElementById('root')!).render(<App />);\n"],"mappings":";;;;;;;AAaA,IAAM,SAAS;AACf,IAAM,aAAa;;AAOnB,eAAsB,aAAqC;CACzD,MAAM,SAAU,OAA2E;CAC3F,MAAM,KAAM,SAAS,MAAM,OAAO,IAAI,IAAI,IAAI;CAC9C,IAAI,CAAC,IAAI,MAAM,IAAI,MAAM,+EAA+E;CAExG,IAAI;CACJ,MAAM,UAAU,IAAI,SAAgB,GAAG,WAAW;EAChD,QAAQ,iBAAiB,uBAAO,IAAI,MAAM,0CAA0C,CAAC,GAAG,UAAU;CACpG,CAAC;CAED,MAAM,UAAS,MADQ,QAAQ,KAAK,CAAC,GAAG,WAAW,MAAM,CAAC,CAAC,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,cAAc,aAAa,KAAK,CAAC,EAAA,CACrF,KAAK,SAAS,QAAQ;EAC5C,MAAM,OAAO,IAAI,KAAK;EACtB,OAAO,OAAO,CAAC,QAAQ,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC;CAC3C,CAAC;CACD,IAAI,OAAO,WAAW,GACpB,MAAM,IAAI,MAAM,sDAAsD,OAAO,4BAA4B;CAC3G,OAAO;AACT;AAEA,SAAS,QAAQ,MAAc,MAA4C;CACzE,MAAM,QAAQ,UAAkB;EAC9B,MAAM,QAAQ,KAAK;EACnB,IAAI,OAAO,UAAU,UAAU,MAAM,IAAI,MAAM,UAAU,KAAK,cAAc,MAAM,4BAA4B;EAC9G,OAAO,KAAK,MAAM,KAAK;CACzB;CACA,OAAO;EACL;EACA,UAAU,OAAO,KA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AA;EACnB,EAAA,GALK,CAKL,CACL;CACC,CAAA;AAER;;;;;;;;AASA,SAAS,cAAc,OAA0C,YAA2C;CAC1G,MAAM,MAAM,OAAuB,IAAI;CACvC,gBAAgB;EACd,MAAM,OAAO,IAAI;EACjB,IAAI,CAAC,QAAQ,CAAC,YAAY;EAC1B,MAAM,YAAY,IAAI,IAAI,CAAC,GAAG,MAAM,MAAM,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI,UAAU,CAAC,IAAc,KAAK,CAAC,CAAC;EAC3F,MAAM,OAAO,WAAW,GAAG,MAAM,WAAW,GAAG,YAAY,GAAG,IAAI,CAAC;EACnE,MAAM,cAAc;GAClB,KAAK,MAAM,QAAQ,KAAK,iBAA8B,gBAAgB,GAAG;IACvE,MAAM,OAAO,MAAM,MAAM,IAAI,KAAK,QAAQ,MAAe;IACzD,IAAI,MAAM,KAAK,aAAa,cAAc,IAAI,UAAU,IAAI,KAAK,EAAY,EAAE,IAAI,KAAK,MAAM,KAAK,MAAM;GAC3G;EACF;EACA,MAAM;EACN,MAAM,WAAW,IAAI,iBAAiB,KAAK;EAC3C,SAAS,QAAQ,MAAM;GAAE,WAAW;GAAM,SAAS;EAAK,CAAC;EACzD,aAAa,SAAS,WAAW;CACnC,GAAG,CAAC,OAAO,UAAU,CAAC;CACtB,OAAO;AACT;AAEA,WAAW,SAAS,eAAe,MAAM,CAAE,CAAC,CAAC,OAAO,oBAAC,KAAD,CAAM,CAAA,CAAC"}
package/dist/cli.js CHANGED
@@ -6,7 +6,7 @@ import { SctxError, assembleSpaceGraph, createSpaceContext, exportSpaceGraph, lo
6
6
  import { Command } from "commander";
7
7
  var package_default = {
8
8
  name: "structured-context-map-views",
9
- version: "0.3.1",
9
+ version: "0.4.0",
10
10
  description: "Declarative map views of structured-context spaces: render a space as a tree, nested containers or an XY plot from a short definition.",
11
11
  license: "MIT",
12
12
  type: "module",