@dxos/plugin-graph 0.8.2-main.f11618f → 0.8.2-staging.42af850
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -3
- package/dist/lib/browser/graph-TD2RDQ7V.mjs +37 -0
- package/dist/lib/browser/graph-TD2RDQ7V.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +22 -33
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/{graph-GCGIYOGJ.cjs → graph-Q4KLVTNI.cjs} +21 -23
- package/dist/lib/node/graph-Q4KLVTNI.cjs.map +7 -0
- package/dist/lib/node/index.cjs +24 -33
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/graph-J5YUB3RG.mjs +39 -0
- package/dist/lib/node-esm/graph-J5YUB3RG.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +22 -32
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/graph.d.ts +5 -5
- package/dist/types/src/graph.d.ts.map +1 -1
- package/dist/types/src/hooks/useNode.d.ts +4 -2
- package/dist/types/src/hooks/useNode.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +14 -8
- package/src/graph.ts +27 -27
- package/src/hooks/useNode.ts +12 -29
- package/dist/lib/browser/chunk-L263B77P.mjs +0 -12
- package/dist/lib/browser/chunk-L263B77P.mjs.map +0 -7
- package/dist/lib/browser/graph-UYXVVZ2I.mjs +0 -42
- package/dist/lib/browser/graph-UYXVVZ2I.mjs.map +0 -7
- package/dist/lib/node/chunk-AKNWBLRY.cjs +0 -35
- package/dist/lib/node/chunk-AKNWBLRY.cjs.map +0 -7
- package/dist/lib/node/graph-GCGIYOGJ.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-RJQY6JZL.mjs +0 -14
- package/dist/lib/node-esm/chunk-RJQY6JZL.mjs.map +0 -7
- package/dist/lib/node-esm/graph-NUZMWBDN.mjs +0 -43
- package/dist/lib/node-esm/graph-NUZMWBDN.mjs.map +0 -7
package/README.md
CHANGED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// packages/plugins/plugin-graph/src/graph.ts
|
|
2
|
+
import { Record } from "effect";
|
|
3
|
+
import { Capabilities, contributes } from "@dxos/app-framework";
|
|
4
|
+
import { flattenExtensions, GraphBuilder, ROOT_ID } from "@dxos/app-graph";
|
|
5
|
+
var graph_default = async (context) => {
|
|
6
|
+
const registry = context.getCapability(Capabilities.RxRegistry);
|
|
7
|
+
const builder = GraphBuilder.from(
|
|
8
|
+
/* localStorage.getItem(KEY) ?? */
|
|
9
|
+
void 0,
|
|
10
|
+
registry
|
|
11
|
+
);
|
|
12
|
+
const unsubscribe = registry.subscribe(context.capabilities(Capabilities.AppGraphBuilder), (extensions) => {
|
|
13
|
+
const next = flattenExtensions(extensions);
|
|
14
|
+
const current = Record.values(registry.get(builder.extensions));
|
|
15
|
+
const removed = current.filter(({ id }) => !next.some(({ id: nextId }) => nextId === id));
|
|
16
|
+
removed.forEach((extension) => builder.removeExtension(extension.id));
|
|
17
|
+
next.forEach((extension) => builder.addExtension(extension));
|
|
18
|
+
}, {
|
|
19
|
+
immediate: true
|
|
20
|
+
});
|
|
21
|
+
void builder.graph.expand(ROOT_ID);
|
|
22
|
+
setupDevtools(builder.graph);
|
|
23
|
+
return contributes(Capabilities.AppGraph, {
|
|
24
|
+
graph: builder.graph,
|
|
25
|
+
explore: builder.explore
|
|
26
|
+
}, () => {
|
|
27
|
+
unsubscribe();
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
var setupDevtools = (graph) => {
|
|
31
|
+
globalThis.composer ??= {};
|
|
32
|
+
globalThis.composer.graph = graph;
|
|
33
|
+
};
|
|
34
|
+
export {
|
|
35
|
+
graph_default as default
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=graph-TD2RDQ7V.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 { Record } from 'effect';\n\nimport { Capabilities, contributes, type PluginContext } from '@dxos/app-framework';\nimport { flattenExtensions, GraphBuilder, type ExpandableGraph, ROOT_ID } from '@dxos/app-graph';\n\n// TODO(wittjosiah): Remove or restore graph caching.\n// import { GRAPH_PLUGIN } from './meta';\n\n// const KEY = `${GRAPH_PLUGIN}/app-graph`;\n\nexport default async (context: PluginContext) => {\n const registry = context.getCapability(Capabilities.RxRegistry);\n const builder = GraphBuilder.from(/* localStorage.getItem(KEY) ?? */ undefined, registry);\n // const interval = setInterval(() => {\n // localStorage.setItem(KEY, builder.graph.pickle());\n // }, 5_000);\n\n const unsubscribe = registry.subscribe(\n context.capabilities(Capabilities.AppGraphBuilder),\n (extensions) => {\n const next = flattenExtensions(extensions);\n const current = Record.values(registry.get(builder.extensions));\n const removed = current.filter(({ id }) => !next.some(({ id: nextId }) => nextId === id));\n removed.forEach((extension) => builder.removeExtension(extension.id));\n next.forEach((extension) => builder.addExtension(extension));\n },\n { immediate: true },\n );\n\n // await builder.initialize();\n void builder.graph.expand(ROOT_ID);\n\n setupDevtools(builder.graph);\n\n return contributes(Capabilities.AppGraph, { graph: builder.graph, explore: builder.explore }, () => {\n // clearInterval(interval);\n unsubscribe();\n });\n};\n\n// Expose the graph to the window for debugging.\nconst setupDevtools = (graph: ExpandableGraph) => {\n (globalThis as any).composer ??= {};\n (globalThis as any).composer.graph = graph;\n};\n"],
|
|
5
|
+
"mappings": ";AAIA,SAASA,cAAc;AAEvB,SAASC,cAAcC,mBAAuC;AAC9D,SAASC,mBAAmBC,cAAoCC,eAAe;AAO/E,IAAA,gBAAe,OAAOC,YAAAA;AACpB,QAAMC,WAAWD,QAAQE,cAAcC,aAAaC,UAAU;AAC9D,QAAMC,UAAUC,aAAaC;;IAAwCC;IAAWP;EAAAA;AAKhF,QAAMQ,cAAcR,SAASS,UAC3BV,QAAQW,aAAaR,aAAaS,eAAe,GACjD,CAACC,eAAAA;AACC,UAAMC,OAAOC,kBAAkBF,UAAAA;AAC/B,UAAMG,UAAUC,OAAOC,OAAOjB,SAASkB,IAAId,QAAQQ,UAAU,CAAA;AAC7D,UAAMO,UAAUJ,QAAQK,OAAO,CAAC,EAAEC,GAAE,MAAO,CAACR,KAAKS,KAAK,CAAC,EAAED,IAAIE,OAAM,MAAOA,WAAWF,EAAAA,CAAAA;AACrFF,YAAQK,QAAQ,CAACC,cAAcrB,QAAQsB,gBAAgBD,UAAUJ,EAAE,CAAA;AACnER,SAAKW,QAAQ,CAACC,cAAcrB,QAAQuB,aAAaF,SAAAA,CAAAA;EACnD,GACA;IAAEG,WAAW;EAAK,CAAA;AAIpB,OAAKxB,QAAQyB,MAAMC,OAAOC,OAAAA;AAE1BC,gBAAc5B,QAAQyB,KAAK;AAE3B,SAAOI,YAAY/B,aAAagC,UAAU;IAAEL,OAAOzB,QAAQyB;IAAOM,SAAS/B,QAAQ+B;EAAQ,GAAG,MAAA;AAE5F3B,gBAAAA;EACF,CAAA;AACF;AAGA,IAAMwB,gBAAgB,CAACH,UAAAA;AACpBO,aAAmBC,aAAa,CAAC;AACjCD,aAAmBC,SAASR,QAAQA;AACvC;",
|
|
6
|
+
"names": ["Record", "Capabilities", "contributes", "flattenExtensions", "GraphBuilder", "ROOT_ID", "context", "registry", "getCapability", "Capabilities", "RxRegistry", "builder", "GraphBuilder", "from", "undefined", "unsubscribe", "subscribe", "capabilities", "AppGraphBuilder", "extensions", "next", "flattenExtensions", "current", "Record", "values", "get", "removed", "filter", "id", "some", "nextId", "forEach", "extension", "removeExtension", "addExtension", "immediate", "graph", "expand", "ROOT_ID", "setupDevtools", "contributes", "AppGraph", "explore", "globalThis", "composer"]
|
|
7
|
+
}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
GRAPH_PLUGIN,
|
|
3
|
-
meta
|
|
4
|
-
} from "./chunk-L263B77P.mjs";
|
|
5
|
-
|
|
6
1
|
// packages/plugins/plugin-graph/src/index.ts
|
|
7
2
|
export * from "@dxos/app-graph";
|
|
8
3
|
|
|
9
4
|
// packages/plugins/plugin-graph/src/GraphPlugin.ts
|
|
10
5
|
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
|
|
11
15
|
var GraphPlugin = () => definePlugin(meta, [
|
|
12
16
|
defineModule({
|
|
13
17
|
id: `${meta.id}/module/graph`,
|
|
@@ -19,43 +23,28 @@ var GraphPlugin = () => definePlugin(meta, [
|
|
|
19
23
|
activatesAfter: [
|
|
20
24
|
Events.AppGraphReady
|
|
21
25
|
],
|
|
22
|
-
activate: lazy(() => import("./graph-
|
|
26
|
+
activate: lazy(() => import("./graph-TD2RDQ7V.mjs"))
|
|
23
27
|
})
|
|
24
28
|
]);
|
|
25
29
|
|
|
26
30
|
// packages/plugins/plugin-graph/src/hooks/useNode.ts
|
|
27
|
-
import {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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;
|
|
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 ?? ""));
|
|
54
41
|
};
|
|
55
42
|
export {
|
|
56
43
|
GRAPH_PLUGIN,
|
|
57
44
|
GraphPlugin,
|
|
58
45
|
meta,
|
|
46
|
+
useActions,
|
|
47
|
+
useConnections,
|
|
59
48
|
useNode
|
|
60
49
|
};
|
|
61
50
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["defineModule", "lazy", "Events", "definePlugin", "GraphPlugin", "definePlugin", "meta", "defineModule", "id", "activatesOn", "Events", "Startup", "activatesBefore", "SetupAppGraph", "SetupMetadata", "activatesAfter", "AppGraphReady", "activate", "lazy", "
|
|
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"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"packages/plugins/plugin-graph/src/meta.ts":{"bytes":
|
|
1
|
+
{"inputs":{"packages/plugins/plugin-graph/src/meta.ts":{"bytes":914,"imports":[],"format":"esm"},"packages/plugins/plugin-graph/src/graph.ts":{"bytes":6317,"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":2750,"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":3137,"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":474,"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":746,"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-TD2RDQ7V.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-TD2RDQ7V.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":3328},"packages/plugins/plugin-graph/dist/lib/browser/graph-TD2RDQ7V.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":1200}},"bytes":1329}}}
|
|
@@ -16,38 +16,36 @@ 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
|
|
20
|
-
__export(
|
|
19
|
+
var graph_Q4KLVTNI_exports = {};
|
|
20
|
+
__export(graph_Q4KLVTNI_exports, {
|
|
21
21
|
default: () => graph_default
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
24
|
-
var
|
|
25
|
-
var import_signals_core = require("@preact/signals-core");
|
|
23
|
+
module.exports = __toCommonJS(graph_Q4KLVTNI_exports);
|
|
24
|
+
var import_effect = require("effect");
|
|
26
25
|
var import_app_framework = require("@dxos/app-framework");
|
|
27
26
|
var import_app_graph = require("@dxos/app-graph");
|
|
28
|
-
var KEY = `${import_chunk_AKNWBLRY.GRAPH_PLUGIN}/app-graph`;
|
|
29
27
|
var graph_default = async (context) => {
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
localStorage.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
|
42
42
|
});
|
|
43
|
-
|
|
44
|
-
await builder.graph.expand(builder.graph.root);
|
|
43
|
+
void builder.graph.expand(import_app_graph.ROOT_ID);
|
|
45
44
|
setupDevtools(builder.graph);
|
|
46
45
|
return (0, import_app_framework.contributes)(import_app_framework.Capabilities.AppGraph, {
|
|
47
46
|
graph: builder.graph,
|
|
48
|
-
explore:
|
|
47
|
+
explore: builder.explore
|
|
49
48
|
}, () => {
|
|
50
|
-
clearInterval(interval);
|
|
51
49
|
unsubscribe();
|
|
52
50
|
});
|
|
53
51
|
};
|
|
@@ -55,4 +53,4 @@ var setupDevtools = (graph) => {
|
|
|
55
53
|
globalThis.composer ??= {};
|
|
56
54
|
globalThis.composer.graph = graph;
|
|
57
55
|
};
|
|
58
|
-
//# sourceMappingURL=graph-
|
|
56
|
+
//# sourceMappingURL=graph-Q4KLVTNI.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 { Record } from 'effect';\n\nimport { Capabilities, contributes, type PluginContext } from '@dxos/app-framework';\nimport { flattenExtensions, GraphBuilder, type ExpandableGraph, ROOT_ID } from '@dxos/app-graph';\n\n// TODO(wittjosiah): Remove or restore graph caching.\n// import { GRAPH_PLUGIN } from './meta';\n\n// const KEY = `${GRAPH_PLUGIN}/app-graph`;\n\nexport default async (context: PluginContext) => {\n const registry = context.getCapability(Capabilities.RxRegistry);\n const builder = GraphBuilder.from(/* localStorage.getItem(KEY) ?? */ undefined, registry);\n // const interval = setInterval(() => {\n // localStorage.setItem(KEY, builder.graph.pickle());\n // }, 5_000);\n\n const unsubscribe = registry.subscribe(\n context.capabilities(Capabilities.AppGraphBuilder),\n (extensions) => {\n const next = flattenExtensions(extensions);\n const current = Record.values(registry.get(builder.extensions));\n const removed = current.filter(({ id }) => !next.some(({ id: nextId }) => nextId === id));\n removed.forEach((extension) => builder.removeExtension(extension.id));\n next.forEach((extension) => builder.addExtension(extension));\n },\n { immediate: true },\n );\n\n // await builder.initialize();\n void builder.graph.expand(ROOT_ID);\n\n setupDevtools(builder.graph);\n\n return contributes(Capabilities.AppGraph, { graph: builder.graph, explore: builder.explore }, () => {\n // clearInterval(interval);\n unsubscribe();\n });\n};\n\n// Expose the graph to the window for debugging.\nconst setupDevtools = (graph: ExpandableGraph) => {\n (globalThis as any).composer ??= {};\n (globalThis as any).composer.graph = graph;\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAIA,oBAAuB;AAEvB,2BAA8D;AAC9D,uBAA+E;AAO/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;AAIpB,OAAKxB,QAAQyB,MAAMC,OAAOC,wBAAAA;AAE1BC,gBAAc5B,QAAQyB,KAAK;AAE3B,aAAOI,kCAAY/B,kCAAagC,UAAU;IAAEL,OAAOzB,QAAQyB;IAAOM,SAAS/B,QAAQ+B;EAAQ,GAAG,MAAA;AAE5F3B,gBAAAA;EACF,CAAA;AACF;AAGA,IAAMwB,gBAAgB,CAACH,UAAAA;AACpBO,aAAmBC,aAAa,CAAC;AACjCD,aAAmBC,SAASR,QAAQA;AACvC;",
|
|
6
|
+
"names": ["context", "registry", "getCapability", "Capabilities", "RxRegistry", "builder", "GraphBuilder", "from", "undefined", "unsubscribe", "subscribe", "capabilities", "AppGraphBuilder", "extensions", "next", "flattenExtensions", "current", "Record", "values", "get", "removed", "filter", "id", "some", "nextId", "forEach", "extension", "removeExtension", "addExtension", "immediate", "graph", "expand", "ROOT_ID", "setupDevtools", "contributes", "AppGraph", "explore", "globalThis", "composer"]
|
|
7
|
+
}
|
package/dist/lib/node/index.cjs
CHANGED
|
@@ -29,19 +29,26 @@ 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: () =>
|
|
32
|
+
GRAPH_PLUGIN: () => GRAPH_PLUGIN,
|
|
33
33
|
GraphPlugin: () => GraphPlugin,
|
|
34
|
-
meta: () =>
|
|
34
|
+
meta: () => meta,
|
|
35
|
+
useActions: () => useActions,
|
|
36
|
+
useConnections: () => useConnections,
|
|
35
37
|
useNode: () => useNode
|
|
36
38
|
});
|
|
37
39
|
module.exports = __toCommonJS(node_exports);
|
|
38
|
-
var import_chunk_AKNWBLRY = require("./chunk-AKNWBLRY.cjs");
|
|
39
40
|
__reExport(node_exports, require("@dxos/app-graph"), module.exports);
|
|
40
41
|
var import_app_framework = require("@dxos/app-framework");
|
|
41
|
-
var
|
|
42
|
-
var
|
|
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, [
|
|
43
50
|
(0, import_app_framework.defineModule)({
|
|
44
|
-
id: `${
|
|
51
|
+
id: `${meta.id}/module/graph`,
|
|
45
52
|
activatesOn: import_app_framework.Events.Startup,
|
|
46
53
|
activatesBefore: [
|
|
47
54
|
import_app_framework.Events.SetupAppGraph,
|
|
@@ -50,41 +57,25 @@ var GraphPlugin = () => (0, import_app_framework.definePlugin)(import_chunk_AKNW
|
|
|
50
57
|
activatesAfter: [
|
|
51
58
|
import_app_framework.Events.AppGraphReady
|
|
52
59
|
],
|
|
53
|
-
activate: (0, import_app_framework.lazy)(() => import("./graph-
|
|
60
|
+
activate: (0, import_app_framework.lazy)(() => import("./graph-Q4KLVTNI.cjs"))
|
|
54
61
|
})
|
|
55
62
|
]);
|
|
56
|
-
var useNode = (graph, id
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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;
|
|
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 ?? ""));
|
|
82
71
|
};
|
|
83
72
|
// Annotate the CommonJS export names for ESM import in node:
|
|
84
73
|
0 && (module.exports = {
|
|
85
74
|
GRAPH_PLUGIN,
|
|
86
75
|
GraphPlugin,
|
|
87
76
|
meta,
|
|
77
|
+
useActions,
|
|
78
|
+
useConnections,
|
|
88
79
|
useNode,
|
|
89
80
|
...require("@dxos/app-graph")
|
|
90
81
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["
|
|
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"]
|
|
7
7
|
}
|
package/dist/lib/node/meta.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"packages/plugins/plugin-graph/src/meta.ts":{"bytes":
|
|
1
|
+
{"inputs":{"packages/plugins/plugin-graph/src/meta.ts":{"bytes":914,"imports":[],"format":"esm"},"packages/plugins/plugin-graph/src/graph.ts":{"bytes":6317,"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":2750,"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":3137,"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":474,"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":746,"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-Q4KLVTNI.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-Q4KLVTNI.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":3328},"packages/plugins/plugin-graph/dist/lib/node/graph-Q4KLVTNI.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":1200}},"bytes":1329}}}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// packages/plugins/plugin-graph/src/graph.ts
|
|
4
|
+
import { Record } from "effect";
|
|
5
|
+
import { Capabilities, contributes } from "@dxos/app-framework";
|
|
6
|
+
import { flattenExtensions, GraphBuilder, ROOT_ID } from "@dxos/app-graph";
|
|
7
|
+
var graph_default = async (context) => {
|
|
8
|
+
const registry = context.getCapability(Capabilities.RxRegistry);
|
|
9
|
+
const builder = GraphBuilder.from(
|
|
10
|
+
/* localStorage.getItem(KEY) ?? */
|
|
11
|
+
void 0,
|
|
12
|
+
registry
|
|
13
|
+
);
|
|
14
|
+
const unsubscribe = registry.subscribe(context.capabilities(Capabilities.AppGraphBuilder), (extensions) => {
|
|
15
|
+
const next = flattenExtensions(extensions);
|
|
16
|
+
const current = Record.values(registry.get(builder.extensions));
|
|
17
|
+
const removed = current.filter(({ id }) => !next.some(({ id: nextId }) => nextId === id));
|
|
18
|
+
removed.forEach((extension) => builder.removeExtension(extension.id));
|
|
19
|
+
next.forEach((extension) => builder.addExtension(extension));
|
|
20
|
+
}, {
|
|
21
|
+
immediate: true
|
|
22
|
+
});
|
|
23
|
+
void builder.graph.expand(ROOT_ID);
|
|
24
|
+
setupDevtools(builder.graph);
|
|
25
|
+
return contributes(Capabilities.AppGraph, {
|
|
26
|
+
graph: builder.graph,
|
|
27
|
+
explore: builder.explore
|
|
28
|
+
}, () => {
|
|
29
|
+
unsubscribe();
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
var setupDevtools = (graph) => {
|
|
33
|
+
globalThis.composer ??= {};
|
|
34
|
+
globalThis.composer.graph = graph;
|
|
35
|
+
};
|
|
36
|
+
export {
|
|
37
|
+
graph_default as default
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=graph-J5YUB3RG.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 { Record } from 'effect';\n\nimport { Capabilities, contributes, type PluginContext } from '@dxos/app-framework';\nimport { flattenExtensions, GraphBuilder, type ExpandableGraph, ROOT_ID } from '@dxos/app-graph';\n\n// TODO(wittjosiah): Remove or restore graph caching.\n// import { GRAPH_PLUGIN } from './meta';\n\n// const KEY = `${GRAPH_PLUGIN}/app-graph`;\n\nexport default async (context: PluginContext) => {\n const registry = context.getCapability(Capabilities.RxRegistry);\n const builder = GraphBuilder.from(/* localStorage.getItem(KEY) ?? */ undefined, registry);\n // const interval = setInterval(() => {\n // localStorage.setItem(KEY, builder.graph.pickle());\n // }, 5_000);\n\n const unsubscribe = registry.subscribe(\n context.capabilities(Capabilities.AppGraphBuilder),\n (extensions) => {\n const next = flattenExtensions(extensions);\n const current = Record.values(registry.get(builder.extensions));\n const removed = current.filter(({ id }) => !next.some(({ id: nextId }) => nextId === id));\n removed.forEach((extension) => builder.removeExtension(extension.id));\n next.forEach((extension) => builder.addExtension(extension));\n },\n { immediate: true },\n );\n\n // await builder.initialize();\n void builder.graph.expand(ROOT_ID);\n\n setupDevtools(builder.graph);\n\n return contributes(Capabilities.AppGraph, { graph: builder.graph, explore: builder.explore }, () => {\n // clearInterval(interval);\n unsubscribe();\n });\n};\n\n// Expose the graph to the window for debugging.\nconst setupDevtools = (graph: ExpandableGraph) => {\n (globalThis as any).composer ??= {};\n (globalThis as any).composer.graph = graph;\n};\n"],
|
|
5
|
+
"mappings": ";;;AAIA,SAASA,cAAc;AAEvB,SAASC,cAAcC,mBAAuC;AAC9D,SAASC,mBAAmBC,cAAoCC,eAAe;AAO/E,IAAA,gBAAe,OAAOC,YAAAA;AACpB,QAAMC,WAAWD,QAAQE,cAAcC,aAAaC,UAAU;AAC9D,QAAMC,UAAUC,aAAaC;;IAAwCC;IAAWP;EAAAA;AAKhF,QAAMQ,cAAcR,SAASS,UAC3BV,QAAQW,aAAaR,aAAaS,eAAe,GACjD,CAACC,eAAAA;AACC,UAAMC,OAAOC,kBAAkBF,UAAAA;AAC/B,UAAMG,UAAUC,OAAOC,OAAOjB,SAASkB,IAAId,QAAQQ,UAAU,CAAA;AAC7D,UAAMO,UAAUJ,QAAQK,OAAO,CAAC,EAAEC,GAAE,MAAO,CAACR,KAAKS,KAAK,CAAC,EAAED,IAAIE,OAAM,MAAOA,WAAWF,EAAAA,CAAAA;AACrFF,YAAQK,QAAQ,CAACC,cAAcrB,QAAQsB,gBAAgBD,UAAUJ,EAAE,CAAA;AACnER,SAAKW,QAAQ,CAACC,cAAcrB,QAAQuB,aAAaF,SAAAA,CAAAA;EACnD,GACA;IAAEG,WAAW;EAAK,CAAA;AAIpB,OAAKxB,QAAQyB,MAAMC,OAAOC,OAAAA;AAE1BC,gBAAc5B,QAAQyB,KAAK;AAE3B,SAAOI,YAAY/B,aAAagC,UAAU;IAAEL,OAAOzB,QAAQyB;IAAOM,SAAS/B,QAAQ+B;EAAQ,GAAG,MAAA;AAE5F3B,gBAAAA;EACF,CAAA;AACF;AAGA,IAAMwB,gBAAgB,CAACH,UAAAA;AACpBO,aAAmBC,aAAa,CAAC;AACjCD,aAAmBC,SAASR,QAAQA;AACvC;",
|
|
6
|
+
"names": ["Record", "Capabilities", "contributes", "flattenExtensions", "GraphBuilder", "ROOT_ID", "context", "registry", "getCapability", "Capabilities", "RxRegistry", "builder", "GraphBuilder", "from", "undefined", "unsubscribe", "subscribe", "capabilities", "AppGraphBuilder", "extensions", "next", "flattenExtensions", "current", "Record", "values", "get", "removed", "filter", "id", "some", "nextId", "forEach", "extension", "removeExtension", "addExtension", "immediate", "graph", "expand", "ROOT_ID", "setupDevtools", "contributes", "AppGraph", "explore", "globalThis", "composer"]
|
|
7
|
+
}
|
|
@@ -1,14 +1,19 @@
|
|
|
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";
|
|
6
2
|
|
|
7
3
|
// packages/plugins/plugin-graph/src/index.ts
|
|
8
4
|
export * from "@dxos/app-graph";
|
|
9
5
|
|
|
10
6
|
// packages/plugins/plugin-graph/src/GraphPlugin.ts
|
|
11
7
|
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
|
|
12
17
|
var GraphPlugin = () => definePlugin(meta, [
|
|
13
18
|
defineModule({
|
|
14
19
|
id: `${meta.id}/module/graph`,
|
|
@@ -20,43 +25,28 @@ var GraphPlugin = () => definePlugin(meta, [
|
|
|
20
25
|
activatesAfter: [
|
|
21
26
|
Events.AppGraphReady
|
|
22
27
|
],
|
|
23
|
-
activate: lazy(() => import("./graph-
|
|
28
|
+
activate: lazy(() => import("./graph-J5YUB3RG.mjs"))
|
|
24
29
|
})
|
|
25
30
|
]);
|
|
26
31
|
|
|
27
32
|
// packages/plugins/plugin-graph/src/hooks/useNode.ts
|
|
28
|
-
import {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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;
|
|
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 ?? ""));
|
|
55
43
|
};
|
|
56
44
|
export {
|
|
57
45
|
GRAPH_PLUGIN,
|
|
58
46
|
GraphPlugin,
|
|
59
47
|
meta,
|
|
48
|
+
useActions,
|
|
49
|
+
useConnections,
|
|
60
50
|
useNode
|
|
61
51
|
};
|
|
62
52
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["defineModule", "lazy", "Events", "definePlugin", "GraphPlugin", "definePlugin", "meta", "defineModule", "id", "activatesOn", "Events", "Startup", "activatesBefore", "SetupAppGraph", "SetupMetadata", "activatesAfter", "AppGraphReady", "activate", "lazy", "
|
|
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"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"packages/plugins/plugin-graph/src/meta.ts":{"bytes":
|
|
1
|
+
{"inputs":{"packages/plugins/plugin-graph/src/meta.ts":{"bytes":914,"imports":[],"format":"esm"},"packages/plugins/plugin-graph/src/graph.ts":{"bytes":6317,"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":2750,"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":3137,"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":474,"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":746,"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-J5YUB3RG.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-J5YUB3RG.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":3330},"packages/plugins/plugin-graph/dist/lib/node-esm/graph-J5YUB3RG.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":1200}},"bytes":1422}}}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import { type
|
|
3
|
-
declare const _default: (context:
|
|
4
|
-
graph:
|
|
5
|
-
explore: (
|
|
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>;
|
|
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,
|
|
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;yBAO3E,SAAS,aAAa;;;;AAA5C,wBA4BE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type ReadableGraph, type Node, type Relation } from '@dxos/app-graph';
|
|
2
2
|
/**
|
|
3
3
|
* React hook to get a node from the graph.
|
|
4
4
|
*
|
|
@@ -7,5 +7,7 @@ import { type Graph, type Node } 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:
|
|
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[];
|
|
11
13
|
//# sourceMappingURL=useNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNode.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useNode.ts"],"names":[],"mappings":"
|
|
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 +1 @@
|
|
|
1
|
-
{"version":"5.
|
|
1
|
+
{"version":"5.8.3"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-graph",
|
|
3
|
-
"version": "0.8.2-
|
|
3
|
+
"version": "0.8.2-staging.42af850",
|
|
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,22 +24,28 @@
|
|
|
24
24
|
"src"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@preact/
|
|
28
|
-
"@dxos/app-
|
|
29
|
-
"@dxos/
|
|
30
|
-
"@dxos/
|
|
31
|
-
"@dxos/
|
|
27
|
+
"@preact-signals/safe-react": "^0.9.0",
|
|
28
|
+
"@dxos/app-graph": "0.8.2-staging.42af850",
|
|
29
|
+
"@dxos/debug": "0.8.2-staging.42af850",
|
|
30
|
+
"@dxos/app-framework": "0.8.2-staging.42af850",
|
|
31
|
+
"@dxos/async": "0.8.2-staging.42af850"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
+
"@effect-rx/rx-react": "^0.34.1",
|
|
35
|
+
"@effect/platform": "0.80.12",
|
|
34
36
|
"@types/react": "~18.2.0",
|
|
35
37
|
"@types/react-dom": "~18.2.0",
|
|
38
|
+
"effect": "^3.13.3",
|
|
36
39
|
"react": "~18.2.0",
|
|
37
40
|
"react-dom": "~18.2.0",
|
|
38
41
|
"vite": "5.4.7",
|
|
39
|
-
"@dxos/react-client": "0.8.2-
|
|
40
|
-
"@dxos/storybook-utils": "0.8.2-
|
|
42
|
+
"@dxos/react-client": "0.8.2-staging.42af850",
|
|
43
|
+
"@dxos/storybook-utils": "0.8.2-staging.42af850"
|
|
41
44
|
},
|
|
42
45
|
"peerDependencies": {
|
|
46
|
+
"@effect-rx/rx-react": "^0.34.1",
|
|
47
|
+
"@effect/platform": "0.80.12",
|
|
48
|
+
"effect": "^3.13.3",
|
|
43
49
|
"react": "~18.2.0",
|
|
44
50
|
"react-dom": "~18.2.0"
|
|
45
51
|
},
|
package/src/graph.ts
CHANGED
|
@@ -2,48 +2,48 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Record } from 'effect';
|
|
6
6
|
|
|
7
|
-
import { Capabilities, contributes, type
|
|
8
|
-
import { flattenExtensions, type
|
|
7
|
+
import { Capabilities, contributes, type PluginContext } from '@dxos/app-framework';
|
|
8
|
+
import { flattenExtensions, GraphBuilder, type ExpandableGraph, ROOT_ID } from '@dxos/app-graph';
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
// TODO(wittjosiah): Remove or restore graph caching.
|
|
11
|
+
// import { GRAPH_PLUGIN } from './meta';
|
|
11
12
|
|
|
12
|
-
const KEY = `${GRAPH_PLUGIN}/app-graph`;
|
|
13
|
+
// const KEY = `${GRAPH_PLUGIN}/app-graph`;
|
|
13
14
|
|
|
14
|
-
export default async (context:
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
export default async (context: PluginContext) => {
|
|
16
|
+
const registry = context.getCapability(Capabilities.RxRegistry);
|
|
17
|
+
const builder = GraphBuilder.from(/* localStorage.getItem(KEY) ?? */ undefined, registry);
|
|
18
|
+
// const interval = setInterval(() => {
|
|
19
|
+
// localStorage.setItem(KEY, builder.graph.pickle());
|
|
20
|
+
// }, 5_000);
|
|
19
21
|
|
|
20
|
-
const unsubscribe =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const
|
|
22
|
+
const unsubscribe = registry.subscribe(
|
|
23
|
+
context.capabilities(Capabilities.AppGraphBuilder),
|
|
24
|
+
(extensions) => {
|
|
25
|
+
const next = flattenExtensions(extensions);
|
|
26
|
+
const current = Record.values(registry.get(builder.extensions));
|
|
24
27
|
const removed = current.filter(({ id }) => !next.some(({ id: nextId }) => nextId === id));
|
|
25
28
|
removed.forEach((extension) => builder.removeExtension(extension.id));
|
|
26
29
|
next.forEach((extension) => builder.addExtension(extension));
|
|
27
|
-
}
|
|
28
|
-
|
|
30
|
+
},
|
|
31
|
+
{ immediate: true },
|
|
32
|
+
);
|
|
29
33
|
|
|
30
|
-
await builder.initialize();
|
|
31
|
-
|
|
34
|
+
// await builder.initialize();
|
|
35
|
+
void builder.graph.expand(ROOT_ID);
|
|
32
36
|
|
|
33
37
|
setupDevtools(builder.graph);
|
|
34
38
|
|
|
35
|
-
return contributes(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
clearInterval(interval);
|
|
40
|
-
unsubscribe();
|
|
41
|
-
},
|
|
42
|
-
);
|
|
39
|
+
return contributes(Capabilities.AppGraph, { graph: builder.graph, explore: builder.explore }, () => {
|
|
40
|
+
// clearInterval(interval);
|
|
41
|
+
unsubscribe();
|
|
42
|
+
});
|
|
43
43
|
};
|
|
44
44
|
|
|
45
45
|
// Expose the graph to the window for debugging.
|
|
46
|
-
const setupDevtools = (graph:
|
|
46
|
+
const setupDevtools = (graph: ExpandableGraph) => {
|
|
47
47
|
(globalThis as any).composer ??= {};
|
|
48
48
|
(globalThis as any).composer.graph = graph;
|
|
49
49
|
};
|
package/src/hooks/useNode.ts
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { useRxValue } from '@effect-rx/rx-react';
|
|
6
|
+
import { Option } from 'effect';
|
|
6
7
|
|
|
7
|
-
import { type
|
|
8
|
+
import { type ReadableGraph, type Node, type Relation } from '@dxos/app-graph';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* React hook to get a node from the graph.
|
|
@@ -14,33 +15,15 @@ import { type Graph, type Node } from '@dxos/app-graph';
|
|
|
14
15
|
* @param timeout Optional timeout in milliseconds to wait for the node to be found.
|
|
15
16
|
* @returns Node if found, undefined otherwise.
|
|
16
17
|
*/
|
|
17
|
-
// TODO(wittjosiah): Factor out
|
|
18
|
-
export const useNode = <T = any>(graph:
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
});
|
|
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
|
+
};
|
|
41
22
|
|
|
42
|
-
|
|
43
|
-
|
|
23
|
+
export const useConnections = (graph: ReadableGraph, id?: string, relation?: Relation): Node[] => {
|
|
24
|
+
return useRxValue(graph.connections(id ?? '', relation));
|
|
25
|
+
};
|
|
44
26
|
|
|
45
|
-
|
|
27
|
+
export const useActions = (graph: ReadableGraph, id?: string): Node[] => {
|
|
28
|
+
return useRxValue(graph.actions(id ?? ''));
|
|
46
29
|
};
|
|
@@ -1,7 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
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
|
|
@@ -1,7 +0,0 @@
|
|
|
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,35 +0,0 @@
|
|
|
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
|
|
@@ -1,7 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
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
|
|
@@ -1,7 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
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
|
|
@@ -1,7 +0,0 @@
|
|
|
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
|
-
}
|