@dxos/plugin-explorer 0.8.4-main.7ace549 → 0.8.4-main.8baae0fced

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 (264) hide show
  1. package/LICENSE +102 -5
  2. package/dist/lib/neutral/ExplorerArticle-EAKRB55W.mjs +277 -0
  3. package/dist/lib/neutral/ExplorerArticle-EAKRB55W.mjs.map +7 -0
  4. package/dist/lib/neutral/ExplorerPlugin.mjs +10 -0
  5. package/dist/lib/neutral/capabilities/index.mjs +11 -0
  6. package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
  7. package/dist/lib/neutral/chunk-7SPMPHRS.mjs +72 -0
  8. package/dist/lib/neutral/chunk-7SPMPHRS.mjs.map +7 -0
  9. package/dist/lib/{browser/chunk-UBHZGWZQ.mjs → neutral/chunk-DXIWQFYO.mjs} +3 -5
  10. package/dist/lib/neutral/chunk-DXIWQFYO.mjs.map +7 -0
  11. package/dist/lib/neutral/chunk-EM2BV4PF.mjs +290 -0
  12. package/dist/lib/neutral/chunk-EM2BV4PF.mjs.map +7 -0
  13. package/dist/lib/neutral/chunk-GRJXLL4Z.mjs +25 -0
  14. package/dist/lib/neutral/chunk-GRJXLL4Z.mjs.map +7 -0
  15. package/dist/lib/neutral/chunk-V2OFO6PI.mjs +14 -0
  16. package/dist/lib/neutral/chunk-V2OFO6PI.mjs.map +7 -0
  17. package/dist/lib/{browser/chunk-ARBGXQFH.mjs → neutral/components/index.mjs} +858 -307
  18. package/dist/lib/neutral/components/index.mjs.map +7 -0
  19. package/dist/lib/neutral/containers/index.mjs +9 -0
  20. package/dist/lib/neutral/containers/index.mjs.map +7 -0
  21. package/dist/lib/neutral/create-object-F6TKVAGV.mjs +39 -0
  22. package/dist/lib/neutral/create-object-F6TKVAGV.mjs.map +7 -0
  23. package/dist/lib/neutral/hooks/index.mjs +45 -0
  24. package/dist/lib/neutral/hooks/index.mjs.map +7 -0
  25. package/dist/lib/neutral/index.mjs +14 -0
  26. package/dist/lib/neutral/meta.json +1 -0
  27. package/dist/lib/{browser → neutral}/meta.mjs +1 -1
  28. package/dist/lib/neutral/plugin.mjs +12 -0
  29. package/dist/lib/neutral/plugin.mjs.map +7 -0
  30. package/dist/lib/neutral/react-surface-APBW2VQG.mjs +26 -0
  31. package/dist/lib/neutral/react-surface-APBW2VQG.mjs.map +7 -0
  32. package/dist/lib/neutral/testing/index.mjs +193 -0
  33. package/dist/lib/neutral/testing/index.mjs.map +7 -0
  34. package/dist/lib/neutral/translations.mjs +33 -0
  35. package/dist/lib/neutral/translations.mjs.map +7 -0
  36. package/dist/lib/{browser → neutral}/types/index.mjs +1 -2
  37. package/dist/types/data/cities.d.ts +4 -4
  38. package/dist/types/data/cities.d.ts.map +1 -1
  39. package/dist/types/data/countries-110m.d.ts +19 -22
  40. package/dist/types/data/countries-110m.d.ts.map +1 -1
  41. package/dist/types/src/ExplorerPlugin.d.ts +3 -1
  42. package/dist/types/src/ExplorerPlugin.d.ts.map +1 -1
  43. package/dist/types/src/ExplorerPlugin.test.d.ts +2 -0
  44. package/dist/types/src/ExplorerPlugin.test.d.ts.map +1 -0
  45. package/dist/types/src/capabilities/create-object.d.ts +11 -0
  46. package/dist/types/src/capabilities/create-object.d.ts.map +1 -0
  47. package/dist/types/src/capabilities/index.d.ts +8 -2
  48. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  49. package/dist/types/src/capabilities/react-surface.d.ts +3 -2
  50. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  51. package/dist/types/src/components/Chart/Chart.d.ts +1 -1
  52. package/dist/types/src/components/Chart/Chart.d.ts.map +1 -1
  53. package/dist/types/src/components/Chart/Chart.stories.d.ts +4 -1
  54. package/dist/types/src/components/Chart/Chart.stories.d.ts.map +1 -1
  55. package/dist/types/src/components/Globe/Globe.d.ts +1 -1
  56. package/dist/types/src/components/Globe/Globe.d.ts.map +1 -1
  57. package/dist/types/src/components/Globe/Globe.stories.d.ts +5 -2
  58. package/dist/types/src/components/Globe/Globe.stories.d.ts.map +1 -1
  59. package/dist/types/src/components/Graph/CanvasForceGraph.d.ts +13 -0
  60. package/dist/types/src/components/Graph/CanvasForceGraph.d.ts.map +1 -0
  61. package/dist/types/src/components/Graph/CanvasForceGraph.stories.d.ts +17 -0
  62. package/dist/types/src/components/Graph/CanvasForceGraph.stories.d.ts.map +1 -0
  63. package/dist/types/src/components/Graph/ForceGraph.d.ts +12 -5
  64. package/dist/types/src/components/Graph/ForceGraph.d.ts.map +1 -1
  65. package/dist/types/src/components/Graph/ForceGraph.stories.d.ts +4 -2
  66. package/dist/types/src/components/Graph/ForceGraph.stories.d.ts.map +1 -1
  67. package/dist/types/src/components/Graph/{adapter.d.ts → graph-adapter.d.ts} +2 -2
  68. package/dist/types/src/components/Graph/graph-adapter.d.ts.map +1 -0
  69. package/dist/types/src/components/Graph/index.d.ts +1 -1
  70. package/dist/types/src/components/Graph/index.d.ts.map +1 -1
  71. package/dist/types/src/components/Lattice/Lattice.d.ts +20 -0
  72. package/dist/types/src/components/Lattice/Lattice.d.ts.map +1 -0
  73. package/dist/types/src/components/Lattice/Lattice.stories.d.ts +8 -0
  74. package/dist/types/src/components/Lattice/Lattice.stories.d.ts.map +1 -0
  75. package/dist/types/src/components/Lattice/index.d.ts +2 -0
  76. package/dist/types/src/components/Lattice/index.d.ts.map +1 -0
  77. package/dist/types/src/components/Tree/EdgeBundling.stories.d.ts +21 -0
  78. package/dist/types/src/components/Tree/EdgeBundling.stories.d.ts.map +1 -0
  79. package/dist/types/src/components/Tree/Tree.d.ts +20 -23
  80. package/dist/types/src/components/Tree/Tree.d.ts.map +1 -1
  81. package/dist/types/src/components/Tree/Tree.stories.d.ts +5 -12
  82. package/dist/types/src/components/Tree/Tree.stories.d.ts.map +1 -1
  83. package/dist/types/src/components/Tree/index.d.ts +2 -0
  84. package/dist/types/src/components/Tree/index.d.ts.map +1 -1
  85. package/dist/types/src/components/Tree/layout/HierarchicalEdgeBundling.d.ts +37 -2
  86. package/dist/types/src/components/Tree/layout/HierarchicalEdgeBundling.d.ts.map +1 -1
  87. package/dist/types/src/components/Tree/layout/RadialTree.d.ts +35 -2
  88. package/dist/types/src/components/Tree/layout/RadialTree.d.ts.map +1 -1
  89. package/dist/types/src/components/Tree/layout/TidyTree.d.ts +24 -2
  90. package/dist/types/src/components/Tree/layout/TidyTree.d.ts.map +1 -1
  91. package/dist/types/src/components/Tree/layout/hierarchy.d.ts +17 -0
  92. package/dist/types/src/components/Tree/layout/hierarchy.d.ts.map +1 -0
  93. package/dist/types/src/components/Tree/layout/index.d.ts +5 -4
  94. package/dist/types/src/components/Tree/layout/index.d.ts.map +1 -1
  95. package/dist/types/src/components/Tree/layout/slots.d.ts +7 -0
  96. package/dist/types/src/components/Tree/layout/slots.d.ts.map +1 -0
  97. package/dist/types/src/components/Tree/layout/useContainerSize.d.ts +15 -0
  98. package/dist/types/src/components/Tree/layout/useContainerSize.d.ts.map +1 -0
  99. package/dist/types/src/components/Tree/types/tree.d.ts +18 -16
  100. package/dist/types/src/components/Tree/types/tree.d.ts.map +1 -1
  101. package/dist/types/src/components/Tree/types/types.d.ts +14 -4
  102. package/dist/types/src/components/Tree/types/types.d.ts.map +1 -1
  103. package/dist/types/src/components/index.d.ts +1 -2
  104. package/dist/types/src/components/index.d.ts.map +1 -1
  105. package/dist/types/src/containers/ExplorerArticle/ExplorerArticle.d.ts +9 -0
  106. package/dist/types/src/containers/ExplorerArticle/ExplorerArticle.d.ts.map +1 -0
  107. package/dist/types/src/containers/ExplorerArticle/ExplorerArticle.stories.d.ts +29 -0
  108. package/dist/types/src/containers/ExplorerArticle/ExplorerArticle.stories.d.ts.map +1 -0
  109. package/dist/types/src/containers/ExplorerArticle/experimental.stories.d.ts +7 -0
  110. package/dist/types/src/containers/ExplorerArticle/experimental.stories.d.ts.map +1 -0
  111. package/dist/types/src/containers/ExplorerArticle/index.d.ts +2 -0
  112. package/dist/types/src/containers/ExplorerArticle/index.d.ts.map +1 -0
  113. package/dist/types/src/containers/index.d.ts +3 -0
  114. package/dist/types/src/containers/index.d.ts.map +1 -0
  115. package/dist/types/src/hooks/useGraphModel.d.ts +2 -2
  116. package/dist/types/src/hooks/useGraphModel.d.ts.map +1 -1
  117. package/dist/types/src/index.d.ts +1 -3
  118. package/dist/types/src/index.d.ts.map +1 -1
  119. package/dist/types/src/meta.d.ts +2 -2
  120. package/dist/types/src/meta.d.ts.map +1 -1
  121. package/dist/types/src/plugin.d.ts +3 -0
  122. package/dist/types/src/plugin.d.ts.map +1 -0
  123. package/dist/types/src/{components/Tree/testing → testing}/generator.d.ts +1 -1
  124. package/dist/types/src/testing/generator.d.ts.map +1 -0
  125. package/dist/types/src/testing/index.d.ts +4 -0
  126. package/dist/types/src/testing/index.d.ts.map +1 -0
  127. package/dist/types/src/testing/relations.d.ts +47 -0
  128. package/dist/types/src/testing/relations.d.ts.map +1 -0
  129. package/dist/types/src/translations.d.ts +29 -28
  130. package/dist/types/src/translations.d.ts.map +1 -1
  131. package/dist/types/src/types/ExplorerAction.d.ts +0 -17
  132. package/dist/types/src/types/ExplorerAction.d.ts.map +1 -1
  133. package/dist/types/src/types/Graph.d.ts +10 -20
  134. package/dist/types/src/types/Graph.d.ts.map +1 -1
  135. package/dist/types/src/util/index.d.ts +3 -0
  136. package/dist/types/src/util/index.d.ts.map +1 -0
  137. package/dist/types/src/util/node-color.d.ts +13 -0
  138. package/dist/types/src/util/node-color.d.ts.map +1 -0
  139. package/dist/types/src/{components → util}/plot.d.ts +1 -1
  140. package/dist/types/src/util/plot.d.ts.map +1 -0
  141. package/dist/types/tsconfig.tsbuildinfo +1 -1
  142. package/package.json +113 -62
  143. package/src/ExplorerPlugin.test.ts +26 -0
  144. package/src/ExplorerPlugin.tsx +15 -45
  145. package/src/capabilities/create-object.ts +36 -0
  146. package/src/capabilities/index.ts +3 -3
  147. package/src/capabilities/react-surface.tsx +24 -18
  148. package/src/components/Chart/Chart.stories.tsx +16 -23
  149. package/src/components/Chart/Chart.tsx +1 -1
  150. package/src/components/Globe/Globe.stories.tsx +19 -22
  151. package/src/components/Globe/Globe.tsx +1 -1
  152. package/src/components/Graph/CanvasForceGraph.stories.tsx +83 -0
  153. package/src/components/Graph/CanvasForceGraph.tsx +124 -0
  154. package/src/components/Graph/ForceGraph.stories.tsx +83 -44
  155. package/src/components/Graph/ForceGraph.tsx +104 -85
  156. package/src/components/Graph/{adapter.ts → graph-adapter.ts} +14 -8
  157. package/src/components/Graph/index.ts +1 -1
  158. package/src/components/Lattice/Lattice.stories.tsx +90 -0
  159. package/src/components/Lattice/Lattice.tsx +182 -0
  160. package/src/components/Lattice/index.ts +5 -0
  161. package/src/components/Tree/EdgeBundling.stories.tsx +144 -0
  162. package/src/components/Tree/Tree.stories.tsx +20 -38
  163. package/src/components/Tree/Tree.tsx +69 -95
  164. package/src/components/Tree/index.ts +2 -0
  165. package/src/components/Tree/layout/HierarchicalEdgeBundling.tsx +296 -0
  166. package/src/components/Tree/layout/RadialTree.tsx +242 -0
  167. package/src/components/Tree/layout/TidyTree.tsx +246 -0
  168. package/src/components/Tree/layout/hierarchy.ts +32 -0
  169. package/src/components/Tree/layout/index.ts +5 -5
  170. package/src/components/Tree/layout/slots.ts +19 -0
  171. package/src/components/Tree/layout/useContainerSize.ts +43 -0
  172. package/src/components/Tree/types/tree.test.ts +6 -5
  173. package/src/components/Tree/types/tree.ts +41 -20
  174. package/src/components/Tree/types/types.ts +38 -29
  175. package/src/components/index.ts +1 -4
  176. package/src/containers/ExplorerArticle/ExplorerArticle.stories.tsx +136 -0
  177. package/src/containers/ExplorerArticle/ExplorerArticle.tsx +465 -0
  178. package/src/containers/ExplorerArticle/experimental.stories.tsx +446 -0
  179. package/src/containers/ExplorerArticle/index.ts +5 -0
  180. package/src/containers/index.ts +7 -0
  181. package/src/hooks/useGraphModel.ts +25 -14
  182. package/src/index.ts +1 -4
  183. package/src/meta.ts +4 -4
  184. package/src/plugin.ts +9 -0
  185. package/src/{components/Tree/testing → testing}/generator.ts +5 -3
  186. package/src/testing/index.ts +9 -0
  187. package/src/testing/relations.ts +192 -0
  188. package/src/translations.ts +14 -13
  189. package/src/types/ExplorerAction.ts +1 -18
  190. package/src/types/Graph.ts +13 -28
  191. package/src/typings.d.ts +8 -0
  192. package/src/util/index.ts +6 -0
  193. package/src/util/node-color.ts +23 -0
  194. package/src/{components → util}/plot.ts +16 -4
  195. package/dist/lib/browser/ExplorerContainer-NOLLVUTE.mjs +0 -50
  196. package/dist/lib/browser/ExplorerContainer-NOLLVUTE.mjs.map +0 -7
  197. package/dist/lib/browser/chunk-2MKBRIUT.mjs +0 -31
  198. package/dist/lib/browser/chunk-2MKBRIUT.mjs.map +0 -7
  199. package/dist/lib/browser/chunk-6BVXZQPP.mjs +0 -188
  200. package/dist/lib/browser/chunk-6BVXZQPP.mjs.map +0 -7
  201. package/dist/lib/browser/chunk-ARBGXQFH.mjs.map +0 -7
  202. package/dist/lib/browser/chunk-P6FFFVPM.mjs +0 -100
  203. package/dist/lib/browser/chunk-P6FFFVPM.mjs.map +0 -7
  204. package/dist/lib/browser/chunk-UBHZGWZQ.mjs.map +0 -7
  205. package/dist/lib/browser/index.mjs +0 -112
  206. package/dist/lib/browser/index.mjs.map +0 -7
  207. package/dist/lib/browser/intent-resolver-EWB3H5KH.mjs +0 -35
  208. package/dist/lib/browser/intent-resolver-EWB3H5KH.mjs.map +0 -7
  209. package/dist/lib/browser/meta.json +0 -1
  210. package/dist/lib/browser/react-surface-BY2DYCTH.mjs +0 -34
  211. package/dist/lib/browser/react-surface-BY2DYCTH.mjs.map +0 -7
  212. package/dist/lib/node-esm/ExplorerContainer-N3S5KSUX.mjs +0 -51
  213. package/dist/lib/node-esm/ExplorerContainer-N3S5KSUX.mjs.map +0 -7
  214. package/dist/lib/node-esm/chunk-3ODK27PU.mjs +0 -33
  215. package/dist/lib/node-esm/chunk-3ODK27PU.mjs.map +0 -7
  216. package/dist/lib/node-esm/chunk-4BY2XZET.mjs +0 -101
  217. package/dist/lib/node-esm/chunk-4BY2XZET.mjs.map +0 -7
  218. package/dist/lib/node-esm/chunk-CRSVAZNA.mjs +0 -190
  219. package/dist/lib/node-esm/chunk-CRSVAZNA.mjs.map +0 -7
  220. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +0 -11
  221. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +0 -7
  222. package/dist/lib/node-esm/chunk-NPIP4VEH.mjs +0 -11091
  223. package/dist/lib/node-esm/chunk-NPIP4VEH.mjs.map +0 -7
  224. package/dist/lib/node-esm/chunk-UXZM5VJB.mjs +0 -26
  225. package/dist/lib/node-esm/chunk-UXZM5VJB.mjs.map +0 -7
  226. package/dist/lib/node-esm/index.mjs +0 -113
  227. package/dist/lib/node-esm/index.mjs.map +0 -7
  228. package/dist/lib/node-esm/intent-resolver-SH6PW7VF.mjs +0 -36
  229. package/dist/lib/node-esm/intent-resolver-SH6PW7VF.mjs.map +0 -7
  230. package/dist/lib/node-esm/meta.json +0 -1
  231. package/dist/lib/node-esm/meta.mjs +0 -9
  232. package/dist/lib/node-esm/react-surface-7AAV7GBG.mjs +0 -35
  233. package/dist/lib/node-esm/react-surface-7AAV7GBG.mjs.map +0 -7
  234. package/dist/lib/node-esm/types/index.mjs +0 -12
  235. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  236. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  237. package/dist/types/src/components/ExplorerContainer.d.ts +0 -9
  238. package/dist/types/src/components/ExplorerContainer.d.ts.map +0 -1
  239. package/dist/types/src/components/Graph/D3ForceGraph.d.ts +0 -14
  240. package/dist/types/src/components/Graph/D3ForceGraph.d.ts.map +0 -1
  241. package/dist/types/src/components/Graph/D3ForceGraph.stories.d.ts +0 -15
  242. package/dist/types/src/components/Graph/D3ForceGraph.stories.d.ts.map +0 -1
  243. package/dist/types/src/components/Graph/adapter.d.ts.map +0 -1
  244. package/dist/types/src/components/Graph/testing.d.ts +0 -14
  245. package/dist/types/src/components/Graph/testing.d.ts.map +0 -1
  246. package/dist/types/src/components/Tree/testing/generator.d.ts.map +0 -1
  247. package/dist/types/src/components/Tree/testing/index.d.ts +0 -2
  248. package/dist/types/src/components/Tree/testing/index.d.ts.map +0 -1
  249. package/dist/types/src/components/plot.d.ts.map +0 -1
  250. package/src/capabilities/intent-resolver.ts +0 -23
  251. package/src/components/ExplorerContainer.tsx +0 -54
  252. package/src/components/Graph/D3ForceGraph.stories.tsx +0 -80
  253. package/src/components/Graph/D3ForceGraph.tsx +0 -101
  254. package/src/components/Graph/testing.ts +0 -55
  255. package/src/components/Tree/layout/HierarchicalEdgeBundling.ts +0 -162
  256. package/src/components/Tree/layout/RadialTree.ts +0 -94
  257. package/src/components/Tree/layout/TidyTree.ts +0 -101
  258. package/src/components/Tree/testing/index.ts +0 -5
  259. /package/dist/lib/{browser/chunk-J5LGTIGS.mjs.map → neutral/ExplorerPlugin.mjs.map} +0 -0
  260. /package/dist/lib/{browser → neutral}/chunk-J5LGTIGS.mjs +0 -0
  261. /package/dist/lib/{browser/meta.mjs.map → neutral/chunk-J5LGTIGS.mjs.map} +0 -0
  262. /package/dist/lib/{browser/types → neutral}/index.mjs.map +0 -0
  263. /package/dist/lib/{node-esm → neutral}/meta.mjs.map +0 -0
  264. /package/dist/lib/{node-esm → neutral}/types/index.mjs.map +0 -0
@@ -0,0 +1,290 @@
1
+ // src/components/Tree/types/types.ts
2
+ var treeTypeToTreeNode = (tree, rootId = tree.root, visited = /* @__PURE__ */ new Set()) => {
3
+ const node = tree.nodes[rootId];
4
+ if (!node) {
5
+ return void 0;
6
+ }
7
+ if (visited.has(rootId)) {
8
+ return {
9
+ id: rootId,
10
+ label: labelOf(node),
11
+ data: node.data
12
+ };
13
+ }
14
+ visited.add(rootId);
15
+ return {
16
+ id: rootId,
17
+ label: labelOf(node),
18
+ data: node.data,
19
+ children: node.children.map((childId) => treeTypeToTreeNode(tree, childId, visited)).filter((c) => Boolean(c))
20
+ };
21
+ };
22
+ var labelOf = (node) => {
23
+ return typeof node.data?.text === "string" ? node.data.text : void 0;
24
+ };
25
+
26
+ // src/components/Tree/types/tree.ts
27
+ import * as Schema from "effect/Schema";
28
+ import { Key, Obj, Ref, Type } from "@dxos/echo";
29
+ import { TestSchema } from "@dxos/echo/testing";
30
+ import { invariant } from "@dxos/invariant";
31
+ var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-explorer/src/components/Tree/types/tree.ts";
32
+ var TreeNodeType = Schema.Struct({
33
+ id: Key.ObjectId,
34
+ children: Schema.mutable(Schema.Array(Key.ObjectId)),
35
+ data: Schema.mutable(Schema.Record({
36
+ key: Schema.String,
37
+ value: Schema.Any
38
+ })),
39
+ ref: Schema.optional(Ref.Ref(TestSchema.Expando))
40
+ }).pipe(Schema.mutable);
41
+ var TreeType = Schema.Struct({
42
+ root: Key.ObjectId,
43
+ nodes: Schema.mutable(Schema.Record({
44
+ key: Key.ObjectId,
45
+ value: TreeNodeType
46
+ }))
47
+ }).pipe(Type.object({
48
+ typename: "org.dxos.type.tree",
49
+ version: "0.1.0"
50
+ }));
51
+ var Tree = class _Tree {
52
+ static create = () => {
53
+ const id = Key.ObjectId.random();
54
+ return Obj.make(TreeType, {
55
+ root: id,
56
+ nodes: {
57
+ [id]: {
58
+ id,
59
+ children: [],
60
+ data: {
61
+ text: ""
62
+ }
63
+ }
64
+ }
65
+ });
66
+ };
67
+ _tree;
68
+ constructor(tree) {
69
+ this._tree = tree ?? _Tree.create();
70
+ }
71
+ get tree() {
72
+ return this._tree;
73
+ }
74
+ // TODO(burdon): Make reactive.
75
+ get size() {
76
+ return Object.keys(this._tree.nodes).length;
77
+ }
78
+ get root() {
79
+ return this.getNode(this._tree.root);
80
+ }
81
+ //
82
+ // Traversal
83
+ //
84
+ /**
85
+ * Recursively traverse the tree until the callback returns a value.
86
+ */
87
+ tranverse(callback, root = this._tree.root, depth = 0) {
88
+ const node = this._tree.nodes[root];
89
+ const result = callback(node, depth);
90
+ if (result !== void 0) {
91
+ return result;
92
+ }
93
+ for (const childId of node.children) {
94
+ const result2 = this.tranverse(callback, childId, depth + 1);
95
+ if (result2 !== void 0) {
96
+ return result2;
97
+ }
98
+ }
99
+ }
100
+ getNode(id) {
101
+ const node = this._tree.nodes[id];
102
+ invariant(node, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 80, S: this, A: ["node", ""] });
103
+ return node;
104
+ }
105
+ /**
106
+ * Get the children of a node.
107
+ */
108
+ getChildNodes(node) {
109
+ return node.children.map((id) => this.getNode(id));
110
+ }
111
+ /**
112
+ * Get the parent of a node.
113
+ */
114
+ getParent(node) {
115
+ const parent = this.tranverse((n) => {
116
+ if (n.children.includes(node.id)) {
117
+ return n;
118
+ }
119
+ });
120
+ return parent ?? null;
121
+ }
122
+ /**
123
+ * Get the next node in the tree.
124
+ */
125
+ getNext(node, hierarchical = true) {
126
+ if (hierarchical && node.children.length) {
127
+ return this.getChildNodes(node)[0];
128
+ } else {
129
+ const parent = this.getParent(node);
130
+ if (parent) {
131
+ const idx = this.getChildNodes(parent).findIndex(({ id }) => id === node.id);
132
+ if (idx < parent.children.length - 1) {
133
+ return this.getNode(parent.children[idx + 1]);
134
+ } else {
135
+ return this.getNext(parent, false);
136
+ }
137
+ }
138
+ }
139
+ }
140
+ /**
141
+ * Get the previous node in the tree.
142
+ */
143
+ getPrevious(node, hierarchical = true) {
144
+ const parent = this.getParent(node);
145
+ const idx = this.getChildNodes(parent).findIndex(({ id }) => id === node.id);
146
+ if (idx === 0) {
147
+ if (hierarchical) {
148
+ return parent;
149
+ }
150
+ } else {
151
+ const previous = this.getNode(parent.children[idx - 1]);
152
+ if (hierarchical && previous.children.length) {
153
+ return this.getLastDescendent(previous);
154
+ }
155
+ return previous;
156
+ }
157
+ }
158
+ /**
159
+ * Get the last descendent of a node.
160
+ */
161
+ getLastDescendent(node) {
162
+ const children = this.getChildNodes(node);
163
+ const last = children.length ? children[children.length - 1] : void 0;
164
+ if (last) {
165
+ return this.getLastDescendent(last);
166
+ }
167
+ return node;
168
+ }
169
+ //
170
+ // Mutations
171
+ //
172
+ /**
173
+ * Clear tree.
174
+ */
175
+ clear() {
176
+ const root = this._tree.nodes[this._tree.root];
177
+ root.children.length = 0;
178
+ Obj.update(this._tree, (obj) => {
179
+ obj.nodes = {
180
+ [root.id]: root
181
+ };
182
+ });
183
+ }
184
+ /**
185
+ * Add node.
186
+ */
187
+ addNode(parent, node, index) {
188
+ if (!node) {
189
+ const id = Key.ObjectId.random();
190
+ node = {
191
+ id,
192
+ children: [],
193
+ data: {
194
+ text: ""
195
+ }
196
+ };
197
+ }
198
+ const nodeToAdd = node;
199
+ Obj.update(this._tree, (obj) => {
200
+ obj.nodes[nodeToAdd.id] = nodeToAdd;
201
+ parent.children.splice(index ?? parent.children.length, 0, nodeToAdd.id);
202
+ });
203
+ return node;
204
+ }
205
+ /**
206
+ * Delete node.
207
+ */
208
+ deleteNode(parent, id) {
209
+ const node = this._tree.nodes[id];
210
+ if (!node) {
211
+ return void 0;
212
+ }
213
+ Obj.update(this._tree, (obj) => {
214
+ delete obj.nodes[node.id];
215
+ });
216
+ const idx = parent.children.findIndex((child) => child === id);
217
+ if (idx !== -1) {
218
+ Obj.update(this._tree, () => {
219
+ parent.children.splice(idx, 1);
220
+ });
221
+ }
222
+ return node;
223
+ }
224
+ /**
225
+ * Move child node.
226
+ */
227
+ moveNode(node, from, to) {
228
+ invariant(from >= 0 && from < node.children.length, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 200, S: this, A: ["from >= 0 && from < node.children.length", ""] });
229
+ invariant(to >= 0 && to < node.children.length, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 201, S: this, A: ["to >= 0 && to < node.children.length", ""] });
230
+ if (from === to) {
231
+ return null;
232
+ }
233
+ const child = node.children[from];
234
+ Obj.update(this._tree, () => {
235
+ node.children.splice(from, 1);
236
+ node.children.splice(to, 0, child);
237
+ });
238
+ return this.getNode(child);
239
+ }
240
+ /**
241
+ * Indent node.
242
+ */
243
+ indentNode(node) {
244
+ const parent = this.getParent(node);
245
+ if (!parent) {
246
+ return;
247
+ }
248
+ const idx = parent.children.findIndex((child) => child === node.id);
249
+ if (idx < 1 || idx >= parent.children.length) {
250
+ return;
251
+ }
252
+ const previous = this.getNode(parent.children[idx - 1]);
253
+ Obj.update(this._tree, () => {
254
+ parent.children.splice(idx, 1);
255
+ previous.children.push(node.id);
256
+ });
257
+ }
258
+ /**
259
+ * Unindent node.
260
+ */
261
+ unindentNode(node) {
262
+ const parent = this.getParent(node);
263
+ if (!parent) {
264
+ return;
265
+ }
266
+ const ancestor = this.getParent(parent);
267
+ if (!ancestor) {
268
+ return;
269
+ }
270
+ const nodeIdx = parent.children.findIndex((id) => id === node.id);
271
+ let rest = [];
272
+ Obj.update(this._tree, () => {
273
+ const removed = parent.children.splice(nodeIdx, parent.children.length - nodeIdx);
274
+ rest = removed.slice(1);
275
+ });
276
+ const parentIdx = this.getChildNodes(ancestor).findIndex((n) => n.id === parent.id);
277
+ Obj.update(this._tree, () => {
278
+ ancestor.children.splice(parentIdx + 1, 0, node.id);
279
+ });
280
+ Obj.update(this._tree, () => {
281
+ node.children.push(...rest);
282
+ });
283
+ }
284
+ };
285
+
286
+ export {
287
+ Tree,
288
+ treeTypeToTreeNode
289
+ };
290
+ //# sourceMappingURL=chunk-EM2BV4PF.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/Tree/types/types.ts", "../../../src/components/Tree/types/tree.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Key } from '@dxos/echo';\n\nimport { type TreeType } from './tree';\n\n/**\n * In-memory tree shape used by the d3 layouts.\n * `data` carries through to layout callbacks (e.g. hover/inspect) — typically an ECHO object on leaves.\n */\nexport type TreeNode<TData = unknown> = {\n id: string;\n label?: string;\n data?: TData;\n children?: TreeNode<TData>[];\n};\n\n/**\n * Convert an ECHO `TreeType` (id-keyed node map) into a nested `TreeNode` hierarchy.\n * Returns `undefined` if the root id is missing — the tree is then incomplete and shouldn't render.\n */\nexport const treeTypeToTreeNode = (\n tree: TreeType,\n rootId: Key.ObjectId = tree.root,\n visited: Set<string> = new Set(),\n): TreeNode | undefined => {\n const node = tree.nodes[rootId];\n if (!node) {\n return undefined;\n }\n if (visited.has(rootId)) {\n return { id: rootId, label: labelOf(node), data: node.data };\n }\n visited.add(rootId);\n\n return {\n id: rootId,\n label: labelOf(node),\n data: node.data,\n children: node.children\n .map((childId) => treeTypeToTreeNode(tree, childId, visited))\n .filter((c): c is TreeNode => Boolean(c)),\n };\n};\n\nconst labelOf = (node: { data: Record<string, any> }): string | undefined => {\n return typeof node.data?.text === 'string' ? node.data.text : undefined;\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { Key, Obj, Ref, Type } from '@dxos/echo';\nimport { TestSchema } from '@dxos/echo/testing';\nimport { invariant } from '@dxos/invariant';\n\n// TODO(burdon): Reconcile with @dxos/graph (i.e., common types).\n\nexport const TreeNodeType = Schema.Struct({\n id: Key.ObjectId,\n children: Schema.mutable(Schema.Array(Key.ObjectId)),\n data: Schema.mutable(Schema.Record({ key: Schema.String, value: Schema.Any })),\n ref: Schema.optional(Ref.Ref(TestSchema.Expando)),\n}).pipe(Schema.mutable);\n\nexport interface TreeNodeType extends Schema.Schema.Type<typeof TreeNodeType> {}\n\nexport const TreeType = Schema.Struct({\n root: Key.ObjectId,\n nodes: Schema.mutable(Schema.Record({ key: Key.ObjectId, value: TreeNodeType })),\n}).pipe(\n Type.object({\n typename: 'org.dxos.type.tree',\n version: '0.1.0',\n }),\n);\n\nexport interface TreeType extends Schema.Schema.Type<typeof TreeType> {}\n\n/**\n * Wrapper object for tree.\n */\nexport class Tree {\n static create = (): TreeType => {\n const id = Key.ObjectId.random();\n return Obj.make(TreeType, {\n root: id,\n nodes: {\n [id]: {\n id,\n children: [],\n data: { text: '' }, // TODO(burdon): Generic.\n },\n },\n });\n };\n\n private _tree: TreeType;\n\n constructor(tree?: TreeType) {\n this._tree = tree ?? Tree.create();\n }\n\n get tree() {\n return this._tree;\n }\n\n // TODO(burdon): Make reactive.\n get size() {\n return Object.keys(this._tree.nodes).length;\n }\n\n get root() {\n return this.getNode(this._tree.root);\n }\n\n //\n // Traversal\n //\n\n /**\n * Recursively traverse the tree until the callback returns a value.\n */\n tranverse<T>(\n callback: (node: TreeNodeType, depth: number) => T | void,\n root: Key.ObjectId = this._tree.root,\n depth = 0,\n ): T | void {\n const node = this._tree.nodes[root];\n const result = callback(node, depth);\n if (result !== undefined) {\n return result;\n }\n\n for (const childId of node.children) {\n const result = this.tranverse(callback, childId, depth + 1);\n if (result !== undefined) {\n return result;\n }\n }\n }\n\n getNode(id: Key.ObjectId): TreeNodeType {\n const node = this._tree.nodes[id];\n invariant(node);\n return node;\n }\n\n /**\n * Get the children of a node.\n */\n getChildNodes(node: TreeNodeType): Array<TreeNodeType> {\n return node.children.map((id) => this.getNode(id));\n }\n\n /**\n * Get the parent of a node.\n */\n getParent(node: TreeNodeType): TreeNodeType | null {\n const parent = this.tranverse((n) => {\n if (n.children.includes(node.id)) {\n return n;\n }\n });\n\n return parent ?? null;\n }\n\n /**\n * Get the next node in the tree.\n */\n getNext(node: TreeNodeType, hierarchical = true): TreeNodeType | undefined {\n if (hierarchical && node.children.length) {\n // First child.\n return this.getChildNodes(node)[0];\n } else {\n const parent = this.getParent(node);\n if (parent) {\n const idx = this.getChildNodes(parent).findIndex(({ id }) => id === node.id);\n if (idx < parent.children.length - 1) {\n // Next sibling.\n return this.getNode(parent.children[idx + 1]);\n } else {\n // Get parent's next sibling.\n return this.getNext(parent, false);\n }\n }\n }\n }\n\n /**\n * Get the previous node in the tree.\n */\n getPrevious(node: TreeNodeType, hierarchical = true): TreeNodeType | undefined {\n const parent = this.getParent(node)!;\n const idx = this.getChildNodes(parent).findIndex(({ id }) => id === node.id);\n if (idx === 0) {\n if (hierarchical) {\n return parent;\n }\n } else {\n const previous = this.getNode(parent.children[idx - 1]);\n if (hierarchical && previous.children.length) {\n return this.getLastDescendent(previous);\n }\n\n return previous;\n }\n }\n\n /**\n * Get the last descendent of a node.\n */\n getLastDescendent(node: TreeNodeType): TreeNodeType | undefined {\n const children = this.getChildNodes(node);\n const last = children.length ? children[children.length - 1] : undefined;\n if (last) {\n return this.getLastDescendent(last);\n }\n\n return node;\n }\n\n //\n // Mutations\n //\n\n /**\n * Clear tree.\n */\n clear(): void {\n const root = this._tree.nodes[this._tree.root];\n root.children.length = 0;\n Obj.update(this._tree, (obj) => {\n obj.nodes = {\n [root.id]: root,\n };\n });\n }\n\n /**\n * Add node.\n */\n addNode(parent: TreeNodeType, node?: TreeNodeType, index?: number): TreeNodeType {\n if (!node) {\n const id = Key.ObjectId.random();\n node = { id, children: [], data: { text: '' } }; // TODO(burdon): Generic.\n }\n\n const nodeToAdd = node;\n Obj.update(this._tree, (obj) => {\n obj.nodes[nodeToAdd.id] = nodeToAdd;\n parent.children.splice(index ?? parent.children.length, 0, nodeToAdd.id);\n });\n return node;\n }\n\n /**\n * Delete node.\n */\n deleteNode(parent: TreeNodeType, id: Key.ObjectId): TreeNodeType | undefined {\n const node = this._tree.nodes[id];\n if (!node) {\n return undefined;\n }\n\n Obj.update(this._tree, (obj) => {\n delete obj.nodes[node.id];\n });\n const idx = parent.children.findIndex((child) => child === id);\n if (idx !== -1) {\n Obj.update(this._tree, () => {\n parent.children.splice(idx, 1);\n });\n }\n\n return node;\n }\n\n /**\n * Move child node.\n */\n moveNode(node: TreeNodeType, from: number, to: number): TreeNodeType | null {\n invariant(from >= 0 && from < node.children.length);\n invariant(to >= 0 && to < node.children.length);\n if (from === to) {\n return null;\n }\n\n const child = node.children[from];\n Obj.update(this._tree, () => {\n node.children.splice(from, 1);\n node.children.splice(to, 0, child);\n });\n return this.getNode(child);\n }\n\n /**\n * Indent node.\n */\n indentNode(node: TreeNodeType): void {\n const parent = this.getParent(node);\n if (!parent) {\n return;\n }\n\n const idx = parent.children.findIndex((child) => child === node.id);\n if (idx < 1 || idx >= parent.children.length) {\n return;\n }\n\n const previous = this.getNode(parent.children[idx - 1]);\n Obj.update(this._tree, () => {\n parent.children.splice(idx, 1);\n previous.children.push(node.id);\n });\n }\n\n /**\n * Unindent node.\n */\n unindentNode(node: TreeNodeType): void {\n const parent = this.getParent(node);\n if (!parent) {\n return;\n }\n\n const ancestor = this.getParent(parent);\n if (!ancestor) {\n return;\n }\n\n // Remove node from parent and get following siblings.\n const nodeIdx = parent.children.findIndex((id) => id === node.id);\n let rest: Key.ObjectId[] = [];\n Obj.update(this._tree, () => {\n const removed = parent.children.splice(nodeIdx, parent.children.length - nodeIdx);\n rest = removed.slice(1); // Skip the node itself.\n });\n\n // Add to ancestor.\n const parentIdx = this.getChildNodes(ancestor).findIndex((n) => n.id === parent.id);\n Obj.update(this._tree, () => {\n ancestor.children.splice(parentIdx + 1, 0, node.id);\n });\n\n // Transplant following siblings to current node.\n Obj.update(this._tree, () => {\n node.children.push(...rest);\n });\n }\n}\n"],
5
+ "mappings": ";AAuBO,IAAMA,qBAAqB,CAChCC,MACAC,SAAuBD,KAAKE,MAC5BC,UAAuB,oBAAIC,IAAAA,MAAK;AAEhC,QAAMC,OAAOL,KAAKM,MAAML,MAAAA;AACxB,MAAI,CAACI,MAAM;AACT,WAAOE;EACT;AACA,MAAIJ,QAAQK,IAAIP,MAAAA,GAAS;AACvB,WAAO;MAAEQ,IAAIR;MAAQS,OAAOC,QAAQN,IAAAA;MAAOO,MAAMP,KAAKO;IAAK;EAC7D;AACAT,UAAQU,IAAIZ,MAAAA;AAEZ,SAAO;IACLQ,IAAIR;IACJS,OAAOC,QAAQN,IAAAA;IACfO,MAAMP,KAAKO;IACXE,UAAUT,KAAKS,SACZC,IAAI,CAACC,YAAYjB,mBAAmBC,MAAMgB,SAASb,OAAAA,CAAAA,EACnDc,OAAO,CAACC,MAAqBC,QAAQD,CAAAA,CAAAA;EAC1C;AACF;AAEA,IAAMP,UAAU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,YAAA,UAAA,OAAA,SAAA,OAAA,SAAA,OAAA,SAAA,SAAA,OAAA;AAEA,aAAA,QAAmB,MAAA,CAAA;IACnB,CAAA;UAEEC,YAASnD,KAASyC,cAAOW,QAAe,EAAG7B,UAAO,CAAA,MAAA,EAAA,OAAA,OAAA,EAAA;AACpD,QAAA,OAAA,KAAA,OAAA,MAAA;AAEA,eAAA,SAAA,OAAA,YAAA,GAAA,GAAA,KAAiD,EAAA;IACjD5B,CAAAA;AAEA,QAAA,OAAA,KAAA,OAAA,MAAA;AACF,WAAA,SAAA,KAAA,GAAA,IAAA;IACF,CAAA;;;",
6
+ "names": ["treeTypeToTreeNode", "tree", "rootId", "root", "visited", "Set", "node", "nodes", "undefined", "has", "id", "label", "labelOf", "data", "add", "children", "map", "childId", "filter", "c", "Boolean", "text", "Schema", "Key", "Obj", "Ref", "Type", "TestSchema", "invariant", "children", "data", "String", "ref", "optional", "pipe", "TreeType", "Struct", "ObjectId", "nodes", "Record", "key", "TreeNodeType", "object", "typename", "version", "id", "make", "root", "_tree", "tree", "result", "callback", "node", "depth", "undefined", "childId", "getNode", "n", "getChildNodes", "parent", "getParent", "idx", "hierarchical", "getLastDescendent", "previous", "length", "last", "update", "obj", "nodeToAdd", "splice", "index", "findIndex", "to", "from", "child", "push", "removed", "rest", "slice", "ancestor", "parentIdx"]
7
+ }
@@ -0,0 +1,25 @@
1
+ // src/ExplorerPlugin.tsx
2
+ import { Plugin } from "@dxos/app-framework";
3
+ import { AppPlugin } from "@dxos/app-toolkit";
4
+ import { CreateObject, ReactSurface } from "#capabilities";
5
+ import { meta } from "#meta";
6
+ import { translations } from "#translations";
7
+ import { Graph } from "#types";
8
+ var ExplorerPlugin = Plugin.define(meta).pipe(AppPlugin.addCreateObjectModule({
9
+ activate: CreateObject
10
+ }), AppPlugin.addSchemaModule({
11
+ schema: [
12
+ Graph.Graph
13
+ ]
14
+ }), AppPlugin.addSurfaceModule({
15
+ activate: ReactSurface
16
+ }), AppPlugin.addTranslationsModule({
17
+ translations
18
+ }), Plugin.make);
19
+ var ExplorerPlugin_default = ExplorerPlugin;
20
+
21
+ export {
22
+ ExplorerPlugin,
23
+ ExplorerPlugin_default
24
+ };
25
+ //# sourceMappingURL=chunk-GRJXLL4Z.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/ExplorerPlugin.tsx"],
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { Plugin } from '@dxos/app-framework';\nimport { AppPlugin } from '@dxos/app-toolkit';\n\nimport { CreateObject, ReactSurface } from '#capabilities';\nimport { meta } from '#meta';\nimport { translations } from '#translations';\nimport { Graph } from '#types';\n\nexport const ExplorerPlugin = Plugin.define(meta).pipe(\n AppPlugin.addCreateObjectModule({ activate: CreateObject }),\n AppPlugin.addSchemaModule({ schema: [Graph.Graph] }),\n AppPlugin.addSurfaceModule({ activate: ReactSurface }),\n AppPlugin.addTranslationsModule({ translations }),\n Plugin.make,\n);\n\nexport default ExplorerPlugin;\n"],
5
+ "mappings": ";AAIA,SAASA,cAAc;AACvB,SAASC,iBAAiB;AAE1B,SAASC,cAAcC,oBAAoB;AAC3C,SAASC,YAAY;AACrB,SAASC,oBAAoB;AAC7B,SAASC,aAAa;AAEf,IAAMC,iBAAiBP,OAAOQ,OAAOJ,IAAAA,EAAMK,KAChDR,UAAUS,sBAAsB;EAAEC,UAAUT;AAAa,CAAA,GACzDD,UAAUW,gBAAgB;EAAEC,QAAQ;IAACP,MAAMA;;AAAO,CAAA,GAClDL,UAAUa,iBAAiB;EAAEH,UAAUR;AAAa,CAAA,GACpDF,UAAUc,sBAAsB;EAAEV;AAAa,CAAA,GAC/CL,OAAOgB,IAAI;AAGb,IAAA,yBAAeT;",
6
+ "names": ["Plugin", "AppPlugin", "CreateObject", "ReactSurface", "meta", "translations", "Graph", "ExplorerPlugin", "define", "pipe", "addCreateObjectModule", "activate", "addSchemaModule", "schema", "addSurfaceModule", "addTranslationsModule", "make"]
7
+ }
@@ -0,0 +1,14 @@
1
+ // src/util/node-color.ts
2
+ import { Obj } from "@dxos/echo";
3
+ import { getHashHue } from "@dxos/ui-theme";
4
+ var getNodeFillForTypename = (typename) => {
5
+ return `var(--color-${getHashHue(typename)}-400)`;
6
+ };
7
+ var getNodeFillForObject = (object) => {
8
+ return getNodeFillForTypename(object && Obj.getTypename(object));
9
+ };
10
+
11
+ export {
12
+ getNodeFillForObject
13
+ };
14
+ //# sourceMappingURL=chunk-V2OFO6PI.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/util/node-color.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2026 DXOS.org\n//\n\nimport { Obj } from '@dxos/echo';\nimport { getHashHue } from '@dxos/ui-theme';\n\n/**\n * Returns the SVG `fill` value for a node, derived from its typename via the\n * same hue-hash used by the force-directed renderer. Resolves to a Tailwind\n * color token CSS variable so the value reads consistently across themes.\n *\n * Used by every variant of `ExplorerArticle` so nodes are colored consistently\n * regardless of which layout is rendering them.\n */\nexport const getNodeFillForTypename = (typename: string | undefined): string => {\n return `var(--color-${getHashHue(typename)}-400)`;\n};\n\n/** Convenience: derive the fill from an ECHO object's typename. */\nexport const getNodeFillForObject = (object: Obj.Unknown | undefined): string => {\n return getNodeFillForTypename(object && Obj.getTypename(object));\n};\n"],
5
+ "mappings": ";AAIA,SAASA,WAAW;AACpB,SAASC,kBAAkB;AAUpB,IAAMC,yBAAyB,CAACC,aAAAA;AACrC,SAAO,eAAeF,WAAWE,QAAAA,CAAAA;AACnC;AAGO,IAAMC,uBAAuB,CAACC,WAAAA;AACnC,SAAOH,uBAAuBG,UAAUL,IAAIM,YAAYD,MAAAA,CAAAA;AAC1D;",
6
+ "names": ["Obj", "getHashHue", "getNodeFillForTypename", "typename", "getNodeFillForObject", "object", "getTypename"]
7
+ }