@dxos/plugin-graph 0.8.4-main.84f28bd → 0.8.4-main.9735255

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.
Files changed (40) hide show
  1. package/dist/lib/browser/graph-PXKA3JXN.mjs +39 -0
  2. package/dist/lib/browser/graph-PXKA3JXN.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +47 -24
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/node-esm/graph-CR2XR64B.mjs +41 -0
  7. package/dist/lib/node-esm/graph-CR2XR64B.mjs.map +7 -0
  8. package/dist/lib/node-esm/index.mjs +47 -24
  9. package/dist/lib/node-esm/index.mjs.map +4 -4
  10. package/dist/lib/node-esm/meta.json +1 -1
  11. package/dist/types/src/GraphPlugin.d.ts +2 -1
  12. package/dist/types/src/GraphPlugin.d.ts.map +1 -1
  13. package/dist/types/src/action.d.ts +12 -0
  14. package/dist/types/src/action.d.ts.map +1 -0
  15. package/dist/types/src/graph.d.ts +7 -6
  16. package/dist/types/src/graph.d.ts.map +1 -1
  17. package/dist/types/src/hooks/index.d.ts +1 -0
  18. package/dist/types/src/hooks/index.d.ts.map +1 -1
  19. package/dist/types/src/hooks/useActionRunner.d.ts +7 -0
  20. package/dist/types/src/hooks/useActionRunner.d.ts.map +1 -0
  21. package/dist/types/src/hooks/useNode.d.ts +4 -4
  22. package/dist/types/src/hooks/useNode.d.ts.map +1 -1
  23. package/dist/types/src/index.d.ts +1 -0
  24. package/dist/types/src/index.d.ts.map +1 -1
  25. package/dist/types/src/meta.d.ts +2 -3
  26. package/dist/types/src/meta.d.ts.map +1 -1
  27. package/dist/types/tsconfig.tsbuildinfo +1 -1
  28. package/package.json +28 -21
  29. package/src/GraphPlugin.ts +12 -11
  30. package/src/action.ts +34 -0
  31. package/src/graph.ts +47 -37
  32. package/src/hooks/index.ts +1 -0
  33. package/src/hooks/useActionRunner.ts +25 -0
  34. package/src/hooks/useNode.ts +9 -9
  35. package/src/index.ts +1 -0
  36. package/src/meta.ts +8 -5
  37. package/dist/lib/browser/graph-IRZE7I2B.mjs +0 -37
  38. package/dist/lib/browser/graph-IRZE7I2B.mjs.map +0 -7
  39. package/dist/lib/node-esm/graph-7HKX6CAT.mjs +0 -39
  40. 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.84f28bd",
3
+ "version": "0.8.4-main.9735255",
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
- "@preact-signals/safe-react": "^0.9.0",
28
- "@dxos/app-framework": "0.8.4-main.84f28bd",
29
- "@dxos/app-graph": "0.8.4-main.84f28bd",
30
- "@dxos/async": "0.8.4-main.84f28bd",
31
- "@dxos/debug": "0.8.4-main.84f28bd"
32
+ "@dxos/app-framework": "0.8.4-main.9735255",
33
+ "@dxos/app-graph": "0.8.4-main.9735255",
34
+ "@dxos/async": "0.8.4-main.9735255",
35
+ "@dxos/effect": "0.8.4-main.9735255",
36
+ "@dxos/debug": "0.8.4-main.9735255",
37
+ "@dxos/util": "0.8.4-main.9735255",
38
+ "@dxos/operation": "0.8.4-main.9735255"
32
39
  },
33
40
  "devDependencies": {
34
- "@effect-rx/rx-react": "0.38.0",
35
- "@effect/platform": "0.88.0",
36
- "@types/react": "~18.2.0",
37
- "@types/react-dom": "~18.2.0",
38
- "effect": "3.16.13",
39
- "react": "~18.2.0",
40
- "react-dom": "~18.2.0",
41
- "vite": "5.4.7",
42
- "@dxos/react-client": "0.8.4-main.84f28bd",
43
- "@dxos/storybook-utils": "0.8.4-main.84f28bd"
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.9735255",
50
+ "@dxos/storybook-utils": "0.8.4-main.9735255"
44
51
  },
45
52
  "peerDependencies": {
46
- "@effect-rx/rx-react": "^0.34.1",
47
- "@effect/platform": "^0.80.12",
48
- "effect": "^3.13.3",
49
- "react": "~18.2.0",
50
- "react-dom": "~18.2.0"
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"
@@ -2,22 +2,23 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { defineModule, lazy, Events, definePlugin } from '@dxos/app-framework';
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
- definePlugin(meta, [
16
- defineModule({
17
- id: `${meta.id}/module/graph`,
18
- activatesOn: Events.Startup,
19
- activatesBefore: [Events.SetupAppGraph, Events.SetupMetadata],
20
- activatesAfter: [Events.AppGraphReady],
21
- activate: lazy(() => import('./graph')),
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 { Record } from 'effect';
5
+ import * as Effect from 'effect/Effect';
6
+ import * as Record from 'effect/Record';
6
7
 
7
- import { Capabilities, contributes, type PluginContext } from '@dxos/app-framework';
8
- import { flattenExtensions, GraphBuilder, type ExpandableGraph, ROOT_ID } from '@dxos/app-graph';
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 { GRAPH_PLUGIN } from './meta';
12
-
13
- // const KEY = `${GRAPH_PLUGIN}/app-graph`;
14
-
15
- export default async (context: PluginContext) => {
16
- const registry = context.getCapability(Capabilities.RxRegistry);
17
- const builder = GraphBuilder.from(/* localStorage.getItem(KEY) ?? */ undefined, registry);
18
- // const interval = setInterval(() => {
19
- // localStorage.setItem(KEY, builder.graph.pickle());
20
- // }, 5_000);
21
-
22
- const unsubscribe = registry.subscribe(
23
- context.capabilities(Capabilities.AppGraphBuilder),
24
- (extensions) => {
25
- const next = flattenExtensions(extensions);
26
- const current = Record.values(registry.get(builder.extensions));
27
- const removed = current.filter(({ id }) => !next.some(({ id: nextId }) => nextId === id));
28
- removed.forEach((extension) => builder.removeExtension(extension.id));
29
- next.forEach((extension) => builder.addExtension(extension));
30
- },
31
- { immediate: true },
32
- );
33
-
34
- // await builder.initialize();
35
- void builder.graph.expand(ROOT_ID);
36
-
37
- setupDevtools(builder.graph);
38
-
39
- return contributes(Capabilities.AppGraph, { graph: builder.graph, explore: builder.explore }, () => {
40
- // clearInterval(interval);
41
- unsubscribe();
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
  };
@@ -2,4 +2,5 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
+ export * from './useActionRunner';
5
6
  export * from './useNode';
@@ -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
+ };
@@ -2,10 +2,10 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { useRxValue } from '@effect-rx/rx-react';
6
- import { Option } from 'effect';
5
+ import { useAtomValue } from '@effect-atom/atom-react';
6
+ import * as Option from 'effect/Option';
7
7
 
8
- import { type ReadableGraph, type Node, type Relation } from '@dxos/app-graph';
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(useRxValue(graph.node(id ?? '')), () => undefined);
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 useRxValue(graph.connections(id ?? '', relation));
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 useRxValue(graph.actions(id ?? ''));
27
+ export const useActions = (graph: Graph.ReadableGraph, id?: string): Node.Node[] => {
28
+ return useAtomValue(graph.actions(id ?? ''));
29
29
  };
package/src/index.ts CHANGED
@@ -4,6 +4,7 @@
4
4
 
5
5
  export * from '@dxos/app-graph';
6
6
 
7
+ export * from './action';
7
8
  export * from './GraphPlugin';
8
9
  export * from './hooks';
9
10
  export * from './meta';
package/src/meta.ts CHANGED
@@ -2,11 +2,14 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { type PluginMeta } from '@dxos/app-framework';
5
+ import { type Plugin } from '@dxos/app-framework';
6
+ import { trim } from '@dxos/util';
6
7
 
7
- export const GRAPH_PLUGIN = 'dxos.org/plugin/graph';
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
- }