structured-context-map-views 0.0.0-stage → 0.1.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.
- package/LICENSE +21 -0
- package/README.md +19 -2
- package/dist/definition-KuPoA1mO.js +582 -0
- package/dist/definition-KuPoA1mO.js.map +1 -0
- package/dist/index.js +889 -0
- package/dist/index.js.map +1 -0
- package/dist/node.js +106 -0
- package/dist/node.js.map +1 -0
- package/dist/styles.css +497 -0
- package/dist/types/core/definition.d.ts +112 -0
- package/dist/types/core/graph.d.ts +16 -0
- package/dist/types/core/index.d.ts +6 -0
- package/dist/types/core/landscape.d.ts +44 -0
- package/dist/types/core/occurrence.d.ts +11 -0
- package/dist/types/core/schemas/definition.d.ts +163 -0
- package/dist/types/core/schemas/index.d.ts +418 -0
- package/dist/types/core/schemas/landscape-layout.d.ts +102 -0
- package/dist/types/core/schemas/param-ref.d.ts +10 -0
- package/dist/types/core/schemas/schema-url.d.ts +7 -0
- package/dist/types/core/schemas/settings.d.ts +27 -0
- package/dist/types/core/schemas/tree-layout.d.ts +40 -0
- package/dist/types/core/schemas/xy-layout.d.ts +94 -0
- package/dist/types/core/tree.d.ts +45 -0
- package/dist/types/core/xy.d.ts +43 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/layouts/EdgeOverlay.d.ts +36 -0
- package/dist/types/layouts/LandscapeLayout.d.ts +8 -0
- package/dist/types/layouts/MapView.d.ts +12 -0
- package/dist/types/layouts/NodeCard.d.ts +16 -0
- package/dist/types/layouts/ParameterControls.d.ts +13 -0
- package/dist/types/layouts/TreeLayout.d.ts +16 -0
- package/dist/types/layouts/XYLayout.d.ts +9 -0
- package/dist/types/node/bundled-definitions.d.ts +1 -0
- package/dist/types/node/index.d.ts +17 -0
- package/package.json +69 -4
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/** Settings of the landscape layout: nested containers following an authored grouping. */
|
|
2
|
+
export declare const landscapeLayoutSchema: {
|
|
3
|
+
readonly $schema: 'https://json-schema.org/draft/2020-12/schema';
|
|
4
|
+
readonly $id: "https://raw.githubusercontent.com/mindsocket/structured-context-map-views/main/schemas/generated/latest/layouts/landscape.json";
|
|
5
|
+
readonly title: 'Landscape layout';
|
|
6
|
+
readonly description: 'Nested containers: each grouping level becomes containers inside the level above, and the last level is drawn as nodes.';
|
|
7
|
+
readonly type: 'object';
|
|
8
|
+
readonly required: readonly ['type', 'group'];
|
|
9
|
+
readonly additionalProperties: false;
|
|
10
|
+
readonly properties: {
|
|
11
|
+
readonly type: {
|
|
12
|
+
readonly const: 'landscape';
|
|
13
|
+
};
|
|
14
|
+
readonly orientation: {
|
|
15
|
+
readonly description: string;
|
|
16
|
+
readonly default: "horizontal";
|
|
17
|
+
readonly anyOf: readonly [{
|
|
18
|
+
readonly $ref: "https://raw.githubusercontent.com/mindsocket/structured-context-map-views/main/schemas/generated/latest/settings.json#/$defs/orientation";
|
|
19
|
+
}, {
|
|
20
|
+
readonly $ref: "https://raw.githubusercontent.com/mindsocket/structured-context-map-views/main/schemas/generated/latest/definition.json#/$defs/paramRef";
|
|
21
|
+
}];
|
|
22
|
+
};
|
|
23
|
+
readonly group: {
|
|
24
|
+
readonly type: 'array';
|
|
25
|
+
readonly minItems: 1;
|
|
26
|
+
readonly 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.';
|
|
27
|
+
readonly items: {
|
|
28
|
+
readonly type: 'object';
|
|
29
|
+
readonly if: {
|
|
30
|
+
readonly type: 'object';
|
|
31
|
+
readonly required: readonly ['field'];
|
|
32
|
+
};
|
|
33
|
+
readonly then: {
|
|
34
|
+
readonly type: 'object';
|
|
35
|
+
readonly description: "Containers labelled by the values of a field of the next node level's nodes. A node with several values appears under each.";
|
|
36
|
+
readonly required: readonly ['field'];
|
|
37
|
+
readonly additionalProperties: false;
|
|
38
|
+
readonly properties: {
|
|
39
|
+
readonly field: {
|
|
40
|
+
readonly type: 'string';
|
|
41
|
+
readonly minLength: 1;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
readonly else: {
|
|
46
|
+
readonly type: 'object';
|
|
47
|
+
readonly description: 'A level of nodes of one type.';
|
|
48
|
+
readonly required: readonly ['type'];
|
|
49
|
+
readonly additionalProperties: false;
|
|
50
|
+
readonly properties: {
|
|
51
|
+
readonly type: {
|
|
52
|
+
readonly description: 'Node type at this level.';
|
|
53
|
+
readonly anyOf: readonly [{
|
|
54
|
+
readonly type: 'string';
|
|
55
|
+
readonly minLength: 1;
|
|
56
|
+
}, {
|
|
57
|
+
readonly $ref: "https://raw.githubusercontent.com/mindsocket/structured-context-map-views/main/schemas/generated/latest/definition.json#/$defs/paramRef";
|
|
58
|
+
}];
|
|
59
|
+
};
|
|
60
|
+
readonly edge: {
|
|
61
|
+
readonly type: 'object';
|
|
62
|
+
readonly 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.';
|
|
63
|
+
readonly required: readonly ['field'];
|
|
64
|
+
readonly additionalProperties: false;
|
|
65
|
+
readonly properties: {
|
|
66
|
+
readonly field: {
|
|
67
|
+
readonly type: 'string';
|
|
68
|
+
readonly minLength: 1;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
readonly via: {
|
|
73
|
+
readonly type: 'array';
|
|
74
|
+
readonly minItems: 1;
|
|
75
|
+
readonly 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.';
|
|
76
|
+
readonly items: {
|
|
77
|
+
readonly type: 'string';
|
|
78
|
+
readonly minLength: 1;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
readonly intermediate: {
|
|
82
|
+
readonly description: string;
|
|
83
|
+
readonly default: "hidden";
|
|
84
|
+
readonly anyOf: readonly [{
|
|
85
|
+
readonly $ref: "https://raw.githubusercontent.com/mindsocket/structured-context-map-views/main/schemas/generated/latest/layouts/landscape.json#/$defs/intermediate";
|
|
86
|
+
}, {
|
|
87
|
+
readonly $ref: "https://raw.githubusercontent.com/mindsocket/structured-context-map-views/main/schemas/generated/latest/definition.json#/$defs/paramRef";
|
|
88
|
+
}];
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
readonly $defs: {
|
|
96
|
+
readonly intermediate: {
|
|
97
|
+
readonly title: 'Skipped levels';
|
|
98
|
+
readonly description: 'hidden: not shown. breadcrumb: listed on each node reached through them.';
|
|
99
|
+
readonly enum: readonly ['hidden', 'breadcrumb'];
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** `$ref` target for a setting whose value comes from a declared parameter. */
|
|
2
|
+
export declare const PARAM_REF: "https://raw.githubusercontent.com/mindsocket/structured-context-map-views/main/schemas/generated/latest/definition.json#/$defs/paramRef";
|
|
3
|
+
/** A setting that takes either a fixed value matching `valueSchema` or a `{ $param }` binding. */
|
|
4
|
+
export declare function parameterisable<const S extends object, const D>(valueSchema: S, defaultValue: D, description: string): {
|
|
5
|
+
readonly description: string;
|
|
6
|
+
readonly default: D;
|
|
7
|
+
readonly anyOf: readonly [S, {
|
|
8
|
+
readonly $ref: "https://raw.githubusercontent.com/mindsocket/structured-context-map-views/main/schemas/generated/latest/definition.json#/$defs/paramRef";
|
|
9
|
+
}];
|
|
10
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where the format schemas are published. `latest` follows the newest format; a release that changes it
|
|
3
|
+
* freezes a copy under its own version folder (`bun run generate:schemas --release`).
|
|
4
|
+
*/
|
|
5
|
+
export declare const SCHEMA_BASE_URL = "https://raw.githubusercontent.com/mindsocket/structured-context-map-views/main/schemas/generated";
|
|
6
|
+
/** Base of the `$id`s the sources use: the `latest` folder. */
|
|
7
|
+
export declare const SCHEMA_URL: "https://raw.githubusercontent.com/mindsocket/structured-context-map-views/main/schemas/generated/latest";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** Reusable setting definitions. Parameters can `$ref` these and narrow them, e.g. with `allOf` and `enum`. */
|
|
2
|
+
export declare const settingsSchema: {
|
|
3
|
+
readonly $schema: 'https://json-schema.org/draft/2020-12/schema';
|
|
4
|
+
readonly $id: "https://raw.githubusercontent.com/mindsocket/structured-context-map-views/main/schemas/generated/latest/settings.json";
|
|
5
|
+
readonly title: 'Shared map view settings';
|
|
6
|
+
readonly description: 'Reusable setting definitions. Parameters can $ref these and narrow them, e.g. with allOf and enum.';
|
|
7
|
+
readonly $defs: {
|
|
8
|
+
readonly orientation: {
|
|
9
|
+
readonly title: 'Orientation';
|
|
10
|
+
readonly enum: readonly ['vertical', 'horizontal'];
|
|
11
|
+
};
|
|
12
|
+
readonly nodeStyle: {
|
|
13
|
+
readonly title: 'Node style';
|
|
14
|
+
readonly description: 'card: a box with the title and selected fields. shape: a compact marker with a tooltip.';
|
|
15
|
+
readonly enum: readonly ['card', 'shape'];
|
|
16
|
+
};
|
|
17
|
+
readonly fieldList: {
|
|
18
|
+
readonly title: 'Fields';
|
|
19
|
+
readonly type: 'array';
|
|
20
|
+
readonly items: {
|
|
21
|
+
readonly type: 'string';
|
|
22
|
+
readonly minLength: 1;
|
|
23
|
+
};
|
|
24
|
+
readonly uniqueItems: true;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** Settings of the tree layout: a tree over the schema's hierarchy. */
|
|
2
|
+
export declare const treeLayoutSchema: {
|
|
3
|
+
readonly $schema: 'https://json-schema.org/draft/2020-12/schema';
|
|
4
|
+
readonly $id: "https://raw.githubusercontent.com/mindsocket/structured-context-map-views/main/schemas/generated/latest/layouts/tree.json";
|
|
5
|
+
readonly title: 'Tree layout';
|
|
6
|
+
readonly description: "A tree over the schema's hierarchy: root-type nodes at the top, children via hierarchy edges.";
|
|
7
|
+
readonly type: 'object';
|
|
8
|
+
readonly required: readonly ['type'];
|
|
9
|
+
readonly additionalProperties: false;
|
|
10
|
+
readonly properties: {
|
|
11
|
+
readonly type: {
|
|
12
|
+
readonly const: 'tree';
|
|
13
|
+
};
|
|
14
|
+
readonly orientation: {
|
|
15
|
+
readonly description: string;
|
|
16
|
+
readonly default: "vertical";
|
|
17
|
+
readonly anyOf: readonly [{
|
|
18
|
+
readonly $ref: "https://raw.githubusercontent.com/mindsocket/structured-context-map-views/main/schemas/generated/latest/settings.json#/$defs/orientation";
|
|
19
|
+
}, {
|
|
20
|
+
readonly $ref: "https://raw.githubusercontent.com/mindsocket/structured-context-map-views/main/schemas/generated/latest/definition.json#/$defs/paramRef";
|
|
21
|
+
}];
|
|
22
|
+
};
|
|
23
|
+
readonly dag: {
|
|
24
|
+
readonly description: string;
|
|
25
|
+
readonly default: "repeat";
|
|
26
|
+
readonly anyOf: readonly [{
|
|
27
|
+
readonly $ref: "https://raw.githubusercontent.com/mindsocket/structured-context-map-views/main/schemas/generated/latest/layouts/tree.json#/$defs/dag";
|
|
28
|
+
}, {
|
|
29
|
+
readonly $ref: "https://raw.githubusercontent.com/mindsocket/structured-context-map-views/main/schemas/generated/latest/definition.json#/$defs/paramRef";
|
|
30
|
+
}];
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
readonly $defs: {
|
|
34
|
+
readonly dag: {
|
|
35
|
+
readonly title: 'Nodes with several parents';
|
|
36
|
+
readonly 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.';
|
|
37
|
+
readonly enum: readonly ['repeat', 'cross-edge'];
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/** Settings of the XY layout: nodes positioned by two numeric fields. */
|
|
2
|
+
export declare const xyLayoutSchema: {
|
|
3
|
+
readonly $schema: 'https://json-schema.org/draft/2020-12/schema';
|
|
4
|
+
readonly $id: "https://raw.githubusercontent.com/mindsocket/structured-context-map-views/main/schemas/generated/latest/layouts/xy.json";
|
|
5
|
+
readonly title: 'XY layout';
|
|
6
|
+
readonly 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.';
|
|
7
|
+
readonly type: 'object';
|
|
8
|
+
readonly required: readonly ['type', 'x', 'y'];
|
|
9
|
+
readonly additionalProperties: false;
|
|
10
|
+
readonly properties: {
|
|
11
|
+
readonly type: {
|
|
12
|
+
readonly const: 'xy';
|
|
13
|
+
};
|
|
14
|
+
readonly x: {
|
|
15
|
+
readonly $ref: "https://raw.githubusercontent.com/mindsocket/structured-context-map-views/main/schemas/generated/latest/layouts/xy.json#/$defs/axis";
|
|
16
|
+
};
|
|
17
|
+
readonly y: {
|
|
18
|
+
readonly $ref: "https://raw.githubusercontent.com/mindsocket/structured-context-map-views/main/schemas/generated/latest/layouts/xy.json#/$defs/axis";
|
|
19
|
+
};
|
|
20
|
+
readonly types: {
|
|
21
|
+
readonly description: string;
|
|
22
|
+
readonly default: readonly [];
|
|
23
|
+
readonly anyOf: readonly [{
|
|
24
|
+
readonly type: "array";
|
|
25
|
+
readonly items: {
|
|
26
|
+
readonly type: "string";
|
|
27
|
+
readonly minLength: 1;
|
|
28
|
+
};
|
|
29
|
+
readonly uniqueItems: true;
|
|
30
|
+
}, {
|
|
31
|
+
readonly $ref: "https://raw.githubusercontent.com/mindsocket/structured-context-map-views/main/schemas/generated/latest/definition.json#/$defs/paramRef";
|
|
32
|
+
}];
|
|
33
|
+
};
|
|
34
|
+
readonly edgeFields: {
|
|
35
|
+
readonly description: string;
|
|
36
|
+
readonly default: readonly [];
|
|
37
|
+
readonly anyOf: readonly [{
|
|
38
|
+
readonly $ref: "https://raw.githubusercontent.com/mindsocket/structured-context-map-views/main/schemas/generated/latest/settings.json#/$defs/fieldList";
|
|
39
|
+
}, {
|
|
40
|
+
readonly $ref: "https://raw.githubusercontent.com/mindsocket/structured-context-map-views/main/schemas/generated/latest/definition.json#/$defs/paramRef";
|
|
41
|
+
}];
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
readonly $defs: {
|
|
45
|
+
readonly axis: {
|
|
46
|
+
readonly title: 'Axis';
|
|
47
|
+
readonly type: 'object';
|
|
48
|
+
readonly required: readonly ['field'];
|
|
49
|
+
readonly additionalProperties: false;
|
|
50
|
+
readonly properties: {
|
|
51
|
+
readonly field: {
|
|
52
|
+
readonly description: 'Numeric field giving the position.';
|
|
53
|
+
readonly anyOf: readonly [{
|
|
54
|
+
readonly type: 'string';
|
|
55
|
+
readonly minLength: 1;
|
|
56
|
+
}, {
|
|
57
|
+
readonly $ref: "https://raw.githubusercontent.com/mindsocket/structured-context-map-views/main/schemas/generated/latest/definition.json#/$defs/paramRef";
|
|
58
|
+
}];
|
|
59
|
+
};
|
|
60
|
+
readonly domain: {
|
|
61
|
+
readonly 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.';
|
|
62
|
+
readonly default: 'data';
|
|
63
|
+
readonly anyOf: readonly [{
|
|
64
|
+
readonly const: 'data';
|
|
65
|
+
}, {
|
|
66
|
+
readonly type: 'array';
|
|
67
|
+
readonly items: {
|
|
68
|
+
readonly type: 'number';
|
|
69
|
+
};
|
|
70
|
+
readonly minItems: 2;
|
|
71
|
+
readonly maxItems: 2;
|
|
72
|
+
}];
|
|
73
|
+
};
|
|
74
|
+
readonly direction: {
|
|
75
|
+
readonly description: string;
|
|
76
|
+
readonly default: "ascending";
|
|
77
|
+
readonly anyOf: readonly [{
|
|
78
|
+
readonly $ref: "https://raw.githubusercontent.com/mindsocket/structured-context-map-views/main/schemas/generated/latest/layouts/xy.json#/$defs/direction";
|
|
79
|
+
}, {
|
|
80
|
+
readonly $ref: "https://raw.githubusercontent.com/mindsocket/structured-context-map-views/main/schemas/generated/latest/definition.json#/$defs/paramRef";
|
|
81
|
+
}];
|
|
82
|
+
};
|
|
83
|
+
readonly label: {
|
|
84
|
+
readonly type: 'string';
|
|
85
|
+
readonly description: 'Axis title. Defaults to the field name.';
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
readonly direction: {
|
|
90
|
+
readonly title: 'Axis direction';
|
|
91
|
+
readonly enum: readonly ['ascending', 'descending'];
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { SpaceGraph, SpaceNode } from 'structured-context/api';
|
|
2
|
+
import type { DagMode } from './definition';
|
|
3
|
+
/** One rendered appearance of a node in a tree. */
|
|
4
|
+
export type TreeOccurrence = {
|
|
5
|
+
/** Path-based key, unique within the map view (see {@link occurrenceKey}). */
|
|
6
|
+
key: string;
|
|
7
|
+
node: SpaceNode;
|
|
8
|
+
children: TreeOccurrence[];
|
|
9
|
+
/**
|
|
10
|
+
* Key of the node's primary occurrence when this is a repeat. A node with several parents
|
|
11
|
+
* appears under each of them, but its subtree is only rendered at its first occurrence.
|
|
12
|
+
*/
|
|
13
|
+
repeatOf?: string;
|
|
14
|
+
};
|
|
15
|
+
export type Tree = {
|
|
16
|
+
roots: TreeOccurrence[];
|
|
17
|
+
/**
|
|
18
|
+
* Hierarchy-typed nodes not reachable from a root, rendered as extra roots: nodes with no
|
|
19
|
+
* hierarchy parent in the space, then entry points into otherwise unreachable cycles.
|
|
20
|
+
*/
|
|
21
|
+
orphans: TreeOccurrence[];
|
|
22
|
+
/** Key of each node's primary (first, fully rendered) occurrence. */
|
|
23
|
+
primary: ReadonlyMap<string, string>;
|
|
24
|
+
/**
|
|
25
|
+
* In cross-edge mode, links from a node's other parents to its primary occurrence, which
|
|
26
|
+
* replace repeat occurrences. Empty in repeat mode.
|
|
27
|
+
*/
|
|
28
|
+
crossLinks: TreeLink[];
|
|
29
|
+
};
|
|
30
|
+
export type TreeLink = {
|
|
31
|
+
from: string;
|
|
32
|
+
to: string;
|
|
33
|
+
kind: 'tree' | 'cross';
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Lay a space out as a tree over its hierarchy.
|
|
37
|
+
*
|
|
38
|
+
* Roots are root-type nodes with no hierarchy parent. Traversal is depth-first in space order,
|
|
39
|
+
* so a node's primary occurrence is under the parent reached first. Under its other parents a
|
|
40
|
+
* node is either repeated without its subtree (`repeat`), or left out and linked by a cross-edge
|
|
41
|
+
* (`cross-edge`). Either way traversal stops there, which also keeps cycles from recursing.
|
|
42
|
+
*/
|
|
43
|
+
export declare function buildTree(graph: SpaceGraph, regionId: string, dag?: DagMode): Tree;
|
|
44
|
+
/** Parent → child pairs of occurrence keys: one per rendered parent-child link, then cross-links. */
|
|
45
|
+
export declare function treeLinks(tree: Tree): TreeLink[];
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { SpaceGraph, SpaceNode } from 'structured-context/api';
|
|
2
|
+
import type { XYLayoutConfig } from './definition';
|
|
3
|
+
/** A plotted node. `x` and `y` run from 0 to 1 across the plot, left to right and bottom to top. */
|
|
4
|
+
export type XYPoint = {
|
|
5
|
+
key: string;
|
|
6
|
+
node: SpaceNode;
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
};
|
|
10
|
+
/** Why a node of a plotted type couldn't be placed, per axis. */
|
|
11
|
+
export type Unplaced = {
|
|
12
|
+
key: string;
|
|
13
|
+
node: SpaceNode;
|
|
14
|
+
reasons: string[];
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* An edge between plotted nodes. `lane` separates edges joining the same two nodes: 0 when
|
|
18
|
+
* there's one, otherwise centred around 0 (e.g. -0.5 and 0.5), for layouts to draw side by side.
|
|
19
|
+
*/
|
|
20
|
+
export type XYLink = {
|
|
21
|
+
from: string;
|
|
22
|
+
to: string;
|
|
23
|
+
field: string;
|
|
24
|
+
hierarchy: boolean;
|
|
25
|
+
lane: number;
|
|
26
|
+
};
|
|
27
|
+
export type XYPlot = {
|
|
28
|
+
points: XYPoint[];
|
|
29
|
+
unplaced: Unplaced[];
|
|
30
|
+
/** Edges between plotted nodes. */
|
|
31
|
+
links: XYLink[];
|
|
32
|
+
/** Each axis's [min, max]; `direction` says which end is drawn where. */
|
|
33
|
+
domains: {
|
|
34
|
+
x: readonly [number, number];
|
|
35
|
+
y: readonly [number, number];
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Position nodes by two numeric fields. Every node of a plotted type appears once: on the plot
|
|
40
|
+
* when both its values are numbers inside the axes' domains, otherwise in `unplaced` with the
|
|
41
|
+
* reason. Positions are normalised; layouts decide the plot's size.
|
|
42
|
+
*/
|
|
43
|
+
export declare function buildXYPlot(graph: SpaceGraph, regionId: string, layout: XYLayoutConfig): XYPlot;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The package's public surface. Everything else (layouts, node cards, the edge overlay, the projections)
|
|
3
|
+
* is internal; add an export here when a host needs it.
|
|
4
|
+
*/
|
|
5
|
+
export { MAP_VIEW_SCHEMAS, type MapViewDefinition, MapViewDefinitionError, mapViewsForSchema, type ParameterValues, parseMapViewDefinition, resolveParameterValues, selectionFilter, } from './core';
|
|
6
|
+
export { MapView } from './layouts/MapView';
|
|
7
|
+
export { ParameterControls } from './layouts/ParameterControls';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Orientation } from '../core';
|
|
2
|
+
/**
|
|
3
|
+
* A connector between two occurrences. `cross` links (e.g. extra parents) are drawn dashed.
|
|
4
|
+
* `id` tells apart several links between the same occurrences; straight links between the same
|
|
5
|
+
* pair are drawn side by side, `lane` apart (0: on the line between centres).
|
|
6
|
+
*/
|
|
7
|
+
export type Link = {
|
|
8
|
+
from: string;
|
|
9
|
+
to: string;
|
|
10
|
+
kind?: 'tree' | 'cross';
|
|
11
|
+
id?: string;
|
|
12
|
+
lane?: number;
|
|
13
|
+
};
|
|
14
|
+
type Props = {
|
|
15
|
+
links: readonly Link[];
|
|
16
|
+
/** Rendered element of each occurrence, by occurrence key. */
|
|
17
|
+
elements: ReadonlyMap<string, HTMLElement>;
|
|
18
|
+
/**
|
|
19
|
+
* Positioned element the overlay covers; coordinates are relative to it. Passed as an element,
|
|
20
|
+
* not a ref: the overlay sits inside it, and React runs a child's layout effects before
|
|
21
|
+
* attaching the parent's ref.
|
|
22
|
+
*/
|
|
23
|
+
container: HTMLElement | null;
|
|
24
|
+
/** Curves leaving along the tree's orientation, or straight lines between centres (drawn under the nodes). */
|
|
25
|
+
routing: Orientation | 'straight';
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* SVG layer drawing connectors between rendered occurrences.
|
|
29
|
+
*
|
|
30
|
+
* Measures occurrence elements after layout and redraws when the container or any occurrence
|
|
31
|
+
* resizes, so it follows embedded panes that resize independently of the window, and reflows
|
|
32
|
+
* such as late font loads. The SVG fills the container instead of being sized from it, so it
|
|
33
|
+
* never holds the container open after the layout shrinks.
|
|
34
|
+
*/
|
|
35
|
+
export declare function EdgeOverlay({ links, elements, container, routing }: Props): import("react").JSX.Element;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type LandscapeLayoutConfig } from '../core';
|
|
2
|
+
import type { LayoutProps } from './TreeLayout';
|
|
3
|
+
/**
|
|
4
|
+
* Nested containers following the layout's grouping levels; the last level is drawn as nodes.
|
|
5
|
+
* Flexbox does the nesting and wrapping. Containment shows the grouping edges, so no connectors
|
|
6
|
+
* are drawn. PROTOTYPE: `edges.show` has no effect here; other edges aren't drawn yet.
|
|
7
|
+
*/
|
|
8
|
+
export declare function LandscapeLayout({ graph, region, instanceId, onNodeSelect }: LayoutProps<LandscapeLayoutConfig>): import("react").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { SpaceGraph, SpaceNode } from 'structured-context/api';
|
|
2
|
+
import { type MapViewDefinition, type ParameterValues } from '../core';
|
|
3
|
+
type Props = {
|
|
4
|
+
definition: MapViewDefinition;
|
|
5
|
+
graph: SpaceGraph;
|
|
6
|
+
/** Current parameter values (host-owned session state); missing values use defaults. */
|
|
7
|
+
values?: ParameterValues;
|
|
8
|
+
onNodeSelect?: (node: SpaceNode) => void;
|
|
9
|
+
};
|
|
10
|
+
/** Renders a map view definition against a space. Sizes to its container and scrolls within it. */
|
|
11
|
+
export declare function MapView({ definition, graph, values, onNodeSelect }: Props): import("react").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SpaceNode } from 'structured-context/api';
|
|
2
|
+
import type { NodesConfig } from '../core';
|
|
3
|
+
type Props = {
|
|
4
|
+
node: SpaceNode;
|
|
5
|
+
/** The node's subtree is rendered at another occurrence. */
|
|
6
|
+
repeat: boolean;
|
|
7
|
+
nodes: NodesConfig;
|
|
8
|
+
onSelect?: (node: SpaceNode) => void;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* A clickable node, drawn as a card (title plus selected fields) or a compact shape with a
|
|
12
|
+
* tooltip. Deliberately a `div` with button semantics rather than a `<button>`: hosts style
|
|
13
|
+
* native form controls globally (Obsidian fixes button height and disables wrapping).
|
|
14
|
+
*/
|
|
15
|
+
export declare function NodeCard({ node, repeat, nodes, onSelect }: Props): import("react").JSX.Element;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type MapViewDefinition, type ParameterValues } from '../core';
|
|
2
|
+
type Props = {
|
|
3
|
+
definition: MapViewDefinition;
|
|
4
|
+
/** Host-owned values; missing or stale ones show as the default, matching what renders. */
|
|
5
|
+
values: ParameterValues;
|
|
6
|
+
onChange: (name: string, value: unknown) => void;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Controls generated from a map view's declared parameters. Hosts own the values (session
|
|
10
|
+
* state) and decide where the controls go.
|
|
11
|
+
*/
|
|
12
|
+
export declare function ParameterControls({ definition, values, onChange }: Props): import("react").JSX.Element | null;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SpaceGraph, SpaceNode } from 'structured-context/api';
|
|
2
|
+
import { type LayoutConfig, type Region, type TreeLayoutConfig } from '../core';
|
|
3
|
+
export type LayoutProps<L extends LayoutConfig = LayoutConfig> = {
|
|
4
|
+
graph: SpaceGraph;
|
|
5
|
+
/** The region with parameter values applied, narrowed to the layout's own settings. */
|
|
6
|
+
region: Region & {
|
|
7
|
+
layout: L;
|
|
8
|
+
};
|
|
9
|
+
/** Scopes occurrence ids when several map views render in one document. */
|
|
10
|
+
instanceId: string;
|
|
11
|
+
onNodeSelect?: (node: SpaceNode) => void;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Tree over the schema's hierarchy. Flexbox does the branching; the SVG overlay draws connectors.
|
|
15
|
+
*/
|
|
16
|
+
export declare function TreeLayout({ graph, region, instanceId, onNodeSelect }: LayoutProps<TreeLayoutConfig>): import("react").JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type XYLayoutConfig } from '../core';
|
|
2
|
+
import type { LayoutProps } from './TreeLayout';
|
|
3
|
+
/**
|
|
4
|
+
* Nodes positioned by two numeric fields, with straight connectors between them. Positions are
|
|
5
|
+
* percentages of the plot area, which fills the container (scrolling below a minimum size). Nodes that can't be
|
|
6
|
+
* placed are listed under the plot with the reason.
|
|
7
|
+
* PROTOTYPE: labels may overlap where nodes sit close together; no collision handling.
|
|
8
|
+
*/
|
|
9
|
+
export declare function XYLayout({ graph, region, instanceId, onNodeSelect }: LayoutProps<XYLayoutConfig>): import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const BUNDLED_DEFINITIONS: Record<string, string>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Config } from 'structured-context/api';
|
|
2
|
+
import { type MapViewDefinition } from '../core';
|
|
3
|
+
export type LoadMapViewDefinitionsOptions = {
|
|
4
|
+
/** Directory of the main config file. Defaults to where structured-context finds it. */
|
|
5
|
+
configDir?: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Every map view definition available with `config`, from:
|
|
9
|
+
* - this package's embedded definitions (`sctx-map-view://core/<name>`), for structured-context's bundled schemas;
|
|
10
|
+
* - each plugin found from a config folder or named by a space (`sctx-map-view://<plugin>/<name>`): the
|
|
11
|
+
* folder named by `"sctx": { "mapViews": "…" }` in its package.json, else its `map-views/` folder;
|
|
12
|
+
* - a `map-views/` folder next to each config file (`sctx-map-view://<name>`).
|
|
13
|
+
*
|
|
14
|
+
* Each definition's `$id` must be in the namespace of where it was found, and ids must be unique.
|
|
15
|
+
* Throws on the first invalid definition.
|
|
16
|
+
*/
|
|
17
|
+
export declare function loadMapViewDefinitions(config: Config, options?: LoadMapViewDefinitionsOptions): MapViewDefinition[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,71 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "structured-context-map-views",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Declarative map views of structured-context spaces: render a space as a tree, nested containers or an XY plot from a short definition.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/mindsocket/structured-context-map-views.git",
|
|
10
|
+
"directory": "packages/map-views"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/mindsocket/structured-context-map-views#readme",
|
|
13
|
+
"bugs": "https://github.com/mindsocket/structured-context-map-views/issues",
|
|
14
|
+
"keywords": [
|
|
15
|
+
"structured-context",
|
|
16
|
+
"visualisation",
|
|
17
|
+
"map-view",
|
|
18
|
+
"react"
|
|
19
|
+
],
|
|
20
|
+
"files": [
|
|
21
|
+
"dist/"
|
|
22
|
+
],
|
|
23
|
+
"sideEffects": false,
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./dist/types/index.d.ts",
|
|
27
|
+
"default": "./dist/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./node": {
|
|
30
|
+
"types": "./dist/types/node/index.d.ts",
|
|
31
|
+
"default": "./dist/node.js"
|
|
32
|
+
},
|
|
33
|
+
"./styles.css": "./dist/styles.css"
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"clean": "rm -rf dist",
|
|
37
|
+
"generate": "bun run generate:schemas && bun run generate:definitions",
|
|
38
|
+
"generate:schemas": "bun scripts/generate-schemas.ts",
|
|
39
|
+
"generate:definitions": "bun scripts/generate-definitions.ts",
|
|
40
|
+
"build": "bun run clean && bun run generate && bun --bun vite build && tsc -p tsconfig.build.json && tailwindcss -i src/layouts/styles.css -o dist/styles.css",
|
|
41
|
+
"typecheck": "tsc --noEmit",
|
|
42
|
+
"capture-fixtures": "bun scripts/capture-fixtures.ts",
|
|
43
|
+
"test": "bun test",
|
|
44
|
+
"test:package": "bash scripts/test-package.sh",
|
|
45
|
+
"prepublishOnly": "bun run build",
|
|
46
|
+
"preversion": "bun run generate && bun run --cwd ../.. lint:fix && bun run --cwd ../.. test && bun run test:package",
|
|
47
|
+
"version": "bun run generate:schemas --release && git add -A"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"react": "^19.3.0",
|
|
51
|
+
"react-dom": "^19.3.0",
|
|
52
|
+
"structured-context": "^0.17.1"
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"ajv": "^8.20.0",
|
|
56
|
+
"json-schema-to-ts": "^3.1.1",
|
|
57
|
+
"json5": "^2.2.3"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@tailwindcss/cli": "^4.3.3",
|
|
61
|
+
"@types/node": "^22.20.5",
|
|
62
|
+
"@types/react": "^19.3.0",
|
|
63
|
+
"@types/react-dom": "^19.3.0",
|
|
64
|
+
"@vitejs/plugin-react": "^6.1.1",
|
|
65
|
+
"react": "^19.3.0",
|
|
66
|
+
"react-dom": "^19.3.0",
|
|
67
|
+
"structured-context": "^0.17.1",
|
|
68
|
+
"tailwindcss": "^4.3.3",
|
|
69
|
+
"vite": "^8.3.2"
|
|
70
|
+
}
|
|
71
|
+
}
|