@dxos/plugin-explorer 0.8.2-main.fbd8ed0 → 0.8.2-staging.42af850
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
|
@@ -26,30 +26,37 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
29
|
+
var chunk_72H5HBTK_exports = {};
|
|
30
|
+
__export(chunk_72H5HBTK_exports, {
|
|
31
31
|
Chart: () => Chart,
|
|
32
32
|
ExplorerContainer: () => ExplorerContainer,
|
|
33
33
|
Globe: () => Globe,
|
|
34
|
-
Tree: () =>
|
|
34
|
+
Tree: () => Tree2,
|
|
35
35
|
defaultTreeLayoutSlots: () => defaultTreeLayoutSlots
|
|
36
36
|
});
|
|
37
|
-
module.exports = __toCommonJS(
|
|
38
|
-
var
|
|
37
|
+
module.exports = __toCommonJS(chunk_72H5HBTK_exports);
|
|
38
|
+
var import_tracking = require("@preact-signals/safe-react/tracking");
|
|
39
39
|
var Plot = __toESM(require("@observablehq/plot"));
|
|
40
40
|
var import_react = __toESM(require("react"));
|
|
41
41
|
var import_react_resize_detector = require("react-resize-detector");
|
|
42
|
+
var import_tracking2 = require("@preact-signals/safe-react/tracking");
|
|
42
43
|
var Plot2 = __toESM(require("@observablehq/plot"));
|
|
43
44
|
var import_react2 = __toESM(require("react"));
|
|
44
45
|
var import_react_resize_detector2 = require("react-resize-detector");
|
|
45
46
|
var topojson = __toESM(require("topojson-client"));
|
|
47
|
+
var import_tracking3 = require("@preact-signals/safe-react/tracking");
|
|
46
48
|
var import_react3 = __toESM(require("react"));
|
|
47
|
-
var import_react_resize_detector3 = require("react-resize-detector");
|
|
48
|
-
var import_gem_core = require("@dxos/gem-core");
|
|
49
49
|
var import_react_ui = require("@dxos/react-ui");
|
|
50
|
+
var import_react_ui_graph = require("@dxos/react-ui-graph");
|
|
51
|
+
var import_schema = require("@dxos/schema");
|
|
50
52
|
var import_d3 = require("d3");
|
|
51
53
|
var import_d32 = require("d3");
|
|
52
54
|
var import_d33 = require("d3");
|
|
55
|
+
var import_effect = require("effect");
|
|
56
|
+
var import_echo = require("@dxos/echo");
|
|
57
|
+
var import_echo_schema = require("@dxos/echo-schema");
|
|
58
|
+
var import_invariant = require("@dxos/invariant");
|
|
59
|
+
var import_live_object = require("@dxos/live-object");
|
|
53
60
|
var import_react4 = require("react");
|
|
54
61
|
var createAdapter = (prop, accessor) => accessor ? {
|
|
55
62
|
transform: (values) => values.map((value) => accessor(value)[prop])
|
|
@@ -61,40 +68,45 @@ var defaultOptions = {
|
|
|
61
68
|
fillOpacity: 0.2
|
|
62
69
|
};
|
|
63
70
|
var Chart = ({ items = [], accessor, options = defaultOptions }) => {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
var _effect = (0, import_tracking.useSignals)();
|
|
72
|
+
try {
|
|
73
|
+
const { ref: containerRef, width = 0, height = 0 } = (0, import_react_resize_detector.useResizeDetector)({
|
|
74
|
+
refreshRate: 200
|
|
75
|
+
});
|
|
76
|
+
(0, import_react.useEffect)(() => {
|
|
77
|
+
if (!width || !height) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const plot3 = Plot.plot({
|
|
81
|
+
grid: true,
|
|
82
|
+
width,
|
|
83
|
+
height,
|
|
84
|
+
style: {
|
|
85
|
+
background: "transparent"
|
|
86
|
+
},
|
|
87
|
+
marks: [
|
|
88
|
+
Plot.frame(),
|
|
89
|
+
Plot.dot(items, {
|
|
90
|
+
x: createAdapter("x", accessor),
|
|
91
|
+
y: createAdapter("y", accessor),
|
|
92
|
+
...options
|
|
93
|
+
})
|
|
94
|
+
]
|
|
95
|
+
});
|
|
96
|
+
containerRef.current.append(plot3);
|
|
97
|
+
return () => plot3?.remove();
|
|
98
|
+
}, [
|
|
99
|
+
items,
|
|
73
100
|
width,
|
|
74
|
-
height
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
Plot.frame(),
|
|
80
|
-
Plot.dot(items, {
|
|
81
|
-
x: createAdapter("x", accessor),
|
|
82
|
-
y: createAdapter("y", accessor),
|
|
83
|
-
...options
|
|
84
|
-
})
|
|
85
|
-
]
|
|
101
|
+
height
|
|
102
|
+
]);
|
|
103
|
+
return /* @__PURE__ */ import_react.default.createElement("div", {
|
|
104
|
+
ref: containerRef,
|
|
105
|
+
className: "grow"
|
|
86
106
|
});
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
items,
|
|
91
|
-
width,
|
|
92
|
-
height
|
|
93
|
-
]);
|
|
94
|
-
return /* @__PURE__ */ import_react.default.createElement("div", {
|
|
95
|
-
ref: containerRef,
|
|
96
|
-
className: "grow"
|
|
97
|
-
});
|
|
107
|
+
} finally {
|
|
108
|
+
_effect.f();
|
|
109
|
+
}
|
|
98
110
|
};
|
|
99
111
|
var countries_110m_default = {
|
|
100
112
|
type: "Topology",
|
|
@@ -10801,58 +10813,63 @@ var defaultOptions2 = {
|
|
|
10801
10813
|
fill: "#003300"
|
|
10802
10814
|
};
|
|
10803
10815
|
var Globe = ({ items = [], accessor, projection = "orthographic", options = defaultOptions2 }) => {
|
|
10804
|
-
|
|
10805
|
-
|
|
10806
|
-
|
|
10807
|
-
|
|
10808
|
-
|
|
10809
|
-
|
|
10810
|
-
|
|
10811
|
-
|
|
10812
|
-
|
|
10813
|
-
|
|
10814
|
-
|
|
10815
|
-
|
|
10816
|
-
|
|
10817
|
-
|
|
10818
|
-
|
|
10816
|
+
var _effect = (0, import_tracking2.useSignals)();
|
|
10817
|
+
try {
|
|
10818
|
+
const { ref: containerRef, width = 0, height = 0 } = (0, import_react_resize_detector2.useResizeDetector)({
|
|
10819
|
+
refreshRate: 200
|
|
10820
|
+
});
|
|
10821
|
+
const land = topojson.feature(countries_110m_default, countries_110m_default.objects.land);
|
|
10822
|
+
(0, import_react2.useEffect)(() => {
|
|
10823
|
+
if (!width || !height) {
|
|
10824
|
+
return;
|
|
10825
|
+
}
|
|
10826
|
+
const plot3 = Plot2.plot({
|
|
10827
|
+
// https://observablehq.com/plot/features/projections
|
|
10828
|
+
projection: {
|
|
10829
|
+
type: projection,
|
|
10830
|
+
rotate: [
|
|
10831
|
+
-100,
|
|
10832
|
+
-20
|
|
10833
|
+
]
|
|
10834
|
+
},
|
|
10835
|
+
// projection: { type: 'equirectangular', rotate: [-140, -30] },
|
|
10836
|
+
width,
|
|
10837
|
+
height,
|
|
10838
|
+
style: {
|
|
10839
|
+
background: "transparent"
|
|
10840
|
+
},
|
|
10841
|
+
// TODO(burdon): Create simple wrapper for Plot with good defaults.
|
|
10842
|
+
marks: [
|
|
10843
|
+
Plot2.sphere({
|
|
10844
|
+
fill: "lightblue",
|
|
10845
|
+
fillOpacity: 0.5
|
|
10846
|
+
}),
|
|
10847
|
+
Plot2.geo(land, {
|
|
10848
|
+
fill: "darkgreen",
|
|
10849
|
+
fillOpacity: 0.5
|
|
10850
|
+
}),
|
|
10851
|
+
Plot2.graticule(),
|
|
10852
|
+
Plot2.dot(items, {
|
|
10853
|
+
x: createAdapter("lat", accessor),
|
|
10854
|
+
y: createAdapter("lng", accessor),
|
|
10855
|
+
...options
|
|
10856
|
+
})
|
|
10819
10857
|
]
|
|
10820
|
-
}
|
|
10821
|
-
|
|
10858
|
+
});
|
|
10859
|
+
containerRef.current.append(plot3);
|
|
10860
|
+
return () => plot3?.remove();
|
|
10861
|
+
}, [
|
|
10862
|
+
items,
|
|
10822
10863
|
width,
|
|
10823
|
-
height
|
|
10824
|
-
|
|
10825
|
-
|
|
10826
|
-
|
|
10827
|
-
|
|
10828
|
-
marks: [
|
|
10829
|
-
Plot2.sphere({
|
|
10830
|
-
fill: "lightblue",
|
|
10831
|
-
fillOpacity: 0.5
|
|
10832
|
-
}),
|
|
10833
|
-
Plot2.geo(land, {
|
|
10834
|
-
fill: "darkgreen",
|
|
10835
|
-
fillOpacity: 0.5
|
|
10836
|
-
}),
|
|
10837
|
-
Plot2.graticule(),
|
|
10838
|
-
Plot2.dot(items, {
|
|
10839
|
-
x: createAdapter("lat", accessor),
|
|
10840
|
-
y: createAdapter("lng", accessor),
|
|
10841
|
-
...options
|
|
10842
|
-
})
|
|
10843
|
-
]
|
|
10864
|
+
height
|
|
10865
|
+
]);
|
|
10866
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
10867
|
+
ref: containerRef,
|
|
10868
|
+
className: "grow p-4"
|
|
10844
10869
|
});
|
|
10845
|
-
|
|
10846
|
-
|
|
10847
|
-
}
|
|
10848
|
-
items,
|
|
10849
|
-
width,
|
|
10850
|
-
height
|
|
10851
|
-
]);
|
|
10852
|
-
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
10853
|
-
ref: containerRef,
|
|
10854
|
-
className: "grow p-4"
|
|
10855
|
-
});
|
|
10870
|
+
} finally {
|
|
10871
|
+
_effect.f();
|
|
10872
|
+
}
|
|
10856
10873
|
};
|
|
10857
10874
|
var HierarchicalEdgeBundling = (s, data, options) => {
|
|
10858
10875
|
const svg = (0, import_d3.select)(s);
|
|
@@ -10978,25 +10995,267 @@ var TidyTree = (s, data, options) => {
|
|
|
10978
10995
|
}
|
|
10979
10996
|
};
|
|
10980
10997
|
var TidyTree_default = TidyTree;
|
|
10981
|
-
var
|
|
10982
|
-
|
|
10983
|
-
|
|
10984
|
-
|
|
10985
|
-
|
|
10998
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-explorer/src/components/Tree/types/tree.ts";
|
|
10999
|
+
var TreeNodeType = import_effect.Schema.Struct({
|
|
11000
|
+
id: import_echo_schema.ObjectId,
|
|
11001
|
+
children: import_effect.Schema.mutable(import_effect.Schema.Array(import_echo_schema.ObjectId)),
|
|
11002
|
+
data: import_effect.Schema.mutable(import_effect.Schema.Record({
|
|
11003
|
+
key: import_effect.Schema.String,
|
|
11004
|
+
value: import_effect.Schema.Any
|
|
11005
|
+
})),
|
|
11006
|
+
ref: import_effect.Schema.optional((0, import_echo_schema.Ref)(import_echo_schema.Expando))
|
|
11007
|
+
}).pipe(import_effect.Schema.mutable);
|
|
11008
|
+
var TreeType = import_effect.Schema.Struct({
|
|
11009
|
+
root: import_echo_schema.ObjectId,
|
|
11010
|
+
nodes: import_effect.Schema.mutable(import_effect.Schema.Record({
|
|
11011
|
+
key: import_echo_schema.ObjectId,
|
|
11012
|
+
value: TreeNodeType
|
|
11013
|
+
}))
|
|
11014
|
+
}).pipe(import_echo.Type.Obj({
|
|
11015
|
+
typename: "dxos.org/type/Tree",
|
|
11016
|
+
version: "0.1.0"
|
|
11017
|
+
}));
|
|
11018
|
+
var Tree = class _Tree {
|
|
11019
|
+
static {
|
|
11020
|
+
this.create = () => {
|
|
11021
|
+
const id = import_echo_schema.ObjectId.random();
|
|
11022
|
+
return (0, import_live_object.live)(TreeType, {
|
|
11023
|
+
root: id,
|
|
11024
|
+
nodes: {
|
|
11025
|
+
[id]: {
|
|
11026
|
+
id,
|
|
11027
|
+
children: [],
|
|
11028
|
+
data: {
|
|
11029
|
+
text: ""
|
|
11030
|
+
}
|
|
11031
|
+
}
|
|
11032
|
+
}
|
|
11033
|
+
});
|
|
10986
11034
|
};
|
|
10987
|
-
|
|
10988
|
-
|
|
10989
|
-
|
|
11035
|
+
}
|
|
11036
|
+
constructor(tree3) {
|
|
11037
|
+
this._tree = tree3 ?? _Tree.create();
|
|
11038
|
+
}
|
|
11039
|
+
get tree() {
|
|
11040
|
+
return this._tree;
|
|
11041
|
+
}
|
|
11042
|
+
// TODO(burdon): Make reactive.
|
|
11043
|
+
get size() {
|
|
11044
|
+
return Object.keys(this._tree.nodes).length;
|
|
11045
|
+
}
|
|
11046
|
+
get root() {
|
|
11047
|
+
return this.getNode(this._tree.root);
|
|
11048
|
+
}
|
|
11049
|
+
//
|
|
11050
|
+
// Traversal
|
|
11051
|
+
//
|
|
11052
|
+
/**
|
|
11053
|
+
* Recursively traverse the tree until the callback returns a value.
|
|
11054
|
+
*/
|
|
11055
|
+
tranverse(callback, root = this._tree.root, depth = 0) {
|
|
11056
|
+
const node = this._tree.nodes[root];
|
|
11057
|
+
const result = callback(node, depth);
|
|
11058
|
+
if (result !== void 0) {
|
|
11059
|
+
return result;
|
|
10990
11060
|
}
|
|
10991
|
-
|
|
10992
|
-
|
|
10993
|
-
|
|
10994
|
-
|
|
10995
|
-
|
|
10996
|
-
|
|
10997
|
-
|
|
11061
|
+
for (const childId of node.children) {
|
|
11062
|
+
const result2 = this.tranverse(callback, childId, depth + 1);
|
|
11063
|
+
if (result2 !== void 0) {
|
|
11064
|
+
return result2;
|
|
11065
|
+
}
|
|
11066
|
+
}
|
|
11067
|
+
}
|
|
11068
|
+
getNode(id) {
|
|
11069
|
+
const node = this._tree.nodes[id];
|
|
11070
|
+
(0, import_invariant.invariant)(node, void 0, {
|
|
11071
|
+
F: __dxlog_file,
|
|
11072
|
+
L: 100,
|
|
11073
|
+
S: this,
|
|
11074
|
+
A: [
|
|
11075
|
+
"node",
|
|
11076
|
+
""
|
|
11077
|
+
]
|
|
11078
|
+
});
|
|
11079
|
+
return node;
|
|
11080
|
+
}
|
|
11081
|
+
/**
|
|
11082
|
+
* Get the children of a node.
|
|
11083
|
+
*/
|
|
11084
|
+
getChildNodes(node) {
|
|
11085
|
+
return node.children.map((id) => this.getNode(id));
|
|
11086
|
+
}
|
|
11087
|
+
/**
|
|
11088
|
+
* Get the parent of a node.
|
|
11089
|
+
*/
|
|
11090
|
+
getParent(node) {
|
|
11091
|
+
const parent = this.tranverse((n) => {
|
|
11092
|
+
if (n.children.includes(node.id)) {
|
|
11093
|
+
return n;
|
|
11094
|
+
}
|
|
11095
|
+
});
|
|
11096
|
+
return parent ?? null;
|
|
11097
|
+
}
|
|
11098
|
+
/**
|
|
11099
|
+
* Get the next node in the tree.
|
|
11100
|
+
*/
|
|
11101
|
+
getNext(node, hierarchical = true) {
|
|
11102
|
+
if (hierarchical && node.children.length) {
|
|
11103
|
+
return this.getChildNodes(node)[0];
|
|
11104
|
+
} else {
|
|
11105
|
+
const parent = this.getParent(node);
|
|
11106
|
+
if (parent) {
|
|
11107
|
+
const idx = this.getChildNodes(parent).findIndex(({ id }) => id === node.id);
|
|
11108
|
+
if (idx < parent.children.length - 1) {
|
|
11109
|
+
return this.getNode(parent.children[idx + 1]);
|
|
11110
|
+
} else {
|
|
11111
|
+
return this.getNext(parent, false);
|
|
11112
|
+
}
|
|
11113
|
+
}
|
|
11114
|
+
}
|
|
11115
|
+
}
|
|
11116
|
+
/**
|
|
11117
|
+
* Get the previous node in the tree.
|
|
11118
|
+
*/
|
|
11119
|
+
getPrevious(node, hierarchical = true) {
|
|
11120
|
+
const parent = this.getParent(node);
|
|
11121
|
+
const idx = this.getChildNodes(parent).findIndex(({ id }) => id === node.id);
|
|
11122
|
+
if (idx === 0) {
|
|
11123
|
+
if (hierarchical) {
|
|
11124
|
+
return parent;
|
|
11125
|
+
}
|
|
11126
|
+
} else {
|
|
11127
|
+
const previous = this.getNode(parent.children[idx - 1]);
|
|
11128
|
+
if (hierarchical && previous.children.length) {
|
|
11129
|
+
return this.getLastDescendent(previous);
|
|
11130
|
+
}
|
|
11131
|
+
return previous;
|
|
11132
|
+
}
|
|
11133
|
+
}
|
|
11134
|
+
/**
|
|
11135
|
+
* Get the last descendent of a node.
|
|
11136
|
+
*/
|
|
11137
|
+
getLastDescendent(node) {
|
|
11138
|
+
const children = this.getChildNodes(node);
|
|
11139
|
+
const last = children.length ? children[children.length - 1] : void 0;
|
|
11140
|
+
if (last) {
|
|
11141
|
+
return this.getLastDescendent(last);
|
|
11142
|
+
}
|
|
11143
|
+
return node;
|
|
11144
|
+
}
|
|
11145
|
+
//
|
|
11146
|
+
// Mutations
|
|
11147
|
+
//
|
|
11148
|
+
/**
|
|
11149
|
+
* Clear tree.
|
|
11150
|
+
*/
|
|
11151
|
+
clear() {
|
|
11152
|
+
const root = this._tree.nodes[this._tree.root];
|
|
11153
|
+
root.children.length = 0;
|
|
11154
|
+
this._tree.nodes = {
|
|
11155
|
+
[root.id]: root
|
|
11156
|
+
};
|
|
11157
|
+
}
|
|
11158
|
+
/**
|
|
11159
|
+
* Add node.
|
|
11160
|
+
*/
|
|
11161
|
+
addNode(parent, node, index) {
|
|
11162
|
+
if (!node) {
|
|
11163
|
+
const id = import_echo_schema.ObjectId.random();
|
|
11164
|
+
node = {
|
|
11165
|
+
id,
|
|
11166
|
+
children: [],
|
|
11167
|
+
data: {
|
|
11168
|
+
text: ""
|
|
11169
|
+
}
|
|
11170
|
+
};
|
|
11171
|
+
}
|
|
11172
|
+
this._tree.nodes[node.id] = node;
|
|
11173
|
+
parent.children.splice(index ?? parent.children.length, 0, node.id);
|
|
11174
|
+
return node;
|
|
11175
|
+
}
|
|
11176
|
+
/**
|
|
11177
|
+
* Delete node.
|
|
11178
|
+
*/
|
|
11179
|
+
deleteNode(parent, id) {
|
|
11180
|
+
const node = this._tree.nodes[id];
|
|
11181
|
+
if (!node) {
|
|
11182
|
+
return void 0;
|
|
10998
11183
|
}
|
|
11184
|
+
delete this._tree.nodes[node.id];
|
|
11185
|
+
const idx = parent.children.findIndex((child) => child === id);
|
|
11186
|
+
if (idx !== -1) {
|
|
11187
|
+
parent.children.splice(idx, 1);
|
|
11188
|
+
}
|
|
11189
|
+
return node;
|
|
10999
11190
|
}
|
|
11191
|
+
/**
|
|
11192
|
+
* Move child node.
|
|
11193
|
+
*/
|
|
11194
|
+
moveNode(node, from, to) {
|
|
11195
|
+
(0, import_invariant.invariant)(from >= 0 && from < node.children.length, void 0, {
|
|
11196
|
+
F: __dxlog_file,
|
|
11197
|
+
L: 230,
|
|
11198
|
+
S: this,
|
|
11199
|
+
A: [
|
|
11200
|
+
"from >= 0 && from < node.children.length",
|
|
11201
|
+
""
|
|
11202
|
+
]
|
|
11203
|
+
});
|
|
11204
|
+
(0, import_invariant.invariant)(to >= 0 && to < node.children.length, void 0, {
|
|
11205
|
+
F: __dxlog_file,
|
|
11206
|
+
L: 231,
|
|
11207
|
+
S: this,
|
|
11208
|
+
A: [
|
|
11209
|
+
"to >= 0 && to < node.children.length",
|
|
11210
|
+
""
|
|
11211
|
+
]
|
|
11212
|
+
});
|
|
11213
|
+
if (from === to) {
|
|
11214
|
+
return null;
|
|
11215
|
+
}
|
|
11216
|
+
const child = node.children[from];
|
|
11217
|
+
node.children.splice(from, 1);
|
|
11218
|
+
node.children.splice(to, 0, child);
|
|
11219
|
+
return this.getNode(child);
|
|
11220
|
+
}
|
|
11221
|
+
/**
|
|
11222
|
+
* Indent node.
|
|
11223
|
+
*/
|
|
11224
|
+
indentNode(node) {
|
|
11225
|
+
const parent = this.getParent(node);
|
|
11226
|
+
if (!parent) {
|
|
11227
|
+
return;
|
|
11228
|
+
}
|
|
11229
|
+
const idx = parent.children.findIndex((child) => child === node.id);
|
|
11230
|
+
if (idx < 1 || idx >= parent.children.length) {
|
|
11231
|
+
return;
|
|
11232
|
+
}
|
|
11233
|
+
const previous = this.getNode(parent.children[idx - 1]);
|
|
11234
|
+
parent.children.splice(idx, 1);
|
|
11235
|
+
previous.children.push(node.id);
|
|
11236
|
+
}
|
|
11237
|
+
/**
|
|
11238
|
+
* Unindent node.
|
|
11239
|
+
*/
|
|
11240
|
+
unindentNode(node) {
|
|
11241
|
+
const parent = this.getParent(node);
|
|
11242
|
+
if (!parent) {
|
|
11243
|
+
return;
|
|
11244
|
+
}
|
|
11245
|
+
const ancestor = this.getParent(parent);
|
|
11246
|
+
if (!ancestor) {
|
|
11247
|
+
return;
|
|
11248
|
+
}
|
|
11249
|
+
const nodeIdx = parent.children.findIndex((id) => id === node.id);
|
|
11250
|
+
const [_, ...rest] = parent.children.splice(nodeIdx, parent.children.length - nodeIdx);
|
|
11251
|
+
parent.children.splice(nodeIdx, parent.children.length - nodeIdx);
|
|
11252
|
+
const parentIdx = this.getChildNodes(ancestor).findIndex((n) => n.id === parent.id);
|
|
11253
|
+
ancestor.children.splice(parentIdx + 1, 0, node.id);
|
|
11254
|
+
node.children.push(...rest);
|
|
11255
|
+
}
|
|
11256
|
+
};
|
|
11257
|
+
var mapGraphToTreeData = (model, maxDepth = 8) => {
|
|
11258
|
+
let data;
|
|
11000
11259
|
return data;
|
|
11001
11260
|
};
|
|
11002
11261
|
var defaultTreeLayoutSlots = {
|
|
@@ -11018,57 +11277,59 @@ var renderers = /* @__PURE__ */ new Map([
|
|
|
11018
11277
|
HierarchicalEdgeBundling_default
|
|
11019
11278
|
]
|
|
11020
11279
|
]);
|
|
11021
|
-
var
|
|
11022
|
-
|
|
11023
|
-
|
|
11024
|
-
|
|
11025
|
-
|
|
11026
|
-
|
|
11027
|
-
|
|
11028
|
-
|
|
11029
|
-
|
|
11030
|
-
|
|
11031
|
-
|
|
11032
|
-
|
|
11033
|
-
|
|
11034
|
-
|
|
11035
|
-
|
|
11036
|
-
|
|
11037
|
-
|
|
11038
|
-
|
|
11039
|
-
|
|
11040
|
-
|
|
11041
|
-
|
|
11042
|
-
|
|
11043
|
-
|
|
11044
|
-
|
|
11045
|
-
|
|
11046
|
-
|
|
11047
|
-
|
|
11048
|
-
|
|
11049
|
-
|
|
11050
|
-
|
|
11051
|
-
|
|
11052
|
-
|
|
11053
|
-
|
|
11054
|
-
|
|
11055
|
-
|
|
11280
|
+
var Tree2 = ({ space, selected, variant = "tidy", onNodeClick }) => {
|
|
11281
|
+
var _effect = (0, import_tracking3.useSignals)();
|
|
11282
|
+
try {
|
|
11283
|
+
const [model] = (0, import_react_ui.useAsyncState)(async () => space ? new import_schema.SpaceGraphModel().open(space) : void 0, [
|
|
11284
|
+
space,
|
|
11285
|
+
selected
|
|
11286
|
+
]);
|
|
11287
|
+
const [tree3, setTree] = (0, import_react3.useState)();
|
|
11288
|
+
(0, import_react3.useEffect)(() => {
|
|
11289
|
+
return model?.subscribe(() => {
|
|
11290
|
+
const tree4 = mapGraphToTreeData(model);
|
|
11291
|
+
setTree(tree4);
|
|
11292
|
+
}, true);
|
|
11293
|
+
}, [
|
|
11294
|
+
model
|
|
11295
|
+
]);
|
|
11296
|
+
const context = (0, import_react3.useRef)(null);
|
|
11297
|
+
(0, import_react3.useEffect)(() => {
|
|
11298
|
+
if (context.current) {
|
|
11299
|
+
const { width, height } = context.current.size;
|
|
11300
|
+
const size = Math.min(width, height);
|
|
11301
|
+
const radius = size * 0.4;
|
|
11302
|
+
const options = {
|
|
11303
|
+
// TODO(burdon): Type.
|
|
11304
|
+
label: (d) => d.label ?? d.id,
|
|
11305
|
+
width,
|
|
11306
|
+
height,
|
|
11307
|
+
radius,
|
|
11308
|
+
marginLeft: (width - radius * 2) / 2,
|
|
11309
|
+
marginRight: (width - radius * 2) / 2,
|
|
11310
|
+
marginTop: (height - radius * 2) / 2,
|
|
11311
|
+
marginBottom: (height - radius * 2) / 2,
|
|
11312
|
+
slots: defaultTreeLayoutSlots
|
|
11313
|
+
};
|
|
11314
|
+
if (tree3) {
|
|
11315
|
+
const renderer = renderers.get(variant);
|
|
11316
|
+
renderer?.(context.current.svg, tree3, options);
|
|
11317
|
+
}
|
|
11056
11318
|
}
|
|
11057
|
-
}
|
|
11058
|
-
|
|
11059
|
-
|
|
11060
|
-
|
|
11061
|
-
|
|
11062
|
-
|
|
11063
|
-
|
|
11064
|
-
|
|
11065
|
-
|
|
11066
|
-
|
|
11067
|
-
|
|
11068
|
-
|
|
11069
|
-
}, /* @__PURE__ */ import_react3.default.createElement(import_gem_core.SVG, null)));
|
|
11319
|
+
}, [
|
|
11320
|
+
context.current,
|
|
11321
|
+
tree3
|
|
11322
|
+
]);
|
|
11323
|
+
return /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
11324
|
+
onClick: () => onNodeClick?.()
|
|
11325
|
+
}, /* @__PURE__ */ import_react3.default.createElement(import_react_ui_graph.SVG.Root, {
|
|
11326
|
+
ref: context
|
|
11327
|
+
}));
|
|
11328
|
+
} finally {
|
|
11329
|
+
_effect.f();
|
|
11330
|
+
}
|
|
11070
11331
|
};
|
|
11071
|
-
var ExplorerContainer = (0, import_react4.lazy)(() => import("./ExplorerContainer-
|
|
11332
|
+
var ExplorerContainer = (0, import_react4.lazy)(() => import("./ExplorerContainer-MVP2AM7R.cjs"));
|
|
11072
11333
|
// Annotate the CommonJS export names for ESM import in node:
|
|
11073
11334
|
0 && (module.exports = {
|
|
11074
11335
|
Chart,
|
|
@@ -11077,4 +11338,4 @@ var ExplorerContainer = (0, import_react4.lazy)(() => import("./ExplorerContaine
|
|
|
11077
11338
|
Tree,
|
|
11078
11339
|
defaultTreeLayoutSlots
|
|
11079
11340
|
});
|
|
11080
|
-
//# sourceMappingURL=chunk-
|
|
11341
|
+
//# sourceMappingURL=chunk-72H5HBTK.cjs.map
|