@dxos/plugin-graph 0.8.4-main.8342792842 → 0.8.4-main.8360d9e660

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/plugin-graph",
3
- "version": "0.8.4-main.8342792842",
3
+ "version": "0.8.4-main.8360d9e660",
4
4
  "description": "DXOS Surface plugin for constructing knowledge graphs",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -29,14 +29,14 @@
29
29
  "src"
30
30
  ],
31
31
  "dependencies": {
32
- "@dxos/app-toolkit": "0.8.4-main.8342792842",
33
- "@dxos/app-framework": "0.8.4-main.8342792842",
34
- "@dxos/async": "0.8.4-main.8342792842",
35
- "@dxos/debug": "0.8.4-main.8342792842",
36
- "@dxos/app-graph": "0.8.4-main.8342792842",
37
- "@dxos/util": "0.8.4-main.8342792842",
38
- "@dxos/effect": "0.8.4-main.8342792842",
39
- "@dxos/operation": "0.8.4-main.8342792842"
32
+ "@dxos/app-toolkit": "0.8.4-main.8360d9e660",
33
+ "@dxos/async": "0.8.4-main.8360d9e660",
34
+ "@dxos/debug": "0.8.4-main.8360d9e660",
35
+ "@dxos/effect": "0.8.4-main.8360d9e660",
36
+ "@dxos/operation": "0.8.4-main.8360d9e660",
37
+ "@dxos/util": "0.8.4-main.8360d9e660",
38
+ "@dxos/app-framework": "0.8.4-main.8360d9e660",
39
+ "@dxos/app-graph": "0.8.4-main.8360d9e660"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@effect-atom/atom-react": "^0.5.0",
@@ -46,9 +46,9 @@
46
46
  "effect": "3.19.16",
47
47
  "react": "~19.2.3",
48
48
  "react-dom": "~19.2.3",
49
- "vite": "7.1.9",
50
- "@dxos/react-client": "0.8.4-main.8342792842",
51
- "@dxos/storybook-utils": "0.8.4-main.8342792842"
49
+ "vite": "^7.1.11",
50
+ "@dxos/react-client": "0.8.4-main.8360d9e660",
51
+ "@dxos/storybook-utils": "0.8.4-main.8360d9e660"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "@effect-atom/atom-react": "^0.5.0",
package/src/graph.ts CHANGED
@@ -12,7 +12,7 @@ import { AppCapabilities } from '@dxos/app-toolkit';
12
12
  // TODO(wittjosiah): Remove or restore graph caching.
13
13
  // import { meta } from './meta';
14
14
 
15
- // const KEY = `${meta.id}/app-graph`;
15
+ // const KEY = `${meta.id}.app-graph`;
16
16
 
17
17
  export default Capability.makeModule(
18
18
  Effect.fnUntraced(function* () {
@@ -37,7 +37,7 @@ export default Capability.makeModule(
37
37
  );
38
38
 
39
39
  // await builder.initialize();
40
- void Graph.expand(builder.graph, Node.RootId);
40
+ void Graph.expand(builder.graph, Node.RootId, 'child');
41
41
 
42
42
  setupDevtools(builder.graph);
43
43
 
@@ -4,6 +4,7 @@
4
4
 
5
5
  import { useAtomValue } from '@effect-atom/atom-react';
6
6
  import * as Option from 'effect/Option';
7
+ import { useMemo } from 'react';
7
8
 
8
9
  import { type Graph, type Node } from '@dxos/app-graph';
9
10
 
@@ -17,13 +18,38 @@ import { type Graph, type Node } from '@dxos/app-graph';
17
18
  */
18
19
  // TODO(wittjosiah): Factor out to @dxos/app-graph/react.
19
20
  export const useNode = <T = any>(graph: Graph.ReadableGraph, id?: string): Node.Node<T> | undefined => {
20
- return Option.getOrElse(useAtomValue(graph.node(id ?? '')), () => undefined);
21
+ const atom = useMemo(() => graph.node(id ?? ''), [graph, id]);
22
+ return Option.getOrElse(useAtomValue(atom), () => undefined);
21
23
  };
22
24
 
23
- export const useConnections = (graph: Graph.ReadableGraph, id?: string, relation?: Node.Relation): Node.Node[] => {
25
+ export const useConnections = (
26
+ graph: Graph.ReadableGraph,
27
+ id: string | undefined,
28
+ relation: Node.RelationInput,
29
+ ): Node.Node[] => {
24
30
  return useAtomValue(graph.connections(id ?? '', relation));
25
31
  };
26
32
 
33
+ /**
34
+ * React hook to get actions available for a node.
35
+ *
36
+ * @param graph Graph containing the node.
37
+ * @param id Id of the node.
38
+ * @returns Actions available for the node.
39
+ */
27
40
  export const useActions = (graph: Graph.ReadableGraph, id?: string): Node.Node[] => {
28
- return useAtomValue(graph.actions(id ?? ''));
41
+ const atom = useMemo(() => graph.actions(id ?? ''), [graph, id]);
42
+ return useAtomValue(atom);
43
+ };
44
+
45
+ /**
46
+ * Subscribe to just the edge topology (inbound/outbound IDs) of a node without subscribing to node content.
47
+ *
48
+ * @param graph Graph containing the node.
49
+ * @param id Id of the node.
50
+ * @returns Edge topology for the node.
51
+ */
52
+ export const useEdges = (graph: Graph.ReadableGraph, id?: string): Graph.Edges => {
53
+ const atom = useMemo(() => graph.edges(id ?? ''), [graph, id]);
54
+ return useAtomValue(atom);
29
55
  };
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.org/plugin/graph',
9
+ id: 'org.dxos.plugin.graph',
10
10
  name: 'Graph',
11
11
  description: trim`
12
12
  Graph database layer providing relationship modeling and queries for workspace objects.