@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,17 +1,16 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
2
|
|
|
3
|
-
//
|
|
4
|
-
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
3
|
+
// src/components/Chart/Chart.tsx
|
|
5
4
|
import * as Plot from "@observablehq/plot";
|
|
6
5
|
import React, { useEffect } from "react";
|
|
7
6
|
import { useResizeDetector } from "react-resize-detector";
|
|
8
7
|
|
|
9
|
-
//
|
|
8
|
+
// src/components/plot.ts
|
|
10
9
|
var createAdapter = (prop, accessor) => accessor ? {
|
|
11
10
|
transform: (values) => values.map((value) => accessor(value)[prop])
|
|
12
11
|
} : prop;
|
|
13
12
|
|
|
14
|
-
//
|
|
13
|
+
// src/components/Chart/Chart.tsx
|
|
15
14
|
var defaultOptions = {
|
|
16
15
|
r: 4,
|
|
17
16
|
stroke: "gray",
|
|
@@ -19,55 +18,49 @@ var defaultOptions = {
|
|
|
19
18
|
fillOpacity: 0.2
|
|
20
19
|
};
|
|
21
20
|
var Chart = ({ items = [], accessor, options = defaultOptions }) => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const plot3 = Plot.plot({
|
|
32
|
-
grid: true,
|
|
33
|
-
width,
|
|
34
|
-
height,
|
|
35
|
-
style: {
|
|
36
|
-
background: "transparent"
|
|
37
|
-
},
|
|
38
|
-
marks: [
|
|
39
|
-
Plot.frame(),
|
|
40
|
-
Plot.dot(items, {
|
|
41
|
-
x: createAdapter("x", accessor),
|
|
42
|
-
y: createAdapter("y", accessor),
|
|
43
|
-
...options
|
|
44
|
-
})
|
|
45
|
-
]
|
|
46
|
-
});
|
|
47
|
-
containerRef.current.append(plot3);
|
|
48
|
-
return () => plot3?.remove();
|
|
49
|
-
}, [
|
|
50
|
-
items,
|
|
21
|
+
const { ref: containerRef, width = 0, height = 0 } = useResizeDetector({
|
|
22
|
+
refreshRate: 200
|
|
23
|
+
});
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (!width || !height) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const plot3 = Plot.plot({
|
|
29
|
+
grid: true,
|
|
51
30
|
width,
|
|
52
|
-
height
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
31
|
+
height,
|
|
32
|
+
style: {
|
|
33
|
+
background: "transparent"
|
|
34
|
+
},
|
|
35
|
+
marks: [
|
|
36
|
+
Plot.frame(),
|
|
37
|
+
Plot.dot(items, {
|
|
38
|
+
x: createAdapter("x", accessor),
|
|
39
|
+
y: createAdapter("y", accessor),
|
|
40
|
+
...options
|
|
41
|
+
})
|
|
42
|
+
]
|
|
57
43
|
});
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
44
|
+
containerRef.current.append(plot3);
|
|
45
|
+
return () => plot3?.remove();
|
|
46
|
+
}, [
|
|
47
|
+
items,
|
|
48
|
+
width,
|
|
49
|
+
height
|
|
50
|
+
]);
|
|
51
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
52
|
+
ref: containerRef,
|
|
53
|
+
className: "grow"
|
|
54
|
+
});
|
|
61
55
|
};
|
|
62
56
|
|
|
63
|
-
//
|
|
64
|
-
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
57
|
+
// src/components/Globe/Globe.tsx
|
|
65
58
|
import * as Plot2 from "@observablehq/plot";
|
|
66
59
|
import React2, { useEffect as useEffect2 } from "react";
|
|
67
60
|
import { useResizeDetector as useResizeDetector2 } from "react-resize-detector";
|
|
68
61
|
import * as topojson from "topojson-client";
|
|
69
62
|
|
|
70
|
-
//
|
|
63
|
+
// data/countries-110m.js
|
|
71
64
|
var countries_110m_default = {
|
|
72
65
|
type: "Topology",
|
|
73
66
|
objects: {
|
|
@@ -10769,79 +10762,74 @@ var countries_110m_default = {
|
|
|
10769
10762
|
}
|
|
10770
10763
|
};
|
|
10771
10764
|
|
|
10772
|
-
//
|
|
10765
|
+
// src/components/Globe/Globe.tsx
|
|
10773
10766
|
var defaultOptions2 = {
|
|
10774
10767
|
r: 4,
|
|
10775
10768
|
fill: "#003300"
|
|
10776
10769
|
};
|
|
10777
10770
|
var Globe = ({ items = [], accessor, projection = "orthographic", options = defaultOptions2 }) => {
|
|
10778
|
-
|
|
10779
|
-
|
|
10780
|
-
|
|
10781
|
-
|
|
10782
|
-
|
|
10783
|
-
|
|
10784
|
-
|
|
10785
|
-
|
|
10786
|
-
|
|
10787
|
-
|
|
10788
|
-
|
|
10789
|
-
|
|
10790
|
-
|
|
10791
|
-
|
|
10792
|
-
|
|
10793
|
-
-100,
|
|
10794
|
-
-20
|
|
10795
|
-
]
|
|
10796
|
-
},
|
|
10797
|
-
// projection: { type: 'equirectangular', rotate: [-140, -30] },
|
|
10798
|
-
width,
|
|
10799
|
-
height,
|
|
10800
|
-
style: {
|
|
10801
|
-
background: "transparent"
|
|
10802
|
-
},
|
|
10803
|
-
// TODO(burdon): Create simple wrapper for Plot with good defaults.
|
|
10804
|
-
marks: [
|
|
10805
|
-
Plot2.sphere({
|
|
10806
|
-
fill: "lightblue",
|
|
10807
|
-
fillOpacity: 0.5
|
|
10808
|
-
}),
|
|
10809
|
-
Plot2.geo(land, {
|
|
10810
|
-
fill: "darkgreen",
|
|
10811
|
-
fillOpacity: 0.5
|
|
10812
|
-
}),
|
|
10813
|
-
Plot2.graticule(),
|
|
10814
|
-
Plot2.dot(items, {
|
|
10815
|
-
x: createAdapter("lat", accessor),
|
|
10816
|
-
y: createAdapter("lng", accessor),
|
|
10817
|
-
...options
|
|
10818
|
-
})
|
|
10771
|
+
const { ref: containerRef, width = 0, height = 0 } = useResizeDetector2({
|
|
10772
|
+
refreshRate: 200
|
|
10773
|
+
});
|
|
10774
|
+
const land = topojson.feature(countries_110m_default, countries_110m_default.objects.land);
|
|
10775
|
+
useEffect2(() => {
|
|
10776
|
+
if (!width || !height) {
|
|
10777
|
+
return;
|
|
10778
|
+
}
|
|
10779
|
+
const plot3 = Plot2.plot({
|
|
10780
|
+
// https://observablehq.com/plot/features/projections
|
|
10781
|
+
projection: {
|
|
10782
|
+
type: projection,
|
|
10783
|
+
rotate: [
|
|
10784
|
+
-100,
|
|
10785
|
+
-20
|
|
10819
10786
|
]
|
|
10820
|
-
}
|
|
10821
|
-
|
|
10822
|
-
return () => plot3?.remove();
|
|
10823
|
-
}, [
|
|
10824
|
-
items,
|
|
10787
|
+
},
|
|
10788
|
+
// projection: { type: 'equirectangular', rotate: [-140, -30] },
|
|
10825
10789
|
width,
|
|
10826
|
-
height
|
|
10827
|
-
|
|
10828
|
-
|
|
10829
|
-
|
|
10830
|
-
|
|
10790
|
+
height,
|
|
10791
|
+
style: {
|
|
10792
|
+
background: "transparent"
|
|
10793
|
+
},
|
|
10794
|
+
// TODO(burdon): Create simple wrapper for Plot with good defaults.
|
|
10795
|
+
marks: [
|
|
10796
|
+
Plot2.sphere({
|
|
10797
|
+
fill: "lightblue",
|
|
10798
|
+
fillOpacity: 0.5
|
|
10799
|
+
}),
|
|
10800
|
+
Plot2.geo(land, {
|
|
10801
|
+
fill: "darkgreen",
|
|
10802
|
+
fillOpacity: 0.5
|
|
10803
|
+
}),
|
|
10804
|
+
Plot2.graticule(),
|
|
10805
|
+
Plot2.dot(items, {
|
|
10806
|
+
x: createAdapter("lat", accessor),
|
|
10807
|
+
y: createAdapter("lng", accessor),
|
|
10808
|
+
...options
|
|
10809
|
+
})
|
|
10810
|
+
]
|
|
10831
10811
|
});
|
|
10832
|
-
|
|
10833
|
-
|
|
10834
|
-
}
|
|
10812
|
+
containerRef.current.append(plot3);
|
|
10813
|
+
return () => plot3?.remove();
|
|
10814
|
+
}, [
|
|
10815
|
+
items,
|
|
10816
|
+
width,
|
|
10817
|
+
height
|
|
10818
|
+
]);
|
|
10819
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
10820
|
+
ref: containerRef,
|
|
10821
|
+
className: "grow p-4"
|
|
10822
|
+
});
|
|
10835
10823
|
};
|
|
10836
10824
|
|
|
10837
|
-
//
|
|
10838
|
-
import {
|
|
10839
|
-
import React3, { useEffect as useEffect3, useRef, useState } from "react";
|
|
10825
|
+
// src/components/Tree/Tree.tsx
|
|
10826
|
+
import { RegistryContext } from "@effect-atom/atom-react";
|
|
10827
|
+
import React3, { useContext, useEffect as useEffect3, useRef, useState } from "react";
|
|
10840
10828
|
import { useAsyncState } from "@dxos/react-ui";
|
|
10841
10829
|
import { SVG } from "@dxos/react-ui-graph";
|
|
10842
10830
|
import { SpaceGraphModel } from "@dxos/schema";
|
|
10843
10831
|
|
|
10844
|
-
//
|
|
10832
|
+
// src/components/Tree/layout/HierarchicalEdgeBundling.ts
|
|
10845
10833
|
import { cluster, curveBundle, hierarchy, lineRadial, select } from "d3";
|
|
10846
10834
|
var HierarchicalEdgeBundling = (s, data, options) => {
|
|
10847
10835
|
const svg = select(s);
|
|
@@ -10904,7 +10892,7 @@ var flatten = (node) => {
|
|
|
10904
10892
|
};
|
|
10905
10893
|
var HierarchicalEdgeBundling_default = HierarchicalEdgeBundling;
|
|
10906
10894
|
|
|
10907
|
-
//
|
|
10895
|
+
// src/components/Tree/layout/RadialTree.ts
|
|
10908
10896
|
import { hierarchy as hierarchy2, linkRadial, select as select2, tree } from "d3";
|
|
10909
10897
|
var RadialTree = (s, data, options) => {
|
|
10910
10898
|
const svg = select2(s);
|
|
@@ -10929,7 +10917,7 @@ var RadialTree = (s, data, options) => {
|
|
|
10929
10917
|
};
|
|
10930
10918
|
var RadialTree_default = RadialTree;
|
|
10931
10919
|
|
|
10932
|
-
//
|
|
10920
|
+
// src/components/Tree/layout/TidyTree.ts
|
|
10933
10921
|
import { curveBumpX, hierarchy as hierarchy3, link, select as select3, tree as tree2 } from "d3";
|
|
10934
10922
|
var TidyTree = (s, data, options) => {
|
|
10935
10923
|
const svg = select3(s);
|
|
@@ -10974,11 +10962,11 @@ var TidyTree = (s, data, options) => {
|
|
|
10974
10962
|
};
|
|
10975
10963
|
var TidyTree_default = TidyTree;
|
|
10976
10964
|
|
|
10977
|
-
//
|
|
10978
|
-
import
|
|
10965
|
+
// src/components/Tree/types/tree.ts
|
|
10966
|
+
import * as Schema from "effect/Schema";
|
|
10979
10967
|
import { Key, Obj, Type } from "@dxos/echo";
|
|
10968
|
+
import { TestSchema } from "@dxos/echo/testing";
|
|
10980
10969
|
import { invariant } from "@dxos/invariant";
|
|
10981
|
-
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-explorer/src/components/Tree/types/tree.ts";
|
|
10982
10970
|
var TreeNodeType = Schema.Struct({
|
|
10983
10971
|
id: Key.ObjectId,
|
|
10984
10972
|
children: Schema.mutable(Schema.Array(Key.ObjectId)),
|
|
@@ -10986,7 +10974,7 @@ var TreeNodeType = Schema.Struct({
|
|
|
10986
10974
|
key: Schema.String,
|
|
10987
10975
|
value: Schema.Any
|
|
10988
10976
|
})),
|
|
10989
|
-
ref: Schema.optional(Type.Ref(
|
|
10977
|
+
ref: Schema.optional(Type.Ref(TestSchema.Expando))
|
|
10990
10978
|
}).pipe(Schema.mutable);
|
|
10991
10979
|
var TreeType = Schema.Struct({
|
|
10992
10980
|
root: Key.ObjectId,
|
|
@@ -10994,257 +10982,18 @@ var TreeType = Schema.Struct({
|
|
|
10994
10982
|
key: Key.ObjectId,
|
|
10995
10983
|
value: TreeNodeType
|
|
10996
10984
|
}))
|
|
10997
|
-
}).pipe(Type.
|
|
10985
|
+
}).pipe(Type.object({
|
|
10998
10986
|
typename: "dxos.org/type/Tree",
|
|
10999
10987
|
version: "0.1.0"
|
|
11000
10988
|
}));
|
|
11001
|
-
var Tree = class _Tree {
|
|
11002
|
-
static {
|
|
11003
|
-
this.create = () => {
|
|
11004
|
-
const id = Key.ObjectId.random();
|
|
11005
|
-
return Obj.make(TreeType, {
|
|
11006
|
-
root: id,
|
|
11007
|
-
nodes: {
|
|
11008
|
-
[id]: {
|
|
11009
|
-
id,
|
|
11010
|
-
children: [],
|
|
11011
|
-
data: {
|
|
11012
|
-
text: ""
|
|
11013
|
-
}
|
|
11014
|
-
}
|
|
11015
|
-
}
|
|
11016
|
-
});
|
|
11017
|
-
};
|
|
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;
|
|
11043
|
-
}
|
|
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: 98,
|
|
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 = Key.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: 228,
|
|
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: 229,
|
|
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;
|
|
11215
|
-
}
|
|
11216
|
-
const previous = this.getNode(parent.children[idx - 1]);
|
|
11217
|
-
parent.children.splice(idx, 1);
|
|
11218
|
-
previous.children.push(node.id);
|
|
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
10989
|
|
|
11241
|
-
//
|
|
10990
|
+
// src/components/Tree/types/types.ts
|
|
11242
10991
|
var mapGraphToTreeData = (model, maxDepth = 8) => {
|
|
11243
10992
|
let data;
|
|
11244
10993
|
return data;
|
|
11245
10994
|
};
|
|
11246
10995
|
|
|
11247
|
-
//
|
|
10996
|
+
// src/components/Tree/Tree.tsx
|
|
11248
10997
|
var defaultTreeLayoutSlots = {
|
|
11249
10998
|
node: "fill-blue-600",
|
|
11250
10999
|
path: "fill-none stroke-blue-400 stroke-[0.5px]",
|
|
@@ -11264,68 +11013,66 @@ var renderers = /* @__PURE__ */ new Map([
|
|
|
11264
11013
|
HierarchicalEdgeBundling_default
|
|
11265
11014
|
]
|
|
11266
11015
|
]);
|
|
11267
|
-
var
|
|
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
|
-
|
|
11303
|
-
|
|
11304
|
-
}
|
|
11016
|
+
var Tree = ({ space, selected, variant = "tidy", onNodeClick }) => {
|
|
11017
|
+
const registry = useContext(RegistryContext);
|
|
11018
|
+
const [model] = useAsyncState(async () => space ? new SpaceGraphModel(registry).open(space.db) : void 0, [
|
|
11019
|
+
space,
|
|
11020
|
+
selected,
|
|
11021
|
+
registry
|
|
11022
|
+
]);
|
|
11023
|
+
const [tree3, setTree] = useState();
|
|
11024
|
+
useEffect3(() => {
|
|
11025
|
+
return model?.subscribe(() => {
|
|
11026
|
+
const tree4 = mapGraphToTreeData(model);
|
|
11027
|
+
setTree(tree4);
|
|
11028
|
+
}, true);
|
|
11029
|
+
}, [
|
|
11030
|
+
model
|
|
11031
|
+
]);
|
|
11032
|
+
const context = useRef(null);
|
|
11033
|
+
useEffect3(() => {
|
|
11034
|
+
if (context.current?.size) {
|
|
11035
|
+
const { width, height } = context.current.size;
|
|
11036
|
+
const size = Math.min(width, height);
|
|
11037
|
+
const radius = size * 0.4;
|
|
11038
|
+
const options = {
|
|
11039
|
+
// TODO(burdon): Type.
|
|
11040
|
+
label: (d) => d.label ?? d.id,
|
|
11041
|
+
width,
|
|
11042
|
+
height,
|
|
11043
|
+
radius,
|
|
11044
|
+
marginLeft: (width - radius * 2) / 2,
|
|
11045
|
+
marginRight: (width - radius * 2) / 2,
|
|
11046
|
+
marginTop: (height - radius * 2) / 2,
|
|
11047
|
+
marginBottom: (height - radius * 2) / 2,
|
|
11048
|
+
slots: defaultTreeLayoutSlots
|
|
11049
|
+
};
|
|
11050
|
+
if (tree3) {
|
|
11051
|
+
const renderer = renderers.get(variant);
|
|
11052
|
+
renderer?.(context.current.svg, tree3, options);
|
|
11305
11053
|
}
|
|
11306
|
-
}
|
|
11307
|
-
|
|
11308
|
-
|
|
11309
|
-
|
|
11310
|
-
|
|
11311
|
-
|
|
11312
|
-
|
|
11313
|
-
|
|
11314
|
-
|
|
11315
|
-
|
|
11316
|
-
|
|
11317
|
-
}
|
|
11054
|
+
}
|
|
11055
|
+
}, [
|
|
11056
|
+
context.current,
|
|
11057
|
+
tree3
|
|
11058
|
+
]);
|
|
11059
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
11060
|
+
className: "grow",
|
|
11061
|
+
onClick: () => onNodeClick?.()
|
|
11062
|
+
}, /* @__PURE__ */ React3.createElement(SVG.Root, {
|
|
11063
|
+
ref: context
|
|
11064
|
+
}));
|
|
11318
11065
|
};
|
|
11319
11066
|
|
|
11320
|
-
//
|
|
11067
|
+
// src/components/index.ts
|
|
11321
11068
|
import { lazy } from "react";
|
|
11322
|
-
var ExplorerContainer = lazy(() => import("./ExplorerContainer-
|
|
11069
|
+
var ExplorerContainer = lazy(() => import("./ExplorerContainer-OZNG47QB.mjs"));
|
|
11323
11070
|
|
|
11324
11071
|
export {
|
|
11325
11072
|
Chart,
|
|
11326
11073
|
Globe,
|
|
11327
11074
|
defaultTreeLayoutSlots,
|
|
11328
|
-
|
|
11075
|
+
Tree,
|
|
11329
11076
|
ExplorerContainer
|
|
11330
11077
|
};
|
|
11331
|
-
//# sourceMappingURL=chunk-
|
|
11078
|
+
//# sourceMappingURL=chunk-K5BYG7BW.mjs.map
|