@dxos/plugin-explorer 0.8.2-main.fbd8ed0 → 0.8.2-staging.4d6ad0f
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-BBZ54DJS.mjs +37 -0
- package/dist/lib/browser/ExplorerContainer-BBZ54DJS.mjs.map +7 -0
- package/dist/lib/browser/{chunk-JL7ZGOFE.mjs → chunk-73GQ46YO.mjs} +415 -155
- package/dist/lib/{node-esm/chunk-MUHCE377.mjs.map → browser/chunk-73GQ46YO.mjs.map} +4 -4
- package/dist/lib/browser/{chunk-HKQSZX7S.mjs → chunk-73YTQHOT.mjs} +3 -3
- package/dist/lib/browser/{chunk-HKQSZX7S.mjs.map → chunk-73YTQHOT.mjs.map} +1 -1
- package/dist/lib/browser/chunk-M2BGAY6H.mjs +177 -0
- package/dist/lib/browser/chunk-M2BGAY6H.mjs.map +7 -0
- package/dist/lib/browser/{chunk-Z2SDLMQM.mjs → chunk-OBAFAA5V.mjs} +3 -3
- package/dist/lib/browser/{chunk-Z2SDLMQM.mjs.map → chunk-OBAFAA5V.mjs.map} +1 -1
- package/dist/lib/browser/chunk-SLB2F5AO.mjs +30 -0
- package/dist/lib/browser/chunk-SLB2F5AO.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +15 -11
- package/dist/lib/browser/index.mjs.map +1 -1
- package/dist/lib/browser/{intent-resolver-7JF4DU2C.mjs → intent-resolver-FJDVBDE3.mjs} +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/meta.mjs +1 -1
- package/dist/lib/browser/{react-surface-JLE6GLG6.mjs → react-surface-H3YDMXAQ.mjs} +5 -5
- package/dist/lib/browser/types/index.mjs +2 -2
- package/dist/lib/node/{ExplorerContainer-4RMWCWRX.cjs → ExplorerContainer-MVP2AM7R.cjs} +24 -16
- package/dist/lib/node/ExplorerContainer-MVP2AM7R.cjs.map +7 -0
- package/dist/lib/node/chunk-4T4LCT5R.cjs +52 -0
- package/dist/lib/node/chunk-4T4LCT5R.cjs.map +7 -0
- package/dist/lib/node/{chunk-R4TOGRPE.cjs → chunk-72H5HBTK.cjs} +414 -153
- package/dist/lib/node/{chunk-R4TOGRPE.cjs.map → chunk-72H5HBTK.cjs.map} +4 -4
- package/dist/lib/node/{chunk-VB3QE6XY.cjs → chunk-BCDVG2CH.cjs} +6 -6
- package/dist/lib/node/{chunk-VB3QE6XY.cjs.map → chunk-BCDVG2CH.cjs.map} +1 -1
- package/dist/lib/node/{chunk-6R5P3UVS.cjs → chunk-MLRYW4WQ.cjs} +7 -7
- package/dist/lib/node/{chunk-6R5P3UVS.cjs.map → chunk-MLRYW4WQ.cjs.map} +1 -1
- package/dist/lib/node/chunk-NELWWGBU.cjs +204 -0
- package/dist/lib/node/chunk-NELWWGBU.cjs.map +7 -0
- package/dist/lib/node/index.cjs +34 -31
- package/dist/lib/node/index.cjs.map +1 -1
- package/dist/lib/node/{intent-resolver-VDAHQEE7.cjs → intent-resolver-DRT67ZU4.cjs} +8 -8
- package/dist/lib/node/meta.cjs +3 -3
- package/dist/lib/node/meta.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/{react-surface-F66QYWDR.cjs → react-surface-6ESLSM33.cjs} +11 -11
- package/dist/lib/node/types/index.cjs +4 -4
- package/dist/lib/node/types/index.cjs.map +1 -1
- package/dist/lib/node-esm/ExplorerContainer-APGUQI4M.mjs +38 -0
- package/dist/lib/node-esm/ExplorerContainer-APGUQI4M.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-MUHCE377.mjs → chunk-34X2VFQN.mjs} +415 -154
- package/dist/lib/{browser/chunk-JL7ZGOFE.mjs.map → node-esm/chunk-34X2VFQN.mjs.map} +4 -4
- package/dist/lib/node-esm/{chunk-PUFSCMN4.mjs → chunk-3CMBLK6W.mjs} +3 -3
- package/dist/lib/node-esm/{chunk-PUFSCMN4.mjs.map → chunk-3CMBLK6W.mjs.map} +1 -1
- package/dist/lib/node-esm/{chunk-QOJSLABX.mjs → chunk-N6VEANUZ.mjs} +3 -3
- package/dist/lib/node-esm/{chunk-QOJSLABX.mjs.map → chunk-N6VEANUZ.mjs.map} +1 -1
- package/dist/lib/node-esm/chunk-PVII2K2B.mjs +179 -0
- package/dist/lib/node-esm/chunk-PVII2K2B.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-VSORIAHH.mjs +32 -0
- package/dist/lib/node-esm/chunk-VSORIAHH.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +15 -11
- package/dist/lib/node-esm/index.mjs.map +1 -1
- package/dist/lib/node-esm/{intent-resolver-XWRVHP6H.mjs → intent-resolver-4RBV644N.mjs} +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/meta.mjs +1 -1
- package/dist/lib/node-esm/{react-surface-4ZT5BQP6.mjs → react-surface-ZEVL3FXG.mjs} +5 -5
- package/dist/lib/node-esm/types/index.mjs +2 -2
- package/dist/types/src/components/ExplorerContainer.d.ts +4 -3
- package/dist/types/src/components/ExplorerContainer.d.ts.map +1 -1
- package/dist/types/src/components/Graph/D3ForceGraph.d.ts +14 -0
- package/dist/types/src/components/Graph/D3ForceGraph.d.ts.map +1 -0
- package/dist/types/src/components/Graph/D3ForceGraph.stories.d.ts +6 -0
- package/dist/types/src/components/Graph/D3ForceGraph.stories.d.ts.map +1 -0
- package/dist/types/src/components/Graph/ForceGraph.d.ts +8 -0
- package/dist/types/src/components/Graph/ForceGraph.d.ts.map +1 -0
- package/dist/types/src/components/Graph/{Graph.stories.d.ts → ForceGraph.stories.d.ts} +1 -1
- package/dist/types/src/components/Graph/ForceGraph.stories.d.ts.map +1 -0
- package/dist/types/src/components/Graph/adapter.d.ts +21 -0
- package/dist/types/src/components/Graph/adapter.d.ts.map +1 -0
- package/dist/types/src/components/Graph/index.d.ts +2 -2
- package/dist/types/src/components/Graph/index.d.ts.map +1 -1
- package/dist/types/src/components/Graph/testing.d.ts +14 -0
- package/dist/types/src/components/Graph/testing.d.ts.map +1 -0
- package/dist/types/src/components/Tree/Tree.d.ts.map +1 -1
- package/dist/types/src/components/Tree/testing/generator.d.ts +8 -0
- package/dist/types/src/components/Tree/testing/generator.d.ts.map +1 -0
- package/dist/types/src/components/Tree/testing/index.d.ts +2 -0
- package/dist/types/src/components/Tree/testing/index.d.ts.map +1 -0
- package/dist/types/src/components/Tree/types/index.d.ts +3 -0
- package/dist/types/src/components/Tree/types/index.d.ts.map +1 -0
- package/dist/types/src/components/Tree/types/tree.d.ts +83 -0
- package/dist/types/src/components/Tree/types/tree.d.ts.map +1 -0
- package/dist/types/src/components/Tree/types/tree.test.d.ts +2 -0
- package/dist/types/src/components/Tree/types/tree.test.d.ts.map +1 -0
- package/dist/types/src/components/Tree/types/types.d.ts +8 -0
- package/dist/types/src/components/Tree/types/types.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +2 -2
- package/dist/types/src/hooks/index.d.ts +2 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -0
- package/dist/types/src/hooks/useGraphModel.d.ts +4 -0
- package/dist/types/src/hooks/useGraphModel.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +2 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/package.json +28 -28
- package/src/components/ExplorerContainer.tsx +11 -4
- package/src/components/Graph/D3ForceGraph.stories.tsx +64 -0
- package/src/components/Graph/D3ForceGraph.tsx +101 -0
- package/src/components/Graph/ForceGraph.stories.tsx +64 -0
- package/src/components/Graph/{Graph.tsx → ForceGraph.tsx} +19 -26
- package/src/components/Graph/adapter.ts +47 -0
- package/src/components/Graph/index.ts +2 -3
- package/src/components/Graph/testing.ts +57 -0
- package/src/components/Tree/Tree.stories.tsx +1 -1
- package/src/components/Tree/Tree.tsx +11 -18
- package/src/components/Tree/testing/generator.ts +46 -0
- package/src/components/Tree/testing/index.ts +5 -0
- package/src/components/Tree/types/index.ts +6 -0
- package/src/components/Tree/types/tree.test.ts +133 -0
- package/src/components/Tree/types/tree.ts +287 -0
- package/src/components/Tree/types/types.ts +41 -0
- package/src/hooks/index.ts +5 -0
- package/src/hooks/useGraphModel.ts +35 -0
- package/src/index.ts +2 -2
- package/src/meta.ts +2 -2
- package/dist/lib/browser/ExplorerContainer-6U4GS62Q.mjs +0 -27
- package/dist/lib/browser/ExplorerContainer-6U4GS62Q.mjs.map +0 -7
- package/dist/lib/browser/chunk-QRPUL5AH.mjs +0 -206
- package/dist/lib/browser/chunk-QRPUL5AH.mjs.map +0 -7
- package/dist/lib/node/ExplorerContainer-4RMWCWRX.cjs.map +0 -7
- package/dist/lib/node/chunk-4ZUNNUQD.cjs +0 -237
- package/dist/lib/node/chunk-4ZUNNUQD.cjs.map +0 -7
- package/dist/lib/node-esm/ExplorerContainer-3GOCCL7Q.mjs +0 -28
- package/dist/lib/node-esm/ExplorerContainer-3GOCCL7Q.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-BJZBPCC3.mjs +0 -208
- package/dist/lib/node-esm/chunk-BJZBPCC3.mjs.map +0 -7
- package/dist/types/src/components/Graph/Graph.d.ts +0 -8
- package/dist/types/src/components/Graph/Graph.d.ts.map +0 -1
- package/dist/types/src/components/Graph/Graph.stories.d.ts.map +0 -1
- package/dist/types/src/components/Graph/graph-model.d.ts +0 -39
- package/dist/types/src/components/Graph/graph-model.d.ts.map +0 -1
- package/dist/types/src/components/Tree/types.d.ts +0 -8
- package/dist/types/src/components/Tree/types.d.ts.map +0 -1
- package/src/components/Graph/Graph.stories.tsx +0 -62
- package/src/components/Graph/graph-model.ts +0 -194
- package/src/components/Tree/types.ts +0 -40
- /package/dist/lib/browser/{intent-resolver-7JF4DU2C.mjs.map → intent-resolver-FJDVBDE3.mjs.map} +0 -0
- /package/dist/lib/browser/{react-surface-JLE6GLG6.mjs.map → react-surface-H3YDMXAQ.mjs.map} +0 -0
- /package/dist/lib/node/{intent-resolver-VDAHQEE7.cjs.map → intent-resolver-DRT67ZU4.cjs.map} +0 -0
- /package/dist/lib/node/{react-surface-F66QYWDR.cjs.map → react-surface-6ESLSM33.cjs.map} +0 -0
- /package/dist/lib/node-esm/{intent-resolver-XWRVHP6H.mjs.map → intent-resolver-4RBV644N.mjs.map} +0 -0
- /package/dist/lib/node-esm/{react-surface-4ZT5BQP6.mjs.map → react-surface-ZEVL3FXG.mjs.map} +0 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useGraphModel
|
|
3
|
+
} from "./chunk-SLB2F5AO.mjs";
|
|
4
|
+
import {
|
|
5
|
+
ForceGraph
|
|
6
|
+
} from "./chunk-M2BGAY6H.mjs";
|
|
7
|
+
|
|
8
|
+
// packages/plugins/plugin-explorer/src/components/ExplorerContainer.tsx
|
|
9
|
+
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
10
|
+
import React from "react";
|
|
11
|
+
import { useGlobalSearch } from "@dxos/plugin-search";
|
|
12
|
+
import { getSpace } from "@dxos/react-client/echo";
|
|
13
|
+
import { StackItem } from "@dxos/react-ui-stack";
|
|
14
|
+
var ExplorerContainer = ({ role, view }) => {
|
|
15
|
+
var _effect = _useSignals();
|
|
16
|
+
try {
|
|
17
|
+
const space = getSpace(view);
|
|
18
|
+
const { match } = useGlobalSearch();
|
|
19
|
+
const model = useGraphModel(space);
|
|
20
|
+
if (!model || !space) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
return /* @__PURE__ */ React.createElement(StackItem.Content, {
|
|
24
|
+
size: role === "section" ? "square" : "intrinsic"
|
|
25
|
+
}, /* @__PURE__ */ React.createElement(ForceGraph, {
|
|
26
|
+
model,
|
|
27
|
+
match
|
|
28
|
+
}));
|
|
29
|
+
} finally {
|
|
30
|
+
_effect.f();
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
var ExplorerContainer_default = ExplorerContainer;
|
|
34
|
+
export {
|
|
35
|
+
ExplorerContainer_default as default
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=ExplorerContainer-BBZ54DJS.mjs.map
|
|
@@ -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 from 'react';\n\nimport { useGlobalSearch } from '@dxos/plugin-search';\nimport { getSpace } from '@dxos/react-client/echo';\nimport { StackItem } from '@dxos/react-ui-stack';\n\nimport { ForceGraph } from './Graph';\nimport { useGraphModel } from '../hooks';\nimport { type ViewType } from '../types';\n\ntype ExplorerContainerProps = {\n role: string;\n view: ViewType;\n};\n\nconst ExplorerContainer = ({ role, view }: ExplorerContainerProps) => {\n const space = getSpace(view);\n const { match } = useGlobalSearch();\n const model = useGraphModel(space);\n\n if (!model || !space) {\n return null;\n }\n\n return (\n <StackItem.Content size={role === 'section' ? 'square' : 'intrinsic'}>\n <ForceGraph model={model} match={match} />\n </StackItem.Content>\n );\n};\n\nexport default ExplorerContainer;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;AAIA,OAAOA,WAAW;AAElB,SAASC,uBAAuB;AAChC,SAASC,gBAAgB;AACzB,SAASC,iBAAiB;AAW1B,IAAMC,oBAAoB,CAAC,EAAEC,MAAMC,KAAI,MAA0B;;;AAC/D,UAAMC,QAAQC,SAASF,IAAAA;AACvB,UAAM,EAAEG,MAAK,IAAKC,gBAAAA;AAClB,UAAMC,QAAQC,cAAcL,KAAAA;AAE5B,QAAI,CAACI,SAAS,CAACJ,OAAO;AACpB,aAAO;IACT;AAEA,WACE,sBAAA,cAACM,UAAUC,SAAO;MAACC,MAAMV,SAAS,YAAY,WAAW;OACvD,sBAAA,cAACW,YAAAA;MAAWL;MAAcF;;;;;AAGhC;AAEA,IAAA,4BAAeL;",
|
|
6
|
+
"names": ["React", "useGlobalSearch", "getSpace", "StackItem", "ExplorerContainer", "role", "view", "space", "getSpace", "match", "useGlobalSearch", "model", "useGraphModel", "StackItem", "Content", "size", "ForceGraph"]
|
|
7
|
+
}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
SpaceGraphModel
|
|
3
|
-
} from "./chunk-QRPUL5AH.mjs";
|
|
4
|
-
|
|
5
1
|
// packages/plugins/plugin-explorer/src/components/Chart/Chart.tsx
|
|
2
|
+
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
6
3
|
import * as Plot from "@observablehq/plot";
|
|
7
4
|
import React, { useEffect } from "react";
|
|
8
5
|
import { useResizeDetector } from "react-resize-detector";
|
|
@@ -20,43 +17,49 @@ var defaultOptions = {
|
|
|
20
17
|
fillOpacity: 0.2
|
|
21
18
|
};
|
|
22
19
|
var Chart = ({ items = [], accessor, options = defaultOptions }) => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
var _effect = _useSignals();
|
|
21
|
+
try {
|
|
22
|
+
const { ref: containerRef, width = 0, height = 0 } = useResizeDetector({
|
|
23
|
+
refreshRate: 200
|
|
24
|
+
});
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (!width || !height) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const plot3 = Plot.plot({
|
|
30
|
+
grid: true,
|
|
31
|
+
width,
|
|
32
|
+
height,
|
|
33
|
+
style: {
|
|
34
|
+
background: "transparent"
|
|
35
|
+
},
|
|
36
|
+
marks: [
|
|
37
|
+
Plot.frame(),
|
|
38
|
+
Plot.dot(items, {
|
|
39
|
+
x: createAdapter("x", accessor),
|
|
40
|
+
y: createAdapter("y", accessor),
|
|
41
|
+
...options
|
|
42
|
+
})
|
|
43
|
+
]
|
|
44
|
+
});
|
|
45
|
+
containerRef.current.append(plot3);
|
|
46
|
+
return () => plot3?.remove();
|
|
47
|
+
}, [
|
|
48
|
+
items,
|
|
32
49
|
width,
|
|
33
|
-
height
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
Plot.frame(),
|
|
39
|
-
Plot.dot(items, {
|
|
40
|
-
x: createAdapter("x", accessor),
|
|
41
|
-
y: createAdapter("y", accessor),
|
|
42
|
-
...options
|
|
43
|
-
})
|
|
44
|
-
]
|
|
50
|
+
height
|
|
51
|
+
]);
|
|
52
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
53
|
+
ref: containerRef,
|
|
54
|
+
className: "grow"
|
|
45
55
|
});
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
items,
|
|
50
|
-
width,
|
|
51
|
-
height
|
|
52
|
-
]);
|
|
53
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
54
|
-
ref: containerRef,
|
|
55
|
-
className: "grow"
|
|
56
|
-
});
|
|
56
|
+
} finally {
|
|
57
|
+
_effect.f();
|
|
58
|
+
}
|
|
57
59
|
};
|
|
58
60
|
|
|
59
61
|
// packages/plugins/plugin-explorer/src/components/Globe/Globe.tsx
|
|
62
|
+
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
60
63
|
import * as Plot2 from "@observablehq/plot";
|
|
61
64
|
import React2, { useEffect as useEffect2 } from "react";
|
|
62
65
|
import { useResizeDetector as useResizeDetector2 } from "react-resize-detector";
|
|
@@ -10770,65 +10773,71 @@ var defaultOptions2 = {
|
|
|
10770
10773
|
fill: "#003300"
|
|
10771
10774
|
};
|
|
10772
10775
|
var Globe = ({ items = [], accessor, projection = "orthographic", options = defaultOptions2 }) => {
|
|
10773
|
-
|
|
10774
|
-
|
|
10775
|
-
|
|
10776
|
-
|
|
10777
|
-
|
|
10778
|
-
|
|
10779
|
-
|
|
10780
|
-
|
|
10781
|
-
|
|
10782
|
-
|
|
10783
|
-
|
|
10784
|
-
|
|
10785
|
-
|
|
10786
|
-
|
|
10787
|
-
|
|
10776
|
+
var _effect = _useSignals2();
|
|
10777
|
+
try {
|
|
10778
|
+
const { ref: containerRef, width = 0, height = 0 } = useResizeDetector2({
|
|
10779
|
+
refreshRate: 200
|
|
10780
|
+
});
|
|
10781
|
+
const land = topojson.feature(countries_110m_default, countries_110m_default.objects.land);
|
|
10782
|
+
useEffect2(() => {
|
|
10783
|
+
if (!width || !height) {
|
|
10784
|
+
return;
|
|
10785
|
+
}
|
|
10786
|
+
const plot3 = Plot2.plot({
|
|
10787
|
+
// https://observablehq.com/plot/features/projections
|
|
10788
|
+
projection: {
|
|
10789
|
+
type: projection,
|
|
10790
|
+
rotate: [
|
|
10791
|
+
-100,
|
|
10792
|
+
-20
|
|
10793
|
+
]
|
|
10794
|
+
},
|
|
10795
|
+
// projection: { type: 'equirectangular', rotate: [-140, -30] },
|
|
10796
|
+
width,
|
|
10797
|
+
height,
|
|
10798
|
+
style: {
|
|
10799
|
+
background: "transparent"
|
|
10800
|
+
},
|
|
10801
|
+
// TODO(burdon): Create simple wrapper for Plot with good defaults.
|
|
10802
|
+
marks: [
|
|
10803
|
+
Plot2.sphere({
|
|
10804
|
+
fill: "lightblue",
|
|
10805
|
+
fillOpacity: 0.5
|
|
10806
|
+
}),
|
|
10807
|
+
Plot2.geo(land, {
|
|
10808
|
+
fill: "darkgreen",
|
|
10809
|
+
fillOpacity: 0.5
|
|
10810
|
+
}),
|
|
10811
|
+
Plot2.graticule(),
|
|
10812
|
+
Plot2.dot(items, {
|
|
10813
|
+
x: createAdapter("lat", accessor),
|
|
10814
|
+
y: createAdapter("lng", accessor),
|
|
10815
|
+
...options
|
|
10816
|
+
})
|
|
10788
10817
|
]
|
|
10789
|
-
}
|
|
10790
|
-
|
|
10818
|
+
});
|
|
10819
|
+
containerRef.current.append(plot3);
|
|
10820
|
+
return () => plot3?.remove();
|
|
10821
|
+
}, [
|
|
10822
|
+
items,
|
|
10791
10823
|
width,
|
|
10792
|
-
height
|
|
10793
|
-
|
|
10794
|
-
|
|
10795
|
-
|
|
10796
|
-
|
|
10797
|
-
marks: [
|
|
10798
|
-
Plot2.sphere({
|
|
10799
|
-
fill: "lightblue",
|
|
10800
|
-
fillOpacity: 0.5
|
|
10801
|
-
}),
|
|
10802
|
-
Plot2.geo(land, {
|
|
10803
|
-
fill: "darkgreen",
|
|
10804
|
-
fillOpacity: 0.5
|
|
10805
|
-
}),
|
|
10806
|
-
Plot2.graticule(),
|
|
10807
|
-
Plot2.dot(items, {
|
|
10808
|
-
x: createAdapter("lat", accessor),
|
|
10809
|
-
y: createAdapter("lng", accessor),
|
|
10810
|
-
...options
|
|
10811
|
-
})
|
|
10812
|
-
]
|
|
10824
|
+
height
|
|
10825
|
+
]);
|
|
10826
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
10827
|
+
ref: containerRef,
|
|
10828
|
+
className: "grow p-4"
|
|
10813
10829
|
});
|
|
10814
|
-
|
|
10815
|
-
|
|
10816
|
-
}
|
|
10817
|
-
items,
|
|
10818
|
-
width,
|
|
10819
|
-
height
|
|
10820
|
-
]);
|
|
10821
|
-
return /* @__PURE__ */ React2.createElement("div", {
|
|
10822
|
-
ref: containerRef,
|
|
10823
|
-
className: "grow p-4"
|
|
10824
|
-
});
|
|
10830
|
+
} finally {
|
|
10831
|
+
_effect.f();
|
|
10832
|
+
}
|
|
10825
10833
|
};
|
|
10826
10834
|
|
|
10827
10835
|
// packages/plugins/plugin-explorer/src/components/Tree/Tree.tsx
|
|
10828
|
-
import
|
|
10829
|
-
import {
|
|
10830
|
-
import { createSvgContext, SVG, SVGRoot } from "@dxos/gem-core";
|
|
10836
|
+
import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
|
|
10837
|
+
import React3, { useEffect as useEffect3, useRef, useState } from "react";
|
|
10831
10838
|
import { useAsyncState } from "@dxos/react-ui";
|
|
10839
|
+
import { SVG } from "@dxos/react-ui-graph";
|
|
10840
|
+
import { SpaceGraphModel } from "@dxos/schema";
|
|
10832
10841
|
|
|
10833
10842
|
// packages/plugins/plugin-explorer/src/components/Tree/layout/HierarchicalEdgeBundling.ts
|
|
10834
10843
|
import { cluster, curveBundle, hierarchy, lineRadial, select } from "d3";
|
|
@@ -10963,26 +10972,275 @@ var TidyTree = (s, data, options) => {
|
|
|
10963
10972
|
};
|
|
10964
10973
|
var TidyTree_default = TidyTree;
|
|
10965
10974
|
|
|
10966
|
-
// packages/plugins/plugin-explorer/src/components/Tree/types.ts
|
|
10967
|
-
|
|
10968
|
-
|
|
10969
|
-
|
|
10970
|
-
|
|
10971
|
-
|
|
10975
|
+
// packages/plugins/plugin-explorer/src/components/Tree/types/tree.ts
|
|
10976
|
+
import { Schema } from "effect";
|
|
10977
|
+
import { Type } from "@dxos/echo";
|
|
10978
|
+
import { ObjectId, Ref, Expando } from "@dxos/echo-schema";
|
|
10979
|
+
import { invariant } from "@dxos/invariant";
|
|
10980
|
+
import { live } from "@dxos/live-object";
|
|
10981
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-explorer/src/components/Tree/types/tree.ts";
|
|
10982
|
+
var TreeNodeType = Schema.Struct({
|
|
10983
|
+
id: ObjectId,
|
|
10984
|
+
children: Schema.mutable(Schema.Array(ObjectId)),
|
|
10985
|
+
data: Schema.mutable(Schema.Record({
|
|
10986
|
+
key: Schema.String,
|
|
10987
|
+
value: Schema.Any
|
|
10988
|
+
})),
|
|
10989
|
+
ref: Schema.optional(Ref(Expando))
|
|
10990
|
+
}).pipe(Schema.mutable);
|
|
10991
|
+
var TreeType = Schema.Struct({
|
|
10992
|
+
root: ObjectId,
|
|
10993
|
+
nodes: Schema.mutable(Schema.Record({
|
|
10994
|
+
key: ObjectId,
|
|
10995
|
+
value: TreeNodeType
|
|
10996
|
+
}))
|
|
10997
|
+
}).pipe(Type.Obj({
|
|
10998
|
+
typename: "dxos.org/type/Tree",
|
|
10999
|
+
version: "0.1.0"
|
|
11000
|
+
}));
|
|
11001
|
+
var Tree = class _Tree {
|
|
11002
|
+
static {
|
|
11003
|
+
this.create = () => {
|
|
11004
|
+
const id = ObjectId.random();
|
|
11005
|
+
return live(TreeType, {
|
|
11006
|
+
root: id,
|
|
11007
|
+
nodes: {
|
|
11008
|
+
[id]: {
|
|
11009
|
+
id,
|
|
11010
|
+
children: [],
|
|
11011
|
+
data: {
|
|
11012
|
+
text: ""
|
|
11013
|
+
}
|
|
11014
|
+
}
|
|
11015
|
+
}
|
|
11016
|
+
});
|
|
10972
11017
|
};
|
|
10973
|
-
|
|
10974
|
-
|
|
10975
|
-
|
|
11018
|
+
}
|
|
11019
|
+
constructor(tree3) {
|
|
11020
|
+
this._tree = tree3 ?? _Tree.create();
|
|
11021
|
+
}
|
|
11022
|
+
get tree() {
|
|
11023
|
+
return this._tree;
|
|
11024
|
+
}
|
|
11025
|
+
// TODO(burdon): Make reactive.
|
|
11026
|
+
get size() {
|
|
11027
|
+
return Object.keys(this._tree.nodes).length;
|
|
11028
|
+
}
|
|
11029
|
+
get root() {
|
|
11030
|
+
return this.getNode(this._tree.root);
|
|
11031
|
+
}
|
|
11032
|
+
//
|
|
11033
|
+
// Traversal
|
|
11034
|
+
//
|
|
11035
|
+
/**
|
|
11036
|
+
* Recursively traverse the tree until the callback returns a value.
|
|
11037
|
+
*/
|
|
11038
|
+
tranverse(callback, root = this._tree.root, depth = 0) {
|
|
11039
|
+
const node = this._tree.nodes[root];
|
|
11040
|
+
const result = callback(node, depth);
|
|
11041
|
+
if (result !== void 0) {
|
|
11042
|
+
return result;
|
|
10976
11043
|
}
|
|
10977
|
-
|
|
10978
|
-
|
|
10979
|
-
|
|
10980
|
-
|
|
10981
|
-
|
|
10982
|
-
|
|
10983
|
-
|
|
11044
|
+
for (const childId of node.children) {
|
|
11045
|
+
const result2 = this.tranverse(callback, childId, depth + 1);
|
|
11046
|
+
if (result2 !== void 0) {
|
|
11047
|
+
return result2;
|
|
11048
|
+
}
|
|
11049
|
+
}
|
|
11050
|
+
}
|
|
11051
|
+
getNode(id) {
|
|
11052
|
+
const node = this._tree.nodes[id];
|
|
11053
|
+
invariant(node, void 0, {
|
|
11054
|
+
F: __dxlog_file,
|
|
11055
|
+
L: 100,
|
|
11056
|
+
S: this,
|
|
11057
|
+
A: [
|
|
11058
|
+
"node",
|
|
11059
|
+
""
|
|
11060
|
+
]
|
|
11061
|
+
});
|
|
11062
|
+
return node;
|
|
11063
|
+
}
|
|
11064
|
+
/**
|
|
11065
|
+
* Get the children of a node.
|
|
11066
|
+
*/
|
|
11067
|
+
getChildNodes(node) {
|
|
11068
|
+
return node.children.map((id) => this.getNode(id));
|
|
11069
|
+
}
|
|
11070
|
+
/**
|
|
11071
|
+
* Get the parent of a node.
|
|
11072
|
+
*/
|
|
11073
|
+
getParent(node) {
|
|
11074
|
+
const parent = this.tranverse((n) => {
|
|
11075
|
+
if (n.children.includes(node.id)) {
|
|
11076
|
+
return n;
|
|
11077
|
+
}
|
|
11078
|
+
});
|
|
11079
|
+
return parent ?? null;
|
|
11080
|
+
}
|
|
11081
|
+
/**
|
|
11082
|
+
* Get the next node in the tree.
|
|
11083
|
+
*/
|
|
11084
|
+
getNext(node, hierarchical = true) {
|
|
11085
|
+
if (hierarchical && node.children.length) {
|
|
11086
|
+
return this.getChildNodes(node)[0];
|
|
11087
|
+
} else {
|
|
11088
|
+
const parent = this.getParent(node);
|
|
11089
|
+
if (parent) {
|
|
11090
|
+
const idx = this.getChildNodes(parent).findIndex(({ id }) => id === node.id);
|
|
11091
|
+
if (idx < parent.children.length - 1) {
|
|
11092
|
+
return this.getNode(parent.children[idx + 1]);
|
|
11093
|
+
} else {
|
|
11094
|
+
return this.getNext(parent, false);
|
|
11095
|
+
}
|
|
11096
|
+
}
|
|
11097
|
+
}
|
|
11098
|
+
}
|
|
11099
|
+
/**
|
|
11100
|
+
* Get the previous node in the tree.
|
|
11101
|
+
*/
|
|
11102
|
+
getPrevious(node, hierarchical = true) {
|
|
11103
|
+
const parent = this.getParent(node);
|
|
11104
|
+
const idx = this.getChildNodes(parent).findIndex(({ id }) => id === node.id);
|
|
11105
|
+
if (idx === 0) {
|
|
11106
|
+
if (hierarchical) {
|
|
11107
|
+
return parent;
|
|
11108
|
+
}
|
|
11109
|
+
} else {
|
|
11110
|
+
const previous = this.getNode(parent.children[idx - 1]);
|
|
11111
|
+
if (hierarchical && previous.children.length) {
|
|
11112
|
+
return this.getLastDescendent(previous);
|
|
11113
|
+
}
|
|
11114
|
+
return previous;
|
|
11115
|
+
}
|
|
11116
|
+
}
|
|
11117
|
+
/**
|
|
11118
|
+
* Get the last descendent of a node.
|
|
11119
|
+
*/
|
|
11120
|
+
getLastDescendent(node) {
|
|
11121
|
+
const children = this.getChildNodes(node);
|
|
11122
|
+
const last = children.length ? children[children.length - 1] : void 0;
|
|
11123
|
+
if (last) {
|
|
11124
|
+
return this.getLastDescendent(last);
|
|
11125
|
+
}
|
|
11126
|
+
return node;
|
|
11127
|
+
}
|
|
11128
|
+
//
|
|
11129
|
+
// Mutations
|
|
11130
|
+
//
|
|
11131
|
+
/**
|
|
11132
|
+
* Clear tree.
|
|
11133
|
+
*/
|
|
11134
|
+
clear() {
|
|
11135
|
+
const root = this._tree.nodes[this._tree.root];
|
|
11136
|
+
root.children.length = 0;
|
|
11137
|
+
this._tree.nodes = {
|
|
11138
|
+
[root.id]: root
|
|
11139
|
+
};
|
|
11140
|
+
}
|
|
11141
|
+
/**
|
|
11142
|
+
* Add node.
|
|
11143
|
+
*/
|
|
11144
|
+
addNode(parent, node, index) {
|
|
11145
|
+
if (!node) {
|
|
11146
|
+
const id = ObjectId.random();
|
|
11147
|
+
node = {
|
|
11148
|
+
id,
|
|
11149
|
+
children: [],
|
|
11150
|
+
data: {
|
|
11151
|
+
text: ""
|
|
11152
|
+
}
|
|
11153
|
+
};
|
|
11154
|
+
}
|
|
11155
|
+
this._tree.nodes[node.id] = node;
|
|
11156
|
+
parent.children.splice(index ?? parent.children.length, 0, node.id);
|
|
11157
|
+
return node;
|
|
11158
|
+
}
|
|
11159
|
+
/**
|
|
11160
|
+
* Delete node.
|
|
11161
|
+
*/
|
|
11162
|
+
deleteNode(parent, id) {
|
|
11163
|
+
const node = this._tree.nodes[id];
|
|
11164
|
+
if (!node) {
|
|
11165
|
+
return void 0;
|
|
11166
|
+
}
|
|
11167
|
+
delete this._tree.nodes[node.id];
|
|
11168
|
+
const idx = parent.children.findIndex((child) => child === id);
|
|
11169
|
+
if (idx !== -1) {
|
|
11170
|
+
parent.children.splice(idx, 1);
|
|
11171
|
+
}
|
|
11172
|
+
return node;
|
|
11173
|
+
}
|
|
11174
|
+
/**
|
|
11175
|
+
* Move child node.
|
|
11176
|
+
*/
|
|
11177
|
+
moveNode(node, from, to) {
|
|
11178
|
+
invariant(from >= 0 && from < node.children.length, void 0, {
|
|
11179
|
+
F: __dxlog_file,
|
|
11180
|
+
L: 230,
|
|
11181
|
+
S: this,
|
|
11182
|
+
A: [
|
|
11183
|
+
"from >= 0 && from < node.children.length",
|
|
11184
|
+
""
|
|
11185
|
+
]
|
|
11186
|
+
});
|
|
11187
|
+
invariant(to >= 0 && to < node.children.length, void 0, {
|
|
11188
|
+
F: __dxlog_file,
|
|
11189
|
+
L: 231,
|
|
11190
|
+
S: this,
|
|
11191
|
+
A: [
|
|
11192
|
+
"to >= 0 && to < node.children.length",
|
|
11193
|
+
""
|
|
11194
|
+
]
|
|
11195
|
+
});
|
|
11196
|
+
if (from === to) {
|
|
11197
|
+
return null;
|
|
11198
|
+
}
|
|
11199
|
+
const child = node.children[from];
|
|
11200
|
+
node.children.splice(from, 1);
|
|
11201
|
+
node.children.splice(to, 0, child);
|
|
11202
|
+
return this.getNode(child);
|
|
11203
|
+
}
|
|
11204
|
+
/**
|
|
11205
|
+
* Indent node.
|
|
11206
|
+
*/
|
|
11207
|
+
indentNode(node) {
|
|
11208
|
+
const parent = this.getParent(node);
|
|
11209
|
+
if (!parent) {
|
|
11210
|
+
return;
|
|
11211
|
+
}
|
|
11212
|
+
const idx = parent.children.findIndex((child) => child === node.id);
|
|
11213
|
+
if (idx < 1 || idx >= parent.children.length) {
|
|
11214
|
+
return;
|
|
10984
11215
|
}
|
|
11216
|
+
const previous = this.getNode(parent.children[idx - 1]);
|
|
11217
|
+
parent.children.splice(idx, 1);
|
|
11218
|
+
previous.children.push(node.id);
|
|
10985
11219
|
}
|
|
11220
|
+
/**
|
|
11221
|
+
* Unindent node.
|
|
11222
|
+
*/
|
|
11223
|
+
unindentNode(node) {
|
|
11224
|
+
const parent = this.getParent(node);
|
|
11225
|
+
if (!parent) {
|
|
11226
|
+
return;
|
|
11227
|
+
}
|
|
11228
|
+
const ancestor = this.getParent(parent);
|
|
11229
|
+
if (!ancestor) {
|
|
11230
|
+
return;
|
|
11231
|
+
}
|
|
11232
|
+
const nodeIdx = parent.children.findIndex((id) => id === node.id);
|
|
11233
|
+
const [_, ...rest] = parent.children.splice(nodeIdx, parent.children.length - nodeIdx);
|
|
11234
|
+
parent.children.splice(nodeIdx, parent.children.length - nodeIdx);
|
|
11235
|
+
const parentIdx = this.getChildNodes(ancestor).findIndex((n) => n.id === parent.id);
|
|
11236
|
+
ancestor.children.splice(parentIdx + 1, 0, node.id);
|
|
11237
|
+
node.children.push(...rest);
|
|
11238
|
+
}
|
|
11239
|
+
};
|
|
11240
|
+
|
|
11241
|
+
// packages/plugins/plugin-explorer/src/components/Tree/types/types.ts
|
|
11242
|
+
var mapGraphToTreeData = (model, maxDepth = 8) => {
|
|
11243
|
+
let data;
|
|
10986
11244
|
return data;
|
|
10987
11245
|
};
|
|
10988
11246
|
|
|
@@ -11006,66 +11264,68 @@ var renderers = /* @__PURE__ */ new Map([
|
|
|
11006
11264
|
HierarchicalEdgeBundling_default
|
|
11007
11265
|
]
|
|
11008
11266
|
]);
|
|
11009
|
-
var
|
|
11010
|
-
|
|
11011
|
-
|
|
11012
|
-
|
|
11013
|
-
|
|
11014
|
-
|
|
11015
|
-
|
|
11016
|
-
|
|
11017
|
-
|
|
11018
|
-
|
|
11019
|
-
|
|
11020
|
-
|
|
11021
|
-
|
|
11022
|
-
|
|
11023
|
-
|
|
11024
|
-
|
|
11025
|
-
|
|
11026
|
-
|
|
11027
|
-
|
|
11028
|
-
|
|
11029
|
-
|
|
11030
|
-
|
|
11031
|
-
|
|
11032
|
-
|
|
11033
|
-
|
|
11034
|
-
|
|
11035
|
-
|
|
11036
|
-
|
|
11037
|
-
|
|
11038
|
-
|
|
11039
|
-
|
|
11040
|
-
|
|
11041
|
-
|
|
11042
|
-
|
|
11043
|
-
|
|
11267
|
+
var Tree2 = ({ space, selected, variant = "tidy", onNodeClick }) => {
|
|
11268
|
+
var _effect = _useSignals3();
|
|
11269
|
+
try {
|
|
11270
|
+
const [model] = useAsyncState(async () => space ? new SpaceGraphModel().open(space) : void 0, [
|
|
11271
|
+
space,
|
|
11272
|
+
selected
|
|
11273
|
+
]);
|
|
11274
|
+
const [tree3, setTree] = useState();
|
|
11275
|
+
useEffect3(() => {
|
|
11276
|
+
return model?.subscribe(() => {
|
|
11277
|
+
const tree4 = mapGraphToTreeData(model);
|
|
11278
|
+
setTree(tree4);
|
|
11279
|
+
}, true);
|
|
11280
|
+
}, [
|
|
11281
|
+
model
|
|
11282
|
+
]);
|
|
11283
|
+
const context = useRef(null);
|
|
11284
|
+
useEffect3(() => {
|
|
11285
|
+
if (context.current) {
|
|
11286
|
+
const { width, height } = context.current.size;
|
|
11287
|
+
const size = Math.min(width, height);
|
|
11288
|
+
const radius = size * 0.4;
|
|
11289
|
+
const options = {
|
|
11290
|
+
// TODO(burdon): Type.
|
|
11291
|
+
label: (d) => d.label ?? d.id,
|
|
11292
|
+
width,
|
|
11293
|
+
height,
|
|
11294
|
+
radius,
|
|
11295
|
+
marginLeft: (width - radius * 2) / 2,
|
|
11296
|
+
marginRight: (width - radius * 2) / 2,
|
|
11297
|
+
marginTop: (height - radius * 2) / 2,
|
|
11298
|
+
marginBottom: (height - radius * 2) / 2,
|
|
11299
|
+
slots: defaultTreeLayoutSlots
|
|
11300
|
+
};
|
|
11301
|
+
if (tree3) {
|
|
11302
|
+
const renderer = renderers.get(variant);
|
|
11303
|
+
renderer?.(context.current.svg, tree3, options);
|
|
11304
|
+
}
|
|
11044
11305
|
}
|
|
11045
|
-
}
|
|
11046
|
-
|
|
11047
|
-
|
|
11048
|
-
|
|
11049
|
-
|
|
11050
|
-
|
|
11051
|
-
|
|
11052
|
-
|
|
11053
|
-
|
|
11054
|
-
|
|
11055
|
-
|
|
11056
|
-
|
|
11057
|
-
}, /* @__PURE__ */ React3.createElement(SVG, null)));
|
|
11306
|
+
}, [
|
|
11307
|
+
context.current,
|
|
11308
|
+
tree3
|
|
11309
|
+
]);
|
|
11310
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
11311
|
+
onClick: () => onNodeClick?.()
|
|
11312
|
+
}, /* @__PURE__ */ React3.createElement(SVG.Root, {
|
|
11313
|
+
ref: context
|
|
11314
|
+
}));
|
|
11315
|
+
} finally {
|
|
11316
|
+
_effect.f();
|
|
11317
|
+
}
|
|
11058
11318
|
};
|
|
11059
11319
|
|
|
11060
11320
|
// packages/plugins/plugin-explorer/src/components/index.ts
|
|
11061
11321
|
import { lazy } from "react";
|
|
11062
|
-
var ExplorerContainer = lazy(() => import("./ExplorerContainer-
|
|
11322
|
+
var ExplorerContainer = lazy(() => import("./ExplorerContainer-BBZ54DJS.mjs"));
|
|
11063
11323
|
|
|
11064
11324
|
export {
|
|
11065
11325
|
Chart,
|
|
11066
11326
|
Globe,
|
|
11067
11327
|
defaultTreeLayoutSlots,
|
|
11068
|
-
Tree,
|
|
11328
|
+
Tree2 as Tree,
|
|
11069
11329
|
ExplorerContainer
|
|
11070
11330
|
};
|
|
11071
|
-
//# sourceMappingURL=chunk-
|
|
11331
|
+
//# sourceMappingURL=chunk-73GQ46YO.mjs.map
|