@dxos/plugin-explorer 0.8.4-main.422d1c7879 → 0.8.4-main.43cb759274
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 +102 -5
- package/PLUGIN.mdl +340 -0
- package/dist/lib/neutral/ExplorerArticle-4I7PNGDC.mjs +459 -0
- package/dist/lib/neutral/ExplorerArticle-4I7PNGDC.mjs.map +7 -0
- package/dist/lib/neutral/ExplorerPlugin.mjs +10 -0
- package/dist/lib/neutral/capabilities/index.mjs +11 -0
- package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
- package/dist/lib/neutral/chunk-3D7BYXOR.mjs +37 -0
- package/dist/lib/neutral/chunk-3D7BYXOR.mjs.map +7 -0
- package/dist/lib/neutral/chunk-42BYLQQA.mjs +42 -0
- package/dist/lib/neutral/chunk-42BYLQQA.mjs.map +7 -0
- package/dist/lib/neutral/chunk-7XUDLV6E.mjs +287 -0
- package/dist/lib/neutral/chunk-7XUDLV6E.mjs.map +7 -0
- package/dist/lib/{browser/types/index.mjs → neutral/chunk-HI324IB4.mjs} +12 -13
- package/dist/lib/neutral/chunk-HI324IB4.mjs.map +7 -0
- package/dist/lib/neutral/chunk-IKHJV3Q4.mjs +20 -0
- package/dist/lib/neutral/chunk-IKHJV3Q4.mjs.map +7 -0
- package/dist/lib/{browser → neutral/components}/index.mjs +730 -437
- package/dist/lib/neutral/components/index.mjs.map +7 -0
- package/dist/lib/neutral/containers/index.mjs +9 -0
- package/dist/lib/neutral/containers/index.mjs.map +7 -0
- package/dist/lib/neutral/create-object-F6TKVAGV.mjs +39 -0
- package/dist/lib/neutral/create-object-F6TKVAGV.mjs.map +7 -0
- package/dist/lib/neutral/hooks/index.mjs +45 -0
- package/dist/lib/neutral/hooks/index.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +14 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/{browser → neutral}/meta.mjs +1 -1
- package/dist/lib/neutral/plugin.mjs +12 -0
- package/dist/lib/neutral/plugin.mjs.map +7 -0
- package/dist/lib/neutral/react-surface-APBW2VQG.mjs +26 -0
- package/dist/lib/neutral/react-surface-APBW2VQG.mjs.map +7 -0
- package/dist/lib/neutral/testing/index.mjs +139 -0
- package/dist/lib/neutral/testing/index.mjs.map +7 -0
- package/dist/lib/neutral/translations.mjs +33 -0
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/lib/neutral/types/index.mjs +10 -0
- package/dist/lib/neutral/types/index.mjs.map +7 -0
- package/dist/types/data/cities.d.ts +4 -4
- package/dist/types/data/cities.d.ts.map +1 -1
- package/dist/types/data/countries-110m.d.ts +19 -22
- package/dist/types/data/countries-110m.d.ts.map +1 -1
- package/dist/types/src/ExplorerPlugin.d.ts +1 -0
- package/dist/types/src/ExplorerPlugin.d.ts.map +1 -1
- package/dist/types/src/ExplorerPlugin.test.d.ts +2 -0
- package/dist/types/src/ExplorerPlugin.test.d.ts.map +1 -0
- package/dist/types/src/capabilities/create-object.d.ts +11 -0
- package/dist/types/src/capabilities/create-object.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +6 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/Chart/Chart.d.ts +1 -1
- package/dist/types/src/components/Chart/Chart.d.ts.map +1 -1
- package/dist/types/src/components/Chart/Chart.stories.d.ts +4 -1
- package/dist/types/src/components/Chart/Chart.stories.d.ts.map +1 -1
- package/dist/types/src/components/Globe/Globe.d.ts +1 -1
- package/dist/types/src/components/Globe/Globe.d.ts.map +1 -1
- package/dist/types/src/components/Globe/Globe.stories.d.ts +5 -2
- package/dist/types/src/components/Globe/Globe.stories.d.ts.map +1 -1
- package/dist/types/src/components/Graph/CanvasForceGraph.d.ts +13 -0
- package/dist/types/src/components/Graph/CanvasForceGraph.d.ts.map +1 -0
- package/dist/types/src/components/Graph/{D3ForceGraph.stories.d.ts → CanvasForceGraph.stories.d.ts} +3 -3
- package/dist/types/src/components/Graph/CanvasForceGraph.stories.d.ts.map +1 -0
- package/dist/types/src/components/Graph/ForceGraph.d.ts +12 -5
- package/dist/types/src/components/Graph/ForceGraph.d.ts.map +1 -1
- package/dist/types/src/components/Graph/ForceGraph.stories.d.ts +3 -1
- package/dist/types/src/components/Graph/ForceGraph.stories.d.ts.map +1 -1
- package/dist/types/src/components/Graph/{adapter.d.ts → graph-adapter.d.ts} +1 -1
- package/dist/types/src/components/Graph/graph-adapter.d.ts.map +1 -0
- package/dist/types/src/components/Graph/index.d.ts +1 -1
- package/dist/types/src/components/Graph/index.d.ts.map +1 -1
- package/dist/types/src/components/Lattice/Lattice.d.ts +20 -0
- package/dist/types/src/components/Lattice/Lattice.d.ts.map +1 -0
- package/dist/types/src/components/Lattice/Lattice.stories.d.ts +8 -0
- package/dist/types/src/components/Lattice/Lattice.stories.d.ts.map +1 -0
- package/dist/types/src/components/Lattice/index.d.ts +2 -0
- package/dist/types/src/components/Lattice/index.d.ts.map +1 -0
- package/dist/types/src/components/Tree/EdgeBundling.stories.d.ts +21 -0
- package/dist/types/src/components/Tree/EdgeBundling.stories.d.ts.map +1 -0
- package/dist/types/src/components/Tree/Tree.d.ts +20 -23
- package/dist/types/src/components/Tree/Tree.d.ts.map +1 -1
- package/dist/types/src/components/Tree/Tree.stories.d.ts +5 -12
- package/dist/types/src/components/Tree/Tree.stories.d.ts.map +1 -1
- package/dist/types/src/components/Tree/index.d.ts +2 -0
- package/dist/types/src/components/Tree/index.d.ts.map +1 -1
- package/dist/types/src/components/Tree/layout/HierarchicalEdgeBundling.d.ts +37 -2
- package/dist/types/src/components/Tree/layout/HierarchicalEdgeBundling.d.ts.map +1 -1
- package/dist/types/src/components/Tree/layout/RadialTree.d.ts +35 -2
- package/dist/types/src/components/Tree/layout/RadialTree.d.ts.map +1 -1
- package/dist/types/src/components/Tree/layout/TidyTree.d.ts +24 -2
- package/dist/types/src/components/Tree/layout/TidyTree.d.ts.map +1 -1
- package/dist/types/src/components/Tree/layout/hierarchy.d.ts +17 -0
- package/dist/types/src/components/Tree/layout/hierarchy.d.ts.map +1 -0
- package/dist/types/src/components/Tree/layout/index.d.ts +5 -4
- package/dist/types/src/components/Tree/layout/index.d.ts.map +1 -1
- package/dist/types/src/components/Tree/layout/slots.d.ts +7 -0
- package/dist/types/src/components/Tree/layout/slots.d.ts.map +1 -0
- package/dist/types/src/components/Tree/layout/useContainerSize.d.ts +15 -0
- package/dist/types/src/components/Tree/layout/useContainerSize.d.ts.map +1 -0
- package/dist/types/src/components/Tree/types/tree.d.ts +41 -20
- package/dist/types/src/components/Tree/types/tree.d.ts.map +1 -1
- package/dist/types/src/components/Tree/types/types.d.ts +14 -4
- package/dist/types/src/components/Tree/types/types.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -0
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/ExplorerArticle/ExplorerArticle.d.ts +8 -0
- package/dist/types/src/containers/ExplorerArticle/ExplorerArticle.d.ts.map +1 -0
- package/dist/types/src/containers/ExplorerArticle/ExplorerArticle.stories.d.ts +15 -0
- package/dist/types/src/containers/ExplorerArticle/ExplorerArticle.stories.d.ts.map +1 -0
- package/dist/types/src/containers/ExplorerArticle/Visualization.d.ts +18 -0
- package/dist/types/src/containers/ExplorerArticle/Visualization.d.ts.map +1 -0
- package/dist/types/src/containers/ExplorerArticle/index.d.ts +2 -0
- package/dist/types/src/containers/ExplorerArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/ExplorerArticle/variants.d.ts +9 -0
- package/dist/types/src/containers/ExplorerArticle/variants.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +1 -1
- package/dist/types/src/containers/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useGraphModel.d.ts +2 -2
- package/dist/types/src/hooks/useGraphModel.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +1 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/plugin.d.ts +3 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/{components/Tree/testing → testing}/generator.d.ts +1 -1
- package/dist/types/src/testing/generator.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +4 -0
- package/dist/types/src/testing/index.d.ts.map +1 -0
- package/dist/types/src/testing/relations.d.ts +32 -0
- package/dist/types/src/testing/relations.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +17 -17
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Graph.d.ts +5 -6
- package/dist/types/src/types/Graph.d.ts.map +1 -1
- package/dist/types/src/util/index.d.ts +3 -0
- package/dist/types/src/util/index.d.ts.map +1 -0
- package/dist/types/src/util/node-color.d.ts +13 -0
- package/dist/types/src/util/node-color.d.ts.map +1 -0
- package/dist/types/src/{components → util}/plot.d.ts +1 -1
- package/dist/types/src/util/plot.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +102 -58
- package/src/ExplorerPlugin.test.ts +26 -0
- package/src/ExplorerPlugin.tsx +11 -34
- package/src/capabilities/create-object.ts +36 -0
- package/src/capabilities/index.ts +1 -0
- package/src/capabilities/react-surface.tsx +2 -2
- package/src/components/Chart/Chart.stories.tsx +14 -20
- package/src/components/Chart/Chart.tsx +1 -1
- package/src/components/Globe/Globe.stories.tsx +17 -19
- package/src/components/Globe/Globe.tsx +1 -1
- package/src/components/Graph/CanvasForceGraph.stories.tsx +97 -0
- package/src/components/Graph/CanvasForceGraph.tsx +124 -0
- package/src/components/Graph/ForceGraph.stories.tsx +88 -38
- package/src/components/Graph/ForceGraph.tsx +105 -85
- package/src/components/Graph/index.ts +1 -1
- package/src/components/Lattice/Lattice.stories.tsx +104 -0
- package/src/components/Lattice/Lattice.tsx +182 -0
- package/src/components/Lattice/index.ts +5 -0
- package/src/components/Tree/EdgeBundling.stories.tsx +144 -0
- package/src/components/Tree/Tree.stories.tsx +17 -38
- package/src/components/Tree/Tree.tsx +69 -100
- package/src/components/Tree/index.ts +2 -0
- package/src/components/Tree/layout/HierarchicalEdgeBundling.tsx +335 -0
- package/src/components/Tree/layout/RadialTree.tsx +242 -0
- package/src/components/Tree/layout/TidyTree.tsx +246 -0
- package/src/components/Tree/layout/hierarchy.ts +32 -0
- package/src/components/Tree/layout/index.ts +5 -5
- package/src/components/Tree/layout/slots.ts +19 -0
- package/src/components/Tree/layout/useContainerSize.ts +43 -0
- package/src/components/Tree/types/tree.test.ts +2 -2
- package/src/components/Tree/types/tree.ts +23 -28
- package/src/components/Tree/types/types.ts +38 -29
- package/src/components/index.ts +1 -0
- package/src/containers/ExplorerArticle/ExplorerArticle.stories.tsx +152 -0
- package/src/containers/ExplorerArticle/ExplorerArticle.tsx +120 -0
- package/src/containers/ExplorerArticle/Visualization.tsx +523 -0
- package/src/containers/ExplorerArticle/index.ts +5 -0
- package/src/containers/ExplorerArticle/variants.ts +47 -0
- package/src/containers/index.ts +1 -1
- package/src/hooks/useGraphModel.ts +10 -6
- package/src/index.ts +1 -4
- package/src/meta.ts +26 -7
- package/src/plugin.ts +9 -0
- package/src/{components/Tree/testing → testing}/generator.ts +3 -3
- package/src/testing/index.ts +9 -0
- package/src/testing/relations.ts +117 -0
- package/src/translations.ts +1 -1
- package/src/types/ExplorerAction.ts +1 -1
- package/src/types/Graph.ts +6 -14
- package/src/util/index.ts +6 -0
- package/src/util/node-color.ts +23 -0
- package/src/{components → util}/plot.ts +16 -4
- package/src/vite-env.d.ts +10 -0
- package/dist/lib/browser/chunk-LSUP47BZ.mjs +0 -24
- package/dist/lib/browser/chunk-LSUP47BZ.mjs.map +0 -7
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/types/index.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-EN3JZNEY.mjs +0 -26
- package/dist/lib/node-esm/chunk-EN3JZNEY.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +0 -11
- package/dist/lib/node-esm/index.mjs +0 -11375
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/meta.mjs +0 -9
- package/dist/lib/node-esm/types/index.mjs +0 -71
- package/dist/lib/node-esm/types/index.mjs.map +0 -7
- package/dist/types/src/components/Graph/D3ForceGraph.d.ts +0 -15
- package/dist/types/src/components/Graph/D3ForceGraph.d.ts.map +0 -1
- package/dist/types/src/components/Graph/D3ForceGraph.stories.d.ts.map +0 -1
- package/dist/types/src/components/Graph/adapter.d.ts.map +0 -1
- package/dist/types/src/components/Graph/testing.d.ts +0 -14
- package/dist/types/src/components/Graph/testing.d.ts.map +0 -1
- package/dist/types/src/components/Tree/testing/generator.d.ts.map +0 -1
- package/dist/types/src/components/Tree/testing/index.d.ts +0 -2
- package/dist/types/src/components/Tree/testing/index.d.ts.map +0 -1
- package/dist/types/src/components/plot.d.ts.map +0 -1
- package/dist/types/src/containers/ExplorerContainer/ExplorerContainer.d.ts +0 -6
- package/dist/types/src/containers/ExplorerContainer/ExplorerContainer.d.ts.map +0 -1
- package/dist/types/src/containers/ExplorerContainer/index.d.ts +0 -2
- package/dist/types/src/containers/ExplorerContainer/index.d.ts.map +0 -1
- package/src/components/Graph/D3ForceGraph.stories.tsx +0 -83
- package/src/components/Graph/D3ForceGraph.tsx +0 -108
- package/src/components/Graph/testing.ts +0 -58
- package/src/components/Tree/layout/HierarchicalEdgeBundling.ts +0 -162
- package/src/components/Tree/layout/RadialTree.ts +0 -94
- package/src/components/Tree/layout/TidyTree.ts +0 -101
- package/src/components/Tree/testing/index.ts +0 -5
- package/src/containers/ExplorerContainer/ExplorerContainer.tsx +0 -53
- package/src/containers/ExplorerContainer/index.ts +0 -5
- /package/dist/lib/{browser/chunk-J5LGTIGS.mjs.map → neutral/ExplorerPlugin.mjs.map} +0 -0
- /package/dist/lib/{browser → neutral}/chunk-J5LGTIGS.mjs +0 -0
- /package/dist/lib/{browser/meta.mjs.map → neutral/chunk-J5LGTIGS.mjs.map} +0 -0
- /package/dist/lib/{node-esm/chunk-HSLMI22Q.mjs.map → neutral/index.mjs.map} +0 -0
- /package/dist/lib/{node-esm → neutral}/meta.mjs.map +0 -0
- /package/src/components/Graph/{adapter.ts → graph-adapter.ts} +0 -0
package/src/plugin.ts
ADDED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { Key, Obj } from '@dxos/echo';
|
|
6
6
|
import { range } from '@dxos/util';
|
|
7
7
|
|
|
8
|
-
import { Tree, type TreeNodeType } from '../types';
|
|
8
|
+
import { Tree, type TreeNodeType } from '../components/Tree/types';
|
|
9
9
|
|
|
10
10
|
type NumberOrNumberArray = number | number[];
|
|
11
11
|
|
|
@@ -16,14 +16,14 @@ const random = (min: number, max: number) => Math.floor(Math.random() * (max - m
|
|
|
16
16
|
*/
|
|
17
17
|
export const createTree = (spec: NumberOrNumberArray[] = [], createText?: () => string): Tree => {
|
|
18
18
|
const tree = new Tree();
|
|
19
|
-
Obj.
|
|
19
|
+
Obj.update(tree.tree, () => {
|
|
20
20
|
tree.root.data = { text: 'root' };
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
const createNodes = (parent: TreeNodeType, spec: NumberOrNumberArray = 0): TreeNodeType[] => {
|
|
24
24
|
const count = Array.isArray(spec) ? random(spec[0], spec[1]) : spec;
|
|
25
25
|
return range(count, (i) => ({
|
|
26
|
-
id: Key.
|
|
26
|
+
id: Key.EntityId.random(),
|
|
27
27
|
children: [],
|
|
28
28
|
data: {
|
|
29
29
|
text: createText?.() ?? [parent.data.text, i + 1].join('.'),
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Space } from '@dxos/client/echo';
|
|
6
|
+
import { Obj, Query, Relation } from '@dxos/echo';
|
|
7
|
+
import {
|
|
8
|
+
type RelationSpec,
|
|
9
|
+
type TypeSpec,
|
|
10
|
+
type ValueGenerator,
|
|
11
|
+
createObjectFactory,
|
|
12
|
+
createRelationFactory,
|
|
13
|
+
} from '@dxos/schema/testing';
|
|
14
|
+
import { HasConnection, Organization, Person } from '@dxos/types';
|
|
15
|
+
|
|
16
|
+
import { type BundleEdge } from '../components/Tree/layout';
|
|
17
|
+
import { type TreeNode } from '../components/Tree/types';
|
|
18
|
+
|
|
19
|
+
const SECTORS = ['Technology', 'Finance', 'Research', 'Media'];
|
|
20
|
+
const CONNECTION_KINDS = ['partner', 'investor', 'vendor', 'customer'];
|
|
21
|
+
|
|
22
|
+
export type ConnectedOrgsResult = {
|
|
23
|
+
organizations: Obj.Any[];
|
|
24
|
+
people: Obj.Any[];
|
|
25
|
+
connections: Obj.Any[];
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export type ConnectedOrgsOptions = {
|
|
29
|
+
organizationCount?: number;
|
|
30
|
+
personCount?: number;
|
|
31
|
+
connectionCount?: number;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Populate a space with Organizations, People, and HasConnection relations between organizations.
|
|
36
|
+
* Uses `createObjectFactory` to generate Org/Person properties from their `GeneratorAnnotation`s,
|
|
37
|
+
* then `createRelationFactory` to wire HasConnection relations (Org→Org) between them, spreading
|
|
38
|
+
* the connections across the available kinds.
|
|
39
|
+
*/
|
|
40
|
+
export const generateConnectedOrgs = async (
|
|
41
|
+
space: Space,
|
|
42
|
+
generator: ValueGenerator,
|
|
43
|
+
{ organizationCount = 12, personCount = 24, connectionCount = 18 }: ConnectedOrgsOptions = {},
|
|
44
|
+
): Promise<ConnectedOrgsResult> => {
|
|
45
|
+
const specs: TypeSpec[] = [
|
|
46
|
+
{ type: Organization.Organization, count: organizationCount },
|
|
47
|
+
// Person has a Ref to Organization — generator fills it from objects already in db.
|
|
48
|
+
{ type: Person.Person, count: personCount },
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
await createObjectFactory(space.db, generator)(specs);
|
|
52
|
+
|
|
53
|
+
// Distribute the requested connections evenly across the connection kinds.
|
|
54
|
+
const relationSpecs: RelationSpec[] = CONNECTION_KINDS.map((kind, index) => ({
|
|
55
|
+
type: HasConnection.HasConnection,
|
|
56
|
+
count:
|
|
57
|
+
Math.floor(connectionCount / CONNECTION_KINDS.length) +
|
|
58
|
+
(index < connectionCount % CONNECTION_KINDS.length ? 1 : 0),
|
|
59
|
+
data: { kind },
|
|
60
|
+
}));
|
|
61
|
+
const connections = await createRelationFactory(space.db, generator)(relationSpecs);
|
|
62
|
+
|
|
63
|
+
const organizations = await space.db.query(Query.type(Organization.Organization)).run();
|
|
64
|
+
const people = await space.db.query(Query.type(Person.Person)).run();
|
|
65
|
+
return { organizations, people, connections };
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Build a TreeNode hierarchy: Root → Sector → Organization (leaf).
|
|
70
|
+
* Organizations are deterministically bucketed into `SECTORS` so the demo has visible groups.
|
|
71
|
+
*/
|
|
72
|
+
export const buildOrgHierarchy = (organizations: Obj.Any[], sectors: readonly string[] = SECTORS): TreeNode => {
|
|
73
|
+
// Avoid modulo-by-zero / missing-bucket crashes when the caller passes an empty sectors list.
|
|
74
|
+
const activeSectors = sectors.length > 0 ? sectors : ['Uncategorized'];
|
|
75
|
+
const buckets = new Map<string, TreeNode[]>();
|
|
76
|
+
for (const sector of activeSectors) {
|
|
77
|
+
buckets.set(sector, []);
|
|
78
|
+
}
|
|
79
|
+
for (let i = 0; i < organizations.length; i++) {
|
|
80
|
+
const org = organizations[i] as any;
|
|
81
|
+
const sector = activeSectors[i % activeSectors.length];
|
|
82
|
+
buckets.get(sector)!.push({
|
|
83
|
+
id: org.id,
|
|
84
|
+
label: org.name ?? org.id.slice(0, 6),
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
id: 'root',
|
|
90
|
+
label: 'Organizations',
|
|
91
|
+
children: activeSectors.map((sector) => ({
|
|
92
|
+
id: `sector:${sector}`,
|
|
93
|
+
label: sector,
|
|
94
|
+
children: buckets.get(sector) ?? [],
|
|
95
|
+
})),
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Convert HasConnection relations into bundle edges between organization ids.
|
|
101
|
+
*/
|
|
102
|
+
export const connectionsToEdges = (connections: Obj.Any[]): BundleEdge[] => {
|
|
103
|
+
return connections
|
|
104
|
+
.map((relation): BundleEdge | undefined => {
|
|
105
|
+
const source = Relation.getSource(relation as any) as any;
|
|
106
|
+
const target = Relation.getTarget(relation as any) as any;
|
|
107
|
+
if (!source?.id || !target?.id) {
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
source: source.id,
|
|
112
|
+
target: target.id,
|
|
113
|
+
kind: (relation as any).kind,
|
|
114
|
+
};
|
|
115
|
+
})
|
|
116
|
+
.filter((e): e is BundleEdge => Boolean(e));
|
|
117
|
+
};
|
package/src/translations.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { Type } from '@dxos/echo';
|
|
6
6
|
import { type Resource } from '@dxos/react-ui';
|
|
7
|
-
import { translations as componentsTranslations } from '@dxos/react-ui-components';
|
|
7
|
+
import { translations as componentsTranslations } from '@dxos/react-ui-components/translations';
|
|
8
8
|
|
|
9
9
|
import { meta } from '#meta';
|
|
10
10
|
import { Graph } from '#types';
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
|
-
import { TypeInputOptionsAnnotation } from '@dxos/plugin-space
|
|
7
|
+
import { TypeInputOptionsAnnotation } from '@dxos/plugin-space';
|
|
8
8
|
|
|
9
9
|
export const GraphProps = Schema.Struct({
|
|
10
10
|
name: Schema.optional(Schema.String),
|
package/src/types/Graph.ts
CHANGED
|
@@ -4,33 +4,25 @@
|
|
|
4
4
|
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
|
-
import { Annotation, Filter, Obj, Query, QueryAST, Ref, Type } from '@dxos/echo';
|
|
8
|
-
import { View } from '@dxos/echo';
|
|
7
|
+
import { DXN, Annotation, Filter, Obj, Query, QueryAST, Ref, Type, View } from '@dxos/echo';
|
|
9
8
|
import { FormInputAnnotation, LabelAnnotation } from '@dxos/echo/internal';
|
|
10
9
|
import { ViewAnnotation } from '@dxos/schema';
|
|
11
10
|
|
|
12
11
|
const GraphSchema = Schema.Struct({
|
|
13
12
|
name: Schema.optional(Schema.String),
|
|
14
|
-
|
|
15
13
|
view: Ref.Ref(View.View).pipe(FormInputAnnotation.set(false)),
|
|
16
|
-
|
|
17
14
|
query: Schema.Struct({
|
|
18
15
|
raw: Schema.optional(Schema.String),
|
|
19
16
|
ast: QueryAST.Query,
|
|
20
17
|
}).pipe(FormInputAnnotation.set(false)),
|
|
21
18
|
}).pipe(
|
|
22
|
-
Type.object({
|
|
23
|
-
typename: 'org.dxos.type.graph',
|
|
24
|
-
version: '0.1.0',
|
|
25
|
-
}),
|
|
26
19
|
LabelAnnotation.set(['name']),
|
|
27
|
-
ViewAnnotation.set(
|
|
28
|
-
Annotation.IconAnnotation.set({
|
|
29
|
-
|
|
30
|
-
hue: 'green',
|
|
31
|
-
}),
|
|
20
|
+
ViewAnnotation.set(['view']),
|
|
21
|
+
Annotation.IconAnnotation.set({ icon: 'ph--graph--regular', hue: 'green' }),
|
|
22
|
+
Type.makeObject(DXN.make('org.dxos.type.graph', '0.1.0')),
|
|
32
23
|
);
|
|
33
|
-
|
|
24
|
+
// TODO(wittjosiah): Try to clean up this type inference.
|
|
25
|
+
export interface Graph extends Type.InstanceType<typeof GraphSchema> {}
|
|
34
26
|
export const Graph: Type.Obj<Graph> = GraphSchema as any;
|
|
35
27
|
|
|
36
28
|
type MakeProps = Omit<Partial<Obj.MakeProps<typeof Graph>>, 'view'> & {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Obj } from '@dxos/echo';
|
|
6
|
+
import { getHashHue } from '@dxos/ui-theme';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Returns the SVG `fill` value for a node, derived from its typename via the
|
|
10
|
+
* same hue-hash used by the force-directed renderer. Resolves to a Tailwind
|
|
11
|
+
* color token CSS variable so the value reads consistently across themes.
|
|
12
|
+
*
|
|
13
|
+
* Used by every variant of `ExplorerArticle` so nodes are colored consistently
|
|
14
|
+
* regardless of which layout is rendering them.
|
|
15
|
+
*/
|
|
16
|
+
export const getNodeFillForTypename = (typename: string | undefined): string => {
|
|
17
|
+
return `var(--color-${getHashHue(typename)}-400)`;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/** Convenience: derive the fill from an ECHO object's typename. */
|
|
21
|
+
export const getNodeFillForObject = (object: Obj.Unknown | undefined): string => {
|
|
22
|
+
return getNodeFillForTypename(object && Obj.getTypename(object));
|
|
23
|
+
};
|
|
@@ -4,12 +4,24 @@
|
|
|
4
4
|
|
|
5
5
|
import type { ChannelValueSpec } from '@observablehq/plot';
|
|
6
6
|
|
|
7
|
-
export type Point = { x: number; y: number };
|
|
8
|
-
export type GeoLocation = { lat: number; lng: number };
|
|
9
|
-
|
|
10
7
|
export type Accessor<T> = (object: any) => T;
|
|
11
8
|
|
|
9
|
+
export type Point = {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type GeoLocation = {
|
|
15
|
+
lat: number;
|
|
16
|
+
lng: number;
|
|
17
|
+
};
|
|
18
|
+
|
|
12
19
|
export const createAdapter = <T extends Record<string, any>>(
|
|
13
20
|
prop: string,
|
|
14
21
|
accessor: Accessor<T> | undefined,
|
|
15
|
-
): ChannelValueSpec =>
|
|
22
|
+
): ChannelValueSpec =>
|
|
23
|
+
accessor
|
|
24
|
+
? {
|
|
25
|
+
transform: (values) => values.map((value) => accessor(value)[prop]),
|
|
26
|
+
}
|
|
27
|
+
: prop;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// src/meta.ts
|
|
2
|
-
import { trim } from "@dxos/util";
|
|
3
|
-
var meta = {
|
|
4
|
-
id: "org.dxos.plugin.explorer",
|
|
5
|
-
name: "Explorer",
|
|
6
|
-
description: trim`
|
|
7
|
-
Interactive hypergraph visualization that reveals relationships between objects in your workspace.
|
|
8
|
-
Navigate complex data structures and discover connections through a dynamic network view.
|
|
9
|
-
`,
|
|
10
|
-
icon: "ph--graph--regular",
|
|
11
|
-
iconHue: "green",
|
|
12
|
-
source: "https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-explorer",
|
|
13
|
-
tags: [
|
|
14
|
-
"labs"
|
|
15
|
-
],
|
|
16
|
-
screenshots: [
|
|
17
|
-
"https://dxos.network/plugin-details-explorer-dark.png"
|
|
18
|
-
]
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export {
|
|
22
|
-
meta
|
|
23
|
-
};
|
|
24
|
-
//# sourceMappingURL=chunk-LSUP47BZ.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/meta.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Plugin } from '@dxos/app-framework';\nimport { trim } from '@dxos/util';\n\nexport const meta: Plugin.Meta = {\n id: 'org.dxos.plugin.explorer',\n name: 'Explorer',\n description: trim`\n Interactive hypergraph visualization that reveals relationships between objects in your workspace.\n Navigate complex data structures and discover connections through a dynamic network view.\n `,\n icon: 'ph--graph--regular',\n iconHue: 'green',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-explorer',\n tags: ['labs'],\n screenshots: ['https://dxos.network/plugin-details-explorer-dark.png'],\n};\n"],
|
|
5
|
-
"mappings": ";AAKA,SAASA,YAAY;AAEd,IAAMC,OAAoB;EAC/BC,IAAI;EACJC,MAAM;EACNC,aAAaC;;;;EAIbC,MAAM;EACNC,SAAS;EACTC,QAAQ;EACRC,MAAM;IAAC;;EACPC,aAAa;IAAC;;AAChB;",
|
|
6
|
-
"names": ["trim", "meta", "id", "name", "description", "trim", "icon", "iconHue", "source", "tags", "screenshots"]
|
|
7
|
-
}
|