structured-context-map-views 0.7.2 → 0.7.4

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.
@@ -99,7 +99,20 @@ function occurrenceKey(regionId, path) {
99
99
  * way a level is joined to the node level above, so `via` applies there too.
100
100
  */
101
101
  function buildLandscape(graph, regionId, layout) {
102
- const order = new Map([...graph.nodes.keys()].map((title, i) => [title, i]));
102
+ const spaceOrder = new Map([...graph.nodes.keys()].map((title, i) => [title, i]));
103
+ const nodeOrder = (node) => {
104
+ const value = node.schemaData?.order;
105
+ return typeof value === "number" && Number.isFinite(value) ? value : void 0;
106
+ };
107
+ /** Sort nodes by numeric `order` ascending (matching SpaceGraph), falling back to space order. */
108
+ const compareNodes = (a, b) => {
109
+ const oa = nodeOrder(a);
110
+ const ob = nodeOrder(b);
111
+ if (oa !== void 0 && ob !== void 0 && oa !== ob) return oa - ob;
112
+ if (oa !== void 0 && ob === void 0) return -1;
113
+ if (oa === void 0 && ob !== void 0) return 1;
114
+ return spaceOrder.get(a.id) - spaceOrder.get(b.id);
115
+ };
103
116
  const first = /* @__PURE__ */ new Map();
104
117
  const occurrenceFor = (strip, candidate, levelIdx, path) => {
105
118
  const { node } = candidate;
@@ -163,10 +176,10 @@ function buildLandscape(graph, regionId, layout) {
163
176
  const values = filters.filter((f) => "field" in f);
164
177
  return reached.filter(({ node }) => values.every((f) => valuesOf(node, f.field).includes(f.value)));
165
178
  };
166
- const ofType = (type) => [...graph.nodes.values()].filter((node) => node.resolvedType === type);
167
- /** Neighbours of a node with the given type, across edges in either direction, in space order. */
179
+ const ofType = (type) => [...graph.nodes.values()].filter((node) => node.resolvedType === type).sort(compareNodes);
180
+ /** Neighbours of a node with the given type, across edges in either direction, in `order` then space order. */
168
181
  const neighbours = (title, type, field) => {
169
- 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));
182
+ 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(compareNodes);
170
183
  };
171
184
  /**
172
185
  * Follow edges from `anchor` through each `via` type to `target`, keeping the skipped nodes on
@@ -196,7 +209,7 @@ function buildLandscape(graph, regionId, layout) {
196
209
  });
197
210
  byTitle.set(next.id, candidate);
198
211
  }
199
- return [...byTitle.values()].sort((a, b) => order.get(a.node.id) - order.get(b.node.id));
212
+ return [...byTitle.values()].sort((a, b) => compareNodes(a.node, b.node));
200
213
  };
201
214
  /**
202
215
  * A dimension's groups, worked out once. A type dimension lists every node of its type, so it can
@@ -204,7 +217,7 @@ function buildLandscape(graph, regionId, layout) {
204
217
  * types of the first node level of each strip it divides) have, so a value no node has is not a group.
205
218
  * A node with no value, or joined to no node of the dimension, is in none of its groups; it
206
219
  * is shown as ungrouped, the same for both kinds.
207
- * PROTOTYPE: groups come in space order. A field's declared domain, or an `order` field, would give
220
+ * PROTOTYPE: field dimension groups come in first-seen order. A field's declared domain would give
208
221
  * the order authors expect and let a field dimension show empty groups too.
209
222
  */
210
223
  const dimensionGroups = (dimension, drawn, prefix) => {
@@ -382,10 +395,8 @@ function buildNeighbourhood(graph, regionId, layout, focusId) {
382
395
  function buildTree(graph, regionId, dag = "repeat") {
383
396
  const { hierarchy } = graph;
384
397
  const levelTypes = new Set(hierarchy?.levels.map((level) => level.type));
385
- const rootType = hierarchy?.levels[0]?.type;
386
398
  const primary = /* @__PURE__ */ new Map();
387
399
  const pendingCross = [];
388
- const hierarchyParents = (title) => parentEdges(graph, title).filter((edge) => isHierarchyEdge(edge, hierarchy));
389
400
  const visit = (node, path) => {
390
401
  const nodePath = [...path, node.id];
391
402
  const key = occurrenceKey(regionId, nodePath);
@@ -419,11 +430,9 @@ function buildTree(graph, regionId, dag = "repeat") {
419
430
  children
420
431
  };
421
432
  };
422
- const levelNodes = [...graph.nodes.values()].filter((node) => levelTypes.has(node.resolvedType));
423
- const unparented = levelNodes.filter((node) => hierarchyParents(node.id).length === 0);
424
- const roots = unparented.filter((node) => node.resolvedType === rootType).map((node) => visit(node, []));
425
- const orphans = unparented.filter((node) => node.resolvedType !== rootType).map((node) => visit(node, []));
426
- for (const node of levelNodes) if (!primary.has(node.id)) orphans.push(visit(node, []));
433
+ const roots = graph.hierarchyRoots.map((node) => visit(node, []));
434
+ const orphans = graph.orphans.map((node) => visit(node, []));
435
+ for (const node of graph.nodes.values()) if (levelTypes.has(node.resolvedType) && !primary.has(node.id)) orphans.push(visit(node, []));
427
436
  return {
428
437
  roots,
429
438
  orphans,
@@ -526,4 +535,4 @@ function position(node, axis, [min, max]) {
526
535
  //#endregion
527
536
  export { buildLandscape as a, isHierarchyEdge as c, filterAnnotations as d, worstSeverity as f, buildNeighbourhood as i, occurrenceKey as l, buildTree as n, assignLanes as o, treeConnectors as r, edgesWithin as s, buildXYPlot as t, annotationsFrom as u };
528
537
 
529
- //# sourceMappingURL=projection-DKNLziP0.js.map
538
+ //# sourceMappingURL=projection-DTgG05R5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projection-DTgG05R5.js","names":[],"sources":["../src/core/annotations.ts","../src/core/layouts/helpers.ts","../src/core/layouts/landscape/projection.ts","../src/core/layouts/neighbourhood/projection.ts","../src/core/layouts/tree/projection.ts","../src/core/layouts/xy/projection.ts"],"sourcesContent":["import type { RuleSeverity, SpaceGraph, ValidationResult } from 'structured-context/api';\nimport type { NodeId, SourceLocation, ValidationIssueKind } from 'structured-context/types';\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 } from 'structured-context/api';\nimport type { NodeId } from 'structured-context/types';\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/**\n * A connector between two occurrences, by key, in the direction of the edge it draws.\n * `field` is the field the edge is declared in. `lane` separates connectors joining the same two\n * occurrences: 0 when there's one, otherwise centred around 0 (e.g. -0.5 and 0.5).\n * `dashed` marks a connector that is secondary to the layout's structure.\n */\nexport type Connector = { from: string; to: string; field?: string; lane?: number; dashed?: boolean };\n\n/** Spread connectors joining the same pair of occurrences (in either direction) into lanes around 0. */\nexport function assignLanes(connectors: Connector[]) {\n const byPair = new Map<string, Connector[]>();\n for (const connector of connectors) {\n const pair = [connector.from, connector.to].sort().join('\\n');\n byPair.set(pair, [...(byPair.get(pair) ?? []), connector]);\n }\n for (const group of byPair.values()) {\n group.forEach((connector, i) => {\n connector.lane = i - (group.length - 1) / 2;\n });\n }\n}\n\n/**\n * One step of an occurrence path: a node title, a `[field, value]` group, `null` for the ungrouped\n * area, or a number for a part of the layout picked by position. Each kind encodes differently in\n * JSON, so none can collide with another.\n */\nexport type PathSegment = string | readonly [field: string, value: string | null] | null | number;\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 { LayoutConfig } from '../../definition';\nimport { childEdges, occurrenceKey, type PathSegment, parentEdges } from '../helpers';\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, within its strip. */\n level: number;\n /** A node, or a field value common to 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\ntype ViaStep = { type: string; nodes: SpaceNode[] };\n\n/** A group of a dimension: a node of the dimension's type, or a value of its field. It holds nothing itself. */\nexport type LandscapeGroup = Pick<LandscapeOccurrence, 'key' | 'item'>;\n\ntype LandscapeStrip = {\n /** The strip's own dimension, dividing it further. */\n dimension?: LandscapeGroup[];\n /**\n * A cell for every group of the layout's dimension paired with every group of the strip's own, the\n * layout's varying slowest. A strip with no dimension has one cell.\n */\n cells: LandscapeCell[];\n /**\n * Nodes of the strip's levels that no cell or container reached (e.g. an Activity with no\n * Outcome when grouping by Outcomes), each with its own contents. Empty when the strip hides them.\n */\n ungrouped: LandscapeOccurrence[];\n};\n\n/** What the strip's grouping levels place among the nodes that belong to one group of each dimension. */\ntype LandscapeCell = {\n /** Path-based key of the strip and its group or pair of groups. */\n key: string;\n /** Indexes of its groups in the layout's dimension and in the strip's own; 0 where there is none. */\n at: [layout: number, strip: number];\n children: LandscapeOccurrence[];\n};\n\n/**\n * The layout as strips divided into cells. A dimension's groups are worked out once, so every cell\n * exists, empty or not. Which axis a dimension runs along is the component's choice. A plain\n * landscape is one strip with one cell and no dimension: the cell holds its top-level containers.\n */\nexport type Landscape = {\n /** The layout's dimension: its groups divide every strip alike, so the strips line up. */\n dimension?: LandscapeGroup[];\n /** The strips, in order. */\n strips: LandscapeStrip[];\n};\n\ntype Candidate = { node: SpaceNode; via: ViaStep[] };\ntype ValueFilter = { field: string; value: string | null };\ntype NodeFilter = { node: SpaceNode; edge?: string };\n/** Keeps the nodes with a field value, or the nodes joined to a node (across edges from `edge`, if set). */\ntype Filter = ValueFilter | NodeFilter;\n\n/**\n * Lay a space out as strips of nested containers following each strip'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 *\n * A dimension divides a strip into cells. A strip's first level is joined to a dimension's node the\n * way a level is joined to the node level above, so `via` applies there too.\n */\nexport function buildLandscape(graph: SpaceGraph, regionId: string, layout: LayoutConfig<'landscape'>): Landscape {\n const spaceOrder = new Map([...graph.nodes.keys()].map((title, i) => [title, i]));\n const nodeOrder = (node: SpaceNode): number | undefined => {\n const value = (node.schemaData as Record<string, unknown> | undefined)?.order;\n return typeof value === 'number' && Number.isFinite(value) ? value : undefined;\n };\n /** Sort nodes by numeric `order` ascending (matching SpaceGraph), falling back to space order. */\n const compareNodes = (a: SpaceNode, b: SpaceNode): number => {\n const oa = nodeOrder(a);\n const ob = nodeOrder(b);\n if (oa !== undefined && ob !== undefined && oa !== ob) return oa - ob;\n if (oa !== undefined && ob === undefined) return -1;\n if (oa === undefined && ob !== undefined) return 1;\n return spaceOrder.get(a.id)! - spaceOrder.get(b.id)!;\n };\n // The first occurrence of each node, across strips, for marking repeats.\n const first = new Map<string, string>();\n\n const occurrenceFor = (\n strip: StripContext,\n candidate: Candidate,\n levelIdx: number,\n path: readonly PathSegment[],\n ): 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 strip.placed.add(node.id);\n return {\n key,\n level: levelIdx,\n item: { kind: 'node', node },\n via: candidate.via,\n ...(repeatOf !== undefined && { repeatOf }),\n children: place(strip, levelIdx + 1, node, [], nodePath),\n };\n };\n\n /** Occurrences for level `levelIdx` of a strip inside `anchor`, the nearest enclosing node. */\n const place = (\n strip: StripContext,\n levelIdx: number,\n anchor: SpaceNode | undefined,\n filters: readonly Filter[],\n path: readonly PathSegment[],\n ): LandscapeOccurrence[] => {\n const level = strip.levels[levelIdx];\n if (level === undefined) return [];\n if (isTypeLevel(level)) {\n return candidates(level, anchor, filters).map((c) => occurrenceFor(strip, c, levelIdx, path));\n }\n\n const nodeLevel = strip.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(strip, levelIdx + 1, anchor, [...filters, { field: level.field, value }], valuePath),\n };\n });\n };\n\n /**\n * Nodes of a type level joined to `anchor` and matching the filters. With no anchor they are all\n * of the type at the top, or, under dimension nodes, those joined to every one of them.\n */\n const candidates = (level: TypeLevel, anchor: SpaceNode | undefined, filters: readonly Filter[]): Candidate[] => {\n const nodeFilters = filters.filter((f): f is NodeFilter => 'node' in f);\n let reached: Candidate[];\n if (anchor !== undefined) {\n reached = walkChain(anchor, level.via ?? [], level.type, level.edge?.field);\n } else if (nodeFilters.length === 0) {\n reached = ofType(level.type).map((node) => ({ node, via: [] }));\n } else {\n // PROTOTYPE: a dimension's `edge` applies to the last hop of a `via` chain, like a level's own,\n // and the skipped nodes shown for `intermediate: breadcrumb` come from the layout dimension only.\n const [head, ...rest] = nodeFilters.map((f) =>\n walkChain(f.node, level.via ?? [], level.type, f.edge ?? level.edge?.field),\n );\n reached = head!.filter((c) => rest.every((others) => others.some((o) => o.node.id === c.node.id)));\n }\n const values = filters.filter((f): f is ValueFilter => 'field' in f);\n return reached.filter(({ node }) => values.every((f) => valuesOf(node, f.field).includes(f.value)));\n };\n\n const ofType = (type: string) =>\n [...graph.nodes.values()].filter((node) => node.resolvedType === type).sort(compareNodes);\n\n /** Neighbours of a node with the given type, across edges in either direction, in `order` then 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(compareNodes);\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) => compareNodes(a.node, b.node));\n };\n\n /**\n * A dimension's groups, worked out once. A type dimension lists every node of its type, so it can\n * show a group that holds nothing. A field dimension takes the values the nodes of `drawn` (the\n * types of the first node level of each strip it divides) have, so a value no node has is not a group.\n * A node with no value, or joined to no node of the dimension, is in none of its groups; it\n * is shown as ungrouped, the same for both kinds.\n * PROTOTYPE: field dimension groups come in first-seen order. A field's declared domain would give\n * the order authors expect and let a field dimension show empty groups too.\n */\n const dimensionGroups = (\n dimension: Dimension,\n drawn: readonly string[],\n prefix: readonly PathSegment[],\n ): { group: LandscapeGroup; filter: Filter; segment: PathSegment }[] => {\n if ('type' in dimension) {\n return ofType(dimension.type).map((node) => ({\n group: { key: occurrenceKey(regionId, [...prefix, node.id]), item: { kind: 'node', node } },\n filter: { node, edge: dimension.edge?.field },\n segment: node.id,\n }));\n }\n const { field } = dimension;\n const nodes = drawn.flatMap(ofType);\n return distinctValues(nodes, field)\n .filter((v) => v !== null)\n .map((value) => ({\n group: { key: occurrenceKey(regionId, [...prefix, [field, value]]), item: { kind: 'value', field, value } },\n filter: { field, value },\n segment: [field, value],\n }));\n };\n\n const firstNodeType = (strip: Strip) => strip.group.find(isTypeLevel)!.type;\n\n /** Nodes of the strip's levels that no container or cell reached get their own contents, like tree orphans. */\n const orphans = (strip: StripContext, hasDimension: boolean, path: readonly PathSegment[]) => {\n const ungrouped: LandscapeOccurrence[] = [];\n strip.levels.forEach((level, levelIdx) => {\n // The first level has no container above it unless a dimension divides the strip.\n if ((levelIdx === 0 && !hasDimension) || !isTypeLevel(level)) return;\n for (const node of ofType(level.type)) {\n if (!strip.placed.has(node.id)) {\n ungrouped.push(occurrenceFor(strip, { node, via: [] }, levelIdx, [...path, null]));\n }\n }\n });\n return ungrouped;\n };\n\n const layoutGroups = layout.dimension\n ? dimensionGroups(layout.dimension, [...new Set(layout.strips.map(firstNodeType))], [])\n : undefined;\n const strips = layout.strips.map((strip, s): LandscapeStrip => {\n const context: StripContext = { levels: strip.group, placed: new Set() };\n // Keys name the strip only where several could share a path; a lone strip keeps the shorter key.\n const stripPath: PathSegment[] = layout.strips.length > 1 ? [s] : [];\n const own = strip.dimension ? dimensionGroups(strip.dimension, [firstNodeType(strip)], stripPath) : undefined;\n const cells = (layoutGroups ?? [undefined]).flatMap((a, i) =>\n (own ?? [undefined]).map((b, j): LandscapeCell => {\n const along = [a, b].filter((d) => d !== undefined);\n const path = [...stripPath, ...along.map((d) => d.segment)];\n return {\n key: occurrenceKey(regionId, path),\n at: [i, j],\n children: place(\n context,\n 0,\n undefined,\n along.map((d) => d.filter),\n path,\n ),\n };\n }),\n );\n return {\n ...(own && { dimension: own.map((d) => d.group) }),\n cells,\n ungrouped: strip.showUngrouped\n ? orphans(context, layoutGroups !== undefined || own !== undefined, stripPath)\n : [],\n };\n });\n\n return { ...(layoutGroups && { dimension: layoutGroups.map((d) => d.group) }), strips };\n}\n\n/** A strip being placed: its levels, and the nodes it has drawn so far. */\ntype StripContext = { levels: readonly GroupLevel[]; placed: Set<string> };\ntype Strip = LayoutConfig<'landscape'>['strips'][number];\ntype GroupLevel = Strip['group'][number];\ntype TypeLevel = Extract<GroupLevel, { type: string }>;\ntype Dimension = NonNullable<LayoutConfig<'landscape'>['dimension']>;\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","import type { SpaceGraph, SpaceNode } from 'structured-context/api';\nimport type { LayoutConfig } from '../../definition';\nimport {\n assignLanes,\n type Connector,\n childEdges,\n type Edge,\n isHierarchyEdge,\n occurrenceKey,\n parentEdges,\n} from '../helpers';\n\ntype NeighbourhoodRole = 'above' | 'below' | 'left' | 'right';\n\n/** One occurrence in a neighbourhood. A neighbour is placed once, however many fields join it to the focus. */\nexport type Neighbour = { key: string; node: SpaceNode };\n\nexport type Neighbourhood = {\n /** `undefined` when the graph has no nodes. */\n focus: Neighbour | undefined;\n roles: Record<NeighbourhoodRole, Neighbour[]>;\n /**\n * The nodes that share a hierarchy parent with the focus or, for a hierarchy root, the other\n * roots of its type. No edge joins them to the focus, so they have no connector.\n */\n siblings: Neighbour[];\n connectors: Connector[];\n};\n\nconst ORDER: readonly NeighbourhoodRole[] = ['above', 'below', 'left', 'right'];\n\n/**\n * The focus and its neighbours placed by role. Without a usable `focusId`, the focus is the\n * first hierarchy root, else the first node.\n */\nexport function buildNeighbourhood(\n graph: SpaceGraph,\n regionId: string,\n layout: LayoutConfig<'neighbourhood'>,\n focusId?: SpaceNode['id'],\n): Neighbourhood {\n const roles: Neighbourhood['roles'] = { above: [], below: [], left: [], right: [] };\n const node = (focusId && graph.nodes.get(focusId)) || graph.hierarchyRoots[0] || graph.nodes.values().next().value;\n if (!node) return { focus: undefined, roles, siblings: [], connectors: [] };\n const focus = { key: occurrenceKey(regionId, [node.id]), node };\n\n // A field a role lists goes there. Otherwise the hierarchy runs down the page and relationships\n // sit to the left; with no hierarchy, every edge runs down the page.\n const roleOf = (edge: Edge, direction: 'parent' | 'child'): NeighbourhoodRole => {\n const listed = ORDER.find((role) => layout[role].includes(edge.field));\n if (listed) return listed;\n if (graph.hierarchy && !isHierarchyEdge(edge, graph.hierarchy)) return 'left';\n return direction === 'parent' ? 'above' : 'below';\n };\n\n const best = new Map<SpaceNode['id'], NeighbourhoodRole>();\n const connectors: Connector[] = [];\n const neighbour = (edge: Edge, direction: 'parent' | 'child') => {\n const id = edge[direction];\n const { field } = edge;\n if (id === node.id || !graph.nodes.has(id)) return;\n const role = roleOf(edge, direction);\n const current = best.get(id);\n if (!current || ORDER.indexOf(role) < ORDER.indexOf(current)) best.set(id, role);\n const key = occurrenceKey(regionId, [node.id, id]);\n connectors.push(direction === 'parent' ? { from: key, to: focus.key, field } : { from: focus.key, to: key, field });\n };\n for (const edge of parentEdges(graph, node.id)) neighbour(edge, 'parent');\n for (const edge of childEdges(graph, node.id)) neighbour(edge, 'child');\n\n const occurrence = (other: SpaceNode) => ({ key: occurrenceKey(regionId, [node.id, other.id]), node: other });\n for (const [id, role] of best) roles[role].push(occurrence(graph.nodes.get(id)!));\n const hierarchyParents = parentEdges(graph, node.id).filter((edge) => isHierarchyEdge(edge, graph.hierarchy));\n const sameLevel = graph.hierarchyRoots.includes(node)\n ? graph.hierarchyRoots.filter((root) => root.resolvedType === node.resolvedType)\n : hierarchyParents\n .flatMap((edge) => childEdges(graph, edge.parent))\n .filter((edge) => isHierarchyEdge(edge, graph.hierarchy))\n .map((edge) => graph.nodes.get(edge.child)!);\n const siblings = [...new Set(sameLevel)].filter((other) => other !== node && !best.has(other.id)).map(occurrence);\n assignLanes(connectors);\n return { focus, roles, siblings, connectors };\n}\n","import type { SpaceGraph, SpaceNode } from 'structured-context/api';\nimport type { LayoutConfig } from '../../definition';\nimport { type Connector, childEdges, isHierarchyEdge, occurrenceKey } from '../helpers';\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 /** The field the parent declares this node through (the edge's label); unset for roots. */\n field?: 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, connectors from a node's other parents to its primary occurrence, which\n * replace repeat occurrences. Empty in repeat mode.\n */\n crossConnectors: Connector[];\n};\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: LayoutConfig<'tree'>['dag'] = 'repeat'): Tree {\n const { hierarchy } = graph;\n const levelTypes = new Set(hierarchy?.levels.map((level) => level.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; field: string }[] = [];\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, under the first.\n const childFields = new Map<SpaceNode['id'], string>();\n for (const edge of childEdges(graph, node.id)) {\n if (isHierarchyEdge(edge, hierarchy) && !childFields.has(edge.child)) childFields.set(edge.child, edge.field);\n }\n const children: TreeOccurrence[] = [];\n for (const [title, field] of childFields) {\n const child = graph.nodes.get(title)!;\n const repeatOf = primary.get(title);\n if (repeatOf === undefined) children.push({ ...visit(child, nodePath), field });\n else if (dag === 'repeat')\n children.push({\n key: occurrenceKey(regionId, [...nodePath, title]),\n node: child,\n children: [],\n repeatOf,\n field,\n });\n else pendingCross.push({ from: key, child: title, field });\n }\n return { key, node, children };\n };\n\n const roots = graph.hierarchyRoots.map((node) => visit(node, []));\n const orphans = graph.orphans.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 graph.nodes.values()) {\n if (levelTypes.has(node.resolvedType) && !primary.has(node.id)) orphans.push(visit(node, []));\n }\n\n const crossConnectors = pendingCross.map(({ from, child, field }) => ({\n from,\n to: primary.get(child)!,\n field,\n dashed: true,\n }));\n return { roots, orphans, primary, crossConnectors };\n}\n\n/** Parent → child pairs of occurrence keys: one per rendered parent-child connector, then cross-edge connectors. */\nexport function treeConnectors(tree: Tree): Connector[] {\n const connectors: Connector[] = [];\n const walk = (occurrence: TreeOccurrence) => {\n for (const child of occurrence.children) {\n connectors.push({ from: occurrence.key, to: child.key, field: child.field });\n walk(child);\n }\n };\n for (const root of [...tree.roots, ...tree.orphans]) walk(root);\n return [...connectors, ...tree.crossConnectors];\n}\n","import type { SpaceGraph, SpaceNode } from 'structured-context/api';\nimport type { LayoutConfig } from '../../definition';\nimport { assignLanes, type Connector, edgesWithin, isHierarchyEdge, occurrenceKey } from '../helpers';\n\ntype XYPlot = {\n /** `x` and `y` run from 0 to 1 across the plot, left to right and bottom to top. */\n points: { key: string; node: SpaceNode; x: number; y: number }[];\n /** Nodes of a plotted type that couldn't be placed, with the reason per axis. */\n unplaced: { key: string; node: SpaceNode; reasons: string[] }[];\n /** Relationship edges are dashed, to tell them from the hierarchy. */\n connectors: Connector[];\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: LayoutConfig<'xy'>): 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: XYPlot['points'] = [];\n const unplaced: XYPlot['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 connectors: Connector[] = 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 dashed: !isHierarchyEdge(e, graph.hierarchy),\n }));\n assignLanes(connectors);\n\n return { points, unplaced, connectors, 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: LayoutConfig<'xy'>['x'], 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(\n node: SpaceNode,\n axis: LayoutConfig<'xy'>['x'],\n [min, max]: readonly [number, number],\n): 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"],"mappings":";;AAmCA,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,SAAS;CAAG,MAAM;AAAE;;AAGvE,SAAgB,cAAc,aAA8D;CAC1F,OAAO,YAAY,QAChB,OAAO,EAAE,eAAgB,UAAU,KAAA,KAAa,KAAK,YAAY,KAAK,SAAS,WAAW,OAC3F,KAAA,CACF;AACF;;;;;AAMA,SAAgB,kBACd,OACA,OACA,SACiB;CACjB,IAAI,UAAU,OAAO,uBAAO,IAAI,IAAI;CACpC,MAAM,2BAAW,IAAI,IAAuC;CAC5D,KAAK,MAAM,CAAC,IAAI,gBAAgB,OAAO;EACr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M,GAAG,MAAM,cAAc,IAAI,GAAG;CACnF,MAAM,KAAK,QAAQ,QAAQ,MAAM;CACjC,OAAO,KAAK,cAAc,eAAe,IAAI,IAAI;AACnD"}
@@ -14,18 +14,27 @@ var SCHEME = "sctx-map-view://";
14
14
  var PACKAGE_NAME = "structured-context-map-views";
15
15
  /**
16
16
  * Definitions in `folders` and this package's embedded ones, each checked against the namespace of its source.
17
- * Throws on the first invalid definition or a repeated id.
17
+ * Throws on the first invalid definition or a repeated id unless `onError` is provided, in which case
18
+ * invalid definitions are reported to `onError` and skipped so valid definitions still load.
18
19
  */
19
- function readDefinitionFolders(folders) {
20
+ function readDefinitionFolders(folders, options = {}) {
20
21
  const foundAt = /* @__PURE__ */ new Map();
21
22
  const definitions = [];
22
23
  const add = (label, text, source) => {
23
- const definition = parseMapViewDefinition(label, text);
24
- assertIdNamespace(definition.id, source, label);
25
- const existing = foundAt.get(definition.id);
26
- if (existing) throw new Error(`Map view id "${definition.id}" is defined by both ${existing} and ${label}.`);
27
- foundAt.set(definition.id, label);
28
- definitions.push(definition);
24
+ try {
25
+ const definition = parseMapViewDefinition(label, text);
26
+ assertIdNamespace(definition.id, source, label);
27
+ const existing = foundAt.get(definition.id);
28
+ if (existing) throw new Error(`Map view id "${definition.id}" is defined by both ${existing} and ${label}.`);
29
+ foundAt.set(definition.id, label);
30
+ definitions.push(definition);
31
+ } catch (err) {
32
+ if (!options.onError) throw err;
33
+ options.onError({
34
+ path: label,
35
+ message: err instanceof Error ? err.message : String(err)
36
+ });
37
+ }
29
38
  };
30
39
  for (const [file, text] of Object.entries(BUNDLED_DEFINITIONS)) add(`${PACKAGE_NAME}/${file}`, text, { kind: "core" });
31
40
  for (const { dir, source } of folders) {
@@ -48,4 +57,4 @@ function isDirectory(path) {
48
57
  //#endregion
49
58
  export { readDefinitionFolders as t };
50
59
 
51
- //# sourceMappingURL=read-definitions-DFcOXatz.js.map
60
+ //# sourceMappingURL=read-definitions-BRHtaObL.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"read-definitions-DFcOXatz.js","names":[],"sources":["../src/node/bundled-definitions.ts","../src/node/read-definitions.ts"],"sourcesContent":["// Generated by scripts/generate-definitions.ts from map-views/*.json5. Do not edit.\nexport const BUNDLED_DEFINITIONS: Record<string, string> = {\n \"graph.json5\": \"// Every node and edge as a network. Any schema.\\n{\\n $schema: 'https://raw.githubusercontent.com/mindsocket/structured-context-map-views/main/schemas/generated/latest/definition.json',\\n $id: 'sctx-map-view://core/graph',\\n title: 'Graph',\\n parameters: {\\n nodeStyle: { $ref: 'settings.json#/$defs/nodeStyle', default: 'shape' },\\n labels: { type: 'boolean', title: 'Relationship labels', default: false },\\n validation: { $ref: 'settings.json#/$defs/validationLevel', default: 'off' },\\n },\\n regions: [\\n {\\n id: 'main',\\n layout: { type: 'graph' },\\n nodes: { style: { $param: 'nodeStyle' }, validation: { $param: 'validation' } },\\n edges: { show: true, labels: { $param: 'labels' } },\\n },\\n ],\\n}\\n\",\n \"neighbourhood.json5\": \"// One node with the nodes it is related to around it. Any schema.\\n{\\n $schema: 'https://raw.githubusercontent.com/mindsocket/structured-context-map-views/main/schemas/generated/latest/definition.json',\\n $id: 'sctx-map-view://core/neighbourhood',\\n title: 'Neighbourhood',\\n parameters: {\\n labels: { type: 'boolean', title: 'Relationship labels', default: true },\\n validation: { $ref: 'settings.json#/$defs/validationLevel', default: 'off' },\\n },\\n regions: [\\n {\\n id: 'main',\\n layout: { type: 'neighbourhood' },\\n nodes: { validation: { $param: 'validation' } },\\n edges: { show: true, labels: { $param: 'labels' } },\\n },\\n ],\\n}\\n\",\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 \"tree.json5\": \"// The hierarchy as a tree. Any schema that has one.\\n{\\n $schema: 'https://raw.githubusercontent.com/mindsocket/structured-context-map-views/main/schemas/generated/latest/definition.json',\\n $id: 'sctx-map-view://core/tree',\\n title: 'Tree',\\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 },\\n regions: [\\n {\\n id: 'main',\\n layout: { type: 'tree', orientation: { $param: 'orientation' } },\\n nodes: { style: { $param: 'nodeStyle' }, validation: { $param: 'validation' } },\\n edges: { show: true },\\n },\\n ],\\n}\\n\",\n};\n","import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { type MapViewDefinition, parseMapViewDefinition } from '../core/definition';\nimport { BUNDLED_DEFINITIONS } from './bundled-definitions';\n\nconst SCHEME = 'sctx-map-view://';\nconst PACKAGE_NAME = 'structured-context-map-views';\n\nexport type DefinitionSource = { kind: 'core' } | { kind: 'plugin'; plugin: string } | { kind: 'config' };\n\n/**\n * Definitions in `folders` and this package's embedded ones, each checked against the namespace of its source.\n * Throws on the first invalid definition or a repeated id.\n */\nexport function readDefinitionFolders(folders: { dir: string; source: DefinitionSource }[]): MapViewDefinition[] {\n const foundAt = new Map<string, string>();\n const definitions: MapViewDefinition[] = [];\n const add = (label: string, text: string, source: DefinitionSource) => {\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\nfunction assertIdNamespace(id: string, source: DefinitionSource, 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;CACzD,eAAe;CACf,uBAAuB;CACvB,uBAAuB;CACvB,cAAc;AAChB;;;ACDA,IAAM,SAAS;AACf,IAAM,eAAe;;;;;AAQrB,SAAgB,sBAAsB,SAA2E;CAC/G,MAAM,0BAAU,IAAI,IAAoB;CACxC,MAAM,cAAmC,CAAC;CAC1C,MAAM,OAAO,OAAe,MAAc,WAA6B;EACrE,MAAM,aAAa,uBAAuB,OAAO,IAAI;EACrD,kBAAkB,WAAW,IAAI,QAAQ,KAAK;EAC9C,MAAM,WAAW,QAAQ,IAAI,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ent":["// Generated by scripts/generate-definitions.ts from map-views/*.json5. Do not edit.\nexport const BUNDLED_DEFINITIONS: Record<string, string> = {\n \"graph.json5\": \"// Every node and edge as a network. Any schema.\\n{\\n $schema: 'https://raw.githubusercontent.com/mindsocket/structured-context-map-views/main/schemas/generated/latest/definition.json',\\n $id: 'sctx-map-view://core/graph',\\n title: 'Graph',\\n parameters: {\\n nodeStyle: { $ref: 'settings.json#/$defs/nodeStyle', default: 'shape' },\\n labels: { type: 'boolean', title: 'Relationship labels', default: false },\\n validation: { $ref: 'settings.json#/$defs/validationLevel', default: 'off' },\\n },\\n regions: [\\n {\\n id: 'main',\\n layout: { type: 'graph' },\\n nodes: { style: { $param: 'nodeStyle' }, validation: { $param: 'validation' } },\\n edges: { show: true, labels: { $param: 'labels' } },\\n },\\n ],\\n}\\n\",\n \"neighbourhood.json5\": \"// One node with the nodes it is related to around it. Any schema.\\n{\\n $schema: 'https://raw.githubusercontent.com/mindsocket/structured-context-map-views/main/schemas/generated/latest/definition.json',\\n $id: 'sctx-map-view://core/neighbourhood',\\n title: 'Neighbourhood',\\n parameters: {\\n labels: { type: 'boolean', title: 'Relationship labels', default: true },\\n validation: { $ref: 'settings.json#/$defs/validationLevel', default: 'off' },\\n },\\n regions: [\\n {\\n id: 'main',\\n layout: { type: 'neighbourhood' },\\n nodes: { validation: { $param: 'validation' } },\\n edges: { show: true, labels: { $param: 'labels' } },\\n },\\n ],\\n}\\n\",\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 \"tree.json5\": \"// The hierarchy as a tree. Any schema that has one.\\n{\\n $schema: 'https://raw.githubusercontent.com/mindsocket/structured-context-map-views/main/schemas/generated/latest/definition.json',\\n $id: 'sctx-map-view://core/tree',\\n title: 'Tree',\\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 },\\n regions: [\\n {\\n id: 'main',\\n layout: { type: 'tree', orientation: { $param: 'orientation' } },\\n nodes: { style: { $param: 'nodeStyle' }, validation: { $param: 'validation' } },\\n edges: { show: true },\\n },\\n ],\\n}\\n\",\n};\n","import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { type MapViewDefinition, parseMapViewDefinition } from '../core/definition';\nimport { BUNDLED_DEFINITIONS } from './bundled-definitions';\n\nconst SCHEME = 'sctx-map-view://';\nconst PACKAGE_NAME = 'structured-context-map-views';\n\nexport type DefinitionSource = { kind: 'core' } | { kind: 'plugin'; plugin: string } | { kind: 'config' };\n\n/**\n * Definitions in `folders` and this package's embedded ones, each checked against the namespace of its source.\n * Throws on the first invalid definition or a repeated id unless `onError` is provided, in which case\n * invalid definitions are reported to `onError` and skipped so valid definitions still load.\n */\nexport function readDefinitionFolders(\n folders: { dir: string; source: DefinitionSource }[],\n options: { onError?: (error: { path: string; message: string }) => void } = {},\n): MapViewDefinition[] {\n const foundAt = new Map<string, string>();\n const definitions: MapViewDefinition[] = [];\n const add = (label: string, text: string, source: DefinitionSource) => {\n try {\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 } catch (err) {\n if (!options.onError) throw err;\n options.onError({ path: label, message: err instanceof Error ? err.message : String(err) });\n }\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\nfunction assertIdNamespace(id: string, source: DefinitionSource, 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;CACzD,eAAe;CACf,uBAAuB;CACvB,uBAAuB;CACvB,cAAc;AAChB;;;ACDA,IAAM,SAAS;AACf,IAAM,eAAe;;;;;;AASrB,SAAgB,sBACd,SACA,UAA4E,CAAC,GACxD;CACrB,MAAM,0BAAU,IAAI,IAAoB;CACxC,MAAM,cAAmC,CAAC;CAC1C,MAAM,OAAO,OAAe,MAAc,WAA6B;EACrE,IAAI;GACF,MAAM,aAAa,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AI,MAAM,iCAAiC,KAAK,YAAY,GAAG,mBAAmB,SAAS,GAAG;AAExG;AAEA,SAAS,YAAY,MAAuB;CAC1C,OAAO,WAAW,IAAI,KAAK,SAAS,IAAI,CAAC,CAAC,YAAY;AACxD"}
@@ -2,10 +2,15 @@ import { type Config } from 'structured-context/api';
2
2
  import type { MapViewDefinition } from '../core/definition';
3
3
  /**
4
4
  * Every map view definition available with `config`, found as docs/definitions.md describes.
5
- * Throws on the first invalid definition, including one outside its namespace or with a duplicate `$id`.
5
+ * Throws on the first invalid definition unless `onError` is provided, in which case invalid
6
+ * definitions are reported to `onError` and skipped so valid definitions still load.
6
7
  *
7
8
  * `configDir` is the root of the main config file; it defaults to where structured-context finds it.
8
9
  */
9
10
  export declare function loadMapViewDefinitions(config: Config, options?: {
10
11
  configDir?: string;
12
+ onError?: (error: {
13
+ path: string;
14
+ message: string;
15
+ }) => void;
11
16
  }): MapViewDefinition[];
@@ -9,9 +9,15 @@ export type DefinitionSource = {
9
9
  };
10
10
  /**
11
11
  * Definitions in `folders` and this package's embedded ones, each checked against the namespace of its source.
12
- * Throws on the first invalid definition or a repeated id.
12
+ * Throws on the first invalid definition or a repeated id unless `onError` is provided, in which case
13
+ * invalid definitions are reported to `onError` and skipped so valid definitions still load.
13
14
  */
14
15
  export declare function readDefinitionFolders(folders: {
15
16
  dir: string;
16
17
  source: DefinitionSource;
17
- }[]): MapViewDefinition[];
18
+ }[], options?: {
19
+ onError?: (error: {
20
+ path: string;
21
+ message: string;
22
+ }) => void;
23
+ }): MapViewDefinition[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "structured-context-map-views",
3
- "version": "0.7.2",
3
+ "version": "0.7.4",
4
4
  "description": "Declarative map views of structured-context spaces: render a space as a tree, nested containers and other layouts from a short definition.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -79,7 +79,7 @@
79
79
  "@vitejs/plugin-react": "^6.1.1",
80
80
  "react": "^19.3.0",
81
81
  "react-dom": "^19.3.0",
82
- "structured-context": "^0.26.0",
82
+ "structured-context": "^0.28.1",
83
83
  "tailwindcss": "^4.3.3",
84
84
  "vite": "^8.3.2"
85
85
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"node-ctbuxC-s.js","names":[],"sources":["../src/node/index.ts"],"sourcesContent":["/// <reference types=\"node\" />\nimport { existsSync, readdirSync, readFileSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport { type Config, PLUGIN_PREFIX, resolveConfigPath, resolvePluginDir, resourceDir } from 'structured-context/api';\nimport type { MapViewDefinition } from '../core/definition';\nimport { type DefinitionSource, readDefinitionFolders } from './read-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 DEFINITIONS_DIR = 'map-views';\nconst CONFIG_PLUGINS_DIR = 'plugins';\n\n/**\n * Every map view definition available with `config`, found as docs/definitions.md describes.\n * Throws on the first invalid definition, including one outside its namespace or with a duplicate `$id`.\n *\n * `configDir` is the root of the main config file; it defaults to where structured-context finds it.\n */\nexport function loadMapViewDefinitions(config: Config, options: { configDir?: string } = {}): MapViewDefinition[] {\n const configDir = options.configDir ?? resolveConfigPath().root;\n const configDirs = [...new Set([configDir, ...config.spaces.flatMap((s) => (s.sourceDir ? [s.sourceDir] : []))])];\n\n const folders: { dir: string; source: DefinitionSource }[] = [\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.flatMap((dir) => {\n const definitions = resourceDir(dir, DEFINITIONS_DIR);\n return definitions ? [{ dir: definitions, source: { kind: 'config' } as const }] : [];\n }),\n ];\n\n return readDefinitionFolders(folders);\n}\n\n/** Plugin short name → root directory, for plugins in a config root's plugins folder 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 = resourceDir(dir, CONFIG_PLUGINS_DIR);\n if (!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?.[DEFINITIONS_DIR];\n if (typeof declared === 'string') return resolve(pluginDir, declared);\n }\n return join(pluginDir, DEFINITIONS_DIR);\n}\n"],"mappings":";;;;;;;;;AAYA,IAAM,kBAAkB;AACxB,IAAM,qBAAqB;;;;;;;AAQ3B,SAAgB,uBAAuB,QAAgB,UAAkC,CAAC,GAAwB;CAChH,MAAM,YAAY,QAAQ,aAAa,kBAAkB,CAAC,CAAC;CAC3D,MAAM,aAAa,CAAC,mBAAG,IAAI,IAAI,CAAC,WAAW,GAAG,OAAO,OAAO,SAAS,MAAO,EAAE,YAAY,CAAC,EAAE,SAAS,IAAI,CAAC,CAAE,CAAC,CAAC,CAAC;CAEhH,MAAM,UAAuD,CAC3D,GAAG,WAAW,QAAQ,WAAW,UAAU,CAAC,CAAC,SA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,CAAC,CAAC,GAAG,IAAI,MAAM,OAAO;CACxE;CACA,OAAO,CAAC,GAAG,KAAK;AAClB;AAEA,SAAS,qBAAqB,WAAuC;CACnE,MAAM,UAAU,KAAK,WAAW,cAAc;CAC9C,IAAI,WAAW,OAAO,GAAG;EACvB,MAAM,WAAW,KAAK,MAAM,aAAa,SAAS,MAAM,CAAC,CAAC,CAAC,OAAO;EAClE,IAAI,OAAO,aAAa,UAAU,OAAO,QAAQ,WAAW,QAAQ;CACtE;CACA,OAAO,KAAK,WAAW,eAAe;AACxC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"projection-DKNLziP0.js","names":[],"sources":["../src/core/annotations.ts","../src/core/layouts/helpers.ts","../src/core/layouts/landscape/projection.ts","../src/core/layouts/neighbourhood/projection.ts","../src/core/layouts/tree/projection.ts","../src/core/layouts/xy/projection.ts"],"sourcesContent":["import type { RuleSeverity, SpaceGraph, ValidationResult } from 'structured-context/api';\nimport type { NodeId, SourceLocation, ValidationIssueKind } from 'structured-context/types';\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 } from 'structured-context/api';\nimport type { NodeId } from 'structured-context/types';\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/**\n * A connector between two occurrences, by key, in the direction of the edge it draws.\n * `field` is the field the edge is declared in. `lane` separates connectors joining the same two\n * occurrences: 0 when there's one, otherwise centred around 0 (e.g. -0.5 and 0.5).\n * `dashed` marks a connector that is secondary to the layout's structure.\n */\nexport type Connector = { from: string; to: string; field?: string; lane?: number; dashed?: boolean };\n\n/** Spread connectors joining the same pair of occurrences (in either direction) into lanes around 0. */\nexport function assignLanes(connectors: Connector[]) {\n const byPair = new Map<string, Connector[]>();\n for (const connector of connectors) {\n const pair = [connector.from, connector.to].sort().join('\\n');\n byPair.set(pair, [...(byPair.get(pair) ?? []), connector]);\n }\n for (const group of byPair.values()) {\n group.forEach((connector, i) => {\n connector.lane = i - (group.length - 1) / 2;\n });\n }\n}\n\n/**\n * One step of an occurrence path: a node title, a `[field, value]` group, `null` for the ungrouped\n * area, or a number for a part of the layout picked by position. Each kind encodes differently in\n * JSON, so none can collide with another.\n */\nexport type PathSegment = string | readonly [field: string, value: string | null] | null | number;\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 { LayoutConfig } from '../../definition';\nimport { childEdges, occurrenceKey, type PathSegment, parentEdges } from '../helpers';\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, within its strip. */\n level: number;\n /** A node, or a field value common to 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\ntype ViaStep = { type: string; nodes: SpaceNode[] };\n\n/** A group of a dimension: a node of the dimension's type, or a value of its field. It holds nothing itself. */\nexport type LandscapeGroup = Pick<LandscapeOccurrence, 'key' | 'item'>;\n\ntype LandscapeStrip = {\n /** The strip's own dimension, dividing it further. */\n dimension?: LandscapeGroup[];\n /**\n * A cell for every group of the layout's dimension paired with every group of the strip's own, the\n * layout's varying slowest. A strip with no dimension has one cell.\n */\n cells: LandscapeCell[];\n /**\n * Nodes of the strip's levels that no cell or container reached (e.g. an Activity with no\n * Outcome when grouping by Outcomes), each with its own contents. Empty when the strip hides them.\n */\n ungrouped: LandscapeOccurrence[];\n};\n\n/** What the strip's grouping levels place among the nodes that belong to one group of each dimension. */\ntype LandscapeCell = {\n /** Path-based key of the strip and its group or pair of groups. */\n key: string;\n /** Indexes of its groups in the layout's dimension and in the strip's own; 0 where there is none. */\n at: [layout: number, strip: number];\n children: LandscapeOccurrence[];\n};\n\n/**\n * The layout as strips divided into cells. A dimension's groups are worked out once, so every cell\n * exists, empty or not. Which axis a dimension runs along is the component's choice. A plain\n * landscape is one strip with one cell and no dimension: the cell holds its top-level containers.\n */\nexport type Landscape = {\n /** The layout's dimension: its groups divide every strip alike, so the strips line up. */\n dimension?: LandscapeGroup[];\n /** The strips, in order. */\n strips: LandscapeStrip[];\n};\n\ntype Candidate = { node: SpaceNode; via: ViaStep[] };\ntype ValueFilter = { field: string; value: string | null };\ntype NodeFilter = { node: SpaceNode; edge?: string };\n/** Keeps the nodes with a field value, or the nodes joined to a node (across edges from `edge`, if set). */\ntype Filter = ValueFilter | NodeFilter;\n\n/**\n * Lay a space out as strips of nested containers following each strip'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 *\n * A dimension divides a strip into cells. A strip's first level is joined to a dimension's node the\n * way a level is joined to the node level above, so `via` applies there too.\n */\nexport function buildLandscape(graph: SpaceGraph, regionId: string, layout: LayoutConfig<'landscape'>): Landscape {\n const order = new Map([...graph.nodes.keys()].map((title, i) => [title, i]));\n // The first occurrence of each node, across strips, for marking repeats.\n const first = new Map<string, string>();\n\n const occurrenceFor = (\n strip: StripContext,\n candidate: Candidate,\n levelIdx: number,\n path: readonly PathSegment[],\n ): 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 strip.placed.add(node.id);\n return {\n key,\n level: levelIdx,\n item: { kind: 'node', node },\n via: candidate.via,\n ...(repeatOf !== undefined && { repeatOf }),\n children: place(strip, levelIdx + 1, node, [], nodePath),\n };\n };\n\n /** Occurrences for level `levelIdx` of a strip inside `anchor`, the nearest enclosing node. */\n const place = (\n strip: StripContext,\n levelIdx: number,\n anchor: SpaceNode | undefined,\n filters: readonly Filter[],\n path: readonly PathSegment[],\n ): LandscapeOccurrence[] => {\n const level = strip.levels[levelIdx];\n if (level === undefined) return [];\n if (isTypeLevel(level)) {\n return candidates(level, anchor, filters).map((c) => occurrenceFor(strip, c, levelIdx, path));\n }\n\n const nodeLevel = strip.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(strip, levelIdx + 1, anchor, [...filters, { field: level.field, value }], valuePath),\n };\n });\n };\n\n /**\n * Nodes of a type level joined to `anchor` and matching the filters. With no anchor they are all\n * of the type at the top, or, under dimension nodes, those joined to every one of them.\n */\n const candidates = (level: TypeLevel, anchor: SpaceNode | undefined, filters: readonly Filter[]): Candidate[] => {\n const nodeFilters = filters.filter((f): f is NodeFilter => 'node' in f);\n let reached: Candidate[];\n if (anchor !== undefined) {\n reached = walkChain(anchor, level.via ?? [], level.type, level.edge?.field);\n } else if (nodeFilters.length === 0) {\n reached = ofType(level.type).map((node) => ({ node, via: [] }));\n } else {\n // PROTOTYPE: a dimension's `edge` applies to the last hop of a `via` chain, like a level's own,\n // and the skipped nodes shown for `intermediate: breadcrumb` come from the layout dimension only.\n const [head, ...rest] = nodeFilters.map((f) =>\n walkChain(f.node, level.via ?? [], level.type, f.edge ?? level.edge?.field),\n );\n reached = head!.filter((c) => rest.every((others) => others.some((o) => o.node.id === c.node.id)));\n }\n const values = filters.filter((f): f is ValueFilter => 'field' in f);\n return reached.filter(({ node }) => values.every((f) => valuesOf(node, f.field).includes(f.value)));\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 /**\n * A dimension's groups, worked out once. A type dimension lists every node of its type, so it can\n * show a group that holds nothing. A field dimension takes the values the nodes of `drawn` (the\n * types of the first node level of each strip it divides) have, so a value no node has is not a group.\n * A node with no value, or joined to no node of the dimension, is in none of its groups; it\n * is shown as ungrouped, the same for both kinds.\n * PROTOTYPE: groups come in space order. A field's declared domain, or an `order` field, would give\n * the order authors expect and let a field dimension show empty groups too.\n */\n const dimensionGroups = (\n dimension: Dimension,\n drawn: readonly string[],\n prefix: readonly PathSegment[],\n ): { group: LandscapeGroup; filter: Filter; segment: PathSegment }[] => {\n if ('type' in dimension) {\n return ofType(dimension.type).map((node) => ({\n group: { key: occurrenceKey(regionId, [...prefix, node.id]), item: { kind: 'node', node } },\n filter: { node, edge: dimension.edge?.field },\n segment: node.id,\n }));\n }\n const { field } = dimension;\n const nodes = drawn.flatMap(ofType);\n return distinctValues(nodes, field)\n .filter((v) => v !== null)\n .map((value) => ({\n group: { key: occurrenceKey(regionId, [...prefix, [field, value]]), item: { kind: 'value', field, value } },\n filter: { field, value },\n segment: [field, value],\n }));\n };\n\n const firstNodeType = (strip: Strip) => strip.group.find(isTypeLevel)!.type;\n\n /** Nodes of the strip's levels that no container or cell reached get their own contents, like tree orphans. */\n const orphans = (strip: StripContext, hasDimension: boolean, path: readonly PathSegment[]) => {\n const ungrouped: LandscapeOccurrence[] = [];\n strip.levels.forEach((level, levelIdx) => {\n // The first level has no container above it unless a dimension divides the strip.\n if ((levelIdx === 0 && !hasDimension) || !isTypeLevel(level)) return;\n for (const node of ofType(level.type)) {\n if (!strip.placed.has(node.id)) {\n ungrouped.push(occurrenceFor(strip, { node, via: [] }, levelIdx, [...path, null]));\n }\n }\n });\n return ungrouped;\n };\n\n const layoutGroups = layout.dimension\n ? dimensionGroups(layout.dimension, [...new Set(layout.strips.map(firstNodeType))], [])\n : undefined;\n const strips = layout.strips.map((strip, s): LandscapeStrip => {\n const context: StripContext = { levels: strip.group, placed: new Set() };\n // Keys name the strip only where several could share a path; a lone strip keeps the shorter key.\n const stripPath: PathSegment[] = layout.strips.length > 1 ? [s] : [];\n const own = strip.dimension ? dimensionGroups(strip.dimension, [firstNodeType(strip)], stripPath) : undefined;\n const cells = (layoutGroups ?? [undefined]).flatMap((a, i) =>\n (own ?? [undefined]).map((b, j): LandscapeCell => {\n const along = [a, b].filter((d) => d !== undefined);\n const path = [...stripPath, ...along.map((d) => d.segment)];\n return {\n key: occurrenceKey(regionId, path),\n at: [i, j],\n children: place(\n context,\n 0,\n undefined,\n along.map((d) => d.filter),\n path,\n ),\n };\n }),\n );\n return {\n ...(own && { dimension: own.map((d) => d.group) }),\n cells,\n ungrouped: strip.showUngrouped\n ? orphans(context, layoutGroups !== undefined || own !== undefined, stripPath)\n : [],\n };\n });\n\n return { ...(layoutGroups && { dimension: layoutGroups.map((d) => d.group) }), strips };\n}\n\n/** A strip being placed: its levels, and the nodes it has drawn so far. */\ntype StripContext = { levels: readonly GroupLevel[]; placed: Set<string> };\ntype Strip = LayoutConfig<'landscape'>['strips'][number];\ntype GroupLevel = Strip['group'][number];\ntype TypeLevel = Extract<GroupLevel, { type: string }>;\ntype Dimension = NonNullable<LayoutConfig<'landscape'>['dimension']>;\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","import type { SpaceGraph, SpaceNode } from 'structured-context/api';\nimport type { LayoutConfig } from '../../definition';\nimport {\n assignLanes,\n type Connector,\n childEdges,\n type Edge,\n isHierarchyEdge,\n occurrenceKey,\n parentEdges,\n} from '../helpers';\n\ntype NeighbourhoodRole = 'above' | 'below' | 'left' | 'right';\n\n/** One occurrence in a neighbourhood. A neighbour is placed once, however many fields join it to the focus. */\nexport type Neighbour = { key: string; node: SpaceNode };\n\nexport type Neighbourhood = {\n /** `undefined` when the graph has no nodes. */\n focus: Neighbour | undefined;\n roles: Record<NeighbourhoodRole, Neighbour[]>;\n /**\n * The nodes that share a hierarchy parent with the focus or, for a hierarchy root, the other\n * roots of its type. No edge joins them to the focus, so they have no connector.\n */\n siblings: Neighbour[];\n connectors: Connector[];\n};\n\nconst ORDER: readonly NeighbourhoodRole[] = ['above', 'below', 'left', 'right'];\n\n/**\n * The focus and its neighbours placed by role. Without a usable `focusId`, the focus is the\n * first hierarchy root, else the first node.\n */\nexport function buildNeighbourhood(\n graph: SpaceGraph,\n regionId: string,\n layout: LayoutConfig<'neighbourhood'>,\n focusId?: SpaceNode['id'],\n): Neighbourhood {\n const roles: Neighbourhood['roles'] = { above: [], below: [], left: [], right: [] };\n const node = (focusId && graph.nodes.get(focusId)) || graph.hierarchyRoots[0] || graph.nodes.values().next().value;\n if (!node) return { focus: undefined, roles, siblings: [], connectors: [] };\n const focus = { key: occurrenceKey(regionId, [node.id]), node };\n\n // A field a role lists goes there. Otherwise the hierarchy runs down the page and relationships\n // sit to the left; with no hierarchy, every edge runs down the page.\n const roleOf = (edge: Edge, direction: 'parent' | 'child'): NeighbourhoodRole => {\n const listed = ORDER.find((role) => layout[role].includes(edge.field));\n if (listed) return listed;\n if (graph.hierarchy && !isHierarchyEdge(edge, graph.hierarchy)) return 'left';\n return direction === 'parent' ? 'above' : 'below';\n };\n\n const best = new Map<SpaceNode['id'], NeighbourhoodRole>();\n const connectors: Connector[] = [];\n const neighbour = (edge: Edge, direction: 'parent' | 'child') => {\n const id = edge[direction];\n const { field } = edge;\n if (id === node.id || !graph.nodes.has(id)) return;\n const role = roleOf(edge, direction);\n const current = best.get(id);\n if (!current || ORDER.indexOf(role) < ORDER.indexOf(current)) best.set(id, role);\n const key = occurrenceKey(regionId, [node.id, id]);\n connectors.push(direction === 'parent' ? { from: key, to: focus.key, field } : { from: focus.key, to: key, field });\n };\n for (const edge of parentEdges(graph, node.id)) neighbour(edge, 'parent');\n for (const edge of childEdges(graph, node.id)) neighbour(edge, 'child');\n\n const occurrence = (other: SpaceNode) => ({ key: occurrenceKey(regionId, [node.id, other.id]), node: other });\n for (const [id, role] of best) roles[role].push(occurrence(graph.nodes.get(id)!));\n const hierarchyParents = parentEdges(graph, node.id).filter((edge) => isHierarchyEdge(edge, graph.hierarchy));\n const sameLevel = graph.hierarchyRoots.includes(node)\n ? graph.hierarchyRoots.filter((root) => root.resolvedType === node.resolvedType)\n : hierarchyParents\n .flatMap((edge) => childEdges(graph, edge.parent))\n .filter((edge) => isHierarchyEdge(edge, graph.hierarchy))\n .map((edge) => graph.nodes.get(edge.child)!);\n const siblings = [...new Set(sameLevel)].filter((other) => other !== node && !best.has(other.id)).map(occurrence);\n assignLanes(connectors);\n return { focus, roles, siblings, connectors };\n}\n","import type { SpaceGraph, SpaceNode } from 'structured-context/api';\nimport type { LayoutConfig } from '../../definition';\nimport { type Connector, childEdges, isHierarchyEdge, occurrenceKey, parentEdges } from '../helpers';\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 /** The field the parent declares this node through (the edge's label); unset for roots. */\n field?: 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, connectors from a node's other parents to its primary occurrence, which\n * replace repeat occurrences. Empty in repeat mode.\n */\n crossConnectors: Connector[];\n};\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: LayoutConfig<'tree'>['dag'] = '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; field: 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, under the first.\n const childFields = new Map<SpaceNode['id'], string>();\n for (const edge of childEdges(graph, node.id)) {\n if (isHierarchyEdge(edge, hierarchy) && !childFields.has(edge.child)) childFields.set(edge.child, edge.field);\n }\n const children: TreeOccurrence[] = [];\n for (const [title, field] of childFields) {\n const child = graph.nodes.get(title)!;\n const repeatOf = primary.get(title);\n if (repeatOf === undefined) children.push({ ...visit(child, nodePath), field });\n else if (dag === 'repeat')\n children.push({\n key: occurrenceKey(regionId, [...nodePath, title]),\n node: child,\n children: [],\n repeatOf,\n field,\n });\n else pendingCross.push({ from: key, child: title, field });\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 crossConnectors = pendingCross.map(({ from, child, field }) => ({\n from,\n to: primary.get(child)!,\n field,\n dashed: true,\n }));\n return { roots, orphans, primary, crossConnectors };\n}\n\n/** Parent → child pairs of occurrence keys: one per rendered parent-child connector, then cross-edge connectors. */\nexport function treeConnectors(tree: Tree): Connector[] {\n const connectors: Connector[] = [];\n const walk = (occurrence: TreeOccurrence) => {\n for (const child of occurrence.children) {\n connectors.push({ from: occurrence.key, to: child.key, field: child.field });\n walk(child);\n }\n };\n for (const root of [...tree.roots, ...tree.orphans]) walk(root);\n return [...connectors, ...tree.crossConnectors];\n}\n","import type { SpaceGraph, SpaceNode } from 'structured-context/api';\nimport type { LayoutConfig } from '../../definition';\nimport { assignLanes, type Connector, edgesWithin, isHierarchyEdge, occurrenceKey } from '../helpers';\n\ntype XYPlot = {\n /** `x` and `y` run from 0 to 1 across the plot, left to right and bottom to top. */\n points: { key: string; node: SpaceNode; x: number; y: number }[];\n /** Nodes of a plotted type that couldn't be placed, with the reason per axis. */\n unplaced: { key: string; node: SpaceNode; reasons: string[] }[];\n /** Relationship edges are dashed, to tell them from the hierarchy. */\n connectors: Connector[];\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: LayoutConfig<'xy'>): 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: XYPlot['points'] = [];\n const unplaced: XYPlot['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 connectors: Connector[] = 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 dashed: !isHierarchyEdge(e, graph.hierarchy),\n }));\n assignLanes(connectors);\n\n return { points, unplaced, connectors, 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: LayoutConfig<'xy'>['x'], 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(\n node: SpaceNode,\n axis: LayoutConfig<'xy'>['x'],\n [min, max]: readonly [number, number],\n): 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"],"mappings":";;AAmCA,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,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