@dxos/plugin-explorer 0.8.4-main.28f8d3d → 0.8.4-main.406dc2a
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-6SHZJ6AK.mjs +50 -0
- package/dist/lib/browser/ExplorerContainer-6SHZJ6AK.mjs.map +7 -0
- package/dist/lib/browser/{chunk-UL5EDJPE.mjs → chunk-2DGFNLRO.mjs} +2 -4
- package/dist/lib/browser/chunk-2DGFNLRO.mjs.map +7 -0
- package/dist/lib/browser/chunk-BZ65T5M3.mjs +79 -0
- package/dist/lib/browser/chunk-BZ65T5M3.mjs.map +7 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/browser/{chunk-LGK64HLU.mjs → chunk-MOM5KCKC.mjs} +258 -6
- package/dist/lib/browser/{chunk-LGK64HLU.mjs.map → chunk-MOM5KCKC.mjs.map} +3 -3
- package/dist/lib/browser/{chunk-L4U4MPSZ.mjs → chunk-NXGP6NTP.mjs} +28 -15
- package/dist/lib/browser/chunk-NXGP6NTP.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +23 -17
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/intent-resolver-K57C3LIX.mjs +31 -0
- package/dist/lib/browser/intent-resolver-K57C3LIX.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/meta.mjs +2 -3
- package/dist/lib/browser/react-surface-OPBND5W3.mjs +35 -0
- package/dist/lib/browser/react-surface-OPBND5W3.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +7 -6
- package/dist/lib/node-esm/{ExplorerContainer-AMYAVLO4.mjs → ExplorerContainer-FRTDXZI5.mjs} +19 -6
- package/dist/lib/node-esm/ExplorerContainer-FRTDXZI5.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-MCOXQ3ML.mjs → chunk-6JACZE7E.mjs} +28 -15
- package/dist/lib/node-esm/chunk-6JACZE7E.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-ES6AOMCY.mjs +80 -0
- package/dist/lib/node-esm/chunk-ES6AOMCY.mjs.map +7 -0
- 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-PIAXA43R.mjs → chunk-PX6LHR2N.mjs} +2 -4
- package/dist/lib/node-esm/chunk-PX6LHR2N.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-W4ZNCGOD.mjs → chunk-ZCV4U7LT.mjs} +258 -6
- package/dist/lib/node-esm/{chunk-W4ZNCGOD.mjs.map → chunk-ZCV4U7LT.mjs.map} +3 -3
- package/dist/lib/node-esm/index.mjs +23 -17
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/intent-resolver-BLPPTTEY.mjs +32 -0
- package/dist/lib/node-esm/intent-resolver-BLPPTTEY.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/meta.mjs +2 -3
- package/dist/lib/node-esm/react-surface-HCKQSHKJ.mjs +36 -0
- package/dist/lib/node-esm/react-surface-HCKQSHKJ.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +7 -6
- package/dist/types/src/ExplorerPlugin.d.ts +1 -1
- package/dist/types/src/ExplorerPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +2 -2
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +2 -2
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/Chart/Chart.stories.d.ts +8 -4
- package/dist/types/src/components/Chart/Chart.stories.d.ts.map +1 -1
- package/dist/types/src/components/ExplorerContainer.d.ts +2 -2
- package/dist/types/src/components/ExplorerContainer.d.ts.map +1 -1
- package/dist/types/src/components/Globe/Globe.stories.d.ts +8 -4
- package/dist/types/src/components/Globe/Globe.stories.d.ts.map +1 -1
- package/dist/types/src/components/Graph/D3ForceGraph.d.ts +2 -2
- package/dist/types/src/components/Graph/D3ForceGraph.d.ts.map +1 -1
- package/dist/types/src/components/Graph/D3ForceGraph.stories.d.ts +13 -4
- package/dist/types/src/components/Graph/D3ForceGraph.stories.d.ts.map +1 -1
- package/dist/types/src/components/Graph/ForceGraph.stories.d.ts +13 -4
- package/dist/types/src/components/Graph/ForceGraph.stories.d.ts.map +1 -1
- package/dist/types/src/components/Tree/Tree.stories.d.ts +13 -16
- package/dist/types/src/components/Tree/Tree.stories.d.ts.map +1 -1
- package/dist/types/src/components/Tree/types/tree.d.ts +1 -1
- package/dist/types/src/components/Tree/types/tree.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -1
- package/dist/types/src/meta.d.ts +0 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +14 -2
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/ExplorerAction.d.ts +23 -0
- package/dist/types/src/types/ExplorerAction.d.ts.map +1 -0
- package/dist/types/src/types/Graph.d.ts +33 -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 +37 -36
- package/src/ExplorerPlugin.tsx +47 -46
- package/src/capabilities/intent-resolver.ts +10 -8
- package/src/capabilities/react-surface.tsx +9 -5
- package/src/components/Chart/Chart.stories.tsx +7 -6
- package/src/components/ExplorerContainer.tsx +22 -5
- package/src/components/Globe/Globe.stories.tsx +11 -10
- package/src/components/Graph/D3ForceGraph.stories.tsx +28 -16
- package/src/components/Graph/D3ForceGraph.tsx +4 -4
- package/src/components/Graph/ForceGraph.stories.tsx +28 -16
- package/src/components/Graph/ForceGraph.tsx +3 -3
- package/src/components/Tree/Tree.stories.tsx +27 -21
- package/src/components/Tree/Tree.tsx +2 -2
- package/src/components/Tree/types/tree.ts +1 -1
- package/src/meta.ts +1 -3
- package/src/translations.ts +4 -2
- package/src/types/ExplorerAction.ts +29 -0
- package/src/types/Graph.ts +45 -0
- package/src/types/index.ts +2 -2
- package/dist/lib/browser/ExplorerContainer-5QHLD2B2.mjs +0 -37
- package/dist/lib/browser/ExplorerContainer-5QHLD2B2.mjs.map +0 -7
- package/dist/lib/browser/chunk-CZZ3DDR7.mjs +0 -38
- package/dist/lib/browser/chunk-CZZ3DDR7.mjs.map +0 -7
- package/dist/lib/browser/chunk-L4U4MPSZ.mjs.map +0 -7
- package/dist/lib/browser/chunk-UL5EDJPE.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-7MVEYNX7.mjs +0 -24
- package/dist/lib/browser/intent-resolver-7MVEYNX7.mjs.map +0 -7
- package/dist/lib/browser/react-surface-FABRDFTF.mjs +0 -31
- package/dist/lib/browser/react-surface-FABRDFTF.mjs.map +0 -7
- package/dist/lib/node-esm/ExplorerContainer-AMYAVLO4.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-4GWDNZ4Z.mjs +0 -39
- package/dist/lib/node-esm/chunk-4GWDNZ4Z.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-MCOXQ3ML.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-PIAXA43R.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-NL3SR2XF.mjs +0 -25
- package/dist/lib/node-esm/intent-resolver-NL3SR2XF.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-EYCZUAAI.mjs +0 -32
- package/dist/lib/node-esm/react-surface-EYCZUAAI.mjs.map +0 -7
- 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/types/schema.ts +0 -16
- package/src/types/types.ts +0 -22
|
@@ -0,0 +1,7 @@
|
|
|
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';\nimport { type DataType } from '@dxos/schema';\n\nimport { useGraphModel } from '../hooks';\n\nimport { D3ForceGraph } from './Graph';\n\ntype ExplorerContainerProps = {\n role: string;\n view: DataType.View;\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 const showToolbar = role === 'article';\n\n if (!space || !model) {\n return null;\n }\n\n return (\n <StackItem.Content toolbar={showToolbar}>\n {showToolbar && (\n <Toolbar.Root>\n <QueryEditor db={space.db} onChange={handleChange} />\n </Toolbar.Root>\n )}\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,UAAME,cAAclB,SAAS;AAE7B,QAAI,CAACE,SAAS,CAACK,OAAO;AACpB,aAAO;IACT;AAEA,WACE,sBAAA,cAACY,UAAUC,SAAO;MAACC,SAASH;OACzBA,eACC,sBAAA,cAACI,QAAQC,MAAI,MACX,sBAAA,cAACC,aAAAA;MAAYC,IAAIvB,MAAMuB;MAAIC,UAAUZ;SAGzC,sBAAA,cAACa,cAAAA;MAAapB;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", "showToolbar", "StackItem", "Content", "toolbar", "Toolbar", "Root", "QueryEditor", "db", "onChange", "D3ForceGraph"]
|
|
7
|
+
}
|
|
@@ -6,7 +6,7 @@ import React, { useCallback, useEffect, useMemo, useRef } from "react";
|
|
|
6
6
|
import { Obj } from "@dxos/echo";
|
|
7
7
|
import { SelectionModel } from "@dxos/graph";
|
|
8
8
|
import { GraphForceProjector, SVG } from "@dxos/react-ui-graph";
|
|
9
|
-
import {
|
|
9
|
+
import { getHashStyles } from "@dxos/react-ui-theme";
|
|
10
10
|
import "@dxos/react-ui-graph/styles/graph.css";
|
|
11
11
|
var D3ForceGraph = ({ classNames, model, selection: _selection, grid, ...props }) => {
|
|
12
12
|
var _effect = _useSignals();
|
|
@@ -71,7 +71,7 @@ var D3ForceGraph = ({ classNames, model, selection: _selection, grid, ...props }
|
|
|
71
71
|
const obj = node.data?.data.object;
|
|
72
72
|
return {
|
|
73
73
|
data: {
|
|
74
|
-
color:
|
|
74
|
+
color: getHashStyles(obj && Obj.getTypename(obj))?.hue
|
|
75
75
|
},
|
|
76
76
|
classes: {
|
|
77
77
|
"dx-selected": selection.contains(node.id)
|
|
@@ -95,11 +95,30 @@ import { useResizeDetector } from "react-resize-detector";
|
|
|
95
95
|
import { filterObjectsSync } from "@dxos/plugin-search";
|
|
96
96
|
|
|
97
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
|
+
}
|
|
98
111
|
var GraphAdapter = class {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
112
|
+
get nodes() {
|
|
113
|
+
return this._nodes;
|
|
114
|
+
}
|
|
115
|
+
get links() {
|
|
116
|
+
return this._links;
|
|
117
|
+
}
|
|
102
118
|
constructor(graph) {
|
|
119
|
+
_define_property(this, "graph", void 0);
|
|
120
|
+
_define_property(this, "_nodes", void 0);
|
|
121
|
+
_define_property(this, "_links", void 0);
|
|
103
122
|
this.graph = graph;
|
|
104
123
|
this._nodes = [];
|
|
105
124
|
this._links = [];
|
|
@@ -115,12 +134,6 @@ var GraphAdapter = class {
|
|
|
115
134
|
data: edge.data
|
|
116
135
|
}));
|
|
117
136
|
}
|
|
118
|
-
get nodes() {
|
|
119
|
-
return this._nodes;
|
|
120
|
-
}
|
|
121
|
-
get links() {
|
|
122
|
-
return this._links;
|
|
123
|
-
}
|
|
124
137
|
};
|
|
125
138
|
|
|
126
139
|
// src/components/Graph/ForceGraph.tsx
|
|
@@ -131,8 +144,8 @@ var ForceGraph = ({ model, match }) => {
|
|
|
131
144
|
refreshRate: 200
|
|
132
145
|
});
|
|
133
146
|
const rootRef = useRef2(null);
|
|
134
|
-
const forceGraph = useRef2();
|
|
135
|
-
const filteredRef = useRef2();
|
|
147
|
+
const forceGraph = useRef2(null);
|
|
148
|
+
const filteredRef = useRef2([]);
|
|
136
149
|
filteredRef.current = filterObjectsSync(model?.objects ?? [], match);
|
|
137
150
|
const [data, setData] = useState();
|
|
138
151
|
useEffect2(() => {
|
|
@@ -151,7 +164,7 @@ var ForceGraph = ({ model, match }) => {
|
|
|
151
164
|
nodes: [],
|
|
152
165
|
links: []
|
|
153
166
|
});
|
|
154
|
-
forceGraph.current =
|
|
167
|
+
forceGraph.current = null;
|
|
155
168
|
};
|
|
156
169
|
}, []);
|
|
157
170
|
useEffect2(() => {
|
|
@@ -189,4 +202,4 @@ export {
|
|
|
189
202
|
D3ForceGraph,
|
|
190
203
|
ForceGraph
|
|
191
204
|
};
|
|
192
|
-
//# sourceMappingURL=chunk-
|
|
205
|
+
//# sourceMappingURL=chunk-6JACZE7E.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
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,IAAMC,eAAe,CAAC,EAAEC,YAAYC,OAAOC,WAAWC,YAAYC,MAAM,GAAGC,MAAAA,MAA0B;;;AAC1G,U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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
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
meta
|
|
4
|
+
} from "./chunk-PX6LHR2N.mjs";
|
|
5
|
+
import {
|
|
6
|
+
__export
|
|
7
|
+
} from "./chunk-HSLMI22Q.mjs";
|
|
8
|
+
|
|
9
|
+
// src/types/ExplorerAction.ts
|
|
10
|
+
var ExplorerAction_exports = {};
|
|
11
|
+
__export(ExplorerAction_exports, {
|
|
12
|
+
CreateGraph: () => CreateGraph,
|
|
13
|
+
GraphProps: () => GraphProps
|
|
14
|
+
});
|
|
15
|
+
import * as Schema from "effect/Schema";
|
|
16
|
+
import { SpaceSchema } from "@dxos/react-client/echo";
|
|
17
|
+
import { DataType, TypenameAnnotationId } from "@dxos/schema";
|
|
18
|
+
var EXPLORER_ACTION = `${meta.id}/action`;
|
|
19
|
+
var GraphProps = Schema.Struct({
|
|
20
|
+
name: Schema.optional(Schema.String),
|
|
21
|
+
typename: Schema.String.annotations({
|
|
22
|
+
[TypenameAnnotationId]: [
|
|
23
|
+
"used-static",
|
|
24
|
+
"dynamic"
|
|
25
|
+
],
|
|
26
|
+
title: "Select graph record type"
|
|
27
|
+
})
|
|
28
|
+
});
|
|
29
|
+
var CreateGraph = class extends Schema.TaggedClass()(`${EXPLORER_ACTION}/create-graph`, {
|
|
30
|
+
input: Schema.Struct({
|
|
31
|
+
space: SpaceSchema
|
|
32
|
+
}).pipe(Schema.extend(GraphProps)),
|
|
33
|
+
output: Schema.Struct({
|
|
34
|
+
object: DataType.View
|
|
35
|
+
})
|
|
36
|
+
}) {
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// src/types/Graph.ts
|
|
40
|
+
var Graph_exports = {};
|
|
41
|
+
__export(Graph_exports, {
|
|
42
|
+
Graph: () => Graph,
|
|
43
|
+
make: () => make,
|
|
44
|
+
makeView: () => makeView
|
|
45
|
+
});
|
|
46
|
+
import * as Schema2 from "effect/Schema";
|
|
47
|
+
import { Filter, Obj, Query, QueryAST, Type } from "@dxos/echo";
|
|
48
|
+
import { LabelAnnotation, ViewAnnotation } from "@dxos/echo/internal";
|
|
49
|
+
import { createViewFromSpace } from "@dxos/schema";
|
|
50
|
+
var Graph = Schema2.Struct({
|
|
51
|
+
name: Schema2.optional(Schema2.String),
|
|
52
|
+
query: Schema2.Struct({
|
|
53
|
+
raw: Schema2.optional(Schema2.String),
|
|
54
|
+
ast: QueryAST.Query
|
|
55
|
+
}).pipe(Schema2.mutable)
|
|
56
|
+
}).pipe(Type.Obj({
|
|
57
|
+
typename: "dxos.org/type/Graph",
|
|
58
|
+
version: "0.1.0"
|
|
59
|
+
}), LabelAnnotation.set([
|
|
60
|
+
"name"
|
|
61
|
+
]), ViewAnnotation.set(true));
|
|
62
|
+
var make = (props = {
|
|
63
|
+
query: {
|
|
64
|
+
raw: "",
|
|
65
|
+
ast: Query.select(Filter.nothing()).ast
|
|
66
|
+
}
|
|
67
|
+
}) => Obj.make(Graph, props);
|
|
68
|
+
var makeView = async ({ presentation, ...props }) => {
|
|
69
|
+
const graph = make(presentation);
|
|
70
|
+
return createViewFromSpace({
|
|
71
|
+
...props,
|
|
72
|
+
presentation: graph
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export {
|
|
77
|
+
ExplorerAction_exports,
|
|
78
|
+
Graph_exports
|
|
79
|
+
};
|
|
80
|
+
//# sourceMappingURL=chunk-ES6AOMCY.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/types/ExplorerAction.ts", "../../../src/types/Graph.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { SpaceSchema } from '@dxos/react-client/echo';\nimport { DataType, TypenameAnnotationId } from '@dxos/schema';\n\nimport { meta } from '../meta';\n\nconst EXPLORER_ACTION = `${meta.id}/action`;\n\nexport const GraphProps = Schema.Struct({\n name: Schema.optional(Schema.String),\n typename: Schema.String.annotations({\n [TypenameAnnotationId]: ['used-static', 'dynamic'],\n title: 'Select graph record type',\n }),\n});\n\nexport class CreateGraph extends Schema.TaggedClass<CreateGraph>()(`${EXPLORER_ACTION}/create-graph`, {\n input: Schema.Struct({\n space: SpaceSchema,\n }).pipe(Schema.extend(GraphProps)),\n output: Schema.Struct({\n object: DataType.View,\n }),\n}) {}\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { Filter, Obj, Query, QueryAST, Type } from '@dxos/echo';\nimport { LabelAnnotation, ViewAnnotation } from '@dxos/echo/internal';\nimport { type CreateViewFromSpaceProps, createViewFromSpace } from '@dxos/schema';\n\nexport const Graph = Schema.Struct({\n name: Schema.optional(Schema.String),\n query: Schema.Struct({\n raw: Schema.optional(Schema.String),\n ast: QueryAST.Query,\n }).pipe(Schema.mutable),\n}).pipe(\n Type.Obj({\n typename: 'dxos.org/type/Graph',\n version: '0.1.0',\n }),\n LabelAnnotation.set(['name']),\n ViewAnnotation.set(true),\n);\n\nexport type Graph = Schema.Schema.Type<typeof Graph>;\n\n/**\n * Make a graph object.\n */\nexport const make = (\n props: Obj.MakeProps<typeof Graph> = { query: { raw: '', ast: Query.select(Filter.nothing()).ast } },\n) => Obj.make(Graph, props);\n\ntype MakeViewProps = Omit<CreateViewFromSpaceProps, 'presentation'> & {\n presentation?: Omit<Obj.MakeProps<typeof Graph>, 'name'>;\n};\n\n/**\n * Make a graph as a view of a data set.\n */\nexport const makeView = async ({ presentation, ...props }: MakeViewProps) => {\n const graph = make(presentation);\n return createViewFromSpace({ ...props, presentation: graph });\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;AAAA;;;;;AAIA,YAAYA,YAAY;AAExB,SAASC,mBAAmB;AAC5B,SAASC,UAAUC,4BAA4B;AAI/C,IAAMC,kBAAkB,GAAGC,KAAKC,EAAE;AAE3B,IAAMC,aAAoBC,cAAO;EACtCC,MAAaC,gBAAgBC,aAAM;EACnCC,UAAiBD,cAAOE,YAAY;IAClC,CAACC,oBAAAA,GAAuB;MAAC;MAAe;;IACxCC,OAAO;EACT,CAAA;AACF,CAAA;AAEO,IAAMC,cAAN,cAAiCC,mBAAW,EAAgB,GAAGb,eAAAA,iBAAgC;EACpGc,OAAcV,cAAO;IACnBW,OAAOC;EACT,CAAA,EAAGC,KAAYC,cAAOf,UAAAA,CAAAA;EACtBgB,QAAef,cAAO;IACpBgB,QAAQC,SAASC;EACnB,CAAA;AACF,CAAA,EAAA;AAAI;;;AC5BJ;;;;;;AAIA,YAAYC,aAAY;AAExB,SAASC,QAAQC,KAAKC,OAAOC,UAAUC,YAAY;AACnD,SAASC,iBAAiBC,sBAAsB;AAChD,SAAwCC,2BAA2B;AAE5D,IAAMC,QAAeC,eAAO;EACjCC,MAAaC,iBAAgBC,cAAM;EACnCC,OAAcJ,eAAO;IACnBK,KAAYH,iBAAgBC,cAAM;IAClCG,KAAKC,SAASC;EAChB,CAAA,EAAGC,KAAYC,eAAO;AACxB,CAAA,EAAGD,KACDE,KAAKC,IAAI;EACPC,UAAU;EACVC,SAAS;AACX,CAAA,GACAC,gBAAgBC,IAAI;EAAC;CAAO,GAC5BC,eAAeD,IAAI,IAAA,CAAA;AAQd,IAAME,OAAO,CAClBC,QAAqC;EAAEf,OAAO;IAAEC,KAAK;IAAIC,KAAKE,MAAMY,OAAOC,OAAOC,QAAO,CAAA,EAAIhB;EAAI;AAAE,MAChGM,IAAIM,KAAKnB,OAAOoB,KAAAA;AASd,IAAMI,WAAW,OAAO,EAAEC,cAAc,GAAGL,MAAAA,MAAsB;AACtE,QAAMM,QAAQP,KAAKM,YAAAA;AACnB,SAAOE,oBAAoB;IAAE,GAAGP;IAAOK,cAAcC;EAAM,CAAA;AAC7D;",
|
|
6
|
+
"names": ["Schema", "SpaceSchema", "DataType", "TypenameAnnotationId", "EXPLORER_ACTION", "meta", "id", "GraphProps", "Struct", "name", "optional", "String", "typename", "annotations", "TypenameAnnotationId", "title", "CreateGraph", "TaggedClass", "input", "space", "SpaceSchema", "pipe", "extend", "output", "object", "DataType", "View", "Schema", "Filter", "Obj", "Query", "QueryAST", "Type", "LabelAnnotation", "ViewAnnotation", "createViewFromSpace", "Graph", "Struct", "name", "optional", "String", "query", "raw", "ast", "QueryAST", "Query", "pipe", "mutable", "Type", "Obj", "typename", "version", "LabelAnnotation", "set", "ViewAnnotation", "make", "props", "select", "Filter", "nothing", "makeView", "presentation", "graph", "createViewFromSpace"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __export = (target, all) => {
|
|
4
|
+
for (var name in all)
|
|
5
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
__export
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=chunk-HSLMI22Q.mjs.map
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
2
|
|
|
3
3
|
// src/meta.ts
|
|
4
|
-
var EXPLORER_PLUGIN = "dxos.org/plugin/explorer";
|
|
5
4
|
var meta = {
|
|
6
|
-
id:
|
|
5
|
+
id: "dxos.org/plugin/explorer",
|
|
7
6
|
name: "Explorer",
|
|
8
7
|
description: "Install this plugin to view a hypergraph of all objects inside of your Space.",
|
|
9
8
|
icon: "ph--graph--regular",
|
|
@@ -17,7 +16,6 @@ var meta = {
|
|
|
17
16
|
};
|
|
18
17
|
|
|
19
18
|
export {
|
|
20
|
-
EXPLORER_PLUGIN,
|
|
21
19
|
meta
|
|
22
20
|
};
|
|
23
|
-
//# sourceMappingURL=chunk-
|
|
21
|
+
//# sourceMappingURL=chunk-PX6LHR2N.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/meta.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const meta: PluginMeta = {\n id: 'dxos.org/plugin/explorer',\n name: 'Explorer',\n description: 'Install this plugin to view a hypergraph of all objects inside of your Space.',\n icon: 'ph--graph--regular',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-explorer',\n tags: ['labs'],\n screenshots: ['https://dxos.network/plugin-details-explorer-dark.png'],\n};\n"],
|
|
5
|
+
"mappings": ";;;AAMO,IAAMA,OAAmB;EAC9BC,IAAI;EACJC,MAAM;EACNC,aAAa;EACbC,MAAM;EACNC,QAAQ;EACRC,MAAM;IAAC;;EACPC,aAAa;IAAC;;AAChB;",
|
|
6
|
+
"names": ["meta", "id", "name", "description", "icon", "source", "tags", "screenshots"]
|
|
7
|
+
}
|
|
@@ -10975,9 +10975,23 @@ var TidyTree = (s, data, options) => {
|
|
|
10975
10975
|
var TidyTree_default = TidyTree;
|
|
10976
10976
|
|
|
10977
10977
|
// src/components/Tree/types/tree.ts
|
|
10978
|
-
import
|
|
10978
|
+
import * as Schema from "effect/Schema";
|
|
10979
10979
|
import { Key, Obj, Type } from "@dxos/echo";
|
|
10980
10980
|
import { invariant } from "@dxos/invariant";
|
|
10981
|
+
function _define_property(obj, key, value) {
|
|
10982
|
+
if (key in obj) {
|
|
10983
|
+
Object.defineProperty(obj, key, {
|
|
10984
|
+
value,
|
|
10985
|
+
enumerable: true,
|
|
10986
|
+
configurable: true,
|
|
10987
|
+
writable: true
|
|
10988
|
+
});
|
|
10989
|
+
} else {
|
|
10990
|
+
obj[key] = value;
|
|
10991
|
+
}
|
|
10992
|
+
return obj;
|
|
10993
|
+
}
|
|
10994
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-explorer/src/components/Tree/types/tree.ts";
|
|
10981
10995
|
var TreeNodeType = Schema.Struct({
|
|
10982
10996
|
id: Key.ObjectId,
|
|
10983
10997
|
children: Schema.mutable(Schema.Array(Key.ObjectId)),
|
|
@@ -10997,6 +11011,244 @@ var TreeType = Schema.Struct({
|
|
|
10997
11011
|
typename: "dxos.org/type/Tree",
|
|
10998
11012
|
version: "0.1.0"
|
|
10999
11013
|
}));
|
|
11014
|
+
var Tree = class _Tree {
|
|
11015
|
+
get tree() {
|
|
11016
|
+
return this._tree;
|
|
11017
|
+
}
|
|
11018
|
+
// TODO(burdon): Make reactive.
|
|
11019
|
+
get size() {
|
|
11020
|
+
return Object.keys(this._tree.nodes).length;
|
|
11021
|
+
}
|
|
11022
|
+
get root() {
|
|
11023
|
+
return this.getNode(this._tree.root);
|
|
11024
|
+
}
|
|
11025
|
+
//
|
|
11026
|
+
// Traversal
|
|
11027
|
+
//
|
|
11028
|
+
/**
|
|
11029
|
+
* Recursively traverse the tree until the callback returns a value.
|
|
11030
|
+
*/
|
|
11031
|
+
tranverse(callback, root = this._tree.root, depth = 0) {
|
|
11032
|
+
const node = this._tree.nodes[root];
|
|
11033
|
+
const result = callback(node, depth);
|
|
11034
|
+
if (result !== void 0) {
|
|
11035
|
+
return result;
|
|
11036
|
+
}
|
|
11037
|
+
for (const childId of node.children) {
|
|
11038
|
+
const result2 = this.tranverse(callback, childId, depth + 1);
|
|
11039
|
+
if (result2 !== void 0) {
|
|
11040
|
+
return result2;
|
|
11041
|
+
}
|
|
11042
|
+
}
|
|
11043
|
+
}
|
|
11044
|
+
getNode(id) {
|
|
11045
|
+
const node = this._tree.nodes[id];
|
|
11046
|
+
invariant(node, void 0, {
|
|
11047
|
+
F: __dxlog_file,
|
|
11048
|
+
L: 98,
|
|
11049
|
+
S: this,
|
|
11050
|
+
A: [
|
|
11051
|
+
"node",
|
|
11052
|
+
""
|
|
11053
|
+
]
|
|
11054
|
+
});
|
|
11055
|
+
return node;
|
|
11056
|
+
}
|
|
11057
|
+
/**
|
|
11058
|
+
* Get the children of a node.
|
|
11059
|
+
*/
|
|
11060
|
+
getChildNodes(node) {
|
|
11061
|
+
return node.children.map((id) => this.getNode(id));
|
|
11062
|
+
}
|
|
11063
|
+
/**
|
|
11064
|
+
* Get the parent of a node.
|
|
11065
|
+
*/
|
|
11066
|
+
getParent(node) {
|
|
11067
|
+
const parent = this.tranverse((n) => {
|
|
11068
|
+
if (n.children.includes(node.id)) {
|
|
11069
|
+
return n;
|
|
11070
|
+
}
|
|
11071
|
+
});
|
|
11072
|
+
return parent ?? null;
|
|
11073
|
+
}
|
|
11074
|
+
/**
|
|
11075
|
+
* Get the next node in the tree.
|
|
11076
|
+
*/
|
|
11077
|
+
getNext(node, hierarchical = true) {
|
|
11078
|
+
if (hierarchical && node.children.length) {
|
|
11079
|
+
return this.getChildNodes(node)[0];
|
|
11080
|
+
} else {
|
|
11081
|
+
const parent = this.getParent(node);
|
|
11082
|
+
if (parent) {
|
|
11083
|
+
const idx = this.getChildNodes(parent).findIndex(({ id }) => id === node.id);
|
|
11084
|
+
if (idx < parent.children.length - 1) {
|
|
11085
|
+
return this.getNode(parent.children[idx + 1]);
|
|
11086
|
+
} else {
|
|
11087
|
+
return this.getNext(parent, false);
|
|
11088
|
+
}
|
|
11089
|
+
}
|
|
11090
|
+
}
|
|
11091
|
+
}
|
|
11092
|
+
/**
|
|
11093
|
+
* Get the previous node in the tree.
|
|
11094
|
+
*/
|
|
11095
|
+
getPrevious(node, hierarchical = true) {
|
|
11096
|
+
const parent = this.getParent(node);
|
|
11097
|
+
const idx = this.getChildNodes(parent).findIndex(({ id }) => id === node.id);
|
|
11098
|
+
if (idx === 0) {
|
|
11099
|
+
if (hierarchical) {
|
|
11100
|
+
return parent;
|
|
11101
|
+
}
|
|
11102
|
+
} else {
|
|
11103
|
+
const previous = this.getNode(parent.children[idx - 1]);
|
|
11104
|
+
if (hierarchical && previous.children.length) {
|
|
11105
|
+
return this.getLastDescendent(previous);
|
|
11106
|
+
}
|
|
11107
|
+
return previous;
|
|
11108
|
+
}
|
|
11109
|
+
}
|
|
11110
|
+
/**
|
|
11111
|
+
* Get the last descendent of a node.
|
|
11112
|
+
*/
|
|
11113
|
+
getLastDescendent(node) {
|
|
11114
|
+
const children = this.getChildNodes(node);
|
|
11115
|
+
const last = children.length ? children[children.length - 1] : void 0;
|
|
11116
|
+
if (last) {
|
|
11117
|
+
return this.getLastDescendent(last);
|
|
11118
|
+
}
|
|
11119
|
+
return node;
|
|
11120
|
+
}
|
|
11121
|
+
//
|
|
11122
|
+
// Mutations
|
|
11123
|
+
//
|
|
11124
|
+
/**
|
|
11125
|
+
* Clear tree.
|
|
11126
|
+
*/
|
|
11127
|
+
clear() {
|
|
11128
|
+
const root = this._tree.nodes[this._tree.root];
|
|
11129
|
+
root.children.length = 0;
|
|
11130
|
+
this._tree.nodes = {
|
|
11131
|
+
[root.id]: root
|
|
11132
|
+
};
|
|
11133
|
+
}
|
|
11134
|
+
/**
|
|
11135
|
+
* Add node.
|
|
11136
|
+
*/
|
|
11137
|
+
addNode(parent, node, index) {
|
|
11138
|
+
if (!node) {
|
|
11139
|
+
const id = Key.ObjectId.random();
|
|
11140
|
+
node = {
|
|
11141
|
+
id,
|
|
11142
|
+
children: [],
|
|
11143
|
+
data: {
|
|
11144
|
+
text: ""
|
|
11145
|
+
}
|
|
11146
|
+
};
|
|
11147
|
+
}
|
|
11148
|
+
this._tree.nodes[node.id] = node;
|
|
11149
|
+
parent.children.splice(index ?? parent.children.length, 0, node.id);
|
|
11150
|
+
return node;
|
|
11151
|
+
}
|
|
11152
|
+
/**
|
|
11153
|
+
* Delete node.
|
|
11154
|
+
*/
|
|
11155
|
+
deleteNode(parent, id) {
|
|
11156
|
+
const node = this._tree.nodes[id];
|
|
11157
|
+
if (!node) {
|
|
11158
|
+
return void 0;
|
|
11159
|
+
}
|
|
11160
|
+
delete this._tree.nodes[node.id];
|
|
11161
|
+
const idx = parent.children.findIndex((child) => child === id);
|
|
11162
|
+
if (idx !== -1) {
|
|
11163
|
+
parent.children.splice(idx, 1);
|
|
11164
|
+
}
|
|
11165
|
+
return node;
|
|
11166
|
+
}
|
|
11167
|
+
/**
|
|
11168
|
+
* Move child node.
|
|
11169
|
+
*/
|
|
11170
|
+
moveNode(node, from, to) {
|
|
11171
|
+
invariant(from >= 0 && from < node.children.length, void 0, {
|
|
11172
|
+
F: __dxlog_file,
|
|
11173
|
+
L: 228,
|
|
11174
|
+
S: this,
|
|
11175
|
+
A: [
|
|
11176
|
+
"from >= 0 && from < node.children.length",
|
|
11177
|
+
""
|
|
11178
|
+
]
|
|
11179
|
+
});
|
|
11180
|
+
invariant(to >= 0 && to < node.children.length, void 0, {
|
|
11181
|
+
F: __dxlog_file,
|
|
11182
|
+
L: 229,
|
|
11183
|
+
S: this,
|
|
11184
|
+
A: [
|
|
11185
|
+
"to >= 0 && to < node.children.length",
|
|
11186
|
+
""
|
|
11187
|
+
]
|
|
11188
|
+
});
|
|
11189
|
+
if (from === to) {
|
|
11190
|
+
return null;
|
|
11191
|
+
}
|
|
11192
|
+
const child = node.children[from];
|
|
11193
|
+
node.children.splice(from, 1);
|
|
11194
|
+
node.children.splice(to, 0, child);
|
|
11195
|
+
return this.getNode(child);
|
|
11196
|
+
}
|
|
11197
|
+
/**
|
|
11198
|
+
* Indent node.
|
|
11199
|
+
*/
|
|
11200
|
+
indentNode(node) {
|
|
11201
|
+
const parent = this.getParent(node);
|
|
11202
|
+
if (!parent) {
|
|
11203
|
+
return;
|
|
11204
|
+
}
|
|
11205
|
+
const idx = parent.children.findIndex((child) => child === node.id);
|
|
11206
|
+
if (idx < 1 || idx >= parent.children.length) {
|
|
11207
|
+
return;
|
|
11208
|
+
}
|
|
11209
|
+
const previous = this.getNode(parent.children[idx - 1]);
|
|
11210
|
+
parent.children.splice(idx, 1);
|
|
11211
|
+
previous.children.push(node.id);
|
|
11212
|
+
}
|
|
11213
|
+
/**
|
|
11214
|
+
* Unindent node.
|
|
11215
|
+
*/
|
|
11216
|
+
unindentNode(node) {
|
|
11217
|
+
const parent = this.getParent(node);
|
|
11218
|
+
if (!parent) {
|
|
11219
|
+
return;
|
|
11220
|
+
}
|
|
11221
|
+
const ancestor = this.getParent(parent);
|
|
11222
|
+
if (!ancestor) {
|
|
11223
|
+
return;
|
|
11224
|
+
}
|
|
11225
|
+
const nodeIdx = parent.children.findIndex((id) => id === node.id);
|
|
11226
|
+
const [_, ...rest] = parent.children.splice(nodeIdx, parent.children.length - nodeIdx);
|
|
11227
|
+
parent.children.splice(nodeIdx, parent.children.length - nodeIdx);
|
|
11228
|
+
const parentIdx = this.getChildNodes(ancestor).findIndex((n) => n.id === parent.id);
|
|
11229
|
+
ancestor.children.splice(parentIdx + 1, 0, node.id);
|
|
11230
|
+
node.children.push(...rest);
|
|
11231
|
+
}
|
|
11232
|
+
constructor(tree3) {
|
|
11233
|
+
_define_property(this, "_tree", void 0);
|
|
11234
|
+
this._tree = tree3 ?? _Tree.create();
|
|
11235
|
+
}
|
|
11236
|
+
};
|
|
11237
|
+
_define_property(Tree, "create", () => {
|
|
11238
|
+
const id = Key.ObjectId.random();
|
|
11239
|
+
return Obj.make(TreeType, {
|
|
11240
|
+
root: id,
|
|
11241
|
+
nodes: {
|
|
11242
|
+
[id]: {
|
|
11243
|
+
id,
|
|
11244
|
+
children: [],
|
|
11245
|
+
data: {
|
|
11246
|
+
text: ""
|
|
11247
|
+
}
|
|
11248
|
+
}
|
|
11249
|
+
}
|
|
11250
|
+
});
|
|
11251
|
+
});
|
|
11000
11252
|
|
|
11001
11253
|
// src/components/Tree/types/types.ts
|
|
11002
11254
|
var mapGraphToTreeData = (model, maxDepth = 8) => {
|
|
@@ -11024,7 +11276,7 @@ var renderers = /* @__PURE__ */ new Map([
|
|
|
11024
11276
|
HierarchicalEdgeBundling_default
|
|
11025
11277
|
]
|
|
11026
11278
|
]);
|
|
11027
|
-
var
|
|
11279
|
+
var Tree2 = ({ space, selected, variant = "tidy", onNodeClick }) => {
|
|
11028
11280
|
var _effect = _useSignals3();
|
|
11029
11281
|
try {
|
|
11030
11282
|
const [model] = useAsyncState(async () => space ? new SpaceGraphModel().open(space) : void 0, [
|
|
@@ -11042,7 +11294,7 @@ var Tree = ({ space, selected, variant = "tidy", onNodeClick }) => {
|
|
|
11042
11294
|
]);
|
|
11043
11295
|
const context = useRef(null);
|
|
11044
11296
|
useEffect3(() => {
|
|
11045
|
-
if (context.current) {
|
|
11297
|
+
if (context.current?.size) {
|
|
11046
11298
|
const { width, height } = context.current.size;
|
|
11047
11299
|
const size = Math.min(width, height);
|
|
11048
11300
|
const radius = size * 0.4;
|
|
@@ -11079,13 +11331,13 @@ var Tree = ({ space, selected, variant = "tidy", onNodeClick }) => {
|
|
|
11079
11331
|
|
|
11080
11332
|
// src/components/index.ts
|
|
11081
11333
|
import { lazy } from "react";
|
|
11082
|
-
var ExplorerContainer = lazy(() => import("./ExplorerContainer-
|
|
11334
|
+
var ExplorerContainer = lazy(() => import("./ExplorerContainer-FRTDXZI5.mjs"));
|
|
11083
11335
|
|
|
11084
11336
|
export {
|
|
11085
11337
|
Chart,
|
|
11086
11338
|
Globe,
|
|
11087
11339
|
defaultTreeLayoutSlots,
|
|
11088
|
-
Tree,
|
|
11340
|
+
Tree2 as Tree,
|
|
11089
11341
|
ExplorerContainer
|
|
11090
11342
|
};
|
|
11091
|
-
//# sourceMappingURL=chunk-
|
|
11343
|
+
//# sourceMappingURL=chunk-ZCV4U7LT.mjs.map
|