@dxos/plugin-explorer 0.8.4-main.1da679c → 0.8.4-main.21d9917

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 (151) hide show
  1. package/dist/lib/browser/ExplorerContainer-BFAWRIAJ.mjs +45 -0
  2. package/dist/lib/browser/ExplorerContainer-BFAWRIAJ.mjs.map +7 -0
  3. package/dist/lib/browser/{chunk-VNOGW2JS.mjs → chunk-AGZAGILW.mjs} +138 -403
  4. package/dist/lib/browser/{chunk-VNOGW2JS.mjs.map → chunk-AGZAGILW.mjs.map} +3 -3
  5. package/dist/lib/browser/{chunk-2MKBRIUT.mjs → chunk-BZMTFAP3.mjs} +8 -5
  6. package/dist/lib/browser/chunk-BZMTFAP3.mjs.map +7 -0
  7. package/dist/lib/browser/chunk-DXORXPUJ.mjs +83 -0
  8. package/dist/lib/browser/chunk-DXORXPUJ.mjs.map +7 -0
  9. package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
  10. package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
  11. package/dist/lib/browser/chunk-MGBT2ZFU.mjs +177 -0
  12. package/dist/lib/browser/chunk-MGBT2ZFU.mjs.map +7 -0
  13. package/dist/lib/browser/chunk-YNQF4CPY.mjs +24 -0
  14. package/dist/lib/browser/chunk-YNQF4CPY.mjs.map +7 -0
  15. package/dist/lib/browser/index.mjs +53 -65
  16. package/dist/lib/browser/index.mjs.map +4 -4
  17. package/dist/lib/browser/meta.json +1 -1
  18. package/dist/lib/browser/meta.mjs +2 -3
  19. package/dist/lib/browser/react-surface-24INQLMB.mjs +35 -0
  20. package/dist/lib/browser/react-surface-24INQLMB.mjs.map +7 -0
  21. package/dist/lib/browser/types/index.mjs +6 -6
  22. package/dist/lib/node-esm/ExplorerContainer-YQ2KKBVS.mjs +46 -0
  23. package/dist/lib/node-esm/ExplorerContainer-YQ2KKBVS.mjs.map +7 -0
  24. package/dist/lib/node-esm/{chunk-PIAXA43R.mjs → chunk-DK77RB6M.mjs} +8 -5
  25. package/dist/lib/node-esm/chunk-DK77RB6M.mjs.map +7 -0
  26. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
  27. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
  28. package/dist/lib/node-esm/{chunk-3ODK27PU.mjs → chunk-IPIGIQHX.mjs} +8 -5
  29. package/dist/lib/node-esm/chunk-IPIGIQHX.mjs.map +7 -0
  30. package/dist/lib/node-esm/{chunk-ODMJ7DPA.mjs → chunk-QLMTN2XI.mjs} +138 -403
  31. package/dist/lib/node-esm/{chunk-ODMJ7DPA.mjs.map → chunk-QLMTN2XI.mjs.map} +3 -3
  32. package/dist/lib/node-esm/chunk-UCH3WYRD.mjs +84 -0
  33. package/dist/lib/node-esm/chunk-UCH3WYRD.mjs.map +7 -0
  34. package/dist/lib/node-esm/chunk-YWJBDETV.mjs +179 -0
  35. package/dist/lib/node-esm/chunk-YWJBDETV.mjs.map +7 -0
  36. package/dist/lib/node-esm/index.mjs +53 -65
  37. package/dist/lib/node-esm/index.mjs.map +4 -4
  38. package/dist/lib/node-esm/meta.json +1 -1
  39. package/dist/lib/node-esm/meta.mjs +2 -3
  40. package/dist/lib/node-esm/react-surface-F465WXH7.mjs +36 -0
  41. package/dist/lib/node-esm/react-surface-F465WXH7.mjs.map +7 -0
  42. package/dist/lib/node-esm/types/index.mjs +6 -6
  43. package/dist/types/src/ExplorerPlugin.d.ts +2 -1
  44. package/dist/types/src/ExplorerPlugin.d.ts.map +1 -1
  45. package/dist/types/src/capabilities/index.d.ts +1 -2
  46. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  47. package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
  48. package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
  49. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
  50. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
  51. package/dist/types/src/components/Chart/Chart.stories.d.ts +3 -1
  52. package/dist/types/src/components/Chart/Chart.stories.d.ts.map +1 -1
  53. package/dist/types/src/components/ExplorerContainer.d.ts +4 -6
  54. package/dist/types/src/components/ExplorerContainer.d.ts.map +1 -1
  55. package/dist/types/src/components/Globe/Globe.stories.d.ts +3 -1
  56. package/dist/types/src/components/Globe/Globe.stories.d.ts.map +1 -1
  57. package/dist/types/src/components/Graph/D3ForceGraph.d.ts +2 -2
  58. package/dist/types/src/components/Graph/D3ForceGraph.d.ts.map +1 -1
  59. package/dist/types/src/components/Graph/D3ForceGraph.stories.d.ts +5 -10
  60. package/dist/types/src/components/Graph/D3ForceGraph.stories.d.ts.map +1 -1
  61. package/dist/types/src/components/Graph/ForceGraph.stories.d.ts +4 -2
  62. package/dist/types/src/components/Graph/ForceGraph.stories.d.ts.map +1 -1
  63. package/dist/types/src/components/Graph/adapter.d.ts +1 -1
  64. package/dist/types/src/components/Graph/adapter.d.ts.map +1 -1
  65. package/dist/types/src/components/Graph/testing.d.ts.map +1 -1
  66. package/dist/types/src/components/Tree/Tree.d.ts.map +1 -1
  67. package/dist/types/src/components/Tree/Tree.stories.d.ts +0 -1
  68. package/dist/types/src/components/Tree/Tree.stories.d.ts.map +1 -1
  69. package/dist/types/src/components/Tree/testing/generator.d.ts.map +1 -1
  70. package/dist/types/src/components/Tree/types/tree.d.ts +18 -16
  71. package/dist/types/src/components/Tree/types/tree.d.ts.map +1 -1
  72. package/dist/types/src/components/Tree/types/types.d.ts +1 -1
  73. package/dist/types/src/components/Tree/types/types.d.ts.map +1 -1
  74. package/dist/types/src/components/index.d.ts +2 -4
  75. package/dist/types/src/components/index.d.ts.map +1 -1
  76. package/dist/types/src/hooks/useGraphModel.d.ts.map +1 -1
  77. package/dist/types/src/meta.d.ts +2 -3
  78. package/dist/types/src/meta.d.ts.map +1 -1
  79. package/dist/types/src/translations.d.ts +24 -5
  80. package/dist/types/src/translations.d.ts.map +1 -1
  81. package/dist/types/src/types/ExplorerAction.d.ts +6 -0
  82. package/dist/types/src/types/ExplorerAction.d.ts.map +1 -0
  83. package/dist/types/src/types/Graph.d.ts +30 -0
  84. package/dist/types/src/types/Graph.d.ts.map +1 -0
  85. package/dist/types/src/types/index.d.ts +2 -2
  86. package/dist/types/src/types/index.d.ts.map +1 -1
  87. package/dist/types/tsconfig.tsbuildinfo +1 -1
  88. package/package.json +53 -47
  89. package/src/ExplorerPlugin.tsx +29 -52
  90. package/src/capabilities/index.ts +1 -4
  91. package/src/capabilities/react-surface/index.ts +7 -0
  92. package/src/capabilities/react-surface/react-surface.tsx +30 -0
  93. package/src/components/Chart/Chart.stories.tsx +5 -4
  94. package/src/components/ExplorerContainer.tsx +26 -11
  95. package/src/components/Globe/Globe.stories.tsx +5 -4
  96. package/src/components/Graph/D3ForceGraph.stories.tsx +32 -16
  97. package/src/components/Graph/D3ForceGraph.tsx +5 -5
  98. package/src/components/Graph/ForceGraph.stories.tsx +32 -16
  99. package/src/components/Graph/ForceGraph.tsx +3 -3
  100. package/src/components/Graph/adapter.ts +14 -8
  101. package/src/components/Graph/testing.ts +11 -8
  102. package/src/components/Tree/Tree.stories.tsx +3 -4
  103. package/src/components/Tree/Tree.tsx +10 -5
  104. package/src/components/Tree/testing/generator.ts +4 -2
  105. package/src/components/Tree/types/tree.test.ts +5 -3
  106. package/src/components/Tree/types/tree.ts +40 -19
  107. package/src/components/Tree/types/types.ts +1 -1
  108. package/src/components/index.ts +3 -3
  109. package/src/hooks/useGraphModel.ts +6 -4
  110. package/src/meta.ts +9 -6
  111. package/src/translations.ts +6 -2
  112. package/src/types/ExplorerAction.ts +21 -0
  113. package/src/types/Graph.ts +62 -0
  114. package/src/types/index.ts +2 -2
  115. package/dist/lib/browser/ExplorerContainer-7MTDS2TQ.mjs +0 -37
  116. package/dist/lib/browser/ExplorerContainer-7MTDS2TQ.mjs.map +0 -7
  117. package/dist/lib/browser/chunk-2MKBRIUT.mjs.map +0 -7
  118. package/dist/lib/browser/chunk-3YITRGGW.mjs +0 -203
  119. package/dist/lib/browser/chunk-3YITRGGW.mjs.map +0 -7
  120. package/dist/lib/browser/chunk-CZZ3DDR7.mjs +0 -38
  121. package/dist/lib/browser/chunk-CZZ3DDR7.mjs.map +0 -7
  122. package/dist/lib/browser/chunk-UL5EDJPE.mjs +0 -21
  123. package/dist/lib/browser/chunk-UL5EDJPE.mjs.map +0 -7
  124. package/dist/lib/browser/intent-resolver-RGPYMKAU.mjs +0 -24
  125. package/dist/lib/browser/intent-resolver-RGPYMKAU.mjs.map +0 -7
  126. package/dist/lib/browser/react-surface-6MSROCJS.mjs +0 -31
  127. package/dist/lib/browser/react-surface-6MSROCJS.mjs.map +0 -7
  128. package/dist/lib/node-esm/ExplorerContainer-OBSRVHZZ.mjs +0 -38
  129. package/dist/lib/node-esm/ExplorerContainer-OBSRVHZZ.mjs.map +0 -7
  130. package/dist/lib/node-esm/chunk-3ODK27PU.mjs.map +0 -7
  131. package/dist/lib/node-esm/chunk-4GWDNZ4Z.mjs +0 -39
  132. package/dist/lib/node-esm/chunk-4GWDNZ4Z.mjs.map +0 -7
  133. package/dist/lib/node-esm/chunk-GFYXDQQV.mjs +0 -205
  134. package/dist/lib/node-esm/chunk-GFYXDQQV.mjs.map +0 -7
  135. package/dist/lib/node-esm/chunk-PIAXA43R.mjs.map +0 -7
  136. package/dist/lib/node-esm/intent-resolver-LTIB6F2Q.mjs +0 -25
  137. package/dist/lib/node-esm/intent-resolver-LTIB6F2Q.mjs.map +0 -7
  138. package/dist/lib/node-esm/react-surface-ZEM4IXFU.mjs +0 -32
  139. package/dist/lib/node-esm/react-surface-ZEM4IXFU.mjs.map +0 -7
  140. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  141. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  142. package/dist/types/src/capabilities/react-surface.d.ts +0 -4
  143. package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
  144. package/dist/types/src/types/schema.d.ts +0 -12
  145. package/dist/types/src/types/schema.d.ts.map +0 -1
  146. package/dist/types/src/types/types.d.ts +0 -18
  147. package/dist/types/src/types/types.d.ts.map +0 -1
  148. package/src/capabilities/intent-resolver.ts +0 -19
  149. package/src/capabilities/react-surface.tsx +0 -23
  150. package/src/types/schema.ts +0 -16
  151. package/src/types/types.ts +0 -22
@@ -1,7 +1,6 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
2
 
3
3
  // src/components/Chart/Chart.tsx
4
- import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
5
4
  import * as Plot from "@observablehq/plot";
6
5
  import React, { useEffect } from "react";
7
6
  import { useResizeDetector } from "react-resize-detector";
@@ -19,49 +18,43 @@ var defaultOptions = {
19
18
  fillOpacity: 0.2
20
19
  };
21
20
  var Chart = ({ items = [], accessor, options = defaultOptions }) => {
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,
21
+ const { ref: containerRef, width = 0, height = 0 } = useResizeDetector({
22
+ refreshRate: 200
23
+ });
24
+ useEffect(() => {
25
+ if (!width || !height) {
26
+ return;
27
+ }
28
+ const plot3 = Plot.plot({
29
+ grid: true,
51
30
  width,
52
- height
53
- ]);
54
- return /* @__PURE__ */ React.createElement("div", {
55
- ref: containerRef,
56
- className: "grow"
31
+ height,
32
+ style: {
33
+ background: "transparent"
34
+ },
35
+ marks: [
36
+ Plot.frame(),
37
+ Plot.dot(items, {
38
+ x: createAdapter("x", accessor),
39
+ y: createAdapter("y", accessor),
40
+ ...options
41
+ })
42
+ ]
57
43
  });
58
- } finally {
59
- _effect.f();
60
- }
44
+ containerRef.current.append(plot3);
45
+ return () => plot3?.remove();
46
+ }, [
47
+ items,
48
+ width,
49
+ height
50
+ ]);
51
+ return /* @__PURE__ */ React.createElement("div", {
52
+ ref: containerRef,
53
+ className: "grow"
54
+ });
61
55
  };
62
56
 
63
57
  // src/components/Globe/Globe.tsx
64
- import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
65
58
  import * as Plot2 from "@observablehq/plot";
66
59
  import React2, { useEffect as useEffect2 } from "react";
67
60
  import { useResizeDetector as useResizeDetector2 } from "react-resize-detector";
@@ -10775,68 +10768,63 @@ var defaultOptions2 = {
10775
10768
  fill: "#003300"
10776
10769
  };
10777
10770
  var Globe = ({ items = [], accessor, projection = "orthographic", options = defaultOptions2 }) => {
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
- })
10771
+ const { ref: containerRef, width = 0, height = 0 } = useResizeDetector2({
10772
+ refreshRate: 200
10773
+ });
10774
+ const land = topojson.feature(countries_110m_default, countries_110m_default.objects.land);
10775
+ useEffect2(() => {
10776
+ if (!width || !height) {
10777
+ return;
10778
+ }
10779
+ const plot3 = Plot2.plot({
10780
+ // https://observablehq.com/plot/features/projections
10781
+ projection: {
10782
+ type: projection,
10783
+ rotate: [
10784
+ -100,
10785
+ -20
10819
10786
  ]
10820
- });
10821
- containerRef.current.append(plot3);
10822
- return () => plot3?.remove();
10823
- }, [
10824
- items,
10787
+ },
10788
+ // projection: { type: 'equirectangular', rotate: [-140, -30] },
10825
10789
  width,
10826
- height
10827
- ]);
10828
- return /* @__PURE__ */ React2.createElement("div", {
10829
- ref: containerRef,
10830
- className: "grow p-4"
10790
+ height,
10791
+ style: {
10792
+ background: "transparent"
10793
+ },
10794
+ // TODO(burdon): Create simple wrapper for Plot with good defaults.
10795
+ marks: [
10796
+ Plot2.sphere({
10797
+ fill: "lightblue",
10798
+ fillOpacity: 0.5
10799
+ }),
10800
+ Plot2.geo(land, {
10801
+ fill: "darkgreen",
10802
+ fillOpacity: 0.5
10803
+ }),
10804
+ Plot2.graticule(),
10805
+ Plot2.dot(items, {
10806
+ x: createAdapter("lat", accessor),
10807
+ y: createAdapter("lng", accessor),
10808
+ ...options
10809
+ })
10810
+ ]
10831
10811
  });
10832
- } finally {
10833
- _effect.f();
10834
- }
10812
+ containerRef.current.append(plot3);
10813
+ return () => plot3?.remove();
10814
+ }, [
10815
+ items,
10816
+ width,
10817
+ height
10818
+ ]);
10819
+ return /* @__PURE__ */ React2.createElement("div", {
10820
+ ref: containerRef,
10821
+ className: "grow p-4"
10822
+ });
10835
10823
  };
10836
10824
 
10837
10825
  // src/components/Tree/Tree.tsx
10838
- import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
10839
- import React3, { useEffect as useEffect3, useRef, useState } from "react";
10826
+ import { RegistryContext } from "@effect-atom/atom-react";
10827
+ import React3, { useContext, useEffect as useEffect3, useRef, useState } from "react";
10840
10828
  import { useAsyncState } from "@dxos/react-ui";
10841
10829
  import { SVG } from "@dxos/react-ui-graph";
10842
10830
  import { SpaceGraphModel } from "@dxos/schema";
@@ -10975,23 +10963,10 @@ var TidyTree = (s, data, options) => {
10975
10963
  var TidyTree_default = TidyTree;
10976
10964
 
10977
10965
  // src/components/Tree/types/tree.ts
10978
- import { Schema } from "effect";
10966
+ import * as Schema from "effect/Schema";
10979
10967
  import { Key, Obj, Type } from "@dxos/echo";
10968
+ import { TestSchema } from "@dxos/echo/testing";
10980
10969
  import { invariant } from "@dxos/invariant";
10981
- function _define_property(obj, key, value) {
10982
- if (key in obj) {
10983
- Object.defineProperty(obj, key, {
10984
- value,
10985
- enumerable: true,
10986
- configurable: true,
10987
- writable: true
10988
- });
10989
- } else {
10990
- obj[key] = value;
10991
- }
10992
- return obj;
10993
- }
10994
- var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-explorer/src/components/Tree/types/tree.ts";
10995
10970
  var TreeNodeType = Schema.Struct({
10996
10971
  id: Key.ObjectId,
10997
10972
  children: Schema.mutable(Schema.Array(Key.ObjectId)),
@@ -10999,7 +10974,7 @@ var TreeNodeType = Schema.Struct({
10999
10974
  key: Schema.String,
11000
10975
  value: Schema.Any
11001
10976
  })),
11002
- ref: Schema.optional(Type.Ref(Type.Expando))
10977
+ ref: Schema.optional(Type.Ref(TestSchema.Expando))
11003
10978
  }).pipe(Schema.mutable);
11004
10979
  var TreeType = Schema.Struct({
11005
10980
  root: Key.ObjectId,
@@ -11007,248 +10982,10 @@ var TreeType = Schema.Struct({
11007
10982
  key: Key.ObjectId,
11008
10983
  value: TreeNodeType
11009
10984
  }))
11010
- }).pipe(Type.Obj({
10985
+ }).pipe(Type.object({
11011
10986
  typename: "dxos.org/type/Tree",
11012
10987
  version: "0.1.0"
11013
10988
  }));
11014
- var Tree = class _Tree {
11015
- get tree() {
11016
- return this._tree;
11017
- }
11018
- // TODO(burdon): Make reactive.
11019
- get size() {
11020
- return Object.keys(this._tree.nodes).length;
11021
- }
11022
- get root() {
11023
- return this.getNode(this._tree.root);
11024
- }
11025
- //
11026
- // Traversal
11027
- //
11028
- /**
11029
- * Recursively traverse the tree until the callback returns a value.
11030
- */
11031
- tranverse(callback, root = this._tree.root, depth = 0) {
11032
- const node = this._tree.nodes[root];
11033
- const result = callback(node, depth);
11034
- if (result !== void 0) {
11035
- return result;
11036
- }
11037
- for (const childId of node.children) {
11038
- const result2 = this.tranverse(callback, childId, depth + 1);
11039
- if (result2 !== void 0) {
11040
- return result2;
11041
- }
11042
- }
11043
- }
11044
- getNode(id) {
11045
- const node = this._tree.nodes[id];
11046
- invariant(node, void 0, {
11047
- F: __dxlog_file,
11048
- L: 98,
11049
- S: this,
11050
- A: [
11051
- "node",
11052
- ""
11053
- ]
11054
- });
11055
- return node;
11056
- }
11057
- /**
11058
- * Get the children of a node.
11059
- */
11060
- getChildNodes(node) {
11061
- return node.children.map((id) => this.getNode(id));
11062
- }
11063
- /**
11064
- * Get the parent of a node.
11065
- */
11066
- getParent(node) {
11067
- const parent = this.tranverse((n) => {
11068
- if (n.children.includes(node.id)) {
11069
- return n;
11070
- }
11071
- });
11072
- return parent ?? null;
11073
- }
11074
- /**
11075
- * Get the next node in the tree.
11076
- */
11077
- getNext(node, hierarchical = true) {
11078
- if (hierarchical && node.children.length) {
11079
- return this.getChildNodes(node)[0];
11080
- } else {
11081
- const parent = this.getParent(node);
11082
- if (parent) {
11083
- const idx = this.getChildNodes(parent).findIndex(({ id }) => id === node.id);
11084
- if (idx < parent.children.length - 1) {
11085
- return this.getNode(parent.children[idx + 1]);
11086
- } else {
11087
- return this.getNext(parent, false);
11088
- }
11089
- }
11090
- }
11091
- }
11092
- /**
11093
- * Get the previous node in the tree.
11094
- */
11095
- getPrevious(node, hierarchical = true) {
11096
- const parent = this.getParent(node);
11097
- const idx = this.getChildNodes(parent).findIndex(({ id }) => id === node.id);
11098
- if (idx === 0) {
11099
- if (hierarchical) {
11100
- return parent;
11101
- }
11102
- } else {
11103
- const previous = this.getNode(parent.children[idx - 1]);
11104
- if (hierarchical && previous.children.length) {
11105
- return this.getLastDescendent(previous);
11106
- }
11107
- return previous;
11108
- }
11109
- }
11110
- /**
11111
- * Get the last descendent of a node.
11112
- */
11113
- getLastDescendent(node) {
11114
- const children = this.getChildNodes(node);
11115
- const last = children.length ? children[children.length - 1] : void 0;
11116
- if (last) {
11117
- return this.getLastDescendent(last);
11118
- }
11119
- return node;
11120
- }
11121
- //
11122
- // Mutations
11123
- //
11124
- /**
11125
- * Clear tree.
11126
- */
11127
- clear() {
11128
- const root = this._tree.nodes[this._tree.root];
11129
- root.children.length = 0;
11130
- this._tree.nodes = {
11131
- [root.id]: root
11132
- };
11133
- }
11134
- /**
11135
- * Add node.
11136
- */
11137
- addNode(parent, node, index) {
11138
- if (!node) {
11139
- const id = Key.ObjectId.random();
11140
- node = {
11141
- id,
11142
- children: [],
11143
- data: {
11144
- text: ""
11145
- }
11146
- };
11147
- }
11148
- this._tree.nodes[node.id] = node;
11149
- parent.children.splice(index ?? parent.children.length, 0, node.id);
11150
- return node;
11151
- }
11152
- /**
11153
- * Delete node.
11154
- */
11155
- deleteNode(parent, id) {
11156
- const node = this._tree.nodes[id];
11157
- if (!node) {
11158
- return void 0;
11159
- }
11160
- delete this._tree.nodes[node.id];
11161
- const idx = parent.children.findIndex((child) => child === id);
11162
- if (idx !== -1) {
11163
- parent.children.splice(idx, 1);
11164
- }
11165
- return node;
11166
- }
11167
- /**
11168
- * Move child node.
11169
- */
11170
- moveNode(node, from, to) {
11171
- invariant(from >= 0 && from < node.children.length, void 0, {
11172
- F: __dxlog_file,
11173
- L: 228,
11174
- S: this,
11175
- A: [
11176
- "from >= 0 && from < node.children.length",
11177
- ""
11178
- ]
11179
- });
11180
- invariant(to >= 0 && to < node.children.length, void 0, {
11181
- F: __dxlog_file,
11182
- L: 229,
11183
- S: this,
11184
- A: [
11185
- "to >= 0 && to < node.children.length",
11186
- ""
11187
- ]
11188
- });
11189
- if (from === to) {
11190
- return null;
11191
- }
11192
- const child = node.children[from];
11193
- node.children.splice(from, 1);
11194
- node.children.splice(to, 0, child);
11195
- return this.getNode(child);
11196
- }
11197
- /**
11198
- * Indent node.
11199
- */
11200
- indentNode(node) {
11201
- const parent = this.getParent(node);
11202
- if (!parent) {
11203
- return;
11204
- }
11205
- const idx = parent.children.findIndex((child) => child === node.id);
11206
- if (idx < 1 || idx >= parent.children.length) {
11207
- return;
11208
- }
11209
- const previous = this.getNode(parent.children[idx - 1]);
11210
- parent.children.splice(idx, 1);
11211
- previous.children.push(node.id);
11212
- }
11213
- /**
11214
- * Unindent node.
11215
- */
11216
- unindentNode(node) {
11217
- const parent = this.getParent(node);
11218
- if (!parent) {
11219
- return;
11220
- }
11221
- const ancestor = this.getParent(parent);
11222
- if (!ancestor) {
11223
- return;
11224
- }
11225
- const nodeIdx = parent.children.findIndex((id) => id === node.id);
11226
- const [_, ...rest] = parent.children.splice(nodeIdx, parent.children.length - nodeIdx);
11227
- parent.children.splice(nodeIdx, parent.children.length - nodeIdx);
11228
- const parentIdx = this.getChildNodes(ancestor).findIndex((n) => n.id === parent.id);
11229
- ancestor.children.splice(parentIdx + 1, 0, node.id);
11230
- node.children.push(...rest);
11231
- }
11232
- constructor(tree3) {
11233
- _define_property(this, "_tree", void 0);
11234
- this._tree = tree3 ?? _Tree.create();
11235
- }
11236
- };
11237
- _define_property(Tree, "create", () => {
11238
- const id = Key.ObjectId.random();
11239
- return Obj.make(TreeType, {
11240
- root: id,
11241
- nodes: {
11242
- [id]: {
11243
- id,
11244
- children: [],
11245
- data: {
11246
- text: ""
11247
- }
11248
- }
11249
- }
11250
- });
11251
- });
11252
10989
 
11253
10990
  // src/components/Tree/types/types.ts
11254
10991
  var mapGraphToTreeData = (model, maxDepth = 8) => {
@@ -11276,68 +11013,66 @@ var renderers = /* @__PURE__ */ new Map([
11276
11013
  HierarchicalEdgeBundling_default
11277
11014
  ]
11278
11015
  ]);
11279
- var Tree2 = ({ space, selected, variant = "tidy", onNodeClick }) => {
11280
- var _effect = _useSignals3();
11281
- try {
11282
- const [model] = useAsyncState(async () => space ? new SpaceGraphModel().open(space) : void 0, [
11283
- space,
11284
- selected
11285
- ]);
11286
- const [tree3, setTree] = useState();
11287
- useEffect3(() => {
11288
- return model?.subscribe(() => {
11289
- const tree4 = mapGraphToTreeData(model);
11290
- setTree(tree4);
11291
- }, true);
11292
- }, [
11293
- model
11294
- ]);
11295
- const context = useRef(null);
11296
- useEffect3(() => {
11297
- if (context.current) {
11298
- const { width, height } = context.current.size;
11299
- const size = Math.min(width, height);
11300
- const radius = size * 0.4;
11301
- const options = {
11302
- // TODO(burdon): Type.
11303
- label: (d) => d.label ?? d.id,
11304
- width,
11305
- height,
11306
- radius,
11307
- marginLeft: (width - radius * 2) / 2,
11308
- marginRight: (width - radius * 2) / 2,
11309
- marginTop: (height - radius * 2) / 2,
11310
- marginBottom: (height - radius * 2) / 2,
11311
- slots: defaultTreeLayoutSlots
11312
- };
11313
- if (tree3) {
11314
- const renderer = renderers.get(variant);
11315
- renderer?.(context.current.svg, tree3, options);
11316
- }
11016
+ var Tree = ({ space, selected, variant = "tidy", onNodeClick }) => {
11017
+ const registry = useContext(RegistryContext);
11018
+ const [model] = useAsyncState(async () => space ? new SpaceGraphModel(registry).open(space.db) : void 0, [
11019
+ space,
11020
+ selected,
11021
+ registry
11022
+ ]);
11023
+ const [tree3, setTree] = useState();
11024
+ useEffect3(() => {
11025
+ return model?.subscribe(() => {
11026
+ const tree4 = mapGraphToTreeData(model);
11027
+ setTree(tree4);
11028
+ }, true);
11029
+ }, [
11030
+ model
11031
+ ]);
11032
+ const context = useRef(null);
11033
+ useEffect3(() => {
11034
+ if (context.current?.size) {
11035
+ const { width, height } = context.current.size;
11036
+ const size = Math.min(width, height);
11037
+ const radius = size * 0.4;
11038
+ const options = {
11039
+ // TODO(burdon): Type.
11040
+ label: (d) => d.label ?? d.id,
11041
+ width,
11042
+ height,
11043
+ radius,
11044
+ marginLeft: (width - radius * 2) / 2,
11045
+ marginRight: (width - radius * 2) / 2,
11046
+ marginTop: (height - radius * 2) / 2,
11047
+ marginBottom: (height - radius * 2) / 2,
11048
+ slots: defaultTreeLayoutSlots
11049
+ };
11050
+ if (tree3) {
11051
+ const renderer = renderers.get(variant);
11052
+ renderer?.(context.current.svg, tree3, options);
11317
11053
  }
11318
- }, [
11319
- context.current,
11320
- tree3
11321
- ]);
11322
- return /* @__PURE__ */ React3.createElement("div", {
11323
- onClick: () => onNodeClick?.()
11324
- }, /* @__PURE__ */ React3.createElement(SVG.Root, {
11325
- ref: context
11326
- }));
11327
- } finally {
11328
- _effect.f();
11329
- }
11054
+ }
11055
+ }, [
11056
+ context.current,
11057
+ tree3
11058
+ ]);
11059
+ return /* @__PURE__ */ React3.createElement("div", {
11060
+ className: "grow",
11061
+ onClick: () => onNodeClick?.()
11062
+ }, /* @__PURE__ */ React3.createElement(SVG.Root, {
11063
+ ref: context
11064
+ }));
11330
11065
  };
11331
11066
 
11332
11067
  // src/components/index.ts
11333
11068
  import { lazy } from "react";
11334
- var ExplorerContainer = lazy(() => import("./ExplorerContainer-OBSRVHZZ.mjs"));
11069
+ var ExplorerContainer = lazy(() => import("./ExplorerContainer-YQ2KKBVS.mjs"));
11335
11070
 
11336
11071
  export {
11337
11072
  Chart,
11338
11073
  Globe,
11339
11074
  defaultTreeLayoutSlots,
11340
- Tree2 as Tree,
11075
+ Tree,
11341
11076
  ExplorerContainer
11342
11077
  };
11343
- //# sourceMappingURL=chunk-ODMJ7DPA.mjs.map
11078
+ //# sourceMappingURL=chunk-QLMTN2XI.mjs.map