@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/plugin-explorer",
3
- "version": "0.8.4-main.9735255",
3
+ "version": "0.8.4-main.abd8ff62ef",
4
4
  "description": "Braneframe data visualization plugin",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -12,74 +12,93 @@
12
12
  "author": "DXOS.org",
13
13
  "sideEffects": true,
14
14
  "type": "module",
15
+ "imports": {
16
+ "#plugin": "./src/ExplorerPlugin.tsx",
17
+ "#capabilities": "./src/capabilities/index.ts",
18
+ "#components": "./src/components/index.ts",
19
+ "#containers": "./src/containers/index.ts",
20
+ "#hooks": "./src/hooks/index.ts",
21
+ "#meta": "./src/meta.ts",
22
+ "#translations": "./src/translations.ts",
23
+ "#types": "./src/types/index.ts"
24
+ },
15
25
  "exports": {
16
26
  ".": {
27
+ "source": "./src/index.ts",
17
28
  "browser": "./dist/lib/browser/index.mjs",
18
29
  "node": "./dist/lib/node-esm/index.mjs",
19
- "source": "./src/index.ts",
20
30
  "types": "./dist/types/src/index.d.ts"
21
31
  },
22
32
  "./meta": {
33
+ "source": "./src/meta.ts",
23
34
  "browser": "./dist/lib/browser/meta.mjs",
24
35
  "node": "./dist/lib/node-esm/meta.mjs",
25
- "source": "./src/meta.ts",
26
36
  "types": "./dist/types/src/meta.d.ts"
27
37
  },
38
+ "./translations": {
39
+ "source": "./src/translations.ts",
40
+ "types": "./dist/types/src/translations.d.ts",
41
+ "browser": "./dist/lib/browser/translations.mjs",
42
+ "node": "./dist/lib/node-esm/translations.mjs"
43
+ },
44
+ "./components": {
45
+ "source": "./src/components/index.ts",
46
+ "browser": "./dist/lib/browser/components/index.mjs",
47
+ "node": "./dist/lib/node-esm/components/index.mjs",
48
+ "types": "./dist/types/src/components/index.d.ts"
49
+ },
50
+ "./hooks": {
51
+ "source": "./src/hooks/index.ts",
52
+ "browser": "./dist/lib/browser/hooks/index.mjs",
53
+ "node": "./dist/lib/node-esm/hooks/index.mjs",
54
+ "types": "./dist/types/src/hooks/index.d.ts"
55
+ },
28
56
  "./types": {
57
+ "source": "./src/types/index.ts",
29
58
  "browser": "./dist/lib/browser/types/index.mjs",
30
59
  "node": "./dist/lib/node-esm/types/index.mjs",
31
- "source": "./src/types/index.ts",
32
60
  "types": "./dist/types/src/types/index.d.ts"
33
61
  }
34
62
  },
35
63
  "types": "dist/types/src/index.d.ts",
36
- "typesVersions": {
37
- "*": {
38
- "meta": [
39
- "dist/types/src/meta.d.ts"
40
- ],
41
- "types": [
42
- "dist/types/src/types/index.d.ts"
43
- ]
44
- }
45
- },
46
64
  "files": [
47
65
  "dist",
48
66
  "src"
49
67
  ],
50
68
  "dependencies": {
51
69
  "3d-force-graph": "^1.76.1",
52
- "@effect-atom/atom-react": "^0.4.6",
70
+ "@effect-atom/atom-react": "^0.5.0",
53
71
  "@observablehq/plot": "^0.6.11",
54
72
  "d3": "^7.9.0",
55
- "effect": "3.19.11",
73
+ "effect": "3.20.0",
56
74
  "force-graph": "^1.49.4",
57
75
  "lodash.defaultsdeep": "^4.6.1",
58
76
  "react-resize-detector": "^11.0.1",
59
77
  "three": "^0.178.0",
60
78
  "topojson-client": "^3.1.0",
61
- "@dxos/app-framework": "0.8.4-main.9735255",
62
- "@dxos/client": "0.8.4-main.9735255",
63
- "@dxos/async": "0.8.4-main.9735255",
64
- "@dxos/echo": "0.8.4-main.9735255",
65
- "@dxos/graph": "0.8.4-main.9735255",
66
- "@dxos/invariant": "0.8.4-main.9735255",
67
- "@dxos/echo-query": "0.8.4-main.9735255",
68
- "@dxos/log": "0.8.4-main.9735255",
69
- "@dxos/operation": "0.8.4-main.9735255",
70
- "@dxos/plugin-client": "0.8.4-main.9735255",
71
- "@dxos/plugin-graph": "0.8.4-main.9735255",
72
- "@dxos/plugin-search": "0.8.4-main.9735255",
73
- "@dxos/plugin-space": "0.8.4-main.9735255",
74
- "@dxos/react-client": "0.8.4-main.9735255",
75
- "@dxos/react-ui-attention": "0.8.4-main.9735255",
76
- "@dxos/react-ui-components": "0.8.4-main.9735255",
77
- "@dxos/react-ui-stack": "0.8.4-main.9735255",
78
- "@dxos/react-ui-mosaic": "0.8.4-main.9735255",
79
- "@dxos/react-ui-graph": "0.8.4-main.9735255",
80
- "@dxos/schema": "0.8.4-main.9735255",
81
- "@dxos/types": "0.8.4-main.9735255",
82
- "@dxos/util": "0.8.4-main.9735255"
79
+ "@dxos/app-framework": "0.8.4-main.abd8ff62ef",
80
+ "@dxos/async": "0.8.4-main.abd8ff62ef",
81
+ "@dxos/client": "0.8.4-main.abd8ff62ef",
82
+ "@dxos/compute": "0.8.4-main.abd8ff62ef",
83
+ "@dxos/app-toolkit": "0.8.4-main.abd8ff62ef",
84
+ "@dxos/echo": "0.8.4-main.abd8ff62ef",
85
+ "@dxos/echo-query": "0.8.4-main.abd8ff62ef",
86
+ "@dxos/graph": "0.8.4-main.abd8ff62ef",
87
+ "@dxos/invariant": "0.8.4-main.abd8ff62ef",
88
+ "@dxos/log": "0.8.4-main.abd8ff62ef",
89
+ "@dxos/plugin-client": "0.8.4-main.abd8ff62ef",
90
+ "@dxos/plugin-search": "0.8.4-main.abd8ff62ef",
91
+ "@dxos/plugin-space": "0.8.4-main.abd8ff62ef",
92
+ "@dxos/react-client": "0.8.4-main.abd8ff62ef",
93
+ "@dxos/react-ui-attention": "0.8.4-main.abd8ff62ef",
94
+ "@dxos/plugin-graph": "0.8.4-main.abd8ff62ef",
95
+ "@dxos/react-ui-components": "0.8.4-main.abd8ff62ef",
96
+ "@dxos/react-ui-graph": "0.8.4-main.abd8ff62ef",
97
+ "@dxos/react-ui-mosaic": "0.8.4-main.abd8ff62ef",
98
+ "@dxos/react-ui-stack": "0.8.4-main.abd8ff62ef",
99
+ "@dxos/schema": "0.8.4-main.abd8ff62ef",
100
+ "@dxos/types": "0.8.4-main.abd8ff62ef",
101
+ "@dxos/util": "0.8.4-main.abd8ff62ef"
83
102
  },
84
103
  "devDependencies": {
85
104
  "@types/d3": "^7.4.3",
@@ -91,19 +110,20 @@
91
110
  "@types/topojson-specification": "^1.0.5",
92
111
  "react": "~19.2.3",
93
112
  "react-dom": "~19.2.3",
94
- "vite": "7.1.9",
95
- "@dxos/random": "0.8.4-main.9735255",
96
- "@dxos/echo-generator": "0.8.4-main.9735255",
97
- "@dxos/react-ui": "0.8.4-main.9735255",
98
- "@dxos/ui-theme": "0.8.4-main.9735255",
99
- "@dxos/storybook-utils": "0.8.4-main.9735255"
113
+ "vite": "^8.0.10",
114
+ "@dxos/echo-generator": "0.8.4-main.abd8ff62ef",
115
+ "@dxos/react-ui": "0.8.4-main.abd8ff62ef",
116
+ "@dxos/plugin-testing": "0.8.4-main.abd8ff62ef",
117
+ "@dxos/random": "0.8.4-main.abd8ff62ef",
118
+ "@dxos/storybook-utils": "0.8.4-main.abd8ff62ef",
119
+ "@dxos/ui-theme": "0.8.4-main.abd8ff62ef"
100
120
  },
101
121
  "peerDependencies": {
102
- "effect": "3.19.11",
122
+ "effect": "3.20.0",
103
123
  "react": "~19.2.3",
104
124
  "react-dom": "~19.2.3",
105
- "@dxos/react-ui": "0.8.4-main.9735255",
106
- "@dxos/ui-theme": "0.8.4-main.9735255"
125
+ "@dxos/react-ui": "0.8.4-main.abd8ff62ef",
126
+ "@dxos/ui-theme": "0.8.4-main.abd8ff62ef"
107
127
  },
108
128
  "publishConfig": {
109
129
  "access": "public"
@@ -0,0 +1,26 @@
1
+ //
2
+ // Copyright 2026 DXOS.org
3
+ //
4
+
5
+ import { describe, test } from 'vitest';
6
+
7
+ import { ClientPlugin } from '@dxos/plugin-client';
8
+ import { createComposerTestApp } from '@dxos/plugin-testing/harness';
9
+
10
+ import { ExplorerPlugin } from '#plugin';
11
+
12
+ import { meta } from './meta';
13
+
14
+ const moduleId = (name: string) => `${meta.id}.module.${name}`;
15
+
16
+ describe('ExplorerPlugin', () => {
17
+ test('modules activate on the expected events', async ({ expect }) => {
18
+ await using harness = await createComposerTestApp({
19
+ plugins: [ClientPlugin({}), ExplorerPlugin()],
20
+ });
21
+
22
+ expect(harness.manager.getActive()).toEqual(
23
+ expect.arrayContaining([moduleId('metadata'), moduleId('schema'), moduleId('ReactSurface')]),
24
+ );
25
+ });
26
+ });
@@ -3,35 +3,49 @@
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 { Operation } from '@dxos/compute';
11
+ import { Annotation, Type } from '@dxos/echo';
12
+ import { SpaceOperation } from '@dxos/plugin-space/operations';
9
13
  import { type CreateObject } from '@dxos/plugin-space/types';
10
- import { View } from '@dxos/schema';
14
+ import { ViewModel } from '@dxos/schema';
11
15
 
12
- import { ReactSurface } from './capabilities';
13
- import { meta } from './meta';
14
- import { translations } from './translations';
15
- import { ExplorerAction, Graph } from './types';
16
+ import { ReactSurface } from '#capabilities';
17
+ import { meta } from '#meta';
18
+ import { translations } from '#translations';
19
+ import { ExplorerAction, Graph } from '#types';
16
20
 
17
21
  export const ExplorerPlugin = Plugin.define(meta).pipe(
18
- Common.Plugin.addTranslationsModule({ translations }),
19
- Common.Plugin.addMetadataModule({
22
+ AppPlugin.addMetadataModule({
20
23
  metadata: {
21
24
  id: Type.getTypename(Graph.Graph),
22
25
  metadata: {
23
- icon: 'ph--graph--regular',
24
- iconHue: 'green',
26
+ icon: Annotation.IconAnnotation.get(Graph.Graph).pipe(Option.getOrThrow).icon,
27
+ iconHue: Annotation.IconAnnotation.get(Graph.Graph).pipe(Option.getOrThrow).hue ?? 'white',
25
28
  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 });
29
+ createObject: ((props, options) =>
30
+ Effect.gen(function* () {
31
+ const object = yield* Effect.promise(async () => {
32
+ const { view } = await ViewModel.makeFromDatabase({ db: options.db, typename: props.typename });
33
+ return Graph.make({ name: props.name, view });
34
+ });
35
+ return yield* Operation.invoke(SpaceOperation.AddObject, {
36
+ object,
37
+ target: options.target,
38
+ hidden: true,
39
+ targetNodeId: options.targetNodeId,
40
+ });
30
41
  })) satisfies CreateObject,
31
42
  },
32
43
  },
33
44
  }),
34
- Common.Plugin.addSchemaModule({ schema: [Graph.Graph] }),
35
- Common.Plugin.addSurfaceModule({ activate: ReactSurface }),
45
+ AppPlugin.addSchemaModule({ schema: [Graph.Graph] }),
46
+ AppPlugin.addSurfaceModule({ activate: ReactSurface }),
47
+ AppPlugin.addTranslationsModule({ translations }),
36
48
  Plugin.make,
37
49
  );
50
+
51
+ export default ExplorerPlugin;
@@ -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'));
@@ -0,0 +1,32 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as Effect from 'effect/Effect';
6
+ import React from 'react';
7
+
8
+ import { Capabilities, Capability } from '@dxos/app-framework';
9
+ import { Surface } from '@dxos/app-framework/ui';
10
+ import { AppSurface } from '@dxos/app-toolkit/ui';
11
+
12
+ import { ExplorerContainer } from '#containers';
13
+ import { Graph } from '#types';
14
+
15
+ export default Capability.makeModule(() =>
16
+ Effect.succeed(
17
+ Capability.contributes(
18
+ Capabilities.ReactSurface,
19
+ Surface.create({
20
+ id: 'article',
21
+ // TODO(wittjosiah): Split into multiple surfaces if this filter proves too strict for non-article roles.
22
+ filter: AppSurface.oneOf(
23
+ AppSurface.object(AppSurface.Article, Graph.Graph),
24
+ AppSurface.object(AppSurface.Section, Graph.Graph),
25
+ ),
26
+ component: ({ data, role }) => {
27
+ return <ExplorerContainer role={role} subject={data.subject} attendableId={data.attendableId} />;
28
+ },
29
+ }),
30
+ ),
31
+ ),
32
+ );
@@ -9,7 +9,6 @@ import { ClientRepeater } from '@dxos/react-client/testing';
9
9
  import { withLayout, withTheme } from '@dxos/react-ui/testing';
10
10
 
11
11
  import CitiesData from '../../../data/cities.js';
12
-
13
12
  import { Chart } from './Chart';
14
13
 
15
14
  // TODO(burdon): Generate data with geo lat/lng.
@@ -32,9 +31,9 @@ const Story = () => {
32
31
  export const Default = () => <ClientRepeater component={Story} />;
33
32
 
34
33
  const meta = {
35
- title: 'plugins/plugin-explorer/Chart',
34
+ title: 'plugins/plugin-explorer/components/Chart',
36
35
  component: Chart,
37
- decorators: [withTheme, withLayout()],
36
+ decorators: [withTheme(), withLayout()],
38
37
  parameters: {
39
38
  layout: 'fullscreen',
40
39
  },
@@ -14,7 +14,6 @@ import { withLayout, withTheme } from '@dxos/react-ui/testing';
14
14
 
15
15
  import CitiesData from '../../../data/cities.js';
16
16
  import CountriesData from '../../../data/countries-110m.js';
17
-
18
17
  import { Globe } from './Globe';
19
18
 
20
19
  // TODO(burdon): Generate data with geo lat/lng.
@@ -80,8 +79,8 @@ const ExtendedStory = () => {
80
79
  };
81
80
 
82
81
  const meta = {
83
- title: 'plugins/plugin-explorer/Globe',
84
- decorators: [withTheme, withLayout()],
82
+ title: 'plugins/plugin-explorer/components/Globe',
83
+ decorators: [withTheme(), withLayout()],
85
84
  parameters: {
86
85
  layout: 'fullscreen',
87
86
  },
@@ -6,27 +6,27 @@ 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 { faker } from '@dxos/random';
9
+ import { View } from '@dxos/echo';
10
+ import { random } 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';
26
26
 
27
- const generator = faker as any as ValueGenerator;
27
+ const generator = random as any as ValueGenerator;
28
28
 
29
- faker.seed(1);
29
+ random.seed(1);
30
30
 
31
31
  const DefaultStory = () => {
32
32
  const client = useClient();
@@ -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,93 @@ 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';
20
-
19
+ import { composable, composableProps, getHashStyles } from '@dxos/ui-theme';
21
20
  import '@dxos/react-ui-graph/styles/graph.css';
22
21
 
23
- export type D3ForceGraphProps = ThemedClassName<
24
- {
25
- model?: SpaceGraphModel;
26
- match?: RegExp;
27
- selection?: SelectionModel;
28
- grid?: boolean;
29
- } & Pick<GraphProps, 'drag'>
30
- >;
22
+ export type D3ForceGraphProps = {
23
+ model?: SpaceGraphModel;
24
+ match?: RegExp;
25
+ selection?: SelectionModel;
26
+ grid?: boolean;
27
+ } & Pick<GraphProps, 'drag'> &
28
+ ComponentPropsWithoutRef<'div'>;
29
+
30
+ const EMPTY_ATOM = Atom.make<{ nodes: SpaceGraphNode[]; edges: SpaceGraphEdge[] }>({ nodes: [], edges: [] });
31
+
32
+ export const D3ForceGraph = composable<HTMLDivElement, D3ForceGraphProps>(
33
+ ({ model, selection: _selection, grid, drag, ...props }, forwardedRef) => {
34
+ // TODO(wittjosiah): This should go into Graph.tsx but for some reason doesn't work.
35
+ useAtomValue(model?.graphAtom ?? EMPTY_ATOM);
31
36
 
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;
37
+ const svgRef = useRef<SVGContext>(null);
38
+ const projector = useMemo<GraphForceProjector | undefined>(() => {
39
+ if (svgRef.current) {
40
+ return new GraphForceProjector(svgRef.current, {
41
+ attributes: {
42
+ linkForce: (edge) => {
43
+ // TODO(burdon): Check type (currently assumes Employee property).
44
+ // Edge shouldn't contribute to force if it's not active.
45
+ return edge.data?.object?.active !== false;
46
+ },
42
47
  },
43
- },
44
- forces: {
45
- point: {
46
- strength: 0.01,
48
+ forces: {
49
+ point: {
50
+ strength: 0.01,
51
+ },
47
52
  },
48
- },
49
- });
50
- }
51
- }, [context.current]);
53
+ });
54
+ }
55
+ }, []);
52
56
 
53
- const graph = useRef<GraphController>(null);
54
- const selection = useMemo(() => _selection ?? new SelectionModel(), [_selection]);
55
- useEffect(() => selection.subscribe(() => graph.current?.repaint()), [selection]);
57
+ const graph = useRef<GraphController>(null);
58
+ const selection = useMemo(() => _selection ?? new SelectionModel(), [_selection]);
59
+ useEffect(() => selection.subscribe(() => graph.current?.repaint()), [selection]);
56
60
 
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
- );
61
+ const handleSelect = useCallback<NonNullable<GraphProps['onSelect']>>(
62
+ (node) => {
63
+ if (selection.contains(node.id)) {
64
+ selection.remove(node.id);
65
+ } else {
66
+ selection.add(node.id);
67
+ }
68
+ },
69
+ [selection],
70
+ );
67
71
 
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,
72
+ return (
73
+ <div {...composableProps(props, { classNames: 'dx-container' })} ref={forwardedRef}>
74
+ <SVG.Root ref={svgRef}>
75
+ <SVG.Markers />
76
+ {grid && <SVG.Grid axis />}
77
+ <SVG.Zoom extent={[1 / 2, 2]}>
78
+ <SVG.Graph<SpaceGraphNode, SpaceGraphEdge>
79
+ drag={drag}
80
+ ref={graph}
81
+ model={model}
82
+ projector={projector}
83
+ labels={{
84
+ text: (node) => {
85
+ return node.data?.data.label ?? node.id;
89
86
  },
90
- classes: {
91
- 'dx-selected': selection.contains(node.id),
87
+ }}
88
+ attributes={{
89
+ node: (node: GraphLayoutNode<SpaceGraphNode>) => {
90
+ const obj = node.data?.data.object;
91
+ return {
92
+ data: {
93
+ color: getHashStyles(obj && Obj.getTypename(obj))?.hue,
94
+ },
95
+ classes: {
96
+ 'dx-selected': selection.contains(node.id),
97
+ },
98
+ };
92
99
  },
93
- };
94
- },
95
- }}
96
- onSelect={handleSelect}
97
- />
98
- </SVG.Zoom>
99
- </SVG.Root>
100
- );
101
- };
100
+ }}
101
+ onSelect={handleSelect}
102
+ />
103
+ </SVG.Zoom>
104
+ </SVG.Root>
105
+ </div>
106
+ );
107
+ },
108
+ );