@dxos/plugin-graph 0.8.2-main.fbd8ed0 → 0.8.2-staging.7ac8446

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 (35) hide show
  1. package/README.md +3 -1
  2. package/dist/lib/browser/chunk-L263B77P.mjs +12 -0
  3. package/dist/lib/browser/chunk-L263B77P.mjs.map +7 -0
  4. package/dist/lib/browser/graph-UYXVVZ2I.mjs +42 -0
  5. package/dist/lib/browser/graph-UYXVVZ2I.mjs.map +7 -0
  6. package/dist/lib/browser/index.mjs +33 -22
  7. package/dist/lib/browser/index.mjs.map +4 -4
  8. package/dist/lib/browser/meta.json +1 -1
  9. package/dist/lib/node/chunk-AKNWBLRY.cjs +35 -0
  10. package/dist/lib/node/chunk-AKNWBLRY.cjs.map +7 -0
  11. package/dist/lib/node/{graph-IZROFGJQ.cjs → graph-GCGIYOGJ.cjs} +23 -26
  12. package/dist/lib/node/graph-GCGIYOGJ.cjs.map +7 -0
  13. package/dist/lib/node/index.cjs +33 -24
  14. package/dist/lib/node/index.cjs.map +4 -4
  15. package/dist/lib/node/meta.json +1 -1
  16. package/dist/lib/node-esm/chunk-RJQY6JZL.mjs +14 -0
  17. package/dist/lib/node-esm/chunk-RJQY6JZL.mjs.map +7 -0
  18. package/dist/lib/node-esm/graph-NUZMWBDN.mjs +43 -0
  19. package/dist/lib/node-esm/graph-NUZMWBDN.mjs.map +7 -0
  20. package/dist/lib/node-esm/index.mjs +32 -22
  21. package/dist/lib/node-esm/index.mjs.map +4 -4
  22. package/dist/lib/node-esm/meta.json +1 -1
  23. package/dist/types/src/graph.d.ts +5 -5
  24. package/dist/types/src/graph.d.ts.map +1 -1
  25. package/dist/types/src/hooks/useNode.d.ts +2 -4
  26. package/dist/types/src/hooks/useNode.d.ts.map +1 -1
  27. package/dist/types/tsconfig.tsbuildinfo +1 -1
  28. package/package.json +8 -13
  29. package/src/graph.ts +27 -32
  30. package/src/hooks/useNode.ts +29 -12
  31. package/dist/lib/browser/graph-5AJD2WYC.mjs +0 -42
  32. package/dist/lib/browser/graph-5AJD2WYC.mjs.map +0 -7
  33. package/dist/lib/node/graph-IZROFGJQ.cjs.map +0 -7
  34. package/dist/lib/node-esm/graph-NJMEGQY3.mjs +0 -44
  35. package/dist/lib/node-esm/graph-NJMEGQY3.mjs.map +0 -7
package/README.md CHANGED
@@ -1,4 +1,6 @@
1
- # @dxos/plugin-graph
1
+ # @dxos/plugin-client
2
+
3
+ Surface plugin for DXOS Client.
2
4
 
3
5
  ## DXOS Resources
4
6
 
@@ -0,0 +1,12 @@
1
+ // packages/plugins/plugin-graph/src/meta.ts
2
+ var GRAPH_PLUGIN = "dxos.org/plugin/graph";
3
+ var meta = {
4
+ id: GRAPH_PLUGIN,
5
+ name: "Graph"
6
+ };
7
+
8
+ export {
9
+ GRAPH_PLUGIN,
10
+ meta
11
+ };
12
+ //# sourceMappingURL=chunk-L263B77P.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/meta.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const GRAPH_PLUGIN = 'dxos.org/plugin/graph';\n\nexport const meta: PluginMeta = {\n id: GRAPH_PLUGIN,\n name: 'Graph',\n};\n"],
5
+ "mappings": ";AAMO,IAAMA,eAAe;AAErB,IAAMC,OAAmB;EAC9BC,IAAIF;EACJG,MAAM;AACR;",
6
+ "names": ["GRAPH_PLUGIN", "meta", "id", "name"]
7
+ }
@@ -0,0 +1,42 @@
1
+ import {
2
+ GRAPH_PLUGIN
3
+ } from "./chunk-L263B77P.mjs";
4
+
5
+ // packages/plugins/plugin-graph/src/graph.ts
6
+ import { batch, effect, untracked } from "@preact/signals-core";
7
+ import { Capabilities, contributes } from "@dxos/app-framework";
8
+ import { flattenExtensions, GraphBuilder } from "@dxos/app-graph";
9
+ var KEY = `${GRAPH_PLUGIN}/app-graph`;
10
+ var graph_default = async (context) => {
11
+ const builder = GraphBuilder.from(localStorage.getItem(KEY) ?? void 0);
12
+ const interval = setInterval(() => {
13
+ localStorage.setItem(KEY, builder.graph.pickle());
14
+ }, 5e3);
15
+ const unsubscribe = effect(() => {
16
+ batch(() => {
17
+ const next = flattenExtensions(context.requestCapabilities(Capabilities.AppGraphBuilder));
18
+ const current = untracked(() => builder.extensions);
19
+ const removed = current.filter(({ id }) => !next.some(({ id: nextId }) => nextId === id));
20
+ removed.forEach((extension) => builder.removeExtension(extension.id));
21
+ next.forEach((extension) => builder.addExtension(extension));
22
+ });
23
+ });
24
+ await builder.initialize();
25
+ await builder.graph.expand(builder.graph.root);
26
+ setupDevtools(builder.graph);
27
+ return contributes(Capabilities.AppGraph, {
28
+ graph: builder.graph,
29
+ explore: (options) => builder.explore(options)
30
+ }, () => {
31
+ clearInterval(interval);
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-UYXVVZ2I.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 { batch, effect, untracked } from '@preact/signals-core';\n\nimport { Capabilities, contributes, type PluginsContext } from '@dxos/app-framework';\nimport { flattenExtensions, type Graph, GraphBuilder } from '@dxos/app-graph';\n\nimport { GRAPH_PLUGIN } from './meta';\n\nconst KEY = `${GRAPH_PLUGIN}/app-graph`;\n\nexport default async (context: PluginsContext) => {\n const builder = GraphBuilder.from(localStorage.getItem(KEY) ?? undefined);\n const interval = setInterval(() => {\n localStorage.setItem(KEY, builder.graph.pickle());\n }, 5_000);\n\n const unsubscribe = effect(() => {\n batch(() => {\n const next = flattenExtensions(context.requestCapabilities(Capabilities.AppGraphBuilder));\n const current = untracked(() => 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 });\n\n await builder.initialize();\n await builder.graph.expand(builder.graph.root);\n\n setupDevtools(builder.graph);\n\n return contributes(\n Capabilities.AppGraph,\n { graph: builder.graph, explore: (options) => builder.explore(options) },\n () => {\n clearInterval(interval);\n unsubscribe();\n },\n );\n};\n\n// Expose the graph to the window for debugging.\nconst setupDevtools = (graph: Graph) => {\n (globalThis as any).composer ??= {};\n (globalThis as any).composer.graph = graph;\n};\n"],
5
+ "mappings": ";;;;;AAIA,SAASA,OAAOC,QAAQC,iBAAiB;AAEzC,SAASC,cAAcC,mBAAwC;AAC/D,SAASC,mBAA+BC,oBAAoB;AAI5D,IAAMC,MAAM,GAAGC,YAAAA;AAEf,IAAA,gBAAe,OAAOC,YAAAA;AACpB,QAAMC,UAAUC,aAAaC,KAAKC,aAAaC,QAAQP,GAAAA,KAAQQ,MAAAA;AAC/D,QAAMC,WAAWC,YAAY,MAAA;AAC3BJ,iBAAaK,QAAQX,KAAKG,QAAQS,MAAMC,OAAM,CAAA;EAChD,GAAG,GAAA;AAEH,QAAMC,cAAcC,OAAO,MAAA;AACzBC,UAAM,MAAA;AACJ,YAAMC,OAAOC,kBAAkBhB,QAAQiB,oBAAoBC,aAAaC,eAAe,CAAA;AACvF,YAAMC,UAAUC,UAAU,MAAMpB,QAAQqB,UAAU;AAClD,YAAMC,UAAUH,QAAQI,OAAO,CAAC,EAAEC,GAAE,MAAO,CAACV,KAAKW,KAAK,CAAC,EAAED,IAAIE,OAAM,MAAOA,WAAWF,EAAAA,CAAAA;AACrFF,cAAQK,QAAQ,CAACC,cAAc5B,QAAQ6B,gBAAgBD,UAAUJ,EAAE,CAAA;AACnEV,WAAKa,QAAQ,CAACC,cAAc5B,QAAQ8B,aAAaF,SAAAA,CAAAA;IACnD,CAAA;EACF,CAAA;AAEA,QAAM5B,QAAQ+B,WAAU;AACxB,QAAM/B,QAAQS,MAAMuB,OAAOhC,QAAQS,MAAMwB,IAAI;AAE7CC,gBAAclC,QAAQS,KAAK;AAE3B,SAAO0B,YACLlB,aAAamB,UACb;IAAE3B,OAAOT,QAAQS;IAAO4B,SAAS,CAACC,YAAYtC,QAAQqC,QAAQC,OAAAA;EAAS,GACvE,MAAA;AACEC,kBAAcjC,QAAAA;AACdK,gBAAAA;EACF,CAAA;AAEJ;AAGA,IAAMuB,gBAAgB,CAACzB,UAAAA;AACpB+B,aAAmBC,aAAa,CAAC;AACjCD,aAAmBC,SAAShC,QAAQA;AACvC;",
6
+ "names": ["batch", "effect", "untracked", "Capabilities", "contributes", "flattenExtensions", "GraphBuilder", "KEY", "GRAPH_PLUGIN", "context", "builder", "GraphBuilder", "from", "localStorage", "getItem", "undefined", "interval", "setInterval", "setItem", "graph", "pickle", "unsubscribe", "effect", "batch", "next", "flattenExtensions", "requestCapabilities", "Capabilities", "AppGraphBuilder", "current", "untracked", "extensions", "removed", "filter", "id", "some", "nextId", "forEach", "extension", "removeExtension", "addExtension", "initialize", "expand", "root", "setupDevtools", "contributes", "AppGraph", "explore", "options", "clearInterval", "globalThis", "composer"]
7
+ }
@@ -1,17 +1,13 @@
1
+ import {
2
+ GRAPH_PLUGIN,
3
+ meta
4
+ } from "./chunk-L263B77P.mjs";
5
+
1
6
  // packages/plugins/plugin-graph/src/index.ts
2
7
  export * from "@dxos/app-graph";
3
8
 
4
9
  // packages/plugins/plugin-graph/src/GraphPlugin.ts
5
10
  import { defineModule, lazy, Events, definePlugin } from "@dxos/app-framework";
6
-
7
- // packages/plugins/plugin-graph/src/meta.ts
8
- var GRAPH_PLUGIN = "dxos.org/plugin/graph";
9
- var meta = {
10
- id: GRAPH_PLUGIN,
11
- name: "Graph"
12
- };
13
-
14
- // packages/plugins/plugin-graph/src/GraphPlugin.ts
15
11
  var GraphPlugin = () => definePlugin(meta, [
16
12
  defineModule({
17
13
  id: `${meta.id}/module/graph`,
@@ -23,28 +19,43 @@ var GraphPlugin = () => definePlugin(meta, [
23
19
  activatesAfter: [
24
20
  Events.AppGraphReady
25
21
  ],
26
- activate: lazy(() => import("./graph-5AJD2WYC.mjs"))
22
+ activate: lazy(() => import("./graph-UYXVVZ2I.mjs"))
27
23
  })
28
24
  ]);
29
25
 
30
26
  // packages/plugins/plugin-graph/src/hooks/useNode.ts
31
- import { useRxValue } from "@effect-rx/rx-react";
32
- import { Option } from "effect";
33
- var useNode = (graph, id) => {
34
- return Option.getOrElse(useRxValue(graph.node(id ?? "")), () => void 0);
35
- };
36
- var useConnections = (graph, id, relation) => {
37
- return useRxValue(graph.connections(id ?? "", relation));
38
- };
39
- var useActions = (graph, id) => {
40
- return useRxValue(graph.actions(id ?? ""));
27
+ import { useEffect, useState } from "react";
28
+ var useNode = (graph, id, timeout) => {
29
+ const [nodeState, setNodeState] = useState(id ? graph.findNode(id, false) : void 0);
30
+ useEffect(() => {
31
+ if (!id && nodeState) {
32
+ setNodeState(void 0);
33
+ }
34
+ if (nodeState?.id === id || !id) {
35
+ return;
36
+ }
37
+ const frame = requestAnimationFrame(async () => {
38
+ try {
39
+ const node = await graph.waitForNode(id, timeout);
40
+ if (node) {
41
+ setNodeState(node);
42
+ }
43
+ } catch {
44
+ }
45
+ });
46
+ return () => cancelAnimationFrame(frame);
47
+ }, [
48
+ graph,
49
+ id,
50
+ timeout,
51
+ nodeState?.id
52
+ ]);
53
+ return nodeState;
41
54
  };
42
55
  export {
43
56
  GRAPH_PLUGIN,
44
57
  GraphPlugin,
45
58
  meta,
46
- useActions,
47
- useConnections,
48
59
  useNode
49
60
  };
50
61
  //# 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 { defineModule, lazy, Events, definePlugin } from '@dxos/app-framework';\n\nimport { meta } from './meta';\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 = () =>\n definePlugin(meta, [\n defineModule({\n id: `${meta.id}/module/graph`,\n activatesOn: Events.Startup,\n activatesBefore: [Events.SetupAppGraph, Events.SetupMetadata],\n activatesAfter: [Events.AppGraphReady],\n activate: lazy(() => import('./graph')),\n }),\n ]);\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const GRAPH_PLUGIN = 'dxos.org/plugin/graph';\n\nexport const meta: PluginMeta = {\n id: GRAPH_PLUGIN,\n name: 'Graph',\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { useRxValue } from '@effect-rx/rx-react';\nimport { Option } from 'effect';\n\nimport { type ReadableGraph, type Node, type Relation } 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: ReadableGraph, id?: string): Node<T> | undefined => {\n return Option.getOrElse(useRxValue(graph.node(id ?? '')), () => undefined);\n};\n\nexport const useConnections = (graph: ReadableGraph, id?: string, relation?: Relation): Node[] => {\n return useRxValue(graph.connections(id ?? '', relation));\n};\n\nexport const useActions = (graph: ReadableGraph, id?: string): Node[] => {\n return useRxValue(graph.actions(id ?? ''));\n};\n"],
5
- "mappings": ";AAIA,cAAc;;;ACAd,SAASA,cAAcC,MAAMC,QAAQC,oBAAoB;;;ACElD,IAAMC,eAAe;AAErB,IAAMC,OAAmB;EAC9BC,IAAIF;EACJG,MAAM;AACR;;;ADEO,IAAMC,cAAc,MACzBC,aAAaC,MAAM;EACjBC,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAOC;IACpBC,iBAAiB;MAACF,OAAOG;MAAeH,OAAOI;;IAC/CC,gBAAgB;MAACL,OAAOM;;IACxBC,UAAUC,KAAK,MAAM,OAAO,sBAAA,CAAA;EAC9B,CAAA;CACD;;;AElBH,SAASC,kBAAkB;AAC3B,SAASC,cAAc;AAahB,IAAMC,UAAU,CAAUC,OAAsBC,OAAAA;AACrD,SAAOC,OAAOC,UAAUC,WAAWJ,MAAMK,KAAKJ,MAAM,EAAA,CAAA,GAAM,MAAMK,MAAAA;AAClE;AAEO,IAAMC,iBAAiB,CAACP,OAAsBC,IAAaO,aAAAA;AAChE,SAAOJ,WAAWJ,MAAMS,YAAYR,MAAM,IAAIO,QAAAA,CAAAA;AAChD;AAEO,IAAME,aAAa,CAACV,OAAsBC,OAAAA;AAC/C,SAAOG,WAAWJ,MAAMW,QAAQV,MAAM,EAAA,CAAA;AACxC;",
6
- "names": ["defineModule", "lazy", "Events", "definePlugin", "GRAPH_PLUGIN", "meta", "id", "name", "GraphPlugin", "definePlugin", "meta", "defineModule", "id", "activatesOn", "Events", "Startup", "activatesBefore", "SetupAppGraph", "SetupMetadata", "activatesAfter", "AppGraphReady", "activate", "lazy", "useRxValue", "Option", "useNode", "graph", "id", "Option", "getOrElse", "useRxValue", "node", "undefined", "useConnections", "relation", "connections", "useActions", "actions"]
3
+ "sources": ["../../../src/index.ts", "../../../src/GraphPlugin.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 { defineModule, lazy, Events, definePlugin } from '@dxos/app-framework';\n\nimport { meta } from './meta';\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 = () =>\n definePlugin(meta, [\n defineModule({\n id: `${meta.id}/module/graph`,\n activatesOn: Events.Startup,\n activatesBefore: [Events.SetupAppGraph, Events.SetupMetadata],\n activatesAfter: [Events.AppGraphReady],\n activate: lazy(() => import('./graph')),\n }),\n ]);\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { useEffect, useState } from 'react';\n\nimport { type Graph, type Node } from '@dxos/app-graph';\n\n/**\n * React hook to get a node from the graph.\n *\n * @param graph Graph to find the node in.\n * @param id Id of the node to find.\n * @param timeout Optional timeout in milliseconds to wait for the node to be found.\n * @returns Node if found, undefined otherwise.\n */\n// TODO(wittjosiah): Factor out?\nexport const useNode = <T = any>(graph: Graph, id?: string, timeout?: number): Node<T> | undefined => {\n const [nodeState, setNodeState] = useState<Node<T> | undefined>(id ? graph.findNode(id, false) : undefined);\n\n useEffect(() => {\n if (!id && nodeState) {\n setNodeState(undefined);\n }\n\n if (nodeState?.id === id || !id) {\n return;\n }\n\n // Set timeout did not seem to effectively not block the UI thread.\n const frame = requestAnimationFrame(async () => {\n try {\n const node = await graph.waitForNode(id, timeout);\n if (node) {\n setNodeState(node);\n }\n } catch {\n // TODO(ZaymonFC): This leaves the resolved node in an invalid state in the case of a timeout.\n }\n });\n\n return () => cancelAnimationFrame(frame);\n }, [graph, id, timeout, nodeState?.id]);\n\n return nodeState;\n};\n"],
5
+ "mappings": ";;;;;;AAIA,cAAc;;;ACAd,SAASA,cAAcC,MAAMC,QAAQC,oBAAoB;AASlD,IAAMC,cAAc,MACzBC,aAAaC,MAAM;EACjBC,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAOC;IACpBC,iBAAiB;MAACF,OAAOG;MAAeH,OAAOI;;IAC/CC,gBAAgB;MAACL,OAAOM;;IACxBC,UAAUC,KAAK,MAAM,OAAO,sBAAA,CAAA;EAC9B,CAAA;CACD;;;AClBH,SAASC,WAAWC,gBAAgB;AAa7B,IAAMC,UAAU,CAAUC,OAAcC,IAAaC,YAAAA;AAC1D,QAAM,CAACC,WAAWC,YAAAA,IAAgBC,SAA8BJ,KAAKD,MAAMM,SAASL,IAAI,KAAA,IAASM,MAAAA;AAEjGC,YAAU,MAAA;AACR,QAAI,CAACP,MAAME,WAAW;AACpBC,mBAAaG,MAAAA;IACf;AAEA,QAAIJ,WAAWF,OAAOA,MAAM,CAACA,IAAI;AAC/B;IACF;AAGA,UAAMQ,QAAQC,sBAAsB,YAAA;AAClC,UAAI;AACF,cAAMC,OAAO,MAAMX,MAAMY,YAAYX,IAAIC,OAAAA;AACzC,YAAIS,MAAM;AACRP,uBAAaO,IAAAA;QACf;MACF,QAAQ;MAER;IACF,CAAA;AAEA,WAAO,MAAME,qBAAqBJ,KAAAA;EACpC,GAAG;IAACT;IAAOC;IAAIC;IAASC,WAAWF;GAAG;AAEtC,SAAOE;AACT;",
6
+ "names": ["defineModule", "lazy", "Events", "definePlugin", "GraphPlugin", "definePlugin", "meta", "defineModule", "id", "activatesOn", "Events", "Startup", "activatesBefore", "SetupAppGraph", "SetupMetadata", "activatesAfter", "AppGraphReady", "activate", "lazy", "useEffect", "useState", "useNode", "graph", "id", "timeout", "nodeState", "setNodeState", "useState", "findNode", "undefined", "useEffect", "frame", "requestAnimationFrame", "node", "waitForNode", "cancelAnimationFrame"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"packages/plugins/plugin-graph/src/meta.ts":{"bytes":950,"imports":[],"format":"esm"},"packages/plugins/plugin-graph/src/graph.ts":{"bytes":7025,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/app-graph","kind":"import-statement","external":true}],"format":"esm"},"packages/plugins/plugin-graph/src/GraphPlugin.ts":{"bytes":2810,"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-graph/src/meta.ts","kind":"import-statement","original":"./meta"},{"path":"packages/plugins/plugin-graph/src/graph.ts","kind":"dynamic-import","original":"./graph"}],"format":"esm"},"packages/plugins/plugin-graph/src/hooks/useNode.ts":{"bytes":3193,"imports":[{"path":"@effect-rx/rx-react","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true}],"format":"esm"},"packages/plugins/plugin-graph/src/hooks/index.ts":{"bytes":506,"imports":[{"path":"packages/plugins/plugin-graph/src/hooks/useNode.ts","kind":"import-statement","original":"./useNode"}],"format":"esm"},"packages/plugins/plugin-graph/src/index.ts":{"bytes":778,"imports":[{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-graph/src/GraphPlugin.ts","kind":"import-statement","original":"./GraphPlugin"},{"path":"packages/plugins/plugin-graph/src/hooks/index.ts","kind":"import-statement","original":"./hooks"},{"path":"packages/plugins/plugin-graph/src/meta.ts","kind":"import-statement","original":"./meta"}],"format":"esm"}},"outputs":{"packages/plugins/plugin-graph/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":3458},"packages/plugins/plugin-graph/dist/lib/browser/index.mjs":{"imports":[{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-graph/dist/lib/browser/graph-5AJD2WYC.mjs","kind":"dynamic-import"},{"path":"@effect-rx/rx-react","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true}],"exports":["GRAPH_PLUGIN","GraphPlugin","meta","useActions","useConnections","useNode"],"entryPoint":"packages/plugins/plugin-graph/src/index.ts","inputs":{"packages/plugins/plugin-graph/src/index.ts":{"bytesInOutput":33},"packages/plugins/plugin-graph/src/GraphPlugin.ts":{"bytesInOutput":417},"packages/plugins/plugin-graph/src/meta.ts":{"bytesInOutput":96},"packages/plugins/plugin-graph/src/hooks/useNode.ts":{"bytesInOutput":386},"packages/plugins/plugin-graph/src/hooks/index.ts":{"bytesInOutput":0}},"bytes":1313},"packages/plugins/plugin-graph/dist/lib/browser/graph-5AJD2WYC.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":3671},"packages/plugins/plugin-graph/dist/lib/browser/graph-5AJD2WYC.mjs":{"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/app-graph","kind":"import-statement","external":true}],"exports":["default"],"entryPoint":"packages/plugins/plugin-graph/src/graph.ts","inputs":{"packages/plugins/plugin-graph/src/graph.ts":{"bytesInOutput":1331}},"bytes":1460}}}
1
+ {"inputs":{"packages/plugins/plugin-graph/src/meta.ts":{"bytes":950,"imports":[],"format":"esm"},"packages/plugins/plugin-graph/src/graph.ts":{"bytes":6242,"imports":[{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-graph/src/meta.ts","kind":"import-statement","original":"./meta"}],"format":"esm"},"packages/plugins/plugin-graph/src/GraphPlugin.ts":{"bytes":2810,"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-graph/src/meta.ts","kind":"import-statement","original":"./meta"},{"path":"packages/plugins/plugin-graph/src/graph.ts","kind":"dynamic-import","original":"./graph"}],"format":"esm"},"packages/plugins/plugin-graph/src/hooks/useNode.ts":{"bytes":4473,"imports":[{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"packages/plugins/plugin-graph/src/hooks/index.ts":{"bytes":506,"imports":[{"path":"packages/plugins/plugin-graph/src/hooks/useNode.ts","kind":"import-statement","original":"./useNode"}],"format":"esm"},"packages/plugins/plugin-graph/src/index.ts":{"bytes":778,"imports":[{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-graph/src/GraphPlugin.ts","kind":"import-statement","original":"./GraphPlugin"},{"path":"packages/plugins/plugin-graph/src/hooks/index.ts","kind":"import-statement","original":"./hooks"},{"path":"packages/plugins/plugin-graph/src/meta.ts","kind":"import-statement","original":"./meta"}],"format":"esm"}},"outputs":{"packages/plugins/plugin-graph/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":3652},"packages/plugins/plugin-graph/dist/lib/browser/index.mjs":{"imports":[{"path":"packages/plugins/plugin-graph/dist/lib/browser/chunk-L263B77P.mjs","kind":"import-statement"},{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-graph/dist/lib/browser/graph-UYXVVZ2I.mjs","kind":"dynamic-import"},{"path":"react","kind":"import-statement","external":true}],"exports":["GRAPH_PLUGIN","GraphPlugin","meta","useNode"],"entryPoint":"packages/plugins/plugin-graph/src/index.ts","inputs":{"packages/plugins/plugin-graph/src/index.ts":{"bytesInOutput":33},"packages/plugins/plugin-graph/src/GraphPlugin.ts":{"bytesInOutput":417},"packages/plugins/plugin-graph/src/hooks/useNode.ts":{"bytesInOutput":662},"packages/plugins/plugin-graph/src/hooks/index.ts":{"bytesInOutput":0}},"bytes":1426},"packages/plugins/plugin-graph/dist/lib/browser/graph-UYXVVZ2I.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":3429},"packages/plugins/plugin-graph/dist/lib/browser/graph-UYXVVZ2I.mjs":{"imports":[{"path":"packages/plugins/plugin-graph/dist/lib/browser/chunk-L263B77P.mjs","kind":"import-statement"},{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/app-graph","kind":"import-statement","external":true}],"exports":["default"],"entryPoint":"packages/plugins/plugin-graph/src/graph.ts","inputs":{"packages/plugins/plugin-graph/src/graph.ts":{"bytesInOutput":1331}},"bytes":1516},"packages/plugins/plugin-graph/dist/lib/browser/chunk-L263B77P.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":447},"packages/plugins/plugin-graph/dist/lib/browser/chunk-L263B77P.mjs":{"imports":[],"exports":["GRAPH_PLUGIN","meta"],"inputs":{"packages/plugins/plugin-graph/src/meta.ts":{"bytesInOutput":96}},"bytes":221}}}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var chunk_AKNWBLRY_exports = {};
20
+ __export(chunk_AKNWBLRY_exports, {
21
+ GRAPH_PLUGIN: () => GRAPH_PLUGIN,
22
+ meta: () => meta
23
+ });
24
+ module.exports = __toCommonJS(chunk_AKNWBLRY_exports);
25
+ var GRAPH_PLUGIN = "dxos.org/plugin/graph";
26
+ var meta = {
27
+ id: GRAPH_PLUGIN,
28
+ name: "Graph"
29
+ };
30
+ // Annotate the CommonJS export names for ESM import in node:
31
+ 0 && (module.exports = {
32
+ GRAPH_PLUGIN,
33
+ meta
34
+ });
35
+ //# sourceMappingURL=chunk-AKNWBLRY.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/meta.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const GRAPH_PLUGIN = 'dxos.org/plugin/graph';\n\nexport const meta: PluginMeta = {\n id: GRAPH_PLUGIN,\n name: 'Graph',\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAMO,IAAMA,eAAe;AAErB,IAAMC,OAAmB;EAC9BC,IAAIF;EACJG,MAAM;AACR;",
6
+ "names": ["GRAPH_PLUGIN", "meta", "id", "name"]
7
+ }
@@ -16,41 +16,38 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var graph_IZROFGJQ_exports = {};
20
- __export(graph_IZROFGJQ_exports, {
19
+ var graph_GCGIYOGJ_exports = {};
20
+ __export(graph_GCGIYOGJ_exports, {
21
21
  default: () => graph_default
22
22
  });
23
- module.exports = __toCommonJS(graph_IZROFGJQ_exports);
24
- var import_effect = require("effect");
23
+ module.exports = __toCommonJS(graph_GCGIYOGJ_exports);
24
+ var import_chunk_AKNWBLRY = require("./chunk-AKNWBLRY.cjs");
25
+ var import_signals_core = require("@preact/signals-core");
25
26
  var import_app_framework = require("@dxos/app-framework");
26
27
  var import_app_graph = require("@dxos/app-graph");
28
+ var KEY = `${import_chunk_AKNWBLRY.GRAPH_PLUGIN}/app-graph`;
27
29
  var graph_default = async (context) => {
28
- const registry = context.getCapability(import_app_framework.Capabilities.RxRegistry);
29
- const builder = import_app_graph.GraphBuilder.from(
30
- /* localStorage.getItem(KEY) ?? */
31
- void 0,
32
- registry
33
- );
34
- const unsubscribe = registry.subscribe(context.capabilities(import_app_framework.Capabilities.AppGraphBuilder), (extensions) => {
35
- const next = (0, import_app_graph.flattenExtensions)(extensions);
36
- const current = import_effect.Record.values(registry.get(builder.extensions));
37
- const removed = current.filter(({ id }) => !next.some(({ id: nextId }) => nextId === id));
38
- removed.forEach((extension) => builder.removeExtension(extension.id));
39
- next.forEach((extension) => builder.addExtension(extension));
40
- }, {
41
- immediate: true
30
+ const builder = import_app_graph.GraphBuilder.from(localStorage.getItem(KEY) ?? void 0);
31
+ const interval = setInterval(() => {
32
+ localStorage.setItem(KEY, builder.graph.pickle());
33
+ }, 5e3);
34
+ const unsubscribe = (0, import_signals_core.effect)(() => {
35
+ (0, import_signals_core.batch)(() => {
36
+ const next = (0, import_app_graph.flattenExtensions)(context.requestCapabilities(import_app_framework.Capabilities.AppGraphBuilder));
37
+ const current = (0, import_signals_core.untracked)(() => builder.extensions);
38
+ const removed = current.filter(({ id }) => !next.some(({ id: nextId }) => nextId === id));
39
+ removed.forEach((extension) => builder.removeExtension(extension.id));
40
+ next.forEach((extension) => builder.addExtension(extension));
41
+ });
42
42
  });
43
- builder.graph.onNodeChanged.on(({ id, node }) => {
44
- if (import_effect.Option.isSome(node)) {
45
- builder.graph.expand(id);
46
- }
47
- });
48
- builder.graph.expand(import_app_graph.ROOT_ID);
43
+ await builder.initialize();
44
+ await builder.graph.expand(builder.graph.root);
49
45
  setupDevtools(builder.graph);
50
46
  return (0, import_app_framework.contributes)(import_app_framework.Capabilities.AppGraph, {
51
47
  graph: builder.graph,
52
- explore: builder.explore
48
+ explore: (options) => builder.explore(options)
53
49
  }, () => {
50
+ clearInterval(interval);
54
51
  unsubscribe();
55
52
  });
56
53
  };
@@ -58,4 +55,4 @@ var setupDevtools = (graph) => {
58
55
  globalThis.composer ??= {};
59
56
  globalThis.composer.graph = graph;
60
57
  };
61
- //# sourceMappingURL=graph-IZROFGJQ.cjs.map
58
+ //# sourceMappingURL=graph-GCGIYOGJ.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/graph.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { batch, effect, untracked } from '@preact/signals-core';\n\nimport { Capabilities, contributes, type PluginsContext } from '@dxos/app-framework';\nimport { flattenExtensions, type Graph, GraphBuilder } from '@dxos/app-graph';\n\nimport { GRAPH_PLUGIN } from './meta';\n\nconst KEY = `${GRAPH_PLUGIN}/app-graph`;\n\nexport default async (context: PluginsContext) => {\n const builder = GraphBuilder.from(localStorage.getItem(KEY) ?? undefined);\n const interval = setInterval(() => {\n localStorage.setItem(KEY, builder.graph.pickle());\n }, 5_000);\n\n const unsubscribe = effect(() => {\n batch(() => {\n const next = flattenExtensions(context.requestCapabilities(Capabilities.AppGraphBuilder));\n const current = untracked(() => 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 });\n\n await builder.initialize();\n await builder.graph.expand(builder.graph.root);\n\n setupDevtools(builder.graph);\n\n return contributes(\n Capabilities.AppGraph,\n { graph: builder.graph, explore: (options) => builder.explore(options) },\n () => {\n clearInterval(interval);\n unsubscribe();\n },\n );\n};\n\n// Expose the graph to the window for debugging.\nconst setupDevtools = (graph: Graph) => {\n (globalThis as any).composer ??= {};\n (globalThis as any).composer.graph = graph;\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAIA,0BAAyC;AAEzC,2BAA+D;AAC/D,uBAA4D;AAI5D,IAAMA,MAAM,GAAGC,kCAAAA;AAEf,IAAA,gBAAe,OAAOC,YAAAA;AACpB,QAAMC,UAAUC,8BAAaC,KAAKC,aAAaC,QAAQP,GAAAA,KAAQQ,MAAAA;AAC/D,QAAMC,WAAWC,YAAY,MAAA;AAC3BJ,iBAAaK,QAAQX,KAAKG,QAAQS,MAAMC,OAAM,CAAA;EAChD,GAAG,GAAA;AAEH,QAAMC,kBAAcC,4BAAO,MAAA;AACzBC,mCAAM,MAAA;AACJ,YAAMC,WAAOC,oCAAkBhB,QAAQiB,oBAAoBC,kCAAaC,eAAe,CAAA;AACvF,YAAMC,cAAUC,+BAAU,MAAMpB,QAAQqB,UAAU;AAClD,YAAMC,UAAUH,QAAQI,OAAO,CAAC,EAAEC,GAAE,MAAO,CAACV,KAAKW,KAAK,CAAC,EAAED,IAAIE,OAAM,MAAOA,WAAWF,EAAAA,CAAAA;AACrFF,cAAQK,QAAQ,CAACC,cAAc5B,QAAQ6B,gBAAgBD,UAAUJ,EAAE,CAAA;AACnEV,WAAKa,QAAQ,CAACC,cAAc5B,QAAQ8B,aAAaF,SAAAA,CAAAA;IACnD,CAAA;EACF,CAAA;AAEA,QAAM5B,QAAQ+B,WAAU;AACxB,QAAM/B,QAAQS,MAAMuB,OAAOhC,QAAQS,MAAMwB,IAAI;AAE7CC,gBAAclC,QAAQS,KAAK;AAE3B,aAAO0B,kCACLlB,kCAAamB,UACb;IAAE3B,OAAOT,QAAQS;IAAO4B,SAAS,CAACC,YAAYtC,QAAQqC,QAAQC,OAAAA;EAAS,GACvE,MAAA;AACEC,kBAAcjC,QAAAA;AACdK,gBAAAA;EACF,CAAA;AAEJ;AAGA,IAAMuB,gBAAgB,CAACzB,UAAAA;AACpB+B,aAAmBC,aAAa,CAAC;AACjCD,aAAmBC,SAAShC,QAAQA;AACvC;",
6
+ "names": ["KEY", "GRAPH_PLUGIN", "context", "builder", "GraphBuilder", "from", "localStorage", "getItem", "undefined", "interval", "setInterval", "setItem", "graph", "pickle", "unsubscribe", "effect", "batch", "next", "flattenExtensions", "requestCapabilities", "Capabilities", "AppGraphBuilder", "current", "untracked", "extensions", "removed", "filter", "id", "some", "nextId", "forEach", "extension", "removeExtension", "addExtension", "initialize", "expand", "root", "setupDevtools", "contributes", "AppGraph", "explore", "options", "clearInterval", "globalThis", "composer"]
7
+ }
@@ -29,26 +29,19 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
29
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
30
  var node_exports = {};
31
31
  __export(node_exports, {
32
- GRAPH_PLUGIN: () => GRAPH_PLUGIN,
32
+ GRAPH_PLUGIN: () => import_chunk_AKNWBLRY.GRAPH_PLUGIN,
33
33
  GraphPlugin: () => GraphPlugin,
34
- meta: () => meta,
35
- useActions: () => useActions,
36
- useConnections: () => useConnections,
34
+ meta: () => import_chunk_AKNWBLRY.meta,
37
35
  useNode: () => useNode
38
36
  });
39
37
  module.exports = __toCommonJS(node_exports);
38
+ var import_chunk_AKNWBLRY = require("./chunk-AKNWBLRY.cjs");
40
39
  __reExport(node_exports, require("@dxos/app-graph"), module.exports);
41
40
  var import_app_framework = require("@dxos/app-framework");
42
- var import_rx_react = require("@effect-rx/rx-react");
43
- var import_effect = require("effect");
44
- var GRAPH_PLUGIN = "dxos.org/plugin/graph";
45
- var meta = {
46
- id: GRAPH_PLUGIN,
47
- name: "Graph"
48
- };
49
- var GraphPlugin = () => (0, import_app_framework.definePlugin)(meta, [
41
+ var import_react = require("react");
42
+ var GraphPlugin = () => (0, import_app_framework.definePlugin)(import_chunk_AKNWBLRY.meta, [
50
43
  (0, import_app_framework.defineModule)({
51
- id: `${meta.id}/module/graph`,
44
+ id: `${import_chunk_AKNWBLRY.meta.id}/module/graph`,
52
45
  activatesOn: import_app_framework.Events.Startup,
53
46
  activatesBefore: [
54
47
  import_app_framework.Events.SetupAppGraph,
@@ -57,25 +50,41 @@ var GraphPlugin = () => (0, import_app_framework.definePlugin)(meta, [
57
50
  activatesAfter: [
58
51
  import_app_framework.Events.AppGraphReady
59
52
  ],
60
- activate: (0, import_app_framework.lazy)(() => import("./graph-IZROFGJQ.cjs"))
53
+ activate: (0, import_app_framework.lazy)(() => import("./graph-GCGIYOGJ.cjs"))
61
54
  })
62
55
  ]);
63
- var useNode = (graph, id) => {
64
- return import_effect.Option.getOrElse((0, import_rx_react.useRxValue)(graph.node(id ?? "")), () => void 0);
65
- };
66
- var useConnections = (graph, id, relation) => {
67
- return (0, import_rx_react.useRxValue)(graph.connections(id ?? "", relation));
68
- };
69
- var useActions = (graph, id) => {
70
- return (0, import_rx_react.useRxValue)(graph.actions(id ?? ""));
56
+ var useNode = (graph, id, timeout) => {
57
+ const [nodeState, setNodeState] = (0, import_react.useState)(id ? graph.findNode(id, false) : void 0);
58
+ (0, import_react.useEffect)(() => {
59
+ if (!id && nodeState) {
60
+ setNodeState(void 0);
61
+ }
62
+ if (nodeState?.id === id || !id) {
63
+ return;
64
+ }
65
+ const frame = requestAnimationFrame(async () => {
66
+ try {
67
+ const node = await graph.waitForNode(id, timeout);
68
+ if (node) {
69
+ setNodeState(node);
70
+ }
71
+ } catch {
72
+ }
73
+ });
74
+ return () => cancelAnimationFrame(frame);
75
+ }, [
76
+ graph,
77
+ id,
78
+ timeout,
79
+ nodeState?.id
80
+ ]);
81
+ return nodeState;
71
82
  };
72
83
  // Annotate the CommonJS export names for ESM import in node:
73
84
  0 && (module.exports = {
74
85
  GRAPH_PLUGIN,
75
86
  GraphPlugin,
76
87
  meta,
77
- useActions,
78
- useConnections,
79
88
  useNode,
80
89
  ...require("@dxos/app-graph")
81
90
  });
@@ -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 { defineModule, lazy, Events, definePlugin } from '@dxos/app-framework';\n\nimport { meta } from './meta';\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 = () =>\n definePlugin(meta, [\n defineModule({\n id: `${meta.id}/module/graph`,\n activatesOn: Events.Startup,\n activatesBefore: [Events.SetupAppGraph, Events.SetupMetadata],\n activatesAfter: [Events.AppGraphReady],\n activate: lazy(() => import('./graph')),\n }),\n ]);\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const GRAPH_PLUGIN = 'dxos.org/plugin/graph';\n\nexport const meta: PluginMeta = {\n id: GRAPH_PLUGIN,\n name: 'Graph',\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { useRxValue } from '@effect-rx/rx-react';\nimport { Option } from 'effect';\n\nimport { type ReadableGraph, type Node, type Relation } 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: ReadableGraph, id?: string): Node<T> | undefined => {\n return Option.getOrElse(useRxValue(graph.node(id ?? '')), () => undefined);\n};\n\nexport const useConnections = (graph: ReadableGraph, id?: string, relation?: Relation): Node[] => {\n return useRxValue(graph.connections(id ?? '', relation));\n};\n\nexport const useActions = (graph: ReadableGraph, id?: string): Node[] => {\n return useRxValue(graph.actions(id ?? ''));\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,yBAAc;ACAd,2BAAyD;AEAzD,sBAA2B;AAC3B,oBAAuB;ADChB,IAAMA,eAAe;AAErB,IAAMC,OAAmB;EAC9BC,IAAIF;EACJG,MAAM;AACR;ADEO,IAAMC,cAAc,UACzBC,mCAAaJ,MAAM;MACjBK,mCAAa;IACXJ,IAAI,GAAGD,KAAKC,EAAE;IACdK,aAAaC,4BAAOC;IACpBC,iBAAiB;MAACF,4BAAOG;MAAeH,4BAAOI;;IAC/CC,gBAAgB;MAACL,4BAAOM;;IACxBC,cAAUC,2BAAK,MAAM,OAAO,sBAAA,CAAA;EAC9B,CAAA;CACD;AEJI,IAAMC,UAAU,CAAUC,OAAsBhB,OAAAA;AACrD,SAAOiB,qBAAOC,cAAUC,4BAAWH,MAAMI,KAAKpB,MAAM,EAAA,CAAA,GAAM,MAAMqB,MAAAA;AAClE;AAEO,IAAMC,iBAAiB,CAACN,OAAsBhB,IAAauB,aAAAA;AAChE,aAAOJ,4BAAWH,MAAMQ,YAAYxB,MAAM,IAAIuB,QAAAA,CAAAA;AAChD;AAEO,IAAME,aAAa,CAACT,OAAsBhB,OAAAA;AAC/C,aAAOmB,4BAAWH,MAAMU,QAAQ1B,MAAM,EAAA,CAAA;AACxC;",
6
- "names": ["GRAPH_PLUGIN", "meta", "id", "name", "GraphPlugin", "definePlugin", "defineModule", "activatesOn", "Events", "Startup", "activatesBefore", "SetupAppGraph", "SetupMetadata", "activatesAfter", "AppGraphReady", "activate", "lazy", "useNode", "graph", "Option", "getOrElse", "useRxValue", "node", "undefined", "useConnections", "relation", "connections", "useActions", "actions"]
3
+ "sources": ["../../../src/index.ts", "../../../src/GraphPlugin.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 { defineModule, lazy, Events, definePlugin } from '@dxos/app-framework';\n\nimport { meta } from './meta';\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 = () =>\n definePlugin(meta, [\n defineModule({\n id: `${meta.id}/module/graph`,\n activatesOn: Events.Startup,\n activatesBefore: [Events.SetupAppGraph, Events.SetupMetadata],\n activatesAfter: [Events.AppGraphReady],\n activate: lazy(() => import('./graph')),\n }),\n ]);\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { useEffect, useState } from 'react';\n\nimport { type Graph, type Node } from '@dxos/app-graph';\n\n/**\n * React hook to get a node from the graph.\n *\n * @param graph Graph to find the node in.\n * @param id Id of the node to find.\n * @param timeout Optional timeout in milliseconds to wait for the node to be found.\n * @returns Node if found, undefined otherwise.\n */\n// TODO(wittjosiah): Factor out?\nexport const useNode = <T = any>(graph: Graph, id?: string, timeout?: number): Node<T> | undefined => {\n const [nodeState, setNodeState] = useState<Node<T> | undefined>(id ? graph.findNode(id, false) : undefined);\n\n useEffect(() => {\n if (!id && nodeState) {\n setNodeState(undefined);\n }\n\n if (nodeState?.id === id || !id) {\n return;\n }\n\n // Set timeout did not seem to effectively not block the UI thread.\n const frame = requestAnimationFrame(async () => {\n try {\n const node = await graph.waitForNode(id, timeout);\n if (node) {\n setNodeState(node);\n }\n } catch {\n // TODO(ZaymonFC): This leaves the resolved node in an invalid state in the case of a timeout.\n }\n });\n\n return () => cancelAnimationFrame(frame);\n }, [graph, id, timeout, nodeState?.id]);\n\n return nodeState;\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,yBAAc;ACAd,2BAAyD;ACAzD,mBAAoC;ADS7B,IAAMA,cAAc,UACzBC,mCAAaC,4BAAM;MACjBC,mCAAa;IACXC,IAAI,GAAGF,2BAAKE,EAAE;IACdC,aAAaC,4BAAOC;IACpBC,iBAAiB;MAACF,4BAAOG;MAAeH,4BAAOI;;IAC/CC,gBAAgB;MAACL,4BAAOM;;IACxBC,cAAUC,2BAAK,MAAM,OAAO,sBAAA,CAAA;EAC9B,CAAA;CACD;ACLI,IAAMC,UAAU,CAAUC,OAAcZ,IAAaa,YAAAA;AAC1D,QAAM,CAACC,WAAWC,YAAAA,QAAgBC,uBAA8BhB,KAAKY,MAAMK,SAASjB,IAAI,KAAA,IAASkB,MAAAA;AAEjGC,8BAAU,MAAA;AACR,QAAI,CAACnB,MAAMc,WAAW;AACpBC,mBAAaG,MAAAA;IACf;AAEA,QAAIJ,WAAWd,OAAOA,MAAM,CAACA,IAAI;AAC/B;IACF;AAGA,UAAMoB,QAAQC,sBAAsB,YAAA;AAClC,UAAI;AACF,cAAMC,OAAO,MAAMV,MAAMW,YAAYvB,IAAIa,OAAAA;AACzC,YAAIS,MAAM;AACRP,uBAAaO,IAAAA;QACf;MACF,QAAQ;MAER;IACF,CAAA;AAEA,WAAO,MAAME,qBAAqBJ,KAAAA;EACpC,GAAG;IAACR;IAAOZ;IAAIa;IAASC,WAAWd;GAAG;AAEtC,SAAOc;AACT;",
6
+ "names": ["GraphPlugin", "definePlugin", "meta", "defineModule", "id", "activatesOn", "Events", "Startup", "activatesBefore", "SetupAppGraph", "SetupMetadata", "activatesAfter", "AppGraphReady", "activate", "lazy", "useNode", "graph", "timeout", "nodeState", "setNodeState", "useState", "findNode", "undefined", "useEffect", "frame", "requestAnimationFrame", "node", "waitForNode", "cancelAnimationFrame"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"packages/plugins/plugin-graph/src/meta.ts":{"bytes":950,"imports":[],"format":"esm"},"packages/plugins/plugin-graph/src/graph.ts":{"bytes":7025,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/app-graph","kind":"import-statement","external":true}],"format":"esm"},"packages/plugins/plugin-graph/src/GraphPlugin.ts":{"bytes":2810,"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-graph/src/meta.ts","kind":"import-statement","original":"./meta"},{"path":"packages/plugins/plugin-graph/src/graph.ts","kind":"dynamic-import","original":"./graph"}],"format":"esm"},"packages/plugins/plugin-graph/src/hooks/useNode.ts":{"bytes":3193,"imports":[{"path":"@effect-rx/rx-react","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true}],"format":"esm"},"packages/plugins/plugin-graph/src/hooks/index.ts":{"bytes":506,"imports":[{"path":"packages/plugins/plugin-graph/src/hooks/useNode.ts","kind":"import-statement","original":"./useNode"}],"format":"esm"},"packages/plugins/plugin-graph/src/index.ts":{"bytes":778,"imports":[{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-graph/src/GraphPlugin.ts","kind":"import-statement","original":"./GraphPlugin"},{"path":"packages/plugins/plugin-graph/src/hooks/index.ts","kind":"import-statement","original":"./hooks"},{"path":"packages/plugins/plugin-graph/src/meta.ts","kind":"import-statement","original":"./meta"}],"format":"esm"}},"outputs":{"packages/plugins/plugin-graph/dist/lib/node/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":3458},"packages/plugins/plugin-graph/dist/lib/node/index.cjs":{"imports":[{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-graph/dist/lib/node/graph-IZROFGJQ.cjs","kind":"dynamic-import"},{"path":"@effect-rx/rx-react","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true}],"exports":["GRAPH_PLUGIN","GraphPlugin","meta","useActions","useConnections","useNode"],"entryPoint":"packages/plugins/plugin-graph/src/index.ts","inputs":{"packages/plugins/plugin-graph/src/index.ts":{"bytesInOutput":33},"packages/plugins/plugin-graph/src/GraphPlugin.ts":{"bytesInOutput":417},"packages/plugins/plugin-graph/src/meta.ts":{"bytesInOutput":96},"packages/plugins/plugin-graph/src/hooks/useNode.ts":{"bytesInOutput":386},"packages/plugins/plugin-graph/src/hooks/index.ts":{"bytesInOutput":0}},"bytes":1313},"packages/plugins/plugin-graph/dist/lib/node/graph-IZROFGJQ.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":3671},"packages/plugins/plugin-graph/dist/lib/node/graph-IZROFGJQ.cjs":{"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/app-graph","kind":"import-statement","external":true}],"exports":["default"],"entryPoint":"packages/plugins/plugin-graph/src/graph.ts","inputs":{"packages/plugins/plugin-graph/src/graph.ts":{"bytesInOutput":1331}},"bytes":1460}}}
1
+ {"inputs":{"packages/plugins/plugin-graph/src/meta.ts":{"bytes":950,"imports":[],"format":"esm"},"packages/plugins/plugin-graph/src/graph.ts":{"bytes":6242,"imports":[{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-graph/src/meta.ts","kind":"import-statement","original":"./meta"}],"format":"esm"},"packages/plugins/plugin-graph/src/GraphPlugin.ts":{"bytes":2810,"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-graph/src/meta.ts","kind":"import-statement","original":"./meta"},{"path":"packages/plugins/plugin-graph/src/graph.ts","kind":"dynamic-import","original":"./graph"}],"format":"esm"},"packages/plugins/plugin-graph/src/hooks/useNode.ts":{"bytes":4473,"imports":[{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"packages/plugins/plugin-graph/src/hooks/index.ts":{"bytes":506,"imports":[{"path":"packages/plugins/plugin-graph/src/hooks/useNode.ts","kind":"import-statement","original":"./useNode"}],"format":"esm"},"packages/plugins/plugin-graph/src/index.ts":{"bytes":778,"imports":[{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-graph/src/GraphPlugin.ts","kind":"import-statement","original":"./GraphPlugin"},{"path":"packages/plugins/plugin-graph/src/hooks/index.ts","kind":"import-statement","original":"./hooks"},{"path":"packages/plugins/plugin-graph/src/meta.ts","kind":"import-statement","original":"./meta"}],"format":"esm"}},"outputs":{"packages/plugins/plugin-graph/dist/lib/node/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":3652},"packages/plugins/plugin-graph/dist/lib/node/index.cjs":{"imports":[{"path":"packages/plugins/plugin-graph/dist/lib/node/chunk-AKNWBLRY.cjs","kind":"import-statement"},{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-graph/dist/lib/node/graph-GCGIYOGJ.cjs","kind":"dynamic-import"},{"path":"react","kind":"import-statement","external":true}],"exports":["GRAPH_PLUGIN","GraphPlugin","meta","useNode"],"entryPoint":"packages/plugins/plugin-graph/src/index.ts","inputs":{"packages/plugins/plugin-graph/src/index.ts":{"bytesInOutput":33},"packages/plugins/plugin-graph/src/GraphPlugin.ts":{"bytesInOutput":417},"packages/plugins/plugin-graph/src/hooks/useNode.ts":{"bytesInOutput":662},"packages/plugins/plugin-graph/src/hooks/index.ts":{"bytesInOutput":0}},"bytes":1426},"packages/plugins/plugin-graph/dist/lib/node/graph-GCGIYOGJ.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":3429},"packages/plugins/plugin-graph/dist/lib/node/graph-GCGIYOGJ.cjs":{"imports":[{"path":"packages/plugins/plugin-graph/dist/lib/node/chunk-AKNWBLRY.cjs","kind":"import-statement"},{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/app-graph","kind":"import-statement","external":true}],"exports":["default"],"entryPoint":"packages/plugins/plugin-graph/src/graph.ts","inputs":{"packages/plugins/plugin-graph/src/graph.ts":{"bytesInOutput":1331}},"bytes":1516},"packages/plugins/plugin-graph/dist/lib/node/chunk-AKNWBLRY.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":447},"packages/plugins/plugin-graph/dist/lib/node/chunk-AKNWBLRY.cjs":{"imports":[],"exports":["GRAPH_PLUGIN","meta"],"inputs":{"packages/plugins/plugin-graph/src/meta.ts":{"bytesInOutput":96}},"bytes":221}}}
@@ -0,0 +1,14 @@
1
+ import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
+
3
+ // packages/plugins/plugin-graph/src/meta.ts
4
+ var GRAPH_PLUGIN = "dxos.org/plugin/graph";
5
+ var meta = {
6
+ id: GRAPH_PLUGIN,
7
+ name: "Graph"
8
+ };
9
+
10
+ export {
11
+ GRAPH_PLUGIN,
12
+ meta
13
+ };
14
+ //# sourceMappingURL=chunk-RJQY6JZL.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/meta.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const GRAPH_PLUGIN = 'dxos.org/plugin/graph';\n\nexport const meta: PluginMeta = {\n id: GRAPH_PLUGIN,\n name: 'Graph',\n};\n"],
5
+ "mappings": ";;;AAMO,IAAMA,eAAe;AAErB,IAAMC,OAAmB;EAC9BC,IAAIF;EACJG,MAAM;AACR;",
6
+ "names": ["GRAPH_PLUGIN", "meta", "id", "name"]
7
+ }
@@ -0,0 +1,43 @@
1
+ import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
+ import {
3
+ GRAPH_PLUGIN
4
+ } from "./chunk-RJQY6JZL.mjs";
5
+
6
+ // packages/plugins/plugin-graph/src/graph.ts
7
+ import { batch, effect, untracked } from "@preact/signals-core";
8
+ import { Capabilities, contributes } from "@dxos/app-framework";
9
+ import { flattenExtensions, GraphBuilder } from "@dxos/app-graph";
10
+ var KEY = `${GRAPH_PLUGIN}/app-graph`;
11
+ var graph_default = async (context) => {
12
+ const builder = GraphBuilder.from(localStorage.getItem(KEY) ?? void 0);
13
+ const interval = setInterval(() => {
14
+ localStorage.setItem(KEY, builder.graph.pickle());
15
+ }, 5e3);
16
+ const unsubscribe = effect(() => {
17
+ batch(() => {
18
+ const next = flattenExtensions(context.requestCapabilities(Capabilities.AppGraphBuilder));
19
+ const current = untracked(() => builder.extensions);
20
+ const removed = current.filter(({ id }) => !next.some(({ id: nextId }) => nextId === id));
21
+ removed.forEach((extension) => builder.removeExtension(extension.id));
22
+ next.forEach((extension) => builder.addExtension(extension));
23
+ });
24
+ });
25
+ await builder.initialize();
26
+ await builder.graph.expand(builder.graph.root);
27
+ setupDevtools(builder.graph);
28
+ return contributes(Capabilities.AppGraph, {
29
+ graph: builder.graph,
30
+ explore: (options) => builder.explore(options)
31
+ }, () => {
32
+ clearInterval(interval);
33
+ unsubscribe();
34
+ });
35
+ };
36
+ var setupDevtools = (graph) => {
37
+ globalThis.composer ??= {};
38
+ globalThis.composer.graph = graph;
39
+ };
40
+ export {
41
+ graph_default as default
42
+ };
43
+ //# sourceMappingURL=graph-NUZMWBDN.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 { batch, effect, untracked } from '@preact/signals-core';\n\nimport { Capabilities, contributes, type PluginsContext } from '@dxos/app-framework';\nimport { flattenExtensions, type Graph, GraphBuilder } from '@dxos/app-graph';\n\nimport { GRAPH_PLUGIN } from './meta';\n\nconst KEY = `${GRAPH_PLUGIN}/app-graph`;\n\nexport default async (context: PluginsContext) => {\n const builder = GraphBuilder.from(localStorage.getItem(KEY) ?? undefined);\n const interval = setInterval(() => {\n localStorage.setItem(KEY, builder.graph.pickle());\n }, 5_000);\n\n const unsubscribe = effect(() => {\n batch(() => {\n const next = flattenExtensions(context.requestCapabilities(Capabilities.AppGraphBuilder));\n const current = untracked(() => 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 });\n\n await builder.initialize();\n await builder.graph.expand(builder.graph.root);\n\n setupDevtools(builder.graph);\n\n return contributes(\n Capabilities.AppGraph,\n { graph: builder.graph, explore: (options) => builder.explore(options) },\n () => {\n clearInterval(interval);\n unsubscribe();\n },\n );\n};\n\n// Expose the graph to the window for debugging.\nconst setupDevtools = (graph: Graph) => {\n (globalThis as any).composer ??= {};\n (globalThis as any).composer.graph = graph;\n};\n"],
5
+ "mappings": ";;;;;;AAIA,SAASA,OAAOC,QAAQC,iBAAiB;AAEzC,SAASC,cAAcC,mBAAwC;AAC/D,SAASC,mBAA+BC,oBAAoB;AAI5D,IAAMC,MAAM,GAAGC,YAAAA;AAEf,IAAA,gBAAe,OAAOC,YAAAA;AACpB,QAAMC,UAAUC,aAAaC,KAAKC,aAAaC,QAAQP,GAAAA,KAAQQ,MAAAA;AAC/D,QAAMC,WAAWC,YAAY,MAAA;AAC3BJ,iBAAaK,QAAQX,KAAKG,QAAQS,MAAMC,OAAM,CAAA;EAChD,GAAG,GAAA;AAEH,QAAMC,cAAcC,OAAO,MAAA;AACzBC,UAAM,MAAA;AACJ,YAAMC,OAAOC,kBAAkBhB,QAAQiB,oBAAoBC,aAAaC,eAAe,CAAA;AACvF,YAAMC,UAAUC,UAAU,MAAMpB,QAAQqB,UAAU;AAClD,YAAMC,UAAUH,QAAQI,OAAO,CAAC,EAAEC,GAAE,MAAO,CAACV,KAAKW,KAAK,CAAC,EAAED,IAAIE,OAAM,MAAOA,WAAWF,EAAAA,CAAAA;AACrFF,cAAQK,QAAQ,CAACC,cAAc5B,QAAQ6B,gBAAgBD,UAAUJ,EAAE,CAAA;AACnEV,WAAKa,QAAQ,CAACC,cAAc5B,QAAQ8B,aAAaF,SAAAA,CAAAA;IACnD,CAAA;EACF,CAAA;AAEA,QAAM5B,QAAQ+B,WAAU;AACxB,QAAM/B,QAAQS,MAAMuB,OAAOhC,QAAQS,MAAMwB,IAAI;AAE7CC,gBAAclC,QAAQS,KAAK;AAE3B,SAAO0B,YACLlB,aAAamB,UACb;IAAE3B,OAAOT,QAAQS;IAAO4B,SAAS,CAACC,YAAYtC,QAAQqC,QAAQC,OAAAA;EAAS,GACvE,MAAA;AACEC,kBAAcjC,QAAAA;AACdK,gBAAAA;EACF,CAAA;AAEJ;AAGA,IAAMuB,gBAAgB,CAACzB,UAAAA;AACpB+B,aAAmBC,aAAa,CAAC;AACjCD,aAAmBC,SAAShC,QAAQA;AACvC;",
6
+ "names": ["batch", "effect", "untracked", "Capabilities", "contributes", "flattenExtensions", "GraphBuilder", "KEY", "GRAPH_PLUGIN", "context", "builder", "GraphBuilder", "from", "localStorage", "getItem", "undefined", "interval", "setInterval", "setItem", "graph", "pickle", "unsubscribe", "effect", "batch", "next", "flattenExtensions", "requestCapabilities", "Capabilities", "AppGraphBuilder", "current", "untracked", "extensions", "removed", "filter", "id", "some", "nextId", "forEach", "extension", "removeExtension", "addExtension", "initialize", "expand", "root", "setupDevtools", "contributes", "AppGraph", "explore", "options", "clearInterval", "globalThis", "composer"]
7
+ }
@@ -1,19 +1,14 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
+ import {
3
+ GRAPH_PLUGIN,
4
+ meta
5
+ } from "./chunk-RJQY6JZL.mjs";
2
6
 
3
7
  // packages/plugins/plugin-graph/src/index.ts
4
8
  export * from "@dxos/app-graph";
5
9
 
6
10
  // packages/plugins/plugin-graph/src/GraphPlugin.ts
7
11
  import { defineModule, lazy, Events, definePlugin } from "@dxos/app-framework";
8
-
9
- // packages/plugins/plugin-graph/src/meta.ts
10
- var GRAPH_PLUGIN = "dxos.org/plugin/graph";
11
- var meta = {
12
- id: GRAPH_PLUGIN,
13
- name: "Graph"
14
- };
15
-
16
- // packages/plugins/plugin-graph/src/GraphPlugin.ts
17
12
  var GraphPlugin = () => definePlugin(meta, [
18
13
  defineModule({
19
14
  id: `${meta.id}/module/graph`,
@@ -25,28 +20,43 @@ var GraphPlugin = () => definePlugin(meta, [
25
20
  activatesAfter: [
26
21
  Events.AppGraphReady
27
22
  ],
28
- activate: lazy(() => import("./graph-NJMEGQY3.mjs"))
23
+ activate: lazy(() => import("./graph-NUZMWBDN.mjs"))
29
24
  })
30
25
  ]);
31
26
 
32
27
  // packages/plugins/plugin-graph/src/hooks/useNode.ts
33
- import { useRxValue } from "@effect-rx/rx-react";
34
- import { Option } from "effect";
35
- var useNode = (graph, id) => {
36
- return Option.getOrElse(useRxValue(graph.node(id ?? "")), () => void 0);
37
- };
38
- var useConnections = (graph, id, relation) => {
39
- return useRxValue(graph.connections(id ?? "", relation));
40
- };
41
- var useActions = (graph, id) => {
42
- return useRxValue(graph.actions(id ?? ""));
28
+ import { useEffect, useState } from "react";
29
+ var useNode = (graph, id, timeout) => {
30
+ const [nodeState, setNodeState] = useState(id ? graph.findNode(id, false) : void 0);
31
+ useEffect(() => {
32
+ if (!id && nodeState) {
33
+ setNodeState(void 0);
34
+ }
35
+ if (nodeState?.id === id || !id) {
36
+ return;
37
+ }
38
+ const frame = requestAnimationFrame(async () => {
39
+ try {
40
+ const node = await graph.waitForNode(id, timeout);
41
+ if (node) {
42
+ setNodeState(node);
43
+ }
44
+ } catch {
45
+ }
46
+ });
47
+ return () => cancelAnimationFrame(frame);
48
+ }, [
49
+ graph,
50
+ id,
51
+ timeout,
52
+ nodeState?.id
53
+ ]);
54
+ return nodeState;
43
55
  };
44
56
  export {
45
57
  GRAPH_PLUGIN,
46
58
  GraphPlugin,
47
59
  meta,
48
- useActions,
49
- useConnections,
50
60
  useNode
51
61
  };
52
62
  //# 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 { defineModule, lazy, Events, definePlugin } from '@dxos/app-framework';\n\nimport { meta } from './meta';\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 = () =>\n definePlugin(meta, [\n defineModule({\n id: `${meta.id}/module/graph`,\n activatesOn: Events.Startup,\n activatesBefore: [Events.SetupAppGraph, Events.SetupMetadata],\n activatesAfter: [Events.AppGraphReady],\n activate: lazy(() => import('./graph')),\n }),\n ]);\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const GRAPH_PLUGIN = 'dxos.org/plugin/graph';\n\nexport const meta: PluginMeta = {\n id: GRAPH_PLUGIN,\n name: 'Graph',\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { useRxValue } from '@effect-rx/rx-react';\nimport { Option } from 'effect';\n\nimport { type ReadableGraph, type Node, type Relation } 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: ReadableGraph, id?: string): Node<T> | undefined => {\n return Option.getOrElse(useRxValue(graph.node(id ?? '')), () => undefined);\n};\n\nexport const useConnections = (graph: ReadableGraph, id?: string, relation?: Relation): Node[] => {\n return useRxValue(graph.connections(id ?? '', relation));\n};\n\nexport const useActions = (graph: ReadableGraph, id?: string): Node[] => {\n return useRxValue(graph.actions(id ?? ''));\n};\n"],
5
- "mappings": ";;;AAIA,cAAc;;;ACAd,SAASA,cAAcC,MAAMC,QAAQC,oBAAoB;;;ACElD,IAAMC,eAAe;AAErB,IAAMC,OAAmB;EAC9BC,IAAIF;EACJG,MAAM;AACR;;;ADEO,IAAMC,cAAc,MACzBC,aAAaC,MAAM;EACjBC,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAOC;IACpBC,iBAAiB;MAACF,OAAOG;MAAeH,OAAOI;;IAC/CC,gBAAgB;MAACL,OAAOM;;IACxBC,UAAUC,KAAK,MAAM,OAAO,sBAAA,CAAA;EAC9B,CAAA;CACD;;;AElBH,SAASC,kBAAkB;AAC3B,SAASC,cAAc;AAahB,IAAMC,UAAU,CAAUC,OAAsBC,OAAAA;AACrD,SAAOC,OAAOC,UAAUC,WAAWJ,MAAMK,KAAKJ,MAAM,EAAA,CAAA,GAAM,MAAMK,MAAAA;AAClE;AAEO,IAAMC,iBAAiB,CAACP,OAAsBC,IAAaO,aAAAA;AAChE,SAAOJ,WAAWJ,MAAMS,YAAYR,MAAM,IAAIO,QAAAA,CAAAA;AAChD;AAEO,IAAME,aAAa,CAACV,OAAsBC,OAAAA;AAC/C,SAAOG,WAAWJ,MAAMW,QAAQV,MAAM,EAAA,CAAA;AACxC;",
6
- "names": ["defineModule", "lazy", "Events", "definePlugin", "GRAPH_PLUGIN", "meta", "id", "name", "GraphPlugin", "definePlugin", "meta", "defineModule", "id", "activatesOn", "Events", "Startup", "activatesBefore", "SetupAppGraph", "SetupMetadata", "activatesAfter", "AppGraphReady", "activate", "lazy", "useRxValue", "Option", "useNode", "graph", "id", "Option", "getOrElse", "useRxValue", "node", "undefined", "useConnections", "relation", "connections", "useActions", "actions"]
3
+ "sources": ["../../../src/index.ts", "../../../src/GraphPlugin.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 { defineModule, lazy, Events, definePlugin } from '@dxos/app-framework';\n\nimport { meta } from './meta';\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 = () =>\n definePlugin(meta, [\n defineModule({\n id: `${meta.id}/module/graph`,\n activatesOn: Events.Startup,\n activatesBefore: [Events.SetupAppGraph, Events.SetupMetadata],\n activatesAfter: [Events.AppGraphReady],\n activate: lazy(() => import('./graph')),\n }),\n ]);\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { useEffect, useState } from 'react';\n\nimport { type Graph, type Node } from '@dxos/app-graph';\n\n/**\n * React hook to get a node from the graph.\n *\n * @param graph Graph to find the node in.\n * @param id Id of the node to find.\n * @param timeout Optional timeout in milliseconds to wait for the node to be found.\n * @returns Node if found, undefined otherwise.\n */\n// TODO(wittjosiah): Factor out?\nexport const useNode = <T = any>(graph: Graph, id?: string, timeout?: number): Node<T> | undefined => {\n const [nodeState, setNodeState] = useState<Node<T> | undefined>(id ? graph.findNode(id, false) : undefined);\n\n useEffect(() => {\n if (!id && nodeState) {\n setNodeState(undefined);\n }\n\n if (nodeState?.id === id || !id) {\n return;\n }\n\n // Set timeout did not seem to effectively not block the UI thread.\n const frame = requestAnimationFrame(async () => {\n try {\n const node = await graph.waitForNode(id, timeout);\n if (node) {\n setNodeState(node);\n }\n } catch {\n // TODO(ZaymonFC): This leaves the resolved node in an invalid state in the case of a timeout.\n }\n });\n\n return () => cancelAnimationFrame(frame);\n }, [graph, id, timeout, nodeState?.id]);\n\n return nodeState;\n};\n"],
5
+ "mappings": ";;;;;;;AAIA,cAAc;;;ACAd,SAASA,cAAcC,MAAMC,QAAQC,oBAAoB;AASlD,IAAMC,cAAc,MACzBC,aAAaC,MAAM;EACjBC,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAOC;IACpBC,iBAAiB;MAACF,OAAOG;MAAeH,OAAOI;;IAC/CC,gBAAgB;MAACL,OAAOM;;IACxBC,UAAUC,KAAK,MAAM,OAAO,sBAAA,CAAA;EAC9B,CAAA;CACD;;;AClBH,SAASC,WAAWC,gBAAgB;AAa7B,IAAMC,UAAU,CAAUC,OAAcC,IAAaC,YAAAA;AAC1D,QAAM,CAACC,WAAWC,YAAAA,IAAgBC,SAA8BJ,KAAKD,MAAMM,SAASL,IAAI,KAAA,IAASM,MAAAA;AAEjGC,YAAU,MAAA;AACR,QAAI,CAACP,MAAME,WAAW;AACpBC,mBAAaG,MAAAA;IACf;AAEA,QAAIJ,WAAWF,OAAOA,MAAM,CAACA,IAAI;AAC/B;IACF;AAGA,UAAMQ,QAAQC,sBAAsB,YAAA;AAClC,UAAI;AACF,cAAMC,OAAO,MAAMX,MAAMY,YAAYX,IAAIC,OAAAA;AACzC,YAAIS,MAAM;AACRP,uBAAaO,IAAAA;QACf;MACF,QAAQ;MAER;IACF,CAAA;AAEA,WAAO,MAAME,qBAAqBJ,KAAAA;EACpC,GAAG;IAACT;IAAOC;IAAIC;IAASC,WAAWF;GAAG;AAEtC,SAAOE;AACT;",
6
+ "names": ["defineModule", "lazy", "Events", "definePlugin", "GraphPlugin", "definePlugin", "meta", "defineModule", "id", "activatesOn", "Events", "Startup", "activatesBefore", "SetupAppGraph", "SetupMetadata", "activatesAfter", "AppGraphReady", "activate", "lazy", "useEffect", "useState", "useNode", "graph", "id", "timeout", "nodeState", "setNodeState", "useState", "findNode", "undefined", "useEffect", "frame", "requestAnimationFrame", "node", "waitForNode", "cancelAnimationFrame"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"packages/plugins/plugin-graph/src/meta.ts":{"bytes":950,"imports":[],"format":"esm"},"packages/plugins/plugin-graph/src/graph.ts":{"bytes":7025,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/app-graph","kind":"import-statement","external":true}],"format":"esm"},"packages/plugins/plugin-graph/src/GraphPlugin.ts":{"bytes":2810,"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-graph/src/meta.ts","kind":"import-statement","original":"./meta"},{"path":"packages/plugins/plugin-graph/src/graph.ts","kind":"dynamic-import","original":"./graph"}],"format":"esm"},"packages/plugins/plugin-graph/src/hooks/useNode.ts":{"bytes":3193,"imports":[{"path":"@effect-rx/rx-react","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true}],"format":"esm"},"packages/plugins/plugin-graph/src/hooks/index.ts":{"bytes":506,"imports":[{"path":"packages/plugins/plugin-graph/src/hooks/useNode.ts","kind":"import-statement","original":"./useNode"}],"format":"esm"},"packages/plugins/plugin-graph/src/index.ts":{"bytes":778,"imports":[{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-graph/src/GraphPlugin.ts","kind":"import-statement","original":"./GraphPlugin"},{"path":"packages/plugins/plugin-graph/src/hooks/index.ts","kind":"import-statement","original":"./hooks"},{"path":"packages/plugins/plugin-graph/src/meta.ts","kind":"import-statement","original":"./meta"}],"format":"esm"}},"outputs":{"packages/plugins/plugin-graph/dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":3460},"packages/plugins/plugin-graph/dist/lib/node-esm/index.mjs":{"imports":[{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-graph/dist/lib/node-esm/graph-NJMEGQY3.mjs","kind":"dynamic-import"},{"path":"@effect-rx/rx-react","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true}],"exports":["GRAPH_PLUGIN","GraphPlugin","meta","useActions","useConnections","useNode"],"entryPoint":"packages/plugins/plugin-graph/src/index.ts","inputs":{"packages/plugins/plugin-graph/src/index.ts":{"bytesInOutput":33},"packages/plugins/plugin-graph/src/GraphPlugin.ts":{"bytesInOutput":417},"packages/plugins/plugin-graph/src/meta.ts":{"bytesInOutput":96},"packages/plugins/plugin-graph/src/hooks/useNode.ts":{"bytesInOutput":386},"packages/plugins/plugin-graph/src/hooks/index.ts":{"bytesInOutput":0}},"bytes":1406},"packages/plugins/plugin-graph/dist/lib/node-esm/graph-NJMEGQY3.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":3673},"packages/plugins/plugin-graph/dist/lib/node-esm/graph-NJMEGQY3.mjs":{"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/app-graph","kind":"import-statement","external":true}],"exports":["default"],"entryPoint":"packages/plugins/plugin-graph/src/graph.ts","inputs":{"packages/plugins/plugin-graph/src/graph.ts":{"bytesInOutput":1331}},"bytes":1553}}}
1
+ {"inputs":{"packages/plugins/plugin-graph/src/meta.ts":{"bytes":950,"imports":[],"format":"esm"},"packages/plugins/plugin-graph/src/graph.ts":{"bytes":6242,"imports":[{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-graph/src/meta.ts","kind":"import-statement","original":"./meta"}],"format":"esm"},"packages/plugins/plugin-graph/src/GraphPlugin.ts":{"bytes":2810,"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-graph/src/meta.ts","kind":"import-statement","original":"./meta"},{"path":"packages/plugins/plugin-graph/src/graph.ts","kind":"dynamic-import","original":"./graph"}],"format":"esm"},"packages/plugins/plugin-graph/src/hooks/useNode.ts":{"bytes":4473,"imports":[{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"packages/plugins/plugin-graph/src/hooks/index.ts":{"bytes":506,"imports":[{"path":"packages/plugins/plugin-graph/src/hooks/useNode.ts","kind":"import-statement","original":"./useNode"}],"format":"esm"},"packages/plugins/plugin-graph/src/index.ts":{"bytes":778,"imports":[{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-graph/src/GraphPlugin.ts","kind":"import-statement","original":"./GraphPlugin"},{"path":"packages/plugins/plugin-graph/src/hooks/index.ts","kind":"import-statement","original":"./hooks"},{"path":"packages/plugins/plugin-graph/src/meta.ts","kind":"import-statement","original":"./meta"}],"format":"esm"}},"outputs":{"packages/plugins/plugin-graph/dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":3653},"packages/plugins/plugin-graph/dist/lib/node-esm/index.mjs":{"imports":[{"path":"packages/plugins/plugin-graph/dist/lib/node-esm/chunk-RJQY6JZL.mjs","kind":"import-statement"},{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-graph/dist/lib/node-esm/graph-NUZMWBDN.mjs","kind":"dynamic-import"},{"path":"react","kind":"import-statement","external":true}],"exports":["GRAPH_PLUGIN","GraphPlugin","meta","useNode"],"entryPoint":"packages/plugins/plugin-graph/src/index.ts","inputs":{"packages/plugins/plugin-graph/src/index.ts":{"bytesInOutput":33},"packages/plugins/plugin-graph/src/GraphPlugin.ts":{"bytesInOutput":417},"packages/plugins/plugin-graph/src/hooks/useNode.ts":{"bytesInOutput":662},"packages/plugins/plugin-graph/src/hooks/index.ts":{"bytesInOutput":0}},"bytes":1518},"packages/plugins/plugin-graph/dist/lib/node-esm/graph-NUZMWBDN.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":3430},"packages/plugins/plugin-graph/dist/lib/node-esm/graph-NUZMWBDN.mjs":{"imports":[{"path":"packages/plugins/plugin-graph/dist/lib/node-esm/chunk-RJQY6JZL.mjs","kind":"import-statement"},{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/app-graph","kind":"import-statement","external":true}],"exports":["default"],"entryPoint":"packages/plugins/plugin-graph/src/graph.ts","inputs":{"packages/plugins/plugin-graph/src/graph.ts":{"bytesInOutput":1331}},"bytes":1608},"packages/plugins/plugin-graph/dist/lib/node-esm/chunk-RJQY6JZL.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":449},"packages/plugins/plugin-graph/dist/lib/node-esm/chunk-RJQY6JZL.mjs":{"imports":[],"exports":["GRAPH_PLUGIN","meta"],"inputs":{"packages/plugins/plugin-graph/src/meta.ts":{"bytesInOutput":96}},"bytes":314}}}
@@ -1,8 +1,8 @@
1
- import { type PluginContext } from '@dxos/app-framework';
2
- import { type ExpandableGraph } from '@dxos/app-graph';
3
- declare const _default: (context: PluginContext) => Promise<import("@dxos/app-framework").Capability<{
4
- graph: ExpandableGraph;
5
- explore: ({ registry, source, relation, visitor }: import("@dxos/app-graph").GraphBuilderTraverseOptions, path?: string[]) => Promise<void>;
1
+ import { type PluginsContext } from '@dxos/app-framework';
2
+ import { type Graph } from '@dxos/app-graph';
3
+ declare const _default: (context: PluginsContext) => Promise<import("@dxos/app-framework").Capability<{
4
+ graph: Graph;
5
+ explore: (options: import("@dxos/app-graph").GraphBuilderTraverseOptions) => Promise<void>;
6
6
  }>>;
7
7
  export default _default;
8
8
  //# sourceMappingURL=graph.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../../src/graph.ts"],"names":[],"mappings":"AAMA,OAAO,EAA6B,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpF,OAAO,EAAmC,KAAK,eAAe,EAAW,MAAM,iBAAiB,CAAC;yBAM3E,SAAS,aAAa;;;;AAA5C,wBAkCE"}
1
+ {"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../../src/graph.ts"],"names":[],"mappings":"AAMA,OAAO,EAA6B,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrF,OAAO,EAAqB,KAAK,KAAK,EAAgB,MAAM,iBAAiB,CAAC;kCAM/C,cAAc;;;;AAA7C,wBA6BE"}
@@ -1,4 +1,4 @@
1
- import { type ReadableGraph, type Node, type Relation } from '@dxos/app-graph';
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,5 @@ 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?: string, relation?: Relation) => Node[];
12
- export declare const useActions: (graph: ReadableGraph, id?: string) => Node[];
10
+ export declare const useNode: <T = any>(graph: Graph, id?: string, timeout?: number) => Node<T> | undefined;
13
11
  //# 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,aAAa,EAAE,KAAK,IAAI,EAAE,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE/E;;;;;;;GAOG;AAEH,eAAO,MAAM,OAAO,GAAI,CAAC,GAAG,GAAG,EAAE,OAAO,aAAa,EAAE,KAAK,MAAM,KAAG,IAAI,CAAC,CAAC,CAAC,GAAG,SAE9E,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,OAAO,aAAa,EAAE,KAAK,MAAM,EAAE,WAAW,QAAQ,KAAG,IAAI,EAE3F,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,OAAO,aAAa,EAAE,KAAK,MAAM,KAAG,IAAI,EAElE,CAAC"}
1
+ {"version":3,"file":"useNode.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useNode.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAExD;;;;;;;GAOG;AAEH,eAAO,MAAM,OAAO,GAAI,CAAC,eAAe,KAAK,OAAO,MAAM,YAAY,MAAM,KAAG,IAAI,CAAC,CAAC,CAAC,GAAG,SA4BxF,CAAC"}
@@ -1 +1 @@
1
- {"version":"5.8.3"}
1
+ {"version":"5.7.3"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/plugin-graph",
3
- "version": "0.8.2-main.fbd8ed0",
3
+ "version": "0.8.2-staging.7ac8446",
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",
@@ -24,27 +24,22 @@
24
24
  "src"
25
25
  ],
26
26
  "dependencies": {
27
- "@dxos/app-framework": "0.8.2-main.fbd8ed0",
28
- "@dxos/async": "0.8.2-main.fbd8ed0",
29
- "@dxos/app-graph": "0.8.2-main.fbd8ed0",
30
- "@dxos/debug": "0.8.2-main.fbd8ed0"
27
+ "@preact/signals-core": "^1.6.0",
28
+ "@dxos/app-framework": "0.8.2-staging.7ac8446",
29
+ "@dxos/debug": "0.8.2-staging.7ac8446",
30
+ "@dxos/async": "0.8.2-staging.7ac8446",
31
+ "@dxos/app-graph": "0.8.2-staging.7ac8446"
31
32
  },
32
33
  "devDependencies": {
33
- "@effect-rx/rx-react": "^0.34.1",
34
- "@effect/platform": "0.80.12",
35
34
  "@types/react": "~18.2.0",
36
35
  "@types/react-dom": "~18.2.0",
37
- "effect": "^3.13.3",
38
36
  "react": "~18.2.0",
39
37
  "react-dom": "~18.2.0",
40
38
  "vite": "5.4.7",
41
- "@dxos/react-client": "0.8.2-main.fbd8ed0",
42
- "@dxos/storybook-utils": "0.8.2-main.fbd8ed0"
39
+ "@dxos/storybook-utils": "0.8.2-staging.7ac8446",
40
+ "@dxos/react-client": "0.8.2-staging.7ac8446"
43
41
  },
44
42
  "peerDependencies": {
45
- "@effect-rx/rx-react": "^0.34.1",
46
- "@effect/platform": "0.80.12",
47
- "effect": "^3.13.3",
48
43
  "react": "~18.2.0",
49
44
  "react-dom": "~18.2.0"
50
45
  },
package/src/graph.ts CHANGED
@@ -2,53 +2,48 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { Option, Record } from 'effect';
5
+ import { batch, effect, untracked } from '@preact/signals-core';
6
6
 
7
- import { Capabilities, contributes, type PluginContext } from '@dxos/app-framework';
8
- import { flattenExtensions, GraphBuilder, type ExpandableGraph, ROOT_ID } from '@dxos/app-graph';
7
+ import { Capabilities, contributes, type PluginsContext } from '@dxos/app-framework';
8
+ import { flattenExtensions, type Graph, GraphBuilder } from '@dxos/app-graph';
9
9
 
10
- // import { GRAPH_PLUGIN } from './meta';
10
+ import { GRAPH_PLUGIN } from './meta';
11
11
 
12
- // const KEY = `${GRAPH_PLUGIN}/app-graph`;
12
+ const KEY = `${GRAPH_PLUGIN}/app-graph`;
13
13
 
14
- export default async (context: PluginContext) => {
15
- const registry = context.getCapability(Capabilities.RxRegistry);
16
- const builder = GraphBuilder.from(/* localStorage.getItem(KEY) ?? */ undefined, registry);
17
- // const interval = setInterval(() => {
18
- // localStorage.setItem(KEY, builder.graph.pickle());
19
- // }, 5_000);
14
+ export default async (context: PluginsContext) => {
15
+ const builder = GraphBuilder.from(localStorage.getItem(KEY) ?? undefined);
16
+ const interval = setInterval(() => {
17
+ localStorage.setItem(KEY, builder.graph.pickle());
18
+ }, 5_000);
20
19
 
21
- const unsubscribe = registry.subscribe(
22
- context.capabilities(Capabilities.AppGraphBuilder),
23
- (extensions) => {
24
- const next = flattenExtensions(extensions);
25
- const current = Record.values(registry.get(builder.extensions));
20
+ const unsubscribe = effect(() => {
21
+ batch(() => {
22
+ const next = flattenExtensions(context.requestCapabilities(Capabilities.AppGraphBuilder));
23
+ const current = untracked(() => builder.extensions);
26
24
  const removed = current.filter(({ id }) => !next.some(({ id: nextId }) => nextId === id));
27
25
  removed.forEach((extension) => builder.removeExtension(extension.id));
28
26
  next.forEach((extension) => builder.addExtension(extension));
29
- },
30
- { immediate: true },
31
- );
32
-
33
- // TODO(wittjosiah): Stop expanding the graph eagerly.
34
- builder.graph.onNodeChanged.on(({ id, node }) => {
35
- if (Option.isSome(node)) {
36
- builder.graph.expand(id);
37
- }
27
+ });
38
28
  });
39
- // await builder.initialize();
40
- builder.graph.expand(ROOT_ID);
29
+
30
+ await builder.initialize();
31
+ await builder.graph.expand(builder.graph.root);
41
32
 
42
33
  setupDevtools(builder.graph);
43
34
 
44
- return contributes(Capabilities.AppGraph, { graph: builder.graph, explore: builder.explore }, () => {
45
- // clearInterval(interval);
46
- unsubscribe();
47
- });
35
+ return contributes(
36
+ Capabilities.AppGraph,
37
+ { graph: builder.graph, explore: (options) => builder.explore(options) },
38
+ () => {
39
+ clearInterval(interval);
40
+ unsubscribe();
41
+ },
42
+ );
48
43
  };
49
44
 
50
45
  // Expose the graph to the window for debugging.
51
- const setupDevtools = (graph: ExpandableGraph) => {
46
+ const setupDevtools = (graph: Graph) => {
52
47
  (globalThis as any).composer ??= {};
53
48
  (globalThis as any).composer.graph = graph;
54
49
  };
@@ -2,10 +2,9 @@
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 { useEffect, useState } from 'react';
7
6
 
8
- import { type ReadableGraph, type Node, type Relation } from '@dxos/app-graph';
7
+ import { type Graph, type Node } from '@dxos/app-graph';
9
8
 
10
9
  /**
11
10
  * React hook to get a node from the graph.
@@ -15,15 +14,33 @@ import { type ReadableGraph, type Node, type Relation } from '@dxos/app-graph';
15
14
  * @param timeout Optional timeout in milliseconds to wait for the node to be found.
16
15
  * @returns Node if found, undefined otherwise.
17
16
  */
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);
21
- };
17
+ // TODO(wittjosiah): Factor out?
18
+ export const useNode = <T = any>(graph: Graph, id?: string, timeout?: number): Node<T> | undefined => {
19
+ const [nodeState, setNodeState] = useState<Node<T> | undefined>(id ? graph.findNode(id, false) : undefined);
22
20
 
23
- export const useConnections = (graph: ReadableGraph, id?: string, relation?: Relation): Node[] => {
24
- return useRxValue(graph.connections(id ?? '', relation));
25
- };
21
+ useEffect(() => {
22
+ if (!id && nodeState) {
23
+ setNodeState(undefined);
24
+ }
25
+
26
+ if (nodeState?.id === id || !id) {
27
+ return;
28
+ }
29
+
30
+ // Set timeout did not seem to effectively not block the UI thread.
31
+ const frame = requestAnimationFrame(async () => {
32
+ try {
33
+ const node = await graph.waitForNode(id, timeout);
34
+ if (node) {
35
+ setNodeState(node);
36
+ }
37
+ } catch {
38
+ // TODO(ZaymonFC): This leaves the resolved node in an invalid state in the case of a timeout.
39
+ }
40
+ });
41
+
42
+ return () => cancelAnimationFrame(frame);
43
+ }, [graph, id, timeout, nodeState?.id]);
26
44
 
27
- export const useActions = (graph: ReadableGraph, id?: string): Node[] => {
28
- return useRxValue(graph.actions(id ?? ''));
45
+ return nodeState;
29
46
  };
@@ -1,42 +0,0 @@
1
- // packages/plugins/plugin-graph/src/graph.ts
2
- import { Option, 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
- builder.graph.onNodeChanged.on(({ id, node }) => {
22
- if (Option.isSome(node)) {
23
- builder.graph.expand(id);
24
- }
25
- });
26
- builder.graph.expand(ROOT_ID);
27
- setupDevtools(builder.graph);
28
- return contributes(Capabilities.AppGraph, {
29
- graph: builder.graph,
30
- explore: builder.explore
31
- }, () => {
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-5AJD2WYC.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 { Option, 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// 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 // TODO(wittjosiah): Stop expanding the graph eagerly.\n builder.graph.onNodeChanged.on(({ id, node }) => {\n if (Option.isSome(node)) {\n builder.graph.expand(id);\n }\n });\n // await builder.initialize();\n 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,QAAQC,cAAc;AAE/B,SAASC,cAAcC,mBAAuC;AAC9D,SAASC,mBAAmBC,cAAoCC,eAAe;AAM/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;AAIpBxB,UAAQyB,MAAMC,cAAcC,GAAG,CAAC,EAAEV,IAAIW,KAAI,MAAE;AAC1C,QAAIC,OAAOC,OAAOF,IAAAA,GAAO;AACvB5B,cAAQyB,MAAMM,OAAOd,EAAAA;IACvB;EACF,CAAA;AAEAjB,UAAQyB,MAAMM,OAAOC,OAAAA;AAErBC,gBAAcjC,QAAQyB,KAAK;AAE3B,SAAOS,YAAYpC,aAAaqC,UAAU;IAAEV,OAAOzB,QAAQyB;IAAOW,SAASpC,QAAQoC;EAAQ,GAAG,MAAA;AAE5FhC,gBAAAA;EACF,CAAA;AACF;AAGA,IAAM6B,gBAAgB,CAACR,UAAAA;AACpBY,aAAmBC,aAAa,CAAC;AACjCD,aAAmBC,SAASb,QAAQA;AACvC;",
6
- "names": ["Option", "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", "onNodeChanged", "on", "node", "Option", "isSome", "expand", "ROOT_ID", "setupDevtools", "contributes", "AppGraph", "explore", "globalThis", "composer"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/graph.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Option, 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// 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 // TODO(wittjosiah): Stop expanding the graph eagerly.\n builder.graph.onNodeChanged.on(({ id, node }) => {\n if (Option.isSome(node)) {\n builder.graph.expand(id);\n }\n });\n // await builder.initialize();\n 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,oBAA+B;AAE/B,2BAA8D;AAC9D,uBAA+E;AAM/E,IAAA,gBAAe,OAAOA,YAAAA;AACpB,QAAMC,WAAWD,QAAQE,cAAcC,kCAAaC,UAAU;AAC9D,QAAMC,UAAUC,8BAAaC;;IAAwCC;IAAWP;EAAAA;AAKhF,QAAMQ,cAAcR,SAASS,UAC3BV,QAAQW,aAAaR,kCAAaS,eAAe,GACjD,CAACC,eAAAA;AACC,UAAMC,WAAOC,oCAAkBF,UAAAA;AAC/B,UAAMG,UAAUC,qBAAOC,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;AAIpBxB,UAAQyB,MAAMC,cAAcC,GAAG,CAAC,EAAEV,IAAIW,KAAI,MAAE;AAC1C,QAAIC,qBAAOC,OAAOF,IAAAA,GAAO;AACvB5B,cAAQyB,MAAMM,OAAOd,EAAAA;IACvB;EACF,CAAA;AAEAjB,UAAQyB,MAAMM,OAAOC,wBAAAA;AAErBC,gBAAcjC,QAAQyB,KAAK;AAE3B,aAAOS,kCAAYpC,kCAAaqC,UAAU;IAAEV,OAAOzB,QAAQyB;IAAOW,SAASpC,QAAQoC;EAAQ,GAAG,MAAA;AAE5FhC,gBAAAA;EACF,CAAA;AACF;AAGA,IAAM6B,gBAAgB,CAACR,UAAAA;AACpBY,aAAmBC,aAAa,CAAC;AACjCD,aAAmBC,SAASb,QAAQA;AACvC;",
6
- "names": ["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", "onNodeChanged", "on", "node", "Option", "isSome", "expand", "ROOT_ID", "setupDevtools", "contributes", "AppGraph", "explore", "globalThis", "composer"]
7
- }
@@ -1,44 +0,0 @@
1
- import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
-
3
- // packages/plugins/plugin-graph/src/graph.ts
4
- import { Option, 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
- builder.graph.onNodeChanged.on(({ id, node }) => {
24
- if (Option.isSome(node)) {
25
- builder.graph.expand(id);
26
- }
27
- });
28
- builder.graph.expand(ROOT_ID);
29
- setupDevtools(builder.graph);
30
- return contributes(Capabilities.AppGraph, {
31
- graph: builder.graph,
32
- explore: builder.explore
33
- }, () => {
34
- unsubscribe();
35
- });
36
- };
37
- var setupDevtools = (graph) => {
38
- globalThis.composer ??= {};
39
- globalThis.composer.graph = graph;
40
- };
41
- export {
42
- graph_default as default
43
- };
44
- //# sourceMappingURL=graph-NJMEGQY3.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 { Option, 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// 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 // TODO(wittjosiah): Stop expanding the graph eagerly.\n builder.graph.onNodeChanged.on(({ id, node }) => {\n if (Option.isSome(node)) {\n builder.graph.expand(id);\n }\n });\n // await builder.initialize();\n 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,QAAQC,cAAc;AAE/B,SAASC,cAAcC,mBAAuC;AAC9D,SAASC,mBAAmBC,cAAoCC,eAAe;AAM/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;AAIpBxB,UAAQyB,MAAMC,cAAcC,GAAG,CAAC,EAAEV,IAAIW,KAAI,MAAE;AAC1C,QAAIC,OAAOC,OAAOF,IAAAA,GAAO;AACvB5B,cAAQyB,MAAMM,OAAOd,EAAAA;IACvB;EACF,CAAA;AAEAjB,UAAQyB,MAAMM,OAAOC,OAAAA;AAErBC,gBAAcjC,QAAQyB,KAAK;AAE3B,SAAOS,YAAYpC,aAAaqC,UAAU;IAAEV,OAAOzB,QAAQyB;IAAOW,SAASpC,QAAQoC;EAAQ,GAAG,MAAA;AAE5FhC,gBAAAA;EACF,CAAA;AACF;AAGA,IAAM6B,gBAAgB,CAACR,UAAAA;AACpBY,aAAmBC,aAAa,CAAC;AACjCD,aAAmBC,SAASb,QAAQA;AACvC;",
6
- "names": ["Option", "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", "onNodeChanged", "on", "node", "Option", "isSome", "expand", "ROOT_ID", "setupDevtools", "contributes", "AppGraph", "explore", "globalThis", "composer"]
7
- }