@dxos/plugin-explorer 0.8.2-staging.7ac8446 → 0.8.2

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.
Files changed (170) hide show
  1. package/dist/lib/browser/ExplorerContainer-BBZ54DJS.mjs +37 -0
  2. package/dist/lib/browser/ExplorerContainer-BBZ54DJS.mjs.map +7 -0
  3. package/dist/lib/browser/{chunk-B2DMPSP5.mjs → chunk-73GQ46YO.mjs} +430 -170
  4. package/dist/lib/{node-esm/chunk-PZOORWFE.mjs.map → browser/chunk-73GQ46YO.mjs.map} +4 -4
  5. package/dist/lib/browser/{chunk-QLQLPZNI.mjs → chunk-73YTQHOT.mjs} +12 -11
  6. package/dist/lib/browser/chunk-73YTQHOT.mjs.map +7 -0
  7. package/dist/lib/browser/chunk-M2BGAY6H.mjs +177 -0
  8. package/dist/lib/browser/chunk-M2BGAY6H.mjs.map +7 -0
  9. package/dist/lib/browser/{chunk-Z2SDLMQM.mjs → chunk-OBAFAA5V.mjs} +3 -3
  10. package/dist/lib/browser/{chunk-Z2SDLMQM.mjs.map → chunk-OBAFAA5V.mjs.map} +1 -1
  11. package/dist/lib/browser/chunk-SLB2F5AO.mjs +30 -0
  12. package/dist/lib/browser/chunk-SLB2F5AO.mjs.map +7 -0
  13. package/dist/lib/browser/index.mjs +15 -11
  14. package/dist/lib/browser/index.mjs.map +1 -1
  15. package/dist/lib/browser/{intent-resolver-NHHRWTOP.mjs → intent-resolver-FJDVBDE3.mjs} +5 -5
  16. package/dist/lib/browser/intent-resolver-FJDVBDE3.mjs.map +7 -0
  17. package/dist/lib/browser/meta.json +1 -1
  18. package/dist/lib/browser/meta.mjs +1 -1
  19. package/dist/lib/browser/{react-surface-N7TC6BMF.mjs → react-surface-H3YDMXAQ.mjs} +5 -5
  20. package/dist/lib/browser/types/index.mjs +2 -2
  21. package/dist/lib/node/{ExplorerContainer-73AHSBAG.cjs → ExplorerContainer-MVP2AM7R.cjs} +24 -16
  22. package/dist/lib/node/ExplorerContainer-MVP2AM7R.cjs.map +7 -0
  23. package/dist/lib/node/chunk-4T4LCT5R.cjs +52 -0
  24. package/dist/lib/node/chunk-4T4LCT5R.cjs.map +7 -0
  25. package/dist/lib/node/{chunk-HCDBN6NN.cjs → chunk-72H5HBTK.cjs} +429 -168
  26. package/dist/lib/node/chunk-72H5HBTK.cjs.map +7 -0
  27. package/dist/lib/node/{chunk-VB3QE6XY.cjs → chunk-BCDVG2CH.cjs} +6 -6
  28. package/dist/lib/node/{chunk-VB3QE6XY.cjs.map → chunk-BCDVG2CH.cjs.map} +1 -1
  29. package/dist/lib/node/{chunk-YLL7H7CZ.cjs → chunk-MLRYW4WQ.cjs} +15 -14
  30. package/dist/lib/node/chunk-MLRYW4WQ.cjs.map +7 -0
  31. package/dist/lib/node/chunk-NELWWGBU.cjs +204 -0
  32. package/dist/lib/node/chunk-NELWWGBU.cjs.map +7 -0
  33. package/dist/lib/node/index.cjs +34 -31
  34. package/dist/lib/node/index.cjs.map +1 -1
  35. package/dist/lib/node/{intent-resolver-EEOTX3OZ.cjs → intent-resolver-DRT67ZU4.cjs} +8 -8
  36. package/dist/lib/node/intent-resolver-DRT67ZU4.cjs.map +7 -0
  37. package/dist/lib/node/meta.cjs +3 -3
  38. package/dist/lib/node/meta.cjs.map +1 -1
  39. package/dist/lib/node/meta.json +1 -1
  40. package/dist/lib/node/{react-surface-WD4G2NRS.cjs → react-surface-6ESLSM33.cjs} +11 -11
  41. package/dist/lib/node/types/index.cjs +4 -4
  42. package/dist/lib/node/types/index.cjs.map +1 -1
  43. package/dist/lib/node-esm/ExplorerContainer-APGUQI4M.mjs +38 -0
  44. package/dist/lib/node-esm/ExplorerContainer-APGUQI4M.mjs.map +7 -0
  45. package/dist/lib/node-esm/{chunk-PZOORWFE.mjs → chunk-34X2VFQN.mjs} +430 -169
  46. package/dist/lib/{browser/chunk-B2DMPSP5.mjs.map → node-esm/chunk-34X2VFQN.mjs.map} +4 -4
  47. package/dist/lib/node-esm/{chunk-PUFSCMN4.mjs → chunk-3CMBLK6W.mjs} +3 -3
  48. package/dist/lib/node-esm/{chunk-PUFSCMN4.mjs.map → chunk-3CMBLK6W.mjs.map} +1 -1
  49. package/dist/lib/node-esm/{chunk-QZH2GDN5.mjs → chunk-N6VEANUZ.mjs} +12 -11
  50. package/dist/lib/node-esm/chunk-N6VEANUZ.mjs.map +7 -0
  51. package/dist/lib/node-esm/chunk-PVII2K2B.mjs +179 -0
  52. package/dist/lib/node-esm/chunk-PVII2K2B.mjs.map +7 -0
  53. package/dist/lib/node-esm/chunk-VSORIAHH.mjs +32 -0
  54. package/dist/lib/node-esm/chunk-VSORIAHH.mjs.map +7 -0
  55. package/dist/lib/node-esm/index.mjs +15 -11
  56. package/dist/lib/node-esm/index.mjs.map +1 -1
  57. package/dist/lib/node-esm/{intent-resolver-PTFKXAT4.mjs → intent-resolver-4RBV644N.mjs} +5 -5
  58. package/dist/lib/node-esm/intent-resolver-4RBV644N.mjs.map +7 -0
  59. package/dist/lib/node-esm/meta.json +1 -1
  60. package/dist/lib/node-esm/meta.mjs +1 -1
  61. package/dist/lib/node-esm/{react-surface-J5SW7VF2.mjs → react-surface-ZEVL3FXG.mjs} +5 -5
  62. package/dist/lib/node-esm/types/index.mjs +2 -2
  63. package/dist/types/src/components/Chart/Chart.d.ts.map +1 -1
  64. package/dist/types/src/components/ExplorerContainer.d.ts +4 -3
  65. package/dist/types/src/components/ExplorerContainer.d.ts.map +1 -1
  66. package/dist/types/src/components/Globe/Globe.d.ts.map +1 -1
  67. package/dist/types/src/components/Graph/D3ForceGraph.d.ts +14 -0
  68. package/dist/types/src/components/Graph/D3ForceGraph.d.ts.map +1 -0
  69. package/dist/types/src/components/Graph/D3ForceGraph.stories.d.ts +6 -0
  70. package/dist/types/src/components/Graph/D3ForceGraph.stories.d.ts.map +1 -0
  71. package/dist/types/src/components/Graph/ForceGraph.d.ts +8 -0
  72. package/dist/types/src/components/Graph/ForceGraph.d.ts.map +1 -0
  73. package/dist/types/src/components/Graph/{Graph.stories.d.ts → ForceGraph.stories.d.ts} +1 -1
  74. package/dist/types/src/components/Graph/ForceGraph.stories.d.ts.map +1 -0
  75. package/dist/types/src/components/Graph/adapter.d.ts +21 -0
  76. package/dist/types/src/components/Graph/adapter.d.ts.map +1 -0
  77. package/dist/types/src/components/Graph/index.d.ts +2 -2
  78. package/dist/types/src/components/Graph/index.d.ts.map +1 -1
  79. package/dist/types/src/components/Graph/testing.d.ts +14 -0
  80. package/dist/types/src/components/Graph/testing.d.ts.map +1 -0
  81. package/dist/types/src/components/Tree/Tree.d.ts.map +1 -1
  82. package/dist/types/src/components/Tree/layout/HierarchicalEdgeBundling.d.ts.map +1 -1
  83. package/dist/types/src/components/Tree/layout/RadialTree.d.ts.map +1 -1
  84. package/dist/types/src/components/Tree/layout/TidyTree.d.ts.map +1 -1
  85. package/dist/types/src/components/Tree/testing/generator.d.ts +8 -0
  86. package/dist/types/src/components/Tree/testing/generator.d.ts.map +1 -0
  87. package/dist/types/src/components/Tree/testing/index.d.ts +2 -0
  88. package/dist/types/src/components/Tree/testing/index.d.ts.map +1 -0
  89. package/dist/types/src/components/Tree/types/index.d.ts +3 -0
  90. package/dist/types/src/components/Tree/types/index.d.ts.map +1 -0
  91. package/dist/types/src/components/Tree/types/tree.d.ts +83 -0
  92. package/dist/types/src/components/Tree/types/tree.d.ts.map +1 -0
  93. package/dist/types/src/components/Tree/types/tree.test.d.ts +2 -0
  94. package/dist/types/src/components/Tree/types/tree.test.d.ts.map +1 -0
  95. package/dist/types/src/components/Tree/types/types.d.ts +8 -0
  96. package/dist/types/src/components/Tree/types/types.d.ts.map +1 -0
  97. package/dist/types/src/components/index.d.ts +2 -2
  98. package/dist/types/src/components/plot.d.ts.map +1 -1
  99. package/dist/types/src/hooks/index.d.ts +2 -0
  100. package/dist/types/src/hooks/index.d.ts.map +1 -0
  101. package/dist/types/src/hooks/useGraphModel.d.ts +4 -0
  102. package/dist/types/src/hooks/useGraphModel.d.ts.map +1 -0
  103. package/dist/types/src/index.d.ts +2 -1
  104. package/dist/types/src/index.d.ts.map +1 -1
  105. package/dist/types/src/translations.d.ts +2 -8
  106. package/dist/types/src/translations.d.ts.map +1 -1
  107. package/dist/types/src/types/schema.d.ts +6 -6
  108. package/dist/types/src/types/schema.d.ts.map +1 -1
  109. package/dist/types/src/types/types.d.ts +6 -6
  110. package/dist/types/src/types/types.d.ts.map +1 -1
  111. package/dist/types/tsconfig.tsbuildinfo +1 -1
  112. package/package.json +30 -27
  113. package/src/capabilities/intent-resolver.ts +2 -2
  114. package/src/components/ExplorerContainer.tsx +11 -4
  115. package/src/components/Globe/Globe.stories.tsx +13 -13
  116. package/src/components/Graph/D3ForceGraph.stories.tsx +64 -0
  117. package/src/components/Graph/D3ForceGraph.tsx +101 -0
  118. package/src/components/Graph/ForceGraph.stories.tsx +64 -0
  119. package/src/components/Graph/{Graph.tsx → ForceGraph.tsx} +19 -26
  120. package/src/components/Graph/adapter.ts +47 -0
  121. package/src/components/Graph/index.ts +2 -3
  122. package/src/components/Graph/testing.ts +57 -0
  123. package/src/components/Tree/Tree.stories.tsx +1 -1
  124. package/src/components/Tree/Tree.tsx +11 -18
  125. package/src/components/Tree/layout/HierarchicalEdgeBundling.ts +17 -19
  126. package/src/components/Tree/layout/RadialTree.ts +5 -7
  127. package/src/components/Tree/layout/TidyTree.ts +5 -6
  128. package/src/components/Tree/testing/generator.ts +46 -0
  129. package/src/components/Tree/testing/index.ts +5 -0
  130. package/src/components/Tree/types/index.ts +6 -0
  131. package/src/components/Tree/types/tree.test.ts +133 -0
  132. package/src/components/Tree/types/tree.ts +287 -0
  133. package/src/components/Tree/types/types.ts +41 -0
  134. package/src/hooks/index.ts +5 -0
  135. package/src/hooks/useGraphModel.ts +35 -0
  136. package/src/index.ts +2 -2
  137. package/src/meta.ts +2 -2
  138. package/src/types/schema.ts +5 -3
  139. package/src/types/types.ts +5 -5
  140. package/dist/lib/browser/ExplorerContainer-HL532ODG.mjs +0 -27
  141. package/dist/lib/browser/ExplorerContainer-HL532ODG.mjs.map +0 -7
  142. package/dist/lib/browser/chunk-QLQLPZNI.mjs.map +0 -7
  143. package/dist/lib/browser/chunk-SBLNE7FL.mjs +0 -205
  144. package/dist/lib/browser/chunk-SBLNE7FL.mjs.map +0 -7
  145. package/dist/lib/browser/intent-resolver-NHHRWTOP.mjs.map +0 -7
  146. package/dist/lib/node/ExplorerContainer-73AHSBAG.cjs.map +0 -7
  147. package/dist/lib/node/chunk-HCDBN6NN.cjs.map +0 -7
  148. package/dist/lib/node/chunk-OIHH6TVE.cjs +0 -236
  149. package/dist/lib/node/chunk-OIHH6TVE.cjs.map +0 -7
  150. package/dist/lib/node/chunk-YLL7H7CZ.cjs.map +0 -7
  151. package/dist/lib/node/intent-resolver-EEOTX3OZ.cjs.map +0 -7
  152. package/dist/lib/node-esm/ExplorerContainer-NMI55PYM.mjs +0 -28
  153. package/dist/lib/node-esm/ExplorerContainer-NMI55PYM.mjs.map +0 -7
  154. package/dist/lib/node-esm/chunk-QZH2GDN5.mjs.map +0 -7
  155. package/dist/lib/node-esm/chunk-SZRRNWYT.mjs +0 -207
  156. package/dist/lib/node-esm/chunk-SZRRNWYT.mjs.map +0 -7
  157. package/dist/lib/node-esm/intent-resolver-PTFKXAT4.mjs.map +0 -7
  158. package/dist/types/src/components/Graph/Graph.d.ts +0 -8
  159. package/dist/types/src/components/Graph/Graph.d.ts.map +0 -1
  160. package/dist/types/src/components/Graph/Graph.stories.d.ts.map +0 -1
  161. package/dist/types/src/components/Graph/graph-model.d.ts +0 -39
  162. package/dist/types/src/components/Graph/graph-model.d.ts.map +0 -1
  163. package/dist/types/src/components/Tree/types.d.ts +0 -8
  164. package/dist/types/src/components/Tree/types.d.ts.map +0 -1
  165. package/src/components/Graph/Graph.stories.tsx +0 -62
  166. package/src/components/Graph/graph-model.ts +0 -193
  167. package/src/components/Tree/types.ts +0 -40
  168. /package/dist/lib/browser/{react-surface-N7TC6BMF.mjs.map → react-surface-H3YDMXAQ.mjs.map} +0 -0
  169. /package/dist/lib/node/{react-surface-WD4G2NRS.cjs.map → react-surface-6ESLSM33.cjs.map} +0 -0
  170. /package/dist/lib/node-esm/{react-surface-J5SW7VF2.mjs.map → react-surface-ZEVL3FXG.mjs.map} +0 -0
@@ -1,8 +1,5 @@
1
- import {
2
- SpaceGraphModel
3
- } from "./chunk-SBLNE7FL.mjs";
4
-
5
1
  // packages/plugins/plugin-explorer/src/components/Chart/Chart.tsx
2
+ import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
6
3
  import * as Plot from "@observablehq/plot";
7
4
  import React, { useEffect } from "react";
8
5
  import { useResizeDetector } from "react-resize-detector";
@@ -20,43 +17,49 @@ var defaultOptions = {
20
17
  fillOpacity: 0.2
21
18
  };
22
19
  var Chart = ({ items = [], accessor, options = defaultOptions }) => {
23
- const { ref: containerRef, width = 0, height = 0 } = useResizeDetector({
24
- refreshRate: 200
25
- });
26
- useEffect(() => {
27
- if (!width || !height) {
28
- return;
29
- }
30
- const plot3 = Plot.plot({
31
- grid: true,
20
+ var _effect = _useSignals();
21
+ try {
22
+ const { ref: containerRef, width = 0, height = 0 } = useResizeDetector({
23
+ refreshRate: 200
24
+ });
25
+ useEffect(() => {
26
+ if (!width || !height) {
27
+ return;
28
+ }
29
+ const plot3 = Plot.plot({
30
+ grid: true,
31
+ width,
32
+ height,
33
+ style: {
34
+ background: "transparent"
35
+ },
36
+ marks: [
37
+ Plot.frame(),
38
+ Plot.dot(items, {
39
+ x: createAdapter("x", accessor),
40
+ y: createAdapter("y", accessor),
41
+ ...options
42
+ })
43
+ ]
44
+ });
45
+ containerRef.current.append(plot3);
46
+ return () => plot3?.remove();
47
+ }, [
48
+ items,
32
49
  width,
33
- height,
34
- style: {
35
- background: "transparent"
36
- },
37
- marks: [
38
- Plot.frame(),
39
- Plot.dot(items, {
40
- x: createAdapter("x", accessor),
41
- y: createAdapter("y", accessor),
42
- ...options
43
- })
44
- ]
50
+ height
51
+ ]);
52
+ return /* @__PURE__ */ React.createElement("div", {
53
+ ref: containerRef,
54
+ className: "grow"
45
55
  });
46
- containerRef.current.append(plot3);
47
- return () => plot3?.remove();
48
- }, [
49
- items,
50
- width,
51
- height
52
- ]);
53
- return /* @__PURE__ */ React.createElement("div", {
54
- ref: containerRef,
55
- className: "grow"
56
- });
56
+ } finally {
57
+ _effect.f();
58
+ }
57
59
  };
58
60
 
59
61
  // packages/plugins/plugin-explorer/src/components/Globe/Globe.tsx
62
+ import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
60
63
  import * as Plot2 from "@observablehq/plot";
61
64
  import React2, { useEffect as useEffect2 } from "react";
62
65
  import { useResizeDetector as useResizeDetector2 } from "react-resize-detector";
@@ -10770,80 +10773,86 @@ var defaultOptions2 = {
10770
10773
  fill: "#003300"
10771
10774
  };
10772
10775
  var Globe = ({ items = [], accessor, projection = "orthographic", options = defaultOptions2 }) => {
10773
- const { ref: containerRef, width = 0, height = 0 } = useResizeDetector2({
10774
- refreshRate: 200
10775
- });
10776
- const land = topojson.feature(countries_110m_default, countries_110m_default.objects.land);
10777
- useEffect2(() => {
10778
- if (!width || !height) {
10779
- return;
10780
- }
10781
- const plot3 = Plot2.plot({
10782
- // https://observablehq.com/plot/features/projections
10783
- projection: {
10784
- type: projection,
10785
- rotate: [
10786
- -100,
10787
- -20
10776
+ var _effect = _useSignals2();
10777
+ try {
10778
+ const { ref: containerRef, width = 0, height = 0 } = useResizeDetector2({
10779
+ refreshRate: 200
10780
+ });
10781
+ const land = topojson.feature(countries_110m_default, countries_110m_default.objects.land);
10782
+ useEffect2(() => {
10783
+ if (!width || !height) {
10784
+ return;
10785
+ }
10786
+ const plot3 = Plot2.plot({
10787
+ // https://observablehq.com/plot/features/projections
10788
+ projection: {
10789
+ type: projection,
10790
+ rotate: [
10791
+ -100,
10792
+ -20
10793
+ ]
10794
+ },
10795
+ // projection: { type: 'equirectangular', rotate: [-140, -30] },
10796
+ width,
10797
+ height,
10798
+ style: {
10799
+ background: "transparent"
10800
+ },
10801
+ // TODO(burdon): Create simple wrapper for Plot with good defaults.
10802
+ marks: [
10803
+ Plot2.sphere({
10804
+ fill: "lightblue",
10805
+ fillOpacity: 0.5
10806
+ }),
10807
+ Plot2.geo(land, {
10808
+ fill: "darkgreen",
10809
+ fillOpacity: 0.5
10810
+ }),
10811
+ Plot2.graticule(),
10812
+ Plot2.dot(items, {
10813
+ x: createAdapter("lat", accessor),
10814
+ y: createAdapter("lng", accessor),
10815
+ ...options
10816
+ })
10788
10817
  ]
10789
- },
10790
- // projection: { type: 'equirectangular', rotate: [-140, -30] },
10818
+ });
10819
+ containerRef.current.append(plot3);
10820
+ return () => plot3?.remove();
10821
+ }, [
10822
+ items,
10791
10823
  width,
10792
- height,
10793
- style: {
10794
- background: "transparent"
10795
- },
10796
- // TODO(burdon): Create simple wrapper for Plot with good defaults.
10797
- marks: [
10798
- Plot2.sphere({
10799
- fill: "lightblue",
10800
- fillOpacity: 0.5
10801
- }),
10802
- Plot2.geo(land, {
10803
- fill: "darkgreen",
10804
- fillOpacity: 0.5
10805
- }),
10806
- Plot2.graticule(),
10807
- Plot2.dot(items, {
10808
- x: createAdapter("lat", accessor),
10809
- y: createAdapter("lng", accessor),
10810
- ...options
10811
- })
10812
- ]
10824
+ height
10825
+ ]);
10826
+ return /* @__PURE__ */ React2.createElement("div", {
10827
+ ref: containerRef,
10828
+ className: "grow p-4"
10813
10829
  });
10814
- containerRef.current.append(plot3);
10815
- return () => plot3?.remove();
10816
- }, [
10817
- items,
10818
- width,
10819
- height
10820
- ]);
10821
- return /* @__PURE__ */ React2.createElement("div", {
10822
- ref: containerRef,
10823
- className: "grow p-4"
10824
- });
10830
+ } finally {
10831
+ _effect.f();
10832
+ }
10825
10833
  };
10826
10834
 
10827
10835
  // packages/plugins/plugin-explorer/src/components/Tree/Tree.tsx
10828
- import React3, { useEffect as useEffect3, useState } from "react";
10829
- import { useResizeDetector as useResizeDetector3 } from "react-resize-detector";
10830
- import { createSvgContext, SVG, SVGRoot } from "@dxos/gem-core";
10836
+ import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
10837
+ import React3, { useEffect as useEffect3, useRef, useState } from "react";
10831
10838
  import { useAsyncState } from "@dxos/react-ui";
10839
+ import { SVG } from "@dxos/react-ui-graph";
10840
+ import { SpaceGraphModel } from "@dxos/schema";
10832
10841
 
10833
10842
  // packages/plugins/plugin-explorer/src/components/Tree/layout/HierarchicalEdgeBundling.ts
10834
- import * as d3 from "d3";
10843
+ import { cluster, curveBundle, hierarchy, lineRadial, select } from "d3";
10835
10844
  var HierarchicalEdgeBundling = (s, data, options) => {
10836
- const svg = d3.select(s);
10845
+ const svg = select(s);
10837
10846
  svg.selectAll("*").remove();
10838
10847
  const { radius = 600, padding = 100, slots } = options;
10839
- const root = d3.hierarchy(flatten(data));
10840
- const tree3 = d3.cluster().size([
10848
+ const root = hierarchy(flatten(data));
10849
+ const tree3 = cluster().size([
10841
10850
  2 * Math.PI,
10842
10851
  radius - padding
10843
10852
  ]);
10844
10853
  const layout = tree3(addLinks(root));
10845
10854
  const node = svg.append("g").selectAll().data(layout.leaves()).join("g").attr("transform", (d) => `rotate(${d.x * (180 / Math.PI) - 90}) translate(${d.y},0)`).append("text").attr("class", slots?.text ?? "").attr("dy", "0.31em").attr("x", (d) => d.x < Math.PI ? 6 : -6).attr("text-anchor", (d) => d.x < Math.PI ? "start" : "end").attr("transform", (d) => d.x >= Math.PI ? "rotate(180)" : null).call((text) => text.text((d) => d.data.id.slice(0, 8)));
10846
- const line = d3.lineRadial().curve(d3.curveBundle.beta(0.85)).radius((d) => d.y).angle((d) => d.x);
10855
+ const line = lineRadial().curve(curveBundle.beta(0.85)).radius((d) => d.y).angle((d) => d.x);
10847
10856
  const links = svg.append("g").selectAll().data(layout.leaves().flatMap((leaf) => leaf.outgoing)).join("path").style("mix-blend-mode", "multiply").attr("class", slots?.path ?? "").attr("d", ([i, o]) => {
10848
10857
  return line(i.path(o));
10849
10858
  }).each(function(d) {
@@ -10894,21 +10903,21 @@ var flatten = (node) => {
10894
10903
  var HierarchicalEdgeBundling_default = HierarchicalEdgeBundling;
10895
10904
 
10896
10905
  // packages/plugins/plugin-explorer/src/components/Tree/layout/RadialTree.ts
10897
- import * as d32 from "d3";
10906
+ import { hierarchy as hierarchy2, linkRadial, select as select2, tree } from "d3";
10898
10907
  var RadialTree = (s, data, options) => {
10899
- const svg = d32.select(s);
10908
+ const svg = select2(s);
10900
10909
  svg.selectAll("*").remove();
10901
10910
  const { label, radius = 400, r = 4, slots } = options;
10902
10911
  const arc = 2 * Math.PI;
10903
- const root = d32.hierarchy(data);
10912
+ const root = hierarchy2(data);
10904
10913
  const descendants = root.descendants();
10905
10914
  const getLabel = label === null ? null : descendants.map((d) => label(d.data));
10906
- const layout = d32.tree().size([
10915
+ const layout = tree().size([
10907
10916
  arc,
10908
10917
  radius
10909
10918
  ]).separation((a, b) => (a.parent === b.parent ? 1 : 2) / a.depth);
10910
10919
  layout(root);
10911
- svg.append("g").selectAll("path").data(root.links()).join("path").attr("class", slots?.path ?? "").attr("d", d32.linkRadial().angle((d) => d.x + Math.PI / 2).radius((d) => d.y));
10920
+ svg.append("g").selectAll("path").data(root.links()).join("path").attr("class", slots?.path ?? "").attr("d", linkRadial().angle((d) => d.x + Math.PI / 2).radius((d) => d.y));
10912
10921
  const node = svg.append("g").selectAll("a").data(root.descendants()).join("a").attr("transform", (d) => `rotate(${d.x * 180 / Math.PI}) translate(${d.y},0)`);
10913
10922
  node.append("circle").attr("class", slots?.node ?? "").attr("r", r);
10914
10923
  if (getLabel) {
@@ -10919,17 +10928,17 @@ var RadialTree = (s, data, options) => {
10919
10928
  var RadialTree_default = RadialTree;
10920
10929
 
10921
10930
  // packages/plugins/plugin-explorer/src/components/Tree/layout/TidyTree.ts
10922
- import * as d33 from "d3";
10931
+ import { curveBumpX, hierarchy as hierarchy3, link, select as select3, tree as tree2 } from "d3";
10923
10932
  var TidyTree = (s, data, options) => {
10924
- const svg = d33.select(s);
10933
+ const svg = select3(s);
10925
10934
  svg.selectAll("*").remove();
10926
10935
  const { label, width, height, r = 4, padding = 4, margin = 60, slots } = options;
10927
- const root = d33.hierarchy(data);
10936
+ const root = hierarchy3(data);
10928
10937
  const descendants = root.descendants();
10929
10938
  const getLabel = label == null ? null : descendants.map((d) => label(d.data));
10930
10939
  const dx = 16;
10931
10940
  const dy = width / (root.height + padding);
10932
- const layout = d33.tree().nodeSize([
10941
+ const layout = tree2().nodeSize([
10933
10942
  dx,
10934
10943
  dy
10935
10944
  ]);
@@ -10954,7 +10963,7 @@ var TidyTree = (s, data, options) => {
10954
10963
  });
10955
10964
  const sx = Math.min(2, Math.max(1, (height - margin * 2) / (x1 - x0)));
10956
10965
  const oy = -(width - (y1 - y0)) / 2;
10957
- svg.append("g").selectAll("path").data(root.links()).join("path").attr("class", slots?.path ?? "").attr("d", d33.link(d33.curveBumpX).x((d) => d.y + oy).y((d) => d.x * sx));
10966
+ svg.append("g").selectAll("path").data(root.links()).join("path").attr("class", slots?.path ?? "").attr("d", link(curveBumpX).x((d) => d.y + oy).y((d) => d.x * sx));
10958
10967
  const node = svg.append("g").selectAll("a").data(root.descendants()).join("a").attr("transform", (d) => `translate(${d.y + oy},${d.x * sx})`);
10959
10968
  node.append("circle").attr("class", slots?.node ?? "").attr("r", r);
10960
10969
  if (getLabel) {
@@ -10963,26 +10972,275 @@ var TidyTree = (s, data, options) => {
10963
10972
  };
10964
10973
  var TidyTree_default = TidyTree;
10965
10974
 
10966
- // packages/plugins/plugin-explorer/src/components/Tree/types.ts
10967
- var mapGraphToTreeData = (model, maxDepth = 8) => {
10968
- const mapNode = (node, depth = 0) => {
10969
- const treeNode = {
10970
- id: model.idAccessor(node),
10971
- label: model.idAccessor(node).slice(0, 8)
10975
+ // packages/plugins/plugin-explorer/src/components/Tree/types/tree.ts
10976
+ import { Schema } from "effect";
10977
+ import { Type } from "@dxos/echo";
10978
+ import { ObjectId, Ref, Expando } from "@dxos/echo-schema";
10979
+ import { invariant } from "@dxos/invariant";
10980
+ import { live } from "@dxos/live-object";
10981
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-explorer/src/components/Tree/types/tree.ts";
10982
+ var TreeNodeType = Schema.Struct({
10983
+ id: ObjectId,
10984
+ children: Schema.mutable(Schema.Array(ObjectId)),
10985
+ data: Schema.mutable(Schema.Record({
10986
+ key: Schema.String,
10987
+ value: Schema.Any
10988
+ })),
10989
+ ref: Schema.optional(Ref(Expando))
10990
+ }).pipe(Schema.mutable);
10991
+ var TreeType = Schema.Struct({
10992
+ root: ObjectId,
10993
+ nodes: Schema.mutable(Schema.Record({
10994
+ key: ObjectId,
10995
+ value: TreeNodeType
10996
+ }))
10997
+ }).pipe(Type.Obj({
10998
+ typename: "dxos.org/type/Tree",
10999
+ version: "0.1.0"
11000
+ }));
11001
+ var Tree = class _Tree {
11002
+ static {
11003
+ this.create = () => {
11004
+ const id = ObjectId.random();
11005
+ return live(TreeType, {
11006
+ root: id,
11007
+ nodes: {
11008
+ [id]: {
11009
+ id,
11010
+ children: [],
11011
+ data: {
11012
+ text: ""
11013
+ }
11014
+ }
11015
+ }
11016
+ });
10972
11017
  };
10973
- const links = model.graph.links.filter((link2) => link2.source === treeNode.id);
10974
- if (depth < maxDepth) {
10975
- treeNode.children = links.map((link2) => mapNode(model.graph.nodes.find((node2) => model.idAccessor(node2) === link2.target), depth + 1));
11018
+ }
11019
+ constructor(tree3) {
11020
+ this._tree = tree3 ?? _Tree.create();
11021
+ }
11022
+ get tree() {
11023
+ return this._tree;
11024
+ }
11025
+ // TODO(burdon): Make reactive.
11026
+ get size() {
11027
+ return Object.keys(this._tree.nodes).length;
11028
+ }
11029
+ get root() {
11030
+ return this.getNode(this._tree.root);
11031
+ }
11032
+ //
11033
+ // Traversal
11034
+ //
11035
+ /**
11036
+ * Recursively traverse the tree until the callback returns a value.
11037
+ */
11038
+ tranverse(callback, root = this._tree.root, depth = 0) {
11039
+ const node = this._tree.nodes[root];
11040
+ const result = callback(node, depth);
11041
+ if (result !== void 0) {
11042
+ return result;
10976
11043
  }
10977
- return treeNode;
10978
- };
10979
- let data;
10980
- if (model.selected) {
10981
- const node = model.graph.nodes.find((node2) => model.idAccessor(node2) === model.selected);
10982
- if (node) {
10983
- data = mapNode(node);
11044
+ for (const childId of node.children) {
11045
+ const result2 = this.tranverse(callback, childId, depth + 1);
11046
+ if (result2 !== void 0) {
11047
+ return result2;
11048
+ }
11049
+ }
11050
+ }
11051
+ getNode(id) {
11052
+ const node = this._tree.nodes[id];
11053
+ invariant(node, void 0, {
11054
+ F: __dxlog_file,
11055
+ L: 100,
11056
+ S: this,
11057
+ A: [
11058
+ "node",
11059
+ ""
11060
+ ]
11061
+ });
11062
+ return node;
11063
+ }
11064
+ /**
11065
+ * Get the children of a node.
11066
+ */
11067
+ getChildNodes(node) {
11068
+ return node.children.map((id) => this.getNode(id));
11069
+ }
11070
+ /**
11071
+ * Get the parent of a node.
11072
+ */
11073
+ getParent(node) {
11074
+ const parent = this.tranverse((n) => {
11075
+ if (n.children.includes(node.id)) {
11076
+ return n;
11077
+ }
11078
+ });
11079
+ return parent ?? null;
11080
+ }
11081
+ /**
11082
+ * Get the next node in the tree.
11083
+ */
11084
+ getNext(node, hierarchical = true) {
11085
+ if (hierarchical && node.children.length) {
11086
+ return this.getChildNodes(node)[0];
11087
+ } else {
11088
+ const parent = this.getParent(node);
11089
+ if (parent) {
11090
+ const idx = this.getChildNodes(parent).findIndex(({ id }) => id === node.id);
11091
+ if (idx < parent.children.length - 1) {
11092
+ return this.getNode(parent.children[idx + 1]);
11093
+ } else {
11094
+ return this.getNext(parent, false);
11095
+ }
11096
+ }
11097
+ }
11098
+ }
11099
+ /**
11100
+ * Get the previous node in the tree.
11101
+ */
11102
+ getPrevious(node, hierarchical = true) {
11103
+ const parent = this.getParent(node);
11104
+ const idx = this.getChildNodes(parent).findIndex(({ id }) => id === node.id);
11105
+ if (idx === 0) {
11106
+ if (hierarchical) {
11107
+ return parent;
11108
+ }
11109
+ } else {
11110
+ const previous = this.getNode(parent.children[idx - 1]);
11111
+ if (hierarchical && previous.children.length) {
11112
+ return this.getLastDescendent(previous);
11113
+ }
11114
+ return previous;
11115
+ }
11116
+ }
11117
+ /**
11118
+ * Get the last descendent of a node.
11119
+ */
11120
+ getLastDescendent(node) {
11121
+ const children = this.getChildNodes(node);
11122
+ const last = children.length ? children[children.length - 1] : void 0;
11123
+ if (last) {
11124
+ return this.getLastDescendent(last);
11125
+ }
11126
+ return node;
11127
+ }
11128
+ //
11129
+ // Mutations
11130
+ //
11131
+ /**
11132
+ * Clear tree.
11133
+ */
11134
+ clear() {
11135
+ const root = this._tree.nodes[this._tree.root];
11136
+ root.children.length = 0;
11137
+ this._tree.nodes = {
11138
+ [root.id]: root
11139
+ };
11140
+ }
11141
+ /**
11142
+ * Add node.
11143
+ */
11144
+ addNode(parent, node, index) {
11145
+ if (!node) {
11146
+ const id = ObjectId.random();
11147
+ node = {
11148
+ id,
11149
+ children: [],
11150
+ data: {
11151
+ text: ""
11152
+ }
11153
+ };
11154
+ }
11155
+ this._tree.nodes[node.id] = node;
11156
+ parent.children.splice(index ?? parent.children.length, 0, node.id);
11157
+ return node;
11158
+ }
11159
+ /**
11160
+ * Delete node.
11161
+ */
11162
+ deleteNode(parent, id) {
11163
+ const node = this._tree.nodes[id];
11164
+ if (!node) {
11165
+ return void 0;
11166
+ }
11167
+ delete this._tree.nodes[node.id];
11168
+ const idx = parent.children.findIndex((child) => child === id);
11169
+ if (idx !== -1) {
11170
+ parent.children.splice(idx, 1);
11171
+ }
11172
+ return node;
11173
+ }
11174
+ /**
11175
+ * Move child node.
11176
+ */
11177
+ moveNode(node, from, to) {
11178
+ invariant(from >= 0 && from < node.children.length, void 0, {
11179
+ F: __dxlog_file,
11180
+ L: 230,
11181
+ S: this,
11182
+ A: [
11183
+ "from >= 0 && from < node.children.length",
11184
+ ""
11185
+ ]
11186
+ });
11187
+ invariant(to >= 0 && to < node.children.length, void 0, {
11188
+ F: __dxlog_file,
11189
+ L: 231,
11190
+ S: this,
11191
+ A: [
11192
+ "to >= 0 && to < node.children.length",
11193
+ ""
11194
+ ]
11195
+ });
11196
+ if (from === to) {
11197
+ return null;
11198
+ }
11199
+ const child = node.children[from];
11200
+ node.children.splice(from, 1);
11201
+ node.children.splice(to, 0, child);
11202
+ return this.getNode(child);
11203
+ }
11204
+ /**
11205
+ * Indent node.
11206
+ */
11207
+ indentNode(node) {
11208
+ const parent = this.getParent(node);
11209
+ if (!parent) {
11210
+ return;
11211
+ }
11212
+ const idx = parent.children.findIndex((child) => child === node.id);
11213
+ if (idx < 1 || idx >= parent.children.length) {
11214
+ return;
10984
11215
  }
11216
+ const previous = this.getNode(parent.children[idx - 1]);
11217
+ parent.children.splice(idx, 1);
11218
+ previous.children.push(node.id);
10985
11219
  }
11220
+ /**
11221
+ * Unindent node.
11222
+ */
11223
+ unindentNode(node) {
11224
+ const parent = this.getParent(node);
11225
+ if (!parent) {
11226
+ return;
11227
+ }
11228
+ const ancestor = this.getParent(parent);
11229
+ if (!ancestor) {
11230
+ return;
11231
+ }
11232
+ const nodeIdx = parent.children.findIndex((id) => id === node.id);
11233
+ const [_, ...rest] = parent.children.splice(nodeIdx, parent.children.length - nodeIdx);
11234
+ parent.children.splice(nodeIdx, parent.children.length - nodeIdx);
11235
+ const parentIdx = this.getChildNodes(ancestor).findIndex((n) => n.id === parent.id);
11236
+ ancestor.children.splice(parentIdx + 1, 0, node.id);
11237
+ node.children.push(...rest);
11238
+ }
11239
+ };
11240
+
11241
+ // packages/plugins/plugin-explorer/src/components/Tree/types/types.ts
11242
+ var mapGraphToTreeData = (model, maxDepth = 8) => {
11243
+ let data;
10986
11244
  return data;
10987
11245
  };
10988
11246
 
@@ -11006,66 +11264,68 @@ var renderers = /* @__PURE__ */ new Map([
11006
11264
  HierarchicalEdgeBundling_default
11007
11265
  ]
11008
11266
  ]);
11009
- var Tree = ({ space, selected, variant = "tidy", onNodeClick }) => {
11010
- const [model] = useAsyncState(async () => space ? new SpaceGraphModel().open(space, selected) : void 0, [
11011
- space,
11012
- selected
11013
- ]);
11014
- const [tree3, setTree] = useState();
11015
- useEffect3(() => {
11016
- return model?.subscribe(() => {
11017
- const tree4 = mapGraphToTreeData(model);
11018
- setTree(tree4);
11019
- }, true);
11020
- }, [
11021
- model
11022
- ]);
11023
- const context = createSvgContext();
11024
- const { ref, width = 0, height = 0 } = useResizeDetector3();
11025
- useEffect3(() => {
11026
- if (width && height) {
11027
- const size = Math.min(width, height);
11028
- const radius = size * 0.4;
11029
- const options = {
11030
- // TODO(burdon): Type.
11031
- label: (d) => d.label ?? d.id,
11032
- width,
11033
- height,
11034
- radius,
11035
- marginLeft: (width - radius * 2) / 2,
11036
- marginRight: (width - radius * 2) / 2,
11037
- marginTop: (height - radius * 2) / 2,
11038
- marginBottom: (height - radius * 2) / 2,
11039
- slots: defaultTreeLayoutSlots
11040
- };
11041
- if (tree3) {
11042
- const renderer = renderers.get(variant);
11043
- renderer?.(context.ref.current, tree3, options);
11267
+ var Tree2 = ({ space, selected, variant = "tidy", onNodeClick }) => {
11268
+ var _effect = _useSignals3();
11269
+ try {
11270
+ const [model] = useAsyncState(async () => space ? new SpaceGraphModel().open(space) : void 0, [
11271
+ space,
11272
+ selected
11273
+ ]);
11274
+ const [tree3, setTree] = useState();
11275
+ useEffect3(() => {
11276
+ return model?.subscribe(() => {
11277
+ const tree4 = mapGraphToTreeData(model);
11278
+ setTree(tree4);
11279
+ }, true);
11280
+ }, [
11281
+ model
11282
+ ]);
11283
+ const context = useRef(null);
11284
+ useEffect3(() => {
11285
+ if (context.current) {
11286
+ const { width, height } = context.current.size;
11287
+ const size = Math.min(width, height);
11288
+ const radius = size * 0.4;
11289
+ const options = {
11290
+ // TODO(burdon): Type.
11291
+ label: (d) => d.label ?? d.id,
11292
+ width,
11293
+ height,
11294
+ radius,
11295
+ marginLeft: (width - radius * 2) / 2,
11296
+ marginRight: (width - radius * 2) / 2,
11297
+ marginTop: (height - radius * 2) / 2,
11298
+ marginBottom: (height - radius * 2) / 2,
11299
+ slots: defaultTreeLayoutSlots
11300
+ };
11301
+ if (tree3) {
11302
+ const renderer = renderers.get(variant);
11303
+ renderer?.(context.current.svg, tree3, options);
11304
+ }
11044
11305
  }
11045
- }
11046
- }, [
11047
- tree3,
11048
- width,
11049
- height
11050
- ]);
11051
- return /* @__PURE__ */ React3.createElement("div", {
11052
- ref,
11053
- className: "flex grow overflow-hidden",
11054
- onClick: () => onNodeClick?.()
11055
- }, /* @__PURE__ */ React3.createElement(SVGRoot, {
11056
- context
11057
- }, /* @__PURE__ */ React3.createElement(SVG, null)));
11306
+ }, [
11307
+ context.current,
11308
+ tree3
11309
+ ]);
11310
+ return /* @__PURE__ */ React3.createElement("div", {
11311
+ onClick: () => onNodeClick?.()
11312
+ }, /* @__PURE__ */ React3.createElement(SVG.Root, {
11313
+ ref: context
11314
+ }));
11315
+ } finally {
11316
+ _effect.f();
11317
+ }
11058
11318
  };
11059
11319
 
11060
11320
  // packages/plugins/plugin-explorer/src/components/index.ts
11061
11321
  import { lazy } from "react";
11062
- var ExplorerContainer = lazy(() => import("./ExplorerContainer-HL532ODG.mjs"));
11322
+ var ExplorerContainer = lazy(() => import("./ExplorerContainer-BBZ54DJS.mjs"));
11063
11323
 
11064
11324
  export {
11065
11325
  Chart,
11066
11326
  Globe,
11067
11327
  defaultTreeLayoutSlots,
11068
- Tree,
11328
+ Tree2 as Tree,
11069
11329
  ExplorerContainer
11070
11330
  };
11071
- //# sourceMappingURL=chunk-B2DMPSP5.mjs.map
11331
+ //# sourceMappingURL=chunk-73GQ46YO.mjs.map