@dxos/plugin-explorer 0.8.4-main.c4373fc → 0.8.4-main.d9fc60f731

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 (278) hide show
  1. package/LICENSE +102 -5
  2. package/PLUGIN.mdl +340 -0
  3. package/dist/lib/neutral/ExplorerArticle-4I7PNGDC.mjs +459 -0
  4. package/dist/lib/neutral/ExplorerArticle-4I7PNGDC.mjs.map +7 -0
  5. package/dist/lib/neutral/ExplorerPlugin.mjs +10 -0
  6. package/dist/lib/neutral/capabilities/index.mjs +11 -0
  7. package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
  8. package/dist/lib/neutral/chunk-3D7BYXOR.mjs +37 -0
  9. package/dist/lib/neutral/chunk-3D7BYXOR.mjs.map +7 -0
  10. package/dist/lib/neutral/chunk-42BYLQQA.mjs +42 -0
  11. package/dist/lib/neutral/chunk-42BYLQQA.mjs.map +7 -0
  12. package/dist/lib/neutral/chunk-7XUDLV6E.mjs +287 -0
  13. package/dist/lib/neutral/chunk-7XUDLV6E.mjs.map +7 -0
  14. package/dist/lib/neutral/chunk-HI324IB4.mjs +69 -0
  15. package/dist/lib/neutral/chunk-HI324IB4.mjs.map +7 -0
  16. package/dist/lib/neutral/chunk-IKHJV3Q4.mjs +20 -0
  17. package/dist/lib/neutral/chunk-IKHJV3Q4.mjs.map +7 -0
  18. package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
  19. package/dist/lib/{browser/chunk-UCDNCIRV.mjs → neutral/components/index.mjs} +882 -556
  20. package/dist/lib/neutral/components/index.mjs.map +7 -0
  21. package/dist/lib/neutral/containers/index.mjs +9 -0
  22. package/dist/lib/neutral/containers/index.mjs.map +7 -0
  23. package/dist/lib/neutral/create-object-F6TKVAGV.mjs +39 -0
  24. package/dist/lib/neutral/create-object-F6TKVAGV.mjs.map +7 -0
  25. package/dist/lib/neutral/hooks/index.mjs +45 -0
  26. package/dist/lib/neutral/hooks/index.mjs.map +7 -0
  27. package/dist/lib/neutral/index.mjs +14 -0
  28. package/dist/lib/neutral/meta.json +1 -0
  29. package/dist/lib/{browser → neutral}/meta.mjs +2 -1
  30. package/dist/lib/neutral/plugin.mjs +12 -0
  31. package/dist/lib/neutral/plugin.mjs.map +7 -0
  32. package/dist/lib/neutral/react-surface-APBW2VQG.mjs +26 -0
  33. package/dist/lib/neutral/react-surface-APBW2VQG.mjs.map +7 -0
  34. package/dist/lib/neutral/testing/index.mjs +139 -0
  35. package/dist/lib/neutral/testing/index.mjs.map +7 -0
  36. package/dist/lib/neutral/translations.mjs +33 -0
  37. package/dist/lib/neutral/translations.mjs.map +7 -0
  38. package/dist/lib/neutral/types/index.mjs +10 -0
  39. package/dist/lib/neutral/types/index.mjs.map +7 -0
  40. package/dist/types/data/cities.d.ts +4 -4
  41. package/dist/types/data/cities.d.ts.map +1 -1
  42. package/dist/types/data/countries-110m.d.ts +19 -22
  43. package/dist/types/data/countries-110m.d.ts.map +1 -1
  44. package/dist/types/src/ExplorerPlugin.d.ts +3 -1
  45. package/dist/types/src/ExplorerPlugin.d.ts.map +1 -1
  46. package/dist/types/src/ExplorerPlugin.test.d.ts +2 -0
  47. package/dist/types/src/ExplorerPlugin.test.d.ts.map +1 -0
  48. package/dist/types/src/capabilities/create-object.d.ts +11 -0
  49. package/dist/types/src/capabilities/create-object.d.ts.map +1 -0
  50. package/dist/types/src/capabilities/index.d.ts +8 -2
  51. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  52. package/dist/types/src/capabilities/react-surface.d.ts +3 -2
  53. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  54. package/dist/types/src/components/Chart/Chart.d.ts +1 -1
  55. package/dist/types/src/components/Chart/Chart.d.ts.map +1 -1
  56. package/dist/types/src/components/Chart/Chart.stories.d.ts +4 -1
  57. package/dist/types/src/components/Chart/Chart.stories.d.ts.map +1 -1
  58. package/dist/types/src/components/Globe/Globe.d.ts +1 -1
  59. package/dist/types/src/components/Globe/Globe.d.ts.map +1 -1
  60. package/dist/types/src/components/Globe/Globe.stories.d.ts +5 -2
  61. package/dist/types/src/components/Globe/Globe.stories.d.ts.map +1 -1
  62. package/dist/types/src/components/Graph/CanvasForceGraph.d.ts +13 -0
  63. package/dist/types/src/components/Graph/CanvasForceGraph.d.ts.map +1 -0
  64. package/dist/types/src/components/Graph/CanvasForceGraph.stories.d.ts +17 -0
  65. package/dist/types/src/components/Graph/CanvasForceGraph.stories.d.ts.map +1 -0
  66. package/dist/types/src/components/Graph/ForceGraph.d.ts +12 -5
  67. package/dist/types/src/components/Graph/ForceGraph.d.ts.map +1 -1
  68. package/dist/types/src/components/Graph/ForceGraph.stories.d.ts +4 -2
  69. package/dist/types/src/components/Graph/ForceGraph.stories.d.ts.map +1 -1
  70. package/dist/types/src/components/Graph/{adapter.d.ts → graph-adapter.d.ts} +2 -2
  71. package/dist/types/src/components/Graph/graph-adapter.d.ts.map +1 -0
  72. package/dist/types/src/components/Graph/index.d.ts +1 -1
  73. package/dist/types/src/components/Graph/index.d.ts.map +1 -1
  74. package/dist/types/src/components/Lattice/Lattice.d.ts +20 -0
  75. package/dist/types/src/components/Lattice/Lattice.d.ts.map +1 -0
  76. package/dist/types/src/components/Lattice/Lattice.stories.d.ts +8 -0
  77. package/dist/types/src/components/Lattice/Lattice.stories.d.ts.map +1 -0
  78. package/dist/types/src/components/Lattice/index.d.ts +2 -0
  79. package/dist/types/src/components/Lattice/index.d.ts.map +1 -0
  80. package/dist/types/src/components/Tree/EdgeBundling.stories.d.ts +21 -0
  81. package/dist/types/src/components/Tree/EdgeBundling.stories.d.ts.map +1 -0
  82. package/dist/types/src/components/Tree/Tree.d.ts +20 -23
  83. package/dist/types/src/components/Tree/Tree.d.ts.map +1 -1
  84. package/dist/types/src/components/Tree/Tree.stories.d.ts +5 -12
  85. package/dist/types/src/components/Tree/Tree.stories.d.ts.map +1 -1
  86. package/dist/types/src/components/Tree/index.d.ts +2 -0
  87. package/dist/types/src/components/Tree/index.d.ts.map +1 -1
  88. package/dist/types/src/components/Tree/layout/HierarchicalEdgeBundling.d.ts +37 -2
  89. package/dist/types/src/components/Tree/layout/HierarchicalEdgeBundling.d.ts.map +1 -1
  90. package/dist/types/src/components/Tree/layout/RadialTree.d.ts +35 -2
  91. package/dist/types/src/components/Tree/layout/RadialTree.d.ts.map +1 -1
  92. package/dist/types/src/components/Tree/layout/TidyTree.d.ts +24 -2
  93. package/dist/types/src/components/Tree/layout/TidyTree.d.ts.map +1 -1
  94. package/dist/types/src/components/Tree/layout/hierarchy.d.ts +17 -0
  95. package/dist/types/src/components/Tree/layout/hierarchy.d.ts.map +1 -0
  96. package/dist/types/src/components/Tree/layout/index.d.ts +5 -4
  97. package/dist/types/src/components/Tree/layout/index.d.ts.map +1 -1
  98. package/dist/types/src/components/Tree/layout/slots.d.ts +7 -0
  99. package/dist/types/src/components/Tree/layout/slots.d.ts.map +1 -0
  100. package/dist/types/src/components/Tree/layout/useContainerSize.d.ts +15 -0
  101. package/dist/types/src/components/Tree/layout/useContainerSize.d.ts.map +1 -0
  102. package/dist/types/src/components/Tree/types/tree.d.ts +50 -27
  103. package/dist/types/src/components/Tree/types/tree.d.ts.map +1 -1
  104. package/dist/types/src/components/Tree/types/types.d.ts +14 -4
  105. package/dist/types/src/components/Tree/types/types.d.ts.map +1 -1
  106. package/dist/types/src/components/index.d.ts +1 -4
  107. package/dist/types/src/components/index.d.ts.map +1 -1
  108. package/dist/types/src/containers/ExplorerArticle/ExplorerArticle.d.ts +8 -0
  109. package/dist/types/src/containers/ExplorerArticle/ExplorerArticle.d.ts.map +1 -0
  110. package/dist/types/src/containers/ExplorerArticle/ExplorerArticle.stories.d.ts +15 -0
  111. package/dist/types/src/containers/ExplorerArticle/ExplorerArticle.stories.d.ts.map +1 -0
  112. package/dist/types/src/containers/ExplorerArticle/Visualization.d.ts +18 -0
  113. package/dist/types/src/containers/ExplorerArticle/Visualization.d.ts.map +1 -0
  114. package/dist/types/src/containers/ExplorerArticle/index.d.ts +2 -0
  115. package/dist/types/src/containers/ExplorerArticle/index.d.ts.map +1 -0
  116. package/dist/types/src/containers/ExplorerArticle/variants.d.ts +9 -0
  117. package/dist/types/src/containers/ExplorerArticle/variants.d.ts.map +1 -0
  118. package/dist/types/src/containers/index.d.ts +3 -0
  119. package/dist/types/src/containers/index.d.ts.map +1 -0
  120. package/dist/types/src/hooks/useGraphModel.d.ts +2 -2
  121. package/dist/types/src/hooks/useGraphModel.d.ts.map +1 -1
  122. package/dist/types/src/index.d.ts +1 -3
  123. package/dist/types/src/index.d.ts.map +1 -1
  124. package/dist/types/src/meta.d.ts +2 -2
  125. package/dist/types/src/meta.d.ts.map +1 -1
  126. package/dist/types/src/plugin.d.ts +3 -0
  127. package/dist/types/src/plugin.d.ts.map +1 -0
  128. package/dist/types/src/{components/Tree/testing → testing}/generator.d.ts +1 -1
  129. package/dist/types/src/testing/generator.d.ts.map +1 -0
  130. package/dist/types/src/testing/index.d.ts +4 -0
  131. package/dist/types/src/testing/index.d.ts.map +1 -0
  132. package/dist/types/src/testing/relations.d.ts +32 -0
  133. package/dist/types/src/testing/relations.d.ts.map +1 -0
  134. package/dist/types/src/translations.d.ts +31 -22
  135. package/dist/types/src/translations.d.ts.map +1 -1
  136. package/dist/types/src/types/ExplorerAction.d.ts +6 -0
  137. package/dist/types/src/types/ExplorerAction.d.ts.map +1 -0
  138. package/dist/types/src/types/Graph.d.ts +22 -0
  139. package/dist/types/src/types/Graph.d.ts.map +1 -0
  140. package/dist/types/src/types/index.d.ts +2 -2
  141. package/dist/types/src/types/index.d.ts.map +1 -1
  142. package/dist/types/src/util/index.d.ts +3 -0
  143. package/dist/types/src/util/index.d.ts.map +1 -0
  144. package/dist/types/src/util/node-color.d.ts +13 -0
  145. package/dist/types/src/util/node-color.d.ts.map +1 -0
  146. package/dist/types/src/{components → util}/plot.d.ts +1 -1
  147. package/dist/types/src/util/plot.d.ts.map +1 -0
  148. package/dist/types/tsconfig.tsbuildinfo +1 -1
  149. package/package.json +113 -65
  150. package/src/ExplorerPlugin.test.ts +26 -0
  151. package/src/ExplorerPlugin.tsx +20 -52
  152. package/src/capabilities/create-object.ts +36 -0
  153. package/src/capabilities/index.ts +3 -3
  154. package/src/capabilities/react-surface.tsx +24 -15
  155. package/src/components/Chart/Chart.stories.tsx +16 -23
  156. package/src/components/Chart/Chart.tsx +1 -1
  157. package/src/components/Globe/Globe.stories.tsx +19 -22
  158. package/src/components/Globe/Globe.tsx +1 -1
  159. package/src/components/Graph/CanvasForceGraph.stories.tsx +97 -0
  160. package/src/components/Graph/CanvasForceGraph.tsx +124 -0
  161. package/src/components/Graph/ForceGraph.stories.tsx +100 -35
  162. package/src/components/Graph/ForceGraph.tsx +105 -85
  163. package/src/components/Graph/{adapter.ts → graph-adapter.ts} +14 -8
  164. package/src/components/Graph/index.ts +1 -1
  165. package/src/components/Lattice/Lattice.stories.tsx +104 -0
  166. package/src/components/Lattice/Lattice.tsx +182 -0
  167. package/src/components/Lattice/index.ts +5 -0
  168. package/src/components/Tree/EdgeBundling.stories.tsx +144 -0
  169. package/src/components/Tree/Tree.stories.tsx +20 -38
  170. package/src/components/Tree/Tree.tsx +69 -95
  171. package/src/components/Tree/index.ts +2 -0
  172. package/src/components/Tree/layout/HierarchicalEdgeBundling.tsx +335 -0
  173. package/src/components/Tree/layout/RadialTree.tsx +242 -0
  174. package/src/components/Tree/layout/TidyTree.tsx +246 -0
  175. package/src/components/Tree/layout/hierarchy.ts +32 -0
  176. package/src/components/Tree/layout/index.ts +5 -5
  177. package/src/components/Tree/layout/slots.ts +19 -0
  178. package/src/components/Tree/layout/useContainerSize.ts +43 -0
  179. package/src/components/Tree/types/tree.test.ts +8 -7
  180. package/src/components/Tree/types/tree.ts +51 -35
  181. package/src/components/Tree/types/types.ts +38 -29
  182. package/src/components/index.ts +1 -4
  183. package/src/containers/ExplorerArticle/ExplorerArticle.stories.tsx +152 -0
  184. package/src/containers/ExplorerArticle/ExplorerArticle.tsx +120 -0
  185. package/src/containers/ExplorerArticle/Visualization.tsx +523 -0
  186. package/src/containers/ExplorerArticle/index.ts +5 -0
  187. package/src/containers/ExplorerArticle/variants.ts +47 -0
  188. package/src/containers/index.ts +7 -0
  189. package/src/hooks/useGraphModel.ts +25 -14
  190. package/src/index.ts +1 -4
  191. package/src/meta.ts +30 -6
  192. package/src/plugin.ts +9 -0
  193. package/src/{components/Tree/testing → testing}/generator.ts +6 -4
  194. package/src/testing/index.ts +9 -0
  195. package/src/testing/relations.ts +117 -0
  196. package/src/translations.ts +16 -13
  197. package/src/types/ExplorerAction.ts +20 -0
  198. package/src/types/Graph.ts +41 -0
  199. package/src/types/index.ts +2 -2
  200. package/src/typings.d.ts +8 -0
  201. package/src/util/index.ts +6 -0
  202. package/src/util/node-color.ts +23 -0
  203. package/src/{components → util}/plot.ts +16 -4
  204. package/src/vite-env.d.ts +10 -0
  205. package/dist/lib/browser/ExplorerContainer-S66JDOAF.mjs +0 -49
  206. package/dist/lib/browser/ExplorerContainer-S66JDOAF.mjs.map +0 -7
  207. package/dist/lib/browser/chunk-2DGFNLRO.mjs +0 -19
  208. package/dist/lib/browser/chunk-2DGFNLRO.mjs.map +0 -7
  209. package/dist/lib/browser/chunk-2MKBRIUT.mjs +0 -31
  210. package/dist/lib/browser/chunk-2MKBRIUT.mjs.map +0 -7
  211. package/dist/lib/browser/chunk-4ETQJYX4.mjs +0 -38
  212. package/dist/lib/browser/chunk-4ETQJYX4.mjs.map +0 -7
  213. package/dist/lib/browser/chunk-NXGP6NTP.mjs +0 -203
  214. package/dist/lib/browser/chunk-NXGP6NTP.mjs.map +0 -7
  215. package/dist/lib/browser/chunk-UCDNCIRV.mjs.map +0 -7
  216. package/dist/lib/browser/index.mjs +0 -112
  217. package/dist/lib/browser/index.mjs.map +0 -7
  218. package/dist/lib/browser/intent-resolver-OXJJ3PII.mjs +0 -24
  219. package/dist/lib/browser/intent-resolver-OXJJ3PII.mjs.map +0 -7
  220. package/dist/lib/browser/meta.json +0 -1
  221. package/dist/lib/browser/react-surface-C4EC6ZDZ.mjs +0 -31
  222. package/dist/lib/browser/react-surface-C4EC6ZDZ.mjs.map +0 -7
  223. package/dist/lib/browser/types/index.mjs +0 -10
  224. package/dist/lib/node-esm/ExplorerContainer-GIJN67DO.mjs +0 -50
  225. package/dist/lib/node-esm/ExplorerContainer-GIJN67DO.mjs.map +0 -7
  226. package/dist/lib/node-esm/chunk-3ODK27PU.mjs +0 -33
  227. package/dist/lib/node-esm/chunk-3ODK27PU.mjs.map +0 -7
  228. package/dist/lib/node-esm/chunk-6JACZE7E.mjs +0 -205
  229. package/dist/lib/node-esm/chunk-6JACZE7E.mjs.map +0 -7
  230. package/dist/lib/node-esm/chunk-AGHU3KVI.mjs +0 -39
  231. package/dist/lib/node-esm/chunk-AGHU3KVI.mjs.map +0 -7
  232. package/dist/lib/node-esm/chunk-PX6LHR2N.mjs +0 -21
  233. package/dist/lib/node-esm/chunk-PX6LHR2N.mjs.map +0 -7
  234. package/dist/lib/node-esm/chunk-WHKUQG5M.mjs +0 -11343
  235. package/dist/lib/node-esm/chunk-WHKUQG5M.mjs.map +0 -7
  236. package/dist/lib/node-esm/index.mjs +0 -113
  237. package/dist/lib/node-esm/index.mjs.map +0 -7
  238. package/dist/lib/node-esm/intent-resolver-GVM36TJX.mjs +0 -25
  239. package/dist/lib/node-esm/intent-resolver-GVM36TJX.mjs.map +0 -7
  240. package/dist/lib/node-esm/meta.json +0 -1
  241. package/dist/lib/node-esm/meta.mjs +0 -8
  242. package/dist/lib/node-esm/react-surface-YGGLTBF3.mjs +0 -32
  243. package/dist/lib/node-esm/react-surface-YGGLTBF3.mjs.map +0 -7
  244. package/dist/lib/node-esm/types/index.mjs +0 -11
  245. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  246. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  247. package/dist/types/src/components/ExplorerContainer.d.ts +0 -9
  248. package/dist/types/src/components/ExplorerContainer.d.ts.map +0 -1
  249. package/dist/types/src/components/Graph/D3ForceGraph.d.ts +0 -14
  250. package/dist/types/src/components/Graph/D3ForceGraph.d.ts.map +0 -1
  251. package/dist/types/src/components/Graph/D3ForceGraph.stories.d.ts +0 -15
  252. package/dist/types/src/components/Graph/D3ForceGraph.stories.d.ts.map +0 -1
  253. package/dist/types/src/components/Graph/adapter.d.ts.map +0 -1
  254. package/dist/types/src/components/Graph/testing.d.ts +0 -14
  255. package/dist/types/src/components/Graph/testing.d.ts.map +0 -1
  256. package/dist/types/src/components/Tree/testing/generator.d.ts.map +0 -1
  257. package/dist/types/src/components/Tree/testing/index.d.ts +0 -2
  258. package/dist/types/src/components/Tree/testing/index.d.ts.map +0 -1
  259. package/dist/types/src/components/plot.d.ts.map +0 -1
  260. package/dist/types/src/types/schema.d.ts +0 -12
  261. package/dist/types/src/types/schema.d.ts.map +0 -1
  262. package/dist/types/src/types/types.d.ts +0 -18
  263. package/dist/types/src/types/types.d.ts.map +0 -1
  264. package/src/capabilities/intent-resolver.ts +0 -19
  265. package/src/components/ExplorerContainer.tsx +0 -50
  266. package/src/components/Graph/D3ForceGraph.stories.tsx +0 -68
  267. package/src/components/Graph/D3ForceGraph.tsx +0 -101
  268. package/src/components/Graph/testing.ts +0 -55
  269. package/src/components/Tree/layout/HierarchicalEdgeBundling.ts +0 -162
  270. package/src/components/Tree/layout/RadialTree.ts +0 -94
  271. package/src/components/Tree/layout/TidyTree.ts +0 -101
  272. package/src/components/Tree/testing/index.ts +0 -5
  273. package/src/types/schema.ts +0 -16
  274. package/src/types/types.ts +0 -22
  275. /package/dist/lib/{browser/meta.mjs.map → neutral/ExplorerPlugin.mjs.map} +0 -0
  276. /package/dist/lib/{browser/types/index.mjs.map → neutral/chunk-J5LGTIGS.mjs.map} +0 -0
  277. /package/dist/lib/{node-esm/types → neutral}/index.mjs.map +0 -0
  278. /package/dist/lib/{node-esm → neutral}/meta.mjs.map +0 -0
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/ExplorerPlugin.tsx", "raw-loader:/__w/dxos/dxos/packages/plugins/plugin-explorer/PLUGIN.mdl?raw"],
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\n// eslint-disable-next-line import/no-relative-packages\nimport pluginSpec from '../PLUGIN.mdl?raw';\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 AppPlugin.addPluginAssetModule({\n asset: { pluginId: meta.id, path: 'PLUGIN.mdl', content: pluginSpec, mimeType: 'application/x-mdl' },\n }),\n Plugin.make,\n);\n\nexport default ExplorerPlugin;\n", "---\nid: org.dxos.plugin.explorer\nname: ExplorerPlugin\nversion: 0.1.0\n---\n\nAn interactive hypergraph visualization plugin for `DXOS` Composer that reveals relationships between objects in a workspace.\nThe plugin renders a live `Graph` object \u2014 backed by a `View` and a `QueryAST` query \u2014 through four switchable layout\nvariants: force-directed, radial cluster, edge bundling, and lattice.\nNode colours are derived from ECHO object types; hovering a node triggers an anchor-card preview.\n\n## Extensions\n\nThe following extension dialects are used in this document.\nEach extension is defined in the Appendix or resolved via its URI.\n\n| Term | URI |\n|-------------|--------------------------------|\n| `type` | `org.dxos.mdl.type@1.0` |\n| `feat` | `org.dxos.mdl.feat@1.0` |\n| `test` | `org.dxos.mdl.test@1.0` |\n| `component` | `org.dxos.mdl.component@1.0` |\n| `op` | `org.dxos.mdl.op@1.0` |\n\n## Types\n\n```mdl\ntype QueryInput\n fields:\n raw?: string # raw query string entered by the user\n ast: QueryAST.Query # compiled AST produced by QueryBuilder\n```\n\n```mdl\ntype GraphObject\n desc: ECHO-persistent object that describes a hypergraph visualisation session.\n fields:\n name?: string\n view: Ref<View> # schema view that defines visible fields\n query: QueryInput\n```\n\n```mdl\ntype ExplorerVariant\n literals: force | cluster | bundle | lattice\n```\n\n## Components\n\n```mdl\ncomponent ExplorerArticle\n desc: |\n Top-level article / section surface for a Graph object.\n Renders one of four SVG layout variants and a toolbar for switching between them.\n props:\n role: article | section\n subject: Ref<View>\n attendableId?: string\n state:\n variant: ExplorerVariant # active layout; default force\n filter?: Filter.Any # compiled from toolbar query input\n model?: SpaceGraphModel # live reactive graph built from db + filter\n slots:\n toolbar?: ReactNode # shown only when role === article\n actions:\n setVariant(v: ExplorerVariant)\n setFilter(raw: string)\n layout: |\n \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n \u2502 [toolbar slot \u2014 article only] \u2502\n \u2502 [QueryEditor] [variant tabs] \u2502\n \u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n \u2502 \u2502\n \u2502 SVG canvas (force / cluster \u2502\n \u2502 / bundle / lattice) \u2502\n \u2502 \u2502\n \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n```\n\n```mdl\ncomponent Visualization\n desc: |\n Internal component that owns a single persistent SVG.Graph mount.\n Swaps the active GraphProjector when the variant changes, seeding the\n new projector with the previous layout so node positions tween smoothly.\n props:\n variant: ExplorerVariant\n model: SpaceGraphModel\n state:\n projector?: GraphProjector<SpaceGraphNode>\n actions:\n createProjector(variant: ExplorerVariant, prev?: GraphLayout) \u2192 GraphProjector\n createRenderNode(variant: ExplorerVariant) \u2192 RenderNode\n```\n\n## Operations\n\n```mdl\nop createGraph\n desc: |\n Creates a new Graph object scoped to a target space or collection.\n Derives a ViewModel from the database for the selected typename, then\n writes the object via SpaceOperation.AddObject.\n input:\n name?: string\n typename?: string # ECHO typename used to seed the initial view\n target: Space | Collection\n targetNodeId?: string\n output: GraphObject\n effects: [echo:write]\n note: |\n The typename is resolved through ViewModel.makeFromDatabase; the resulting\n View is stored as a Ref inside the Graph object.\n```\n\n```mdl\nop buildFilter\n desc: |\n Compiles a raw query string into a Filter via QueryBuilder.\n Pure \u2014 no side effects; result is passed to SpaceGraphModel.setFilter.\n input:\n raw: string\n output: Filter.Any\n errors:\n ParseError: raw string is not valid query syntax\n```\n\n## Features\n\n```mdl\nfeat F-1: Graph Object\n\n req F-1.1: A Graph object stores a name, a View ref, and a compiled QueryAST.\n req F-1.2:\n when: user creates a new graph\n then: op:createGraph derives a ViewModel from the chosen typename and writes the Graph to ECHO\n\n req F-1.3:\n when: Graph is persisted\n then: it appears in the space object list and can be opened as an article\n```\n\n```mdl\nfeat F-2: Live Graph Model\n\n req F-2.1:\n when: ExplorerArticle mounts with a valid Graph subject\n then: SpaceGraphModel is opened against the subject's database\n\n req F-2.2:\n when: user types a query in the toolbar\n then: op:buildFilter compiles the raw string; model.setFilter applied; SVG re-renders\n\n req F-2.3:\n when: Graph is unmounted\n then: SpaceGraphModel is closed and all subscriptions released\n\n req F-2.4:\n when: an ECHO object in the database changes\n then: SpaceGraphModel emits an update and SVG.Graph re-renders without full remount\n tags: [reactive, collaborative]\n```\n\n```mdl\nfeat F-3: Visualization Variants\n\n req F-3.1:\n when: variant tab is selected\n then: Visualization swaps projector; previous node x/y seed the new projector so positions tween\n\n req F-3.2:\n when: variant is force\n then: SVG.Zoom wrapper is mounted enabling pan/zoom drag interaction\n\n req F-3.3:\n when: variant is cluster or bundle\n then: no SVG.Zoom wrapper; leaves grouped by typename; radial labels fade in after tween\n\n req F-3.4:\n when: variant is lattice\n then: nodes rendered as small rounded rectangles sorted by typename then label\n\n req F-3.5:\n when: variant is cluster and user clicks a root or group node\n then: subtree toggles collapsed/expanded via GraphClusterProjector.toggleCollapsed\n```\n\n```mdl\nfeat F-4: Node Interaction\n\n req F-4.1:\n when: pointer enters a node\n then: DxAnchorActivate event dispatched with the object's DXN and label, kind: card\n\n req F-4.2:\n when: pointer leaves a node\n then: DxAnchorActivate cleared (onNodeHover called with null)\n\n req F-4.3:\n when: node has no underlying ECHO object (synthetic root / group)\n then: no preview dispatched; node rendered in neutral colour\n```\n\n## Acceptance\n\n```mdl\ntest T-1: Graph creation\n given: user opens the object creation dialog and selects Graph\n when: a typename is selected and the form submitted\n then:\n - op:createGraph runs without error\n - new Graph object visible in space object list\n - Graph.view references a valid View object\n```\n\n```mdl\ntest T-2: Article mounts model\n given: a Graph with a populated query\n when: ExplorerArticle is rendered with role === article\n then:\n - SpaceGraphModel is opened\n - SVG canvas renders nodes derived from the database\n - toolbar shows QueryEditor and variant tabs\n```\n\n```mdl\ntest T-3: Variant switch preserves positions\n given: force variant is active with nodes positioned\n when: user switches to cluster variant\n then:\n - projector is recreated from previous layout\n - nodes tween from old positions to cluster target positions\n - SVG.Zoom wrapper is absent in the new mount\n```\n\n```mdl\ntest T-4: Query filter updates graph\n given: ExplorerArticle is open with all objects visible\n when: user types a typename filter in QueryEditor\n then:\n - op:buildFilter returns a Filter without error\n - SpaceGraphModel.setFilter applied\n - only matching nodes remain visible in the SVG\n```\n\n```mdl\ntest T-5: Node hover preview\n given: force-directed graph with at least one ECHO object node\n when: pointer enters that node\n then:\n - DxAnchorActivate event fired with correct DXN\n - kind === card\n```\n\n```mdl\ntest T-6: Lattice sort order\n given: database contains objects of two typenames A and B\n when: lattice variant is active\n then:\n - all typename-A nodes appear before typename-B nodes (or vice-versa, consistent order)\n - within each group nodes are ordered alphabetically by label\n```\n\n```mdl\ntest T-7: Model closed on unmount\n given: ExplorerArticle is mounted and SpaceGraphModel is open\n when: component unmounts\n then:\n - SpaceGraphModel.close() is called\n - no lingering ECHO subscriptions remain\n```\n\n---\n\n## Appendix: Extension Definitions\n\nExtension block types used in this document are defined below using\nthe core `ext` primitive \u2014 the only construct the base language provides.\n\n```mdl\next type\n uri: org.dxos.mdl.type@1.0\n desc: A named data structure with typed fields and optional literals.\n fields:\n desc?: Prose\n fields?: FieldMap # name[?]: TypeExpr (# inline comment)\n literals?: UnionList # a | b | c\n extends?: TypeRef[]\n```\n\n```mdl\next feat\n uri: org.dxos.mdl.feat@1.0\n desc: A named feature grouping one or more requirements.\n fields:\n desc?: Prose\n req: RequirementList\n nesting: self # feat blocks may contain feat blocks\n```\n\n```mdl\next test\n uri: org.dxos.mdl.test@1.0\n desc: An acceptance scenario expressed as given / when / then steps.\n fields:\n given?: Step | Step[]\n when?: Step | Step[]\n then: Step | Step[]\n tags?: TagList\n```\n\n```mdl\next component\n uri: org.dxos.mdl.component@1.0\n desc: A UI component with props, internal state, slots, actions, and events.\n fields:\n desc?: Prose\n props?: FieldMap # external inputs (immutable inside component)\n state?: FieldMap # internal reactive state\n slots?: FieldMap # named ReactNode injection points\n actions?: ActionMap # methods the component exposes or handles\n emits?: EventMap # events the component raises to its parent\n layout?: CodeBlock # ASCII sketch of visual structure (non-normative)\n```\n\n```mdl\next op\n uri: org.dxos.mdl.op@1.0\n desc: |\n A named operation with typed inputs, outputs, and declared errors.\n Pure ops have no effects or requires. Effectful ops declare both.\n fields:\n desc?: Prose\n input?: FieldMap # named input parameters\n output?: TypeExpr # return type\n errors?: ErrorMap # name: Prose (when this error occurs)\n effects?: EffectList # echo:read | echo:write | http | fs | ...\n requires?: ServiceList # injected service dependencies\n note?: Prose # implementation guidance (non-normative)\n```\n"],
5
+ "mappings": ";AAIA,SAASA,cAAc;AACvB,SAASC,iBAAiB;AAE1B,SAASC,cAAcC,oBAAoB;AAC3C,SAASC,YAAY;AACrB,SAASC,oBAAoB;AAC7B,SAASC,aAAa;;;ACVtB;;;ADeO,IAAMC,iBAAiBC,OAAOC,OAAOC,IAAAA,EAAMC,KAChDC,UAAUC,sBAAsB;EAAEC,UAAUC;AAAa,CAAA,GACzDH,UAAUI,gBAAgB;EAAEC,QAAQ;IAACC,MAAMA;;AAAO,CAAA,GAClDN,UAAUO,iBAAiB;EAAEL,UAAUM;AAAa,CAAA,GACpDR,UAAUS,sBAAsB;EAAEC;AAAa,CAAA,GAC/CV,UAAUW,qBAAqB;EAC7BC,OAAO;IAAEC,UAAUf,KAAKgB;IAAIC,MAAM;IAAcC,SAASC;IAAYC,UAAU;EAAoB;AACrG,CAAA,GACAtB,OAAOuB,IAAI;AAGb,IAAA,yBAAexB;",
6
+ "names": ["Plugin", "AppPlugin", "CreateObject", "ReactSurface", "meta", "translations", "Graph", "ExplorerPlugin", "Plugin", "define", "meta", "pipe", "AppPlugin", "addCreateObjectModule", "activate", "CreateObject", "addSchemaModule", "schema", "Graph", "addSurfaceModule", "ReactSurface", "addTranslationsModule", "translations", "addPluginAssetModule", "asset", "pluginId", "id", "path", "content", "pluginSpec", "mimeType", "make"]
7
+ }
@@ -0,0 +1,42 @@
1
+ // src/meta.ts
2
+ import { Plugin } from "@dxos/app-framework";
3
+ import { DXN } from "@dxos/keys";
4
+ import { trim } from "@dxos/util";
5
+ var meta = Plugin.makeMeta({
6
+ key: DXN.make("org.dxos.plugin.explorer"),
7
+ name: "Explorer",
8
+ author: "DXOS",
9
+ description: trim`
10
+ Explorer is an interactive hypergraph visualization plugin that reveals the relationships
11
+ between objects stored in your DXOS workspace. Each Graph document is backed by a live
12
+ ECHO query and a View that you configure — Explorer keeps the visualization synchronized
13
+ with the database in real time so every peer immediately sees changes made by collaborators.
14
+
15
+ The plugin offers four switchable layout algorithms for the same data set: a physics-based
16
+ force-directed graph for freeform exploration, a radial cluster layout that groups objects
17
+ by type around a central root, an edge-bundling layout that tames visual clutter on dense
18
+ graphs, and a lattice grid that arranges objects in a sorted matrix sorted by type and label.
19
+ Switching between layouts smoothly tweens node positions so spatial context is preserved.
20
+
21
+ Nodes are coloured by their ECHO object type, and hovering any node opens an anchor-card
22
+ preview panel with the object's details without leaving the graph view.
23
+ The toolbar's query editor lets you filter the visible node set on the fly using
24
+ the same query syntax available across Composer.
25
+
26
+ A new Graph document can be created from the object-creation dialog; Explorer automatically
27
+ derives an initial View from the chosen type and persists both to ECHO so the graph is
28
+ immediately shareable and replicable across the space.
29
+ `,
30
+ icon: "ph--graph--regular",
31
+ iconHue: "green",
32
+ source: "https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-explorer",
33
+ spec: "PLUGIN.mdl",
34
+ screenshots: [
35
+ "https://dxos.network/plugin-details-explorer-dark.png"
36
+ ]
37
+ });
38
+
39
+ export {
40
+ meta
41
+ };
42
+ //# sourceMappingURL=chunk-42BYLQQA.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/meta.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { Plugin } from '@dxos/app-framework';\nimport { DXN } from '@dxos/keys';\nimport { trim } from '@dxos/util';\n\nexport const meta = Plugin.makeMeta({\n key: DXN.make('org.dxos.plugin.explorer'),\n name: 'Explorer',\n author: 'DXOS',\n description: trim`\n Explorer is an interactive hypergraph visualization plugin that reveals the relationships\n between objects stored in your DXOS workspace. Each Graph document is backed by a live\n ECHO query and a View that you configure — Explorer keeps the visualization synchronized\n with the database in real time so every peer immediately sees changes made by collaborators.\n\n The plugin offers four switchable layout algorithms for the same data set: a physics-based\n force-directed graph for freeform exploration, a radial cluster layout that groups objects\n by type around a central root, an edge-bundling layout that tames visual clutter on dense\n graphs, and a lattice grid that arranges objects in a sorted matrix sorted by type and label.\n Switching between layouts smoothly tweens node positions so spatial context is preserved.\n\n Nodes are coloured by their ECHO object type, and hovering any node opens an anchor-card\n preview panel with the object's details without leaving the graph view.\n The toolbar's query editor lets you filter the visible node set on the fly using\n the same query syntax available across Composer.\n\n A new Graph document can be created from the object-creation dialog; Explorer automatically\n derives an initial View from the chosen type and persists both to ECHO so the graph is\n immediately shareable and replicable across the space.\n `,\n icon: 'ph--graph--regular',\n iconHue: 'green',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-explorer',\n spec: 'PLUGIN.mdl',\n screenshots: ['https://dxos.network/plugin-details-explorer-dark.png'],\n});\n"],
5
+ "mappings": ";AAIA,SAASA,cAAc;AACvB,SAASC,WAAW;AACpB,SAASC,YAAY;AAEd,IAAMC,OAAOH,OAAOI,SAAS;EAClCC,KAAKJ,IAAIK,KAAK,0BAAA;EACdC,MAAM;EACNC,QAAQ;EACRC,aAAaP;;;;;;;;;;;;;;;;;;;;;EAqBbQ,MAAM;EACNC,SAAS;EACTC,QAAQ;EACRC,MAAM;EACNC,aAAa;IAAC;;AAChB,CAAA;",
6
+ "names": ["Plugin", "DXN", "trim", "meta", "makeMeta", "key", "make", "name", "author", "description", "icon", "iconHue", "source", "spec", "screenshots"]
7
+ }
@@ -0,0 +1,287 @@
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 { DXN, 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.EntityId,
34
+ children: Schema.mutable(Schema.Array(Key.EntityId)),
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.EntityId,
43
+ nodes: Schema.mutable(Schema.Record({
44
+ key: Key.EntityId,
45
+ value: TreeNodeType
46
+ }))
47
+ }).pipe(Type.makeObject(DXN.make("org.dxos.type.tree", "0.1.0")));
48
+ var Tree = class _Tree {
49
+ static create = () => {
50
+ const id = Key.EntityId.random();
51
+ return Obj.make(TreeType, {
52
+ root: id,
53
+ nodes: {
54
+ [id]: {
55
+ id,
56
+ children: [],
57
+ data: {
58
+ text: ""
59
+ }
60
+ }
61
+ }
62
+ });
63
+ };
64
+ _tree;
65
+ constructor(tree) {
66
+ this._tree = tree ?? _Tree.create();
67
+ }
68
+ get tree() {
69
+ return this._tree;
70
+ }
71
+ // TODO(burdon): Make reactive.
72
+ get size() {
73
+ return Object.keys(this._tree.nodes).length;
74
+ }
75
+ get root() {
76
+ return this.getNode(this._tree.root);
77
+ }
78
+ //
79
+ // Traversal
80
+ //
81
+ /**
82
+ * Recursively traverse the tree until the callback returns a value.
83
+ */
84
+ tranverse(callback, root = this._tree.root, depth = 0) {
85
+ const node = this._tree.nodes[root];
86
+ const result = callback(node, depth);
87
+ if (result !== void 0) {
88
+ return result;
89
+ }
90
+ for (const childId of node.children) {
91
+ const result2 = this.tranverse(callback, childId, depth + 1);
92
+ if (result2 !== void 0) {
93
+ return result2;
94
+ }
95
+ }
96
+ }
97
+ getNode(id) {
98
+ const node = this._tree.nodes[id];
99
+ invariant(node, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 77, S: this, A: ["node", ""] });
100
+ return node;
101
+ }
102
+ /**
103
+ * Get the children of a node.
104
+ */
105
+ getChildNodes(node) {
106
+ return node.children.map((id) => this.getNode(id));
107
+ }
108
+ /**
109
+ * Get the parent of a node.
110
+ */
111
+ getParent(node) {
112
+ const parent = this.tranverse((n) => {
113
+ if (n.children.includes(node.id)) {
114
+ return n;
115
+ }
116
+ });
117
+ return parent ?? null;
118
+ }
119
+ /**
120
+ * Get the next node in the tree.
121
+ */
122
+ getNext(node, hierarchical = true) {
123
+ if (hierarchical && node.children.length) {
124
+ return this.getChildNodes(node)[0];
125
+ } else {
126
+ const parent = this.getParent(node);
127
+ if (parent) {
128
+ const idx = this.getChildNodes(parent).findIndex(({ id }) => id === node.id);
129
+ if (idx < parent.children.length - 1) {
130
+ return this.getNode(parent.children[idx + 1]);
131
+ } else {
132
+ return this.getNext(parent, false);
133
+ }
134
+ }
135
+ }
136
+ }
137
+ /**
138
+ * Get the previous node in the tree.
139
+ */
140
+ getPrevious(node, hierarchical = true) {
141
+ const parent = this.getParent(node);
142
+ const idx = this.getChildNodes(parent).findIndex(({ id }) => id === node.id);
143
+ if (idx === 0) {
144
+ if (hierarchical) {
145
+ return parent;
146
+ }
147
+ } else {
148
+ const previous = this.getNode(parent.children[idx - 1]);
149
+ if (hierarchical && previous.children.length) {
150
+ return this.getLastDescendent(previous);
151
+ }
152
+ return previous;
153
+ }
154
+ }
155
+ /**
156
+ * Get the last descendent of a node.
157
+ */
158
+ getLastDescendent(node) {
159
+ const children = this.getChildNodes(node);
160
+ const last = children.length ? children[children.length - 1] : void 0;
161
+ if (last) {
162
+ return this.getLastDescendent(last);
163
+ }
164
+ return node;
165
+ }
166
+ //
167
+ // Mutations
168
+ //
169
+ /**
170
+ * Clear tree.
171
+ */
172
+ clear() {
173
+ const root = this._tree.nodes[this._tree.root];
174
+ root.children.length = 0;
175
+ Obj.update(this._tree, (obj) => {
176
+ obj.nodes = {
177
+ [root.id]: root
178
+ };
179
+ });
180
+ }
181
+ /**
182
+ * Add node.
183
+ */
184
+ addNode(parent, node, index) {
185
+ if (!node) {
186
+ const id = Key.EntityId.random();
187
+ node = {
188
+ id,
189
+ children: [],
190
+ data: {
191
+ text: ""
192
+ }
193
+ };
194
+ }
195
+ const nodeToAdd = node;
196
+ Obj.update(this._tree, (obj) => {
197
+ obj.nodes[nodeToAdd.id] = nodeToAdd;
198
+ parent.children.splice(index ?? parent.children.length, 0, nodeToAdd.id);
199
+ });
200
+ return node;
201
+ }
202
+ /**
203
+ * Delete node.
204
+ */
205
+ deleteNode(parent, id) {
206
+ const node = this._tree.nodes[id];
207
+ if (!node) {
208
+ return void 0;
209
+ }
210
+ Obj.update(this._tree, (obj) => {
211
+ delete obj.nodes[node.id];
212
+ });
213
+ const idx = parent.children.findIndex((child) => child === id);
214
+ if (idx !== -1) {
215
+ Obj.update(this._tree, () => {
216
+ parent.children.splice(idx, 1);
217
+ });
218
+ }
219
+ return node;
220
+ }
221
+ /**
222
+ * Move child node.
223
+ */
224
+ moveNode(node, from, to) {
225
+ invariant(from >= 0 && from < node.children.length, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 197, S: this, A: ["from >= 0 && from < node.children.length", ""] });
226
+ invariant(to >= 0 && to < node.children.length, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 198, S: this, A: ["to >= 0 && to < node.children.length", ""] });
227
+ if (from === to) {
228
+ return null;
229
+ }
230
+ const child = node.children[from];
231
+ Obj.update(this._tree, () => {
232
+ node.children.splice(from, 1);
233
+ node.children.splice(to, 0, child);
234
+ });
235
+ return this.getNode(child);
236
+ }
237
+ /**
238
+ * Indent node.
239
+ */
240
+ indentNode(node) {
241
+ const parent = this.getParent(node);
242
+ if (!parent) {
243
+ return;
244
+ }
245
+ const idx = parent.children.findIndex((child) => child === node.id);
246
+ if (idx < 1 || idx >= parent.children.length) {
247
+ return;
248
+ }
249
+ const previous = this.getNode(parent.children[idx - 1]);
250
+ Obj.update(this._tree, () => {
251
+ parent.children.splice(idx, 1);
252
+ previous.children.push(node.id);
253
+ });
254
+ }
255
+ /**
256
+ * Unindent node.
257
+ */
258
+ unindentNode(node) {
259
+ const parent = this.getParent(node);
260
+ if (!parent) {
261
+ return;
262
+ }
263
+ const ancestor = this.getParent(parent);
264
+ if (!ancestor) {
265
+ return;
266
+ }
267
+ const nodeIdx = parent.children.findIndex((id) => id === node.id);
268
+ let rest = [];
269
+ Obj.update(this._tree, () => {
270
+ const removed = parent.children.splice(nodeIdx, parent.children.length - nodeIdx);
271
+ rest = removed.slice(1);
272
+ });
273
+ const parentIdx = this.getChildNodes(ancestor).findIndex((n) => n.id === parent.id);
274
+ Obj.update(this._tree, () => {
275
+ ancestor.children.splice(parentIdx + 1, 0, node.id);
276
+ });
277
+ Obj.update(this._tree, () => {
278
+ node.children.push(...rest);
279
+ });
280
+ }
281
+ };
282
+
283
+ export {
284
+ Tree,
285
+ treeTypeToTreeNode
286
+ };
287
+ //# sourceMappingURL=chunk-7XUDLV6E.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.EntityId = 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 { DXN, 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.EntityId,\n children: Schema.mutable(Schema.Array(Key.EntityId)),\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 type TreeNodeType = Schema.Schema.Type<typeof TreeNodeType>;\n\nexport const TreeType = Schema.Struct({\n root: Key.EntityId,\n nodes: Schema.mutable(Schema.Record({ key: Key.EntityId, value: TreeNodeType })),\n}).pipe(Type.makeObject(DXN.make('org.dxos.type.tree', '0.1.0')));\n\nexport type TreeType = Type.InstanceType<typeof TreeType>;\n\n/**\n * Wrapper object for tree.\n */\nexport class Tree {\n static create = (): TreeType => {\n const id = Key.EntityId.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.EntityId = 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.EntityId): 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.EntityId.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.EntityId): 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.EntityId[] = [];\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,CAACN,SAAAA;AACf,SAAO,OAAOA,KAAKO,MAAMQ,SAAS,WAAWf,KAAKO,KAAKQ,OAAOb;AAChE;;;AC7CA,YAAYc,YAAY;AAExB,SAASC,KAAKC,KAAKC,KAAKC,KAAKC,YAAY;AACzC,SAASC,kBAAkB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AA;AAEA,eAAA,SAAA,OAAA,YAAA,GAAA,GAAA,KAAiD,EAAA;IACjD1B,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", "DXN", "Key", "Obj", "Ref", "Type", "TestSchema", "invariant", "children", "data", "String", "ref", "optional", "pipe", "TreeType", "Struct", "EntityId", "nodes", "Record", "key", "TreeNodeType", "makeObject", "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,69 @@
1
+ import {
2
+ __export
3
+ } from "./chunk-J5LGTIGS.mjs";
4
+
5
+ // src/types/ExplorerAction.ts
6
+ var ExplorerAction_exports = {};
7
+ __export(ExplorerAction_exports, {
8
+ GraphProps: () => GraphProps
9
+ });
10
+ import * as Schema from "effect/Schema";
11
+ import { TypeInputOptionsAnnotation } from "@dxos/plugin-space";
12
+ var GraphProps = Schema.Struct({
13
+ name: Schema.optional(Schema.String),
14
+ // TODO(wittjosiah): This should be a query input instead.
15
+ typename: Schema.String.pipe(Schema.annotations({
16
+ title: "Select type"
17
+ }), TypeInputOptionsAnnotation.set({
18
+ location: [
19
+ "database",
20
+ "runtime"
21
+ ],
22
+ kind: [
23
+ "user"
24
+ ]
25
+ }), Schema.optional)
26
+ });
27
+
28
+ // src/types/Graph.ts
29
+ var Graph_exports = {};
30
+ __export(Graph_exports, {
31
+ Graph: () => Graph,
32
+ make: () => make
33
+ });
34
+ import * as Schema2 from "effect/Schema";
35
+ import { DXN, Annotation, Filter, Obj, Query, QueryAST, Ref, Type, View } from "@dxos/echo";
36
+ import { FormInputAnnotation, LabelAnnotation } from "@dxos/echo/internal";
37
+ import { ViewAnnotation } from "@dxos/schema";
38
+ var GraphSchema = Schema2.Struct({
39
+ name: Schema2.optional(Schema2.String),
40
+ view: Ref.Ref(View.View).pipe(FormInputAnnotation.set(false)),
41
+ query: Schema2.Struct({
42
+ raw: Schema2.optional(Schema2.String),
43
+ ast: QueryAST.Query
44
+ }).pipe(FormInputAnnotation.set(false))
45
+ }).pipe(LabelAnnotation.set([
46
+ "name"
47
+ ]), ViewAnnotation.set([
48
+ "view"
49
+ ]), Annotation.IconAnnotation.set({
50
+ icon: "ph--graph--regular",
51
+ hue: "green"
52
+ }), Type.makeObject(DXN.make("org.dxos.type.graph", "0.1.0")));
53
+ var Graph = GraphSchema;
54
+ var make = ({ name, query = {
55
+ raw: "",
56
+ ast: Query.select(Filter.nothing()).ast
57
+ }, view }) => {
58
+ return Obj.make(Graph, {
59
+ name,
60
+ view: Ref.make(view),
61
+ query
62
+ });
63
+ };
64
+
65
+ export {
66
+ ExplorerAction_exports,
67
+ Graph_exports
68
+ };
69
+ //# sourceMappingURL=chunk-HI324IB4.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/types/ExplorerAction.ts", "../../../src/types/Graph.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { TypeInputOptionsAnnotation } from '@dxos/plugin-space';\n\nexport const GraphProps = Schema.Struct({\n name: Schema.optional(Schema.String),\n // TODO(wittjosiah): This should be a query input instead.\n typename: Schema.String.pipe(\n Schema.annotations({ title: 'Select type' }),\n TypeInputOptionsAnnotation.set({\n location: ['database', 'runtime'],\n kind: ['user'],\n }),\n Schema.optional,\n ),\n});\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { DXN, Annotation, Filter, Obj, Query, QueryAST, Ref, Type, View } from '@dxos/echo';\nimport { FormInputAnnotation, LabelAnnotation } from '@dxos/echo/internal';\nimport { ViewAnnotation } from '@dxos/schema';\n\nconst GraphSchema = Schema.Struct({\n name: Schema.optional(Schema.String),\n view: Ref.Ref(View.View).pipe(FormInputAnnotation.set(false)),\n query: Schema.Struct({\n raw: Schema.optional(Schema.String),\n ast: QueryAST.Query,\n }).pipe(FormInputAnnotation.set(false)),\n}).pipe(\n LabelAnnotation.set(['name']),\n ViewAnnotation.set(['view']),\n Annotation.IconAnnotation.set({ icon: 'ph--graph--regular', hue: 'green' }),\n Type.makeObject(DXN.make('org.dxos.type.graph', '0.1.0')),\n);\n// TODO(wittjosiah): Try to clean up this type inference.\nexport interface Graph extends Type.InstanceType<typeof GraphSchema> {}\nexport const Graph: Type.Obj<Graph> = GraphSchema as any;\n\ntype MakeProps = Omit<Partial<Obj.MakeProps<typeof Graph>>, 'view'> & {\n view: View.View;\n};\n\n/**\n * Make a graph as a view of a data set.\n */\nexport const make = ({\n name,\n query = { raw: '', ast: Query.select(Filter.nothing()).ast },\n view,\n}: MakeProps): Graph => {\n return Obj.make(Graph, { name, view: Ref.make(view), query });\n};\n"],
5
+ "mappings": ";;;;;AAAA;;;;AAIA,YAAYA,YAAY;AAExB,SAASC,kCAAkC;AAEpC,IAAMC,aAAoBC,cAAO;EACtCC,MAAaC,gBAAgBC,aAAM;;EAEnCC,UAAiBD,cAAOE,KACfC,mBAAY;IAAEC,OAAO;EAAc,CAAA,GAC1CT,2BAA2BU,IAAI;IAC7BC,UAAU;MAAC;MAAY;;IACvBC,MAAM;MAAC;;EACT,CAAA,GACOR,eAAQ;AAEnB,CAAA;;;ACnBA;;;;;AAIA,YAAYS,aAAY;AAExB,SAASC,KAAKC,YAAYC,QAAQC,KAAKC,OAAOC,UAAUC,KAAKC,MAAMC,YAAY;AAC/E,SAASC,qBAAqBC,uBAAuB;AACrD,SAASC,sBAAsB;AAE/B,IAAMC,cAAqBC,eAAO;EAChCC,MAAaC,iBAAgBC,cAAM;EACnCC,MAAMX,IAAIA,IAAIE,KAAKA,IAAI,EAAEU,KAAKT,oBAAoBU,IAAI,KAAA,CAAA;EACtDC,OAAcP,eAAO;IACnBQ,KAAYN,iBAAgBC,cAAM;IAClCM,KAAKjB,SAASD;EAChB,CAAA,EAAGc,KAAKT,oBAAoBU,IAAI,KAAA,CAAA;AAClC,CAAA,EAAGD,KACDR,gBAAgBS,IAAI;EAAC;CAAO,GAC5BR,eAAeQ,IAAI;EAAC;CAAO,GAC3BlB,WAAWsB,eAAeJ,IAAI;EAAEK,MAAM;EAAsBC,KAAK;AAAQ,CAAA,GACzElB,KAAKmB,WAAW1B,IAAI2B,KAAK,uBAAuB,OAAA,CAAA,CAAA;AAI3C,IAAMC,QAAyBhB;AAS/B,IAAMe,OAAO,CAAC,EACnBb,MACAM,QAAQ;EAAEC,KAAK;EAAIC,KAAKlB,MAAMyB,OAAO3B,OAAO4B,QAAO,CAAA,EAAIR;AAAI,GAC3DL,KAAI,MACM;AACV,SAAOd,IAAIwB,KAAKC,OAAO;IAAEd;IAAMG,MAAMX,IAAIqB,KAAKV,IAAAA;IAAOG;EAAM,CAAA;AAC7D;",
6
+ "names": ["Schema", "TypeInputOptionsAnnotation", "GraphProps", "Struct", "name", "optional", "String", "typename", "pipe", "annotations", "title", "set", "location", "kind", "Schema", "DXN", "Annotation", "Filter", "Obj", "Query", "QueryAST", "Ref", "Type", "View", "FormInputAnnotation", "LabelAnnotation", "ViewAnnotation", "GraphSchema", "Struct", "name", "optional", "String", "view", "pipe", "set", "query", "raw", "ast", "IconAnnotation", "icon", "hue", "makeObject", "make", "Graph", "select", "nothing"]
7
+ }
@@ -0,0 +1,20 @@
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
+ // src/util/plot.ts
12
+ var createAdapter = (prop, accessor) => accessor ? {
13
+ transform: (values) => values.map((value) => accessor(value)[prop])
14
+ } : prop;
15
+
16
+ export {
17
+ getNodeFillForObject,
18
+ createAdapter
19
+ };
20
+ //# sourceMappingURL=chunk-IKHJV3Q4.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/util/node-color.ts", "../../../src/util/plot.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", "//\n// Copyright 2023 DXOS.org\n//\n\nimport type { ChannelValueSpec } from '@observablehq/plot';\n\nexport type Accessor<T> = (object: any) => T;\n\nexport type Point = {\n x: number;\n y: number;\n};\n\nexport type GeoLocation = {\n lat: number;\n lng: number;\n};\n\nexport const createAdapter = <T extends Record<string, any>>(\n prop: string,\n accessor: Accessor<T> | undefined,\n): ChannelValueSpec =>\n accessor\n ? {\n transform: (values) => values.map((value) => accessor(value)[prop]),\n }\n : prop;\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;;;ACJO,IAAME,gBAAgB,CAC3BC,MACAC,aAEAA,WACI;EACEC,WAAW,CAACC,WAAWA,OAAOC,IAAI,CAACC,UAAUJ,SAASI,KAAAA,EAAOL,IAAAA,CAAK;AACpE,IACAA;",
6
+ "names": ["Obj", "getHashHue", "getNodeFillForTypename", "typename", "getNodeFillForObject", "object", "getTypename", "createAdapter", "prop", "accessor", "transform", "values", "map", "value"]
7
+ }
@@ -0,0 +1,10 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
7
+ export {
8
+ __export
9
+ };
10
+ //# sourceMappingURL=chunk-J5LGTIGS.mjs.map