@dxos/plugin-explorer 0.8.4-main.bc674ce → 0.8.4-main.bcb3aa67d6

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 (98) hide show
  1. package/dist/lib/browser/{chunk-YNQF4CPY.mjs → chunk-LSUP47BZ.mjs} +2 -2
  2. package/dist/lib/browser/{chunk-YNQF4CPY.mjs.map → chunk-LSUP47BZ.mjs.map} +1 -1
  3. package/dist/lib/browser/index.mjs +11331 -57
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/meta.mjs +1 -1
  7. package/dist/lib/browser/types/index.mjs +64 -4
  8. package/dist/lib/browser/types/index.mjs.map +4 -4
  9. package/dist/lib/node-esm/{chunk-DK77RB6M.mjs → chunk-EN3JZNEY.mjs} +2 -2
  10. package/dist/lib/node-esm/{chunk-DK77RB6M.mjs.map → chunk-EN3JZNEY.mjs.map} +1 -1
  11. package/dist/lib/node-esm/index.mjs +11331 -57
  12. package/dist/lib/node-esm/index.mjs.map +4 -4
  13. package/dist/lib/node-esm/meta.json +1 -1
  14. package/dist/lib/node-esm/meta.mjs +1 -1
  15. package/dist/lib/node-esm/types/index.mjs +64 -4
  16. package/dist/lib/node-esm/types/index.mjs.map +4 -4
  17. package/dist/types/src/ExplorerPlugin.d.ts.map +1 -1
  18. package/dist/types/src/capabilities/index.d.ts +2 -1
  19. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  20. package/dist/types/src/capabilities/react-surface.d.ts +5 -0
  21. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
  22. package/dist/types/src/components/Graph/D3ForceGraph.d.ts +10 -5
  23. package/dist/types/src/components/Graph/D3ForceGraph.d.ts.map +1 -1
  24. package/dist/types/src/components/Graph/D3ForceGraph.stories.d.ts +8 -2
  25. package/dist/types/src/components/Graph/D3ForceGraph.stories.d.ts.map +1 -1
  26. package/dist/types/src/components/Graph/ForceGraph.stories.d.ts +1 -1
  27. package/dist/types/src/components/Tree/Tree.stories.d.ts.map +1 -1
  28. package/dist/types/src/components/Tree/types/tree.d.ts +3 -3
  29. package/dist/types/src/components/Tree/types/tree.d.ts.map +1 -1
  30. package/dist/types/src/components/index.d.ts +0 -2
  31. package/dist/types/src/components/index.d.ts.map +1 -1
  32. package/dist/types/src/containers/ExplorerContainer/ExplorerContainer.d.ts +6 -0
  33. package/dist/types/src/containers/ExplorerContainer/ExplorerContainer.d.ts.map +1 -0
  34. package/dist/types/src/containers/ExplorerContainer/index.d.ts +3 -0
  35. package/dist/types/src/containers/ExplorerContainer/index.d.ts.map +1 -0
  36. package/dist/types/src/containers/index.d.ts +3 -0
  37. package/dist/types/src/containers/index.d.ts.map +1 -0
  38. package/dist/types/src/hooks/useGraphModel.d.ts.map +1 -1
  39. package/dist/types/src/translations.d.ts +28 -26
  40. package/dist/types/src/translations.d.ts.map +1 -1
  41. package/dist/types/src/types/ExplorerAction.d.ts.map +1 -1
  42. package/dist/types/src/types/Graph.d.ts +3 -10
  43. package/dist/types/src/types/Graph.d.ts.map +1 -1
  44. package/dist/types/tsconfig.tsbuildinfo +1 -1
  45. package/package.json +46 -37
  46. package/src/ExplorerPlugin.tsx +29 -16
  47. package/src/capabilities/index.ts +3 -1
  48. package/src/capabilities/{react-surface/react-surface.tsx → react-surface.tsx} +9 -8
  49. package/src/components/Chart/Chart.stories.tsx +2 -2
  50. package/src/components/Globe/Globe.stories.tsx +2 -2
  51. package/src/components/Graph/D3ForceGraph.stories.tsx +13 -13
  52. package/src/components/Graph/D3ForceGraph.tsx +82 -74
  53. package/src/components/Graph/ForceGraph.stories.tsx +13 -13
  54. package/src/components/Graph/testing.ts +2 -2
  55. package/src/components/Tree/Tree.stories.tsx +5 -3
  56. package/src/components/Tree/types/tree.ts +9 -9
  57. package/src/components/index.ts +0 -4
  58. package/src/containers/ExplorerContainer/ExplorerContainer.tsx +53 -0
  59. package/src/containers/ExplorerContainer/index.ts +7 -0
  60. package/src/containers/index.ts +7 -0
  61. package/src/hooks/useGraphModel.ts +18 -13
  62. package/src/meta.ts +1 -1
  63. package/src/translations.ts +13 -12
  64. package/src/types/ExplorerAction.ts +0 -1
  65. package/src/types/Graph.ts +10 -23
  66. package/src/typings.d.ts +8 -0
  67. package/dist/lib/browser/ExplorerContainer-BFAWRIAJ.mjs +0 -45
  68. package/dist/lib/browser/ExplorerContainer-BFAWRIAJ.mjs.map +0 -7
  69. package/dist/lib/browser/chunk-AGZAGILW.mjs +0 -11076
  70. package/dist/lib/browser/chunk-AGZAGILW.mjs.map +0 -7
  71. package/dist/lib/browser/chunk-BZMTFAP3.mjs +0 -34
  72. package/dist/lib/browser/chunk-BZMTFAP3.mjs.map +0 -7
  73. package/dist/lib/browser/chunk-HIFLWHXR.mjs +0 -83
  74. package/dist/lib/browser/chunk-HIFLWHXR.mjs.map +0 -7
  75. package/dist/lib/browser/chunk-MGBT2ZFU.mjs +0 -177
  76. package/dist/lib/browser/chunk-MGBT2ZFU.mjs.map +0 -7
  77. package/dist/lib/browser/react-surface-RWVHQL3J.mjs +0 -35
  78. package/dist/lib/browser/react-surface-RWVHQL3J.mjs.map +0 -7
  79. package/dist/lib/node-esm/ExplorerContainer-YQ2KKBVS.mjs +0 -46
  80. package/dist/lib/node-esm/ExplorerContainer-YQ2KKBVS.mjs.map +0 -7
  81. package/dist/lib/node-esm/chunk-3OE6TBJI.mjs +0 -84
  82. package/dist/lib/node-esm/chunk-3OE6TBJI.mjs.map +0 -7
  83. package/dist/lib/node-esm/chunk-IPIGIQHX.mjs +0 -36
  84. package/dist/lib/node-esm/chunk-IPIGIQHX.mjs.map +0 -7
  85. package/dist/lib/node-esm/chunk-QLMTN2XI.mjs +0 -11078
  86. package/dist/lib/node-esm/chunk-QLMTN2XI.mjs.map +0 -7
  87. package/dist/lib/node-esm/chunk-YWJBDETV.mjs +0 -179
  88. package/dist/lib/node-esm/chunk-YWJBDETV.mjs.map +0 -7
  89. package/dist/lib/node-esm/react-surface-3REUS7KW.mjs +0 -36
  90. package/dist/lib/node-esm/react-surface-3REUS7KW.mjs.map +0 -7
  91. package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
  92. package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
  93. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +0 -5
  94. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
  95. package/dist/types/src/components/ExplorerContainer.d.ts +0 -7
  96. package/dist/types/src/components/ExplorerContainer.d.ts.map +0 -1
  97. package/src/capabilities/react-surface/index.ts +0 -7
  98. package/src/components/ExplorerContainer.tsx +0 -52
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/plugin-explorer",
3
- "version": "0.8.4-main.bc674ce",
3
+ "version": "0.8.4-main.bcb3aa67d6",
4
4
  "description": "Braneframe data visualization plugin",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -12,23 +12,31 @@
12
12
  "author": "DXOS.org",
13
13
  "sideEffects": true,
14
14
  "type": "module",
15
+ "imports": {
16
+ "#capabilities": "./src/capabilities/index.ts",
17
+ "#components": "./src/components/index.ts",
18
+ "#containers": "./src/containers/index.ts",
19
+ "#hooks": "./src/hooks/index.ts",
20
+ "#meta": "./src/meta.ts",
21
+ "#types": "./src/types/index.ts"
22
+ },
15
23
  "exports": {
16
24
  ".": {
25
+ "source": "./src/index.ts",
17
26
  "browser": "./dist/lib/browser/index.mjs",
18
27
  "node": "./dist/lib/node-esm/index.mjs",
19
- "source": "./src/index.ts",
20
28
  "types": "./dist/types/src/index.d.ts"
21
29
  },
22
30
  "./meta": {
31
+ "source": "./src/meta.ts",
23
32
  "browser": "./dist/lib/browser/meta.mjs",
24
33
  "node": "./dist/lib/node-esm/meta.mjs",
25
- "source": "./src/meta.ts",
26
34
  "types": "./dist/types/src/meta.d.ts"
27
35
  },
28
36
  "./types": {
37
+ "source": "./src/types/index.ts",
29
38
  "browser": "./dist/lib/browser/types/index.mjs",
30
39
  "node": "./dist/lib/node-esm/types/index.mjs",
31
- "source": "./src/types/index.ts",
32
40
  "types": "./dist/types/src/types/index.d.ts"
33
41
  }
34
42
  },
@@ -49,37 +57,38 @@
49
57
  ],
50
58
  "dependencies": {
51
59
  "3d-force-graph": "^1.76.1",
52
- "@effect-atom/atom-react": "^0.4.6",
60
+ "@effect-atom/atom-react": "^0.5.0",
53
61
  "@observablehq/plot": "^0.6.11",
54
62
  "d3": "^7.9.0",
55
- "effect": "3.19.11",
63
+ "effect": "3.20.0",
56
64
  "force-graph": "^1.49.4",
57
65
  "lodash.defaultsdeep": "^4.6.1",
58
66
  "react-resize-detector": "^11.0.1",
59
67
  "three": "^0.178.0",
60
68
  "topojson-client": "^3.1.0",
61
- "@dxos/async": "0.8.4-main.bc674ce",
62
- "@dxos/app-framework": "0.8.4-main.bc674ce",
63
- "@dxos/client": "0.8.4-main.bc674ce",
64
- "@dxos/graph": "0.8.4-main.bc674ce",
65
- "@dxos/echo": "0.8.4-main.bc674ce",
66
- "@dxos/echo-query": "0.8.4-main.bc674ce",
67
- "@dxos/invariant": "0.8.4-main.bc674ce",
68
- "@dxos/log": "0.8.4-main.bc674ce",
69
- "@dxos/operation": "0.8.4-main.bc674ce",
70
- "@dxos/plugin-graph": "0.8.4-main.bc674ce",
71
- "@dxos/plugin-client": "0.8.4-main.bc674ce",
72
- "@dxos/plugin-space": "0.8.4-main.bc674ce",
73
- "@dxos/plugin-search": "0.8.4-main.bc674ce",
74
- "@dxos/react-client": "0.8.4-main.bc674ce",
75
- "@dxos/react-ui-components": "0.8.4-main.bc674ce",
76
- "@dxos/react-ui-graph": "0.8.4-main.bc674ce",
77
- "@dxos/react-ui-mosaic": "0.8.4-main.bc674ce",
78
- "@dxos/react-ui-attention": "0.8.4-main.bc674ce",
79
- "@dxos/react-ui-stack": "0.8.4-main.bc674ce",
80
- "@dxos/schema": "0.8.4-main.bc674ce",
81
- "@dxos/types": "0.8.4-main.bc674ce",
82
- "@dxos/util": "0.8.4-main.bc674ce"
69
+ "@dxos/app-framework": "0.8.4-main.bcb3aa67d6",
70
+ "@dxos/async": "0.8.4-main.bcb3aa67d6",
71
+ "@dxos/client": "0.8.4-main.bcb3aa67d6",
72
+ "@dxos/app-toolkit": "0.8.4-main.bcb3aa67d6",
73
+ "@dxos/echo": "0.8.4-main.bcb3aa67d6",
74
+ "@dxos/echo-query": "0.8.4-main.bcb3aa67d6",
75
+ "@dxos/graph": "0.8.4-main.bcb3aa67d6",
76
+ "@dxos/operation": "0.8.4-main.bcb3aa67d6",
77
+ "@dxos/log": "0.8.4-main.bcb3aa67d6",
78
+ "@dxos/plugin-client": "0.8.4-main.bcb3aa67d6",
79
+ "@dxos/invariant": "0.8.4-main.bcb3aa67d6",
80
+ "@dxos/plugin-graph": "0.8.4-main.bcb3aa67d6",
81
+ "@dxos/plugin-search": "0.8.4-main.bcb3aa67d6",
82
+ "@dxos/plugin-space": "0.8.4-main.bcb3aa67d6",
83
+ "@dxos/react-ui-components": "0.8.4-main.bcb3aa67d6",
84
+ "@dxos/react-ui-graph": "0.8.4-main.bcb3aa67d6",
85
+ "@dxos/react-client": "0.8.4-main.bcb3aa67d6",
86
+ "@dxos/react-ui-mosaic": "0.8.4-main.bcb3aa67d6",
87
+ "@dxos/react-ui-stack": "0.8.4-main.bcb3aa67d6",
88
+ "@dxos/types": "0.8.4-main.bcb3aa67d6",
89
+ "@dxos/util": "0.8.4-main.bcb3aa67d6",
90
+ "@dxos/schema": "0.8.4-main.bcb3aa67d6",
91
+ "@dxos/react-ui-attention": "0.8.4-main.bcb3aa67d6"
83
92
  },
84
93
  "devDependencies": {
85
94
  "@types/d3": "^7.4.3",
@@ -91,19 +100,19 @@
91
100
  "@types/topojson-specification": "^1.0.5",
92
101
  "react": "~19.2.3",
93
102
  "react-dom": "~19.2.3",
94
- "vite": "7.1.9",
95
- "@dxos/echo-generator": "0.8.4-main.bc674ce",
96
- "@dxos/random": "0.8.4-main.bc674ce",
97
- "@dxos/storybook-utils": "0.8.4-main.bc674ce",
98
- "@dxos/react-ui": "0.8.4-main.bc674ce",
99
- "@dxos/ui-theme": "0.8.4-main.bc674ce"
103
+ "vite": "^7.1.11",
104
+ "@dxos/echo-generator": "0.8.4-main.bcb3aa67d6",
105
+ "@dxos/random": "0.8.4-main.bcb3aa67d6",
106
+ "@dxos/react-ui": "0.8.4-main.bcb3aa67d6",
107
+ "@dxos/storybook-utils": "0.8.4-main.bcb3aa67d6",
108
+ "@dxos/ui-theme": "0.8.4-main.bcb3aa67d6"
100
109
  },
101
110
  "peerDependencies": {
102
- "effect": "3.19.11",
111
+ "effect": "3.20.0",
103
112
  "react": "~19.2.3",
104
113
  "react-dom": "~19.2.3",
105
- "@dxos/react-ui": "0.8.4-main.bc674ce",
106
- "@dxos/ui-theme": "0.8.4-main.bc674ce"
114
+ "@dxos/react-ui": "0.8.4-main.bcb3aa67d6",
115
+ "@dxos/ui-theme": "0.8.4-main.bcb3aa67d6"
107
116
  },
108
117
  "publishConfig": {
109
118
  "access": "public"
@@ -3,35 +3,48 @@
3
3
  //
4
4
 
5
5
  import * as Effect from 'effect/Effect';
6
+ import * as Option from 'effect/Option';
6
7
 
7
- import { Common, Plugin } from '@dxos/app-framework';
8
- import { Type } from '@dxos/echo';
8
+ import { Plugin } from '@dxos/app-framework';
9
+ import { AppPlugin } from '@dxos/app-toolkit';
10
+ import { Annotation, Type } from '@dxos/echo';
11
+ import { Operation } from '@dxos/operation';
9
12
  import { type CreateObject } from '@dxos/plugin-space/types';
10
- import { View } from '@dxos/schema';
13
+ import { SpaceOperation } from '@dxos/plugin-space/operations';
14
+ import { ViewModel } from '@dxos/schema';
11
15
 
12
- import { ReactSurface } from './capabilities';
13
- import { meta } from './meta';
16
+ import { meta } from '#meta';
14
17
  import { translations } from './translations';
15
- import { ExplorerAction, Graph } from './types';
18
+ import { ExplorerAction, Graph } from '#types';
19
+
20
+ import { ReactSurface } from '#capabilities';
16
21
 
17
22
  export const ExplorerPlugin = Plugin.define(meta).pipe(
18
- Common.Plugin.addTranslationsModule({ translations }),
19
- Common.Plugin.addMetadataModule({
23
+ AppPlugin.addMetadataModule({
20
24
  metadata: {
21
25
  id: Type.getTypename(Graph.Graph),
22
26
  metadata: {
23
- icon: 'ph--graph--regular',
24
- iconHue: 'green',
27
+ icon: Annotation.IconAnnotation.get(Graph.Graph).pipe(Option.getOrThrow).icon,
28
+ iconHue: Annotation.IconAnnotation.get(Graph.Graph).pipe(Option.getOrThrow).hue ?? 'white',
25
29
  inputSchema: ExplorerAction.GraphProps,
26
- createObject: ((props, { db }) =>
27
- Effect.promise(async () => {
28
- const { view } = await View.makeFromDatabase({ db, typename: props.typename });
29
- return Graph.make({ name: props.name, view });
30
+ createObject: ((props, options) =>
31
+ Effect.gen(function* () {
32
+ const object = yield* Effect.promise(async () => {
33
+ const { view } = await ViewModel.makeFromDatabase({ db: options.db, typename: props.typename });
34
+ return Graph.make({ name: props.name, view });
35
+ });
36
+ return yield* Operation.invoke(SpaceOperation.AddObject, {
37
+ object,
38
+ target: options.target,
39
+ hidden: true,
40
+ targetNodeId: options.targetNodeId,
41
+ });
30
42
  })) satisfies CreateObject,
31
43
  },
32
44
  },
33
45
  }),
34
- Common.Plugin.addSchemaModule({ schema: [Graph.Graph] }),
35
- Common.Plugin.addSurfaceModule({ activate: ReactSurface }),
46
+ AppPlugin.addSchemaModule({ schema: [Graph.Graph] }),
47
+ AppPlugin.addSurfaceModule({ activate: ReactSurface }),
48
+ AppPlugin.addTranslationsModule({ translations }),
36
49
  Plugin.make,
37
50
  );
@@ -2,4 +2,6 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- export * from './react-surface';
5
+ import { Capability } from '@dxos/app-framework';
6
+
7
+ export const ReactSurface = Capability.lazy('ReactSurface', () => import('./react-surface'));
@@ -5,20 +5,21 @@
5
5
  import * as Effect from 'effect/Effect';
6
6
  import React from 'react';
7
7
 
8
- import { Capability, Common } from '@dxos/app-framework';
8
+ import { Capabilities, Capability } from '@dxos/app-framework';
9
+ import { Surface } from '@dxos/app-framework/ui';
9
10
  import { Obj } from '@dxos/echo';
10
- import { type View } from '@dxos/schema';
11
+ import { type View } from '@dxos/echo';
11
12
 
12
- import { ExplorerContainer } from '../../components';
13
- import { meta } from '../../meta';
14
- import { Graph } from '../../types';
13
+ import { ExplorerContainer } from '#containers';
14
+ import { meta } from '#meta';
15
+ import { Graph } from '#types';
15
16
 
16
17
  export default Capability.makeModule(() =>
17
18
  Effect.succeed(
18
19
  Capability.contributes(
19
- Common.Capability.ReactSurface,
20
- Common.createSurface({
21
- id: `${meta.id}/article`,
20
+ Capabilities.ReactSurface,
21
+ Surface.create({
22
+ id: `${meta.id}.article`,
22
23
  role: ['article', 'section'],
23
24
  filter: (data): data is { subject: View.View } => Obj.instanceOf(Graph.Graph, data.subject),
24
25
  component: ({ data, role }) => {
@@ -32,9 +32,9 @@ const Story = () => {
32
32
  export const Default = () => <ClientRepeater component={Story} />;
33
33
 
34
34
  const meta = {
35
- title: 'plugins/plugin-explorer/Chart',
35
+ title: 'plugins/plugin-explorer/components/Chart',
36
36
  component: Chart,
37
- decorators: [withTheme, withLayout()],
37
+ decorators: [withTheme(), withLayout()],
38
38
  parameters: {
39
39
  layout: 'fullscreen',
40
40
  },
@@ -80,8 +80,8 @@ const ExtendedStory = () => {
80
80
  };
81
81
 
82
82
  const meta = {
83
- title: 'plugins/plugin-explorer/Globe',
84
- decorators: [withTheme, withLayout()],
83
+ title: 'plugins/plugin-explorer/components/Globe',
84
+ decorators: [withTheme(), withLayout()],
85
85
  parameters: {
86
86
  layout: 'fullscreen',
87
87
  },
@@ -6,20 +6,20 @@ import { type Meta, type StoryObj } from '@storybook/react-vite';
6
6
  import React, { useState } from 'react';
7
7
 
8
8
  import { Type } from '@dxos/echo';
9
+ import { View } from '@dxos/echo';
9
10
  import { faker } from '@dxos/random';
10
11
  import { useClient } from '@dxos/react-client';
11
12
  import { type Space } from '@dxos/react-client/echo';
12
13
  import { withClientProvider } from '@dxos/react-client/testing';
13
14
  import { useAsyncEffect } from '@dxos/react-ui';
14
- import { withLayout, withTheme } from '@dxos/react-ui/testing';
15
- import { View } from '@dxos/schema';
15
+ import { Loading, withLayout, withTheme } from '@dxos/react-ui/testing';
16
+ import { ViewModel } from '@dxos/schema';
16
17
  import { type ValueGenerator } from '@dxos/schema/testing';
17
18
  import { withRegistry } from '@dxos/storybook-utils';
18
- import { render } from '@dxos/storybook-utils';
19
- import { HasRelationship, Organization, Person, Project } from '@dxos/types';
19
+ import { HasRelationship, Organization, Person, Pipeline } from '@dxos/types';
20
20
 
21
- import { useGraphModel } from '../../hooks';
22
- import { Graph } from '../../types';
21
+ import { useGraphModel } from '#hooks';
22
+ import { Graph } from '#types';
23
23
 
24
24
  import { D3ForceGraph } from './D3ForceGraph';
25
25
  import { generate } from './testing';
@@ -34,9 +34,9 @@ const DefaultStory = () => {
34
34
  const [graph, setGraph] = useState<Graph.Graph>();
35
35
 
36
36
  useAsyncEffect(async () => {
37
- const space = client.spaces.default;
37
+ const space = client.spaces.get()[0];
38
38
  void generate(space, generator);
39
- const { view } = await View.makeFromDatabase({ db: space.db, typename: Type.getTypename(Graph.Graph) });
39
+ const { view } = await ViewModel.makeFromDatabase({ db: space.db, typename: Type.getTypename(Graph.Graph) });
40
40
  const graph = Graph.make({ name: 'Test', view });
41
41
  space.db.add(graph);
42
42
  setSpace(space);
@@ -45,19 +45,19 @@ const DefaultStory = () => {
45
45
 
46
46
  const model = useGraphModel(space);
47
47
  if (!model || !space || !graph) {
48
- return null;
48
+ return <Loading data={{ model: !!model, space: !!space, graph: !!graph }} />;
49
49
  }
50
50
 
51
51
  return <D3ForceGraph model={model} />;
52
52
  };
53
53
 
54
54
  const meta = {
55
- title: 'plugins/plugin-explorer/D3ForceGraph',
55
+ title: 'plugins/plugin-explorer/components/D3ForceGraph',
56
56
  component: D3ForceGraph,
57
- render: render(DefaultStory),
57
+ render: DefaultStory,
58
58
  decorators: [
59
59
  withRegistry,
60
- withTheme,
60
+ withTheme(),
61
61
  withLayout(),
62
62
  withClientProvider({
63
63
  createSpace: true,
@@ -65,7 +65,7 @@ const meta = {
65
65
  Graph.Graph,
66
66
  View.View,
67
67
  Organization.Organization,
68
- Project.Project,
68
+ Pipeline.Pipeline,
69
69
  Person.Person,
70
70
  HasRelationship.HasRelationship,
71
71
  ],
@@ -2,11 +2,11 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import React, { useCallback, useEffect, useMemo, useRef } from 'react';
5
+ import { Atom, useAtomValue } from '@effect-atom/atom-react';
6
+ import React, { type ComponentPropsWithoutRef, useCallback, useEffect, useMemo, useRef } from 'react';
6
7
 
7
8
  import { Obj } from '@dxos/echo';
8
9
  import { SelectionModel } from '@dxos/graph';
9
- import { type ThemedClassName } from '@dxos/react-ui';
10
10
  import {
11
11
  type GraphController,
12
12
  GraphForceProjector,
@@ -16,86 +16,94 @@ import {
16
16
  type SVGContext,
17
17
  } from '@dxos/react-ui-graph';
18
18
  import { type SpaceGraphEdge, type SpaceGraphModel, type SpaceGraphNode } from '@dxos/schema';
19
- import { getHashStyles } from '@dxos/ui-theme';
19
+ import { composable, composableProps, getHashStyles } from '@dxos/ui-theme';
20
20
 
21
21
  import '@dxos/react-ui-graph/styles/graph.css';
22
22
 
23
- export type D3ForceGraphProps = ThemedClassName<
24
- {
25
- model?: SpaceGraphModel;
26
- match?: RegExp;
27
- selection?: SelectionModel;
28
- grid?: boolean;
29
- } & Pick<GraphProps, 'drag'>
30
- >;
23
+ export type D3ForceGraphProps = {
24
+ model?: SpaceGraphModel;
25
+ match?: RegExp;
26
+ selection?: SelectionModel;
27
+ grid?: boolean;
28
+ } & Pick<GraphProps, 'drag'> &
29
+ ComponentPropsWithoutRef<'div'>;
31
30
 
32
- export const D3ForceGraph = ({ classNames, model, selection: _selection, grid, ...props }: D3ForceGraphProps) => {
33
- const context = useRef<SVGContext>(null);
34
- const projector = useMemo<GraphForceProjector | undefined>(() => {
35
- if (context.current) {
36
- return new GraphForceProjector(context.current, {
37
- attributes: {
38
- linkForce: (edge) => {
39
- // TODO(burdon): Check type (currently assumes Employee property).
40
- // Edge shouldn't contribute to force if it's not active.
41
- return edge.data?.object?.active !== false;
31
+ const EMPTY_ATOM = Atom.make<{ nodes: SpaceGraphNode[]; edges: SpaceGraphEdge[] }>({ nodes: [], edges: [] });
32
+
33
+ export const D3ForceGraph = composable<HTMLDivElement, D3ForceGraphProps>(
34
+ ({ model, selection: _selection, grid, drag, ...props }, forwardedRef) => {
35
+ // TODO(wittjosiah): This should go into Graph.tsx but for some reason doesn't work.
36
+ useAtomValue(model?.graphAtom ?? EMPTY_ATOM);
37
+
38
+ const svgRef = useRef<SVGContext>(null);
39
+ const projector = useMemo<GraphForceProjector | undefined>(() => {
40
+ if (svgRef.current) {
41
+ return new GraphForceProjector(svgRef.current, {
42
+ attributes: {
43
+ linkForce: (edge) => {
44
+ // TODO(burdon): Check type (currently assumes Employee property).
45
+ // Edge shouldn't contribute to force if it's not active.
46
+ return edge.data?.object?.active !== false;
47
+ },
42
48
  },
43
- },
44
- forces: {
45
- point: {
46
- strength: 0.01,
49
+ forces: {
50
+ point: {
51
+ strength: 0.01,
52
+ },
47
53
  },
48
- },
49
- });
50
- }
51
- }, [context.current]);
54
+ });
55
+ }
56
+ }, []);
52
57
 
53
- const graph = useRef<GraphController>(null);
54
- const selection = useMemo(() => _selection ?? new SelectionModel(), [_selection]);
55
- useEffect(() => selection.subscribe(() => graph.current?.repaint()), [selection]);
58
+ const graph = useRef<GraphController>(null);
59
+ const selection = useMemo(() => _selection ?? new SelectionModel(), [_selection]);
60
+ useEffect(() => selection.subscribe(() => graph.current?.repaint()), [selection]);
56
61
 
57
- const handleSelect = useCallback<NonNullable<GraphProps['onSelect']>>(
58
- (node) => {
59
- if (selection.contains(node.id)) {
60
- selection.remove(node.id);
61
- } else {
62
- selection.add(node.id);
63
- }
64
- },
65
- [selection],
66
- );
62
+ const handleSelect = useCallback<NonNullable<GraphProps['onSelect']>>(
63
+ (node) => {
64
+ if (selection.contains(node.id)) {
65
+ selection.remove(node.id);
66
+ } else {
67
+ selection.add(node.id);
68
+ }
69
+ },
70
+ [selection],
71
+ );
67
72
 
68
- return (
69
- <SVG.Root ref={context} classNames={classNames}>
70
- <SVG.Markers />
71
- {grid && <SVG.Grid axis />}
72
- <SVG.Zoom extent={[1 / 2, 2]}>
73
- <SVG.Graph<SpaceGraphNode, SpaceGraphEdge>
74
- {...props}
75
- ref={graph}
76
- model={model}
77
- projector={projector}
78
- labels={{
79
- text: (node) => {
80
- return node.data?.data.label ?? node.id;
81
- },
82
- }}
83
- attributes={{
84
- node: (node: GraphLayoutNode<SpaceGraphNode>) => {
85
- const obj = node.data?.data.object;
86
- return {
87
- data: {
88
- color: getHashStyles(obj && Obj.getTypename(obj))?.hue,
73
+ return (
74
+ <div {...composableProps(props, { classNames: 'dx-container' })} ref={forwardedRef}>
75
+ <SVG.Root ref={svgRef}>
76
+ <SVG.Markers />
77
+ {grid && <SVG.Grid axis />}
78
+ <SVG.Zoom extent={[1 / 2, 2]}>
79
+ <SVG.Graph<SpaceGraphNode, SpaceGraphEdge>
80
+ drag={drag}
81
+ ref={graph}
82
+ model={model}
83
+ projector={projector}
84
+ labels={{
85
+ text: (node) => {
86
+ return node.data?.data.label ?? node.id;
89
87
  },
90
- classes: {
91
- 'dx-selected': selection.contains(node.id),
88
+ }}
89
+ attributes={{
90
+ node: (node: GraphLayoutNode<SpaceGraphNode>) => {
91
+ const obj = node.data?.data.object;
92
+ return {
93
+ data: {
94
+ color: getHashStyles(obj && Obj.getTypename(obj))?.hue,
95
+ },
96
+ classes: {
97
+ 'dx-selected': selection.contains(node.id),
98
+ },
99
+ };
92
100
  },
93
- };
94
- },
95
- }}
96
- onSelect={handleSelect}
97
- />
98
- </SVG.Zoom>
99
- </SVG.Root>
100
- );
101
- };
101
+ }}
102
+ onSelect={handleSelect}
103
+ />
104
+ </SVG.Zoom>
105
+ </SVG.Root>
106
+ </div>
107
+ );
108
+ },
109
+ );
@@ -6,20 +6,20 @@ import { type Meta, type StoryObj } from '@storybook/react-vite';
6
6
  import React, { useState } from 'react';
7
7
 
8
8
  import { Type } from '@dxos/echo';
9
+ import { View } from '@dxos/echo';
9
10
  import { faker } from '@dxos/random';
10
11
  import { useClient } from '@dxos/react-client';
11
12
  import { type Space } from '@dxos/react-client/echo';
12
13
  import { withClientProvider } from '@dxos/react-client/testing';
13
14
  import { useAsyncEffect } from '@dxos/react-ui';
14
- import { withLayout, withTheme } from '@dxos/react-ui/testing';
15
- import { View } from '@dxos/schema';
15
+ import { Loading, withLayout, withTheme } from '@dxos/react-ui/testing';
16
+ import { ViewModel } from '@dxos/schema';
16
17
  import { type ValueGenerator } from '@dxos/schema/testing';
17
18
  import { withRegistry } from '@dxos/storybook-utils';
18
- import { render } from '@dxos/storybook-utils';
19
- import { HasRelationship, Organization, Person, Project } from '@dxos/types';
19
+ import { HasRelationship, Organization, Person, Pipeline } from '@dxos/types';
20
20
 
21
- import { useGraphModel } from '../../hooks';
22
- import { Graph } from '../../types';
21
+ import { useGraphModel } from '#hooks';
22
+ import { Graph } from '#types';
23
23
 
24
24
  import { ForceGraph } from './ForceGraph';
25
25
  import { generate } from './testing';
@@ -34,9 +34,9 @@ const DefaultStory = () => {
34
34
  const [graph, setGraph] = useState<Graph.Graph>();
35
35
 
36
36
  useAsyncEffect(async () => {
37
- const space = client.spaces.default;
37
+ const space = client.spaces.get()[0];
38
38
  void generate(space, generator);
39
- const { view } = await View.makeFromDatabase({ db: space.db, typename: Type.getTypename(Graph.Graph) });
39
+ const { view } = await ViewModel.makeFromDatabase({ db: space.db, typename: Type.getTypename(Graph.Graph) });
40
40
  const graph = Graph.make({ name: 'Test', view });
41
41
  space.db.add(graph);
42
42
  setSpace(space);
@@ -45,19 +45,19 @@ const DefaultStory = () => {
45
45
 
46
46
  const model = useGraphModel(space);
47
47
  if (!model || !space || !graph) {
48
- return null;
48
+ return <Loading data={{ model: !!model, space: !!space, graph: !!graph }} />;
49
49
  }
50
50
 
51
51
  return <ForceGraph model={model} />;
52
52
  };
53
53
 
54
54
  const meta = {
55
- title: 'plugins/plugin-explorer/ForceGraph',
55
+ title: 'plugins/plugin-explorer/components/ForceGraph',
56
56
  component: ForceGraph,
57
- render: render(DefaultStory),
57
+ render: DefaultStory,
58
58
  decorators: [
59
59
  withRegistry,
60
- withTheme,
60
+ withTheme(),
61
61
  withLayout(),
62
62
  withClientProvider({
63
63
  createSpace: true,
@@ -66,7 +66,7 @@ const meta = {
66
66
  View.View,
67
67
  HasRelationship.HasRelationship,
68
68
  Organization.Organization,
69
- Project.Project,
69
+ Pipeline.Pipeline,
70
70
  Person.Person,
71
71
  ],
72
72
  }),
@@ -5,14 +5,14 @@
5
5
  import { type Space } from '@dxos/client/echo';
6
6
  import { type Obj, Query, Relation } from '@dxos/echo';
7
7
  import { type TypeSpec, type ValueGenerator, createObjectFactory } from '@dxos/schema/testing';
8
- import { HasRelationship, Organization, Person, Project } from '@dxos/types';
8
+ import { HasRelationship, Organization, Person, Pipeline } from '@dxos/types';
9
9
  import { range } from '@dxos/util';
10
10
 
11
11
  const getObject = (objects: Obj.Unknown[]) => objects[Math.floor(Math.random() * objects.length)];
12
12
 
13
13
  const defaultTypes: TypeSpec[] = [
14
14
  { type: Organization.Organization, count: 5 },
15
- { type: Project.Project, count: 5 },
15
+ { type: Pipeline.Pipeline, count: 5 },
16
16
  { type: Person.Person, count: 10 },
17
17
  ];
18
18
 
@@ -5,6 +5,7 @@
5
5
  import { type Meta, type StoryObj } from '@storybook/react-vite';
6
6
  import React, { useEffect, useState } from 'react';
7
7
 
8
+ import { invariant } from '@dxos/invariant';
8
9
  import { faker } from '@dxos/random';
9
10
  import { useClient } from '@dxos/react-client';
10
11
  import { type ClientRepeatedComponentProps, ClientRepeater } from '@dxos/react-client/testing';
@@ -23,7 +24,8 @@ type ComponentProps = ClientRepeatedComponentProps & { type?: TreeComponentProps
23
24
 
24
25
  const Component = ({ type }: ComponentProps) => {
25
26
  const client = useClient();
26
- const space = client.spaces.default;
27
+ const space = client.spaces.get()[0];
28
+ invariant(space, 'Tree story requires at least one space');
27
29
  const [object, setObject] = useState<TreeType>();
28
30
  useEffect(() => {
29
31
  setTimeout(() => {
@@ -44,10 +46,10 @@ const DefaultStory = () => {
44
46
  };
45
47
 
46
48
  const meta = {
47
- title: 'plugins/plugin-explorer/Tree',
49
+ title: 'plugins/plugin-explorer/components/Tree',
48
50
  component: Tree as any,
49
51
  render: DefaultStory,
50
- decorators: [withRegistry, withTheme, withLayout()],
52
+ decorators: [withRegistry, withTheme(), withLayout()],
51
53
  parameters: {
52
54
  layout: 'fullscreen',
53
55
  },