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
@@ -1,34 +1,11 @@
1
1
  import { type Config } from 'structured-context/api';
2
- import { type MapViewDefinition } from '../core/definition';
3
- export type DefinitionSource = {
4
- kind: 'core';
5
- } | {
6
- kind: 'plugin';
7
- plugin: string;
8
- } | {
9
- kind: 'config';
10
- };
11
- export type LoadMapViewDefinitionsOptions = {
12
- /** Root of the main config file (`resolveConfigPath().root`). Defaults to where structured-context finds it. */
13
- configDir?: string;
14
- };
2
+ import type { MapViewDefinition } from '../core/definition';
15
3
  /**
16
- * Every map view definition available with `config`, from:
17
- * - this package's embedded definitions (`sctx-map-view://core/<name>`), for structured-context's bundled schemas;
18
- * - each plugin found from a config folder or named by a space (`sctx-map-view://<plugin>/<name>`): the
19
- * folder named by `"sctx": { "mapViews": "…" }` in its package.json, else its `map-views/` folder;
20
- * - the `map-views` resources folder of each config root (`sctx-map-view://<name>`).
4
+ * Every map view definition available with `config`, found as docs/definitions.md describes.
5
+ * Throws on the first invalid definition, including one outside its namespace or with a duplicate `$id`.
21
6
  *
22
- * Each definition's `$id` must be in the namespace of where it was found, and ids must be unique.
23
- * Throws on the first invalid definition.
24
- */
25
- export declare function loadMapViewDefinitions(config: Config, options?: LoadMapViewDefinitionsOptions): MapViewDefinition[];
26
- /**
27
- * Definitions in `folders` and this package's embedded ones, each checked against the namespace of its source.
28
- * Throws on the first invalid definition or a repeated id.
7
+ * `configDir` is the root of the main config file; it defaults to where structured-context finds it.
29
8
  */
30
- export declare function readDefinitionFolders(folders: {
31
- dir: string;
32
- source: DefinitionSource;
33
- }[]): MapViewDefinition[];
34
- export { fillPage } from './page';
9
+ export declare function loadMapViewDefinitions(config: Config, options?: {
10
+ configDir?: string;
11
+ }): MapViewDefinition[];
@@ -1,4 +1,4 @@
1
- import type { SpaceSnapshot } from '../core/snapshot';
1
+ import type { SpaceSnapshot } from '../core/space-snapshot';
2
2
  export declare const PAGE_SLOTS: {
3
3
  readonly title: '<!--sctx-title-->';
4
4
  readonly snapshots: '<!--sctx-snapshots-->';
@@ -0,0 +1,17 @@
1
+ import { type MapViewDefinition } from '../core/definition';
2
+ export type DefinitionSource = {
3
+ kind: 'core';
4
+ } | {
5
+ kind: 'plugin';
6
+ plugin: string;
7
+ } | {
8
+ kind: 'config';
9
+ };
10
+ /**
11
+ * Definitions in `folders` and this package's embedded ones, each checked against the namespace of its source.
12
+ * Throws on the first invalid definition or a repeated id.
13
+ */
14
+ export declare function readDefinitionFolders(folders: {
15
+ dir: string;
16
+ source: DefinitionSource;
17
+ }[]): MapViewDefinition[];
@@ -1,5 +1,5 @@
1
1
  import { type Config, validateSpace } from 'structured-context/api';
2
- import type { SpaceSnapshot } from '../core/snapshot';
2
+ import type { SpaceSnapshot } from '../core/space-snapshot';
3
3
  /** The `validateSpace` options `export` passes through unchanged. */
4
4
  export type ExportValidateOptions = Pick<NonNullable<Parameters<typeof validateSpace>[1]>, 'depth' | 'includeGated' | 'semantic' | 'ruleFilter'>;
5
5
  /**
@@ -1,14 +1,14 @@
1
1
  import { type SpaceGraph, type SpaceNode } from 'structured-context/browser';
2
2
  import type { MapViewDefinition } from '../core/definition';
3
- import type { SpaceSnapshot } from '../core/snapshot';
3
+ import type { SpaceSnapshot } from '../core/space-snapshot';
4
4
  /**
5
- * A page-filling viewer for one or more space snapshots: a space and map view switcher, the parameter
6
- * controls, the map view, and a side panel with the selected node's fields and validation results. Hosts
7
- * supply the snapshots and anything specific to where the page is shown. See docs/architecture.md.
5
+ * A page-filling viewer for one or more space snapshots. Hosts supply the snapshots and anything
6
+ * specific to where the page is shown. See docs/architecture.md.
8
7
  */
9
- export type ViewerProps = {
8
+ type ViewerProps = {
10
9
  spaces: SpaceSnapshot[];
11
10
  /** Accessible name for each card, for hosts whose surroundings read it. Cards keep their default name without it. */
12
11
  cardLabel?: (node: SpaceNode, graph: SpaceGraph, definition: MapViewDefinition) => string;
13
12
  };
14
13
  export declare function Viewer({ spaces, cardLabel }: ViewerProps): import("react").JSX.Element;
14
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "structured-context-map-views",
3
- "version": "0.6.1",
4
- "description": "Declarative map views of structured-context spaces: render a space as a tree, nested containers or an XY plot from a short definition.",
3
+ "version": "0.7.0",
4
+ "description": "Declarative map views of structured-context spaces: render a space as a tree, nested containers and other layouts from a short definition.",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "repository": {
@@ -33,6 +33,10 @@
33
33
  "types": "./dist/types/node/index.d.ts",
34
34
  "default": "./dist/node.js"
35
35
  },
36
+ "./html": {
37
+ "types": "./dist/types/node/html.d.ts",
38
+ "default": "./dist/html.js"
39
+ },
36
40
  "./styles.css": "./dist/styles.css",
37
41
  "./page.html": {
38
42
  "types": "./dist/page.html.d.ts",
@@ -44,14 +48,14 @@
44
48
  "generate": "bun run generate:schemas && bun run generate:definitions",
45
49
  "generate:schemas": "bun scripts/generate-schemas.ts",
46
50
  "generate:definitions": "bun scripts/generate-definitions.ts",
47
- "build:library": "bun run clean && bun run generate && bun --bun vite build && tsc -p tsconfig.build.json && tailwindcss -i src/layouts/styles.css -o dist/styles.css && bun scripts/build-page.ts",
51
+ "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",
48
52
  "build": "bun run build:library && bun scripts/build-artifact-page.ts",
49
53
  "typecheck": "tsc --noEmit",
50
54
  "capture-fixtures": "bun scripts/capture-fixtures.ts",
51
55
  "test": "bun test",
52
56
  "test:package": "bash scripts/test-package.sh",
53
57
  "prepublishOnly": "bun run build",
54
- "preversion": "bun run generate && bun run --cwd ../.. lint:fix && bun run --cwd ../.. test && bun run --cwd ../.. test:package",
58
+ "preversion": "bun run build:library && bun run --cwd ../.. lint:fix && bun run --cwd ../.. test && bun run --cwd ../.. test:package",
55
59
  "version": "bun run generate:schemas --release && git add -A"
56
60
  },
57
61
  "peerDependencies": {
@@ -62,11 +66,13 @@
62
66
  "dependencies": {
63
67
  "ajv": "^8.20.0",
64
68
  "commander": "^15.0.0",
69
+ "d3-force": "^3.0.1",
65
70
  "json-schema-to-ts": "^3.1.1",
66
71
  "json5": "^2.2.3"
67
72
  },
68
73
  "devDependencies": {
69
74
  "@tailwindcss/cli": "^4.3.3",
75
+ "@types/d3-force": "^3.0.10",
70
76
  "@types/node": "^22.20.5",
71
77
  "@types/react": "^19.3.0",
72
78
  "@types/react-dom": "^19.3.0",
@@ -1 +0,0 @@
1
- {"version":3,"file":"ParameterControls-A1HJWyt9.js","names":["_Fragment"],"sources":["../src/layouts/annotations-context.ts","../src/layouts/NodeCard.tsx","../src/layouts/LandscapeLayout.tsx","../src/layouts/EdgeOverlay.tsx","../src/layouts/TreeLayout.tsx","../src/layouts/XYLayout.tsx","../src/layouts/MapView.tsx","../src/layouts/ParameterInputs.tsx","../src/layouts/useParameterControls.ts","../src/layouts/ParameterControls.tsx"],"sourcesContent":["import { createContext, useContext } from 'react';\nimport type { AnnotationIndex } from '../core/annotations';\n\nconst NONE: AnnotationIndex = new Map();\n\n/** The annotations a map view shows, already narrowed by its validation settings. Read by node cards. */\nexport const AnnotationsContext = createContext<AnnotationIndex>(NONE);\n\nexport const useAnnotations = () => useContext(AnnotationsContext);\n","import type { SpaceNode } from 'structured-context/api';\nimport { type NodeAnnotation, type Severity, worstSeverity } from '../core/annotations';\nimport type { NodesConfig } from '../core/definition';\nimport { useAnnotations } from './annotations-context';\n\ntype Props = {\n node: SpaceNode;\n /** The node's subtree is rendered at another occurrence. */\n repeat: boolean;\n nodes: NodesConfig;\n onSelect?: (node: SpaceNode) => void;\n};\n\n/**\n * A clickable node, drawn as a card (title plus selected fields) or a compact shape with a\n * tooltip. Deliberately a `div` with button semantics rather than a `<button>`: hosts style\n * native form controls globally (Obsidian fixes button height and disables wrapping).\n */\nexport function NodeCard({ node, repeat, nodes, onSelect }: Props) {\n const select = () => onSelect?.(node);\n const annotations = useAnnotations().get(node.id);\n const label = `${node.resolvedType}: ${node.title}${repeat ? ' (shown in full elsewhere)' : ''}${annotationsLabel(annotations)}`;\n const onKeyDown = (e: React.KeyboardEvent) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n select();\n }\n };\n const border = repeat ? 'mv:border-dashed mv:border-muted/60 mv:opacity-75' : 'mv:border-edge';\n\n if (nodes.style === 'shape') {\n // 24px: the minimum target size for pointer input (WCAG 2.2 AA). The type's initial is the\n // visible cue; the full type and title are in the tooltip and accessible name.\n return (\n // biome-ignore lint/a11y/useSemanticElements: a native button inherits host button styles.\n <div\n role=\"button\"\n tabIndex={0}\n title={label}\n data-node-id={node.id}\n onClick={select}\n onKeyDown={onKeyDown}\n aria-label={label}\n className={`mv:relative mv:flex mv:size-6 mv:cursor-pointer mv:items-center mv:justify-center mv:rounded-full mv:border-2 mv:bg-card mv:text-[0.65rem] mv:font-semibold mv:uppercase mv:text-muted mv:hover:border-accent mv:focus-visible:outline-2 mv:focus-visible:outline-accent ${border}`}\n >\n <span aria-hidden=\"true\">{node.resolvedType.charAt(0)}</span>\n <AnnotationBadge annotations={annotations} />\n </div>\n );\n }\n\n const fields = nodes.fields\n .map((field) => [field, formatValue(node.schemaData[field])] as const)\n .filter(([, value]) => value !== undefined);\n\n return (\n // biome-ignore lint/a11y/useSemanticElements: a native button inherits host button styles.\n <div\n role=\"button\"\n tabIndex={0}\n title={label}\n data-node-id={node.id}\n onClick={select}\n onKeyDown={onKeyDown}\n className={`mv:relative mv:w-44 mv:cursor-pointer mv:rounded-md mv:border mv:bg-card mv:px-2.5 mv:py-1.5 mv:text-left mv:shadow-sm mv:hover:border-accent mv:focus-visible:outline-2 mv:focus-visible:outline-accent ${border}`}\n >\n <span className=\"mv:block mv:text-[0.65rem] mv:uppercase mv:tracking-wide mv:text-muted\">\n {node.resolvedType}\n {repeat && ' · repeat'}\n </span>\n <span className=\"mv:block mv:text-sm mv:leading-snug\">{node.title}</span>\n {fields.length > 0 && (\n <dl className=\"mv:m-0 mv:mt-1 mv:text-xs mv:text-muted\">\n {fields.map(([field, value]) => (\n <div key={field} className=\"mv:flex mv:gap-1\">\n <dt className=\"mv:shrink-0\">{field}:</dt>\n <dd className=\"mv:m-0 mv:truncate mv:text-ink\">{value}</dd>\n </div>\n ))}\n </dl>\n )}\n <AnnotationBadge annotations={annotations} />\n </div>\n );\n}\n\nconst BADGE: Record<Severity, string> = {\n error: 'mv:bg-error',\n warning: 'mv:bg-warning',\n info: 'mv:bg-info',\n};\n\n/** A count of the node's validation results in the corner, coloured by the most serious. Decorative: the count is in the card's label. */\nfunction AnnotationBadge({ annotations }: { annotations: readonly NodeAnnotation[] | undefined }) {\n const worst = annotations && worstSeverity(annotations);\n if (!annotations || !worst) return null;\n return (\n <span\n aria-hidden=\"true\"\n className={`mv:absolute mv:-top-1.5 mv:-right-1.5 mv:flex mv:h-4 mv:min-w-4 mv:items-center mv:justify-center mv:rounded-full mv:px-1 mv:text-[0.6rem] mv:font-semibold mv:text-white ${BADGE[worst]}`}\n >\n {annotations.length}\n </span>\n );\n}\n\nfunction annotationsLabel(annotations: readonly NodeAnnotation[] | undefined): string {\n const worst = annotations && worstSeverity(annotations);\n if (!annotations || !worst) return '';\n return ` (${annotations.length} validation ${annotations.length === 1 ? 'result' : 'results'}, most serious: ${worst})`;\n}\n\nfunction formatValue(value: unknown): string | undefined {\n if (value === undefined || value === null || value === '') return undefined;\n if (Array.isArray(value)) return value.map(String).join(', ');\n if (typeof value === 'object') return JSON.stringify(value);\n return String(value);\n}\n","import { useMemo } from 'react';\nimport type { SpaceNode } from 'structured-context/api';\nimport type { LandscapeLayoutConfig, Orientation } from '../core/definition';\nimport { buildLandscape, type LandscapeOccurrence } from '../core/landscape';\nimport { NodeCard } from './NodeCard';\nimport type { LayoutProps } from './TreeLayout';\n\n/**\n * Nested containers following the layout's grouping levels; the last level is drawn as nodes.\n * Flexbox does the nesting and wrapping. Containment shows the grouping edges, so no connectors\n * are drawn. PROTOTYPE: `edges.show` has no effect here; other edges aren't drawn yet.\n */\nexport function LandscapeLayout({ graph, region, instanceId, onNodeSelect }: LayoutProps<LandscapeLayoutConfig>) {\n const { layout } = region;\n const landscape = useMemo(() => buildLandscape(graph, region.id, layout), [graph, region.id, layout]);\n const last = layout.group.length - 1;\n\n const breadcrumb = (occurrence: LandscapeOccurrence) => {\n const level = layout.group[occurrence.level];\n if (!level || !('type' in level) || level.intermediate !== 'breadcrumb') return null;\n const steps = occurrence.via.filter((step) => step.nodes.length > 0);\n if (steps.length === 0) return null;\n return (\n <span className=\"mv:block mv:max-w-44 mv:text-[0.65rem] mv:leading-tight mv:text-muted\">\n via {steps.map((step) => step.nodes.map((n) => n.title).join(', ')).join(' › ')}\n </span>\n );\n };\n\n const render = (occurrence: LandscapeOccurrence, direction: Orientation): React.ReactNode => {\n const repeat = occurrence.repeatOf !== undefined;\n const marker = { 'data-occurrence': `${instanceId}${occurrence.key}` };\n\n if (occurrence.item.kind === 'node' && occurrence.level === last) {\n return (\n <li key={occurrence.key} {...marker} className=\"mv:flex mv:flex-col mv:gap-0.5\">\n <NodeCard node={occurrence.item.node} repeat={repeat} nodes={region.nodes} onSelect={onNodeSelect} />\n {breadcrumb(occurrence)}\n </li>\n );\n }\n\n // Containers alternate direction with depth; a container of nodes wraps them.\n const inner: Orientation = direction === 'horizontal' ? 'vertical' : 'horizontal';\n const holdsNodes = occurrence.level + 1 === last;\n return (\n <li\n key={occurrence.key}\n {...marker}\n className={`mv:flex mv:flex-col mv:gap-2 mv:rounded-lg mv:border mv:bg-surface mv:p-2 ${repeat ? 'mv:border-dashed mv:border-muted/60' : 'mv:border-edge'}`}\n >\n {occurrence.item.kind === 'node' ? (\n <ContainerHeading node={occurrence.item.node} repeat={repeat} onSelect={onNodeSelect}>\n {breadcrumb(occurrence)}\n </ContainerHeading>\n ) : (\n <span className=\"mv:text-xs mv:font-semibold mv:text-muted\">\n {occurrence.item.field}: {occurrence.item.value === null ? '(none)' : displayValue(occurrence.item.value)}\n </span>\n )}\n <Items direction={holdsNodes ? 'wrap' : inner}>\n {occurrence.children.map((child) => render(child, inner))}\n </Items>\n </li>\n );\n };\n\n const top = layout.orientation;\n return (\n <div className=\"mv:w-max mv:min-w-full mv:p-4\">\n <Items direction={last === 0 ? 'wrap' : top}>\n {landscape.groups.map((group) => render(group, top))}\n {landscape.ungrouped.length > 0 && (\n <li className=\"mv:flex mv:flex-col mv:gap-2 mv:rounded-lg mv:border mv:border-dashed mv:border-edge mv:p-2\">\n <span className=\"mv:text-xs mv:font-semibold mv:text-muted\">Ungrouped</span>\n <Items direction=\"wrap\">{landscape.ungrouped.map((o) => render(o, top))}</Items>\n </li>\n )}\n </Items>\n </div>\n );\n}\n\nfunction Items({ direction, children }: { direction: Orientation | 'wrap'; children: React.ReactNode }) {\n const layout = {\n horizontal: 'mv:flex-row mv:items-start mv:gap-3',\n vertical: 'mv:flex-col mv:items-stretch mv:gap-2',\n wrap: 'mv:max-w-[36rem] mv:flex-row mv:flex-wrap mv:items-start mv:gap-2',\n }[direction];\n return <ul className={`mv:m-0 mv:flex mv:list-none mv:p-0 ${layout}`}>{children}</ul>;\n}\n\n/** A container's node: type and title, selectable like a card. */\nfunction ContainerHeading({\n node,\n repeat,\n onSelect,\n children,\n}: {\n node: SpaceNode;\n repeat: boolean;\n onSelect?: (node: SpaceNode) => void;\n children?: React.ReactNode;\n}) {\n const select = () => onSelect?.(node);\n return (\n // biome-ignore lint/a11y/useSemanticElements: a native button inherits host button styles.\n <div\n role=\"button\"\n tabIndex={0}\n title={`${node.resolvedType}: ${node.title}${repeat ? ' (also shown elsewhere)' : ''}`}\n onClick={select}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n select();\n }\n }}\n className=\"mv:cursor-pointer mv:rounded mv:px-1 mv:hover:text-accent mv:focus-visible:outline-2 mv:focus-visible:outline-accent\"\n >\n <span className=\"mv:block mv:text-[0.65rem] mv:uppercase mv:tracking-wide mv:text-muted\">\n {node.resolvedType}\n {repeat && ' · repeat'}\n </span>\n <span className=\"mv:block mv:text-sm mv:font-semibold mv:leading-snug\">{node.title}</span>\n {children}\n </div>\n );\n}\n\n/** Field values that are wikilinks show as the linked title. */\nfunction displayValue(value: string): string {\n return value.replace(/^\\[\\[([^\\]|]+)(\\|[^\\]]*)?\\]\\]$/, '$1');\n}\n","import { useLayoutEffect, useState } from 'react';\nimport type { Orientation } from '../core/definition';\n\n/**\n * A connector between two occurrences. `cross` links (e.g. extra parents) are drawn dashed.\n * `id` tells apart several links between the same occurrences; straight links between the same\n * pair are drawn side by side, `lane` apart (0: on the line between centres).\n */\nexport type Link = { from: string; to: string; kind?: 'tree' | 'cross'; id?: string; lane?: number };\n\ntype Props = {\n links: readonly Link[];\n /** Rendered element of each occurrence, by occurrence key. */\n elements: ReadonlyMap<string, HTMLElement>;\n /**\n * Positioned element the overlay covers; coordinates are relative to it. Passed as an element,\n * not a ref: the overlay sits inside it, and React runs a child's layout effects before\n * attaching the parent's ref.\n */\n container: HTMLElement | null;\n /** Curves leaving along the tree's orientation, or straight lines between centres (drawn under the nodes). */\n routing: Orientation | 'straight';\n};\n\ntype Drawn = { key: string; d: string; cross: boolean };\n\n/**\n * SVG layer drawing connectors between rendered occurrences.\n *\n * Measures occurrence elements after layout and redraws when the container or any occurrence\n * resizes, so it follows embedded panes that resize independently of the window, and reflows\n * such as late font loads. The SVG fills the container instead of being sized from it, so it\n * never holds the container open after the layout shrinks.\n */\nexport function EdgeOverlay({ links, elements, container, routing }: Props) {\n const [paths, setPaths] = useState<Drawn[]>([]);\n\n useLayoutEffect(() => {\n if (!container) return;\n\n const measure = () => {\n const origin = container.getBoundingClientRect();\n const paths: Drawn[] = [];\n for (const { from, to, kind, id, lane = 0 } of links) {\n const a = elements.get(from)?.getBoundingClientRect();\n const b = elements.get(to)?.getBoundingClientRect();\n if (!a || !b) continue;\n paths.push({\n key: `${from}→${to}${id ?? ''}`,\n d: routing === 'straight' ? line(a, b, origin, lane) : connector(a, b, origin, routing),\n cross: kind === 'cross',\n });\n }\n setPaths(paths);\n };\n\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(container);\n for (const element of elements.values()) observer.observe(element);\n return () => observer.disconnect();\n }, [links, elements, container, routing]);\n\n return (\n <svg\n aria-hidden=\"true\"\n className=\"mv:pointer-events-none mv:absolute mv:inset-0 mv:h-full mv:w-full mv:overflow-visible\"\n >\n {paths.map(({ key, d, cross }) => (\n <path\n key={key}\n d={d}\n className={`mv:fill-none ${cross ? 'mv:stroke-accent/60' : 'mv:stroke-muted/50'}`}\n strokeWidth={1.5}\n strokeDasharray={cross ? '4 3' : undefined}\n />\n ))}\n </svg>\n );\n}\n\n/** Cubic curve from the parent's trailing edge to the child's leading edge. */\nfunction connector(a: DOMRect, b: DOMRect, origin: DOMRect, orientation: Orientation): string {\n if (orientation === 'vertical') {\n const x1 = a.left + a.width / 2 - origin.left;\n const y1 = a.bottom - origin.top;\n const x2 = b.left + b.width / 2 - origin.left;\n const y2 = b.top - origin.top;\n const my = (y1 + y2) / 2;\n return `M${x1},${y1} C${x1},${my} ${x2},${my} ${x2},${y2}`;\n }\n const x1 = a.right - origin.left;\n const y1 = a.top + a.height / 2 - origin.top;\n const x2 = b.left - origin.left;\n const y2 = b.top + b.height / 2 - origin.top;\n const mx = (x1 + x2) / 2;\n return `M${x1},${y1} C${mx},${y1} ${mx},${y2} ${x2},${y2}`;\n}\n\n/** Pixels between parallel straight links. */\nconst LANE_GAP = 6;\n\n/**\n * Straight line between centres, shifted sideways by its lane; the layout draws nodes over the\n * overlay to hide the ends. The shift is relative to a fixed orientation of the pair, so links in\n * opposite directions between the same nodes still separate.\n */\nfunction line(a: DOMRect, b: DOMRect, origin: DOMRect, lane: number): string {\n const x1 = a.left + a.width / 2 - origin.left;\n const y1 = a.top + a.height / 2 - origin.top;\n const x2 = b.left + b.width / 2 - origin.left;\n const y2 = b.top + b.height / 2 - origin.top;\n const flip = x1 < x2 || (x1 === x2 && y1 < y2) ? 1 : -1;\n const length = Math.hypot(x2 - x1, y2 - y1) || 1;\n const dx = (-(y2 - y1) / length) * lane * LANE_GAP * flip;\n const dy = ((x2 - x1) / length) * lane * LANE_GAP * flip;\n return `M${x1 + dx},${y1 + dy} L${x2 + dx},${y2 + dy}`;\n}\n","import { useCallback, useMemo, useRef, useState } from 'react';\nimport type { SpaceGraph, SpaceNode } from 'structured-context/api';\nimport type { LayoutConfig, Orientation, Region, TreeLayoutConfig } from '../core/definition';\nimport { buildTree, type TreeOccurrence, treeLinks } from '../core/tree';\nimport { EdgeOverlay } from './EdgeOverlay';\nimport { NodeCard } from './NodeCard';\n\nexport type LayoutProps<L extends LayoutConfig = LayoutConfig> = {\n graph: SpaceGraph;\n /** The region with parameter values applied, narrowed to the layout's own settings. */\n region: Region & { layout: L };\n /** Scopes occurrence ids when several map views render in one document. */\n instanceId: string;\n onNodeSelect?: (node: SpaceNode) => void;\n};\n\n/**\n * Tree over the schema's hierarchy. Flexbox does the branching; the SVG overlay draws connectors.\n */\nexport function TreeLayout({ graph, region, instanceId, onNodeSelect }: LayoutProps<TreeLayoutConfig>) {\n const { orientation, dag } = region.layout;\n const tree = useMemo(() => buildTree(graph, region.id, dag), [graph, region.id, dag]);\n const links = useMemo(() => (region.edges.show ? treeLinks(tree) : []), [tree, region.edges.show]);\n\n const [container, setContainer] = useState<HTMLDivElement | null>(null);\n // Filled by ref callbacks during commit, read by the overlay's layout effect afterwards.\n const elements = useRef(new Map<string, HTMLElement>()).current;\n const register = useCallback(\n (key: string) => (el: HTMLElement | null) => {\n if (el) elements.set(key, el);\n else elements.delete(key);\n },\n [elements],\n );\n\n const branch = (occurrence: TreeOccurrence) => (\n <li\n key={occurrence.key}\n className={`mv:flex mv:items-center ${orientation === 'vertical' ? 'mv:flex-col' : 'mv:flex-row'}`}\n >\n <div ref={register(occurrence.key)} data-occurrence={`${instanceId}${occurrence.key}`}>\n <NodeCard\n node={occurrence.node}\n repeat={occurrence.repeatOf !== undefined}\n nodes={region.nodes}\n onSelect={onNodeSelect}\n />\n </div>\n {occurrence.children.length > 0 && (\n <Branches orientation={orientation} nested>\n {occurrence.children.map(branch)}\n </Branches>\n )}\n </li>\n );\n\n return (\n <div ref={setContainer} className=\"mv:relative mv:w-max mv:min-w-full mv:p-4\">\n <Branches orientation={orientation}>{[...tree.roots, ...tree.orphans].map(branch)}</Branches>\n <EdgeOverlay links={links} elements={elements} container={container} routing={orientation} />\n </div>\n );\n}\n\nfunction Branches({\n orientation,\n nested = false,\n children,\n}: {\n orientation: Orientation;\n nested?: boolean;\n children: React.ReactNode;\n}) {\n // Siblings run across the main axis; nested branches leave a gap for connectors.\n const layout =\n orientation === 'vertical'\n ? `mv:flex-row mv:items-start mv:justify-center mv:gap-3 ${nested ? 'mv:pt-10' : ''}`\n : `mv:flex-col mv:items-start mv:justify-center mv:gap-2 ${nested ? 'mv:pl-14' : ''}`;\n return <ul className={`mv:m-0 mv:flex mv:list-none mv:p-0 ${layout}`}>{children}</ul>;\n}\n","import { useCallback, useMemo, useRef, useState } from 'react';\nimport type { AxisConfig, XYLayoutConfig } from '../core/definition';\nimport { buildXYPlot } from '../core/xy';\nimport { EdgeOverlay } from './EdgeOverlay';\nimport { NodeCard } from './NodeCard';\nimport type { LayoutProps } from './TreeLayout';\n\n/**\n * Nodes positioned by two numeric fields, with straight connectors between them. Positions are\n * percentages of the plot area, which fills the container (scrolling below a minimum size). Nodes that can't be\n * placed are listed under the plot with the reason.\n * PROTOTYPE: labels may overlap where nodes sit close together; no collision handling.\n */\nexport function XYLayout({ graph, region, instanceId, onNodeSelect }: LayoutProps<XYLayoutConfig>) {\n const { layout } = region;\n const plot = useMemo(() => buildXYPlot(graph, region.id, layout), [graph, region.id, layout]);\n // Relationship edges (flows, pipelines) are dashed, to tell them from the value chain.\n const links = useMemo(\n () =>\n region.edges.show\n ? plot.links.map(({ from, to, field, hierarchy, lane }) => ({\n from,\n to,\n id: field,\n lane,\n kind: hierarchy ? ('tree' as const) : ('cross' as const),\n }))\n : [],\n [plot, region.edges.show],\n );\n const shape = region.nodes.style === 'shape';\n\n const [container, setContainer] = useState<HTMLDivElement | null>(null);\n const elements = useRef(new Map<string, HTMLElement>()).current;\n const register = useCallback(\n (key: string) => (el: HTMLElement | null) => {\n if (el) elements.set(key, el);\n else elements.delete(key);\n },\n [elements],\n );\n\n return (\n <div className=\"mv:box-border mv:flex mv:h-full mv:min-h-[28rem] mv:min-w-[36rem] mv:flex-col mv:gap-4 mv:p-4\">\n <div className=\"mv:grid mv:min-h-0 mv:flex-1 mv:grid-cols-[auto_1fr] mv:grid-rows-[1fr_auto] mv:gap-1\">\n <AxisTitle axis={layout.y} domain={plot.domains.y} vertical />\n <div ref={setContainer} className=\"mv:relative mv:border-b mv:border-l mv:border-edge\">\n {/* Before the nodes, so the opaque nodes cover the ends of the lines. */}\n <EdgeOverlay links={links} elements={elements} container={container} routing=\"straight\" />\n {/* Inset, so nodes at the ends of a domain stay inside the plot. */}\n <div className=\"mv:absolute mv:inset-8\">\n {plot.points.map((point) => (\n <div\n key={point.key}\n data-occurrence={`${instanceId}${point.key}`}\n className={`mv:absolute mv:flex mv:items-center mv:gap-1 ${shape ? 'mv:-translate-x-3 mv:translate-y-3' : 'mv:-translate-x-1/2 mv:translate-y-1/2'}`}\n style={{ left: `${point.x * 100}%`, bottom: `${point.y * 100}%` }}\n >\n <div ref={register(point.key)}>\n <NodeCard node={point.node} repeat={false} nodes={region.nodes} onSelect={onNodeSelect} />\n </div>\n {shape && (\n <span className=\"mv:whitespace-nowrap mv:rounded mv:bg-surface/80 mv:px-0.5 mv:text-xs\">\n {point.node.title}\n </span>\n )}\n </div>\n ))}\n </div>\n </div>\n <div />\n <AxisTitle axis={layout.x} domain={plot.domains.x} />\n </div>\n\n {plot.unplaced.length > 0 && (\n <section className=\"mv:flex mv:flex-col mv:gap-2\">\n <span className=\"mv:text-xs mv:font-semibold mv:text-muted\">Not plotted</span>\n <ul className=\"mv:m-0 mv:flex mv:list-none mv:flex-wrap mv:gap-3 mv:p-0\">\n {plot.unplaced.map(({ key, node, reasons }) => (\n <li key={key} data-occurrence={`${instanceId}${key}`} className=\"mv:flex mv:items-center mv:gap-1\">\n <NodeCard node={node} repeat={false} nodes={region.nodes} onSelect={onNodeSelect} />\n <span className=\"mv:text-xs\">\n {shape && `${node.title} `}\n <span className=\"mv:text-muted\">({reasons.join('; ')})</span>\n </span>\n </li>\n ))}\n </ul>\n </section>\n )}\n </div>\n );\n}\n\n/** Axis title with the values at each end, in drawing order. */\nfunction AxisTitle({\n axis,\n domain: [min, max],\n vertical = false,\n}: {\n axis: AxisConfig;\n domain: readonly [number, number];\n vertical?: boolean;\n}) {\n const [start, end] = axis.direction === 'descending' ? [max, min] : [min, max];\n return (\n <div\n className={`mv:flex mv:items-center mv:justify-between mv:gap-2 mv:text-xs mv:text-muted ${vertical ? 'mv:flex-col-reverse mv:py-8' : 'mv:px-8'}`}\n >\n <span>{format(start)}</span>\n <span className={`mv:font-semibold ${vertical ? 'mv:[writing-mode:vertical-rl] mv:rotate-180' : ''}`}>\n {axis.label ?? axis.field}\n </span>\n <span>{format(end)}</span>\n </div>\n );\n}\n\nfunction format(value: number): string {\n return Number.isInteger(value) ? String(value) : value.toPrecision(3).replace(/\\.?0+$/, '');\n}\n","import { useId, useMemo } from 'react';\nimport type { SpaceGraph, SpaceNode } from 'structured-context/api';\nimport { type AnnotationIndex, filterAnnotations } from '../core/annotations';\nimport { type MapViewDefinition, type ParameterValues, type Region, resolveRegions } from '../core/definition';\nimport { AnnotationsContext } from './annotations-context';\nimport { LandscapeLayout } from './LandscapeLayout';\nimport { type LayoutProps, TreeLayout } from './TreeLayout';\nimport { XYLayout } from './XYLayout';\n\ntype Props = {\n definition: MapViewDefinition;\n graph: SpaceGraph;\n /** Current parameter values (host-owned session state); missing values use defaults. */\n values?: ParameterValues;\n /**\n * Validation results by node (see `annotationsFrom`). Which of them show, and at what severity, is\n * the region's `nodes.validation` setting; with none supplied, nothing is drawn.\n */\n annotations?: AnnotationIndex;\n onNodeSelect?: (node: SpaceNode) => void;\n};\n\nconst EMPTY: AnnotationIndex = new Map();\n\n/** Renders a map view definition against a space. Sizes to its container and scrolls within it. */\nexport function MapView({ definition, graph, values, annotations, onNodeSelect }: Props) {\n const instanceId = useId();\n const regions = useMemo(() => resolveRegions(definition, values), [definition, values]);\n // PROTOTYPE: only the first region is rendered. Arranging several regions is undesigned (#8).\n const region = regions[0]!;\n const props = { graph, instanceId, onNodeSelect };\n const { validation, validationSources } = region.nodes;\n const visibleAnnotations = useMemo(\n () => (annotations ? filterAnnotations(annotations, validation, validationSources) : EMPTY),\n [annotations, validation, validationSources],\n );\n\n return (\n <AnnotationsContext.Provider value={visibleAnnotations}>\n <div className=\"mv:h-full mv:w-full mv:overflow-auto mv:bg-surface mv:text-ink\">{layoutFor(region, props)}</div>\n </AnnotationsContext.Provider>\n );\n}\n\nfunction layoutFor(region: Region, props: Omit<LayoutProps, 'region'>) {\n const { layout } = region;\n switch (layout.type) {\n case 'tree':\n return <TreeLayout {...props} region={{ ...region, layout }} />;\n case 'landscape':\n return <LandscapeLayout {...props} region={{ ...region, layout }} />;\n case 'xy':\n return <XYLayout {...props} region={{ ...region, layout }} />;\n }\n}\n","import { useId } from 'react';\nimport type { Parameter, ParameterControl } from '../core/definition';\n\ntype InputProps<Kind extends ParameterControl['kind']> = {\n parameter: Parameter & { control: Extract<ParameterControl, { kind: Kind }> };\n value: unknown;\n onChange: (value: unknown) => void;\n};\n\nconst same = (a: unknown, b: unknown) => JSON.stringify(a) === JSON.stringify(b);\n\n/** A checkbox for a boolean parameter, labelled with the parameter's title. */\nexport function ToggleParameterInput({ parameter, value, onChange }: InputProps<'toggle'>) {\n const id = useId();\n return (\n <>\n <input id={id} type=\"checkbox\" checked={value === true} onChange={(e) => onChange(e.target.checked)} />\n <label htmlFor={id}>{parameter.title}</label>\n </>\n );\n}\n\n/** A dropdown for a parameter with one of several options. */\nexport function SelectParameterInput({ parameter, value, onChange }: InputProps<'select'>) {\n const id = useId();\n return (\n <>\n <label htmlFor={id} className=\"mv:text-muted\">\n {parameter.title}\n </label>\n <select id={id} value={JSON.stringify(value)} onChange={(e) => onChange(JSON.parse(e.target.value))}>\n {parameter.control.options.map((option) => (\n <option key={JSON.stringify(option)} value={JSON.stringify(option)}>\n {String(option)}\n </option>\n ))}\n </select>\n </>\n );\n}\n\n/** A checkbox group for a parameter taking any subset of its options. */\nexport function MultiSelectParameterInput({ parameter, value, onChange }: InputProps<'multiselect'>) {\n const { options } = parameter.control;\n const selected = Array.isArray(value) ? value : [];\n return (\n <fieldset className=\"mv:m-0 mv:flex mv:flex-wrap mv:items-center mv:gap-2 mv:border-0 mv:p-0\">\n <legend className=\"mv:float-left mv:mr-1.5 mv:p-0 mv:text-muted\">{parameter.title}</legend>\n {options.map((option) => {\n const checked = selected.some((v) => same(v, option));\n return (\n <label key={JSON.stringify(option)} className=\"mv:flex mv:items-center mv:gap-1\">\n <input\n type=\"checkbox\"\n checked={checked}\n onChange={() =>\n // Keep the options' order rather than the order of clicks.\n onChange(options.filter((o) => (o === option ? !checked : selected.some((v) => same(v, o)))))\n }\n />\n {String(option)}\n </label>\n );\n })}\n </fieldset>\n );\n}\n\n/** The input matching a parameter's control kind. */\nexport function ParameterInput({\n parameter,\n value,\n onChange,\n}: Omit<InputProps<ParameterControl['kind']>, 'parameter'> & { parameter: Parameter }) {\n const { control } = parameter;\n switch (control.kind) {\n case 'toggle':\n return <ToggleParameterInput parameter={{ ...parameter, control }} value={value} onChange={onChange} />;\n case 'select':\n return <SelectParameterInput parameter={{ ...parameter, control }} value={value} onChange={onChange} />;\n case 'multiselect':\n return <MultiSelectParameterInput parameter={{ ...parameter, control }} value={value} onChange={onChange} />;\n }\n}\n","import { useMemo } from 'react';\nimport {\n type MapViewDefinition,\n type Parameter,\n type ParameterValues,\n resolveParameterValues,\n} from '../core/definition';\n\n/** One parameter with its current value and a setter, ready for a host to lay out. */\nexport type ParameterControlState = {\n parameter: Parameter;\n /** The value in effect: the host's value, else the default, matching what renders. */\n value: unknown;\n setValue: (value: unknown) => void;\n};\n\n/**\n * The state behind a map view's parameter controls, with no markup, for hosts that lay the controls\n * out themselves. Pair each entry with `ParameterInput`, or with one of the typed inputs.\n */\nexport function useParameterControls(\n definition: MapViewDefinition,\n values: ParameterValues,\n onChange: (name: string, value: unknown) => void,\n): ParameterControlState[] {\n const resolved = useMemo(() => resolveParameterValues(definition, values), [definition, values]);\n return definition.parameters.map((parameter) => ({\n parameter,\n value: resolved[parameter.name],\n setValue: (value) => onChange(parameter.name, value),\n }));\n}\n","import type { MapViewDefinition, ParameterValues } from '../core/definition';\nimport { ParameterInput } from './ParameterInputs';\nimport { useParameterControls } from './useParameterControls';\n\ntype Props = {\n definition: MapViewDefinition;\n /** Host-owned values; missing or stale ones show as the default, matching what renders. */\n values: ParameterValues;\n onChange: (name: string, value: unknown) => void;\n};\n\n/**\n * Default layout for a map view's parameter controls: a wrapping row. Hosts wanting their own layout\n * use `useParameterControls` with `ParameterInput` (or the typed inputs) instead.\n */\nexport function ParameterControls({ definition, values, onChange }: Props) {\n const controls = useParameterControls(definition, values, onChange);\n if (controls.length === 0) return null;\n return (\n <div className=\"mv:flex mv:flex-wrap mv:items-center mv:gap-x-4 mv:gap-y-2 mv:text-sm\">\n {controls.map(({ parameter, value, setValue }) => (\n <div key={parameter.name} className=\"mv:flex mv:items-center mv:gap-1.5\" title={parameter.description}>\n <ParameterInput parameter={parameter} value={value} onChange={setValue} />\n </div>\n ))}\n </div>\n );\n}\n"],"mappings":";;;;;AAMA,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A,SAAgB,kBAAkB,EAAE,YAAY,QAAQ,YAAmB;CACzE,MAAM,WAAW,qBAAqB,YAAY,QAAQ,QAAQ;CAClE,IAAI,SAAS,WAAW,GAAG,OAAO;CAClC,OACE,oBAAC,OAAD;EAAK,WAAU;EACZ,UAAA,SAAS,KAAK,EAAE,WAAW,OAAO,eACjC,oBAAC,OAAD;GAA0B,WAAU;GAAqC,OAAO,UAAU;GACxF,UAAA,oBAAC,gBAAD;IAA2B;IAAkB;IAAO,UAAU;GAAW,CAAA;EACtE,GAFK,UAAU,IAEf,CACN;CACE,CAAA;AAET"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"definition-Cp1CCigh.js","names":[],"sources":["../src/core/format/schema-url.ts","../src/core/format/param-ref.ts","../src/core/format/definition-schema.ts","../src/core/format/landscape-layout.ts","../src/core/format/settings.ts","../src/core/format/tree-layout.ts","../src/core/format/xy-layout.ts","../src/core/format/index.ts","../src/core/definition.ts"],"sourcesContent":["/**\n * Where the format schemas are published. `latest` follows the newest format; a release that changes it\n * freezes a copy under its own version folder (`bun run generate:schemas --release`).\n */\nexport const SCHEMA_BASE_URL =\n 'https://raw.githubusercontent.com/mindsocket/structured-context-map-views/main/schemas/generated';\n\n/** Base of the `$id`s the sources use: the `latest` folder. */\nexport const SCHEMA_URL = `${SCHEMA_BASE_URL}/latest` as const;\n","import { SCHEMA_URL } from './schema-url';\n/** `$ref` target for a setting whose value comes from a declared parameter. */\nexport const PARAM_REF = `${SCHEMA_URL}/definition.json#/$defs/paramRef` as const;\n\n/** A setting that takes either a fixed value matching `valueSchema` or a `{ $param }` binding. */\nexport function parameterisable<const S extends object, const D>(valueSchema: S, defaultValue: D, description: string) {\n return { description, default: defaultValue, anyOf: [valueSchema, { $ref: PARAM_REF }] } as const;\n}\n","import { VALIDATION_ISSUE_KINDS } from 'structured-context/types';\nimport { PARAM_REF, parameterisable } from './param-ref';\nimport { SCHEMA_URL } from './schema-url';\n\n/**\n * The map view definition format: shared parameters, and the regions a map view is composed of.\n *\n * Written as TypeScript so the definition types derive from it (`FromSchema`); the JSON files\n * for `$schema` references and editors are generated (`bun run generate:schemas`).\n */\nexport const definitionSchema = {\n $schema: 'https://json-schema.org/draft/2020-12/schema',\n $id: `${SCHEMA_URL}/definition.json`,\n title: 'Map view definition',\n description:\n 'Declares how spaces of one schema are projected into a map view: shared parameters, and the regions the map view is composed of.',\n type: 'object',\n required: ['$id', 'schema', 'regions'],\n additionalProperties: false,\n properties: {\n $schema: { type: 'string' },\n $id: {\n type: 'string',\n pattern: '^sctx-map-view://[^/]+(/[^/]+)?$',\n description:\n 'Identifier, namespaced by where the definition is found: \"sctx-map-view://core/<name>\" (bundled), \"sctx-map-view://<plugin>/<name>\" (a plugin) or \"sctx-map-view://<name>\" (the config folder).',\n },\n title: { type: 'string', minLength: 1, description: 'Display name. Defaults to the last segment of the `$id`.' },\n description: { type: 'string' },\n schema: {\n type: 'string',\n minLength: 1,\n description: '`$id` of the structured-context schema whose spaces this map view applies to.',\n },\n parameters: {\n type: 'object',\n description:\n 'Settings the reader can change. Each is a JSON Schema with a default, bound to settings anywhere in the definition with { \"$param\": \"<name>\" }.',\n additionalProperties: { $ref: '#/$defs/parameter' },\n },\n regions: {\n type: 'array',\n minItems: 1,\n description:\n 'Parts of the map view, each with its own layout, nodes and edges. Only the first region is rendered for now.',\n items: { $ref: '#/$defs/region' },\n },\n },\n $defs: {\n parameter: {\n type: 'object',\n description:\n \"A JSON Schema for the parameter's values (it can $ref, narrow or extend the bundled setting definitions), plus a title for its control.\",\n required: ['default'],\n properties: {\n title: { type: 'string' },\n description: { type: 'string' },\n default: {},\n },\n },\n paramRef: {\n type: 'object',\n description: \"Takes this setting's value from a declared parameter.\",\n required: ['$param'],\n additionalProperties: false,\n properties: { $param: { type: 'string', minLength: 1 } },\n },\n region: {\n type: 'object',\n required: ['id', 'layout'],\n additionalProperties: false,\n properties: {\n id: {\n type: 'string',\n minLength: 1,\n description: 'Unique within the map view; part of every occurrence id in the region.',\n },\n select: {\n type: 'object',\n description: 'Which nodes of the space the region shows. By default, all of them.',\n additionalProperties: false,\n properties: {\n filter: {\n type: 'string',\n minLength: 1,\n description:\n \"A structured-context filter: a view name from the space's config, or an expression such as `WHERE …` or `SELECT … WHERE …`.\",\n },\n },\n },\n layout: {\n description: 'How the region is arranged, chosen by `type`.',\n type: 'object',\n required: ['type'],\n // Ajv validates only the branch `type` selects, so errors name that layout's settings.\n discriminator: { propertyName: 'type' },\n oneOf: [\n { $ref: `${SCHEMA_URL}/layouts/tree.json` },\n { $ref: `${SCHEMA_URL}/layouts/landscape.json` },\n { $ref: `${SCHEMA_URL}/layouts/xy.json` },\n ],\n },\n nodes: {\n type: 'object',\n additionalProperties: false,\n default: {},\n properties: {\n style: parameterisable(\n { $ref: `${SCHEMA_URL}/settings.json#/$defs/nodeStyle` },\n 'card',\n 'How nodes are drawn.',\n ),\n fields: parameterisable(\n { $ref: `${SCHEMA_URL}/settings.json#/$defs/fieldList` },\n [],\n 'Schema fields shown on cards.',\n ),\n validation: parameterisable(\n { $ref: `${SCHEMA_URL}/settings.json#/$defs/validationLevel` },\n 'off',\n 'The lowest severity of validation result shown on nodes, or off. Needs the host to supply results.',\n ),\n validationSources: parameterisable(\n { $ref: `${SCHEMA_URL}/settings.json#/$defs/validationSources` },\n VALIDATION_ISSUE_KINDS,\n 'Which kinds of validation result are shown.',\n ),\n },\n },\n edges: {\n type: 'object',\n additionalProperties: false,\n default: {},\n properties: {\n show: parameterisable({ type: 'boolean' }, true, 'Whether connectors are drawn.'),\n },\n },\n },\n },\n },\n} as const;\n\nexport { PARAM_REF };\n","import { PARAM_REF, parameterisable } from './param-ref';\nimport { SCHEMA_URL } from './schema-url';\n\n/** Settings of the landscape layout: nested containers following an authored grouping. */\nexport const landscapeLayoutSchema = {\n $schema: 'https://json-schema.org/draft/2020-12/schema',\n $id: `${SCHEMA_URL}/layouts/landscape.json`,\n title: 'Landscape layout',\n description:\n 'Nested containers: each grouping level becomes containers inside the level above, and the last level is drawn as nodes.',\n type: 'object',\n required: ['type', 'group'],\n additionalProperties: false,\n properties: {\n type: { const: 'landscape' },\n orientation: parameterisable(\n { $ref: `${SCHEMA_URL}/settings.json#/$defs/orientation` },\n 'horizontal',\n 'horizontal: top-level containers side by side, as columns. vertical: stacked, as rows.',\n ),\n group: {\n type: 'array',\n minItems: 1,\n description:\n 'Grouping levels, outermost first. The last level is drawn as nodes; the others as containers. Adjacent node levels are joined by any edge between their types, in either direction.',\n // Dispatch on `field`, so errors come from the kind of level written, not both.\n items: {\n type: 'object',\n if: { type: 'object', required: ['field'] },\n // biome-ignore lint/suspicious/noThenProperty: JSON Schema's `then` keyword.\n then: {\n type: 'object',\n description:\n \"Containers labelled by the values of a field of the next node level's nodes. A node with several values appears under each.\",\n required: ['field'],\n additionalProperties: false,\n properties: { field: { type: 'string', minLength: 1 } },\n },\n else: {\n type: 'object',\n description: 'A level of nodes of one type.',\n required: ['type'],\n additionalProperties: false,\n properties: {\n type: {\n description: 'Node type at this level.',\n anyOf: [{ type: 'string', minLength: 1 }, { $ref: PARAM_REF }],\n },\n edge: {\n type: 'object',\n description:\n 'Which edges join this level to the node level above (or to the last `via` type). By default, any edge between the two types.',\n required: ['field'],\n additionalProperties: false,\n properties: { field: { type: 'string', minLength: 1 } },\n },\n via: {\n type: 'array',\n minItems: 1,\n description:\n 'Types skipped between the node level above and this one, in order. Nodes are joined through a chain of edges across them. Ignored on the first level, which has no level above.',\n items: { type: 'string', minLength: 1 },\n },\n intermediate: parameterisable(\n { $ref: `${SCHEMA_URL}/layouts/landscape.json#/$defs/intermediate` },\n 'hidden',\n 'How the skipped nodes of a `via` chain are shown.',\n ),\n },\n },\n },\n },\n },\n $defs: {\n intermediate: {\n title: 'Skipped levels',\n description: 'hidden: not shown. breadcrumb: listed on each node reached through them.',\n enum: ['hidden', 'breadcrumb'],\n },\n },\n} as const;\n","import { VALIDATION_ISSUE_KINDS } from 'structured-context/types';\nimport { SCHEMA_URL } from './schema-url';\n/** Reusable setting definitions. Parameters can `$ref` these and narrow them, e.g. with `allOf` and `enum`. */\nexport const settingsSchema = {\n $schema: 'https://json-schema.org/draft/2020-12/schema',\n $id: `${SCHEMA_URL}/settings.json`,\n title: 'Shared map view settings',\n description: 'Reusable setting definitions. Parameters can $ref these and narrow them, e.g. with allOf and enum.',\n $defs: {\n orientation: {\n title: 'Orientation',\n enum: ['vertical', 'horizontal'],\n },\n nodeStyle: {\n title: 'Node style',\n description: 'card: a box with the title and selected fields. shape: a compact marker with a tooltip.',\n enum: ['card', 'shape'],\n },\n validationLevel: {\n title: 'Validation overlay',\n description:\n 'The lowest severity of validation result shown on nodes, or off. error: only errors. warning: errors and warnings. info: everything.',\n enum: ['off', 'error', 'warning', 'info'],\n },\n validationSources: {\n title: 'Validation sources',\n description:\n 'Which kinds of validation result are shown. schema: a node failing its schema. duplicate: an id more than one node uses. broken-link: a relationship to a node that does not exist. hierarchy: a node under a parent type it is not allowed under. rule: a schema rule violation. gated: a note that rules were not checked because an ancestor failed. content-link: a link in the body that resolves to no node.',\n type: 'array',\n items: { enum: VALIDATION_ISSUE_KINDS },\n uniqueItems: true,\n },\n fieldList: {\n title: 'Fields',\n type: 'array',\n items: { type: 'string', minLength: 1 },\n uniqueItems: true,\n },\n },\n} as const;\n","import { parameterisable } from './param-ref';\nimport { SCHEMA_URL } from './schema-url';\n\n/** Settings of the tree layout: a tree over the schema's hierarchy. */\nexport const treeLayoutSchema = {\n $schema: 'https://json-schema.org/draft/2020-12/schema',\n $id: `${SCHEMA_URL}/layouts/tree.json`,\n title: 'Tree layout',\n description: \"A tree over the schema's hierarchy: root-type nodes at the top, children via hierarchy edges.\",\n type: 'object',\n required: ['type'],\n additionalProperties: false,\n properties: {\n type: { const: 'tree' },\n orientation: parameterisable(\n { $ref: `${SCHEMA_URL}/settings.json#/$defs/orientation` },\n 'vertical',\n 'Direction the tree grows.',\n ),\n dag: parameterisable(\n { $ref: `${SCHEMA_URL}/layouts/tree.json#/$defs/dag` },\n 'repeat',\n 'How a node with several parents is shown.',\n ),\n },\n $defs: {\n dag: {\n title: 'Nodes with several parents',\n description:\n 'repeat: the node appears under each parent, its subtree shown once. cross-edge: the node appears under its first parent, with extra connectors from the others.',\n enum: ['repeat', 'cross-edge'],\n },\n },\n} as const;\n","import { PARAM_REF, parameterisable } from './param-ref';\nimport { SCHEMA_URL } from './schema-url';\n\n/** Settings of the XY layout: nodes positioned by two numeric fields. */\nexport const xyLayoutSchema = {\n $schema: 'https://json-schema.org/draft/2020-12/schema',\n $id: `${SCHEMA_URL}/layouts/xy.json`,\n title: 'XY layout',\n description:\n 'Nodes positioned on two axes by numeric fields. Nodes of the plotted types without a usable value on both axes are listed beside the plot, not dropped.',\n type: 'object',\n required: ['type', 'x', 'y'],\n additionalProperties: false,\n properties: {\n type: { const: 'xy' },\n x: { $ref: `${SCHEMA_URL}/layouts/xy.json#/$defs/axis` },\n y: { $ref: `${SCHEMA_URL}/layouts/xy.json#/$defs/axis` },\n types: parameterisable(\n { type: 'array', items: { type: 'string', minLength: 1 }, uniqueItems: true },\n [],\n 'Node types to plot. Empty: every type with a value on either axis.',\n ),\n edgeFields: parameterisable(\n { $ref: `${SCHEMA_URL}/settings.json#/$defs/fieldList` },\n [],\n 'Fields whose edges are drawn between plotted nodes. Empty: all edges.',\n ),\n },\n $defs: {\n axis: {\n title: 'Axis',\n type: 'object',\n required: ['field'],\n additionalProperties: false,\n properties: {\n field: {\n description: 'Numeric field giving the position.',\n anyOf: [{ type: 'string', minLength: 1 }, { $ref: PARAM_REF }],\n },\n domain: {\n description:\n 'Values at the two ends of the axis: [min, max], or \"data\" for the smallest and largest plotted values. Nodes outside a fixed domain are listed as unplaced.',\n default: 'data',\n anyOf: [{ const: 'data' }, { type: 'array', items: { type: 'number' }, minItems: 2, maxItems: 2 }],\n },\n direction: parameterisable(\n { $ref: `${SCHEMA_URL}/layouts/xy.json#/$defs/direction` },\n 'ascending',\n 'ascending: values grow rightwards (x) or upwards (y). descending: the reverse.',\n ),\n label: { type: 'string', description: 'Axis title. Defaults to the field name.' },\n },\n },\n direction: {\n title: 'Axis direction',\n enum: ['ascending', 'descending'],\n },\n },\n} as const;\n","import { definitionSchema } from './definition-schema';\nimport { landscapeLayoutSchema } from './landscape-layout';\nimport { settingsSchema } from './settings';\nimport { treeLayoutSchema } from './tree-layout';\nimport { xyLayoutSchema } from './xy-layout';\n\nexport { PARAM_REF } from './param-ref';\nexport { definitionSchema, landscapeLayoutSchema, settingsSchema, treeLayoutSchema, xyLayoutSchema };\n\n/** The bundled schemas describing the map view definition format. */\nexport const MAP_VIEW_SCHEMAS = [\n definitionSchema,\n settingsSchema,\n treeLayoutSchema,\n landscapeLayoutSchema,\n xyLayoutSchema,\n] as const;\n","import Ajv2020, { type AnySchemaObject, type ErrorObject } from 'ajv/dist/2020';\nimport type { FromSchema } from 'json-schema-to-ts';\nimport JSON5 from 'json5';\nimport {\n definitionSchema,\n type landscapeLayoutSchema,\n MAP_VIEW_SCHEMAS,\n type settingsSchema,\n type treeLayoutSchema,\n type xyLayoutSchema,\n} from './format';\nimport { SCHEMA_URL } from './format/schema-url';\n\nexport { MAP_VIEW_SCHEMAS };\n\ntype References = {\n references: [\n typeof settingsSchema,\n typeof treeLayoutSchema,\n typeof landscapeLayoutSchema,\n typeof xyLayoutSchema,\n typeof definitionSchema,\n ];\n // Grouping levels dispatch with if/then/else (see the landscape layout schema).\n parseIfThenElseKeywords: true;\n};\ntype ParamRef = { $param: string };\n/** Drop `{ $param }` bindings from every setting's type: what remains after resolution. */\ntype Resolved<T> = T extends ParamRef\n ? never\n : T extends readonly (infer U)[]\n ? Resolved<U>[]\n : T extends object\n ? { [K in keyof T]: Resolved<T[K]> }\n : T;\n\n/** A definition as authored: settings may be `{ $param }` bindings, defaulted properties may be absent. */\nexport type AuthoredDefinition = FromSchema<\n typeof definitionSchema,\n References & { keepDefaultedPropertiesOptional: true }\n>;\ntype FilledDefinition = FromSchema<typeof definitionSchema, References>;\n\n/** A region with parameters applied and defaults filled in: what layouts receive. */\nexport type Region = Resolved<FilledDefinition['regions'][number]>;\nexport type LayoutConfig = Region['layout'];\nexport type TreeLayoutConfig = Extract<LayoutConfig, { type: 'tree' }>;\nexport type LandscapeLayoutConfig = Extract<LayoutConfig, { type: 'landscape' }>;\nexport type XYLayoutConfig = Extract<LayoutConfig, { type: 'xy' }>;\nexport type AxisConfig = XYLayoutConfig['x'];\nexport type GroupLevel = LandscapeLayoutConfig['group'][number];\nexport type IntermediateDisplay = Extract<GroupLevel, { type: string }>['intermediate'];\nexport type NodesConfig = Region['nodes'];\nexport type EdgesConfig = Region['edges'];\nexport type Orientation = TreeLayoutConfig['orientation'];\nexport type DagMode = TreeLayoutConfig['dag'];\nexport type NodeStyle = NodesConfig['style'];\n\n/**\n * A validated map view definition. Plain data, so hosts can pass it across a server/browser\n * boundary. Settings in `source` may still be `{ $param }` bindings; {@link resolveRegions}\n * replaces them with parameter values.\n */\nexport type MapViewDefinition = {\n /** The definition's `$id`. */\n id: string;\n title: string;\n description?: string;\n /** `$id` of the schema whose spaces this map view applies to. */\n schema: string;\n parameters: Parameter[];\n /** The definition as authored. */\n source: AuthoredDefinition;\n};\n\n/** A setting the reader can change, with the control generated from its schema. */\nexport type Parameter = {\n name: string;\n title: string;\n description?: string;\n default: unknown;\n control: ParameterControl;\n};\n\n/** Options are JSON primitives, so they can be labelled and compared directly. */\nexport type ParameterControl =\n | { kind: 'select'; options: readonly Primitive[] }\n | { kind: 'multiselect'; options: readonly Primitive[] }\n | { kind: 'toggle' };\n\ntype Primitive = string | number | boolean | null;\n\nexport type ParameterValues = Readonly<Record<string, unknown>>;\n\nexport class MapViewDefinitionError extends Error {\n constructor(name: string, message: string) {\n super(`Map view \"${name}\": ${message}`);\n this.name = 'MapViewDefinitionError';\n }\n}\n\nconst newAjv = (options: { useDefaults?: boolean } = {}) =>\n new Ajv2020({\n allErrors: true,\n discriminator: true,\n ...options,\n schemas: MAP_VIEW_SCHEMAS.map((s) => structuredClone(s) as AnySchemaObject),\n });\n\n/** Validates definitions as authored. */\nconst ajv = newAjv();\nconst validateDefinition = ajv.getSchema(definitionSchema.$id)!;\n/** Validates resolved definitions, filling in setting defaults from the schemas. */\nconst fillDefaults = newAjv({ useDefaults: true }).getSchema(definitionSchema.$id)!;\n\n/**\n * Parse a JSON5 map view definition and check it against the bundled schemas. `name` labels\n * error messages (hosts pass where the definition came from).\n *\n * Beyond schema validation: every parameter needs a control derivable from its schema, and\n * every value that control can produce must satisfy the parameter's schema; every `$param`\n * must name a declared parameter; and each parameter's values must be valid wherever it's\n * bound, checked by substituting them and re-validating.\n */\nexport function parseMapViewDefinition(name: string, text: string): MapViewDefinition {\n const fail = (message: string): never => {\n throw new MapViewDefinitionError(name, message);\n };\n\n let raw: unknown;\n try {\n raw = JSON5.parse(text);\n } catch (err) {\n return fail(`invalid JSON5: ${err instanceof Error ? err.message : String(err)}`);\n }\n if (!validateDefinition(raw)) return fail(formatErrors(validateDefinition.errors, raw));\n const source = raw as AuthoredDefinition;\n\n // A fresh instance per parse, so compiled parameter schemas aren't cached indefinitely.\n const parameterAjv = newAjv();\n const declared = (source.parameters ?? {}) as Record<string, AnySchemaObject>;\n const parameters = Object.entries(declared).map(([paramName, schema]) =>\n parseParameter(paramName, schema, parameterAjv, (message) => fail(`parameter \"${paramName}\": ${message}`)),\n );\n\n for (const bound of paramNames(source.regions)) {\n if (!(bound in declared)) fail(`\"$param\": \"${bound}\" is not a declared parameter`);\n }\n checkBindings(source, parameters, fail);\n\n const regionIds = new Set<string>();\n for (const region of source.regions) {\n if (regionIds.has(region.id)) fail(`duplicate region id \"${region.id}\"`);\n regionIds.add(region.id);\n // A field level labels the nodes of a later level, so a node level must come last.\n if (region.layout.type === 'landscape' && !('type' in region.layout.group.at(-1)!)) {\n fail(`region \"${region.id}\": the last grouping level must be a node type, not a field`);\n }\n if (region.layout.type === 'xy') {\n for (const axis of ['x', 'y'] as const) {\n const { domain } = region.layout[axis];\n if (Array.isArray(domain) && !(domain[0]! < domain[1]!)) {\n fail(`region \"${region.id}\": ${axis} domain must be [min, max] with min < max`);\n }\n }\n }\n }\n\n return {\n id: source.$id,\n title: source.title ?? source.$id.slice(source.$id.lastIndexOf('/') + 1),\n ...(source.description !== undefined && { description: source.description }),\n schema: source.schema,\n parameters,\n source,\n };\n}\n\n/**\n * The value each parameter takes: the given value if its control could produce it, otherwise\n * (missing, or stale saved state) the default. Hosts' controls and rendering both use this.\n */\nexport function resolveParameterValues(definition: MapViewDefinition, values: ParameterValues = {}): ParameterValues {\n return Object.fromEntries(\n definition.parameters.map((param) => {\n const value = values[param.name];\n const chosen = value !== undefined && isProducible(param.control, value) ? value : param.default;\n return [param.name, structuredClone(chosen)];\n }),\n );\n}\n\n/** Apply parameter values to a definition's regions and fill in setting defaults. */\nexport function resolveRegions(definition: MapViewDefinition, values: ParameterValues = {}): Region[] {\n const resolved = resolveParameterValues(definition, values);\n const filled = substitute(definition.source, (paramName) => resolved[paramName]);\n if (!fillDefaults(filled)) {\n // parseMapViewDefinition checked every producible value, so this means a bug, not bad input.\n throw new MapViewDefinitionError(\n definition.id,\n `resolved definition is invalid: ${formatErrors(fillDefaults.errors, filled)}`,\n );\n }\n return (filled as FilledDefinition).regions as Region[];\n}\n\n/**\n * The filter selecting the nodes a map view shows, if any. Hosts apply it when loading the space.\n * PROTOTYPE: filters are evaluated by the host, not per region in the browser, because\n * structured-context's filter evaluator can't yet be bundled for a browser (its only entry point,\n * `structured-context/api`, imports Node built-ins). That's fine while only the first region renders.\n */\nexport function selectionFilter(definition: MapViewDefinition, values: ParameterValues = {}): string | undefined {\n return resolveRegions(definition, values)[0]?.select?.filter;\n}\n\n/**\n * The lowest severity of validation result the map view shows on nodes, or `off`. Hosts check it to\n * decide whether to run validation at all, since results are only drawn when this isn't `off`.\n */\nexport function viewValidationLevel(\n definition: MapViewDefinition,\n values: ParameterValues = {},\n): NodesConfig['validation'] {\n return resolveRegions(definition, values)[0]?.nodes.validation ?? 'off';\n}\n\n/** Map view definitions that apply to a space with the given schema. */\nexport function mapViewsForSchema(\n definitions: readonly MapViewDefinition[],\n schemaId: string | undefined,\n): MapViewDefinition[] {\n return schemaId === undefined ? [] : definitions.filter((d) => d.schema === schemaId);\n}\n\n/** Resolve `$ref`s relative to the format schemas, so parameters can write `settings.json#/$defs/orientation`. */\nfunction absoluteRefs(node: unknown): unknown {\n if (Array.isArray(node)) return node.map(absoluteRefs);\n if (typeof node !== 'object' || node === null) return node;\n return Object.fromEntries(\n Object.entries(node).map(([key, value]) => [\n key,\n key === '$ref' && typeof value === 'string' ? new URL(value, `${SCHEMA_URL}/`).href : absoluteRefs(value),\n ]),\n );\n}\n\nfunction parseParameter(\n name: string,\n schema: AnySchemaObject,\n parameterAjv: Ajv2020,\n fail: (message: string) => never,\n): Parameter {\n const { title, description, default: defaultValue, ...authored } = schema;\n const valueSchema = absoluteRefs(authored) as AnySchemaObject;\n let validate: (value: unknown) => boolean;\n try {\n validate = parameterAjv.compile(valueSchema);\n } catch (err) {\n return fail(`invalid schema: ${err instanceof Error ? err.message : String(err)}`);\n }\n if (!validate(defaultValue)) return fail(`default ${JSON.stringify(defaultValue)} doesn't match its schema`);\n\n const control = controlFor(valueSchema, fail);\n const invalid = producibleValues(control).filter((value) => !validate(value));\n if (invalid.length > 0) {\n fail(\n `its ${control.kind} control can produce ${invalid.map((v) => JSON.stringify(v)).join(', ')}, which its schema rejects; remove constraints the control can't enforce`,\n );\n }\n\n return {\n name,\n title: typeof title === 'string' ? title : (titleFromRef(valueSchema) ?? name),\n ...(typeof description === 'string' && { description }),\n default: defaultValue,\n control,\n };\n}\n\n/**\n * Values a control can produce, as checked against schemas. For a multi-select that's none,\n * each option alone, and all of them. PROTOTYPE: other subsets are assumed valid if these are,\n * which holds for the constraints in use (enum items, uniqueItems) but not, say, `contains`.\n */\nfunction producibleValues(control: ParameterControl): unknown[] {\n switch (control.kind) {\n case 'toggle':\n return [true, false];\n case 'select':\n return [...control.options];\n case 'multiselect':\n return [[], ...control.options.map((option) => [option]), [...control.options]];\n }\n}\n\n/**\n * Every `$param` binding must accept each value the parameter's control can produce.\n * PROTOTYPE: parameters are checked one at a time, with the others at their defaults, which\n * assumes their bindings don't constrain each other.\n */\nfunction checkBindings(source: AuthoredDefinition, parameters: Parameter[], fail: (message: string) => never) {\n const defaults = new Map(parameters.map((p) => [p.name, p.default]));\n for (const param of parameters) {\n for (const candidate of producibleValues(param.control)) {\n const substituted = substitute(source, (n) => (n === param.name ? candidate : defaults.get(n)));\n if (!validateDefinition(substituted)) {\n fail(\n `parameter \"${param.name}\" value ${JSON.stringify(candidate)} isn't valid where it's used: ${formatErrors(validateDefinition.errors, substituted)}`,\n );\n }\n }\n }\n}\n\n/**\n * Derive a control from a parameter's value schema: `enum` (directly, via `$ref`, or narrowed\n * with `allOf`) gives a select, an array of such items a multi-select, `boolean` a toggle.\n */\nfunction controlFor(schema: AnySchemaObject, fail: (message: string) => never): ParameterControl {\n if (typeOf(schema) === 'boolean') return { kind: 'toggle' };\n const isArray = typeOf(schema) === 'array';\n const options = isArray ? intersect(itemSchemas(schema).map(enumOf)) : enumOf(schema);\n if (!options) {\n return fail(\n 'no control can be generated: give it enum options (directly, or via $ref/allOf), array items with enum options, or type boolean',\n );\n }\n if (options.length === 0) return fail('its options narrow to nothing');\n if (!options.every(isPrimitive)) return fail('options must be strings, numbers, booleans or null');\n return { kind: isArray ? 'multiselect' : 'select', options };\n}\n\n/** Schemas linked from this one through `$ref` and `allOf`. */\nfunction linked(schema: AnySchemaObject): AnySchemaObject[] {\n const ref = typeof schema.$ref === 'string' ? ajv.getSchema(schema.$ref)?.schema : undefined;\n return [...(typeof ref === 'object' ? [ref] : []), ...((schema.allOf as AnySchemaObject[] | undefined) ?? [])];\n}\n\n/** Allowed values, intersecting `enum`/`const` with those reached through `$ref` and `allOf`. */\nfunction enumOf(schema: AnySchemaObject): unknown[] | undefined {\n return intersect([\n Array.isArray(schema.enum) ? schema.enum : undefined,\n 'const' in schema ? [schema.const] : undefined,\n ...linked(schema).map(enumOf),\n ]);\n}\n\nfunction typeOf(schema: AnySchemaObject): unknown {\n if (schema.type !== undefined) return schema.type;\n return linked(schema)\n .map(typeOf)\n .find((type) => type !== undefined);\n}\n\n/** Every `items` schema applying to an array, so their constraints can be intersected. */\nfunction itemSchemas(schema: AnySchemaObject): AnySchemaObject[] {\n return [...(typeof schema.items === 'object' ? [schema.items] : []), ...linked(schema).flatMap(itemSchemas)];\n}\n\nfunction intersect(sets: (unknown[] | undefined)[]): unknown[] | undefined {\n const defined = sets.filter((set): set is unknown[] => set !== undefined);\n if (defined.length === 0) return undefined;\n const key = (v: unknown) => JSON.stringify(v);\n return defined.reduce((acc, set) => acc.filter((v) => set.some((w) => key(w) === key(v))));\n}\n\nfunction titleFromRef(schema: AnySchemaObject): string | undefined {\n const title = linked(schema)[0]?.title;\n return typeof title === 'string' ? title : undefined;\n}\n\nfunction isPrimitive(value: unknown): value is Primitive {\n return value === null || ['string', 'number', 'boolean'].includes(typeof value);\n}\n\nfunction isProducible(control: ParameterControl, value: unknown): boolean {\n switch (control.kind) {\n case 'toggle':\n return typeof value === 'boolean';\n case 'select':\n return control.options.includes(value as Primitive);\n case 'multiselect':\n return Array.isArray(value) && value.every((v) => control.options.includes(v));\n }\n}\n\nfunction isParamRef(value: unknown): value is ParamRef {\n return typeof value === 'object' && value !== null && typeof (value as { $param?: unknown }).$param === 'string';\n}\n\n/** Copy a JSON value, replacing each `{ $param }` binding with its value. */\nfunction substitute(value: unknown, valueFor: (paramName: string) => unknown): unknown {\n if (isParamRef(value)) return structuredClone(valueFor(value.$param));\n if (Array.isArray(value)) return value.map((v) => substitute(v, valueFor));\n if (typeof value === 'object' && value !== null) {\n return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, substitute(v, valueFor)]));\n }\n return value;\n}\n\nfunction paramNames(value: unknown): string[] {\n if (isParamRef(value)) return [value.$param];\n if (Array.isArray(value)) return value.flatMap(paramNames);\n if (typeof value === 'object' && value !== null) return Object.values(value).flatMap(paramNames);\n return [];\n}\n\n/**\n * Readable Ajv errors. A setting accepts a value or a `{ $param }` binding (`anyOf`), so a bad\n * value also fails the binding branch; those errors, and the bare anyOf summary, are dropped\n * unless the value actually is a binding. An `if` failure only repeats its branch's errors.\n */\nfunction formatErrors(errors: ErrorObject[] | null | undefined, instance: unknown): string {\n const relevant = (errors ?? []).filter(\n (e) =>\n e.keyword !== 'anyOf' &&\n e.keyword !== 'if' &&\n !(e.schemaPath.includes('/$defs/paramRef') && !isParamRef(at(instance, e.instancePath))),\n );\n return relevant.map((e) => `${e.instancePath || '/'} ${message(e)}${detail(e)}`).join('; ');\n}\n\n/** The value at a JSON pointer. */\nfunction at(value: unknown, pointer: string): unknown {\n return pointer\n .split('/')\n .slice(1)\n .map((segment) => segment.replaceAll('~1', '/').replaceAll('~0', '~'))\n .reduce<unknown>(\n (node, key) => (typeof node === 'object' && node !== null ? (node as Record<string, unknown>)[key] : undefined),\n value,\n );\n}\n\nfunction message(error: ErrorObject): string | undefined {\n if (error.keyword === 'discriminator' && error.params.error === 'mapping') {\n return `has unknown ${error.params.tag} ${JSON.stringify(error.params.tagValue)}`;\n }\n return error.message;\n}\n\nfunction detail(error: ErrorObject): string {\n if (error.keyword === 'additionalProperties') return ` (\"${error.params.additionalProperty}\")`;\n if (error.keyword === 'enum') {\n return ` (${(error.params.allowedValues as unknown[]).map((v) => JSON.stringify(v)).join(', ')})`;\n }\n return '';\n}\n"],"mappings":";;;;AAQA,IAAa,aAAa;;;;ACN1B,IAAa,YAAY,GAAG,WAAW;;AAGvC,SAAgB,gBAAiD,aAAgB,cAAiB,aAAqB;CACrH,OAAO;EAAE;EAAa,SAAS;EAAc,OAAO,CAAC,aAAa,EAAE,MAAM,UAAU,CAAC;CAAE;AACzF;;;;;;;;;ACGA,IAAa,mBAAmB;CAC9B,SAAS;CACT,KAAK,GAAG,WAAW;CACnB,OAAO;CACP,aACE;CACF,MAAM;CACN,UAAU;EAAC;EAAO;EAAU;CAAS;CACrC,sB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IAAI,GAAG,QAAQ,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,IAAI;AAC5F;;AAGA,SAAS,GAAG,OAAgB,SAA0B;CACpD,OAAO,QACJ,MAAM,GAAG,CAAC,CACV,MAAM,CAAC,CAAC,CACR,KAAK,YAAY,QAAQ,WAAW,MAAM,GAAG,CAAC,CAAC,WAAW,MAAM,GAAG,CAAC,CAAC,CACrE,QACE,MAAM,QAAS,OAAO,SAAS,YAAY,SAAS,OAAQ,KAAiC,OAAO,KAAA,GACrG,KACF;AACJ;AAEA,SAAS,QAAQ,OAAwC;CACvD,IAAI,MAAM,YAAY,mBAAmB,MAAM,OAAO,UAAU,WAC9D,OAAO,eAAe,MAAM,OAAO,IAAI,GAAG,KAAK,UAAU,MAAM,OAAO,QAAQ;CAEhF,OAAO,MAAM;AACf;AAEA,SAAS,OAAO,OAA4B;CAC1C,IAAI,MAAM,YAAY,wBAAwB,OAAO,MAAM,MAAM,OAAO,mBAAmB;CAC3F,IAAI,MAAM,YAAY,QACpB,OAAO,KAAM,MAAM,OAAO,cAA4B,KAAK,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE;CAEjG,OAAO;AACT"}
@@ -1,130 +0,0 @@
1
- import { r as parseMapViewDefinition } from "./definition-Cp1CCigh.js";
2
- import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
3
- import { join, resolve } from "node:path";
4
- import { PLUGIN_PREFIX, resolveConfigPath, resolvePluginDir, resourceDir } from "structured-context/api";
5
- //#region src/node/bundled-definitions.ts
6
- var BUNDLED_DEFINITIONS = { "strategy-tree.json5": "// Strategy stack as a tree: vision → mission → goals → opportunities → solutions → experiments.\n{\n $schema: 'https://raw.githubusercontent.com/mindsocket/structured-context-map-views/main/schemas/generated/latest/definition.json',\n $id: 'sctx-map-view://core/strategy-tree',\n title: 'Strategy tree',\n schema: 'sctx://core/strategy_general',\n parameters: {\n orientation: { $ref: 'settings.json#/$defs/orientation', default: 'vertical' },\n nodeStyle: { $ref: 'settings.json#/$defs/nodeStyle', default: 'card' },\n validation: { $ref: 'settings.json#/$defs/validationLevel', default: 'off' },\n cardFields: {\n title: 'Card fields',\n type: 'array',\n items: { enum: ['status', 'priority', 'summary'] },\n default: ['status'],\n },\n },\n regions: [\n {\n id: 'main',\n layout: { type: 'tree', orientation: { $param: 'orientation' } },\n nodes: { style: { $param: 'nodeStyle' }, fields: { $param: 'cardFields' }, validation: { $param: 'validation' } },\n edges: { show: true },\n },\n ],\n}\n" };
7
- //#endregion
8
- //#region src/node/page.ts
9
- var PAGE_SLOTS = {
10
- title: "<!--sctx-title-->",
11
- snapshots: "<!--sctx-snapshots-->"
12
- };
13
- /** `template` (`dist/page.html`) with the title and snapshots written in. */
14
- function fillPage(template, snapshots, title) {
15
- for (const slot of Object.values(PAGE_SLOTS)) if (template.split(slot).length !== 2) throw new Error(`The page template must hold ${slot} exactly once.`);
16
- const json = JSON.stringify(snapshots).replaceAll("<", "\\u003c");
17
- return template.replace(PAGE_SLOTS.title, () => escapeHtml(title)).replace(PAGE_SLOTS.snapshots, () => json);
18
- }
19
- function escapeHtml(text) {
20
- return text.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
21
- }
22
- //#endregion
23
- //#region src/node/index.ts
24
- /**
25
- * Node-only: finds map view definitions the way structured-context finds plugin schemas.
26
- * Browser-only hosts receive the result from a server, like graph data.
27
- */
28
- var SCHEME = "sctx-map-view://";
29
- var DEFINITIONS_DIR = "map-views";
30
- var CONFIG_PLUGINS_DIR = "plugins";
31
- var PACKAGE_NAME = "structured-context-map-views";
32
- /**
33
- * Every map view definition available with `config`, from:
34
- * - this package's embedded definitions (`sctx-map-view://core/<name>`), for structured-context's bundled schemas;
35
- * - each plugin found from a config folder or named by a space (`sctx-map-view://<plugin>/<name>`): the
36
- * folder named by `"sctx": { "mapViews": "…" }` in its package.json, else its `map-views/` folder;
37
- * - the `map-views` resources folder of each config root (`sctx-map-view://<name>`).
38
- *
39
- * Each definition's `$id` must be in the namespace of where it was found, and ids must be unique.
40
- * Throws on the first invalid definition.
41
- */
42
- function loadMapViewDefinitions(config, options = {}) {
43
- const configDir = options.configDir ?? resolveConfigPath().root;
44
- const configDirs = [.../* @__PURE__ */ new Set([configDir, ...config.spaces.flatMap((s) => s.sourceDir ? [s.sourceDir] : [])])];
45
- return readDefinitionFolders([...pluginDirs(config, configDir, configDirs).flatMap(([plugin, dir]) => {
46
- const definitions = pluginDefinitionsDir(dir);
47
- return definitions ? [{
48
- dir: definitions,
49
- source: {
50
- kind: "plugin",
51
- plugin
52
- }
53
- }] : [];
54
- }), ...configDirs.flatMap((dir) => {
55
- const definitions = resourceDir(dir, DEFINITIONS_DIR);
56
- return definitions ? [{
57
- dir: definitions,
58
- source: { kind: "config" }
59
- }] : [];
60
- })]);
61
- }
62
- /**
63
- * Definitions in `folders` and this package's embedded ones, each checked against the namespace of its source.
64
- * Throws on the first invalid definition or a repeated id.
65
- */
66
- function readDefinitionFolders(folders) {
67
- const foundAt = /* @__PURE__ */ new Map();
68
- const definitions = [];
69
- const add = (label, text, source) => {
70
- const definition = parseMapViewDefinition(label, text);
71
- assertIdNamespace(definition.id, source, label);
72
- const existing = foundAt.get(definition.id);
73
- if (existing) throw new Error(`Map view id "${definition.id}" is defined by both ${existing} and ${label}.`);
74
- foundAt.set(definition.id, label);
75
- definitions.push(definition);
76
- };
77
- for (const [file, text] of Object.entries(BUNDLED_DEFINITIONS)) add(`${PACKAGE_NAME}/${file}`, text, { kind: "core" });
78
- for (const { dir, source } of folders) {
79
- if (!isDirectory(dir)) continue;
80
- for (const file of readdirSync(dir).filter((f) => f.endsWith(".json5")).sort()) {
81
- const path = join(dir, file);
82
- add(path, readFileSync(path, "utf8"), source);
83
- }
84
- }
85
- return definitions;
86
- }
87
- /** Plugin short name → root directory, for plugins in a config root's plugins folder or named by the config. */
88
- function pluginDirs(config, configDir, configDirs) {
89
- const found = /* @__PURE__ */ new Map();
90
- const add = (name, fromDir) => {
91
- const short = name.startsWith(PLUGIN_PREFIX) ? name.slice(PLUGIN_PREFIX.length) : name;
92
- if (found.has(short)) return;
93
- const dir = resolvePluginDir(name, fromDir);
94
- if (dir) found.set(short, dir);
95
- };
96
- for (const dir of configDirs) {
97
- const plugins = resourceDir(dir, CONFIG_PLUGINS_DIR);
98
- if (!plugins) continue;
99
- for (const entry of readdirSync(plugins).filter((e) => e.startsWith(PLUGIN_PREFIX)).sort()) add(entry, dir);
100
- }
101
- const topLevel = config.plugins ?? {};
102
- for (const name of Object.keys(topLevel)) add(name, configDir);
103
- for (const space of config.spaces) {
104
- const fromDir = space.sourceDir ?? configDir;
105
- const schemaPlugin = /^([^./][^/]*)\/./.exec(space.schema ?? "")?.[1];
106
- if (schemaPlugin) add(schemaPlugin, fromDir);
107
- for (const name of Object.keys(space.plugins ?? {})) add(name, fromDir);
108
- }
109
- return [...found];
110
- }
111
- function pluginDefinitionsDir(pluginDir) {
112
- const pkgPath = join(pluginDir, "package.json");
113
- if (existsSync(pkgPath)) {
114
- const declared = JSON.parse(readFileSync(pkgPath, "utf8")).sctx?.mapViews;
115
- if (typeof declared === "string") return resolve(pluginDir, declared);
116
- }
117
- return join(pluginDir, DEFINITIONS_DIR);
118
- }
119
- function assertIdNamespace(id, source, path) {
120
- const segments = id.slice(16).split("/");
121
- const expected = source.kind === "core" ? `${SCHEME}core/<name>` : source.kind === "plugin" ? `${SCHEME}${source.plugin}/<name>` : `${SCHEME}<name>`;
122
- if (!(source.kind === "config" ? segments.length === 1 : segments.length === 2 && segments[0] === (source.kind === "core" ? "core" : source.plugin)) || source.kind === "plugin" && source.plugin === "core") throw new Error(`Map view namespace violation: ${path} has $id "${id}". Use the form "${expected}".`);
123
- }
124
- function isDirectory(path) {
125
- return existsSync(path) && statSync(path).isDirectory();
126
- }
127
- //#endregion
128
- export { readDefinitionFolders as n, fillPage as r, loadMapViewDefinitions as t };
129
-
130
- //# sourceMappingURL=node-aizYAYlq.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"node-aizYAYlq.js","names":[],"sources":["../src/node/bundled-definitions.ts","../src/node/page.ts","../src/node/index.ts"],"sourcesContent":["// Generated by scripts/generate-definitions.ts from map-views/*.json5. Do not edit.\nexport const BUNDLED_DEFINITIONS: Record<string, string> = {\n \"strategy-tree.json5\": \"// Strategy stack as a tree: vision → mission → goals → opportunities → solutions → experiments.\\n{\\n $schema: 'https://raw.githubusercontent.com/mindsocket/structured-context-map-views/main/schemas/generated/latest/definition.json',\\n $id: 'sctx-map-view://core/strategy-tree',\\n title: 'Strategy tree',\\n schema: 'sctx://core/strategy_general',\\n parameters: {\\n orientation: { $ref: 'settings.json#/$defs/orientation', default: 'vertical' },\\n nodeStyle: { $ref: 'settings.json#/$defs/nodeStyle', default: 'card' },\\n validation: { $ref: 'settings.json#/$defs/validationLevel', default: 'off' },\\n cardFields: {\\n title: 'Card fields',\\n type: 'array',\\n items: { enum: ['status', 'priority', 'summary'] },\\n default: ['status'],\\n },\\n },\\n regions: [\\n {\\n id: 'main',\\n layout: { type: 'tree', orientation: { $param: 'orientation' } },\\n nodes: { style: { $param: 'nodeStyle' }, fields: { $param: 'cardFields' }, validation: { $param: 'validation' } },\\n edges: { show: true },\\n },\\n ],\\n}\\n\",\n};\n","import type { SpaceSnapshot } from '../core/snapshot';\n\nexport const PAGE_SLOTS = { title: '<!--sctx-title-->', snapshots: '<!--sctx-snapshots-->' } as const;\n\n/** `template` (`dist/page.html`) with the title and snapshots written in. */\nexport function fillPage(template: string, snapshots: SpaceSnapshot[], title: string): string {\n for (const slot of Object.values(PAGE_SLOTS)) {\n if (template.split(slot).length !== 2) throw new Error(`The page template must hold ${slot} exactly once.`);\n }\n // Escaping `<` stops a string in the data ending the script element\n const json = JSON.stringify(snapshots).replaceAll('<', '\\\\u003c');\n return template.replace(PAGE_SLOTS.title, () => escapeHtml(title)).replace(PAGE_SLOTS.snapshots, () => json);\n}\n\nfunction escapeHtml(text: string): string {\n return text.replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;');\n}\n","/// <reference types=\"node\" />\nimport { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport { type Config, PLUGIN_PREFIX, resolveConfigPath, resolvePluginDir, resourceDir } from 'structured-context/api';\nimport { type MapViewDefinition, parseMapViewDefinition } from '../core/definition';\nimport { BUNDLED_DEFINITIONS } from './bundled-definitions';\n\n/**\n * Node-only: finds map view definitions the way structured-context finds plugin schemas.\n * Browser-only hosts receive the result from a server, like graph data.\n */\n\nconst SCHEME = 'sctx-map-view://';\nconst DEFINITIONS_DIR = 'map-views';\nconst CONFIG_PLUGINS_DIR = 'plugins';\nconst PACKAGE_NAME = 'structured-context-map-views';\n\nexport type DefinitionSource = { kind: 'core' } | { kind: 'plugin'; plugin: string } | { kind: 'config' };\n\nexport type LoadMapViewDefinitionsOptions = {\n /** Root of the main config file (`resolveConfigPath().root`). Defaults to where structured-context finds it. */\n configDir?: string;\n};\n\n/**\n * Every map view definition available with `config`, from:\n * - this package's embedded definitions (`sctx-map-view://core/<name>`), for structured-context's bundled schemas;\n * - each plugin found from a config folder or named by a space (`sctx-map-view://<plugin>/<name>`): the\n * folder named by `\"sctx\": { \"mapViews\": \"…\" }` in its package.json, else its `map-views/` folder;\n * - the `map-views` resources folder of each config root (`sctx-map-view://<name>`).\n *\n * Each definition's `$id` must be in the namespace of where it was found, and ids must be unique.\n * Throws on the first invalid definition.\n */\nexport function loadMapViewDefinitions(\n config: Config,\n options: LoadMapViewDefinitionsOptions = {},\n): MapViewDefinition[] {\n const configDir = options.configDir ?? resolveConfigPath().root;\n const configDirs = [...new Set([configDir, ...config.spaces.flatMap((s) => (s.sourceDir ? [s.sourceDir] : []))])];\n\n const folders: { dir: string; source: DefinitionSource }[] = [\n ...pluginDirs(config, configDir, configDirs).flatMap(([plugin, dir]) => {\n const definitions = pluginDefinitionsDir(dir);\n return definitions ? [{ dir: definitions, source: { kind: 'plugin', plugin } as const }] : [];\n }),\n ...configDirs.flatMap((dir) => {\n const definitions = resourceDir(dir, DEFINITIONS_DIR);\n return definitions ? [{ dir: definitions, source: { kind: 'config' } as const }] : [];\n }),\n ];\n\n return readDefinitionFolders(folders);\n}\n\n/**\n * Definitions in `folders` and this package's embedded ones, each checked against the namespace of its source.\n * Throws on the first invalid definition or a repeated id.\n */\nexport function readDefinitionFolders(folders: { dir: string; source: DefinitionSource }[]): MapViewDefinition[] {\n const foundAt = new Map<string, string>();\n const definitions: MapViewDefinition[] = [];\n const add = (label: string, text: string, source: DefinitionSource) => {\n const definition = parseMapViewDefinition(label, text);\n assertIdNamespace(definition.id, source, label);\n const existing = foundAt.get(definition.id);\n if (existing) throw new Error(`Map view id \"${definition.id}\" is defined by both ${existing} and ${label}.`);\n foundAt.set(definition.id, label);\n definitions.push(definition);\n };\n\n for (const [file, text] of Object.entries(BUNDLED_DEFINITIONS))\n add(`${PACKAGE_NAME}/${file}`, text, { kind: 'core' });\n for (const { dir, source } of folders) {\n if (!isDirectory(dir)) continue;\n for (const file of readdirSync(dir)\n .filter((f) => f.endsWith('.json5'))\n .sort()) {\n const path = join(dir, file);\n add(path, readFileSync(path, 'utf8'), source);\n }\n }\n return definitions;\n}\n\n/** Plugin short name → root directory, for plugins in a config root's plugins folder or named by the config. */\nfunction pluginDirs(config: Config, configDir: string, configDirs: string[]): [string, string][] {\n const found = new Map<string, string>();\n const add = (name: string, fromDir: string) => {\n const short = name.startsWith(PLUGIN_PREFIX) ? name.slice(PLUGIN_PREFIX.length) : name;\n if (found.has(short)) return;\n const dir = resolvePluginDir(name, fromDir);\n if (dir) found.set(short, dir);\n };\n\n for (const dir of configDirs) {\n const plugins = resourceDir(dir, CONFIG_PLUGINS_DIR);\n if (!plugins) continue;\n for (const entry of readdirSync(plugins)\n .filter((e) => e.startsWith(PLUGIN_PREFIX))\n .sort())\n add(entry, dir);\n }\n const topLevel = (config as { plugins?: Record<string, unknown> }).plugins ?? {};\n for (const name of Object.keys(topLevel)) add(name, configDir);\n for (const space of config.spaces) {\n const fromDir = space.sourceDir ?? configDir;\n // A schema named through a plugin, e.g. \"sctx-wardley-mapping/wardley_map.json\".\n const schemaPlugin = /^([^./][^/]*)\\/./.exec(space.schema ?? '')?.[1];\n if (schemaPlugin) add(schemaPlugin, fromDir);\n for (const name of Object.keys(space.plugins ?? {})) add(name, fromDir);\n }\n return [...found];\n}\n\nfunction pluginDefinitionsDir(pluginDir: string): string | undefined {\n const pkgPath = join(pluginDir, 'package.json');\n if (existsSync(pkgPath)) {\n const declared = JSON.parse(readFileSync(pkgPath, 'utf8')).sctx?.mapViews;\n if (typeof declared === 'string') return resolve(pluginDir, declared);\n }\n return join(pluginDir, DEFINITIONS_DIR);\n}\n\nfunction assertIdNamespace(id: string, source: DefinitionSource, path: string): void {\n const segments = id.slice(SCHEME.length).split('/');\n const expected =\n source.kind === 'core'\n ? `${SCHEME}core/<name>`\n : source.kind === 'plugin'\n ? `${SCHEME}${source.plugin}/<name>`\n : `${SCHEME}<name>`;\n const ok =\n source.kind === 'config'\n ? segments.length === 1\n : segments.length === 2 && segments[0] === (source.kind === 'core' ? 'core' : source.plugin);\n if (!ok || (source.kind === 'plugin' && source.plugin === 'core')) {\n throw new Error(`Map view namespace violation: ${path} has $id \"${id}\". Use the form \"${expected}\".`);\n }\n}\n\nfunction isDirectory(path: string): boolean {\n return existsSync(path) && statSync(path).isDirectory();\n}\n\nexport { fillPage } from './page';\n"],"mappings":";;;;;AACA,IAAa,sBAA8C,EACzD,uBAAuB,8iCACzB;;;ACDA,IAAa,aAAa;CAAE,OAAO;CAAqB,WAAW;AAAwB;;AAG3F,SAAgB,SAAS,UAAkB,WAA4B,OAAuB;CAC5F,KAAK,MAAM,QAAQ,OAAO,OAAO,UAAU,GACzC,IAAI,SAAS,MAAM,IAAI,CAAC,CAAC,WAAW,GAAG,MAAM,IAAI,MAAM,+BAA+B,KAAK,eAAe;CAG5G,MAAM,OAAO,KAAK,UAAU,SAAS,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