@dxos/plugin-explorer 0.8.4-main.f9ba587 → 0.8.4-main.fcc0d83b33
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/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +11323 -92
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/meta.mjs +21 -5
- package/dist/lib/browser/meta.mjs.map +4 -4
- package/dist/lib/browser/translations.mjs +33 -0
- package/dist/lib/browser/translations.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +68 -6
- package/dist/lib/browser/types/index.mjs.map +4 -4
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +11323 -92
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/meta.mjs +21 -5
- package/dist/lib/node-esm/meta.mjs.map +4 -4
- package/dist/lib/node-esm/translations.mjs +34 -0
- package/dist/lib/node-esm/translations.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +68 -6
- package/dist/lib/node-esm/types/index.mjs.map +4 -4
- 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 +2 -1
- package/dist/types/src/ExplorerPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +2 -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.map +1 -1
- package/dist/types/src/components/Chart/Chart.stories.d.ts +8 -4
- package/dist/types/src/components/Chart/Chart.stories.d.ts.map +1 -1
- package/dist/types/src/components/Globe/Globe.d.ts.map +1 -1
- package/dist/types/src/components/Globe/Globe.stories.d.ts +8 -4
- package/dist/types/src/components/Globe/Globe.stories.d.ts.map +1 -1
- package/dist/types/src/components/Graph/D3ForceGraph.d.ts +6 -5
- package/dist/types/src/components/Graph/D3ForceGraph.d.ts.map +1 -1
- package/dist/types/src/components/Graph/D3ForceGraph.stories.d.ts +15 -4
- package/dist/types/src/components/Graph/D3ForceGraph.stories.d.ts.map +1 -1
- package/dist/types/src/components/Graph/ForceGraph.stories.d.ts +13 -4
- package/dist/types/src/components/Graph/ForceGraph.stories.d.ts.map +1 -1
- package/dist/types/src/components/Graph/adapter.d.ts +1 -1
- package/dist/types/src/components/Graph/adapter.d.ts.map +1 -1
- package/dist/types/src/components/Graph/testing.d.ts +1 -1
- package/dist/types/src/components/Graph/testing.d.ts.map +1 -1
- package/dist/types/src/components/Tree/Tree.d.ts.map +1 -1
- package/dist/types/src/components/Tree/Tree.stories.d.ts +13 -16
- package/dist/types/src/components/Tree/Tree.stories.d.ts.map +1 -1
- package/dist/types/src/components/Tree/layout/HierarchicalEdgeBundling.d.ts.map +1 -1
- package/dist/types/src/components/Tree/layout/RadialTree.d.ts.map +1 -1
- package/dist/types/src/components/Tree/layout/TidyTree.d.ts.map +1 -1
- package/dist/types/src/components/Tree/testing/generator.d.ts.map +1 -1
- package/dist/types/src/components/Tree/types/tree.d.ts +19 -17
- package/dist/types/src/components/Tree/types/tree.d.ts.map +1 -1
- package/dist/types/src/components/Tree/types/types.d.ts +1 -1
- package/dist/types/src/components/Tree/types/types.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +0 -4
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/components/plot.d.ts.map +1 -1
- package/dist/types/src/containers/ExplorerContainer/ExplorerContainer.d.ts +6 -0
- package/dist/types/src/containers/ExplorerContainer/ExplorerContainer.d.ts.map +1 -0
- package/dist/types/src/containers/ExplorerContainer/index.d.ts +2 -0
- package/dist/types/src/containers/ExplorerContainer/index.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 +0 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -3
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +34 -11
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/ExplorerAction.d.ts +6 -0
- package/dist/types/src/types/ExplorerAction.d.ts.map +1 -0
- package/dist/types/src/types/Graph.d.ts +23 -0
- package/dist/types/src/types/Graph.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +2 -2
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +69 -54
- package/src/ExplorerPlugin.tsx +43 -54
- package/src/capabilities/index.ts +2 -3
- package/src/capabilities/react-surface.tsx +24 -15
- package/src/components/Chart/Chart.stories.tsx +9 -8
- package/src/components/Chart/Chart.tsx +1 -1
- package/src/components/Globe/Globe.stories.tsx +13 -12
- package/src/components/Globe/Globe.tsx +1 -1
- package/src/components/Graph/D3ForceGraph.stories.tsx +47 -28
- package/src/components/Graph/D3ForceGraph.tsx +83 -76
- package/src/components/Graph/ForceGraph.stories.tsx +47 -28
- package/src/components/Graph/ForceGraph.tsx +5 -5
- package/src/components/Graph/adapter.ts +14 -8
- package/src/components/Graph/testing.ts +13 -10
- package/src/components/Tree/Tree.stories.tsx +34 -25
- package/src/components/Tree/Tree.tsx +11 -6
- package/src/components/Tree/testing/generator.ts +4 -2
- package/src/components/Tree/types/tree.test.ts +9 -7
- package/src/components/Tree/types/tree.ts +42 -21
- package/src/components/Tree/types/types.ts +1 -1
- package/src/components/index.ts +0 -4
- package/src/containers/ExplorerContainer/ExplorerContainer.tsx +53 -0
- package/src/containers/ExplorerContainer/index.ts +5 -0
- package/src/containers/index.ts +7 -0
- package/src/hooks/useGraphModel.ts +19 -11
- package/src/index.ts +0 -1
- package/src/meta.ts +9 -6
- package/src/translations.ts +17 -10
- package/src/types/ExplorerAction.ts +20 -0
- package/src/types/Graph.ts +49 -0
- package/src/types/index.ts +2 -2
- package/src/typings.d.ts +8 -0
- package/dist/lib/browser/ExplorerContainer-WYPM7YXU.mjs +0 -37
- package/dist/lib/browser/ExplorerContainer-WYPM7YXU.mjs.map +0 -7
- package/dist/lib/browser/chunk-4UVJNXCE.mjs +0 -11329
- package/dist/lib/browser/chunk-4UVJNXCE.mjs.map +0 -7
- package/dist/lib/browser/chunk-EF4BFHTI.mjs +0 -38
- package/dist/lib/browser/chunk-EF4BFHTI.mjs.map +0 -7
- package/dist/lib/browser/chunk-OAOY7SHY.mjs +0 -30
- package/dist/lib/browser/chunk-OAOY7SHY.mjs.map +0 -7
- package/dist/lib/browser/chunk-UL5EDJPE.mjs +0 -21
- package/dist/lib/browser/chunk-UL5EDJPE.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZZX52LNU.mjs +0 -187
- package/dist/lib/browser/chunk-ZZX52LNU.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-XH2UO2FM.mjs +0 -24
- package/dist/lib/browser/intent-resolver-XH2UO2FM.mjs.map +0 -7
- package/dist/lib/browser/react-surface-5ENPAK3V.mjs +0 -31
- package/dist/lib/browser/react-surface-5ENPAK3V.mjs.map +0 -7
- package/dist/lib/node-esm/ExplorerContainer-S5GL733T.mjs +0 -38
- package/dist/lib/node-esm/ExplorerContainer-S5GL733T.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-6M6W7DKH.mjs +0 -189
- package/dist/lib/node-esm/chunk-6M6W7DKH.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HCV3J2HM.mjs +0 -11331
- package/dist/lib/node-esm/chunk-HCV3J2HM.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-PIAXA43R.mjs +0 -23
- package/dist/lib/node-esm/chunk-PIAXA43R.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-PPBUWC7F.mjs +0 -32
- package/dist/lib/node-esm/chunk-PPBUWC7F.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-VKCOKQRG.mjs +0 -39
- package/dist/lib/node-esm/chunk-VKCOKQRG.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-AGBBNA67.mjs +0 -25
- package/dist/lib/node-esm/intent-resolver-AGBBNA67.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-4MDNPYQ6.mjs +0 -32
- package/dist/lib/node-esm/react-surface-4MDNPYQ6.mjs.map +0 -7
- 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/types/schema.d.ts +0 -12
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/dist/types/src/types/types.d.ts +0 -18
- package/dist/types/src/types/types.d.ts.map +0 -1
- package/src/capabilities/intent-resolver.ts +0 -19
- package/src/components/ExplorerContainer.tsx +0 -36
- package/src/types/schema.ts +0 -16
- package/src/types/types.ts +0 -21
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
|
-
import { Key, Obj, Type } from '@dxos/echo';
|
|
7
|
+
import { Key, Obj, Ref, Type } from '@dxos/echo';
|
|
8
|
+
import { TestSchema } from '@dxos/echo/testing';
|
|
8
9
|
import { invariant } from '@dxos/invariant';
|
|
9
10
|
|
|
10
11
|
// TODO(burdon): Reconcile with @dxos/graph (i.e., common types).
|
|
@@ -13,7 +14,7 @@ export const TreeNodeType = Schema.Struct({
|
|
|
13
14
|
id: Key.ObjectId,
|
|
14
15
|
children: Schema.mutable(Schema.Array(Key.ObjectId)),
|
|
15
16
|
data: Schema.mutable(Schema.Record({ key: Schema.String, value: Schema.Any })),
|
|
16
|
-
ref: Schema.optional(
|
|
17
|
+
ref: Schema.optional(Ref.Ref(TestSchema.Expando)),
|
|
17
18
|
}).pipe(Schema.mutable);
|
|
18
19
|
|
|
19
20
|
export interface TreeNodeType extends Schema.Schema.Type<typeof TreeNodeType> {}
|
|
@@ -22,8 +23,8 @@ export const TreeType = Schema.Struct({
|
|
|
22
23
|
root: Key.ObjectId,
|
|
23
24
|
nodes: Schema.mutable(Schema.Record({ key: Key.ObjectId, value: TreeNodeType })),
|
|
24
25
|
}).pipe(
|
|
25
|
-
Type.
|
|
26
|
-
typename: 'dxos.
|
|
26
|
+
Type.object({
|
|
27
|
+
typename: 'org.dxos.type.tree',
|
|
27
28
|
version: '0.1.0',
|
|
28
29
|
}),
|
|
29
30
|
);
|
|
@@ -184,9 +185,11 @@ export class Tree {
|
|
|
184
185
|
clear(): void {
|
|
185
186
|
const root = this._tree.nodes[this._tree.root];
|
|
186
187
|
root.children.length = 0;
|
|
187
|
-
this._tree
|
|
188
|
-
|
|
189
|
-
|
|
188
|
+
Obj.update(this._tree, (obj) => {
|
|
189
|
+
obj.nodes = {
|
|
190
|
+
[root.id]: root,
|
|
191
|
+
};
|
|
192
|
+
});
|
|
190
193
|
}
|
|
191
194
|
|
|
192
195
|
/**
|
|
@@ -198,8 +201,11 @@ export class Tree {
|
|
|
198
201
|
node = { id, children: [], data: { text: '' } }; // TODO(burdon): Generic.
|
|
199
202
|
}
|
|
200
203
|
|
|
201
|
-
|
|
202
|
-
|
|
204
|
+
const nodeToAdd = node;
|
|
205
|
+
Obj.update(this._tree, (obj) => {
|
|
206
|
+
obj.nodes[nodeToAdd.id] = nodeToAdd;
|
|
207
|
+
parent.children.splice(index ?? parent.children.length, 0, nodeToAdd.id);
|
|
208
|
+
});
|
|
203
209
|
return node;
|
|
204
210
|
}
|
|
205
211
|
|
|
@@ -212,10 +218,14 @@ export class Tree {
|
|
|
212
218
|
return undefined;
|
|
213
219
|
}
|
|
214
220
|
|
|
215
|
-
|
|
221
|
+
Obj.update(this._tree, (obj) => {
|
|
222
|
+
delete obj.nodes[node.id];
|
|
223
|
+
});
|
|
216
224
|
const idx = parent.children.findIndex((child) => child === id);
|
|
217
225
|
if (idx !== -1) {
|
|
218
|
-
|
|
226
|
+
Obj.update(this._tree, () => {
|
|
227
|
+
parent.children.splice(idx, 1);
|
|
228
|
+
});
|
|
219
229
|
}
|
|
220
230
|
|
|
221
231
|
return node;
|
|
@@ -232,8 +242,10 @@ export class Tree {
|
|
|
232
242
|
}
|
|
233
243
|
|
|
234
244
|
const child = node.children[from];
|
|
235
|
-
|
|
236
|
-
|
|
245
|
+
Obj.update(this._tree, () => {
|
|
246
|
+
node.children.splice(from, 1);
|
|
247
|
+
node.children.splice(to, 0, child);
|
|
248
|
+
});
|
|
237
249
|
return this.getNode(child);
|
|
238
250
|
}
|
|
239
251
|
|
|
@@ -252,8 +264,10 @@ export class Tree {
|
|
|
252
264
|
}
|
|
253
265
|
|
|
254
266
|
const previous = this.getNode(parent.children[idx - 1]);
|
|
255
|
-
|
|
256
|
-
|
|
267
|
+
Obj.update(this._tree, () => {
|
|
268
|
+
parent.children.splice(idx, 1);
|
|
269
|
+
previous.children.push(node.id);
|
|
270
|
+
});
|
|
257
271
|
}
|
|
258
272
|
|
|
259
273
|
/**
|
|
@@ -270,16 +284,23 @@ export class Tree {
|
|
|
270
284
|
return;
|
|
271
285
|
}
|
|
272
286
|
|
|
273
|
-
// Remove node from parent.
|
|
287
|
+
// Remove node from parent and get following siblings.
|
|
274
288
|
const nodeIdx = parent.children.findIndex((id) => id === node.id);
|
|
275
|
-
|
|
276
|
-
|
|
289
|
+
let rest: Key.ObjectId[] = [];
|
|
290
|
+
Obj.update(this._tree, () => {
|
|
291
|
+
const removed = parent.children.splice(nodeIdx, parent.children.length - nodeIdx);
|
|
292
|
+
rest = removed.slice(1); // Skip the node itself.
|
|
293
|
+
});
|
|
277
294
|
|
|
278
295
|
// Add to ancestor.
|
|
279
296
|
const parentIdx = this.getChildNodes(ancestor).findIndex((n) => n.id === parent.id);
|
|
280
|
-
|
|
297
|
+
Obj.update(this._tree, () => {
|
|
298
|
+
ancestor.children.splice(parentIdx + 1, 0, node.id);
|
|
299
|
+
});
|
|
281
300
|
|
|
282
301
|
// Transplant following siblings to current node.
|
|
283
|
-
|
|
302
|
+
Obj.update(this._tree, () => {
|
|
303
|
+
node.children.push(...rest);
|
|
304
|
+
});
|
|
284
305
|
}
|
|
285
306
|
}
|
|
@@ -10,7 +10,7 @@ export type TreeNode = {
|
|
|
10
10
|
children?: TreeNode[];
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
export const mapGraphToTreeData = (model: GraphModel, maxDepth = 8): TreeNode | undefined => {
|
|
13
|
+
export const mapGraphToTreeData = (model: GraphModel.GraphModel, maxDepth = 8): TreeNode | undefined => {
|
|
14
14
|
// TODO(burdon): Convert to common/graph.
|
|
15
15
|
// const mapNode = (node: N, depth = 0): TreeNode => {
|
|
16
16
|
// const treeNode: TreeNode = {
|
package/src/components/index.ts
CHANGED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { useCallback, useMemo, useState } from 'react';
|
|
6
|
+
|
|
7
|
+
import { type AppSurface } from '@dxos/app-toolkit/ui';
|
|
8
|
+
import { type Filter } from '@dxos/echo';
|
|
9
|
+
import { type View } from '@dxos/echo';
|
|
10
|
+
import { QueryBuilder } from '@dxos/echo-query';
|
|
11
|
+
import { useGlobalSearch } from '@dxos/plugin-search';
|
|
12
|
+
import { getSpace, useObject } from '@dxos/react-client/echo';
|
|
13
|
+
import { Panel, Toolbar } from '@dxos/react-ui';
|
|
14
|
+
import { QueryEditor, type QueryEditorProps } from '@dxos/react-ui-components';
|
|
15
|
+
|
|
16
|
+
import { D3ForceGraph } from '#components';
|
|
17
|
+
import { useGraphModel } from '#hooks';
|
|
18
|
+
|
|
19
|
+
export type ExplorerContainerProps = AppSurface.ObjectArticleProps<View.View>;
|
|
20
|
+
|
|
21
|
+
export const ExplorerContainer = ({ role, subject, attendableId: _attendableId }: ExplorerContainerProps) => {
|
|
22
|
+
const [view] = useObject(subject);
|
|
23
|
+
const space = view && getSpace(view);
|
|
24
|
+
const [filter, setFilter] = useState<Filter.Any>();
|
|
25
|
+
const model = useGraphModel(space, filter);
|
|
26
|
+
const { match } = useGlobalSearch();
|
|
27
|
+
|
|
28
|
+
const builder = useMemo(() => new QueryBuilder(), []);
|
|
29
|
+
const handleChange = useCallback<NonNullable<QueryEditorProps['onChange']>>((value) => {
|
|
30
|
+
setFilter(builder.build(value).filter);
|
|
31
|
+
}, []);
|
|
32
|
+
|
|
33
|
+
const showToolbar = role === 'article';
|
|
34
|
+
|
|
35
|
+
if (!space || !model) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<Panel.Root role={role}>
|
|
41
|
+
{showToolbar && (
|
|
42
|
+
<Panel.Toolbar asChild>
|
|
43
|
+
<Toolbar.Root>
|
|
44
|
+
<QueryEditor db={space.db} onChange={handleChange} />
|
|
45
|
+
</Toolbar.Root>
|
|
46
|
+
</Panel.Toolbar>
|
|
47
|
+
)}
|
|
48
|
+
<Panel.Content asChild>
|
|
49
|
+
<D3ForceGraph model={model} match={match} />
|
|
50
|
+
</Panel.Content>
|
|
51
|
+
</Panel.Root>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
import { useEffect, useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { Capabilities } from '@dxos/app-framework';
|
|
8
|
+
import { useCapability } from '@dxos/app-framework/ui';
|
|
9
|
+
import { type Filter, type Queue, type Space } from '@dxos/client/echo';
|
|
8
10
|
import { SpaceGraphModel, type SpaceGraphModelOptions } from '@dxos/schema';
|
|
9
11
|
|
|
10
12
|
// TODO(burdon): Factor out.
|
|
@@ -12,24 +14,30 @@ export const useGraphModel = (
|
|
|
12
14
|
space: Space | undefined,
|
|
13
15
|
filter?: Filter.Any | undefined,
|
|
14
16
|
options?: SpaceGraphModelOptions,
|
|
17
|
+
queue?: Queue,
|
|
15
18
|
): SpaceGraphModel | undefined => {
|
|
19
|
+
const registry = useCapability(Capabilities.AtomRegistry);
|
|
16
20
|
const [model, setModel] = useState<SpaceGraphModel | undefined>(undefined);
|
|
21
|
+
|
|
17
22
|
useEffect(() => {
|
|
18
23
|
if (!space) {
|
|
19
|
-
void model?.close();
|
|
20
24
|
setModel(undefined);
|
|
21
25
|
return;
|
|
22
26
|
}
|
|
23
27
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
}, [space,
|
|
28
|
+
const newModel = new SpaceGraphModel(registry);
|
|
29
|
+
void newModel.open(space.db, queue);
|
|
30
|
+
setModel(newModel);
|
|
31
|
+
|
|
32
|
+
return () => {
|
|
33
|
+
setModel(undefined);
|
|
34
|
+
void newModel.close();
|
|
35
|
+
};
|
|
36
|
+
}, [space, registry, queue]);
|
|
37
|
+
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
model?.setFilter(filter).setOptions(options);
|
|
40
|
+
}, [model, filter, options]);
|
|
33
41
|
|
|
34
42
|
return model;
|
|
35
43
|
};
|
package/src/index.ts
CHANGED
package/src/meta.ts
CHANGED
|
@@ -2,15 +2,18 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type
|
|
5
|
+
import { type Plugin } from '@dxos/app-framework';
|
|
6
|
+
import { trim } from '@dxos/util';
|
|
6
7
|
|
|
7
|
-
export const
|
|
8
|
-
|
|
9
|
-
export const meta: PluginMeta = {
|
|
10
|
-
id: EXPLORER_PLUGIN,
|
|
8
|
+
export const meta: Plugin.Meta = {
|
|
9
|
+
id: 'org.dxos.plugin.explorer',
|
|
11
10
|
name: 'Explorer',
|
|
12
|
-
description:
|
|
11
|
+
description: trim`
|
|
12
|
+
Interactive hypergraph visualization that reveals relationships between objects in your workspace.
|
|
13
|
+
Navigate complex data structures and discover connections through a dynamic network view.
|
|
14
|
+
`,
|
|
13
15
|
icon: 'ph--graph--regular',
|
|
16
|
+
iconHue: 'green',
|
|
14
17
|
source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-explorer',
|
|
15
18
|
tags: ['labs'],
|
|
16
19
|
screenshots: ['https://dxos.network/plugin-details-explorer-dark.png'],
|
package/src/translations.ts
CHANGED
|
@@ -2,25 +2,32 @@
|
|
|
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';
|
|
7
|
+
import { translations as componentsTranslations } from '@dxos/react-ui-components/translations';
|
|
6
8
|
|
|
7
|
-
import { meta } from '
|
|
8
|
-
import {
|
|
9
|
+
import { meta } from '#meta';
|
|
10
|
+
import { Graph } from '#types';
|
|
9
11
|
|
|
10
12
|
export const translations = [
|
|
11
13
|
{
|
|
12
14
|
'en-US': {
|
|
13
|
-
[
|
|
14
|
-
'typename
|
|
15
|
-
'typename
|
|
16
|
-
'typename
|
|
17
|
-
'typename
|
|
18
|
-
'object
|
|
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',
|
|
19
25
|
},
|
|
20
26
|
[meta.id]: {
|
|
21
|
-
'plugin
|
|
22
|
-
'object
|
|
27
|
+
'plugin.name': 'Explorer',
|
|
28
|
+
'object-title.label': 'Title',
|
|
23
29
|
},
|
|
24
30
|
},
|
|
25
31
|
},
|
|
32
|
+
...componentsTranslations,
|
|
26
33
|
] as const satisfies Resource[];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
import { TypeInputOptionsAnnotation } from '@dxos/plugin-space/types';
|
|
8
|
+
|
|
9
|
+
export const GraphProps = Schema.Struct({
|
|
10
|
+
name: Schema.optional(Schema.String),
|
|
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
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
import { Annotation, Filter, Obj, Query, QueryAST, Ref, Type } from '@dxos/echo';
|
|
8
|
+
import { View } from '@dxos/echo';
|
|
9
|
+
import { FormInputAnnotation, LabelAnnotation } from '@dxos/echo/internal';
|
|
10
|
+
import { ViewAnnotation } from '@dxos/schema';
|
|
11
|
+
|
|
12
|
+
const GraphSchema = Schema.Struct({
|
|
13
|
+
name: Schema.optional(Schema.String),
|
|
14
|
+
|
|
15
|
+
view: Ref.Ref(View.View).pipe(FormInputAnnotation.set(false)),
|
|
16
|
+
|
|
17
|
+
query: Schema.Struct({
|
|
18
|
+
raw: Schema.optional(Schema.String),
|
|
19
|
+
ast: QueryAST.Query,
|
|
20
|
+
}).pipe(FormInputAnnotation.set(false)),
|
|
21
|
+
}).pipe(
|
|
22
|
+
Type.object({
|
|
23
|
+
typename: 'org.dxos.type.graph',
|
|
24
|
+
version: '0.1.0',
|
|
25
|
+
}),
|
|
26
|
+
LabelAnnotation.set(['name']),
|
|
27
|
+
ViewAnnotation.set(['view']),
|
|
28
|
+
Annotation.IconAnnotation.set({
|
|
29
|
+
icon: 'ph--graph--regular',
|
|
30
|
+
hue: 'green',
|
|
31
|
+
}),
|
|
32
|
+
);
|
|
33
|
+
export interface Graph extends Schema.Schema.Type<typeof GraphSchema> {}
|
|
34
|
+
export const Graph: Type.Obj<Graph> = GraphSchema as any;
|
|
35
|
+
|
|
36
|
+
type MakeProps = Omit<Partial<Obj.MakeProps<typeof Graph>>, 'view'> & {
|
|
37
|
+
view: View.View;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Make a graph as a view of a data set.
|
|
42
|
+
*/
|
|
43
|
+
export const make = ({
|
|
44
|
+
name,
|
|
45
|
+
query = { raw: '', ast: Query.select(Filter.nothing()).ast },
|
|
46
|
+
view,
|
|
47
|
+
}: MakeProps): Graph => {
|
|
48
|
+
return Obj.make(Graph, { name, view: Ref.make(view), query });
|
|
49
|
+
};
|
package/src/types/index.ts
CHANGED
package/src/typings.d.ts
ADDED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useGraphModel
|
|
3
|
-
} from "./chunk-OAOY7SHY.mjs";
|
|
4
|
-
import {
|
|
5
|
-
D3ForceGraph
|
|
6
|
-
} from "./chunk-ZZX52LNU.mjs";
|
|
7
|
-
|
|
8
|
-
// src/components/ExplorerContainer.tsx
|
|
9
|
-
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
10
|
-
import React from "react";
|
|
11
|
-
import { useGlobalSearch } from "@dxos/plugin-search";
|
|
12
|
-
import { getSpace } from "@dxos/react-client/echo";
|
|
13
|
-
import { StackItem } from "@dxos/react-ui-stack";
|
|
14
|
-
var ExplorerContainer = ({ role, view }) => {
|
|
15
|
-
var _effect = _useSignals();
|
|
16
|
-
try {
|
|
17
|
-
const space = getSpace(view);
|
|
18
|
-
const model = useGraphModel(space);
|
|
19
|
-
const { match } = useGlobalSearch();
|
|
20
|
-
if (!space || !model) {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
return /* @__PURE__ */ React.createElement(StackItem.Content, {
|
|
24
|
-
size: role === "section" ? "square" : "intrinsic"
|
|
25
|
-
}, /* @__PURE__ */ React.createElement(D3ForceGraph, {
|
|
26
|
-
model,
|
|
27
|
-
match
|
|
28
|
-
}));
|
|
29
|
-
} finally {
|
|
30
|
-
_effect.f();
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
var ExplorerContainer_default = ExplorerContainer;
|
|
34
|
-
export {
|
|
35
|
-
ExplorerContainer_default as default
|
|
36
|
-
};
|
|
37
|
-
//# sourceMappingURL=ExplorerContainer-WYPM7YXU.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 from 'react';\n\nimport { useGlobalSearch } from '@dxos/plugin-search';\nimport { getSpace } from '@dxos/react-client/echo';\nimport { StackItem } from '@dxos/react-ui-stack';\n\nimport { D3ForceGraph } from './Graph';\nimport { useGraphModel } from '../hooks';\nimport { type ViewType } from '../types';\n\ntype ExplorerContainerProps = {\n role: string;\n view: ViewType;\n};\n\nconst ExplorerContainer = ({ role, view }: ExplorerContainerProps) => {\n const space = getSpace(view);\n const model = useGraphModel(space);\n const { match } = useGlobalSearch();\n\n if (!space || !model) {\n return null;\n }\n\n return (\n <StackItem.Content size={role === 'section' ? 'square' : 'intrinsic'}>\n <D3ForceGraph model={model} match={match} />\n </StackItem.Content>\n );\n};\n\nexport default ExplorerContainer;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;AAIA,OAAOA,WAAW;AAElB,SAASC,uBAAuB;AAChC,SAASC,gBAAgB;AACzB,SAASC,iBAAiB;AAW1B,IAAMC,oBAAoB,CAAC,EAAEC,MAAMC,KAAI,MAA0B;;;AAC/D,UAAMC,QAAQC,SAASF,IAAAA;AACvB,UAAMG,QAAQC,cAAcH,KAAAA;AAC5B,UAAM,EAAEI,MAAK,IAAKC,gBAAAA;AAElB,QAAI,CAACL,SAAS,CAACE,OAAO;AACpB,aAAO;IACT;AAEA,WACE,sBAAA,cAACI,UAAUC,SAAO;MAACC,MAAMV,SAAS,YAAY,WAAW;OACvD,sBAAA,cAACW,cAAAA;MAAaP;MAAcE;;;;;AAGlC;AAEA,IAAA,4BAAeP;",
|
|
6
|
-
"names": ["React", "useGlobalSearch", "getSpace", "StackItem", "ExplorerContainer", "role", "view", "space", "getSpace", "model", "useGraphModel", "match", "useGlobalSearch", "StackItem", "Content", "size", "D3ForceGraph"]
|
|
7
|
-
}
|