@dxos/plugin-graph 0.8.4-main.bc674ce → 0.8.4-main.c351d160a8

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.bc674ce",
3
+ "version": "0.8.4-main.c351d160a8",
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,30 +29,31 @@
29
29
  "src"
30
30
  ],
31
31
  "dependencies": {
32
- "@dxos/app-framework": "0.8.4-main.bc674ce",
33
- "@dxos/async": "0.8.4-main.bc674ce",
34
- "@dxos/effect": "0.8.4-main.bc674ce",
35
- "@dxos/app-graph": "0.8.4-main.bc674ce",
36
- "@dxos/operation": "0.8.4-main.bc674ce",
37
- "@dxos/debug": "0.8.4-main.bc674ce",
38
- "@dxos/util": "0.8.4-main.bc674ce"
32
+ "@dxos/app-framework": "0.8.4-main.c351d160a8",
33
+ "@dxos/app-graph": "0.8.4-main.c351d160a8",
34
+ "@dxos/debug": "0.8.4-main.c351d160a8",
35
+ "@dxos/app-toolkit": "0.8.4-main.c351d160a8",
36
+ "@dxos/effect": "0.8.4-main.c351d160a8",
37
+ "@dxos/operation": "0.8.4-main.c351d160a8",
38
+ "@dxos/async": "0.8.4-main.c351d160a8",
39
+ "@dxos/util": "0.8.4-main.c351d160a8"
39
40
  },
40
41
  "devDependencies": {
41
- "@effect-atom/atom-react": "^0.4.6",
42
- "@effect/platform": "0.93.6",
42
+ "@effect-atom/atom-react": "^0.5.0",
43
+ "@effect/platform": "0.94.4",
43
44
  "@types/react": "~19.2.7",
44
45
  "@types/react-dom": "~19.2.3",
45
- "effect": "3.19.11",
46
+ "effect": "3.19.16",
46
47
  "react": "~19.2.3",
47
48
  "react-dom": "~19.2.3",
48
- "vite": "7.1.9",
49
- "@dxos/react-client": "0.8.4-main.bc674ce",
50
- "@dxos/storybook-utils": "0.8.4-main.bc674ce"
49
+ "vite": "^7.1.11",
50
+ "@dxos/react-client": "0.8.4-main.c351d160a8",
51
+ "@dxos/storybook-utils": "0.8.4-main.c351d160a8"
51
52
  },
52
53
  "peerDependencies": {
53
- "@effect-atom/atom-react": "^0.4.6",
54
- "@effect/platform": "0.93.6",
55
- "effect": "3.19.11",
54
+ "@effect-atom/atom-react": "^0.5.0",
55
+ "@effect/platform": "0.94.4",
56
+ "effect": "3.19.16",
56
57
  "react": "~19.2.3",
57
58
  "react-dom": "~19.2.3"
58
59
  },
@@ -2,7 +2,8 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { Capability, Common, Plugin } from '@dxos/app-framework';
5
+ import { ActivationEvents, Capability, Plugin } from '@dxos/app-framework';
6
+ import { AppActivationEvents } from '@dxos/app-toolkit';
6
7
 
7
8
  import { meta } from './meta';
8
9
 
@@ -15,9 +16,9 @@ const Graph = Capability.lazy('Graph', () => import('./graph'));
15
16
  */
16
17
  export const GraphPlugin = Plugin.define(meta).pipe(
17
18
  Plugin.addModule({
18
- activatesOn: Common.ActivationEvent.Startup,
19
- activatesBefore: [Common.ActivationEvent.SetupAppGraph, Common.ActivationEvent.SetupMetadata],
20
- activatesAfter: [Common.ActivationEvent.AppGraphReady],
19
+ activatesOn: ActivationEvents.Startup,
20
+ activatesBefore: [AppActivationEvents.SetupAppGraph, AppActivationEvents.SetupMetadata],
21
+ activatesAfter: [AppActivationEvents.AppGraphReady],
21
22
  activate: Graph,
22
23
  }),
23
24
  Plugin.make,
package/src/graph.ts CHANGED
@@ -5,18 +5,19 @@
5
5
  import * as Effect from 'effect/Effect';
6
6
  import * as Record from 'effect/Record';
7
7
 
8
- import { Capability, Common } from '@dxos/app-framework';
8
+ import { Capabilities, Capability } from '@dxos/app-framework';
9
9
  import { Graph, GraphBuilder, Node } from '@dxos/app-graph';
10
+ import { AppCapabilities } from '@dxos/app-toolkit';
10
11
 
11
12
  // TODO(wittjosiah): Remove or restore graph caching.
12
13
  // import { meta } from './meta';
13
14
 
14
- // const KEY = `${meta.id}/app-graph`;
15
+ // const KEY = `${meta.id}.app-graph`;
15
16
 
16
17
  export default Capability.makeModule(
17
18
  Effect.fnUntraced(function* () {
18
- const registry = yield* Capability.get(Common.Capability.AtomRegistry);
19
- const extensionsAtom = yield* Capability.atom(Common.Capability.AppGraphBuilder);
19
+ const registry = yield* Capability.get(Capabilities.AtomRegistry);
20
+ const extensionsAtom = yield* Capability.atom(AppCapabilities.AppGraphBuilder);
20
21
 
21
22
  const builder = GraphBuilder.from(/* localStorage.getItem(KEY) ?? */ undefined, registry);
22
23
  // const interval = setInterval(() => {
@@ -36,12 +37,12 @@ export default Capability.makeModule(
36
37
  );
37
38
 
38
39
  // await builder.initialize();
39
- void Graph.expand(builder.graph, Node.RootId);
40
+ void Graph.expand(builder.graph, Node.RootId, 'child');
40
41
 
41
42
  setupDevtools(builder.graph);
42
43
 
43
44
  return Capability.contributes(
44
- Common.Capability.AppGraph,
45
+ AppCapabilities.AppGraph,
45
46
  { graph: builder.graph, explore: GraphBuilder.explore },
46
47
  () =>
47
48
  Effect.sync(() => {
@@ -4,7 +4,7 @@
4
4
 
5
5
  import { useCallback } from 'react';
6
6
 
7
- import { useOperationInvoker, usePluginManager } from '@dxos/app-framework/react';
7
+ import { useOperationInvoker, usePluginManager } from '@dxos/app-framework/ui';
8
8
  import { type Node } from '@dxos/app-graph';
9
9
 
10
10
  import { runAction } from '../action';
@@ -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.
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/graph.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport * as Record from 'effect/Record';\n\nimport { Capability, Common } from '@dxos/app-framework';\nimport { Graph, GraphBuilder, Node } from '@dxos/app-graph';\n\n// TODO(wittjosiah): Remove or restore graph caching.\n// import { meta } from './meta';\n\n// const KEY = `${meta.id}/app-graph`;\n\nexport default Capability.makeModule(\n Effect.fnUntraced(function* () {\n const registry = yield* Capability.get(Common.Capability.AtomRegistry);\n const extensionsAtom = yield* Capability.atom(Common.Capability.AppGraphBuilder);\n\n const builder = GraphBuilder.from(/* localStorage.getItem(KEY) ?? */ undefined, registry);\n // const interval = setInterval(() => {\n // localStorage.setItem(KEY, builder.graph.pickle());\n // }, 5_000);\n\n const unsubscribe = registry.subscribe(\n extensionsAtom,\n (extensions) => {\n const next = GraphBuilder.flattenExtensions(extensions);\n const current = Record.values(registry.get(builder.extensions));\n const removed = current.filter(({ id }) => !next.some(({ id: nextId }) => nextId === id));\n removed.forEach((extension) => GraphBuilder.removeExtension(builder, extension.id));\n next.forEach((extension) => GraphBuilder.addExtension(builder, extension));\n },\n { immediate: true },\n );\n\n // await builder.initialize();\n void Graph.expand(builder.graph, Node.RootId);\n\n setupDevtools(builder.graph);\n\n return Capability.contributes(\n Common.Capability.AppGraph,\n { graph: builder.graph, explore: GraphBuilder.explore },\n () =>\n Effect.sync(() => {\n // clearInterval(interval);\n unsubscribe();\n }),\n );\n }),\n);\n\n// Expose the graph to the window for debugging.\nconst setupDevtools = (graph: Graph.ExpandableGraph) => {\n (globalThis as any).composer ??= {};\n (globalThis as any).composer.graph = graph;\n};\n"],
5
- "mappings": ";AAIA,YAAYA,YAAY;AACxB,YAAYC,YAAY;AAExB,SAASC,YAAYC,cAAc;AACnC,SAASC,OAAOC,cAAcC,YAAY;AAO1C,IAAA,gBAAeC,WAAWC,WACjBC,kBAAW,aAAA;AAChB,QAAMC,WAAW,OAAOH,WAAWI,IAAIC,OAAOL,WAAWM,YAAY;AACrE,QAAMC,iBAAiB,OAAOP,WAAWQ,KAAKH,OAAOL,WAAWS,eAAe;AAE/E,QAAMC,UAAUC,aAAaC;;IAAwCC;IAAWV;EAAAA;AAKhF,QAAMW,cAAcX,SAASY,UAC3BR,gBACA,CAACS,eAAAA;AACC,UAAMC,OAAON,aAAaO,kBAAkBF,UAAAA;AAC5C,UAAMG,UAAiBC,cAAOjB,SAASC,IAAIM,QAAQM,UAAU,CAAA;AAC7D,UAAMK,UAAUF,QAAQG,OAAO,CAAC,EAAEC,GAAE,MAAO,CAACN,KAAKO,KAAK,CAAC,EAAED,IAAIE,OAAM,MAAOA,WAAWF,EAAAA,CAAAA;AACrFF,YAAQK,QAAQ,CAACC,cAAchB,aAAaiB,gBAAgBlB,SAASiB,UAAUJ,EAAE,CAAA;AACjFN,SAAKS,QAAQ,CAACC,cAAchB,aAAakB,aAAanB,SAASiB,SAAAA,CAAAA;EACjE,GACA;IAAEG,WAAW;EAAK,CAAA;AAIpB,OAAKC,MAAMC,OAAOtB,QAAQuB,OAAOC,KAAKC,MAAM;AAE5CC,gBAAc1B,QAAQuB,KAAK;AAE3B,SAAOjC,WAAWqC,YAChBhC,OAAOL,WAAWsC,UAClB;IAAEL,OAAOvB,QAAQuB;IAAOM,SAAS5B,aAAa4B;EAAQ,GACtD,MACSC,YAAK,MAAA;AAEV1B,gBAAAA;EACF,CAAA,CAAA;AAEN,CAAA,CAAA;AAIF,IAAMsB,gBAAgB,CAACH,UAAAA;AACpBQ,aAAmBC,aAAa,CAAC;AACjCD,aAAmBC,SAAST,QAAQA;AACvC;",
6
- "names": ["Effect", "Record", "Capability", "Common", "Graph", "GraphBuilder", "Node", "Capability", "makeModule", "fnUntraced", "registry", "get", "Common", "AtomRegistry", "extensionsAtom", "atom", "AppGraphBuilder", "builder", "GraphBuilder", "from", "undefined", "unsubscribe", "subscribe", "extensions", "next", "flattenExtensions", "current", "values", "removed", "filter", "id", "some", "nextId", "forEach", "extension", "removeExtension", "addExtension", "immediate", "Graph", "expand", "graph", "Node", "RootId", "setupDevtools", "contributes", "AppGraph", "explore", "sync", "globalThis", "composer"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/graph.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport * as Record from 'effect/Record';\n\nimport { Capability, Common } from '@dxos/app-framework';\nimport { Graph, GraphBuilder, Node } from '@dxos/app-graph';\n\n// TODO(wittjosiah): Remove or restore graph caching.\n// import { meta } from './meta';\n\n// const KEY = `${meta.id}/app-graph`;\n\nexport default Capability.makeModule(\n Effect.fnUntraced(function* () {\n const registry = yield* Capability.get(Common.Capability.AtomRegistry);\n const extensionsAtom = yield* Capability.atom(Common.Capability.AppGraphBuilder);\n\n const builder = GraphBuilder.from(/* localStorage.getItem(KEY) ?? */ undefined, registry);\n // const interval = setInterval(() => {\n // localStorage.setItem(KEY, builder.graph.pickle());\n // }, 5_000);\n\n const unsubscribe = registry.subscribe(\n extensionsAtom,\n (extensions) => {\n const next = GraphBuilder.flattenExtensions(extensions);\n const current = Record.values(registry.get(builder.extensions));\n const removed = current.filter(({ id }) => !next.some(({ id: nextId }) => nextId === id));\n removed.forEach((extension) => GraphBuilder.removeExtension(builder, extension.id));\n next.forEach((extension) => GraphBuilder.addExtension(builder, extension));\n },\n { immediate: true },\n );\n\n // await builder.initialize();\n void Graph.expand(builder.graph, Node.RootId);\n\n setupDevtools(builder.graph);\n\n return Capability.contributes(\n Common.Capability.AppGraph,\n { graph: builder.graph, explore: GraphBuilder.explore },\n () =>\n Effect.sync(() => {\n // clearInterval(interval);\n unsubscribe();\n }),\n );\n }),\n);\n\n// Expose the graph to the window for debugging.\nconst setupDevtools = (graph: Graph.ExpandableGraph) => {\n (globalThis as any).composer ??= {};\n (globalThis as any).composer.graph = graph;\n};\n"],
5
- "mappings": ";;;AAIA,YAAYA,YAAY;AACxB,YAAYC,YAAY;AAExB,SAASC,YAAYC,cAAc;AACnC,SAASC,OAAOC,cAAcC,YAAY;AAO1C,IAAA,gBAAeC,WAAWC,WACjBC,kBAAW,aAAA;AAChB,QAAMC,WAAW,OAAOH,WAAWI,IAAIC,OAAOL,WAAWM,YAAY;AACrE,QAAMC,iBAAiB,OAAOP,WAAWQ,KAAKH,OAAOL,WAAWS,eAAe;AAE/E,QAAMC,UAAUC,aAAaC;;IAAwCC;IAAWV;EAAAA;AAKhF,QAAMW,cAAcX,SAASY,UAC3BR,gBACA,CAACS,eAAAA;AACC,UAAMC,OAAON,aAAaO,kBAAkBF,UAAAA;AAC5C,UAAMG,UAAiBC,cAAOjB,SAASC,IAAIM,QAAQM,UAAU,CAAA;AAC7D,UAAMK,UAAUF,QAAQG,OAAO,CAAC,EAAEC,GAAE,MAAO,CAACN,KAAKO,KAAK,CAAC,EAAED,IAAIE,OAAM,MAAOA,WAAWF,EAAAA,CAAAA;AACrFF,YAAQK,QAAQ,CAACC,cAAchB,aAAaiB,gBAAgBlB,SAASiB,UAAUJ,EAAE,CAAA;AACjFN,SAAKS,QAAQ,CAACC,cAAchB,aAAakB,aAAanB,SAASiB,SAAAA,CAAAA;EACjE,GACA;IAAEG,WAAW;EAAK,CAAA;AAIpB,OAAKC,MAAMC,OAAOtB,QAAQuB,OAAOC,KAAKC,MAAM;AAE5CC,gBAAc1B,QAAQuB,KAAK;AAE3B,SAAOjC,WAAWqC,YAChBhC,OAAOL,WAAWsC,UAClB;IAAEL,OAAOvB,QAAQuB;IAAOM,SAAS5B,aAAa4B;EAAQ,GACtD,MACSC,YAAK,MAAA;AAEV1B,gBAAAA;EACF,CAAA,CAAA;AAEN,CAAA,CAAA;AAIF,IAAMsB,gBAAgB,CAACH,UAAAA;AACpBQ,aAAmBC,aAAa,CAAC;AACjCD,aAAmBC,SAAST,QAAQA;AACvC;",
6
- "names": ["Effect", "Record", "Capability", "Common", "Graph", "GraphBuilder", "Node", "Capability", "makeModule", "fnUntraced", "registry", "get", "Common", "AtomRegistry", "extensionsAtom", "atom", "AppGraphBuilder", "builder", "GraphBuilder", "from", "undefined", "unsubscribe", "subscribe", "extensions", "next", "flattenExtensions", "current", "values", "removed", "filter", "id", "some", "nextId", "forEach", "extension", "removeExtension", "addExtension", "immediate", "Graph", "expand", "graph", "Node", "RootId", "setupDevtools", "contributes", "AppGraph", "explore", "sync", "globalThis", "composer"]
7
- }