@dxos/plugin-explorer 0.8.3 → 0.8.4-main.1068cf700f
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-46BHUF6R.mjs +45 -0
- package/dist/lib/browser/ExplorerContainer-46BHUF6R.mjs.map +7 -0
- package/dist/lib/browser/chunk-HIFLWHXR.mjs +83 -0
- package/dist/lib/browser/chunk-HIFLWHXR.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-JRKQNHS6.mjs → chunk-JZSBQYJQ.mjs} +152 -405
- package/dist/lib/{node-esm/chunk-IUFYOE44.mjs.map → browser/chunk-JZSBQYJQ.mjs.map} +3 -3
- package/dist/lib/browser/chunk-KIXHZZ2C.mjs +35 -0
- package/dist/lib/browser/chunk-KIXHZZ2C.mjs.map +7 -0
- package/dist/lib/browser/chunk-MGBT2ZFU.mjs +177 -0
- package/dist/lib/browser/chunk-MGBT2ZFU.mjs.map +7 -0
- package/dist/lib/browser/chunk-YNQF4CPY.mjs +24 -0
- package/dist/lib/browser/chunk-YNQF4CPY.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +60 -70
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/meta.mjs +2 -3
- package/dist/lib/browser/react-surface-TPQAT5EI.mjs +36 -0
- package/dist/lib/browser/react-surface-TPQAT5EI.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +6 -6
- package/dist/lib/node-esm/ExplorerContainer-OZNG47QB.mjs +46 -0
- package/dist/lib/node-esm/ExplorerContainer-OZNG47QB.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-3OE6TBJI.mjs +84 -0
- package/dist/lib/node-esm/chunk-3OE6TBJI.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-VSORIAHH.mjs → chunk-ASRWO2N5.mjs} +12 -7
- package/dist/lib/node-esm/chunk-ASRWO2N5.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-3CMBLK6W.mjs → chunk-DK77RB6M.mjs} +9 -6
- package/dist/lib/node-esm/chunk-DK77RB6M.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-IUFYOE44.mjs → chunk-K5BYG7BW.mjs} +152 -405
- package/dist/lib/{browser/chunk-JRKQNHS6.mjs.map → node-esm/chunk-K5BYG7BW.mjs.map} +3 -3
- package/dist/lib/node-esm/chunk-YWJBDETV.mjs +179 -0
- package/dist/lib/node-esm/chunk-YWJBDETV.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +60 -70
- 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 -3
- package/dist/lib/node-esm/react-surface-CYHGJJDU.mjs +37 -0
- package/dist/lib/node-esm/react-surface-CYHGJJDU.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/Chart/Chart.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 +4 -6
- package/dist/types/src/components/ExplorerContainer.d.ts.map +1 -1
- package/dist/types/src/components/Globe/Globe.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/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 +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 +13 -16
- 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 +2 -4
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useGraphModel.d.ts +2 -2
- package/dist/types/src/hooks/useGraphModel.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -3
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +34 -22
- 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 +61 -44
- package/src/ExplorerPlugin.tsx +31 -53
- 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 +10 -8
- package/src/components/Chart/Chart.tsx +1 -1
- package/src/components/ExplorerContainer.tsx +30 -14
- package/src/components/Globe/Globe.stories.tsx +15 -13
- package/src/components/Globe/Globe.tsx +1 -1
- package/src/components/Graph/D3ForceGraph.stories.tsx +40 -21
- package/src/components/Graph/D3ForceGraph.tsx +6 -6
- package/src/components/Graph/ForceGraph.stories.tsx +40 -21
- package/src/components/Graph/ForceGraph.tsx +5 -5
- package/src/components/Graph/adapter.ts +14 -8
- package/src/components/Graph/testing.ts +13 -10
- package/src/components/Tree/Tree.stories.tsx +29 -22
- package/src/components/Tree/Tree.tsx +11 -6
- package/src/components/Tree/testing/generator.ts +4 -2
- package/src/components/Tree/types/tree.test.ts +8 -5
- package/src/components/Tree/types/tree.ts +40 -19
- package/src/components/Tree/types/types.ts +1 -1
- package/src/components/index.ts +3 -3
- package/src/hooks/useGraphModel.ts +9 -5
- package/src/meta.ts +9 -6
- package/src/translations.ts +12 -6
- package/src/types/ExplorerAction.ts +21 -0
- package/src/types/Graph.ts +62 -0
- package/src/types/index.ts +2 -2
- package/dist/lib/browser/ExplorerContainer-DXL34I3F.mjs +0 -37
- package/dist/lib/browser/ExplorerContainer-DXL34I3F.mjs.map +0 -7
- package/dist/lib/browser/chunk-73YTQHOT.mjs +0 -38
- package/dist/lib/browser/chunk-73YTQHOT.mjs.map +0 -7
- package/dist/lib/browser/chunk-OBAFAA5V.mjs +0 -21
- package/dist/lib/browser/chunk-OBAFAA5V.mjs.map +0 -7
- package/dist/lib/browser/chunk-SLB2F5AO.mjs +0 -30
- package/dist/lib/browser/chunk-SLB2F5AO.mjs.map +0 -7
- package/dist/lib/browser/chunk-Z5BGAHLD.mjs +0 -187
- package/dist/lib/browser/chunk-Z5BGAHLD.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-JZKYVFQJ.mjs +0 -24
- package/dist/lib/browser/intent-resolver-JZKYVFQJ.mjs.map +0 -7
- package/dist/lib/browser/react-surface-IAEP2GBT.mjs +0 -31
- package/dist/lib/browser/react-surface-IAEP2GBT.mjs.map +0 -7
- package/dist/lib/node/ExplorerContainer-VUXH55VV.cjs +0 -61
- package/dist/lib/node/ExplorerContainer-VUXH55VV.cjs.map +0 -7
- package/dist/lib/node/chunk-4T4LCT5R.cjs +0 -52
- package/dist/lib/node/chunk-4T4LCT5R.cjs.map +0 -7
- package/dist/lib/node/chunk-BCDVG2CH.cjs +0 -44
- package/dist/lib/node/chunk-BCDVG2CH.cjs.map +0 -7
- package/dist/lib/node/chunk-MLRYW4WQ.cjs +0 -56
- package/dist/lib/node/chunk-MLRYW4WQ.cjs.map +0 -7
- package/dist/lib/node/chunk-SVU4VMYX.cjs +0 -11339
- package/dist/lib/node/chunk-SVU4VMYX.cjs.map +0 -7
- package/dist/lib/node/chunk-TY543HPV.cjs +0 -214
- package/dist/lib/node/chunk-TY543HPV.cjs.map +0 -7
- package/dist/lib/node/index.cjs +0 -130
- package/dist/lib/node/index.cjs.map +0 -7
- package/dist/lib/node/intent-resolver-G2MFNIXA.cjs +0 -39
- package/dist/lib/node/intent-resolver-G2MFNIXA.cjs.map +0 -7
- package/dist/lib/node/meta.cjs +0 -31
- package/dist/lib/node/meta.cjs.map +0 -7
- package/dist/lib/node/meta.json +0 -1
- package/dist/lib/node/react-surface-UJD5RGRZ.cjs +0 -53
- package/dist/lib/node/react-surface-UJD5RGRZ.cjs.map +0 -7
- package/dist/lib/node/types/index.cjs +0 -32
- package/dist/lib/node/types/index.cjs.map +0 -7
- package/dist/lib/node-esm/ExplorerContainer-MFE7PXF4.mjs +0 -38
- package/dist/lib/node-esm/ExplorerContainer-MFE7PXF4.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-3CMBLK6W.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-AE7VHUJM.mjs +0 -189
- package/dist/lib/node-esm/chunk-AE7VHUJM.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-N6VEANUZ.mjs +0 -39
- package/dist/lib/node-esm/chunk-N6VEANUZ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-VSORIAHH.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-7G6ZKM6E.mjs +0 -25
- package/dist/lib/node-esm/intent-resolver-7G6ZKM6E.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-XBH3WZDL.mjs +0 -32
- package/dist/lib/node-esm/react-surface-XBH3WZDL.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/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/types/schema.ts +0 -16
- package/src/types/types.ts +0 -21
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
//
|
|
2
|
-
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
1
|
+
// src/components/Chart/Chart.tsx
|
|
3
2
|
import * as Plot from "@observablehq/plot";
|
|
4
3
|
import React, { useEffect } from "react";
|
|
5
4
|
import { useResizeDetector } from "react-resize-detector";
|
|
6
5
|
|
|
7
|
-
//
|
|
6
|
+
// src/components/plot.ts
|
|
8
7
|
var createAdapter = (prop, accessor) => accessor ? {
|
|
9
8
|
transform: (values) => values.map((value) => accessor(value)[prop])
|
|
10
9
|
} : prop;
|
|
11
10
|
|
|
12
|
-
//
|
|
11
|
+
// src/components/Chart/Chart.tsx
|
|
13
12
|
var defaultOptions = {
|
|
14
13
|
r: 4,
|
|
15
14
|
stroke: "gray",
|
|
@@ -17,55 +16,49 @@ var defaultOptions = {
|
|
|
17
16
|
fillOpacity: 0.2
|
|
18
17
|
};
|
|
19
18
|
var Chart = ({ items = [], accessor, options = defaultOptions }) => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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,
|
|
19
|
+
const { ref: containerRef, width = 0, height = 0 } = useResizeDetector({
|
|
20
|
+
refreshRate: 200
|
|
21
|
+
});
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (!width || !height) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const plot3 = Plot.plot({
|
|
27
|
+
grid: true,
|
|
49
28
|
width,
|
|
50
|
-
height
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
29
|
+
height,
|
|
30
|
+
style: {
|
|
31
|
+
background: "transparent"
|
|
32
|
+
},
|
|
33
|
+
marks: [
|
|
34
|
+
Plot.frame(),
|
|
35
|
+
Plot.dot(items, {
|
|
36
|
+
x: createAdapter("x", accessor),
|
|
37
|
+
y: createAdapter("y", accessor),
|
|
38
|
+
...options
|
|
39
|
+
})
|
|
40
|
+
]
|
|
55
41
|
});
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
42
|
+
containerRef.current.append(plot3);
|
|
43
|
+
return () => plot3?.remove();
|
|
44
|
+
}, [
|
|
45
|
+
items,
|
|
46
|
+
width,
|
|
47
|
+
height
|
|
48
|
+
]);
|
|
49
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
50
|
+
ref: containerRef,
|
|
51
|
+
className: "grow"
|
|
52
|
+
});
|
|
59
53
|
};
|
|
60
54
|
|
|
61
|
-
//
|
|
62
|
-
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
55
|
+
// src/components/Globe/Globe.tsx
|
|
63
56
|
import * as Plot2 from "@observablehq/plot";
|
|
64
57
|
import React2, { useEffect as useEffect2 } from "react";
|
|
65
58
|
import { useResizeDetector as useResizeDetector2 } from "react-resize-detector";
|
|
66
59
|
import * as topojson from "topojson-client";
|
|
67
60
|
|
|
68
|
-
//
|
|
61
|
+
// data/countries-110m.js
|
|
69
62
|
var countries_110m_default = {
|
|
70
63
|
type: "Topology",
|
|
71
64
|
objects: {
|
|
@@ -10767,79 +10760,74 @@ var countries_110m_default = {
|
|
|
10767
10760
|
}
|
|
10768
10761
|
};
|
|
10769
10762
|
|
|
10770
|
-
//
|
|
10763
|
+
// src/components/Globe/Globe.tsx
|
|
10771
10764
|
var defaultOptions2 = {
|
|
10772
10765
|
r: 4,
|
|
10773
10766
|
fill: "#003300"
|
|
10774
10767
|
};
|
|
10775
10768
|
var Globe = ({ items = [], accessor, projection = "orthographic", options = defaultOptions2 }) => {
|
|
10776
|
-
|
|
10777
|
-
|
|
10778
|
-
|
|
10779
|
-
|
|
10780
|
-
|
|
10781
|
-
|
|
10782
|
-
|
|
10783
|
-
|
|
10784
|
-
|
|
10785
|
-
|
|
10786
|
-
|
|
10787
|
-
|
|
10788
|
-
|
|
10789
|
-
|
|
10790
|
-
|
|
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
|
-
})
|
|
10769
|
+
const { ref: containerRef, width = 0, height = 0 } = useResizeDetector2({
|
|
10770
|
+
refreshRate: 200
|
|
10771
|
+
});
|
|
10772
|
+
const land = topojson.feature(countries_110m_default, countries_110m_default.objects.land);
|
|
10773
|
+
useEffect2(() => {
|
|
10774
|
+
if (!width || !height) {
|
|
10775
|
+
return;
|
|
10776
|
+
}
|
|
10777
|
+
const plot3 = Plot2.plot({
|
|
10778
|
+
// https://observablehq.com/plot/features/projections
|
|
10779
|
+
projection: {
|
|
10780
|
+
type: projection,
|
|
10781
|
+
rotate: [
|
|
10782
|
+
-100,
|
|
10783
|
+
-20
|
|
10817
10784
|
]
|
|
10818
|
-
}
|
|
10819
|
-
|
|
10820
|
-
return () => plot3?.remove();
|
|
10821
|
-
}, [
|
|
10822
|
-
items,
|
|
10785
|
+
},
|
|
10786
|
+
// projection: { type: 'equirectangular', rotate: [-140, -30] },
|
|
10823
10787
|
width,
|
|
10824
|
-
height
|
|
10825
|
-
|
|
10826
|
-
|
|
10827
|
-
|
|
10828
|
-
|
|
10788
|
+
height,
|
|
10789
|
+
style: {
|
|
10790
|
+
background: "transparent"
|
|
10791
|
+
},
|
|
10792
|
+
// TODO(burdon): Create simple wrapper for Plot with good defaults.
|
|
10793
|
+
marks: [
|
|
10794
|
+
Plot2.sphere({
|
|
10795
|
+
fill: "lightblue",
|
|
10796
|
+
fillOpacity: 0.5
|
|
10797
|
+
}),
|
|
10798
|
+
Plot2.geo(land, {
|
|
10799
|
+
fill: "darkgreen",
|
|
10800
|
+
fillOpacity: 0.5
|
|
10801
|
+
}),
|
|
10802
|
+
Plot2.graticule(),
|
|
10803
|
+
Plot2.dot(items, {
|
|
10804
|
+
x: createAdapter("lat", accessor),
|
|
10805
|
+
y: createAdapter("lng", accessor),
|
|
10806
|
+
...options
|
|
10807
|
+
})
|
|
10808
|
+
]
|
|
10829
10809
|
});
|
|
10830
|
-
|
|
10831
|
-
|
|
10832
|
-
}
|
|
10810
|
+
containerRef.current.append(plot3);
|
|
10811
|
+
return () => plot3?.remove();
|
|
10812
|
+
}, [
|
|
10813
|
+
items,
|
|
10814
|
+
width,
|
|
10815
|
+
height
|
|
10816
|
+
]);
|
|
10817
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
10818
|
+
ref: containerRef,
|
|
10819
|
+
className: "grow p-4"
|
|
10820
|
+
});
|
|
10833
10821
|
};
|
|
10834
10822
|
|
|
10835
|
-
//
|
|
10836
|
-
import {
|
|
10837
|
-
import React3, { useEffect as useEffect3, useRef, useState } from "react";
|
|
10823
|
+
// src/components/Tree/Tree.tsx
|
|
10824
|
+
import { RegistryContext } from "@effect-atom/atom-react";
|
|
10825
|
+
import React3, { useContext, useEffect as useEffect3, useRef, useState } from "react";
|
|
10838
10826
|
import { useAsyncState } from "@dxos/react-ui";
|
|
10839
10827
|
import { SVG } from "@dxos/react-ui-graph";
|
|
10840
10828
|
import { SpaceGraphModel } from "@dxos/schema";
|
|
10841
10829
|
|
|
10842
|
-
//
|
|
10830
|
+
// src/components/Tree/layout/HierarchicalEdgeBundling.ts
|
|
10843
10831
|
import { cluster, curveBundle, hierarchy, lineRadial, select } from "d3";
|
|
10844
10832
|
var HierarchicalEdgeBundling = (s, data, options) => {
|
|
10845
10833
|
const svg = select(s);
|
|
@@ -10902,7 +10890,7 @@ var flatten = (node) => {
|
|
|
10902
10890
|
};
|
|
10903
10891
|
var HierarchicalEdgeBundling_default = HierarchicalEdgeBundling;
|
|
10904
10892
|
|
|
10905
|
-
//
|
|
10893
|
+
// src/components/Tree/layout/RadialTree.ts
|
|
10906
10894
|
import { hierarchy as hierarchy2, linkRadial, select as select2, tree } from "d3";
|
|
10907
10895
|
var RadialTree = (s, data, options) => {
|
|
10908
10896
|
const svg = select2(s);
|
|
@@ -10927,7 +10915,7 @@ var RadialTree = (s, data, options) => {
|
|
|
10927
10915
|
};
|
|
10928
10916
|
var RadialTree_default = RadialTree;
|
|
10929
10917
|
|
|
10930
|
-
//
|
|
10918
|
+
// src/components/Tree/layout/TidyTree.ts
|
|
10931
10919
|
import { curveBumpX, hierarchy as hierarchy3, link, select as select3, tree as tree2 } from "d3";
|
|
10932
10920
|
var TidyTree = (s, data, options) => {
|
|
10933
10921
|
const svg = select3(s);
|
|
@@ -10972,11 +10960,11 @@ var TidyTree = (s, data, options) => {
|
|
|
10972
10960
|
};
|
|
10973
10961
|
var TidyTree_default = TidyTree;
|
|
10974
10962
|
|
|
10975
|
-
//
|
|
10976
|
-
import
|
|
10963
|
+
// src/components/Tree/types/tree.ts
|
|
10964
|
+
import * as Schema from "effect/Schema";
|
|
10977
10965
|
import { Key, Obj, Type } from "@dxos/echo";
|
|
10966
|
+
import { TestSchema } from "@dxos/echo/testing";
|
|
10978
10967
|
import { invariant } from "@dxos/invariant";
|
|
10979
|
-
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-explorer/src/components/Tree/types/tree.ts";
|
|
10980
10968
|
var TreeNodeType = Schema.Struct({
|
|
10981
10969
|
id: Key.ObjectId,
|
|
10982
10970
|
children: Schema.mutable(Schema.Array(Key.ObjectId)),
|
|
@@ -10984,7 +10972,7 @@ var TreeNodeType = Schema.Struct({
|
|
|
10984
10972
|
key: Schema.String,
|
|
10985
10973
|
value: Schema.Any
|
|
10986
10974
|
})),
|
|
10987
|
-
ref: Schema.optional(Type.Ref(
|
|
10975
|
+
ref: Schema.optional(Type.Ref(TestSchema.Expando))
|
|
10988
10976
|
}).pipe(Schema.mutable);
|
|
10989
10977
|
var TreeType = Schema.Struct({
|
|
10990
10978
|
root: Key.ObjectId,
|
|
@@ -10992,257 +10980,18 @@ var TreeType = Schema.Struct({
|
|
|
10992
10980
|
key: Key.ObjectId,
|
|
10993
10981
|
value: TreeNodeType
|
|
10994
10982
|
}))
|
|
10995
|
-
}).pipe(Type.
|
|
10983
|
+
}).pipe(Type.object({
|
|
10996
10984
|
typename: "dxos.org/type/Tree",
|
|
10997
10985
|
version: "0.1.0"
|
|
10998
10986
|
}));
|
|
10999
|
-
var Tree = class _Tree {
|
|
11000
|
-
static {
|
|
11001
|
-
this.create = () => {
|
|
11002
|
-
const id = Key.ObjectId.random();
|
|
11003
|
-
return Obj.make(TreeType, {
|
|
11004
|
-
root: id,
|
|
11005
|
-
nodes: {
|
|
11006
|
-
[id]: {
|
|
11007
|
-
id,
|
|
11008
|
-
children: [],
|
|
11009
|
-
data: {
|
|
11010
|
-
text: ""
|
|
11011
|
-
}
|
|
11012
|
-
}
|
|
11013
|
-
}
|
|
11014
|
-
});
|
|
11015
|
-
};
|
|
11016
|
-
}
|
|
11017
|
-
constructor(tree3) {
|
|
11018
|
-
this._tree = tree3 ?? _Tree.create();
|
|
11019
|
-
}
|
|
11020
|
-
get tree() {
|
|
11021
|
-
return this._tree;
|
|
11022
|
-
}
|
|
11023
|
-
// TODO(burdon): Make reactive.
|
|
11024
|
-
get size() {
|
|
11025
|
-
return Object.keys(this._tree.nodes).length;
|
|
11026
|
-
}
|
|
11027
|
-
get root() {
|
|
11028
|
-
return this.getNode(this._tree.root);
|
|
11029
|
-
}
|
|
11030
|
-
//
|
|
11031
|
-
// Traversal
|
|
11032
|
-
//
|
|
11033
|
-
/**
|
|
11034
|
-
* Recursively traverse the tree until the callback returns a value.
|
|
11035
|
-
*/
|
|
11036
|
-
tranverse(callback, root = this._tree.root, depth = 0) {
|
|
11037
|
-
const node = this._tree.nodes[root];
|
|
11038
|
-
const result = callback(node, depth);
|
|
11039
|
-
if (result !== void 0) {
|
|
11040
|
-
return result;
|
|
11041
|
-
}
|
|
11042
|
-
for (const childId of node.children) {
|
|
11043
|
-
const result2 = this.tranverse(callback, childId, depth + 1);
|
|
11044
|
-
if (result2 !== void 0) {
|
|
11045
|
-
return result2;
|
|
11046
|
-
}
|
|
11047
|
-
}
|
|
11048
|
-
}
|
|
11049
|
-
getNode(id) {
|
|
11050
|
-
const node = this._tree.nodes[id];
|
|
11051
|
-
invariant(node, void 0, {
|
|
11052
|
-
F: __dxlog_file,
|
|
11053
|
-
L: 98,
|
|
11054
|
-
S: this,
|
|
11055
|
-
A: [
|
|
11056
|
-
"node",
|
|
11057
|
-
""
|
|
11058
|
-
]
|
|
11059
|
-
});
|
|
11060
|
-
return node;
|
|
11061
|
-
}
|
|
11062
|
-
/**
|
|
11063
|
-
* Get the children of a node.
|
|
11064
|
-
*/
|
|
11065
|
-
getChildNodes(node) {
|
|
11066
|
-
return node.children.map((id) => this.getNode(id));
|
|
11067
|
-
}
|
|
11068
|
-
/**
|
|
11069
|
-
* Get the parent of a node.
|
|
11070
|
-
*/
|
|
11071
|
-
getParent(node) {
|
|
11072
|
-
const parent = this.tranverse((n) => {
|
|
11073
|
-
if (n.children.includes(node.id)) {
|
|
11074
|
-
return n;
|
|
11075
|
-
}
|
|
11076
|
-
});
|
|
11077
|
-
return parent ?? null;
|
|
11078
|
-
}
|
|
11079
|
-
/**
|
|
11080
|
-
* Get the next node in the tree.
|
|
11081
|
-
*/
|
|
11082
|
-
getNext(node, hierarchical = true) {
|
|
11083
|
-
if (hierarchical && node.children.length) {
|
|
11084
|
-
return this.getChildNodes(node)[0];
|
|
11085
|
-
} else {
|
|
11086
|
-
const parent = this.getParent(node);
|
|
11087
|
-
if (parent) {
|
|
11088
|
-
const idx = this.getChildNodes(parent).findIndex(({ id }) => id === node.id);
|
|
11089
|
-
if (idx < parent.children.length - 1) {
|
|
11090
|
-
return this.getNode(parent.children[idx + 1]);
|
|
11091
|
-
} else {
|
|
11092
|
-
return this.getNext(parent, false);
|
|
11093
|
-
}
|
|
11094
|
-
}
|
|
11095
|
-
}
|
|
11096
|
-
}
|
|
11097
|
-
/**
|
|
11098
|
-
* Get the previous node in the tree.
|
|
11099
|
-
*/
|
|
11100
|
-
getPrevious(node, hierarchical = true) {
|
|
11101
|
-
const parent = this.getParent(node);
|
|
11102
|
-
const idx = this.getChildNodes(parent).findIndex(({ id }) => id === node.id);
|
|
11103
|
-
if (idx === 0) {
|
|
11104
|
-
if (hierarchical) {
|
|
11105
|
-
return parent;
|
|
11106
|
-
}
|
|
11107
|
-
} else {
|
|
11108
|
-
const previous = this.getNode(parent.children[idx - 1]);
|
|
11109
|
-
if (hierarchical && previous.children.length) {
|
|
11110
|
-
return this.getLastDescendent(previous);
|
|
11111
|
-
}
|
|
11112
|
-
return previous;
|
|
11113
|
-
}
|
|
11114
|
-
}
|
|
11115
|
-
/**
|
|
11116
|
-
* Get the last descendent of a node.
|
|
11117
|
-
*/
|
|
11118
|
-
getLastDescendent(node) {
|
|
11119
|
-
const children = this.getChildNodes(node);
|
|
11120
|
-
const last = children.length ? children[children.length - 1] : void 0;
|
|
11121
|
-
if (last) {
|
|
11122
|
-
return this.getLastDescendent(last);
|
|
11123
|
-
}
|
|
11124
|
-
return node;
|
|
11125
|
-
}
|
|
11126
|
-
//
|
|
11127
|
-
// Mutations
|
|
11128
|
-
//
|
|
11129
|
-
/**
|
|
11130
|
-
* Clear tree.
|
|
11131
|
-
*/
|
|
11132
|
-
clear() {
|
|
11133
|
-
const root = this._tree.nodes[this._tree.root];
|
|
11134
|
-
root.children.length = 0;
|
|
11135
|
-
this._tree.nodes = {
|
|
11136
|
-
[root.id]: root
|
|
11137
|
-
};
|
|
11138
|
-
}
|
|
11139
|
-
/**
|
|
11140
|
-
* Add node.
|
|
11141
|
-
*/
|
|
11142
|
-
addNode(parent, node, index) {
|
|
11143
|
-
if (!node) {
|
|
11144
|
-
const id = Key.ObjectId.random();
|
|
11145
|
-
node = {
|
|
11146
|
-
id,
|
|
11147
|
-
children: [],
|
|
11148
|
-
data: {
|
|
11149
|
-
text: ""
|
|
11150
|
-
}
|
|
11151
|
-
};
|
|
11152
|
-
}
|
|
11153
|
-
this._tree.nodes[node.id] = node;
|
|
11154
|
-
parent.children.splice(index ?? parent.children.length, 0, node.id);
|
|
11155
|
-
return node;
|
|
11156
|
-
}
|
|
11157
|
-
/**
|
|
11158
|
-
* Delete node.
|
|
11159
|
-
*/
|
|
11160
|
-
deleteNode(parent, id) {
|
|
11161
|
-
const node = this._tree.nodes[id];
|
|
11162
|
-
if (!node) {
|
|
11163
|
-
return void 0;
|
|
11164
|
-
}
|
|
11165
|
-
delete this._tree.nodes[node.id];
|
|
11166
|
-
const idx = parent.children.findIndex((child) => child === id);
|
|
11167
|
-
if (idx !== -1) {
|
|
11168
|
-
parent.children.splice(idx, 1);
|
|
11169
|
-
}
|
|
11170
|
-
return node;
|
|
11171
|
-
}
|
|
11172
|
-
/**
|
|
11173
|
-
* Move child node.
|
|
11174
|
-
*/
|
|
11175
|
-
moveNode(node, from, to) {
|
|
11176
|
-
invariant(from >= 0 && from < node.children.length, void 0, {
|
|
11177
|
-
F: __dxlog_file,
|
|
11178
|
-
L: 228,
|
|
11179
|
-
S: this,
|
|
11180
|
-
A: [
|
|
11181
|
-
"from >= 0 && from < node.children.length",
|
|
11182
|
-
""
|
|
11183
|
-
]
|
|
11184
|
-
});
|
|
11185
|
-
invariant(to >= 0 && to < node.children.length, void 0, {
|
|
11186
|
-
F: __dxlog_file,
|
|
11187
|
-
L: 229,
|
|
11188
|
-
S: this,
|
|
11189
|
-
A: [
|
|
11190
|
-
"to >= 0 && to < node.children.length",
|
|
11191
|
-
""
|
|
11192
|
-
]
|
|
11193
|
-
});
|
|
11194
|
-
if (from === to) {
|
|
11195
|
-
return null;
|
|
11196
|
-
}
|
|
11197
|
-
const child = node.children[from];
|
|
11198
|
-
node.children.splice(from, 1);
|
|
11199
|
-
node.children.splice(to, 0, child);
|
|
11200
|
-
return this.getNode(child);
|
|
11201
|
-
}
|
|
11202
|
-
/**
|
|
11203
|
-
* Indent node.
|
|
11204
|
-
*/
|
|
11205
|
-
indentNode(node) {
|
|
11206
|
-
const parent = this.getParent(node);
|
|
11207
|
-
if (!parent) {
|
|
11208
|
-
return;
|
|
11209
|
-
}
|
|
11210
|
-
const idx = parent.children.findIndex((child) => child === node.id);
|
|
11211
|
-
if (idx < 1 || idx >= parent.children.length) {
|
|
11212
|
-
return;
|
|
11213
|
-
}
|
|
11214
|
-
const previous = this.getNode(parent.children[idx - 1]);
|
|
11215
|
-
parent.children.splice(idx, 1);
|
|
11216
|
-
previous.children.push(node.id);
|
|
11217
|
-
}
|
|
11218
|
-
/**
|
|
11219
|
-
* Unindent node.
|
|
11220
|
-
*/
|
|
11221
|
-
unindentNode(node) {
|
|
11222
|
-
const parent = this.getParent(node);
|
|
11223
|
-
if (!parent) {
|
|
11224
|
-
return;
|
|
11225
|
-
}
|
|
11226
|
-
const ancestor = this.getParent(parent);
|
|
11227
|
-
if (!ancestor) {
|
|
11228
|
-
return;
|
|
11229
|
-
}
|
|
11230
|
-
const nodeIdx = parent.children.findIndex((id) => id === node.id);
|
|
11231
|
-
const [_, ...rest] = parent.children.splice(nodeIdx, parent.children.length - nodeIdx);
|
|
11232
|
-
parent.children.splice(nodeIdx, parent.children.length - nodeIdx);
|
|
11233
|
-
const parentIdx = this.getChildNodes(ancestor).findIndex((n) => n.id === parent.id);
|
|
11234
|
-
ancestor.children.splice(parentIdx + 1, 0, node.id);
|
|
11235
|
-
node.children.push(...rest);
|
|
11236
|
-
}
|
|
11237
|
-
};
|
|
11238
10987
|
|
|
11239
|
-
//
|
|
10988
|
+
// src/components/Tree/types/types.ts
|
|
11240
10989
|
var mapGraphToTreeData = (model, maxDepth = 8) => {
|
|
11241
10990
|
let data;
|
|
11242
10991
|
return data;
|
|
11243
10992
|
};
|
|
11244
10993
|
|
|
11245
|
-
//
|
|
10994
|
+
// src/components/Tree/Tree.tsx
|
|
11246
10995
|
var defaultTreeLayoutSlots = {
|
|
11247
10996
|
node: "fill-blue-600",
|
|
11248
10997
|
path: "fill-none stroke-blue-400 stroke-[0.5px]",
|
|
@@ -11262,68 +11011,66 @@ var renderers = /* @__PURE__ */ new Map([
|
|
|
11262
11011
|
HierarchicalEdgeBundling_default
|
|
11263
11012
|
]
|
|
11264
11013
|
]);
|
|
11265
|
-
var
|
|
11266
|
-
|
|
11267
|
-
|
|
11268
|
-
|
|
11269
|
-
|
|
11270
|
-
|
|
11271
|
-
|
|
11272
|
-
|
|
11273
|
-
|
|
11274
|
-
|
|
11275
|
-
|
|
11276
|
-
|
|
11277
|
-
|
|
11278
|
-
|
|
11279
|
-
|
|
11280
|
-
|
|
11281
|
-
|
|
11282
|
-
|
|
11283
|
-
|
|
11284
|
-
|
|
11285
|
-
|
|
11286
|
-
|
|
11287
|
-
|
|
11288
|
-
|
|
11289
|
-
|
|
11290
|
-
|
|
11291
|
-
|
|
11292
|
-
|
|
11293
|
-
|
|
11294
|
-
|
|
11295
|
-
|
|
11296
|
-
|
|
11297
|
-
|
|
11298
|
-
|
|
11299
|
-
|
|
11300
|
-
|
|
11301
|
-
|
|
11302
|
-
}
|
|
11014
|
+
var Tree = ({ space, selected, variant = "tidy", onNodeClick }) => {
|
|
11015
|
+
const registry = useContext(RegistryContext);
|
|
11016
|
+
const [model] = useAsyncState(async () => space ? new SpaceGraphModel(registry).open(space.db) : void 0, [
|
|
11017
|
+
space,
|
|
11018
|
+
selected,
|
|
11019
|
+
registry
|
|
11020
|
+
]);
|
|
11021
|
+
const [tree3, setTree] = useState();
|
|
11022
|
+
useEffect3(() => {
|
|
11023
|
+
return model?.subscribe(() => {
|
|
11024
|
+
const tree4 = mapGraphToTreeData(model);
|
|
11025
|
+
setTree(tree4);
|
|
11026
|
+
}, true);
|
|
11027
|
+
}, [
|
|
11028
|
+
model
|
|
11029
|
+
]);
|
|
11030
|
+
const context = useRef(null);
|
|
11031
|
+
useEffect3(() => {
|
|
11032
|
+
if (context.current?.size) {
|
|
11033
|
+
const { width, height } = context.current.size;
|
|
11034
|
+
const size = Math.min(width, height);
|
|
11035
|
+
const radius = size * 0.4;
|
|
11036
|
+
const options = {
|
|
11037
|
+
// TODO(burdon): Type.
|
|
11038
|
+
label: (d) => d.label ?? d.id,
|
|
11039
|
+
width,
|
|
11040
|
+
height,
|
|
11041
|
+
radius,
|
|
11042
|
+
marginLeft: (width - radius * 2) / 2,
|
|
11043
|
+
marginRight: (width - radius * 2) / 2,
|
|
11044
|
+
marginTop: (height - radius * 2) / 2,
|
|
11045
|
+
marginBottom: (height - radius * 2) / 2,
|
|
11046
|
+
slots: defaultTreeLayoutSlots
|
|
11047
|
+
};
|
|
11048
|
+
if (tree3) {
|
|
11049
|
+
const renderer = renderers.get(variant);
|
|
11050
|
+
renderer?.(context.current.svg, tree3, options);
|
|
11303
11051
|
}
|
|
11304
|
-
}
|
|
11305
|
-
|
|
11306
|
-
|
|
11307
|
-
|
|
11308
|
-
|
|
11309
|
-
|
|
11310
|
-
|
|
11311
|
-
|
|
11312
|
-
|
|
11313
|
-
|
|
11314
|
-
|
|
11315
|
-
}
|
|
11052
|
+
}
|
|
11053
|
+
}, [
|
|
11054
|
+
context.current,
|
|
11055
|
+
tree3
|
|
11056
|
+
]);
|
|
11057
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
11058
|
+
className: "grow",
|
|
11059
|
+
onClick: () => onNodeClick?.()
|
|
11060
|
+
}, /* @__PURE__ */ React3.createElement(SVG.Root, {
|
|
11061
|
+
ref: context
|
|
11062
|
+
}));
|
|
11316
11063
|
};
|
|
11317
11064
|
|
|
11318
|
-
//
|
|
11065
|
+
// src/components/index.ts
|
|
11319
11066
|
import { lazy } from "react";
|
|
11320
|
-
var ExplorerContainer = lazy(() => import("./ExplorerContainer-
|
|
11067
|
+
var ExplorerContainer = lazy(() => import("./ExplorerContainer-46BHUF6R.mjs"));
|
|
11321
11068
|
|
|
11322
11069
|
export {
|
|
11323
11070
|
Chart,
|
|
11324
11071
|
Globe,
|
|
11325
11072
|
defaultTreeLayoutSlots,
|
|
11326
|
-
|
|
11073
|
+
Tree,
|
|
11327
11074
|
ExplorerContainer
|
|
11328
11075
|
};
|
|
11329
|
-
//# sourceMappingURL=chunk-
|
|
11076
|
+
//# sourceMappingURL=chunk-JZSBQYJQ.mjs.map
|