@dxos/plugin-graph 0.8.4-main.c1de068 → 0.8.4-main.c85a9c8dae
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-KGMD75RR.mjs +40 -0
- package/dist/lib/browser/graph-KGMD75RR.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +52 -24
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/graph-AKMWV2C7.mjs +42 -0
- package/dist/lib/node-esm/graph-AKMWV2C7.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +52 -24
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/GraphPlugin.d.ts +2 -1
- package/dist/types/src/GraphPlugin.d.ts.map +1 -1
- package/dist/types/src/action.d.ts +12 -0
- package/dist/types/src/action.d.ts.map +1 -0
- package/dist/types/src/graph.d.ts +7 -6
- package/dist/types/src/graph.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +1 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useActionRunner.d.ts +7 -0
- package/dist/types/src/hooks/useActionRunner.d.ts.map +1 -0
- package/dist/types/src/hooks/useNode.d.ts +6 -4
- package/dist/types/src/hooks/useNode.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -3
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +29 -21
- package/src/GraphPlugin.ts +13 -11
- package/src/action.ts +34 -0
- package/src/graph.ts +48 -37
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useActionRunner.ts +25 -0
- package/src/hooks/useNode.ts +18 -9
- package/src/index.ts +1 -0
- package/src/meta.ts +8 -5
- package/dist/lib/browser/graph-IRZE7I2B.mjs +0 -37
- package/dist/lib/browser/graph-IRZE7I2B.mjs.map +0 -7
- package/dist/lib/node-esm/graph-7HKX6CAT.mjs +0 -39
- package/dist/lib/node-esm/graph-7HKX6CAT.mjs.map +0 -7
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// src/graph.ts
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Record from "effect/Record";
|
|
4
|
+
import { Capabilities, Capability } from "@dxos/app-framework";
|
|
5
|
+
import { Graph, GraphBuilder, Node } from "@dxos/app-graph";
|
|
6
|
+
import { AppCapabilities } from "@dxos/app-toolkit";
|
|
7
|
+
var graph_default = Capability.makeModule(Effect.fnUntraced(function* () {
|
|
8
|
+
const registry = yield* Capability.get(Capabilities.AtomRegistry);
|
|
9
|
+
const extensionsAtom = yield* Capability.atom(AppCapabilities.AppGraphBuilder);
|
|
10
|
+
const builder = GraphBuilder.from(
|
|
11
|
+
/* localStorage.getItem(KEY) ?? */
|
|
12
|
+
void 0,
|
|
13
|
+
registry
|
|
14
|
+
);
|
|
15
|
+
const unsubscribe = registry.subscribe(extensionsAtom, (extensions) => {
|
|
16
|
+
const next = GraphBuilder.flattenExtensions(extensions);
|
|
17
|
+
const current = Record.values(registry.get(builder.extensions));
|
|
18
|
+
const removed = current.filter(({ id }) => !next.some(({ id: nextId }) => nextId === id));
|
|
19
|
+
removed.forEach((extension) => GraphBuilder.removeExtension(builder, extension.id));
|
|
20
|
+
next.forEach((extension) => GraphBuilder.addExtension(builder, extension));
|
|
21
|
+
}, {
|
|
22
|
+
immediate: true
|
|
23
|
+
});
|
|
24
|
+
void Graph.expand(builder.graph, Node.RootId, "child");
|
|
25
|
+
setupDevtools(builder.graph);
|
|
26
|
+
return Capability.contributes(AppCapabilities.AppGraph, {
|
|
27
|
+
graph: builder.graph,
|
|
28
|
+
explore: GraphBuilder.explore
|
|
29
|
+
}, () => Effect.sync(() => {
|
|
30
|
+
unsubscribe();
|
|
31
|
+
}));
|
|
32
|
+
}));
|
|
33
|
+
var setupDevtools = (graph) => {
|
|
34
|
+
globalThis.composer ??= {};
|
|
35
|
+
globalThis.composer.graph = graph;
|
|
36
|
+
};
|
|
37
|
+
export {
|
|
38
|
+
graph_default as default
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=graph-KGMD75RR.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
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 { Capabilities, Capability } from '@dxos/app-framework';\nimport { Graph, GraphBuilder, Node } from '@dxos/app-graph';\nimport { AppCapabilities } 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 extensionsAtom = yield* Capability.atom(AppCapabilities.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, 'child');\n\n setupDevtools(builder.graph);\n\n return Capability.contributes(\n AppCapabilities.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,cAAcC,kBAAkB;AACzC,SAASC,OAAOC,cAAcC,YAAY;AAC1C,SAASC,uBAAuB;AAOhC,IAAA,gBAAeC,WAAWC,WACjBC,kBAAW,aAAA;AAChB,QAAMC,WAAW,OAAOH,WAAWI,IAAIC,aAAaC,YAAY;AAChE,QAAMC,iBAAiB,OAAOP,WAAWQ,KAAKC,gBAAgBC,eAAe;AAE7E,QAAMC,UAAUC,aAAaC;;IAAwCC;IAAWX;EAAAA;AAKhF,QAAMY,cAAcZ,SAASa,UAC3BT,gBACA,CAACU,eAAAA;AACC,UAAMC,OAAON,aAAaO,kBAAkBF,UAAAA;AAC5C,UAAMG,UAAiBC,cAAOlB,SAASC,IAAIO,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,QAAQ,OAAA;AAE9CC,gBAAc1B,QAAQuB,KAAK;AAE3B,SAAOlC,WAAWsC,YAChB7B,gBAAgB8B,UAChB;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", "Capabilities", "Capability", "Graph", "GraphBuilder", "Node", "AppCapabilities", "Capability", "makeModule", "fnUntraced", "registry", "get", "Capabilities", "AtomRegistry", "extensionsAtom", "atom", "AppCapabilities", "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,50 +1,78 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
export * from "@dxos/app-graph";
|
|
3
3
|
|
|
4
|
+
// src/action.ts
|
|
5
|
+
import * as Effect from "effect/Effect";
|
|
6
|
+
import * as Function from "effect/Function";
|
|
7
|
+
import { Capability } from "@dxos/app-framework";
|
|
8
|
+
import { runAndForwardErrors } from "@dxos/effect";
|
|
9
|
+
import { Operation } from "@dxos/operation";
|
|
10
|
+
var runAction = async (invoker, capabilityManager, action, params = {}) => runAndForwardErrors(action.data(params).pipe(Effect.provideService(Operation.Service, invoker), Effect.provideService(Capability.Service, capabilityManager), action._actionContext ? Effect.provide(action._actionContext) : Function.identity));
|
|
11
|
+
|
|
4
12
|
// src/GraphPlugin.ts
|
|
5
|
-
import {
|
|
13
|
+
import { ActivationEvents, Capability as Capability2, Plugin } from "@dxos/app-framework";
|
|
14
|
+
import { AppActivationEvents } from "@dxos/app-toolkit";
|
|
6
15
|
|
|
7
16
|
// src/meta.ts
|
|
8
|
-
|
|
17
|
+
import { trim } from "@dxos/util";
|
|
9
18
|
var meta = {
|
|
10
|
-
id:
|
|
11
|
-
name: "Graph"
|
|
19
|
+
id: "dxos.org/plugin/graph",
|
|
20
|
+
name: "Graph",
|
|
21
|
+
description: trim`
|
|
22
|
+
Graph database layer providing relationship modeling and queries for workspace objects.
|
|
23
|
+
Build knowledge graphs and explore complex data relationships.
|
|
24
|
+
`
|
|
12
25
|
};
|
|
13
26
|
|
|
14
27
|
// src/GraphPlugin.ts
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
var Graph = Capability2.lazy("Graph", () => import("./graph-KGMD75RR.mjs"));
|
|
29
|
+
var GraphPlugin = Plugin.define(meta).pipe(Plugin.addModule({
|
|
30
|
+
activatesOn: ActivationEvents.Startup,
|
|
31
|
+
activatesBefore: [
|
|
32
|
+
AppActivationEvents.SetupAppGraph,
|
|
33
|
+
AppActivationEvents.SetupMetadata
|
|
34
|
+
],
|
|
35
|
+
activatesAfter: [
|
|
36
|
+
AppActivationEvents.AppGraphReady
|
|
37
|
+
],
|
|
38
|
+
activate: Graph
|
|
39
|
+
}), Plugin.make);
|
|
40
|
+
|
|
41
|
+
// src/hooks/useActionRunner.ts
|
|
42
|
+
import { useCallback } from "react";
|
|
43
|
+
import { useOperationInvoker, usePluginManager } from "@dxos/app-framework/ui";
|
|
44
|
+
var useActionRunner = () => {
|
|
45
|
+
const invoker = useOperationInvoker();
|
|
46
|
+
const pluginManager = usePluginManager();
|
|
47
|
+
return useCallback((action, params = {}) => runAction(invoker, pluginManager.capabilities, action, params), [
|
|
48
|
+
invoker,
|
|
49
|
+
pluginManager.capabilities
|
|
50
|
+
]);
|
|
51
|
+
};
|
|
29
52
|
|
|
30
53
|
// src/hooks/useNode.ts
|
|
31
|
-
import {
|
|
32
|
-
import
|
|
54
|
+
import { useAtomValue } from "@effect-atom/atom-react";
|
|
55
|
+
import * as Option from "effect/Option";
|
|
33
56
|
var useNode = (graph, id) => {
|
|
34
|
-
return Option.getOrElse(
|
|
57
|
+
return Option.getOrElse(useAtomValue(graph.node(id ?? "")), () => void 0);
|
|
35
58
|
};
|
|
36
59
|
var useConnections = (graph, id, relation) => {
|
|
37
|
-
return
|
|
60
|
+
return useAtomValue(graph.connections(id ?? "", relation));
|
|
38
61
|
};
|
|
39
62
|
var useActions = (graph, id) => {
|
|
40
|
-
return
|
|
63
|
+
return useAtomValue(graph.actions(id ?? ""));
|
|
64
|
+
};
|
|
65
|
+
var useEdges = (graph, id) => {
|
|
66
|
+
return useAtomValue(graph.edges(id ?? ""));
|
|
41
67
|
};
|
|
42
68
|
export {
|
|
43
|
-
GRAPH_PLUGIN,
|
|
44
69
|
GraphPlugin,
|
|
45
70
|
meta,
|
|
71
|
+
runAction,
|
|
72
|
+
useActionRunner,
|
|
46
73
|
useActions,
|
|
47
74
|
useConnections,
|
|
75
|
+
useEdges,
|
|
48
76
|
useNode
|
|
49
77
|
};
|
|
50
78
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/index.ts", "../../../src/GraphPlugin.ts", "../../../src/meta.ts", "../../../src/hooks/useNode.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nexport * from '@dxos/app-graph';\n\nexport * from './GraphPlugin';\nexport * from './hooks';\nexport * from './meta';\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport {
|
|
5
|
-
"mappings": ";AAIA,cAAc;;;ACAd,
|
|
6
|
-
"names": ["
|
|
3
|
+
"sources": ["../../../src/index.ts", "../../../src/action.ts", "../../../src/GraphPlugin.ts", "../../../src/meta.ts", "../../../src/hooks/useActionRunner.ts", "../../../src/hooks/useNode.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nexport * from '@dxos/app-graph';\n\nexport * from './action';\nexport * from './GraphPlugin';\nexport * from './hooks';\nexport * from './meta';\n", "//\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 { runAndForwardErrors } from '@dxos/effect';\nimport { Operation, type OperationInvoker } from '@dxos/operation';\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: OperationInvoker.OperationInvoker,\n capabilityManager: CapabilityManager.CapabilityManager,\n action: Node.Action,\n params: Node.InvokeProps = {},\n): Promise<void> =>\n 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", "//\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 activatesBefore: [AppActivationEvents.SetupAppGraph, AppActivationEvents.SetupMetadata],\n activatesAfter: [AppActivationEvents.AppGraphReady],\n activate: Graph,\n }),\n Plugin.make,\n);\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Plugin } from '@dxos/app-framework';\nimport { trim } from '@dxos/util';\n\nexport const meta: Plugin.Meta = {\n id: 'dxos.org/plugin/graph',\n name: 'Graph',\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};\n", "//\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';\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 return Option.getOrElse(useAtomValue(graph.node(id ?? '')), () => 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\nexport const useActions = (graph: Graph.ReadableGraph, id?: string): Node.Node[] => {\n return useAtomValue(graph.actions(id ?? ''));\n};\n\n/** Subscribe to just the edge topology (inbound/outbound IDs) of a node without subscribing to node content. */\nexport const useEdges = (graph: Graph.ReadableGraph, id?: string): Graph.Edges => {\n return useAtomValue(graph.edges(id ?? ''));\n};\n"],
|
|
5
|
+
"mappings": ";AAIA,cAAc;;;ACAd,YAAYA,YAAY;AACxB,YAAYC,cAAc;AAE1B,SAASC,kBAA0C;AAEnD,SAASC,2BAA2B;AACpC,SAASC,iBAAwC;AAS1C,IAAMC,YAAY,OACvBC,SACAC,mBACAC,QACAC,SAA2B,CAAC,MAE5BC,oBACEF,OACGG,KAAKF,MAAAA,EACLG,KACQC,sBAAeC,UAAUC,SAAST,OAAAA,GAClCO,sBAAeG,WAAWD,SAASR,iBAAAA,GAC1CC,OAAOS,iBAAwBC,eAAQV,OAAOS,cAAc,IAAaE,iBAAQ,CAAA;;;AC3BzF,SAASC,kBAAkBC,cAAAA,aAAYC,cAAc;AACrD,SAASC,2BAA2B;;;ACApC,SAASC,YAAY;AAEd,IAAMC,OAAoB;EAC/BC,IAAI;EACJC,MAAM;EACNC,aAAaC;;;;AAIf;;;ADLA,IAAMC,QAAQC,YAAWC,KAAK,SAAS,MAAM,OAAO,sBAAA,CAAA;AAO7C,IAAMC,cAAcC,OAAOC,OAAOC,IAAAA,EAAMC,KAC7CH,OAAOI,UAAU;EACfC,aAAaC,iBAAiBC;EAC9BC,iBAAiB;IAACC,oBAAoBC;IAAeD,oBAAoBE;;EACzEC,gBAAgB;IAACH,oBAAoBI;;EACrCC,UAAUlB;AACZ,CAAA,GACAI,OAAOe,IAAI;;;AEnBb,SAASC,mBAAmB;AAE5B,SAASC,qBAAqBC,wBAAwB;AAS/C,IAAMC,kBAAkB,MAAA;AAC7B,QAAMC,UAAUC,oBAAAA;AAChB,QAAMC,gBAAgBC,iBAAAA;AAEtB,SAAOC,YACL,CAACC,QAAqBC,SAA2B,CAAC,MAChDC,UAAUP,SAASE,cAAcM,cAAcH,QAAQC,MAAAA,GACzD;IAACN;IAASE,cAAcM;GAAa;AAEzC;;;ACpBA,SAASC,oBAAoB;AAC7B,YAAYC,YAAY;AAajB,IAAMC,UAAU,CAAUC,OAA4BC,OAAAA;AAC3D,SAAcC,iBAAUC,aAAaH,MAAMI,KAAKH,MAAM,EAAA,CAAA,GAAM,MAAMI,MAAAA;AACpE;AAEO,IAAMC,iBAAiB,CAC5BN,OACAC,IACAM,aAAAA;AAEA,SAAOJ,aAAaH,MAAMQ,YAAYP,MAAM,IAAIM,QAAAA,CAAAA;AAClD;AAEO,IAAME,aAAa,CAACT,OAA4BC,OAAAA;AACrD,SAAOE,aAAaH,MAAMU,QAAQT,MAAM,EAAA,CAAA;AAC1C;AAGO,IAAMU,WAAW,CAACX,OAA4BC,OAAAA;AACnD,SAAOE,aAAaH,MAAMY,MAAMX,MAAM,EAAA,CAAA;AACxC;",
|
|
6
|
+
"names": ["Effect", "Function", "Capability", "runAndForwardErrors", "Operation", "runAction", "invoker", "capabilityManager", "action", "params", "runAndForwardErrors", "data", "pipe", "provideService", "Operation", "Service", "Capability", "_actionContext", "provide", "identity", "ActivationEvents", "Capability", "Plugin", "AppActivationEvents", "trim", "meta", "id", "name", "description", "trim", "Graph", "Capability", "lazy", "GraphPlugin", "Plugin", "define", "meta", "pipe", "addModule", "activatesOn", "ActivationEvents", "Startup", "activatesBefore", "AppActivationEvents", "SetupAppGraph", "SetupMetadata", "activatesAfter", "AppGraphReady", "activate", "make", "useCallback", "useOperationInvoker", "usePluginManager", "useActionRunner", "invoker", "useOperationInvoker", "pluginManager", "usePluginManager", "useCallback", "action", "params", "runAction", "capabilities", "useAtomValue", "Option", "useNode", "graph", "id", "getOrElse", "useAtomValue", "node", "undefined", "useConnections", "relation", "connections", "useActions", "actions", "useEdges", "edges"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"src/meta.ts":{"bytes":
|
|
1
|
+
{"inputs":{"src/action.ts":{"bytes":3719,"imports":[{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Function","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/effect","kind":"import-statement","external":true},{"path":"@dxos/operation","kind":"import-statement","external":true}],"format":"esm"},"src/meta.ts":{"bytes":1365,"imports":[{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/graph.ts":{"bytes":7347,"imports":[{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Record","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"@dxos/app-toolkit","kind":"import-statement","external":true}],"format":"esm"},"src/GraphPlugin.ts":{"bytes":3056,"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/app-toolkit","kind":"import-statement","external":true},{"path":"src/meta.ts","kind":"import-statement","original":"./meta"},{"path":"src/graph.ts","kind":"dynamic-import","original":"./graph"}],"format":"esm"},"src/hooks/useActionRunner.ts":{"bytes":2530,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/app-framework/ui","kind":"import-statement","external":true},{"path":"src/action.ts","kind":"import-statement","original":"../action"}],"format":"esm"},"src/hooks/useNode.ts":{"bytes":3919,"imports":[{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true}],"format":"esm"},"src/hooks/index.ts":{"bytes":568,"imports":[{"path":"src/hooks/useActionRunner.ts","kind":"import-statement","original":"./useActionRunner"},{"path":"src/hooks/useNode.ts","kind":"import-statement","original":"./useNode"}],"format":"esm"},"src/index.ts":{"bytes":815,"imports":[{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"src/action.ts","kind":"import-statement","original":"./action"},{"path":"src/GraphPlugin.ts","kind":"import-statement","original":"./GraphPlugin"},{"path":"src/hooks/index.ts","kind":"import-statement","original":"./hooks"},{"path":"src/meta.ts","kind":"import-statement","original":"./meta"}],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":7444},"dist/lib/browser/index.mjs":{"imports":[{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Function","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/effect","kind":"import-statement","external":true},{"path":"@dxos/operation","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/app-toolkit","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"dist/lib/browser/graph-KGMD75RR.mjs","kind":"dynamic-import"},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/app-framework/ui","kind":"import-statement","external":true},{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true}],"exports":["GraphPlugin","meta","runAction","useActionRunner","useActions","useConnections","useEdges","useNode"],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":33},"src/action.ts":{"bytesInOutput":551},"src/GraphPlugin.ts":{"bytesInOutput":530},"src/meta.ts":{"bytesInOutput":283},"src/hooks/useActionRunner.ts":{"bytesInOutput":397},"src/hooks/index.ts":{"bytesInOutput":0},"src/hooks/useNode.ts":{"bytesInOutput":487}},"bytes":2591},"dist/lib/browser/graph-KGMD75RR.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":3865},"dist/lib/browser/graph-KGMD75RR.mjs":{"imports":[{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Record","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"@dxos/app-toolkit","kind":"import-statement","external":true}],"exports":["default"],"entryPoint":"src/graph.ts","inputs":{"src/graph.ts":{"bytesInOutput":1469}},"bytes":1568}}}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// src/graph.ts
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Record from "effect/Record";
|
|
6
|
+
import { Capabilities, Capability } from "@dxos/app-framework";
|
|
7
|
+
import { Graph, GraphBuilder, Node } from "@dxos/app-graph";
|
|
8
|
+
import { AppCapabilities } from "@dxos/app-toolkit";
|
|
9
|
+
var graph_default = Capability.makeModule(Effect.fnUntraced(function* () {
|
|
10
|
+
const registry = yield* Capability.get(Capabilities.AtomRegistry);
|
|
11
|
+
const extensionsAtom = yield* Capability.atom(AppCapabilities.AppGraphBuilder);
|
|
12
|
+
const builder = GraphBuilder.from(
|
|
13
|
+
/* localStorage.getItem(KEY) ?? */
|
|
14
|
+
void 0,
|
|
15
|
+
registry
|
|
16
|
+
);
|
|
17
|
+
const unsubscribe = registry.subscribe(extensionsAtom, (extensions) => {
|
|
18
|
+
const next = GraphBuilder.flattenExtensions(extensions);
|
|
19
|
+
const current = Record.values(registry.get(builder.extensions));
|
|
20
|
+
const removed = current.filter(({ id }) => !next.some(({ id: nextId }) => nextId === id));
|
|
21
|
+
removed.forEach((extension) => GraphBuilder.removeExtension(builder, extension.id));
|
|
22
|
+
next.forEach((extension) => GraphBuilder.addExtension(builder, extension));
|
|
23
|
+
}, {
|
|
24
|
+
immediate: true
|
|
25
|
+
});
|
|
26
|
+
void Graph.expand(builder.graph, Node.RootId, "child");
|
|
27
|
+
setupDevtools(builder.graph);
|
|
28
|
+
return Capability.contributes(AppCapabilities.AppGraph, {
|
|
29
|
+
graph: builder.graph,
|
|
30
|
+
explore: GraphBuilder.explore
|
|
31
|
+
}, () => Effect.sync(() => {
|
|
32
|
+
unsubscribe();
|
|
33
|
+
}));
|
|
34
|
+
}));
|
|
35
|
+
var setupDevtools = (graph) => {
|
|
36
|
+
globalThis.composer ??= {};
|
|
37
|
+
globalThis.composer.graph = graph;
|
|
38
|
+
};
|
|
39
|
+
export {
|
|
40
|
+
graph_default as default
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=graph-AKMWV2C7.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
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 { Capabilities, Capability } from '@dxos/app-framework';\nimport { Graph, GraphBuilder, Node } from '@dxos/app-graph';\nimport { AppCapabilities } 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 extensionsAtom = yield* Capability.atom(AppCapabilities.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, 'child');\n\n setupDevtools(builder.graph);\n\n return Capability.contributes(\n AppCapabilities.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,cAAcC,kBAAkB;AACzC,SAASC,OAAOC,cAAcC,YAAY;AAC1C,SAASC,uBAAuB;AAOhC,IAAA,gBAAeC,WAAWC,WACjBC,kBAAW,aAAA;AAChB,QAAMC,WAAW,OAAOH,WAAWI,IAAIC,aAAaC,YAAY;AAChE,QAAMC,iBAAiB,OAAOP,WAAWQ,KAAKC,gBAAgBC,eAAe;AAE7E,QAAMC,UAAUC,aAAaC;;IAAwCC;IAAWX;EAAAA;AAKhF,QAAMY,cAAcZ,SAASa,UAC3BT,gBACA,CAACU,eAAAA;AACC,UAAMC,OAAON,aAAaO,kBAAkBF,UAAAA;AAC5C,UAAMG,UAAiBC,cAAOlB,SAASC,IAAIO,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,QAAQ,OAAA;AAE9CC,gBAAc1B,QAAQuB,KAAK;AAE3B,SAAOlC,WAAWsC,YAChB7B,gBAAgB8B,UAChB;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", "Capabilities", "Capability", "Graph", "GraphBuilder", "Node", "AppCapabilities", "Capability", "makeModule", "fnUntraced", "registry", "get", "Capabilities", "AtomRegistry", "extensionsAtom", "atom", "AppCapabilities", "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
|
+
}
|
|
@@ -3,50 +3,78 @@ import { createRequire } from 'node:module';const require = createRequire(import
|
|
|
3
3
|
// src/index.ts
|
|
4
4
|
export * from "@dxos/app-graph";
|
|
5
5
|
|
|
6
|
+
// src/action.ts
|
|
7
|
+
import * as Effect from "effect/Effect";
|
|
8
|
+
import * as Function from "effect/Function";
|
|
9
|
+
import { Capability } from "@dxos/app-framework";
|
|
10
|
+
import { runAndForwardErrors } from "@dxos/effect";
|
|
11
|
+
import { Operation } from "@dxos/operation";
|
|
12
|
+
var runAction = async (invoker, capabilityManager, action, params = {}) => runAndForwardErrors(action.data(params).pipe(Effect.provideService(Operation.Service, invoker), Effect.provideService(Capability.Service, capabilityManager), action._actionContext ? Effect.provide(action._actionContext) : Function.identity));
|
|
13
|
+
|
|
6
14
|
// src/GraphPlugin.ts
|
|
7
|
-
import {
|
|
15
|
+
import { ActivationEvents, Capability as Capability2, Plugin } from "@dxos/app-framework";
|
|
16
|
+
import { AppActivationEvents } from "@dxos/app-toolkit";
|
|
8
17
|
|
|
9
18
|
// src/meta.ts
|
|
10
|
-
|
|
19
|
+
import { trim } from "@dxos/util";
|
|
11
20
|
var meta = {
|
|
12
|
-
id:
|
|
13
|
-
name: "Graph"
|
|
21
|
+
id: "dxos.org/plugin/graph",
|
|
22
|
+
name: "Graph",
|
|
23
|
+
description: trim`
|
|
24
|
+
Graph database layer providing relationship modeling and queries for workspace objects.
|
|
25
|
+
Build knowledge graphs and explore complex data relationships.
|
|
26
|
+
`
|
|
14
27
|
};
|
|
15
28
|
|
|
16
29
|
// src/GraphPlugin.ts
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
var Graph = Capability2.lazy("Graph", () => import("./graph-AKMWV2C7.mjs"));
|
|
31
|
+
var GraphPlugin = Plugin.define(meta).pipe(Plugin.addModule({
|
|
32
|
+
activatesOn: ActivationEvents.Startup,
|
|
33
|
+
activatesBefore: [
|
|
34
|
+
AppActivationEvents.SetupAppGraph,
|
|
35
|
+
AppActivationEvents.SetupMetadata
|
|
36
|
+
],
|
|
37
|
+
activatesAfter: [
|
|
38
|
+
AppActivationEvents.AppGraphReady
|
|
39
|
+
],
|
|
40
|
+
activate: Graph
|
|
41
|
+
}), Plugin.make);
|
|
42
|
+
|
|
43
|
+
// src/hooks/useActionRunner.ts
|
|
44
|
+
import { useCallback } from "react";
|
|
45
|
+
import { useOperationInvoker, usePluginManager } from "@dxos/app-framework/ui";
|
|
46
|
+
var useActionRunner = () => {
|
|
47
|
+
const invoker = useOperationInvoker();
|
|
48
|
+
const pluginManager = usePluginManager();
|
|
49
|
+
return useCallback((action, params = {}) => runAction(invoker, pluginManager.capabilities, action, params), [
|
|
50
|
+
invoker,
|
|
51
|
+
pluginManager.capabilities
|
|
52
|
+
]);
|
|
53
|
+
};
|
|
31
54
|
|
|
32
55
|
// src/hooks/useNode.ts
|
|
33
|
-
import {
|
|
34
|
-
import
|
|
56
|
+
import { useAtomValue } from "@effect-atom/atom-react";
|
|
57
|
+
import * as Option from "effect/Option";
|
|
35
58
|
var useNode = (graph, id) => {
|
|
36
|
-
return Option.getOrElse(
|
|
59
|
+
return Option.getOrElse(useAtomValue(graph.node(id ?? "")), () => void 0);
|
|
37
60
|
};
|
|
38
61
|
var useConnections = (graph, id, relation) => {
|
|
39
|
-
return
|
|
62
|
+
return useAtomValue(graph.connections(id ?? "", relation));
|
|
40
63
|
};
|
|
41
64
|
var useActions = (graph, id) => {
|
|
42
|
-
return
|
|
65
|
+
return useAtomValue(graph.actions(id ?? ""));
|
|
66
|
+
};
|
|
67
|
+
var useEdges = (graph, id) => {
|
|
68
|
+
return useAtomValue(graph.edges(id ?? ""));
|
|
43
69
|
};
|
|
44
70
|
export {
|
|
45
|
-
GRAPH_PLUGIN,
|
|
46
71
|
GraphPlugin,
|
|
47
72
|
meta,
|
|
73
|
+
runAction,
|
|
74
|
+
useActionRunner,
|
|
48
75
|
useActions,
|
|
49
76
|
useConnections,
|
|
77
|
+
useEdges,
|
|
50
78
|
useNode
|
|
51
79
|
};
|
|
52
80
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/index.ts", "../../../src/GraphPlugin.ts", "../../../src/meta.ts", "../../../src/hooks/useNode.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nexport * from '@dxos/app-graph';\n\nexport * from './GraphPlugin';\nexport * from './hooks';\nexport * from './meta';\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport {
|
|
5
|
-
"mappings": ";;;AAIA,cAAc;;;ACAd,
|
|
6
|
-
"names": ["
|
|
3
|
+
"sources": ["../../../src/index.ts", "../../../src/action.ts", "../../../src/GraphPlugin.ts", "../../../src/meta.ts", "../../../src/hooks/useActionRunner.ts", "../../../src/hooks/useNode.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nexport * from '@dxos/app-graph';\n\nexport * from './action';\nexport * from './GraphPlugin';\nexport * from './hooks';\nexport * from './meta';\n", "//\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 { runAndForwardErrors } from '@dxos/effect';\nimport { Operation, type OperationInvoker } from '@dxos/operation';\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: OperationInvoker.OperationInvoker,\n capabilityManager: CapabilityManager.CapabilityManager,\n action: Node.Action,\n params: Node.InvokeProps = {},\n): Promise<void> =>\n 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", "//\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 activatesBefore: [AppActivationEvents.SetupAppGraph, AppActivationEvents.SetupMetadata],\n activatesAfter: [AppActivationEvents.AppGraphReady],\n activate: Graph,\n }),\n Plugin.make,\n);\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Plugin } from '@dxos/app-framework';\nimport { trim } from '@dxos/util';\n\nexport const meta: Plugin.Meta = {\n id: 'dxos.org/plugin/graph',\n name: 'Graph',\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};\n", "//\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';\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 return Option.getOrElse(useAtomValue(graph.node(id ?? '')), () => 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\nexport const useActions = (graph: Graph.ReadableGraph, id?: string): Node.Node[] => {\n return useAtomValue(graph.actions(id ?? ''));\n};\n\n/** Subscribe to just the edge topology (inbound/outbound IDs) of a node without subscribing to node content. */\nexport const useEdges = (graph: Graph.ReadableGraph, id?: string): Graph.Edges => {\n return useAtomValue(graph.edges(id ?? ''));\n};\n"],
|
|
5
|
+
"mappings": ";;;AAIA,cAAc;;;ACAd,YAAYA,YAAY;AACxB,YAAYC,cAAc;AAE1B,SAASC,kBAA0C;AAEnD,SAASC,2BAA2B;AACpC,SAASC,iBAAwC;AAS1C,IAAMC,YAAY,OACvBC,SACAC,mBACAC,QACAC,SAA2B,CAAC,MAE5BC,oBACEF,OACGG,KAAKF,MAAAA,EACLG,KACQC,sBAAeC,UAAUC,SAAST,OAAAA,GAClCO,sBAAeG,WAAWD,SAASR,iBAAAA,GAC1CC,OAAOS,iBAAwBC,eAAQV,OAAOS,cAAc,IAAaE,iBAAQ,CAAA;;;AC3BzF,SAASC,kBAAkBC,cAAAA,aAAYC,cAAc;AACrD,SAASC,2BAA2B;;;ACApC,SAASC,YAAY;AAEd,IAAMC,OAAoB;EAC/BC,IAAI;EACJC,MAAM;EACNC,aAAaC;;;;AAIf;;;ADLA,IAAMC,QAAQC,YAAWC,KAAK,SAAS,MAAM,OAAO,sBAAA,CAAA;AAO7C,IAAMC,cAAcC,OAAOC,OAAOC,IAAAA,EAAMC,KAC7CH,OAAOI,UAAU;EACfC,aAAaC,iBAAiBC;EAC9BC,iBAAiB;IAACC,oBAAoBC;IAAeD,oBAAoBE;;EACzEC,gBAAgB;IAACH,oBAAoBI;;EACrCC,UAAUlB;AACZ,CAAA,GACAI,OAAOe,IAAI;;;AEnBb,SAASC,mBAAmB;AAE5B,SAASC,qBAAqBC,wBAAwB;AAS/C,IAAMC,kBAAkB,MAAA;AAC7B,QAAMC,UAAUC,oBAAAA;AAChB,QAAMC,gBAAgBC,iBAAAA;AAEtB,SAAOC,YACL,CAACC,QAAqBC,SAA2B,CAAC,MAChDC,UAAUP,SAASE,cAAcM,cAAcH,QAAQC,MAAAA,GACzD;IAACN;IAASE,cAAcM;GAAa;AAEzC;;;ACpBA,SAASC,oBAAoB;AAC7B,YAAYC,YAAY;AAajB,IAAMC,UAAU,CAAUC,OAA4BC,OAAAA;AAC3D,SAAcC,iBAAUC,aAAaH,MAAMI,KAAKH,MAAM,EAAA,CAAA,GAAM,MAAMI,MAAAA;AACpE;AAEO,IAAMC,iBAAiB,CAC5BN,OACAC,IACAM,aAAAA;AAEA,SAAOJ,aAAaH,MAAMQ,YAAYP,MAAM,IAAIM,QAAAA,CAAAA;AAClD;AAEO,IAAME,aAAa,CAACT,OAA4BC,OAAAA;AACrD,SAAOE,aAAaH,MAAMU,QAAQT,MAAM,EAAA,CAAA;AAC1C;AAGO,IAAMU,WAAW,CAACX,OAA4BC,OAAAA;AACnD,SAAOE,aAAaH,MAAMY,MAAMX,MAAM,EAAA,CAAA;AACxC;",
|
|
6
|
+
"names": ["Effect", "Function", "Capability", "runAndForwardErrors", "Operation", "runAction", "invoker", "capabilityManager", "action", "params", "runAndForwardErrors", "data", "pipe", "provideService", "Operation", "Service", "Capability", "_actionContext", "provide", "identity", "ActivationEvents", "Capability", "Plugin", "AppActivationEvents", "trim", "meta", "id", "name", "description", "trim", "Graph", "Capability", "lazy", "GraphPlugin", "Plugin", "define", "meta", "pipe", "addModule", "activatesOn", "ActivationEvents", "Startup", "activatesBefore", "AppActivationEvents", "SetupAppGraph", "SetupMetadata", "activatesAfter", "AppGraphReady", "activate", "make", "useCallback", "useOperationInvoker", "usePluginManager", "useActionRunner", "invoker", "useOperationInvoker", "pluginManager", "usePluginManager", "useCallback", "action", "params", "runAction", "capabilities", "useAtomValue", "Option", "useNode", "graph", "id", "getOrElse", "useAtomValue", "node", "undefined", "useConnections", "relation", "connections", "useActions", "actions", "useEdges", "edges"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"src/meta.ts":{"bytes":
|
|
1
|
+
{"inputs":{"src/action.ts":{"bytes":3719,"imports":[{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Function","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/effect","kind":"import-statement","external":true},{"path":"@dxos/operation","kind":"import-statement","external":true}],"format":"esm"},"src/meta.ts":{"bytes":1365,"imports":[{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/graph.ts":{"bytes":7347,"imports":[{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Record","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"@dxos/app-toolkit","kind":"import-statement","external":true}],"format":"esm"},"src/GraphPlugin.ts":{"bytes":3056,"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/app-toolkit","kind":"import-statement","external":true},{"path":"src/meta.ts","kind":"import-statement","original":"./meta"},{"path":"src/graph.ts","kind":"dynamic-import","original":"./graph"}],"format":"esm"},"src/hooks/useActionRunner.ts":{"bytes":2530,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/app-framework/ui","kind":"import-statement","external":true},{"path":"src/action.ts","kind":"import-statement","original":"../action"}],"format":"esm"},"src/hooks/useNode.ts":{"bytes":3919,"imports":[{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true}],"format":"esm"},"src/hooks/index.ts":{"bytes":568,"imports":[{"path":"src/hooks/useActionRunner.ts","kind":"import-statement","original":"./useActionRunner"},{"path":"src/hooks/useNode.ts","kind":"import-statement","original":"./useNode"}],"format":"esm"},"src/index.ts":{"bytes":815,"imports":[{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"src/action.ts","kind":"import-statement","original":"./action"},{"path":"src/GraphPlugin.ts","kind":"import-statement","original":"./GraphPlugin"},{"path":"src/hooks/index.ts","kind":"import-statement","original":"./hooks"},{"path":"src/meta.ts","kind":"import-statement","original":"./meta"}],"format":"esm"}},"outputs":{"dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":7446},"dist/lib/node-esm/index.mjs":{"imports":[{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Function","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/effect","kind":"import-statement","external":true},{"path":"@dxos/operation","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/app-toolkit","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"dist/lib/node-esm/graph-AKMWV2C7.mjs","kind":"dynamic-import"},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/app-framework/ui","kind":"import-statement","external":true},{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true}],"exports":["GraphPlugin","meta","runAction","useActionRunner","useActions","useConnections","useEdges","useNode"],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":33},"src/action.ts":{"bytesInOutput":551},"src/GraphPlugin.ts":{"bytesInOutput":530},"src/meta.ts":{"bytesInOutput":283},"src/hooks/useActionRunner.ts":{"bytesInOutput":397},"src/hooks/index.ts":{"bytesInOutput":0},"src/hooks/useNode.ts":{"bytesInOutput":487}},"bytes":2684},"dist/lib/node-esm/graph-AKMWV2C7.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":3867},"dist/lib/node-esm/graph-AKMWV2C7.mjs":{"imports":[{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Record","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"@dxos/app-toolkit","kind":"import-statement","external":true}],"exports":["default"],"entryPoint":"src/graph.ts","inputs":{"src/graph.ts":{"bytesInOutput":1469}},"bytes":1661}}}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { Plugin } from '@dxos/app-framework';
|
|
1
2
|
/**
|
|
2
3
|
* Manages the state of the graph for the application.
|
|
3
4
|
* Enables other plugins to register node builders to add nodes to the graph.
|
|
4
5
|
* This includes actions and annotation each other's nodes.
|
|
5
6
|
*/
|
|
6
|
-
export declare const GraphPlugin:
|
|
7
|
+
export declare const GraphPlugin: Plugin.PluginFactory<void>;
|
|
7
8
|
//# sourceMappingURL=GraphPlugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GraphPlugin.d.ts","sourceRoot":"","sources":["../../../src/GraphPlugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GraphPlugin.d.ts","sourceRoot":"","sources":["../../../src/GraphPlugin.ts"],"names":[],"mappings":"AAIA,OAAO,EAAgC,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAO3E;;;;GAIG;AACH,eAAO,MAAM,WAAW,4BAQvB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type CapabilityManager } from '@dxos/app-framework';
|
|
2
|
+
import { type Node } from '@dxos/app-graph';
|
|
3
|
+
import { type OperationInvoker } from '@dxos/operation';
|
|
4
|
+
/**
|
|
5
|
+
* Run an action with required layers: Operation.Service, Capability.Service, and captured context.
|
|
6
|
+
* @param invoker The operation invoker to use for Operation.Service.
|
|
7
|
+
* @param capabilityManager The capability manager for Capability.Service.
|
|
8
|
+
* @param action The action to execute.
|
|
9
|
+
* @param params Parameters to pass to the action.
|
|
10
|
+
*/
|
|
11
|
+
export declare const runAction: (invoker: OperationInvoker.OperationInvoker, capabilityManager: CapabilityManager.CapabilityManager, action: Node.Action, params?: Node.InvokeProps) => Promise<void>;
|
|
12
|
+
//# sourceMappingURL=action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../../src/action.ts"],"names":[],"mappings":"AAOA,OAAO,EAAc,KAAK,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAa,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnE;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,GACpB,SAAS,gBAAgB,CAAC,gBAAgB,EAC1C,mBAAmB,iBAAiB,CAAC,iBAAiB,EACtD,QAAQ,IAAI,CAAC,MAAM,EACnB,SAAQ,IAAI,CAAC,WAAgB,KAC5B,OAAO,CAAC,IAAI,CASZ,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import * as Effect from 'effect/Effect';
|
|
2
|
+
import { Capability } from '@dxos/app-framework';
|
|
3
|
+
import { Graph, GraphBuilder } from '@dxos/app-graph';
|
|
4
|
+
declare const _default: (props: void) => Effect.Effect<Capability.Capability<Capability.InterfaceDef<Readonly<{
|
|
5
|
+
graph: Graph.ExpandableGraph;
|
|
6
|
+
explore: typeof GraphBuilder.explore;
|
|
7
|
+
}>>>, Error, Capability.Service>;
|
|
7
8
|
export default _default;
|
|
8
9
|
//# sourceMappingURL=graph.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../../src/graph.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../../src/graph.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAGxC,OAAO,EAAgB,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,YAAY,EAAQ,MAAM,iBAAiB,CAAC;;;;;AAQ5D,wBAqCE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/index.ts"],"names":[],"mappings":"AAIA,cAAc,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/index.ts"],"names":[],"mappings":"AAIA,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type Node } from '@dxos/app-graph';
|
|
2
|
+
/**
|
|
3
|
+
* Hook that returns a function to run action Effects.
|
|
4
|
+
* Provides Operation.Service, PluginContextService, and captured plugin context.
|
|
5
|
+
*/
|
|
6
|
+
export declare const useActionRunner: () => (action: Node.Action, params?: Node.InvokeProps) => Promise<void>;
|
|
7
|
+
//# sourceMappingURL=useActionRunner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useActionRunner.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useActionRunner.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAI5C;;;GAGG;AACH,eAAO,MAAM,eAAe,iBAKf,IAAI,CAAC,MAAM,WAAU,IAAI,CAAC,WAAW,kBAIjD,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type Graph, type Node } from '@dxos/app-graph';
|
|
2
2
|
/**
|
|
3
3
|
* React hook to get a node from the graph.
|
|
4
4
|
*
|
|
@@ -7,7 +7,9 @@ import { type ReadableGraph, type Node, type Relation } from '@dxos/app-graph';
|
|
|
7
7
|
* @param timeout Optional timeout in milliseconds to wait for the node to be found.
|
|
8
8
|
* @returns Node if found, undefined otherwise.
|
|
9
9
|
*/
|
|
10
|
-
export declare const useNode: <T = any>(graph: ReadableGraph, id?: string) => Node<T> | undefined;
|
|
11
|
-
export declare const useConnections: (graph: ReadableGraph, id
|
|
12
|
-
export declare const useActions: (graph: ReadableGraph, id?: string) => Node[];
|
|
10
|
+
export declare const useNode: <T = any>(graph: Graph.ReadableGraph, id?: string) => Node.Node<T> | undefined;
|
|
11
|
+
export declare const useConnections: (graph: Graph.ReadableGraph, id: string | undefined, relation: Node.RelationInput) => Node.Node[];
|
|
12
|
+
export declare const useActions: (graph: Graph.ReadableGraph, id?: string) => Node.Node[];
|
|
13
|
+
/** Subscribe to just the edge topology (inbound/outbound IDs) of a node without subscribing to node content. */
|
|
14
|
+
export declare const useEdges: (graph: Graph.ReadableGraph, id?: string) => Graph.Edges;
|
|
13
15
|
//# sourceMappingURL=useNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNode.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useNode.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"useNode.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useNode.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAExD;;;;;;;GAOG;AAEH,eAAO,MAAM,OAAO,GAAI,CAAC,GAAG,GAAG,EAAE,OAAO,KAAK,CAAC,aAAa,EAAE,KAAK,MAAM,KAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,SAEzF,CAAC;AAEF,eAAO,MAAM,cAAc,GACzB,OAAO,KAAK,CAAC,aAAa,EAC1B,IAAI,MAAM,GAAG,SAAS,EACtB,UAAU,IAAI,CAAC,aAAa,KAC3B,IAAI,CAAC,IAAI,EAEX,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,OAAO,KAAK,CAAC,aAAa,EAAE,KAAK,MAAM,KAAG,IAAI,CAAC,IAAI,EAE7E,CAAC;AAEF,gHAAgH;AAChH,eAAO,MAAM,QAAQ,GAAI,OAAO,KAAK,CAAC,aAAa,EAAE,KAAK,MAAM,KAAG,KAAK,CAAC,KAExE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,iBAAiB,CAAC;AAEhC,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,iBAAiB,CAAC;AAEhC,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC"}
|