@dxos/plugin-explorer 0.8.1 → 0.8.2-main.10c050d

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