structured-context-map-views 0.6.1 → 0.7.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.
Files changed (75) hide show
  1. package/README.md +1 -1
  2. package/dist/{ParameterControls-A1HJWyt9.js → ParameterControls-Be05VST0.js} +505 -188
  3. package/dist/ParameterControls-Be05VST0.js.map +1 -0
  4. package/dist/artifact.html +70 -1
  5. package/dist/artifact.js +2 -2
  6. package/dist/artifact.js.map +1 -1
  7. package/dist/cli.js +12 -6
  8. package/dist/cli.js.map +1 -1
  9. package/dist/{definition-Cp1CCigh.js → definition-SjmROmJC.js} +308 -188
  10. package/dist/definition-SjmROmJC.js.map +1 -0
  11. package/dist/html.js +19 -0
  12. package/dist/html.js.map +1 -0
  13. package/dist/index.js +3 -3
  14. package/dist/node-ctbuxC-s.js +74 -0
  15. package/dist/node-ctbuxC-s.js.map +1 -0
  16. package/dist/node.js +2 -2
  17. package/dist/page.html +94 -25
  18. package/dist/{projection-C-dATsdO.js → projection-DKNLziP0.js} +282 -124
  19. package/dist/projection-DKNLziP0.js.map +1 -0
  20. package/dist/read-definitions-DFcOXatz.js +51 -0
  21. package/dist/read-definitions-DFcOXatz.js.map +1 -0
  22. package/dist/styles.css +69 -0
  23. package/dist/types/artifact/load.d.ts +1 -1
  24. package/dist/types/{layouts/EdgeOverlay.d.ts → components/ConnectorOverlay.d.ts} +6 -15
  25. package/dist/types/components/GraphLayout.d.ts +8 -0
  26. package/dist/types/components/LandscapeLayout.d.ts +9 -0
  27. package/dist/types/{layouts → components}/MapView.d.ts +4 -1
  28. package/dist/types/components/NeighbourhoodLayout.d.ts +7 -0
  29. package/dist/types/{layouts/NodeCard.d.ts → components/NodeComponent.d.ts} +1 -1
  30. package/dist/types/components/TreeLayout.d.ts +6 -0
  31. package/dist/types/{layouts → components}/XYLayout.d.ts +3 -3
  32. package/dist/types/{layouts → components}/annotations-context.d.ts +1 -1
  33. package/dist/types/components/layout.d.ts +22 -0
  34. package/dist/types/core/annotations.d.ts +2 -3
  35. package/dist/types/core/definition.d.ts +664 -30
  36. package/dist/types/core/layouts/graph/schema.d.ts +24 -0
  37. package/dist/types/core/layouts/helpers.d.ts +42 -0
  38. package/dist/types/core/layouts/landscape/projection.d.ts +75 -0
  39. package/dist/types/core/layouts/landscape/schema.d.ts +223 -0
  40. package/dist/types/core/layouts/neighbourhood/projection.d.ts +26 -0
  41. package/dist/types/core/layouts/neighbourhood/schema.d.ts +51 -0
  42. package/dist/types/core/layouts/schemas.d.ts +427 -0
  43. package/dist/types/core/{tree.d.ts → layouts/tree/projection.d.ts} +9 -11
  44. package/dist/types/core/layouts/xy/projection.d.ts +32 -0
  45. package/dist/types/core/{format/xy-layout.d.ts → layouts/xy/schema.d.ts} +2 -0
  46. package/dist/types/core/{format → schema}/definition-schema.d.ts +22 -12
  47. package/dist/types/core/{snapshot.d.ts → space-snapshot.d.ts} +1 -4
  48. package/dist/types/index.d.ts +6 -9
  49. package/dist/types/node/html.d.ts +6 -0
  50. package/dist/types/node/index.d.ts +7 -30
  51. package/dist/types/node/page.d.ts +1 -1
  52. package/dist/types/node/read-definitions.d.ts +17 -0
  53. package/dist/types/node/snapshot.d.ts +1 -1
  54. package/dist/types/viewer/Viewer.d.ts +5 -5
  55. package/package.json +10 -4
  56. package/dist/ParameterControls-A1HJWyt9.js.map +0 -1
  57. package/dist/definition-Cp1CCigh.js.map +0 -1
  58. package/dist/node-aizYAYlq.js +0 -130
  59. package/dist/node-aizYAYlq.js.map +0 -1
  60. package/dist/projection-C-dATsdO.js.map +0 -1
  61. package/dist/types/core/format/index.d.ts +0 -450
  62. package/dist/types/core/format/landscape-layout.d.ts +0 -102
  63. package/dist/types/core/graph.d.ts +0 -16
  64. package/dist/types/core/landscape.d.ts +0 -44
  65. package/dist/types/core/occurrence.d.ts +0 -11
  66. package/dist/types/core/xy.d.ts +0 -43
  67. package/dist/types/layouts/LandscapeLayout.d.ts +0 -8
  68. package/dist/types/layouts/TreeLayout.d.ts +0 -16
  69. /package/dist/types/{layouts → components}/ParameterControls.d.ts +0 -0
  70. /package/dist/types/{layouts → components}/ParameterInputs.d.ts +0 -0
  71. /package/dist/types/{layouts → components}/useParameterControls.d.ts +0 -0
  72. /package/dist/types/core/{format/tree-layout.d.ts → layouts/tree/schema.d.ts} +0 -0
  73. /package/dist/types/core/{format → schema}/param-ref.d.ts +0 -0
  74. /package/dist/types/core/{format → schema}/schema-url.d.ts +0 -0
  75. /package/dist/types/core/{format → schema}/settings.d.ts +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ParameterControls-Be05VST0.js","names":["_Fragment","_Fragment"],"sources":["../src/components/annotations-context.ts","../src/components/ConnectorOverlay.tsx","../src/components/layout.ts","../src/components/NodeComponent.tsx","../src/components/GraphLayout.tsx","../src/components/LandscapeLayout.tsx","../src/components/NeighbourhoodLayout.tsx","../src/components/TreeLayout.tsx","../src/components/XYLayout.tsx","../src/components/MapView.tsx","../src/components/ParameterInputs.tsx","../src/components/useParameterControls.ts","../src/components/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 components. */\nexport const AnnotationsContext = createContext<AnnotationIndex>(NONE);\n\nexport const useAnnotations = () => useContext(AnnotationsContext);\n","import { useLayoutEffect, useState } from 'react';\nimport type { EdgesConfig, Orientation } from '../core/definition';\nimport type { Connector } from '../core/layouts/helpers';\n\ntype Props = {\n connectors: readonly Connector[];\n /** The region's `edges` settings: whether connectors are drawn, and whether each shows its field. */\n edges: EdgesConfig;\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; dashed: boolean; label?: string; at: readonly [number, number] };\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 ConnectorOverlay({ connectors, edges, elements, container, routing }: Props) {\n const [paths, setPaths] = useState<Drawn[]>([]);\n\n useLayoutEffect(() => {\n if (!container || !edges.show) return;\n\n const measure = () => {\n const origin = container.getBoundingClientRect();\n const paths: Drawn[] = [];\n for (const { from, to, field, lane = 0, dashed = false } of connectors) {\n const a = elements.get(from)?.getBoundingClientRect();\n const b = elements.get(to)?.getBoundingClientRect();\n if (!a || !b) continue;\n const [d, at] = routing === 'straight' ? line(a, b, origin, lane) : connector(a, b, origin, routing);\n paths.push({ key: `${from}→${to}${field ?? ''}`, d, dashed, label: edges.labels ? field : undefined, at });\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 }, [connectors, edges.show, edges.labels, elements, container, routing]);\n\n if (!edges.show) return null;\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, dashed }) => (\n <path\n key={key}\n d={d}\n className={`mv:fill-none ${dashed ? 'mv:stroke-accent/60' : 'mv:stroke-muted/50'}`}\n strokeWidth={1.5}\n strokeDasharray={dashed ? '4 3' : undefined}\n />\n ))}\n {paths.map(({ key, label, at }) =>\n label ? (\n <text\n key={`${key}:label`}\n x={at[0]}\n y={at[1]}\n textAnchor=\"middle\"\n dominantBaseline=\"central\"\n // The surface-coloured outline keeps the text legible over the line it labels.\n paintOrder=\"stroke\"\n strokeWidth={4}\n className=\"mv:fill-muted mv:stroke-surface mv:text-[10px]\"\n >\n {label}\n </text>\n ) : null,\n )}\n </svg>\n );\n}\n\n/** Cubic curve from the parent's trailing edge to the child's leading edge, and its midpoint. */\nfunction connector(a: DOMRect, b: DOMRect, origin: DOMRect, orientation: Orientation): [string, [number, number]] {\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}`, [(x1 + x2) / 2, my]];\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}`, [mx, (y1 + y2) / 2]];\n}\n\n/** Pixels between parallel straight connectors. */\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 connectors in\n * opposite directions between the same nodes still separate.\n */\nfunction line(a: DOMRect, b: DOMRect, origin: DOMRect, lane: number): [string, [number, number]] {\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}`, [(x1 + x2) / 2 + dx, (y1 + y2) / 2 + dy]];\n}\n","import { useCallback, useRef, useState } from 'react';\nimport type { SpaceGraph, SpaceNode } from 'structured-context/api';\nimport type { LayoutConfig, Region } from '../core/definition';\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 keys when several map views render in one document. */\n instanceId: string;\n onNodeSelect?: (node: SpaceNode) => void;\n /** The focus, for layouts arranged around one node; the layout keeps its own once the reader picks another. */\n focus?: SpaceNode['id'];\n onFocusChange?: (id: SpaceNode['id']) => void;\n};\n\n/** Connects a layout's occurrences to its `ConnectorOverlay`: `register` fills `elements` during commit, ahead of the overlay's layout effect. */\nexport function useOccurrenceElements() {\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 return { container, setContainer, elements, register };\n}\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 NodeComponent({ 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 { forceCollide, forceLink, forceManyBody, forceSimulation, forceX, forceY } from 'd3-force';\nimport { useMemo } from 'react';\nimport type { SpaceGraph } from 'structured-context/api';\nimport type { LayoutConfig } from '../core/definition';\nimport { assignLanes, type Connector, edgesWithin, isHierarchyEdge, occurrenceKey } from '../core/layouts/helpers';\nimport { ConnectorOverlay } from './ConnectorOverlay';\nimport { type LayoutProps, useOccurrenceElements } from './layout';\nimport { NodeComponent } from './NodeComponent';\n\n// Room each node needs. A card is a wide box; a shape is a marker with a label beside it.\nconst CARD_ROOM = { width: 230, height: 110 };\nconst SHAPE_ROOM = { width: 170, height: 40 };\nconst TICKS = 300;\nconst PADDING = 24;\n// Nodes across per node down in a level's band.\nconst BAND_ASPECT = 4;\n// Rows left clear between bands, for the connectors.\nconst BAND_GAP = 1.5;\nconst LOOSE_PER_ROW = 4;\n\n/**\n * The space graph as a network, positioned by a force simulation. The hierarchy gives it shape:\n * hierarchy edges hold their nodes close and each level settles below the one above, while\n * relationship edges pull weakly and are drawn dashed.\n */\nexport function GraphLayout({ graph, region, instanceId, onNodeSelect }: LayoutProps<LayoutConfig<'graph'>>) {\n const shape = region.nodes.style === 'shape';\n const plot = useMemo(\n () => settle(graph, region.id, region.layout.edgeFields, shape ? SHAPE_ROOM : CARD_ROOM),\n [graph, region.id, region.layout.edgeFields, shape],\n );\n\n const { container, setContainer, elements, register } = useOccurrenceElements();\n\n return (\n <div\n ref={setContainer}\n className=\"mv:relative mv:min-h-full mv:min-w-full\"\n style={{ width: plot.width, height: plot.height }}\n >\n {/* Before the nodes, so the opaque nodes cover the ends of the lines. */}\n <ConnectorOverlay\n connectors={plot.connectors}\n edges={region.edges}\n elements={elements}\n container={container}\n routing=\"straight\"\n />\n {plot.points.map(({ key, node, x, y }) => (\n <div\n key={key}\n data-occurrence={`${instanceId}${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: x, top: y }}\n >\n <div ref={register(key)}>\n <NodeComponent node={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\">{node.title}</span>\n )}\n </div>\n ))}\n </div>\n );\n}\n\n/**\n * Run the simulation to rest. d3-force seeds its own random source, so the same graph settles\n * the same way on every render.\n *\n * The simulation treats each node as a circle one row high; x is stretched afterwards to the\n * node's width, which packs wide nodes as boxes without a rectangular collision force.\n */\nfunction settle(graph: SpaceGraph, regionId: string, edgeFields: readonly string[], room: typeof CARD_ROOM) {\n const row = room.height;\n const edges = edgesWithin(graph)\n // An edge from a node to itself has nothing to connect.\n .filter((e) => e.parent !== e.child && (edgeFields.length === 0 || edgeFields.includes(e.field)))\n .map((e) => ({\n source: occurrenceKey(regionId, [e.parent]),\n target: occurrenceKey(regionId, [e.child]),\n field: e.field,\n hierarchy: isHierarchyEdge(e, graph.hierarchy),\n }));\n const connected = new Set(edges.flatMap((e) => [e.source, e.target]));\n\n const levelTypes = graph.hierarchy?.levels.map((level) => level.type) ?? [];\n const all = [...graph.nodes.values()].map((node) => ({\n key: occurrenceKey(regionId, [node.id]),\n node,\n // -1: not in the hierarchy.\n level: levelTypes.indexOf(node.resolvedType),\n x: 0,\n y: 0,\n }));\n const points = all.filter((p) => connected.has(p.key));\n const loose = all.filter((p) => !connected.has(p.key));\n\n // Each hierarchy level gets a band deep enough to hold its nodes a few rows high, below the\n // band of the level above.\n let bandTop = 0;\n const bandCentre = levelTypes.map((_, level) => {\n const count = points.filter((p) => p.level === level).length;\n const depth = Math.max(1, Math.ceil(Math.sqrt(count / BAND_ASPECT))) * row;\n const centre = bandTop + depth / 2;\n bandTop += depth + row * BAND_GAP;\n return centre;\n });\n\n forceSimulation(points)\n .force(\n 'link',\n forceLink<(typeof points)[number], (typeof edges)[number]>(edges.map((e) => ({ ...e })))\n .id((point) => point.key)\n .distance(row * (BAND_GAP + 1))\n .strength((e) => (e.hierarchy ? 0.2 : 0.05)),\n )\n .force(\n 'charge',\n forceManyBody()\n .strength(-row / 2)\n .distanceMax(row * 4),\n )\n .force('collide', forceCollide(row / 2))\n // Hierarchy nodes are drawn to the middle, which keeps the hierarchy together; any other node\n // is free to drift to the sides.\n .force(\n 'x',\n forceX<(typeof points)[number]>().strength((p) => (p.level < 0 ? 0.01 : 0.15)),\n )\n // A hierarchy node is held in its level's band; any other node goes where its edges pull it.\n .force(\n 'y',\n forceY<(typeof points)[number]>((p) => bandCentre[p.level] ?? 0).strength((p) => (p.level < 0 ? 0 : 0.6)),\n )\n .stop()\n .tick(TICKS);\n\n const stretch = room.width / row;\n const left = Math.min(0, ...points.map((p) => p.x));\n const top = Math.min(0, ...points.map((p) => p.y));\n for (const point of points) {\n point.x = (point.x - left) * stretch + room.width / 2 + PADDING;\n point.y = point.y - top + row / 2 + PADDING;\n }\n const width = Math.max(room.width * LOOSE_PER_ROW, ...points.map((p) => p.x + room.width / 2)) + PADDING;\n const bottom = Math.max(0, ...points.map((p) => p.y + row / 2));\n\n // Nodes with no edge shown have nothing to position them: they sit in a grid underneath.\n const perRow = Math.max(1, Math.floor((width - PADDING * 2) / room.width));\n loose.forEach((point, i) => {\n point.x = PADDING + room.width / 2 + (i % perRow) * room.width;\n point.y = bottom + row * 1.5 + Math.floor(i / perRow) * row;\n });\n\n const connectors: Connector[] = edges.map((e) => ({\n from: e.source,\n to: e.target,\n field: e.field,\n dashed: !e.hierarchy,\n }));\n assignLanes(connectors);\n return {\n points: all,\n connectors,\n width,\n height: Math.max(bottom, ...loose.map((p) => p.y + row / 2)) + PADDING,\n };\n}\n","import { useMemo } from 'react';\nimport type { SpaceNode } from 'structured-context/api';\nimport type { LayoutConfig, Orientation } from '../core/definition';\nimport { buildLandscape, type LandscapeGroup, type LandscapeOccurrence } from '../core/layouts/landscape/projection';\nimport type { LayoutProps } from './layout';\nimport { NodeComponent } from './NodeComponent';\n\ntype Level = LayoutConfig<'landscape'>['strips'][number]['group'][number];\n\n/**\n * Strips of nested containers following each strip's grouping levels; the last level is drawn as\n * nodes. Flexbox does the nesting and wrapping, and CSS grid lays out strips divided into cells.\n * Containment shows the grouping edges, so no connectors are drawn. PROTOTYPE: `edges.show` has no\n * effect here; other edges aren't drawn yet.\n */\nexport function LandscapeLayout({ graph, region, instanceId, onNodeSelect }: LayoutProps<LayoutConfig<'landscape'>>) {\n const { layout } = region;\n const landscape = useMemo(() => buildLandscape(graph, region.id, layout), [graph, region.id, layout]);\n\n const breadcrumb = (occurrence: LandscapeOccurrence, levels: readonly Level[]) => {\n const level = levels[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 /** The label of a container or a dimension's group: its node, or its field value. */\n const heading = (occurrence: LandscapeGroup | LandscapeOccurrence, levels: readonly Level[] = []) =>\n occurrence.item.kind === 'node' ? (\n <ContainerHeading\n node={occurrence.item.node}\n repeat={'repeatOf' in occurrence && occurrence.repeatOf !== undefined}\n onSelect={onNodeSelect}\n >\n {'level' in occurrence && breadcrumb(occurrence, levels)}\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\n const render = (\n occurrence: LandscapeOccurrence,\n direction: Orientation,\n levels: readonly Level[],\n ): React.ReactNode => {\n const repeat = occurrence.repeatOf !== undefined;\n const marker = { 'data-occurrence': `${instanceId}${occurrence.key}` };\n // A level is drawn as nodes when it is the strip's last.\n const isLeaf = (level: number) => level === levels.length - 1;\n\n if (occurrence.item.kind === 'node' && isLeaf(occurrence.level)) {\n return (\n <li key={occurrence.key} {...marker} className=\"mv:flex mv:flex-col mv:gap-0.5\">\n <NodeComponent node={occurrence.item.node} repeat={repeat} nodes={region.nodes} onSelect={onNodeSelect} />\n {breadcrumb(occurrence, levels)}\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 = isLeaf(occurrence.level + 1);\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 {heading(occurrence, levels)}\n <Items direction={holdsNodes ? 'wrap' : inner}>\n {occurrence.children.map((child) => render(child, inner, levels))}\n </Items>\n </li>\n );\n };\n\n const top = layout.orientation;\n const ungroupedClass = 'mv:flex mv:flex-col mv:gap-2 mv:rounded-lg mv:border mv:border-dashed mv:border-edge mv:p-2';\n const ungroupedItems = (ungrouped: LandscapeOccurrence[], levels: readonly Level[]) => (\n <>\n <span className=\"mv:text-xs mv:font-semibold mv:text-muted\">Ungrouped</span>\n <Items direction=\"wrap\">{ungrouped.map((o) => render(o, top, levels))}</Items>\n </>\n );\n\n const [only] = landscape.strips;\n // One strip with no dimension of either kind is plain nested containers, with no grid.\n const plain = only && landscape.strips.length === 1 && !landscape.dimension && !only.dimension;\n if (!plain) {\n const anyOwn = landscape.strips.some((strip) => strip.dimension);\n // A strip takes a position for each group of its own dimension (one without), and one for its ungrouped nodes.\n const sizes = landscape.strips.map(\n (strip) => (strip.dimension?.length ?? 1) + (strip.ungrouped.length > 0 ? 1 : 0),\n );\n const starts = sizes.map(\n (_, s) => 1 + (landscape.dimension ? 1 : 0) + sizes.slice(0, s).reduce((a, b) => a + b, 0),\n );\n const place = gridPlacement(top, {\n lead: anyOwn ? 2 : 1,\n dimensionSize: landscape.dimension?.length ?? 1,\n leadStrips: landscape.dimension ? 1 : 0,\n strips: sizes.reduce((a, b) => a + b, 0),\n });\n return (\n <div className=\"mv:w-max mv:min-w-full mv:p-4\">\n <div data-grid className=\"mv:grid mv:gap-2\" style={place.container}>\n {landscape.dimension?.map((group, i) => (\n <div\n key={group.key}\n data-dimension=\"layout\"\n {...{ 'data-occurrence': `${instanceId}${group.key}` }}\n className=\"mv:self-center mv:px-1\"\n style={place.heading(i)}\n >\n {heading(group)}\n </div>\n ))}\n {landscape.strips.map((strip, s) => {\n const levels = layout.strips[s]!.group;\n const start = starts[s]!;\n return (\n // biome-ignore lint/suspicious/noArrayIndexKey: strips are positional, fixed by the definition.\n <div key={s} className=\"mv:contents\" data-strip={s}>\n <div\n data-strip-name\n className=\"mv:self-center mv:px-1 mv:text-xs mv:font-semibold mv:uppercase mv:tracking-wide mv:text-muted\"\n style={place.name(start, Math.max(sizes[s]!, 1))}\n >\n {levelLabel(levels[0]!)}\n </div>\n {strip.dimension?.map((group, j) => (\n <div\n key={group.key}\n data-dimension=\"strip\"\n {...{ 'data-occurrence': `${instanceId}${group.key}` }}\n className=\"mv:self-center mv:px-1\"\n style={place.stripHeading(start + j)}\n >\n {heading(group)}\n </div>\n ))}\n {strip.cells.map((cell) => (\n <div\n key={cell.key}\n data-cell\n data-strip-cell={s}\n className=\"mv:min-h-12 mv:rounded-lg mv:border mv:border-edge mv:bg-surface mv:p-2\"\n style={place.cell(cell.at[0], start + cell.at[1])}\n >\n <Items direction=\"vertical\">{cell.children.map((child) => render(child, top, levels))}</Items>\n </div>\n ))}\n {strip.ungrouped.length > 0 && (\n <div\n data-ungrouped\n className={ungroupedClass}\n style={place.ungrouped(start + (strip.dimension?.length ?? 1))}\n >\n {ungroupedItems(strip.ungrouped, levels)}\n </div>\n )}\n </div>\n );\n })}\n </div>\n </div>\n );\n }\n\n const levels = layout.strips[0]!.group;\n return (\n <div className=\"mv:w-max mv:min-w-full mv:p-4\">\n <Items direction={levels.length === 1 ? 'wrap' : top}>\n {only.cells[0]!.children.map((group) => render(group, top, levels))}\n {only.ungrouped.length > 0 && <li className={ungroupedClass}>{ungroupedItems(only.ungrouped, levels)}</li>}\n </Items>\n </div>\n );\n}\n\nconst levelLabel = (level: Level) => ('type' in level ? level.type : level.field);\n\n/**\n * Where the grid's labels, headings and cells go. The only place that decides which way the layout\n * dimension runs: with `horizontal` its groups sit side by side, like top-level containers elsewhere\n * in this layout, and strips stack; with `vertical` its groups stack and strips sit side by side.\n * Along the layout dimension's axis, the leading positions hold the strip names and, if any strip\n * has its own dimension, that dimension's headings. Along the strips' axis, the first holds the\n * layout dimension's headings.\n * PROTOTYPE: track sizes are fixed guesses, headings scroll away with the grid, and a grid has no\n * connectors or highlights.\n */\nfunction gridPlacement(\n orientation: Orientation,\n shape: { lead: number; dimensionSize: number; leadStrips: number; strips: number },\n) {\n const dimensionAcross = orientation === 'horizontal';\n /** A start line, and how many lines it spans. */\n const lines = (start: number, span = 1) => (span === 1 ? start : `${start} / span ${span}`);\n /** `onDimension` runs along the layout dimension's axis, `onStrips` along the strips'. */\n const at = (onDimension: number, onStrips: number, dimensionSpan = 1, stripsSpan = 1) =>\n dimensionAcross\n ? { gridColumn: lines(onDimension, dimensionSpan), gridRow: lines(onStrips, stripsSpan) }\n : { gridColumn: lines(onStrips, stripsSpan), gridRow: lines(onDimension, dimensionSpan) };\n const groupsStart = shape.lead + 1;\n return {\n // Only the columns are given tracks; the rows size to their content.\n container: {\n gridTemplateColumns: dimensionAcross\n ? `${'max-content '.repeat(shape.lead)}repeat(${shape.dimensionSize}, minmax(9rem, 1fr))`\n : `${'max-content '.repeat(shape.leadStrips)}repeat(${shape.strips}, minmax(9rem, 1fr))`,\n },\n heading: (index: number) => at(groupsStart + index, 1),\n name: (start: number, span: number) => at(1, start, 1, span),\n stripHeading: (line: number) => at(2, line),\n cell: (index: number, line: number) => at(groupsStart + index, line),\n ungrouped: (line: number) => at(groupsStart, line, shape.dimensionSize),\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 { useMemo, useState } from 'react';\nimport type { SpaceNode } from 'structured-context/api';\nimport type { LayoutConfig } from '../core/definition';\nimport { buildNeighbourhood, type Neighbour } from '../core/layouts/neighbourhood/projection';\nimport { ConnectorOverlay } from './ConnectorOverlay';\nimport { type LayoutProps, useOccurrenceElements } from './layout';\nimport { NodeComponent } from './NodeComponent';\n\n// The most nodes across in the zones above and below, and down in the zones at the sides.\nconst ACROSS = 3;\nconst SIDE_ROWS = 6;\n\n/**\n * One node with its neighbours around it. Selecting a neighbour moves the focus to it; selecting\n * the focus is a regular node selection.\n */\nexport function NeighbourhoodLayout({\n graph,\n region,\n instanceId,\n onNodeSelect,\n focus,\n onFocusChange,\n}: LayoutProps<LayoutConfig<'neighbourhood'>>) {\n const [picked, setPicked] = useState<{ from: SpaceNode['id'] | undefined; id: SpaceNode['id'] }>();\n // A focus the host sets later wins over the reader's earlier pick.\n const focusId = picked && picked.from === focus ? picked.id : focus;\n const neighbourhood = useMemo(\n () => buildNeighbourhood(graph, region.id, region.layout, focusId),\n [graph, region.id, region.layout, focusId],\n );\n\n const { container, setContainer, elements, register } = useOccurrenceElements();\n\n if (!neighbourhood.focus) return null;\n const current = neighbourhood.focus.node;\n const select = (node: SpaceNode) => {\n if (node.id === current.id) return onNodeSelect?.(node);\n setPicked({ from: focus, id: node.id });\n onFocusChange?.(node.id);\n };\n const cell = (item: { key: string; node: SpaceNode }) => (\n <div\n key={item.key}\n ref={register(item.key)}\n className=\"mv:relative mv:z-10\"\n data-occurrence={`${instanceId}${item.key}`}\n >\n <NodeComponent node={item.node} repeat={false} nodes={region.nodes} onSelect={select} />\n </div>\n );\n // A zone wraps into a few rows or columns, so a large one doesn't push the focus off screen.\n const zone = (items: Neighbour[], columns: number, className = '') =>\n items.length > 0 && (\n <div\n className={`mv:grid mv:items-center mv:gap-3 ${className}`}\n style={{ gridTemplateColumns: `repeat(${Math.min(items.length, columns)}, max-content)` }}\n >\n {items.map(cell)}\n </div>\n );\n const side = (items: Neighbour[]) => Math.ceil(items.length / SIDE_ROWS);\n const { above, below, left, right } = neighbourhood.roles;\n const { siblings } = neighbourhood;\n\n return (\n <div\n ref={setContainer}\n className=\"mv:relative mv:grid mv:w-max mv:min-w-full mv:grid-cols-[auto_auto_auto] mv:items-center mv:justify-center mv:gap-x-24 mv:gap-y-16 mv:p-6\"\n >\n <div className=\"mv:col-start-2 mv:justify-self-center\">{zone(above, ACROSS)}</div>\n <div className=\"mv:col-start-1 mv:justify-self-end\">{zone(left, side(left))}</div>\n <div className=\"mv:col-start-2 mv:justify-self-center mv:rounded-md mv:ring-2 mv:ring-accent\">\n {cell(neighbourhood.focus)}\n </div>\n <div className=\"mv:flex mv:items-center mv:gap-24\">\n {zone(right, side(right))}\n {zone(siblings, side(siblings), 'mv:opacity-70')}\n </div>\n <div className=\"mv:col-start-2 mv:justify-self-center\">{zone(below, ACROSS)}</div>\n <ConnectorOverlay\n connectors={neighbourhood.connectors}\n edges={region.edges}\n elements={elements}\n container={container}\n routing=\"straight\"\n />\n </div>\n );\n}\n","import { useMemo } from 'react';\nimport type { LayoutConfig, Orientation } from '../core/definition';\nimport { buildTree, type TreeOccurrence, treeConnectors } from '../core/layouts/tree/projection';\nimport { ConnectorOverlay } from './ConnectorOverlay';\nimport { type LayoutProps, useOccurrenceElements } from './layout';\nimport { NodeComponent } from './NodeComponent';\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<LayoutConfig<'tree'>>) {\n const { orientation, dag } = region.layout;\n const tree = useMemo(() => buildTree(graph, region.id, dag), [graph, region.id, dag]);\n const connectors = useMemo(() => treeConnectors(tree), [tree]);\n\n const { container, setContainer, elements, register } = useOccurrenceElements();\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 <NodeComponent\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 if (!graph.hierarchy) return <p className=\"mv:p-4 mv:text-muted\">This schema has no hierarchy to draw as a tree.</p>;\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 <ConnectorOverlay\n connectors={connectors}\n edges={region.edges}\n elements={elements}\n container={container}\n routing={orientation}\n />\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 { useMemo } from 'react';\nimport type { LayoutConfig } from '../core/definition';\nimport { buildXYPlot } from '../core/layouts/xy/projection';\nimport { ConnectorOverlay } from './ConnectorOverlay';\nimport { type LayoutProps, useOccurrenceElements } from './layout';\nimport { NodeComponent } from './NodeComponent';\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<LayoutConfig<'xy'>>) {\n const { layout } = region;\n const plot = useMemo(() => buildXYPlot(graph, region.id, layout), [graph, region.id, layout]);\n const shape = region.nodes.style === 'shape';\n\n const { container, setContainer, elements, register } = useOccurrenceElements();\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 <ConnectorOverlay\n connectors={plot.connectors}\n edges={region.edges}\n elements={elements}\n container={container}\n routing=\"straight\"\n />\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 <NodeComponent 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 <NodeComponent 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: LayoutConfig<'xy'>['x'];\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 { type ComponentType, useId, useMemo } from 'react';\nimport type { SpaceGraph, SpaceNode } from 'structured-context/api';\nimport { type AnnotationIndex, filterAnnotations } from '../core/annotations';\nimport { type LayoutConfig, type MapViewDefinition, type ParameterValues, resolveRegions } from '../core/definition';\nimport { AnnotationsContext } from './annotations-context';\nimport { GraphLayout } from './GraphLayout';\nimport { LandscapeLayout } from './LandscapeLayout';\nimport type { LayoutProps } from './layout';\nimport { NeighbourhoodLayout } from './NeighbourhoodLayout';\nimport { 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 focus?: LayoutProps['focus'];\n onFocusChange?: LayoutProps['onFocusChange'];\n};\n\nconst EMPTY: AnnotationIndex = new Map();\n\nconst LAYOUTS: { [T in LayoutConfig['type']]: ComponentType<LayoutProps<LayoutConfig<T>>> } = {\n tree: TreeLayout,\n landscape: LandscapeLayout,\n xy: XYLayout,\n neighbourhood: NeighbourhoodLayout,\n graph: GraphLayout,\n};\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, focus, onFocusChange }: 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 // TypeScript can't relate the region's layout type to the component it indexes.\n const Layout = LAYOUTS[region.layout.type] as ComponentType<LayoutProps>;\n\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\">\n <Layout\n graph={graph}\n region={region}\n instanceId={instanceId}\n onNodeSelect={onNodeSelect}\n focus={focus}\n onFocusChange={onFocusChange}\n />\n </div>\n </AnnotationsContext.Provider>\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;;;;;;;;;;;ACsBjE,SAAgB,iBAAiB,EAAE,YAAY,OAAO,UAAU,WAAW,WAAkB;CAC3F,MAAM,CAAC,OAAO,YAAY,SAAkB,CAAC,CAAC;CAE9C,sBAAsB;EACpB,IAAI,CAAC,aAAa,CAAC,MAAM,MAAM;EAE/B,MAAM,gBAAgB;GACpB,MAAM,SAAS,UAAU,sBAAsB;GAC/C,MAAM,QAAiB,CAAC;GACxB,KAAK,MAAM,EAAE,MAAM,IAAI,OAAO,OAAO,GAAG,SAAS,WAAW,YAAY;IACtE,MAAM,IAAI,SAAS,IAAI,IAAI,CAAC,EAAE,sBAAsB;IACpD,MAAM,IAAI,SAAS,IAAI,EAAE,CAAC,EAAE,sBAAsB;IAClD,IAAI,CAAC,KAAK,CAAC,GAAG;IACd,MAAM,CAAC,GAAG,MAAM,YAAY,aAAa,KAAK,GAAG,GAAG,QAAQ,IAAI,IAAI,UAAU,GAAG,GAAG,QAAQ,OAAO;IACnG,MAAM,KAAK;KAAE,KAAK,GAAG,KAAK,GAAG,KAAK,SAAS;KAAM;KAAG;KAAQ,OAAO,MAAM,SAAS,QAAQ,KAAA;KAAW;IAAG,CAAC;GAC3G;GACA,SAAS,KAAK;EAChB;EAEA,QAAQ;EACR,MAAM,WAAW,IAA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+ z-index: 10;
53
+ }
54
+ .mv\:col-start-1 {
55
+ grid-column-start: 1;
56
+ }
57
+ .mv\:col-start-2 {
58
+ grid-column-start: 2;
59
+ }
51
60
  .mv\:float-left {
52
61
  float: left;
53
62
  }
@@ -66,6 +75,9 @@
66
75
  .mv\:block {
67
76
  display: block;
68
77
  }
78
+ .mv\:contents {
79
+ display: contents;
80
+ }
69
81
  .mv\:flex {
70
82
  display: flex;
71
83
  }
@@ -85,9 +97,15 @@
85
97
  .mv\:min-h-0 {
86
98
  min-height: 0px;
87
99
  }
100
+ .mv\:min-h-12 {
101
+ min-height: calc(var(--mv-spacing) * 12);
102
+ }
88
103
  .mv\:min-h-\[28rem\] {
89
104
  min-height: 28rem;
90
105
  }
106
+ .mv\:min-h-full {
107
+ min-height: 100%;
108
+ }
91
109
  .mv\:w-44 {
92
110
  width: calc(var(--mv-spacing) * 44);
93
111
  }
@@ -126,6 +144,14 @@
126
144
  --tw-translate-x: calc(var(--mv-spacing) * -3);
127
145
  translate: var(--tw-translate-x) var(--tw-translate-y);
128
146
  }
147
+ .mv\:-translate-y-1\/2 {
148
+ --tw-translate-y: calc(calc(1 / 2 * 100%) * -1);
149
+ translate: var(--tw-translate-x) var(--tw-translate-y);
150
+ }
151
+ .mv\:-translate-y-3 {
152
+ --tw-translate-y: calc(var(--mv-spacing) * -3);
153
+ translate: var(--tw-translate-x) var(--tw-translate-y);
154
+ }
129
155
  .mv\:translate-y-1\/2 {
130
156
  --tw-translate-y: calc(1 / 2 * 100%);
131
157
  translate: var(--tw-translate-x) var(--tw-translate-y);
@@ -146,6 +172,9 @@
146
172
  .mv\:grid-cols-\[auto_1fr\] {
147
173
  grid-template-columns: auto 1fr;
148
174
  }
175
+ .mv\:grid-cols-\[auto_auto_auto\] {
176
+ grid-template-columns: auto auto auto;
177
+ }
149
178
  .mv\:grid-rows-\[1fr_auto\] {
150
179
  grid-template-rows: 1fr auto;
151
180
  }
@@ -194,12 +223,30 @@
194
223
  .mv\:gap-4 {
195
224
  gap: calc(var(--mv-spacing) * 4);
196
225
  }
226
+ .mv\:gap-24 {
227
+ gap: calc(var(--mv-spacing) * 24);
228
+ }
197
229
  .mv\:gap-x-4 {
198
230
  column-gap: calc(var(--mv-spacing) * 4);
199
231
  }
232
+ .mv\:gap-x-24 {
233
+ column-gap: calc(var(--mv-spacing) * 24);
234
+ }
200
235
  .mv\:gap-y-2 {
201
236
  row-gap: calc(var(--mv-spacing) * 2);
202
237
  }
238
+ .mv\:gap-y-16 {
239
+ row-gap: calc(var(--mv-spacing) * 16);
240
+ }
241
+ .mv\:self-center {
242
+ align-self: center;
243
+ }
244
+ .mv\:justify-self-center {
245
+ justify-self: center;
246
+ }
247
+ .mv\:justify-self-end {
248
+ justify-self: flex-end;
249
+ }
203
250
  .mv\:truncate {
204
251
  overflow: hidden;
205
252
  text-overflow: ellipsis;
@@ -277,6 +324,9 @@
277
324
  .mv\:bg-warning {
278
325
  background-color: var(--mv-color-warning);
279
326
  }
327
+ .mv\:fill-muted {
328
+ fill: var(--mv-color-muted);
329
+ }
280
330
  .mv\:fill-none {
281
331
  fill: none;
282
332
  }
@@ -292,6 +342,9 @@
292
342
  stroke: color-mix(in oklab, var(--mv-color-muted) 50%, transparent);
293
343
  }
294
344
  }
345
+ .mv\:stroke-surface {
346
+ stroke: var(--mv-color-surface);
347
+ }
295
348
  .mv\:p-0 {
296
349
  padding: 0px;
297
350
  }
@@ -301,6 +354,9 @@
301
354
  .mv\:p-4 {
302
355
  padding: calc(var(--mv-spacing) * 4);
303
356
  }
357
+ .mv\:p-6 {
358
+ padding: calc(var(--mv-spacing) * 6);
359
+ }
304
360
  .mv\:px-0\.5 {
305
361
  padding-inline: calc(var(--mv-spacing) * 0.5);
306
362
  }
@@ -342,6 +398,9 @@
342
398
  .mv\:text-\[0\.65rem\] {
343
399
  font-size: 0.65rem;
344
400
  }
401
+ .mv\:text-\[10px\] {
402
+ font-size: 10px;
403
+ }
345
404
  .mv\:leading-snug {
346
405
  --tw-leading: var(--mv-leading-snug);
347
406
  line-height: var(--mv-leading-snug);
@@ -373,6 +432,9 @@
373
432
  .mv\:uppercase {
374
433
  text-transform: uppercase;
375
434
  }
435
+ .mv\:opacity-70 {
436
+ opacity: 70%;
437
+ }
376
438
  .mv\:opacity-75 {
377
439
  opacity: 75%;
378
440
  }
@@ -380,6 +442,13 @@
380
442
  --tw-shadow: 0 1px 3px 0 var(--tw-shadow-color, rgb(0 0 0 / 0.1)), 0 1px 2px -1px var(--tw-shadow-color, rgb(0 0 0 / 0.1));
381
443
  box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
382
444
  }
445
+ .mv\:ring-2 {
446
+ --tw-ring-shadow: var(--tw-ring-inset,) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color, currentcolor);
447
+ box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
448
+ }
449
+ .mv\:ring-accent {
450
+ --tw-ring-color: var(--mv-color-accent);
451
+ }
383
452
  .mv\:\[writing-mode\:vertical-rl\] {
384
453
  writing-mode: vertical-rl;
385
454
  }
@@ -598,4 +667,4 @@ body { background: var(--viewer-ground); color: var(--mv-color-ink); }
598
667
  </style>
599
668
  <div id="root"></div>
600
669
  <script type="importmap">{"imports":{"structured-context/browser":"https://cdn.jsdelivr.net/npm/structured-context@0.24.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.6.1/dist/artifact.js"></script>
670
+ <script type="module" src="https://cdn.jsdelivr.net/npm/structured-context-map-views@0.7.0/dist/artifact.js"></script>
package/dist/artifact.js CHANGED
@@ -1,5 +1,5 @@
1
- import { a as annotationsFrom } from "./projection-C-dATsdO.js";
2
- import { s as MapView, t as ParameterControls } from "./ParameterControls-A1HJWyt9.js";
1
+ import { u as annotationsFrom } from "./projection-DKNLziP0.js";
2
+ import { s as MapView, t as ParameterControls } from "./ParameterControls-Be05VST0.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";
@@ -1 +1 @@
1
- {"version":3,"file":"artifact.js","names":["_Fragment"],"sources":["../src/viewer/Viewer.tsx","../src/artifact/load.ts","../src/artifact/main.tsx"],"sourcesContent":["import { useEffect, useMemo, useRef, useState } from 'react';\nimport { type SpaceGraph, type SpaceNode, spaceGraphFrom } from 'structured-context/browser';\nimport { annotationsFrom } from '../core/annotations';\nimport type { MapViewDefinition, ParameterValues } from '../core/definition';\nimport type { SpaceSnapshot } from '../core/snapshot';\nimport { MapView } from '../layouts/MapView';\nimport { ParameterControls } from '../layouts/ParameterControls';\n\n/**\n * A page-filling viewer for one or more space snapshots: a space and map view switcher, the parameter\n * controls, the map view, and a side panel with the selected node's fields and validation results. Hosts\n * supply the snapshots and anything specific to where the page is shown. See docs/architecture.md.\n */\n\nexport type ViewerProps = {\n spaces: SpaceSnapshot[];\n /** Accessible name for each card, for hosts whose surroundings read it. Cards keep their default name without it. */\n cardLabel?: (node: SpaceNode, graph: SpaceGraph, definition: MapViewDefinition) => string;\n};\n\nexport function Viewer({ spaces, cardLabel }: ViewerProps) {\n const [spaceName, setSpaceName] = useState(spaces[0]!.space);\n const space = spaces.find((s) => s.space === spaceName)!;\n const [viewId, setViewId] = useState(space.definitions[0]?.id);\n const definition = space.definitions.find((d) => d.id === viewId) ?? space.definitions[0];\n const [values, setValues] = useState<ParameterValues>({});\n const [selectedId, setSelectedId] = useState<string>();\n\n const graph = useMemo(() => spaceGraphFrom(space.graph), [space]);\n const annotated = useMemo(() => annotationsFrom(space.validation, graph), [space, graph]);\n const mapRef = useCardLabels(graph, definition, cardLabel);\n\n if (!definition) return <p className=\"viewer-message\">No map views apply to the schema of \"{space.space}\".</p>;\n const selected = selectedId ? graph.nodes.get(selectedId as never) : undefined;\n const results = selected ? (annotated.annotations.get(selected.id as never) ?? []) : [];\n\n return (\n <div className=\"viewer-root\">\n <header className=\"viewer-bar\">\n {spaces.length > 1 && (\n <select\n aria-label=\"Space\"\n value={spaceName}\n onChange={(e) => {\n const next = spaces.find((s) => s.space === e.target.value)!;\n setSpaceName(next.space);\n setViewId(next.definitions[0]?.id);\n setValues({});\n setSelectedId(undefined);\n }}\n >\n {spaces.map((s) => (\n <option key={s.space} value={s.space}>\n {s.space}\n </option>\n ))}\n </select>\n )}\n {space.definitions.length > 1 && (\n <select\n aria-label=\"Map view\"\n value={definition.id}\n onChange={(e) => {\n setViewId(e.target.value);\n setValues({});\n }}\n >\n {space.definitions.map((d) => (\n <option key={d.id} value={d.id}>\n {d.title}\n </option>\n ))}\n </select>\n )}\n <ParameterControls\n definition={definition}\n values={values}\n onChange={(name, value) => setValues((prev) => ({ ...prev, [name]: value }))}\n />\n </header>\n <div className=\"viewer-body\">\n <div className=\"viewer-map\" ref={mapRef}>\n <MapView\n definition={definition}\n graph={graph}\n values={values}\n annotations={annotated.annotations}\n onNodeSelect={(node) => setSelectedId(node.id)}\n />\n </div>\n {(selected || annotated.unattached.length > 0) && (\n <aside className=\"viewer-panel\" aria-label=\"Validation results\">\n {selected && (\n <section>\n <button\n type=\"button\"\n className=\"viewer-close\"\n aria-label=\"Close\"\n onClick={() => setSelectedId(undefined)}\n >\n ×\n </button>\n <p className=\"viewer-type\">{selected.resolvedType}</p>\n <h2>{selected.title}</h2>\n {results.length > 0 && (\n <>\n <h3>Validation</h3>\n <Results items={results} />\n </>\n )}\n <Fields data={selected.schemaData} />\n {selected.content && (\n <>\n <h3>Content</h3>\n <p className=\"viewer-content\">{selected.content}</p>\n </>\n )}\n {selected.source && <p className=\"viewer-muted\">{selected.source.file}</p>}\n </section>\n )}\n {annotated.unattached.length > 0 && (\n <section>\n <h3>Not on a node ({annotated.unattached.length})</h3>\n <Results items={annotated.unattached} />\n </section>\n )}\n </aside>\n )}\n </div>\n </div>\n );\n}\n\nconst SKIPPED_FIELDS = new Set(['title', 'type', 'content']);\nconst isEmpty = (v: unknown) => v === undefined || v === null || v === '' || (Array.isArray(v) && v.length === 0);\nconst asText = (v: unknown): string =>\n Array.isArray(v) ? v.map(asText).join(', ') : v !== null && typeof v === 'object' ? JSON.stringify(v) : String(v);\n\n/** The node's fields as a list; the title, type and body are shown elsewhere. */\nfunction Fields({ data }: { data: Record<string, unknown> }) {\n const fields = Object.entries(data).filter(([name, value]) => !SKIPPED_FIELDS.has(name) && !isEmpty(value));\n if (fields.length === 0) return null;\n return (\n <>\n <h3>Fields</h3>\n <dl className=\"viewer-fields\">\n {fields.map(([name, value]) => (\n <div key={name}>\n <dt>{name}</dt>\n <dd>{asText(value)}</dd>\n </div>\n ))}\n </dl>\n </>\n );\n}\n\nfunction Results({\n items,\n}: {\n items: readonly { severity: string; source: string; ruleId?: string; message: string; nodeId?: string }[];\n}) {\n return (\n <ul className=\"viewer-results\">\n {items.map((a, i) => (\n // biome-ignore lint/suspicious/noArrayIndexKey: a static list with no stable identity beyond position.\n <li key={i}>\n <span className={`viewer-severity viewer-${a.severity}`}>{a.severity}</span>{' '}\n <span className=\"viewer-muted\">{a.ruleId ? `${a.source} · ${a.ruleId}` : a.source}</span>\n {a.nodeId && <span className=\"viewer-muted\"> · {a.nodeId}</span>}\n <div>{a.message}</div>\n </li>\n ))}\n </ul>\n );\n}\n\n/** Names each card with `cardLabel`, again whenever the map view redraws its cards. */\nfunction useCardLabels(\n graph: SpaceGraph,\n definition: MapViewDefinition | undefined,\n cardLabel: ViewerProps['cardLabel'],\n) {\n const ref = useRef<HTMLDivElement>(null);\n useEffect(() => {\n const root = ref.current;\n if (!root || !definition || !cardLabel) return;\n const stamp = () => {\n for (const card of root.querySelectorAll<HTMLElement>('[data-node-id]')) {\n const node = graph.nodes.get(card.dataset.nodeId as never);\n if (node) card.setAttribute('aria-label', cardLabel(node, graph, definition));\n }\n };\n stamp();\n const observer = new MutationObserver(stamp);\n observer.observe(root, { childList: true, subtree: true });\n return () => observer.disconnect();\n }, [graph, definition, cardLabel]);\n return ref;\n}\n","import type { SpaceSnapshot } from '../core/snapshot';\n\nconst SPACES = 'spaces';\nconst TIMEOUT_MS = 10_000;\n\ntype Db = {\n collection(path: string): { get(): Promise<{ docs: { id: string; data(): Record<string, unknown> | undefined }[] }> };\n};\n\n/**\n * Every space written to the artifact's `spaces` collection: the `export` command's document, keyed by space\n * name, with its parts as JSON strings. Rejects with a message fit to show the viewer.\n */\nexport async function loadSpaces(): Promise<SpaceSnapshot[]> {\n const claude = (window as unknown as { claude?: { use(name: string): Promise<unknown> } }).claude;\n const db = (claude ? await claude.use('db') : null) as Db | null;\n if (!db) throw new Error('This page needs the artifact database, which is not available to this viewer.');\n\n let timer: ReturnType<typeof setTimeout> | undefined;\n const timeout = new Promise<never>((_, reject) => {\n timer = setTimeout(() => reject(new Error('Reading the artifact database timed out.')), TIMEOUT_MS);\n });\n const snapshot = await Promise.race([db.collection(SPACES).get(), timeout]).finally(() => clearTimeout(timer));\n const spaces = snapshot.docs.flatMap((doc) => {\n const data = doc.data();\n return data ? [toSpace(doc.id, data)] : [];\n });\n if (spaces.length === 0)\n throw new Error(`Nothing to show yet: no space has been written to \"${SPACES}\" in the artifact database.`);\n return spaces;\n}\n\nfunction toSpace(space: string, data: Record<string, unknown>): SpaceSnapshot {\n const json = (field: string) => {\n const value = data[field];\n if (typeof value !== 'string') throw new Error(`Space \"${space}\": missing \"${field}\" in the artifact database.`);\n return JSON.parse(value);\n };\n return {\n space,\n schemaId: typeof data.schemaId === 'string' ? data.schemaId : undefined,\n graph: json('graph'),\n validation: json('validation'),\n definitions: json('definitions'),\n };\n}\n","import { useEffect, useState } from 'react';\nimport { createRoot } from 'react-dom/client';\nimport type { SpaceGraph, SpaceNode } from 'structured-context/browser';\nimport type { MapViewDefinition } from '../core/definition';\nimport type { SpaceSnapshot } from '../core/snapshot';\nimport { Viewer } from '../viewer/Viewer';\nimport { loadSpaces } from './load';\n\n/**\n * The host for a Claude artifact: shows the spaces the publishing agent wrote to the artifact's db in the\n * viewer, and names cards for the artifact's comment mode. It ships as `dist/artifact.js`;\n * `dist/artifact.html` is the page that loads it. See docs/architecture.md.\n */\n\ntype State =\n | { status: 'loading' }\n | { status: 'error'; message: string }\n | { status: 'ready'; spaces: SpaceSnapshot[] };\n\nfunction App() {\n const [state, setState] = useState<State>({ status: 'loading' });\n useEffect(() => {\n loadSpaces().then(\n (spaces) => setState({ status: 'ready', spaces }),\n (err) => setState({ status: 'error', message: err instanceof Error ? err.message : String(err) }),\n );\n }, []);\n if (state.status === 'loading') return <p className=\"viewer-message\">Loading from the artifact database…</p>;\n if (state.status === 'error') return <p className=\"viewer-message\">{state.message}</p>;\n return <Viewer spaces={state.spaces} cardLabel={commentLabel} />;\n}\n\nconst positionsByGraph = new WeakMap<SpaceGraph, Map<string, number>>();\n\n/**\n * The comment mode reads a comment's location from the element's accessible name, cut at about 45\n * characters. Node ids are long (a file and heading), so the name leads with the node's position in the\n * stored graph, then its title and the view: `[<index>] <title> · <view>`. An agent reading the comment\n * takes `graph.nodes[<index>]` from the db and checks the title.\n */\nfunction commentLabel(node: SpaceNode, graph: SpaceGraph, definition: MapViewDefinition): string {\n let positions = positionsByGraph.get(graph);\n if (!positions) {\n positions = new Map([...graph.nodes.keys()].map((id, index) => [id as string, index]));\n positionsByGraph.set(graph, positions);\n }\n const view = definition.id.slice(definition.id.lastIndexOf('/') + 1);\n return `[${positions.get(node.id as string)}] ${node.title} · ${view}`;\n}\n\ncreateRoot(document.getElementById('root')!).render(<App />);\n"],"mappings":";;;;;;;AAoBA,SAAgB,OAAO,EAAE,QAAQ,aAA0B;CACzD,MAAM,CAAC,WAAW,gBAAgB,SAAS,OAAO,EAAE,CAAE,KAAK;CAC3D,MAAM,QAAQ,OAAO,MAAM,MAAM,EAAE,UAAU,SAAS;CACtD,MAAM,CAAC,QAAQ,aAAa,SAAS,MAAM,YAAY,EAAE,EAAE,EAAE;CAC7D,MAAM,aAAa,MAAM,YAAY,MAAM,MAAM,EAAE,OAAO,MAAM,KAAK,MAAM,YAAY;CACvF,MAAM,CAAC,QAAQ,aAAa,SAA0B,CAAC,CAAC;CACxD,MAAM,CAAC,YAAY,iBAAiB,SAAiB;CAErD,MAAM,QAAQ,cAAc,eAAe,MAAM,KAAK,GAAG,CAAC,KAAK,CAAC;CAChE,MAAM,YAAY,cAAc,gBAAgB,MAAM,YAAY,KAAK,GAAG,CAAC,OAAO,KAAK,CAAC;CACxF,MAAM,SAAS,cAAc,OAAO,YAAY,SAAS;CAEzD,IAAI,CAAC,YAAY,OAAO,qBAAC,KAAD;EAAG,WAAU;EAAb,UAAA;GAA8B;GAAsC,MAAM;GAAM;EAAK;;CAC7G,MAAM,WAAW,aAAa,MAAM,MAAM,IAAI,UAAmB,IAAI,KAAA;CACrE,MAAM,UAAU,WAAY,UAAU,YAAY,IAAI,SAAS,EAAW,KAAK,CAAC,IAAK,CAAC;CAEtF,OACE,qBAAC,OAAD;EAAK,WAAU;EAAf,UAAA,CACE,qBAAC,UAAD;GAAQ,WAAU;GAAlB,UAAA;IACG,OAAO,SAAS,KACf,oBAAC,UAAD;KACE,cAAW;KACX,OAAO;KACP,WAAW,MAAM;MACf,MAAM,OAAO,OAAO,MAAM,MAAM,EAAE,UAAU,EAAE,OAAO,KAAK;MAC1D,aAAa,KAAK,K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AAU,CAAC;CAC/D,gBAAgB;EACd,WAAW,CAAC,CAAC,MACV,WAAW,SAAS;GAAE,QAAQ;GAAS;EAAO,CAAC,IAC/C,QAAQ,SAAS;GAAE,QAAQ;GAAS,SAAS,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;EAAE,CAAC,CAClG;CACF,GAAG,CAAC,CAAC;CACL,IAAI,MAAM,WAAW,WAAW,OAAO,oBAAC,KAAD;EAAG,WAAU;EAAiB,UAAA;CAAsC,CAAA;CAC3G,IAAI,MAAM,WAAW,SAAS,OAAO,oBAAC,KAAD;EAAG,WAAU;EAAkB,UAAA,MAAM;CAAW,CAAA;CACrF,OAAO,oBAAC,QAAD;EAAQ,QAAQ,MAAM;EAAQ,WAAW;CAAe,CAAA;AACjE;AAEA,IAAM,mCAAmB,IAAI,QAAyC;;;;;;;AAQtE,SAAS,aAAa,MAAiB,OAAmB,YAAuC;CAC/F,IAAI,YAAY,iBAAiB,IAAI,KAAK;CAC1C,IAAI,CAAC,WAAW;EACd,YAAY,IAAI,IAAI,CAAC,GAAG,MAAM,MAAM,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI,UAAU,CAAC,IAAc,KAAK,CAAC,CAAC;EACrF,iBAAiB,IAAI,OAAO,SAAS;CACvC;CACA,MAAM,OAAO,WAAW,GAAG,MAAM,WAAW,GAAG,YAAY,GAAG,IAAI,CAAC;CACnE,OAAO,IAAI,UAAU,IAAI,KAAK,EAAY,EAAE,IAAI,KAAK,MAAM,KAAK;AAClE;AAEA,WAAW,SAAS,eAAe,MAAM,CAAE,CAAC,CAAC,OAAO,oBAAC,KAAD,CAAM,CAAA,CAAC"}
1
+ {"version":3,"file":"artifact.js","names":["_Fragment"],"sources":["../src/viewer/Viewer.tsx","../src/artifact/load.ts","../src/artifact/main.tsx"],"sourcesContent":["import { useEffect, useMemo, useRef, useState } from 'react';\nimport { type SpaceGraph, type SpaceNode, spaceGraphFrom } from 'structured-context/browser';\nimport { MapView } from '../components/MapView';\nimport { ParameterControls } from '../components/ParameterControls';\nimport { annotationsFrom } from '../core/annotations';\nimport type { MapViewDefinition, ParameterValues } from '../core/definition';\nimport type { SpaceSnapshot } from '../core/space-snapshot';\n\n/**\n * A page-filling viewer for one or more space snapshots. Hosts supply the snapshots and anything\n * specific to where the page is shown. See docs/architecture.md.\n */\n\ntype ViewerProps = {\n spaces: SpaceSnapshot[];\n /** Accessible name for each card, for hosts whose surroundings read it. Cards keep their default name without it. */\n cardLabel?: (node: SpaceNode, graph: SpaceGraph, definition: MapViewDefinition) => string;\n};\n\nexport function Viewer({ spaces, cardLabel }: ViewerProps) {\n const [spaceName, setSpaceName] = useState(spaces[0]!.space);\n const space = spaces.find((s) => s.space === spaceName)!;\n const [viewId, setViewId] = useState(space.definitions[0]?.id);\n const definition = space.definitions.find((d) => d.id === viewId) ?? space.definitions[0];\n const [values, setValues] = useState<ParameterValues>({});\n const [selectedId, setSelectedId] = useState<SpaceNode['id']>();\n\n const graph = useMemo(() => spaceGraphFrom(space.graph), [space]);\n const annotated = useMemo(() => annotationsFrom(space.validation, graph), [space, graph]);\n const mapRef = useCardLabels(graph, definition, cardLabel);\n\n if (!definition) return <p className=\"viewer-message\">No map views apply to the schema of \"{space.space}\".</p>;\n const selected = selectedId ? graph.nodes.get(selectedId) : undefined;\n const results = selected ? (annotated.annotations.get(selected.id) ?? []) : [];\n\n return (\n <div className=\"viewer-root\">\n <header className=\"viewer-bar\">\n {spaces.length > 1 && (\n <select\n aria-label=\"Space\"\n value={spaceName}\n onChange={(e) => {\n const next = spaces.find((s) => s.space === e.target.value)!;\n setSpaceName(next.space);\n setViewId(next.definitions[0]?.id);\n setValues({});\n setSelectedId(undefined);\n }}\n >\n {spaces.map((s) => (\n <option key={s.space} value={s.space}>\n {s.space}\n </option>\n ))}\n </select>\n )}\n {space.definitions.length > 1 && (\n <select\n aria-label=\"Map view\"\n value={definition.id}\n onChange={(e) => {\n setViewId(e.target.value);\n setValues({});\n }}\n >\n {space.definitions.map((d) => (\n <option key={d.id} value={d.id}>\n {d.title}\n </option>\n ))}\n </select>\n )}\n <ParameterControls\n definition={definition}\n values={values}\n onChange={(name, value) => setValues((prev) => ({ ...prev, [name]: value }))}\n />\n </header>\n <div className=\"viewer-body\">\n <div className=\"viewer-map\" ref={mapRef}>\n <MapView\n definition={definition}\n graph={graph}\n values={values}\n annotations={annotated.annotations}\n onNodeSelect={(node) => setSelectedId(node.id)}\n />\n </div>\n {(selected || annotated.unattached.length > 0) && (\n <aside className=\"viewer-panel\" aria-label=\"Validation results\">\n {selected && (\n <section>\n <button\n type=\"button\"\n className=\"viewer-close\"\n aria-label=\"Close\"\n onClick={() => setSelectedId(undefined)}\n >\n ×\n </button>\n <p className=\"viewer-type\">{selected.resolvedType}</p>\n <h2>{selected.title}</h2>\n {results.length > 0 && (\n <>\n <h3>Validation</h3>\n <Results items={results} />\n </>\n )}\n <Fields data={selected.schemaData} />\n {selected.content && (\n <>\n <h3>Content</h3>\n <p className=\"viewer-content\">{selected.content}</p>\n </>\n )}\n {selected.source && <p className=\"viewer-muted\">{selected.source.file}</p>}\n </section>\n )}\n {annotated.unattached.length > 0 && (\n <section>\n <h3>Not on a node ({annotated.unattached.length})</h3>\n <Results items={annotated.unattached} />\n </section>\n )}\n </aside>\n )}\n </div>\n </div>\n );\n}\n\nconst SKIPPED_FIELDS = new Set(['title', 'type', 'content']);\nconst isEmpty = (v: unknown) => v === undefined || v === null || v === '' || (Array.isArray(v) && v.length === 0);\nconst asText = (v: unknown): string =>\n Array.isArray(v) ? v.map(asText).join(', ') : v !== null && typeof v === 'object' ? JSON.stringify(v) : String(v);\n\n/** The node's fields as a list; the title, type and body are shown elsewhere. */\nfunction Fields({ data }: { data: Record<string, unknown> }) {\n const fields = Object.entries(data).filter(([name, value]) => !SKIPPED_FIELDS.has(name) && !isEmpty(value));\n if (fields.length === 0) return null;\n return (\n <>\n <h3>Fields</h3>\n <dl className=\"viewer-fields\">\n {fields.map(([name, value]) => (\n <div key={name}>\n <dt>{name}</dt>\n <dd>{asText(value)}</dd>\n </div>\n ))}\n </dl>\n </>\n );\n}\n\nfunction Results({\n items,\n}: {\n items: readonly { severity: string; source: string; ruleId?: string; message: string; nodeId?: string }[];\n}) {\n return (\n <ul className=\"viewer-results\">\n {items.map((a, i) => (\n // biome-ignore lint/suspicious/noArrayIndexKey: a static list with no stable identity beyond position.\n <li key={i}>\n <span className={`viewer-severity viewer-${a.severity}`}>{a.severity}</span>{' '}\n <span className=\"viewer-muted\">{a.ruleId ? `${a.source} · ${a.ruleId}` : a.source}</span>\n {a.nodeId && <span className=\"viewer-muted\"> · {a.nodeId}</span>}\n <div>{a.message}</div>\n </li>\n ))}\n </ul>\n );\n}\n\n/** Names each card with `cardLabel`, again whenever the map view redraws its cards. */\nfunction useCardLabels(\n graph: SpaceGraph,\n definition: MapViewDefinition | undefined,\n cardLabel: ViewerProps['cardLabel'],\n) {\n const ref = useRef<HTMLDivElement>(null);\n useEffect(() => {\n const root = ref.current;\n if (!root || !definition || !cardLabel) return;\n const stamp = () => {\n for (const card of root.querySelectorAll<HTMLElement>('[data-node-id]')) {\n const node = graph.nodes.get(card.dataset.nodeId as SpaceNode['id']);\n if (node) card.setAttribute('aria-label', cardLabel(node, graph, definition));\n }\n };\n stamp();\n const observer = new MutationObserver(stamp);\n observer.observe(root, { childList: true, subtree: true });\n return () => observer.disconnect();\n }, [graph, definition, cardLabel]);\n return ref;\n}\n","import type { SpaceSnapshot } from '../core/space-snapshot';\n\nconst SPACES = 'spaces';\nconst TIMEOUT_MS = 10_000;\n\ntype Db = {\n collection(path: string): { get(): Promise<{ docs: { id: string; data(): Record<string, unknown> | undefined }[] }> };\n};\n\n/**\n * Every space written to the artifact's `spaces` collection: the `export` command's document, keyed by space\n * name, with its parts as JSON strings. Rejects with a message fit to show the viewer.\n */\nexport async function loadSpaces(): Promise<SpaceSnapshot[]> {\n const claude = (window as unknown as { claude?: { use(name: string): Promise<unknown> } }).claude;\n const db = (claude ? await claude.use('db') : null) as Db | null;\n if (!db) throw new Error('This page needs the artifact database, which is not available to this viewer.');\n\n let timer: ReturnType<typeof setTimeout> | undefined;\n const timeout = new Promise<never>((_, reject) => {\n timer = setTimeout(() => reject(new Error('Reading the artifact database timed out.')), TIMEOUT_MS);\n });\n const snapshot = await Promise.race([db.collection(SPACES).get(), timeout]).finally(() => clearTimeout(timer));\n const spaces = snapshot.docs.flatMap((doc) => {\n const data = doc.data();\n return data ? [toSpace(doc.id, data)] : [];\n });\n if (spaces.length === 0)\n throw new Error(`Nothing to show yet: no space has been written to \"${SPACES}\" in the artifact database.`);\n return spaces;\n}\n\nfunction toSpace(space: string, data: Record<string, unknown>): SpaceSnapshot {\n const json = (field: string) => {\n const value = data[field];\n if (typeof value !== 'string') throw new Error(`Space \"${space}\": missing \"${field}\" in the artifact database.`);\n return JSON.parse(value);\n };\n return {\n space,\n schemaId: typeof data.schemaId === 'string' ? data.schemaId : undefined,\n graph: json('graph'),\n validation: json('validation'),\n definitions: json('definitions'),\n };\n}\n","import { useEffect, useState } from 'react';\nimport { createRoot } from 'react-dom/client';\nimport type { SpaceGraph, SpaceNode } from 'structured-context/browser';\nimport type { MapViewDefinition } from '../core/definition';\nimport type { SpaceSnapshot } from '../core/space-snapshot';\nimport { Viewer } from '../viewer/Viewer';\nimport { loadSpaces } from './load';\n\n/**\n * The host for a Claude artifact: shows the spaces the publishing agent wrote to the artifact's db in the\n * viewer, and names cards for the artifact's comment mode. It ships as `dist/artifact.js`;\n * `dist/artifact.html` is the page that loads it. See docs/architecture.md.\n */\n\ntype State =\n | { status: 'loading' }\n | { status: 'error'; message: string }\n | { status: 'ready'; spaces: SpaceSnapshot[] };\n\nfunction App() {\n const [state, setState] = useState<State>({ status: 'loading' });\n useEffect(() => {\n loadSpaces().then(\n (spaces) => setState({ status: 'ready', spaces }),\n (err) => setState({ status: 'error', message: err instanceof Error ? err.message : String(err) }),\n );\n }, []);\n if (state.status === 'loading') return <p className=\"viewer-message\">Loading from the artifact database…</p>;\n if (state.status === 'error') return <p className=\"viewer-message\">{state.message}</p>;\n return <Viewer spaces={state.spaces} cardLabel={commentLabel} />;\n}\n\nconst positionsByGraph = new WeakMap<SpaceGraph, Map<string, number>>();\n\n/**\n * The comment mode reads a comment's location from the element's accessible name, cut at about 45\n * characters. Node ids are long (a file and heading), so the name leads with the node's position in the\n * stored graph, then its title and the view: `[<index>] <title> · <view>`. An agent reading the comment\n * takes `graph.nodes[<index>]` from the db and checks the title.\n */\nfunction commentLabel(node: SpaceNode, graph: SpaceGraph, definition: MapViewDefinition): string {\n let positions = positionsByGraph.get(graph);\n if (!positions) {\n positions = new Map([...graph.nodes.keys()].map((id, index) => [id as string, index]));\n positionsByGraph.set(graph, positions);\n }\n const view = definition.id.slice(definition.id.lastIndexOf('/') + 1);\n return `[${positions.get(node.id as string)}] ${node.title} · ${view}`;\n}\n\ncreateRoot(document.getElementById('root')!).render(<App />);\n"],"mappings":";;;;;;;AAmBA,SAAgB,OAAO,EAAE,QAAQ,aAA0B;CACzD,MAAM,CAAC,WAAW,gBAAgB,SAAS,OAAO,EAAE,CAAE,KAAK;CAC3D,MAAM,QAAQ,OAAO,MAAM,MAAM,EAAE,UAAU,SAAS;CACtD,MAAM,CAAC,QAAQ,aAAa,SAAS,MAAM,YAAY,EAAE,EAAE,EAAE;CAC7D,MAAM,aAAa,MAAM,YAAY,MAAM,MAAM,EAAE,OAAO,MAAM,KAAK,MAAM,YAAY;CACvF,MAAM,CAAC,QAAQ,aAAa,SAA0B,CAAC,CAAC;CACxD,MAAM,CAAC,YAAY,iBAAiB,SAA0B;CAE9D,MAAM,QAAQ,cAAc,eAAe,MAAM,KAAK,GAAG,CAAC,KAAK,CAAC;CAChE,MAAM,YAAY,cAAc,gBAAgB,MAAM,YAAY,KAAK,GAAG,CAAC,OAAO,KAAK,CAAC;CACxF,MAAM,SAAS,cAAc,OAAO,YAAY,SAAS;CAEzD,IAAI,CAAC,YAAY,OAAO,qBAAC,KAAD;EAAG,WAAU;EAAb,UAAA;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W,GAAG,MAAM,WAAW,GAAG,YAAY,GAAG,IAAI,CAAC;CACnE,OAAO,IAAI,UAAU,IAAI,KAAK,EAAY,EAAE,IAAI,KAAK,MAAM,KAAK;AAClE;AAEA,WAAW,SAAS,eAAe,MAAM,CAAE,CAAC,CAAC,OAAO,oBAAC,KAAD,CAAM,CAAA,CAAC"}
package/dist/cli.js CHANGED
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env bun
2
- import { n as mapViewsForSchema } from "./definition-Cp1CCigh.js";
3
- import { t as loadMapViewDefinitions } from "./node-aizYAYlq.js";
2
+ import { r as mapViewsForSchema } from "./definition-SjmROmJC.js";
3
+ import { t as loadMapViewDefinitions } from "./node-ctbuxC-s.js";
4
4
  import { SctxError, assembleSpaceGraph, createSpaceContext, exportSpaceGraph, loadConfig, resolveConfigPath, setConfigPath, validateSpace } from "structured-context/api";
5
5
  import { Command } from "commander";
6
6
  var package_default = {
7
7
  name: "structured-context-map-views",
8
- version: "0.6.1",
9
- description: "Declarative map views of structured-context spaces: render a space as a tree, nested containers or an XY plot from a short definition.",
8
+ version: "0.7.0",
9
+ description: "Declarative map views of structured-context spaces: render a space as a tree, nested containers and other layouts from a short definition.",
10
10
  license: "MIT",
11
11
  type: "module",
12
12
  repository: {
@@ -34,6 +34,10 @@ var package_default = {
34
34
  "types": "./dist/types/node/index.d.ts",
35
35
  "default": "./dist/node.js"
36
36
  },
37
+ "./html": {
38
+ "types": "./dist/types/node/html.d.ts",
39
+ "default": "./dist/html.js"
40
+ },
37
41
  "./styles.css": "./dist/styles.css",
38
42
  "./page.html": {
39
43
  "types": "./dist/page.html.d.ts",
@@ -45,14 +49,14 @@ var package_default = {
45
49
  "generate": "bun run generate:schemas && bun run generate:definitions",
46
50
  "generate:schemas": "bun scripts/generate-schemas.ts",
47
51
  "generate:definitions": "bun scripts/generate-definitions.ts",
48
- "build:library": "bun run clean && bun run generate && bun --bun vite build && tsc -p tsconfig.build.json && tailwindcss -i src/layouts/styles.css -o dist/styles.css && bun scripts/build-page.ts",
52
+ "build:library": "bun run clean && bun run generate && bun --bun vite build && tsc -p tsconfig.build.json && tailwindcss -i src/components/styles.css -o dist/styles.css && bun scripts/build-page.ts",
49
53
  "build": "bun run build:library && bun scripts/build-artifact-page.ts",
50
54
  "typecheck": "tsc --noEmit",
51
55
  "capture-fixtures": "bun scripts/capture-fixtures.ts",
52
56
  "test": "bun test",
53
57
  "test:package": "bash scripts/test-package.sh",
54
58
  "prepublishOnly": "bun run build",
55
- "preversion": "bun run generate && bun run --cwd ../.. lint:fix && bun run --cwd ../.. test && bun run --cwd ../.. test:package",
59
+ "preversion": "bun run build:library && bun run --cwd ../.. lint:fix && bun run --cwd ../.. test && bun run --cwd ../.. test:package",
56
60
  "version": "bun run generate:schemas --release && git add -A"
57
61
  },
58
62
  peerDependencies: {
@@ -63,11 +67,13 @@ var package_default = {
63
67
  dependencies: {
64
68
  "ajv": "^8.20.0",
65
69
  "commander": "^15.0.0",
70
+ "d3-force": "^3.0.1",
66
71
  "json-schema-to-ts": "^3.1.1",
67
72
  "json5": "^2.2.3"
68
73
  },
69
74
  devDependencies: {
70
75
  "@tailwindcss/cli": "^4.3.3",
76
+ "@types/d3-force": "^3.0.10",
71
77
  "@types/node": "^22.20.5",
72
78
  "@types/react": "^19.3.0",
73
79
  "@types/react-dom": "^19.3.0",
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.6.1\",\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 \"./page.html\": {\n \"types\": \"./dist/page.html.d.ts\",\n \"default\": \"./dist/page.html\"\n }\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:library\": \"bun run clean && bun run generate && bun --bun vite build && tsc -p tsconfig.build.json && tailwindcss -i src/layouts/styles.css -o dist/styles.css && bun scripts/build-page.ts\",\n \"build\": \"bun run build:library && 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 --cwd ../.. 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.24.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.24.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 { mapViewsForSchema } from '../core/definition';\nimport type { SpaceSnapshot } from '../core/snapshot';\nimport { loadMapViewDefinitions } from './index';\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: validation.issues },\n definitions: mapViewsForSchema(loadMapViewDefinitions(config, { configDir }), schemaId),\n };\n}\n","#!/usr/bin/env bun\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 = resolveConfigPath().root;\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACqBA,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,EAAE,QAAQ,WAAW,OAAO;EACxC,aAAa,kBAAkB,uBAAuB,QAAQ,EAAE,UAAU,CAAC,GAAG,QAAQ;CACxF;AACF;;;AChCA,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;EACF,MAAM,SAAS,WAAW;EAC1B,MAAM,YAAY,kBAAkB,CAAC,CAAC;EACtC,MAAM,SAAS,MAAM,eAAe,WAAW,QAAQ,WAAW,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.7.0\",\n \"description\": \"Declarative map views of structured-context spaces: render a space as a tree, nested containers and other layouts 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 \"./html\": {\n \"types\": \"./dist/types/node/html.d.ts\",\n \"default\": \"./dist/html.js\"\n },\n \"./styles.css\": \"./dist/styles.css\",\n \"./page.html\": {\n \"types\": \"./dist/page.html.d.ts\",\n \"default\": \"./dist/page.html\"\n }\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:library\": \"bun run clean && bun run generate && bun --bun vite build && tsc -p tsconfig.build.json && tailwindcss -i src/components/styles.css -o dist/styles.css && bun scripts/build-page.ts\",\n \"build\": \"bun run build:library && 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 build:library && bun run --cwd ../.. lint:fix && bun run --cwd ../.. test && bun run --cwd ../.. 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.24.0\"\n },\n \"dependencies\": {\n \"ajv\": \"^8.20.0\",\n \"commander\": \"^15.0.0\",\n \"d3-force\": \"^3.0.1\",\n \"json-schema-to-ts\": \"^3.1.1\",\n \"json5\": \"^2.2.3\"\n },\n \"devDependencies\": {\n \"@tailwindcss/cli\": \"^4.3.3\",\n \"@types/d3-force\": \"^3.0.10\",\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.24.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 { mapViewsForSchema } from '../core/definition';\nimport type { SpaceSnapshot } from '../core/space-snapshot';\nimport { loadMapViewDefinitions } from './index';\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: validation.issues },\n definitions: mapViewsForSchema(loadMapViewDefinitions(config, { configDir }), schemaId),\n };\n}\n","#!/usr/bin/env bun\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 = resolveConfigPath().root;\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACqBA,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,EAAE,QAAQ,WAAW,OAAO;EACxC,aAAa,kBAAkB,uBAAuB,QAAQ,EAAE,UAAU,CAAC,GAAG,QAAQ;CACxF;AACF;;;AChCA,IAAM,UAAU,IAAI,QAAQ;AAE5B,QACG,KAAK,8BAA8B,CAAC,CACpC,YAAY,8CAA8C,CAAC,CAC3D,QAAQA,gBAAY,OAAO,CAAC,CAC5B,OAAO,mBA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