@dxos/plugin-graph 0.10.0 → 0.11.0
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/GraphPlugin.mjs +20 -0
- package/dist/lib/GraphPlugin.mjs.map +1 -0
- package/dist/lib/chunk-action.mjs +18 -0
- package/dist/lib/chunk-action.mjs.map +1 -0
- package/dist/lib/chunk-graph.mjs +36 -0
- package/dist/lib/chunk-graph.mjs.map +1 -0
- package/dist/lib/{neutral/chunk-PC3NGG7Y.mjs → chunk-meta.mjs} +13 -20
- package/dist/lib/chunk-meta.mjs.map +1 -0
- package/dist/lib/hooks.mjs +56 -0
- package/dist/lib/hooks.mjs.map +1 -0
- package/dist/lib/index.mjs +4 -0
- package/dist/lib/meta.mjs +2 -0
- package/dist/lib/plugin.mjs +8 -0
- package/dist/lib/plugin.mjs.map +1 -0
- package/dist/lib/testing.mjs +2 -0
- package/dist/types/src/graph.d.ts +1 -1
- package/dist/types/src/hooks/index.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/tsconfig.tsbuildinfo +1 -1
- package/package.json +23 -18
- package/src/graph.ts +16 -11
- package/src/hooks/index.ts +3 -0
- package/src/index.ts +0 -3
- package/dist/lib/neutral/GraphPlugin.mjs +0 -9
- package/dist/lib/neutral/GraphPlugin.mjs.map +0 -7
- package/dist/lib/neutral/chunk-PC3NGG7Y.mjs.map +0 -7
- package/dist/lib/neutral/chunk-S2DLYPRU.mjs +0 -22
- package/dist/lib/neutral/chunk-S2DLYPRU.mjs.map +0 -7
- package/dist/lib/neutral/chunk-UED6UYDB.mjs +0 -60
- package/dist/lib/neutral/chunk-UED6UYDB.mjs.map +0 -7
- package/dist/lib/neutral/graph-RCKCHDM6.mjs +0 -48
- package/dist/lib/neutral/graph-RCKCHDM6.mjs.map +0 -7
- package/dist/lib/neutral/hooks/index.mjs +0 -15
- package/dist/lib/neutral/hooks/index.mjs.map +0 -7
- package/dist/lib/neutral/index.mjs +0 -24
- package/dist/lib/neutral/index.mjs.map +0 -7
- package/dist/lib/neutral/meta.json +0 -1
- package/dist/lib/neutral/meta.mjs +0 -7
- package/dist/lib/neutral/meta.mjs.map +0 -7
- package/dist/lib/neutral/plugin.mjs +0 -11
- package/dist/lib/neutral/plugin.mjs.map +0 -7
- package/dist/lib/neutral/testing.mjs +0 -7
- package/dist/lib/neutral/testing.mjs.map +0 -7
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ActivationEvents, Capability, Plugin } from "@dxos/app-framework";
|
|
2
|
+
import { AppActivationEvents } from "@dxos/app-toolkit";
|
|
3
|
+
import { meta } from "#meta";
|
|
4
|
+
//#region src/GraphPlugin.ts
|
|
5
|
+
var Graph = Capability.lazy("Graph", () => import("./chunk-graph.mjs"));
|
|
6
|
+
/**
|
|
7
|
+
* Manages the state of the graph for the application.
|
|
8
|
+
* Enables other plugins to register node builders to add nodes to the graph.
|
|
9
|
+
* This includes actions and annotation each other's nodes.
|
|
10
|
+
*/
|
|
11
|
+
var GraphPlugin = Plugin.define(meta).pipe(Plugin.addModule({
|
|
12
|
+
activatesOn: ActivationEvents.Startup,
|
|
13
|
+
firesBeforeActivation: [AppActivationEvents.SetupAppGraph],
|
|
14
|
+
firesAfterActivation: [AppActivationEvents.AppGraphReady],
|
|
15
|
+
activate: Graph
|
|
16
|
+
}), Plugin.make);
|
|
17
|
+
//#endregion
|
|
18
|
+
export { GraphPlugin, GraphPlugin as default };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=GraphPlugin.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GraphPlugin.mjs","names":[],"sources":["../../src/GraphPlugin.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport { ActivationEvents, Capability, Plugin } from '@dxos/app-framework';\nimport { AppActivationEvents } from '@dxos/app-toolkit';\n\nimport { meta } from '#meta';\n\nconst Graph = Capability.lazy('Graph', () => import('./graph'));\n\n/**\n * Manages the state of the graph for the application.\n * Enables other plugins to register node builders to add nodes to the graph.\n * This includes actions and annotation each other's nodes.\n */\nexport const GraphPlugin = Plugin.define(meta).pipe(\n Plugin.addModule({\n activatesOn: ActivationEvents.Startup,\n firesBeforeActivation: [AppActivationEvents.SetupAppGraph],\n firesAfterActivation: [AppActivationEvents.AppGraphReady],\n activate: Graph,\n }),\n Plugin.make,\n);\n\nexport default GraphPlugin;\n"],"mappings":";;;;AASA,IAAM,QAAQ,WAAW,KAAK,eAAe,OAAO,oBAAU;;;;;;AAO9D,IAAa,cAAc,OAAO,OAAO,IAAI,CAAC,CAAC,KAC7C,OAAO,UAAU;CACf,aAAa,iBAAiB;CAC9B,uBAAuB,CAAC,oBAAoB,aAAa;CACzD,sBAAsB,CAAC,oBAAoB,aAAa;CACxD,UAAU;AACZ,CAAC,GACD,OAAO,IACT"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Capability } from "@dxos/app-framework";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Function from "effect/Function";
|
|
4
|
+
import { Operation } from "@dxos/compute";
|
|
5
|
+
import { EffectEx } from "@dxos/effect";
|
|
6
|
+
//#region src/action.ts
|
|
7
|
+
/**
|
|
8
|
+
* Run an action with required layers: Operation.Service, Capability.Service, and captured context.
|
|
9
|
+
* @param invoker The operation invoker to use for Operation.Service.
|
|
10
|
+
* @param capabilityManager The capability manager for Capability.Service.
|
|
11
|
+
* @param action The action to execute.
|
|
12
|
+
* @param params Parameters to pass to the action.
|
|
13
|
+
*/
|
|
14
|
+
var runAction = async (invoker, capabilityManager, action, params = {}) => EffectEx.runAndForwardErrors(action.data(params).pipe(Effect.provideService(Operation.Service, invoker), Effect.provideService(Capability.Service, capabilityManager), action._actionContext ? Effect.provide(action._actionContext) : Function.identity));
|
|
15
|
+
//#endregion
|
|
16
|
+
export { runAction as t };
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=chunk-action.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-action.mjs","names":[],"sources":["../../src/action.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport * as Function from 'effect/Function';\n\nimport { Capability, type CapabilityManager } from '@dxos/app-framework';\nimport { type Node } from '@dxos/app-graph';\nimport { Operation } from '@dxos/compute';\nimport { EffectEx } from '@dxos/effect';\n\n/**\n * Run an action with required layers: Operation.Service, Capability.Service, and captured context.\n * @param invoker The operation invoker to use for Operation.Service.\n * @param capabilityManager The capability manager for Capability.Service.\n * @param action The action to execute.\n * @param params Parameters to pass to the action.\n */\nexport const runAction = async (\n invoker: Operation.OperationService,\n capabilityManager: CapabilityManager.CapabilityManager,\n action: Node.Action,\n params: Node.InvokeProps = {},\n): Promise<void> =>\n EffectEx.runAndForwardErrors(\n action\n .data(params)\n .pipe(\n Effect.provideService(Operation.Service, invoker),\n Effect.provideService(Capability.Service, capabilityManager),\n action._actionContext ? Effect.provide(action._actionContext) : Function.identity,\n ),\n );\n"],"mappings":";;;;;;;;;;;;;AAmBA,IAAa,YAAY,OACvB,SACA,mBACA,QACA,SAA2B,CAAC,MAE5B,SAAS,oBACP,OACG,KAAK,MAAM,CAAA,CACX,KACC,OAAO,eAAe,UAAU,SAAS,OAAO,GAChD,OAAO,eAAe,WAAW,SAAS,iBAAiB,GAC3D,OAAO,iBAAiB,OAAO,QAAQ,OAAO,cAAc,IAAI,SAAS,QAC3E,CACJ"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Capabilities, Capability } from "@dxos/app-framework";
|
|
2
|
+
import { Graph, GraphBuilder, Node } from "@dxos/app-graph";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import { AppCapabilities, UrlPath } from "@dxos/app-toolkit";
|
|
5
|
+
import * as Record from "effect/Record";
|
|
6
|
+
//#region src/graph.ts
|
|
7
|
+
var graph_default = Capability.makeModule(Effect.fnUntraced(function* () {
|
|
8
|
+
const registry = yield* Capability.get(Capabilities.AtomRegistry);
|
|
9
|
+
const extensionsByModuleAtom = yield* Capability.atomByModule(AppCapabilities.AppGraphBuilder);
|
|
10
|
+
const builder = GraphBuilder.from(void 0, registry, {
|
|
11
|
+
anchorKey: UrlPath.WORKSPACE_KEY,
|
|
12
|
+
linkedKey: UrlPath.COMPANION_KEY
|
|
13
|
+
});
|
|
14
|
+
const unsubscribe = registry.subscribe(extensionsByModuleAtom, (extensionsByModule) => {
|
|
15
|
+
const next = [];
|
|
16
|
+
for (const [moduleId, extensions] of Object.entries(extensionsByModule)) for (const ext of GraphBuilder.flattenExtensions(extensions)) next.push({
|
|
17
|
+
...ext,
|
|
18
|
+
id: `${moduleId}.${ext.id}`
|
|
19
|
+
});
|
|
20
|
+
Record.values(registry.get(builder.extensions)).filter(({ id }) => !next.some(({ id: nextId }) => nextId === id)).forEach((extension) => GraphBuilder.removeExtension(builder, extension.id));
|
|
21
|
+
next.forEach((extension) => GraphBuilder.addExtension(builder, extension));
|
|
22
|
+
}, { immediate: true });
|
|
23
|
+
Graph.expand(builder.graph, Node.RootId, "child");
|
|
24
|
+
setupDevtools(builder.graph);
|
|
25
|
+
return Capability.contributes(AppCapabilities.AppGraph, builder, () => Effect.sync(() => {
|
|
26
|
+
unsubscribe();
|
|
27
|
+
}));
|
|
28
|
+
}));
|
|
29
|
+
var setupDevtools = (graph) => {
|
|
30
|
+
globalThis.composer ??= {};
|
|
31
|
+
globalThis.composer.graph = graph;
|
|
32
|
+
};
|
|
33
|
+
//#endregion
|
|
34
|
+
export { graph_default as default };
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=chunk-graph.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-graph.mjs","names":[],"sources":["../../src/graph.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport * as Record from 'effect/Record';\n\nimport { Capabilities, Capability } from '@dxos/app-framework';\nimport { Graph, GraphBuilder, Node } from '@dxos/app-graph';\nimport { AppCapabilities, UrlPath } from '@dxos/app-toolkit';\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(Capabilities.AtomRegistry);\n const extensionsByModuleAtom = yield* Capability.atomByModule(AppCapabilities.AppGraphBuilder);\n\n // The grammar's fixed tiers, configured here rather than declared by an extension: no connector\n // produces their nodes (see `GraphBuilder.UrlGrammar`).\n const builder = GraphBuilder.from(/* localStorage.getItem(KEY) ?? */ undefined, registry, {\n anchorKey: UrlPath.WORKSPACE_KEY,\n linkedKey: UrlPath.COMPANION_KEY,\n });\n // const interval = setInterval(() => {\n // localStorage.setItem(KEY, builder.graph.pickle());\n // }, 5_000);\n\n const unsubscribe = registry.subscribe(\n extensionsByModuleAtom,\n (extensionsByModule) => {\n const next: GraphBuilder.BuilderExtension[] = [];\n for (const [moduleId, extensions] of Object.entries(extensionsByModule)) {\n for (const ext of GraphBuilder.flattenExtensions(extensions)) {\n next.push({\n ...ext,\n id: `${moduleId}.${ext.id}`,\n });\n }\n }\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, 'child');\n\n setupDevtools(builder.graph);\n\n return Capability.contributes(AppCapabilities.AppGraph, builder, () =>\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"],"mappings":";;;;;;AAgBA,IAAA,gBAAe,WAAW,WACxB,OAAO,WAAW,aAAa;CAC7B,MAAM,WAAW,OAAO,WAAW,IAAI,aAAa,YAAY;CAChE,MAAM,yBAAyB,OAAO,WAAW,aAAa,gBAAgB,eAAe;CAI7F,MAAM,UAAU,aAAa,KAAwC,KAAA,GAAW,UAAU;EACxF,WAAW,QAAQ;EACnB,WAAW,QAAQ;CACrB,CAAC;CAKD,MAAM,cAAc,SAAS,UAC3B,yBACC,uBAAuB;EACtB,MAAM,OAAwC,CAAC;EAC/C,KAAK,MAAM,CAAC,UAAU,eAAe,OAAO,QAAQ,kBAAkB,GACpE,KAAK,MAAM,OAAO,aAAa,kBAAkB,UAAU,GACzD,KAAK,KAAK;GACR,GAAG;GACH,IAAI,GAAG,SAAS,GAAG,IAAI;EACzB,CAAC;EAKL,OAFuB,OAAO,SAAS,IAAI,QAAQ,UAAU,CAC7C,CAAA,CAAQ,QAAQ,EAAE,SAAS,CAAC,KAAK,MAAM,EAAE,IAAI,aAAa,WAAW,EAAE,CACvF,CAAA,CAAQ,SAAS,cAAc,aAAa,gBAAgB,SAAS,UAAU,EAAE,CAAC;EAClF,KAAK,SAAS,cAAc,aAAa,aAAa,SAAS,SAAS,CAAC;CAC3E,GACA,EAAE,WAAW,KAAK,CACpB;CAGA,MAAW,OAAO,QAAQ,OAAO,KAAK,QAAQ,OAAO;CAErD,cAAc,QAAQ,KAAK;CAE3B,OAAO,WAAW,YAAY,gBAAgB,UAAU,eACtD,OAAO,WAAW;EAEhB,YAAY;CACd,CAAC,CACH;AACF,CAAC,CACH;AAGA,IAAM,iBAAiB,UAAiC;CACtD,WAAoB,aAAa,CAAC;CAClC,WAAoB,SAAS,QAAQ;AACvC"}
|
|
@@ -1,28 +1,21 @@
|
|
|
1
|
-
// src/meta.ts
|
|
2
1
|
import { Plugin } from "@dxos/app-framework";
|
|
3
|
-
|
|
4
|
-
// dx.config.ts
|
|
5
2
|
import { Config2 } from "@dxos/app-framework/config";
|
|
6
3
|
import { trim } from "@dxos/util";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
//#region dx.config.ts
|
|
5
|
+
var dx_config_default = Config2.make({ plugin: {
|
|
6
|
+
key: "org.dxos.plugin.graph",
|
|
7
|
+
name: "Graph",
|
|
8
|
+
author: "DXOS",
|
|
9
|
+
description: trim`
|
|
13
10
|
Graph database layer providing relationship modeling and queries for workspace objects.
|
|
14
11
|
Build knowledge graphs and explore complex data relationships.
|
|
15
12
|
`,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
// src/meta.ts
|
|
13
|
+
tags: ["system"]
|
|
14
|
+
} });
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/meta.ts
|
|
23
17
|
var meta = Plugin.getMetaFromConfig(dx_config_default);
|
|
18
|
+
//#endregion
|
|
19
|
+
export { meta as t };
|
|
24
20
|
|
|
25
|
-
|
|
26
|
-
meta
|
|
27
|
-
};
|
|
28
|
-
//# sourceMappingURL=chunk-PC3NGG7Y.mjs.map
|
|
21
|
+
//# sourceMappingURL=chunk-meta.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-meta.mjs","names":[],"sources":["../../dx.config.ts","../../src/meta.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Config2 } from '@dxos/app-framework/config';\nimport { trim } from '@dxos/util';\n\nexport default Config2.make({\n plugin: {\n key: 'org.dxos.plugin.graph',\n name: 'Graph',\n author: 'DXOS',\n description: trim`\n Graph database layer providing relationship modeling and queries for workspace objects.\n Build knowledge graphs and explore complex data relationships.\n `,\n tags: ['system'],\n },\n});\n","//\n// Copyright 2023 DXOS.org\n//\n\nimport { Plugin } from '@dxos/app-framework';\n\nimport config from '../dx.config';\n\nexport const meta = Plugin.getMetaFromConfig(config);\n"],"mappings":";;;;AAOA,IAAA,oBAAe,QAAQ,KAAK,EAC1B,QAAQ;CACN,KAAK;CACL,MAAM;CACN,QAAQ;CACR,aAAa,IAAI;;;;CAIjB,MAAM,CAAC,QAAQ;AACjB,EACF,CAAC;;;ACVD,IAAa,OAAO,OAAO,kBAAkB,iBAAM"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { t as runAction } from "./chunk-action.mjs";
|
|
2
|
+
import { useCallback, useMemo } from "react";
|
|
3
|
+
import { useOperationInvoker, usePluginManager } from "@dxos/app-framework/ui";
|
|
4
|
+
import { useAtomValue } from "@effect-atom/atom-react";
|
|
5
|
+
import * as Option from "effect/Option";
|
|
6
|
+
//#region src/hooks/useActionRunner.ts
|
|
7
|
+
/**
|
|
8
|
+
* Hook that returns a function to run action Effects.
|
|
9
|
+
* Provides Operation.Service, PluginContextService, and captured plugin context.
|
|
10
|
+
*/
|
|
11
|
+
var useActionRunner = () => {
|
|
12
|
+
const invoker = useOperationInvoker();
|
|
13
|
+
const pluginManager = usePluginManager();
|
|
14
|
+
return useCallback((action, params = {}) => runAction(invoker, pluginManager.capabilities, action, params), [invoker, pluginManager.capabilities]);
|
|
15
|
+
};
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/hooks/useNode.ts
|
|
18
|
+
/**
|
|
19
|
+
* React hook to get a node from the graph.
|
|
20
|
+
*
|
|
21
|
+
* @param graph Graph to find the node in.
|
|
22
|
+
* @param id Id of the node to find.
|
|
23
|
+
* @param timeout Optional timeout in milliseconds to wait for the node to be found.
|
|
24
|
+
* @returns Node if found, undefined otherwise.
|
|
25
|
+
*/
|
|
26
|
+
var useNode = (graph, id) => {
|
|
27
|
+
const atom = useMemo(() => graph.node(id ?? ""), [graph, id]);
|
|
28
|
+
return Option.getOrElse(useAtomValue(atom), () => void 0);
|
|
29
|
+
};
|
|
30
|
+
var useConnections = (graph, id, relation) => {
|
|
31
|
+
return useAtomValue(graph.connections(id ?? "", relation));
|
|
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
|
+
*/
|
|
40
|
+
var useActions = (graph, id) => {
|
|
41
|
+
return useAtomValue(useMemo(() => graph.actions(id ?? ""), [graph, id]));
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Subscribe to just the edge topology (inbound/outbound IDs) of a node without subscribing to node content.
|
|
45
|
+
*
|
|
46
|
+
* @param graph Graph containing the node.
|
|
47
|
+
* @param id Id of the node.
|
|
48
|
+
* @returns Edge topology for the node.
|
|
49
|
+
*/
|
|
50
|
+
var useEdges = (graph, id) => {
|
|
51
|
+
return useAtomValue(useMemo(() => graph.edges(id ?? ""), [graph, id]));
|
|
52
|
+
};
|
|
53
|
+
//#endregion
|
|
54
|
+
export { useActionRunner, useActions, useConnections, useEdges, useNode };
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=hooks.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.mjs","names":[],"sources":["../../src/hooks/useActionRunner.ts","../../src/hooks/useNode.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport { useCallback } from 'react';\n\nimport { useOperationInvoker, usePluginManager } from '@dxos/app-framework/ui';\nimport { type Node } from '@dxos/app-graph';\n\nimport { runAction } from '../action';\n\n/**\n * Hook that returns a function to run action Effects.\n * Provides Operation.Service, PluginContextService, and captured plugin context.\n */\nexport const useActionRunner = () => {\n const invoker = useOperationInvoker();\n const pluginManager = usePluginManager();\n\n return useCallback(\n (action: Node.Action, params: Node.InvokeProps = {}) =>\n runAction(invoker, pluginManager.capabilities, action, params),\n [invoker, pluginManager.capabilities],\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport { useAtomValue } from '@effect-atom/atom-react';\nimport * as Option from 'effect/Option';\nimport { useMemo } from 'react';\n\nimport { type Graph, type Node } from '@dxos/app-graph';\n\n/**\n * React hook to get a node from the graph.\n *\n * @param graph Graph to find the node in.\n * @param id Id of the node to find.\n * @param timeout Optional timeout in milliseconds to wait for the node to be found.\n * @returns Node if found, undefined otherwise.\n */\n// TODO(wittjosiah): Factor out to @dxos/app-graph/react.\nexport const useNode = <T = any>(graph: Graph.ReadableGraph, id?: string): Node.Node<T> | undefined => {\n const atom = useMemo(() => graph.node(id ?? ''), [graph, id]);\n return Option.getOrElse(useAtomValue(atom), () => undefined);\n};\n\nexport const useConnections = (\n graph: Graph.ReadableGraph,\n id: string | undefined,\n relation: Node.RelationInput,\n): Node.Node[] => {\n return useAtomValue(graph.connections(id ?? '', relation));\n};\n\n/**\n * React hook to get actions available for a node.\n *\n * @param graph Graph containing the node.\n * @param id Id of the node.\n * @returns Actions available for the node.\n */\nexport const useActions = (graph: Graph.ReadableGraph, id?: string): Node.Node[] => {\n const atom = useMemo(() => graph.actions(id ?? ''), [graph, id]);\n return useAtomValue(atom);\n};\n\n/**\n * Subscribe to just the edge topology (inbound/outbound IDs) of a node without subscribing to node content.\n *\n * @param graph Graph containing the node.\n * @param id Id of the node.\n * @returns Edge topology for the node.\n */\nexport const useEdges = (graph: Graph.ReadableGraph, id?: string): Graph.Edges => {\n const atom = useMemo(() => graph.edges(id ?? ''), [graph, id]);\n return useAtomValue(atom);\n};\n"],"mappings":";;;;;;;;;;AAeA,IAAa,wBAAwB;CACnC,MAAM,UAAU,oBAAoB;CACpC,MAAM,gBAAgB,iBAAiB;CAEvC,OAAO,aACJ,QAAqB,SAA2B,CAAC,MAChD,UAAU,SAAS,cAAc,cAAc,QAAQ,MAAM,GAC/D,CAAC,SAAS,cAAc,YAAY,CACtC;AACF;;;;;;;;;;;ACLA,IAAa,WAAoB,OAA4B,OAA0C;CACrG,MAAM,OAAO,cAAc,MAAM,KAAK,MAAM,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC;CAC5D,OAAO,OAAO,UAAU,aAAa,IAAI,SAAS,KAAA,CAAS;AAC7D;AAEA,IAAa,kBACX,OACA,IACA,aACgB;CAChB,OAAO,aAAa,MAAM,YAAY,MAAM,IAAI,QAAQ,CAAC;AAC3D;;;;;;;;AASA,IAAa,cAAc,OAA4B,OAA6B;CAElF,OAAO,aADM,cAAc,MAAM,QAAQ,MAAM,EAAE,GAAG,CAAC,OAAO,EAAE,CAC1C,CAAI;AAC1B;;;;;;;;AASA,IAAa,YAAY,OAA4B,OAA6B;CAEhF,OAAO,aADM,cAAc,MAAM,MAAM,MAAM,EAAE,GAAG,CAAC,OAAO,EAAE,CACxC,CAAI;AAC1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.mjs","names":[],"sources":["../../src/plugin.ts"],"sourcesContent":["//\n// Copyright 2023 DXOS.org\n//\n\nimport { Plugin } from '@dxos/app-framework';\n\nimport { meta } from './meta';\n\nexport const GraphPlugin = Plugin.lazy(meta, () => import('#plugin'));\n"],"mappings":";;;AAQA,IAAa,cAAc,OAAO,KAAK,YAAY,OAAO,UAAU"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as Effect from 'effect/Effect';
|
|
2
2
|
import { Capability } from '@dxos/app-framework';
|
|
3
|
-
declare const _default: (props: void) => Effect.Effect<Capability.Any, Error, Capability.Service>;
|
|
3
|
+
declare const _default: (props: void) => Effect.Effect<Capability.Any, Error, import("effect/Scope").Scope | Capability.Service>;
|
|
4
4
|
export default _default;
|
|
5
5
|
//# sourceMappingURL=graph.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/index.ts"],"names":[],"mappings":"AAOA,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,QAAQ,CAAC;AAEvB,cAAc,iBAAiB,CAAC;AAEhC,cAAc,UAAU,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,QAAQ,CAAC;AAEvB,cAAc,iBAAiB,CAAC;AAEhC,cAAc,UAAU,CAAC"}
|