structured-context-map-views 0.6.2 → 0.7.1

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 (74) 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 +71 -2
  5. package/dist/artifact.js +2 -2
  6. package/dist/artifact.js.map +1 -1
  7. package/dist/cli.js +10 -8
  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 +1 -1
  12. package/dist/html.js.map +1 -1
  13. package/dist/index.js +3 -3
  14. package/dist/{node-B0VWZju6.js → node-ctbuxC-s.js} +5 -9
  15. package/dist/node-ctbuxC-s.js.map +1 -0
  16. package/dist/node.js +1 -1
  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/index.d.ts +6 -12
  50. package/dist/types/node/page.d.ts +1 -1
  51. package/dist/types/node/snapshot.d.ts +1 -1
  52. package/dist/types/viewer/Viewer.d.ts +5 -5
  53. package/package.json +8 -6
  54. package/dist/ParameterControls-A1HJWyt9.js.map +0 -1
  55. package/dist/definition-Cp1CCigh.js.map +0 -1
  56. package/dist/node-B0VWZju6.js.map +0 -1
  57. package/dist/projection-C-dATsdO.js.map +0 -1
  58. package/dist/read-definitions-DNcsxgXM.js +0 -46
  59. package/dist/read-definitions-DNcsxgXM.js.map +0 -1
  60. package/dist/types/core/format/index.d.ts +0 -450
  61. package/dist/types/core/format/landscape-layout.d.ts +0 -102
  62. package/dist/types/core/graph.d.ts +0 -16
  63. package/dist/types/core/landscape.d.ts +0 -44
  64. package/dist/types/core/occurrence.d.ts +0 -11
  65. package/dist/types/core/xy.d.ts +0 -43
  66. package/dist/types/layouts/LandscapeLayout.d.ts +0 -8
  67. package/dist/types/layouts/TreeLayout.d.ts +0 -16
  68. /package/dist/types/{layouts → components}/ParameterControls.d.ts +0 -0
  69. /package/dist/types/{layouts → components}/ParameterInputs.d.ts +0 -0
  70. /package/dist/types/{layouts → components}/useParameterControls.d.ts +0 -0
  71. /package/dist/types/core/{format/tree-layout.d.ts → layouts/tree/schema.d.ts} +0 -0
  72. /package/dist/types/core/{format → schema}/param-ref.d.ts +0 -0
  73. /package/dist/types/core/{format → schema}/schema-url.d.ts +0 -0
  74. /package/dist/types/core/{format → schema}/settings.d.ts +0 -0
@@ -4,7 +4,7 @@ import { VALIDATION_ISSUE_KINDS } from "structured-context/types";
4
4
  /** Base of the `$id`s the sources use: the `latest` folder. */
5
5
  var SCHEMA_URL = `https://raw.githubusercontent.com/mindsocket/structured-context-map-views/main/schemas/generated/latest`;
6
6
  //#endregion
7
- //#region src/core/format/param-ref.ts
7
+ //#region src/core/schema/param-ref.ts
8
8
  /** `$ref` target for a setting whose value comes from a declared parameter. */
9
9
  var PARAM_REF = `${SCHEMA_URL}/definition.json#/$defs/paramRef`;
10
10
  /** A setting that takes either a fixed value matching `valueSchema` or a `{ $param }` binding. */
@@ -16,7 +16,297 @@ function parameterisable(valueSchema, defaultValue, description) {
16
16
  };
17
17
  }
18
18
  //#endregion
19
- //#region src/core/format/definition-schema.ts
19
+ //#region src/core/layouts/graph/schema.ts
20
+ /** Settings of the graph layout: every node and edge as a network. */
21
+ var graphLayoutSchema = {
22
+ $schema: "https://json-schema.org/draft/2020-12/schema",
23
+ $id: `${SCHEMA_URL}/layouts/graph.json`,
24
+ title: "Graph layout",
25
+ description: "Nodes and edges as a network: connected nodes sit close together. Works with any schema.",
26
+ type: "object",
27
+ required: ["type"],
28
+ additionalProperties: false,
29
+ properties: {
30
+ type: { const: "graph" },
31
+ edgeFields: parameterisable({ $ref: `${SCHEMA_URL}/settings.json#/$defs/fieldList` }, [], "Fields whose edges are drawn and pull nodes together. Empty: all edges.")
32
+ }
33
+ };
34
+ //#endregion
35
+ //#region src/core/layouts/landscape/schema.ts
36
+ /** A dimension: groups that are the same wherever the dimension is used. Dispatches on `field`, like a grouping level. */
37
+ var dimensionSchema = {
38
+ type: "object",
39
+ if: {
40
+ type: "object",
41
+ required: ["field"]
42
+ },
43
+ then: {
44
+ type: "object",
45
+ description: "Groups labelled by the values of a field of the strip's first node level. A value no node has is not a group.",
46
+ required: ["field"],
47
+ additionalProperties: false,
48
+ properties: { field: {
49
+ type: "string",
50
+ minLength: 1
51
+ } }
52
+ },
53
+ else: {
54
+ type: "object",
55
+ description: "A group for every node of one type.",
56
+ required: ["type"],
57
+ additionalProperties: false,
58
+ properties: {
59
+ type: {
60
+ description: "Node type of the groups.",
61
+ anyOf: [{
62
+ type: "string",
63
+ minLength: 1
64
+ }, { $ref: PARAM_REF }]
65
+ },
66
+ edge: {
67
+ type: "object",
68
+ description: "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.",
69
+ required: ["field"],
70
+ additionalProperties: false,
71
+ properties: { field: {
72
+ type: "string",
73
+ minLength: 1
74
+ } }
75
+ }
76
+ }
77
+ }
78
+ };
79
+ /** Settings of the landscape layout: strips of nested containers, optionally divided into cells by dimensions. */
80
+ var landscapeLayoutSchema = {
81
+ $schema: "https://json-schema.org/draft/2020-12/schema",
82
+ $id: `${SCHEMA_URL}/layouts/landscape.json`,
83
+ title: "Landscape layout",
84
+ description: "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.",
85
+ type: "object",
86
+ required: ["type", "strips"],
87
+ additionalProperties: false,
88
+ properties: {
89
+ type: { const: "landscape" },
90
+ orientation: parameterisable({ $ref: `${SCHEMA_URL}/settings.json#/$defs/orientation` }, "horizontal", "horizontal: top-level containers, or the layout dimension's groups, side by side, as columns, and strips stacked. vertical: the reverse."),
91
+ dimension: {
92
+ ...dimensionSchema,
93
+ description: "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."
94
+ },
95
+ strips: {
96
+ type: "array",
97
+ minItems: 1,
98
+ description: "The strips, in order along the axis the layout dimension does not run along.",
99
+ items: {
100
+ type: "object",
101
+ required: ["group"],
102
+ additionalProperties: false,
103
+ properties: {
104
+ dimension: {
105
+ ...dimensionSchema,
106
+ description: "Divides this strip further, along the strip's own axis. Without a layout dimension, a strip with its own dimension is a swimlane."
107
+ },
108
+ showUngrouped: parameterisable({ type: "boolean" }, true, "Whether to draw the nodes of the strip's levels that no cell or container reached."),
109
+ group: {
110
+ type: "array",
111
+ minItems: 1,
112
+ description: "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.",
113
+ items: {
114
+ type: "object",
115
+ if: {
116
+ type: "object",
117
+ required: ["field"]
118
+ },
119
+ then: {
120
+ type: "object",
121
+ description: "Containers labelled by the values of a field of the next node level's nodes. A node with several values appears under each.",
122
+ required: ["field"],
123
+ additionalProperties: false,
124
+ properties: { field: {
125
+ type: "string",
126
+ minLength: 1
127
+ } }
128
+ },
129
+ else: {
130
+ type: "object",
131
+ description: "A level of nodes of one type.",
132
+ required: ["type"],
133
+ additionalProperties: false,
134
+ properties: {
135
+ type: {
136
+ description: "Node type at this level.",
137
+ anyOf: [{
138
+ type: "string",
139
+ minLength: 1
140
+ }, { $ref: PARAM_REF }]
141
+ },
142
+ edge: {
143
+ type: "object",
144
+ description: "Which edges join this level to the node level above (or to the last `via` type). By default, any edge between the two types.",
145
+ required: ["field"],
146
+ additionalProperties: false,
147
+ properties: { field: {
148
+ type: "string",
149
+ minLength: 1
150
+ } }
151
+ },
152
+ via: {
153
+ type: "array",
154
+ minItems: 1,
155
+ description: "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.",
156
+ items: {
157
+ type: "string",
158
+ minLength: 1
159
+ }
160
+ },
161
+ intermediate: parameterisable({ $ref: `${SCHEMA_URL}/layouts/landscape.json#/$defs/intermediate` }, "hidden", "How the skipped nodes of a `via` chain are shown.")
162
+ }
163
+ }
164
+ }
165
+ }
166
+ }
167
+ }
168
+ }
169
+ },
170
+ $defs: { intermediate: {
171
+ title: "Skipped levels",
172
+ description: "hidden: not shown. breadcrumb: listed on each node reached through them.",
173
+ enum: ["hidden", "breadcrumb"]
174
+ } }
175
+ };
176
+ function checkLandscapeLayout(layout) {
177
+ if (layout.strips.some((strip) => !("type" in strip.group.at(-1)))) return "the last grouping level of a strip must be a node type, not a field";
178
+ }
179
+ //#endregion
180
+ //#region src/core/layouts/neighbourhood/schema.ts
181
+ var roleFields = (description) => parameterisable({ $ref: `${SCHEMA_URL}/settings.json#/$defs/fieldList` }, [], description);
182
+ /** Settings of the neighbourhood layout: the neighbourhood of one node, placed by role. */
183
+ var neighbourhoodLayoutSchema = {
184
+ $schema: "https://json-schema.org/draft/2020-12/schema",
185
+ $id: `${SCHEMA_URL}/layouts/neighbourhood.json`,
186
+ title: "Neighbourhood layout",
187
+ description: "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.",
188
+ type: "object",
189
+ required: ["type"],
190
+ additionalProperties: false,
191
+ properties: {
192
+ type: { const: "neighbourhood" },
193
+ above: roleFields("Fields whose nodes are shown above the focus, in addition to the default."),
194
+ below: roleFields("Fields whose nodes are shown below the focus, in addition to the default."),
195
+ left: roleFields("Fields whose nodes are shown to the left of the focus, in addition to the default."),
196
+ right: roleFields("Fields whose nodes are shown to the right of the focus, in addition to the default.")
197
+ }
198
+ };
199
+ //#endregion
200
+ //#region src/core/layouts/tree/schema.ts
201
+ /** Settings of the tree layout: a tree over the schema's hierarchy. */
202
+ var treeLayoutSchema = {
203
+ $schema: "https://json-schema.org/draft/2020-12/schema",
204
+ $id: `${SCHEMA_URL}/layouts/tree.json`,
205
+ title: "Tree layout",
206
+ description: "A tree over the schema's hierarchy: root-type nodes at the top, children via hierarchy edges.",
207
+ type: "object",
208
+ required: ["type"],
209
+ additionalProperties: false,
210
+ properties: {
211
+ type: { const: "tree" },
212
+ orientation: parameterisable({ $ref: `${SCHEMA_URL}/settings.json#/$defs/orientation` }, "vertical", "Direction the tree grows."),
213
+ dag: parameterisable({ $ref: `${SCHEMA_URL}/layouts/tree.json#/$defs/dag` }, "repeat", "How a node with several parents is shown.")
214
+ },
215
+ $defs: { dag: {
216
+ title: "Nodes with several parents",
217
+ description: "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.",
218
+ enum: ["repeat", "cross-edge"]
219
+ } }
220
+ };
221
+ //#endregion
222
+ //#region src/core/layouts/xy/schema.ts
223
+ /** Settings of the XY layout: nodes positioned by two numeric fields. */
224
+ var xyLayoutSchema = {
225
+ $schema: "https://json-schema.org/draft/2020-12/schema",
226
+ $id: `${SCHEMA_URL}/layouts/xy.json`,
227
+ title: "XY layout",
228
+ description: "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.",
229
+ type: "object",
230
+ required: [
231
+ "type",
232
+ "x",
233
+ "y"
234
+ ],
235
+ additionalProperties: false,
236
+ properties: {
237
+ type: { const: "xy" },
238
+ x: { $ref: `${SCHEMA_URL}/layouts/xy.json#/$defs/axis` },
239
+ y: { $ref: `${SCHEMA_URL}/layouts/xy.json#/$defs/axis` },
240
+ types: parameterisable({
241
+ type: "array",
242
+ items: {
243
+ type: "string",
244
+ minLength: 1
245
+ },
246
+ uniqueItems: true
247
+ }, [], "Node types to plot. Empty: every type with a value on either axis."),
248
+ edgeFields: parameterisable({ $ref: `${SCHEMA_URL}/settings.json#/$defs/fieldList` }, [], "Fields whose edges are drawn between plotted nodes. Empty: all edges.")
249
+ },
250
+ $defs: {
251
+ axis: {
252
+ title: "Axis",
253
+ type: "object",
254
+ required: ["field"],
255
+ additionalProperties: false,
256
+ properties: {
257
+ field: {
258
+ description: "Numeric field giving the position.",
259
+ anyOf: [{
260
+ type: "string",
261
+ minLength: 1
262
+ }, { $ref: PARAM_REF }]
263
+ },
264
+ domain: {
265
+ description: "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.",
266
+ default: "data",
267
+ anyOf: [{ const: "data" }, {
268
+ type: "array",
269
+ items: { type: "number" },
270
+ minItems: 2,
271
+ maxItems: 2
272
+ }]
273
+ },
274
+ direction: parameterisable({ $ref: `${SCHEMA_URL}/layouts/xy.json#/$defs/direction` }, "ascending", "ascending: values grow rightwards (x) or upwards (y). descending: the reverse."),
275
+ label: {
276
+ type: "string",
277
+ description: "Axis title. Defaults to the field name."
278
+ }
279
+ }
280
+ },
281
+ direction: {
282
+ title: "Axis direction",
283
+ enum: ["ascending", "descending"]
284
+ }
285
+ }
286
+ };
287
+ function checkXYLayout(layout) {
288
+ for (const axis of ["x", "y"]) {
289
+ const { domain } = layout[axis];
290
+ if (Array.isArray(domain) && !(domain[0] < domain[1])) return `${axis} domain must be [min, max] with min < max`;
291
+ }
292
+ }
293
+ //#endregion
294
+ //#region src/core/layouts/schemas.ts
295
+ /** Every layout's settings schema. The definition format and its types follow from this list. */
296
+ var layoutSchemas = [
297
+ treeLayoutSchema,
298
+ landscapeLayoutSchema,
299
+ xyLayoutSchema,
300
+ neighbourhoodLayoutSchema,
301
+ graphLayoutSchema
302
+ ];
303
+ /** Rules a layout's schema can't express. A check returns a message for settings that break one. */
304
+ var layoutChecks = {
305
+ landscape: checkLandscapeLayout,
306
+ xy: checkXYLayout
307
+ };
308
+ //#endregion
309
+ //#region src/core/schema/definition-schema.ts
20
310
  /**
21
311
  * The map view definition format: shared parameters, and the regions a map view is composed of.
22
312
  *
@@ -29,11 +319,7 @@ var definitionSchema = {
29
319
  title: "Map view definition",
30
320
  description: "Declares how spaces of one schema are projected into a map view: shared parameters, and the regions the map view is composed of.",
31
321
  type: "object",
32
- required: [
33
- "$id",
34
- "schema",
35
- "regions"
36
- ],
322
+ required: ["$id", "regions"],
37
323
  additionalProperties: false,
38
324
  properties: {
39
325
  $schema: { type: "string" },
@@ -51,7 +337,7 @@ var definitionSchema = {
51
337
  schema: {
52
338
  type: "string",
53
339
  minLength: 1,
54
- description: "`$id` of the structured-context schema whose spaces this map view applies to."
340
+ description: "`$id` of the structured-context schema whose spaces this map view applies to. Omitted: it applies to every schema."
55
341
  },
56
342
  parameters: {
57
343
  type: "object",
@@ -94,7 +380,7 @@ var definitionSchema = {
94
380
  id: {
95
381
  type: "string",
96
382
  minLength: 1,
97
- description: "Unique within the map view; part of every occurrence id in the region."
383
+ description: "Unique within the map view; part of every occurrence key in the region."
98
384
  },
99
385
  select: {
100
386
  type: "object",
@@ -111,11 +397,7 @@ var definitionSchema = {
111
397
  type: "object",
112
398
  required: ["type"],
113
399
  discriminator: { propertyName: "type" },
114
- oneOf: [
115
- { $ref: `${SCHEMA_URL}/layouts/tree.json` },
116
- { $ref: `${SCHEMA_URL}/layouts/landscape.json` },
117
- { $ref: `${SCHEMA_URL}/layouts/xy.json` }
118
- ]
400
+ oneOf: layoutSchemas.map((schema) => ({ $ref: schema.$id }))
119
401
  },
120
402
  nodes: {
121
403
  type: "object",
@@ -132,92 +414,17 @@ var definitionSchema = {
132
414
  type: "object",
133
415
  additionalProperties: false,
134
416
  default: {},
135
- properties: { show: parameterisable({ type: "boolean" }, true, "Whether connectors are drawn.") }
136
- }
137
- }
138
- }
139
- }
140
- };
141
- //#endregion
142
- //#region src/core/format/landscape-layout.ts
143
- /** Settings of the landscape layout: nested containers following an authored grouping. */
144
- var landscapeLayoutSchema = {
145
- $schema: "https://json-schema.org/draft/2020-12/schema",
146
- $id: `${SCHEMA_URL}/layouts/landscape.json`,
147
- title: "Landscape layout",
148
- description: "Nested containers: each grouping level becomes containers inside the level above, and the last level is drawn as nodes.",
149
- type: "object",
150
- required: ["type", "group"],
151
- additionalProperties: false,
152
- properties: {
153
- type: { const: "landscape" },
154
- orientation: parameterisable({ $ref: `${SCHEMA_URL}/settings.json#/$defs/orientation` }, "horizontal", "horizontal: top-level containers side by side, as columns. vertical: stacked, as rows."),
155
- group: {
156
- type: "array",
157
- minItems: 1,
158
- description: "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.",
159
- items: {
160
- type: "object",
161
- if: {
162
- type: "object",
163
- required: ["field"]
164
- },
165
- then: {
166
- type: "object",
167
- description: "Containers labelled by the values of a field of the next node level's nodes. A node with several values appears under each.",
168
- required: ["field"],
169
- additionalProperties: false,
170
- properties: { field: {
171
- type: "string",
172
- minLength: 1
173
- } }
174
- },
175
- else: {
176
- type: "object",
177
- description: "A level of nodes of one type.",
178
- required: ["type"],
179
- additionalProperties: false,
180
417
  properties: {
181
- type: {
182
- description: "Node type at this level.",
183
- anyOf: [{
184
- type: "string",
185
- minLength: 1
186
- }, { $ref: PARAM_REF }]
187
- },
188
- edge: {
189
- type: "object",
190
- description: "Which edges join this level to the node level above (or to the last `via` type). By default, any edge between the two types.",
191
- required: ["field"],
192
- additionalProperties: false,
193
- properties: { field: {
194
- type: "string",
195
- minLength: 1
196
- } }
197
- },
198
- via: {
199
- type: "array",
200
- minItems: 1,
201
- description: "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.",
202
- items: {
203
- type: "string",
204
- minLength: 1
205
- }
206
- },
207
- intermediate: parameterisable({ $ref: `${SCHEMA_URL}/layouts/landscape.json#/$defs/intermediate` }, "hidden", "How the skipped nodes of a `via` chain are shown.")
418
+ show: parameterisable({ type: "boolean" }, true, "Whether connectors are drawn."),
419
+ labels: parameterisable({ type: "boolean" }, false, "Whether each connector is labelled with the field the relationship is declared in.")
208
420
  }
209
421
  }
210
422
  }
211
423
  }
212
- },
213
- $defs: { intermediate: {
214
- title: "Skipped levels",
215
- description: "hidden: not shown. breadcrumb: listed on each node reached through them.",
216
- enum: ["hidden", "breadcrumb"]
217
- } }
424
+ }
218
425
  };
219
426
  //#endregion
220
- //#region src/core/format/index.ts
427
+ //#region src/core/definition.ts
221
428
  /** The bundled schemas describing the map view definition format. */
222
429
  var MAP_VIEW_SCHEMAS = [
223
430
  definitionSchema,
@@ -264,92 +471,8 @@ var MAP_VIEW_SCHEMAS = [
264
471
  }
265
472
  }
266
473
  },
267
- {
268
- $schema: "https://json-schema.org/draft/2020-12/schema",
269
- $id: `${SCHEMA_URL}/layouts/tree.json`,
270
- title: "Tree layout",
271
- description: "A tree over the schema's hierarchy: root-type nodes at the top, children via hierarchy edges.",
272
- type: "object",
273
- required: ["type"],
274
- additionalProperties: false,
275
- properties: {
276
- type: { const: "tree" },
277
- orientation: parameterisable({ $ref: `${SCHEMA_URL}/settings.json#/$defs/orientation` }, "vertical", "Direction the tree grows."),
278
- dag: parameterisable({ $ref: `${SCHEMA_URL}/layouts/tree.json#/$defs/dag` }, "repeat", "How a node with several parents is shown.")
279
- },
280
- $defs: { dag: {
281
- title: "Nodes with several parents",
282
- description: "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.",
283
- enum: ["repeat", "cross-edge"]
284
- } }
285
- },
286
- landscapeLayoutSchema,
287
- {
288
- $schema: "https://json-schema.org/draft/2020-12/schema",
289
- $id: `${SCHEMA_URL}/layouts/xy.json`,
290
- title: "XY layout",
291
- description: "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.",
292
- type: "object",
293
- required: [
294
- "type",
295
- "x",
296
- "y"
297
- ],
298
- additionalProperties: false,
299
- properties: {
300
- type: { const: "xy" },
301
- x: { $ref: `${SCHEMA_URL}/layouts/xy.json#/$defs/axis` },
302
- y: { $ref: `${SCHEMA_URL}/layouts/xy.json#/$defs/axis` },
303
- types: parameterisable({
304
- type: "array",
305
- items: {
306
- type: "string",
307
- minLength: 1
308
- },
309
- uniqueItems: true
310
- }, [], "Node types to plot. Empty: every type with a value on either axis."),
311
- edgeFields: parameterisable({ $ref: `${SCHEMA_URL}/settings.json#/$defs/fieldList` }, [], "Fields whose edges are drawn between plotted nodes. Empty: all edges.")
312
- },
313
- $defs: {
314
- axis: {
315
- title: "Axis",
316
- type: "object",
317
- required: ["field"],
318
- additionalProperties: false,
319
- properties: {
320
- field: {
321
- description: "Numeric field giving the position.",
322
- anyOf: [{
323
- type: "string",
324
- minLength: 1
325
- }, { $ref: PARAM_REF }]
326
- },
327
- domain: {
328
- description: "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.",
329
- default: "data",
330
- anyOf: [{ const: "data" }, {
331
- type: "array",
332
- items: { type: "number" },
333
- minItems: 2,
334
- maxItems: 2
335
- }]
336
- },
337
- direction: parameterisable({ $ref: `${SCHEMA_URL}/layouts/xy.json#/$defs/direction` }, "ascending", "ascending: values grow rightwards (x) or upwards (y). descending: the reverse."),
338
- label: {
339
- type: "string",
340
- description: "Axis title. Defaults to the field name."
341
- }
342
- }
343
- },
344
- direction: {
345
- title: "Axis direction",
346
- enum: ["ascending", "descending"]
347
- }
348
- }
349
- }
474
+ ...layoutSchemas
350
475
  ];
351
- //#endregion
352
- //#region src/core/definition.ts
353
476
  var MapViewDefinitionError = class extends Error {
354
477
  constructor(name, message) {
355
478
  super(`Map view "${name}": ${message}`);
@@ -397,17 +520,14 @@ function parseMapViewDefinition(name, text) {
397
520
  for (const region of source.regions) {
398
521
  if (regionIds.has(region.id)) fail(`duplicate region id "${region.id}"`);
399
522
  regionIds.add(region.id);
400
- if (region.layout.type === "landscape" && !("type" in region.layout.group.at(-1))) fail(`region "${region.id}": the last grouping level must be a node type, not a field`);
401
- if (region.layout.type === "xy") for (const axis of ["x", "y"]) {
402
- const { domain } = region.layout[axis];
403
- if (Array.isArray(domain) && !(domain[0] < domain[1])) fail(`region "${region.id}": ${axis} domain must be [min, max] with min < max`);
404
- }
523
+ const broken = layoutChecks[region.layout.type]?.(region.layout);
524
+ if (broken) fail(`region "${region.id}": ${broken}`);
405
525
  }
406
526
  return {
407
527
  id: source.$id,
408
528
  title: source.title ?? source.$id.slice(source.$id.lastIndexOf("/") + 1),
409
529
  ...source.description !== void 0 && { description: source.description },
410
- schema: source.schema,
530
+ ...source.schema !== void 0 && { schema: source.schema },
411
531
  parameters,
412
532
  source
413
533
  };
@@ -446,9 +566,9 @@ function selectionFilter(definition, values = {}) {
446
566
  function viewValidationLevel(definition, values = {}) {
447
567
  return resolveRegions(definition, values)[0]?.nodes.validation ?? "off";
448
568
  }
449
- /** Map view definitions that apply to a space with the given schema. */
569
+ /** Map view definitions that apply to a space with the given schema, including those for every schema. */
450
570
  function mapViewsForSchema(definitions, schemaId) {
451
- return schemaId === void 0 ? [] : definitions.filter((d) => d.schema === schemaId);
571
+ return definitions.filter((d) => d.schema === void 0 || d.schema === schemaId);
452
572
  }
453
573
  /** Resolve `$ref`s relative to the format schemas, so parameters can write `settings.json#/$defs/orientation`. */
454
574
  function absoluteRefs(node) {
@@ -604,6 +724,6 @@ function detail(error) {
604
724
  return "";
605
725
  }
606
726
  //#endregion
607
- export { resolveRegions as a, MAP_VIEW_SCHEMAS as c, resolveParameterValues as i, mapViewsForSchema as n, selectionFilter as o, parseMapViewDefinition as r, viewValidationLevel as s, MapViewDefinitionError as t };
727
+ export { resolveParameterValues as a, viewValidationLevel as c, parseMapViewDefinition as i, MapViewDefinitionError as n, resolveRegions as o, mapViewsForSchema as r, selectionFilter as s, MAP_VIEW_SCHEMAS as t };
608
728
 
609
- //# sourceMappingURL=definition-Cp1CCigh.js.map
729
+ //# sourceMappingURL=definition-SjmROmJC.js.map