structured-context-map-views 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import { i as treeLinks, n as buildLandscape, o as filterAnnotations, r as buildTree, s as worstSeverity, t as buildXYPlot } from "./projection-GaO0MCbR.js";
2
- import { a as resolveRegions, i as resolveParameterValues } from "./definition-Cft28YUA.js";
1
+ import { i as treeLinks, n as buildLandscape, o as filterAnnotations, r as buildTree, s as worstSeverity, t as buildXYPlot } from "./projection-CYShQhug.js";
2
+ import { a as resolveRegions, i as resolveParameterValues } from "./definition-Cp1CCigh.js";
3
3
  import { createContext, useCallback, useContext, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
4
4
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
5
  /** The annotations a map view shows, already narrowed by its validation settings. Read by node cards. */
@@ -664,4 +664,4 @@ function ParameterControls({ definition, values, onChange }) {
664
664
  //#endregion
665
665
  export { SelectParameterInput as a, ParameterInput as i, useParameterControls as n, ToggleParameterInput as o, MultiSelectParameterInput as r, MapView as s, ParameterControls as t };
666
666
 
667
- //# sourceMappingURL=ParameterControls-eKRxNr1P.js.map
667
+ //# sourceMappingURL=ParameterControls--sD0-okx.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ParameterControls-eKRxNr1P.js","names":["_Fragment"],"sources":["../src/layouts/annotations-context.ts","../src/layouts/NodeCard.tsx","../src/layouts/LandscapeLayout.tsx","../src/layouts/EdgeOverlay.tsx","../src/layouts/TreeLayout.tsx","../src/layouts/XYLayout.tsx","../src/layouts/MapView.tsx","../src/layouts/ParameterInputs.tsx","../src/layouts/useParameterControls.ts","../src/layouts/ParameterControls.tsx"],"sourcesContent":["import { createContext, useContext } from 'react';\nimport type { AnnotationIndex } from '../core/annotations';\n\nconst NONE: AnnotationIndex = new Map();\n\n/** The annotations a map view shows, already narrowed by its validation settings. Read by node cards. */\nexport const AnnotationsContext = createContext<AnnotationIndex>(NONE);\n\nexport const useAnnotations = () => useContext(AnnotationsContext);\n","import type { SpaceNode } from 'structured-context/api';\nimport { type NodeAnnotation, type Severity, worstSeverity } from '../core/annotations';\nimport type { NodesConfig } from '../core/definition';\nimport { useAnnotations } from './annotations-context';\n\ntype Props = {\n node: SpaceNode;\n /** The node's subtree is rendered at another occurrence. */\n repeat: boolean;\n nodes: NodesConfig;\n onSelect?: (node: SpaceNode) => void;\n};\n\n/**\n * A clickable node, drawn as a card (title plus selected fields) or a compact shape with a\n * tooltip. Deliberately a `div` with button semantics rather than a `<button>`: hosts style\n * native form controls globally (Obsidian fixes button height and disables wrapping).\n */\nexport function NodeCard({ node, repeat, nodes, onSelect }: Props) {\n const select = () => onSelect?.(node);\n const annotations = useAnnotations().get(node.id);\n const label = `${node.resolvedType}: ${node.title}${repeat ? ' (shown in full elsewhere)' : ''}${annotationsLabel(annotations)}`;\n const onKeyDown = (e: React.KeyboardEvent) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n select();\n }\n };\n const border = repeat ? 'mv:border-dashed mv:border-muted/60 mv:opacity-75' : 'mv:border-edge';\n\n if (nodes.style === 'shape') {\n // 24px: the minimum target size for pointer input (WCAG 2.2 AA). The type's initial is the\n // visible cue; the full type and title are in the tooltip and accessible name.\n return (\n // biome-ignore lint/a11y/useSemanticElements: a native button inherits host button styles.\n <div\n role=\"button\"\n tabIndex={0}\n title={label}\n data-node-id={node.id}\n onClick={select}\n onKeyDown={onKeyDown}\n aria-label={label}\n className={`mv:relative mv:flex mv:size-6 mv:cursor-pointer mv:items-center mv:justify-center mv:rounded-full mv:border-2 mv:bg-card mv:text-[0.65rem] mv:font-semibold mv:uppercase mv:text-muted mv:hover:border-accent mv:focus-visible:outline-2 mv:focus-visible:outline-accent ${border}`}\n >\n <span aria-hidden=\"true\">{node.resolvedType.charAt(0)}</span>\n <AnnotationBadge annotations={annotations} />\n </div>\n );\n }\n\n const fields = nodes.fields\n .map((field) => [field, formatValue(node.schemaData[field])] as const)\n .filter(([, value]) => value !== undefined);\n\n return (\n // biome-ignore lint/a11y/useSemanticElements: a native button inherits host button styles.\n <div\n role=\"button\"\n tabIndex={0}\n title={label}\n data-node-id={node.id}\n onClick={select}\n onKeyDown={onKeyDown}\n className={`mv:relative mv:w-44 mv:cursor-pointer mv:rounded-md mv:border mv:bg-card mv:px-2.5 mv:py-1.5 mv:text-left mv:shadow-sm mv:hover:border-accent mv:focus-visible:outline-2 mv:focus-visible:outline-accent ${border}`}\n >\n <span className=\"mv:block mv:text-[0.65rem] mv:uppercase mv:tracking-wide mv:text-muted\">\n {node.resolvedType}\n {repeat && ' · repeat'}\n </span>\n <span className=\"mv:block mv:text-sm mv:leading-snug\">{node.title}</span>\n {fields.length > 0 && (\n <dl className=\"mv:m-0 mv:mt-1 mv:text-xs mv:text-muted\">\n {fields.map(([field, value]) => (\n <div key={field} className=\"mv:flex mv:gap-1\">\n <dt className=\"mv:shrink-0\">{field}:</dt>\n <dd className=\"mv:m-0 mv:truncate mv:text-ink\">{value}</dd>\n </div>\n ))}\n </dl>\n )}\n <AnnotationBadge annotations={annotations} />\n </div>\n );\n}\n\nconst BADGE: Record<Severity, string> = {\n error: 'mv:bg-error',\n warning: 'mv:bg-warning',\n info: 'mv:bg-info',\n};\n\n/** A count of the node's validation results in the corner, coloured by the most serious. Decorative: the count is in the card's label. */\nfunction AnnotationBadge({ annotations }: { annotations: readonly NodeAnnotation[] | undefined }) {\n const worst = annotations && worstSeverity(annotations);\n if (!annotations || !worst) return null;\n return (\n <span\n aria-hidden=\"true\"\n className={`mv:absolute mv:-top-1.5 mv:-right-1.5 mv:flex mv:h-4 mv:min-w-4 mv:items-center mv:justify-center mv:rounded-full mv:px-1 mv:text-[0.6rem] mv:font-semibold mv:text-white ${BADGE[worst]}`}\n >\n {annotations.length}\n </span>\n );\n}\n\nfunction annotationsLabel(annotations: readonly NodeAnnotation[] | undefined): string {\n const worst = annotations && worstSeverity(annotations);\n if (!annotations || !worst) return '';\n return ` (${annotations.length} validation ${annotations.length === 1 ? 'result' : 'results'}, most serious: ${worst})`;\n}\n\nfunction formatValue(value: unknown): string | undefined {\n if (value === undefined || value === null || value === '') return undefined;\n if (Array.isArray(value)) return value.map(String).join(', ');\n if (typeof value === 'object') return JSON.stringify(value);\n return String(value);\n}\n","import { useMemo } from 'react';\nimport type { SpaceNode } from 'structured-context/api';\nimport type { LandscapeLayoutConfig, Orientation } from '../core/definition';\nimport { buildLandscape, type LandscapeOccurrence } from '../core/landscape';\nimport { NodeCard } from './NodeCard';\nimport type { LayoutProps } from './TreeLayout';\n\n/**\n * Nested containers following the layout's grouping levels; the last level is drawn as nodes.\n * Flexbox does the nesting and wrapping. Containment shows the grouping edges, so no connectors\n * are drawn. PROTOTYPE: `edges.show` has no effect here; other edges aren't drawn yet.\n */\nexport function LandscapeLayout({ graph, region, instanceId, onNodeSelect }: LayoutProps<LandscapeLayoutConfig>) {\n const { layout } = region;\n const landscape = useMemo(() => buildLandscape(graph, region.id, layout), [graph, region.id, layout]);\n const last = layout.group.length - 1;\n\n const breadcrumb = (occurrence: LandscapeOccurrence) => {\n const level = layout.group[occurrence.level];\n if (!level || !('type' in level) || level.intermediate !== 'breadcrumb') return null;\n const steps = occurrence.via.filter((step) => step.nodes.length > 0);\n if (steps.length === 0) return null;\n return (\n <span className=\"mv:block mv:max-w-44 mv:text-[0.65rem] mv:leading-tight mv:text-muted\">\n via {steps.map((step) => step.nodes.map((n) => n.title).join(', ')).join(' › ')}\n </span>\n );\n };\n\n const render = (occurrence: LandscapeOccurrence, direction: Orientation): React.ReactNode => {\n const repeat = occurrence.repeatOf !== undefined;\n const marker = { 'data-occurrence': `${instanceId}${occurrence.key}` };\n\n if (occurrence.item.kind === 'node' && occurrence.level === last) {\n return (\n <li key={occurrence.key} {...marker} className=\"mv:flex mv:flex-col mv:gap-0.5\">\n <NodeCard node={occurrence.item.node} repeat={repeat} nodes={region.nodes} onSelect={onNodeSelect} />\n {breadcrumb(occurrence)}\n </li>\n );\n }\n\n // Containers alternate direction with depth; a container of nodes wraps them.\n const inner: Orientation = direction === 'horizontal' ? 'vertical' : 'horizontal';\n const holdsNodes = occurrence.level + 1 === last;\n return (\n <li\n key={occurrence.key}\n {...marker}\n className={`mv:flex mv:flex-col mv:gap-2 mv:rounded-lg mv:border mv:bg-surface mv:p-2 ${repeat ? 'mv:border-dashed mv:border-muted/60' : 'mv:border-edge'}`}\n >\n {occurrence.item.kind === 'node' ? (\n <ContainerHeading node={occurrence.item.node} repeat={repeat} onSelect={onNodeSelect}>\n {breadcrumb(occurrence)}\n </ContainerHeading>\n ) : (\n <span className=\"mv:text-xs mv:font-semibold mv:text-muted\">\n {occurrence.item.field}: {occurrence.item.value === null ? '(none)' : displayValue(occurrence.item.value)}\n </span>\n )}\n <Items direction={holdsNodes ? 'wrap' : inner}>\n {occurrence.children.map((child) => render(child, inner))}\n </Items>\n </li>\n );\n };\n\n const top = layout.orientation;\n return (\n <div className=\"mv:w-max mv:min-w-full mv:p-4\">\n <Items direction={last === 0 ? 'wrap' : top}>\n {landscape.groups.map((group) => render(group, top))}\n {landscape.ungrouped.length > 0 && (\n <li className=\"mv:flex mv:flex-col mv:gap-2 mv:rounded-lg mv:border mv:border-dashed mv:border-edge mv:p-2\">\n <span className=\"mv:text-xs mv:font-semibold mv:text-muted\">Ungrouped</span>\n <Items direction=\"wrap\">{landscape.ungrouped.map((o) => render(o, top))}</Items>\n </li>\n )}\n </Items>\n </div>\n );\n}\n\nfunction Items({ direction, children }: { direction: Orientation | 'wrap'; children: React.ReactNode }) {\n const layout = {\n horizontal: 'mv:flex-row mv:items-start mv:gap-3',\n vertical: 'mv:flex-col mv:items-stretch mv:gap-2',\n wrap: 'mv:max-w-[36rem] mv:flex-row mv:flex-wrap mv:items-start mv:gap-2',\n }[direction];\n return <ul className={`mv:m-0 mv:flex mv:list-none mv:p-0 ${layout}`}>{children}</ul>;\n}\n\n/** A container's node: type and title, selectable like a card. */\nfunction ContainerHeading({\n node,\n repeat,\n onSelect,\n children,\n}: {\n node: SpaceNode;\n repeat: boolean;\n onSelect?: (node: SpaceNode) => void;\n children?: React.ReactNode;\n}) {\n const select = () => onSelect?.(node);\n return (\n // biome-ignore lint/a11y/useSemanticElements: a native button inherits host button styles.\n <div\n role=\"button\"\n tabIndex={0}\n title={`${node.resolvedType}: ${node.title}${repeat ? ' (also shown elsewhere)' : ''}`}\n onClick={select}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n select();\n }\n }}\n className=\"mv:cursor-pointer mv:rounded mv:px-1 mv:hover:text-accent mv:focus-visible:outline-2 mv:focus-visible:outline-accent\"\n >\n <span className=\"mv:block mv:text-[0.65rem] mv:uppercase mv:tracking-wide mv:text-muted\">\n {node.resolvedType}\n {repeat && ' · repeat'}\n </span>\n <span className=\"mv:block mv:text-sm mv:font-semibold mv:leading-snug\">{node.title}</span>\n {children}\n </div>\n );\n}\n\n/** Field values that are wikilinks show as the linked title. */\nfunction displayValue(value: string): string {\n return value.replace(/^\\[\\[([^\\]|]+)(\\|[^\\]]*)?\\]\\]$/, '$1');\n}\n","import { useLayoutEffect, useState } from 'react';\nimport type { Orientation } from '../core/definition';\n\n/**\n * A connector between two occurrences. `cross` links (e.g. extra parents) are drawn dashed.\n * `id` tells apart several links between the same occurrences; straight links between the same\n * pair are drawn side by side, `lane` apart (0: on the line between centres).\n */\nexport type Link = { from: string; to: string; kind?: 'tree' | 'cross'; id?: string; lane?: number };\n\ntype Props = {\n links: readonly Link[];\n /** Rendered element of each occurrence, by occurrence key. */\n elements: ReadonlyMap<string, HTMLElement>;\n /**\n * Positioned element the overlay covers; coordinates are relative to it. Passed as an element,\n * not a ref: the overlay sits inside it, and React runs a child's layout effects before\n * attaching the parent's ref.\n */\n container: HTMLElement | null;\n /** Curves leaving along the tree's orientation, or straight lines between centres (drawn under the nodes). */\n routing: Orientation | 'straight';\n};\n\ntype Drawn = { key: string; d: string; cross: boolean };\n\n/**\n * SVG layer drawing connectors between rendered occurrences.\n *\n * Measures occurrence elements after layout and redraws when the container or any occurrence\n * resizes, so it follows embedded panes that resize independently of the window, and reflows\n * such as late font loads. The SVG fills the container instead of being sized from it, so it\n * never holds the container open after the layout shrinks.\n */\nexport function EdgeOverlay({ links, elements, container, routing }: Props) {\n const [paths, setPaths] = useState<Drawn[]>([]);\n\n useLayoutEffect(() => {\n if (!container) return;\n\n const measure = () => {\n const origin = container.getBoundingClientRect();\n const paths: Drawn[] = [];\n for (const { from, to, kind, id, lane = 0 } of links) {\n const a = elements.get(from)?.getBoundingClientRect();\n const b = elements.get(to)?.getBoundingClientRect();\n if (!a || !b) continue;\n paths.push({\n key: `${from}→${to}${id ?? ''}`,\n d: routing === 'straight' ? line(a, b, origin, lane) : connector(a, b, origin, routing),\n cross: kind === 'cross',\n });\n }\n setPaths(paths);\n };\n\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(container);\n for (const element of elements.values()) observer.observe(element);\n return () => observer.disconnect();\n }, [links, elements, container, routing]);\n\n return (\n <svg\n aria-hidden=\"true\"\n className=\"mv:pointer-events-none mv:absolute mv:inset-0 mv:h-full mv:w-full mv:overflow-visible\"\n >\n {paths.map(({ key, d, cross }) => (\n <path\n key={key}\n d={d}\n className={`mv:fill-none ${cross ? 'mv:stroke-accent/60' : 'mv:stroke-muted/50'}`}\n strokeWidth={1.5}\n strokeDasharray={cross ? '4 3' : undefined}\n />\n ))}\n </svg>\n );\n}\n\n/** Cubic curve from the parent's trailing edge to the child's leading edge. */\nfunction connector(a: DOMRect, b: DOMRect, origin: DOMRect, orientation: Orientation): string {\n if (orientation === 'vertical') {\n const x1 = a.left + a.width / 2 - origin.left;\n const y1 = a.bottom - origin.top;\n const x2 = b.left + b.width / 2 - origin.left;\n const y2 = b.top - origin.top;\n const my = (y1 + y2) / 2;\n return `M${x1},${y1} C${x1},${my} ${x2},${my} ${x2},${y2}`;\n }\n const x1 = a.right - origin.left;\n const y1 = a.top + a.height / 2 - origin.top;\n const x2 = b.left - origin.left;\n const y2 = b.top + b.height / 2 - origin.top;\n const mx = (x1 + x2) / 2;\n return `M${x1},${y1} C${mx},${y1} ${mx},${y2} ${x2},${y2}`;\n}\n\n/** Pixels between parallel straight links. */\nconst LANE_GAP = 6;\n\n/**\n * Straight line between centres, shifted sideways by its lane; the layout draws nodes over the\n * overlay to hide the ends. The shift is relative to a fixed orientation of the pair, so links in\n * opposite directions between the same nodes still separate.\n */\nfunction line(a: DOMRect, b: DOMRect, origin: DOMRect, lane: number): string {\n const x1 = a.left + a.width / 2 - origin.left;\n const y1 = a.top + a.height / 2 - origin.top;\n const x2 = b.left + b.width / 2 - origin.left;\n const y2 = b.top + b.height / 2 - origin.top;\n const flip = x1 < x2 || (x1 === x2 && y1 < y2) ? 1 : -1;\n const length = Math.hypot(x2 - x1, y2 - y1) || 1;\n const dx = (-(y2 - y1) / length) * lane * LANE_GAP * flip;\n const dy = ((x2 - x1) / length) * lane * LANE_GAP * flip;\n return `M${x1 + dx},${y1 + dy} L${x2 + dx},${y2 + dy}`;\n}\n","import { useCallback, useMemo, useRef, useState } from 'react';\nimport type { SpaceGraph, SpaceNode } from 'structured-context/api';\nimport type { LayoutConfig, Orientation, Region, TreeLayoutConfig } from '../core/definition';\nimport { buildTree, type TreeOccurrence, treeLinks } from '../core/tree';\nimport { EdgeOverlay } from './EdgeOverlay';\nimport { NodeCard } from './NodeCard';\n\nexport type LayoutProps<L extends LayoutConfig = LayoutConfig> = {\n graph: SpaceGraph;\n /** The region with parameter values applied, narrowed to the layout's own settings. */\n region: Region & { layout: L };\n /** Scopes occurrence ids when several map views render in one document. */\n instanceId: string;\n onNodeSelect?: (node: SpaceNode) => void;\n};\n\n/**\n * Tree over the schema's hierarchy. Flexbox does the branching; the SVG overlay draws connectors.\n */\nexport function TreeLayout({ graph, region, instanceId, onNodeSelect }: LayoutProps<TreeLayoutConfig>) {\n const { orientation, dag } = region.layout;\n const tree = useMemo(() => buildTree(graph, region.id, dag), [graph, region.id, dag]);\n const links = useMemo(() => (region.edges.show ? treeLinks(tree) : []), [tree, region.edges.show]);\n\n const [container, setContainer] = useState<HTMLDivElement | null>(null);\n // Filled by ref callbacks during commit, read by the overlay's layout effect afterwards.\n const elements = useRef(new Map<string, HTMLElement>()).current;\n const register = useCallback(\n (key: string) => (el: HTMLElement | null) => {\n if (el) elements.set(key, el);\n else elements.delete(key);\n },\n [elements],\n );\n\n const branch = (occurrence: TreeOccurrence) => (\n <li\n key={occurrence.key}\n className={`mv:flex mv:items-center ${orientation === 'vertical' ? 'mv:flex-col' : 'mv:flex-row'}`}\n >\n <div ref={register(occurrence.key)} data-occurrence={`${instanceId}${occurrence.key}`}>\n <NodeCard\n node={occurrence.node}\n repeat={occurrence.repeatOf !== undefined}\n nodes={region.nodes}\n onSelect={onNodeSelect}\n />\n </div>\n {occurrence.children.length > 0 && (\n <Branches orientation={orientation} nested>\n {occurrence.children.map(branch)}\n </Branches>\n )}\n </li>\n );\n\n return (\n <div ref={setContainer} className=\"mv:relative mv:w-max mv:min-w-full mv:p-4\">\n <Branches orientation={orientation}>{[...tree.roots, ...tree.orphans].map(branch)}</Branches>\n <EdgeOverlay links={links} elements={elements} container={container} routing={orientation} />\n </div>\n );\n}\n\nfunction Branches({\n orientation,\n nested = false,\n children,\n}: {\n orientation: Orientation;\n nested?: boolean;\n children: React.ReactNode;\n}) {\n // Siblings run across the main axis; nested branches leave a gap for connectors.\n const layout =\n orientation === 'vertical'\n ? `mv:flex-row mv:items-start mv:justify-center mv:gap-3 ${nested ? 'mv:pt-10' : ''}`\n : `mv:flex-col mv:items-start mv:justify-center mv:gap-2 ${nested ? 'mv:pl-14' : ''}`;\n return <ul className={`mv:m-0 mv:flex mv:list-none mv:p-0 ${layout}`}>{children}</ul>;\n}\n","import { useCallback, useMemo, useRef, useState } from 'react';\nimport type { AxisConfig, XYLayoutConfig } from '../core/definition';\nimport { buildXYPlot } from '../core/xy';\nimport { EdgeOverlay } from './EdgeOverlay';\nimport { NodeCard } from './NodeCard';\nimport type { LayoutProps } from './TreeLayout';\n\n/**\n * Nodes positioned by two numeric fields, with straight connectors between them. Positions are\n * percentages of the plot area, which fills the container (scrolling below a minimum size). Nodes that can't be\n * placed are listed under the plot with the reason.\n * PROTOTYPE: labels may overlap where nodes sit close together; no collision handling.\n */\nexport function XYLayout({ graph, region, instanceId, onNodeSelect }: LayoutProps<XYLayoutConfig>) {\n const { layout } = region;\n const plot = useMemo(() => buildXYPlot(graph, region.id, layout), [graph, region.id, layout]);\n // Relationship edges (flows, pipelines) are dashed, to tell them from the value chain.\n const links = useMemo(\n () =>\n region.edges.show\n ? plot.links.map(({ from, to, field, hierarchy, lane }) => ({\n from,\n to,\n id: field,\n lane,\n kind: hierarchy ? ('tree' as const) : ('cross' as const),\n }))\n : [],\n [plot, region.edges.show],\n );\n const shape = region.nodes.style === 'shape';\n\n const [container, setContainer] = useState<HTMLDivElement | null>(null);\n const elements = useRef(new Map<string, HTMLElement>()).current;\n const register = useCallback(\n (key: string) => (el: HTMLElement | null) => {\n if (el) elements.set(key, el);\n else elements.delete(key);\n },\n [elements],\n );\n\n return (\n <div className=\"mv:box-border mv:flex mv:h-full mv:min-h-[28rem] mv:min-w-[36rem] mv:flex-col mv:gap-4 mv:p-4\">\n <div className=\"mv:grid mv:min-h-0 mv:flex-1 mv:grid-cols-[auto_1fr] mv:grid-rows-[1fr_auto] mv:gap-1\">\n <AxisTitle axis={layout.y} domain={plot.domains.y} vertical />\n <div ref={setContainer} className=\"mv:relative mv:border-b mv:border-l mv:border-edge\">\n {/* Before the nodes, so the opaque nodes cover the ends of the lines. */}\n <EdgeOverlay links={links} elements={elements} container={container} routing=\"straight\" />\n {/* Inset, so nodes at the ends of a domain stay inside the plot. */}\n <div className=\"mv:absolute mv:inset-8\">\n {plot.points.map((point) => (\n <div\n key={point.key}\n data-occurrence={`${instanceId}${point.key}`}\n className={`mv:absolute mv:flex mv:items-center mv:gap-1 ${shape ? 'mv:-translate-x-3 mv:translate-y-3' : 'mv:-translate-x-1/2 mv:translate-y-1/2'}`}\n style={{ left: `${point.x * 100}%`, bottom: `${point.y * 100}%` }}\n >\n <div ref={register(point.key)}>\n <NodeCard node={point.node} repeat={false} nodes={region.nodes} onSelect={onNodeSelect} />\n </div>\n {shape && (\n <span className=\"mv:whitespace-nowrap mv:rounded mv:bg-surface/80 mv:px-0.5 mv:text-xs\">\n {point.node.title}\n </span>\n )}\n </div>\n ))}\n </div>\n </div>\n <div />\n <AxisTitle axis={layout.x} domain={plot.domains.x} />\n </div>\n\n {plot.unplaced.length > 0 && (\n <section className=\"mv:flex mv:flex-col mv:gap-2\">\n <span className=\"mv:text-xs mv:font-semibold mv:text-muted\">Not plotted</span>\n <ul className=\"mv:m-0 mv:flex mv:list-none mv:flex-wrap mv:gap-3 mv:p-0\">\n {plot.unplaced.map(({ key, node, reasons }) => (\n <li key={key} data-occurrence={`${instanceId}${key}`} className=\"mv:flex mv:items-center mv:gap-1\">\n <NodeCard node={node} repeat={false} nodes={region.nodes} onSelect={onNodeSelect} />\n <span className=\"mv:text-xs\">\n {shape && `${node.title} `}\n <span className=\"mv:text-muted\">({reasons.join('; ')})</span>\n </span>\n </li>\n ))}\n </ul>\n </section>\n )}\n </div>\n );\n}\n\n/** Axis title with the values at each end, in drawing order. */\nfunction AxisTitle({\n axis,\n domain: [min, max],\n vertical = false,\n}: {\n axis: AxisConfig;\n domain: readonly [number, number];\n vertical?: boolean;\n}) {\n const [start, end] = axis.direction === 'descending' ? [max, min] : [min, max];\n return (\n <div\n className={`mv:flex mv:items-center mv:justify-between mv:gap-2 mv:text-xs mv:text-muted ${vertical ? 'mv:flex-col-reverse mv:py-8' : 'mv:px-8'}`}\n >\n <span>{format(start)}</span>\n <span className={`mv:font-semibold ${vertical ? 'mv:[writing-mode:vertical-rl] mv:rotate-180' : ''}`}>\n {axis.label ?? axis.field}\n </span>\n <span>{format(end)}</span>\n </div>\n );\n}\n\nfunction format(value: number): string {\n return Number.isInteger(value) ? String(value) : value.toPrecision(3).replace(/\\.?0+$/, '');\n}\n","import { useId, useMemo } from 'react';\nimport type { SpaceGraph, SpaceNode } from 'structured-context/api';\nimport { type AnnotationIndex, filterAnnotations } from '../core/annotations';\nimport { type MapViewDefinition, type ParameterValues, type Region, resolveRegions } from '../core/definition';\nimport { AnnotationsContext } from './annotations-context';\nimport { LandscapeLayout } from './LandscapeLayout';\nimport { type LayoutProps, TreeLayout } from './TreeLayout';\nimport { XYLayout } from './XYLayout';\n\ntype Props = {\n definition: MapViewDefinition;\n graph: SpaceGraph;\n /** Current parameter values (host-owned session state); missing values use defaults. */\n values?: ParameterValues;\n /**\n * Validation results by node (see `annotationsFrom`). Which of them show, and at what severity, is\n * the region's `nodes.validation` setting; with none supplied, nothing is drawn.\n */\n annotations?: AnnotationIndex;\n onNodeSelect?: (node: SpaceNode) => void;\n};\n\nconst EMPTY: AnnotationIndex = new Map();\n\n/** Renders a map view definition against a space. Sizes to its container and scrolls within it. */\nexport function MapView({ definition, graph, values, annotations, onNodeSelect }: Props) {\n const instanceId = useId();\n const regions = useMemo(() => resolveRegions(definition, values), [definition, values]);\n // PROTOTYPE: only the first region is rendered. Arranging several regions is undesigned (#8).\n const region = regions[0]!;\n const props = { graph, instanceId, onNodeSelect };\n const { validation, validationSources } = region.nodes;\n const visibleAnnotations = useMemo(\n () => (annotations ? filterAnnotations(annotations, validation, validationSources) : EMPTY),\n [annotations, validation, validationSources],\n );\n\n return (\n <AnnotationsContext.Provider value={visibleAnnotations}>\n <div className=\"mv:h-full mv:w-full mv:overflow-auto mv:bg-surface mv:text-ink\">{layoutFor(region, props)}</div>\n </AnnotationsContext.Provider>\n );\n}\n\nfunction layoutFor(region: Region, props: Omit<LayoutProps, 'region'>) {\n const { layout } = region;\n switch (layout.type) {\n case 'tree':\n return <TreeLayout {...props} region={{ ...region, layout }} />;\n case 'landscape':\n return <LandscapeLayout {...props} region={{ ...region, layout }} />;\n case 'xy':\n return <XYLayout {...props} region={{ ...region, layout }} />;\n }\n}\n","import { useId } from 'react';\nimport type { Parameter, ParameterControl } from '../core/definition';\n\ntype InputProps<Kind extends ParameterControl['kind']> = {\n parameter: Parameter & { control: Extract<ParameterControl, { kind: Kind }> };\n value: unknown;\n onChange: (value: unknown) => void;\n};\n\nconst same = (a: unknown, b: unknown) => JSON.stringify(a) === JSON.stringify(b);\n\n/** A checkbox for a boolean parameter, labelled with the parameter's title. */\nexport function ToggleParameterInput({ parameter, value, onChange }: InputProps<'toggle'>) {\n const id = useId();\n return (\n <>\n <input id={id} type=\"checkbox\" checked={value === true} onChange={(e) => onChange(e.target.checked)} />\n <label htmlFor={id}>{parameter.title}</label>\n </>\n );\n}\n\n/** A dropdown for a parameter with one of several options. */\nexport function SelectParameterInput({ parameter, value, onChange }: InputProps<'select'>) {\n const id = useId();\n return (\n <>\n <label htmlFor={id} className=\"mv:text-muted\">\n {parameter.title}\n </label>\n <select id={id} value={JSON.stringify(value)} onChange={(e) => onChange(JSON.parse(e.target.value))}>\n {parameter.control.options.map((option) => (\n <option key={JSON.stringify(option)} value={JSON.stringify(option)}>\n {String(option)}\n </option>\n ))}\n </select>\n </>\n );\n}\n\n/** A checkbox group for a parameter taking any subset of its options. */\nexport function MultiSelectParameterInput({ parameter, value, onChange }: InputProps<'multiselect'>) {\n const { options } = parameter.control;\n const selected = Array.isArray(value) ? value : [];\n return (\n <fieldset className=\"mv:m-0 mv:flex mv:flex-wrap mv:items-center mv:gap-2 mv:border-0 mv:p-0\">\n <legend className=\"mv:float-left mv:mr-1.5 mv:p-0 mv:text-muted\">{parameter.title}</legend>\n {options.map((option) => {\n const checked = selected.some((v) => same(v, option));\n return (\n <label key={JSON.stringify(option)} className=\"mv:flex mv:items-center mv:gap-1\">\n <input\n type=\"checkbox\"\n checked={checked}\n onChange={() =>\n // Keep the options' order rather than the order of clicks.\n onChange(options.filter((o) => (o === option ? !checked : selected.some((v) => same(v, o)))))\n }\n />\n {String(option)}\n </label>\n );\n })}\n </fieldset>\n );\n}\n\n/** The input matching a parameter's control kind. */\nexport function ParameterInput({\n parameter,\n value,\n onChange,\n}: Omit<InputProps<ParameterControl['kind']>, 'parameter'> & { parameter: Parameter }) {\n const { control } = parameter;\n switch (control.kind) {\n case 'toggle':\n return <ToggleParameterInput parameter={{ ...parameter, control }} value={value} onChange={onChange} />;\n case 'select':\n return <SelectParameterInput parameter={{ ...parameter, control }} value={value} onChange={onChange} />;\n case 'multiselect':\n return <MultiSelectParameterInput parameter={{ ...parameter, control }} value={value} onChange={onChange} />;\n }\n}\n","import { useMemo } from 'react';\nimport {\n type MapViewDefinition,\n type Parameter,\n type ParameterValues,\n resolveParameterValues,\n} from '../core/definition';\n\n/** One parameter with its current value and a setter, ready for a host to lay out. */\nexport type ParameterControlState = {\n parameter: Parameter;\n /** The value in effect: the host's value, else the default, matching what renders. */\n value: unknown;\n setValue: (value: unknown) => void;\n};\n\n/**\n * The state behind a map view's parameter controls, with no markup, for hosts that lay the controls\n * out themselves. Pair each entry with `ParameterInput`, or with one of the typed inputs.\n */\nexport function useParameterControls(\n definition: MapViewDefinition,\n values: ParameterValues,\n onChange: (name: string, value: unknown) => void,\n): ParameterControlState[] {\n const resolved = useMemo(() => resolveParameterValues(definition, values), [definition, values]);\n return definition.parameters.map((parameter) => ({\n parameter,\n value: resolved[parameter.name],\n setValue: (value) => onChange(parameter.name, value),\n }));\n}\n","import type { MapViewDefinition, ParameterValues } from '../core/definition';\nimport { ParameterInput } from './ParameterInputs';\nimport { useParameterControls } from './useParameterControls';\n\ntype Props = {\n definition: MapViewDefinition;\n /** Host-owned values; missing or stale ones show as the default, matching what renders. */\n values: ParameterValues;\n onChange: (name: string, value: unknown) => void;\n};\n\n/**\n * Default layout for a map view's parameter controls: a wrapping row. Hosts wanting their own layout\n * use `useParameterControls` with `ParameterInput` (or the typed inputs) instead.\n */\nexport function ParameterControls({ definition, values, onChange }: Props) {\n const controls = useParameterControls(definition, values, onChange);\n if (controls.length === 0) return null;\n return (\n <div className=\"mv:flex mv:flex-wrap mv:items-center mv:gap-x-4 mv:gap-y-2 mv:text-sm\">\n {controls.map(({ parameter, value, setValue }) => (\n <div key={parameter.name} className=\"mv:flex mv:items-center mv:gap-1.5\" title={parameter.description}>\n <ParameterInput parameter={parameter} value={value} onChange={setValue} />\n </div>\n ))}\n </div>\n );\n}\n"],"mappings":";;;;;AAMA,IAAa,qBAAqB,8BAA+B,IAH/B,IAG+B,CAAI;AAErE,IAAa,uBAAuB,WAAW,kBAAkB;;;;;;;;ACUjE,SAAgB,SAAS,EAAE,MAAM,QAAQ,OAAO,YAAmB;CACjE,MAAM,eAAe,WAAW,IAAI;CACpC,MAAM,cAAc,eAAe,CAAC,CAAC,IAAI,KAAK,EAAE;CAChD,MAAM,QAAQ,GAAG,KAAK,aAAa,IAAI,KAAK,QAAQ,SAAS,+BAA+B,KAAK,iBAAiB,WAAW;CAC7H,MAAM,aAAa,MAA2B;EAC5C,IAAI,EAAE,QAAQ,WAAW,EAAE,QAAQ,KAAK;GACtC,EAAE,eAAe;GACjB,OAAO;EACT;CACF;CACA,MAAM,SAAS,SAAS,sDAAsD;CAE9E,IAAI,MAAM,UAAU,SAGlB,OAEE,qBAAC,OAAD;EACE,MAAK;EACL,UAAU;EACV,OAAO;EACP,gBAAc,KAAK;EACnB,SAAS;EACE;EACX,cAAY;EACZ,WAAW,4QAA4Q;EARzR,UAAA,CAUE,oBAAC,QAAD;GAAM,eAAY;GAAQ,UAAA,KAAK,aAAa,OAAO,CAAC;EAAQ,CAAA,GAC5D,oBAAC,iBAAD,EAA8B,YAAc,CAAA,CACzC;;CAIT,MAAM,SAAS,MAAM,OAClB,KAAK,UAAU,CAAC,OAAO,YAAY,KAAK,WAAW,MAAM,CAAC,CAAU,CAAC,CACrE,QAAQ,GAAG,WAAW,UAAU,KAAA,CAAS;CAE5C,OAEE,qBAAC,OAAD;EACE,MAAK;EACL,UAAU;EACV,OAAO;EACP,gBAAc,KAAK;EACnB,SAAS;EACE;EACX,WAAW,4MAA4M;EAPzN,U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ACzB,MAAM,WAAW,cAAc,uBAAuB,YAAY,MAAM,GAAG,CAAC,YAAY,MAAM,CAAC;CAC/F,OAAO,WAAW,WAAW,KAAK,eAAe;EAC/C;EACA,OAAO,SAAS,UAAU;EAC1B,WAAW,UAAU,SAAS,UAAU,MAAM,KAAK;CACrD,EAAE;AACJ;;;;;;;AChBA,SAAgB,kBAAkB,EAAE,YAAY,QAAQ,YAAmB;CACzE,MAAM,WAAW,qBAAqB,YAAY,QAAQ,QAAQ;CAClE,IAAI,SAAS,WAAW,GAAG,OAAO;CAClC,OACE,oBAAC,OAAD;EAAK,WAAU;EACZ,UAAA,SAAS,KAAK,EAAE,WAAW,OAAO,eACjC,oBAAC,OAAD;GAA0B,WAAU;GAAqC,OAAO,UAAU;GACxF,UAAA,oBAAC,gBAAD;IAA2B;IAAkB;IAAO,UAAU;GAAW,CAAA;EACtE,GAFK,UAAU,IAEf,CACN;CACE,CAAA;AAET"}
1
+ {"version":3,"file":"ParameterControls--sD0-okx.js","names":["_Fragment"],"sources":["../src/layouts/annotations-context.ts","../src/layouts/NodeCard.tsx","../src/layouts/LandscapeLayout.tsx","../src/layouts/EdgeOverlay.tsx","../src/layouts/TreeLayout.tsx","../src/layouts/XYLayout.tsx","../src/layouts/MapView.tsx","../src/layouts/ParameterInputs.tsx","../src/layouts/useParameterControls.ts","../src/layouts/ParameterControls.tsx"],"sourcesContent":["import { createContext, useContext } from 'react';\nimport type { AnnotationIndex } from '../core/annotations';\n\nconst NONE: AnnotationIndex = new Map();\n\n/** The annotations a map view shows, already narrowed by its validation settings. Read by node cards. */\nexport const AnnotationsContext = createContext<AnnotationIndex>(NONE);\n\nexport const useAnnotations = () => useContext(AnnotationsContext);\n","import type { SpaceNode } from 'structured-context/api';\nimport { type NodeAnnotation, type Severity, worstSeverity } from '../core/annotations';\nimport type { NodesConfig } from '../core/definition';\nimport { useAnnotations } from './annotations-context';\n\ntype Props = {\n node: SpaceNode;\n /** The node's subtree is rendered at another occurrence. */\n repeat: boolean;\n nodes: NodesConfig;\n onSelect?: (node: SpaceNode) => void;\n};\n\n/**\n * A clickable node, drawn as a card (title plus selected fields) or a compact shape with a\n * tooltip. Deliberately a `div` with button semantics rather than a `<button>`: hosts style\n * native form controls globally (Obsidian fixes button height and disables wrapping).\n */\nexport function NodeCard({ node, repeat, nodes, onSelect }: Props) {\n const select = () => onSelect?.(node);\n const annotations = useAnnotations().get(node.id);\n const label = `${node.resolvedType}: ${node.title}${repeat ? ' (shown in full elsewhere)' : ''}${annotationsLabel(annotations)}`;\n const onKeyDown = (e: React.KeyboardEvent) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n select();\n }\n };\n const border = repeat ? 'mv:border-dashed mv:border-muted/60 mv:opacity-75' : 'mv:border-edge';\n\n if (nodes.style === 'shape') {\n // 24px: the minimum target size for pointer input (WCAG 2.2 AA). The type's initial is the\n // visible cue; the full type and title are in the tooltip and accessible name.\n return (\n // biome-ignore lint/a11y/useSemanticElements: a native button inherits host button styles.\n <div\n role=\"button\"\n tabIndex={0}\n title={label}\n data-node-id={node.id}\n onClick={select}\n onKeyDown={onKeyDown}\n aria-label={label}\n className={`mv:relative mv:flex mv:size-6 mv:cursor-pointer mv:items-center mv:justify-center mv:rounded-full mv:border-2 mv:bg-card mv:text-[0.65rem] mv:font-semibold mv:uppercase mv:text-muted mv:hover:border-accent mv:focus-visible:outline-2 mv:focus-visible:outline-accent ${border}`}\n >\n <span aria-hidden=\"true\">{node.resolvedType.charAt(0)}</span>\n <AnnotationBadge annotations={annotations} />\n </div>\n );\n }\n\n const fields = nodes.fields\n .map((field) => [field, formatValue(node.schemaData[field])] as const)\n .filter(([, value]) => value !== undefined);\n\n return (\n // biome-ignore lint/a11y/useSemanticElements: a native button inherits host button styles.\n <div\n role=\"button\"\n tabIndex={0}\n title={label}\n data-node-id={node.id}\n onClick={select}\n onKeyDown={onKeyDown}\n className={`mv:relative mv:w-44 mv:cursor-pointer mv:rounded-md mv:border mv:bg-card mv:px-2.5 mv:py-1.5 mv:text-left mv:shadow-sm mv:hover:border-accent mv:focus-visible:outline-2 mv:focus-visible:outline-accent ${border}`}\n >\n <span className=\"mv:block mv:text-[0.65rem] mv:uppercase mv:tracking-wide mv:text-muted\">\n {node.resolvedType}\n {repeat && ' · repeat'}\n </span>\n <span className=\"mv:block mv:text-sm mv:leading-snug\">{node.title}</span>\n {fields.length > 0 && (\n <dl className=\"mv:m-0 mv:mt-1 mv:text-xs mv:text-muted\">\n {fields.map(([field, value]) => (\n <div key={field} className=\"mv:flex mv:gap-1\">\n <dt className=\"mv:shrink-0\">{field}:</dt>\n <dd className=\"mv:m-0 mv:truncate mv:text-ink\">{value}</dd>\n </div>\n ))}\n </dl>\n )}\n <AnnotationBadge annotations={annotations} />\n </div>\n );\n}\n\nconst BADGE: Record<Severity, string> = {\n error: 'mv:bg-error',\n warning: 'mv:bg-warning',\n info: 'mv:bg-info',\n};\n\n/** A count of the node's validation results in the corner, coloured by the most serious. Decorative: the count is in the card's label. */\nfunction AnnotationBadge({ annotations }: { annotations: readonly NodeAnnotation[] | undefined }) {\n const worst = annotations && worstSeverity(annotations);\n if (!annotations || !worst) return null;\n return (\n <span\n aria-hidden=\"true\"\n className={`mv:absolute mv:-top-1.5 mv:-right-1.5 mv:flex mv:h-4 mv:min-w-4 mv:items-center mv:justify-center mv:rounded-full mv:px-1 mv:text-[0.6rem] mv:font-semibold mv:text-white ${BADGE[worst]}`}\n >\n {annotations.length}\n </span>\n );\n}\n\nfunction annotationsLabel(annotations: readonly NodeAnnotation[] | undefined): string {\n const worst = annotations && worstSeverity(annotations);\n if (!annotations || !worst) return '';\n return ` (${annotations.length} validation ${annotations.length === 1 ? 'result' : 'results'}, most serious: ${worst})`;\n}\n\nfunction formatValue(value: unknown): string | undefined {\n if (value === undefined || value === null || value === '') return undefined;\n if (Array.isArray(value)) return value.map(String).join(', ');\n if (typeof value === 'object') return JSON.stringify(value);\n return String(value);\n}\n","import { useMemo } from 'react';\nimport type { SpaceNode } from 'structured-context/api';\nimport type { LandscapeLayoutConfig, Orientation } from '../core/definition';\nimport { buildLandscape, type LandscapeOccurrence } from '../core/landscape';\nimport { NodeCard } from './NodeCard';\nimport type { LayoutProps } from './TreeLayout';\n\n/**\n * Nested containers following the layout's grouping levels; the last level is drawn as nodes.\n * Flexbox does the nesting and wrapping. Containment shows the grouping edges, so no connectors\n * are drawn. PROTOTYPE: `edges.show` has no effect here; other edges aren't drawn yet.\n */\nexport function LandscapeLayout({ graph, region, instanceId, onNodeSelect }: LayoutProps<LandscapeLayoutConfig>) {\n const { layout } = region;\n const landscape = useMemo(() => buildLandscape(graph, region.id, layout), [graph, region.id, layout]);\n const last = layout.group.length - 1;\n\n const breadcrumb = (occurrence: LandscapeOccurrence) => {\n const level = layout.group[occurrence.level];\n if (!level || !('type' in level) || level.intermediate !== 'breadcrumb') return null;\n const steps = occurrence.via.filter((step) => step.nodes.length > 0);\n if (steps.length === 0) return null;\n return (\n <span className=\"mv:block mv:max-w-44 mv:text-[0.65rem] mv:leading-tight mv:text-muted\">\n via {steps.map((step) => step.nodes.map((n) => n.title).join(', ')).join(' › ')}\n </span>\n );\n };\n\n const render = (occurrence: LandscapeOccurrence, direction: Orientation): React.ReactNode => {\n const repeat = occurrence.repeatOf !== undefined;\n const marker = { 'data-occurrence': `${instanceId}${occurrence.key}` };\n\n if (occurrence.item.kind === 'node' && occurrence.level === last) {\n return (\n <li key={occurrence.key} {...marker} className=\"mv:flex mv:flex-col mv:gap-0.5\">\n <NodeCard node={occurrence.item.node} repeat={repeat} nodes={region.nodes} onSelect={onNodeSelect} />\n {breadcrumb(occurrence)}\n </li>\n );\n }\n\n // Containers alternate direction with depth; a container of nodes wraps them.\n const inner: Orientation = direction === 'horizontal' ? 'vertical' : 'horizontal';\n const holdsNodes = occurrence.level + 1 === last;\n return (\n <li\n key={occurrence.key}\n {...marker}\n className={`mv:flex mv:flex-col mv:gap-2 mv:rounded-lg mv:border mv:bg-surface mv:p-2 ${repeat ? 'mv:border-dashed mv:border-muted/60' : 'mv:border-edge'}`}\n >\n {occurrence.item.kind === 'node' ? (\n <ContainerHeading node={occurrence.item.node} repeat={repeat} onSelect={onNodeSelect}>\n {breadcrumb(occurrence)}\n </ContainerHeading>\n ) : (\n <span className=\"mv:text-xs mv:font-semibold mv:text-muted\">\n {occurrence.item.field}: {occurrence.item.value === null ? '(none)' : displayValue(occurrence.item.value)}\n </span>\n )}\n <Items direction={holdsNodes ? 'wrap' : inner}>\n {occurrence.children.map((child) => render(child, inner))}\n </Items>\n </li>\n );\n };\n\n const top = layout.orientation;\n return (\n <div className=\"mv:w-max mv:min-w-full mv:p-4\">\n <Items direction={last === 0 ? 'wrap' : top}>\n {landscape.groups.map((group) => render(group, top))}\n {landscape.ungrouped.length > 0 && (\n <li className=\"mv:flex mv:flex-col mv:gap-2 mv:rounded-lg mv:border mv:border-dashed mv:border-edge mv:p-2\">\n <span className=\"mv:text-xs mv:font-semibold mv:text-muted\">Ungrouped</span>\n <Items direction=\"wrap\">{landscape.ungrouped.map((o) => render(o, top))}</Items>\n </li>\n )}\n </Items>\n </div>\n );\n}\n\nfunction Items({ direction, children }: { direction: Orientation | 'wrap'; children: React.ReactNode }) {\n const layout = {\n horizontal: 'mv:flex-row mv:items-start mv:gap-3',\n vertical: 'mv:flex-col mv:items-stretch mv:gap-2',\n wrap: 'mv:max-w-[36rem] mv:flex-row mv:flex-wrap mv:items-start mv:gap-2',\n }[direction];\n return <ul className={`mv:m-0 mv:flex mv:list-none mv:p-0 ${layout}`}>{children}</ul>;\n}\n\n/** A container's node: type and title, selectable like a card. */\nfunction ContainerHeading({\n node,\n repeat,\n onSelect,\n children,\n}: {\n node: SpaceNode;\n repeat: boolean;\n onSelect?: (node: SpaceNode) => void;\n children?: React.ReactNode;\n}) {\n const select = () => onSelect?.(node);\n return (\n // biome-ignore lint/a11y/useSemanticElements: a native button inherits host button styles.\n <div\n role=\"button\"\n tabIndex={0}\n title={`${node.resolvedType}: ${node.title}${repeat ? ' (also shown elsewhere)' : ''}`}\n onClick={select}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n select();\n }\n }}\n className=\"mv:cursor-pointer mv:rounded mv:px-1 mv:hover:text-accent mv:focus-visible:outline-2 mv:focus-visible:outline-accent\"\n >\n <span className=\"mv:block mv:text-[0.65rem] mv:uppercase mv:tracking-wide mv:text-muted\">\n {node.resolvedType}\n {repeat && ' · repeat'}\n </span>\n <span className=\"mv:block mv:text-sm mv:font-semibold mv:leading-snug\">{node.title}</span>\n {children}\n </div>\n );\n}\n\n/** Field values that are wikilinks show as the linked title. */\nfunction displayValue(value: string): string {\n return value.replace(/^\\[\\[([^\\]|]+)(\\|[^\\]]*)?\\]\\]$/, '$1');\n}\n","import { useLayoutEffect, useState } from 'react';\nimport type { Orientation } from '../core/definition';\n\n/**\n * A connector between two occurrences. `cross` links (e.g. extra parents) are drawn dashed.\n * `id` tells apart several links between the same occurrences; straight links between the same\n * pair are drawn side by side, `lane` apart (0: on the line between centres).\n */\nexport type Link = { from: string; to: string; kind?: 'tree' | 'cross'; id?: string; lane?: number };\n\ntype Props = {\n links: readonly Link[];\n /** Rendered element of each occurrence, by occurrence key. */\n elements: ReadonlyMap<string, HTMLElement>;\n /**\n * Positioned element the overlay covers; coordinates are relative to it. Passed as an element,\n * not a ref: the overlay sits inside it, and React runs a child's layout effects before\n * attaching the parent's ref.\n */\n container: HTMLElement | null;\n /** Curves leaving along the tree's orientation, or straight lines between centres (drawn under the nodes). */\n routing: Orientation | 'straight';\n};\n\ntype Drawn = { key: string; d: string; cross: boolean };\n\n/**\n * SVG layer drawing connectors between rendered occurrences.\n *\n * Measures occurrence elements after layout and redraws when the container or any occurrence\n * resizes, so it follows embedded panes that resize independently of the window, and reflows\n * such as late font loads. The SVG fills the container instead of being sized from it, so it\n * never holds the container open after the layout shrinks.\n */\nexport function EdgeOverlay({ links, elements, container, routing }: Props) {\n const [paths, setPaths] = useState<Drawn[]>([]);\n\n useLayoutEffect(() => {\n if (!container) return;\n\n const measure = () => {\n const origin = container.getBoundingClientRect();\n const paths: Drawn[] = [];\n for (const { from, to, kind, id, lane = 0 } of links) {\n const a = elements.get(from)?.getBoundingClientRect();\n const b = elements.get(to)?.getBoundingClientRect();\n if (!a || !b) continue;\n paths.push({\n key: `${from}→${to}${id ?? ''}`,\n d: routing === 'straight' ? line(a, b, origin, lane) : connector(a, b, origin, routing),\n cross: kind === 'cross',\n });\n }\n setPaths(paths);\n };\n\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(container);\n for (const element of elements.values()) observer.observe(element);\n return () => observer.disconnect();\n }, [links, elements, container, routing]);\n\n return (\n <svg\n aria-hidden=\"true\"\n className=\"mv:pointer-events-none mv:absolute mv:inset-0 mv:h-full mv:w-full mv:overflow-visible\"\n >\n {paths.map(({ key, d, cross }) => (\n <path\n key={key}\n d={d}\n className={`mv:fill-none ${cross ? 'mv:stroke-accent/60' : 'mv:stroke-muted/50'}`}\n strokeWidth={1.5}\n strokeDasharray={cross ? '4 3' : undefined}\n />\n ))}\n </svg>\n );\n}\n\n/** Cubic curve from the parent's trailing edge to the child's leading edge. */\nfunction connector(a: DOMRect, b: DOMRect, origin: DOMRect, orientation: Orientation): string {\n if (orientation === 'vertical') {\n const x1 = a.left + a.width / 2 - origin.left;\n const y1 = a.bottom - origin.top;\n const x2 = b.left + b.width / 2 - origin.left;\n const y2 = b.top - origin.top;\n const my = (y1 + y2) / 2;\n return `M${x1},${y1} C${x1},${my} ${x2},${my} ${x2},${y2}`;\n }\n const x1 = a.right - origin.left;\n const y1 = a.top + a.height / 2 - origin.top;\n const x2 = b.left - origin.left;\n const y2 = b.top + b.height / 2 - origin.top;\n const mx = (x1 + x2) / 2;\n return `M${x1},${y1} C${mx},${y1} ${mx},${y2} ${x2},${y2}`;\n}\n\n/** Pixels between parallel straight links. */\nconst LANE_GAP = 6;\n\n/**\n * Straight line between centres, shifted sideways by its lane; the layout draws nodes over the\n * overlay to hide the ends. The shift is relative to a fixed orientation of the pair, so links in\n * opposite directions between the same nodes still separate.\n */\nfunction line(a: DOMRect, b: DOMRect, origin: DOMRect, lane: number): string {\n const x1 = a.left + a.width / 2 - origin.left;\n const y1 = a.top + a.height / 2 - origin.top;\n const x2 = b.left + b.width / 2 - origin.left;\n const y2 = b.top + b.height / 2 - origin.top;\n const flip = x1 < x2 || (x1 === x2 && y1 < y2) ? 1 : -1;\n const length = Math.hypot(x2 - x1, y2 - y1) || 1;\n const dx = (-(y2 - y1) / length) * lane * LANE_GAP * flip;\n const dy = ((x2 - x1) / length) * lane * LANE_GAP * flip;\n return `M${x1 + dx},${y1 + dy} L${x2 + dx},${y2 + dy}`;\n}\n","import { useCallback, useMemo, useRef, useState } from 'react';\nimport type { SpaceGraph, SpaceNode } from 'structured-context/api';\nimport type { LayoutConfig, Orientation, Region, TreeLayoutConfig } from '../core/definition';\nimport { buildTree, type TreeOccurrence, treeLinks } from '../core/tree';\nimport { EdgeOverlay } from './EdgeOverlay';\nimport { NodeCard } from './NodeCard';\n\nexport type LayoutProps<L extends LayoutConfig = LayoutConfig> = {\n graph: SpaceGraph;\n /** The region with parameter values applied, narrowed to the layout's own settings. */\n region: Region & { layout: L };\n /** Scopes occurrence ids when several map views render in one document. */\n instanceId: string;\n onNodeSelect?: (node: SpaceNode) => void;\n};\n\n/**\n * Tree over the schema's hierarchy. Flexbox does the branching; the SVG overlay draws connectors.\n */\nexport function TreeLayout({ graph, region, instanceId, onNodeSelect }: LayoutProps<TreeLayoutConfig>) {\n const { orientation, dag } = region.layout;\n const tree = useMemo(() => buildTree(graph, region.id, dag), [graph, region.id, dag]);\n const links = useMemo(() => (region.edges.show ? treeLinks(tree) : []), [tree, region.edges.show]);\n\n const [container, setContainer] = useState<HTMLDivElement | null>(null);\n // Filled by ref callbacks during commit, read by the overlay's layout effect afterwards.\n const elements = useRef(new Map<string, HTMLElement>()).current;\n const register = useCallback(\n (key: string) => (el: HTMLElement | null) => {\n if (el) elements.set(key, el);\n else elements.delete(key);\n },\n [elements],\n );\n\n const branch = (occurrence: TreeOccurrence) => (\n <li\n key={occurrence.key}\n className={`mv:flex mv:items-center ${orientation === 'vertical' ? 'mv:flex-col' : 'mv:flex-row'}`}\n >\n <div ref={register(occurrence.key)} data-occurrence={`${instanceId}${occurrence.key}`}>\n <NodeCard\n node={occurrence.node}\n repeat={occurrence.repeatOf !== undefined}\n nodes={region.nodes}\n onSelect={onNodeSelect}\n />\n </div>\n {occurrence.children.length > 0 && (\n <Branches orientation={orientation} nested>\n {occurrence.children.map(branch)}\n </Branches>\n )}\n </li>\n );\n\n return (\n <div ref={setContainer} className=\"mv:relative mv:w-max mv:min-w-full mv:p-4\">\n <Branches orientation={orientation}>{[...tree.roots, ...tree.orphans].map(branch)}</Branches>\n <EdgeOverlay links={links} elements={elements} container={container} routing={orientation} />\n </div>\n );\n}\n\nfunction Branches({\n orientation,\n nested = false,\n children,\n}: {\n orientation: Orientation;\n nested?: boolean;\n children: React.ReactNode;\n}) {\n // Siblings run across the main axis; nested branches leave a gap for connectors.\n const layout =\n orientation === 'vertical'\n ? `mv:flex-row mv:items-start mv:justify-center mv:gap-3 ${nested ? 'mv:pt-10' : ''}`\n : `mv:flex-col mv:items-start mv:justify-center mv:gap-2 ${nested ? 'mv:pl-14' : ''}`;\n return <ul className={`mv:m-0 mv:flex mv:list-none mv:p-0 ${layout}`}>{children}</ul>;\n}\n","import { useCallback, useMemo, useRef, useState } from 'react';\nimport type { AxisConfig, XYLayoutConfig } from '../core/definition';\nimport { buildXYPlot } from '../core/xy';\nimport { EdgeOverlay } from './EdgeOverlay';\nimport { NodeCard } from './NodeCard';\nimport type { LayoutProps } from './TreeLayout';\n\n/**\n * Nodes positioned by two numeric fields, with straight connectors between them. Positions are\n * percentages of the plot area, which fills the container (scrolling below a minimum size). Nodes that can't be\n * placed are listed under the plot with the reason.\n * PROTOTYPE: labels may overlap where nodes sit close together; no collision handling.\n */\nexport function XYLayout({ graph, region, instanceId, onNodeSelect }: LayoutProps<XYLayoutConfig>) {\n const { layout } = region;\n const plot = useMemo(() => buildXYPlot(graph, region.id, layout), [graph, region.id, layout]);\n // Relationship edges (flows, pipelines) are dashed, to tell them from the value chain.\n const links = useMemo(\n () =>\n region.edges.show\n ? plot.links.map(({ from, to, field, hierarchy, lane }) => ({\n from,\n to,\n id: field,\n lane,\n kind: hierarchy ? ('tree' as const) : ('cross' as const),\n }))\n : [],\n [plot, region.edges.show],\n );\n const shape = region.nodes.style === 'shape';\n\n const [container, setContainer] = useState<HTMLDivElement | null>(null);\n const elements = useRef(new Map<string, HTMLElement>()).current;\n const register = useCallback(\n (key: string) => (el: HTMLElement | null) => {\n if (el) elements.set(key, el);\n else elements.delete(key);\n },\n [elements],\n );\n\n return (\n <div className=\"mv:box-border mv:flex mv:h-full mv:min-h-[28rem] mv:min-w-[36rem] mv:flex-col mv:gap-4 mv:p-4\">\n <div className=\"mv:grid mv:min-h-0 mv:flex-1 mv:grid-cols-[auto_1fr] mv:grid-rows-[1fr_auto] mv:gap-1\">\n <AxisTitle axis={layout.y} domain={plot.domains.y} vertical />\n <div ref={setContainer} className=\"mv:relative mv:border-b mv:border-l mv:border-edge\">\n {/* Before the nodes, so the opaque nodes cover the ends of the lines. */}\n <EdgeOverlay links={links} elements={elements} container={container} routing=\"straight\" />\n {/* Inset, so nodes at the ends of a domain stay inside the plot. */}\n <div className=\"mv:absolute mv:inset-8\">\n {plot.points.map((point) => (\n <div\n key={point.key}\n data-occurrence={`${instanceId}${point.key}`}\n className={`mv:absolute mv:flex mv:items-center mv:gap-1 ${shape ? 'mv:-translate-x-3 mv:translate-y-3' : 'mv:-translate-x-1/2 mv:translate-y-1/2'}`}\n style={{ left: `${point.x * 100}%`, bottom: `${point.y * 100}%` }}\n >\n <div ref={register(point.key)}>\n <NodeCard node={point.node} repeat={false} nodes={region.nodes} onSelect={onNodeSelect} />\n </div>\n {shape && (\n <span className=\"mv:whitespace-nowrap mv:rounded mv:bg-surface/80 mv:px-0.5 mv:text-xs\">\n {point.node.title}\n </span>\n )}\n </div>\n ))}\n </div>\n </div>\n <div />\n <AxisTitle axis={layout.x} domain={plot.domains.x} />\n </div>\n\n {plot.unplaced.length > 0 && (\n <section className=\"mv:flex mv:flex-col mv:gap-2\">\n <span className=\"mv:text-xs mv:font-semibold mv:text-muted\">Not plotted</span>\n <ul className=\"mv:m-0 mv:flex mv:list-none mv:flex-wrap mv:gap-3 mv:p-0\">\n {plot.unplaced.map(({ key, node, reasons }) => (\n <li key={key} data-occurrence={`${instanceId}${key}`} className=\"mv:flex mv:items-center mv:gap-1\">\n <NodeCard node={node} repeat={false} nodes={region.nodes} onSelect={onNodeSelect} />\n <span className=\"mv:text-xs\">\n {shape && `${node.title} `}\n <span className=\"mv:text-muted\">({reasons.join('; ')})</span>\n </span>\n </li>\n ))}\n </ul>\n </section>\n )}\n </div>\n );\n}\n\n/** Axis title with the values at each end, in drawing order. */\nfunction AxisTitle({\n axis,\n domain: [min, max],\n vertical = false,\n}: {\n axis: AxisConfig;\n domain: readonly [number, number];\n vertical?: boolean;\n}) {\n const [start, end] = axis.direction === 'descending' ? [max, min] : [min, max];\n return (\n <div\n className={`mv:flex mv:items-center mv:justify-between mv:gap-2 mv:text-xs mv:text-muted ${vertical ? 'mv:flex-col-reverse mv:py-8' : 'mv:px-8'}`}\n >\n <span>{format(start)}</span>\n <span className={`mv:font-semibold ${vertical ? 'mv:[writing-mode:vertical-rl] mv:rotate-180' : ''}`}>\n {axis.label ?? axis.field}\n </span>\n <span>{format(end)}</span>\n </div>\n );\n}\n\nfunction format(value: number): string {\n return Number.isInteger(value) ? String(value) : value.toPrecision(3).replace(/\\.?0+$/, '');\n}\n","import { useId, useMemo } from 'react';\nimport type { SpaceGraph, SpaceNode } from 'structured-context/api';\nimport { type AnnotationIndex, filterAnnotations } from '../core/annotations';\nimport { type MapViewDefinition, type ParameterValues, type Region, resolveRegions } from '../core/definition';\nimport { AnnotationsContext } from './annotations-context';\nimport { LandscapeLayout } from './LandscapeLayout';\nimport { type LayoutProps, TreeLayout } from './TreeLayout';\nimport { XYLayout } from './XYLayout';\n\ntype Props = {\n definition: MapViewDefinition;\n graph: SpaceGraph;\n /** Current parameter values (host-owned session state); missing values use defaults. */\n values?: ParameterValues;\n /**\n * Validation results by node (see `annotationsFrom`). Which of them show, and at what severity, is\n * the region's `nodes.validation` setting; with none supplied, nothing is drawn.\n */\n annotations?: AnnotationIndex;\n onNodeSelect?: (node: SpaceNode) => void;\n};\n\nconst EMPTY: AnnotationIndex = new Map();\n\n/** Renders a map view definition against a space. Sizes to its container and scrolls within it. */\nexport function MapView({ definition, graph, values, annotations, onNodeSelect }: Props) {\n const instanceId = useId();\n const regions = useMemo(() => resolveRegions(definition, values), [definition, values]);\n // PROTOTYPE: only the first region is rendered. Arranging several regions is undesigned (#8).\n const region = regions[0]!;\n const props = { graph, instanceId, onNodeSelect };\n const { validation, validationSources } = region.nodes;\n const visibleAnnotations = useMemo(\n () => (annotations ? filterAnnotations(annotations, validation, validationSources) : EMPTY),\n [annotations, validation, validationSources],\n );\n\n return (\n <AnnotationsContext.Provider value={visibleAnnotations}>\n <div className=\"mv:h-full mv:w-full mv:overflow-auto mv:bg-surface mv:text-ink\">{layoutFor(region, props)}</div>\n </AnnotationsContext.Provider>\n );\n}\n\nfunction layoutFor(region: Region, props: Omit<LayoutProps, 'region'>) {\n const { layout } = region;\n switch (layout.type) {\n case 'tree':\n return <TreeLayout {...props} region={{ ...region, layout }} />;\n case 'landscape':\n return <LandscapeLayout {...props} region={{ ...region, layout }} />;\n case 'xy':\n return <XYLayout {...props} region={{ ...region, layout }} />;\n }\n}\n","import { useId } from 'react';\nimport type { Parameter, ParameterControl } from '../core/definition';\n\ntype InputProps<Kind extends ParameterControl['kind']> = {\n parameter: Parameter & { control: Extract<ParameterControl, { kind: Kind }> };\n value: unknown;\n onChange: (value: unknown) => void;\n};\n\nconst same = (a: unknown, b: unknown) => JSON.stringify(a) === JSON.stringify(b);\n\n/** A checkbox for a boolean parameter, labelled with the parameter's title. */\nexport function ToggleParameterInput({ parameter, value, onChange }: InputProps<'toggle'>) {\n const id = useId();\n return (\n <>\n <input id={id} type=\"checkbox\" checked={value === true} onChange={(e) => onChange(e.target.checked)} />\n <label htmlFor={id}>{parameter.title}</label>\n </>\n );\n}\n\n/** A dropdown for a parameter with one of several options. */\nexport function SelectParameterInput({ parameter, value, onChange }: InputProps<'select'>) {\n const id = useId();\n return (\n <>\n <label htmlFor={id} className=\"mv:text-muted\">\n {parameter.title}\n </label>\n <select id={id} value={JSON.stringify(value)} onChange={(e) => onChange(JSON.parse(e.target.value))}>\n {parameter.control.options.map((option) => (\n <option key={JSON.stringify(option)} value={JSON.stringify(option)}>\n {String(option)}\n </option>\n ))}\n </select>\n </>\n );\n}\n\n/** A checkbox group for a parameter taking any subset of its options. */\nexport function MultiSelectParameterInput({ parameter, value, onChange }: InputProps<'multiselect'>) {\n const { options } = parameter.control;\n const selected = Array.isArray(value) ? value : [];\n return (\n <fieldset className=\"mv:m-0 mv:flex mv:flex-wrap mv:items-center mv:gap-2 mv:border-0 mv:p-0\">\n <legend className=\"mv:float-left mv:mr-1.5 mv:p-0 mv:text-muted\">{parameter.title}</legend>\n {options.map((option) => {\n const checked = selected.some((v) => same(v, option));\n return (\n <label key={JSON.stringify(option)} className=\"mv:flex mv:items-center mv:gap-1\">\n <input\n type=\"checkbox\"\n checked={checked}\n onChange={() =>\n // Keep the options' order rather than the order of clicks.\n onChange(options.filter((o) => (o === option ? !checked : selected.some((v) => same(v, o)))))\n }\n />\n {String(option)}\n </label>\n );\n })}\n </fieldset>\n );\n}\n\n/** The input matching a parameter's control kind. */\nexport function ParameterInput({\n parameter,\n value,\n onChange,\n}: Omit<InputProps<ParameterControl['kind']>, 'parameter'> & { parameter: Parameter }) {\n const { control } = parameter;\n switch (control.kind) {\n case 'toggle':\n return <ToggleParameterInput parameter={{ ...parameter, control }} value={value} onChange={onChange} />;\n case 'select':\n return <SelectParameterInput parameter={{ ...parameter, control }} value={value} onChange={onChange} />;\n case 'multiselect':\n return <MultiSelectParameterInput parameter={{ ...parameter, control }} value={value} onChange={onChange} />;\n }\n}\n","import { useMemo } from 'react';\nimport {\n type MapViewDefinition,\n type Parameter,\n type ParameterValues,\n resolveParameterValues,\n} from '../core/definition';\n\n/** One parameter with its current value and a setter, ready for a host to lay out. */\nexport type ParameterControlState = {\n parameter: Parameter;\n /** The value in effect: the host's value, else the default, matching what renders. */\n value: unknown;\n setValue: (value: unknown) => void;\n};\n\n/**\n * The state behind a map view's parameter controls, with no markup, for hosts that lay the controls\n * out themselves. Pair each entry with `ParameterInput`, or with one of the typed inputs.\n */\nexport function useParameterControls(\n definition: MapViewDefinition,\n values: ParameterValues,\n onChange: (name: string, value: unknown) => void,\n): ParameterControlState[] {\n const resolved = useMemo(() => resolveParameterValues(definition, values), [definition, values]);\n return definition.parameters.map((parameter) => ({\n parameter,\n value: resolved[parameter.name],\n setValue: (value) => onChange(parameter.name, value),\n }));\n}\n","import type { MapViewDefinition, ParameterValues } from '../core/definition';\nimport { ParameterInput } from './ParameterInputs';\nimport { useParameterControls } from './useParameterControls';\n\ntype Props = {\n definition: MapViewDefinition;\n /** Host-owned values; missing or stale ones show as the default, matching what renders. */\n values: ParameterValues;\n onChange: (name: string, value: unknown) => void;\n};\n\n/**\n * Default layout for a map view's parameter controls: a wrapping row. Hosts wanting their own layout\n * use `useParameterControls` with `ParameterInput` (or the typed inputs) instead.\n */\nexport function ParameterControls({ definition, values, onChange }: Props) {\n const controls = useParameterControls(definition, values, onChange);\n if (controls.length === 0) return null;\n return (\n <div className=\"mv:flex mv:flex-wrap mv:items-center mv:gap-x-4 mv:gap-y-2 mv:text-sm\">\n {controls.map(({ parameter, value, setValue }) => (\n <div key={parameter.name} className=\"mv:flex mv:items-center mv:gap-1.5\" title={parameter.description}>\n <ParameterInput parameter={parameter} value={value} onChange={setValue} />\n </div>\n ))}\n </div>\n );\n}\n"],"mappings":";;;;;AAMA,IAAa,qBAAqB,8BAA+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AE,YAAY,QAAQ,YAAmB;CACzE,MAAM,WAAW,qBAAqB,YAAY,QAAQ,QAAQ;CAClE,IAAI,SAAS,WAAW,GAAG,OAAO;CAClC,OACE,oBAAC,OAAD;EAAK,WAAU;EACZ,UAAA,SAAS,KAAK,EAAE,WAAW,OAAO,eACjC,oBAAC,OAAD;GAA0B,WAAU;GAAqC,OAAO,UAAU;GACxF,UAAA,oBAAC,gBAAD;IAA2B;IAAkB;IAAO,UAAU;GAAW,CAAA;EACtE,GAFK,UAAU,IAEf,CACN;CACE,CAAA;AAET"}
@@ -597,5 +597,5 @@ body { background: var(--art-ground); color: var(--mv-color-ink); }
597
597
 
598
598
  </style>
599
599
  <div id="root"></div>
600
- <script type="importmap">{"imports":{"structured-context/browser":"https://cdn.jsdelivr.net/npm/structured-context@0.21.0/dist/browser.js/+esm","react":"https://cdn.jsdelivr.net/npm/react@19.3.0/+esm","react/jsx-runtime":"https://cdn.jsdelivr.net/npm/react@19.3.0/jsx-runtime/+esm","react-dom":"https://cdn.jsdelivr.net/npm/react-dom@19.3.0/+esm","react-dom/client":"https://cdn.jsdelivr.net/npm/react-dom@19.3.0/client/+esm","ajv/dist/2020":"https://cdn.jsdelivr.net/npm/ajv@8.20.0/dist/2020.js/+esm","json5":"https://cdn.jsdelivr.net/npm/json5@2.2.3/+esm","https://cdn.jsdelivr.net/npm/react@%5E19.3.0/+esm":"https://cdn.jsdelivr.net/npm/react@19.3.0/+esm"}}</script>
601
- <script type="module" src="https://cdn.jsdelivr.net/npm/structured-context-map-views@0.4.0/dist/artifact.js"></script>
600
+ <script type="importmap">{"imports":{"structured-context/browser":"https://cdn.jsdelivr.net/npm/structured-context@0.22.1/dist/browser.js/+esm","react":"https://cdn.jsdelivr.net/npm/react@19.3.0/+esm","react/jsx-runtime":"https://cdn.jsdelivr.net/npm/react@19.3.0/jsx-runtime/+esm","react-dom":"https://cdn.jsdelivr.net/npm/react-dom@19.3.0/+esm","react-dom/client":"https://cdn.jsdelivr.net/npm/react-dom@19.3.0/client/+esm","ajv/dist/2020":"https://cdn.jsdelivr.net/npm/ajv@8.20.0/dist/2020.js/+esm","json5":"https://cdn.jsdelivr.net/npm/json5@2.2.3/+esm","https://cdn.jsdelivr.net/npm/react@%5E19.3.0/+esm":"https://cdn.jsdelivr.net/npm/react@19.3.0/+esm"}}</script>
601
+ <script type="module" src="https://cdn.jsdelivr.net/npm/structured-context-map-views@0.5.0/dist/artifact.js"></script>
package/dist/artifact.js CHANGED
@@ -1,5 +1,5 @@
1
- import { a as annotationsFrom } from "./projection-GaO0MCbR.js";
2
- import { s as MapView, t as ParameterControls } from "./ParameterControls-eKRxNr1P.js";
1
+ import { a as annotationsFrom } from "./projection-CYShQhug.js";
2
+ import { s as MapView, t as ParameterControls } from "./ParameterControls--sD0-okx.js";
3
3
  import { useEffect, useMemo, useRef, useState } from "react";
4
4
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
5
  import { createRoot } from "react-dom/client";
package/dist/cli.js CHANGED
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env bun
2
- import { n as mapViewsForSchema } from "./definition-Cft28YUA.js";
3
- import { t as loadMapViewDefinitions } from "./node-BceB0Wzc.js";
2
+ import { n as mapViewsForSchema } from "./definition-Cp1CCigh.js";
3
+ import { t as loadMapViewDefinitions } from "./node-Co_JiEZV.js";
4
4
  import { dirname, resolve } from "node:path";
5
- import { SctxError, assembleSpaceGraph, createSpaceContext, exportSpaceGraph, loadConfig, resolveConfigPath, setConfigPath, validateSpace } from "structured-context/api";
5
+ import { SctxError, assembleSpaceGraph, createSpaceContext, exportSpaceGraph, loadConfig, nodeIssues, resolveConfigPath, setConfigPath, validateSpace } from "structured-context/api";
6
6
  import { Command } from "commander";
7
7
  var package_default = {
8
8
  name: "structured-context-map-views",
9
- version: "0.4.0",
9
+ version: "0.5.0",
10
10
  description: "Declarative map views of structured-context spaces: render a space as a tree, nested containers or an XY plot from a short definition.",
11
11
  license: "MIT",
12
12
  type: "module",
@@ -54,7 +54,7 @@ var package_default = {
54
54
  peerDependencies: {
55
55
  "react": "^19.3.0",
56
56
  "react-dom": "^19.3.0",
57
- "structured-context": "^0.21.0"
57
+ "structured-context": "^0.22.1"
58
58
  },
59
59
  dependencies: {
60
60
  "ajv": "^8.20.0",
@@ -70,7 +70,7 @@ var package_default = {
70
70
  "@vitejs/plugin-react": "^6.1.1",
71
71
  "react": "^19.3.0",
72
72
  "react-dom": "^19.3.0",
73
- "structured-context": "^0.21.0",
73
+ "structured-context": "^0.22.1",
74
74
  "tailwindcss": "^4.3.3",
75
75
  "vite": "^8.3.2"
76
76
  }
@@ -85,11 +85,15 @@ async function exportSnapshot(spaceName, config, configDir, validateOptions = {}
85
85
  const context = createSpaceContext(spaceName, config);
86
86
  const graph = await assembleSpaceGraph(context, {});
87
87
  const schemaId = context.schema.$id;
88
+ const validation = await validateSpace(context, validateOptions);
88
89
  return {
89
90
  space: spaceName,
90
91
  schemaId,
91
92
  graph: exportSpaceGraph(graph.nodes.values(), context.schema.metadata),
92
- validation: await validateSpace(context, validateOptions),
93
+ validation: {
94
+ issues: nodeIssues(validation, validateOptions),
95
+ ruleViolations: validation.ruleViolations
96
+ },
93
97
  definitions: mapViewsForSchema(loadMapViewDefinitions(config, { configDir }), schemaId)
94
98
  };
95
99
  }
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","names":["packageJson"],"sources":["../package.json","../src/node/snapshot.ts","../src/node/cli.ts"],"sourcesContent":["{\n \"name\": \"structured-context-map-views\",\n \"version\": \"0.4.0\",\n \"description\": \"Declarative map views of structured-context spaces: render a space as a tree, nested containers or an XY plot from a short definition.\",\n \"license\": \"MIT\",\n \"type\": \"module\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/mindsocket/structured-context-map-views.git\",\n \"directory\": \"packages/map-views\"\n },\n \"homepage\": \"https://github.com/mindsocket/structured-context-map-views#readme\",\n \"bugs\": \"https://github.com/mindsocket/structured-context-map-views/issues\",\n \"keywords\": [\n \"structured-context\",\n \"visualisation\",\n \"map-view\",\n \"react\"\n ],\n \"files\": [\n \"dist/\"\n ],\n \"sideEffects\": false,\n \"bin\": {\n \"structured-context-map-views\": \"dist/cli.js\"\n },\n \"exports\": {\n \".\": {\n \"types\": \"./dist/types/index.d.ts\",\n \"default\": \"./dist/index.js\"\n },\n \"./node\": {\n \"types\": \"./dist/types/node/index.d.ts\",\n \"default\": \"./dist/node.js\"\n },\n \"./styles.css\": \"./dist/styles.css\"\n },\n \"scripts\": {\n \"clean\": \"rm -rf dist\",\n \"generate\": \"bun run generate:schemas && bun run generate:definitions\",\n \"generate:schemas\": \"bun scripts/generate-schemas.ts\",\n \"generate:definitions\": \"bun scripts/generate-definitions.ts\",\n \"build\": \"bun run clean && bun run generate && bun --bun vite build && tsc -p tsconfig.build.json && tailwindcss -i src/layouts/styles.css -o dist/styles.css && bun scripts/build-artifact-page.ts\",\n \"typecheck\": \"tsc --noEmit\",\n \"capture-fixtures\": \"bun scripts/capture-fixtures.ts\",\n \"test\": \"bun test\",\n \"test:package\": \"bash scripts/test-package.sh\",\n \"prepublishOnly\": \"bun run build\",\n \"preversion\": \"bun run generate && bun run --cwd ../.. lint:fix && bun run --cwd ../.. test && bun run test:package\",\n \"version\": \"bun run generate:schemas --release && git add -A\"\n },\n \"peerDependencies\": {\n \"react\": \"^19.3.0\",\n \"react-dom\": \"^19.3.0\",\n \"structured-context\": \"^0.21.0\"\n },\n \"dependencies\": {\n \"ajv\": \"^8.20.0\",\n \"commander\": \"^15.0.0\",\n \"json-schema-to-ts\": \"^3.1.1\",\n \"json5\": \"^2.2.3\"\n },\n \"devDependencies\": {\n \"@tailwindcss/cli\": \"^4.3.3\",\n \"@types/node\": \"^22.20.5\",\n \"@types/react\": \"^19.3.0\",\n \"@types/react-dom\": \"^19.3.0\",\n \"@vitejs/plugin-react\": \"^6.1.1\",\n \"react\": \"^19.3.0\",\n \"react-dom\": \"^19.3.0\",\n \"structured-context\": \"^0.21.0\",\n \"tailwindcss\": \"^4.3.3\",\n \"vite\": \"^8.3.2\"\n }\n}\n","import {\n assembleSpaceGraph,\n type Config,\n createSpaceContext,\n exportSpaceGraph,\n validateSpace,\n} from 'structured-context/api';\nimport { type MapViewDefinition, mapViewsForSchema } from '../core/definition';\nimport { loadMapViewDefinitions } from './index';\n\n/**\n * Everything a host without filesystem access needs to render a space: its graph, the validation\n * results that attach to nodes, and the map view definitions that apply to its schema. Plain JSON.\n */\nexport type SpaceSnapshot = {\n space: string;\n schemaId: string | undefined;\n graph: ReturnType<typeof exportSpaceGraph>;\n validation: Awaited<ReturnType<typeof validateSpace>>;\n definitions: MapViewDefinition[];\n};\n\n/** The `validateSpace` options `export` passes through unchanged. */\nexport type ExportValidateOptions = Pick<\n NonNullable<Parameters<typeof validateSpace>[1]>,\n 'depth' | 'includeGated' | 'semantic' | 'ruleFilter'\n>;\n\n/**\n * Node-only: snapshot a space for a browser-only host. Validation is structured-context's own\n * `validateSpace`, which also decides whether a judge runs.\n */\nexport async function exportSnapshot(\n spaceName: string,\n config: Config,\n configDir?: string,\n validateOptions: ExportValidateOptions = {},\n): Promise<SpaceSnapshot> {\n const context = createSpaceContext(spaceName, config);\n const graph = await assembleSpaceGraph(context, {});\n const schemaId = context.schema.$id;\n return {\n space: spaceName,\n schemaId,\n graph: exportSpaceGraph(graph.nodes.values(), context.schema.metadata),\n validation: await validateSpace(context, validateOptions),\n definitions: mapViewsForSchema(loadMapViewDefinitions(config, { configDir }), schemaId),\n };\n}\n","#!/usr/bin/env bun\nimport { dirname, resolve } from 'node:path';\nimport { Command } from 'commander';\nimport { loadConfig, resolveConfigPath, SctxError, setConfigPath } from 'structured-context/api';\nimport packageJson from '../../package.json' with { type: 'json' };\nimport { type ExportValidateOptions, exportSnapshot } from './snapshot';\n\nconst program = new Command();\n\nprogram\n .name('structured-context-map-views')\n .description('Map view tools for structured-context spaces')\n .version(packageJson.version)\n .option('--config <path>', 'Path to config file (overrides config discovery)');\n\nprogram\n .command('export')\n .description('Print a JSON snapshot of a space: its graph, validation results and map view definitions')\n .argument('<space-name>', 'Space name')\n .option('--depth <n>', 'Validate only hierarchy nodes within N levels from the top', (v) => parseInt(v, 10))\n .option('--include-gated', 'Evaluate rules even on nodes gated by an upstream failure')\n .option(\n '--rule-filter <dimension=values>',\n 'Evaluate only matching rules; dimensions: category, severity, type, id (repeatable, e.g. severity=error)',\n (v: string, prev: string[] = []) => [...prev, v],\n )\n .option('--semantic [provider]', 'Evaluate semantic rules, with the configured model provider or the one named')\n .action(async (spaceName: string, options: ExportValidateOptions) => {\n setConfigPath(program.opts().config);\n try {\n const config = loadConfig();\n const configDir = dirname(resolve(resolveConfigPath().path));\n const result = await exportSnapshot(spaceName, config, configDir, options);\n process.stdout.write(`${JSON.stringify(result)}\\n`);\n } catch (err) {\n if (!(err instanceof SctxError)) throw err;\n console.error(`${err.code}: ${err.message}`);\n process.exitCode = 1;\n }\n });\n\nawait program.parseAsync();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACgCA,eAAsB,eACpB,WACA,QACA,WACA,kBAAyC,CAAC,GAClB;CACxB,MAAM,UAAU,mBAAmB,WAAW,MAAM;CACpD,MAAM,QAAQ,MAAM,mBAAmB,SAAS,CAAC,CAAC;CAClD,MAAM,WAAW,QAAQ,OAAO;CAChC,OAAO;EACL,OAAO;EACP;EACA,OAAO,iBAAiB,MAAM,MAAM,OAAO,GAAG,QAAQ,OAAO,QAAQ;EACrE,YAAY,MAAM,cAAc,SAAS,eAAe;EACxD,aAAa,kBAAkB,uBAAuB,QAAQ,EAAE,UAAU,CAAC,GAAG,QAAQ;CACxF;AACF;;;ACzCA,IAAM,UAAU,IAAI,QAAQ;AAE5B,QACG,KAAK,8BAA8B,CAAC,CACpC,YAAY,8CAA8C,CAAC,CAC3D,QAAQA,gBAAY,OAAO,CAAC,CAC5B,OAAO,mBAAmB,kDAAkD;AAE/E,QACG,QAAQ,QAAQ,CAAC,CACjB,YAAY,0FAA0F,CAAC,CACvG,SAAS,gBAAgB,YAAY,CAAC,CACtC,OAAO,eAAe,+DAA+D,MAAM,SAAS,GAAG,EAAE,CAAC,CAAC,CAC3G,OAAO,mBAAmB,2DAA2D,CAAC,CACtF,OACC,oCACA,6GACC,GAAW,OAAiB,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,CACjD,CAAC,CACA,OAAO,yBAAyB,8EAA8E,CAAC,CAC/G,OAAO,OAAO,WAAmB,YAAmC;CACnE,cAAc,QAAQ,KAAK,CAAC,CAAC,MAAM;CACnC,IAAI;EAGF,MAAM,SAAS,MAAM,eAAe,WAFrB,WAEgC,GAD7B,QAAQ,QAAQ,kBAAkB,CAAC,CAAC,IAAI,CACH,GAAW,OAAO;EACzE,QAAQ,OAAO,MAAM,GAAG,KAAK,UAAU,MAAM,EAAE,GAAG;CACpD,SAAS,KAAK;EACZ,IAAI,EAAE,eAAe,YAAY,MAAM;EACvC,QAAQ,MAAM,GAAG,IAAI,KAAK,IAAI,IAAI,SAAS;EAC3C,QAAQ,WAAW;CACrB;AACF,CAAC;AAEH,MAAM,QAAQ,WAAW"}
1
+ {"version":3,"file":"cli.js","names":["packageJson"],"sources":["../package.json","../src/node/snapshot.ts","../src/node/cli.ts"],"sourcesContent":["{\n \"name\": \"structured-context-map-views\",\n \"version\": \"0.5.0\",\n \"description\": \"Declarative map views of structured-context spaces: render a space as a tree, nested containers or an XY plot from a short definition.\",\n \"license\": \"MIT\",\n \"type\": \"module\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/mindsocket/structured-context-map-views.git\",\n \"directory\": \"packages/map-views\"\n },\n \"homepage\": \"https://github.com/mindsocket/structured-context-map-views#readme\",\n \"bugs\": \"https://github.com/mindsocket/structured-context-map-views/issues\",\n \"keywords\": [\n \"structured-context\",\n \"visualisation\",\n \"map-view\",\n \"react\"\n ],\n \"files\": [\n \"dist/\"\n ],\n \"sideEffects\": false,\n \"bin\": {\n \"structured-context-map-views\": \"dist/cli.js\"\n },\n \"exports\": {\n \".\": {\n \"types\": \"./dist/types/index.d.ts\",\n \"default\": \"./dist/index.js\"\n },\n \"./node\": {\n \"types\": \"./dist/types/node/index.d.ts\",\n \"default\": \"./dist/node.js\"\n },\n \"./styles.css\": \"./dist/styles.css\"\n },\n \"scripts\": {\n \"clean\": \"rm -rf dist\",\n \"generate\": \"bun run generate:schemas && bun run generate:definitions\",\n \"generate:schemas\": \"bun scripts/generate-schemas.ts\",\n \"generate:definitions\": \"bun scripts/generate-definitions.ts\",\n \"build\": \"bun run clean && bun run generate && bun --bun vite build && tsc -p tsconfig.build.json && tailwindcss -i src/layouts/styles.css -o dist/styles.css && bun scripts/build-artifact-page.ts\",\n \"typecheck\": \"tsc --noEmit\",\n \"capture-fixtures\": \"bun scripts/capture-fixtures.ts\",\n \"test\": \"bun test\",\n \"test:package\": \"bash scripts/test-package.sh\",\n \"prepublishOnly\": \"bun run build\",\n \"preversion\": \"bun run generate && bun run --cwd ../.. lint:fix && bun run --cwd ../.. test && bun run test:package\",\n \"version\": \"bun run generate:schemas --release && git add -A\"\n },\n \"peerDependencies\": {\n \"react\": \"^19.3.0\",\n \"react-dom\": \"^19.3.0\",\n \"structured-context\": \"^0.22.1\"\n },\n \"dependencies\": {\n \"ajv\": \"^8.20.0\",\n \"commander\": \"^15.0.0\",\n \"json-schema-to-ts\": \"^3.1.1\",\n \"json5\": \"^2.2.3\"\n },\n \"devDependencies\": {\n \"@tailwindcss/cli\": \"^4.3.3\",\n \"@types/node\": \"^22.20.5\",\n \"@types/react\": \"^19.3.0\",\n \"@types/react-dom\": \"^19.3.0\",\n \"@vitejs/plugin-react\": \"^6.1.1\",\n \"react\": \"^19.3.0\",\n \"react-dom\": \"^19.3.0\",\n \"structured-context\": \"^0.22.1\",\n \"tailwindcss\": \"^4.3.3\",\n \"vite\": \"^8.3.2\"\n }\n}\n","import {\n assembleSpaceGraph,\n type Config,\n createSpaceContext,\n exportSpaceGraph,\n nodeIssues,\n validateSpace,\n} from 'structured-context/api';\nimport type { ValidationInput } from '../core/annotations';\nimport { type MapViewDefinition, mapViewsForSchema } from '../core/definition';\nimport { loadMapViewDefinitions } from './index';\n\n/**\n * Everything a host without filesystem access needs to render a space: its graph, the validation\n * results that attach to nodes, and the map view definitions that apply to its schema. Plain JSON.\n */\nexport type SpaceSnapshot = {\n space: string;\n schemaId: string | undefined;\n graph: ReturnType<typeof exportSpaceGraph>;\n /** What `annotationsFrom` attaches: each node's issues and the rule violations */\n validation: ValidationInput;\n definitions: MapViewDefinition[];\n};\n\n/** The `validateSpace` options `export` passes through unchanged. */\nexport type ExportValidateOptions = Pick<\n NonNullable<Parameters<typeof validateSpace>[1]>,\n 'depth' | 'includeGated' | 'semantic' | 'ruleFilter'\n>;\n\n/**\n * Node-only: snapshot a space for a browser-only host. Validation is structured-context's own\n * `validateSpace`, which also decides whether a judge runs.\n */\nexport async function exportSnapshot(\n spaceName: string,\n config: Config,\n configDir?: string,\n validateOptions: ExportValidateOptions = {},\n): Promise<SpaceSnapshot> {\n const context = createSpaceContext(spaceName, config);\n const graph = await assembleSpaceGraph(context, {});\n const schemaId = context.schema.$id;\n const validation = await validateSpace(context, validateOptions);\n return {\n space: spaceName,\n schemaId,\n graph: exportSpaceGraph(graph.nodes.values(), context.schema.metadata),\n validation: { issues: nodeIssues(validation, validateOptions), ruleViolations: validation.ruleViolations },\n definitions: mapViewsForSchema(loadMapViewDefinitions(config, { configDir }), schemaId),\n };\n}\n","#!/usr/bin/env bun\nimport { dirname, resolve } from 'node:path';\nimport { Command } from 'commander';\nimport { loadConfig, resolveConfigPath, SctxError, setConfigPath } from 'structured-context/api';\nimport packageJson from '../../package.json' with { type: 'json' };\nimport { type ExportValidateOptions, exportSnapshot } from './snapshot';\n\nconst program = new Command();\n\nprogram\n .name('structured-context-map-views')\n .description('Map view tools for structured-context spaces')\n .version(packageJson.version)\n .option('--config <path>', 'Path to config file (overrides config discovery)');\n\nprogram\n .command('export')\n .description('Print a JSON snapshot of a space: its graph, validation results and map view definitions')\n .argument('<space-name>', 'Space name')\n .option('--depth <n>', 'Validate only hierarchy nodes within N levels from the top', (v) => parseInt(v, 10))\n .option('--include-gated', 'Evaluate rules even on nodes gated by an upstream failure')\n .option(\n '--rule-filter <dimension=values>',\n 'Evaluate only matching rules; dimensions: category, severity, type, id (repeatable, e.g. severity=error)',\n (v: string, prev: string[] = []) => [...prev, v],\n )\n .option('--semantic [provider]', 'Evaluate semantic rules, with the configured model provider or the one named')\n .action(async (spaceName: string, options: ExportValidateOptions) => {\n setConfigPath(program.opts().config);\n try {\n const config = loadConfig();\n const configDir = dirname(resolve(resolveConfigPath().path));\n const result = await exportSnapshot(spaceName, config, configDir, options);\n process.stdout.write(`${JSON.stringify(result)}\\n`);\n } catch (err) {\n if (!(err instanceof SctxError)) throw err;\n console.error(`${err.code}: ${err.message}`);\n process.exitCode = 1;\n }\n });\n\nawait program.parseAsync();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACmCA,eAAsB,eACpB,WACA,QACA,WACA,kBAAyC,CAAC,GAClB;CACxB,MAAM,UAAU,mBAAmB,WAAW,MAAM;CACpD,MAAM,QAAQ,MAAM,mBAAmB,SAAS,CAAC,CAAC;CAClD,MAAM,WAAW,QAAQ,OAAO;CAChC,MAAM,aAAa,MAAM,cAAc,SAAS,eAAe;CAC/D,OAAO;EACL,OAAO;EACP;EACA,OAAO,iBAAiB,MAAM,MAAM,OAAO,GAAG,QAAQ,OAAO,QAAQ;EACrE,YAAY;GAAE,QAAQ,WAAW,YAAY,eAAe;GAAG,gBAAgB,WAAW;EAAe;EACzG,aAAa,kBAAkB,uBAAuB,QAAQ,EAAE,UAAU,CAAC,GAAG,QAAQ;CACxF;AACF;;;AC7CA,IAAM,UAAU,IAAI,QAAQ;AAE5B,QACG,KAAK,8BAA8B,CAAC,CACpC,YAAY,8CAA8C,CAAC,CAC3D,QAAQA,gBAAY,OAAO,CAAC,CAC5B,OAAO,mBAAmB,kDAAkD;AAE/E,QACG,QAAQ,QAAQ,CAAC,CACjB,YAAY,0FAA0F,CAAC,CACvG,SAAS,gBAAgB,YAAY,CAAC,CACtC,OAAO,eAAe,+DAA+D,MAAM,SAAS,GAAG,EAAE,CAAC,CAAC,CAC3G,OAAO,mBAAmB,2DAA2D,CAAC,CACtF,OACC,oCACA,6GACC,GAAW,OAAiB,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,CACjD,CAAC,CACA,OAAO,yBAAyB,8EAA8E,CAAC,CAC/G,OAAO,OAAO,WAAmB,YAAmC;CACnE,cAAc,QAAQ,KAAK,CAAC,CAAC,MAAM;CACnC,IAAI;EAGF,MAAM,SAAS,MAAM,eAAe,WAFrB,WAEgC,GAD7B,QAAQ,QAAQ,kBAAkB,CAAC,CAAC,IAAI,CACH,GAAW,OAAO;EACzE,QAAQ,OAAO,MAAM,GAAG,KAAK,UAAU,MAAM,EAAE,GAAG;CACpD,SAAS,KAAK;EACZ,IAAI,EAAE,eAAe,YAAY,MAAM;EACvC,QAAQ,MAAM,GAAG,IAAI,KAAK,IAAI,IAAI,SAAS;EAC3C,QAAQ,WAAW;CACrB;AACF,CAAC;AAEH,MAAM,QAAQ,WAAW"}
@@ -1,5 +1,6 @@
1
1
  import Ajv2020 from "ajv/dist/2020";
2
2
  import JSON5 from "json5";
3
+ import { VALIDATION_ISSUE_KINDS } from "structured-context/types";
3
4
  /** Base of the `$id`s the sources use: the `latest` folder. */
4
5
  var SCHEMA_URL = `https://raw.githubusercontent.com/mindsocket/structured-context-map-views/main/schemas/generated/latest`;
5
6
  //#endregion
@@ -124,11 +125,7 @@ var definitionSchema = {
124
125
  style: parameterisable({ $ref: `${SCHEMA_URL}/settings.json#/$defs/nodeStyle` }, "card", "How nodes are drawn."),
125
126
  fields: parameterisable({ $ref: `${SCHEMA_URL}/settings.json#/$defs/fieldList` }, [], "Schema fields shown on cards."),
126
127
  validation: parameterisable({ $ref: `${SCHEMA_URL}/settings.json#/$defs/validationLevel` }, "off", "The lowest severity of validation result shown on nodes, or off. Needs the host to supply results."),
127
- validationSources: parameterisable({ $ref: `${SCHEMA_URL}/settings.json#/$defs/validationSources` }, [
128
- "schema",
129
- "hierarchy",
130
- "rule"
131
- ], "Which kinds of validation result are shown.")
128
+ validationSources: parameterisable({ $ref: `${SCHEMA_URL}/settings.json#/$defs/validationSources` }, VALIDATION_ISSUE_KINDS, "Which kinds of validation result are shown.")
132
129
  }
133
130
  },
134
131
  edges: {
@@ -251,13 +248,9 @@ var MAP_VIEW_SCHEMAS = [
251
248
  },
252
249
  validationSources: {
253
250
  title: "Validation sources",
254
- description: "Which kinds of validation result are shown. schema: a node failing its schema. hierarchy: a node under a parent type it is not allowed under. rule: a schema rule violation.",
251
+ description: "Which kinds of validation result are shown. schema: a node failing its schema. duplicate: an id more than one node uses. broken-link: a relationship to a node that does not exist. hierarchy: a node under a parent type it is not allowed under. rule: a schema rule violation. gated: a note that rules were not checked because an ancestor failed. content-link: a link in the body that resolves to no node.",
255
252
  type: "array",
256
- items: { enum: [
257
- "schema",
258
- "hierarchy",
259
- "rule"
260
- ] },
253
+ items: { enum: VALIDATION_ISSUE_KINDS },
261
254
  uniqueItems: true
262
255
  },
263
256
  fieldList: {
@@ -613,4 +606,4 @@ function detail(error) {
613
606
  //#endregion
614
607
  export { resolveRegions as a, MAP_VIEW_SCHEMAS as c, resolveParameterValues as i, mapViewsForSchema as n, selectionFilter as o, parseMapViewDefinition as r, viewValidationLevel as s, MapViewDefinitionError as t };
615
608
 
616
- //# sourceMappingURL=definition-Cft28YUA.js.map
609
+ //# sourceMappingURL=definition-Cp1CCigh.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definition-Cp1CCigh.js","names":[],"sources":["../src/core/format/schema-url.ts","../src/core/format/param-ref.ts","../src/core/format/definition-schema.ts","../src/core/format/landscape-layout.ts","../src/core/format/settings.ts","../src/core/format/tree-layout.ts","../src/core/format/xy-layout.ts","../src/core/format/index.ts","../src/core/definition.ts"],"sourcesContent":["/**\n * Where the format schemas are published. `latest` follows the newest format; a release that changes it\n * freezes a copy under its own version folder (`bun run generate:schemas --release`).\n */\nexport const SCHEMA_BASE_URL =\n 'https://raw.githubusercontent.com/mindsocket/structured-context-map-views/main/schemas/generated';\n\n/** Base of the `$id`s the sources use: the `latest` folder. */\nexport const SCHEMA_URL = `${SCHEMA_BASE_URL}/latest` as const;\n","import { SCHEMA_URL } from './schema-url';\n/** `$ref` target for a setting whose value comes from a declared parameter. */\nexport const PARAM_REF = `${SCHEMA_URL}/definition.json#/$defs/paramRef` as const;\n\n/** A setting that takes either a fixed value matching `valueSchema` or a `{ $param }` binding. */\nexport function parameterisable<const S extends object, const D>(valueSchema: S, defaultValue: D, description: string) {\n return { description, default: defaultValue, anyOf: [valueSchema, { $ref: PARAM_REF }] } as const;\n}\n","import { VALIDATION_ISSUE_KINDS } from 'structured-context/types';\nimport { PARAM_REF, parameterisable } from './param-ref';\nimport { SCHEMA_URL } from './schema-url';\n\n/**\n * The map view definition format: shared parameters, and the regions a map view is composed of.\n *\n * Written as TypeScript so the definition types derive from it (`FromSchema`); the JSON files\n * for `$schema` references and editors are generated (`bun run generate:schemas`).\n */\nexport const definitionSchema = {\n $schema: 'https://json-schema.org/draft/2020-12/schema',\n $id: `${SCHEMA_URL}/definition.json`,\n title: 'Map view definition',\n description:\n 'Declares how spaces of one schema are projected into a map view: shared parameters, and the regions the map view is composed of.',\n type: 'object',\n required: ['$id', 'schema', 'regions'],\n additionalProperties: false,\n properties: {\n $schema: { type: 'string' },\n $id: {\n type: 'string',\n pattern: '^sctx-map-view://[^/]+(/[^/]+)?$',\n description:\n 'Identifier, namespaced by where the definition is found: \"sctx-map-view://core/<name>\" (bundled), \"sctx-map-view://<plugin>/<name>\" (a plugin) or \"sctx-map-view://<name>\" (the config folder).',\n },\n title: { type: 'string', minLength: 1, description: 'Display name. Defaults to the last segment of the `$id`.' },\n description: { type: 'string' },\n schema: {\n type: 'string',\n minLength: 1,\n description: '`$id` of the structured-context schema whose spaces this map view applies to.',\n },\n parameters: {\n type: 'object',\n description:\n 'Settings the reader can change. Each is a JSON Schema with a default, bound to settings anywhere in the definition with { \"$param\": \"<name>\" }.',\n additionalProperties: { $ref: '#/$defs/parameter' },\n },\n regions: {\n type: 'array',\n minItems: 1,\n description:\n 'Parts of the map view, each with its own layout, nodes and edges. Only the first region is rendered for now.',\n items: { $ref: '#/$defs/region' },\n },\n },\n $defs: {\n parameter: {\n type: 'object',\n description:\n \"A JSON Schema for the parameter's values (it can $ref, narrow or extend the bundled setting definitions), plus a title for its control.\",\n required: ['default'],\n properties: {\n title: { type: 'string' },\n description: { type: 'string' },\n default: {},\n },\n },\n paramRef: {\n type: 'object',\n description: \"Takes this setting's value from a declared parameter.\",\n required: ['$param'],\n additionalProperties: false,\n properties: { $param: { type: 'string', minLength: 1 } },\n },\n region: {\n type: 'object',\n required: ['id', 'layout'],\n additionalProperties: false,\n properties: {\n id: {\n type: 'string',\n minLength: 1,\n description: 'Unique within the map view; part of every occurrence id in the region.',\n },\n select: {\n type: 'object',\n description: 'Which nodes of the space the region shows. By default, all of them.',\n additionalProperties: false,\n properties: {\n filter: {\n type: 'string',\n minLength: 1,\n description:\n \"A structured-context filter: a view name from the space's config, or an expression such as `WHERE …` or `SELECT … WHERE …`.\",\n },\n },\n },\n layout: {\n description: 'How the region is arranged, chosen by `type`.',\n type: 'object',\n required: ['type'],\n // Ajv validates only the branch `type` selects, so errors name that layout's settings.\n discriminator: { propertyName: 'type' },\n oneOf: [\n { $ref: `${SCHEMA_URL}/layouts/tree.json` },\n { $ref: `${SCHEMA_URL}/layouts/landscape.json` },\n { $ref: `${SCHEMA_URL}/layouts/xy.json` },\n ],\n },\n nodes: {\n type: 'object',\n additionalProperties: false,\n default: {},\n properties: {\n style: parameterisable(\n { $ref: `${SCHEMA_URL}/settings.json#/$defs/nodeStyle` },\n 'card',\n 'How nodes are drawn.',\n ),\n fields: parameterisable(\n { $ref: `${SCHEMA_URL}/settings.json#/$defs/fieldList` },\n [],\n 'Schema fields shown on cards.',\n ),\n validation: parameterisable(\n { $ref: `${SCHEMA_URL}/settings.json#/$defs/validationLevel` },\n 'off',\n 'The lowest severity of validation result shown on nodes, or off. Needs the host to supply results.',\n ),\n validationSources: parameterisable(\n { $ref: `${SCHEMA_URL}/settings.json#/$defs/validationSources` },\n VALIDATION_ISSUE_KINDS,\n 'Which kinds of validation result are shown.',\n ),\n },\n },\n edges: {\n type: 'object',\n additionalProperties: false,\n default: {},\n properties: {\n show: parameterisable({ type: 'boolean' }, true, 'Whether connectors are drawn.'),\n },\n },\n },\n },\n },\n} as const;\n\nexport { PARAM_REF };\n","import { PARAM_REF, parameterisable } from './param-ref';\nimport { SCHEMA_URL } from './schema-url';\n\n/** Settings of the landscape layout: nested containers following an authored grouping. */\nexport const landscapeLayoutSchema = {\n $schema: 'https://json-schema.org/draft/2020-12/schema',\n $id: `${SCHEMA_URL}/layouts/landscape.json`,\n title: 'Landscape layout',\n description:\n 'Nested containers: each grouping level becomes containers inside the level above, and the last level is drawn as nodes.',\n type: 'object',\n required: ['type', 'group'],\n additionalProperties: false,\n properties: {\n type: { const: 'landscape' },\n orientation: parameterisable(\n { $ref: `${SCHEMA_URL}/settings.json#/$defs/orientation` },\n 'horizontal',\n 'horizontal: top-level containers side by side, as columns. vertical: stacked, as rows.',\n ),\n group: {\n type: 'array',\n minItems: 1,\n description:\n 'Grouping levels, outermost first. The last level is drawn as nodes; the others as containers. Adjacent node levels are joined by any edge between their types, in either direction.',\n // Dispatch on `field`, so errors come from the kind of level written, not both.\n items: {\n type: 'object',\n if: { type: 'object', required: ['field'] },\n // biome-ignore lint/suspicious/noThenProperty: JSON Schema's `then` keyword.\n then: {\n type: 'object',\n description:\n \"Containers labelled by the values of a field of the next node level's nodes. A node with several values appears under each.\",\n required: ['field'],\n additionalProperties: false,\n properties: { field: { type: 'string', minLength: 1 } },\n },\n else: {\n type: 'object',\n description: 'A level of nodes of one type.',\n required: ['type'],\n additionalProperties: false,\n properties: {\n type: {\n description: 'Node type at this level.',\n anyOf: [{ type: 'string', minLength: 1 }, { $ref: PARAM_REF }],\n },\n edge: {\n type: 'object',\n description:\n 'Which edges join this level to the node level above (or to the last `via` type). By default, any edge between the two types.',\n required: ['field'],\n additionalProperties: false,\n properties: { field: { type: 'string', minLength: 1 } },\n },\n via: {\n type: 'array',\n minItems: 1,\n description:\n 'Types skipped between the node level above and this one, in order. Nodes are joined through a chain of edges across them. Ignored on the first level, which has no level above.',\n items: { type: 'string', minLength: 1 },\n },\n intermediate: parameterisable(\n { $ref: `${SCHEMA_URL}/layouts/landscape.json#/$defs/intermediate` },\n 'hidden',\n 'How the skipped nodes of a `via` chain are shown.',\n ),\n },\n },\n },\n },\n },\n $defs: {\n intermediate: {\n title: 'Skipped levels',\n description: 'hidden: not shown. breadcrumb: listed on each node reached through them.',\n enum: ['hidden', 'breadcrumb'],\n },\n },\n} as const;\n","import { VALIDATION_ISSUE_KINDS } from 'structured-context/types';\nimport { SCHEMA_URL } from './schema-url';\n/** Reusable setting definitions. Parameters can `$ref` these and narrow them, e.g. with `allOf` and `enum`. */\nexport const settingsSchema = {\n $schema: 'https://json-schema.org/draft/2020-12/schema',\n $id: `${SCHEMA_URL}/settings.json`,\n title: 'Shared map view settings',\n description: 'Reusable setting definitions. Parameters can $ref these and narrow them, e.g. with allOf and enum.',\n $defs: {\n orientation: {\n title: 'Orientation',\n enum: ['vertical', 'horizontal'],\n },\n nodeStyle: {\n title: 'Node style',\n description: 'card: a box with the title and selected fields. shape: a compact marker with a tooltip.',\n enum: ['card', 'shape'],\n },\n validationLevel: {\n title: 'Validation overlay',\n description:\n 'The lowest severity of validation result shown on nodes, or off. error: only errors. warning: errors and warnings. info: everything.',\n enum: ['off', 'error', 'warning', 'info'],\n },\n validationSources: {\n title: 'Validation sources',\n description:\n 'Which kinds of validation result are shown. schema: a node failing its schema. duplicate: an id more than one node uses. broken-link: a relationship to a node that does not exist. hierarchy: a node under a parent type it is not allowed under. rule: a schema rule violation. gated: a note that rules were not checked because an ancestor failed. content-link: a link in the body that resolves to no node.',\n type: 'array',\n items: { enum: VALIDATION_ISSUE_KINDS },\n uniqueItems: true,\n },\n fieldList: {\n title: 'Fields',\n type: 'array',\n items: { type: 'string', minLength: 1 },\n uniqueItems: true,\n },\n },\n} as const;\n","import { parameterisable } from './param-ref';\nimport { SCHEMA_URL } from './schema-url';\n\n/** Settings of the tree layout: a tree over the schema's hierarchy. */\nexport const treeLayoutSchema = {\n $schema: 'https://json-schema.org/draft/2020-12/schema',\n $id: `${SCHEMA_URL}/layouts/tree.json`,\n title: 'Tree layout',\n description: \"A tree over the schema's hierarchy: root-type nodes at the top, children via hierarchy edges.\",\n type: 'object',\n required: ['type'],\n additionalProperties: false,\n properties: {\n type: { const: 'tree' },\n orientation: parameterisable(\n { $ref: `${SCHEMA_URL}/settings.json#/$defs/orientation` },\n 'vertical',\n 'Direction the tree grows.',\n ),\n dag: parameterisable(\n { $ref: `${SCHEMA_URL}/layouts/tree.json#/$defs/dag` },\n 'repeat',\n 'How a node with several parents is shown.',\n ),\n },\n $defs: {\n dag: {\n title: 'Nodes with several parents',\n description:\n 'repeat: the node appears under each parent, its subtree shown once. cross-edge: the node appears under its first parent, with extra connectors from the others.',\n enum: ['repeat', 'cross-edge'],\n },\n },\n} as const;\n","import { PARAM_REF, parameterisable } from './param-ref';\nimport { SCHEMA_URL } from './schema-url';\n\n/** Settings of the XY layout: nodes positioned by two numeric fields. */\nexport const xyLayoutSchema = {\n $schema: 'https://json-schema.org/draft/2020-12/schema',\n $id: `${SCHEMA_URL}/layouts/xy.json`,\n title: 'XY layout',\n description:\n 'Nodes positioned on two axes by numeric fields. Nodes of the plotted types without a usable value on both axes are listed beside the plot, not dropped.',\n type: 'object',\n required: ['type', 'x', 'y'],\n additionalProperties: false,\n properties: {\n type: { const: 'xy' },\n x: { $ref: `${SCHEMA_URL}/layouts/xy.json#/$defs/axis` },\n y: { $ref: `${SCHEMA_URL}/layouts/xy.json#/$defs/axis` },\n types: parameterisable(\n { type: 'array', items: { type: 'string', minLength: 1 }, uniqueItems: true },\n [],\n 'Node types to plot. Empty: every type with a value on either axis.',\n ),\n edgeFields: parameterisable(\n { $ref: `${SCHEMA_URL}/settings.json#/$defs/fieldList` },\n [],\n 'Fields whose edges are drawn between plotted nodes. Empty: all edges.',\n ),\n },\n $defs: {\n axis: {\n title: 'Axis',\n type: 'object',\n required: ['field'],\n additionalProperties: false,\n properties: {\n field: {\n description: 'Numeric field giving the position.',\n anyOf: [{ type: 'string', minLength: 1 }, { $ref: PARAM_REF }],\n },\n domain: {\n description:\n 'Values at the two ends of the axis: [min, max], or \"data\" for the smallest and largest plotted values. Nodes outside a fixed domain are listed as unplaced.',\n default: 'data',\n anyOf: [{ const: 'data' }, { type: 'array', items: { type: 'number' }, minItems: 2, maxItems: 2 }],\n },\n direction: parameterisable(\n { $ref: `${SCHEMA_URL}/layouts/xy.json#/$defs/direction` },\n 'ascending',\n 'ascending: values grow rightwards (x) or upwards (y). descending: the reverse.',\n ),\n label: { type: 'string', description: 'Axis title. Defaults to the field name.' },\n },\n },\n direction: {\n title: 'Axis direction',\n enum: ['ascending', 'descending'],\n },\n },\n} as const;\n","import { definitionSchema } from './definition-schema';\nimport { landscapeLayoutSchema } from './landscape-layout';\nimport { settingsSchema } from './settings';\nimport { treeLayoutSchema } from './tree-layout';\nimport { xyLayoutSchema } from './xy-layout';\n\nexport { PARAM_REF } from './param-ref';\nexport { definitionSchema, landscapeLayoutSchema, settingsSchema, treeLayoutSchema, xyLayoutSchema };\n\n/** The bundled schemas describing the map view definition format. */\nexport const MAP_VIEW_SCHEMAS = [\n definitionSchema,\n settingsSchema,\n treeLayoutSchema,\n landscapeLayoutSchema,\n xyLayoutSchema,\n] as const;\n","import Ajv2020, { type AnySchemaObject, type ErrorObject } from 'ajv/dist/2020';\nimport type { FromSchema } from 'json-schema-to-ts';\nimport JSON5 from 'json5';\nimport {\n definitionSchema,\n type landscapeLayoutSchema,\n MAP_VIEW_SCHEMAS,\n type settingsSchema,\n type treeLayoutSchema,\n type xyLayoutSchema,\n} from './format';\nimport { SCHEMA_URL } from './format/schema-url';\n\nexport { MAP_VIEW_SCHEMAS };\n\ntype References = {\n references: [\n typeof settingsSchema,\n typeof treeLayoutSchema,\n typeof landscapeLayoutSchema,\n typeof xyLayoutSchema,\n typeof definitionSchema,\n ];\n // Grouping levels dispatch with if/then/else (see the landscape layout schema).\n parseIfThenElseKeywords: true;\n};\ntype ParamRef = { $param: string };\n/** Drop `{ $param }` bindings from every setting's type: what remains after resolution. */\ntype Resolved<T> = T extends ParamRef\n ? never\n : T extends readonly (infer U)[]\n ? Resolved<U>[]\n : T extends object\n ? { [K in keyof T]: Resolved<T[K]> }\n : T;\n\n/** A definition as authored: settings may be `{ $param }` bindings, defaulted properties may be absent. */\nexport type AuthoredDefinition = FromSchema<\n typeof definitionSchema,\n References & { keepDefaultedPropertiesOptional: true }\n>;\ntype FilledDefinition = FromSchema<typeof definitionSchema, References>;\n\n/** A region with parameters applied and defaults filled in: what layouts receive. */\nexport type Region = Resolved<FilledDefinition['regions'][number]>;\nexport type LayoutConfig = Region['layout'];\nexport type TreeLayoutConfig = Extract<LayoutConfig, { type: 'tree' }>;\nexport type LandscapeLayoutConfig = Extract<LayoutConfig, { type: 'landscape' }>;\nexport type XYLayoutConfig = Extract<LayoutConfig, { type: 'xy' }>;\nexport type AxisConfig = XYLayoutConfig['x'];\nexport type GroupLevel = LandscapeLayoutConfig['group'][number];\nexport type IntermediateDisplay = Extract<GroupLevel, { type: string }>['intermediate'];\nexport type NodesConfig = Region['nodes'];\nexport type EdgesConfig = Region['edges'];\nexport type Orientation = TreeLayoutConfig['orientation'];\nexport type DagMode = TreeLayoutConfig['dag'];\nexport type NodeStyle = NodesConfig['style'];\n\n/**\n * A validated map view definition. Plain data, so hosts can pass it across a server/browser\n * boundary. Settings in `source` may still be `{ $param }` bindings; {@link resolveRegions}\n * replaces them with parameter values.\n */\nexport type MapViewDefinition = {\n /** The definition's `$id`. */\n id: string;\n title: string;\n description?: string;\n /** `$id` of the schema whose spaces this map view applies to. */\n schema: string;\n parameters: Parameter[];\n /** The definition as authored. */\n source: AuthoredDefinition;\n};\n\n/** A setting the reader can change, with the control generated from its schema. */\nexport type Parameter = {\n name: string;\n title: string;\n description?: string;\n default: unknown;\n control: ParameterControl;\n};\n\n/** Options are JSON primitives, so they can be labelled and compared directly. */\nexport type ParameterControl =\n | { kind: 'select'; options: readonly Primitive[] }\n | { kind: 'multiselect'; options: readonly Primitive[] }\n | { kind: 'toggle' };\n\ntype Primitive = string | number | boolean | null;\n\nexport type ParameterValues = Readonly<Record<string, unknown>>;\n\nexport class MapViewDefinitionError extends Error {\n constructor(name: string, message: string) {\n super(`Map view \"${name}\": ${message}`);\n this.name = 'MapViewDefinitionError';\n }\n}\n\nconst newAjv = (options: { useDefaults?: boolean } = {}) =>\n new Ajv2020({\n allErrors: true,\n discriminator: true,\n ...options,\n schemas: MAP_VIEW_SCHEMAS.map((s) => structuredClone(s) as AnySchemaObject),\n });\n\n/** Validates definitions as authored. */\nconst ajv = newAjv();\nconst validateDefinition = ajv.getSchema(definitionSchema.$id)!;\n/** Validates resolved definitions, filling in setting defaults from the schemas. */\nconst fillDefaults = newAjv({ useDefaults: true }).getSchema(definitionSchema.$id)!;\n\n/**\n * Parse a JSON5 map view definition and check it against the bundled schemas. `name` labels\n * error messages (hosts pass where the definition came from).\n *\n * Beyond schema validation: every parameter needs a control derivable from its schema, and\n * every value that control can produce must satisfy the parameter's schema; every `$param`\n * must name a declared parameter; and each parameter's values must be valid wherever it's\n * bound, checked by substituting them and re-validating.\n */\nexport function parseMapViewDefinition(name: string, text: string): MapViewDefinition {\n const fail = (message: string): never => {\n throw new MapViewDefinitionError(name, message);\n };\n\n let raw: unknown;\n try {\n raw = JSON5.parse(text);\n } catch (err) {\n return fail(`invalid JSON5: ${err instanceof Error ? err.message : String(err)}`);\n }\n if (!validateDefinition(raw)) return fail(formatErrors(validateDefinition.errors, raw));\n const source = raw as AuthoredDefinition;\n\n // A fresh instance per parse, so compiled parameter schemas aren't cached indefinitely.\n const parameterAjv = newAjv();\n const declared = (source.parameters ?? {}) as Record<string, AnySchemaObject>;\n const parameters = Object.entries(declared).map(([paramName, schema]) =>\n parseParameter(paramName, schema, parameterAjv, (message) => fail(`parameter \"${paramName}\": ${message}`)),\n );\n\n for (const bound of paramNames(source.regions)) {\n if (!(bound in declared)) fail(`\"$param\": \"${bound}\" is not a declared parameter`);\n }\n checkBindings(source, parameters, fail);\n\n const regionIds = new Set<string>();\n for (const region of source.regions) {\n if (regionIds.has(region.id)) fail(`duplicate region id \"${region.id}\"`);\n regionIds.add(region.id);\n // A field level labels the nodes of a later level, so a node level must come last.\n if (region.layout.type === 'landscape' && !('type' in region.layout.group.at(-1)!)) {\n fail(`region \"${region.id}\": the last grouping level must be a node type, not a field`);\n }\n if (region.layout.type === 'xy') {\n for (const axis of ['x', 'y'] as const) {\n const { domain } = region.layout[axis];\n if (Array.isArray(domain) && !(domain[0]! < domain[1]!)) {\n fail(`region \"${region.id}\": ${axis} domain must be [min, max] with min < max`);\n }\n }\n }\n }\n\n return {\n id: source.$id,\n title: source.title ?? source.$id.slice(source.$id.lastIndexOf('/') + 1),\n ...(source.description !== undefined && { description: source.description }),\n schema: source.schema,\n parameters,\n source,\n };\n}\n\n/**\n * The value each parameter takes: the given value if its control could produce it, otherwise\n * (missing, or stale saved state) the default. Hosts' controls and rendering both use this.\n */\nexport function resolveParameterValues(definition: MapViewDefinition, values: ParameterValues = {}): ParameterValues {\n return Object.fromEntries(\n definition.parameters.map((param) => {\n const value = values[param.name];\n const chosen = value !== undefined && isProducible(param.control, value) ? value : param.default;\n return [param.name, structuredClone(chosen)];\n }),\n );\n}\n\n/** Apply parameter values to a definition's regions and fill in setting defaults. */\nexport function resolveRegions(definition: MapViewDefinition, values: ParameterValues = {}): Region[] {\n const resolved = resolveParameterValues(definition, values);\n const filled = substitute(definition.source, (paramName) => resolved[paramName]);\n if (!fillDefaults(filled)) {\n // parseMapViewDefinition checked every producible value, so this means a bug, not bad input.\n throw new MapViewDefinitionError(\n definition.id,\n `resolved definition is invalid: ${formatErrors(fillDefaults.errors, filled)}`,\n );\n }\n return (filled as FilledDefinition).regions as Region[];\n}\n\n/**\n * The filter selecting the nodes a map view shows, if any. Hosts apply it when loading the space.\n * PROTOTYPE: filters are evaluated by the host, not per region in the browser, because\n * structured-context's filter evaluator can't yet be bundled for a browser (its only entry point,\n * `structured-context/api`, imports Node built-ins). That's fine while only the first region renders.\n */\nexport function selectionFilter(definition: MapViewDefinition, values: ParameterValues = {}): string | undefined {\n return resolveRegions(definition, values)[0]?.select?.filter;\n}\n\n/**\n * The lowest severity of validation result the map view shows on nodes, or `off`. Hosts check it to\n * decide whether to run validation at all, since results are only drawn when this isn't `off`.\n */\nexport function viewValidationLevel(\n definition: MapViewDefinition,\n values: ParameterValues = {},\n): NodesConfig['validation'] {\n return resolveRegions(definition, values)[0]?.nodes.validation ?? 'off';\n}\n\n/** Map view definitions that apply to a space with the given schema. */\nexport function mapViewsForSchema(\n definitions: readonly MapViewDefinition[],\n schemaId: string | undefined,\n): MapViewDefinition[] {\n return schemaId === undefined ? [] : definitions.filter((d) => d.schema === schemaId);\n}\n\n/** Resolve `$ref`s relative to the format schemas, so parameters can write `settings.json#/$defs/orientation`. */\nfunction absoluteRefs(node: unknown): unknown {\n if (Array.isArray(node)) return node.map(absoluteRefs);\n if (typeof node !== 'object' || node === null) return node;\n return Object.fromEntries(\n Object.entries(node).map(([key, value]) => [\n key,\n key === '$ref' && typeof value === 'string' ? new URL(value, `${SCHEMA_URL}/`).href : absoluteRefs(value),\n ]),\n );\n}\n\nfunction parseParameter(\n name: string,\n schema: AnySchemaObject,\n parameterAjv: Ajv2020,\n fail: (message: string) => never,\n): Parameter {\n const { title, description, default: defaultValue, ...authored } = schema;\n const valueSchema = absoluteRefs(authored) as AnySchemaObject;\n let validate: (value: unknown) => boolean;\n try {\n validate = parameterAjv.compile(valueSchema);\n } catch (err) {\n return fail(`invalid schema: ${err instanceof Error ? err.message : String(err)}`);\n }\n if (!validate(defaultValue)) return fail(`default ${JSON.stringify(defaultValue)} doesn't match its schema`);\n\n const control = controlFor(valueSchema, fail);\n const invalid = producibleValues(control).filter((value) => !validate(value));\n if (invalid.length > 0) {\n fail(\n `its ${control.kind} control can produce ${invalid.map((v) => JSON.stringify(v)).join(', ')}, which its schema rejects; remove constraints the control can't enforce`,\n );\n }\n\n return {\n name,\n title: typeof title === 'string' ? title : (titleFromRef(valueSchema) ?? name),\n ...(typeof description === 'string' && { description }),\n default: defaultValue,\n control,\n };\n}\n\n/**\n * Values a control can produce, as checked against schemas. For a multi-select that's none,\n * each option alone, and all of them. PROTOTYPE: other subsets are assumed valid if these are,\n * which holds for the constraints in use (enum items, uniqueItems) but not, say, `contains`.\n */\nfunction producibleValues(control: ParameterControl): unknown[] {\n switch (control.kind) {\n case 'toggle':\n return [true, false];\n case 'select':\n return [...control.options];\n case 'multiselect':\n return [[], ...control.options.map((option) => [option]), [...control.options]];\n }\n}\n\n/**\n * Every `$param` binding must accept each value the parameter's control can produce.\n * PROTOTYPE: parameters are checked one at a time, with the others at their defaults, which\n * assumes their bindings don't constrain each other.\n */\nfunction checkBindings(source: AuthoredDefinition, parameters: Parameter[], fail: (message: string) => never) {\n const defaults = new Map(parameters.map((p) => [p.name, p.default]));\n for (const param of parameters) {\n for (const candidate of producibleValues(param.control)) {\n const substituted = substitute(source, (n) => (n === param.name ? candidate : defaults.get(n)));\n if (!validateDefinition(substituted)) {\n fail(\n `parameter \"${param.name}\" value ${JSON.stringify(candidate)} isn't valid where it's used: ${formatErrors(validateDefinition.errors, substituted)}`,\n );\n }\n }\n }\n}\n\n/**\n * Derive a control from a parameter's value schema: `enum` (directly, via `$ref`, or narrowed\n * with `allOf`) gives a select, an array of such items a multi-select, `boolean` a toggle.\n */\nfunction controlFor(schema: AnySchemaObject, fail: (message: string) => never): ParameterControl {\n if (typeOf(schema) === 'boolean') return { kind: 'toggle' };\n const isArray = typeOf(schema) === 'array';\n const options = isArray ? intersect(itemSchemas(schema).map(enumOf)) : enumOf(schema);\n if (!options) {\n return fail(\n 'no control can be generated: give it enum options (directly, or via $ref/allOf), array items with enum options, or type boolean',\n );\n }\n if (options.length === 0) return fail('its options narrow to nothing');\n if (!options.every(isPrimitive)) return fail('options must be strings, numbers, booleans or null');\n return { kind: isArray ? 'multiselect' : 'select', options };\n}\n\n/** Schemas linked from this one through `$ref` and `allOf`. */\nfunction linked(schema: AnySchemaObject): AnySchemaObject[] {\n const ref = typeof schema.$ref === 'string' ? ajv.getSchema(schema.$ref)?.schema : undefined;\n return [...(typeof ref === 'object' ? [ref] : []), ...((schema.allOf as AnySchemaObject[] | undefined) ?? [])];\n}\n\n/** Allowed values, intersecting `enum`/`const` with those reached through `$ref` and `allOf`. */\nfunction enumOf(schema: AnySchemaObject): unknown[] | undefined {\n return intersect([\n Array.isArray(schema.enum) ? schema.enum : undefined,\n 'const' in schema ? [schema.const] : undefined,\n ...linked(schema).map(enumOf),\n ]);\n}\n\nfunction typeOf(schema: AnySchemaObject): unknown {\n if (schema.type !== undefined) return schema.type;\n return linked(schema)\n .map(typeOf)\n .find((type) => type !== undefined);\n}\n\n/** Every `items` schema applying to an array, so their constraints can be intersected. */\nfunction itemSchemas(schema: AnySchemaObject): AnySchemaObject[] {\n return [...(typeof schema.items === 'object' ? [schema.items] : []), ...linked(schema).flatMap(itemSchemas)];\n}\n\nfunction intersect(sets: (unknown[] | undefined)[]): unknown[] | undefined {\n const defined = sets.filter((set): set is unknown[] => set !== undefined);\n if (defined.length === 0) return undefined;\n const key = (v: unknown) => JSON.stringify(v);\n return defined.reduce((acc, set) => acc.filter((v) => set.some((w) => key(w) === key(v))));\n}\n\nfunction titleFromRef(schema: AnySchemaObject): string | undefined {\n const title = linked(schema)[0]?.title;\n return typeof title === 'string' ? title : undefined;\n}\n\nfunction isPrimitive(value: unknown): value is Primitive {\n return value === null || ['string', 'number', 'boolean'].includes(typeof value);\n}\n\nfunction isProducible(control: ParameterControl, value: unknown): boolean {\n switch (control.kind) {\n case 'toggle':\n return typeof value === 'boolean';\n case 'select':\n return control.options.includes(value as Primitive);\n case 'multiselect':\n return Array.isArray(value) && value.every((v) => control.options.includes(v));\n }\n}\n\nfunction isParamRef(value: unknown): value is ParamRef {\n return typeof value === 'object' && value !== null && typeof (value as { $param?: unknown }).$param === 'string';\n}\n\n/** Copy a JSON value, replacing each `{ $param }` binding with its value. */\nfunction substitute(value: unknown, valueFor: (paramName: string) => unknown): unknown {\n if (isParamRef(value)) return structuredClone(valueFor(value.$param));\n if (Array.isArray(value)) return value.map((v) => substitute(v, valueFor));\n if (typeof value === 'object' && value !== null) {\n return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, substitute(v, valueFor)]));\n }\n return value;\n}\n\nfunction paramNames(value: unknown): string[] {\n if (isParamRef(value)) return [value.$param];\n if (Array.isArray(value)) return value.flatMap(paramNames);\n if (typeof value === 'object' && value !== null) return Object.values(value).flatMap(paramNames);\n return [];\n}\n\n/**\n * Readable Ajv errors. A setting accepts a value or a `{ $param }` binding (`anyOf`), so a bad\n * value also fails the binding branch; those errors, and the bare anyOf summary, are dropped\n * unless the value actually is a binding. An `if` failure only repeats its branch's errors.\n */\nfunction formatErrors(errors: ErrorObject[] | null | undefined, instance: unknown): string {\n const relevant = (errors ?? []).filter(\n (e) =>\n e.keyword !== 'anyOf' &&\n e.keyword !== 'if' &&\n !(e.schemaPath.includes('/$defs/paramRef') && !isParamRef(at(instance, e.instancePath))),\n );\n return relevant.map((e) => `${e.instancePath || '/'} ${message(e)}${detail(e)}`).join('; ');\n}\n\n/** The value at a JSON pointer. */\nfunction at(value: unknown, pointer: string): unknown {\n return pointer\n .split('/')\n .slice(1)\n .map((segment) => segment.replaceAll('~1', '/').replaceAll('~0', '~'))\n .reduce<unknown>(\n (node, key) => (typeof node === 'object' && node !== null ? (node as Record<string, unknown>)[key] : undefined),\n value,\n );\n}\n\nfunction message(error: ErrorObject): string | undefined {\n if (error.keyword === 'discriminator' && error.params.error === 'mapping') {\n return `has unknown ${error.params.tag} ${JSON.stringify(error.params.tagValue)}`;\n }\n return error.message;\n}\n\nfunction detail(error: ErrorObject): string {\n if (error.keyword === 'additionalProperties') return ` (\"${error.params.additionalProperty}\")`;\n if (error.keyword === 'enum') {\n return ` (${(error.params.allowedValues as unknown[]).map((v) => JSON.stringify(v)).join(', ')})`;\n }\n return '';\n}\n"],"mappings":";;;;AAQA,IAAa,aAAa;;;;ACN1B,IAAa,YAAY,GAAG,WAAW;;AAGvC,SAAgB,gBAAiD,aAAgB,cAAiB,aAAqB;CACrH,OAAO;EAAE;EAAa,SAAS;EAAc,OAAO,CAAC,aAAa,EAAE,MAAM,UAAU,CAAC;CAAE;AACzF;;;;;;;;;ACGA,IAAa,mBAAmB;CAC9B,SAAS;CACT,KAAK,GAAG,WAAW;CACnB,OAAO;CACP,aACE;CACF,MAAM;CACN,UAAU;EAAC;EAAO;EAAU;CAAS;CACrC,sBAAsB;CACtB,YAAY;EACV,SAAS,EAAE,MAAM,SAAS;EAC1B,KAAK;GACH,MAAM;GACN,SAAS;GACT,aACE;EACJ;EACA,OAAO;GAAE,MAAM;GAAU,WAAW;GAAG,aAAa;EAA2D;EAC/G,aAAa,EAAE,MAAM,SAAS;EAC9B,QAAQ;GACN,MAAM;GACN,WAAW;GACX,aAAa;EACf;EACA,YAAY;GACV,MAAM;GACN,aACE;GACF,sBAAsB,EAAE,MAAM,oBAAoB;EACpD;EACA,SAAS;GACP,MAAM;GACN,UAAU;GACV,aACE;GACF,OAAO,EAAE,MAAM,iBAAiB;EAClC;CACF;CACA,OAAO;EACL,WAAW;GACT,MAAM;GACN,aACE;GACF,UAAU,CAAC,SAAS;GACpB,YAAY;IACV,OAAO,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U,MAAM,OAAO,QAAQ;CAEhF,OAAO,MAAM;AACf;AAEA,SAAS,OAAO,OAA4B;CAC1C,IAAI,MAAM,YAAY,wBAAwB,OAAO,MAAM,MAAM,OAAO,mBAAmB;CAC3F,IAAI,MAAM,YAAY,QACpB,OAAO,KAAM,MAAM,OAAO,cAA4B,KAAK,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE;CAEjG,OAAO;AACT"}
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as annotationsFrom, r as buildTree, s as worstSeverity } from "./projection-GaO0MCbR.js";
2
- import { c as MAP_VIEW_SCHEMAS, i as resolveParameterValues, n as mapViewsForSchema, o as selectionFilter, r as parseMapViewDefinition, s as viewValidationLevel, t as MapViewDefinitionError } from "./definition-Cft28YUA.js";
3
- import { a as SelectParameterInput, i as ParameterInput, n as useParameterControls, o as ToggleParameterInput, r as MultiSelectParameterInput, s as MapView, t as ParameterControls } from "./ParameterControls-eKRxNr1P.js";
1
+ import { a as annotationsFrom, r as buildTree, s as worstSeverity } from "./projection-CYShQhug.js";
2
+ import { c as MAP_VIEW_SCHEMAS, i as resolveParameterValues, n as mapViewsForSchema, o as selectionFilter, r as parseMapViewDefinition, s as viewValidationLevel, t as MapViewDefinitionError } from "./definition-Cp1CCigh.js";
3
+ import { a as SelectParameterInput, i as ParameterInput, n as useParameterControls, o as ToggleParameterInput, r as MultiSelectParameterInput, s as MapView, t as ParameterControls } from "./ParameterControls--sD0-okx.js";
4
4
  export { MAP_VIEW_SCHEMAS, MapView, MapViewDefinitionError, MultiSelectParameterInput, ParameterControls, ParameterInput, SelectParameterInput, ToggleParameterInput, annotationsFrom, buildTree, mapViewsForSchema, parseMapViewDefinition, resolveParameterValues, selectionFilter, useParameterControls, viewValidationLevel, worstSeverity };
@@ -1,4 +1,4 @@
1
- import { r as parseMapViewDefinition } from "./definition-Cft28YUA.js";
1
+ import { r as parseMapViewDefinition } from "./definition-Cp1CCigh.js";
2
2
  import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
3
3
  import { dirname, join, resolve } from "node:path";
4
4
  import { PLUGIN_PREFIX, resolveConfigPath, resolvePluginDir } from "structured-context/api";
@@ -103,4 +103,4 @@ function isDirectory(path) {
103
103
  //#endregion
104
104
  export { loadMapViewDefinitions as t };
105
105
 
106
- //# sourceMappingURL=node-BceB0Wzc.js.map
106
+ //# sourceMappingURL=node-Co_JiEZV.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"node-BceB0Wzc.js","names":[],"sources":["../src/node/bundled-definitions.ts","../src/node/index.ts"],"sourcesContent":["// Generated by scripts/generate-definitions.ts from map-views/*.json5. Do not edit.\nexport const BUNDLED_DEFINITIONS: Record<string, string> = {\n \"strategy-tree.json5\": \"// Strategy stack as a tree: vision → mission → goals → opportunities → solutions → experiments.\\n{\\n $schema: 'https://raw.githubusercontent.com/mindsocket/structured-context-map-views/main/schemas/generated/latest/definition.json',\\n $id: 'sctx-map-view://core/strategy-tree',\\n title: 'Strategy tree',\\n schema: 'sctx://core/strategy_general',\\n parameters: {\\n orientation: { $ref: 'settings.json#/$defs/orientation', default: 'vertical' },\\n nodeStyle: { $ref: 'settings.json#/$defs/nodeStyle', default: 'card' },\\n validation: { $ref: 'settings.json#/$defs/validationLevel', default: 'off' },\\n cardFields: {\\n title: 'Card fields',\\n type: 'array',\\n items: { enum: ['status', 'priority', 'summary'] },\\n default: ['status'],\\n },\\n },\\n regions: [\\n {\\n id: 'main',\\n layout: { type: 'tree', orientation: { $param: 'orientation' } },\\n nodes: { style: { $param: 'nodeStyle' }, fields: { $param: 'cardFields' }, validation: { $param: 'validation' } },\\n edges: { show: true },\\n },\\n ],\\n}\\n\",\n};\n","/// <reference types=\"node\" />\nimport { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';\nimport { dirname, join, resolve } from 'node:path';\nimport { type Config, PLUGIN_PREFIX, resolveConfigPath, resolvePluginDir } from 'structured-context/api';\nimport { type MapViewDefinition, parseMapViewDefinition } from '../core/definition';\nimport { BUNDLED_DEFINITIONS } from './bundled-definitions';\n\n/**\n * Node-only: finds map view definitions the way structured-context finds plugin schemas.\n * Browser-only hosts receive the result from a server, like graph data.\n */\n\nconst SCHEME = 'sctx-map-view://';\nconst DEFINITIONS_DIR = 'map-views';\nconst CONFIG_PLUGINS_DIR = 'plugins';\nconst PACKAGE_NAME = 'structured-context-map-views';\n\ntype Source = { kind: 'core' } | { kind: 'plugin'; plugin: string } | { kind: 'config' };\n\nexport type LoadMapViewDefinitionsOptions = {\n /** Directory of the main config file. Defaults to where structured-context finds it. */\n configDir?: string;\n};\n\n/**\n * Every map view definition available with `config`, from:\n * - this package's embedded definitions (`sctx-map-view://core/<name>`), for structured-context's bundled schemas;\n * - each plugin found from a config folder or named by a space (`sctx-map-view://<plugin>/<name>`): the\n * folder named by `\"sctx\": { \"mapViews\": \"…\" }` in its package.json, else its `map-views/` folder;\n * - a `map-views/` folder next to each config file (`sctx-map-view://<name>`).\n *\n * Each definition's `$id` must be in the namespace of where it was found, and ids must be unique.\n * Throws on the first invalid definition.\n */\nexport function loadMapViewDefinitions(\n config: Config,\n options: LoadMapViewDefinitionsOptions = {},\n): MapViewDefinition[] {\n const configDir = options.configDir ?? dirname(resolve(resolveConfigPath().path));\n const configDirs = [...new Set([configDir, ...config.spaces.flatMap((s) => (s.sourceDir ? [s.sourceDir] : []))])];\n\n const folders: { dir: string; source: Source }[] = [\n ...pluginDirs(config, configDir, configDirs).flatMap(([plugin, dir]) => {\n const definitions = pluginDefinitionsDir(dir);\n return definitions ? [{ dir: definitions, source: { kind: 'plugin', plugin } as const }] : [];\n }),\n ...configDirs.map((dir) => ({ dir: join(dir, DEFINITIONS_DIR), source: { kind: 'config' } as const })),\n ];\n\n const foundAt = new Map<string, string>();\n const definitions: MapViewDefinition[] = [];\n const add = (label: string, text: string, source: Source) => {\n const definition = parseMapViewDefinition(label, text);\n assertIdNamespace(definition.id, source, label);\n const existing = foundAt.get(definition.id);\n if (existing) throw new Error(`Map view id \"${definition.id}\" is defined by both ${existing} and ${label}.`);\n foundAt.set(definition.id, label);\n definitions.push(definition);\n };\n\n for (const [file, text] of Object.entries(BUNDLED_DEFINITIONS))\n add(`${PACKAGE_NAME}/${file}`, text, { kind: 'core' });\n for (const { dir, source } of folders) {\n if (!isDirectory(dir)) continue;\n for (const file of readdirSync(dir)\n .filter((f) => f.endsWith('.json5'))\n .sort()) {\n const path = join(dir, file);\n add(path, readFileSync(path, 'utf8'), source);\n }\n }\n return definitions;\n}\n\n/** Plugin short name → root directory, for plugins in a config folder's `plugins/` or named by the config. */\nfunction pluginDirs(config: Config, configDir: string, configDirs: string[]): [string, string][] {\n const found = new Map<string, string>();\n const add = (name: string, fromDir: string) => {\n const short = name.startsWith(PLUGIN_PREFIX) ? name.slice(PLUGIN_PREFIX.length) : name;\n if (found.has(short)) return;\n const dir = resolvePluginDir(name, fromDir);\n if (dir) found.set(short, dir);\n };\n\n for (const dir of configDirs) {\n const plugins = join(dir, CONFIG_PLUGINS_DIR);\n if (!isDirectory(plugins)) continue;\n for (const entry of readdirSync(plugins)\n .filter((e) => e.startsWith(PLUGIN_PREFIX))\n .sort())\n add(entry, dir);\n }\n const topLevel = (config as { plugins?: Record<string, unknown> }).plugins ?? {};\n for (const name of Object.keys(topLevel)) add(name, configDir);\n for (const space of config.spaces) {\n const fromDir = space.sourceDir ?? configDir;\n // A schema named through a plugin, e.g. \"sctx-wardley-mapping/wardley_map.json\".\n const schemaPlugin = /^([^./][^/]*)\\/./.exec(space.schema ?? '')?.[1];\n if (schemaPlugin) add(schemaPlugin, fromDir);\n for (const name of Object.keys(space.plugins ?? {})) add(name, fromDir);\n }\n return [...found];\n}\n\nfunction pluginDefinitionsDir(pluginDir: string): string | undefined {\n const pkgPath = join(pluginDir, 'package.json');\n if (existsSync(pkgPath)) {\n const declared = JSON.parse(readFileSync(pkgPath, 'utf8')).sctx?.mapViews;\n if (typeof declared === 'string') return resolve(pluginDir, declared);\n }\n return join(pluginDir, DEFINITIONS_DIR);\n}\n\nfunction assertIdNamespace(id: string, source: Source, path: string): void {\n const segments = id.slice(SCHEME.length).split('/');\n const expected =\n source.kind === 'core'\n ? `${SCHEME}core/<name>`\n : source.kind === 'plugin'\n ? `${SCHEME}${source.plugin}/<name>`\n : `${SCHEME}<name>`;\n const ok =\n source.kind === 'config'\n ? segments.length === 1\n : segments.length === 2 && segments[0] === (source.kind === 'core' ? 'core' : source.plugin);\n if (!ok || (source.kind === 'plugin' && source.plugin === 'core')) {\n throw new Error(`Map view namespace violation: ${path} has $id \"${id}\". Use the form \"${expected}\".`);\n }\n}\n\nfunction isDirectory(path: string): boolean {\n return existsSync(path) && statSync(path).isDirectory();\n}\n"],"mappings":";;;;;AACA,IAAa,sBAA8C,EACzD,uBAAuB,8iCACzB;;;;;;;ACSA,IAAM,SAAS;AACf,IAAM,kBAAkB;AACxB,IAAM,qBAAqB;AAC3B,IAAM,eAAe;;;;;;;;;;;AAmBrB,SAAgB,uBACd,QACA,UAAyC,CAAC,GACrB;CACrB,MAAM,YAAY,QAAQ,aAAa,QAAQ,QAAQ,kBAAkB,CAAC,CAAC,IAAI,CAAC;CAChF,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,UAA6C,CACjD,GAAG,WAAW,QAAQ,WAAW,UAAU,CAAC,CAAC,SAAS,CAAC,QAAQ,SAAS;EACtE,MAAM,cAAc,qBAAqB,GAAG;EAC5C,OAAO,cAAc,CAAC;GAAE,KAAK;GAAa,QAAQ;IAAE,MAAM;IAAU;GAAO;EAAW,CAAC,IAAI,CAAC;CAC9F,CAAC,GACD,GAAG,WAAW,KAAK,SAAS;EAAE,KAAK,KAAK,KAAK,eAAe;EAAG,QAAQ,EAAE,MAAM,SAAS;CAAW,EAAE,CACvG;CAEA,MAAM,0B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S,YAAY,MAAuB;CAC1C,OAAO,WAAW,IAAI,KAAK,SAAS,IAAI,CAAC,CAAC,YAAY;AACxD"}
1
+ {"version":3,"file":"node-Co_JiEZV.js","names":[],"sources":["../src/node/bundled-definitions.ts","../src/node/index.ts"],"sourcesContent":["// Generated by scripts/generate-definitions.ts from map-views/*.json5. Do not edit.\nexport const BUNDLED_DEFINITIONS: Record<string, string> = {\n \"strategy-tree.json5\": \"// Strategy stack as a tree: vision → mission → goals → opportunities → solutions → experiments.\\n{\\n $schema: 'https://raw.githubusercontent.com/mindsocket/structured-context-map-views/main/schemas/generated/latest/definition.json',\\n $id: 'sctx-map-view://core/strategy-tree',\\n title: 'Strategy tree',\\n schema: 'sctx://core/strategy_general',\\n parameters: {\\n orientation: { $ref: 'settings.json#/$defs/orientation', default: 'vertical' },\\n nodeStyle: { $ref: 'settings.json#/$defs/nodeStyle', default: 'card' },\\n validation: { $ref: 'settings.json#/$defs/validationLevel', default: 'off' },\\n cardFields: {\\n title: 'Card fields',\\n type: 'array',\\n items: { enum: ['status', 'priority', 'summary'] },\\n default: ['status'],\\n },\\n },\\n regions: [\\n {\\n id: 'main',\\n layout: { type: 'tree', orientation: { $param: 'orientation' } },\\n nodes: { style: { $param: 'nodeStyle' }, fields: { $param: 'cardFields' }, validation: { $param: 'validation' } },\\n edges: { show: true },\\n },\\n ],\\n}\\n\",\n};\n","/// <reference types=\"node\" />\nimport { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';\nimport { dirname, join, resolve } from 'node:path';\nimport { type Config, PLUGIN_PREFIX, resolveConfigPath, resolvePluginDir } from 'structured-context/api';\nimport { type MapViewDefinition, parseMapViewDefinition } from '../core/definition';\nimport { BUNDLED_DEFINITIONS } from './bundled-definitions';\n\n/**\n * Node-only: finds map view definitions the way structured-context finds plugin schemas.\n * Browser-only hosts receive the result from a server, like graph data.\n */\n\nconst SCHEME = 'sctx-map-view://';\nconst DEFINITIONS_DIR = 'map-views';\nconst CONFIG_PLUGINS_DIR = 'plugins';\nconst PACKAGE_NAME = 'structured-context-map-views';\n\ntype Source = { kind: 'core' } | { kind: 'plugin'; plugin: string } | { kind: 'config' };\n\nexport type LoadMapViewDefinitionsOptions = {\n /** Directory of the main config file. Defaults to where structured-context finds it. */\n configDir?: string;\n};\n\n/**\n * Every map view definition available with `config`, from:\n * - this package's embedded definitions (`sctx-map-view://core/<name>`), for structured-context's bundled schemas;\n * - each plugin found from a config folder or named by a space (`sctx-map-view://<plugin>/<name>`): the\n * folder named by `\"sctx\": { \"mapViews\": \"…\" }` in its package.json, else its `map-views/` folder;\n * - a `map-views/` folder next to each config file (`sctx-map-view://<name>`).\n *\n * Each definition's `$id` must be in the namespace of where it was found, and ids must be unique.\n * Throws on the first invalid definition.\n */\nexport function loadMapViewDefinitions(\n config: Config,\n options: LoadMapViewDefinitionsOptions = {},\n): MapViewDefinition[] {\n const configDir = options.configDir ?? dirname(resolve(resolveConfigPath().path));\n const configDirs = [...new Set([configDir, ...config.spaces.flatMap((s) => (s.sourceDir ? [s.sourceDir] : []))])];\n\n const folders: { dir: string; source: Source }[] = [\n ...pluginDirs(config, configDir, configDirs).flatMap(([plugin, dir]) => {\n const definitions = pluginDefinitionsDir(dir);\n return definitions ? [{ dir: definitions, source: { kind: 'plugin', plugin } as const }] : [];\n }),\n ...configDirs.map((dir) => ({ dir: join(dir, DEFINITIONS_DIR), source: { kind: 'config' } as const })),\n ];\n\n const foundAt = new Map<string, string>();\n const definitions: MapViewDefinition[] = [];\n const add = (label: string, text: string, source: Source) => {\n const definition = parseMapViewDefinition(label, text);\n assertIdNamespace(definition.id, source, label);\n const existing = foundAt.get(definition.id);\n if (existing) throw new Error(`Map view id \"${definition.id}\" is defined by both ${existing} and ${label}.`);\n foundAt.set(definition.id, label);\n definitions.push(definition);\n };\n\n for (const [file, text] of Object.entries(BUNDLED_DEFINITIONS))\n add(`${PACKAGE_NAME}/${file}`, text, { kind: 'core' });\n for (const { dir, source } of folders) {\n if (!isDirectory(dir)) continue;\n for (const file of readdirSync(dir)\n .filter((f) => f.endsWith('.json5'))\n .sort()) {\n const path = join(dir, file);\n add(path, readFileSync(path, 'utf8'), source);\n }\n }\n return definitions;\n}\n\n/** Plugin short name → root directory, for plugins in a config folder's `plugins/` or named by the config. */\nfunction pluginDirs(config: Config, configDir: string, configDirs: string[]): [string, string][] {\n const found = new Map<string, string>();\n const add = (name: string, fromDir: string) => {\n const short = name.startsWith(PLUGIN_PREFIX) ? name.slice(PLUGIN_PREFIX.length) : name;\n if (found.has(short)) return;\n const dir = resolvePluginDir(name, fromDir);\n if (dir) found.set(short, dir);\n };\n\n for (const dir of configDirs) {\n const plugins = join(dir, CONFIG_PLUGINS_DIR);\n if (!isDirectory(plugins)) continue;\n for (const entry of readdirSync(plugins)\n .filter((e) => e.startsWith(PLUGIN_PREFIX))\n .sort())\n add(entry, dir);\n }\n const topLevel = (config as { plugins?: Record<string, unknown> }).plugins ?? {};\n for (const name of Object.keys(topLevel)) add(name, configDir);\n for (const space of config.spaces) {\n const fromDir = space.sourceDir ?? configDir;\n // A schema named through a plugin, e.g. \"sctx-wardley-mapping/wardley_map.json\".\n const schemaPlugin = /^([^./][^/]*)\\/./.exec(space.schema ?? '')?.[1];\n if (schemaPlugin) add(schemaPlugin, fromDir);\n for (const name of Object.keys(space.plugins ?? {})) add(name, fromDir);\n }\n return [...found];\n}\n\nfunction pluginDefinitionsDir(pluginDir: string): string | undefined {\n const pkgPath = join(pluginDir, 'package.json');\n if (existsSync(pkgPath)) {\n const declared = JSON.parse(readFileSync(pkgPath, 'utf8')).sctx?.mapViews;\n if (typeof declared === 'string') return resolve(pluginDir, declared);\n }\n return join(pluginDir, DEFINITIONS_DIR);\n}\n\nfunction assertIdNamespace(id: string, source: Source, path: string): void {\n const segments = id.slice(SCHEME.length).split('/');\n const expected =\n source.kind === 'core'\n ? `${SCHEME}core/<name>`\n : source.kind === 'plugin'\n ? `${SCHEME}${source.plugin}/<name>`\n : `${SCHEME}<name>`;\n const ok =\n source.kind === 'config'\n ? segments.length === 1\n : segments.length === 2 && segments[0] === (source.kind === 'core' ? 'core' : source.plugin);\n if (!ok || (source.kind === 'plugin' && source.plugin === 'core')) {\n throw new Error(`Map view namespace violation: ${path} has $id \"${id}\". Use the form \"${expected}\".`);\n }\n}\n\nfunction isDirectory(path: string): boolean {\n return existsSync(path) && statSync(path).isDirectory();\n}\n"],"mappings":";;;;;AACA,IAAa,sBAA8C,EACzD,uBAAuB,8iCACzB;;;;;;;ACSA,IAAM,SAAS;AACf,IAAM,kBAAkB;AACxB,IAAM,qBAAqB;AAC3B,IAAM,eAAe;;;;;;;;;;;AAmBrB,SAAgB,uBACd,QACA,UAAyC,CAAC,GACrB;CACrB,MAAM,YAAY,QAAQ,aAAa,QAAQ,QAAQ,kBAAkB,CAAC,CAAC,IAAI,CAAC;CAChF,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,UAA6C,CACjD,GAAG,WAAW,QAAQ,WAAW,UAAU,CAAC,CAAC,SAAS,CAAC,QAAQ,SAAS;EACtE,MAAM,cAAc,qBAAqB,GAAG;EAC5C,OAAO,cAAc,CAAC;GAAE,KAAK;GAAa,QAAQ;IAAE,MAAM;IAAU;GAAO;EAAW,CAAC,IAAI,CAAC;CAC9F,CAAC,GACD,GAAG,WAAW,KAAK,SAAS;EAAE,KAAK,KAAK,KAAK,eAAe;EAAG,QAAQ,EAAE,MAAM,SAAS;CAAW,EAAE,CACvG;CAEA,MAAM,0BAAU,IAAI,IAAoB;CACxC,MAAM,cAAmC,CAAC;CAC1C,MAAM,OAAO,OAAe,MAAc,WAAmB;EAC3D,MAAM,aAAa,uBAAuB,OAAO,IAAI;EACrD,kBAAkB,WAAW,IAAI,QAAQ,KAAK;EAC9C,MAAM,WAAW,QAAQ,IAAI,WAAW,EAAE;EAC1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
2
  export { loadMapViewDefinitions };
@@ -7,25 +7,25 @@
7
7
  function annotationsFrom(input, graph) {
8
8
  const annotations = /* @__PURE__ */ new Map();
9
9
  const unattached = [];
10
- const add = (nodeId, annotation, location) => {
11
- if (nodeId !== void 0 && graph.nodes.has(nodeId)) annotations.set(nodeId, [...annotations.get(nodeId) ?? [], annotation]);
12
- else unattached.push({
13
- ...annotation,
14
- nodeId,
15
- ...location && { location }
16
- });
17
- };
18
- for (const { nodeId, source, issues } of input.nodeErrors ?? []) for (const issue of issues) add(nodeId, {
19
- severity: "error",
20
- source: "schema",
21
- message: issue.message
22
- }, source);
23
- for (const { nodeId, description } of input.hierarchyViolations ?? []) add(nodeId, {
24
- severity: "error",
25
- source: "hierarchy",
26
- message: description
27
- });
28
- for (const { nodeId, description, severity, ruleId } of input.ruleViolations ?? []) add(nodeId, {
10
+ for (const [id, issues] of Object.entries(input.issues)) {
11
+ const nodeId = id;
12
+ for (const [key, { kind, message, severity, line, column }] of Object.entries(issues)) {
13
+ const annotation = {
14
+ severity,
15
+ source: kind,
16
+ message,
17
+ ...kind === "rule" && key.startsWith("rule:") && { ruleId: key.slice(5) }
18
+ };
19
+ if (graph.nodes.has(nodeId)) annotations.set(nodeId, [...annotations.get(nodeId) ?? [], annotation]);
20
+ else unattached.push({
21
+ ...annotation,
22
+ nodeId,
23
+ ...line !== void 0 && { line },
24
+ ...column !== void 0 && { column }
25
+ });
26
+ }
27
+ }
28
+ for (const { nodeId, description, severity, ruleId } of input.ruleViolations ?? []) if (nodeId === void 0) unattached.push({
29
29
  severity,
30
30
  source: "rule",
31
31
  message: description,
@@ -382,4 +382,4 @@ function assignLanes(links) {
382
382
  //#endregion
383
383
  export { annotationsFrom as a, treeLinks as i, buildLandscape as n, filterAnnotations as o, buildTree as r, worstSeverity as s, buildXYPlot as t };
384
384
 
385
- //# sourceMappingURL=projection-GaO0MCbR.js.map
385
+ //# sourceMappingURL=projection-CYShQhug.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projection-CYShQhug.js","names":[],"sources":["../src/core/annotations.ts","../src/core/graph.ts","../src/core/occurrence.ts","../src/core/tree.ts","../src/core/landscape.ts","../src/core/xy.ts"],"sourcesContent":["import type { nodeIssues, RuleSeverity, SpaceGraph, SpaceNode, ValidationResult } from 'structured-context/api';\nimport type { ValidationIssueKind } from 'structured-context/types';\n\n// core doesn't export NodeId from `structured-context/api` yet; this derives it.\ntype NodeId = SpaceNode['id'];\n\n/** How serious a result is: structured-context's rule severity, which every result carries. */\nexport type Severity = RuleSeverity;\n\n/** The kind of check a result came from: structured-context's issue `kind`. */\nexport type AnnotationSource = ValidationIssueKind;\n\n/** One validation result attached to a node. */\nexport type NodeAnnotation = {\n severity: Severity;\n source: AnnotationSource;\n message: string;\n /** The violated rule, for `rule` results. */\n ruleId?: string;\n};\n\n/** A validation result with no node on the map to attach to. */\nexport type UnattachedAnnotation = NodeAnnotation & {\n /** The node it concerns. Absent for a global-scope rule. A node that failed its schema isn't in the graph. */\n nodeId?: NodeId;\n /** Where in that node's file the result points, if known (1-indexed). */\n line?: number;\n column?: number;\n};\n\n/** Annotations by the id of the node they apply to. */\nexport type AnnotationIndex = ReadonlyMap<NodeId, readonly NodeAnnotation[]>;\n\n/**\n * Validation results to attach: each node's issues, from structured-context's `nodeIssues(result)` or the\n * `issues` of `sctx validate --json`, and the rule violations, of which only those without a node are read\n * (the others are in `issues`). `sctx validate --json` output can be passed as it is.\n */\nexport type ValidationInput = {\n issues: Readonly<ReturnType<typeof nodeIssues>>;\n ruleViolations?: ReadonlyArray<\n Pick<ValidationResult['ruleViolations'][number], 'nodeId' | 'ruleId' | 'severity' | 'description'>\n >;\n};\n\n/**\n * Attach validation results to the nodes of `graph`, by node id. Results that can't be attached are\n * returned in `unattached` for the host to surface: global-scope rules (no node), and nodes that\n * aren't in the graph, which includes every node that failed its schema.\n */\nexport function annotationsFrom(\n input: ValidationInput,\n graph: SpaceGraph,\n): { annotations: AnnotationIndex; unattached: UnattachedAnnotation[] } {\n const annotations = new Map<NodeId, NodeAnnotation[]>();\n const unattached: UnattachedAnnotation[] = [];\n\n for (const [id, issues] of Object.entries(input.issues)) {\n const nodeId = id as NodeId;\n for (const [key, { kind, message, severity, line, column }] of Object.entries(issues)) {\n const annotation: NodeAnnotation = {\n severity,\n source: kind,\n message,\n ...(kind === 'rule' && key.startsWith('rule:') && { ruleId: key.slice('rule:'.length) }),\n };\n if (graph.nodes.has(nodeId)) {\n annotations.set(nodeId, [...(annotations.get(nodeId) ?? []), annotation]);\n } else {\n unattached.push({\n ...annotation,\n nodeId,\n ...(line !== undefined && { line }),\n ...(column !== undefined && { column }),\n });\n }\n }\n }\n for (const { nodeId, description, severity, ruleId } of input.ruleViolations ?? []) {\n if (nodeId === undefined) unattached.push({ severity, source: 'rule', message: description, ruleId });\n }\n return { annotations, unattached };\n}\n\nconst RANK: Record<Severity, number> = { error: 0, warning: 1, info: 2 };\n\n/** The most serious severity among annotations, or undefined if there are none. */\nexport function worstSeverity(annotations: readonly NodeAnnotation[]): Severity | undefined {\n return annotations.reduce<Severity | undefined>(\n (worst, { severity }) => (worst === undefined || RANK[severity] < RANK[worst] ? severity : worst),\n undefined,\n );\n}\n\n/**\n * The annotations a map view shows: those at `level` or more serious, from `sources`. `off` shows none.\n * Nodes left with no annotations are dropped from the index.\n */\nexport function filterAnnotations(\n index: AnnotationIndex,\n level: Severity | 'off',\n sources: readonly AnnotationSource[],\n): AnnotationIndex {\n if (level === 'off') return new Map();\n const filtered = new Map<NodeId, readonly NodeAnnotation[]>();\n for (const [id, annotations] of index) {\n const kept = annotations.filter((a) => RANK[a.severity] <= RANK[level] && sources.includes(a.source));\n if (kept.length > 0) filtered.set(id, kept);\n }\n return filtered;\n}\n","import type { Hierarchy, SpaceGraph, SpaceNode } from 'structured-context/api';\n\ntype NodeId = SpaceNode['id'];\n\n/** A directed parent → child edge of a space graph, carrying the metadata of the reference it came from. */\nexport type Edge = SpaceGraph['parentEdges'] extends ReadonlyMap<string, readonly (infer E)[]> ? E : never;\n\nconst NONE: readonly Edge[] = [];\n\n/**\n * Edges to a node's parents, in the order the node declares them. A graph narrowed by a filter keeps\n * edges to parents outside it; those are left out.\n */\nexport function parentEdges(graph: SpaceGraph, id: NodeId): readonly Edge[] {\n return (graph.parentEdges.get(id) ?? NONE).filter((edge) => graph.nodes.has(edge.parent));\n}\n\n/** Edges to a node's children, in graph order of the children. */\nexport function childEdges(graph: SpaceGraph, id: NodeId): readonly Edge[] {\n return graph.childEdges.get(id) ?? NONE;\n}\n\n/** Every edge whose parent and child are both in the graph. */\nexport function edgesWithin(graph: SpaceGraph): Edge[] {\n return [...graph.nodes.keys()].flatMap((id) => parentEdges(graph, id));\n}\n\n/** Whether an edge belongs to the given hierarchy (as opposed to a relationship or another hierarchy). */\nexport function isHierarchyEdge(edge: Edge, hierarchy: Hierarchy | undefined): boolean {\n return hierarchy !== undefined && edge.kind === 'hierarchy' && edge.hierarchy === hierarchy.name;\n}\n","/**\n * One step of an occurrence path: a node title, a `[field, value]` group, or `null` for the\n * ungrouped area. Encoded distinctly, so a field group can't collide with a node of the same name.\n */\nexport type PathSegment = string | readonly [field: string, value: string | null] | null;\n\n/**\n * Path-based key for one occurrence of a node: region, then the steps from the outermost\n * container down to the node. Unique within a map view even when a node appears several times.\n * Hosts can render several map views at once, so layouts scope keys to the map view instance.\n */\nexport function occurrenceKey(regionId: string, path: readonly PathSegment[]): string {\n return JSON.stringify([regionId, ...path]);\n}\n","import type { SpaceGraph, SpaceNode } from 'structured-context/api';\nimport type { DagMode } from './definition';\nimport { childEdges, isHierarchyEdge, parentEdges } from './graph';\nimport { occurrenceKey } from './occurrence';\n\n/** One rendered appearance of a node in a tree. */\nexport type TreeOccurrence = {\n /** Path-based key, unique within the map view (see {@link occurrenceKey}). */\n key: string;\n node: SpaceNode;\n children: TreeOccurrence[];\n /**\n * Key of the node's primary occurrence when this is a repeat. A node with several parents\n * appears under each of them, but its subtree is only rendered at its first occurrence.\n */\n repeatOf?: string;\n};\n\nexport type Tree = {\n roots: TreeOccurrence[];\n /**\n * Hierarchy-typed nodes not reachable from a root, rendered as extra roots: nodes with no\n * hierarchy parent in the space, then entry points into otherwise unreachable cycles.\n */\n orphans: TreeOccurrence[];\n /** Key of each node's primary (first, fully rendered) occurrence. */\n primary: ReadonlyMap<string, string>;\n /**\n * In cross-edge mode, links from a node's other parents to its primary occurrence, which\n * replace repeat occurrences. Empty in repeat mode.\n */\n crossLinks: TreeLink[];\n};\n\nexport type TreeLink = { from: string; to: string; kind: 'tree' | 'cross' };\n\n/**\n * Lay a space out as a tree over its hierarchy.\n *\n * Roots are root-type nodes with no hierarchy parent. Traversal is depth-first in space order,\n * so a node's primary occurrence is under the parent reached first. Under its other parents a\n * node is either repeated without its subtree (`repeat`), or left out and linked by a cross-edge\n * (`cross-edge`). Either way traversal stops there, which also keeps cycles from recursing.\n */\nexport function buildTree(graph: SpaceGraph, regionId: string, dag: DagMode = 'repeat'): Tree {\n const { hierarchy } = graph;\n const levelTypes = new Set(hierarchy?.levels.map((level) => level.type));\n const rootType = hierarchy?.levels[0]?.type;\n const primary = new Map<string, string>();\n // Parent occurrence → child title, resolved to the child's primary occurrence afterwards.\n const pendingCross: { from: string; child: string }[] = [];\n\n const hierarchyParents = (title: SpaceNode['id']) =>\n parentEdges(graph, title).filter((edge) => isHierarchyEdge(edge, hierarchy));\n\n const visit = (node: SpaceNode, path: readonly string[]): TreeOccurrence => {\n const nodePath = [...path, node.id];\n const key = occurrenceKey(regionId, nodePath);\n primary.set(node.id, key);\n // A child can reference the same parent through more than one field; it occurs once.\n const childTitles = new Set(\n childEdges(graph, node.id)\n .filter((edge) => isHierarchyEdge(edge, hierarchy))\n .map((edge) => edge.child),\n );\n const children: TreeOccurrence[] = [];\n for (const title of childTitles) {\n const child = graph.nodes.get(title)!;\n const repeatOf = primary.get(title);\n if (repeatOf === undefined) children.push(visit(child, nodePath));\n else if (dag === 'repeat')\n children.push({ key: occurrenceKey(regionId, [...nodePath, title]), node: child, children: [], repeatOf });\n else pendingCross.push({ from: key, child: title });\n }\n return { key, node, children };\n };\n\n const levelNodes = [...graph.nodes.values()].filter((node) => levelTypes.has(node.resolvedType));\n const unparented = levelNodes.filter((node) => hierarchyParents(node.id).length === 0);\n const roots = unparented.filter((node) => node.resolvedType === rootType).map((node) => visit(node, []));\n const orphans = unparented.filter((node) => node.resolvedType !== rootType).map((node) => visit(node, []));\n // Nodes only reachable through a cycle have a parent but no path from a root. Rather than\n // drop them, enter each such cycle at its first node in space order.\n for (const node of levelNodes) {\n if (!primary.has(node.id)) orphans.push(visit(node, []));\n }\n\n const crossLinks = pendingCross.map(({ from, child }) => ({ from, to: primary.get(child)!, kind: 'cross' as const }));\n return { roots, orphans, primary, crossLinks };\n}\n\n/** Parent → child pairs of occurrence keys: one per rendered parent-child link, then cross-links. */\nexport function treeLinks(tree: Tree): TreeLink[] {\n const links: TreeLink[] = [];\n const walk = (occurrence: TreeOccurrence) => {\n for (const child of occurrence.children) {\n links.push({ from: occurrence.key, to: child.key, kind: 'tree' });\n walk(child);\n }\n };\n for (const root of [...tree.roots, ...tree.orphans]) walk(root);\n return [...links, ...tree.crossLinks];\n}\n","import type { SpaceGraph, SpaceNode } from 'structured-context/api';\nimport type { GroupLevel, LandscapeLayoutConfig } from './definition';\nimport { childEdges, parentEdges } from './graph';\nimport { occurrenceKey, type PathSegment } from './occurrence';\n\n/** One rendered container or node in a landscape. */\nexport type LandscapeOccurrence = {\n /** Path-based key, unique within the map view (see {@link occurrenceKey}). */\n key: string;\n /** Index of the grouping level this occurrence belongs to. */\n level: number;\n /** A node, or a field value shared by the nodes inside (`null`: the field is empty). */\n item: { kind: 'node'; node: SpaceNode } | { kind: 'value'; field: string; value: string | null };\n /** Nodes on the `via` chain that joined this node to the node level above, one entry per skipped type. */\n via: ViaStep[];\n /** Key of the node's first occurrence when this is a repeat. Repeats are rendered in full. */\n repeatOf?: string;\n children: LandscapeOccurrence[];\n};\n\nexport type ViaStep = { type: string; nodes: SpaceNode[] };\n\nexport type Landscape = {\n groups: LandscapeOccurrence[];\n /**\n * Nodes of a grouped level that no container above reaches (e.g. an Activity with no\n * Outcome when grouping by Outcomes), each with its own contents.\n */\n ungrouped: LandscapeOccurrence[];\n};\n\ntype Candidate = { node: SpaceNode; via: ViaStep[] };\ntype FieldFilter = { field: string; value: string | null };\n\n/**\n * Lay a space out as nested containers following the layout's grouping levels.\n *\n * Adjacent node levels are joined by any edge between their types, in either direction, or only\n * edges from `edge.field`. A `via` chain joins them through the skipped types. A field level\n * splits the next node level by that field's values. A node reached from several containers\n * appears in each, in full: the levels are finite, so repeating contents can't recurse.\n */\nexport function buildLandscape(graph: SpaceGraph, regionId: string, layout: LandscapeLayoutConfig): Landscape {\n const levels = layout.group;\n const order = new Map([...graph.nodes.keys()].map((title, i) => [title, i]));\n const first = new Map<string, string>();\n\n const occurrenceFor = (candidate: Candidate, levelIdx: number, path: readonly PathSegment[]): LandscapeOccurrence => {\n const { node } = candidate;\n const nodePath = [...path, node.id];\n const key = occurrenceKey(regionId, nodePath);\n const repeatOf = first.get(node.id);\n if (repeatOf === undefined) first.set(node.id, key);\n return {\n key,\n level: levelIdx,\n item: { kind: 'node', node },\n via: candidate.via,\n ...(repeatOf !== undefined && { repeatOf }),\n children: place(levelIdx + 1, node, [], nodePath),\n };\n };\n\n /** Occurrences for level `levelIdx` inside `anchor`, the nearest enclosing node. */\n const place = (\n levelIdx: number,\n anchor: SpaceNode | undefined,\n filters: readonly FieldFilter[],\n path: readonly PathSegment[],\n ): LandscapeOccurrence[] => {\n const level = levels[levelIdx];\n if (level === undefined) return [];\n if (isTypeLevel(level)) {\n return candidates(level, anchor, filters).map((c) => occurrenceFor(c, levelIdx, path));\n }\n\n const nodeLevel = levels.slice(levelIdx).find(isTypeLevel)!;\n const values = distinctValues(\n candidates(nodeLevel, anchor, filters).map((c) => c.node),\n level.field,\n );\n return values.map((value) => {\n const valuePath = [...path, [level.field, value] as const];\n return {\n key: occurrenceKey(regionId, valuePath),\n level: levelIdx,\n item: { kind: 'value', field: level.field, value },\n via: [],\n children: place(levelIdx + 1, anchor, [...filters, { field: level.field, value }], valuePath),\n };\n });\n };\n\n /** Nodes of a type level joined to `anchor` (all of the type at the top) and matching the filters. */\n const candidates = (\n level: TypeLevel,\n anchor: SpaceNode | undefined,\n filters: readonly FieldFilter[],\n ): Candidate[] => {\n const reached: Candidate[] =\n anchor === undefined\n ? ofType(level.type).map((node) => ({ node, via: [] }))\n : walkChain(anchor, level.via ?? [], level.type, level.edge?.field);\n return reached.filter(({ node }) => filters.every((f) => hasValue(node, f)));\n };\n\n const ofType = (type: string) => [...graph.nodes.values()].filter((node) => node.resolvedType === type);\n\n /** Neighbours of a node with the given type, across edges in either direction, in space order. */\n const neighbours = (title: SpaceNode['id'], type: string, field: string | undefined): SpaceNode[] => {\n const titles = new Set([\n ...childEdges(graph, title)\n .filter((e) => field === undefined || e.field === field)\n .map((e) => e.child),\n ...parentEdges(graph, title)\n .filter((e) => field === undefined || e.field === field)\n .map((e) => e.parent),\n ]);\n return [...titles]\n .map((t) => graph.nodes.get(t)!)\n .filter((node) => node.resolvedType === type)\n .sort((a, b) => order.get(a.id)! - order.get(b.id)!);\n };\n\n /**\n * Follow edges from `anchor` through each `via` type to `target`, keeping the skipped nodes on\n * the way to each target node. Several chains to one target merge into one candidate.\n */\n const walkChain = (anchor: SpaceNode, via: readonly string[], target: string, field: string | undefined) => {\n let frontier = [{ node: anchor, trail: [] as SpaceNode[] }];\n for (const type of via) {\n frontier = frontier.flatMap(({ node, trail }) =>\n neighbours(node.id, type, undefined).map((next) => ({ node: next, trail: [...trail, next] })),\n );\n }\n const byTitle = new Map<string, Candidate>();\n for (const { node, trail } of frontier) {\n for (const next of neighbours(node.id, target, field)) {\n const candidate = byTitle.get(next.id) ?? { node: next, via: via.map((type) => ({ type, nodes: [] })) };\n trail.forEach((skipped, i) => {\n const step = candidate.via[i]!;\n if (!step.nodes.includes(skipped)) step.nodes.push(skipped);\n });\n byTitle.set(next.id, candidate);\n }\n }\n return [...byTitle.values()].sort((a, b) => order.get(a.node.id)! - order.get(b.node.id)!);\n };\n\n const groups = place(0, undefined, [], []);\n\n // Nodes of an inner level that no container reached get their own contents, like tree orphans.\n const ungrouped: LandscapeOccurrence[] = [];\n levels.forEach((level, levelIdx) => {\n if (levelIdx === 0 || !isTypeLevel(level)) return;\n for (const node of ofType(level.type)) {\n if (!first.has(node.id)) ungrouped.push(occurrenceFor({ node, via: [] }, levelIdx, [null]));\n }\n });\n\n return { groups, ungrouped };\n}\n\ntype TypeLevel = Extract<GroupLevel, { type: string }>;\n\nfunction isTypeLevel(level: GroupLevel): level is TypeLevel {\n return 'type' in level;\n}\n\n/** A field's values as group labels: strings, an entry per array item, `null` when empty. */\nfunction valuesOf(node: SpaceNode, field: string): (string | null)[] {\n const raw = node.schemaData[field];\n const list = (Array.isArray(raw) ? raw : [raw]).filter((v) => v !== undefined && v !== null && v !== '');\n return list.length === 0 ? [null] : list.map((v) => (typeof v === 'object' ? JSON.stringify(v) : String(v)));\n}\n\n/** Distinct values in first-seen order, with the empty group last. */\nfunction distinctValues(nodes: SpaceNode[], field: string): (string | null)[] {\n const values = new Set(nodes.flatMap((node) => valuesOf(node, field)));\n const present = [...values].filter((v): v is string => v !== null);\n return values.has(null) ? [...present, null] : present;\n}\n\nfunction hasValue(node: SpaceNode, { field, value }: FieldFilter): boolean {\n return valuesOf(node, field).includes(value);\n}\n","import type { SpaceGraph, SpaceNode } from 'structured-context/api';\nimport type { AxisConfig, XYLayoutConfig } from './definition';\nimport { edgesWithin, isHierarchyEdge } from './graph';\nimport { occurrenceKey } from './occurrence';\n\n/** A plotted node. `x` and `y` run from 0 to 1 across the plot, left to right and bottom to top. */\nexport type XYPoint = { key: string; node: SpaceNode; x: number; y: number };\n\n/** Why a node of a plotted type couldn't be placed, per axis. */\nexport type Unplaced = { key: string; node: SpaceNode; reasons: string[] };\n\n/**\n * An edge between plotted nodes. `lane` separates edges joining the same two nodes: 0 when\n * there's one, otherwise centred around 0 (e.g. -0.5 and 0.5), for layouts to draw side by side.\n */\nexport type XYLink = { from: string; to: string; field: string; hierarchy: boolean; lane: number };\n\nexport type XYPlot = {\n points: XYPoint[];\n unplaced: Unplaced[];\n /** Edges between plotted nodes. */\n links: XYLink[];\n /** Each axis's [min, max]; `direction` says which end is drawn where. */\n domains: { x: readonly [number, number]; y: readonly [number, number] };\n};\n\n/**\n * Position nodes by two numeric fields. Every node of a plotted type appears once: on the plot\n * when both its values are numbers inside the axes' domains, otherwise in `unplaced` with the\n * reason. Positions are normalised; layouts decide the plot's size.\n */\nexport function buildXYPlot(graph: SpaceGraph, regionId: string, layout: XYLayoutConfig): XYPlot {\n const { x, y } = layout;\n const nodes = [...graph.nodes.values()];\n const types = new Set(\n layout.types.length > 0\n ? layout.types\n : nodes\n .filter((n) => isNumber(n.schemaData[x.field]) || isNumber(n.schemaData[y.field]))\n .map((n) => n.resolvedType),\n );\n const plotted = nodes.filter((n) => types.has(n.resolvedType));\n\n const domains = {\n x: domainOf(x, plotted),\n y: domainOf(y, plotted),\n };\n\n const points: XYPoint[] = [];\n const unplaced: Unplaced[] = [];\n for (const node of plotted) {\n const key = occurrenceKey(regionId, [node.id]);\n const px = position(node, x, domains.x);\n const py = position(node, y, domains.y);\n if (typeof px === 'number' && typeof py === 'number') points.push({ key, node, x: px, y: py });\n else unplaced.push({ key, node, reasons: [px, py].filter((r): r is string => typeof r === 'string') });\n }\n\n const keys = new Map<string, string>(points.map((p) => [p.node.id, p.key]));\n const fields = new Set(layout.edgeFields);\n const links = edgesWithin(graph)\n .filter((e) => keys.has(e.parent) && keys.has(e.child) && (fields.size === 0 || fields.has(e.field)))\n .map((e) => ({\n from: keys.get(e.parent)!,\n to: keys.get(e.child)!,\n field: e.field,\n hierarchy: isHierarchyEdge(e, graph.hierarchy),\n lane: 0,\n }));\n assignLanes(links);\n\n return { points, unplaced, links, domains };\n}\n\nfunction isNumber(value: unknown): value is number {\n return typeof value === 'number' && Number.isFinite(value);\n}\n\n/** The axis's fixed domain, or the range of plotted values (widened when they're all equal). */\nfunction domainOf(axis: AxisConfig, nodes: readonly SpaceNode[]): readonly [number, number] {\n if (Array.isArray(axis.domain)) return [axis.domain[0]!, axis.domain[1]!];\n const values = nodes.map((n) => n.schemaData[axis.field]).filter(isNumber);\n if (values.length === 0) return [0, 1];\n const min = Math.min(...values);\n const max = Math.max(...values);\n return min === max ? [min - 1, max + 1] : [min, max];\n}\n\n/** The node's normalised position on the axis, or why it has none. */\nfunction position(node: SpaceNode, axis: AxisConfig, [min, max]: readonly [number, number]): number | string {\n const value = node.schemaData[axis.field];\n if (value === undefined || value === null) return `no ${axis.field}`;\n if (!isNumber(value)) return `${axis.field} is not a number`;\n if (value < min || value > max) return `${axis.field} ${value} is outside ${min}–${max}`;\n const t = (value - min) / (max - min);\n return axis.direction === 'descending' ? 1 - t : t;\n}\n\n/** Spread links joining the same pair of nodes (in either direction) into lanes around 0. */\nfunction assignLanes(links: XYLink[]) {\n const byPair = new Map<string, XYLink[]>();\n for (const link of links) {\n const pair = [link.from, link.to].sort().join('\\n');\n byPair.set(pair, [...(byPair.get(pair) ?? []), link]);\n }\n for (const group of byPair.values()) {\n group.forEach((link, i) => {\n link.lane = i - (group.length - 1) / 2;\n });\n }\n}\n"],"mappings":";;;;;;AAkDA,SAAgB,gBACd,OACA,OACsE;CACtE,MAAM,8BAAc,IAAI,IAA8B;CACtD,MAAM,aAAqC,CAAC;CAE5C,KAAK,MAAM,CAAC,IAAI,WAAW,OAAO,QAAQ,MAAM,MAAM,GAAG;EACvD,MAAM,SAAS;EACf,KAAK,MAAM,CAAC,KAAK,EAAE,MAAM,SAAS,UAAU,MAAM,aAAa,OAAO,QAAQ,MAAM,GAAG;GACrF,MAAM,aAA6B;IACjC;IACA,QAAQ;IACR;IACA,GAAI,SAAS,UAAU,IAAI,WAAW,OAAO,KAAK,EAAE,QAAQ,IAAI,MAAM,CAAc,EAAE;GACxF;GACA,IAAI,MAAM,MAAM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structured-context/api';
1
+ import type { nodeIssues, RuleSeverity, SpaceGraph, SpaceNode, ValidationResult } from 'structured-context/api';
2
+ import type { ValidationIssueKind } from 'structured-context/types';
2
3
  type NodeId = SpaceNode['id'];
3
- /** How serious a result is: structured-context's rule severity. Schema and hierarchy failures are errors. */
4
+ /** How serious a result is: structured-context's rule severity, which every result carries. */
4
5
  export type Severity = RuleSeverity;
5
- /** The kind of check a result came from. */
6
- export type AnnotationSource = 'schema' | 'hierarchy' | 'rule';
6
+ /** The kind of check a result came from: structured-context's issue `kind`. */
7
+ export type AnnotationSource = ValidationIssueKind;
7
8
  /** One validation result attached to a node. */
8
9
  export type NodeAnnotation = {
9
10
  severity: Severity;
@@ -16,18 +17,21 @@ export type NodeAnnotation = {
16
17
  export type UnattachedAnnotation = NodeAnnotation & {
17
18
  /** The node it concerns. Absent for a global-scope rule. A node that failed its schema isn't in the graph. */
18
19
  nodeId?: NodeId;
19
- /** Where that node is defined, if known. */
20
- location?: SourceLocation;
20
+ /** Where in that node's file the result points, if known (1-indexed). */
21
+ line?: number;
22
+ column?: number;
21
23
  };
22
24
  /** Annotations by the id of the node they apply to. */
23
25
  export type AnnotationIndex = ReadonlyMap<NodeId, readonly NodeAnnotation[]>;
24
26
  /**
25
- * The parts of structured-context's `ValidationResult` that attach to a node. Every part is optional:
26
- * a host that only runs some checks (the Obsidian plugin runs no AI-judged rules, say) passes what it has.
27
+ * Validation results to attach: each node's issues, from structured-context's `nodeIssues(result)` or the
28
+ * `issues` of `sctx validate --json`, and the rule violations, of which only those without a node are read
29
+ * (the others are in `issues`). `sctx validate --json` output can be passed as it is.
27
30
  */
28
- export type ValidationInput = Partial<Pick<ValidationResult, 'ruleViolations' | 'hierarchyViolations'> & {
29
- nodeErrors: ReadonlyArray<Pick<ValidationResult['nodeErrors'][number], 'nodeId' | 'source' | 'issues'>>;
30
- }>;
31
+ export type ValidationInput = {
32
+ issues: Readonly<ReturnType<typeof nodeIssues>>;
33
+ ruleViolations?: ReadonlyArray<Pick<ValidationResult['ruleViolations'][number], 'nodeId' | 'ruleId' | 'severity' | 'description'>>;
34
+ };
31
35
  /**
32
36
  * Attach validation results to the nodes of `graph`, by node id. Results that can't be attached are
33
37
  * returned in `unattached` for the host to surface: global-scope rules (no node), and nodes that
@@ -149,7 +149,7 @@ export declare const definitionSchema: {
149
149
  };
150
150
  readonly validationSources: {
151
151
  readonly description: string;
152
- readonly default: readonly ["schema", "hierarchy", "rule"];
152
+ readonly default: readonly ["schema", "duplicate", "broken-link", "hierarchy", "rule", "gated", "content-link"];
153
153
  readonly anyOf: readonly [{
154
154
  readonly $ref: "https://raw.githubusercontent.com/mindsocket/structured-context-map-views/main/schemas/generated/latest/settings.json#/$defs/validationSources";
155
155
  }, {
@@ -150,7 +150,7 @@ export declare const MAP_VIEW_SCHEMAS: readonly [{
150
150
  };
151
151
  readonly validationSources: {
152
152
  readonly description: string;
153
- readonly default: readonly ["schema", "hierarchy", "rule"];
153
+ readonly default: readonly ["schema", "duplicate", "broken-link", "hierarchy", "rule", "gated", "content-link"];
154
154
  readonly anyOf: readonly [{
155
155
  readonly $ref: "https://raw.githubusercontent.com/mindsocket/structured-context-map-views/main/schemas/generated/latest/settings.json#/$defs/validationSources";
156
156
  }, {
@@ -200,10 +200,10 @@ export declare const MAP_VIEW_SCHEMAS: readonly [{
200
200
  };
201
201
  readonly validationSources: {
202
202
  readonly title: 'Validation sources';
203
- readonly description: 'Which kinds of validation result are shown. schema: a node failing its schema. hierarchy: a node under a parent type it is not allowed under. rule: a schema rule violation.';
203
+ readonly description: 'Which kinds of validation result are shown. schema: a node failing its schema. duplicate: an id more than one node uses. broken-link: a relationship to a node that does not exist. hierarchy: a node under a parent type it is not allowed under. rule: a schema rule violation. gated: a note that rules were not checked because an ancestor failed. content-link: a link in the body that resolves to no node.';
204
204
  readonly type: 'array';
205
205
  readonly items: {
206
- readonly enum: readonly ['schema', 'hierarchy', 'rule'];
206
+ readonly enum: readonly ["schema", "duplicate", "broken-link", "hierarchy", "rule", "gated", "content-link"];
207
207
  };
208
208
  readonly uniqueItems: true;
209
209
  };
@@ -21,10 +21,10 @@ export declare const settingsSchema: {
21
21
  };
22
22
  readonly validationSources: {
23
23
  readonly title: 'Validation sources';
24
- readonly description: 'Which kinds of validation result are shown. schema: a node failing its schema. hierarchy: a node under a parent type it is not allowed under. rule: a schema rule violation.';
24
+ readonly description: 'Which kinds of validation result are shown. schema: a node failing its schema. duplicate: an id more than one node uses. broken-link: a relationship to a node that does not exist. hierarchy: a node under a parent type it is not allowed under. rule: a schema rule violation. gated: a note that rules were not checked because an ancestor failed. content-link: a link in the body that resolves to no node.';
25
25
  readonly type: 'array';
26
26
  readonly items: {
27
- readonly enum: readonly ['schema', 'hierarchy', 'rule'];
27
+ readonly enum: readonly ["schema", "duplicate", "broken-link", "hierarchy", "rule", "gated", "content-link"];
28
28
  };
29
29
  readonly uniqueItems: true;
30
30
  };
@@ -1,4 +1,5 @@
1
1
  import { type Config, exportSpaceGraph, validateSpace } from 'structured-context/api';
2
+ import type { ValidationInput } from '../core/annotations';
2
3
  import { type MapViewDefinition } from '../core/definition';
3
4
  /**
4
5
  * Everything a host without filesystem access needs to render a space: its graph, the validation
@@ -8,7 +9,8 @@ export type SpaceSnapshot = {
8
9
  space: string;
9
10
  schemaId: string | undefined;
10
11
  graph: ReturnType<typeof exportSpaceGraph>;
11
- validation: Awaited<ReturnType<typeof validateSpace>>;
12
+ /** What `annotationsFrom` attaches: each node's issues and the rule violations */
13
+ validation: ValidationInput;
12
14
  definitions: MapViewDefinition[];
13
15
  };
14
16
  /** The `validateSpace` options `export` passes through unchanged. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "structured-context-map-views",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Declarative map views of structured-context spaces: render a space as a tree, nested containers or an XY plot from a short definition.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -52,7 +52,7 @@
52
52
  "peerDependencies": {
53
53
  "react": "^19.3.0",
54
54
  "react-dom": "^19.3.0",
55
- "structured-context": "^0.21.0"
55
+ "structured-context": "^0.22.1"
56
56
  },
57
57
  "dependencies": {
58
58
  "ajv": "^8.20.0",
@@ -68,7 +68,7 @@
68
68
  "@vitejs/plugin-react": "^6.1.1",
69
69
  "react": "^19.3.0",
70
70
  "react-dom": "^19.3.0",
71
- "structured-context": "^0.21.0",
71
+ "structured-context": "^0.22.1",
72
72
  "tailwindcss": "^4.3.3",
73
73
  "vite": "^8.3.2"
74
74
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"definition-Cft28YUA.js","names":[],"sources":["../src/core/format/schema-url.ts","../src/core/format/param-ref.ts","../src/core/format/definition-schema.ts","../src/core/format/landscape-layout.ts","../src/core/format/settings.ts","../src/core/format/tree-layout.ts","../src/core/format/xy-layout.ts","../src/core/format/index.ts","../src/core/definition.ts"],"sourcesContent":["/**\n * Where the format schemas are published. `latest` follows the newest format; a release that changes it\n * freezes a copy under its own version folder (`bun run generate:schemas --release`).\n */\nexport const SCHEMA_BASE_URL =\n 'https://raw.githubusercontent.com/mindsocket/structured-context-map-views/main/schemas/generated';\n\n/** Base of the `$id`s the sources use: the `latest` folder. */\nexport const SCHEMA_URL = `${SCHEMA_BASE_URL}/latest` as const;\n","import { SCHEMA_URL } from './schema-url';\n/** `$ref` target for a setting whose value comes from a declared parameter. */\nexport const PARAM_REF = `${SCHEMA_URL}/definition.json#/$defs/paramRef` as const;\n\n/** A setting that takes either a fixed value matching `valueSchema` or a `{ $param }` binding. */\nexport function parameterisable<const S extends object, const D>(valueSchema: S, defaultValue: D, description: string) {\n return { description, default: defaultValue, anyOf: [valueSchema, { $ref: PARAM_REF }] } as const;\n}\n","import { PARAM_REF, parameterisable } from './param-ref';\nimport { SCHEMA_URL } from './schema-url';\n\n/**\n * The map view definition format: shared parameters, and the regions a map view is composed of.\n *\n * Written as TypeScript so the definition types derive from it (`FromSchema`); the JSON files\n * for `$schema` references and editors are generated (`bun run generate:schemas`).\n */\nexport const definitionSchema = {\n $schema: 'https://json-schema.org/draft/2020-12/schema',\n $id: `${SCHEMA_URL}/definition.json`,\n title: 'Map view definition',\n description:\n 'Declares how spaces of one schema are projected into a map view: shared parameters, and the regions the map view is composed of.',\n type: 'object',\n required: ['$id', 'schema', 'regions'],\n additionalProperties: false,\n properties: {\n $schema: { type: 'string' },\n $id: {\n type: 'string',\n pattern: '^sctx-map-view://[^/]+(/[^/]+)?$',\n description:\n 'Identifier, namespaced by where the definition is found: \"sctx-map-view://core/<name>\" (bundled), \"sctx-map-view://<plugin>/<name>\" (a plugin) or \"sctx-map-view://<name>\" (the config folder).',\n },\n title: { type: 'string', minLength: 1, description: 'Display name. Defaults to the last segment of the `$id`.' },\n description: { type: 'string' },\n schema: {\n type: 'string',\n minLength: 1,\n description: '`$id` of the structured-context schema whose spaces this map view applies to.',\n },\n parameters: {\n type: 'object',\n description:\n 'Settings the reader can change. Each is a JSON Schema with a default, bound to settings anywhere in the definition with { \"$param\": \"<name>\" }.',\n additionalProperties: { $ref: '#/$defs/parameter' },\n },\n regions: {\n type: 'array',\n minItems: 1,\n description:\n 'Parts of the map view, each with its own layout, nodes and edges. Only the first region is rendered for now.',\n items: { $ref: '#/$defs/region' },\n },\n },\n $defs: {\n parameter: {\n type: 'object',\n description:\n \"A JSON Schema for the parameter's values (it can $ref, narrow or extend the bundled setting definitions), plus a title for its control.\",\n required: ['default'],\n properties: {\n title: { type: 'string' },\n description: { type: 'string' },\n default: {},\n },\n },\n paramRef: {\n type: 'object',\n description: \"Takes this setting's value from a declared parameter.\",\n required: ['$param'],\n additionalProperties: false,\n properties: { $param: { type: 'string', minLength: 1 } },\n },\n region: {\n type: 'object',\n required: ['id', 'layout'],\n additionalProperties: false,\n properties: {\n id: {\n type: 'string',\n minLength: 1,\n description: 'Unique within the map view; part of every occurrence id in the region.',\n },\n select: {\n type: 'object',\n description: 'Which nodes of the space the region shows. By default, all of them.',\n additionalProperties: false,\n properties: {\n filter: {\n type: 'string',\n minLength: 1,\n description:\n \"A structured-context filter: a view name from the space's config, or an expression such as `WHERE …` or `SELECT … WHERE …`.\",\n },\n },\n },\n layout: {\n description: 'How the region is arranged, chosen by `type`.',\n type: 'object',\n required: ['type'],\n // Ajv validates only the branch `type` selects, so errors name that layout's settings.\n discriminator: { propertyName: 'type' },\n oneOf: [\n { $ref: `${SCHEMA_URL}/layouts/tree.json` },\n { $ref: `${SCHEMA_URL}/layouts/landscape.json` },\n { $ref: `${SCHEMA_URL}/layouts/xy.json` },\n ],\n },\n nodes: {\n type: 'object',\n additionalProperties: false,\n default: {},\n properties: {\n style: parameterisable(\n { $ref: `${SCHEMA_URL}/settings.json#/$defs/nodeStyle` },\n 'card',\n 'How nodes are drawn.',\n ),\n fields: parameterisable(\n { $ref: `${SCHEMA_URL}/settings.json#/$defs/fieldList` },\n [],\n 'Schema fields shown on cards.',\n ),\n validation: parameterisable(\n { $ref: `${SCHEMA_URL}/settings.json#/$defs/validationLevel` },\n 'off',\n 'The lowest severity of validation result shown on nodes, or off. Needs the host to supply results.',\n ),\n validationSources: parameterisable(\n { $ref: `${SCHEMA_URL}/settings.json#/$defs/validationSources` },\n ['schema', 'hierarchy', 'rule'],\n 'Which kinds of validation result are shown.',\n ),\n },\n },\n edges: {\n type: 'object',\n additionalProperties: false,\n default: {},\n properties: {\n show: parameterisable({ type: 'boolean' }, true, 'Whether connectors are drawn.'),\n },\n },\n },\n },\n },\n} as const;\n\nexport { PARAM_REF };\n","import { PARAM_REF, parameterisable } from './param-ref';\nimport { SCHEMA_URL } from './schema-url';\n\n/** Settings of the landscape layout: nested containers following an authored grouping. */\nexport const landscapeLayoutSchema = {\n $schema: 'https://json-schema.org/draft/2020-12/schema',\n $id: `${SCHEMA_URL}/layouts/landscape.json`,\n title: 'Landscape layout',\n description:\n 'Nested containers: each grouping level becomes containers inside the level above, and the last level is drawn as nodes.',\n type: 'object',\n required: ['type', 'group'],\n additionalProperties: false,\n properties: {\n type: { const: 'landscape' },\n orientation: parameterisable(\n { $ref: `${SCHEMA_URL}/settings.json#/$defs/orientation` },\n 'horizontal',\n 'horizontal: top-level containers side by side, as columns. vertical: stacked, as rows.',\n ),\n group: {\n type: 'array',\n minItems: 1,\n description:\n 'Grouping levels, outermost first. The last level is drawn as nodes; the others as containers. Adjacent node levels are joined by any edge between their types, in either direction.',\n // Dispatch on `field`, so errors come from the kind of level written, not both.\n items: {\n type: 'object',\n if: { type: 'object', required: ['field'] },\n // biome-ignore lint/suspicious/noThenProperty: JSON Schema's `then` keyword.\n then: {\n type: 'object',\n description:\n \"Containers labelled by the values of a field of the next node level's nodes. A node with several values appears under each.\",\n required: ['field'],\n additionalProperties: false,\n properties: { field: { type: 'string', minLength: 1 } },\n },\n else: {\n type: 'object',\n description: 'A level of nodes of one type.',\n required: ['type'],\n additionalProperties: false,\n properties: {\n type: {\n description: 'Node type at this level.',\n anyOf: [{ type: 'string', minLength: 1 }, { $ref: PARAM_REF }],\n },\n edge: {\n type: 'object',\n description:\n 'Which edges join this level to the node level above (or to the last `via` type). By default, any edge between the two types.',\n required: ['field'],\n additionalProperties: false,\n properties: { field: { type: 'string', minLength: 1 } },\n },\n via: {\n type: 'array',\n minItems: 1,\n description:\n 'Types skipped between the node level above and this one, in order. Nodes are joined through a chain of edges across them. Ignored on the first level, which has no level above.',\n items: { type: 'string', minLength: 1 },\n },\n intermediate: parameterisable(\n { $ref: `${SCHEMA_URL}/layouts/landscape.json#/$defs/intermediate` },\n 'hidden',\n 'How the skipped nodes of a `via` chain are shown.',\n ),\n },\n },\n },\n },\n },\n $defs: {\n intermediate: {\n title: 'Skipped levels',\n description: 'hidden: not shown. breadcrumb: listed on each node reached through them.',\n enum: ['hidden', 'breadcrumb'],\n },\n },\n} as const;\n","import { SCHEMA_URL } from './schema-url';\n/** Reusable setting definitions. Parameters can `$ref` these and narrow them, e.g. with `allOf` and `enum`. */\nexport const settingsSchema = {\n $schema: 'https://json-schema.org/draft/2020-12/schema',\n $id: `${SCHEMA_URL}/settings.json`,\n title: 'Shared map view settings',\n description: 'Reusable setting definitions. Parameters can $ref these and narrow them, e.g. with allOf and enum.',\n $defs: {\n orientation: {\n title: 'Orientation',\n enum: ['vertical', 'horizontal'],\n },\n nodeStyle: {\n title: 'Node style',\n description: 'card: a box with the title and selected fields. shape: a compact marker with a tooltip.',\n enum: ['card', 'shape'],\n },\n validationLevel: {\n title: 'Validation overlay',\n description:\n 'The lowest severity of validation result shown on nodes, or off. error: only errors. warning: errors and warnings. info: everything.',\n enum: ['off', 'error', 'warning', 'info'],\n },\n validationSources: {\n title: 'Validation sources',\n description:\n 'Which kinds of validation result are shown. schema: a node failing its schema. hierarchy: a node under a parent type it is not allowed under. rule: a schema rule violation.',\n type: 'array',\n items: { enum: ['schema', 'hierarchy', 'rule'] },\n uniqueItems: true,\n },\n fieldList: {\n title: 'Fields',\n type: 'array',\n items: { type: 'string', minLength: 1 },\n uniqueItems: true,\n },\n },\n} as const;\n","import { parameterisable } from './param-ref';\nimport { SCHEMA_URL } from './schema-url';\n\n/** Settings of the tree layout: a tree over the schema's hierarchy. */\nexport const treeLayoutSchema = {\n $schema: 'https://json-schema.org/draft/2020-12/schema',\n $id: `${SCHEMA_URL}/layouts/tree.json`,\n title: 'Tree layout',\n description: \"A tree over the schema's hierarchy: root-type nodes at the top, children via hierarchy edges.\",\n type: 'object',\n required: ['type'],\n additionalProperties: false,\n properties: {\n type: { const: 'tree' },\n orientation: parameterisable(\n { $ref: `${SCHEMA_URL}/settings.json#/$defs/orientation` },\n 'vertical',\n 'Direction the tree grows.',\n ),\n dag: parameterisable(\n { $ref: `${SCHEMA_URL}/layouts/tree.json#/$defs/dag` },\n 'repeat',\n 'How a node with several parents is shown.',\n ),\n },\n $defs: {\n dag: {\n title: 'Nodes with several parents',\n description:\n 'repeat: the node appears under each parent, its subtree shown once. cross-edge: the node appears under its first parent, with extra connectors from the others.',\n enum: ['repeat', 'cross-edge'],\n },\n },\n} as const;\n","import { PARAM_REF, parameterisable } from './param-ref';\nimport { SCHEMA_URL } from './schema-url';\n\n/** Settings of the XY layout: nodes positioned by two numeric fields. */\nexport const xyLayoutSchema = {\n $schema: 'https://json-schema.org/draft/2020-12/schema',\n $id: `${SCHEMA_URL}/layouts/xy.json`,\n title: 'XY layout',\n description:\n 'Nodes positioned on two axes by numeric fields. Nodes of the plotted types without a usable value on both axes are listed beside the plot, not dropped.',\n type: 'object',\n required: ['type', 'x', 'y'],\n additionalProperties: false,\n properties: {\n type: { const: 'xy' },\n x: { $ref: `${SCHEMA_URL}/layouts/xy.json#/$defs/axis` },\n y: { $ref: `${SCHEMA_URL}/layouts/xy.json#/$defs/axis` },\n types: parameterisable(\n { type: 'array', items: { type: 'string', minLength: 1 }, uniqueItems: true },\n [],\n 'Node types to plot. Empty: every type with a value on either axis.',\n ),\n edgeFields: parameterisable(\n { $ref: `${SCHEMA_URL}/settings.json#/$defs/fieldList` },\n [],\n 'Fields whose edges are drawn between plotted nodes. Empty: all edges.',\n ),\n },\n $defs: {\n axis: {\n title: 'Axis',\n type: 'object',\n required: ['field'],\n additionalProperties: false,\n properties: {\n field: {\n description: 'Numeric field giving the position.',\n anyOf: [{ type: 'string', minLength: 1 }, { $ref: PARAM_REF }],\n },\n domain: {\n description:\n 'Values at the two ends of the axis: [min, max], or \"data\" for the smallest and largest plotted values. Nodes outside a fixed domain are listed as unplaced.',\n default: 'data',\n anyOf: [{ const: 'data' }, { type: 'array', items: { type: 'number' }, minItems: 2, maxItems: 2 }],\n },\n direction: parameterisable(\n { $ref: `${SCHEMA_URL}/layouts/xy.json#/$defs/direction` },\n 'ascending',\n 'ascending: values grow rightwards (x) or upwards (y). descending: the reverse.',\n ),\n label: { type: 'string', description: 'Axis title. Defaults to the field name.' },\n },\n },\n direction: {\n title: 'Axis direction',\n enum: ['ascending', 'descending'],\n },\n },\n} as const;\n","import { definitionSchema } from './definition-schema';\nimport { landscapeLayoutSchema } from './landscape-layout';\nimport { settingsSchema } from './settings';\nimport { treeLayoutSchema } from './tree-layout';\nimport { xyLayoutSchema } from './xy-layout';\n\nexport { PARAM_REF } from './param-ref';\nexport { definitionSchema, landscapeLayoutSchema, settingsSchema, treeLayoutSchema, xyLayoutSchema };\n\n/** The bundled schemas describing the map view definition format. */\nexport const MAP_VIEW_SCHEMAS = [\n definitionSchema,\n settingsSchema,\n treeLayoutSchema,\n landscapeLayoutSchema,\n xyLayoutSchema,\n] as const;\n","import Ajv2020, { type AnySchemaObject, type ErrorObject } from 'ajv/dist/2020';\nimport type { FromSchema } from 'json-schema-to-ts';\nimport JSON5 from 'json5';\nimport {\n definitionSchema,\n type landscapeLayoutSchema,\n MAP_VIEW_SCHEMAS,\n type settingsSchema,\n type treeLayoutSchema,\n type xyLayoutSchema,\n} from './format';\nimport { SCHEMA_URL } from './format/schema-url';\n\nexport { MAP_VIEW_SCHEMAS };\n\ntype References = {\n references: [\n typeof settingsSchema,\n typeof treeLayoutSchema,\n typeof landscapeLayoutSchema,\n typeof xyLayoutSchema,\n typeof definitionSchema,\n ];\n // Grouping levels dispatch with if/then/else (see the landscape layout schema).\n parseIfThenElseKeywords: true;\n};\ntype ParamRef = { $param: string };\n/** Drop `{ $param }` bindings from every setting's type: what remains after resolution. */\ntype Resolved<T> = T extends ParamRef\n ? never\n : T extends readonly (infer U)[]\n ? Resolved<U>[]\n : T extends object\n ? { [K in keyof T]: Resolved<T[K]> }\n : T;\n\n/** A definition as authored: settings may be `{ $param }` bindings, defaulted properties may be absent. */\nexport type AuthoredDefinition = FromSchema<\n typeof definitionSchema,\n References & { keepDefaultedPropertiesOptional: true }\n>;\ntype FilledDefinition = FromSchema<typeof definitionSchema, References>;\n\n/** A region with parameters applied and defaults filled in: what layouts receive. */\nexport type Region = Resolved<FilledDefinition['regions'][number]>;\nexport type LayoutConfig = Region['layout'];\nexport type TreeLayoutConfig = Extract<LayoutConfig, { type: 'tree' }>;\nexport type LandscapeLayoutConfig = Extract<LayoutConfig, { type: 'landscape' }>;\nexport type XYLayoutConfig = Extract<LayoutConfig, { type: 'xy' }>;\nexport type AxisConfig = XYLayoutConfig['x'];\nexport type GroupLevel = LandscapeLayoutConfig['group'][number];\nexport type IntermediateDisplay = Extract<GroupLevel, { type: string }>['intermediate'];\nexport type NodesConfig = Region['nodes'];\nexport type EdgesConfig = Region['edges'];\nexport type Orientation = TreeLayoutConfig['orientation'];\nexport type DagMode = TreeLayoutConfig['dag'];\nexport type NodeStyle = NodesConfig['style'];\n\n/**\n * A validated map view definition. Plain data, so hosts can pass it across a server/browser\n * boundary. Settings in `source` may still be `{ $param }` bindings; {@link resolveRegions}\n * replaces them with parameter values.\n */\nexport type MapViewDefinition = {\n /** The definition's `$id`. */\n id: string;\n title: string;\n description?: string;\n /** `$id` of the schema whose spaces this map view applies to. */\n schema: string;\n parameters: Parameter[];\n /** The definition as authored. */\n source: AuthoredDefinition;\n};\n\n/** A setting the reader can change, with the control generated from its schema. */\nexport type Parameter = {\n name: string;\n title: string;\n description?: string;\n default: unknown;\n control: ParameterControl;\n};\n\n/** Options are JSON primitives, so they can be labelled and compared directly. */\nexport type ParameterControl =\n | { kind: 'select'; options: readonly Primitive[] }\n | { kind: 'multiselect'; options: readonly Primitive[] }\n | { kind: 'toggle' };\n\ntype Primitive = string | number | boolean | null;\n\nexport type ParameterValues = Readonly<Record<string, unknown>>;\n\nexport class MapViewDefinitionError extends Error {\n constructor(name: string, message: string) {\n super(`Map view \"${name}\": ${message}`);\n this.name = 'MapViewDefinitionError';\n }\n}\n\nconst newAjv = (options: { useDefaults?: boolean } = {}) =>\n new Ajv2020({\n allErrors: true,\n discriminator: true,\n ...options,\n schemas: MAP_VIEW_SCHEMAS.map((s) => structuredClone(s) as AnySchemaObject),\n });\n\n/** Validates definitions as authored. */\nconst ajv = newAjv();\nconst validateDefinition = ajv.getSchema(definitionSchema.$id)!;\n/** Validates resolved definitions, filling in setting defaults from the schemas. */\nconst fillDefaults = newAjv({ useDefaults: true }).getSchema(definitionSchema.$id)!;\n\n/**\n * Parse a JSON5 map view definition and check it against the bundled schemas. `name` labels\n * error messages (hosts pass where the definition came from).\n *\n * Beyond schema validation: every parameter needs a control derivable from its schema, and\n * every value that control can produce must satisfy the parameter's schema; every `$param`\n * must name a declared parameter; and each parameter's values must be valid wherever it's\n * bound, checked by substituting them and re-validating.\n */\nexport function parseMapViewDefinition(name: string, text: string): MapViewDefinition {\n const fail = (message: string): never => {\n throw new MapViewDefinitionError(name, message);\n };\n\n let raw: unknown;\n try {\n raw = JSON5.parse(text);\n } catch (err) {\n return fail(`invalid JSON5: ${err instanceof Error ? err.message : String(err)}`);\n }\n if (!validateDefinition(raw)) return fail(formatErrors(validateDefinition.errors, raw));\n const source = raw as AuthoredDefinition;\n\n // A fresh instance per parse, so compiled parameter schemas aren't cached indefinitely.\n const parameterAjv = newAjv();\n const declared = (source.parameters ?? {}) as Record<string, AnySchemaObject>;\n const parameters = Object.entries(declared).map(([paramName, schema]) =>\n parseParameter(paramName, schema, parameterAjv, (message) => fail(`parameter \"${paramName}\": ${message}`)),\n );\n\n for (const bound of paramNames(source.regions)) {\n if (!(bound in declared)) fail(`\"$param\": \"${bound}\" is not a declared parameter`);\n }\n checkBindings(source, parameters, fail);\n\n const regionIds = new Set<string>();\n for (const region of source.regions) {\n if (regionIds.has(region.id)) fail(`duplicate region id \"${region.id}\"`);\n regionIds.add(region.id);\n // A field level labels the nodes of a later level, so a node level must come last.\n if (region.layout.type === 'landscape' && !('type' in region.layout.group.at(-1)!)) {\n fail(`region \"${region.id}\": the last grouping level must be a node type, not a field`);\n }\n if (region.layout.type === 'xy') {\n for (const axis of ['x', 'y'] as const) {\n const { domain } = region.layout[axis];\n if (Array.isArray(domain) && !(domain[0]! < domain[1]!)) {\n fail(`region \"${region.id}\": ${axis} domain must be [min, max] with min < max`);\n }\n }\n }\n }\n\n return {\n id: source.$id,\n title: source.title ?? source.$id.slice(source.$id.lastIndexOf('/') + 1),\n ...(source.description !== undefined && { description: source.description }),\n schema: source.schema,\n parameters,\n source,\n };\n}\n\n/**\n * The value each parameter takes: the given value if its control could produce it, otherwise\n * (missing, or stale saved state) the default. Hosts' controls and rendering both use this.\n */\nexport function resolveParameterValues(definition: MapViewDefinition, values: ParameterValues = {}): ParameterValues {\n return Object.fromEntries(\n definition.parameters.map((param) => {\n const value = values[param.name];\n const chosen = value !== undefined && isProducible(param.control, value) ? value : param.default;\n return [param.name, structuredClone(chosen)];\n }),\n );\n}\n\n/** Apply parameter values to a definition's regions and fill in setting defaults. */\nexport function resolveRegions(definition: MapViewDefinition, values: ParameterValues = {}): Region[] {\n const resolved = resolveParameterValues(definition, values);\n const filled = substitute(definition.source, (paramName) => resolved[paramName]);\n if (!fillDefaults(filled)) {\n // parseMapViewDefinition checked every producible value, so this means a bug, not bad input.\n throw new MapViewDefinitionError(\n definition.id,\n `resolved definition is invalid: ${formatErrors(fillDefaults.errors, filled)}`,\n );\n }\n return (filled as FilledDefinition).regions as Region[];\n}\n\n/**\n * The filter selecting the nodes a map view shows, if any. Hosts apply it when loading the space.\n * PROTOTYPE: filters are evaluated by the host, not per region in the browser, because\n * structured-context's filter evaluator can't yet be bundled for a browser (its only entry point,\n * `structured-context/api`, imports Node built-ins). That's fine while only the first region renders.\n */\nexport function selectionFilter(definition: MapViewDefinition, values: ParameterValues = {}): string | undefined {\n return resolveRegions(definition, values)[0]?.select?.filter;\n}\n\n/**\n * The lowest severity of validation result the map view shows on nodes, or `off`. Hosts check it to\n * decide whether to run validation at all, since results are only drawn when this isn't `off`.\n */\nexport function viewValidationLevel(\n definition: MapViewDefinition,\n values: ParameterValues = {},\n): NodesConfig['validation'] {\n return resolveRegions(definition, values)[0]?.nodes.validation ?? 'off';\n}\n\n/** Map view definitions that apply to a space with the given schema. */\nexport function mapViewsForSchema(\n definitions: readonly MapViewDefinition[],\n schemaId: string | undefined,\n): MapViewDefinition[] {\n return schemaId === undefined ? [] : definitions.filter((d) => d.schema === schemaId);\n}\n\n/** Resolve `$ref`s relative to the format schemas, so parameters can write `settings.json#/$defs/orientation`. */\nfunction absoluteRefs(node: unknown): unknown {\n if (Array.isArray(node)) return node.map(absoluteRefs);\n if (typeof node !== 'object' || node === null) return node;\n return Object.fromEntries(\n Object.entries(node).map(([key, value]) => [\n key,\n key === '$ref' && typeof value === 'string' ? new URL(value, `${SCHEMA_URL}/`).href : absoluteRefs(value),\n ]),\n );\n}\n\nfunction parseParameter(\n name: string,\n schema: AnySchemaObject,\n parameterAjv: Ajv2020,\n fail: (message: string) => never,\n): Parameter {\n const { title, description, default: defaultValue, ...authored } = schema;\n const valueSchema = absoluteRefs(authored) as AnySchemaObject;\n let validate: (value: unknown) => boolean;\n try {\n validate = parameterAjv.compile(valueSchema);\n } catch (err) {\n return fail(`invalid schema: ${err instanceof Error ? err.message : String(err)}`);\n }\n if (!validate(defaultValue)) return fail(`default ${JSON.stringify(defaultValue)} doesn't match its schema`);\n\n const control = controlFor(valueSchema, fail);\n const invalid = producibleValues(control).filter((value) => !validate(value));\n if (invalid.length > 0) {\n fail(\n `its ${control.kind} control can produce ${invalid.map((v) => JSON.stringify(v)).join(', ')}, which its schema rejects; remove constraints the control can't enforce`,\n );\n }\n\n return {\n name,\n title: typeof title === 'string' ? title : (titleFromRef(valueSchema) ?? name),\n ...(typeof description === 'string' && { description }),\n default: defaultValue,\n control,\n };\n}\n\n/**\n * Values a control can produce, as checked against schemas. For a multi-select that's none,\n * each option alone, and all of them. PROTOTYPE: other subsets are assumed valid if these are,\n * which holds for the constraints in use (enum items, uniqueItems) but not, say, `contains`.\n */\nfunction producibleValues(control: ParameterControl): unknown[] {\n switch (control.kind) {\n case 'toggle':\n return [true, false];\n case 'select':\n return [...control.options];\n case 'multiselect':\n return [[], ...control.options.map((option) => [option]), [...control.options]];\n }\n}\n\n/**\n * Every `$param` binding must accept each value the parameter's control can produce.\n * PROTOTYPE: parameters are checked one at a time, with the others at their defaults, which\n * assumes their bindings don't constrain each other.\n */\nfunction checkBindings(source: AuthoredDefinition, parameters: Parameter[], fail: (message: string) => never) {\n const defaults = new Map(parameters.map((p) => [p.name, p.default]));\n for (const param of parameters) {\n for (const candidate of producibleValues(param.control)) {\n const substituted = substitute(source, (n) => (n === param.name ? candidate : defaults.get(n)));\n if (!validateDefinition(substituted)) {\n fail(\n `parameter \"${param.name}\" value ${JSON.stringify(candidate)} isn't valid where it's used: ${formatErrors(validateDefinition.errors, substituted)}`,\n );\n }\n }\n }\n}\n\n/**\n * Derive a control from a parameter's value schema: `enum` (directly, via `$ref`, or narrowed\n * with `allOf`) gives a select, an array of such items a multi-select, `boolean` a toggle.\n */\nfunction controlFor(schema: AnySchemaObject, fail: (message: string) => never): ParameterControl {\n if (typeOf(schema) === 'boolean') return { kind: 'toggle' };\n const isArray = typeOf(schema) === 'array';\n const options = isArray ? intersect(itemSchemas(schema).map(enumOf)) : enumOf(schema);\n if (!options) {\n return fail(\n 'no control can be generated: give it enum options (directly, or via $ref/allOf), array items with enum options, or type boolean',\n );\n }\n if (options.length === 0) return fail('its options narrow to nothing');\n if (!options.every(isPrimitive)) return fail('options must be strings, numbers, booleans or null');\n return { kind: isArray ? 'multiselect' : 'select', options };\n}\n\n/** Schemas linked from this one through `$ref` and `allOf`. */\nfunction linked(schema: AnySchemaObject): AnySchemaObject[] {\n const ref = typeof schema.$ref === 'string' ? ajv.getSchema(schema.$ref)?.schema : undefined;\n return [...(typeof ref === 'object' ? [ref] : []), ...((schema.allOf as AnySchemaObject[] | undefined) ?? [])];\n}\n\n/** Allowed values, intersecting `enum`/`const` with those reached through `$ref` and `allOf`. */\nfunction enumOf(schema: AnySchemaObject): unknown[] | undefined {\n return intersect([\n Array.isArray(schema.enum) ? schema.enum : undefined,\n 'const' in schema ? [schema.const] : undefined,\n ...linked(schema).map(enumOf),\n ]);\n}\n\nfunction typeOf(schema: AnySchemaObject): unknown {\n if (schema.type !== undefined) return schema.type;\n return linked(schema)\n .map(typeOf)\n .find((type) => type !== undefined);\n}\n\n/** Every `items` schema applying to an array, so their constraints can be intersected. */\nfunction itemSchemas(schema: AnySchemaObject): AnySchemaObject[] {\n return [...(typeof schema.items === 'object' ? [schema.items] : []), ...linked(schema).flatMap(itemSchemas)];\n}\n\nfunction intersect(sets: (unknown[] | undefined)[]): unknown[] | undefined {\n const defined = sets.filter((set): set is unknown[] => set !== undefined);\n if (defined.length === 0) return undefined;\n const key = (v: unknown) => JSON.stringify(v);\n return defined.reduce((acc, set) => acc.filter((v) => set.some((w) => key(w) === key(v))));\n}\n\nfunction titleFromRef(schema: AnySchemaObject): string | undefined {\n const title = linked(schema)[0]?.title;\n return typeof title === 'string' ? title : undefined;\n}\n\nfunction isPrimitive(value: unknown): value is Primitive {\n return value === null || ['string', 'number', 'boolean'].includes(typeof value);\n}\n\nfunction isProducible(control: ParameterControl, value: unknown): boolean {\n switch (control.kind) {\n case 'toggle':\n return typeof value === 'boolean';\n case 'select':\n return control.options.includes(value as Primitive);\n case 'multiselect':\n return Array.isArray(value) && value.every((v) => control.options.includes(v));\n }\n}\n\nfunction isParamRef(value: unknown): value is ParamRef {\n return typeof value === 'object' && value !== null && typeof (value as { $param?: unknown }).$param === 'string';\n}\n\n/** Copy a JSON value, replacing each `{ $param }` binding with its value. */\nfunction substitute(value: unknown, valueFor: (paramName: string) => unknown): unknown {\n if (isParamRef(value)) return structuredClone(valueFor(value.$param));\n if (Array.isArray(value)) return value.map((v) => substitute(v, valueFor));\n if (typeof value === 'object' && value !== null) {\n return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, substitute(v, valueFor)]));\n }\n return value;\n}\n\nfunction paramNames(value: unknown): string[] {\n if (isParamRef(value)) return [value.$param];\n if (Array.isArray(value)) return value.flatMap(paramNames);\n if (typeof value === 'object' && value !== null) return Object.values(value).flatMap(paramNames);\n return [];\n}\n\n/**\n * Readable Ajv errors. A setting accepts a value or a `{ $param }` binding (`anyOf`), so a bad\n * value also fails the binding branch; those errors, and the bare anyOf summary, are dropped\n * unless the value actually is a binding. An `if` failure only repeats its branch's errors.\n */\nfunction formatErrors(errors: ErrorObject[] | null | undefined, instance: unknown): string {\n const relevant = (errors ?? []).filter(\n (e) =>\n e.keyword !== 'anyOf' &&\n e.keyword !== 'if' &&\n !(e.schemaPath.includes('/$defs/paramRef') && !isParamRef(at(instance, e.instancePath))),\n );\n return relevant.map((e) => `${e.instancePath || '/'} ${message(e)}${detail(e)}`).join('; ');\n}\n\n/** The value at a JSON pointer. */\nfunction at(value: unknown, pointer: string): unknown {\n return pointer\n .split('/')\n .slice(1)\n .map((segment) => segment.replaceAll('~1', '/').replaceAll('~0', '~'))\n .reduce<unknown>(\n (node, key) => (typeof node === 'object' && node !== null ? (node as Record<string, unknown>)[key] : undefined),\n value,\n );\n}\n\nfunction message(error: ErrorObject): string | undefined {\n if (error.keyword === 'discriminator' && error.params.error === 'mapping') {\n return `has unknown ${error.params.tag} ${JSON.stringify(error.params.tagValue)}`;\n }\n return error.message;\n}\n\nfunction detail(error: ErrorObject): string {\n if (error.keyword === 'additionalProperties') return ` (\"${error.params.additionalProperty}\")`;\n if (error.keyword === 'enum') {\n return ` (${(error.params.allowedValues as unknown[]).map((v) => JSON.stringify(v)).join(', ')})`;\n }\n return '';\n}\n"],"mappings":";;;AAQA,IAAa,aAAa;;;;ACN1B,IAAa,YAAY,GAAG,WAAW;;AAGvC,SAAgB,gBAAiD,aAAgB,cAAiB,aAAqB;CACrH,OAAO;EAAE;EAAa,SAAS;EAAc,OAAO,CAAC,aAAa,EAAE,MAAM,UAAU,CAAC;CAAE;AACzF;;;;;;;;;ACEA,IAAa,mBAAmB;CAC9B,SAAS;CACT,KAAK,GAAG,WAAW;CACnB,OAAO;CACP,aACE;CACF,MAAM;CACN,UAAU;EAAC;EAAO;EAAU;CAAS;CACrC,sBAAsB;CACtB,YAAY;EACV,SAAS,EAAE,MAAM,SAAS;EAC1B,KAAK;GACH,MAAM;GACN,SAAS;GACT,aACE;EACJ;EACA,OAAO;GAAE,MAAM;GAAU,WAAW;GAAG,aAAa;EAA2D;EAC/G,aAAa,EAAE,MAAM,SAAS;EAC9B,QAAQ;GACN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V,MAAM,CAAC,CAAC,CACR,KAAK,YAAY,QAAQ,WAAW,MAAM,GAAG,CAAC,CAAC,WAAW,MAAM,GAAG,CAAC,CAAC,CACrE,QACE,MAAM,QAAS,OAAO,SAAS,YAAY,SAAS,OAAQ,KAAiC,OAAO,KAAA,GACrG,KACF;AACJ;AAEA,SAAS,QAAQ,OAAwC;CACvD,IAAI,MAAM,YAAY,mBAAmB,MAAM,OAAO,UAAU,WAC9D,OAAO,eAAe,MAAM,OAAO,IAAI,GAAG,KAAK,UAAU,MAAM,OAAO,QAAQ;CAEhF,OAAO,MAAM;AACf;AAEA,SAAS,OAAO,OAA4B;CAC1C,IAAI,MAAM,YAAY,wBAAwB,OAAO,MAAM,MAAM,OAAO,mBAAmB;CAC3F,IAAI,MAAM,YAAY,QACpB,OAAO,KAAM,MAAM,OAAO,cAA4B,KAAK,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE;CAEjG,OAAO;AACT"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"projection-GaO0MCbR.js","names":[],"sources":["../src/core/annotations.ts","../src/core/graph.ts","../src/core/occurrence.ts","../src/core/tree.ts","../src/core/landscape.ts","../src/core/xy.ts"],"sourcesContent":["import type { RuleSeverity, SourceLocation, SpaceGraph, SpaceNode, ValidationResult } from 'structured-context/api';\n\n// core doesn't export NodeId from `structured-context/api` yet; this derives it.\ntype NodeId = SpaceNode['id'];\n\n/** How serious a result is: structured-context's rule severity. Schema and hierarchy failures are errors. */\nexport type Severity = RuleSeverity;\n\n/** The kind of check a result came from. */\nexport type AnnotationSource = 'schema' | 'hierarchy' | 'rule';\n\n/** One validation result attached to a node. */\nexport type NodeAnnotation = {\n severity: Severity;\n source: AnnotationSource;\n message: string;\n /** The violated rule, for `rule` results. */\n ruleId?: string;\n};\n\n/** A validation result with no node on the map to attach to. */\nexport type UnattachedAnnotation = NodeAnnotation & {\n /** The node it concerns. Absent for a global-scope rule. A node that failed its schema isn't in the graph. */\n nodeId?: NodeId;\n /** Where that node is defined, if known. */\n location?: SourceLocation;\n};\n\n/** Annotations by the id of the node they apply to. */\nexport type AnnotationIndex = ReadonlyMap<NodeId, readonly NodeAnnotation[]>;\n\n/**\n * The parts of structured-context's `ValidationResult` that attach to a node. Every part is optional:\n * a host that only runs some checks (the Obsidian plugin runs no AI-judged rules, say) passes what it has.\n */\nexport type ValidationInput = Partial<\n Pick<ValidationResult, 'ruleViolations' | 'hierarchyViolations'> & {\n nodeErrors: ReadonlyArray<Pick<ValidationResult['nodeErrors'][number], 'nodeId' | 'source' | 'issues'>>;\n }\n>;\n\n/**\n * Attach validation results to the nodes of `graph`, by node id. Results that can't be attached are\n * returned in `unattached` for the host to surface: global-scope rules (no node), and nodes that\n * aren't in the graph, which includes every node that failed its schema.\n */\nexport function annotationsFrom(\n input: ValidationInput,\n graph: SpaceGraph,\n): { annotations: AnnotationIndex; unattached: UnattachedAnnotation[] } {\n const annotations = new Map<NodeId, NodeAnnotation[]>();\n const unattached: UnattachedAnnotation[] = [];\n const add = (nodeId: NodeId | undefined, annotation: NodeAnnotation, location?: SourceLocation) => {\n if (nodeId !== undefined && graph.nodes.has(nodeId)) {\n annotations.set(nodeId, [...(annotations.get(nodeId) ?? []), annotation]);\n } else {\n unattached.push({ ...annotation, nodeId, ...(location && { location }) });\n }\n };\n\n for (const { nodeId, source, issues } of input.nodeErrors ?? []) {\n for (const issue of issues) {\n add(nodeId, { severity: 'error', source: 'schema', message: issue.message }, source);\n }\n }\n for (const { nodeId, description } of input.hierarchyViolations ?? []) {\n add(nodeId, { severity: 'error', source: 'hierarchy', message: description });\n }\n for (const { nodeId, description, severity, ruleId } of input.ruleViolations ?? []) {\n add(nodeId, { severity, source: 'rule', message: description, ruleId });\n }\n return { annotations, unattached };\n}\n\nconst RANK: Record<Severity, number> = { error: 0, warning: 1, info: 2 };\n\n/** The most serious severity among annotations, or undefined if there are none. */\nexport function worstSeverity(annotations: readonly NodeAnnotation[]): Severity | undefined {\n return annotations.reduce<Severity | undefined>(\n (worst, { severity }) => (worst === undefined || RANK[severity] < RANK[worst] ? severity : worst),\n undefined,\n );\n}\n\n/**\n * The annotations a map view shows: those at `level` or more serious, from `sources`. `off` shows none.\n * Nodes left with no annotations are dropped from the index.\n */\nexport function filterAnnotations(\n index: AnnotationIndex,\n level: Severity | 'off',\n sources: readonly AnnotationSource[],\n): AnnotationIndex {\n if (level === 'off') return new Map();\n const filtered = new Map<NodeId, readonly NodeAnnotation[]>();\n for (const [id, annotations] of index) {\n const kept = annotations.filter((a) => RANK[a.severity] <= RANK[level] && sources.includes(a.source));\n if (kept.length > 0) filtered.set(id, kept);\n }\n return filtered;\n}\n","import type { Hierarchy, SpaceGraph, SpaceNode } from 'structured-context/api';\n\ntype NodeId = SpaceNode['id'];\n\n/** A directed parent → child edge of a space graph, carrying the metadata of the reference it came from. */\nexport type Edge = SpaceGraph['parentEdges'] extends ReadonlyMap<string, readonly (infer E)[]> ? E : never;\n\nconst NONE: readonly Edge[] = [];\n\n/**\n * Edges to a node's parents, in the order the node declares them. A graph narrowed by a filter keeps\n * edges to parents outside it; those are left out.\n */\nexport function parentEdges(graph: SpaceGraph, id: NodeId): readonly Edge[] {\n return (graph.parentEdges.get(id) ?? NONE).filter((edge) => graph.nodes.has(edge.parent));\n}\n\n/** Edges to a node's children, in graph order of the children. */\nexport function childEdges(graph: SpaceGraph, id: NodeId): readonly Edge[] {\n return graph.childEdges.get(id) ?? NONE;\n}\n\n/** Every edge whose parent and child are both in the graph. */\nexport function edgesWithin(graph: SpaceGraph): Edge[] {\n return [...graph.nodes.keys()].flatMap((id) => parentEdges(graph, id));\n}\n\n/** Whether an edge belongs to the given hierarchy (as opposed to a relationship or another hierarchy). */\nexport function isHierarchyEdge(edge: Edge, hierarchy: Hierarchy | undefined): boolean {\n return hierarchy !== undefined && edge.kind === 'hierarchy' && edge.hierarchy === hierarchy.name;\n}\n","/**\n * One step of an occurrence path: a node title, a `[field, value]` group, or `null` for the\n * ungrouped area. Encoded distinctly, so a field group can't collide with a node of the same name.\n */\nexport type PathSegment = string | readonly [field: string, value: string | null] | null;\n\n/**\n * Path-based key for one occurrence of a node: region, then the steps from the outermost\n * container down to the node. Unique within a map view even when a node appears several times.\n * Hosts can render several map views at once, so layouts scope keys to the map view instance.\n */\nexport function occurrenceKey(regionId: string, path: readonly PathSegment[]): string {\n return JSON.stringify([regionId, ...path]);\n}\n","import type { SpaceGraph, SpaceNode } from 'structured-context/api';\nimport type { DagMode } from './definition';\nimport { childEdges, isHierarchyEdge, parentEdges } from './graph';\nimport { occurrenceKey } from './occurrence';\n\n/** One rendered appearance of a node in a tree. */\nexport type TreeOccurrence = {\n /** Path-based key, unique within the map view (see {@link occurrenceKey}). */\n key: string;\n node: SpaceNode;\n children: TreeOccurrence[];\n /**\n * Key of the node's primary occurrence when this is a repeat. A node with several parents\n * appears under each of them, but its subtree is only rendered at its first occurrence.\n */\n repeatOf?: string;\n};\n\nexport type Tree = {\n roots: TreeOccurrence[];\n /**\n * Hierarchy-typed nodes not reachable from a root, rendered as extra roots: nodes with no\n * hierarchy parent in the space, then entry points into otherwise unreachable cycles.\n */\n orphans: TreeOccurrence[];\n /** Key of each node's primary (first, fully rendered) occurrence. */\n primary: ReadonlyMap<string, string>;\n /**\n * In cross-edge mode, links from a node's other parents to its primary occurrence, which\n * replace repeat occurrences. Empty in repeat mode.\n */\n crossLinks: TreeLink[];\n};\n\nexport type TreeLink = { from: string; to: string; kind: 'tree' | 'cross' };\n\n/**\n * Lay a space out as a tree over its hierarchy.\n *\n * Roots are root-type nodes with no hierarchy parent. Traversal is depth-first in space order,\n * so a node's primary occurrence is under the parent reached first. Under its other parents a\n * node is either repeated without its subtree (`repeat`), or left out and linked by a cross-edge\n * (`cross-edge`). Either way traversal stops there, which also keeps cycles from recursing.\n */\nexport function buildTree(graph: SpaceGraph, regionId: string, dag: DagMode = 'repeat'): Tree {\n const { hierarchy } = graph;\n const levelTypes = new Set(hierarchy?.levels.map((level) => level.type));\n const rootType = hierarchy?.levels[0]?.type;\n const primary = new Map<string, string>();\n // Parent occurrence → child title, resolved to the child's primary occurrence afterwards.\n const pendingCross: { from: string; child: string }[] = [];\n\n const hierarchyParents = (title: SpaceNode['id']) =>\n parentEdges(graph, title).filter((edge) => isHierarchyEdge(edge, hierarchy));\n\n const visit = (node: SpaceNode, path: readonly string[]): TreeOccurrence => {\n const nodePath = [...path, node.id];\n const key = occurrenceKey(regionId, nodePath);\n primary.set(node.id, key);\n // A child can reference the same parent through more than one field; it occurs once.\n const childTitles = new Set(\n childEdges(graph, node.id)\n .filter((edge) => isHierarchyEdge(edge, hierarchy))\n .map((edge) => edge.child),\n );\n const children: TreeOccurrence[] = [];\n for (const title of childTitles) {\n const child = graph.nodes.get(title)!;\n const repeatOf = primary.get(title);\n if (repeatOf === undefined) children.push(visit(child, nodePath));\n else if (dag === 'repeat')\n children.push({ key: occurrenceKey(regionId, [...nodePath, title]), node: child, children: [], repeatOf });\n else pendingCross.push({ from: key, child: title });\n }\n return { key, node, children };\n };\n\n const levelNodes = [...graph.nodes.values()].filter((node) => levelTypes.has(node.resolvedType));\n const unparented = levelNodes.filter((node) => hierarchyParents(node.id).length === 0);\n const roots = unparented.filter((node) => node.resolvedType === rootType).map((node) => visit(node, []));\n const orphans = unparented.filter((node) => node.resolvedType !== rootType).map((node) => visit(node, []));\n // Nodes only reachable through a cycle have a parent but no path from a root. Rather than\n // drop them, enter each such cycle at its first node in space order.\n for (const node of levelNodes) {\n if (!primary.has(node.id)) orphans.push(visit(node, []));\n }\n\n const crossLinks = pendingCross.map(({ from, child }) => ({ from, to: primary.get(child)!, kind: 'cross' as const }));\n return { roots, orphans, primary, crossLinks };\n}\n\n/** Parent → child pairs of occurrence keys: one per rendered parent-child link, then cross-links. */\nexport function treeLinks(tree: Tree): TreeLink[] {\n const links: TreeLink[] = [];\n const walk = (occurrence: TreeOccurrence) => {\n for (const child of occurrence.children) {\n links.push({ from: occurrence.key, to: child.key, kind: 'tree' });\n walk(child);\n }\n };\n for (const root of [...tree.roots, ...tree.orphans]) walk(root);\n return [...links, ...tree.crossLinks];\n}\n","import type { SpaceGraph, SpaceNode } from 'structured-context/api';\nimport type { GroupLevel, LandscapeLayoutConfig } from './definition';\nimport { childEdges, parentEdges } from './graph';\nimport { occurrenceKey, type PathSegment } from './occurrence';\n\n/** One rendered container or node in a landscape. */\nexport type LandscapeOccurrence = {\n /** Path-based key, unique within the map view (see {@link occurrenceKey}). */\n key: string;\n /** Index of the grouping level this occurrence belongs to. */\n level: number;\n /** A node, or a field value shared by the nodes inside (`null`: the field is empty). */\n item: { kind: 'node'; node: SpaceNode } | { kind: 'value'; field: string; value: string | null };\n /** Nodes on the `via` chain that joined this node to the node level above, one entry per skipped type. */\n via: ViaStep[];\n /** Key of the node's first occurrence when this is a repeat. Repeats are rendered in full. */\n repeatOf?: string;\n children: LandscapeOccurrence[];\n};\n\nexport type ViaStep = { type: string; nodes: SpaceNode[] };\n\nexport type Landscape = {\n groups: LandscapeOccurrence[];\n /**\n * Nodes of a grouped level that no container above reaches (e.g. an Activity with no\n * Outcome when grouping by Outcomes), each with its own contents.\n */\n ungrouped: LandscapeOccurrence[];\n};\n\ntype Candidate = { node: SpaceNode; via: ViaStep[] };\ntype FieldFilter = { field: string; value: string | null };\n\n/**\n * Lay a space out as nested containers following the layout's grouping levels.\n *\n * Adjacent node levels are joined by any edge between their types, in either direction, or only\n * edges from `edge.field`. A `via` chain joins them through the skipped types. A field level\n * splits the next node level by that field's values. A node reached from several containers\n * appears in each, in full: the levels are finite, so repeating contents can't recurse.\n */\nexport function buildLandscape(graph: SpaceGraph, regionId: string, layout: LandscapeLayoutConfig): Landscape {\n const levels = layout.group;\n const order = new Map([...graph.nodes.keys()].map((title, i) => [title, i]));\n const first = new Map<string, string>();\n\n const occurrenceFor = (candidate: Candidate, levelIdx: number, path: readonly PathSegment[]): LandscapeOccurrence => {\n const { node } = candidate;\n const nodePath = [...path, node.id];\n const key = occurrenceKey(regionId, nodePath);\n const repeatOf = first.get(node.id);\n if (repeatOf === undefined) first.set(node.id, key);\n return {\n key,\n level: levelIdx,\n item: { kind: 'node', node },\n via: candidate.via,\n ...(repeatOf !== undefined && { repeatOf }),\n children: place(levelIdx + 1, node, [], nodePath),\n };\n };\n\n /** Occurrences for level `levelIdx` inside `anchor`, the nearest enclosing node. */\n const place = (\n levelIdx: number,\n anchor: SpaceNode | undefined,\n filters: readonly FieldFilter[],\n path: readonly PathSegment[],\n ): LandscapeOccurrence[] => {\n const level = levels[levelIdx];\n if (level === undefined) return [];\n if (isTypeLevel(level)) {\n return candidates(level, anchor, filters).map((c) => occurrenceFor(c, levelIdx, path));\n }\n\n const nodeLevel = levels.slice(levelIdx).find(isTypeLevel)!;\n const values = distinctValues(\n candidates(nodeLevel, anchor, filters).map((c) => c.node),\n level.field,\n );\n return values.map((value) => {\n const valuePath = [...path, [level.field, value] as const];\n return {\n key: occurrenceKey(regionId, valuePath),\n level: levelIdx,\n item: { kind: 'value', field: level.field, value },\n via: [],\n children: place(levelIdx + 1, anchor, [...filters, { field: level.field, value }], valuePath),\n };\n });\n };\n\n /** Nodes of a type level joined to `anchor` (all of the type at the top) and matching the filters. */\n const candidates = (\n level: TypeLevel,\n anchor: SpaceNode | undefined,\n filters: readonly FieldFilter[],\n ): Candidate[] => {\n const reached: Candidate[] =\n anchor === undefined\n ? ofType(level.type).map((node) => ({ node, via: [] }))\n : walkChain(anchor, level.via ?? [], level.type, level.edge?.field);\n return reached.filter(({ node }) => filters.every((f) => hasValue(node, f)));\n };\n\n const ofType = (type: string) => [...graph.nodes.values()].filter((node) => node.resolvedType === type);\n\n /** Neighbours of a node with the given type, across edges in either direction, in space order. */\n const neighbours = (title: SpaceNode['id'], type: string, field: string | undefined): SpaceNode[] => {\n const titles = new Set([\n ...childEdges(graph, title)\n .filter((e) => field === undefined || e.field === field)\n .map((e) => e.child),\n ...parentEdges(graph, title)\n .filter((e) => field === undefined || e.field === field)\n .map((e) => e.parent),\n ]);\n return [...titles]\n .map((t) => graph.nodes.get(t)!)\n .filter((node) => node.resolvedType === type)\n .sort((a, b) => order.get(a.id)! - order.get(b.id)!);\n };\n\n /**\n * Follow edges from `anchor` through each `via` type to `target`, keeping the skipped nodes on\n * the way to each target node. Several chains to one target merge into one candidate.\n */\n const walkChain = (anchor: SpaceNode, via: readonly string[], target: string, field: string | undefined) => {\n let frontier = [{ node: anchor, trail: [] as SpaceNode[] }];\n for (const type of via) {\n frontier = frontier.flatMap(({ node, trail }) =>\n neighbours(node.id, type, undefined).map((next) => ({ node: next, trail: [...trail, next] })),\n );\n }\n const byTitle = new Map<string, Candidate>();\n for (const { node, trail } of frontier) {\n for (const next of neighbours(node.id, target, field)) {\n const candidate = byTitle.get(next.id) ?? { node: next, via: via.map((type) => ({ type, nodes: [] })) };\n trail.forEach((skipped, i) => {\n const step = candidate.via[i]!;\n if (!step.nodes.includes(skipped)) step.nodes.push(skipped);\n });\n byTitle.set(next.id, candidate);\n }\n }\n return [...byTitle.values()].sort((a, b) => order.get(a.node.id)! - order.get(b.node.id)!);\n };\n\n const groups = place(0, undefined, [], []);\n\n // Nodes of an inner level that no container reached get their own contents, like tree orphans.\n const ungrouped: LandscapeOccurrence[] = [];\n levels.forEach((level, levelIdx) => {\n if (levelIdx === 0 || !isTypeLevel(level)) return;\n for (const node of ofType(level.type)) {\n if (!first.has(node.id)) ungrouped.push(occurrenceFor({ node, via: [] }, levelIdx, [null]));\n }\n });\n\n return { groups, ungrouped };\n}\n\ntype TypeLevel = Extract<GroupLevel, { type: string }>;\n\nfunction isTypeLevel(level: GroupLevel): level is TypeLevel {\n return 'type' in level;\n}\n\n/** A field's values as group labels: strings, an entry per array item, `null` when empty. */\nfunction valuesOf(node: SpaceNode, field: string): (string | null)[] {\n const raw = node.schemaData[field];\n const list = (Array.isArray(raw) ? raw : [raw]).filter((v) => v !== undefined && v !== null && v !== '');\n return list.length === 0 ? [null] : list.map((v) => (typeof v === 'object' ? JSON.stringify(v) : String(v)));\n}\n\n/** Distinct values in first-seen order, with the empty group last. */\nfunction distinctValues(nodes: SpaceNode[], field: string): (string | null)[] {\n const values = new Set(nodes.flatMap((node) => valuesOf(node, field)));\n const present = [...values].filter((v): v is string => v !== null);\n return values.has(null) ? [...present, null] : present;\n}\n\nfunction hasValue(node: SpaceNode, { field, value }: FieldFilter): boolean {\n return valuesOf(node, field).includes(value);\n}\n","import type { SpaceGraph, SpaceNode } from 'structured-context/api';\nimport type { AxisConfig, XYLayoutConfig } from './definition';\nimport { edgesWithin, isHierarchyEdge } from './graph';\nimport { occurrenceKey } from './occurrence';\n\n/** A plotted node. `x` and `y` run from 0 to 1 across the plot, left to right and bottom to top. */\nexport type XYPoint = { key: string; node: SpaceNode; x: number; y: number };\n\n/** Why a node of a plotted type couldn't be placed, per axis. */\nexport type Unplaced = { key: string; node: SpaceNode; reasons: string[] };\n\n/**\n * An edge between plotted nodes. `lane` separates edges joining the same two nodes: 0 when\n * there's one, otherwise centred around 0 (e.g. -0.5 and 0.5), for layouts to draw side by side.\n */\nexport type XYLink = { from: string; to: string; field: string; hierarchy: boolean; lane: number };\n\nexport type XYPlot = {\n points: XYPoint[];\n unplaced: Unplaced[];\n /** Edges between plotted nodes. */\n links: XYLink[];\n /** Each axis's [min, max]; `direction` says which end is drawn where. */\n domains: { x: readonly [number, number]; y: readonly [number, number] };\n};\n\n/**\n * Position nodes by two numeric fields. Every node of a plotted type appears once: on the plot\n * when both its values are numbers inside the axes' domains, otherwise in `unplaced` with the\n * reason. Positions are normalised; layouts decide the plot's size.\n */\nexport function buildXYPlot(graph: SpaceGraph, regionId: string, layout: XYLayoutConfig): XYPlot {\n const { x, y } = layout;\n const nodes = [...graph.nodes.values()];\n const types = new Set(\n layout.types.length > 0\n ? layout.types\n : nodes\n .filter((n) => isNumber(n.schemaData[x.field]) || isNumber(n.schemaData[y.field]))\n .map((n) => n.resolvedType),\n );\n const plotted = nodes.filter((n) => types.has(n.resolvedType));\n\n const domains = {\n x: domainOf(x, plotted),\n y: domainOf(y, plotted),\n };\n\n const points: XYPoint[] = [];\n const unplaced: Unplaced[] = [];\n for (const node of plotted) {\n const key = occurrenceKey(regionId, [node.id]);\n const px = position(node, x, domains.x);\n const py = position(node, y, domains.y);\n if (typeof px === 'number' && typeof py === 'number') points.push({ key, node, x: px, y: py });\n else unplaced.push({ key, node, reasons: [px, py].filter((r): r is string => typeof r === 'string') });\n }\n\n const keys = new Map<string, string>(points.map((p) => [p.node.id, p.key]));\n const fields = new Set(layout.edgeFields);\n const links = edgesWithin(graph)\n .filter((e) => keys.has(e.parent) && keys.has(e.child) && (fields.size === 0 || fields.has(e.field)))\n .map((e) => ({\n from: keys.get(e.parent)!,\n to: keys.get(e.child)!,\n field: e.field,\n hierarchy: isHierarchyEdge(e, graph.hierarchy),\n lane: 0,\n }));\n assignLanes(links);\n\n return { points, unplaced, links, domains };\n}\n\nfunction isNumber(value: unknown): value is number {\n return typeof value === 'number' && Number.isFinite(value);\n}\n\n/** The axis's fixed domain, or the range of plotted values (widened when they're all equal). */\nfunction domainOf(axis: AxisConfig, nodes: readonly SpaceNode[]): readonly [number, number] {\n if (Array.isArray(axis.domain)) return [axis.domain[0]!, axis.domain[1]!];\n const values = nodes.map((n) => n.schemaData[axis.field]).filter(isNumber);\n if (values.length === 0) return [0, 1];\n const min = Math.min(...values);\n const max = Math.max(...values);\n return min === max ? [min - 1, max + 1] : [min, max];\n}\n\n/** The node's normalised position on the axis, or why it has none. */\nfunction position(node: SpaceNode, axis: AxisConfig, [min, max]: readonly [number, number]): number | string {\n const value = node.schemaData[axis.field];\n if (value === undefined || value === null) return `no ${axis.field}`;\n if (!isNumber(value)) return `${axis.field} is not a number`;\n if (value < min || value > max) return `${axis.field} ${value} is outside ${min}–${max}`;\n const t = (value - min) / (max - min);\n return axis.direction === 'descending' ? 1 - t : t;\n}\n\n/** Spread links joining the same pair of nodes (in either direction) into lanes around 0. */\nfunction assignLanes(links: XYLink[]) {\n const byPair = new Map<string, XYLink[]>();\n for (const link of links) {\n const pair = [link.from, link.to].sort().join('\\n');\n byPair.set(pair, [...(byPair.get(pair) ?? []), link]);\n }\n for (const group of byPair.values()) {\n group.forEach((link, i) => {\n link.lane = i - (group.length - 1) / 2;\n });\n }\n}\n"],"mappings":";;;;;;AA8CA,SAAgB,gBACd,OACA,OACsE;CACtE,MAAM,8BAAc,IAAI,IAA8B;CACtD,MAAM,aAAqC,CAAC;CAC5C,MAAM,OAAO,QAA4B,YAA4B,aAA8B;EACjG,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;GAAE,GAAG;GAAY;GAAQ,GAAI,YAAY,EAAE,SAAS;EAAG,CAAC;CAE5E;CAEA,KAAK,MAAM,EAAE,QAAQ,QAAQ,YAAY,MAAM,cAAc,CAAC,GAC5D,KAAK,MAAM,SAAS,QAClB,IAAI,QAAQ;EAAE,UAAU;EAAS,QAAQ;EAAU,SAAS,MAAM;CAAQ,GAAG,MAAM;CAGvF,KAAK,MAAM,EAAE,QAAQ,iBAAiB,MAAM,uBAAuB,CAAC,GAClE,IAAI,QAAQ;EAAE,UAAU;EAAS,QAAQ;EAAa,SAAS;CAAY,CAAC;CAE9E,KAAK,MAAM,EAAE,QAAQ,aAAa,UAAU,YAAY,MAAM,kBAAkB,CAAC,GAC/E,IAAI,QAAQ;EAAE;EAAU,QAAQ;EAAQ,SAAS;EAAa;CAAO,CAAC;CAExE,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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