@dxos/plugin-explorer 0.8.4-main.9735255 → 0.8.4-main.abd8ff62ef

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 (130) hide show
  1. package/dist/lib/browser/{chunk-YNQF4CPY.mjs → chunk-HPIS2WXY.mjs} +2 -2
  2. package/dist/lib/browser/{chunk-YNQF4CPY.mjs.map → chunk-HPIS2WXY.mjs.map} +3 -3
  3. package/dist/lib/{node-esm/chunk-QLMTN2XI.mjs → browser/components/index.mjs} +196 -20
  4. package/dist/lib/{node-esm/chunk-QLMTN2XI.mjs.map → browser/components/index.mjs.map} +4 -4
  5. package/dist/lib/browser/hooks/index.mjs +40 -0
  6. package/dist/lib/browser/hooks/index.mjs.map +7 -0
  7. package/dist/lib/browser/index.mjs +5 -92
  8. package/dist/lib/browser/index.mjs.map +4 -4
  9. package/dist/lib/browser/meta.json +1 -1
  10. package/dist/lib/browser/meta.mjs +1 -1
  11. package/dist/lib/browser/types/index.mjs +66 -4
  12. package/dist/lib/browser/types/index.mjs.map +4 -4
  13. package/dist/lib/node-esm/{chunk-DK77RB6M.mjs → chunk-6EUBRHHX.mjs} +2 -2
  14. package/dist/lib/node-esm/{chunk-DK77RB6M.mjs.map → chunk-6EUBRHHX.mjs.map} +3 -3
  15. package/dist/lib/{browser/chunk-AGZAGILW.mjs → node-esm/components/index.mjs} +198 -19
  16. package/dist/lib/{browser/chunk-AGZAGILW.mjs.map → node-esm/components/index.mjs.map} +4 -4
  17. package/dist/lib/node-esm/hooks/index.mjs +41 -0
  18. package/dist/lib/node-esm/hooks/index.mjs.map +7 -0
  19. package/dist/lib/node-esm/index.mjs +5 -92
  20. package/dist/lib/node-esm/index.mjs.map +4 -4
  21. package/dist/lib/node-esm/meta.json +1 -1
  22. package/dist/lib/node-esm/meta.mjs +1 -1
  23. package/dist/lib/node-esm/types/index.mjs +66 -4
  24. package/dist/lib/node-esm/types/index.mjs.map +4 -4
  25. package/dist/types/data/cities.d.ts +4 -4
  26. package/dist/types/data/cities.d.ts.map +1 -1
  27. package/dist/types/data/countries-110m.d.ts +19 -22
  28. package/dist/types/data/countries-110m.d.ts.map +1 -1
  29. package/dist/types/src/ExplorerPlugin.d.ts +1 -0
  30. package/dist/types/src/ExplorerPlugin.d.ts.map +1 -1
  31. package/dist/types/src/ExplorerPlugin.test.d.ts +2 -0
  32. package/dist/types/src/ExplorerPlugin.test.d.ts.map +1 -0
  33. package/dist/types/src/capabilities/index.d.ts +2 -1
  34. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  35. package/dist/types/src/capabilities/react-surface.d.ts +5 -0
  36. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
  37. package/dist/types/src/components/Chart/Chart.d.ts.map +1 -1
  38. package/dist/types/src/components/Chart/Chart.stories.d.ts.map +1 -1
  39. package/dist/types/src/components/Globe/Globe.d.ts.map +1 -1
  40. package/dist/types/src/components/Globe/Globe.stories.d.ts.map +1 -1
  41. package/dist/types/src/components/Graph/D3ForceGraph.d.ts +6 -5
  42. package/dist/types/src/components/Graph/D3ForceGraph.d.ts.map +1 -1
  43. package/dist/types/src/components/Graph/D3ForceGraph.stories.d.ts +4 -2
  44. package/dist/types/src/components/Graph/D3ForceGraph.stories.d.ts.map +1 -1
  45. package/dist/types/src/components/Graph/ForceGraph.stories.d.ts +1 -1
  46. package/dist/types/src/components/Graph/ForceGraph.stories.d.ts.map +1 -1
  47. package/dist/types/src/components/Graph/adapter.d.ts.map +1 -1
  48. package/dist/types/src/components/Graph/testing.d.ts.map +1 -1
  49. package/dist/types/src/components/Tree/Tree.d.ts.map +1 -1
  50. package/dist/types/src/components/Tree/Tree.stories.d.ts.map +1 -1
  51. package/dist/types/src/components/Tree/layout/HierarchicalEdgeBundling.d.ts.map +1 -1
  52. package/dist/types/src/components/Tree/layout/RadialTree.d.ts.map +1 -1
  53. package/dist/types/src/components/Tree/layout/TidyTree.d.ts.map +1 -1
  54. package/dist/types/src/components/Tree/testing/generator.d.ts.map +1 -1
  55. package/dist/types/src/components/Tree/types/tree.d.ts +7 -7
  56. package/dist/types/src/components/Tree/types/tree.d.ts.map +1 -1
  57. package/dist/types/src/components/Tree/types/types.d.ts.map +1 -1
  58. package/dist/types/src/components/index.d.ts +0 -2
  59. package/dist/types/src/components/index.d.ts.map +1 -1
  60. package/dist/types/src/components/plot.d.ts.map +1 -1
  61. package/dist/types/src/containers/ExplorerContainer/ExplorerContainer.d.ts +6 -0
  62. package/dist/types/src/containers/ExplorerContainer/ExplorerContainer.d.ts.map +1 -0
  63. package/dist/types/src/containers/ExplorerContainer/index.d.ts +2 -0
  64. package/dist/types/src/containers/ExplorerContainer/index.d.ts.map +1 -0
  65. package/dist/types/src/containers/index.d.ts +3 -0
  66. package/dist/types/src/containers/index.d.ts.map +1 -0
  67. package/dist/types/src/hooks/useGraphModel.d.ts.map +1 -1
  68. package/dist/types/src/index.d.ts +2 -3
  69. package/dist/types/src/index.d.ts.map +1 -1
  70. package/dist/types/src/translations.d.ts +28 -26
  71. package/dist/types/src/translations.d.ts.map +1 -1
  72. package/dist/types/src/types/ExplorerAction.d.ts.map +1 -1
  73. package/dist/types/src/types/Graph.d.ts +3 -10
  74. package/dist/types/src/types/Graph.d.ts.map +1 -1
  75. package/dist/types/tsconfig.tsbuildinfo +1 -1
  76. package/package.json +67 -47
  77. package/src/ExplorerPlugin.test.ts +26 -0
  78. package/src/ExplorerPlugin.tsx +31 -17
  79. package/src/capabilities/index.ts +3 -1
  80. package/src/capabilities/react-surface.tsx +32 -0
  81. package/src/components/Chart/Chart.stories.tsx +2 -3
  82. package/src/components/Globe/Globe.stories.tsx +2 -3
  83. package/src/components/Graph/D3ForceGraph.stories.tsx +16 -16
  84. package/src/components/Graph/D3ForceGraph.tsx +82 -75
  85. package/src/components/Graph/ForceGraph.stories.tsx +16 -16
  86. package/src/components/Graph/testing.ts +2 -2
  87. package/src/components/Tree/Tree.stories.tsx +7 -5
  88. package/src/components/Tree/testing/generator.ts +1 -1
  89. package/src/components/Tree/types/tree.test.ts +3 -4
  90. package/src/components/Tree/types/tree.ts +15 -15
  91. package/src/components/index.ts +0 -4
  92. package/src/containers/ExplorerContainer/ExplorerContainer.tsx +53 -0
  93. package/src/containers/ExplorerContainer/index.ts +5 -0
  94. package/src/containers/index.ts +7 -0
  95. package/src/hooks/useGraphModel.ts +18 -13
  96. package/src/index.ts +5 -3
  97. package/src/meta.ts +1 -1
  98. package/src/translations.ts +14 -13
  99. package/src/types/ExplorerAction.ts +0 -1
  100. package/src/types/Graph.ts +11 -24
  101. package/src/typings.d.ts +8 -0
  102. package/dist/lib/browser/ExplorerContainer-BFAWRIAJ.mjs +0 -45
  103. package/dist/lib/browser/ExplorerContainer-BFAWRIAJ.mjs.map +0 -7
  104. package/dist/lib/browser/chunk-BZMTFAP3.mjs +0 -34
  105. package/dist/lib/browser/chunk-BZMTFAP3.mjs.map +0 -7
  106. package/dist/lib/browser/chunk-HIFLWHXR.mjs +0 -83
  107. package/dist/lib/browser/chunk-HIFLWHXR.mjs.map +0 -7
  108. package/dist/lib/browser/chunk-MGBT2ZFU.mjs +0 -177
  109. package/dist/lib/browser/chunk-MGBT2ZFU.mjs.map +0 -7
  110. package/dist/lib/browser/react-surface-RWVHQL3J.mjs +0 -35
  111. package/dist/lib/browser/react-surface-RWVHQL3J.mjs.map +0 -7
  112. package/dist/lib/node-esm/ExplorerContainer-YQ2KKBVS.mjs +0 -46
  113. package/dist/lib/node-esm/ExplorerContainer-YQ2KKBVS.mjs.map +0 -7
  114. package/dist/lib/node-esm/chunk-3OE6TBJI.mjs +0 -84
  115. package/dist/lib/node-esm/chunk-3OE6TBJI.mjs.map +0 -7
  116. package/dist/lib/node-esm/chunk-IPIGIQHX.mjs +0 -36
  117. package/dist/lib/node-esm/chunk-IPIGIQHX.mjs.map +0 -7
  118. package/dist/lib/node-esm/chunk-YWJBDETV.mjs +0 -179
  119. package/dist/lib/node-esm/chunk-YWJBDETV.mjs.map +0 -7
  120. package/dist/lib/node-esm/react-surface-3REUS7KW.mjs +0 -36
  121. package/dist/lib/node-esm/react-surface-3REUS7KW.mjs.map +0 -7
  122. package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
  123. package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
  124. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +0 -5
  125. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
  126. package/dist/types/src/components/ExplorerContainer.d.ts +0 -7
  127. package/dist/types/src/components/ExplorerContainer.d.ts.map +0 -1
  128. package/src/capabilities/react-surface/index.ts +0 -7
  129. package/src/capabilities/react-surface/react-surface.tsx +0 -30
  130. package/src/components/ExplorerContainer.tsx +0 -52
@@ -1,3 +1,6 @@
1
+ import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
+ import "../chunk-HSLMI22Q.mjs";
3
+
1
4
  // src/components/Chart/Chart.tsx
2
5
  import * as Plot from "@observablehq/plot";
3
6
  import React, { useEffect } from "react";
@@ -10820,11 +10823,191 @@ var Globe = ({ items = [], accessor, projection = "orthographic", options = defa
10820
10823
  });
10821
10824
  };
10822
10825
 
10826
+ // src/components/Graph/D3ForceGraph.tsx
10827
+ import { Atom, useAtomValue } from "@effect-atom/atom-react";
10828
+ import React3, { useCallback, useEffect as useEffect3, useMemo, useRef } from "react";
10829
+ import { Obj } from "@dxos/echo";
10830
+ import { SelectionModel } from "@dxos/graph";
10831
+ import { GraphForceProjector, SVG } from "@dxos/react-ui-graph";
10832
+ import { composable, composableProps, getHashStyles } from "@dxos/ui-theme";
10833
+ import "@dxos/react-ui-graph/styles/graph.css";
10834
+ var EMPTY_ATOM = Atom.make({
10835
+ nodes: [],
10836
+ edges: []
10837
+ });
10838
+ var D3ForceGraph = composable(({ model, selection: _selection, grid, drag, ...props }, forwardedRef) => {
10839
+ useAtomValue(model?.graphAtom ?? EMPTY_ATOM);
10840
+ const svgRef = useRef(null);
10841
+ const projector = useMemo(() => {
10842
+ if (svgRef.current) {
10843
+ return new GraphForceProjector(svgRef.current, {
10844
+ attributes: {
10845
+ linkForce: (edge) => {
10846
+ return edge.data?.object?.active !== false;
10847
+ }
10848
+ },
10849
+ forces: {
10850
+ point: {
10851
+ strength: 0.01
10852
+ }
10853
+ }
10854
+ });
10855
+ }
10856
+ }, []);
10857
+ const graph = useRef(null);
10858
+ const selection = useMemo(() => _selection ?? new SelectionModel(), [
10859
+ _selection
10860
+ ]);
10861
+ useEffect3(() => selection.subscribe(() => graph.current?.repaint()), [
10862
+ selection
10863
+ ]);
10864
+ const handleSelect = useCallback((node) => {
10865
+ if (selection.contains(node.id)) {
10866
+ selection.remove(node.id);
10867
+ } else {
10868
+ selection.add(node.id);
10869
+ }
10870
+ }, [
10871
+ selection
10872
+ ]);
10873
+ return /* @__PURE__ */ React3.createElement("div", {
10874
+ ...composableProps(props, {
10875
+ classNames: "dx-container"
10876
+ }),
10877
+ ref: forwardedRef
10878
+ }, /* @__PURE__ */ React3.createElement(SVG.Root, {
10879
+ ref: svgRef
10880
+ }, /* @__PURE__ */ React3.createElement(SVG.Markers, null), grid && /* @__PURE__ */ React3.createElement(SVG.Grid, {
10881
+ axis: true
10882
+ }), /* @__PURE__ */ React3.createElement(SVG.Zoom, {
10883
+ extent: [
10884
+ 1 / 2,
10885
+ 2
10886
+ ]
10887
+ }, /* @__PURE__ */ React3.createElement(SVG.Graph, {
10888
+ drag,
10889
+ ref: graph,
10890
+ model,
10891
+ projector,
10892
+ labels: {
10893
+ text: (node) => {
10894
+ return node.data?.data.label ?? node.id;
10895
+ }
10896
+ },
10897
+ attributes: {
10898
+ node: (node) => {
10899
+ const obj = node.data?.data.object;
10900
+ return {
10901
+ data: {
10902
+ color: getHashStyles(obj && Obj.getTypename(obj))?.hue
10903
+ },
10904
+ classes: {
10905
+ "dx-selected": selection.contains(node.id)
10906
+ }
10907
+ };
10908
+ }
10909
+ },
10910
+ onSelect: handleSelect
10911
+ }))));
10912
+ });
10913
+
10914
+ // src/components/Graph/ForceGraph.tsx
10915
+ import { forceLink, forceManyBody } from "d3";
10916
+ import NativeForceGraph from "force-graph";
10917
+ import React4, { useEffect as useEffect4, useRef as useRef2, useState } from "react";
10918
+ import { useResizeDetector as useResizeDetector3 } from "react-resize-detector";
10919
+ import { filterObjectsSync } from "@dxos/plugin-search";
10920
+
10921
+ // src/components/Graph/adapter.ts
10922
+ var GraphAdapter = class {
10923
+ graph;
10924
+ _nodes = [];
10925
+ _links = [];
10926
+ constructor(graph) {
10927
+ this.graph = graph;
10928
+ this._nodes = graph.nodes.map((node) => ({
10929
+ id: node.id,
10930
+ type: node.type,
10931
+ data: node.data
10932
+ }));
10933
+ const nodeIds = new Set(this._nodes.map((node) => node.id));
10934
+ this._links = graph.edges.filter((edge) => nodeIds.has(edge.source) && nodeIds.has(edge.target)).map((edge) => ({
10935
+ type: edge.type,
10936
+ source: edge.source,
10937
+ target: edge.target,
10938
+ data: edge.data
10939
+ }));
10940
+ }
10941
+ get nodes() {
10942
+ return this._nodes;
10943
+ }
10944
+ get links() {
10945
+ return this._links;
10946
+ }
10947
+ };
10948
+
10949
+ // src/components/Graph/ForceGraph.tsx
10950
+ var ForceGraph = ({ model, match }) => {
10951
+ const { ref, width, height } = useResizeDetector3({
10952
+ refreshRate: 200
10953
+ });
10954
+ const rootRef = useRef2(null);
10955
+ const forceGraph = useRef2(null);
10956
+ const filteredRef = useRef2([]);
10957
+ filteredRef.current = filterObjectsSync(model?.objects ?? [], match);
10958
+ const [data, setData] = useState();
10959
+ useEffect4(() => {
10960
+ return model?.subscribe((model2) => {
10961
+ setData(new GraphAdapter(model2.graph));
10962
+ });
10963
+ }, [
10964
+ model
10965
+ ]);
10966
+ useEffect4(() => {
10967
+ if (rootRef.current) {
10968
+ forceGraph.current = new NativeForceGraph(rootRef.current).nodeRelSize(6).nodeLabel((node) => node.type === "schema" ? node.data.typename : node.data.label ?? node.id).nodeAutoColorBy((node) => node.type === "schema" ? "schema" : node.data.typename).linkAutoColorBy((link2) => link2.type);
10969
+ }
10970
+ return () => {
10971
+ forceGraph.current?.pauseAnimation().graphData({
10972
+ nodes: [],
10973
+ links: []
10974
+ });
10975
+ forceGraph.current = null;
10976
+ };
10977
+ }, []);
10978
+ useEffect4(() => {
10979
+ if (!data || !width || !height || !forceGraph.current) {
10980
+ return;
10981
+ }
10982
+ forceGraph.current.pauseAnimation().width(width).height(height).onEngineStop(() => {
10983
+ handleZoomToFit();
10984
+ }).onNodeClick((node) => {
10985
+ forceGraph.current?.emitParticle(node);
10986
+ }).d3Force("link", forceLink().distance(160).strength(0.5)).d3Force("charge", forceManyBody().strength(-30)).graphData(data).warmupTicks(100).cooldownTime(1e3).resumeAnimation();
10987
+ }, [
10988
+ data,
10989
+ width,
10990
+ height,
10991
+ forceGraph.current
10992
+ ]);
10993
+ const handleZoomToFit = () => {
10994
+ forceGraph.current?.zoomToFit(400, 40);
10995
+ };
10996
+ return /* @__PURE__ */ React4.createElement("div", {
10997
+ ref,
10998
+ className: "relative grow",
10999
+ onClick: handleZoomToFit
11000
+ }, /* @__PURE__ */ React4.createElement("div", {
11001
+ ref: rootRef,
11002
+ className: "absolute inset-0"
11003
+ }));
11004
+ };
11005
+
10823
11006
  // src/components/Tree/Tree.tsx
10824
11007
  import { RegistryContext } from "@effect-atom/atom-react";
10825
- import React3, { useContext, useEffect as useEffect3, useRef, useState } from "react";
11008
+ import React5, { useContext, useEffect as useEffect5, useRef as useRef3, useState as useState2 } from "react";
10826
11009
  import { useAsyncState } from "@dxos/react-ui";
10827
- import { SVG } from "@dxos/react-ui-graph";
11010
+ import { SVG as SVG2 } from "@dxos/react-ui-graph";
10828
11011
  import { SpaceGraphModel } from "@dxos/schema";
10829
11012
 
10830
11013
  // src/components/Tree/layout/HierarchicalEdgeBundling.ts
@@ -10962,7 +11145,7 @@ var TidyTree_default = TidyTree;
10962
11145
 
10963
11146
  // src/components/Tree/types/tree.ts
10964
11147
  import * as Schema from "effect/Schema";
10965
- import { Key, Obj, Type } from "@dxos/echo";
11148
+ import { Key, Obj as Obj2, Ref, Type } from "@dxos/echo";
10966
11149
  import { TestSchema } from "@dxos/echo/testing";
10967
11150
  import { invariant } from "@dxos/invariant";
10968
11151
  var TreeNodeType = Schema.Struct({
@@ -10972,7 +11155,7 @@ var TreeNodeType = Schema.Struct({
10972
11155
  key: Schema.String,
10973
11156
  value: Schema.Any
10974
11157
  })),
10975
- ref: Schema.optional(Type.Ref(TestSchema.Expando))
11158
+ ref: Schema.optional(Ref.Ref(TestSchema.Expando))
10976
11159
  }).pipe(Schema.mutable);
10977
11160
  var TreeType = Schema.Struct({
10978
11161
  root: Key.ObjectId,
@@ -10981,7 +11164,7 @@ var TreeType = Schema.Struct({
10981
11164
  value: TreeNodeType
10982
11165
  }))
10983
11166
  }).pipe(Type.object({
10984
- typename: "dxos.org/type/Tree",
11167
+ typename: "org.dxos.type.tree",
10985
11168
  version: "0.1.0"
10986
11169
  }));
10987
11170
 
@@ -11018,8 +11201,8 @@ var Tree = ({ space, selected, variant = "tidy", onNodeClick }) => {
11018
11201
  selected,
11019
11202
  registry
11020
11203
  ]);
11021
- const [tree3, setTree] = useState();
11022
- useEffect3(() => {
11204
+ const [tree3, setTree] = useState2();
11205
+ useEffect5(() => {
11023
11206
  return model?.subscribe(() => {
11024
11207
  const tree4 = mapGraphToTreeData(model);
11025
11208
  setTree(tree4);
@@ -11027,8 +11210,8 @@ var Tree = ({ space, selected, variant = "tidy", onNodeClick }) => {
11027
11210
  }, [
11028
11211
  model
11029
11212
  ]);
11030
- const context = useRef(null);
11031
- useEffect3(() => {
11213
+ const context = useRef3(null);
11214
+ useEffect5(() => {
11032
11215
  if (context.current?.size) {
11033
11216
  const { width, height } = context.current.size;
11034
11217
  const size = Math.min(width, height);
@@ -11054,23 +11237,19 @@ var Tree = ({ space, selected, variant = "tidy", onNodeClick }) => {
11054
11237
  context.current,
11055
11238
  tree3
11056
11239
  ]);
11057
- return /* @__PURE__ */ React3.createElement("div", {
11240
+ return /* @__PURE__ */ React5.createElement("div", {
11058
11241
  className: "grow",
11059
11242
  onClick: () => onNodeClick?.()
11060
- }, /* @__PURE__ */ React3.createElement(SVG.Root, {
11243
+ }, /* @__PURE__ */ React5.createElement(SVG2.Root, {
11061
11244
  ref: context
11062
11245
  }));
11063
11246
  };
11064
-
11065
- // src/components/index.ts
11066
- import { lazy } from "react";
11067
- var ExplorerContainer = lazy(() => import("./ExplorerContainer-BFAWRIAJ.mjs"));
11068
-
11069
11247
  export {
11070
11248
  Chart,
11249
+ D3ForceGraph,
11250
+ ForceGraph,
11071
11251
  Globe,
11072
- defaultTreeLayoutSlots,
11073
11252
  Tree,
11074
- ExplorerContainer
11253
+ defaultTreeLayoutSlots
11075
11254
  };
11076
- //# sourceMappingURL=chunk-AGZAGILW.mjs.map
11255
+ //# sourceMappingURL=index.mjs.map