@dxos/plugin-explorer 0.8.4-main.c85a9c8dae → 0.8.4-main.dfabb4ec29
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/ExplorerContainer-4RB2TY3G.mjs → neutral/ExplorerContainer-5TOK2ZEY.mjs} +8 -16
- package/dist/lib/neutral/ExplorerContainer-5TOK2ZEY.mjs.map +7 -0
- package/dist/lib/neutral/ExplorerPlugin.mjs +26 -0
- package/dist/lib/neutral/ExplorerPlugin.mjs.map +7 -0
- package/dist/lib/neutral/capabilities/index.mjs +11 -0
- package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
- package/dist/lib/{browser/chunk-4NFGHCGO.mjs → neutral/chunk-5X5ATGCS.mjs} +11 -22
- package/dist/lib/neutral/chunk-5X5ATGCS.mjs.map +7 -0
- package/dist/lib/{browser/chunk-YNQF4CPY.mjs → neutral/chunk-HPIS2WXY.mjs} +2 -2
- package/dist/lib/{browser/chunk-YNQF4CPY.mjs.map → neutral/chunk-HPIS2WXY.mjs.map} +3 -3
- package/dist/lib/{browser/chunk-6AZY4CDH.mjs → neutral/components/index.mjs} +144 -148
- package/dist/lib/{node-esm/chunk-DOXAIJEC.mjs.map → neutral/components/index.mjs.map} +4 -4
- 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 +40 -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-U3JEY7V7.mjs +26 -0
- package/dist/lib/neutral/react-surface-U3JEY7V7.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 -1
- 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 +8 -1
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- 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.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} +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/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 +5 -1
- 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 +6 -6
- package/dist/types/src/components/Tree/types/tree.d.ts.map +1 -1
- package/dist/types/src/components/Tree/types/types.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 +3 -3
- package/dist/types/src/containers/ExplorerContainer/ExplorerContainer.d.ts.map +1 -1
- package/dist/types/src/containers/ExplorerContainer/index.d.ts +1 -2
- package/dist/types/src/containers/ExplorerContainer/index.d.ts.map +1 -1
- 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/plugin.d.ts +3 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +28 -26
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/ExplorerAction.d.ts.map +1 -1
- package/dist/types/src/types/Graph.d.ts +2 -9
- package/dist/types/src/types/Graph.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +98 -57
- package/src/ExplorerPlugin.test.ts +26 -0
- package/src/ExplorerPlugin.tsx +7 -24
- package/src/capabilities/create-object.ts +36 -0
- package/src/capabilities/index.ts +4 -1
- package/src/capabilities/{react-surface/react-surface.tsx → react-surface.tsx} +10 -9
- package/src/components/Chart/Chart.stories.tsx +14 -21
- package/src/components/Globe/Globe.stories.tsx +17 -20
- package/src/components/Graph/CanvasForceGraph.stories.tsx +83 -0
- package/src/components/Graph/CanvasForceGraph.tsx +124 -0
- package/src/components/Graph/ForceGraph.stories.tsx +75 -44
- package/src/components/Graph/ForceGraph.tsx +104 -85
- package/src/components/Graph/index.ts +1 -1
- package/src/components/Tree/Tree.stories.tsx +43 -36
- package/src/components/Tree/testing/generator.ts +1 -1
- package/src/components/Tree/types/tree.test.ts +3 -4
- package/src/components/Tree/types/tree.ts +13 -13
- package/src/containers/ExplorerContainer/ExplorerContainer.tsx +7 -9
- package/src/containers/ExplorerContainer/index.ts +1 -3
- package/src/hooks/useGraphModel.ts +14 -10
- package/src/index.ts +1 -4
- package/src/meta.ts +1 -1
- package/src/plugin.ts +9 -0
- package/src/translations.ts +14 -13
- package/src/types/ExplorerAction.ts +1 -2
- package/src/types/Graph.ts +8 -22
- package/src/typings.d.ts +8 -0
- package/dist/lib/browser/ExplorerContainer-4RB2TY3G.mjs.map +0 -7
- package/dist/lib/browser/chunk-4NFGHCGO.mjs.map +0 -7
- package/dist/lib/browser/chunk-6AZY4CDH.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -95
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/react-surface-KAHVDMFX.mjs +0 -38
- package/dist/lib/browser/react-surface-KAHVDMFX.mjs.map +0 -7
- package/dist/lib/node-esm/ExplorerContainer-LCG425I7.mjs +0 -49
- package/dist/lib/node-esm/ExplorerContainer-LCG425I7.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-DK77RB6M.mjs +0 -26
- package/dist/lib/node-esm/chunk-DK77RB6M.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-DOXAIJEC.mjs +0 -11280
- 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-V42OFY7B.mjs +0 -85
- package/dist/lib/node-esm/chunk-V42OFY7B.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -96
- 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/meta.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-7XILIUI4.mjs +0 -39
- package/dist/lib/node-esm/react-surface-7XILIUI4.mjs.map +0 -7
- package/dist/lib/node-esm/types/index.mjs +0 -11
- package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/react-surface.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/src/capabilities/react-surface/index.ts +0 -7
- package/src/components/Graph/D3ForceGraph.stories.tsx +0 -84
- package/src/components/Graph/D3ForceGraph.tsx +0 -102
- /package/dist/lib/{browser → neutral}/chunk-J5LGTIGS.mjs +0 -0
- /package/dist/lib/{browser → neutral}/chunk-J5LGTIGS.mjs.map +0 -0
- /package/dist/lib/{browser/types → neutral}/index.mjs.map +0 -0
- /package/dist/lib/{browser → neutral}/meta.mjs.map +0 -0
- /package/dist/lib/{node-esm → neutral}/types/index.mjs.map +0 -0
- /package/dist/types/src/capabilities/{react-surface/react-surface.d.ts → react-surface.d.ts} +0 -0
- /package/src/components/Graph/{adapter.ts → graph-adapter.ts} +0 -0
|
@@ -24,7 +24,7 @@ export const TreeType = Schema.Struct({
|
|
|
24
24
|
nodes: Schema.mutable(Schema.Record({ key: Key.ObjectId, value: TreeNodeType })),
|
|
25
25
|
}).pipe(
|
|
26
26
|
Type.object({
|
|
27
|
-
typename: 'dxos.
|
|
27
|
+
typename: 'org.dxos.type.tree',
|
|
28
28
|
version: '0.1.0',
|
|
29
29
|
}),
|
|
30
30
|
);
|
|
@@ -185,8 +185,8 @@ export class Tree {
|
|
|
185
185
|
clear(): void {
|
|
186
186
|
const root = this._tree.nodes[this._tree.root];
|
|
187
187
|
root.children.length = 0;
|
|
188
|
-
Obj.
|
|
189
|
-
|
|
188
|
+
Obj.update(this._tree, (obj) => {
|
|
189
|
+
obj.nodes = {
|
|
190
190
|
[root.id]: root,
|
|
191
191
|
};
|
|
192
192
|
});
|
|
@@ -202,8 +202,8 @@ export class Tree {
|
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
const nodeToAdd = node;
|
|
205
|
-
Obj.
|
|
206
|
-
|
|
205
|
+
Obj.update(this._tree, (obj) => {
|
|
206
|
+
obj.nodes[nodeToAdd.id] = nodeToAdd;
|
|
207
207
|
parent.children.splice(index ?? parent.children.length, 0, nodeToAdd.id);
|
|
208
208
|
});
|
|
209
209
|
return node;
|
|
@@ -218,12 +218,12 @@ export class Tree {
|
|
|
218
218
|
return undefined;
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
-
Obj.
|
|
222
|
-
delete
|
|
221
|
+
Obj.update(this._tree, (obj) => {
|
|
222
|
+
delete obj.nodes[node.id];
|
|
223
223
|
});
|
|
224
224
|
const idx = parent.children.findIndex((child) => child === id);
|
|
225
225
|
if (idx !== -1) {
|
|
226
|
-
Obj.
|
|
226
|
+
Obj.update(this._tree, () => {
|
|
227
227
|
parent.children.splice(idx, 1);
|
|
228
228
|
});
|
|
229
229
|
}
|
|
@@ -242,7 +242,7 @@ export class Tree {
|
|
|
242
242
|
}
|
|
243
243
|
|
|
244
244
|
const child = node.children[from];
|
|
245
|
-
Obj.
|
|
245
|
+
Obj.update(this._tree, () => {
|
|
246
246
|
node.children.splice(from, 1);
|
|
247
247
|
node.children.splice(to, 0, child);
|
|
248
248
|
});
|
|
@@ -264,7 +264,7 @@ export class Tree {
|
|
|
264
264
|
}
|
|
265
265
|
|
|
266
266
|
const previous = this.getNode(parent.children[idx - 1]);
|
|
267
|
-
Obj.
|
|
267
|
+
Obj.update(this._tree, () => {
|
|
268
268
|
parent.children.splice(idx, 1);
|
|
269
269
|
previous.children.push(node.id);
|
|
270
270
|
});
|
|
@@ -287,19 +287,19 @@ export class Tree {
|
|
|
287
287
|
// Remove node from parent and get following siblings.
|
|
288
288
|
const nodeIdx = parent.children.findIndex((id) => id === node.id);
|
|
289
289
|
let rest: Key.ObjectId[] = [];
|
|
290
|
-
Obj.
|
|
290
|
+
Obj.update(this._tree, () => {
|
|
291
291
|
const removed = parent.children.splice(nodeIdx, parent.children.length - nodeIdx);
|
|
292
292
|
rest = removed.slice(1); // Skip the node itself.
|
|
293
293
|
});
|
|
294
294
|
|
|
295
295
|
// Add to ancestor.
|
|
296
296
|
const parentIdx = this.getChildNodes(ancestor).findIndex((n) => n.id === parent.id);
|
|
297
|
-
Obj.
|
|
297
|
+
Obj.update(this._tree, () => {
|
|
298
298
|
ancestor.children.splice(parentIdx + 1, 0, node.id);
|
|
299
299
|
});
|
|
300
300
|
|
|
301
301
|
// Transplant following siblings to current node.
|
|
302
|
-
Obj.
|
|
302
|
+
Obj.update(this._tree, () => {
|
|
303
303
|
node.children.push(...rest);
|
|
304
304
|
});
|
|
305
305
|
}
|
|
@@ -4,26 +4,24 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { useCallback, useMemo, useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import { type
|
|
7
|
+
import { type AppSurface } from '@dxos/app-toolkit/ui';
|
|
8
8
|
import { type Filter } from '@dxos/echo';
|
|
9
9
|
import { type View } from '@dxos/echo';
|
|
10
10
|
import { QueryBuilder } from '@dxos/echo-query';
|
|
11
|
-
import { useGlobalSearch } from '@dxos/plugin-search';
|
|
12
11
|
import { getSpace, useObject } from '@dxos/react-client/echo';
|
|
13
12
|
import { Panel, Toolbar } from '@dxos/react-ui';
|
|
14
13
|
import { QueryEditor, type QueryEditorProps } from '@dxos/react-ui-components';
|
|
15
14
|
|
|
16
|
-
import {
|
|
17
|
-
import { useGraphModel } from '
|
|
15
|
+
import { ForceGraph } from '#components';
|
|
16
|
+
import { useGraphModel } from '#hooks';
|
|
18
17
|
|
|
19
|
-
export type ExplorerContainerProps =
|
|
18
|
+
export type ExplorerContainerProps = AppSurface.ObjectArticleProps<View.View>;
|
|
20
19
|
|
|
21
|
-
export const ExplorerContainer = ({ role, subject:
|
|
22
|
-
useObject(
|
|
20
|
+
export const ExplorerContainer = ({ role, subject, attendableId: _attendableId }: ExplorerContainerProps) => {
|
|
21
|
+
const [view] = useObject(subject);
|
|
23
22
|
const space = view && getSpace(view);
|
|
24
23
|
const [filter, setFilter] = useState<Filter.Any>();
|
|
25
24
|
const model = useGraphModel(space, filter);
|
|
26
|
-
const { match } = useGlobalSearch();
|
|
27
25
|
|
|
28
26
|
const builder = useMemo(() => new QueryBuilder(), []);
|
|
29
27
|
const handleChange = useCallback<NonNullable<QueryEditorProps['onChange']>>((value) => {
|
|
@@ -46,7 +44,7 @@ export const ExplorerContainer = ({ role, subject: view }: ExplorerContainerProp
|
|
|
46
44
|
</Panel.Toolbar>
|
|
47
45
|
)}
|
|
48
46
|
<Panel.Content asChild>
|
|
49
|
-
<
|
|
47
|
+
<ForceGraph model={model} />
|
|
50
48
|
</Panel.Content>
|
|
51
49
|
</Panel.Root>
|
|
52
50
|
);
|
|
@@ -18,22 +18,26 @@ export const useGraphModel = (
|
|
|
18
18
|
): SpaceGraphModel | undefined => {
|
|
19
19
|
const registry = useCapability(Capabilities.AtomRegistry);
|
|
20
20
|
const [model, setModel] = useState<SpaceGraphModel | undefined>(undefined);
|
|
21
|
+
|
|
21
22
|
useEffect(() => {
|
|
22
23
|
if (!space) {
|
|
23
|
-
void model?.close();
|
|
24
24
|
setModel(undefined);
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
}, [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]);
|
|
37
41
|
|
|
38
42
|
return model;
|
|
39
43
|
};
|
package/src/index.ts
CHANGED
package/src/meta.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { type Plugin } from '@dxos/app-framework';
|
|
|
6
6
|
import { trim } from '@dxos/util';
|
|
7
7
|
|
|
8
8
|
export const meta: Plugin.Meta = {
|
|
9
|
-
id: 'dxos.
|
|
9
|
+
id: 'org.dxos.plugin.explorer',
|
|
10
10
|
name: 'Explorer',
|
|
11
11
|
description: trim`
|
|
12
12
|
Interactive hypergraph visualization that reveals relationships between objects in your workspace.
|
package/src/plugin.ts
ADDED
package/src/translations.ts
CHANGED
|
@@ -4,27 +4,28 @@
|
|
|
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
|
-
import { meta } from '
|
|
10
|
-
import { Graph } from '
|
|
9
|
+
import { meta } from '#meta';
|
|
10
|
+
import { Graph } from '#types';
|
|
11
11
|
|
|
12
12
|
export const translations = [
|
|
13
13
|
{
|
|
14
14
|
'en-US': {
|
|
15
15
|
[Type.getTypename(Graph.Graph)]: {
|
|
16
|
-
'typename
|
|
17
|
-
'typename
|
|
18
|
-
'typename
|
|
19
|
-
'typename
|
|
20
|
-
'object
|
|
21
|
-
'
|
|
22
|
-
'
|
|
23
|
-
'object
|
|
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',
|
|
24
25
|
},
|
|
25
26
|
[meta.id]: {
|
|
26
|
-
'plugin
|
|
27
|
-
'object
|
|
27
|
+
'plugin.name': 'Explorer',
|
|
28
|
+
'object-title.label': 'Title',
|
|
28
29
|
},
|
|
29
30
|
},
|
|
30
31
|
},
|
|
@@ -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),
|
|
@@ -14,7 +14,6 @@ export const GraphProps = Schema.Struct({
|
|
|
14
14
|
TypeInputOptionsAnnotation.set({
|
|
15
15
|
location: ['database', 'runtime'],
|
|
16
16
|
kind: ['user'],
|
|
17
|
-
registered: ['registered'],
|
|
18
17
|
}),
|
|
19
18
|
Schema.optional,
|
|
20
19
|
),
|
package/src/types/Graph.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
|
-
import { Filter, Obj, Query, QueryAST, Ref, Type } from '@dxos/echo';
|
|
7
|
+
import { Annotation, Filter, Obj, Query, QueryAST, Ref, Type } from '@dxos/echo';
|
|
8
8
|
import { View } from '@dxos/echo';
|
|
9
9
|
import { FormInputAnnotation, LabelAnnotation } from '@dxos/echo/internal';
|
|
10
10
|
import { ViewAnnotation } from '@dxos/schema';
|
|
@@ -20,11 +20,15 @@ const GraphSchema = Schema.Struct({
|
|
|
20
20
|
}).pipe(FormInputAnnotation.set(false)),
|
|
21
21
|
}).pipe(
|
|
22
22
|
Type.object({
|
|
23
|
-
typename: 'dxos.
|
|
24
|
-
version: '0.
|
|
23
|
+
typename: 'org.dxos.type.graph',
|
|
24
|
+
version: '0.1.0',
|
|
25
25
|
}),
|
|
26
26
|
LabelAnnotation.set(['name']),
|
|
27
|
-
ViewAnnotation.set(
|
|
27
|
+
ViewAnnotation.set(['view']),
|
|
28
|
+
Annotation.IconAnnotation.set({
|
|
29
|
+
icon: 'ph--graph--regular',
|
|
30
|
+
hue: 'green',
|
|
31
|
+
}),
|
|
28
32
|
);
|
|
29
33
|
export interface Graph extends Schema.Schema.Type<typeof GraphSchema> {}
|
|
30
34
|
export const Graph: Type.Obj<Graph> = GraphSchema as any;
|
|
@@ -43,21 +47,3 @@ export const make = ({
|
|
|
43
47
|
}: MakeProps): Graph => {
|
|
44
48
|
return Obj.make(Graph, { name, view: Ref.make(view), query });
|
|
45
49
|
};
|
|
46
|
-
|
|
47
|
-
//
|
|
48
|
-
// V1
|
|
49
|
-
//
|
|
50
|
-
|
|
51
|
-
export const GraphV1 = Schema.Struct({
|
|
52
|
-
name: Schema.optional(Schema.String),
|
|
53
|
-
query: Schema.Struct({
|
|
54
|
-
raw: Schema.optional(Schema.String),
|
|
55
|
-
ast: QueryAST.Query,
|
|
56
|
-
}),
|
|
57
|
-
}).pipe(
|
|
58
|
-
Type.object({
|
|
59
|
-
typename: 'dxos.org/type/Graph',
|
|
60
|
-
version: '0.1.0',
|
|
61
|
-
}),
|
|
62
|
-
LabelAnnotation.set(['name']),
|
|
63
|
-
);
|
package/src/typings.d.ts
ADDED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/containers/ExplorerContainer/ExplorerContainer.tsx", "../../../src/containers/ExplorerContainer/index.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { useCallback, useMemo, useState } from 'react';\n\nimport { type SurfaceComponentProps } from '@dxos/app-toolkit/ui';\nimport { type Filter } from '@dxos/echo';\nimport { type View } from '@dxos/echo';\nimport { QueryBuilder } from '@dxos/echo-query';\nimport { useGlobalSearch } from '@dxos/plugin-search';\nimport { getSpace, useObject } from '@dxos/react-client/echo';\nimport { Panel, Toolbar } from '@dxos/react-ui';\nimport { QueryEditor, type QueryEditorProps } from '@dxos/react-ui-components';\n\nimport { D3ForceGraph } from '../../components';\nimport { useGraphModel } from '../../hooks';\n\nexport type ExplorerContainerProps = SurfaceComponentProps<View.View>;\n\nexport const ExplorerContainer = ({ role, subject: view }: ExplorerContainerProps) => {\n useObject(view);\n const space = view && 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).filter);\n }, []);\n\n const showToolbar = role === 'article';\n\n if (!space || !model) {\n return null;\n }\n\n return (\n <Panel.Root role={role}>\n {showToolbar && (\n <Panel.Toolbar asChild>\n <Toolbar.Root>\n <QueryEditor db={space.db} onChange={handleChange} />\n </Toolbar.Root>\n </Panel.Toolbar>\n )}\n <Panel.Content asChild>\n <D3ForceGraph model={model} match={match} />\n </Panel.Content>\n </Panel.Root>\n );\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { ExplorerContainer } from './ExplorerContainer';\n\nexport default ExplorerContainer;\n"],
|
|
5
|
-
"mappings": ";;;;;;;AAIA,OAAOA,SAASC,aAAaC,SAASC,gBAAgB;AAKtD,SAASC,oBAAoB;AAC7B,SAASC,uBAAuB;AAChC,SAASC,UAAUC,iBAAiB;AACpC,SAASC,OAAOC,eAAe;AAC/B,SAASC,mBAA0C;AAO5C,IAAMC,oBAAoB,CAAC,EAAEC,MAAMC,SAASC,KAAI,MAA0B;AAC/EC,YAAUD,IAAAA;AACV,QAAME,QAAQF,QAAQG,SAASH,IAAAA;AAC/B,QAAM,CAACI,QAAQC,SAAAA,IAAaC,SAAAA;AAC5B,QAAMC,QAAQC,cAAcN,OAAOE,MAAAA;AACnC,QAAM,EAAEK,MAAK,IAAKC,gBAAAA;AAElB,QAAMC,UAAUC,QAAQ,MAAM,IAAIC,aAAAA,GAAgB,CAAA,CAAE;AACpD,QAAMC,eAAeC,YAAuD,CAACC,UAAAA;AAC3EX,cAAUM,QAAQM,MAAMD,KAAAA,EAAOZ,MAAM;EACvC,GAAG,CAAA,CAAE;AAEL,QAAMc,cAAcpB,SAAS;AAE7B,MAAI,CAACI,SAAS,CAACK,OAAO;AACpB,WAAO;EACT;AAEA,SACE,sBAAA,cAACY,MAAMC,MAAI;IAACtB;KACToB,eACC,sBAAA,cAACC,MAAME,SAAO;IAACC,SAAAA;KACb,sBAAA,cAACD,QAAQD,MAAI,MACX,sBAAA,cAACG,aAAAA;IAAYC,IAAItB,MAAMsB;IAAIC,UAAUX;QAI3C,sBAAA,cAACK,MAAMO,SAAO;IAACJ,SAAAA;KACb,sBAAA,cAACK,cAAAA;IAAapB;IAAcE;;AAIpC;;;AC9CA,IAAA,4BAAemB;",
|
|
6
|
-
"names": ["React", "useCallback", "useMemo", "useState", "QueryBuilder", "useGlobalSearch", "getSpace", "useObject", "Panel", "Toolbar", "QueryEditor", "ExplorerContainer", "role", "subject", "view", "useObject", "space", "getSpace", "filter", "setFilter", "useState", "model", "useGraphModel", "match", "useGlobalSearch", "builder", "useMemo", "QueryBuilder", "handleChange", "useCallback", "value", "build", "showToolbar", "Panel", "Root", "Toolbar", "asChild", "QueryEditor", "db", "onChange", "Content", "D3ForceGraph", "ExplorerContainer"]
|
|
7
|
-
}
|
|
@@ -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 { TypeInputOptionsAnnotation } from '@dxos/plugin-space/types';\n\nexport const GraphProps = Schema.Struct({\n name: Schema.optional(Schema.String),\n // TODO(wittjosiah): This should be a query input instead.\n typename: Schema.String.pipe(\n Schema.annotations({ title: 'Select type' }),\n TypeInputOptionsAnnotation.set({\n location: ['database', 'runtime'],\n kind: ['user'],\n registered: ['registered'],\n }),\n Schema.optional,\n ),\n});\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { Filter, Obj, Query, QueryAST, Ref, Type } from '@dxos/echo';\nimport { View } from '@dxos/echo';\nimport { FormInputAnnotation, LabelAnnotation } from '@dxos/echo/internal';\nimport { ViewAnnotation } from '@dxos/schema';\n\nconst GraphSchema = Schema.Struct({\n name: Schema.optional(Schema.String),\n\n view: Ref.Ref(View.View).pipe(FormInputAnnotation.set(false)),\n\n query: Schema.Struct({\n raw: Schema.optional(Schema.String),\n ast: QueryAST.Query,\n }).pipe(FormInputAnnotation.set(false)),\n}).pipe(\n Type.object({\n typename: 'dxos.org/type/Graph',\n version: '0.2.0',\n }),\n LabelAnnotation.set(['name']),\n ViewAnnotation.set(true),\n);\nexport interface Graph extends Schema.Schema.Type<typeof GraphSchema> {}\nexport const Graph: Type.Obj<Graph> = GraphSchema as any;\n\ntype MakeProps = Omit<Partial<Obj.MakeProps<typeof Graph>>, 'view'> & {\n view: View.View;\n};\n\n/**\n * Make a graph as a view of a data set.\n */\nexport const make = ({\n name,\n query = { raw: '', ast: Query.select(Filter.nothing()).ast },\n view,\n}: MakeProps): Graph => {\n return Obj.make(Graph, { name, view: Ref.make(view), query });\n};\n\n//\n// V1\n//\n\nexport const GraphV1 = Schema.Struct({\n name: Schema.optional(Schema.String),\n query: Schema.Struct({\n raw: Schema.optional(Schema.String),\n ast: QueryAST.Query,\n }),\n}).pipe(\n Type.object({\n typename: 'dxos.org/type/Graph',\n version: '0.1.0',\n }),\n LabelAnnotation.set(['name']),\n);\n"],
|
|
5
|
-
"mappings": ";;;;;AAAA;;;;AAIA,YAAYA,YAAY;AAExB,SAASC,kCAAkC;AAEpC,IAAMC,aAAoBC,cAAO;EACtCC,MAAaC,gBAAgBC,aAAM;;EAEnCC,UAAiBD,cAAOE,KACfC,mBAAY;IAAEC,OAAO;EAAc,CAAA,GAC1CC,2BAA2BC,IAAI;IAC7BC,UAAU;MAAC;MAAY;;IACvBC,MAAM;MAAC;;IACPC,YAAY;MAAC;;EACf,CAAA,GACOV,eAAQ;AAEnB,CAAA;;;ACpBA;;;;;;AAIA,YAAYW,aAAY;AAExB,SAASC,QAAQC,KAAKC,OAAOC,UAAUC,KAAKC,YAAY;AACxD,SAASC,YAAY;AACrB,SAASC,qBAAqBC,uBAAuB;AACrD,SAASC,sBAAsB;AAE/B,IAAMC,cAAqBC,eAAO;EAChCC,MAAaC,iBAAgBC,cAAM;EAEnCC,MAAMC,IAAIA,IAAIC,KAAKA,IAAI,EAAEC,KAAKC,oBAAoBC,IAAI,KAAA,CAAA;EAEtDC,OAAcV,eAAO;IACnBW,KAAYT,iBAAgBC,cAAM;IAClCS,KAAKC,SAASC;EAChB,CAAA,EAAGP,KAAKC,oBAAoBC,IAAI,KAAA,CAAA;AAClC,CAAA,EAAGF,KACDQ,KAAKC,OAAO;EACVC,UAAU;EACVC,SAAS;AACX,CAAA,GACAC,gBAAgBV,IAAI;EAAC;CAAO,GAC5BW,eAAeX,IAAI,IAAA,CAAA;AAGd,IAAMY,QAAyBtB;AAS/B,IAAMuB,OAAO,CAAC,EACnBrB,MACAS,QAAQ;EAAEC,KAAK;EAAIC,KAAKE,MAAMS,OAAOC,OAAOC,QAAO,CAAA,EAAIb;AAAI,GAC3DR,KAAI,MACM;AACV,SAAOsB,IAAIJ,KAAKD,OAAO;IAAEpB;IAAMG,MAAMC,IAAIiB,KAAKlB,IAAAA;IAAOM;EAAM,CAAA;AAC7D;AAMO,IAAMiB,UAAiB3B,eAAO;EACnCC,MAAaC,iBAAgBC,cAAM;EACnCO,OAAcV,eAAO;IACnBW,KAAYT,iBAAgBC,cAAM;IAClCS,KAAKC,SAASC;EAChB,CAAA;AACF,CAAA,EAAGP,KACDQ,KAAKC,OAAO;EACVC,UAAU;EACVC,SAAS;AACX,CAAA,GACAC,gBAAgBV,IAAI;EAAC;CAAO,CAAA;",
|
|
6
|
-
"names": ["Schema", "TypeInputOptionsAnnotation", "GraphProps", "Struct", "name", "optional", "String", "typename", "pipe", "annotations", "title", "TypeInputOptionsAnnotation", "set", "location", "kind", "registered", "Schema", "Filter", "Obj", "Query", "QueryAST", "Ref", "Type", "View", "FormInputAnnotation", "LabelAnnotation", "ViewAnnotation", "GraphSchema", "Struct", "name", "optional", "String", "view", "Ref", "View", "pipe", "FormInputAnnotation", "set", "query", "raw", "ast", "QueryAST", "Query", "Type", "object", "typename", "version", "LabelAnnotation", "ViewAnnotation", "Graph", "make", "select", "Filter", "nothing", "Obj", "GraphV1"]
|
|
7
|
-
}
|