@dxos/plugin-explorer 0.8.4-main.ead640a → 0.8.4-main.effb148878
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/dist/lib/neutral/ExplorerArticle-LLNHXWNG.mjs +420 -0
- package/dist/lib/neutral/ExplorerArticle-LLNHXWNG.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-7FSP4SPO.mjs +69 -0
- package/dist/lib/neutral/chunk-7FSP4SPO.mjs.map +7 -0
- package/dist/lib/neutral/chunk-CWN2BELW.mjs +287 -0
- package/dist/lib/neutral/chunk-CWN2BELW.mjs.map +7 -0
- package/dist/lib/neutral/chunk-GRJXLL4Z.mjs +25 -0
- package/dist/lib/neutral/chunk-GRJXLL4Z.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/neutral/chunk-LL3PXKB5.mjs +40 -0
- package/dist/lib/neutral/chunk-LL3PXKB5.mjs.map +7 -0
- package/dist/lib/{browser/chunk-MOM5KCKC.mjs → neutral/components/index.mjs} +882 -556
- 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 +193 -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/{browser → neutral}/types/index.mjs +1 -2
- 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 +3 -1
- 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 +8 -2
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts +3 -2
- 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/CanvasForceGraph.stories.d.ts +17 -0
- 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 +4 -2
- 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} +2 -2
- 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 +45 -22
- 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 -4
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/ExplorerArticle/ExplorerArticle.d.ts +13 -0
- package/dist/types/src/containers/ExplorerArticle/ExplorerArticle.d.ts.map +1 -0
- package/dist/types/src/containers/ExplorerArticle/ExplorerArticle.stories.d.ts +30 -0
- package/dist/types/src/containers/ExplorerArticle/ExplorerArticle.stories.d.ts.map +1 -0
- package/dist/types/src/containers/ExplorerArticle/Visualization.d.ts +24 -0
- package/dist/types/src/containers/ExplorerArticle/Visualization.d.ts.map +1 -0
- package/dist/types/src/containers/ExplorerArticle/experimental.stories.d.ts +7 -0
- package/dist/types/src/containers/ExplorerArticle/experimental.stories.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 +3 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- 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 +2 -2
- 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 +47 -0
- package/dist/types/src/testing/relations.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +31 -22
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/ExplorerAction.d.ts +1 -18
- package/dist/types/src/types/ExplorerAction.d.ts.map +1 -1
- package/dist/types/src/types/Graph.d.ts +14 -25
- 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 +114 -61
- package/src/ExplorerPlugin.test.ts +26 -0
- package/src/ExplorerPlugin.tsx +15 -56
- package/src/capabilities/create-object.ts +36 -0
- package/src/capabilities/index.ts +3 -3
- package/src/capabilities/react-surface.tsx +24 -19
- package/src/components/Chart/Chart.stories.tsx +16 -23
- package/src/components/Chart/Chart.tsx +1 -1
- package/src/components/Globe/Globe.stories.tsx +19 -22
- package/src/components/Globe/Globe.tsx +1 -1
- package/src/components/Graph/CanvasForceGraph.stories.tsx +83 -0
- package/src/components/Graph/CanvasForceGraph.tsx +124 -0
- package/src/components/Graph/ForceGraph.stories.tsx +83 -41
- package/src/components/Graph/ForceGraph.tsx +105 -85
- package/src/components/Graph/{adapter.ts → graph-adapter.ts} +14 -8
- package/src/components/Graph/index.ts +1 -1
- package/src/components/Lattice/Lattice.stories.tsx +90 -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 +20 -38
- package/src/components/Tree/Tree.tsx +69 -95
- 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 +8 -7
- package/src/components/Tree/types/tree.ts +42 -26
- package/src/components/Tree/types/types.ts +38 -29
- package/src/components/index.ts +1 -4
- package/src/containers/ExplorerArticle/ExplorerArticle.stories.tsx +142 -0
- package/src/containers/ExplorerArticle/ExplorerArticle.tsx +112 -0
- package/src/containers/ExplorerArticle/Visualization.tsx +497 -0
- package/src/containers/ExplorerArticle/experimental.stories.tsx +446 -0
- package/src/containers/ExplorerArticle/index.ts +5 -0
- package/src/containers/ExplorerArticle/variants.ts +37 -0
- package/src/containers/index.ts +7 -0
- package/src/hooks/useGraphModel.ts +25 -14
- package/src/index.ts +1 -4
- package/src/meta.ts +28 -5
- package/src/plugin.ts +9 -0
- package/src/{components/Tree/testing → testing}/generator.ts +5 -3
- package/src/testing/index.ts +9 -0
- package/src/testing/relations.ts +192 -0
- package/src/translations.ts +16 -13
- package/src/types/ExplorerAction.ts +10 -19
- package/src/types/Graph.ts +25 -24
- package/src/typings.d.ts +8 -0
- package/src/util/index.ts +6 -0
- package/src/util/node-color.ts +23 -0
- package/src/{components → util}/plot.ts +16 -4
- package/dist/lib/browser/ExplorerContainer-6SHZJ6AK.mjs +0 -50
- package/dist/lib/browser/ExplorerContainer-6SHZJ6AK.mjs.map +0 -7
- package/dist/lib/browser/chunk-2DGFNLRO.mjs +0 -19
- package/dist/lib/browser/chunk-2DGFNLRO.mjs.map +0 -7
- package/dist/lib/browser/chunk-2MKBRIUT.mjs +0 -31
- package/dist/lib/browser/chunk-2MKBRIUT.mjs.map +0 -7
- package/dist/lib/browser/chunk-BZ65T5M3.mjs +0 -79
- package/dist/lib/browser/chunk-BZ65T5M3.mjs.map +0 -7
- package/dist/lib/browser/chunk-MOM5KCKC.mjs.map +0 -7
- package/dist/lib/browser/chunk-NXGP6NTP.mjs +0 -203
- package/dist/lib/browser/chunk-NXGP6NTP.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -119
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-K57C3LIX.mjs +0 -31
- package/dist/lib/browser/intent-resolver-K57C3LIX.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/react-surface-OPBND5W3.mjs +0 -35
- package/dist/lib/browser/react-surface-OPBND5W3.mjs.map +0 -7
- package/dist/lib/node-esm/ExplorerContainer-FRTDXZI5.mjs +0 -51
- package/dist/lib/node-esm/ExplorerContainer-FRTDXZI5.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-3ODK27PU.mjs +0 -33
- package/dist/lib/node-esm/chunk-3ODK27PU.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-6JACZE7E.mjs +0 -205
- package/dist/lib/node-esm/chunk-6JACZE7E.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ES6AOMCY.mjs +0 -80
- package/dist/lib/node-esm/chunk-ES6AOMCY.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +0 -11
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-PX6LHR2N.mjs +0 -21
- package/dist/lib/node-esm/chunk-PX6LHR2N.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ZCV4U7LT.mjs +0 -11343
- package/dist/lib/node-esm/chunk-ZCV4U7LT.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -120
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-BLPPTTEY.mjs +0 -32
- package/dist/lib/node-esm/intent-resolver-BLPPTTEY.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/react-surface-HCKQSHKJ.mjs +0 -36
- package/dist/lib/node-esm/react-surface-HCKQSHKJ.mjs.map +0 -7
- package/dist/lib/node-esm/types/index.mjs +0 -12
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/components/ExplorerContainer.d.ts +0 -9
- package/dist/types/src/components/ExplorerContainer.d.ts.map +0 -1
- package/dist/types/src/components/Graph/D3ForceGraph.d.ts +0 -14
- package/dist/types/src/components/Graph/D3ForceGraph.d.ts.map +0 -1
- package/dist/types/src/components/Graph/D3ForceGraph.stories.d.ts +0 -15
- 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/src/capabilities/intent-resolver.ts +0 -21
- package/src/components/ExplorerContainer.tsx +0 -54
- package/src/components/Graph/D3ForceGraph.stories.tsx +0 -77
- package/src/components/Graph/D3ForceGraph.tsx +0 -101
- package/src/components/Graph/testing.ts +0 -55
- 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/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/{browser/types → neutral}/index.mjs.map +0 -0
- /package/dist/lib/{node-esm → neutral}/meta.mjs.map +0 -0
- /package/dist/lib/{node-esm → neutral}/types/index.mjs.map +0 -0
|
@@ -0,0 +1,192 @@
|
|
|
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 { type TypeSpec, type ValueGenerator, createObjectFactory } from '@dxos/schema/testing';
|
|
8
|
+
import { HasConnection, HasRelationship, Organization, Person, Pipeline } from '@dxos/types';
|
|
9
|
+
import { range } from '@dxos/util';
|
|
10
|
+
|
|
11
|
+
import { type BundleEdge } from '../components/Tree/layout';
|
|
12
|
+
import { type TreeNode } from '../components/Tree/types';
|
|
13
|
+
|
|
14
|
+
const SECTORS = ['Technology', 'Finance', 'Research', 'Media'];
|
|
15
|
+
const CONNECTION_KINDS = ['partner', 'investor', 'vendor', 'customer'];
|
|
16
|
+
|
|
17
|
+
const pick = <T>(arr: readonly T[], rng = Math.random): T => arr[Math.floor(rng() * arr.length)];
|
|
18
|
+
|
|
19
|
+
export type ConnectedOrgsResult = {
|
|
20
|
+
organizations: Obj.Any[];
|
|
21
|
+
people: Obj.Any[];
|
|
22
|
+
connections: Obj.Any[];
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type ConnectedOrgsOptions = {
|
|
26
|
+
organizationCount?: number;
|
|
27
|
+
personCount?: number;
|
|
28
|
+
connectionCount?: number;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Populate a space with Organizations, People, and HasConnection relations between organizations.
|
|
33
|
+
* Uses `createObjectFactory` to generate Org/Person properties from their `GeneratorAnnotation`s,
|
|
34
|
+
* then layers manual HasConnection relations on top — the connection schema is fixed
|
|
35
|
+
* (Org→Org) so it isn't a fit for the generator's reference inference.
|
|
36
|
+
*/
|
|
37
|
+
export const generateConnectedOrgs = async (
|
|
38
|
+
space: Space,
|
|
39
|
+
generator: ValueGenerator,
|
|
40
|
+
{ organizationCount = 12, personCount = 24, connectionCount = 18 }: ConnectedOrgsOptions = {},
|
|
41
|
+
): Promise<ConnectedOrgsResult> => {
|
|
42
|
+
const specs: TypeSpec[] = [
|
|
43
|
+
{ type: Organization.Organization, count: organizationCount },
|
|
44
|
+
// Person has a Ref to Organization — generator fills it from objects already in db.
|
|
45
|
+
{ type: Person.Person, count: personCount },
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
const factory = createObjectFactory(space.db, generator);
|
|
49
|
+
await factory(specs);
|
|
50
|
+
|
|
51
|
+
const organizations = await space.db.query(Query.type(Organization.Organization)).run();
|
|
52
|
+
const people = await space.db.query(Query.type(Person.Person)).run();
|
|
53
|
+
|
|
54
|
+
const connections: Obj.Any[] = [];
|
|
55
|
+
const seen = new Set<string>();
|
|
56
|
+
for (let i = 0; i < connectionCount && organizations.length >= 2; i++) {
|
|
57
|
+
const source = pick(organizations);
|
|
58
|
+
const target = pick(organizations);
|
|
59
|
+
if (source.id === target.id) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
const key = `${source.id}->${target.id}`;
|
|
63
|
+
if (seen.has(key)) {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
seen.add(key);
|
|
67
|
+
|
|
68
|
+
const relation = Relation.make(HasConnection.HasConnection, {
|
|
69
|
+
[Relation.Source]: source as any,
|
|
70
|
+
[Relation.Target]: target as any,
|
|
71
|
+
kind: pick(CONNECTION_KINDS),
|
|
72
|
+
});
|
|
73
|
+
connections.push(space.db.add(relation as any));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
await space.db.flush();
|
|
77
|
+
return { organizations, people, connections };
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Build a TreeNode hierarchy: Root → Sector → Organization (leaf).
|
|
82
|
+
* Organizations are deterministically bucketed into `SECTORS` so the demo has visible groups.
|
|
83
|
+
*/
|
|
84
|
+
export const buildOrgHierarchy = (organizations: Obj.Any[], sectors: readonly string[] = SECTORS): TreeNode => {
|
|
85
|
+
// Avoid modulo-by-zero / missing-bucket crashes when the caller passes an empty sectors list.
|
|
86
|
+
const activeSectors = sectors.length > 0 ? sectors : ['Uncategorized'];
|
|
87
|
+
const buckets = new Map<string, TreeNode[]>();
|
|
88
|
+
for (const sector of activeSectors) {
|
|
89
|
+
buckets.set(sector, []);
|
|
90
|
+
}
|
|
91
|
+
for (let i = 0; i < organizations.length; i++) {
|
|
92
|
+
const org = organizations[i] as any;
|
|
93
|
+
const sector = activeSectors[i % activeSectors.length];
|
|
94
|
+
buckets.get(sector)!.push({
|
|
95
|
+
id: org.id,
|
|
96
|
+
label: org.name ?? org.id.slice(0, 6),
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return {
|
|
101
|
+
id: 'root',
|
|
102
|
+
label: 'Organizations',
|
|
103
|
+
children: activeSectors.map((sector) => ({
|
|
104
|
+
id: `sector:${sector}`,
|
|
105
|
+
label: sector,
|
|
106
|
+
children: buckets.get(sector) ?? [],
|
|
107
|
+
})),
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export type GenerateOptions = {
|
|
112
|
+
spec?: TypeSpec[];
|
|
113
|
+
relations?: {
|
|
114
|
+
count: number;
|
|
115
|
+
kind: string;
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const defaultGenerateTypes: TypeSpec[] = [
|
|
120
|
+
{
|
|
121
|
+
type: Organization.Organization,
|
|
122
|
+
count: 20,
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
type: Person.Person,
|
|
126
|
+
count: 20,
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
type: Pipeline.Pipeline,
|
|
130
|
+
count: 20,
|
|
131
|
+
},
|
|
132
|
+
];
|
|
133
|
+
|
|
134
|
+
const defaultGenerateRelations: NonNullable<GenerateOptions['relations']> = {
|
|
135
|
+
kind: 'friend',
|
|
136
|
+
count: 10,
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Populate a space with a mixed dataset (Orgs, Pipelines, People) plus
|
|
141
|
+
* `HasRelationship` edges between random pairs of People.
|
|
142
|
+
*
|
|
143
|
+
* Used by the force-directed and canvas-force graph stories that want a
|
|
144
|
+
* heterogeneous typed dataset without caring about the precise shape of relations.
|
|
145
|
+
*/
|
|
146
|
+
export const generate = async (
|
|
147
|
+
space: Space,
|
|
148
|
+
generator: ValueGenerator,
|
|
149
|
+
{ spec = defaultGenerateTypes, relations = defaultGenerateRelations }: GenerateOptions = {},
|
|
150
|
+
) => {
|
|
151
|
+
const createObjects = createObjectFactory(space.db, generator);
|
|
152
|
+
await createObjects(spec);
|
|
153
|
+
|
|
154
|
+
const contacts: Obj.Any[] = await space.db.query(Query.type(Person.Person)).run();
|
|
155
|
+
if (contacts.length < 2 || relations.count <= 0) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
for (const _ of range(relations.count)) {
|
|
160
|
+
const source = pick(contacts);
|
|
161
|
+
const target = pick(contacts);
|
|
162
|
+
if (source.id !== target.id) {
|
|
163
|
+
space.db.add(
|
|
164
|
+
Relation.make(HasRelationship.HasRelationship, {
|
|
165
|
+
[Relation.Source]: source as any,
|
|
166
|
+
[Relation.Target]: target as any,
|
|
167
|
+
kind: relations.kind,
|
|
168
|
+
}) as any,
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Convert HasConnection relations into bundle edges between organization ids.
|
|
176
|
+
*/
|
|
177
|
+
export const connectionsToEdges = (connections: Obj.Any[]): BundleEdge[] => {
|
|
178
|
+
return connections
|
|
179
|
+
.map((relation): BundleEdge | undefined => {
|
|
180
|
+
const source = Relation.getSource(relation as any) as any;
|
|
181
|
+
const target = Relation.getTarget(relation as any) as any;
|
|
182
|
+
if (!source?.id || !target?.id) {
|
|
183
|
+
return undefined;
|
|
184
|
+
}
|
|
185
|
+
return {
|
|
186
|
+
source: source.id,
|
|
187
|
+
target: target.id,
|
|
188
|
+
kind: (relation as any).kind,
|
|
189
|
+
};
|
|
190
|
+
})
|
|
191
|
+
.filter((e): e is BundleEdge => Boolean(e));
|
|
192
|
+
};
|
package/src/translations.ts
CHANGED
|
@@ -2,27 +2,30 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { Type } from '@dxos/echo';
|
|
5
6
|
import { type Resource } from '@dxos/react-ui';
|
|
6
|
-
import { translations as componentsTranslations } from '@dxos/react-ui-components';
|
|
7
|
+
import { translations as componentsTranslations } from '@dxos/react-ui-components/translations';
|
|
7
8
|
|
|
8
|
-
import { meta } from '
|
|
9
|
-
import { Graph } from '
|
|
9
|
+
import { meta } from '#meta';
|
|
10
|
+
import { Graph } from '#types';
|
|
10
11
|
|
|
11
12
|
export const translations = [
|
|
12
13
|
{
|
|
13
14
|
'en-US': {
|
|
14
|
-
[Graph.Graph
|
|
15
|
-
'typename
|
|
16
|
-
'typename
|
|
17
|
-
'typename
|
|
18
|
-
'typename
|
|
19
|
-
'object
|
|
20
|
-
'
|
|
21
|
-
'
|
|
15
|
+
[Type.getTypename(Graph.Graph)]: {
|
|
16
|
+
'typename.label': 'Explorer',
|
|
17
|
+
'typename.label_zero': 'Explorers',
|
|
18
|
+
'typename.label_one': 'Explorer',
|
|
19
|
+
'typename.label_other': 'Explorers',
|
|
20
|
+
'object-name.placeholder': 'New explorer',
|
|
21
|
+
'add-object.label': 'Add explorer',
|
|
22
|
+
'rename-object.label': 'Rename explorer',
|
|
23
|
+
'delete-object.label': 'Delete explorer',
|
|
24
|
+
'object-deleted.label': 'Explorer deleted',
|
|
22
25
|
},
|
|
23
26
|
[meta.id]: {
|
|
24
|
-
'plugin
|
|
25
|
-
'object
|
|
27
|
+
'plugin.name': 'Explorer',
|
|
28
|
+
'object-title.label': 'Title',
|
|
26
29
|
},
|
|
27
30
|
},
|
|
28
31
|
},
|
|
@@ -4,26 +4,17 @@
|
|
|
4
4
|
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import { DataType, TypenameAnnotationId } from '@dxos/schema';
|
|
9
|
-
|
|
10
|
-
import { meta } from '../meta';
|
|
11
|
-
|
|
12
|
-
const EXPLORER_ACTION = `${meta.id}/action`;
|
|
7
|
+
import { TypeInputOptionsAnnotation } from '@dxos/plugin-space';
|
|
13
8
|
|
|
14
9
|
export const GraphProps = Schema.Struct({
|
|
15
10
|
name: Schema.optional(Schema.String),
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
title: 'Select
|
|
19
|
-
|
|
11
|
+
// TODO(wittjosiah): This should be a query input instead.
|
|
12
|
+
typename: Schema.String.pipe(
|
|
13
|
+
Schema.annotations({ title: 'Select type' }),
|
|
14
|
+
TypeInputOptionsAnnotation.set({
|
|
15
|
+
location: ['database', 'runtime'],
|
|
16
|
+
kind: ['user'],
|
|
17
|
+
}),
|
|
18
|
+
Schema.optional,
|
|
19
|
+
),
|
|
20
20
|
});
|
|
21
|
-
|
|
22
|
-
export class CreateGraph extends Schema.TaggedClass<CreateGraph>()(`${EXPLORER_ACTION}/create-graph`, {
|
|
23
|
-
input: Schema.Struct({
|
|
24
|
-
space: SpaceSchema,
|
|
25
|
-
}).pipe(Schema.extend(GraphProps)),
|
|
26
|
-
output: Schema.Struct({
|
|
27
|
-
object: DataType.View,
|
|
28
|
-
}),
|
|
29
|
-
}) {}
|
package/src/types/Graph.ts
CHANGED
|
@@ -4,42 +4,43 @@
|
|
|
4
4
|
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
|
-
import { Filter, Obj, Query, QueryAST, Type } from '@dxos/echo';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
7
|
+
import { DXN, Annotation, Filter, Obj, Query, QueryAST, Ref, Type, View } from '@dxos/echo';
|
|
8
|
+
import { FormInputAnnotation, LabelAnnotation } from '@dxos/echo/internal';
|
|
9
|
+
import { ViewAnnotation } from '@dxos/schema';
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
const GraphSchema = Schema.Struct({
|
|
12
12
|
name: Schema.optional(Schema.String),
|
|
13
|
+
|
|
14
|
+
view: Ref.Ref(View.View).pipe(FormInputAnnotation.set(false)),
|
|
15
|
+
|
|
13
16
|
query: Schema.Struct({
|
|
14
17
|
raw: Schema.optional(Schema.String),
|
|
15
18
|
ast: QueryAST.Query,
|
|
16
|
-
}).pipe(
|
|
19
|
+
}).pipe(FormInputAnnotation.set(false)),
|
|
17
20
|
}).pipe(
|
|
18
|
-
Type.Obj({
|
|
19
|
-
typename: 'dxos.org/type/Graph',
|
|
20
|
-
version: '0.1.0',
|
|
21
|
-
}),
|
|
22
21
|
LabelAnnotation.set(['name']),
|
|
23
|
-
ViewAnnotation.set(
|
|
22
|
+
ViewAnnotation.set(['view']),
|
|
23
|
+
Annotation.IconAnnotation.set({
|
|
24
|
+
icon: 'ph--graph--regular',
|
|
25
|
+
hue: 'green',
|
|
26
|
+
}),
|
|
27
|
+
Type.makeObject(DXN.make('org.dxos.type.graph', '0.1.0')),
|
|
24
28
|
);
|
|
29
|
+
// TODO(wittjosiah): Try to clean up this type inference.
|
|
30
|
+
export interface Graph extends Type.InstanceType<typeof GraphSchema> {}
|
|
31
|
+
export const Graph: Type.Obj<Graph> = GraphSchema as any;
|
|
25
32
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Make a graph object.
|
|
30
|
-
*/
|
|
31
|
-
export const make = (
|
|
32
|
-
props: Obj.MakeProps<typeof Graph> = { query: { raw: '', ast: Query.select(Filter.nothing()).ast } },
|
|
33
|
-
) => Obj.make(Graph, props);
|
|
34
|
-
|
|
35
|
-
type MakeViewProps = Omit<CreateViewFromSpaceProps, 'presentation'> & {
|
|
36
|
-
presentation?: Omit<Obj.MakeProps<typeof Graph>, 'name'>;
|
|
33
|
+
type MakeProps = Omit<Partial<Obj.MakeProps<typeof Graph>>, 'view'> & {
|
|
34
|
+
view: View.View;
|
|
37
35
|
};
|
|
38
36
|
|
|
39
37
|
/**
|
|
40
38
|
* Make a graph as a view of a data set.
|
|
41
39
|
*/
|
|
42
|
-
export const
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
export const make = ({
|
|
41
|
+
name,
|
|
42
|
+
query = { raw: '', ast: Query.select(Filter.nothing()).ast },
|
|
43
|
+
view,
|
|
44
|
+
}: MakeProps): Graph => {
|
|
45
|
+
return Obj.make(Graph, { name, view: Ref.make(view), query });
|
|
45
46
|
};
|
package/src/typings.d.ts
ADDED
|
@@ -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,50 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useGraphModel
|
|
3
|
-
} from "./chunk-2MKBRIUT.mjs";
|
|
4
|
-
import {
|
|
5
|
-
D3ForceGraph
|
|
6
|
-
} from "./chunk-NXGP6NTP.mjs";
|
|
7
|
-
import "./chunk-J5LGTIGS.mjs";
|
|
8
|
-
|
|
9
|
-
// src/components/ExplorerContainer.tsx
|
|
10
|
-
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
11
|
-
import React, { useCallback, useMemo, useState } from "react";
|
|
12
|
-
import { QueryBuilder } from "@dxos/echo-query";
|
|
13
|
-
import { useGlobalSearch } from "@dxos/plugin-search";
|
|
14
|
-
import { getSpace } from "@dxos/react-client/echo";
|
|
15
|
-
import { Toolbar } from "@dxos/react-ui";
|
|
16
|
-
import { QueryEditor } from "@dxos/react-ui-components";
|
|
17
|
-
import { StackItem } from "@dxos/react-ui-stack";
|
|
18
|
-
var ExplorerContainer = ({ role, view }) => {
|
|
19
|
-
var _effect = _useSignals();
|
|
20
|
-
try {
|
|
21
|
-
const space = getSpace(view);
|
|
22
|
-
const [filter, setFilter] = useState();
|
|
23
|
-
const model = useGraphModel(space, filter);
|
|
24
|
-
const { match } = useGlobalSearch();
|
|
25
|
-
const builder = useMemo(() => new QueryBuilder(), []);
|
|
26
|
-
const handleChange = useCallback((value) => {
|
|
27
|
-
setFilter(builder.build(value));
|
|
28
|
-
}, []);
|
|
29
|
-
const showToolbar = role === "article";
|
|
30
|
-
if (!space || !model) {
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
return /* @__PURE__ */ React.createElement(StackItem.Content, {
|
|
34
|
-
toolbar: showToolbar
|
|
35
|
-
}, showToolbar && /* @__PURE__ */ React.createElement(Toolbar.Root, null, /* @__PURE__ */ React.createElement(QueryEditor, {
|
|
36
|
-
db: space.db,
|
|
37
|
-
onChange: handleChange
|
|
38
|
-
})), /* @__PURE__ */ React.createElement(D3ForceGraph, {
|
|
39
|
-
model,
|
|
40
|
-
match
|
|
41
|
-
}));
|
|
42
|
-
} finally {
|
|
43
|
-
_effect.f();
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
var ExplorerContainer_default = ExplorerContainer;
|
|
47
|
-
export {
|
|
48
|
-
ExplorerContainer_default as default
|
|
49
|
-
};
|
|
50
|
-
//# sourceMappingURL=ExplorerContainer-6SHZJ6AK.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/ExplorerContainer.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { useCallback, useMemo, useState } from 'react';\n\nimport { type Filter } from '@dxos/echo';\nimport { QueryBuilder } from '@dxos/echo-query';\nimport { useGlobalSearch } from '@dxos/plugin-search';\nimport { getSpace } from '@dxos/react-client/echo';\nimport { Toolbar } from '@dxos/react-ui';\nimport { QueryEditor, type QueryEditorProps } from '@dxos/react-ui-components';\nimport { StackItem } from '@dxos/react-ui-stack';\nimport { type DataType } from '@dxos/schema';\n\nimport { useGraphModel } from '../hooks';\n\nimport { D3ForceGraph } from './Graph';\n\ntype ExplorerContainerProps = {\n role: string;\n view: DataType.View;\n};\n\nconst ExplorerContainer = ({ role, view }: ExplorerContainerProps) => {\n const space = getSpace(view);\n const [filter, setFilter] = useState<Filter.Any>();\n const model = useGraphModel(space, filter);\n const { match } = useGlobalSearch();\n\n const builder = useMemo(() => new QueryBuilder(), []);\n const handleChange = useCallback<NonNullable<QueryEditorProps['onChange']>>((value) => {\n setFilter(builder.build(value));\n }, []);\n\n const showToolbar = role === 'article';\n\n if (!space || !model) {\n return null;\n }\n\n return (\n <StackItem.Content toolbar={showToolbar}>\n {showToolbar && (\n <Toolbar.Root>\n <QueryEditor db={space.db} onChange={handleChange} />\n </Toolbar.Root>\n )}\n <D3ForceGraph model={model} match={match} />\n </StackItem.Content>\n );\n};\n\nexport default ExplorerContainer;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;AAIA,OAAOA,SAASC,aAAaC,SAASC,gBAAgB;AAGtD,SAASC,oBAAoB;AAC7B,SAASC,uBAAuB;AAChC,SAASC,gBAAgB;AACzB,SAASC,eAAe;AACxB,SAASC,mBAA0C;AACnD,SAASC,iBAAiB;AAY1B,IAAMC,oBAAoB,CAAC,EAAEC,MAAMC,KAAI,MAA0B;;;AAC/D,UAAMC,QAAQC,SAASF,IAAAA;AACvB,UAAM,CAACG,QAAQC,SAAAA,IAAaC,SAAAA;AAC5B,UAAMC,QAAQC,cAAcN,OAAOE,MAAAA;AACnC,UAAM,EAAEK,MAAK,IAAKC,gBAAAA;AAElB,UAAMC,UAAUC,QAAQ,MAAM,IAAIC,aAAAA,GAAgB,CAAA,CAAE;AACpD,UAAMC,eAAeC,YAAuD,CAACC,UAAAA;AAC3EX,gBAAUM,QAAQM,MAAMD,KAAAA,CAAAA;IAC1B,GAAG,CAAA,CAAE;AAEL,UAAME,cAAclB,SAAS;AAE7B,QAAI,CAACE,SAAS,CAACK,OAAO;AACpB,aAAO;IACT;AAEA,WACE,sBAAA,cAACY,UAAUC,SAAO;MAACC,SAASH;OACzBA,eACC,sBAAA,cAACI,QAAQC,MAAI,MACX,sBAAA,cAACC,aAAAA;MAAYC,IAAIvB,MAAMuB;MAAIC,UAAUZ;SAGzC,sBAAA,cAACa,cAAAA;MAAapB;MAAcE;;;;;AAGlC;AAEA,IAAA,4BAAeV;",
|
|
6
|
-
"names": ["React", "useCallback", "useMemo", "useState", "QueryBuilder", "useGlobalSearch", "getSpace", "Toolbar", "QueryEditor", "StackItem", "ExplorerContainer", "role", "view", "space", "getSpace", "filter", "setFilter", "useState", "model", "useGraphModel", "match", "useGlobalSearch", "builder", "useMemo", "QueryBuilder", "handleChange", "useCallback", "value", "build", "showToolbar", "StackItem", "Content", "toolbar", "Toolbar", "Root", "QueryEditor", "db", "onChange", "D3ForceGraph"]
|
|
7
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// src/meta.ts
|
|
2
|
-
var meta = {
|
|
3
|
-
id: "dxos.org/plugin/explorer",
|
|
4
|
-
name: "Explorer",
|
|
5
|
-
description: "Install this plugin to view a hypergraph of all objects inside of your Space.",
|
|
6
|
-
icon: "ph--graph--regular",
|
|
7
|
-
source: "https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-explorer",
|
|
8
|
-
tags: [
|
|
9
|
-
"labs"
|
|
10
|
-
],
|
|
11
|
-
screenshots: [
|
|
12
|
-
"https://dxos.network/plugin-details-explorer-dark.png"
|
|
13
|
-
]
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export {
|
|
17
|
-
meta
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=chunk-2DGFNLRO.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 PluginMeta } from '@dxos/app-framework';\n\nexport const meta: PluginMeta = {\n id: 'dxos.org/plugin/explorer',\n name: 'Explorer',\n description: 'Install this plugin to view a hypergraph of all objects inside of your Space.',\n icon: 'ph--graph--regular',\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": ";AAMO,IAAMA,OAAmB;EAC9BC,IAAI;EACJC,MAAM;EACNC,aAAa;EACbC,MAAM;EACNC,QAAQ;EACRC,MAAM;IAAC;;EACPC,aAAa;IAAC;;AAChB;",
|
|
6
|
-
"names": ["meta", "id", "name", "description", "icon", "source", "tags", "screenshots"]
|
|
7
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
// src/hooks/useGraphModel.ts
|
|
2
|
-
import { useEffect, useState } from "react";
|
|
3
|
-
import { SpaceGraphModel } from "@dxos/schema";
|
|
4
|
-
var useGraphModel = (space, filter, options, queue) => {
|
|
5
|
-
const [model, setModel] = useState(void 0);
|
|
6
|
-
useEffect(() => {
|
|
7
|
-
if (!space) {
|
|
8
|
-
void model?.close();
|
|
9
|
-
setModel(void 0);
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
if (!model || model.queue !== queue) {
|
|
13
|
-
const model2 = new SpaceGraphModel().setFilter(filter).setOptions(options);
|
|
14
|
-
void model2.open(space, queue);
|
|
15
|
-
setModel(model2);
|
|
16
|
-
} else {
|
|
17
|
-
model.setFilter(filter).setOptions(options);
|
|
18
|
-
}
|
|
19
|
-
}, [
|
|
20
|
-
space,
|
|
21
|
-
filter,
|
|
22
|
-
options,
|
|
23
|
-
queue
|
|
24
|
-
]);
|
|
25
|
-
return model;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export {
|
|
29
|
-
useGraphModel
|
|
30
|
-
};
|
|
31
|
-
//# sourceMappingURL=chunk-2MKBRIUT.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/hooks/useGraphModel.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { useEffect, useState } from 'react';\n\nimport { type Filter, type Queue, type Space } from '@dxos/client/echo';\nimport { SpaceGraphModel, type SpaceGraphModelOptions } from '@dxos/schema';\n\n// TODO(burdon): Factor out.\nexport const useGraphModel = (\n space: Space | undefined,\n filter?: Filter.Any | undefined,\n options?: SpaceGraphModelOptions,\n queue?: Queue,\n): SpaceGraphModel | undefined => {\n const [model, setModel] = useState<SpaceGraphModel | undefined>(undefined);\n useEffect(() => {\n if (!space) {\n void model?.close();\n setModel(undefined);\n return;\n }\n\n // TODO(burdon): Does this need to be a dependency?\n if (!model || model.queue !== queue) {\n const model = new SpaceGraphModel().setFilter(filter).setOptions(options);\n void model.open(space, queue);\n setModel(model);\n } else {\n model.setFilter(filter).setOptions(options);\n }\n }, [space, filter, options, queue]);\n\n return model;\n};\n"],
|
|
5
|
-
"mappings": ";AAIA,SAASA,WAAWC,gBAAgB;AAGpC,SAASC,uBAAoD;AAGtD,IAAMC,gBAAgB,CAC3BC,OACAC,QACAC,SACAC,UAAAA;AAEA,QAAM,CAACC,OAAOC,QAAAA,IAAYC,SAAsCC,MAAAA;AAChEC,YAAU,MAAA;AACR,QAAI,CAACR,OAAO;AACV,WAAKI,OAAOK,MAAAA;AACZJ,eAASE,MAAAA;AACT;IACF;AAGA,QAAI,CAACH,SAASA,MAAMD,UAAUA,OAAO;AACnC,YAAMC,SAAQ,IAAIM,gBAAAA,EAAkBC,UAAUV,MAAAA,EAAQW,WAAWV,OAAAA;AACjE,WAAKE,OAAMS,KAAKb,OAAOG,KAAAA;AACvBE,eAASD,MAAAA;IACX,OAAO;AACLA,YAAMO,UAAUV,MAAAA,EAAQW,WAAWV,OAAAA;IACrC;EACF,GAAG;IAACF;IAAOC;IAAQC;IAASC;GAAM;AAElC,SAAOC;AACT;",
|
|
6
|
-
"names": ["useEffect", "useState", "SpaceGraphModel", "useGraphModel", "space", "filter", "options", "queue", "model", "setModel", "useState", "undefined", "useEffect", "close", "SpaceGraphModel", "setFilter", "setOptions", "open"]
|
|
7
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
meta
|
|
3
|
-
} from "./chunk-2DGFNLRO.mjs";
|
|
4
|
-
import {
|
|
5
|
-
__export
|
|
6
|
-
} from "./chunk-J5LGTIGS.mjs";
|
|
7
|
-
|
|
8
|
-
// src/types/ExplorerAction.ts
|
|
9
|
-
var ExplorerAction_exports = {};
|
|
10
|
-
__export(ExplorerAction_exports, {
|
|
11
|
-
CreateGraph: () => CreateGraph,
|
|
12
|
-
GraphProps: () => GraphProps
|
|
13
|
-
});
|
|
14
|
-
import * as Schema from "effect/Schema";
|
|
15
|
-
import { SpaceSchema } from "@dxos/react-client/echo";
|
|
16
|
-
import { DataType, TypenameAnnotationId } from "@dxos/schema";
|
|
17
|
-
var EXPLORER_ACTION = `${meta.id}/action`;
|
|
18
|
-
var GraphProps = Schema.Struct({
|
|
19
|
-
name: Schema.optional(Schema.String),
|
|
20
|
-
typename: Schema.String.annotations({
|
|
21
|
-
[TypenameAnnotationId]: [
|
|
22
|
-
"used-static",
|
|
23
|
-
"dynamic"
|
|
24
|
-
],
|
|
25
|
-
title: "Select graph record type"
|
|
26
|
-
})
|
|
27
|
-
});
|
|
28
|
-
var CreateGraph = class extends Schema.TaggedClass()(`${EXPLORER_ACTION}/create-graph`, {
|
|
29
|
-
input: Schema.Struct({
|
|
30
|
-
space: SpaceSchema
|
|
31
|
-
}).pipe(Schema.extend(GraphProps)),
|
|
32
|
-
output: Schema.Struct({
|
|
33
|
-
object: DataType.View
|
|
34
|
-
})
|
|
35
|
-
}) {
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
// src/types/Graph.ts
|
|
39
|
-
var Graph_exports = {};
|
|
40
|
-
__export(Graph_exports, {
|
|
41
|
-
Graph: () => Graph,
|
|
42
|
-
make: () => make,
|
|
43
|
-
makeView: () => makeView
|
|
44
|
-
});
|
|
45
|
-
import * as Schema2 from "effect/Schema";
|
|
46
|
-
import { Filter, Obj, Query, QueryAST, Type } from "@dxos/echo";
|
|
47
|
-
import { LabelAnnotation, ViewAnnotation } from "@dxos/echo/internal";
|
|
48
|
-
import { createViewFromSpace } from "@dxos/schema";
|
|
49
|
-
var Graph = Schema2.Struct({
|
|
50
|
-
name: Schema2.optional(Schema2.String),
|
|
51
|
-
query: Schema2.Struct({
|
|
52
|
-
raw: Schema2.optional(Schema2.String),
|
|
53
|
-
ast: QueryAST.Query
|
|
54
|
-
}).pipe(Schema2.mutable)
|
|
55
|
-
}).pipe(Type.Obj({
|
|
56
|
-
typename: "dxos.org/type/Graph",
|
|
57
|
-
version: "0.1.0"
|
|
58
|
-
}), LabelAnnotation.set([
|
|
59
|
-
"name"
|
|
60
|
-
]), ViewAnnotation.set(true));
|
|
61
|
-
var make = (props = {
|
|
62
|
-
query: {
|
|
63
|
-
raw: "",
|
|
64
|
-
ast: Query.select(Filter.nothing()).ast
|
|
65
|
-
}
|
|
66
|
-
}) => Obj.make(Graph, props);
|
|
67
|
-
var makeView = async ({ presentation, ...props }) => {
|
|
68
|
-
const graph = make(presentation);
|
|
69
|
-
return createViewFromSpace({
|
|
70
|
-
...props,
|
|
71
|
-
presentation: graph
|
|
72
|
-
});
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export {
|
|
76
|
-
ExplorerAction_exports,
|
|
77
|
-
Graph_exports
|
|
78
|
-
};
|
|
79
|
-
//# sourceMappingURL=chunk-BZ65T5M3.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/types/ExplorerAction.ts", "../../../src/types/Graph.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { SpaceSchema } from '@dxos/react-client/echo';\nimport { DataType, TypenameAnnotationId } from '@dxos/schema';\n\nimport { meta } from '../meta';\n\nconst EXPLORER_ACTION = `${meta.id}/action`;\n\nexport const GraphProps = Schema.Struct({\n name: Schema.optional(Schema.String),\n typename: Schema.String.annotations({\n [TypenameAnnotationId]: ['used-static', 'dynamic'],\n title: 'Select graph record type',\n }),\n});\n\nexport class CreateGraph extends Schema.TaggedClass<CreateGraph>()(`${EXPLORER_ACTION}/create-graph`, {\n input: Schema.Struct({\n space: SpaceSchema,\n }).pipe(Schema.extend(GraphProps)),\n output: Schema.Struct({\n object: DataType.View,\n }),\n}) {}\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { Filter, Obj, Query, QueryAST, Type } from '@dxos/echo';\nimport { LabelAnnotation, ViewAnnotation } from '@dxos/echo/internal';\nimport { type CreateViewFromSpaceProps, createViewFromSpace } from '@dxos/schema';\n\nexport const Graph = Schema.Struct({\n name: Schema.optional(Schema.String),\n query: Schema.Struct({\n raw: Schema.optional(Schema.String),\n ast: QueryAST.Query,\n }).pipe(Schema.mutable),\n}).pipe(\n Type.Obj({\n typename: 'dxos.org/type/Graph',\n version: '0.1.0',\n }),\n LabelAnnotation.set(['name']),\n ViewAnnotation.set(true),\n);\n\nexport type Graph = Schema.Schema.Type<typeof Graph>;\n\n/**\n * Make a graph object.\n */\nexport const make = (\n props: Obj.MakeProps<typeof Graph> = { query: { raw: '', ast: Query.select(Filter.nothing()).ast } },\n) => Obj.make(Graph, props);\n\ntype MakeViewProps = Omit<CreateViewFromSpaceProps, 'presentation'> & {\n presentation?: Omit<Obj.MakeProps<typeof Graph>, 'name'>;\n};\n\n/**\n * Make a graph as a view of a data set.\n */\nexport const makeView = async ({ presentation, ...props }: MakeViewProps) => {\n const graph = make(presentation);\n return createViewFromSpace({ ...props, presentation: graph });\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;AAAA;;;;;AAIA,YAAYA,YAAY;AAExB,SAASC,mBAAmB;AAC5B,SAASC,UAAUC,4BAA4B;AAI/C,IAAMC,kBAAkB,GAAGC,KAAKC,EAAE;AAE3B,IAAMC,aAAoBC,cAAO;EACtCC,MAAaC,gBAAgBC,aAAM;EACnCC,UAAiBD,cAAOE,YAAY;IAClC,CAACC,oBAAAA,GAAuB;MAAC;MAAe;;IACxCC,OAAO;EACT,CAAA;AACF,CAAA;AAEO,IAAMC,cAAN,cAAiCC,mBAAW,EAAgB,GAAGb,eAAAA,iBAAgC;EACpGc,OAAcV,cAAO;IACnBW,OAAOC;EACT,CAAA,EAAGC,KAAYC,cAAOf,UAAAA,CAAAA;EACtBgB,QAAef,cAAO;IACpBgB,QAAQC,SAASC;EACnB,CAAA;AACF,CAAA,EAAA;AAAI;;;AC5BJ;;;;;;AAIA,YAAYC,aAAY;AAExB,SAASC,QAAQC,KAAKC,OAAOC,UAAUC,YAAY;AACnD,SAASC,iBAAiBC,sBAAsB;AAChD,SAAwCC,2BAA2B;AAE5D,IAAMC,QAAeC,eAAO;EACjCC,MAAaC,iBAAgBC,cAAM;EACnCC,OAAcJ,eAAO;IACnBK,KAAYH,iBAAgBC,cAAM;IAClCG,KAAKC,SAASC;EAChB,CAAA,EAAGC,KAAYC,eAAO;AACxB,CAAA,EAAGD,KACDE,KAAKC,IAAI;EACPC,UAAU;EACVC,SAAS;AACX,CAAA,GACAC,gBAAgBC,IAAI;EAAC;CAAO,GAC5BC,eAAeD,IAAI,IAAA,CAAA;AAQd,IAAME,OAAO,CAClBC,QAAqC;EAAEf,OAAO;IAAEC,KAAK;IAAIC,KAAKE,MAAMY,OAAOC,OAAOC,QAAO,CAAA,EAAIhB;EAAI;AAAE,MAChGM,IAAIM,KAAKnB,OAAOoB,KAAAA;AASd,IAAMI,WAAW,OAAO,EAAEC,cAAc,GAAGL,MAAAA,MAAsB;AACtE,QAAMM,QAAQP,KAAKM,YAAAA;AACnB,SAAOE,oBAAoB;IAAE,GAAGP;IAAOK,cAAcC;EAAM,CAAA;AAC7D;",
|
|
6
|
-
"names": ["Schema", "SpaceSchema", "DataType", "TypenameAnnotationId", "EXPLORER_ACTION", "meta", "id", "GraphProps", "Struct", "name", "optional", "String", "typename", "annotations", "TypenameAnnotationId", "title", "CreateGraph", "TaggedClass", "input", "space", "SpaceSchema", "pipe", "extend", "output", "object", "DataType", "View", "Schema", "Filter", "Obj", "Query", "QueryAST", "Type", "LabelAnnotation", "ViewAnnotation", "createViewFromSpace", "Graph", "Struct", "name", "optional", "String", "query", "raw", "ast", "QueryAST", "Query", "pipe", "mutable", "Type", "Obj", "typename", "version", "LabelAnnotation", "set", "ViewAnnotation", "make", "props", "select", "Filter", "nothing", "makeView", "presentation", "graph", "createViewFromSpace"]
|
|
7
|
-
}
|