@dxos/plugin-graph 0.8.4-main.e098934 → 0.8.4-main.e8ec1fe
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/{graph-UW77N6TF.mjs → graph-FFQ77VLS.mjs} +6 -7
- package/dist/lib/browser/graph-FFQ77VLS.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +14 -11
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/{graph-UIVRXZE6.mjs → graph-7GDCGF7M.mjs} +6 -7
- package/dist/lib/node-esm/graph-7GDCGF7M.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +14 -11
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/GraphPlugin.d.ts +1 -1
- package/dist/types/src/GraphPlugin.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +0 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +19 -18
- package/src/GraphPlugin.ts +9 -10
- package/src/graph.ts +4 -4
- package/src/hooks/useNode.ts +5 -5
- package/src/meta.ts +6 -3
- package/dist/lib/browser/graph-UW77N6TF.mjs.map +0 -7
- package/dist/lib/node-esm/graph-UIVRXZE6.mjs.map +0 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-graph",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.e8ec1fe",
|
|
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",
|
|
@@ -26,29 +26,30 @@
|
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@preact-signals/safe-react": "^0.9.0",
|
|
29
|
-
"@dxos/app-framework": "0.8.4-main.
|
|
30
|
-
"@dxos/
|
|
31
|
-
"@dxos/
|
|
32
|
-
"@dxos/debug": "0.8.4-main.
|
|
29
|
+
"@dxos/app-framework": "0.8.4-main.e8ec1fe",
|
|
30
|
+
"@dxos/app-graph": "0.8.4-main.e8ec1fe",
|
|
31
|
+
"@dxos/async": "0.8.4-main.e8ec1fe",
|
|
32
|
+
"@dxos/debug": "0.8.4-main.e8ec1fe",
|
|
33
|
+
"@dxos/util": "0.8.4-main.e8ec1fe"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
|
-
"@effect-
|
|
36
|
-
"@effect/platform": "0.
|
|
37
|
-
"@types/react": "~
|
|
38
|
-
"@types/react-dom": "~
|
|
39
|
-
"effect": "3.
|
|
40
|
-
"react": "~
|
|
41
|
-
"react-dom": "~
|
|
42
|
-
"vite": "7.1.
|
|
43
|
-
"@dxos/react-client": "0.8.4-main.
|
|
44
|
-
"@dxos/storybook-utils": "0.8.4-main.
|
|
36
|
+
"@effect-atom/atom-react": "^0.3.4",
|
|
37
|
+
"@effect/platform": "0.92.1",
|
|
38
|
+
"@types/react": "~19.2.2",
|
|
39
|
+
"@types/react-dom": "~19.2.2",
|
|
40
|
+
"effect": "3.18.3",
|
|
41
|
+
"react": "~19.2.0",
|
|
42
|
+
"react-dom": "~19.2.0",
|
|
43
|
+
"vite": "7.1.9",
|
|
44
|
+
"@dxos/react-client": "0.8.4-main.e8ec1fe",
|
|
45
|
+
"@dxos/storybook-utils": "0.8.4-main.e8ec1fe"
|
|
45
46
|
},
|
|
46
47
|
"peerDependencies": {
|
|
47
|
-
"@effect-
|
|
48
|
+
"@effect-atom/atom-react": "^0.3.4",
|
|
48
49
|
"@effect/platform": "^0.80.12",
|
|
49
50
|
"effect": "^3.13.3",
|
|
50
|
-
"react": "
|
|
51
|
-
"react-dom": "
|
|
51
|
+
"react": "^19.0.0",
|
|
52
|
+
"react-dom": "^19.0.0"
|
|
52
53
|
},
|
|
53
54
|
"publishConfig": {
|
|
54
55
|
"access": "public"
|
package/src/GraphPlugin.ts
CHANGED
|
@@ -11,13 +11,12 @@ import { meta } from './meta';
|
|
|
11
11
|
* Enables other plugins to register node builders to add nodes to the graph.
|
|
12
12
|
* This includes actions and annotation each other's nodes.
|
|
13
13
|
*/
|
|
14
|
-
export const GraphPlugin = () =>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
]);
|
|
14
|
+
export const GraphPlugin = definePlugin(meta, () => [
|
|
15
|
+
defineModule({
|
|
16
|
+
id: `${meta.id}/module/graph`,
|
|
17
|
+
activatesOn: Events.Startup,
|
|
18
|
+
activatesBefore: [Events.SetupAppGraph, Events.SetupMetadata],
|
|
19
|
+
activatesAfter: [Events.AppGraphReady],
|
|
20
|
+
activate: lazy(() => import('./graph')),
|
|
21
|
+
}),
|
|
22
|
+
]);
|
package/src/graph.ts
CHANGED
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Record from 'effect/Record';
|
|
6
6
|
|
|
7
7
|
import { Capabilities, type PluginContext, contributes } from '@dxos/app-framework';
|
|
8
8
|
import { type ExpandableGraph, GraphBuilder, ROOT_ID, flattenExtensions } from '@dxos/app-graph';
|
|
9
9
|
|
|
10
10
|
// TODO(wittjosiah): Remove or restore graph caching.
|
|
11
|
-
// import {
|
|
11
|
+
// import { meta } from './meta';
|
|
12
12
|
|
|
13
|
-
// const KEY = `${
|
|
13
|
+
// const KEY = `${meta.id}/app-graph`;
|
|
14
14
|
|
|
15
15
|
export default async (context: PluginContext) => {
|
|
16
|
-
const registry = context.getCapability(Capabilities.
|
|
16
|
+
const registry = context.getCapability(Capabilities.AtomRegistry);
|
|
17
17
|
const builder = GraphBuilder.from(/* localStorage.getItem(KEY) ?? */ undefined, registry);
|
|
18
18
|
// const interval = setInterval(() => {
|
|
19
19
|
// localStorage.setItem(KEY, builder.graph.pickle());
|
package/src/hooks/useNode.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
5
|
+
import { useAtomValue } from '@effect-atom/atom-react';
|
|
6
|
+
import * as Option from 'effect/Option';
|
|
7
7
|
|
|
8
8
|
import { type Node, type ReadableGraph, type Relation } from '@dxos/app-graph';
|
|
9
9
|
|
|
@@ -17,13 +17,13 @@ import { type Node, type ReadableGraph, type Relation } from '@dxos/app-graph';
|
|
|
17
17
|
*/
|
|
18
18
|
// TODO(wittjosiah): Factor out to @dxos/app-graph/react.
|
|
19
19
|
export const useNode = <T = any>(graph: ReadableGraph, id?: string): Node<T> | undefined => {
|
|
20
|
-
return Option.getOrElse(
|
|
20
|
+
return Option.getOrElse(useAtomValue(graph.node(id ?? '')), () => undefined);
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
export const useConnections = (graph: ReadableGraph, id?: string, relation?: Relation): Node[] => {
|
|
24
|
-
return
|
|
24
|
+
return useAtomValue(graph.connections(id ?? '', relation));
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
export const useActions = (graph: ReadableGraph, id?: string): Node[] => {
|
|
28
|
-
return
|
|
28
|
+
return useAtomValue(graph.actions(id ?? ''));
|
|
29
29
|
};
|
package/src/meta.ts
CHANGED
|
@@ -3,10 +3,13 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type PluginMeta } from '@dxos/app-framework';
|
|
6
|
-
|
|
7
|
-
export const GRAPH_PLUGIN = 'dxos.org/plugin/graph';
|
|
6
|
+
import { trim } from '@dxos/util';
|
|
8
7
|
|
|
9
8
|
export const meta: PluginMeta = {
|
|
10
|
-
id:
|
|
9
|
+
id: 'dxos.org/plugin/graph',
|
|
11
10
|
name: 'Graph',
|
|
11
|
+
description: trim`
|
|
12
|
+
Graph database layer providing relationship modeling and queries for workspace objects.
|
|
13
|
+
Build knowledge graphs and explore complex data relationships.
|
|
14
|
+
`,
|
|
12
15
|
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/graph.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Record } from 'effect';\n\nimport { Capabilities, type PluginContext, contributes } from '@dxos/app-framework';\nimport { type ExpandableGraph, GraphBuilder, ROOT_ID, flattenExtensions } from '@dxos/app-graph';\n\n// TODO(wittjosiah): Remove or restore graph caching.\n// import { GRAPH_PLUGIN } from './meta';\n\n// const KEY = `${GRAPH_PLUGIN}/app-graph`;\n\nexport default async (context: PluginContext) => {\n const registry = context.getCapability(Capabilities.RxRegistry);\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 context.capabilities(Capabilities.AppGraphBuilder),\n (extensions) => {\n const next = 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) => builder.removeExtension(extension.id));\n next.forEach((extension) => builder.addExtension(extension));\n },\n { immediate: true },\n );\n\n // await builder.initialize();\n void builder.graph.expand(ROOT_ID);\n\n setupDevtools(builder.graph);\n\n return contributes(Capabilities.AppGraph, { graph: builder.graph, explore: builder.explore }, () => {\n // clearInterval(interval);\n unsubscribe();\n });\n};\n\n// Expose the graph to the window for debugging.\nconst setupDevtools = (graph: ExpandableGraph) => {\n (globalThis as any).composer ??= {};\n (globalThis as any).composer.graph = graph;\n};\n"],
|
|
5
|
-
"mappings": ";AAIA,SAASA,cAAc;AAEvB,SAASC,cAAkCC,mBAAmB;AAC9D,SAA+BC,cAAcC,SAASC,yBAAyB;AAO/E,IAAA,gBAAe,OAAOC,YAAAA;AACpB,QAAMC,WAAWD,QAAQE,cAAcC,aAAaC,UAAU;AAC9D,QAAMC,UAAUC,aAAaC;;IAAwCC;IAAWP;EAAAA;AAKhF,QAAMQ,cAAcR,SAASS,UAC3BV,QAAQW,aAAaR,aAAaS,eAAe,GACjD,CAACC,eAAAA;AACC,UAAMC,OAAOC,kBAAkBF,UAAAA;AAC/B,UAAMG,UAAUC,OAAOC,OAAOjB,SAASkB,IAAId,QAAQQ,UAAU,CAAA;AAC7D,UAAMO,UAAUJ,QAAQK,OAAO,CAAC,EAAEC,GAAE,MAAO,CAACR,KAAKS,KAAK,CAAC,EAAED,IAAIE,OAAM,MAAOA,WAAWF,EAAAA,CAAAA;AACrFF,YAAQK,QAAQ,CAACC,cAAcrB,QAAQsB,gBAAgBD,UAAUJ,EAAE,CAAA;AACnER,SAAKW,QAAQ,CAACC,cAAcrB,QAAQuB,aAAaF,SAAAA,CAAAA;EACnD,GACA;IAAEG,WAAW;EAAK,CAAA;AAIpB,OAAKxB,QAAQyB,MAAMC,OAAOC,OAAAA;AAE1BC,gBAAc5B,QAAQyB,KAAK;AAE3B,SAAOI,YAAY/B,aAAagC,UAAU;IAAEL,OAAOzB,QAAQyB;IAAOM,SAAS/B,QAAQ+B;EAAQ,GAAG,MAAA;AAE5F3B,gBAAAA;EACF,CAAA;AACF;AAGA,IAAMwB,gBAAgB,CAACH,UAAAA;MACpBO;AAAD,GAACA,cAAAA,YAAmBC,aAAnBD,YAAmBC,WAAa,CAAC;AACjCD,aAAmBC,SAASR,QAAQA;AACvC;",
|
|
6
|
-
"names": ["Record", "Capabilities", "contributes", "GraphBuilder", "ROOT_ID", "flattenExtensions", "context", "registry", "getCapability", "Capabilities", "RxRegistry", "builder", "GraphBuilder", "from", "undefined", "unsubscribe", "subscribe", "capabilities", "AppGraphBuilder", "extensions", "next", "flattenExtensions", "current", "Record", "values", "get", "removed", "filter", "id", "some", "nextId", "forEach", "extension", "removeExtension", "addExtension", "immediate", "graph", "expand", "ROOT_ID", "setupDevtools", "contributes", "AppGraph", "explore", "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 { Record } from 'effect';\n\nimport { Capabilities, type PluginContext, contributes } from '@dxos/app-framework';\nimport { type ExpandableGraph, GraphBuilder, ROOT_ID, flattenExtensions } from '@dxos/app-graph';\n\n// TODO(wittjosiah): Remove or restore graph caching.\n// import { GRAPH_PLUGIN } from './meta';\n\n// const KEY = `${GRAPH_PLUGIN}/app-graph`;\n\nexport default async (context: PluginContext) => {\n const registry = context.getCapability(Capabilities.RxRegistry);\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 context.capabilities(Capabilities.AppGraphBuilder),\n (extensions) => {\n const next = 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) => builder.removeExtension(extension.id));\n next.forEach((extension) => builder.addExtension(extension));\n },\n { immediate: true },\n );\n\n // await builder.initialize();\n void builder.graph.expand(ROOT_ID);\n\n setupDevtools(builder.graph);\n\n return contributes(Capabilities.AppGraph, { graph: builder.graph, explore: builder.explore }, () => {\n // clearInterval(interval);\n unsubscribe();\n });\n};\n\n// Expose the graph to the window for debugging.\nconst setupDevtools = (graph: ExpandableGraph) => {\n (globalThis as any).composer ??= {};\n (globalThis as any).composer.graph = graph;\n};\n"],
|
|
5
|
-
"mappings": ";;;AAIA,SAASA,cAAc;AAEvB,SAASC,cAAkCC,mBAAmB;AAC9D,SAA+BC,cAAcC,SAASC,yBAAyB;AAO/E,IAAA,gBAAe,OAAOC,YAAAA;AACpB,QAAMC,WAAWD,QAAQE,cAAcC,aAAaC,UAAU;AAC9D,QAAMC,UAAUC,aAAaC;;IAAwCC;IAAWP;EAAAA;AAKhF,QAAMQ,cAAcR,SAASS,UAC3BV,QAAQW,aAAaR,aAAaS,eAAe,GACjD,CAACC,eAAAA;AACC,UAAMC,OAAOC,kBAAkBF,UAAAA;AAC/B,UAAMG,UAAUC,OAAOC,OAAOjB,SAASkB,IAAId,QAAQQ,UAAU,CAAA;AAC7D,UAAMO,UAAUJ,QAAQK,OAAO,CAAC,EAAEC,GAAE,MAAO,CAACR,KAAKS,KAAK,CAAC,EAAED,IAAIE,OAAM,MAAOA,WAAWF,EAAAA,CAAAA;AACrFF,YAAQK,QAAQ,CAACC,cAAcrB,QAAQsB,gBAAgBD,UAAUJ,EAAE,CAAA;AACnER,SAAKW,QAAQ,CAACC,cAAcrB,QAAQuB,aAAaF,SAAAA,CAAAA;EACnD,GACA;IAAEG,WAAW;EAAK,CAAA;AAIpB,OAAKxB,QAAQyB,MAAMC,OAAOC,OAAAA;AAE1BC,gBAAc5B,QAAQyB,KAAK;AAE3B,SAAOI,YAAY/B,aAAagC,UAAU;IAAEL,OAAOzB,QAAQyB;IAAOM,SAAS/B,QAAQ+B;EAAQ,GAAG,MAAA;AAE5F3B,gBAAAA;EACF,CAAA;AACF;AAGA,IAAMwB,gBAAgB,CAACH,UAAAA;MACpBO;AAAD,GAACA,cAAAA,YAAmBC,aAAnBD,YAAmBC,WAAa,CAAC;AACjCD,aAAmBC,SAASR,QAAQA;AACvC;",
|
|
6
|
-
"names": ["Record", "Capabilities", "contributes", "GraphBuilder", "ROOT_ID", "flattenExtensions", "context", "registry", "getCapability", "Capabilities", "RxRegistry", "builder", "GraphBuilder", "from", "undefined", "unsubscribe", "subscribe", "capabilities", "AppGraphBuilder", "extensions", "next", "flattenExtensions", "current", "Record", "values", "get", "removed", "filter", "id", "some", "nextId", "forEach", "extension", "removeExtension", "addExtension", "immediate", "graph", "expand", "ROOT_ID", "setupDevtools", "contributes", "AppGraph", "explore", "globalThis", "composer"]
|
|
7
|
-
}
|