structured-context-map-views 0.0.0-stage → 0.2.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 (38) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +19 -2
  3. package/dist/definition-Cft28YUA.js +616 -0
  4. package/dist/definition-Cft28YUA.js.map +1 -0
  5. package/dist/index.js +1045 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/node.js +106 -0
  8. package/dist/node.js.map +1 -0
  9. package/dist/styles.css +528 -0
  10. package/dist/types/core/annotations.d.ts +47 -0
  11. package/dist/types/core/definition.d.ts +117 -0
  12. package/dist/types/core/format/definition-schema.d.ts +181 -0
  13. package/dist/types/core/format/index.d.ts +450 -0
  14. package/dist/types/core/format/landscape-layout.d.ts +102 -0
  15. package/dist/types/core/format/param-ref.d.ts +10 -0
  16. package/dist/types/core/format/schema-url.d.ts +7 -0
  17. package/dist/types/core/format/settings.d.ts +41 -0
  18. package/dist/types/core/format/tree-layout.d.ts +40 -0
  19. package/dist/types/core/format/xy-layout.d.ts +94 -0
  20. package/dist/types/core/graph.d.ts +16 -0
  21. package/dist/types/core/landscape.d.ts +44 -0
  22. package/dist/types/core/occurrence.d.ts +11 -0
  23. package/dist/types/core/tree.d.ts +45 -0
  24. package/dist/types/core/xy.d.ts +43 -0
  25. package/dist/types/index.d.ts +10 -0
  26. package/dist/types/layouts/EdgeOverlay.d.ts +36 -0
  27. package/dist/types/layouts/LandscapeLayout.d.ts +8 -0
  28. package/dist/types/layouts/MapView.d.ts +18 -0
  29. package/dist/types/layouts/NodeCard.d.ts +16 -0
  30. package/dist/types/layouts/ParameterControls.d.ts +13 -0
  31. package/dist/types/layouts/ParameterInputs.d.ts +21 -0
  32. package/dist/types/layouts/TreeLayout.d.ts +16 -0
  33. package/dist/types/layouts/XYLayout.d.ts +9 -0
  34. package/dist/types/layouts/annotations-context.d.ts +4 -0
  35. package/dist/types/layouts/useParameterControls.d.ts +13 -0
  36. package/dist/types/node/bundled-definitions.d.ts +1 -0
  37. package/dist/types/node/index.d.ts +17 -0
  38. package/package.json +69 -4
@@ -0,0 +1,528 @@
1
+ /*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */
2
+ @layer properties;
3
+ @layer theme {
4
+ :root, :host {
5
+ --mv-color-white: #fff;
6
+ --mv-spacing: 0.25rem;
7
+ --mv-text-xs: 0.75rem;
8
+ --mv-text-xs--line-height: calc(1 / 0.75);
9
+ --mv-text-sm: 0.875rem;
10
+ --mv-text-sm--line-height: calc(1.25 / 0.875);
11
+ --mv-font-weight-semibold: 600;
12
+ --mv-tracking-wide: 0.025em;
13
+ --mv-leading-tight: 1.25;
14
+ --mv-leading-snug: 1.375;
15
+ --mv-radius-md: 0.375rem;
16
+ --mv-radius-lg: 0.5rem;
17
+ --mv-color-surface: #f8f8f7;
18
+ --mv-color-card: #ffffff;
19
+ --mv-color-ink: #1f2328;
20
+ --mv-color-muted: #59636e;
21
+ --mv-color-edge: #d1d9e0;
22
+ --mv-color-accent: #0969da;
23
+ --mv-color-error: #cf222e;
24
+ --mv-color-warning: #9a6700;
25
+ --mv-color-info: #0969da;
26
+ }
27
+ }
28
+ .mv\:pointer-events-none {
29
+ pointer-events: none;
30
+ }
31
+ .mv\:absolute {
32
+ position: absolute;
33
+ }
34
+ .mv\:relative {
35
+ position: relative;
36
+ }
37
+ .mv\:inset-0 {
38
+ inset: 0px;
39
+ }
40
+ .mv\:inset-8 {
41
+ inset: calc(var(--mv-spacing) * 8);
42
+ }
43
+ .mv\:-top-1\.5 {
44
+ top: calc(var(--mv-spacing) * -1.5);
45
+ }
46
+ .mv\:-right-1\.5 {
47
+ right: calc(var(--mv-spacing) * -1.5);
48
+ }
49
+ .mv\:float-left {
50
+ float: left;
51
+ }
52
+ .mv\:m-0 {
53
+ margin: 0px;
54
+ }
55
+ .mv\:mt-1 {
56
+ margin-top: var(--mv-spacing);
57
+ }
58
+ .mv\:mr-1\.5 {
59
+ margin-right: calc(var(--mv-spacing) * 1.5);
60
+ }
61
+ .mv\:box-border {
62
+ box-sizing: border-box;
63
+ }
64
+ .mv\:block {
65
+ display: block;
66
+ }
67
+ .mv\:flex {
68
+ display: flex;
69
+ }
70
+ .mv\:grid {
71
+ display: grid;
72
+ }
73
+ .mv\:size-6 {
74
+ width: calc(var(--mv-spacing) * 6);
75
+ height: calc(var(--mv-spacing) * 6);
76
+ }
77
+ .mv\:h-4 {
78
+ height: calc(var(--mv-spacing) * 4);
79
+ }
80
+ .mv\:h-full {
81
+ height: 100%;
82
+ }
83
+ .mv\:min-h-0 {
84
+ min-height: 0px;
85
+ }
86
+ .mv\:min-h-\[28rem\] {
87
+ min-height: 28rem;
88
+ }
89
+ .mv\:w-44 {
90
+ width: calc(var(--mv-spacing) * 44);
91
+ }
92
+ .mv\:w-full {
93
+ width: 100%;
94
+ }
95
+ .mv\:w-max {
96
+ width: max-content;
97
+ }
98
+ .mv\:max-w-44 {
99
+ max-width: calc(var(--mv-spacing) * 44);
100
+ }
101
+ .mv\:max-w-\[36rem\] {
102
+ max-width: 36rem;
103
+ }
104
+ .mv\:min-w-4 {
105
+ min-width: calc(var(--mv-spacing) * 4);
106
+ }
107
+ .mv\:min-w-\[36rem\] {
108
+ min-width: 36rem;
109
+ }
110
+ .mv\:min-w-full {
111
+ min-width: 100%;
112
+ }
113
+ .mv\:flex-1 {
114
+ flex: 1;
115
+ }
116
+ .mv\:shrink-0 {
117
+ flex-shrink: 0;
118
+ }
119
+ .mv\:-translate-x-1\/2 {
120
+ --tw-translate-x: calc(calc(1 / 2 * 100%) * -1);
121
+ translate: var(--tw-translate-x) var(--tw-translate-y);
122
+ }
123
+ .mv\:-translate-x-3 {
124
+ --tw-translate-x: calc(var(--mv-spacing) * -3);
125
+ translate: var(--tw-translate-x) var(--tw-translate-y);
126
+ }
127
+ .mv\:translate-y-1\/2 {
128
+ --tw-translate-y: calc(1 / 2 * 100%);
129
+ translate: var(--tw-translate-x) var(--tw-translate-y);
130
+ }
131
+ .mv\:translate-y-3 {
132
+ --tw-translate-y: calc(var(--mv-spacing) * 3);
133
+ translate: var(--tw-translate-x) var(--tw-translate-y);
134
+ }
135
+ .mv\:rotate-180 {
136
+ rotate: 180deg;
137
+ }
138
+ .mv\:cursor-pointer {
139
+ cursor: pointer;
140
+ }
141
+ .mv\:list-none {
142
+ list-style-type: none;
143
+ }
144
+ .mv\:grid-cols-\[auto_1fr\] {
145
+ grid-template-columns: auto 1fr;
146
+ }
147
+ .mv\:grid-rows-\[1fr_auto\] {
148
+ grid-template-rows: 1fr auto;
149
+ }
150
+ .mv\:flex-col {
151
+ flex-direction: column;
152
+ }
153
+ .mv\:flex-col-reverse {
154
+ flex-direction: column-reverse;
155
+ }
156
+ .mv\:flex-row {
157
+ flex-direction: row;
158
+ }
159
+ .mv\:flex-wrap {
160
+ flex-wrap: wrap;
161
+ }
162
+ .mv\:items-center {
163
+ align-items: center;
164
+ }
165
+ .mv\:items-start {
166
+ align-items: flex-start;
167
+ }
168
+ .mv\:items-stretch {
169
+ align-items: stretch;
170
+ }
171
+ .mv\:justify-between {
172
+ justify-content: space-between;
173
+ }
174
+ .mv\:justify-center {
175
+ justify-content: center;
176
+ }
177
+ .mv\:gap-0\.5 {
178
+ gap: calc(var(--mv-spacing) * 0.5);
179
+ }
180
+ .mv\:gap-1 {
181
+ gap: var(--mv-spacing);
182
+ }
183
+ .mv\:gap-1\.5 {
184
+ gap: calc(var(--mv-spacing) * 1.5);
185
+ }
186
+ .mv\:gap-2 {
187
+ gap: calc(var(--mv-spacing) * 2);
188
+ }
189
+ .mv\:gap-3 {
190
+ gap: calc(var(--mv-spacing) * 3);
191
+ }
192
+ .mv\:gap-4 {
193
+ gap: calc(var(--mv-spacing) * 4);
194
+ }
195
+ .mv\:gap-x-4 {
196
+ column-gap: calc(var(--mv-spacing) * 4);
197
+ }
198
+ .mv\:gap-y-2 {
199
+ row-gap: calc(var(--mv-spacing) * 2);
200
+ }
201
+ .mv\:truncate {
202
+ overflow: hidden;
203
+ text-overflow: ellipsis;
204
+ white-space: nowrap;
205
+ }
206
+ .mv\:overflow-auto {
207
+ overflow: auto;
208
+ }
209
+ .mv\:overflow-visible {
210
+ overflow: visible;
211
+ }
212
+ .mv\:rounded {
213
+ border-radius: 0.25rem;
214
+ }
215
+ .mv\:rounded-full {
216
+ border-radius: calc(infinity * 1px);
217
+ }
218
+ .mv\:rounded-lg {
219
+ border-radius: var(--mv-radius-lg);
220
+ }
221
+ .mv\:rounded-md {
222
+ border-radius: var(--mv-radius-md);
223
+ }
224
+ .mv\:border {
225
+ border-style: var(--tw-border-style);
226
+ border-width: 1px;
227
+ }
228
+ .mv\:border-0 {
229
+ border-style: var(--tw-border-style);
230
+ border-width: 0px;
231
+ }
232
+ .mv\:border-2 {
233
+ border-style: var(--tw-border-style);
234
+ border-width: 2px;
235
+ }
236
+ .mv\:border-b {
237
+ border-bottom-style: var(--tw-border-style);
238
+ border-bottom-width: 1px;
239
+ }
240
+ .mv\:border-l {
241
+ border-left-style: var(--tw-border-style);
242
+ border-left-width: 1px;
243
+ }
244
+ .mv\:border-dashed {
245
+ --tw-border-style: dashed;
246
+ border-style: dashed;
247
+ }
248
+ .mv\:border-edge {
249
+ border-color: var(--mv-color-edge);
250
+ }
251
+ .mv\:border-muted\/60 {
252
+ border-color: var(--mv-color-muted);
253
+ @supports (color: color-mix(in lab, red, red)) {
254
+ border-color: color-mix(in oklab, var(--mv-color-muted) 60%, transparent);
255
+ }
256
+ }
257
+ .mv\:bg-card {
258
+ background-color: var(--mv-color-card);
259
+ }
260
+ .mv\:bg-error {
261
+ background-color: var(--mv-color-error);
262
+ }
263
+ .mv\:bg-info {
264
+ background-color: var(--mv-color-info);
265
+ }
266
+ .mv\:bg-surface {
267
+ background-color: var(--mv-color-surface);
268
+ }
269
+ .mv\:bg-surface\/80 {
270
+ background-color: var(--mv-color-surface);
271
+ @supports (color: color-mix(in lab, red, red)) {
272
+ background-color: color-mix(in oklab, var(--mv-color-surface) 80%, transparent);
273
+ }
274
+ }
275
+ .mv\:bg-warning {
276
+ background-color: var(--mv-color-warning);
277
+ }
278
+ .mv\:fill-none {
279
+ fill: none;
280
+ }
281
+ .mv\:stroke-accent\/60 {
282
+ stroke: var(--mv-color-accent);
283
+ @supports (color: color-mix(in lab, red, red)) {
284
+ stroke: color-mix(in oklab, var(--mv-color-accent) 60%, transparent);
285
+ }
286
+ }
287
+ .mv\:stroke-muted\/50 {
288
+ stroke: var(--mv-color-muted);
289
+ @supports (color: color-mix(in lab, red, red)) {
290
+ stroke: color-mix(in oklab, var(--mv-color-muted) 50%, transparent);
291
+ }
292
+ }
293
+ .mv\:p-0 {
294
+ padding: 0px;
295
+ }
296
+ .mv\:p-2 {
297
+ padding: calc(var(--mv-spacing) * 2);
298
+ }
299
+ .mv\:p-4 {
300
+ padding: calc(var(--mv-spacing) * 4);
301
+ }
302
+ .mv\:px-0\.5 {
303
+ padding-inline: calc(var(--mv-spacing) * 0.5);
304
+ }
305
+ .mv\:px-1 {
306
+ padding-inline: var(--mv-spacing);
307
+ }
308
+ .mv\:px-2\.5 {
309
+ padding-inline: calc(var(--mv-spacing) * 2.5);
310
+ }
311
+ .mv\:px-8 {
312
+ padding-inline: calc(var(--mv-spacing) * 8);
313
+ }
314
+ .mv\:py-1\.5 {
315
+ padding-block: calc(var(--mv-spacing) * 1.5);
316
+ }
317
+ .mv\:py-8 {
318
+ padding-block: calc(var(--mv-spacing) * 8);
319
+ }
320
+ .mv\:pt-10 {
321
+ padding-top: calc(var(--mv-spacing) * 10);
322
+ }
323
+ .mv\:pl-14 {
324
+ padding-left: calc(var(--mv-spacing) * 14);
325
+ }
326
+ .mv\:text-left {
327
+ text-align: left;
328
+ }
329
+ .mv\:text-sm {
330
+ font-size: var(--mv-text-sm);
331
+ line-height: var(--tw-leading, var(--mv-text-sm--line-height));
332
+ }
333
+ .mv\:text-xs {
334
+ font-size: var(--mv-text-xs);
335
+ line-height: var(--tw-leading, var(--mv-text-xs--line-height));
336
+ }
337
+ .mv\:text-\[0\.6rem\] {
338
+ font-size: 0.6rem;
339
+ }
340
+ .mv\:text-\[0\.65rem\] {
341
+ font-size: 0.65rem;
342
+ }
343
+ .mv\:leading-snug {
344
+ --tw-leading: var(--mv-leading-snug);
345
+ line-height: var(--mv-leading-snug);
346
+ }
347
+ .mv\:leading-tight {
348
+ --tw-leading: var(--mv-leading-tight);
349
+ line-height: var(--mv-leading-tight);
350
+ }
351
+ .mv\:font-semibold {
352
+ --tw-font-weight: var(--mv-font-weight-semibold);
353
+ font-weight: var(--mv-font-weight-semibold);
354
+ }
355
+ .mv\:tracking-wide {
356
+ --tw-tracking: var(--mv-tracking-wide);
357
+ letter-spacing: var(--mv-tracking-wide);
358
+ }
359
+ .mv\:whitespace-nowrap {
360
+ white-space: nowrap;
361
+ }
362
+ .mv\:text-ink {
363
+ color: var(--mv-color-ink);
364
+ }
365
+ .mv\:text-muted {
366
+ color: var(--mv-color-muted);
367
+ }
368
+ .mv\:text-white {
369
+ color: var(--mv-color-white);
370
+ }
371
+ .mv\:uppercase {
372
+ text-transform: uppercase;
373
+ }
374
+ .mv\:opacity-75 {
375
+ opacity: 75%;
376
+ }
377
+ .mv\:shadow-sm {
378
+ --tw-shadow: 0 1px 3px 0 var(--tw-shadow-color, rgb(0 0 0 / 0.1)), 0 1px 2px -1px var(--tw-shadow-color, rgb(0 0 0 / 0.1));
379
+ box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
380
+ }
381
+ .mv\:\[writing-mode\:vertical-rl\] {
382
+ writing-mode: vertical-rl;
383
+ }
384
+ @media (hover: hover) {
385
+ .mv\:hover\:border-accent:hover {
386
+ border-color: var(--mv-color-accent);
387
+ }
388
+ .mv\:hover\:text-accent:hover {
389
+ color: var(--mv-color-accent);
390
+ }
391
+ }
392
+ .mv\:focus-visible\:outline-2:focus-visible {
393
+ outline-style: var(--tw-outline-style);
394
+ outline-width: 2px;
395
+ }
396
+ .mv\:focus-visible\:outline-accent:focus-visible {
397
+ outline-color: var(--mv-color-accent);
398
+ }
399
+ @property --tw-translate-x {
400
+ syntax: "*";
401
+ inherits: false;
402
+ initial-value: 0;
403
+ }
404
+ @property --tw-translate-y {
405
+ syntax: "*";
406
+ inherits: false;
407
+ initial-value: 0;
408
+ }
409
+ @property --tw-translate-z {
410
+ syntax: "*";
411
+ inherits: false;
412
+ initial-value: 0;
413
+ }
414
+ @property --tw-border-style {
415
+ syntax: "*";
416
+ inherits: false;
417
+ initial-value: solid;
418
+ }
419
+ @property --tw-leading {
420
+ syntax: "*";
421
+ inherits: false;
422
+ }
423
+ @property --tw-font-weight {
424
+ syntax: "*";
425
+ inherits: false;
426
+ }
427
+ @property --tw-tracking {
428
+ syntax: "*";
429
+ inherits: false;
430
+ }
431
+ @property --tw-shadow {
432
+ syntax: "*";
433
+ inherits: false;
434
+ initial-value: 0 0 #0000;
435
+ }
436
+ @property --tw-shadow-color {
437
+ syntax: "*";
438
+ inherits: false;
439
+ }
440
+ @property --tw-shadow-alpha {
441
+ syntax: "<percentage>";
442
+ inherits: false;
443
+ initial-value: 100%;
444
+ }
445
+ @property --tw-inset-shadow {
446
+ syntax: "*";
447
+ inherits: false;
448
+ initial-value: 0 0 #0000;
449
+ }
450
+ @property --tw-inset-shadow-color {
451
+ syntax: "*";
452
+ inherits: false;
453
+ }
454
+ @property --tw-inset-shadow-alpha {
455
+ syntax: "<percentage>";
456
+ inherits: false;
457
+ initial-value: 100%;
458
+ }
459
+ @property --tw-ring-color {
460
+ syntax: "*";
461
+ inherits: false;
462
+ }
463
+ @property --tw-ring-shadow {
464
+ syntax: "*";
465
+ inherits: false;
466
+ initial-value: 0 0 #0000;
467
+ }
468
+ @property --tw-inset-ring-color {
469
+ syntax: "*";
470
+ inherits: false;
471
+ }
472
+ @property --tw-inset-ring-shadow {
473
+ syntax: "*";
474
+ inherits: false;
475
+ initial-value: 0 0 #0000;
476
+ }
477
+ @property --tw-ring-inset {
478
+ syntax: "*";
479
+ inherits: false;
480
+ }
481
+ @property --tw-ring-offset-width {
482
+ syntax: "<length>";
483
+ inherits: false;
484
+ initial-value: 0px;
485
+ }
486
+ @property --tw-ring-offset-color {
487
+ syntax: "*";
488
+ inherits: false;
489
+ initial-value: #fff;
490
+ }
491
+ @property --tw-ring-offset-shadow {
492
+ syntax: "*";
493
+ inherits: false;
494
+ initial-value: 0 0 #0000;
495
+ }
496
+ @property --tw-outline-style {
497
+ syntax: "*";
498
+ inherits: false;
499
+ initial-value: solid;
500
+ }
501
+ @layer properties {
502
+ @supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))) {
503
+ *, ::before, ::after, ::backdrop {
504
+ --tw-translate-x: 0;
505
+ --tw-translate-y: 0;
506
+ --tw-translate-z: 0;
507
+ --tw-border-style: solid;
508
+ --tw-leading: initial;
509
+ --tw-font-weight: initial;
510
+ --tw-tracking: initial;
511
+ --tw-shadow: 0 0 #0000;
512
+ --tw-shadow-color: initial;
513
+ --tw-shadow-alpha: 100%;
514
+ --tw-inset-shadow: 0 0 #0000;
515
+ --tw-inset-shadow-color: initial;
516
+ --tw-inset-shadow-alpha: 100%;
517
+ --tw-ring-color: initial;
518
+ --tw-ring-shadow: 0 0 #0000;
519
+ --tw-inset-ring-color: initial;
520
+ --tw-inset-ring-shadow: 0 0 #0000;
521
+ --tw-ring-inset: initial;
522
+ --tw-ring-offset-width: 0px;
523
+ --tw-ring-offset-color: #fff;
524
+ --tw-ring-offset-shadow: 0 0 #0000;
525
+ --tw-outline-style: solid;
526
+ }
527
+ }
528
+ }
@@ -0,0 +1,47 @@
1
+ import type { RuleSeverity, SourceLocation, SpaceGraph, SpaceNode, ValidationResult } from 'structured-context/api';
2
+ type NodeId = SpaceNode['id'];
3
+ /** How serious a result is: structured-context's rule severity. Schema and hierarchy failures are errors. */
4
+ export type Severity = RuleSeverity;
5
+ /** The kind of check a result came from. */
6
+ export type AnnotationSource = 'schema' | 'hierarchy' | 'rule';
7
+ /** One validation result attached to a node. */
8
+ export type NodeAnnotation = {
9
+ severity: Severity;
10
+ source: AnnotationSource;
11
+ message: string;
12
+ /** The violated rule, for `rule` results. */
13
+ ruleId?: string;
14
+ };
15
+ /** A validation result with no node on the map to attach to. */
16
+ export type UnattachedAnnotation = NodeAnnotation & {
17
+ /** The node it concerns. Absent for a global-scope rule. A node that failed its schema isn't in the graph. */
18
+ nodeId?: NodeId;
19
+ /** Where that node is defined, if known. */
20
+ location?: SourceLocation;
21
+ };
22
+ /** Annotations by the id of the node they apply to. */
23
+ export type AnnotationIndex = ReadonlyMap<NodeId, readonly NodeAnnotation[]>;
24
+ /**
25
+ * The parts of structured-context's `ValidationResult` that attach to a node. Every part is optional:
26
+ * a host that only runs some checks (the Obsidian plugin runs no AI-judged rules, say) passes what it has.
27
+ */
28
+ export type ValidationInput = Partial<Pick<ValidationResult, 'ruleViolations' | 'hierarchyViolations'> & {
29
+ nodeErrors: ReadonlyArray<Pick<ValidationResult['nodeErrors'][number], 'nodeId' | 'source' | 'issues'>>;
30
+ }>;
31
+ /**
32
+ * Attach validation results to the nodes of `graph`, by node id. Results that can't be attached are
33
+ * returned in `unattached` for the host to surface: global-scope rules (no node), and nodes that
34
+ * aren't in the graph, which includes every node that failed its schema.
35
+ */
36
+ export declare function annotationsFrom(input: ValidationInput, graph: SpaceGraph): {
37
+ annotations: AnnotationIndex;
38
+ unattached: UnattachedAnnotation[];
39
+ };
40
+ /** The most serious severity among annotations, or undefined if there are none. */
41
+ export declare function worstSeverity(annotations: readonly NodeAnnotation[]): Severity | undefined;
42
+ /**
43
+ * The annotations a map view shows: those at `level` or more serious, from `sources`. `off` shows none.
44
+ * Nodes left with no annotations are dropped from the index.
45
+ */
46
+ export declare function filterAnnotations(index: AnnotationIndex, level: Severity | 'off', sources: readonly AnnotationSource[]): AnnotationIndex;
47
+ export {};
@@ -0,0 +1,117 @@
1
+ import type { FromSchema } from 'json-schema-to-ts';
2
+ import { definitionSchema, type landscapeLayoutSchema, MAP_VIEW_SCHEMAS, type settingsSchema, type treeLayoutSchema, type xyLayoutSchema } from './format';
3
+ export { MAP_VIEW_SCHEMAS };
4
+ type References = {
5
+ references: [
6
+ typeof settingsSchema,
7
+ typeof treeLayoutSchema,
8
+ typeof landscapeLayoutSchema,
9
+ typeof xyLayoutSchema,
10
+ typeof definitionSchema
11
+ ];
12
+ parseIfThenElseKeywords: true;
13
+ };
14
+ type ParamRef = {
15
+ $param: string;
16
+ };
17
+ /** Drop `{ $param }` bindings from every setting's type: what remains after resolution. */
18
+ type Resolved<T> = T extends ParamRef ? never : T extends readonly (infer U)[] ? Resolved<U>[] : T extends object ? {
19
+ [K in keyof T]: Resolved<T[K]>;
20
+ } : T;
21
+ /** A definition as authored: settings may be `{ $param }` bindings, defaulted properties may be absent. */
22
+ export type AuthoredDefinition = FromSchema<typeof definitionSchema, References & {
23
+ keepDefaultedPropertiesOptional: true;
24
+ }>;
25
+ type FilledDefinition = FromSchema<typeof definitionSchema, References>;
26
+ /** A region with parameters applied and defaults filled in: what layouts receive. */
27
+ export type Region = Resolved<FilledDefinition['regions'][number]>;
28
+ export type LayoutConfig = Region['layout'];
29
+ export type TreeLayoutConfig = Extract<LayoutConfig, {
30
+ type: 'tree';
31
+ }>;
32
+ export type LandscapeLayoutConfig = Extract<LayoutConfig, {
33
+ type: 'landscape';
34
+ }>;
35
+ export type XYLayoutConfig = Extract<LayoutConfig, {
36
+ type: 'xy';
37
+ }>;
38
+ export type AxisConfig = XYLayoutConfig['x'];
39
+ export type GroupLevel = LandscapeLayoutConfig['group'][number];
40
+ export type IntermediateDisplay = Extract<GroupLevel, {
41
+ type: string;
42
+ }>['intermediate'];
43
+ export type NodesConfig = Region['nodes'];
44
+ export type EdgesConfig = Region['edges'];
45
+ export type Orientation = TreeLayoutConfig['orientation'];
46
+ export type DagMode = TreeLayoutConfig['dag'];
47
+ export type NodeStyle = NodesConfig['style'];
48
+ /**
49
+ * A validated map view definition. Plain data, so hosts can pass it across a server/browser
50
+ * boundary. Settings in `source` may still be `{ $param }` bindings; {@link resolveRegions}
51
+ * replaces them with parameter values.
52
+ */
53
+ export type MapViewDefinition = {
54
+ /** The definition's `$id`. */
55
+ id: string;
56
+ title: string;
57
+ description?: string;
58
+ /** `$id` of the schema whose spaces this map view applies to. */
59
+ schema: string;
60
+ parameters: Parameter[];
61
+ /** The definition as authored. */
62
+ source: AuthoredDefinition;
63
+ };
64
+ /** A setting the reader can change, with the control generated from its schema. */
65
+ export type Parameter = {
66
+ name: string;
67
+ title: string;
68
+ description?: string;
69
+ default: unknown;
70
+ control: ParameterControl;
71
+ };
72
+ /** Options are JSON primitives, so they can be labelled and compared directly. */
73
+ export type ParameterControl = {
74
+ kind: 'select';
75
+ options: readonly Primitive[];
76
+ } | {
77
+ kind: 'multiselect';
78
+ options: readonly Primitive[];
79
+ } | {
80
+ kind: 'toggle';
81
+ };
82
+ type Primitive = string | number | boolean | null;
83
+ export type ParameterValues = Readonly<Record<string, unknown>>;
84
+ export declare class MapViewDefinitionError extends Error {
85
+ constructor(name: string, message: string);
86
+ }
87
+ /**
88
+ * Parse a JSON5 map view definition and check it against the bundled schemas. `name` labels
89
+ * error messages (hosts pass where the definition came from).
90
+ *
91
+ * Beyond schema validation: every parameter needs a control derivable from its schema, and
92
+ * every value that control can produce must satisfy the parameter's schema; every `$param`
93
+ * must name a declared parameter; and each parameter's values must be valid wherever it's
94
+ * bound, checked by substituting them and re-validating.
95
+ */
96
+ export declare function parseMapViewDefinition(name: string, text: string): MapViewDefinition;
97
+ /**
98
+ * The value each parameter takes: the given value if its control could produce it, otherwise
99
+ * (missing, or stale saved state) the default. Hosts' controls and rendering both use this.
100
+ */
101
+ export declare function resolveParameterValues(definition: MapViewDefinition, values?: ParameterValues): ParameterValues;
102
+ /** Apply parameter values to a definition's regions and fill in setting defaults. */
103
+ export declare function resolveRegions(definition: MapViewDefinition, values?: ParameterValues): Region[];
104
+ /**
105
+ * The filter selecting the nodes a map view shows, if any. Hosts apply it when loading the space.
106
+ * PROTOTYPE: filters are evaluated by the host, not per region in the browser, because
107
+ * structured-context's filter evaluator can't yet be bundled for a browser (its only entry point,
108
+ * `structured-context/api`, imports Node built-ins). That's fine while only the first region renders.
109
+ */
110
+ export declare function selectionFilter(definition: MapViewDefinition, values?: ParameterValues): string | undefined;
111
+ /**
112
+ * The lowest severity of validation result the map view shows on nodes, or `off`. Hosts check it to
113
+ * decide whether to run validation at all, since results are only drawn when this isn't `off`.
114
+ */
115
+ export declare function viewValidationLevel(definition: MapViewDefinition, values?: ParameterValues): NodesConfig['validation'];
116
+ /** Map view definitions that apply to a space with the given schema. */
117
+ export declare function mapViewsForSchema(definitions: readonly MapViewDefinition[], schemaId: string | undefined): MapViewDefinition[];