structured-context-map-views 0.5.0 → 0.6.1

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.
@@ -0,0 +1,2 @@
1
+ declare const page: string;
2
+ export default page;
@@ -1,36 +1,22 @@
1
1
  //#region src/core/annotations.ts
2
- /**
3
- * Attach validation results to the nodes of `graph`, by node id. Results that can't be attached are
4
- * returned in `unattached` for the host to surface: global-scope rules (no node), and nodes that
5
- * aren't in the graph, which includes every node that failed its schema.
6
- */
2
+ /** Attach validation issues to the nodes of `graph`. Issues whose node isn't in the graph are `unattached`. */
7
3
  function annotationsFrom(input, graph) {
8
4
  const annotations = /* @__PURE__ */ new Map();
9
5
  const unattached = [];
10
- for (const [id, issues] of Object.entries(input.issues)) {
11
- const nodeId = id;
12
- for (const [key, { kind, message, severity, line, column }] of Object.entries(issues)) {
13
- const annotation = {
14
- severity,
15
- source: kind,
16
- message,
17
- ...kind === "rule" && key.startsWith("rule:") && { ruleId: key.slice(5) }
18
- };
19
- if (graph.nodes.has(nodeId)) annotations.set(nodeId, [...annotations.get(nodeId) ?? [], annotation]);
20
- else unattached.push({
21
- ...annotation,
22
- nodeId,
23
- ...line !== void 0 && { line },
24
- ...column !== void 0 && { column }
25
- });
26
- }
6
+ for (const { kind, severity, message, nodeId, source, ruleId } of input.issues) {
7
+ const annotation = {
8
+ severity,
9
+ source: kind,
10
+ message,
11
+ ...kind === "rule" && ruleId !== void 0 && { ruleId }
12
+ };
13
+ if (nodeId !== void 0 && graph.nodes.has(nodeId)) annotations.set(nodeId, [...annotations.get(nodeId) ?? [], annotation]);
14
+ else unattached.push({
15
+ ...annotation,
16
+ ...nodeId !== void 0 && { nodeId },
17
+ ...source !== void 0 && { location: source }
18
+ });
27
19
  }
28
- for (const { nodeId, description, severity, ruleId } of input.ruleViolations ?? []) if (nodeId === void 0) unattached.push({
29
- severity,
30
- source: "rule",
31
- message: description,
32
- ruleId
33
- });
34
20
  return {
35
21
  annotations,
36
22
  unattached
@@ -382,4 +368,4 @@ function assignLanes(links) {
382
368
  //#endregion
383
369
  export { annotationsFrom as a, treeLinks as i, buildLandscape as n, filterAnnotations as o, buildTree as r, worstSeverity as s, buildXYPlot as t };
384
370
 
385
- //# sourceMappingURL=projection-CYShQhug.js.map
371
+ //# sourceMappingURL=projection-C-dATsdO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projection-C-dATsdO.js","names":[],"sources":["../src/core/annotations.ts","../src/core/graph.ts","../src/core/occurrence.ts","../src/core/tree.ts","../src/core/landscape.ts","../src/core/xy.ts"],"sourcesContent":["import type { RuleSeverity, SpaceGraph, SpaceNode, ValidationResult } from 'structured-context/api';\nimport type { SourceLocation, ValidationIssueKind } from 'structured-context/types';\n\n// core doesn't export NodeId from `structured-context/api` yet; this derives it.\ntype NodeId = SpaceNode['id'];\n\n/** structured-context's severity. */\nexport type Severity = RuleSeverity;\n\n/** structured-context's issue `kind`. */\nexport type AnnotationSource = ValidationIssueKind;\n\n/** One validation result attached to a node. */\nexport type NodeAnnotation = {\n severity: Severity;\n source: AnnotationSource;\n message: string;\n /** The violated rule, for `rule` results. */\n ruleId?: string;\n};\n\n/** A validation result with no node on the map to attach to. */\nexport type UnattachedAnnotation = NodeAnnotation & {\n nodeId?: NodeId;\n location?: SourceLocation;\n};\n\n/** Annotations by the id of the node they apply to. */\nexport type AnnotationIndex = ReadonlyMap<NodeId, readonly NodeAnnotation[]>;\n\ntype Issue = ValidationResult['issues'][number];\n\n/** A `ValidationResult`, or the output of `sctx validate --json`. */\nexport type ValidationInput = {\n issues: ReadonlyArray<Pick<Issue, 'kind' | 'severity' | 'message' | 'nodeId' | 'source'> & { ruleId?: string }>;\n};\n\n/** Attach validation issues to the nodes of `graph`. Issues whose node isn't in the graph are `unattached`. */\nexport function annotationsFrom(\n input: ValidationInput,\n graph: SpaceGraph,\n): { annotations: AnnotationIndex; unattached: UnattachedAnnotation[] } {\n const annotations = new Map<NodeId, NodeAnnotation[]>();\n const unattached: UnattachedAnnotation[] = [];\n\n for (const { kind, severity, message, nodeId, source, ruleId } of input.issues) {\n const annotation: NodeAnnotation = {\n severity,\n source: kind,\n message,\n ...(kind === 'rule' && ruleId !== undefined && { ruleId }),\n };\n if (nodeId !== undefined && graph.nodes.has(nodeId)) {\n annotations.set(nodeId, [...(annotations.get(nodeId) ?? []), annotation]);\n } else {\n unattached.push({\n ...annotation,\n ...(nodeId !== undefined && { nodeId }),\n ...(source !== undefined && { location: source }),\n });\n }\n }\n return { annotations, unattached };\n}\n\nconst RANK: Record<Severity, number> = { error: 0, warning: 1, info: 2 };\n\n/** The most serious severity among annotations, or undefined if there are none. */\nexport function worstSeverity(annotations: readonly NodeAnnotation[]): Severity | undefined {\n return annotations.reduce<Severity | undefined>(\n (worst, { severity }) => (worst === undefined || RANK[severity] < RANK[worst] ? severity : worst),\n undefined,\n );\n}\n\n/**\n * The annotations a map view shows: those at `level` or more serious, from `sources`. `off` shows none.\n * Nodes left with no annotations are dropped from the index.\n */\nexport function filterAnnotations(\n index: AnnotationIndex,\n level: Severity | 'off',\n sources: readonly AnnotationSource[],\n): AnnotationIndex {\n if (level === 'off') return new Map();\n const filtered = new Map<NodeId, readonly NodeAnnotation[]>();\n for (const [id, annotations] of index) {\n const kept = annotations.filter((a) => RANK[a.severity] <= RANK[level] && sources.includes(a.source));\n if (kept.length > 0) filtered.set(id, kept);\n }\n return filtered;\n}\n","import type { Hierarchy, SpaceGraph, SpaceNode } from 'structured-context/api';\n\ntype NodeId = SpaceNode['id'];\n\n/** A directed parent → child edge of a space graph, carrying the metadata of the reference it came from. */\nexport type Edge = SpaceGraph['parentEdges'] extends ReadonlyMap<string, readonly (infer E)[]> ? E : never;\n\nconst NONE: readonly Edge[] = [];\n\n/**\n * Edges to a node's parents, in the order the node declares them. A graph narrowed by a filter keeps\n * edges to parents outside it; those are left out.\n */\nexport function parentEdges(graph: SpaceGraph, id: NodeId): readonly Edge[] {\n return (graph.parentEdges.get(id) ?? NONE).filter((edge) => graph.nodes.has(edge.parent));\n}\n\n/** Edges to a node's children, in graph order of the children. */\nexport function childEdges(graph: SpaceGraph, id: NodeId): readonly Edge[] {\n return graph.childEdges.get(id) ?? NONE;\n}\n\n/** Every edge whose parent and child are both in the graph. */\nexport function edgesWithin(graph: SpaceGraph): Edge[] {\n return [...graph.nodes.keys()].flatMap((id) => parentEdges(graph, id));\n}\n\n/** Whether an edge belongs to the given hierarchy (as opposed to a relationship or another hierarchy). */\nexport function isHierarchyEdge(edge: Edge, hierarchy: Hierarchy | undefined): boolean {\n return hierarchy !== undefined && edge.kind === 'hierarchy' && edge.hierarchy === hierarchy.name;\n}\n","/**\n * One step of an occurrence path: a node title, a `[field, value]` group, or `null` for the\n * ungrouped area. Encoded distinctly, so a field group can't collide with a node of the same name.\n */\nexport type PathSegment = string | readonly [field: string, value: string | null] | null;\n\n/**\n * Path-based key for one occurrence of a node: region, then the steps from the outermost\n * container down to the node. Unique within a map view even when a node appears several times.\n * Hosts can render several map views at once, so layouts scope keys to the map view instance.\n */\nexport function occurrenceKey(regionId: string, path: readonly PathSegment[]): string {\n return JSON.stringify([regionId, ...path]);\n}\n","import type { SpaceGraph, SpaceNode } from 'structured-context/api';\nimport type { DagMode } from './definition';\nimport { childEdges, isHierarchyEdge, parentEdges } from './graph';\nimport { occurrenceKey } from './occurrence';\n\n/** One rendered appearance of a node in a tree. */\nexport type TreeOccurrence = {\n /** Path-based key, unique within the map view (see {@link occurrenceKey}). */\n key: string;\n node: SpaceNode;\n children: TreeOccurrence[];\n /**\n * Key of the node's primary occurrence when this is a repeat. A node with several parents\n * appears under each of them, but its subtree is only rendered at its first occurrence.\n */\n repeatOf?: string;\n};\n\nexport type Tree = {\n roots: TreeOccurrence[];\n /**\n * Hierarchy-typed nodes not reachable from a root, rendered as extra roots: nodes with no\n * hierarchy parent in the space, then entry points into otherwise unreachable cycles.\n */\n orphans: TreeOccurrence[];\n /** Key of each node's primary (first, fully rendered) occurrence. */\n primary: ReadonlyMap<string, string>;\n /**\n * In cross-edge mode, links from a node's other parents to its primary occurrence, which\n * replace repeat occurrences. Empty in repeat mode.\n */\n crossLinks: TreeLink[];\n};\n\nexport type TreeLink = { from: string; to: string; kind: 'tree' | 'cross' };\n\n/**\n * Lay a space out as a tree over its hierarchy.\n *\n * Roots are root-type nodes with no hierarchy parent. Traversal is depth-first in space order,\n * so a node's primary occurrence is under the parent reached first. Under its other parents a\n * node is either repeated without its subtree (`repeat`), or left out and linked by a cross-edge\n * (`cross-edge`). Either way traversal stops there, which also keeps cycles from recursing.\n */\nexport function buildTree(graph: SpaceGraph, regionId: string, dag: DagMode = 'repeat'): Tree {\n const { hierarchy } = graph;\n const levelTypes = new Set(hierarchy?.levels.map((level) => level.type));\n const rootType = hierarchy?.levels[0]?.type;\n const primary = new Map<string, string>();\n // Parent occurrence → child title, resolved to the child's primary occurrence afterwards.\n const pendingCross: { from: string; child: string }[] = [];\n\n const hierarchyParents = (title: SpaceNode['id']) =>\n parentEdges(graph, title).filter((edge) => isHierarchyEdge(edge, hierarchy));\n\n const visit = (node: SpaceNode, path: readonly string[]): TreeOccurrence => {\n const nodePath = [...path, node.id];\n const key = occurrenceKey(regionId, nodePath);\n primary.set(node.id, key);\n // A child can reference the same parent through more than one field; it occurs once.\n const childTitles = new Set(\n childEdges(graph, node.id)\n .filter((edge) => isHierarchyEdge(edge, hierarchy))\n .map((edge) => edge.child),\n );\n const children: TreeOccurrence[] = [];\n for (const title of childTitles) {\n const child = graph.nodes.get(title)!;\n const repeatOf = primary.get(title);\n if (repeatOf === undefined) children.push(visit(child, nodePath));\n else if (dag === 'repeat')\n children.push({ key: occurrenceKey(regionId, [...nodePath, title]), node: child, children: [], repeatOf });\n else pendingCross.push({ from: key, child: title });\n }\n return { key, node, children };\n };\n\n const levelNodes = [...graph.nodes.values()].filter((node) => levelTypes.has(node.resolvedType));\n const unparented = levelNodes.filter((node) => hierarchyParents(node.id).length === 0);\n const roots = unparented.filter((node) => node.resolvedType === rootType).map((node) => visit(node, []));\n const orphans = unparented.filter((node) => node.resolvedType !== rootType).map((node) => visit(node, []));\n // Nodes only reachable through a cycle have a parent but no path from a root. Rather than\n // drop them, enter each such cycle at its first node in space order.\n for (const node of levelNodes) {\n if (!primary.has(node.id)) orphans.push(visit(node, []));\n }\n\n const crossLinks = pendingCross.map(({ from, child }) => ({ from, to: primary.get(child)!, kind: 'cross' as const }));\n return { roots, orphans, primary, crossLinks };\n}\n\n/** Parent → child pairs of occurrence keys: one per rendered parent-child link, then cross-links. */\nexport function treeLinks(tree: Tree): TreeLink[] {\n const links: TreeLink[] = [];\n const walk = (occurrence: TreeOccurrence) => {\n for (const child of occurrence.children) {\n links.push({ from: occurrence.key, to: child.key, kind: 'tree' });\n walk(child);\n }\n };\n for (const root of [...tree.roots, ...tree.orphans]) walk(root);\n return [...links, ...tree.crossLinks];\n}\n","import type { SpaceGraph, SpaceNode } from 'structured-context/api';\nimport type { GroupLevel, LandscapeLayoutConfig } from './definition';\nimport { childEdges, parentEdges } from './graph';\nimport { occurrenceKey, type PathSegment } from './occurrence';\n\n/** One rendered container or node in a landscape. */\nexport type LandscapeOccurrence = {\n /** Path-based key, unique within the map view (see {@link occurrenceKey}). */\n key: string;\n /** Index of the grouping level this occurrence belongs to. */\n level: number;\n /** A node, or a field value shared by the nodes inside (`null`: the field is empty). */\n item: { kind: 'node'; node: SpaceNode } | { kind: 'value'; field: string; value: string | null };\n /** Nodes on the `via` chain that joined this node to the node level above, one entry per skipped type. */\n via: ViaStep[];\n /** Key of the node's first occurrence when this is a repeat. Repeats are rendered in full. */\n repeatOf?: string;\n children: LandscapeOccurrence[];\n};\n\nexport type ViaStep = { type: string; nodes: SpaceNode[] };\n\nexport type Landscape = {\n groups: LandscapeOccurrence[];\n /**\n * Nodes of a grouped level that no container above reaches (e.g. an Activity with no\n * Outcome when grouping by Outcomes), each with its own contents.\n */\n ungrouped: LandscapeOccurrence[];\n};\n\ntype Candidate = { node: SpaceNode; via: ViaStep[] };\ntype FieldFilter = { field: string; value: string | null };\n\n/**\n * Lay a space out as nested containers following the layout's grouping levels.\n *\n * Adjacent node levels are joined by any edge between their types, in either direction, or only\n * edges from `edge.field`. A `via` chain joins them through the skipped types. A field level\n * splits the next node level by that field's values. A node reached from several containers\n * appears in each, in full: the levels are finite, so repeating contents can't recurse.\n */\nexport function buildLandscape(graph: SpaceGraph, regionId: string, layout: LandscapeLayoutConfig): Landscape {\n const levels = layout.group;\n const order = new Map([...graph.nodes.keys()].map((title, i) => [title, i]));\n const first = new Map<string, string>();\n\n const occurrenceFor = (candidate: Candidate, levelIdx: number, path: readonly PathSegment[]): LandscapeOccurrence => {\n const { node } = candidate;\n const nodePath = [...path, node.id];\n const key = occurrenceKey(regionId, nodePath);\n const repeatOf = first.get(node.id);\n if (repeatOf === undefined) first.set(node.id, key);\n return {\n key,\n level: levelIdx,\n item: { kind: 'node', node },\n via: candidate.via,\n ...(repeatOf !== undefined && { repeatOf }),\n children: place(levelIdx + 1, node, [], nodePath),\n };\n };\n\n /** Occurrences for level `levelIdx` inside `anchor`, the nearest enclosing node. */\n const place = (\n levelIdx: number,\n anchor: SpaceNode | undefined,\n filters: readonly FieldFilter[],\n path: readonly PathSegment[],\n ): LandscapeOccurrence[] => {\n const level = levels[levelIdx];\n if (level === undefined) return [];\n if (isTypeLevel(level)) {\n return candidates(level, anchor, filters).map((c) => occurrenceFor(c, levelIdx, path));\n }\n\n const nodeLevel = levels.slice(levelIdx).find(isTypeLevel)!;\n const values = distinctValues(\n candidates(nodeLevel, anchor, filters).map((c) => c.node),\n level.field,\n );\n return values.map((value) => {\n const valuePath = [...path, [level.field, value] as const];\n return {\n key: occurrenceKey(regionId, valuePath),\n level: levelIdx,\n item: { kind: 'value', field: level.field, value },\n via: [],\n children: place(levelIdx + 1, anchor, [...filters, { field: level.field, value }], valuePath),\n };\n });\n };\n\n /** Nodes of a type level joined to `anchor` (all of the type at the top) and matching the filters. */\n const candidates = (\n level: TypeLevel,\n anchor: SpaceNode | undefined,\n filters: readonly FieldFilter[],\n ): Candidate[] => {\n const reached: Candidate[] =\n anchor === undefined\n ? ofType(level.type).map((node) => ({ node, via: [] }))\n : walkChain(anchor, level.via ?? [], level.type, level.edge?.field);\n return reached.filter(({ node }) => filters.every((f) => hasValue(node, f)));\n };\n\n const ofType = (type: string) => [...graph.nodes.values()].filter((node) => node.resolvedType === type);\n\n /** Neighbours of a node with the given type, across edges in either direction, in space order. */\n const neighbours = (title: SpaceNode['id'], type: string, field: string | undefined): SpaceNode[] => {\n const titles = new Set([\n ...childEdges(graph, title)\n .filter((e) => field === undefined || e.field === field)\n .map((e) => e.child),\n ...parentEdges(graph, title)\n .filter((e) => field === undefined || e.field === field)\n .map((e) => e.parent),\n ]);\n return [...titles]\n .map((t) => graph.nodes.get(t)!)\n .filter((node) => node.resolvedType === type)\n .sort((a, b) => order.get(a.id)! - order.get(b.id)!);\n };\n\n /**\n * Follow edges from `anchor` through each `via` type to `target`, keeping the skipped nodes on\n * the way to each target node. Several chains to one target merge into one candidate.\n */\n const walkChain = (anchor: SpaceNode, via: readonly string[], target: string, field: string | undefined) => {\n let frontier = [{ node: anchor, trail: [] as SpaceNode[] }];\n for (const type of via) {\n frontier = frontier.flatMap(({ node, trail }) =>\n neighbours(node.id, type, undefined).map((next) => ({ node: next, trail: [...trail, next] })),\n );\n }\n const byTitle = new Map<string, Candidate>();\n for (const { node, trail } of frontier) {\n for (const next of neighbours(node.id, target, field)) {\n const candidate = byTitle.get(next.id) ?? { node: next, via: via.map((type) => ({ type, nodes: [] })) };\n trail.forEach((skipped, i) => {\n const step = candidate.via[i]!;\n if (!step.nodes.includes(skipped)) step.nodes.push(skipped);\n });\n byTitle.set(next.id, candidate);\n }\n }\n return [...byTitle.values()].sort((a, b) => order.get(a.node.id)! - order.get(b.node.id)!);\n };\n\n const groups = place(0, undefined, [], []);\n\n // Nodes of an inner level that no container reached get their own contents, like tree orphans.\n const ungrouped: LandscapeOccurrence[] = [];\n levels.forEach((level, levelIdx) => {\n if (levelIdx === 0 || !isTypeLevel(level)) return;\n for (const node of ofType(level.type)) {\n if (!first.has(node.id)) ungrouped.push(occurrenceFor({ node, via: [] }, levelIdx, [null]));\n }\n });\n\n return { groups, ungrouped };\n}\n\ntype TypeLevel = Extract<GroupLevel, { type: string }>;\n\nfunction isTypeLevel(level: GroupLevel): level is TypeLevel {\n return 'type' in level;\n}\n\n/** A field's values as group labels: strings, an entry per array item, `null` when empty. */\nfunction valuesOf(node: SpaceNode, field: string): (string | null)[] {\n const raw = node.schemaData[field];\n const list = (Array.isArray(raw) ? raw : [raw]).filter((v) => v !== undefined && v !== null && v !== '');\n return list.length === 0 ? [null] : list.map((v) => (typeof v === 'object' ? JSON.stringify(v) : String(v)));\n}\n\n/** Distinct values in first-seen order, with the empty group last. */\nfunction distinctValues(nodes: SpaceNode[], field: string): (string | null)[] {\n const values = new Set(nodes.flatMap((node) => valuesOf(node, field)));\n const present = [...values].filter((v): v is string => v !== null);\n return values.has(null) ? [...present, null] : present;\n}\n\nfunction hasValue(node: SpaceNode, { field, value }: FieldFilter): boolean {\n return valuesOf(node, field).includes(value);\n}\n","import type { SpaceGraph, SpaceNode } from 'structured-context/api';\nimport type { AxisConfig, XYLayoutConfig } from './definition';\nimport { edgesWithin, isHierarchyEdge } from './graph';\nimport { occurrenceKey } from './occurrence';\n\n/** A plotted node. `x` and `y` run from 0 to 1 across the plot, left to right and bottom to top. */\nexport type XYPoint = { key: string; node: SpaceNode; x: number; y: number };\n\n/** Why a node of a plotted type couldn't be placed, per axis. */\nexport type Unplaced = { key: string; node: SpaceNode; reasons: string[] };\n\n/**\n * An edge between plotted nodes. `lane` separates edges joining the same two nodes: 0 when\n * there's one, otherwise centred around 0 (e.g. -0.5 and 0.5), for layouts to draw side by side.\n */\nexport type XYLink = { from: string; to: string; field: string; hierarchy: boolean; lane: number };\n\nexport type XYPlot = {\n points: XYPoint[];\n unplaced: Unplaced[];\n /** Edges between plotted nodes. */\n links: XYLink[];\n /** Each axis's [min, max]; `direction` says which end is drawn where. */\n domains: { x: readonly [number, number]; y: readonly [number, number] };\n};\n\n/**\n * Position nodes by two numeric fields. Every node of a plotted type appears once: on the plot\n * when both its values are numbers inside the axes' domains, otherwise in `unplaced` with the\n * reason. Positions are normalised; layouts decide the plot's size.\n */\nexport function buildXYPlot(graph: SpaceGraph, regionId: string, layout: XYLayoutConfig): XYPlot {\n const { x, y } = layout;\n const nodes = [...graph.nodes.values()];\n const types = new Set(\n layout.types.length > 0\n ? layout.types\n : nodes\n .filter((n) => isNumber(n.schemaData[x.field]) || isNumber(n.schemaData[y.field]))\n .map((n) => n.resolvedType),\n );\n const plotted = nodes.filter((n) => types.has(n.resolvedType));\n\n const domains = {\n x: domainOf(x, plotted),\n y: domainOf(y, plotted),\n };\n\n const points: XYPoint[] = [];\n const unplaced: Unplaced[] = [];\n for (const node of plotted) {\n const key = occurrenceKey(regionId, [node.id]);\n const px = position(node, x, domains.x);\n const py = position(node, y, domains.y);\n if (typeof px === 'number' && typeof py === 'number') points.push({ key, node, x: px, y: py });\n else unplaced.push({ key, node, reasons: [px, py].filter((r): r is string => typeof r === 'string') });\n }\n\n const keys = new Map<string, string>(points.map((p) => [p.node.id, p.key]));\n const fields = new Set(layout.edgeFields);\n const links = edgesWithin(graph)\n .filter((e) => keys.has(e.parent) && keys.has(e.child) && (fields.size === 0 || fields.has(e.field)))\n .map((e) => ({\n from: keys.get(e.parent)!,\n to: keys.get(e.child)!,\n field: e.field,\n hierarchy: isHierarchyEdge(e, graph.hierarchy),\n lane: 0,\n }));\n assignLanes(links);\n\n return { points, unplaced, links, domains };\n}\n\nfunction isNumber(value: unknown): value is number {\n return typeof value === 'number' && Number.isFinite(value);\n}\n\n/** The axis's fixed domain, or the range of plotted values (widened when they're all equal). */\nfunction domainOf(axis: AxisConfig, nodes: readonly SpaceNode[]): readonly [number, number] {\n if (Array.isArray(axis.domain)) return [axis.domain[0]!, axis.domain[1]!];\n const values = nodes.map((n) => n.schemaData[axis.field]).filter(isNumber);\n if (values.length === 0) return [0, 1];\n const min = Math.min(...values);\n const max = Math.max(...values);\n return min === max ? [min - 1, max + 1] : [min, max];\n}\n\n/** The node's normalised position on the axis, or why it has none. */\nfunction position(node: SpaceNode, axis: AxisConfig, [min, max]: readonly [number, number]): number | string {\n const value = node.schemaData[axis.field];\n if (value === undefined || value === null) return `no ${axis.field}`;\n if (!isNumber(value)) return `${axis.field} is not a number`;\n if (value < min || value > max) return `${axis.field} ${value} is outside ${min}–${max}`;\n const t = (value - min) / (max - min);\n return axis.direction === 'descending' ? 1 - t : t;\n}\n\n/** Spread links joining the same pair of nodes (in either direction) into lanes around 0. */\nfunction assignLanes(links: XYLink[]) {\n const byPair = new Map<string, XYLink[]>();\n for (const link of links) {\n const pair = [link.from, link.to].sort().join('\\n');\n byPair.set(pair, [...(byPair.get(pair) ?? []), link]);\n }\n for (const group of byPair.values()) {\n group.forEach((link, i) => {\n link.lane = i - (group.length - 1) / 2;\n });\n }\n}\n"],"mappings":";;AAsCA,SAAgB,gBACd,OACA,OACsE;CACtE,MAAM,8BAAc,IAAI,IAA8B;CACtD,MAAM,aAAqC,CAAC;CAE5C,KAAK,MAAM,EAAE,MAAM,UAAU,SAAS,QAAQ,QAAQ,YAAY,MAAM,QAAQ;EAC9E,MAAM,aAA6B;GACjC;GACA,QAAQ;GACR;GACA,GAAI,SAAS,UAAU,WAAW,KAAA,KAAa,EAAE,OAAO;EAC1D;EACA,IAAI,WAAW,KAAA,KAAa,MAAM,MAAM,IAAI,MAAM,GAChD,YAAY,IAAI,QAAQ,CAAC,GAAI,YAAY,IAAI,MAAM,KAAK,CAAC,GAAI,UAAU,CAAC;OAExE,WAAW,KAAK;GACd,GAAG;GACH,GAAI,WAAW,KAAA,KAAa,EAAE,OAAO;GACrC,GAAI,WAAW,KAAA,KAAa,EAAE,UAAU,OAAO;EACjD,CAAC;CAEL;CACA,OAAO;EAAE;EAAa;CAAW;AACnC;AAEA,IAAM,OAAiC;CAAE,OAAO;CAAG,S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AAA,KAAa,UAAU,MAAM,OAAO,MAAM,KAAK;CAC7D,IAAI,CAAC,SAAS,KAAK,GAAG,OAAO,GAAG,KAAK,MAAM;CAC3C,IAAI,QAAQ,OAAO,QAAQ,KAAK,OAAO,GAAG,KAAK,MAAM,GAAG,MAAM,cAAc,IAAI,GAAG;CACnF,MAAM,KAAK,QAAQ,QAAQ,MAAM;CACjC,OAAO,KAAK,cAAc,eAAe,IAAI,IAAI;AACnD;;AAGA,SAAS,YAAY,OAAiB;CACpC,MAAM,yBAAS,IAAI,IAAsB;CACzC,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,OAAO,CAAC,KAAK,MAAM,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,IAAI;EAClD,OAAO,IAAI,MAAM,CAAC,GAAI,OAAO,IAAI,IAAI,KAAK,CAAC,GAAI,IAAI,CAAC;CACtD;CACA,KAAK,MAAM,SAAS,OAAO,OAAO,GAChC,MAAM,SAAS,MAAM,MAAM;EACzB,KAAK,OAAO,KAAK,MAAM,SAAS,KAAK;CACvC,CAAC;AAEL"}
@@ -1,13 +1,6 @@
1
- import type { spaceGraphFrom } from 'structured-context/browser';
2
- import type { ValidationInput } from '../core/annotations';
3
- import type { MapViewDefinition } from '../core/definition';
4
- /** A space as the artifact's db holds it: the `export` command's document with its parts as JSON strings. */
5
- export type LoadedSpace = {
6
- name: string;
7
- schemaId: string | undefined;
8
- graph: Parameters<typeof spaceGraphFrom>[0];
9
- validation: ValidationInput;
10
- definitions: MapViewDefinition[];
11
- };
12
- /** Every space written to the artifact's `spaces` collection. Rejects with a message fit to show the viewer. */
13
- export declare function loadSpaces(): Promise<LoadedSpace[]>;
1
+ import type { SpaceSnapshot } from '../core/snapshot';
2
+ /**
3
+ * Every space written to the artifact's `spaces` collection: the `export` command's document, keyed by space
4
+ * name, with its parts as JSON strings. Rejects with a message fit to show the viewer.
5
+ */
6
+ export declare function loadSpaces(): Promise<SpaceSnapshot[]>;
@@ -1,9 +1,9 @@
1
- import type { nodeIssues, RuleSeverity, SpaceGraph, SpaceNode, ValidationResult } from 'structured-context/api';
2
- import type { ValidationIssueKind } from 'structured-context/types';
1
+ import type { RuleSeverity, SpaceGraph, SpaceNode, ValidationResult } from 'structured-context/api';
2
+ import type { SourceLocation, ValidationIssueKind } from 'structured-context/types';
3
3
  type NodeId = SpaceNode['id'];
4
- /** How serious a result is: structured-context's rule severity, which every result carries. */
4
+ /** structured-context's severity. */
5
5
  export type Severity = RuleSeverity;
6
- /** The kind of check a result came from: structured-context's issue `kind`. */
6
+ /** structured-context's issue `kind`. */
7
7
  export type AnnotationSource = ValidationIssueKind;
8
8
  /** One validation result attached to a node. */
9
9
  export type NodeAnnotation = {
@@ -15,28 +15,19 @@ export type NodeAnnotation = {
15
15
  };
16
16
  /** A validation result with no node on the map to attach to. */
17
17
  export type UnattachedAnnotation = NodeAnnotation & {
18
- /** The node it concerns. Absent for a global-scope rule. A node that failed its schema isn't in the graph. */
19
18
  nodeId?: NodeId;
20
- /** Where in that node's file the result points, if known (1-indexed). */
21
- line?: number;
22
- column?: number;
19
+ location?: SourceLocation;
23
20
  };
24
21
  /** Annotations by the id of the node they apply to. */
25
22
  export type AnnotationIndex = ReadonlyMap<NodeId, readonly NodeAnnotation[]>;
26
- /**
27
- * Validation results to attach: each node's issues, from structured-context's `nodeIssues(result)` or the
28
- * `issues` of `sctx validate --json`, and the rule violations, of which only those without a node are read
29
- * (the others are in `issues`). `sctx validate --json` output can be passed as it is.
30
- */
23
+ type Issue = ValidationResult['issues'][number];
24
+ /** A `ValidationResult`, or the output of `sctx validate --json`. */
31
25
  export type ValidationInput = {
32
- issues: Readonly<ReturnType<typeof nodeIssues>>;
33
- ruleViolations?: ReadonlyArray<Pick<ValidationResult['ruleViolations'][number], 'nodeId' | 'ruleId' | 'severity' | 'description'>>;
26
+ issues: ReadonlyArray<Pick<Issue, 'kind' | 'severity' | 'message' | 'nodeId' | 'source'> & {
27
+ ruleId?: string;
28
+ }>;
34
29
  };
35
- /**
36
- * Attach validation results to the nodes of `graph`, by node id. Results that can't be attached are
37
- * returned in `unattached` for the host to surface: global-scope rules (no node), and nodes that
38
- * aren't in the graph, which includes every node that failed its schema.
39
- */
30
+ /** Attach validation issues to the nodes of `graph`. Issues whose node isn't in the graph are `unattached`. */
40
31
  export declare function annotationsFrom(input: ValidationInput, graph: SpaceGraph): {
41
32
  annotations: AnnotationIndex;
42
33
  unattached: UnattachedAnnotation[];
@@ -149,7 +149,7 @@ export declare const definitionSchema: {
149
149
  };
150
150
  readonly validationSources: {
151
151
  readonly description: string;
152
- readonly default: readonly ["schema", "duplicate", "broken-link", "hierarchy", "rule", "gated", "content-link"];
152
+ readonly default: readonly ["parse", "schema", "duplicate", "broken-link", "hierarchy", "rule", "gated", "content-link"];
153
153
  readonly anyOf: readonly [{
154
154
  readonly $ref: "https://raw.githubusercontent.com/mindsocket/structured-context-map-views/main/schemas/generated/latest/settings.json#/$defs/validationSources";
155
155
  }, {
@@ -150,7 +150,7 @@ export declare const MAP_VIEW_SCHEMAS: readonly [{
150
150
  };
151
151
  readonly validationSources: {
152
152
  readonly description: string;
153
- readonly default: readonly ["schema", "duplicate", "broken-link", "hierarchy", "rule", "gated", "content-link"];
153
+ readonly default: readonly ["parse", "schema", "duplicate", "broken-link", "hierarchy", "rule", "gated", "content-link"];
154
154
  readonly anyOf: readonly [{
155
155
  readonly $ref: "https://raw.githubusercontent.com/mindsocket/structured-context-map-views/main/schemas/generated/latest/settings.json#/$defs/validationSources";
156
156
  }, {
@@ -203,7 +203,7 @@ export declare const MAP_VIEW_SCHEMAS: readonly [{
203
203
  readonly description: 'Which kinds of validation result are shown. schema: a node failing its schema. duplicate: an id more than one node uses. broken-link: a relationship to a node that does not exist. hierarchy: a node under a parent type it is not allowed under. rule: a schema rule violation. gated: a note that rules were not checked because an ancestor failed. content-link: a link in the body that resolves to no node.';
204
204
  readonly type: 'array';
205
205
  readonly items: {
206
- readonly enum: readonly ["schema", "duplicate", "broken-link", "hierarchy", "rule", "gated", "content-link"];
206
+ readonly enum: readonly ["parse", "schema", "duplicate", "broken-link", "hierarchy", "rule", "gated", "content-link"];
207
207
  };
208
208
  readonly uniqueItems: true;
209
209
  };
@@ -24,7 +24,7 @@ export declare const settingsSchema: {
24
24
  readonly description: 'Which kinds of validation result are shown. schema: a node failing its schema. duplicate: an id more than one node uses. broken-link: a relationship to a node that does not exist. hierarchy: a node under a parent type it is not allowed under. rule: a schema rule violation. gated: a note that rules were not checked because an ancestor failed. content-link: a link in the body that resolves to no node.';
25
25
  readonly type: 'array';
26
26
  readonly items: {
27
- readonly enum: readonly ["schema", "duplicate", "broken-link", "hierarchy", "rule", "gated", "content-link"];
27
+ readonly enum: readonly ["parse", "schema", "duplicate", "broken-link", "hierarchy", "rule", "gated", "content-link"];
28
28
  };
29
29
  readonly uniqueItems: true;
30
30
  };
@@ -0,0 +1,15 @@
1
+ import type { spaceGraphFrom } from 'structured-context/browser';
2
+ import type { ValidationInput } from './annotations';
3
+ import type { MapViewDefinition } from './definition';
4
+ /**
5
+ * Everything a host without filesystem access needs to render a space: its graph, the validation
6
+ * results that attach to nodes, and the map view definitions that apply to its schema. Plain JSON.
7
+ */
8
+ export type SpaceSnapshot = {
9
+ space: string;
10
+ schemaId: string | undefined;
11
+ graph: Parameters<typeof spaceGraphFrom>[0];
12
+ /** What `annotationsFrom` attaches */
13
+ validation: ValidationInput;
14
+ definitions: MapViewDefinition[];
15
+ };
@@ -1,7 +1,15 @@
1
1
  import { type Config } from 'structured-context/api';
2
2
  import { type MapViewDefinition } from '../core/definition';
3
+ export type DefinitionSource = {
4
+ kind: 'core';
5
+ } | {
6
+ kind: 'plugin';
7
+ plugin: string;
8
+ } | {
9
+ kind: 'config';
10
+ };
3
11
  export type LoadMapViewDefinitionsOptions = {
4
- /** Directory of the main config file. Defaults to where structured-context finds it. */
12
+ /** Root of the main config file (`resolveConfigPath().root`). Defaults to where structured-context finds it. */
5
13
  configDir?: string;
6
14
  };
7
15
  /**
@@ -9,9 +17,18 @@ export type LoadMapViewDefinitionsOptions = {
9
17
  * - this package's embedded definitions (`sctx-map-view://core/<name>`), for structured-context's bundled schemas;
10
18
  * - each plugin found from a config folder or named by a space (`sctx-map-view://<plugin>/<name>`): the
11
19
  * folder named by `"sctx": { "mapViews": "…" }` in its package.json, else its `map-views/` folder;
12
- * - a `map-views/` folder next to each config file (`sctx-map-view://<name>`).
20
+ * - the `map-views` resources folder of each config root (`sctx-map-view://<name>`).
13
21
  *
14
22
  * Each definition's `$id` must be in the namespace of where it was found, and ids must be unique.
15
23
  * Throws on the first invalid definition.
16
24
  */
17
25
  export declare function loadMapViewDefinitions(config: Config, options?: LoadMapViewDefinitionsOptions): MapViewDefinition[];
26
+ /**
27
+ * Definitions in `folders` and this package's embedded ones, each checked against the namespace of its source.
28
+ * Throws on the first invalid definition or a repeated id.
29
+ */
30
+ export declare function readDefinitionFolders(folders: {
31
+ dir: string;
32
+ source: DefinitionSource;
33
+ }[]): MapViewDefinition[];
34
+ export { fillPage } from './page';
@@ -0,0 +1,7 @@
1
+ import type { SpaceSnapshot } from '../core/snapshot';
2
+ export declare const PAGE_SLOTS: {
3
+ readonly title: '<!--sctx-title-->';
4
+ readonly snapshots: '<!--sctx-snapshots-->';
5
+ };
6
+ /** `template` (`dist/page.html`) with the title and snapshots written in. */
7
+ export declare function fillPage(template: string, snapshots: SpaceSnapshot[], title: string): string;
@@ -1,18 +1,5 @@
1
- import { type Config, exportSpaceGraph, validateSpace } from 'structured-context/api';
2
- import type { ValidationInput } from '../core/annotations';
3
- import { type MapViewDefinition } from '../core/definition';
4
- /**
5
- * Everything a host without filesystem access needs to render a space: its graph, the validation
6
- * results that attach to nodes, and the map view definitions that apply to its schema. Plain JSON.
7
- */
8
- export type SpaceSnapshot = {
9
- space: string;
10
- schemaId: string | undefined;
11
- graph: ReturnType<typeof exportSpaceGraph>;
12
- /** What `annotationsFrom` attaches: each node's issues and the rule violations */
13
- validation: ValidationInput;
14
- definitions: MapViewDefinition[];
15
- };
1
+ import { type Config, validateSpace } from 'structured-context/api';
2
+ import type { SpaceSnapshot } from '../core/snapshot';
16
3
  /** The `validateSpace` options `export` passes through unchanged. */
17
4
  export type ExportValidateOptions = Pick<NonNullable<Parameters<typeof validateSpace>[1]>, 'depth' | 'includeGated' | 'semantic' | 'ruleFilter'>;
18
5
  /**
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,14 @@
1
+ import { type SpaceGraph, type SpaceNode } from 'structured-context/browser';
2
+ import type { MapViewDefinition } from '../core/definition';
3
+ import type { SpaceSnapshot } from '../core/snapshot';
4
+ /**
5
+ * A page-filling viewer for one or more space snapshots: a space and map view switcher, the parameter
6
+ * controls, the map view, and a side panel with the selected node's fields and validation results. Hosts
7
+ * supply the snapshots and anything specific to where the page is shown. See docs/architecture.md.
8
+ */
9
+ export type ViewerProps = {
10
+ spaces: SpaceSnapshot[];
11
+ /** Accessible name for each card, for hosts whose surroundings read it. Cards keep their default name without it. */
12
+ cardLabel?: (node: SpaceNode, graph: SpaceGraph, definition: MapViewDefinition) => string;
13
+ };
14
+ export declare function Viewer({ spaces, cardLabel }: ViewerProps): import("react").JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "structured-context-map-views",
3
- "version": "0.5.0",
3
+ "version": "0.6.1",
4
4
  "description": "Declarative map views of structured-context spaces: render a space as a tree, nested containers or an XY plot from a short definition.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -33,26 +33,31 @@
33
33
  "types": "./dist/types/node/index.d.ts",
34
34
  "default": "./dist/node.js"
35
35
  },
36
- "./styles.css": "./dist/styles.css"
36
+ "./styles.css": "./dist/styles.css",
37
+ "./page.html": {
38
+ "types": "./dist/page.html.d.ts",
39
+ "default": "./dist/page.html"
40
+ }
37
41
  },
38
42
  "scripts": {
39
43
  "clean": "rm -rf dist",
40
44
  "generate": "bun run generate:schemas && bun run generate:definitions",
41
45
  "generate:schemas": "bun scripts/generate-schemas.ts",
42
46
  "generate:definitions": "bun scripts/generate-definitions.ts",
43
- "build": "bun run clean && bun run generate && bun --bun vite build && tsc -p tsconfig.build.json && tailwindcss -i src/layouts/styles.css -o dist/styles.css && bun scripts/build-artifact-page.ts",
47
+ "build:library": "bun run clean && bun run generate && bun --bun vite build && tsc -p tsconfig.build.json && tailwindcss -i src/layouts/styles.css -o dist/styles.css && bun scripts/build-page.ts",
48
+ "build": "bun run build:library && bun scripts/build-artifact-page.ts",
44
49
  "typecheck": "tsc --noEmit",
45
50
  "capture-fixtures": "bun scripts/capture-fixtures.ts",
46
51
  "test": "bun test",
47
52
  "test:package": "bash scripts/test-package.sh",
48
53
  "prepublishOnly": "bun run build",
49
- "preversion": "bun run generate && bun run --cwd ../.. lint:fix && bun run --cwd ../.. test && bun run test:package",
54
+ "preversion": "bun run generate && bun run --cwd ../.. lint:fix && bun run --cwd ../.. test && bun run --cwd ../.. test:package",
50
55
  "version": "bun run generate:schemas --release && git add -A"
51
56
  },
52
57
  "peerDependencies": {
53
58
  "react": "^19.3.0",
54
59
  "react-dom": "^19.3.0",
55
- "structured-context": "^0.22.1"
60
+ "structured-context": "^0.24.0"
56
61
  },
57
62
  "dependencies": {
58
63
  "ajv": "^8.20.0",
@@ -68,7 +73,7 @@
68
73
  "@vitejs/plugin-react": "^6.1.1",
69
74
  "react": "^19.3.0",
70
75
  "react-dom": "^19.3.0",
71
- "structured-context": "^0.22.1",
76
+ "structured-context": "^0.24.0",
72
77
  "tailwindcss": "^4.3.3",
73
78
  "vite": "^8.3.2"
74
79
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"node-Co_JiEZV.js","names":[],"sources":["../src/node/bundled-definitions.ts","../src/node/index.ts"],"sourcesContent":["// Generated by scripts/generate-definitions.ts from map-views/*.json5. Do not edit.\nexport const BUNDLED_DEFINITIONS: Record<string, string> = {\n \"strategy-tree.json5\": \"// Strategy stack as a tree: vision → mission → goals → opportunities → solutions → experiments.\\n{\\n $schema: 'https://raw.githubusercontent.com/mindsocket/structured-context-map-views/main/schemas/generated/latest/definition.json',\\n $id: 'sctx-map-view://core/strategy-tree',\\n title: 'Strategy tree',\\n schema: 'sctx://core/strategy_general',\\n parameters: {\\n orientation: { $ref: 'settings.json#/$defs/orientation', default: 'vertical' },\\n nodeStyle: { $ref: 'settings.json#/$defs/nodeStyle', default: 'card' },\\n validation: { $ref: 'settings.json#/$defs/validationLevel', default: 'off' },\\n cardFields: {\\n title: 'Card fields',\\n type: 'array',\\n items: { enum: ['status', 'priority', 'summary'] },\\n default: ['status'],\\n },\\n },\\n regions: [\\n {\\n id: 'main',\\n layout: { type: 'tree', orientation: { $param: 'orientation' } },\\n nodes: { style: { $param: 'nodeStyle' }, fields: { $param: 'cardFields' }, validation: { $param: 'validation' } },\\n edges: { show: true },\\n },\\n ],\\n}\\n\",\n};\n","/// <reference types=\"node\" />\nimport { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';\nimport { dirname, join, resolve } from 'node:path';\nimport { type Config, PLUGIN_PREFIX, resolveConfigPath, resolvePluginDir } from 'structured-context/api';\nimport { type MapViewDefinition, parseMapViewDefinition } from '../core/definition';\nimport { BUNDLED_DEFINITIONS } from './bundled-definitions';\n\n/**\n * Node-only: finds map view definitions the way structured-context finds plugin schemas.\n * Browser-only hosts receive the result from a server, like graph data.\n */\n\nconst SCHEME = 'sctx-map-view://';\nconst DEFINITIONS_DIR = 'map-views';\nconst CONFIG_PLUGINS_DIR = 'plugins';\nconst PACKAGE_NAME = 'structured-context-map-views';\n\ntype Source = { kind: 'core' } | { kind: 'plugin'; plugin: string } | { kind: 'config' };\n\nexport type LoadMapViewDefinitionsOptions = {\n /** Directory of the main config file. Defaults to where structured-context finds it. */\n configDir?: string;\n};\n\n/**\n * Every map view definition available with `config`, from:\n * - this package's embedded definitions (`sctx-map-view://core/<name>`), for structured-context's bundled schemas;\n * - each plugin found from a config folder or named by a space (`sctx-map-view://<plugin>/<name>`): the\n * folder named by `\"sctx\": { \"mapViews\": \"…\" }` in its package.json, else its `map-views/` folder;\n * - a `map-views/` folder next to each config file (`sctx-map-view://<name>`).\n *\n * Each definition's `$id` must be in the namespace of where it was found, and ids must be unique.\n * Throws on the first invalid definition.\n */\nexport function loadMapViewDefinitions(\n config: Config,\n options: LoadMapViewDefinitionsOptions = {},\n): MapViewDefinition[] {\n const configDir = options.configDir ?? dirname(resolve(resolveConfigPath().path));\n const configDirs = [...new Set([configDir, ...config.spaces.flatMap((s) => (s.sourceDir ? [s.sourceDir] : []))])];\n\n const folders: { dir: string; source: Source }[] = [\n ...pluginDirs(config, configDir, configDirs).flatMap(([plugin, dir]) => {\n const definitions = pluginDefinitionsDir(dir);\n return definitions ? [{ dir: definitions, source: { kind: 'plugin', plugin } as const }] : [];\n }),\n ...configDirs.map((dir) => ({ dir: join(dir, DEFINITIONS_DIR), source: { kind: 'config' } as const })),\n ];\n\n const foundAt = new Map<string, string>();\n const definitions: MapViewDefinition[] = [];\n const add = (label: string, text: string, source: Source) => {\n const definition = parseMapViewDefinition(label, text);\n assertIdNamespace(definition.id, source, label);\n const existing = foundAt.get(definition.id);\n if (existing) throw new Error(`Map view id \"${definition.id}\" is defined by both ${existing} and ${label}.`);\n foundAt.set(definition.id, label);\n definitions.push(definition);\n };\n\n for (const [file, text] of Object.entries(BUNDLED_DEFINITIONS))\n add(`${PACKAGE_NAME}/${file}`, text, { kind: 'core' });\n for (const { dir, source } of folders) {\n if (!isDirectory(dir)) continue;\n for (const file of readdirSync(dir)\n .filter((f) => f.endsWith('.json5'))\n .sort()) {\n const path = join(dir, file);\n add(path, readFileSync(path, 'utf8'), source);\n }\n }\n return definitions;\n}\n\n/** Plugin short name → root directory, for plugins in a config folder's `plugins/` or named by the config. */\nfunction pluginDirs(config: Config, configDir: string, configDirs: string[]): [string, string][] {\n const found = new Map<string, string>();\n const add = (name: string, fromDir: string) => {\n const short = name.startsWith(PLUGIN_PREFIX) ? name.slice(PLUGIN_PREFIX.length) : name;\n if (found.has(short)) return;\n const dir = resolvePluginDir(name, fromDir);\n if (dir) found.set(short, dir);\n };\n\n for (const dir of configDirs) {\n const plugins = join(dir, CONFIG_PLUGINS_DIR);\n if (!isDirectory(plugins)) continue;\n for (const entry of readdirSync(plugins)\n .filter((e) => e.startsWith(PLUGIN_PREFIX))\n .sort())\n add(entry, dir);\n }\n const topLevel = (config as { plugins?: Record<string, unknown> }).plugins ?? {};\n for (const name of Object.keys(topLevel)) add(name, configDir);\n for (const space of config.spaces) {\n const fromDir = space.sourceDir ?? configDir;\n // A schema named through a plugin, e.g. \"sctx-wardley-mapping/wardley_map.json\".\n const schemaPlugin = /^([^./][^/]*)\\/./.exec(space.schema ?? '')?.[1];\n if (schemaPlugin) add(schemaPlugin, fromDir);\n for (const name of Object.keys(space.plugins ?? {})) add(name, fromDir);\n }\n return [...found];\n}\n\nfunction pluginDefinitionsDir(pluginDir: string): string | undefined {\n const pkgPath = join(pluginDir, 'package.json');\n if (existsSync(pkgPath)) {\n const declared = JSON.parse(readFileSync(pkgPath, 'utf8')).sctx?.mapViews;\n if (typeof declared === 'string') return resolve(pluginDir, declared);\n }\n return join(pluginDir, DEFINITIONS_DIR);\n}\n\nfunction assertIdNamespace(id: string, source: Source, path: string): void {\n const segments = id.slice(SCHEME.length).split('/');\n const expected =\n source.kind === 'core'\n ? `${SCHEME}core/<name>`\n : source.kind === 'plugin'\n ? `${SCHEME}${source.plugin}/<name>`\n : `${SCHEME}<name>`;\n const ok =\n source.kind === 'config'\n ? segments.length === 1\n : segments.length === 2 && segments[0] === (source.kind === 'core' ? 'core' : source.plugin);\n if (!ok || (source.kind === 'plugin' && source.plugin === 'core')) {\n throw new Error(`Map view namespace violation: ${path} has $id \"${id}\". Use the form \"${expected}\".`);\n }\n}\n\nfunction isDirectory(path: string): boolean {\n return existsSync(path) && statSync(path).isDirectory();\n}\n"],"mappings":";;;;;AACA,IAAa,sBAA8C,EACzD,uBAAuB,8iCACzB;;;;;;;ACSA,IAAM,SAAS;AACf,IAAM,kBAAkB;A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E,MAAM,UAAU,KAAK,WAAW,cAAc;CAC9C,IAAI,WAAW,OAAO,GAAG;EACvB,MAAM,WAAW,KAAK,MAAM,aAAa,SAAS,MAAM,CAAC,CAAC,CAAC,MAAM;EACjE,IAAI,OAAO,aAAa,UAAU,OAAO,QAAQ,WAAW,QAAQ;CACtE;CACA,OAAO,KAAK,WAAW,eAAe;AACxC;AAEA,SAAS,kBAAkB,IAAY,QAAgB,MAAoB;CACzE,MAAM,WAAW,GAAG,MAAM,EAAa,CAAC,CAAC,MAAM,GAAG;CAClD,MAAM,WACJ,OAAO,SAAS,SACZ,GAAG,OAAO,eACV,OAAO,SAAS,WACd,GAAG,SAAS,OAAO,OAAO,WAC1B,GAAG,OAAO;CAKlB,IAAI,EAHF,OAAO,SAAS,WACZ,SAAS,WAAW,IACpB,SAAS,WAAW,KAAK,SAAS,QAAQ,OAAO,SAAS,SAAS,SAAS,OAAO,YAC7E,OAAO,SAAS,YAAY,OAAO,WAAW,QACxD,MAAM,IAAI,MAAM,iCAAiC,KAAK,YAAY,GAAG,mBAAmB,SAAS,GAAG;AAExG;AAEA,SAAS,YAAY,MAAuB;CAC1C,OAAO,WAAW,IAAI,KAAK,SAAS,IAAI,CAAC,CAAC,YAAY;AACxD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"projection-CYShQhug.js","names":[],"sources":["../src/core/annotations.ts","../src/core/graph.ts","../src/core/occurrence.ts","../src/core/tree.ts","../src/core/landscape.ts","../src/core/xy.ts"],"sourcesContent":["import type { nodeIssues, RuleSeverity, SpaceGraph, SpaceNode, ValidationResult } from 'structured-context/api';\nimport type { ValidationIssueKind } from 'structured-context/types';\n\n// core doesn't export NodeId from `structured-context/api` yet; this derives it.\ntype NodeId = SpaceNode['id'];\n\n/** How serious a result is: structured-context's rule severity, which every result carries. */\nexport type Severity = RuleSeverity;\n\n/** The kind of check a result came from: structured-context's issue `kind`. */\nexport type AnnotationSource = ValidationIssueKind;\n\n/** One validation result attached to a node. */\nexport type NodeAnnotation = {\n severity: Severity;\n source: AnnotationSource;\n message: string;\n /** The violated rule, for `rule` results. */\n ruleId?: string;\n};\n\n/** A validation result with no node on the map to attach to. */\nexport type UnattachedAnnotation = NodeAnnotation & {\n /** The node it concerns. Absent for a global-scope rule. A node that failed its schema isn't in the graph. */\n nodeId?: NodeId;\n /** Where in that node's file the result points, if known (1-indexed). */\n line?: number;\n column?: number;\n};\n\n/** Annotations by the id of the node they apply to. */\nexport type AnnotationIndex = ReadonlyMap<NodeId, readonly NodeAnnotation[]>;\n\n/**\n * Validation results to attach: each node's issues, from structured-context's `nodeIssues(result)` or the\n * `issues` of `sctx validate --json`, and the rule violations, of which only those without a node are read\n * (the others are in `issues`). `sctx validate --json` output can be passed as it is.\n */\nexport type ValidationInput = {\n issues: Readonly<ReturnType<typeof nodeIssues>>;\n ruleViolations?: ReadonlyArray<\n Pick<ValidationResult['ruleViolations'][number], 'nodeId' | 'ruleId' | 'severity' | 'description'>\n >;\n};\n\n/**\n * Attach validation results to the nodes of `graph`, by node id. Results that can't be attached are\n * returned in `unattached` for the host to surface: global-scope rules (no node), and nodes that\n * aren't in the graph, which includes every node that failed its schema.\n */\nexport function annotationsFrom(\n input: ValidationInput,\n graph: SpaceGraph,\n): { annotations: AnnotationIndex; unattached: UnattachedAnnotation[] } {\n const annotations = new Map<NodeId, NodeAnnotation[]>();\n const unattached: UnattachedAnnotation[] = [];\n\n for (const [id, issues] of Object.entries(input.issues)) {\n const nodeId = id as NodeId;\n for (const [key, { kind, message, severity, line, column }] of Object.entries(issues)) {\n const annotation: NodeAnnotation = {\n severity,\n source: kind,\n message,\n ...(kind === 'rule' && key.startsWith('rule:') && { ruleId: key.slice('rule:'.length) }),\n };\n if (graph.nodes.has(nodeId)) {\n annotations.set(nodeId, [...(annotations.get(nodeId) ?? []), annotation]);\n } else {\n unattached.push({\n ...annotation,\n nodeId,\n ...(line !== undefined && { line }),\n ...(column !== undefined && { column }),\n });\n }\n }\n }\n for (const { nodeId, description, severity, ruleId } of input.ruleViolations ?? []) {\n if (nodeId === undefined) unattached.push({ severity, source: 'rule', message: description, ruleId });\n }\n return { annotations, unattached };\n}\n\nconst RANK: Record<Severity, number> = { error: 0, warning: 1, info: 2 };\n\n/** The most serious severity among annotations, or undefined if there are none. */\nexport function worstSeverity(annotations: readonly NodeAnnotation[]): Severity | undefined {\n return annotations.reduce<Severity | undefined>(\n (worst, { severity }) => (worst === undefined || RANK[severity] < RANK[worst] ? severity : worst),\n undefined,\n );\n}\n\n/**\n * The annotations a map view shows: those at `level` or more serious, from `sources`. `off` shows none.\n * Nodes left with no annotations are dropped from the index.\n */\nexport function filterAnnotations(\n index: AnnotationIndex,\n level: Severity | 'off',\n sources: readonly AnnotationSource[],\n): AnnotationIndex {\n if (level === 'off') return new Map();\n const filtered = new Map<NodeId, readonly NodeAnnotation[]>();\n for (const [id, annotations] of index) {\n const kept = annotations.filter((a) => RANK[a.severity] <= RANK[level] && sources.includes(a.source));\n if (kept.length > 0) filtered.set(id, kept);\n }\n return filtered;\n}\n","import type { Hierarchy, SpaceGraph, SpaceNode } from 'structured-context/api';\n\ntype NodeId = SpaceNode['id'];\n\n/** A directed parent → child edge of a space graph, carrying the metadata of the reference it came from. */\nexport type Edge = SpaceGraph['parentEdges'] extends ReadonlyMap<string, readonly (infer E)[]> ? E : never;\n\nconst NONE: readonly Edge[] = [];\n\n/**\n * Edges to a node's parents, in the order the node declares them. A graph narrowed by a filter keeps\n * edges to parents outside it; those are left out.\n */\nexport function parentEdges(graph: SpaceGraph, id: NodeId): readonly Edge[] {\n return (graph.parentEdges.get(id) ?? NONE).filter((edge) => graph.nodes.has(edge.parent));\n}\n\n/** Edges to a node's children, in graph order of the children. */\nexport function childEdges(graph: SpaceGraph, id: NodeId): readonly Edge[] {\n return graph.childEdges.get(id) ?? NONE;\n}\n\n/** Every edge whose parent and child are both in the graph. */\nexport function edgesWithin(graph: SpaceGraph): Edge[] {\n return [...graph.nodes.keys()].flatMap((id) => parentEdges(graph, id));\n}\n\n/** Whether an edge belongs to the given hierarchy (as opposed to a relationship or another hierarchy). */\nexport function isHierarchyEdge(edge: Edge, hierarchy: Hierarchy | undefined): boolean {\n return hierarchy !== undefined && edge.kind === 'hierarchy' && edge.hierarchy === hierarchy.name;\n}\n","/**\n * One step of an occurrence path: a node title, a `[field, value]` group, or `null` for the\n * ungrouped area. Encoded distinctly, so a field group can't collide with a node of the same name.\n */\nexport type PathSegment = string | readonly [field: string, value: string | null] | null;\n\n/**\n * Path-based key for one occurrence of a node: region, then the steps from the outermost\n * container down to the node. Unique within a map view even when a node appears several times.\n * Hosts can render several map views at once, so layouts scope keys to the map view instance.\n */\nexport function occurrenceKey(regionId: string, path: readonly PathSegment[]): string {\n return JSON.stringify([regionId, ...path]);\n}\n","import type { SpaceGraph, SpaceNode } from 'structured-context/api';\nimport type { DagMode } from './definition';\nimport { childEdges, isHierarchyEdge, parentEdges } from './graph';\nimport { occurrenceKey } from './occurrence';\n\n/** One rendered appearance of a node in a tree. */\nexport type TreeOccurrence = {\n /** Path-based key, unique within the map view (see {@link occurrenceKey}). */\n key: string;\n node: SpaceNode;\n children: TreeOccurrence[];\n /**\n * Key of the node's primary occurrence when this is a repeat. A node with several parents\n * appears under each of them, but its subtree is only rendered at its first occurrence.\n */\n repeatOf?: string;\n};\n\nexport type Tree = {\n roots: TreeOccurrence[];\n /**\n * Hierarchy-typed nodes not reachable from a root, rendered as extra roots: nodes with no\n * hierarchy parent in the space, then entry points into otherwise unreachable cycles.\n */\n orphans: TreeOccurrence[];\n /** Key of each node's primary (first, fully rendered) occurrence. */\n primary: ReadonlyMap<string, string>;\n /**\n * In cross-edge mode, links from a node's other parents to its primary occurrence, which\n * replace repeat occurrences. Empty in repeat mode.\n */\n crossLinks: TreeLink[];\n};\n\nexport type TreeLink = { from: string; to: string; kind: 'tree' | 'cross' };\n\n/**\n * Lay a space out as a tree over its hierarchy.\n *\n * Roots are root-type nodes with no hierarchy parent. Traversal is depth-first in space order,\n * so a node's primary occurrence is under the parent reached first. Under its other parents a\n * node is either repeated without its subtree (`repeat`), or left out and linked by a cross-edge\n * (`cross-edge`). Either way traversal stops there, which also keeps cycles from recursing.\n */\nexport function buildTree(graph: SpaceGraph, regionId: string, dag: DagMode = 'repeat'): Tree {\n const { hierarchy } = graph;\n const levelTypes = new Set(hierarchy?.levels.map((level) => level.type));\n const rootType = hierarchy?.levels[0]?.type;\n const primary = new Map<string, string>();\n // Parent occurrence → child title, resolved to the child's primary occurrence afterwards.\n const pendingCross: { from: string; child: string }[] = [];\n\n const hierarchyParents = (title: SpaceNode['id']) =>\n parentEdges(graph, title).filter((edge) => isHierarchyEdge(edge, hierarchy));\n\n const visit = (node: SpaceNode, path: readonly string[]): TreeOccurrence => {\n const nodePath = [...path, node.id];\n const key = occurrenceKey(regionId, nodePath);\n primary.set(node.id, key);\n // A child can reference the same parent through more than one field; it occurs once.\n const childTitles = new Set(\n childEdges(graph, node.id)\n .filter((edge) => isHierarchyEdge(edge, hierarchy))\n .map((edge) => edge.child),\n );\n const children: TreeOccurrence[] = [];\n for (const title of childTitles) {\n const child = graph.nodes.get(title)!;\n const repeatOf = primary.get(title);\n if (repeatOf === undefined) children.push(visit(child, nodePath));\n else if (dag === 'repeat')\n children.push({ key: occurrenceKey(regionId, [...nodePath, title]), node: child, children: [], repeatOf });\n else pendingCross.push({ from: key, child: title });\n }\n return { key, node, children };\n };\n\n const levelNodes = [...graph.nodes.values()].filter((node) => levelTypes.has(node.resolvedType));\n const unparented = levelNodes.filter((node) => hierarchyParents(node.id).length === 0);\n const roots = unparented.filter((node) => node.resolvedType === rootType).map((node) => visit(node, []));\n const orphans = unparented.filter((node) => node.resolvedType !== rootType).map((node) => visit(node, []));\n // Nodes only reachable through a cycle have a parent but no path from a root. Rather than\n // drop them, enter each such cycle at its first node in space order.\n for (const node of levelNodes) {\n if (!primary.has(node.id)) orphans.push(visit(node, []));\n }\n\n const crossLinks = pendingCross.map(({ from, child }) => ({ from, to: primary.get(child)!, kind: 'cross' as const }));\n return { roots, orphans, primary, crossLinks };\n}\n\n/** Parent → child pairs of occurrence keys: one per rendered parent-child link, then cross-links. */\nexport function treeLinks(tree: Tree): TreeLink[] {\n const links: TreeLink[] = [];\n const walk = (occurrence: TreeOccurrence) => {\n for (const child of occurrence.children) {\n links.push({ from: occurrence.key, to: child.key, kind: 'tree' });\n walk(child);\n }\n };\n for (const root of [...tree.roots, ...tree.orphans]) walk(root);\n return [...links, ...tree.crossLinks];\n}\n","import type { SpaceGraph, SpaceNode } from 'structured-context/api';\nimport type { GroupLevel, LandscapeLayoutConfig } from './definition';\nimport { childEdges, parentEdges } from './graph';\nimport { occurrenceKey, type PathSegment } from './occurrence';\n\n/** One rendered container or node in a landscape. */\nexport type LandscapeOccurrence = {\n /** Path-based key, unique within the map view (see {@link occurrenceKey}). */\n key: string;\n /** Index of the grouping level this occurrence belongs to. */\n level: number;\n /** A node, or a field value shared by the nodes inside (`null`: the field is empty). */\n item: { kind: 'node'; node: SpaceNode } | { kind: 'value'; field: string; value: string | null };\n /** Nodes on the `via` chain that joined this node to the node level above, one entry per skipped type. */\n via: ViaStep[];\n /** Key of the node's first occurrence when this is a repeat. Repeats are rendered in full. */\n repeatOf?: string;\n children: LandscapeOccurrence[];\n};\n\nexport type ViaStep = { type: string; nodes: SpaceNode[] };\n\nexport type Landscape = {\n groups: LandscapeOccurrence[];\n /**\n * Nodes of a grouped level that no container above reaches (e.g. an Activity with no\n * Outcome when grouping by Outcomes), each with its own contents.\n */\n ungrouped: LandscapeOccurrence[];\n};\n\ntype Candidate = { node: SpaceNode; via: ViaStep[] };\ntype FieldFilter = { field: string; value: string | null };\n\n/**\n * Lay a space out as nested containers following the layout's grouping levels.\n *\n * Adjacent node levels are joined by any edge between their types, in either direction, or only\n * edges from `edge.field`. A `via` chain joins them through the skipped types. A field level\n * splits the next node level by that field's values. A node reached from several containers\n * appears in each, in full: the levels are finite, so repeating contents can't recurse.\n */\nexport function buildLandscape(graph: SpaceGraph, regionId: string, layout: LandscapeLayoutConfig): Landscape {\n const levels = layout.group;\n const order = new Map([...graph.nodes.keys()].map((title, i) => [title, i]));\n const first = new Map<string, string>();\n\n const occurrenceFor = (candidate: Candidate, levelIdx: number, path: readonly PathSegment[]): LandscapeOccurrence => {\n const { node } = candidate;\n const nodePath = [...path, node.id];\n const key = occurrenceKey(regionId, nodePath);\n const repeatOf = first.get(node.id);\n if (repeatOf === undefined) first.set(node.id, key);\n return {\n key,\n level: levelIdx,\n item: { kind: 'node', node },\n via: candidate.via,\n ...(repeatOf !== undefined && { repeatOf }),\n children: place(levelIdx + 1, node, [], nodePath),\n };\n };\n\n /** Occurrences for level `levelIdx` inside `anchor`, the nearest enclosing node. */\n const place = (\n levelIdx: number,\n anchor: SpaceNode | undefined,\n filters: readonly FieldFilter[],\n path: readonly PathSegment[],\n ): LandscapeOccurrence[] => {\n const level = levels[levelIdx];\n if (level === undefined) return [];\n if (isTypeLevel(level)) {\n return candidates(level, anchor, filters).map((c) => occurrenceFor(c, levelIdx, path));\n }\n\n const nodeLevel = levels.slice(levelIdx).find(isTypeLevel)!;\n const values = distinctValues(\n candidates(nodeLevel, anchor, filters).map((c) => c.node),\n level.field,\n );\n return values.map((value) => {\n const valuePath = [...path, [level.field, value] as const];\n return {\n key: occurrenceKey(regionId, valuePath),\n level: levelIdx,\n item: { kind: 'value', field: level.field, value },\n via: [],\n children: place(levelIdx + 1, anchor, [...filters, { field: level.field, value }], valuePath),\n };\n });\n };\n\n /** Nodes of a type level joined to `anchor` (all of the type at the top) and matching the filters. */\n const candidates = (\n level: TypeLevel,\n anchor: SpaceNode | undefined,\n filters: readonly FieldFilter[],\n ): Candidate[] => {\n const reached: Candidate[] =\n anchor === undefined\n ? ofType(level.type).map((node) => ({ node, via: [] }))\n : walkChain(anchor, level.via ?? [], level.type, level.edge?.field);\n return reached.filter(({ node }) => filters.every((f) => hasValue(node, f)));\n };\n\n const ofType = (type: string) => [...graph.nodes.values()].filter((node) => node.resolvedType === type);\n\n /** Neighbours of a node with the given type, across edges in either direction, in space order. */\n const neighbours = (title: SpaceNode['id'], type: string, field: string | undefined): SpaceNode[] => {\n const titles = new Set([\n ...childEdges(graph, title)\n .filter((e) => field === undefined || e.field === field)\n .map((e) => e.child),\n ...parentEdges(graph, title)\n .filter((e) => field === undefined || e.field === field)\n .map((e) => e.parent),\n ]);\n return [...titles]\n .map((t) => graph.nodes.get(t)!)\n .filter((node) => node.resolvedType === type)\n .sort((a, b) => order.get(a.id)! - order.get(b.id)!);\n };\n\n /**\n * Follow edges from `anchor` through each `via` type to `target`, keeping the skipped nodes on\n * the way to each target node. Several chains to one target merge into one candidate.\n */\n const walkChain = (anchor: SpaceNode, via: readonly string[], target: string, field: string | undefined) => {\n let frontier = [{ node: anchor, trail: [] as SpaceNode[] }];\n for (const type of via) {\n frontier = frontier.flatMap(({ node, trail }) =>\n neighbours(node.id, type, undefined).map((next) => ({ node: next, trail: [...trail, next] })),\n );\n }\n const byTitle = new Map<string, Candidate>();\n for (const { node, trail } of frontier) {\n for (const next of neighbours(node.id, target, field)) {\n const candidate = byTitle.get(next.id) ?? { node: next, via: via.map((type) => ({ type, nodes: [] })) };\n trail.forEach((skipped, i) => {\n const step = candidate.via[i]!;\n if (!step.nodes.includes(skipped)) step.nodes.push(skipped);\n });\n byTitle.set(next.id, candidate);\n }\n }\n return [...byTitle.values()].sort((a, b) => order.get(a.node.id)! - order.get(b.node.id)!);\n };\n\n const groups = place(0, undefined, [], []);\n\n // Nodes of an inner level that no container reached get their own contents, like tree orphans.\n const ungrouped: LandscapeOccurrence[] = [];\n levels.forEach((level, levelIdx) => {\n if (levelIdx === 0 || !isTypeLevel(level)) return;\n for (const node of ofType(level.type)) {\n if (!first.has(node.id)) ungrouped.push(occurrenceFor({ node, via: [] }, levelIdx, [null]));\n }\n });\n\n return { groups, ungrouped };\n}\n\ntype TypeLevel = Extract<GroupLevel, { type: string }>;\n\nfunction isTypeLevel(level: GroupLevel): level is TypeLevel {\n return 'type' in level;\n}\n\n/** A field's values as group labels: strings, an entry per array item, `null` when empty. */\nfunction valuesOf(node: SpaceNode, field: string): (string | null)[] {\n const raw = node.schemaData[field];\n const list = (Array.isArray(raw) ? raw : [raw]).filter((v) => v !== undefined && v !== null && v !== '');\n return list.length === 0 ? [null] : list.map((v) => (typeof v === 'object' ? JSON.stringify(v) : String(v)));\n}\n\n/** Distinct values in first-seen order, with the empty group last. */\nfunction distinctValues(nodes: SpaceNode[], field: string): (string | null)[] {\n const values = new Set(nodes.flatMap((node) => valuesOf(node, field)));\n const present = [...values].filter((v): v is string => v !== null);\n return values.has(null) ? [...present, null] : present;\n}\n\nfunction hasValue(node: SpaceNode, { field, value }: FieldFilter): boolean {\n return valuesOf(node, field).includes(value);\n}\n","import type { SpaceGraph, SpaceNode } from 'structured-context/api';\nimport type { AxisConfig, XYLayoutConfig } from './definition';\nimport { edgesWithin, isHierarchyEdge } from './graph';\nimport { occurrenceKey } from './occurrence';\n\n/** A plotted node. `x` and `y` run from 0 to 1 across the plot, left to right and bottom to top. */\nexport type XYPoint = { key: string; node: SpaceNode; x: number; y: number };\n\n/** Why a node of a plotted type couldn't be placed, per axis. */\nexport type Unplaced = { key: string; node: SpaceNode; reasons: string[] };\n\n/**\n * An edge between plotted nodes. `lane` separates edges joining the same two nodes: 0 when\n * there's one, otherwise centred around 0 (e.g. -0.5 and 0.5), for layouts to draw side by side.\n */\nexport type XYLink = { from: string; to: string; field: string; hierarchy: boolean; lane: number };\n\nexport type XYPlot = {\n points: XYPoint[];\n unplaced: Unplaced[];\n /** Edges between plotted nodes. */\n links: XYLink[];\n /** Each axis's [min, max]; `direction` says which end is drawn where. */\n domains: { x: readonly [number, number]; y: readonly [number, number] };\n};\n\n/**\n * Position nodes by two numeric fields. Every node of a plotted type appears once: on the plot\n * when both its values are numbers inside the axes' domains, otherwise in `unplaced` with the\n * reason. Positions are normalised; layouts decide the plot's size.\n */\nexport function buildXYPlot(graph: SpaceGraph, regionId: string, layout: XYLayoutConfig): XYPlot {\n const { x, y } = layout;\n const nodes = [...graph.nodes.values()];\n const types = new Set(\n layout.types.length > 0\n ? layout.types\n : nodes\n .filter((n) => isNumber(n.schemaData[x.field]) || isNumber(n.schemaData[y.field]))\n .map((n) => n.resolvedType),\n );\n const plotted = nodes.filter((n) => types.has(n.resolvedType));\n\n const domains = {\n x: domainOf(x, plotted),\n y: domainOf(y, plotted),\n };\n\n const points: XYPoint[] = [];\n const unplaced: Unplaced[] = [];\n for (const node of plotted) {\n const key = occurrenceKey(regionId, [node.id]);\n const px = position(node, x, domains.x);\n const py = position(node, y, domains.y);\n if (typeof px === 'number' && typeof py === 'number') points.push({ key, node, x: px, y: py });\n else unplaced.push({ key, node, reasons: [px, py].filter((r): r is string => typeof r === 'string') });\n }\n\n const keys = new Map<string, string>(points.map((p) => [p.node.id, p.key]));\n const fields = new Set(layout.edgeFields);\n const links = edgesWithin(graph)\n .filter((e) => keys.has(e.parent) && keys.has(e.child) && (fields.size === 0 || fields.has(e.field)))\n .map((e) => ({\n from: keys.get(e.parent)!,\n to: keys.get(e.child)!,\n field: e.field,\n hierarchy: isHierarchyEdge(e, graph.hierarchy),\n lane: 0,\n }));\n assignLanes(links);\n\n return { points, unplaced, links, domains };\n}\n\nfunction isNumber(value: unknown): value is number {\n return typeof value === 'number' && Number.isFinite(value);\n}\n\n/** The axis's fixed domain, or the range of plotted values (widened when they're all equal). */\nfunction domainOf(axis: AxisConfig, nodes: readonly SpaceNode[]): readonly [number, number] {\n if (Array.isArray(axis.domain)) return [axis.domain[0]!, axis.domain[1]!];\n const values = nodes.map((n) => n.schemaData[axis.field]).filter(isNumber);\n if (values.length === 0) return [0, 1];\n const min = Math.min(...values);\n const max = Math.max(...values);\n return min === max ? [min - 1, max + 1] : [min, max];\n}\n\n/** The node's normalised position on the axis, or why it has none. */\nfunction position(node: SpaceNode, axis: AxisConfig, [min, max]: readonly [number, number]): number | string {\n const value = node.schemaData[axis.field];\n if (value === undefined || value === null) return `no ${axis.field}`;\n if (!isNumber(value)) return `${axis.field} is not a number`;\n if (value < min || value > max) return `${axis.field} ${value} is outside ${min}–${max}`;\n const t = (value - min) / (max - min);\n return axis.direction === 'descending' ? 1 - t : t;\n}\n\n/** Spread links joining the same pair of nodes (in either direction) into lanes around 0. */\nfunction assignLanes(links: XYLink[]) {\n const byPair = new Map<string, XYLink[]>();\n for (const link of links) {\n const pair = [link.from, link.to].sort().join('\\n');\n byPair.set(pair, [...(byPair.get(pair) ?? []), link]);\n }\n for (const group of byPair.values()) {\n group.forEach((link, i) => {\n link.lane = i - (group.length - 1) / 2;\n });\n }\n}\n"],"mappings":";;;;;;AAkDA,SAAgB,gBACd,OACA,OACsE;CACtE,MAAM,8BAAc,IAAI,IAA8B;CACtD,MAAM,aAAqC,CAAC;CAE5C,KAAK,MAAM,CAAC,IAAI,WAAW,OAAO,QAAQ,MAAM,MAAM,GAAG;EACvD,MAAM,SAAS;EACf,KAAK,MAAM,CAAC,KAAK,EAAE,MAAM,SAAS,UAAU,MAAM,aAAa,OAAO,QAAQ,MAAM,GAAG;GACrF,MAAM,aAA6B;IACjC;IACA,QAAQ;IACR;IACA,GAAI,SAAS,UAAU,IAAI,WAAW,OAAO,KAAK,EAAE,QAAQ,IAAI,MAAM,CAAc,EAAE;GACxF;GACA,IAAI,MAAM,MAAM,IAAI,MAAM,GACxB,YAAY,IAAI,QAAQ,CAAC,GAAI,YAAY,IAAI,MAAM,KAAK,CAAC,GAAI,UAAU,CAAC;QAExE,WAAW,KAAK;IACd,GAAG;IACH;IACA,GAAI,SAAS,KAAA,KAAa,EAAE,KAAK;IACjC,GAAI,WAAW,KAAA,KAAa,EAAE,OAAO;GACvC,CAAC;EAEL;CACF;CACA,KAAK,MAAM,EAAE,QAAQ,aAAa,UAAU,YAAY,MAAM,kBAAkB,CAAC,GAC/E,IAAI,WAAW,KAAA,GAAW,WAAW,KAAK;EAAE;EAAU,QAAQ;EAAQ,SAAS;EAAa;CAAO,CAAC;CAEtG,OAAO;EAAE;EAAa;CAAW;AAC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