@dxos/plugin-graph 0.8.4-main.84f28bd → 0.8.4-main.937b3ca
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-PXKA3JXN.mjs +39 -0
- package/dist/lib/browser/graph-PXKA3JXN.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +47 -24
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/graph-CR2XR64B.mjs +41 -0
- package/dist/lib/node-esm/graph-CR2XR64B.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +47 -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 +4 -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 +28 -21
- package/src/GraphPlugin.ts +12 -11
- package/src/action.ts +34 -0
- package/src/graph.ts +47 -37
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useActionRunner.ts +25 -0
- package/src/hooks/useNode.ts +9 -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
package/package.json
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-graph",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.937b3ca",
|
|
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",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/dxos/dxos"
|
|
10
|
+
},
|
|
7
11
|
"license": "MIT",
|
|
8
12
|
"author": "DXOS.org",
|
|
9
13
|
"sideEffects": true,
|
|
10
14
|
"type": "module",
|
|
11
15
|
"exports": {
|
|
12
16
|
".": {
|
|
17
|
+
"source": "./src/index.ts",
|
|
13
18
|
"types": "./dist/types/src/index.d.ts",
|
|
14
19
|
"browser": "./dist/lib/browser/index.mjs",
|
|
15
20
|
"node": "./dist/lib/node-esm/index.mjs"
|
|
@@ -24,30 +29,32 @@
|
|
|
24
29
|
"src"
|
|
25
30
|
],
|
|
26
31
|
"dependencies": {
|
|
27
|
-
"@
|
|
28
|
-
"@dxos/app-
|
|
29
|
-
"@dxos/
|
|
30
|
-
"@dxos/
|
|
31
|
-
"@dxos/debug": "0.8.4-main.
|
|
32
|
+
"@dxos/app-framework": "0.8.4-main.937b3ca",
|
|
33
|
+
"@dxos/app-graph": "0.8.4-main.937b3ca",
|
|
34
|
+
"@dxos/async": "0.8.4-main.937b3ca",
|
|
35
|
+
"@dxos/util": "0.8.4-main.937b3ca",
|
|
36
|
+
"@dxos/debug": "0.8.4-main.937b3ca",
|
|
37
|
+
"@dxos/operation": "0.8.4-main.937b3ca",
|
|
38
|
+
"@dxos/effect": "0.8.4-main.937b3ca"
|
|
32
39
|
},
|
|
33
40
|
"devDependencies": {
|
|
34
|
-
"@effect-
|
|
35
|
-
"@effect/platform": "0.
|
|
36
|
-
"@types/react": "~
|
|
37
|
-
"@types/react-dom": "~
|
|
38
|
-
"effect": "3.
|
|
39
|
-
"react": "~
|
|
40
|
-
"react-dom": "~
|
|
41
|
-
"vite": "
|
|
42
|
-
"@dxos/react-client": "0.8.4-main.
|
|
43
|
-
"@dxos/storybook-utils": "0.8.4-main.
|
|
41
|
+
"@effect-atom/atom-react": "^0.4.6",
|
|
42
|
+
"@effect/platform": "0.93.6",
|
|
43
|
+
"@types/react": "~19.2.7",
|
|
44
|
+
"@types/react-dom": "~19.2.3",
|
|
45
|
+
"effect": "3.19.11",
|
|
46
|
+
"react": "~19.2.3",
|
|
47
|
+
"react-dom": "~19.2.3",
|
|
48
|
+
"vite": "7.1.9",
|
|
49
|
+
"@dxos/react-client": "0.8.4-main.937b3ca",
|
|
50
|
+
"@dxos/storybook-utils": "0.8.4-main.937b3ca"
|
|
44
51
|
},
|
|
45
52
|
"peerDependencies": {
|
|
46
|
-
"@effect-
|
|
47
|
-
"@effect/platform": "
|
|
48
|
-
"effect": "
|
|
49
|
-
"react": "~
|
|
50
|
-
"react-dom": "~
|
|
53
|
+
"@effect-atom/atom-react": "^0.4.6",
|
|
54
|
+
"@effect/platform": "0.93.6",
|
|
55
|
+
"effect": "3.19.11",
|
|
56
|
+
"react": "~19.2.3",
|
|
57
|
+
"react-dom": "~19.2.3"
|
|
51
58
|
},
|
|
52
59
|
"publishConfig": {
|
|
53
60
|
"access": "public"
|
package/src/GraphPlugin.ts
CHANGED
|
@@ -2,22 +2,23 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Capability, Common, Plugin } from '@dxos/app-framework';
|
|
6
6
|
|
|
7
7
|
import { meta } from './meta';
|
|
8
8
|
|
|
9
|
+
const Graph = Capability.lazy('Graph', () => import('./graph'));
|
|
10
|
+
|
|
9
11
|
/**
|
|
10
12
|
* Manages the state of the graph for the application.
|
|
11
13
|
* Enables other plugins to register node builders to add nodes to the graph.
|
|
12
14
|
* This includes actions and annotation each other's nodes.
|
|
13
15
|
*/
|
|
14
|
-
export const GraphPlugin = ()
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
]);
|
|
16
|
+
export const GraphPlugin = Plugin.define(meta).pipe(
|
|
17
|
+
Plugin.addModule({
|
|
18
|
+
activatesOn: Common.ActivationEvent.Startup,
|
|
19
|
+
activatesBefore: [Common.ActivationEvent.SetupAppGraph, Common.ActivationEvent.SetupMetadata],
|
|
20
|
+
activatesAfter: [Common.ActivationEvent.AppGraphReady],
|
|
21
|
+
activate: Graph,
|
|
22
|
+
}),
|
|
23
|
+
Plugin.make,
|
|
24
|
+
);
|
package/src/action.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
import * as Function from 'effect/Function';
|
|
7
|
+
|
|
8
|
+
import { Capability, type CapabilityManager } from '@dxos/app-framework';
|
|
9
|
+
import { type Node } from '@dxos/app-graph';
|
|
10
|
+
import { runAndForwardErrors } from '@dxos/effect';
|
|
11
|
+
import { Operation, type OperationInvoker } from '@dxos/operation';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Run an action with required layers: Operation.Service, Capability.Service, and captured context.
|
|
15
|
+
* @param invoker The operation invoker to use for Operation.Service.
|
|
16
|
+
* @param capabilityManager The capability manager for Capability.Service.
|
|
17
|
+
* @param action The action to execute.
|
|
18
|
+
* @param params Parameters to pass to the action.
|
|
19
|
+
*/
|
|
20
|
+
export const runAction = async (
|
|
21
|
+
invoker: OperationInvoker.OperationInvoker,
|
|
22
|
+
capabilityManager: CapabilityManager.CapabilityManager,
|
|
23
|
+
action: Node.Action,
|
|
24
|
+
params: Node.InvokeProps = {},
|
|
25
|
+
): Promise<void> =>
|
|
26
|
+
runAndForwardErrors(
|
|
27
|
+
action
|
|
28
|
+
.data(params)
|
|
29
|
+
.pipe(
|
|
30
|
+
Effect.provideService(Operation.Service, invoker),
|
|
31
|
+
Effect.provideService(Capability.Service, capabilityManager),
|
|
32
|
+
action._actionContext ? Effect.provide(action._actionContext) : Function.identity,
|
|
33
|
+
),
|
|
34
|
+
);
|
package/src/graph.ts
CHANGED
|
@@ -2,48 +2,58 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
import * as Record from 'effect/Record';
|
|
6
7
|
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
8
|
+
import { Capability, Common } from '@dxos/app-framework';
|
|
9
|
+
import { Graph, GraphBuilder, Node } from '@dxos/app-graph';
|
|
9
10
|
|
|
10
11
|
// TODO(wittjosiah): Remove or restore graph caching.
|
|
11
|
-
// import {
|
|
12
|
-
|
|
13
|
-
// const KEY = `${
|
|
14
|
-
|
|
15
|
-
export default
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
12
|
+
// import { meta } from './meta';
|
|
13
|
+
|
|
14
|
+
// const KEY = `${meta.id}/app-graph`;
|
|
15
|
+
|
|
16
|
+
export default Capability.makeModule(
|
|
17
|
+
Effect.fnUntraced(function* () {
|
|
18
|
+
const registry = yield* Capability.get(Common.Capability.AtomRegistry);
|
|
19
|
+
const extensionsAtom = yield* Capability.atom(Common.Capability.AppGraphBuilder);
|
|
20
|
+
|
|
21
|
+
const builder = GraphBuilder.from(/* localStorage.getItem(KEY) ?? */ undefined, registry);
|
|
22
|
+
// const interval = setInterval(() => {
|
|
23
|
+
// localStorage.setItem(KEY, builder.graph.pickle());
|
|
24
|
+
// }, 5_000);
|
|
25
|
+
|
|
26
|
+
const unsubscribe = registry.subscribe(
|
|
27
|
+
extensionsAtom,
|
|
28
|
+
(extensions) => {
|
|
29
|
+
const next = GraphBuilder.flattenExtensions(extensions);
|
|
30
|
+
const current = Record.values(registry.get(builder.extensions));
|
|
31
|
+
const removed = current.filter(({ id }) => !next.some(({ id: nextId }) => nextId === id));
|
|
32
|
+
removed.forEach((extension) => GraphBuilder.removeExtension(builder, extension.id));
|
|
33
|
+
next.forEach((extension) => GraphBuilder.addExtension(builder, extension));
|
|
34
|
+
},
|
|
35
|
+
{ immediate: true },
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
// await builder.initialize();
|
|
39
|
+
void Graph.expand(builder.graph, Node.RootId);
|
|
40
|
+
|
|
41
|
+
setupDevtools(builder.graph);
|
|
42
|
+
|
|
43
|
+
return Capability.contributes(
|
|
44
|
+
Common.Capability.AppGraph,
|
|
45
|
+
{ graph: builder.graph, explore: GraphBuilder.explore },
|
|
46
|
+
() =>
|
|
47
|
+
Effect.sync(() => {
|
|
48
|
+
// clearInterval(interval);
|
|
49
|
+
unsubscribe();
|
|
50
|
+
}),
|
|
51
|
+
);
|
|
52
|
+
}),
|
|
53
|
+
);
|
|
44
54
|
|
|
45
55
|
// Expose the graph to the window for debugging.
|
|
46
|
-
const setupDevtools = (graph: ExpandableGraph) => {
|
|
56
|
+
const setupDevtools = (graph: Graph.ExpandableGraph) => {
|
|
47
57
|
(globalThis as any).composer ??= {};
|
|
48
58
|
(globalThis as any).composer.graph = graph;
|
|
49
59
|
};
|
package/src/hooks/index.ts
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { useCallback } from 'react';
|
|
6
|
+
|
|
7
|
+
import { useOperationInvoker, usePluginManager } from '@dxos/app-framework/react';
|
|
8
|
+
import { type Node } from '@dxos/app-graph';
|
|
9
|
+
|
|
10
|
+
import { runAction } from '../action';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Hook that returns a function to run action Effects.
|
|
14
|
+
* Provides Operation.Service, PluginContextService, and captured plugin context.
|
|
15
|
+
*/
|
|
16
|
+
export const useActionRunner = () => {
|
|
17
|
+
const invoker = useOperationInvoker();
|
|
18
|
+
const pluginManager = usePluginManager();
|
|
19
|
+
|
|
20
|
+
return useCallback(
|
|
21
|
+
(action: Node.Action, params: Node.InvokeProps = {}) =>
|
|
22
|
+
runAction(invoker, pluginManager.capabilities, action, params),
|
|
23
|
+
[invoker, pluginManager.capabilities],
|
|
24
|
+
);
|
|
25
|
+
};
|
package/src/hooks/useNode.ts
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
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
|
-
import { type
|
|
8
|
+
import { type Graph, type Node } from '@dxos/app-graph';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* React hook to get a node from the graph.
|
|
@@ -16,14 +16,14 @@ import { type ReadableGraph, type Node, type Relation } from '@dxos/app-graph';
|
|
|
16
16
|
* @returns Node if found, undefined otherwise.
|
|
17
17
|
*/
|
|
18
18
|
// TODO(wittjosiah): Factor out to @dxos/app-graph/react.
|
|
19
|
-
export const useNode = <T = any>(graph: ReadableGraph, id?: string): Node<T> | undefined => {
|
|
20
|
-
return Option.getOrElse(
|
|
19
|
+
export const useNode = <T = any>(graph: Graph.ReadableGraph, id?: string): Node.Node<T> | undefined => {
|
|
20
|
+
return Option.getOrElse(useAtomValue(graph.node(id ?? '')), () => undefined);
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
export const useConnections = (graph: ReadableGraph, id?: string, relation?: Relation): Node[] => {
|
|
24
|
-
return
|
|
23
|
+
export const useConnections = (graph: Graph.ReadableGraph, id?: string, relation?: Node.Relation): Node.Node[] => {
|
|
24
|
+
return useAtomValue(graph.connections(id ?? '', relation));
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
export const useActions = (graph: ReadableGraph, id?: string): Node[] => {
|
|
28
|
-
return
|
|
27
|
+
export const useActions = (graph: Graph.ReadableGraph, id?: string): Node.Node[] => {
|
|
28
|
+
return useAtomValue(graph.actions(id ?? ''));
|
|
29
29
|
};
|
package/src/index.ts
CHANGED
package/src/meta.ts
CHANGED
|
@@ -2,11 +2,14 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type
|
|
5
|
+
import { type Plugin } from '@dxos/app-framework';
|
|
6
|
+
import { trim } from '@dxos/util';
|
|
6
7
|
|
|
7
|
-
export const
|
|
8
|
-
|
|
9
|
-
export const meta: PluginMeta = {
|
|
10
|
-
id: GRAPH_PLUGIN,
|
|
8
|
+
export const meta: Plugin.Meta = {
|
|
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,37 +0,0 @@
|
|
|
1
|
-
// src/graph.ts
|
|
2
|
-
import { Record } from "effect";
|
|
3
|
-
import { Capabilities, contributes } from "@dxos/app-framework";
|
|
4
|
-
import { flattenExtensions, GraphBuilder, ROOT_ID } from "@dxos/app-graph";
|
|
5
|
-
var graph_default = async (context) => {
|
|
6
|
-
const registry = context.getCapability(Capabilities.RxRegistry);
|
|
7
|
-
const builder = GraphBuilder.from(
|
|
8
|
-
/* localStorage.getItem(KEY) ?? */
|
|
9
|
-
void 0,
|
|
10
|
-
registry
|
|
11
|
-
);
|
|
12
|
-
const unsubscribe = registry.subscribe(context.capabilities(Capabilities.AppGraphBuilder), (extensions) => {
|
|
13
|
-
const next = flattenExtensions(extensions);
|
|
14
|
-
const current = Record.values(registry.get(builder.extensions));
|
|
15
|
-
const removed = current.filter(({ id }) => !next.some(({ id: nextId }) => nextId === id));
|
|
16
|
-
removed.forEach((extension) => builder.removeExtension(extension.id));
|
|
17
|
-
next.forEach((extension) => builder.addExtension(extension));
|
|
18
|
-
}, {
|
|
19
|
-
immediate: true
|
|
20
|
-
});
|
|
21
|
-
void builder.graph.expand(ROOT_ID);
|
|
22
|
-
setupDevtools(builder.graph);
|
|
23
|
-
return contributes(Capabilities.AppGraph, {
|
|
24
|
-
graph: builder.graph,
|
|
25
|
-
explore: builder.explore
|
|
26
|
-
}, () => {
|
|
27
|
-
unsubscribe();
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
var setupDevtools = (graph) => {
|
|
31
|
-
globalThis.composer ??= {};
|
|
32
|
-
globalThis.composer.graph = graph;
|
|
33
|
-
};
|
|
34
|
-
export {
|
|
35
|
-
graph_default as default
|
|
36
|
-
};
|
|
37
|
-
//# sourceMappingURL=graph-IRZE7I2B.mjs.map
|
|
@@ -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, contributes, type PluginContext } from '@dxos/app-framework';\nimport { flattenExtensions, GraphBuilder, type ExpandableGraph, ROOT_ID } 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,cAAcC,mBAAuC;AAC9D,SAASC,mBAAmBC,cAAoCC,eAAe;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;AACpBO,aAAmBC,aAAa,CAAC;AACjCD,aAAmBC,SAASR,QAAQA;AACvC;",
|
|
6
|
-
"names": ["Record", "Capabilities", "contributes", "flattenExtensions", "GraphBuilder", "ROOT_ID", "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,39 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
|
|
3
|
-
// src/graph.ts
|
|
4
|
-
import { Record } from "effect";
|
|
5
|
-
import { Capabilities, contributes } from "@dxos/app-framework";
|
|
6
|
-
import { flattenExtensions, GraphBuilder, ROOT_ID } from "@dxos/app-graph";
|
|
7
|
-
var graph_default = async (context) => {
|
|
8
|
-
const registry = context.getCapability(Capabilities.RxRegistry);
|
|
9
|
-
const builder = GraphBuilder.from(
|
|
10
|
-
/* localStorage.getItem(KEY) ?? */
|
|
11
|
-
void 0,
|
|
12
|
-
registry
|
|
13
|
-
);
|
|
14
|
-
const unsubscribe = registry.subscribe(context.capabilities(Capabilities.AppGraphBuilder), (extensions) => {
|
|
15
|
-
const next = flattenExtensions(extensions);
|
|
16
|
-
const current = Record.values(registry.get(builder.extensions));
|
|
17
|
-
const removed = current.filter(({ id }) => !next.some(({ id: nextId }) => nextId === id));
|
|
18
|
-
removed.forEach((extension) => builder.removeExtension(extension.id));
|
|
19
|
-
next.forEach((extension) => builder.addExtension(extension));
|
|
20
|
-
}, {
|
|
21
|
-
immediate: true
|
|
22
|
-
});
|
|
23
|
-
void builder.graph.expand(ROOT_ID);
|
|
24
|
-
setupDevtools(builder.graph);
|
|
25
|
-
return contributes(Capabilities.AppGraph, {
|
|
26
|
-
graph: builder.graph,
|
|
27
|
-
explore: builder.explore
|
|
28
|
-
}, () => {
|
|
29
|
-
unsubscribe();
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
var setupDevtools = (graph) => {
|
|
33
|
-
globalThis.composer ??= {};
|
|
34
|
-
globalThis.composer.graph = graph;
|
|
35
|
-
};
|
|
36
|
-
export {
|
|
37
|
-
graph_default as default
|
|
38
|
-
};
|
|
39
|
-
//# sourceMappingURL=graph-7HKX6CAT.mjs.map
|
|
@@ -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, contributes, type PluginContext } from '@dxos/app-framework';\nimport { flattenExtensions, GraphBuilder, type ExpandableGraph, ROOT_ID } 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,cAAcC,mBAAuC;AAC9D,SAASC,mBAAmBC,cAAoCC,eAAe;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;AACpBO,aAAmBC,aAAa,CAAC;AACjCD,aAAmBC,SAASR,QAAQA;AACvC;",
|
|
6
|
-
"names": ["Record", "Capabilities", "contributes", "flattenExtensions", "GraphBuilder", "ROOT_ID", "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
|
-
}
|