structured-context-map-views 0.6.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/README.md +1 -1
  2. package/dist/{ParameterControls-A1HJWyt9.js → ParameterControls-Be05VST0.js} +505 -188
  3. package/dist/ParameterControls-Be05VST0.js.map +1 -0
  4. package/dist/artifact.html +70 -1
  5. package/dist/artifact.js +2 -2
  6. package/dist/artifact.js.map +1 -1
  7. package/dist/cli.js +12 -6
  8. package/dist/cli.js.map +1 -1
  9. package/dist/{definition-Cp1CCigh.js → definition-SjmROmJC.js} +308 -188
  10. package/dist/definition-SjmROmJC.js.map +1 -0
  11. package/dist/html.js +19 -0
  12. package/dist/html.js.map +1 -0
  13. package/dist/index.js +3 -3
  14. package/dist/node-ctbuxC-s.js +74 -0
  15. package/dist/node-ctbuxC-s.js.map +1 -0
  16. package/dist/node.js +2 -2
  17. package/dist/page.html +94 -25
  18. package/dist/{projection-C-dATsdO.js → projection-DKNLziP0.js} +282 -124
  19. package/dist/projection-DKNLziP0.js.map +1 -0
  20. package/dist/read-definitions-DFcOXatz.js +51 -0
  21. package/dist/read-definitions-DFcOXatz.js.map +1 -0
  22. package/dist/styles.css +69 -0
  23. package/dist/types/artifact/load.d.ts +1 -1
  24. package/dist/types/{layouts/EdgeOverlay.d.ts → components/ConnectorOverlay.d.ts} +6 -15
  25. package/dist/types/components/GraphLayout.d.ts +8 -0
  26. package/dist/types/components/LandscapeLayout.d.ts +9 -0
  27. package/dist/types/{layouts → components}/MapView.d.ts +4 -1
  28. package/dist/types/components/NeighbourhoodLayout.d.ts +7 -0
  29. package/dist/types/{layouts/NodeCard.d.ts → components/NodeComponent.d.ts} +1 -1
  30. package/dist/types/components/TreeLayout.d.ts +6 -0
  31. package/dist/types/{layouts → components}/XYLayout.d.ts +3 -3
  32. package/dist/types/{layouts → components}/annotations-context.d.ts +1 -1
  33. package/dist/types/components/layout.d.ts +22 -0
  34. package/dist/types/core/annotations.d.ts +2 -3
  35. package/dist/types/core/definition.d.ts +664 -30
  36. package/dist/types/core/layouts/graph/schema.d.ts +24 -0
  37. package/dist/types/core/layouts/helpers.d.ts +42 -0
  38. package/dist/types/core/layouts/landscape/projection.d.ts +75 -0
  39. package/dist/types/core/layouts/landscape/schema.d.ts +223 -0
  40. package/dist/types/core/layouts/neighbourhood/projection.d.ts +26 -0
  41. package/dist/types/core/layouts/neighbourhood/schema.d.ts +51 -0
  42. package/dist/types/core/layouts/schemas.d.ts +427 -0
  43. package/dist/types/core/{tree.d.ts → layouts/tree/projection.d.ts} +9 -11
  44. package/dist/types/core/layouts/xy/projection.d.ts +32 -0
  45. package/dist/types/core/{format/xy-layout.d.ts → layouts/xy/schema.d.ts} +2 -0
  46. package/dist/types/core/{format → schema}/definition-schema.d.ts +22 -12
  47. package/dist/types/core/{snapshot.d.ts → space-snapshot.d.ts} +1 -4
  48. package/dist/types/index.d.ts +6 -9
  49. package/dist/types/node/html.d.ts +6 -0
  50. package/dist/types/node/index.d.ts +7 -30
  51. package/dist/types/node/page.d.ts +1 -1
  52. package/dist/types/node/read-definitions.d.ts +17 -0
  53. package/dist/types/node/snapshot.d.ts +1 -1
  54. package/dist/types/viewer/Viewer.d.ts +5 -5
  55. package/package.json +10 -4
  56. package/dist/ParameterControls-A1HJWyt9.js.map +0 -1
  57. package/dist/definition-Cp1CCigh.js.map +0 -1
  58. package/dist/node-aizYAYlq.js +0 -130
  59. package/dist/node-aizYAYlq.js.map +0 -1
  60. package/dist/projection-C-dATsdO.js.map +0 -1
  61. package/dist/types/core/format/index.d.ts +0 -450
  62. package/dist/types/core/format/landscape-layout.d.ts +0 -102
  63. package/dist/types/core/graph.d.ts +0 -16
  64. package/dist/types/core/landscape.d.ts +0 -44
  65. package/dist/types/core/occurrence.d.ts +0 -11
  66. package/dist/types/core/xy.d.ts +0 -43
  67. package/dist/types/layouts/LandscapeLayout.d.ts +0 -8
  68. package/dist/types/layouts/TreeLayout.d.ts +0 -16
  69. /package/dist/types/{layouts → components}/ParameterControls.d.ts +0 -0
  70. /package/dist/types/{layouts → components}/ParameterInputs.d.ts +0 -0
  71. /package/dist/types/{layouts → components}/useParameterControls.d.ts +0 -0
  72. /package/dist/types/core/{format/tree-layout.d.ts → layouts/tree/schema.d.ts} +0 -0
  73. /package/dist/types/core/{format → schema}/param-ref.d.ts +0 -0
  74. /package/dist/types/core/{format → schema}/schema-url.d.ts +0 -0
  75. /package/dist/types/core/{format → schema}/settings.d.ts +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definition-SjmROmJC.js","names":[],"sources":["../src/core/schema/schema-url.ts","../src/core/schema/param-ref.ts","../src/core/layouts/graph/schema.ts","../src/core/layouts/landscape/schema.ts","../src/core/layouts/neighbourhood/schema.ts","../src/core/layouts/tree/schema.ts","../src/core/layouts/xy/schema.ts","../src/core/layouts/schemas.ts","../src/core/schema/definition-schema.ts","../src/core/schema/settings.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 { parameterisable } from '../../schema/param-ref';\nimport { SCHEMA_URL } from '../../schema/schema-url';\n\n/** Settings of the graph layout: every node and edge as a network. */\nexport const graphLayoutSchema = {\n $schema: 'https://json-schema.org/draft/2020-12/schema',\n $id: `${SCHEMA_URL}/layouts/graph.json`,\n title: 'Graph layout',\n description: 'Nodes and edges as a network: connected nodes sit close together. Works with any schema.',\n type: 'object',\n required: ['type'],\n additionalProperties: false,\n properties: {\n type: { const: 'graph' },\n edgeFields: parameterisable(\n { $ref: `${SCHEMA_URL}/settings.json#/$defs/fieldList` },\n [],\n 'Fields whose edges are drawn and pull nodes together. Empty: all edges.',\n ),\n },\n} as const;\n","import type { AuthoredLayout } from '../../definition';\nimport { PARAM_REF, parameterisable } from '../../schema/param-ref';\nimport { SCHEMA_URL } from '../../schema/schema-url';\n\n/** A dimension: groups that are the same wherever the dimension is used. Dispatches on `field`, like a grouping level. */\nconst dimensionSchema = {\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 \"Groups labelled by the values of a field of the strip's first node level. A value no node has is not a group.\",\n required: ['field'],\n additionalProperties: false,\n properties: { field: { type: 'string', minLength: 1 } },\n },\n else: {\n type: 'object',\n description: 'A group for every node of one type.',\n required: ['type'],\n additionalProperties: false,\n properties: {\n type: {\n description: 'Node type of the groups.',\n anyOf: [{ type: 'string', minLength: 1 }, { $ref: PARAM_REF }],\n },\n edge: {\n type: 'object',\n description:\n \"Which edges join a group's node to the strip's first node level, or to its last `via` type. By default, any edge between the two types, in either direction.\",\n required: ['field'],\n additionalProperties: false,\n properties: { field: { type: 'string', minLength: 1 } },\n },\n },\n },\n} as const;\n\n/** Settings of the landscape layout: strips of nested containers, optionally divided into cells by dimensions. */\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 \"Strips, one after the other. Each strip nests its grouping levels, and its last level is drawn as nodes. A dimension divides a strip into cells: the layout's dimension divides every strip alike, so they line up, and a strip's own dimension divides that strip further.\",\n type: 'object',\n required: ['type', 'strips'],\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, or the layout dimension's groups, side by side, as columns, and strips stacked. vertical: the reverse.\",\n ),\n dimension: {\n ...dimensionSchema,\n description:\n 'Divides every strip. Its groups are worked out once, so every strip has the same groups in the same order, and a cell exists even when it is empty.',\n },\n strips: {\n type: 'array',\n minItems: 1,\n description: 'The strips, in order along the axis the layout dimension does not run along.',\n items: {\n type: 'object',\n required: ['group'],\n additionalProperties: false,\n properties: {\n dimension: {\n ...dimensionSchema,\n description:\n \"Divides this strip further, along the strip's own axis. Without a layout dimension, a strip with its own dimension is a swimlane.\",\n },\n showUngrouped: parameterisable(\n { type: 'boolean' },\n true,\n \"Whether to draw the nodes of the strip's levels that no cell or container reached.\",\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. In a strip with a dimension, the first level is joined to each dimension node the same way, so `edge` and `via` apply there.',\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 (or the dimension's node) and this one, in order. Nodes are joined through a chain of edges across them. Ignored on the first level of a strip with no dimension.\",\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 },\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\nexport function checkLandscapeLayout(layout: AuthoredLayout<'landscape'>) {\n // A field level labels the nodes of a later level, so a node level must come last in each strip.\n if (layout.strips.some((strip) => !('type' in strip.group.at(-1)!))) {\n return 'the last grouping level of a strip must be a node type, not a field';\n }\n}\n","import { parameterisable } from '../../schema/param-ref';\nimport { SCHEMA_URL } from '../../schema/schema-url';\n\nconst roleFields = (description: string) =>\n parameterisable({ $ref: `${SCHEMA_URL}/settings.json#/$defs/fieldList` }, [], description);\n\n/** Settings of the neighbourhood layout: the neighbourhood of one node, placed by role. */\nexport const neighbourhoodLayoutSchema = {\n $schema: 'https://json-schema.org/draft/2020-12/schema',\n $id: `${SCHEMA_URL}/layouts/neighbourhood.json`,\n title: 'Neighbourhood layout',\n description:\n 'The neighbourhood of one focus node, with related nodes placed around it by role. By default the hierarchy runs down the page (parents above, children below), relationships in either direction sit to the left and the siblings of the focus to the right; with no hierarchy, every edge runs down the page. A role that lists a field takes the nodes that field joins to the focus, in either direction. A node joined by several fields is placed once, by the first of above, below, left, right.',\n type: 'object',\n required: ['type'],\n additionalProperties: false,\n properties: {\n type: { const: 'neighbourhood' },\n above: roleFields('Fields whose nodes are shown above the focus, in addition to the default.'),\n below: roleFields('Fields whose nodes are shown below the focus, in addition to the default.'),\n left: roleFields('Fields whose nodes are shown to the left of the focus, in addition to the default.'),\n right: roleFields('Fields whose nodes are shown to the right of the focus, in addition to the default.'),\n },\n} as const;\n","import { parameterisable } from '../../schema/param-ref';\nimport { SCHEMA_URL } from '../../schema/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 type { AuthoredLayout } from '../../definition';\nimport { PARAM_REF, parameterisable } from '../../schema/param-ref';\nimport { SCHEMA_URL } from '../../schema/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\nexport function checkXYLayout(layout: AuthoredLayout<'xy'>) {\n for (const axis of ['x', 'y'] as const) {\n const { domain } = layout[axis];\n if (Array.isArray(domain) && !(domain[0]! < domain[1]!)) return `${axis} domain must be [min, max] with min < max`;\n }\n}\n","import type { AuthoredLayout } from '../definition';\nimport { graphLayoutSchema } from './graph/schema';\nimport { checkLandscapeLayout, landscapeLayoutSchema } from './landscape/schema';\nimport { neighbourhoodLayoutSchema } from './neighbourhood/schema';\nimport { treeLayoutSchema } from './tree/schema';\nimport { checkXYLayout, xyLayoutSchema } from './xy/schema';\n\n/** Every layout's settings schema. The definition format and its types follow from this list. */\nexport const layoutSchemas = [\n treeLayoutSchema,\n landscapeLayoutSchema,\n xyLayoutSchema,\n neighbourhoodLayoutSchema,\n graphLayoutSchema,\n] as const;\n\n/** Rules a layout's schema can't express. A check returns a message for settings that break one. */\nexport const layoutChecks: { [T in AuthoredLayout['type']]?: (layout: AuthoredLayout<T>) => string | undefined } = {\n landscape: checkLandscapeLayout,\n xy: checkXYLayout,\n};\n","import { VALIDATION_ISSUE_KINDS } from 'structured-context/types';\nimport { layoutSchemas } from '../layouts/schemas';\nimport { parameterisable } from './param-ref';\nimport { SCHEMA_URL } from './schema-url';\n\n// `map` loses the tuple the definition types are derived from, so it is restated.\ntype Refs<T extends readonly { $id: string }[]> = { readonly [K in keyof T]: { readonly $ref: T[K]['$id'] } };\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', '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:\n '`$id` of the structured-context schema whose spaces this map view applies to. Omitted: it applies to every schema.',\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 key 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: layoutSchemas.map((schema) => ({ $ref: schema.$id })) as unknown as Refs<typeof layoutSchemas>,\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 labels: parameterisable(\n { type: 'boolean' },\n false,\n 'Whether each connector is labelled with the field the relationship is declared in.',\n ),\n },\n },\n },\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 Ajv2020, { type AnySchemaObject, type ErrorObject } from 'ajv/dist/2020';\nimport type { FromSchema } from 'json-schema-to-ts';\nimport JSON5 from 'json5';\nimport { layoutChecks, layoutSchemas } from './layouts/schemas';\nimport { definitionSchema } from './schema/definition-schema';\nimport { SCHEMA_URL } from './schema/schema-url';\nimport { settingsSchema } from './schema/settings';\n\n/** The bundled schemas describing the map view definition format. */\nexport const MAP_VIEW_SCHEMAS = [definitionSchema, settingsSchema, ...layoutSchemas] as const;\n\ntype References = {\n references: [typeof settingsSchema, ...typeof layoutSchemas, typeof definitionSchema];\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>;\ntype LayoutOf<L extends { type: string }, T extends L['type']> = Extract<L, { type: T }>;\n/** One layout's settings as authored. */\nexport type AuthoredLayout<\n T extends\n AuthoredDefinition['regions'][number]['layout']['type'] = AuthoredDefinition['regions'][number]['layout']['type'],\n> = LayoutOf<AuthoredDefinition['regions'][number]['layout'], T>;\n\n/** A region with parameters applied and defaults filled in: what layouts receive. */\nexport type Region = Resolved<FilledDefinition['regions'][number]>;\n/** A layout's settings, resolved: every layout's, or those of the layout `T` names. */\nexport type LayoutConfig<T extends Region['layout']['type'] = Region['layout']['type']> = LayoutOf<Region['layout'], T>;\nexport type NodesConfig = Region['nodes'];\nexport type EdgesConfig = Region['edges'];\nexport type Orientation = LayoutConfig<'tree'>['orientation'];\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; unset: every schema. */\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 // The check is the one for this layout's type, which TypeScript can't relate to the settings.\n const broken = layoutChecks[region.layout.type]?.(region.layout as never);\n if (broken) fail(`region \"${region.id}\": ${broken}`);\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 ...(source.schema !== undefined && { 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, including those for every schema. */\nexport function mapViewsForSchema(\n definitions: readonly MapViewDefinition[],\n schemaId: string | undefined,\n): MapViewDefinition[] {\n return definitions.filter((d) => d.schema === undefined || 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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G,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"}
package/dist/html.js ADDED
@@ -0,0 +1,19 @@
1
+ import { t as readDefinitionFolders } from "./read-definitions-DFcOXatz.js";
2
+ //#region src/node/page.ts
3
+ var PAGE_SLOTS = {
4
+ title: "<!--sctx-title-->",
5
+ snapshots: "<!--sctx-snapshots-->"
6
+ };
7
+ /** `template` (`dist/page.html`) with the title and snapshots written in. */
8
+ function fillPage(template, snapshots, title) {
9
+ 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.`);
10
+ const json = JSON.stringify(snapshots).replaceAll("<", "\\u003c");
11
+ return template.replace(PAGE_SLOTS.title, () => escapeHtml(title)).replace(PAGE_SLOTS.snapshots, () => json);
12
+ }
13
+ function escapeHtml(text) {
14
+ return text.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
15
+ }
16
+ //#endregion
17
+ export { fillPage, readDefinitionFolders };
18
+
19
+ //# sourceMappingURL=html.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html.js","names":[],"sources":["../src/node/page.ts"],"sourcesContent":["import type { SpaceSnapshot } from '../core/space-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"],"mappings":";;AAEA,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,CAAC,CAAC,WAAW,KAAK,SAAS;CAChE,OAAO,SAAS,QAAQ,WAAW,aAAa,WAAW,KAAK,CAAC,CAAC,CAAC,QAAQ,WAAW,iBAAiB,IAAI;AAC7G;AAEA,SAAS,WAAW,MAAsB;CACxC,OAAO,KAAK,WAAW,KAAK,OAAO,CAAC,CAAC,WAAW,KAAK,MAAM,CAAC,CAAC,WAAW,KAAK,MAAM;AACrF"}
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as annotationsFrom, r as buildTree, s as worstSeverity } from "./projection-C-dATsdO.js";
2
- import { c as MAP_VIEW_SCHEMAS, i as resolveParameterValues, n as mapViewsForSchema, o as selectionFilter, r as parseMapViewDefinition, s as viewValidationLevel, t as MapViewDefinitionError } from "./definition-Cp1CCigh.js";
3
- import { a as SelectParameterInput, i as ParameterInput, n as useParameterControls, o as ToggleParameterInput, r as MultiSelectParameterInput, s as MapView, t as ParameterControls } from "./ParameterControls-A1HJWyt9.js";
1
+ import { f as worstSeverity, n as buildTree, u as annotationsFrom } from "./projection-DKNLziP0.js";
2
+ import { a as resolveParameterValues, c as viewValidationLevel, i as parseMapViewDefinition, n as MapViewDefinitionError, r as mapViewsForSchema, s as selectionFilter, t as MAP_VIEW_SCHEMAS } from "./definition-SjmROmJC.js";
3
+ import { a as SelectParameterInput, i as ParameterInput, n as useParameterControls, o as ToggleParameterInput, r as MultiSelectParameterInput, s as MapView, t as ParameterControls } from "./ParameterControls-Be05VST0.js";
4
4
  export { MAP_VIEW_SCHEMAS, MapView, MapViewDefinitionError, MultiSelectParameterInput, ParameterControls, ParameterInput, SelectParameterInput, ToggleParameterInput, annotationsFrom, buildTree, mapViewsForSchema, parseMapViewDefinition, resolveParameterValues, selectionFilter, useParameterControls, viewValidationLevel, worstSeverity };
@@ -0,0 +1,74 @@
1
+ import { t as readDefinitionFolders } from "./read-definitions-DFcOXatz.js";
2
+ import { existsSync, readFileSync, readdirSync } 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/index.ts
6
+ /**
7
+ * Node-only: finds map view definitions the way structured-context finds plugin schemas.
8
+ * Browser-only hosts receive the result from a server, like graph data.
9
+ */
10
+ var DEFINITIONS_DIR = "map-views";
11
+ var CONFIG_PLUGINS_DIR = "plugins";
12
+ /**
13
+ * Every map view definition available with `config`, found as docs/definitions.md describes.
14
+ * Throws on the first invalid definition, including one outside its namespace or with a duplicate `$id`.
15
+ *
16
+ * `configDir` is the root of the main config file; it defaults to where structured-context finds it.
17
+ */
18
+ function loadMapViewDefinitions(config, options = {}) {
19
+ const configDir = options.configDir ?? resolveConfigPath().root;
20
+ const configDirs = [.../* @__PURE__ */ new Set([configDir, ...config.spaces.flatMap((s) => s.sourceDir ? [s.sourceDir] : [])])];
21
+ const folders = [...pluginDirs(config, configDir, configDirs).flatMap(([plugin, dir]) => {
22
+ const definitions = pluginDefinitionsDir(dir);
23
+ return definitions ? [{
24
+ dir: definitions,
25
+ source: {
26
+ kind: "plugin",
27
+ plugin
28
+ }
29
+ }] : [];
30
+ }), ...configDirs.flatMap((dir) => {
31
+ const definitions = resourceDir(dir, DEFINITIONS_DIR);
32
+ return definitions ? [{
33
+ dir: definitions,
34
+ source: { kind: "config" }
35
+ }] : [];
36
+ })];
37
+ return readDefinitionFolders(folders);
38
+ }
39
+ /** Plugin short name → root directory, for plugins in a config root's plugins folder or named by the config. */
40
+ function pluginDirs(config, configDir, configDirs) {
41
+ const found = /* @__PURE__ */ new Map();
42
+ const add = (name, fromDir) => {
43
+ const short = name.startsWith(PLUGIN_PREFIX) ? name.slice(PLUGIN_PREFIX.length) : name;
44
+ if (found.has(short)) return;
45
+ const dir = resolvePluginDir(name, fromDir);
46
+ if (dir) found.set(short, dir);
47
+ };
48
+ for (const dir of configDirs) {
49
+ const plugins = resourceDir(dir, CONFIG_PLUGINS_DIR);
50
+ if (!plugins) continue;
51
+ for (const entry of readdirSync(plugins).filter((e) => e.startsWith(PLUGIN_PREFIX)).sort()) add(entry, dir);
52
+ }
53
+ const topLevel = config.plugins ?? {};
54
+ for (const name of Object.keys(topLevel)) add(name, configDir);
55
+ for (const space of config.spaces) {
56
+ const fromDir = space.sourceDir ?? configDir;
57
+ const schemaPlugin = /^([^./][^/]*)\/./.exec(space.schema ?? "")?.[1];
58
+ if (schemaPlugin) add(schemaPlugin, fromDir);
59
+ for (const name of Object.keys(space.plugins ?? {})) add(name, fromDir);
60
+ }
61
+ return [...found];
62
+ }
63
+ function pluginDefinitionsDir(pluginDir) {
64
+ const pkgPath = join(pluginDir, "package.json");
65
+ if (existsSync(pkgPath)) {
66
+ const declared = JSON.parse(readFileSync(pkgPath, "utf8")).sctx?.[DEFINITIONS_DIR];
67
+ if (typeof declared === "string") return resolve(pluginDir, declared);
68
+ }
69
+ return join(pluginDir, DEFINITIONS_DIR);
70
+ }
71
+ //#endregion
72
+ export { loadMapViewDefinitions as t };
73
+
74
+ //# sourceMappingURL=node-ctbuxC-s.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-ctbuxC-s.js","names":[],"sources":["../src/node/index.ts"],"sourcesContent":["/// <reference types=\"node\" />\nimport { existsSync, readdirSync, readFileSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport { type Config, PLUGIN_PREFIX, resolveConfigPath, resolvePluginDir, resourceDir } from 'structured-context/api';\nimport type { MapViewDefinition } from '../core/definition';\nimport { type DefinitionSource, readDefinitionFolders } from './read-definitions';\n\n/**\n * Node-only: finds map view definitions the way structured-context finds plugin schemas.\n * Browser-only hosts receive the result from a server, like graph data.\n */\n\nconst DEFINITIONS_DIR = 'map-views';\nconst CONFIG_PLUGINS_DIR = 'plugins';\n\n/**\n * Every map view definition available with `config`, found as docs/definitions.md describes.\n * Throws on the first invalid definition, including one outside its namespace or with a duplicate `$id`.\n *\n * `configDir` is the root of the main config file; it defaults to where structured-context finds it.\n */\nexport function loadMapViewDefinitions(config: Config, options: { configDir?: string } = {}): MapViewDefinition[] {\n const configDir = options.configDir ?? resolveConfigPath().root;\n const configDirs = [...new Set([configDir, ...config.spaces.flatMap((s) => (s.sourceDir ? [s.sourceDir] : []))])];\n\n const folders: { dir: string; source: DefinitionSource }[] = [\n ...pluginDirs(config, configDir, configDirs).flatMap(([plugin, dir]) => {\n const definitions = pluginDefinitionsDir(dir);\n return definitions ? [{ dir: definitions, source: { kind: 'plugin', plugin } as const }] : [];\n }),\n ...configDirs.flatMap((dir) => {\n const definitions = resourceDir(dir, DEFINITIONS_DIR);\n return definitions ? [{ dir: definitions, source: { kind: 'config' } as const }] : [];\n }),\n ];\n\n return readDefinitionFolders(folders);\n}\n\n/** Plugin short name → root directory, for plugins in a config root's plugins folder or named by the config. */\nfunction pluginDirs(config: Config, configDir: string, configDirs: string[]): [string, string][] {\n const found = new Map<string, string>();\n const add = (name: string, fromDir: string) => {\n const short = name.startsWith(PLUGIN_PREFIX) ? name.slice(PLUGIN_PREFIX.length) : name;\n if (found.has(short)) return;\n const dir = resolvePluginDir(name, fromDir);\n if (dir) found.set(short, dir);\n };\n\n for (const dir of configDirs) {\n const plugins = resourceDir(dir, CONFIG_PLUGINS_DIR);\n if (!plugins) continue;\n for (const entry of readdirSync(plugins)\n .filter((e) => e.startsWith(PLUGIN_PREFIX))\n .sort())\n add(entry, dir);\n }\n const topLevel = (config as { plugins?: Record<string, unknown> }).plugins ?? {};\n for (const name of Object.keys(topLevel)) add(name, configDir);\n for (const space of config.spaces) {\n const fromDir = space.sourceDir ?? configDir;\n // A schema named through a plugin, e.g. \"sctx-wardley-mapping/wardley_map.json\".\n const schemaPlugin = /^([^./][^/]*)\\/./.exec(space.schema ?? '')?.[1];\n if (schemaPlugin) add(schemaPlugin, fromDir);\n for (const name of Object.keys(space.plugins ?? {})) add(name, fromDir);\n }\n return [...found];\n}\n\nfunction pluginDefinitionsDir(pluginDir: string): string | undefined {\n const pkgPath = join(pluginDir, 'package.json');\n if (existsSync(pkgPath)) {\n const declared = JSON.parse(readFileSync(pkgPath, 'utf8')).sctx?.[DEFINITIONS_DIR];\n if (typeof declared === 'string') return resolve(pluginDir, declared);\n }\n return join(pluginDir, DEFINITIONS_DIR);\n}\n"],"mappings":";;;;;;;;;AAYA,IAAM,kBAAkB;AACxB,IAAM,qBAAqB;;;;;;;AAQ3B,SAAgB,uBAAuB,QAAgB,UAAkC,CAAC,GAAwB;CAChH,MAAM,YAAY,QAAQ,aAAa,kBAAkB,CAAC,CAAC;CAC3D,MAAM,aAAa,CAAC,mBAAG,IAAI,IAAI,CAAC,WAAW,GAAG,OAAO,OAAO,SAAS,MAAO,EAAE,YAAY,CAAC,EAAE,SAAS,IAAI,CAAC,CAAE,CAAC,CAAC,CAAC;CAEhH,MAAM,UAAuD,CAC3D,GAAG,WAAW,QAAQ,WAAW,UAAU,CAAC,CAAC,SAAS,CAAC,QAAQ,SAAS;EACtE,MAAM,cAAc,qBAAqB,GAAG;EAC5C,OAAO,cAAc,CAAC;GAAE,KAAK;GAAa,QAAQ;IAAE,MAAM;IAAU;GAAO;EAAW,CAAC,IAAI,CAAC;CAC9F,CAAC,GACD,GAAG,WAAW,SAAS,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,KAAK,MAAM,aAAa,SAAS,MAAM,CAAC,CAAC,CAAC,OAAO;EAClE,IAAI,OAAO,aAAa,UAAU,OAAO,QAAQ,WAAW,QAAQ;CACtE;CACA,OAAO,KAAK,WAAW,eAAe;AACxC"}
package/dist/node.js CHANGED
@@ -1,2 +1,2 @@
1
- import { n as readDefinitionFolders, r as fillPage, t as loadMapViewDefinitions } from "./node-aizYAYlq.js";
2
- export { fillPage, loadMapViewDefinitions, readDefinitionFolders };
1
+ import { t as loadMapViewDefinitions } from "./node-ctbuxC-s.js";
2
+ export { loadMapViewDefinitions };