@dxos/plugin-explorer 0.8.4-main.ae835ea → 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 (119) hide show
  1. package/dist/lib/browser/{chunk-UBHZGWZQ.mjs → chunk-LSUP47BZ.mjs} +2 -2
  2. package/dist/lib/browser/chunk-LSUP47BZ.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +11342 -87
  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 -5
  8. package/dist/lib/browser/types/index.mjs.map +4 -4
  9. package/dist/lib/node-esm/{chunk-UXZM5VJB.mjs → chunk-EN3JZNEY.mjs} +2 -2
  10. package/dist/lib/node-esm/chunk-EN3JZNEY.mjs.map +7 -0
  11. package/dist/lib/node-esm/index.mjs +11342 -87
  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 -5
  16. package/dist/lib/node-esm/types/index.mjs.map +4 -4
  17. package/dist/types/src/ExplorerPlugin.d.ts +2 -1
  18. package/dist/types/src/ExplorerPlugin.d.ts.map +1 -1
  19. package/dist/types/src/capabilities/index.d.ts +2 -2
  20. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  21. package/dist/types/src/capabilities/react-surface.d.ts +3 -2
  22. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  23. package/dist/types/src/components/Graph/D3ForceGraph.d.ts +10 -5
  24. package/dist/types/src/components/Graph/D3ForceGraph.d.ts.map +1 -1
  25. package/dist/types/src/components/Graph/D3ForceGraph.stories.d.ts +8 -2
  26. package/dist/types/src/components/Graph/D3ForceGraph.stories.d.ts.map +1 -1
  27. package/dist/types/src/components/Graph/ForceGraph.stories.d.ts +1 -1
  28. package/dist/types/src/components/Graph/ForceGraph.stories.d.ts.map +1 -1
  29. package/dist/types/src/components/Graph/adapter.d.ts +1 -1
  30. package/dist/types/src/components/Graph/adapter.d.ts.map +1 -1
  31. package/dist/types/src/components/Graph/testing.d.ts.map +1 -1
  32. package/dist/types/src/components/Tree/Tree.d.ts.map +1 -1
  33. package/dist/types/src/components/Tree/Tree.stories.d.ts.map +1 -1
  34. package/dist/types/src/components/Tree/testing/generator.d.ts.map +1 -1
  35. package/dist/types/src/components/Tree/types/tree.d.ts +18 -16
  36. package/dist/types/src/components/Tree/types/tree.d.ts.map +1 -1
  37. package/dist/types/src/components/Tree/types/types.d.ts +1 -1
  38. package/dist/types/src/components/Tree/types/types.d.ts.map +1 -1
  39. package/dist/types/src/components/index.d.ts +0 -4
  40. package/dist/types/src/components/index.d.ts.map +1 -1
  41. package/dist/types/src/containers/ExplorerContainer/ExplorerContainer.d.ts +6 -0
  42. package/dist/types/src/containers/ExplorerContainer/ExplorerContainer.d.ts.map +1 -0
  43. package/dist/types/src/containers/ExplorerContainer/index.d.ts +3 -0
  44. package/dist/types/src/containers/ExplorerContainer/index.d.ts.map +1 -0
  45. package/dist/types/src/containers/index.d.ts +3 -0
  46. package/dist/types/src/containers/index.d.ts.map +1 -0
  47. package/dist/types/src/hooks/useGraphModel.d.ts.map +1 -1
  48. package/dist/types/src/meta.d.ts +2 -2
  49. package/dist/types/src/meta.d.ts.map +1 -1
  50. package/dist/types/src/translations.d.ts +31 -22
  51. package/dist/types/src/translations.d.ts.map +1 -1
  52. package/dist/types/src/types/ExplorerAction.d.ts +1 -18
  53. package/dist/types/src/types/ExplorerAction.d.ts.map +1 -1
  54. package/dist/types/src/types/Graph.d.ts +14 -24
  55. package/dist/types/src/types/Graph.d.ts.map +1 -1
  56. package/dist/types/tsconfig.tsbuildinfo +1 -1
  57. package/package.json +59 -45
  58. package/src/ExplorerPlugin.tsx +42 -54
  59. package/src/capabilities/index.ts +2 -3
  60. package/src/capabilities/react-surface.tsx +22 -18
  61. package/src/components/Chart/Chart.stories.tsx +3 -3
  62. package/src/components/Globe/Globe.stories.tsx +3 -3
  63. package/src/components/Graph/D3ForceGraph.stories.tsx +27 -21
  64. package/src/components/Graph/D3ForceGraph.tsx +82 -74
  65. package/src/components/Graph/ForceGraph.stories.tsx +27 -21
  66. package/src/components/Graph/adapter.ts +14 -8
  67. package/src/components/Graph/testing.ts +11 -8
  68. package/src/components/Tree/Tree.stories.tsx +7 -4
  69. package/src/components/Tree/Tree.tsx +8 -3
  70. package/src/components/Tree/testing/generator.ts +4 -2
  71. package/src/components/Tree/types/tree.test.ts +5 -3
  72. package/src/components/Tree/types/tree.ts +41 -20
  73. package/src/components/Tree/types/types.ts +1 -1
  74. package/src/components/index.ts +0 -4
  75. package/src/containers/ExplorerContainer/ExplorerContainer.tsx +53 -0
  76. package/src/containers/ExplorerContainer/index.ts +7 -0
  77. package/src/containers/index.ts +7 -0
  78. package/src/hooks/useGraphModel.ts +17 -10
  79. package/src/meta.ts +3 -3
  80. package/src/translations.ts +15 -12
  81. package/src/types/ExplorerAction.ts +10 -19
  82. package/src/types/Graph.ts +25 -21
  83. package/src/typings.d.ts +8 -0
  84. package/dist/lib/browser/ExplorerContainer-L5RVUJRL.mjs +0 -50
  85. package/dist/lib/browser/ExplorerContainer-L5RVUJRL.mjs.map +0 -7
  86. package/dist/lib/browser/chunk-2MKBRIUT.mjs +0 -31
  87. package/dist/lib/browser/chunk-2MKBRIUT.mjs.map +0 -7
  88. package/dist/lib/browser/chunk-6BVXZQPP.mjs +0 -188
  89. package/dist/lib/browser/chunk-6BVXZQPP.mjs.map +0 -7
  90. package/dist/lib/browser/chunk-BGNRYZUN.mjs +0 -79
  91. package/dist/lib/browser/chunk-BGNRYZUN.mjs.map +0 -7
  92. package/dist/lib/browser/chunk-CRN65FY3.mjs +0 -11089
  93. package/dist/lib/browser/chunk-CRN65FY3.mjs.map +0 -7
  94. package/dist/lib/browser/chunk-UBHZGWZQ.mjs.map +0 -7
  95. package/dist/lib/browser/intent-resolver-FX5H52QN.mjs +0 -31
  96. package/dist/lib/browser/intent-resolver-FX5H52QN.mjs.map +0 -7
  97. package/dist/lib/browser/react-surface-VS3ZFL2Y.mjs +0 -35
  98. package/dist/lib/browser/react-surface-VS3ZFL2Y.mjs.map +0 -7
  99. package/dist/lib/node-esm/ExplorerContainer-BBLPHH7K.mjs +0 -51
  100. package/dist/lib/node-esm/ExplorerContainer-BBLPHH7K.mjs.map +0 -7
  101. package/dist/lib/node-esm/chunk-3ODK27PU.mjs +0 -33
  102. package/dist/lib/node-esm/chunk-3ODK27PU.mjs.map +0 -7
  103. package/dist/lib/node-esm/chunk-CRSVAZNA.mjs +0 -190
  104. package/dist/lib/node-esm/chunk-CRSVAZNA.mjs.map +0 -7
  105. package/dist/lib/node-esm/chunk-RSZFBKZM.mjs +0 -11091
  106. package/dist/lib/node-esm/chunk-RSZFBKZM.mjs.map +0 -7
  107. package/dist/lib/node-esm/chunk-TQESRBUJ.mjs +0 -80
  108. package/dist/lib/node-esm/chunk-TQESRBUJ.mjs.map +0 -7
  109. package/dist/lib/node-esm/chunk-UXZM5VJB.mjs.map +0 -7
  110. package/dist/lib/node-esm/intent-resolver-RGBBXXYM.mjs +0 -32
  111. package/dist/lib/node-esm/intent-resolver-RGBBXXYM.mjs.map +0 -7
  112. package/dist/lib/node-esm/react-surface-SXPT2T37.mjs +0 -36
  113. package/dist/lib/node-esm/react-surface-SXPT2T37.mjs.map +0 -7
  114. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  115. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  116. package/dist/types/src/components/ExplorerContainer.d.ts +0 -9
  117. package/dist/types/src/components/ExplorerContainer.d.ts.map +0 -1
  118. package/src/capabilities/intent-resolver.ts +0 -21
  119. package/src/components/ExplorerContainer.tsx +0 -54
package/package.json CHANGED
@@ -1,31 +1,43 @@
1
1
  {
2
2
  "name": "@dxos/plugin-explorer",
3
- "version": "0.8.4-main.ae835ea",
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",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/dxos/dxos"
10
+ },
7
11
  "license": "MIT",
8
12
  "author": "DXOS.org",
9
13
  "sideEffects": true,
10
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
+ },
11
23
  "exports": {
12
24
  ".": {
13
25
  "source": "./src/index.ts",
14
- "types": "./dist/types/src/index.d.ts",
15
26
  "browser": "./dist/lib/browser/index.mjs",
16
- "node": "./dist/lib/node-esm/index.mjs"
27
+ "node": "./dist/lib/node-esm/index.mjs",
28
+ "types": "./dist/types/src/index.d.ts"
17
29
  },
18
30
  "./meta": {
19
31
  "source": "./src/meta.ts",
20
- "types": "./dist/types/src/meta.d.ts",
21
32
  "browser": "./dist/lib/browser/meta.mjs",
22
- "node": "./dist/lib/node-esm/meta.mjs"
33
+ "node": "./dist/lib/node-esm/meta.mjs",
34
+ "types": "./dist/types/src/meta.d.ts"
23
35
  },
24
36
  "./types": {
25
37
  "source": "./src/types/index.ts",
26
- "types": "./dist/types/src/types/index.d.ts",
27
38
  "browser": "./dist/lib/browser/types/index.mjs",
28
- "node": "./dist/lib/node-esm/types/index.mjs"
39
+ "node": "./dist/lib/node-esm/types/index.mjs",
40
+ "types": "./dist/types/src/types/index.d.ts"
29
41
  }
30
42
  },
31
43
  "types": "dist/types/src/index.d.ts",
@@ -45,60 +57,62 @@
45
57
  ],
46
58
  "dependencies": {
47
59
  "3d-force-graph": "^1.76.1",
60
+ "@effect-atom/atom-react": "^0.5.0",
48
61
  "@observablehq/plot": "^0.6.11",
49
- "@preact-signals/safe-react": "^0.9.0",
50
- "@preact/signals-core": "^1.12.1",
51
62
  "d3": "^7.9.0",
52
- "effect": "3.18.3",
63
+ "effect": "3.20.0",
53
64
  "force-graph": "^1.49.4",
54
65
  "lodash.defaultsdeep": "^4.6.1",
55
66
  "react-resize-detector": "^11.0.1",
56
67
  "three": "^0.178.0",
57
68
  "topojson-client": "^3.1.0",
58
- "@dxos/app-framework": "0.8.4-main.ae835ea",
59
- "@dxos/client": "0.8.4-main.ae835ea",
60
- "@dxos/async": "0.8.4-main.ae835ea",
61
- "@dxos/graph": "0.8.4-main.ae835ea",
62
- "@dxos/invariant": "0.8.4-main.ae835ea",
63
- "@dxos/echo-query": "0.8.4-main.ae835ea",
64
- "@dxos/live-object": "0.8.4-main.ae835ea",
65
- "@dxos/log": "0.8.4-main.ae835ea",
66
- "@dxos/plugin-client": "0.8.4-main.ae835ea",
67
- "@dxos/plugin-graph": "0.8.4-main.ae835ea",
68
- "@dxos/plugin-search": "0.8.4-main.ae835ea",
69
- "@dxos/plugin-space": "0.8.4-main.ae835ea",
70
- "@dxos/react-client": "0.8.4-main.ae835ea",
71
- "@dxos/react-ui-components": "0.8.4-main.ae835ea",
72
- "@dxos/react-ui-attention": "0.8.4-main.ae835ea",
73
- "@dxos/echo": "0.8.4-main.ae835ea",
74
- "@dxos/react-ui-graph": "0.8.4-main.ae835ea",
75
- "@dxos/react-ui-stack": "0.8.4-main.ae835ea",
76
- "@dxos/schema": "0.8.4-main.ae835ea",
77
- "@dxos/util": "0.8.4-main.ae835ea"
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"
78
92
  },
79
93
  "devDependencies": {
80
94
  "@types/d3": "^7.4.3",
81
95
  "@types/d3-hierarchy": "^3.1.6",
82
96
  "@types/lodash.defaultsdeep": "^4.6.6",
83
- "@types/react": "~19.2.2",
84
- "@types/react-dom": "~19.2.2",
97
+ "@types/react": "~19.2.7",
98
+ "@types/react-dom": "~19.2.3",
85
99
  "@types/topojson-client": "^3.1.4",
86
100
  "@types/topojson-specification": "^1.0.5",
87
- "react": "~19.2.0",
88
- "react-dom": "~19.2.0",
89
- "vite": "7.1.9",
90
- "@dxos/echo-generator": "0.8.4-main.ae835ea",
91
- "@dxos/random": "0.8.4-main.ae835ea",
92
- "@dxos/react-ui": "0.8.4-main.ae835ea",
93
- "@dxos/react-ui-theme": "0.8.4-main.ae835ea",
94
- "@dxos/storybook-utils": "0.8.4-main.ae835ea"
101
+ "react": "~19.2.3",
102
+ "react-dom": "~19.2.3",
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"
95
109
  },
96
110
  "peerDependencies": {
97
- "effect": "^3.13.3",
98
- "react": "^19.0.0",
99
- "react-dom": "^19.0.0",
100
- "@dxos/react-ui-theme": "0.8.4-main.ae835ea",
101
- "@dxos/react-ui": "0.8.4-main.ae835ea"
111
+ "effect": "3.20.0",
112
+ "react": "~19.2.3",
113
+ "react-dom": "~19.2.3",
114
+ "@dxos/react-ui": "0.8.4-main.bcb3aa67d6",
115
+ "@dxos/ui-theme": "0.8.4-main.bcb3aa67d6"
102
116
  },
103
117
  "publishConfig": {
104
118
  "access": "public"
@@ -2,61 +2,49 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { Capabilities, Events, contributes, createIntent, defineModule, definePlugin } from '@dxos/app-framework';
6
- import { ClientCapabilities, ClientEvents } from '@dxos/plugin-client';
7
- import { SpaceCapabilities } from '@dxos/plugin-space';
8
- import { defineObjectForm } from '@dxos/plugin-space/types';
5
+ import * as Effect from 'effect/Effect';
6
+ import * as Option from 'effect/Option';
9
7
 
10
- import { IntentResolver, ReactSurface } from './capabilities';
11
- import { meta } from './meta';
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';
12
+ import { type CreateObject } from '@dxos/plugin-space/types';
13
+ import { SpaceOperation } from '@dxos/plugin-space/operations';
14
+ import { ViewModel } from '@dxos/schema';
15
+
16
+ import { meta } from '#meta';
12
17
  import { translations } from './translations';
13
- import { ExplorerAction, Graph } from './types';
18
+ import { ExplorerAction, Graph } from '#types';
14
19
 
15
- export const ExplorerPlugin = definePlugin(meta, () => [
16
- defineModule({
17
- id: `${meta.id}/module/translations`,
18
- activatesOn: Events.SetupTranslations,
19
- activate: () => contributes(Capabilities.Translations, translations),
20
- }),
21
- defineModule({
22
- id: `${meta.id}/module/metadata`,
23
- activatesOn: Events.SetupMetadata,
24
- activate: () =>
25
- contributes(Capabilities.Metadata, {
26
- id: Graph.Graph.typename,
27
- metadata: {
28
- icon: 'ph--graph--regular',
29
- iconHue: 'green',
30
- },
31
- }),
32
- }),
33
- defineModule({
34
- id: `${meta.id}/module/object-form`,
35
- activatesOn: ClientEvents.SetupSchema,
36
- activate: () =>
37
- contributes(
38
- SpaceCapabilities.ObjectForm,
39
- defineObjectForm({
40
- objectSchema: Graph.Graph,
41
- formSchema: ExplorerAction.GraphProps,
42
- hidden: true,
43
- getIntent: (props, options) => createIntent(ExplorerAction.CreateGraph, { ...props, space: options.space }),
44
- }),
45
- ),
46
- }),
47
- defineModule({
48
- id: `${meta.id}/module/schema`,
49
- activatesOn: ClientEvents.SetupSchema,
50
- activate: () => contributes(ClientCapabilities.Schema, [Graph.Graph]),
51
- }),
52
- defineModule({
53
- id: `${meta.id}/module/react-surface`,
54
- activatesOn: Events.SetupReactSurface,
55
- activate: ReactSurface,
56
- }),
57
- defineModule({
58
- id: `${meta.id}/module/intent-resolver`,
59
- activatesOn: Events.SetupIntentResolver,
60
- activate: IntentResolver,
20
+ import { ReactSurface } from '#capabilities';
21
+
22
+ export const ExplorerPlugin = Plugin.define(meta).pipe(
23
+ AppPlugin.addMetadataModule({
24
+ metadata: {
25
+ id: Type.getTypename(Graph.Graph),
26
+ metadata: {
27
+ icon: Annotation.IconAnnotation.get(Graph.Graph).pipe(Option.getOrThrow).icon,
28
+ iconHue: Annotation.IconAnnotation.get(Graph.Graph).pipe(Option.getOrThrow).hue ?? 'white',
29
+ inputSchema: ExplorerAction.GraphProps,
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
+ });
42
+ })) satisfies CreateObject,
43
+ },
44
+ },
61
45
  }),
62
- ]);
46
+ AppPlugin.addSchemaModule({ schema: [Graph.Graph] }),
47
+ AppPlugin.addSurfaceModule({ activate: ReactSurface }),
48
+ AppPlugin.addTranslationsModule({ translations }),
49
+ Plugin.make,
50
+ );
@@ -2,7 +2,6 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { lazy } from '@dxos/app-framework';
5
+ import { Capability } from '@dxos/app-framework';
6
6
 
7
- export const IntentResolver = lazy(() => import('./intent-resolver'));
8
- export const ReactSurface = lazy(() => import('./react-surface'));
7
+ export const ReactSurface = Capability.lazy('ReactSurface', () => import('./react-surface'));
@@ -2,26 +2,30 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
+ import * as Effect from 'effect/Effect';
5
6
  import React from 'react';
6
7
 
7
- import { Capabilities, contributes, createSurface } from '@dxos/app-framework';
8
+ import { Capabilities, Capability } from '@dxos/app-framework';
9
+ import { Surface } from '@dxos/app-framework/ui';
8
10
  import { Obj } from '@dxos/echo';
9
- import { DataType } from '@dxos/schema';
11
+ import { type View } from '@dxos/echo';
10
12
 
11
- import { ExplorerContainer } from '../components';
12
- import { meta } from '../meta';
13
- import { Graph } from '../types';
13
+ import { ExplorerContainer } from '#containers';
14
+ import { meta } from '#meta';
15
+ import { Graph } from '#types';
14
16
 
15
- export default () =>
16
- contributes(
17
- Capabilities.ReactSurface,
18
- createSurface({
19
- id: `${meta.id}/article`,
20
- role: ['article', 'section'],
21
- filter: (data): data is { subject: DataType.View } =>
22
- Obj.instanceOf(DataType.View, data.subject) && Obj.instanceOf(Graph.Graph, data.subject.presentation.target),
23
- component: ({ data, role }) => {
24
- return <ExplorerContainer view={data.subject} role={role} />;
25
- },
26
- }),
27
- );
17
+ export default Capability.makeModule(() =>
18
+ Effect.succeed(
19
+ Capability.contributes(
20
+ Capabilities.ReactSurface,
21
+ Surface.create({
22
+ id: `${meta.id}.article`,
23
+ role: ['article', 'section'],
24
+ filter: (data): data is { subject: View.View } => Obj.instanceOf(Graph.Graph, data.subject),
25
+ component: ({ data, role }) => {
26
+ return <ExplorerContainer role={role} subject={data.subject} />;
27
+ },
28
+ }),
29
+ ),
30
+ ),
31
+ );
@@ -6,7 +6,7 @@ import { type Meta } from '@storybook/react-vite';
6
6
  import React from 'react';
7
7
 
8
8
  import { ClientRepeater } from '@dxos/react-client/testing';
9
- import { withTheme } from '@dxos/react-ui/testing';
9
+ import { withLayout, withTheme } from '@dxos/react-ui/testing';
10
10
 
11
11
  import CitiesData from '../../../data/cities.js';
12
12
 
@@ -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],
37
+ decorators: [withTheme(), withLayout()],
38
38
  parameters: {
39
39
  layout: 'fullscreen',
40
40
  },
@@ -10,7 +10,7 @@ import { useResizeDetector } from 'react-resize-detector';
10
10
  import { feature } from 'topojson-client';
11
11
 
12
12
  import { ClientRepeater } from '@dxos/react-client/testing';
13
- import { withTheme } from '@dxos/react-ui/testing';
13
+ 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';
@@ -80,8 +80,8 @@ const ExtendedStory = () => {
80
80
  };
81
81
 
82
82
  const meta = {
83
- title: 'plugins/plugin-explorer/Globe',
84
- decorators: [withTheme],
83
+ title: 'plugins/plugin-explorer/components/Globe',
84
+ decorators: [withTheme(), withLayout()],
85
85
  parameters: {
86
86
  layout: 'fullscreen',
87
87
  },
@@ -5,18 +5,21 @@
5
5
  import { type Meta, type StoryObj } from '@storybook/react-vite';
6
6
  import React, { useState } from 'react';
7
7
 
8
+ import { Type } from '@dxos/echo';
9
+ import { View } from '@dxos/echo';
8
10
  import { faker } from '@dxos/random';
9
11
  import { useClient } from '@dxos/react-client';
10
12
  import { type Space } from '@dxos/react-client/echo';
11
13
  import { withClientProvider } from '@dxos/react-client/testing';
12
14
  import { useAsyncEffect } from '@dxos/react-ui';
13
- import { withTheme } from '@dxos/react-ui/testing';
14
- import { DataType } from '@dxos/schema';
15
+ import { Loading, withLayout, withTheme } from '@dxos/react-ui/testing';
16
+ import { ViewModel } from '@dxos/schema';
15
17
  import { type ValueGenerator } from '@dxos/schema/testing';
16
- import { render } from '@dxos/storybook-utils';
18
+ import { withRegistry } from '@dxos/storybook-utils';
19
+ import { HasRelationship, Organization, Person, Pipeline } from '@dxos/types';
17
20
 
18
- import { useGraphModel } from '../../hooks';
19
- import { Graph } from '../../types';
21
+ import { useGraphModel } from '#hooks';
22
+ import { Graph } from '#types';
20
23
 
21
24
  import { D3ForceGraph } from './D3ForceGraph';
22
25
  import { generate } from './testing';
@@ -28,40 +31,43 @@ faker.seed(1);
28
31
  const DefaultStory = () => {
29
32
  const client = useClient();
30
33
  const [space, setSpace] = useState<Space>();
31
- const [view, setView] = useState<DataType.View>();
34
+ const [graph, setGraph] = useState<Graph.Graph>();
32
35
 
33
36
  useAsyncEffect(async () => {
34
- const space = client.spaces.default;
37
+ const space = client.spaces.get()[0];
35
38
  void generate(space, generator);
36
- const { view } = await Graph.makeView({ client, space, name: 'Test', typename: Graph.Graph.typename });
37
- space.db.add(view);
39
+ const { view } = await ViewModel.makeFromDatabase({ db: space.db, typename: Type.getTypename(Graph.Graph) });
40
+ const graph = Graph.make({ name: 'Test', view });
41
+ space.db.add(graph);
38
42
  setSpace(space);
39
- setView(view);
40
- }, []);
43
+ setGraph(graph);
44
+ }, [client]);
41
45
 
42
46
  const model = useGraphModel(space);
43
- if (!model || !space || !view) {
44
- return null;
47
+ if (!model || !space || !graph) {
48
+ return <Loading data={{ model: !!model, space: !!space, graph: !!graph }} />;
45
49
  }
46
50
 
47
51
  return <D3ForceGraph model={model} />;
48
52
  };
49
53
 
50
54
  const meta = {
51
- title: 'plugins/plugin-explorer/D3ForceGraph',
55
+ title: 'plugins/plugin-explorer/components/D3ForceGraph',
52
56
  component: D3ForceGraph,
53
- render: render(DefaultStory),
57
+ render: DefaultStory,
54
58
  decorators: [
55
- withTheme,
59
+ withRegistry,
60
+ withTheme(),
61
+ withLayout(),
56
62
  withClientProvider({
57
63
  createSpace: true,
58
64
  types: [
59
65
  Graph.Graph,
60
- DataType.View,
61
- DataType.Organization,
62
- DataType.Project,
63
- DataType.Person,
64
- DataType.HasRelationship,
66
+ View.View,
67
+ Organization.Organization,
68
+ Pipeline.Pipeline,
69
+ Person.Person,
70
+ HasRelationship.HasRelationship,
65
71
  ],
66
72
  }),
67
73
  ],
@@ -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,
@@ -15,87 +15,95 @@ import {
15
15
  SVG,
16
16
  type SVGContext,
17
17
  } from '@dxos/react-ui-graph';
18
- import { getHashStyles } from '@dxos/react-ui-theme';
19
18
  import { type SpaceGraphEdge, type SpaceGraphModel, type SpaceGraphNode } from '@dxos/schema';
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(() => graph.current?.repaint(), [selection.selected.value]);
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
+ );