@dxos/plugin-explorer 0.8.4-main.c4373fc → 0.8.4-main.c85a9c8dae
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/ExplorerContainer-4RB2TY3G.mjs +48 -0
- package/dist/lib/browser/ExplorerContainer-4RB2TY3G.mjs.map +7 -0
- package/dist/lib/browser/chunk-4NFGHCGO.mjs +84 -0
- package/dist/lib/browser/chunk-4NFGHCGO.mjs.map +7 -0
- package/dist/lib/browser/{chunk-UCDNCIRV.mjs → chunk-6AZY4CDH.mjs} +343 -406
- package/dist/lib/{node-esm/chunk-WHKUQG5M.mjs.map → browser/chunk-6AZY4CDH.mjs.map} +4 -4
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/browser/{chunk-2DGFNLRO.mjs → chunk-YNQF4CPY.mjs} +7 -2
- package/dist/lib/browser/chunk-YNQF4CPY.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +51 -68
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/meta.mjs +2 -1
- package/dist/lib/browser/react-surface-KAHVDMFX.mjs +38 -0
- package/dist/lib/browser/react-surface-KAHVDMFX.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +6 -6
- package/dist/lib/node-esm/ExplorerContainer-LCG425I7.mjs +49 -0
- package/dist/lib/node-esm/ExplorerContainer-LCG425I7.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-PX6LHR2N.mjs → chunk-DK77RB6M.mjs} +7 -2
- package/dist/lib/node-esm/chunk-DK77RB6M.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-WHKUQG5M.mjs → chunk-DOXAIJEC.mjs} +343 -406
- package/dist/lib/{browser/chunk-UCDNCIRV.mjs.map → node-esm/chunk-DOXAIJEC.mjs.map} +4 -4
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-V42OFY7B.mjs +85 -0
- package/dist/lib/node-esm/chunk-V42OFY7B.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +51 -68
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/meta.mjs +2 -1
- package/dist/lib/node-esm/react-surface-7XILIUI4.mjs +39 -0
- package/dist/lib/node-esm/react-surface-7XILIUI4.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +6 -6
- package/dist/types/src/ExplorerPlugin.d.ts +2 -1
- package/dist/types/src/ExplorerPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +1 -2
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- package/dist/types/src/components/Graph/D3ForceGraph.d.ts +3 -3
- package/dist/types/src/components/Graph/D3ForceGraph.d.ts.map +1 -1
- package/dist/types/src/components/Graph/D3ForceGraph.stories.d.ts +1 -1
- package/dist/types/src/components/Graph/D3ForceGraph.stories.d.ts.map +1 -1
- package/dist/types/src/components/Graph/ForceGraph.stories.d.ts.map +1 -1
- package/dist/types/src/components/Graph/adapter.d.ts +1 -1
- package/dist/types/src/components/Graph/adapter.d.ts.map +1 -1
- package/dist/types/src/components/Graph/testing.d.ts.map +1 -1
- package/dist/types/src/components/Tree/Tree.d.ts.map +1 -1
- package/dist/types/src/components/Tree/Tree.stories.d.ts.map +1 -1
- package/dist/types/src/components/Tree/testing/generator.d.ts.map +1 -1
- package/dist/types/src/components/Tree/types/tree.d.ts +18 -16
- package/dist/types/src/components/Tree/types/tree.d.ts.map +1 -1
- package/dist/types/src/components/Tree/types/types.d.ts +1 -1
- package/dist/types/src/components/Tree/types/types.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +0 -4
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/ExplorerContainer/ExplorerContainer.d.ts +6 -0
- package/dist/types/src/containers/ExplorerContainer/ExplorerContainer.d.ts.map +1 -0
- package/dist/types/src/containers/ExplorerContainer/index.d.ts +3 -0
- package/dist/types/src/containers/ExplorerContainer/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +3 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/hooks/useGraphModel.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +17 -10
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/ExplorerAction.d.ts +6 -0
- package/dist/types/src/types/ExplorerAction.d.ts.map +1 -0
- package/dist/types/src/types/Graph.d.ts +30 -0
- package/dist/types/src/types/Graph.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +2 -2
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +51 -45
- package/src/ExplorerPlugin.tsx +29 -50
- package/src/capabilities/index.ts +1 -4
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +31 -0
- package/src/components/Chart/Chart.stories.tsx +3 -3
- package/src/components/Globe/Globe.stories.tsx +3 -3
- package/src/components/Graph/D3ForceGraph.stories.tsx +30 -14
- package/src/components/Graph/D3ForceGraph.tsx +8 -7
- package/src/components/Graph/ForceGraph.stories.tsx +30 -14
- package/src/components/Graph/adapter.ts +14 -8
- package/src/components/Graph/testing.ts +11 -8
- package/src/components/Tree/Tree.stories.tsx +4 -3
- package/src/components/Tree/Tree.tsx +8 -3
- package/src/components/Tree/testing/generator.ts +4 -2
- package/src/components/Tree/types/tree.test.ts +5 -3
- package/src/components/Tree/types/tree.ts +40 -19
- package/src/components/Tree/types/types.ts +1 -1
- package/src/components/index.ts +0 -4
- package/src/containers/ExplorerContainer/ExplorerContainer.tsx +53 -0
- package/src/containers/ExplorerContainer/index.ts +7 -0
- package/src/containers/index.ts +7 -0
- package/src/hooks/useGraphModel.ts +6 -3
- package/src/meta.ts +8 -3
- package/src/translations.ts +4 -2
- package/src/types/ExplorerAction.ts +21 -0
- package/src/types/Graph.ts +63 -0
- package/src/types/index.ts +2 -2
- package/dist/lib/browser/ExplorerContainer-S66JDOAF.mjs +0 -49
- package/dist/lib/browser/ExplorerContainer-S66JDOAF.mjs.map +0 -7
- package/dist/lib/browser/chunk-2DGFNLRO.mjs.map +0 -7
- package/dist/lib/browser/chunk-2MKBRIUT.mjs +0 -31
- package/dist/lib/browser/chunk-2MKBRIUT.mjs.map +0 -7
- package/dist/lib/browser/chunk-4ETQJYX4.mjs +0 -38
- package/dist/lib/browser/chunk-4ETQJYX4.mjs.map +0 -7
- package/dist/lib/browser/chunk-NXGP6NTP.mjs +0 -203
- package/dist/lib/browser/chunk-NXGP6NTP.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-OXJJ3PII.mjs +0 -24
- package/dist/lib/browser/intent-resolver-OXJJ3PII.mjs.map +0 -7
- package/dist/lib/browser/react-surface-C4EC6ZDZ.mjs +0 -31
- package/dist/lib/browser/react-surface-C4EC6ZDZ.mjs.map +0 -7
- package/dist/lib/node-esm/ExplorerContainer-GIJN67DO.mjs +0 -50
- package/dist/lib/node-esm/ExplorerContainer-GIJN67DO.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-3ODK27PU.mjs +0 -33
- package/dist/lib/node-esm/chunk-3ODK27PU.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-6JACZE7E.mjs +0 -205
- package/dist/lib/node-esm/chunk-6JACZE7E.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-AGHU3KVI.mjs +0 -39
- package/dist/lib/node-esm/chunk-AGHU3KVI.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-PX6LHR2N.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-GVM36TJX.mjs +0 -25
- package/dist/lib/node-esm/intent-resolver-GVM36TJX.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-YGGLTBF3.mjs +0 -32
- package/dist/lib/node-esm/react-surface-YGGLTBF3.mjs.map +0 -7
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/dist/types/src/components/ExplorerContainer.d.ts +0 -9
- package/dist/types/src/components/ExplorerContainer.d.ts.map +0 -1
- package/dist/types/src/types/schema.d.ts +0 -12
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/dist/types/src/types/types.d.ts +0 -18
- package/dist/types/src/types/types.d.ts.map +0 -1
- package/src/capabilities/intent-resolver.ts +0 -19
- package/src/capabilities/react-surface.tsx +0 -23
- package/src/components/ExplorerContainer.tsx +0 -50
- package/src/types/schema.ts +0 -16
- package/src/types/types.ts +0 -22
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
// src/components/Graph/D3ForceGraph.tsx
|
|
2
|
-
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
3
|
-
import React, { useCallback, useEffect, useMemo, useRef } from "react";
|
|
4
|
-
import { Obj } from "@dxos/echo";
|
|
5
|
-
import { SelectionModel } from "@dxos/graph";
|
|
6
|
-
import { GraphForceProjector, SVG } from "@dxos/react-ui-graph";
|
|
7
|
-
import { getHashStyles } from "@dxos/react-ui-theme";
|
|
8
|
-
import "@dxos/react-ui-graph/styles/graph.css";
|
|
9
|
-
var D3ForceGraph = ({ classNames, model, selection: _selection, grid, ...props }) => {
|
|
10
|
-
var _effect = _useSignals();
|
|
11
|
-
try {
|
|
12
|
-
const context = useRef(null);
|
|
13
|
-
const projector = useMemo(() => {
|
|
14
|
-
if (context.current) {
|
|
15
|
-
return new GraphForceProjector(context.current, {
|
|
16
|
-
attributes: {
|
|
17
|
-
linkForce: (edge) => {
|
|
18
|
-
return edge.data?.object?.active !== false;
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
forces: {
|
|
22
|
-
point: {
|
|
23
|
-
strength: 0.01
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
}, [
|
|
29
|
-
context.current
|
|
30
|
-
]);
|
|
31
|
-
const graph = useRef(null);
|
|
32
|
-
const selection = useMemo(() => _selection ?? new SelectionModel(), [
|
|
33
|
-
_selection
|
|
34
|
-
]);
|
|
35
|
-
useEffect(() => graph.current?.repaint(), [
|
|
36
|
-
selection.selected.value
|
|
37
|
-
]);
|
|
38
|
-
const handleSelect = useCallback((node) => {
|
|
39
|
-
if (selection.contains(node.id)) {
|
|
40
|
-
selection.remove(node.id);
|
|
41
|
-
} else {
|
|
42
|
-
selection.add(node.id);
|
|
43
|
-
}
|
|
44
|
-
}, [
|
|
45
|
-
selection
|
|
46
|
-
]);
|
|
47
|
-
return /* @__PURE__ */ React.createElement(SVG.Root, {
|
|
48
|
-
ref: context,
|
|
49
|
-
classNames
|
|
50
|
-
}, /* @__PURE__ */ React.createElement(SVG.Markers, null), grid && /* @__PURE__ */ React.createElement(SVG.Grid, {
|
|
51
|
-
axis: true
|
|
52
|
-
}), /* @__PURE__ */ React.createElement(SVG.Zoom, {
|
|
53
|
-
extent: [
|
|
54
|
-
1 / 2,
|
|
55
|
-
2
|
|
56
|
-
]
|
|
57
|
-
}, /* @__PURE__ */ React.createElement(SVG.Graph, {
|
|
58
|
-
...props,
|
|
59
|
-
ref: graph,
|
|
60
|
-
model,
|
|
61
|
-
projector,
|
|
62
|
-
labels: {
|
|
63
|
-
text: (node) => {
|
|
64
|
-
return node.data?.data.label ?? node.id;
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
attributes: {
|
|
68
|
-
node: (node) => {
|
|
69
|
-
const obj = node.data?.data.object;
|
|
70
|
-
return {
|
|
71
|
-
data: {
|
|
72
|
-
color: getHashStyles(obj && Obj.getTypename(obj))?.hue
|
|
73
|
-
},
|
|
74
|
-
classes: {
|
|
75
|
-
"dx-selected": selection.contains(node.id)
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
onSelect: handleSelect
|
|
81
|
-
})));
|
|
82
|
-
} finally {
|
|
83
|
-
_effect.f();
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
// src/components/Graph/ForceGraph.tsx
|
|
88
|
-
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
89
|
-
import { forceLink, forceManyBody } from "d3";
|
|
90
|
-
import NativeForceGraph from "force-graph";
|
|
91
|
-
import React2, { useEffect as useEffect2, useRef as useRef2, useState } from "react";
|
|
92
|
-
import { useResizeDetector } from "react-resize-detector";
|
|
93
|
-
import { filterObjectsSync } from "@dxos/plugin-search";
|
|
94
|
-
|
|
95
|
-
// src/components/Graph/adapter.ts
|
|
96
|
-
function _define_property(obj, key, value) {
|
|
97
|
-
if (key in obj) {
|
|
98
|
-
Object.defineProperty(obj, key, {
|
|
99
|
-
value,
|
|
100
|
-
enumerable: true,
|
|
101
|
-
configurable: true,
|
|
102
|
-
writable: true
|
|
103
|
-
});
|
|
104
|
-
} else {
|
|
105
|
-
obj[key] = value;
|
|
106
|
-
}
|
|
107
|
-
return obj;
|
|
108
|
-
}
|
|
109
|
-
var GraphAdapter = class {
|
|
110
|
-
get nodes() {
|
|
111
|
-
return this._nodes;
|
|
112
|
-
}
|
|
113
|
-
get links() {
|
|
114
|
-
return this._links;
|
|
115
|
-
}
|
|
116
|
-
constructor(graph) {
|
|
117
|
-
_define_property(this, "graph", void 0);
|
|
118
|
-
_define_property(this, "_nodes", void 0);
|
|
119
|
-
_define_property(this, "_links", void 0);
|
|
120
|
-
this.graph = graph;
|
|
121
|
-
this._nodes = [];
|
|
122
|
-
this._links = [];
|
|
123
|
-
this._nodes = graph.nodes.map((node) => ({
|
|
124
|
-
id: node.id,
|
|
125
|
-
type: node.type,
|
|
126
|
-
data: node.data
|
|
127
|
-
}));
|
|
128
|
-
this._links = graph.edges.map((edge) => ({
|
|
129
|
-
type: edge.type,
|
|
130
|
-
source: edge.source,
|
|
131
|
-
target: edge.target,
|
|
132
|
-
data: edge.data
|
|
133
|
-
}));
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
// src/components/Graph/ForceGraph.tsx
|
|
138
|
-
var ForceGraph = ({ model, match }) => {
|
|
139
|
-
var _effect = _useSignals2();
|
|
140
|
-
try {
|
|
141
|
-
const { ref, width, height } = useResizeDetector({
|
|
142
|
-
refreshRate: 200
|
|
143
|
-
});
|
|
144
|
-
const rootRef = useRef2(null);
|
|
145
|
-
const forceGraph = useRef2(null);
|
|
146
|
-
const filteredRef = useRef2([]);
|
|
147
|
-
filteredRef.current = filterObjectsSync(model?.objects ?? [], match);
|
|
148
|
-
const [data, setData] = useState();
|
|
149
|
-
useEffect2(() => {
|
|
150
|
-
return model?.subscribe((model2) => {
|
|
151
|
-
setData(new GraphAdapter(model2.graph));
|
|
152
|
-
});
|
|
153
|
-
}, [
|
|
154
|
-
model
|
|
155
|
-
]);
|
|
156
|
-
useEffect2(() => {
|
|
157
|
-
if (rootRef.current) {
|
|
158
|
-
forceGraph.current = new NativeForceGraph(rootRef.current).nodeRelSize(6).nodeLabel((node) => node.type === "schema" ? node.data.typename : node.data.label ?? node.id).nodeAutoColorBy((node) => node.type === "schema" ? "schema" : node.data.typename).linkAutoColorBy((link) => link.type);
|
|
159
|
-
}
|
|
160
|
-
return () => {
|
|
161
|
-
forceGraph.current?.pauseAnimation().graphData({
|
|
162
|
-
nodes: [],
|
|
163
|
-
links: []
|
|
164
|
-
});
|
|
165
|
-
forceGraph.current = null;
|
|
166
|
-
};
|
|
167
|
-
}, []);
|
|
168
|
-
useEffect2(() => {
|
|
169
|
-
if (!data || !width || !height || !forceGraph.current) {
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
forceGraph.current.pauseAnimation().width(width).height(height).onEngineStop(() => {
|
|
173
|
-
handleZoomToFit();
|
|
174
|
-
}).onNodeClick((node) => {
|
|
175
|
-
forceGraph.current?.emitParticle(node);
|
|
176
|
-
}).d3Force("link", forceLink().distance(160).strength(0.5)).d3Force("charge", forceManyBody().strength(-30)).graphData(data).warmupTicks(100).cooldownTime(1e3).resumeAnimation();
|
|
177
|
-
}, [
|
|
178
|
-
data,
|
|
179
|
-
width,
|
|
180
|
-
height,
|
|
181
|
-
forceGraph.current
|
|
182
|
-
]);
|
|
183
|
-
const handleZoomToFit = () => {
|
|
184
|
-
forceGraph.current?.zoomToFit(400, 40);
|
|
185
|
-
};
|
|
186
|
-
return /* @__PURE__ */ React2.createElement("div", {
|
|
187
|
-
ref,
|
|
188
|
-
className: "relative grow",
|
|
189
|
-
onClick: handleZoomToFit
|
|
190
|
-
}, /* @__PURE__ */ React2.createElement("div", {
|
|
191
|
-
ref: rootRef,
|
|
192
|
-
className: "absolute inset-0"
|
|
193
|
-
}));
|
|
194
|
-
} finally {
|
|
195
|
-
_effect.f();
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
export {
|
|
200
|
-
D3ForceGraph,
|
|
201
|
-
ForceGraph
|
|
202
|
-
};
|
|
203
|
-
//# sourceMappingURL=chunk-NXGP6NTP.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/Graph/D3ForceGraph.tsx", "../../../src/components/Graph/ForceGraph.tsx", "../../../src/components/Graph/adapter.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { useCallback, useEffect, useMemo, useRef } from 'react';\n\nimport { Obj } from '@dxos/echo';\nimport { SelectionModel } from '@dxos/graph';\nimport { type ThemedClassName } from '@dxos/react-ui';\nimport {\n type GraphController,\n GraphForceProjector,\n type GraphLayoutNode,\n type GraphProps,\n SVG,\n type SVGContext,\n} from '@dxos/react-ui-graph';\nimport { getHashStyles } from '@dxos/react-ui-theme';\nimport { type SpaceGraphEdge, type SpaceGraphModel, type SpaceGraphNode } from '@dxos/schema';\n\nimport '@dxos/react-ui-graph/styles/graph.css';\n\nexport type D3ForceGraphProps = ThemedClassName<\n {\n model?: SpaceGraphModel;\n match?: RegExp;\n selection?: SelectionModel;\n grid?: boolean;\n } & Pick<GraphProps, 'drag'>\n>;\n\nexport const D3ForceGraph = ({ classNames, model, selection: _selection, grid, ...props }: D3ForceGraphProps) => {\n const context = useRef<SVGContext>(null);\n const projector = useMemo<GraphForceProjector | undefined>(() => {\n if (context.current) {\n return new GraphForceProjector(context.current, {\n attributes: {\n linkForce: (edge) => {\n // TODO(burdon): Check type (currently assumes Employee property).\n // Edge shouldn't contribute to force if it's not active.\n return edge.data?.object?.active !== false;\n },\n },\n forces: {\n point: {\n strength: 0.01,\n },\n },\n });\n }\n }, [context.current]);\n\n const graph = useRef<GraphController>(null);\n const selection = useMemo(() => _selection ?? new SelectionModel(), [_selection]);\n useEffect(() => graph.current?.repaint(), [selection.selected.value]);\n\n const handleSelect = useCallback<NonNullable<GraphProps['onSelect']>>(\n (node) => {\n if (selection.contains(node.id)) {\n selection.remove(node.id);\n } else {\n selection.add(node.id);\n }\n },\n [selection],\n );\n\n return (\n <SVG.Root ref={context} classNames={classNames}>\n <SVG.Markers />\n {grid && <SVG.Grid axis />}\n <SVG.Zoom extent={[1 / 2, 2]}>\n <SVG.Graph<SpaceGraphNode, SpaceGraphEdge>\n {...props}\n ref={graph}\n model={model}\n projector={projector}\n labels={{\n text: (node) => {\n return node.data?.data.label ?? node.id;\n },\n }}\n attributes={{\n node: (node: GraphLayoutNode<SpaceGraphNode>) => {\n const obj = node.data?.data.object;\n return {\n data: {\n color: getHashStyles(obj && Obj.getTypename(obj))?.hue,\n },\n classes: {\n 'dx-selected': selection.contains(node.id),\n },\n };\n },\n }}\n onSelect={handleSelect}\n />\n </SVG.Zoom>\n </SVG.Root>\n );\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { forceLink, forceManyBody } from 'd3';\nimport NativeForceGraph from 'force-graph';\nimport React, { type FC, useEffect, useRef, useState } from 'react';\nimport { useResizeDetector } from 'react-resize-detector';\n\nimport { type SearchResult, filterObjectsSync } from '@dxos/plugin-search';\nimport { type SpaceGraphModel } from '@dxos/schema';\n\nimport { GraphAdapter } from './adapter';\n\nexport type ForceGraphProps = {\n model?: SpaceGraphModel;\n match?: RegExp;\n};\n\nexport const ForceGraph: FC<ForceGraphProps> = ({ model, match }) => {\n const { ref, width, height } = useResizeDetector({ refreshRate: 200 });\n const rootRef = useRef<HTMLDivElement>(null);\n const forceGraph = useRef<NativeForceGraph>(null);\n\n const filteredRef = useRef<SearchResult[]>([]);\n filteredRef.current = filterObjectsSync(model?.objects ?? [], match);\n\n const [data, setData] = useState<GraphAdapter>();\n useEffect(() => {\n return model?.subscribe((model) => {\n setData(new GraphAdapter(model.graph));\n });\n }, [model]);\n\n useEffect(() => {\n if (rootRef.current) {\n // https://github.com/vasturiano/force-graph\n // https://github.com/vasturiano/3d-force-graph\n forceGraph.current = new NativeForceGraph(rootRef.current)\n // https://github.com/vasturiano/force-graph?tab=readme-ov-file#node-styling\n .nodeRelSize(6)\n .nodeLabel((node: any) => (node.type === 'schema' ? node.data.typename : (node.data.label ?? node.id)))\n .nodeAutoColorBy((node: any) => (node.type === 'schema' ? 'schema' : node.data.typename))\n\n // https://github.com/vasturiano/force-graph?tab=readme-ov-file#link-styling\n .linkAutoColorBy((link: any) => link.type);\n }\n\n return () => {\n forceGraph.current?.pauseAnimation().graphData({ nodes: [], links: [] });\n forceGraph.current = null;\n };\n }, []);\n\n useEffect(() => {\n if (!data || !width || !height || !forceGraph.current) {\n return;\n }\n\n // https://github.com/vasturiano/force-graph?tab=readme-ov-file#container-layout\n forceGraph.current\n .pauseAnimation()\n .width(width)\n .height(height)\n .onEngineStop(() => {\n handleZoomToFit();\n })\n .onNodeClick((node: any) => {\n forceGraph.current?.emitParticle(node);\n })\n\n // https://github.com/vasturiano/force-graph?tab=readme-ov-file#force-engine-d3-force-configuration\n // .d3Force('center', forceCenter().strength(0.9))\n .d3Force('link', forceLink().distance(160).strength(0.5))\n .d3Force('charge', forceManyBody().strength(-30))\n\n .graphData(data)\n .warmupTicks(100)\n .cooldownTime(1_000)\n .resumeAnimation();\n }, [data, width, height, forceGraph.current]);\n\n const handleZoomToFit = () => {\n forceGraph.current?.zoomToFit(400, 40);\n };\n\n return (\n <div ref={ref} className='relative grow' onClick={handleZoomToFit}>\n <div ref={rootRef} className='absolute inset-0' />\n </div>\n );\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Graph } from '@dxos/graph';\n\nexport type GraphNode = {\n id?: string;\n};\n\nexport type GraphLink = {\n source?: string;\n target?: string;\n};\n\nexport type GraphData = {\n nodes: GraphNode[];\n links: GraphLink[];\n};\n\n/**\n * Map common graph to force-graph format.\n */\nexport class GraphAdapter implements GraphData {\n private readonly _nodes: GraphNode[] = [];\n private readonly _links: GraphLink[] = [];\n\n constructor(private readonly graph: Graph) {\n this._nodes = graph.nodes.map((node) => ({\n id: node.id,\n type: node.type,\n data: node.data,\n }));\n\n this._links = graph.edges.map((edge) => ({\n type: edge.type,\n source: edge.source,\n target: edge.target,\n data: edge.data,\n }));\n }\n\n get nodes() {\n return this._nodes;\n }\n\n get links() {\n return this._links;\n }\n}\n"],
|
|
5
|
-
"mappings": ";;AAIA,OAAOA,SAASC,aAAaC,WAAWC,SAASC,cAAc;AAE/D,SAASC,WAAW;AACpB,SAASC,sBAAsB;AAE/B,SAEEC,qBAGAC,WAEK;AACP,SAASC,qBAAqB;AAG9B,OAAO;AAWA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+B,YAAY,GAAA,EACZC,aAAa,GAAA,EACbC,gBAAe;IACpB,GAAG;MAACjC;MAAMX;MAAOC;MAAQK,WAAWE;KAAQ;AAE5C,UAAM0B,kBAAkB,MAAA;AACtB5B,iBAAWE,SAASqC,UAAU,KAAK,EAAA;IACrC;AAEA,WACE,gBAAAC,OAAA,cAACC,OAAAA;MAAIhD;MAAUiD,WAAU;MAAgBC,SAASf;OAChD,gBAAAY,OAAA,cAACC,OAAAA;MAAIhD,KAAKK;MAAS4C,WAAU;;;;;AAGnC;",
|
|
6
|
-
"names": ["React", "useCallback", "useEffect", "useMemo", "useRef", "Obj", "SelectionModel", "GraphForceProjector", "SVG", "getHashStyles", "D3ForceGraph", "classNames", "model", "selection", "_selection", "grid", "props", "context", "useRef", "projector", "useMemo", "current", "GraphForceProjector", "attributes", "linkForce", "edge", "data", "object", "active", "forces", "point", "strength", "graph", "SelectionModel", "useEffect", "repaint", "selected", "value", "handleSelect", "useCallback", "node", "contains", "id", "remove", "add", "SVG", "Root", "ref", "Markers", "Grid", "axis", "Zoom", "extent", "Graph", "labels", "text", "label", "obj", "color", "getHashStyles", "Obj", "getTypename", "hue", "classes", "onSelect", "forceLink", "forceManyBody", "NativeForceGraph", "React", "useEffect", "useRef", "useState", "useResizeDetector", "filterObjectsSync", "GraphAdapter", "nodes", "_nodes", "links", "_links", "graph", "map", "node", "id", "type", "data", "edges", "edge", "source", "target", "ForceGraph", "model", "match", "ref", "width", "height", "useResizeDetector", "refreshRate", "rootRef", "useRef", "forceGraph", "filteredRef", "current", "filterObjectsSync", "objects", "data", "setData", "useState", "useEffect", "subscribe", "GraphAdapter", "graph", "NativeForceGraph", "nodeRelSize", "nodeLabel", "node", "type", "typename", "label", "id", "nodeAutoColorBy", "linkAutoColorBy", "link", "pauseAnimation", "graphData", "nodes", "links", "onEngineStop", "handleZoomToFit", "onNodeClick", "emitParticle", "d3Force", "forceLink", "distance", "strength", "forceManyBody", "warmupTicks", "cooldownTime", "resumeAnimation", "zoomToFit", "React", "div", "className", "onClick"]
|
|
7
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ExplorerAction,
|
|
3
|
-
ViewType
|
|
4
|
-
} from "./chunk-4ETQJYX4.mjs";
|
|
5
|
-
import "./chunk-2DGFNLRO.mjs";
|
|
6
|
-
|
|
7
|
-
// src/capabilities/intent-resolver.ts
|
|
8
|
-
import { Capabilities, contributes, createResolver } from "@dxos/app-framework";
|
|
9
|
-
import { Obj } from "@dxos/echo";
|
|
10
|
-
var intent_resolver_default = (() => contributes(Capabilities.IntentResolver, createResolver({
|
|
11
|
-
intent: ExplorerAction.Create,
|
|
12
|
-
resolve: ({ name }) => ({
|
|
13
|
-
data: {
|
|
14
|
-
object: Obj.make(ViewType, {
|
|
15
|
-
name,
|
|
16
|
-
type: ""
|
|
17
|
-
})
|
|
18
|
-
}
|
|
19
|
-
})
|
|
20
|
-
})));
|
|
21
|
-
export {
|
|
22
|
-
intent_resolver_default as default
|
|
23
|
-
};
|
|
24
|
-
//# sourceMappingURL=intent-resolver-OXJJ3PII.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/intent-resolver.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Capabilities, contributes, createResolver } from '@dxos/app-framework';\nimport { Obj } from '@dxos/echo';\n\nimport { ExplorerAction, ViewType } from '../types';\n\nexport default () =>\n contributes(\n Capabilities.IntentResolver,\n createResolver({\n intent: ExplorerAction.Create,\n resolve: ({ name }) => ({\n data: { object: Obj.make(ViewType, { name, type: '' }) },\n }),\n }),\n );\n"],
|
|
5
|
-
"mappings": ";;;;;;;AAIA,SAASA,cAAcC,aAAaC,sBAAsB;AAC1D,SAASC,WAAW;AAIpB,IAAA,2BAAe,MACbC,YACEC,aAAaC,gBACbC,eAAe;EACbC,QAAQC,eAAeC;EACvBC,SAAS,CAAC,EAAEC,KAAI,OAAQ;IACtBC,MAAM;MAAEC,QAAQC,IAAIC,KAAKC,UAAU;QAAEL;QAAMM,MAAM;MAAG,CAAA;IAAG;EACzD;AACF,CAAA,CAAA;",
|
|
6
|
-
"names": ["Capabilities", "contributes", "createResolver", "Obj", "contributes", "Capabilities", "IntentResolver", "createResolver", "intent", "ExplorerAction", "Create", "resolve", "name", "data", "object", "Obj", "make", "ViewType", "type"]
|
|
7
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ExplorerContainer
|
|
3
|
-
} from "./chunk-UCDNCIRV.mjs";
|
|
4
|
-
import "./chunk-NXGP6NTP.mjs";
|
|
5
|
-
import {
|
|
6
|
-
ViewType
|
|
7
|
-
} from "./chunk-4ETQJYX4.mjs";
|
|
8
|
-
import {
|
|
9
|
-
meta
|
|
10
|
-
} from "./chunk-2DGFNLRO.mjs";
|
|
11
|
-
|
|
12
|
-
// src/capabilities/react-surface.tsx
|
|
13
|
-
import React from "react";
|
|
14
|
-
import { Capabilities, contributes, createSurface } from "@dxos/app-framework";
|
|
15
|
-
import { Obj } from "@dxos/echo";
|
|
16
|
-
var react_surface_default = (() => contributes(Capabilities.ReactSurface, createSurface({
|
|
17
|
-
id: `${meta.id}/article`,
|
|
18
|
-
role: [
|
|
19
|
-
"article",
|
|
20
|
-
"section"
|
|
21
|
-
],
|
|
22
|
-
filter: (data) => Obj.instanceOf(ViewType, data.subject),
|
|
23
|
-
component: ({ data, role }) => /* @__PURE__ */ React.createElement(ExplorerContainer, {
|
|
24
|
-
view: data.subject,
|
|
25
|
-
role
|
|
26
|
-
})
|
|
27
|
-
})));
|
|
28
|
-
export {
|
|
29
|
-
react_surface_default as default
|
|
30
|
-
};
|
|
31
|
-
//# sourceMappingURL=react-surface-C4EC6ZDZ.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/react-surface.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport React from 'react';\n\nimport { Capabilities, contributes, createSurface } from '@dxos/app-framework';\nimport { Obj } from '@dxos/echo';\n\nimport { ExplorerContainer } from '../components';\nimport { meta } from '../meta';\nimport { ViewType } from '../types';\n\nexport default () =>\n contributes(\n Capabilities.ReactSurface,\n createSurface({\n id: `${meta.id}/article`,\n role: ['article', 'section'],\n filter: (data): data is { subject: ViewType } => Obj.instanceOf(ViewType, data.subject),\n component: ({ data, role }) => <ExplorerContainer view={data.subject} role={role} />,\n }),\n );\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;AAIA,OAAOA,WAAW;AAElB,SAASC,cAAcC,aAAaC,qBAAqB;AACzD,SAASC,WAAW;AAMpB,IAAA,yBAAe,MACbC,YACEC,aAAaC,cACbC,cAAc;EACZC,IAAI,GAAGC,KAAKD,EAAE;EACdE,MAAM;IAAC;IAAW;;EAClBC,QAAQ,CAACC,SAAwCC,IAAIC,WAAWC,UAAUH,KAAKI,OAAO;EACtFC,WAAW,CAAC,EAAEL,MAAMF,KAAI,MAAO,sBAAA,cAACQ,mBAAAA;IAAkBC,MAAMP,KAAKI;IAASN;;AACxE,CAAA,CAAA;",
|
|
6
|
-
"names": ["React", "Capabilities", "contributes", "createSurface", "Obj", "contributes", "Capabilities", "ReactSurface", "createSurface", "id", "meta", "role", "filter", "data", "Obj", "instanceOf", "ViewType", "subject", "component", "ExplorerContainer", "view"]
|
|
7
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
useGraphModel
|
|
4
|
-
} from "./chunk-3ODK27PU.mjs";
|
|
5
|
-
import {
|
|
6
|
-
D3ForceGraph
|
|
7
|
-
} from "./chunk-6JACZE7E.mjs";
|
|
8
|
-
|
|
9
|
-
// src/components/ExplorerContainer.tsx
|
|
10
|
-
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
11
|
-
import React, { useCallback, useMemo, useState } from "react";
|
|
12
|
-
import { QueryBuilder } from "@dxos/echo-query";
|
|
13
|
-
import { useGlobalSearch } from "@dxos/plugin-search";
|
|
14
|
-
import { getSpace } from "@dxos/react-client/echo";
|
|
15
|
-
import { Toolbar } from "@dxos/react-ui";
|
|
16
|
-
import { QueryEditor } from "@dxos/react-ui-components";
|
|
17
|
-
import { StackItem } from "@dxos/react-ui-stack";
|
|
18
|
-
var ExplorerContainer = ({ role, view }) => {
|
|
19
|
-
var _effect = _useSignals();
|
|
20
|
-
try {
|
|
21
|
-
const space = getSpace(view);
|
|
22
|
-
const [filter, setFilter] = useState();
|
|
23
|
-
const model = useGraphModel(space, filter);
|
|
24
|
-
const { match } = useGlobalSearch();
|
|
25
|
-
const builder = useMemo(() => new QueryBuilder(), []);
|
|
26
|
-
const handleChange = useCallback((value) => {
|
|
27
|
-
setFilter(builder.build(value));
|
|
28
|
-
}, []);
|
|
29
|
-
if (!space || !model) {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
return /* @__PURE__ */ React.createElement(StackItem.Content, {
|
|
33
|
-
toolbar: true,
|
|
34
|
-
size: role === "section" ? "square" : "intrinsic"
|
|
35
|
-
}, /* @__PURE__ */ React.createElement(Toolbar.Root, null, /* @__PURE__ */ React.createElement(QueryEditor, {
|
|
36
|
-
space,
|
|
37
|
-
onChange: handleChange
|
|
38
|
-
})), /* @__PURE__ */ React.createElement(D3ForceGraph, {
|
|
39
|
-
model,
|
|
40
|
-
match
|
|
41
|
-
}));
|
|
42
|
-
} finally {
|
|
43
|
-
_effect.f();
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
var ExplorerContainer_default = ExplorerContainer;
|
|
47
|
-
export {
|
|
48
|
-
ExplorerContainer_default as default
|
|
49
|
-
};
|
|
50
|
-
//# sourceMappingURL=ExplorerContainer-GIJN67DO.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/ExplorerContainer.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { useCallback, useMemo, useState } from 'react';\n\nimport { type Filter } from '@dxos/echo';\nimport { QueryBuilder } from '@dxos/echo-query';\nimport { useGlobalSearch } from '@dxos/plugin-search';\nimport { getSpace } from '@dxos/react-client/echo';\nimport { Toolbar } from '@dxos/react-ui';\nimport { QueryEditor, type QueryEditorProps } from '@dxos/react-ui-components';\nimport { StackItem } from '@dxos/react-ui-stack';\n\nimport { useGraphModel } from '../hooks';\nimport { type ViewType } from '../types';\n\nimport { D3ForceGraph } from './Graph';\n\ntype ExplorerContainerProps = {\n role: string;\n view: ViewType;\n};\n\nconst ExplorerContainer = ({ role, view }: ExplorerContainerProps) => {\n const space = getSpace(view);\n const [filter, setFilter] = useState<Filter.Any>();\n const model = useGraphModel(space, filter);\n const { match } = useGlobalSearch();\n\n const builder = useMemo(() => new QueryBuilder(), []);\n const handleChange = useCallback<NonNullable<QueryEditorProps['onChange']>>((value) => {\n setFilter(builder.build(value));\n }, []);\n\n if (!space || !model) {\n return null;\n }\n\n return (\n <StackItem.Content toolbar size={role === 'section' ? 'square' : 'intrinsic'}>\n <Toolbar.Root>\n <QueryEditor space={space} onChange={handleChange} />\n </Toolbar.Root>\n <D3ForceGraph model={model} match={match} />\n </StackItem.Content>\n );\n};\n\nexport default ExplorerContainer;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;AAIA,OAAOA,SAASC,aAAaC,SAASC,gBAAgB;AAGtD,SAASC,oBAAoB;AAC7B,SAASC,uBAAuB;AAChC,SAASC,gBAAgB;AACzB,SAASC,eAAe;AACxB,SAASC,mBAA0C;AACnD,SAASC,iBAAiB;AAY1B,IAAMC,oBAAoB,CAAC,EAAEC,MAAMC,KAAI,MAA0B;;;AAC/D,UAAMC,QAAQC,SAASF,IAAAA;AACvB,UAAM,CAACG,QAAQC,SAAAA,IAAaC,SAAAA;AAC5B,UAAMC,QAAQC,cAAcN,OAAOE,MAAAA;AACnC,UAAM,EAAEK,MAAK,IAAKC,gBAAAA;AAElB,UAAMC,UAAUC,QAAQ,MAAM,IAAIC,aAAAA,GAAgB,CAAA,CAAE;AACpD,UAAMC,eAAeC,YAAuD,CAACC,UAAAA;AAC3EX,gBAAUM,QAAQM,MAAMD,KAAAA,CAAAA;IAC1B,GAAG,CAAA,CAAE;AAEL,QAAI,CAACd,SAAS,CAACK,OAAO;AACpB,aAAO;IACT;AAEA,WACE,sBAAA,cAACW,UAAUC,SAAO;MAACC,SAAAA;MAAQC,MAAMrB,SAAS,YAAY,WAAW;OAC/D,sBAAA,cAACsB,QAAQC,MAAI,MACX,sBAAA,cAACC,aAAAA;MAAYtB;MAAcuB,UAAUX;SAEvC,sBAAA,cAACY,cAAAA;MAAanB;MAAcE;;;;;AAGlC;AAEA,IAAA,4BAAeV;",
|
|
6
|
-
"names": ["React", "useCallback", "useMemo", "useState", "QueryBuilder", "useGlobalSearch", "getSpace", "Toolbar", "QueryEditor", "StackItem", "ExplorerContainer", "role", "view", "space", "getSpace", "filter", "setFilter", "useState", "model", "useGraphModel", "match", "useGlobalSearch", "builder", "useMemo", "QueryBuilder", "handleChange", "useCallback", "value", "build", "StackItem", "Content", "toolbar", "size", "Toolbar", "Root", "QueryEditor", "onChange", "D3ForceGraph"]
|
|
7
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
|
|
3
|
-
// src/hooks/useGraphModel.ts
|
|
4
|
-
import { useEffect, useState } from "react";
|
|
5
|
-
import { SpaceGraphModel } from "@dxos/schema";
|
|
6
|
-
var useGraphModel = (space, filter, options, queue) => {
|
|
7
|
-
const [model, setModel] = useState(void 0);
|
|
8
|
-
useEffect(() => {
|
|
9
|
-
if (!space) {
|
|
10
|
-
void model?.close();
|
|
11
|
-
setModel(void 0);
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
if (!model || model.queue !== queue) {
|
|
15
|
-
const model2 = new SpaceGraphModel().setFilter(filter).setOptions(options);
|
|
16
|
-
void model2.open(space, queue);
|
|
17
|
-
setModel(model2);
|
|
18
|
-
} else {
|
|
19
|
-
model.setFilter(filter).setOptions(options);
|
|
20
|
-
}
|
|
21
|
-
}, [
|
|
22
|
-
space,
|
|
23
|
-
filter,
|
|
24
|
-
options,
|
|
25
|
-
queue
|
|
26
|
-
]);
|
|
27
|
-
return model;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export {
|
|
31
|
-
useGraphModel
|
|
32
|
-
};
|
|
33
|
-
//# sourceMappingURL=chunk-3ODK27PU.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/hooks/useGraphModel.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { useEffect, useState } from 'react';\n\nimport { type Filter, type Queue, type Space } from '@dxos/client/echo';\nimport { SpaceGraphModel, type SpaceGraphModelOptions } from '@dxos/schema';\n\n// TODO(burdon): Factor out.\nexport const useGraphModel = (\n space: Space | undefined,\n filter?: Filter.Any | undefined,\n options?: SpaceGraphModelOptions,\n queue?: Queue,\n): SpaceGraphModel | undefined => {\n const [model, setModel] = useState<SpaceGraphModel | undefined>(undefined);\n useEffect(() => {\n if (!space) {\n void model?.close();\n setModel(undefined);\n return;\n }\n\n // TODO(burdon): Does this need to be a dependency?\n if (!model || model.queue !== queue) {\n const model = new SpaceGraphModel().setFilter(filter).setOptions(options);\n void model.open(space, queue);\n setModel(model);\n } else {\n model.setFilter(filter).setOptions(options);\n }\n }, [space, filter, options, queue]);\n\n return model;\n};\n"],
|
|
5
|
-
"mappings": ";;;AAIA,SAASA,WAAWC,gBAAgB;AAGpC,SAASC,uBAAoD;AAGtD,IAAMC,gBAAgB,CAC3BC,OACAC,QACAC,SACAC,UAAAA;AAEA,QAAM,CAACC,OAAOC,QAAAA,IAAYC,SAAsCC,MAAAA;AAChEC,YAAU,MAAA;AACR,QAAI,CAACR,OAAO;AACV,WAAKI,OAAOK,MAAAA;AACZJ,eAASE,MAAAA;AACT;IACF;AAGA,QAAI,CAACH,SAASA,MAAMD,UAAUA,OAAO;AACnC,YAAMC,SAAQ,IAAIM,gBAAAA,EAAkBC,UAAUV,MAAAA,EAAQW,WAAWV,OAAAA;AACjE,WAAKE,OAAMS,KAAKb,OAAOG,KAAAA;AACvBE,eAASD,MAAAA;IACX,OAAO;AACLA,YAAMO,UAAUV,MAAAA,EAAQW,WAAWV,OAAAA;IACrC;EACF,GAAG;IAACF;IAAOC;IAAQC;IAASC;GAAM;AAElC,SAAOC;AACT;",
|
|
6
|
-
"names": ["useEffect", "useState", "SpaceGraphModel", "useGraphModel", "space", "filter", "options", "queue", "model", "setModel", "useState", "undefined", "useEffect", "close", "SpaceGraphModel", "setFilter", "setOptions", "open"]
|
|
7
|
-
}
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
|
|
3
|
-
// src/components/Graph/D3ForceGraph.tsx
|
|
4
|
-
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
5
|
-
import React, { useCallback, useEffect, useMemo, useRef } from "react";
|
|
6
|
-
import { Obj } from "@dxos/echo";
|
|
7
|
-
import { SelectionModel } from "@dxos/graph";
|
|
8
|
-
import { GraphForceProjector, SVG } from "@dxos/react-ui-graph";
|
|
9
|
-
import { getHashStyles } from "@dxos/react-ui-theme";
|
|
10
|
-
import "@dxos/react-ui-graph/styles/graph.css";
|
|
11
|
-
var D3ForceGraph = ({ classNames, model, selection: _selection, grid, ...props }) => {
|
|
12
|
-
var _effect = _useSignals();
|
|
13
|
-
try {
|
|
14
|
-
const context = useRef(null);
|
|
15
|
-
const projector = useMemo(() => {
|
|
16
|
-
if (context.current) {
|
|
17
|
-
return new GraphForceProjector(context.current, {
|
|
18
|
-
attributes: {
|
|
19
|
-
linkForce: (edge) => {
|
|
20
|
-
return edge.data?.object?.active !== false;
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
forces: {
|
|
24
|
-
point: {
|
|
25
|
-
strength: 0.01
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
}, [
|
|
31
|
-
context.current
|
|
32
|
-
]);
|
|
33
|
-
const graph = useRef(null);
|
|
34
|
-
const selection = useMemo(() => _selection ?? new SelectionModel(), [
|
|
35
|
-
_selection
|
|
36
|
-
]);
|
|
37
|
-
useEffect(() => graph.current?.repaint(), [
|
|
38
|
-
selection.selected.value
|
|
39
|
-
]);
|
|
40
|
-
const handleSelect = useCallback((node) => {
|
|
41
|
-
if (selection.contains(node.id)) {
|
|
42
|
-
selection.remove(node.id);
|
|
43
|
-
} else {
|
|
44
|
-
selection.add(node.id);
|
|
45
|
-
}
|
|
46
|
-
}, [
|
|
47
|
-
selection
|
|
48
|
-
]);
|
|
49
|
-
return /* @__PURE__ */ React.createElement(SVG.Root, {
|
|
50
|
-
ref: context,
|
|
51
|
-
classNames
|
|
52
|
-
}, /* @__PURE__ */ React.createElement(SVG.Markers, null), grid && /* @__PURE__ */ React.createElement(SVG.Grid, {
|
|
53
|
-
axis: true
|
|
54
|
-
}), /* @__PURE__ */ React.createElement(SVG.Zoom, {
|
|
55
|
-
extent: [
|
|
56
|
-
1 / 2,
|
|
57
|
-
2
|
|
58
|
-
]
|
|
59
|
-
}, /* @__PURE__ */ React.createElement(SVG.Graph, {
|
|
60
|
-
...props,
|
|
61
|
-
ref: graph,
|
|
62
|
-
model,
|
|
63
|
-
projector,
|
|
64
|
-
labels: {
|
|
65
|
-
text: (node) => {
|
|
66
|
-
return node.data?.data.label ?? node.id;
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
attributes: {
|
|
70
|
-
node: (node) => {
|
|
71
|
-
const obj = node.data?.data.object;
|
|
72
|
-
return {
|
|
73
|
-
data: {
|
|
74
|
-
color: getHashStyles(obj && Obj.getTypename(obj))?.hue
|
|
75
|
-
},
|
|
76
|
-
classes: {
|
|
77
|
-
"dx-selected": selection.contains(node.id)
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
onSelect: handleSelect
|
|
83
|
-
})));
|
|
84
|
-
} finally {
|
|
85
|
-
_effect.f();
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
// src/components/Graph/ForceGraph.tsx
|
|
90
|
-
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
91
|
-
import { forceLink, forceManyBody } from "d3";
|
|
92
|
-
import NativeForceGraph from "force-graph";
|
|
93
|
-
import React2, { useEffect as useEffect2, useRef as useRef2, useState } from "react";
|
|
94
|
-
import { useResizeDetector } from "react-resize-detector";
|
|
95
|
-
import { filterObjectsSync } from "@dxos/plugin-search";
|
|
96
|
-
|
|
97
|
-
// src/components/Graph/adapter.ts
|
|
98
|
-
function _define_property(obj, key, value) {
|
|
99
|
-
if (key in obj) {
|
|
100
|
-
Object.defineProperty(obj, key, {
|
|
101
|
-
value,
|
|
102
|
-
enumerable: true,
|
|
103
|
-
configurable: true,
|
|
104
|
-
writable: true
|
|
105
|
-
});
|
|
106
|
-
} else {
|
|
107
|
-
obj[key] = value;
|
|
108
|
-
}
|
|
109
|
-
return obj;
|
|
110
|
-
}
|
|
111
|
-
var GraphAdapter = class {
|
|
112
|
-
get nodes() {
|
|
113
|
-
return this._nodes;
|
|
114
|
-
}
|
|
115
|
-
get links() {
|
|
116
|
-
return this._links;
|
|
117
|
-
}
|
|
118
|
-
constructor(graph) {
|
|
119
|
-
_define_property(this, "graph", void 0);
|
|
120
|
-
_define_property(this, "_nodes", void 0);
|
|
121
|
-
_define_property(this, "_links", void 0);
|
|
122
|
-
this.graph = graph;
|
|
123
|
-
this._nodes = [];
|
|
124
|
-
this._links = [];
|
|
125
|
-
this._nodes = graph.nodes.map((node) => ({
|
|
126
|
-
id: node.id,
|
|
127
|
-
type: node.type,
|
|
128
|
-
data: node.data
|
|
129
|
-
}));
|
|
130
|
-
this._links = graph.edges.map((edge) => ({
|
|
131
|
-
type: edge.type,
|
|
132
|
-
source: edge.source,
|
|
133
|
-
target: edge.target,
|
|
134
|
-
data: edge.data
|
|
135
|
-
}));
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
// src/components/Graph/ForceGraph.tsx
|
|
140
|
-
var ForceGraph = ({ model, match }) => {
|
|
141
|
-
var _effect = _useSignals2();
|
|
142
|
-
try {
|
|
143
|
-
const { ref, width, height } = useResizeDetector({
|
|
144
|
-
refreshRate: 200
|
|
145
|
-
});
|
|
146
|
-
const rootRef = useRef2(null);
|
|
147
|
-
const forceGraph = useRef2(null);
|
|
148
|
-
const filteredRef = useRef2([]);
|
|
149
|
-
filteredRef.current = filterObjectsSync(model?.objects ?? [], match);
|
|
150
|
-
const [data, setData] = useState();
|
|
151
|
-
useEffect2(() => {
|
|
152
|
-
return model?.subscribe((model2) => {
|
|
153
|
-
setData(new GraphAdapter(model2.graph));
|
|
154
|
-
});
|
|
155
|
-
}, [
|
|
156
|
-
model
|
|
157
|
-
]);
|
|
158
|
-
useEffect2(() => {
|
|
159
|
-
if (rootRef.current) {
|
|
160
|
-
forceGraph.current = new NativeForceGraph(rootRef.current).nodeRelSize(6).nodeLabel((node) => node.type === "schema" ? node.data.typename : node.data.label ?? node.id).nodeAutoColorBy((node) => node.type === "schema" ? "schema" : node.data.typename).linkAutoColorBy((link) => link.type);
|
|
161
|
-
}
|
|
162
|
-
return () => {
|
|
163
|
-
forceGraph.current?.pauseAnimation().graphData({
|
|
164
|
-
nodes: [],
|
|
165
|
-
links: []
|
|
166
|
-
});
|
|
167
|
-
forceGraph.current = null;
|
|
168
|
-
};
|
|
169
|
-
}, []);
|
|
170
|
-
useEffect2(() => {
|
|
171
|
-
if (!data || !width || !height || !forceGraph.current) {
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
forceGraph.current.pauseAnimation().width(width).height(height).onEngineStop(() => {
|
|
175
|
-
handleZoomToFit();
|
|
176
|
-
}).onNodeClick((node) => {
|
|
177
|
-
forceGraph.current?.emitParticle(node);
|
|
178
|
-
}).d3Force("link", forceLink().distance(160).strength(0.5)).d3Force("charge", forceManyBody().strength(-30)).graphData(data).warmupTicks(100).cooldownTime(1e3).resumeAnimation();
|
|
179
|
-
}, [
|
|
180
|
-
data,
|
|
181
|
-
width,
|
|
182
|
-
height,
|
|
183
|
-
forceGraph.current
|
|
184
|
-
]);
|
|
185
|
-
const handleZoomToFit = () => {
|
|
186
|
-
forceGraph.current?.zoomToFit(400, 40);
|
|
187
|
-
};
|
|
188
|
-
return /* @__PURE__ */ React2.createElement("div", {
|
|
189
|
-
ref,
|
|
190
|
-
className: "relative grow",
|
|
191
|
-
onClick: handleZoomToFit
|
|
192
|
-
}, /* @__PURE__ */ React2.createElement("div", {
|
|
193
|
-
ref: rootRef,
|
|
194
|
-
className: "absolute inset-0"
|
|
195
|
-
}));
|
|
196
|
-
} finally {
|
|
197
|
-
_effect.f();
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
export {
|
|
202
|
-
D3ForceGraph,
|
|
203
|
-
ForceGraph
|
|
204
|
-
};
|
|
205
|
-
//# sourceMappingURL=chunk-6JACZE7E.mjs.map
|