@dxos/plugin-graph 0.12.0-next-73daef452f1464b62efdbca75fb0067c1066f264 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/chunk-action.mjs +1 -1
- package/dist/lib/chunk-action.mjs.map +1 -1
- package/dist/lib/chunk-graph.mjs +11 -1
- package/dist/lib/chunk-graph.mjs.map +1 -1
- package/dist/lib/chunk-rolldown-runtime.mjs +15 -1
- package/dist/lib/hooks.mjs +84 -5
- package/dist/lib/hooks.mjs.map +1 -1
- package/dist/lib/index.mjs +3 -3
- package/dist/lib/meta.mjs.map +1 -1
- package/dist/lib/ns/GraphAction.mjs +8 -0
- package/dist/lib/ns/GraphAction.mjs.map +1 -0
- package/dist/lib/ns/Hooks.mjs +10 -0
- package/dist/lib/ns/Hooks.mjs.map +1 -0
- package/dist/lib/plugin.mjs +1 -1
- package/dist/lib/plugin.mjs.map +1 -1
- package/dist/types/src/GraphAction.d.ts +2 -0
- package/dist/types/src/GraphAction.d.ts.map +1 -0
- package/dist/types/src/Hooks.d.ts +2 -0
- package/dist/types/src/Hooks.d.ts.map +1 -0
- package/dist/types/src/hooks/graph-tree-model.test.d.ts +2 -0
- package/dist/types/src/hooks/graph-tree-model.test.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +3 -2
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useActionRunner.d.ts.map +1 -1
- package/dist/types/src/hooks/useGraphTreeModel.d.ts +18 -0
- package/dist/types/src/hooks/useGraphTreeModel.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +3 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/testing.d.ts +1 -1
- package/dist/types/src/testing.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +30 -23
- package/src/GraphAction.ts +7 -0
- package/src/Hooks.ts +7 -0
- package/src/action.ts +1 -1
- package/src/graph.ts +14 -2
- package/src/hooks/graph-tree-model.test.ts +73 -0
- package/src/hooks/index.ts +3 -2
- package/src/hooks/useActionRunner.ts +5 -4
- package/src/hooks/useGraphTreeModel.ts +114 -0
- package/src/index.ts +3 -3
- package/src/meta.ts +1 -1
- package/src/plugin.test.ts +2 -2
- package/src/plugin.ts +1 -1
- package/src/testing.ts +1 -1
|
@@ -2,7 +2,7 @@ import * as Effect from "effect/Effect";
|
|
|
2
2
|
import * as Function from "effect/Function";
|
|
3
3
|
import * as Capability from "@dxos/app-framework/Capability";
|
|
4
4
|
import * as Operation from "@dxos/compute/Operation";
|
|
5
|
-
import
|
|
5
|
+
import * as EffectEx from "@dxos/effect/EffectEx";
|
|
6
6
|
//#region src/action.ts
|
|
7
7
|
/**
|
|
8
8
|
* Run an action with required layers: Operation.Service, Capability.Service, and captured context.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunk-action.mjs","names":[],"sources":["../../src/action.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport * as Function from 'effect/Function';\n\nimport * as Capability from '@dxos/app-framework/Capability';\nimport type * as CapabilityManager from '@dxos/app-framework/CapabilityManager';\nimport type * as AppGraphNode from '@dxos/app-graph/AppGraphNode';\nimport * as Operation from '@dxos/compute/Operation';\nimport
|
|
1
|
+
{"version":3,"file":"chunk-action.mjs","names":[],"sources":["../../src/action.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport * as Function from 'effect/Function';\n\nimport * as Capability from '@dxos/app-framework/Capability';\nimport type * as CapabilityManager from '@dxos/app-framework/CapabilityManager';\nimport type * as AppGraphNode from '@dxos/app-graph/AppGraphNode';\nimport * as Operation from '@dxos/compute/Operation';\nimport * as EffectEx from '@dxos/effect/EffectEx';\n\n/**\n * Run an action with required layers: Operation.Service, Capability.Service, and captured context.\n * @param invoker The operation invoker to use for Operation.Service.\n * @param capabilityManager The capability manager for Capability.Service.\n * @param action The action to execute.\n * @param params Parameters to pass to the action.\n */\nexport const runAction = async (\n invoker: Operation.OperationService,\n capabilityManager: CapabilityManager.CapabilityManager,\n action: AppGraphNode.Action,\n params: AppGraphNode.InvokeProps = {},\n): Promise<void> =>\n EffectEx.runAndForwardErrors(\n action\n .data(params)\n .pipe(\n Effect.provideService(Operation.Service, invoker),\n Effect.provideService(Capability.Service, capabilityManager),\n action._actionContext ? Effect.provide(action._actionContext) : Function.identity,\n ),\n );\n"],"mappings":";;;;;;;;;;;;;AAoBA,IAAa,YAAY,OACvB,SACA,mBACA,QACA,SAAmC,CAAC,MAEpC,SAAS,oBACP,OACG,KAAK,MAAM,CAAA,CACX,KACC,OAAO,eAAe,UAAU,SAAS,OAAO,GAChD,OAAO,eAAe,WAAW,SAAS,iBAAiB,GAC3D,OAAO,iBAAiB,OAAO,QAAQ,OAAO,cAAc,IAAI,SAAS,QAC3E,CACJ"}
|
package/dist/lib/chunk-graph.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import * as AppCapabilities from "@dxos/app-toolkit/AppCapabilities";
|
|
|
5
5
|
import * as Record from "effect/Record";
|
|
6
6
|
import * as AppGraph from "@dxos/app-graph/AppGraph";
|
|
7
7
|
import * as AppGraphBuilder from "@dxos/app-graph/AppGraphBuilder";
|
|
8
|
+
import * as AppNode from "@dxos/app-toolkit/AppNode";
|
|
8
9
|
import * as UrlPath from "@dxos/app-toolkit/UrlPath";
|
|
9
10
|
import * as GraphNode from "@dxos/graph/GraphNode";
|
|
10
11
|
//#region src/graph.ts
|
|
@@ -13,7 +14,11 @@ var graph_default = Capability.makeModule(Effect.fnUntraced(function* () {
|
|
|
13
14
|
const extensionsByModuleAtom = yield* Capability.atomByModule(AppCapabilities.AppGraphBuilder);
|
|
14
15
|
const builder = AppGraphBuilder.from(void 0, registry, {
|
|
15
16
|
anchorKey: UrlPath.WORKSPACE_KEY,
|
|
16
|
-
|
|
17
|
+
linked: {
|
|
18
|
+
key: UrlPath.COMPANION_KEY,
|
|
19
|
+
relation: AppNode.companion
|
|
20
|
+
},
|
|
21
|
+
tailSeparator: UrlPath.TAIL_SEPARATOR
|
|
17
22
|
});
|
|
18
23
|
const unsubscribe = registry.subscribe(extensionsByModuleAtom, (extensionsByModule) => {
|
|
19
24
|
const next = [];
|
|
@@ -24,10 +29,15 @@ var graph_default = Capability.makeModule(Effect.fnUntraced(function* () {
|
|
|
24
29
|
Record.values(registry.get(builder.extensions)).filter(({ id }) => !next.some(({ id: nextId }) => nextId === id)).forEach((extension) => AppGraphBuilder.removeExtension(builder, extension.id));
|
|
25
30
|
next.forEach((extension) => AppGraphBuilder.addExtension(builder, extension));
|
|
26
31
|
}, { immediate: true });
|
|
32
|
+
const retentionAtom = yield* Capability.atom(AppCapabilities.AppGraphRetention);
|
|
33
|
+
const unsubscribeRetention = registry.subscribe(retentionAtom, (retentions) => AppGraphBuilder.setRetention(builder, retentions), { immediate: true });
|
|
27
34
|
AppGraph.expandSync(builder.graph, GraphNode.RootId, "child");
|
|
28
35
|
setupDevtools(builder.graph);
|
|
29
36
|
yield* Effect.addFinalizer(() => Effect.sync(() => {
|
|
30
37
|
unsubscribe();
|
|
38
|
+
unsubscribeRetention();
|
|
39
|
+
AppGraphBuilder.setRetention(builder, []);
|
|
40
|
+
AppGraphBuilder.destroy(builder);
|
|
31
41
|
}));
|
|
32
42
|
return Capability.contribute(AppCapabilities.AppGraph, builder);
|
|
33
43
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunk-graph.mjs","names":[],"sources":["../../src/graph.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport * as Record from 'effect/Record';\n\nimport * as Capabilities from '@dxos/app-framework/Capabilities';\nimport * as Capability from '@dxos/app-framework/Capability';\nimport * as AppGraph from '@dxos/app-graph/AppGraph';\nimport * as AppGraphBuilder from '@dxos/app-graph/AppGraphBuilder';\nimport * as AppCapabilities from '@dxos/app-toolkit/AppCapabilities';\nimport * as UrlPath from '@dxos/app-toolkit/UrlPath';\nimport * as GraphNode from '@dxos/graph/GraphNode';\n\n// TODO(wittjosiah): Remove or restore graph caching.\n// import { meta } from './meta';\n\n// const KEY = `${meta.id}.app-graph`;\n\nexport default Capability.makeModule(\n Effect.fnUntraced(function* () {\n const registry = yield* Capabilities.AtomRegistry;\n\n // Live view: extensions contributed by dependency-mode modules (including those enabled\n // later in the session) reach this subscription reactively.\n const extensionsByModuleAtom = yield* Capability.atomByModule(AppCapabilities.AppGraphBuilder);\n\n // The grammar's fixed tiers, configured here rather than declared by an extension: no connector\n // produces their nodes (see `AppGraphBuilder.UrlGrammar`).\n const builder = AppGraphBuilder.from(/* localStorage.getItem(KEY) ?? */ undefined, registry, {\n anchorKey: UrlPath.WORKSPACE_KEY,\n
|
|
1
|
+
{"version":3,"file":"chunk-graph.mjs","names":[],"sources":["../../src/graph.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport * as Record from 'effect/Record';\n\nimport * as Capabilities from '@dxos/app-framework/Capabilities';\nimport * as Capability from '@dxos/app-framework/Capability';\nimport * as AppGraph from '@dxos/app-graph/AppGraph';\nimport * as AppGraphBuilder from '@dxos/app-graph/AppGraphBuilder';\nimport * as AppCapabilities from '@dxos/app-toolkit/AppCapabilities';\nimport * as AppNode from '@dxos/app-toolkit/AppNode';\nimport * as UrlPath from '@dxos/app-toolkit/UrlPath';\nimport * as GraphNode from '@dxos/graph/GraphNode';\n\n// TODO(wittjosiah): Remove or restore graph caching.\n// import { meta } from './meta.ts';\n\n// const KEY = `${meta.id}.app-graph`;\n\nexport default Capability.makeModule(\n Effect.fnUntraced(function* () {\n const registry = yield* Capabilities.AtomRegistry;\n\n // Live view: extensions contributed by dependency-mode modules (including those enabled\n // later in the session) reach this subscription reactively.\n const extensionsByModuleAtom = yield* Capability.atomByModule(AppCapabilities.AppGraphBuilder);\n\n // The grammar's fixed tiers, configured here rather than declared by an extension: no connector\n // produces their nodes (see `AppGraphBuilder.UrlGrammar`).\n const builder = AppGraphBuilder.from(/* localStorage.getItem(KEY) ?? */ undefined, registry, {\n anchorKey: UrlPath.WORKSPACE_KEY,\n linked: { key: UrlPath.COMPANION_KEY, relation: AppNode.companion },\n tailSeparator: UrlPath.TAIL_SEPARATOR,\n });\n // const interval = setInterval(() => {\n // localStorage.setItem(KEY, builder.graph.pickle());\n // }, 5_000);\n\n const unsubscribe = registry.subscribe(\n extensionsByModuleAtom,\n (extensionsByModule) => {\n const next: AppGraphBuilder.BuilderExtension[] = [];\n for (const [moduleId, extensions] of Object.entries(extensionsByModule)) {\n for (const ext of AppGraphBuilder.flattenExtensions(extensions)) {\n next.push({\n ...ext,\n id: `${moduleId}.${ext.id}`,\n });\n }\n }\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) => AppGraphBuilder.removeExtension(builder, extension.id));\n next.forEach((extension) => AppGraphBuilder.addExtension(builder, extension));\n },\n { immediate: true },\n );\n\n const retentionAtom = yield* Capability.atom(AppCapabilities.AppGraphRetention);\n const unsubscribeRetention = registry.subscribe(\n retentionAtom,\n (retentions) => AppGraphBuilder.setRetention(builder, retentions),\n { immediate: true },\n );\n\n // await builder.initialize();\n void AppGraph.expandSync(builder.graph, GraphNode.RootId, 'child');\n\n setupDevtools(builder.graph);\n\n yield* Effect.addFinalizer(() =>\n Effect.sync(() => {\n // clearInterval(interval);\n unsubscribe();\n unsubscribeRetention();\n AppGraphBuilder.setRetention(builder, []);\n AppGraphBuilder.destroy(builder);\n }),\n );\n return Capability.contribute(AppCapabilities.AppGraph, builder);\n }),\n);\n\n// Expose the graph to the window for debugging.\nconst setupDevtools = (graph: AppGraph.ExpandableGraph) => {\n (globalThis as any).composer ??= {};\n (globalThis as any).composer.graph = graph;\n};\n"],"mappings":";;;;;;;;;;;AAqBA,IAAA,gBAAe,WAAW,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AgB,UAAU,OAAO;AAChE,CAAC,CACH;AAGA,IAAM,iBAAiB,UAAoC;CACzD,WAAoB,aAAa,CAAC;CAClC,WAAoB,SAAS,QAAQ;AACvC"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
//#region \0rolldown/runtime.js
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
3
6
|
var __exportAll = (all, no_symbols) => {
|
|
4
7
|
let target = {};
|
|
5
8
|
for (var name in all) __defProp(target, name, {
|
|
@@ -9,5 +12,16 @@ var __exportAll = (all, no_symbols) => {
|
|
|
9
12
|
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
10
13
|
return target;
|
|
11
14
|
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
17
|
+
key = keys[i];
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
19
|
+
get: ((k) => from[k]).bind(null, key),
|
|
20
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
12
26
|
//#endregion
|
|
13
|
-
export { __exportAll as t };
|
|
27
|
+
export { __reExport as n, __exportAll as t };
|
package/dist/lib/hooks.mjs
CHANGED
|
@@ -1,19 +1,98 @@
|
|
|
1
1
|
import { t as runAction } from "./chunk-action.mjs";
|
|
2
2
|
import { useCallback, useMemo } from "react";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import * as Hooks$1 from "@dxos/app-framework/Hooks";
|
|
4
|
+
import * as PluginManagerProvider from "@dxos/app-framework/PluginManagerProvider";
|
|
5
5
|
import * as Option from "effect/Option";
|
|
6
|
+
import * as Atom from "effect/reactivity/Atom";
|
|
7
|
+
import * as AppGraphNode from "@dxos/app-graph/AppGraphNode";
|
|
8
|
+
import * as Hooks from "@dxos/app-toolkit/Hooks";
|
|
9
|
+
import { Path } from "@dxos/react-ui-list";
|
|
10
|
+
import { mx } from "@dxos/ui-theme";
|
|
11
|
+
import { useAtomValue } from "@effect/atom-react/Hooks";
|
|
6
12
|
//#region src/hooks/useActionRunner.ts
|
|
7
13
|
/**
|
|
8
14
|
* Hook that returns a function to run action Effects.
|
|
9
15
|
* Provides Operation.Service, PluginContextService, and captured plugin context.
|
|
10
16
|
*/
|
|
11
17
|
var useActionRunner = () => {
|
|
12
|
-
const invoker = useOperationInvoker();
|
|
13
|
-
const pluginManager = usePluginManager();
|
|
18
|
+
const invoker = Hooks$1.useOperationInvoker();
|
|
19
|
+
const pluginManager = PluginManagerProvider.usePluginManager();
|
|
14
20
|
return useCallback((action, params = {}) => runAction(invoker, pluginManager.capabilities, action, params), [invoker, pluginManager.capabilities]);
|
|
15
21
|
};
|
|
16
22
|
//#endregion
|
|
23
|
+
//#region src/hooks/useGraphTreeModel.ts
|
|
24
|
+
/** Rows the tree lists: not hidden, and either a plain node or an action the graph marks as an item. */
|
|
25
|
+
var isItem = (node) => !AppGraphNode.hasDisposition(node, "hidden") && (!AppGraphNode.isAction(node) || AppGraphNode.hasDisposition(node, "item"));
|
|
26
|
+
/**
|
|
27
|
+
* A `TreeModel` over the app graph: topology and row props come from the graph, open/current state
|
|
28
|
+
* from the caller, so one mapping serves the navtree (persisted state) and any other tree host.
|
|
29
|
+
*/
|
|
30
|
+
var createGraphTreeModel = (graph, rootId, { itemOpen, itemCurrent }) => {
|
|
31
|
+
const isVisibleChild = (node) => !AppGraphNode.hasDisposition(node, "hidden");
|
|
32
|
+
const itemPropsFamily = Atom.family((pathKey) => {
|
|
33
|
+
const path = Path.parts(pathKey);
|
|
34
|
+
const id = Path.last(pathKey);
|
|
35
|
+
return Atom.make((get) => {
|
|
36
|
+
const node = Option.getOrUndefined(get(graph.node(id)));
|
|
37
|
+
if (!node) return {
|
|
38
|
+
id,
|
|
39
|
+
label: id
|
|
40
|
+
};
|
|
41
|
+
const visibleChildren = get(graph.connections(node.id, "child")).filter((child) => !path.includes(child.id)).filter(isVisibleChild);
|
|
42
|
+
const parentOf = visibleChildren.length > 0 ? visibleChildren.map((child) => child.id) : node.properties.role === "branch" ? [] : void 0;
|
|
43
|
+
const parentId = path.length >= 2 ? path[path.length - 2] : void 0;
|
|
44
|
+
const parentNode = parentId ? Option.getOrUndefined(get(graph.node(parentId))) : void 0;
|
|
45
|
+
const droppable = node.properties.droppable === false || parentNode?.properties.childrenDroppable === false ? false : void 0;
|
|
46
|
+
const disposition = node.properties.disposition;
|
|
47
|
+
const isGroup = disposition === "group";
|
|
48
|
+
return {
|
|
49
|
+
id: node.id,
|
|
50
|
+
parentOf: isGroup ? void 0 : parentOf,
|
|
51
|
+
disposition,
|
|
52
|
+
disabled: isGroup || node.properties.disabled,
|
|
53
|
+
draggable: isGroup ? false : node.properties.draggable,
|
|
54
|
+
droppable: isGroup ? false : droppable,
|
|
55
|
+
label: node.properties.label ?? node.id,
|
|
56
|
+
className: mx(node.properties.className, node.properties.modified && "italic"),
|
|
57
|
+
headingClassName: node.properties.headingClassName,
|
|
58
|
+
icon: node.properties.icon,
|
|
59
|
+
iconHue: node.properties.iconHue,
|
|
60
|
+
testId: node.properties.testId,
|
|
61
|
+
count: node.properties.count,
|
|
62
|
+
modifiedCount: node.properties.modifiedCount
|
|
63
|
+
};
|
|
64
|
+
}).pipe(Atom.keepAlive);
|
|
65
|
+
});
|
|
66
|
+
const childIdsFamily = Atom.family((id) => Atom.make((get) => get(graph.connections(id, "child")).filter(isVisibleChild).map((child) => child.id)).pipe(Atom.keepAlive));
|
|
67
|
+
const itemFamily = Atom.family((id) => Atom.make((get) => {
|
|
68
|
+
const node = Option.getOrUndefined(get(graph.node(id)));
|
|
69
|
+
return node && isItem(node) ? node : void 0;
|
|
70
|
+
}).pipe(Atom.keepAlive));
|
|
71
|
+
const itemOpenFamily = Atom.family((pathKey) => itemOpen(Path.parts(pathKey)));
|
|
72
|
+
const itemCurrentFamily = Atom.family((pathKey) => itemCurrent(Path.parts(pathKey)));
|
|
73
|
+
return {
|
|
74
|
+
item: (id) => itemFamily(id),
|
|
75
|
+
itemProps: (path) => itemPropsFamily(Path.create(...path)),
|
|
76
|
+
itemOpen: (path) => itemOpenFamily(Path.create(...path)),
|
|
77
|
+
itemCurrent: (path) => itemCurrentFamily(Path.create(...path)),
|
|
78
|
+
childIds: (parentId) => childIdsFamily(parentId ?? rootId)
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
/** {@link createGraphTreeModel} over the app graph capability, memoised on its inputs. */
|
|
82
|
+
var useGraphTreeModel = (rootId, options) => {
|
|
83
|
+
const { graph } = Hooks.useAppGraph();
|
|
84
|
+
const { itemOpen, itemCurrent } = options;
|
|
85
|
+
return useMemo(() => createGraphTreeModel(graph, rootId, {
|
|
86
|
+
itemOpen,
|
|
87
|
+
itemCurrent
|
|
88
|
+
}), [
|
|
89
|
+
graph,
|
|
90
|
+
rootId,
|
|
91
|
+
itemOpen,
|
|
92
|
+
itemCurrent
|
|
93
|
+
]);
|
|
94
|
+
};
|
|
95
|
+
//#endregion
|
|
17
96
|
//#region src/hooks/useNode.ts
|
|
18
97
|
/**
|
|
19
98
|
* React hook to get a node from the graph.
|
|
@@ -53,6 +132,6 @@ var useEdges = (graph, id) => {
|
|
|
53
132
|
return useAtomValue(atom);
|
|
54
133
|
};
|
|
55
134
|
//#endregion
|
|
56
|
-
export { useActionRunner, useActions, useConnections, useEdges, useNode };
|
|
135
|
+
export { createGraphTreeModel, useActionRunner, useActions, useConnections, useEdges, useGraphTreeModel, useNode };
|
|
57
136
|
|
|
58
137
|
//# sourceMappingURL=hooks.mjs.map
|
package/dist/lib/hooks.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.mjs","names":[],"sources":["../../src/hooks/useActionRunner.ts","../../src/hooks/useNode.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport { useCallback } from 'react';\n\nimport { useOperationInvoker, usePluginManager } from '@dxos/app-framework/ui';\nimport type * as AppGraphNode from '@dxos/app-graph/AppGraphNode';\n\nimport { runAction } from '../action';\n\n/**\n * Hook that returns a function to run action Effects.\n * Provides Operation.Service, PluginContextService, and captured plugin context.\n */\nexport const useActionRunner = () => {\n const invoker = useOperationInvoker();\n const pluginManager = usePluginManager();\n\n return useCallback(\n (action: AppGraphNode.Action, params: AppGraphNode.InvokeProps = {}) =>\n runAction(invoker, pluginManager.capabilities, action, params),\n [invoker, pluginManager.capabilities],\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport { useAtomValue } from '@effect/atom-react/Hooks';\nimport * as Option from 'effect/Option';\nimport { useMemo } from 'react';\n\nimport type * as AppGraph from '@dxos/app-graph/AppGraph';\nimport type * as AppGraphNode from '@dxos/app-graph/AppGraphNode';\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: AppGraph.ReadableGraph, id?: string): AppGraphNode.Node<T> | undefined => {\n const atom = useMemo(() => graph.node(id ?? ''), [graph, id]);\n return Option.getOrElse(useAtomValue(atom), () => undefined);\n};\n\nexport const useConnections = (\n graph: AppGraph.ReadableGraph,\n id: string | undefined,\n relation: AppGraphNode.RelationInput,\n): AppGraphNode.Node[] => {\n return useAtomValue(graph.connections(id ?? '', relation));\n};\n\n/**\n * React hook to get actions available for a node.\n *\n * @param graph Graph containing the node.\n * @param id Id of the node.\n * @returns Actions available for the node.\n */\nexport const useActions = (graph: AppGraph.ReadableGraph, id?: string): AppGraphNode.Node[] => {\n const atom = useMemo(() => graph.actions(id ?? ''), [graph, id]);\n return useAtomValue(atom);\n};\n\n/**\n * Subscribe to just the edge topology (inbound/outbound IDs) of a node without subscribing to node content.\n *\n * @param graph Graph containing the node.\n * @param id Id of the node.\n * @returns Edge topology for the node.\n */\nexport const useEdges = (graph: AppGraph.ReadableGraph, id?: string): AppGraph.Edges => {\n const atom = useMemo(() => graph.edges(id ?? ''), [graph, id]);\n return useAtomValue(atom);\n};\n"],"mappings":";;;;;;;;;;AAeA,IAAa,wBAAwB;CACnC,MAAM,UAAU,oBAAoB;CACpC,MAAM,gBAAgB,iBAAiB;CAEvC,OAAO,aACJ,QAA6B,SAAmC,CAAC,MAChE,UAAU,SAAS,cAAc,cAAc,QAAQ,MAAM,GAC/D,CAAC,SAAS,cAAc,YAAY,CACtC;AACF;;;;;;;;;;;ACJA,IAAa,WAAoB,OAA+B,OAAkD;CAChH,MAAM,OAAO,cAAc,MAAM,KAAK,MAAM,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC;CAC5D,OAAO,OAAO,UAAU,aAAa,IAAI,SAAS,KAAA,CAAS;AAC7D;AAEA,IAAa,kBACX,OACA,IACA,aACwB;CACxB,OAAO,aAAa,MAAM,YAAY,MAAM,IAAI,QAAQ,CAAC;AAC3D;;;;;;;;AASA,IAAa,cAAc,OAA+B,OAAqC;CAC7F,MAAM,OAAO,cAAc,MAAM,QAAQ,MAAM,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC;CAC/D,OAAO,aAAa,IAAI;AAC1B;;;;;;;;AASA,IAAa,YAAY,OAA+B,OAAgC;CACtF,MAAM,OAAO,cAAc,MAAM,MAAM,MAAM,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC;CAC7D,OAAO,aAAa,IAAI;AAC1B"}
|
|
1
|
+
{"version":3,"file":"hooks.mjs","names":[],"sources":["../../src/hooks/useActionRunner.ts","../../src/hooks/useGraphTreeModel.ts","../../src/hooks/useNode.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport { useCallback } from 'react';\n\nimport * as Hooks from '@dxos/app-framework/Hooks';\nimport * as PluginManagerProvider from '@dxos/app-framework/PluginManagerProvider';\nimport type * as AppGraphNode from '@dxos/app-graph/AppGraphNode';\n\nimport { runAction } from '../action.ts';\n\n/**\n * Hook that returns a function to run action Effects.\n * Provides Operation.Service, PluginContextService, and captured plugin context.\n */\nexport const useActionRunner = () => {\n const invoker = Hooks.useOperationInvoker();\n const pluginManager = PluginManagerProvider.usePluginManager();\n\n return useCallback(\n (action: AppGraphNode.Action, params: AppGraphNode.InvokeProps = {}) =>\n runAction(invoker, pluginManager.capabilities, action, params),\n [invoker, pluginManager.capabilities],\n );\n};\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Option from 'effect/Option';\nimport * as Atom from 'effect/reactivity/Atom';\nimport { useMemo } from 'react';\n\nimport type * as AppGraph from '@dxos/app-graph/AppGraph';\nimport * as AppGraphNode from '@dxos/app-graph/AppGraphNode';\nimport * as Hooks from '@dxos/app-toolkit/Hooks';\nimport { Path, type TreeModel } from '@dxos/react-ui-list';\nimport { mx } from '@dxos/ui-theme';\n\nexport type GraphTreeState = {\n /** Open state keyed by the joined path (`Path.create`). */\n itemOpen: (path: string[]) => Atom.Atom<boolean>;\n /** Selected state keyed by the joined path. */\n itemCurrent: (path: string[]) => Atom.Atom<boolean>;\n};\n\n/** Rows the tree lists: not hidden, and either a plain node or an action the graph marks as an item. */\nconst isItem = (node: AppGraphNode.Node): boolean =>\n !AppGraphNode.hasDisposition(node, 'hidden') &&\n (!AppGraphNode.isAction(node) || AppGraphNode.hasDisposition(node, 'item'));\n\n/**\n * A `TreeModel` over the app graph: topology and row props come from the graph, open/current state\n * from the caller, so one mapping serves the navtree (persisted state) and any other tree host.\n */\nexport const createGraphTreeModel = (\n graph: AppGraph.ReadableGraph,\n rootId: string,\n { itemOpen, itemCurrent }: GraphTreeState,\n): TreeModel<AppGraphNode.Node> => {\n const isVisibleChild = (node: AppGraphNode.Node) => !AppGraphNode.hasDisposition(node, 'hidden');\n\n const itemPropsFamily = Atom.family((pathKey: string) => {\n const path = Path.parts(pathKey);\n const id = Path.last(pathKey);\n return Atom.make((get) => {\n const node = Option.getOrUndefined(get(graph.node(id)));\n if (!node) {\n return { id, label: id };\n }\n const safeChildren = get(graph.connections(node.id, 'child')).filter((child) => !path.includes(child.id));\n const visibleChildren = safeChildren.filter(isVisibleChild);\n const parentOf =\n visibleChildren.length > 0\n ? visibleChildren.map((child) => child.id)\n : node.properties.role === 'branch'\n ? []\n : undefined;\n const parentId = path.length >= 2 ? path[path.length - 2] : undefined;\n const parentNode = parentId ? Option.getOrUndefined(get(graph.node(parentId))) : undefined;\n const droppable =\n node.properties.droppable === false || parentNode?.properties.childrenDroppable === false ? false : undefined;\n const disposition = node.properties.disposition as string | undefined;\n const isGroup = disposition === 'group';\n return {\n id: node.id,\n parentOf: isGroup ? undefined : parentOf,\n disposition,\n disabled: isGroup || node.properties.disabled,\n draggable: isGroup ? false : node.properties.draggable,\n droppable: isGroup ? false : droppable,\n label: node.properties.label ?? node.id,\n className: mx(node.properties.className, node.properties.modified && 'italic'),\n headingClassName: node.properties.headingClassName,\n icon: node.properties.icon,\n iconHue: node.properties.iconHue,\n testId: node.properties.testId,\n count: node.properties.count,\n modifiedCount: node.properties.modifiedCount,\n };\n }).pipe(Atom.keepAlive);\n });\n\n const childIdsFamily = Atom.family((id: string) =>\n Atom.make((get) =>\n get(graph.connections(id, 'child'))\n .filter(isVisibleChild)\n .map((child) => child.id),\n ).pipe(Atom.keepAlive),\n );\n\n const itemFamily = Atom.family((id: string) =>\n Atom.make((get) => {\n const node = Option.getOrUndefined(get(graph.node(id)));\n return node && isItem(node) ? node : undefined;\n }).pipe(Atom.keepAlive),\n );\n\n const itemOpenFamily = Atom.family((pathKey: string) => itemOpen(Path.parts(pathKey)));\n const itemCurrentFamily = Atom.family((pathKey: string) => itemCurrent(Path.parts(pathKey)));\n\n return {\n item: (id) => itemFamily(id),\n itemProps: (path) => itemPropsFamily(Path.create(...path)),\n itemOpen: (path) => itemOpenFamily(Path.create(...path)),\n itemCurrent: (path) => itemCurrentFamily(Path.create(...path)),\n childIds: (parentId) => childIdsFamily(parentId ?? rootId),\n };\n};\n\n/** {@link createGraphTreeModel} over the app graph capability, memoised on its inputs. */\nexport const useGraphTreeModel = (rootId: string, options: GraphTreeState): TreeModel<AppGraphNode.Node> => {\n const { graph } = Hooks.useAppGraph();\n const { itemOpen, itemCurrent } = options;\n return useMemo(\n () => createGraphTreeModel(graph, rootId, { itemOpen, itemCurrent }),\n [graph, rootId, itemOpen, itemCurrent],\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport { useAtomValue } from '@effect/atom-react/Hooks';\nimport * as Option from 'effect/Option';\nimport { useMemo } from 'react';\n\nimport type * as AppGraph from '@dxos/app-graph/AppGraph';\nimport type * as AppGraphNode from '@dxos/app-graph/AppGraphNode';\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: AppGraph.ReadableGraph, id?: string): AppGraphNode.Node<T> | undefined => {\n const atom = useMemo(() => graph.node(id ?? ''), [graph, id]);\n return Option.getOrElse(useAtomValue(atom), () => undefined);\n};\n\nexport const useConnections = (\n graph: AppGraph.ReadableGraph,\n id: string | undefined,\n relation: AppGraphNode.RelationInput,\n): AppGraphNode.Node[] => {\n return useAtomValue(graph.connections(id ?? '', relation));\n};\n\n/**\n * React hook to get actions available for a node.\n *\n * @param graph Graph containing the node.\n * @param id Id of the node.\n * @returns Actions available for the node.\n */\nexport const useActions = (graph: AppGraph.ReadableGraph, id?: string): AppGraphNode.Node[] => {\n const atom = useMemo(() => graph.actions(id ?? ''), [graph, id]);\n return useAtomValue(atom);\n};\n\n/**\n * Subscribe to just the edge topology (inbound/outbound IDs) of a node without subscribing to node content.\n *\n * @param graph Graph containing the node.\n * @param id Id of the node.\n * @returns Edge topology for the node.\n */\nexport const useEdges = (graph: AppGraph.ReadableGraph, id?: string): AppGraph.Edges => {\n const atom = useMemo(() => graph.edges(id ?? ''), [graph, id]);\n return useAtomValue(atom);\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,IAAa,wBAAwB;CACnC,MAAM,UAAU,QAAM,oBAAoB;CAC1C,MAAM,gBAAgB,sBAAsB,iBAAiB;CAE7D,OAAO,aACJ,QAA6B,SAAmC,CAAC,MAChE,UAAU,SAAS,cAAc,cAAc,QAAQ,MAAM,GAC/D,CAAC,SAAS,cAAc,YAAY,CACtC;AACF;;;;ACHA,IAAM,UAAU,SACd,CAAC,aAAa,eAAe,MAAM,QAAQ,MAC1C,CAAC,aAAa,SAAS,IAAI,KAAK,aAAa,eAAe,MAAM,MAAM;;;;;AAM3E,IAAa,wBACX,OACA,QACA,EAAE,UAAU,kBACqB;CACjC,MAAM,kBAAkB,SAA4B,CAAC,aAAa,eAAe,MAAM,QAAQ;CAE/F,MAAM,kBAAkB,KAAK,QAAQ,YAAoB;EACvD,MAAM,OAAO,KAAK,MAAM,OAAO;EAC/B,MAAM,KAAK,KAAK,KAAK,OAAO;EAC5B,OAAO,KAAK,MAAM,QAAQ;GACxB,MAAM,OAAO,OAAO,eAAe,IAAI,MAAM,KAAK,EAAE,CAAC,CAAC;GACtD,IAAI,CAAC,MACH,OAAO;IAAE;IAAI,OAAO;GAAG;GAGzB,MAAM,kBADe,IAAI,MAAM,YAAY,KAAK,IAAI,OAAO,CAAC,CAAC,CAAC,QAAQ,UAAU,CAAC,KAAK,SAAS,MAAM,EAAE,CAC/E,CAAA,CAAa,OAAO,cAAc;GAC1D,MAAM,WACJ,gBAA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,aAAa,IAAI;AAC1B"}
|
package/dist/lib/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
+
import { t as GraphAction_exports } from "./ns/GraphAction.mjs";
|
|
2
|
+
import { t as Hooks_exports } from "./ns/Hooks.mjs";
|
|
1
3
|
import { t as GraphPlugin_exports } from "./GraphPlugin.mjs";
|
|
2
|
-
|
|
3
|
-
export * from "#meta";
|
|
4
|
-
export { GraphPlugin_exports as GraphPlugin, runAction };
|
|
4
|
+
export { GraphAction_exports as GraphAction, GraphPlugin_exports as GraphPlugin, Hooks_exports as Hooks };
|
package/dist/lib/meta.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta.mjs","names":[],"sources":["../../dx.config.ts","../../src/meta.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Config2 } from '@dxos/app-framework/config';\nimport { trim } from '@dxos/util';\n\nexport default Config2.make({\n plugin: {\n key: 'org.dxos.plugin.graph',\n name: 'Graph',\n author: 'DXOS',\n description: trim`\n Graph database layer providing relationship modeling and queries for workspace objects.\n Build knowledge graphs and explore complex data relationships.\n `,\n tags: ['system'],\n },\n});\n","//\n// Copyright 2023 DXOS.org\n//\n\nimport * as Plugin from '@dxos/app-framework/Plugin';\n\nimport config from '../dx.config';\n\nexport const meta = Plugin.getMetaFromConfig(config);\n"],"mappings":";;;;AAOA,IAAA,oBAAe,QAAQ,KAAK,EAC1B,QAAQ;CACN,KAAK;CACL,MAAM;CACN,QAAQ;CACR,aAAa,IAAI;;;;CAIjB,MAAM,CAAC,QAAQ;AACjB,EACF,CAAC;;;ACVD,IAAa,OAAO,OAAO,kBAAkB,iBAAM"}
|
|
1
|
+
{"version":3,"file":"meta.mjs","names":[],"sources":["../../dx.config.ts","../../src/meta.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Config2 } from '@dxos/app-framework/config';\nimport { trim } from '@dxos/util';\n\nexport default Config2.make({\n plugin: {\n key: 'org.dxos.plugin.graph',\n name: 'Graph',\n author: 'DXOS',\n description: trim`\n Graph database layer providing relationship modeling and queries for workspace objects.\n Build knowledge graphs and explore complex data relationships.\n `,\n tags: ['system'],\n },\n});\n","//\n// Copyright 2023 DXOS.org\n//\n\nimport * as Plugin from '@dxos/app-framework/Plugin';\n\nimport config from '../dx.config.ts';\n\nexport const meta = Plugin.getMetaFromConfig(config);\n"],"mappings":";;;;AAOA,IAAA,oBAAe,QAAQ,KAAK,EAC1B,QAAQ;CACN,KAAK;CACL,MAAM;CACN,QAAQ;CACR,aAAa,IAAI;;;;CAIjB,MAAM,CAAC,QAAQ;AACjB,EACF,CAAC;;;ACVD,IAAa,OAAO,OAAO,kBAAkB,iBAAM"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { t as __exportAll } from "../chunk-rolldown-runtime.mjs";
|
|
2
|
+
import { t as runAction } from "../chunk-action.mjs";
|
|
3
|
+
//#region src/GraphAction.ts
|
|
4
|
+
var GraphAction_exports = /* @__PURE__ */ __exportAll({ run: () => runAction });
|
|
5
|
+
//#endregion
|
|
6
|
+
export { runAction as run, GraphAction_exports as t };
|
|
7
|
+
|
|
8
|
+
//# sourceMappingURL=GraphAction.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GraphAction.mjs","names":[],"sources":["../../../src/GraphAction.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nexport { runAction as run } from './action.ts';\n"],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { n as __reExport, t as __exportAll } from "../chunk-rolldown-runtime.mjs";
|
|
2
|
+
export * from "#hooks";
|
|
3
|
+
//#region src/Hooks.ts
|
|
4
|
+
var Hooks_exports = /* @__PURE__ */ __exportAll({});
|
|
5
|
+
import * as import__hooks from "#hooks";
|
|
6
|
+
__reExport(Hooks_exports, import__hooks);
|
|
7
|
+
//#endregion
|
|
8
|
+
export { Hooks_exports as t };
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=Hooks.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Hooks.mjs","names":[],"sources":["../../../src/Hooks.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nexport * from '#hooks';\n"],"mappings":""}
|
package/dist/lib/plugin.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import * as Capability from "@dxos/app-framework/Capability";
|
|
1
2
|
import * as Plugin from "@dxos/app-framework/Plugin";
|
|
2
3
|
import { meta } from "#meta";
|
|
3
|
-
import * as Capability from "@dxos/app-framework/Capability";
|
|
4
4
|
import * as Capabilities from "@dxos/app-framework/Capabilities";
|
|
5
5
|
import * as AppCapabilities from "@dxos/app-toolkit/AppCapabilities";
|
|
6
6
|
//#region src/plugin.ts
|
package/dist/lib/plugin.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.mjs","names":[],"sources":["../../src/plugin.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Capabilities from '@dxos/app-framework/Capabilities';\nimport * as Capability from '@dxos/app-framework/Capability';\nimport * as Plugin from '@dxos/app-framework/Plugin';\nimport * as AppCapabilities from '@dxos/app-toolkit/AppCapabilities';\n\nimport { meta } from '#meta';\n\nconst Graph = Capability.lazyModule(\n 'Graph',\n { requires: [Capabilities.AtomRegistry], provides: [AppCapabilities.AppGraph] },\n () => import('./graph'),\n);\n\n/**\n * Manages the state of the graph for the application.\n * Enables other plugins to register node builders to add nodes to the graph.\n * This includes actions and annotation each other's nodes.\n */\nexport const GraphPlugin = Plugin.define(meta).pipe(Plugin.addModule(Graph), Plugin.make);\n\nexport default GraphPlugin;\n"],"mappings":";;;;;;AAWA,IAAM,QAAQ,WAAW,WACvB,SACA;CAAE,UAAU,CAAC,aAAa,YAAY;CAAG,UAAU,CAAC,gBAAgB,QAAQ;AAAE,SACxE,OAAO,oBACf;;;;;;AAOA,IAAa,cAAc,OAAO,OAAO,IAAI,CAAC,CAAC,KAAK,OAAO,UAAU,KAAK,GAAG,OAAO,IAAI"}
|
|
1
|
+
{"version":3,"file":"plugin.mjs","names":[],"sources":["../../src/plugin.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Capabilities from '@dxos/app-framework/Capabilities';\nimport * as Capability from '@dxos/app-framework/Capability';\nimport * as Plugin from '@dxos/app-framework/Plugin';\nimport * as AppCapabilities from '@dxos/app-toolkit/AppCapabilities';\n\nimport { meta } from '#meta';\n\nconst Graph = Capability.lazyModule(\n 'Graph',\n { requires: [Capabilities.AtomRegistry], provides: [AppCapabilities.AppGraph] },\n () => import('./graph.ts'),\n);\n\n/**\n * Manages the state of the graph for the application.\n * Enables other plugins to register node builders to add nodes to the graph.\n * This includes actions and annotation each other's nodes.\n */\nexport const GraphPlugin = Plugin.define(meta).pipe(Plugin.addModule(Graph), Plugin.make);\n\nexport default GraphPlugin;\n"],"mappings":";;;;;;AAWA,IAAM,QAAQ,WAAW,WACvB,SACA;CAAE,UAAU,CAAC,aAAa,YAAY;CAAG,UAAU,CAAC,gBAAgB,QAAQ;AAAE,SACxE,OAAO,oBACf;;;;;;AAOA,IAAa,cAAc,OAAO,OAAO,IAAI,CAAC,CAAC,KAAK,OAAO,UAAU,KAAK,GAAG,OAAO,IAAI"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GraphAction.d.ts","sourceRoot":"","sources":["../../../src/GraphAction.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,IAAI,GAAG,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Hooks.d.ts","sourceRoot":"","sources":["../../../src/Hooks.ts"],"names":[],"mappings":"AAMA,cAAc,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph-tree-model.test.d.ts","sourceRoot":"","sources":["../../../../src/hooks/graph-tree-model.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/index.ts"],"names":[],"mappings":"AAOA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/index.ts"],"names":[],"mappings":"AAOA,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useActionRunner.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useActionRunner.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useActionRunner.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useActionRunner.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,KAAK,YAAY,MAAM,8BAA8B,CAAC;AAIlE;;;GAGG;AACH,eAAO,MAAM,eAAe,iBAKf,YAAY,CAAC,MAAM,WAAU,YAAY,CAAC,WAAW,kBAIjE,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as Atom from 'effect/reactivity/Atom';
|
|
2
|
+
import type * as AppGraph from '@dxos/app-graph/AppGraph';
|
|
3
|
+
import * as AppGraphNode from '@dxos/app-graph/AppGraphNode';
|
|
4
|
+
import { type TreeModel } from '@dxos/react-ui-list';
|
|
5
|
+
export type GraphTreeState = {
|
|
6
|
+
/** Open state keyed by the joined path (`Path.create`). */
|
|
7
|
+
itemOpen: (path: string[]) => Atom.Atom<boolean>;
|
|
8
|
+
/** Selected state keyed by the joined path. */
|
|
9
|
+
itemCurrent: (path: string[]) => Atom.Atom<boolean>;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* A `TreeModel` over the app graph: topology and row props come from the graph, open/current state
|
|
13
|
+
* from the caller, so one mapping serves the navtree (persisted state) and any other tree host.
|
|
14
|
+
*/
|
|
15
|
+
export declare const createGraphTreeModel: (graph: AppGraph.ReadableGraph, rootId: string, { itemOpen, itemCurrent }: GraphTreeState) => TreeModel<AppGraphNode.Node>;
|
|
16
|
+
/** {@link createGraphTreeModel} over the app graph capability, memoised on its inputs. */
|
|
17
|
+
export declare const useGraphTreeModel: (rootId: string, options: GraphTreeState) => TreeModel<AppGraphNode.Node>;
|
|
18
|
+
//# sourceMappingURL=useGraphTreeModel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGraphTreeModel.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useGraphTreeModel.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAG/C,OAAO,KAAK,KAAK,QAAQ,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,YAAY,MAAM,8BAA8B,CAAC;AAE7D,OAAO,EAAQ,KAAK,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAG3D,MAAM,MAAM,cAAc,GAAG;IAC3B,2DAA2D;IAC3D,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACjD,+CAA+C;IAC/C,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;CACrD,CAAC;AAOF;;;GAGG;AACH,eAAO,MAAM,oBAAoB,UACxB,QAAQ,CAAC,aAAa,UACrB,MAAM,6BACa,cAAc,KACxC,SAAS,CAAC,YAAY,CAAC,IAAI,CAqE7B,CAAC;AAEF,0FAA0F;AAC1F,eAAO,MAAM,iBAAiB,WAAY,MAAM,WAAW,cAAc,KAAG,SAAS,CAAC,YAAY,CAAC,IAAI,CAOtG,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * as
|
|
2
|
-
export * from './
|
|
3
|
-
export * from '
|
|
1
|
+
export * as GraphAction from './GraphAction.ts';
|
|
2
|
+
export * as GraphPlugin from './GraphPlugin.ts';
|
|
3
|
+
export * as Hooks from './Hooks.ts';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,WAAW,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * as GraphPlugin from './GraphPlugin.testing';
|
|
1
|
+
export * as GraphPlugin from './GraphPlugin.testing.ts';
|
|
2
2
|
//# sourceMappingURL=testing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../../src/testing.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,WAAW,MAAM,
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../../src/testing.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,WAAW,MAAM,0BAA0B,CAAC"}
|