@dxos/plugin-explorer 0.8.4-main.422d1c7879 → 0.8.4-main.4f23b4e393

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/neutral/ExplorerContainer-BOXGUSRG.mjs +41 -0
  2. package/dist/lib/neutral/ExplorerContainer-BOXGUSRG.mjs.map +7 -0
  3. package/dist/lib/neutral/ExplorerPlugin.mjs +26 -0
  4. package/dist/lib/neutral/ExplorerPlugin.mjs.map +7 -0
  5. package/dist/lib/neutral/capabilities/index.mjs +11 -0
  6. package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
  7. package/dist/lib/{browser/types/index.mjs → neutral/chunk-7SPMPHRS.mjs} +10 -8
  8. package/dist/lib/neutral/chunk-7SPMPHRS.mjs.map +7 -0
  9. package/dist/lib/{browser/chunk-LSUP47BZ.mjs → neutral/chunk-HPIS2WXY.mjs} +1 -1
  10. package/dist/lib/{browser/chunk-LSUP47BZ.mjs.map → neutral/chunk-HPIS2WXY.mjs.map} +2 -2
  11. package/dist/lib/{browser → neutral/components}/index.mjs +140 -240
  12. package/dist/lib/{node-esm → neutral/components}/index.mjs.map +4 -4
  13. package/dist/lib/neutral/containers/index.mjs +9 -0
  14. package/dist/lib/neutral/containers/index.mjs.map +7 -0
  15. package/dist/lib/neutral/create-object-F6TKVAGV.mjs +39 -0
  16. package/dist/lib/neutral/create-object-F6TKVAGV.mjs.map +7 -0
  17. package/dist/lib/neutral/hooks/index.mjs +45 -0
  18. package/dist/lib/neutral/hooks/index.mjs.map +7 -0
  19. package/dist/lib/neutral/index.mjs +14 -0
  20. package/dist/lib/neutral/meta.json +1 -0
  21. package/dist/lib/{browser → neutral}/meta.mjs +1 -1
  22. package/dist/lib/neutral/plugin.mjs +12 -0
  23. package/dist/lib/neutral/plugin.mjs.map +7 -0
  24. package/dist/lib/neutral/react-surface-U3JEY7V7.mjs +26 -0
  25. package/dist/lib/neutral/react-surface-U3JEY7V7.mjs.map +7 -0
  26. package/dist/lib/neutral/translations.mjs +33 -0
  27. package/dist/lib/neutral/translations.mjs.map +7 -0
  28. package/dist/lib/neutral/types/index.mjs +10 -0
  29. package/dist/types/data/cities.d.ts +4 -4
  30. package/dist/types/data/cities.d.ts.map +1 -1
  31. package/dist/types/data/countries-110m.d.ts +19 -22
  32. package/dist/types/data/countries-110m.d.ts.map +1 -1
  33. package/dist/types/src/ExplorerPlugin.d.ts +1 -0
  34. package/dist/types/src/ExplorerPlugin.d.ts.map +1 -1
  35. package/dist/types/src/ExplorerPlugin.test.d.ts +2 -0
  36. package/dist/types/src/ExplorerPlugin.test.d.ts.map +1 -0
  37. package/dist/types/src/capabilities/create-object.d.ts +11 -0
  38. package/dist/types/src/capabilities/create-object.d.ts.map +1 -0
  39. package/dist/types/src/capabilities/index.d.ts +6 -0
  40. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  41. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  42. package/dist/types/src/components/Chart/Chart.d.ts.map +1 -1
  43. package/dist/types/src/components/Chart/Chart.stories.d.ts +4 -1
  44. package/dist/types/src/components/Chart/Chart.stories.d.ts.map +1 -1
  45. package/dist/types/src/components/Globe/Globe.d.ts.map +1 -1
  46. package/dist/types/src/components/Globe/Globe.stories.d.ts +5 -2
  47. package/dist/types/src/components/Globe/Globe.stories.d.ts.map +1 -1
  48. package/dist/types/src/components/Graph/CanvasForceGraph.d.ts +13 -0
  49. package/dist/types/src/components/Graph/CanvasForceGraph.d.ts.map +1 -0
  50. package/dist/types/src/components/Graph/{D3ForceGraph.stories.d.ts → CanvasForceGraph.stories.d.ts} +3 -3
  51. package/dist/types/src/components/Graph/CanvasForceGraph.stories.d.ts.map +1 -0
  52. package/dist/types/src/components/Graph/ForceGraph.d.ts +12 -5
  53. package/dist/types/src/components/Graph/ForceGraph.d.ts.map +1 -1
  54. package/dist/types/src/components/Graph/ForceGraph.stories.d.ts +3 -1
  55. package/dist/types/src/components/Graph/ForceGraph.stories.d.ts.map +1 -1
  56. package/dist/types/src/components/Graph/{adapter.d.ts → graph-adapter.d.ts} +1 -1
  57. package/dist/types/src/components/Graph/graph-adapter.d.ts.map +1 -0
  58. package/dist/types/src/components/Graph/index.d.ts +1 -1
  59. package/dist/types/src/components/Graph/index.d.ts.map +1 -1
  60. package/dist/types/src/components/Graph/testing.d.ts.map +1 -1
  61. package/dist/types/src/components/Tree/Tree.d.ts.map +1 -1
  62. package/dist/types/src/components/Tree/Tree.stories.d.ts +5 -1
  63. package/dist/types/src/components/Tree/Tree.stories.d.ts.map +1 -1
  64. package/dist/types/src/components/Tree/layout/HierarchicalEdgeBundling.d.ts.map +1 -1
  65. package/dist/types/src/components/Tree/layout/RadialTree.d.ts.map +1 -1
  66. package/dist/types/src/components/Tree/layout/TidyTree.d.ts.map +1 -1
  67. package/dist/types/src/components/Tree/testing/generator.d.ts.map +1 -1
  68. package/dist/types/src/components/Tree/types/tree.d.ts +6 -6
  69. package/dist/types/src/components/Tree/types/tree.d.ts.map +1 -1
  70. package/dist/types/src/components/Tree/types/types.d.ts.map +1 -1
  71. package/dist/types/src/components/plot.d.ts.map +1 -1
  72. package/dist/types/src/containers/ExplorerContainer/ExplorerContainer.d.ts +1 -1
  73. package/dist/types/src/containers/ExplorerContainer/ExplorerContainer.d.ts.map +1 -1
  74. package/dist/types/src/hooks/useGraphModel.d.ts +2 -2
  75. package/dist/types/src/hooks/useGraphModel.d.ts.map +1 -1
  76. package/dist/types/src/index.d.ts +1 -3
  77. package/dist/types/src/index.d.ts.map +1 -1
  78. package/dist/types/src/plugin.d.ts +3 -0
  79. package/dist/types/src/plugin.d.ts.map +1 -0
  80. package/dist/types/src/translations.d.ts +17 -17
  81. package/dist/types/src/translations.d.ts.map +1 -1
  82. package/dist/types/src/types/Graph.d.ts +3 -4
  83. package/dist/types/src/types/Graph.d.ts.map +1 -1
  84. package/dist/types/tsconfig.tsbuildinfo +1 -1
  85. package/package.json +94 -51
  86. package/src/ExplorerPlugin.test.ts +26 -0
  87. package/src/ExplorerPlugin.tsx +6 -35
  88. package/src/capabilities/create-object.ts +36 -0
  89. package/src/capabilities/index.ts +1 -0
  90. package/src/components/Chart/Chart.stories.tsx +14 -20
  91. package/src/components/Globe/Globe.stories.tsx +17 -19
  92. package/src/components/Graph/CanvasForceGraph.stories.tsx +83 -0
  93. package/src/components/Graph/CanvasForceGraph.tsx +124 -0
  94. package/src/components/Graph/ForceGraph.stories.tsx +68 -36
  95. package/src/components/Graph/ForceGraph.tsx +104 -85
  96. package/src/components/Graph/index.ts +1 -1
  97. package/src/components/Tree/Tree.stories.tsx +40 -35
  98. package/src/components/Tree/testing/generator.ts +1 -1
  99. package/src/components/Tree/types/tree.test.ts +1 -1
  100. package/src/components/Tree/types/tree.ts +9 -9
  101. package/src/containers/ExplorerContainer/ExplorerContainer.tsx +10 -13
  102. package/src/hooks/useGraphModel.ts +10 -6
  103. package/src/index.ts +1 -4
  104. package/src/plugin.ts +9 -0
  105. package/src/translations.ts +1 -1
  106. package/src/types/ExplorerAction.ts +1 -1
  107. package/src/types/Graph.ts +2 -3
  108. package/dist/lib/browser/index.mjs.map +0 -7
  109. package/dist/lib/browser/meta.json +0 -1
  110. package/dist/lib/browser/types/index.mjs.map +0 -7
  111. package/dist/lib/node-esm/chunk-EN3JZNEY.mjs +0 -26
  112. package/dist/lib/node-esm/chunk-EN3JZNEY.mjs.map +0 -7
  113. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +0 -11
  114. package/dist/lib/node-esm/index.mjs +0 -11375
  115. package/dist/lib/node-esm/meta.json +0 -1
  116. package/dist/lib/node-esm/meta.mjs +0 -9
  117. package/dist/lib/node-esm/types/index.mjs +0 -71
  118. package/dist/lib/node-esm/types/index.mjs.map +0 -7
  119. package/dist/types/src/components/Graph/D3ForceGraph.d.ts +0 -15
  120. package/dist/types/src/components/Graph/D3ForceGraph.d.ts.map +0 -1
  121. package/dist/types/src/components/Graph/D3ForceGraph.stories.d.ts.map +0 -1
  122. package/dist/types/src/components/Graph/adapter.d.ts.map +0 -1
  123. package/src/components/Graph/D3ForceGraph.stories.tsx +0 -83
  124. package/src/components/Graph/D3ForceGraph.tsx +0 -108
  125. /package/dist/lib/{browser → neutral}/chunk-J5LGTIGS.mjs +0 -0
  126. /package/dist/lib/{browser → neutral}/chunk-J5LGTIGS.mjs.map +0 -0
  127. /package/dist/lib/{browser/meta.mjs.map → neutral/index.mjs.map} +0 -0
  128. /package/dist/lib/{node-esm → neutral}/meta.mjs.map +0 -0
  129. /package/dist/lib/{node-esm/chunk-HSLMI22Q.mjs.map → neutral/types/index.mjs.map} +0 -0
  130. /package/src/components/Graph/{adapter.ts → graph-adapter.ts} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/plugin-explorer",
3
- "version": "0.8.4-main.422d1c7879",
3
+ "version": "0.8.4-main.4f23b4e393",
4
4
  "description": "Braneframe data visualization plugin",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -13,31 +13,72 @@
13
13
  "sideEffects": true,
14
14
  "type": "module",
15
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"
16
+ "#capabilities": {
17
+ "source": "./src/capabilities/index.ts",
18
+ "types": "./dist/types/src/capabilities/index.d.ts",
19
+ "default": "./dist/lib/neutral/capabilities/index.mjs"
20
+ },
21
+ "#components": {
22
+ "source": "./src/components/index.ts",
23
+ "types": "./dist/types/src/components/index.d.ts",
24
+ "default": "./dist/lib/neutral/components/index.mjs"
25
+ },
26
+ "#containers": {
27
+ "source": "./src/containers/index.ts",
28
+ "types": "./dist/types/src/containers/index.d.ts",
29
+ "default": "./dist/lib/neutral/containers/index.mjs"
30
+ },
31
+ "#hooks": {
32
+ "source": "./src/hooks/index.ts",
33
+ "types": "./dist/types/src/hooks/index.d.ts",
34
+ "default": "./dist/lib/neutral/hooks/index.mjs"
35
+ },
36
+ "#meta": {
37
+ "source": "./src/meta.ts",
38
+ "types": "./dist/types/src/meta.d.ts",
39
+ "default": "./dist/lib/neutral/meta.mjs"
40
+ },
41
+ "#plugin": {
42
+ "source": "./src/ExplorerPlugin.tsx",
43
+ "types": "./dist/types/src/ExplorerPlugin.d.ts",
44
+ "default": "./dist/lib/neutral/ExplorerPlugin.mjs"
45
+ },
46
+ "#translations": {
47
+ "source": "./src/translations.ts",
48
+ "types": "./dist/types/src/translations.d.ts",
49
+ "default": "./dist/lib/neutral/translations.mjs"
50
+ },
51
+ "#types": {
52
+ "source": "./src/types/index.ts",
53
+ "types": "./dist/types/src/types/index.d.ts",
54
+ "default": "./dist/lib/neutral/types/index.mjs"
55
+ }
22
56
  },
23
57
  "exports": {
24
58
  ".": {
25
59
  "source": "./src/index.ts",
26
- "browser": "./dist/lib/browser/index.mjs",
27
- "node": "./dist/lib/node-esm/index.mjs",
28
- "types": "./dist/types/src/index.d.ts"
60
+ "types": "./dist/types/src/index.d.ts",
61
+ "default": "./dist/lib/neutral/index.mjs"
29
62
  },
30
- "./meta": {
31
- "source": "./src/meta.ts",
32
- "browser": "./dist/lib/browser/meta.mjs",
33
- "node": "./dist/lib/node-esm/meta.mjs",
34
- "types": "./dist/types/src/meta.d.ts"
63
+ "./components": {
64
+ "source": "./src/components/index.ts",
65
+ "types": "./dist/types/src/components/index.d.ts",
66
+ "default": "./dist/lib/neutral/components/index.mjs"
35
67
  },
36
- "./types": {
37
- "source": "./src/types/index.ts",
38
- "browser": "./dist/lib/browser/types/index.mjs",
39
- "node": "./dist/lib/node-esm/types/index.mjs",
40
- "types": "./dist/types/src/types/index.d.ts"
68
+ "./hooks": {
69
+ "source": "./src/hooks/index.ts",
70
+ "types": "./dist/types/src/hooks/index.d.ts",
71
+ "default": "./dist/lib/neutral/hooks/index.mjs"
72
+ },
73
+ "./plugin": {
74
+ "source": "./src/plugin.ts",
75
+ "types": "./dist/types/src/plugin.d.ts",
76
+ "default": "./dist/lib/neutral/plugin.mjs"
77
+ },
78
+ "./translations": {
79
+ "source": "./src/translations.ts",
80
+ "types": "./dist/types/src/translations.d.ts",
81
+ "default": "./dist/lib/neutral/translations.mjs"
41
82
  }
42
83
  },
43
84
  "types": "dist/types/src/index.d.ts",
@@ -56,29 +97,29 @@
56
97
  "react-resize-detector": "^11.0.1",
57
98
  "three": "^0.178.0",
58
99
  "topojson-client": "^3.1.0",
59
- "@dxos/app-framework": "0.8.4-main.422d1c7879",
60
- "@dxos/app-toolkit": "0.8.4-main.422d1c7879",
61
- "@dxos/client": "0.8.4-main.422d1c7879",
62
- "@dxos/async": "0.8.4-main.422d1c7879",
63
- "@dxos/echo": "0.8.4-main.422d1c7879",
64
- "@dxos/echo-query": "0.8.4-main.422d1c7879",
65
- "@dxos/graph": "0.8.4-main.422d1c7879",
66
- "@dxos/operation": "0.8.4-main.422d1c7879",
67
- "@dxos/plugin-client": "0.8.4-main.422d1c7879",
68
- "@dxos/plugin-graph": "0.8.4-main.422d1c7879",
69
- "@dxos/plugin-search": "0.8.4-main.422d1c7879",
70
- "@dxos/invariant": "0.8.4-main.422d1c7879",
71
- "@dxos/plugin-space": "0.8.4-main.422d1c7879",
72
- "@dxos/react-client": "0.8.4-main.422d1c7879",
73
- "@dxos/react-ui-attention": "0.8.4-main.422d1c7879",
74
- "@dxos/react-ui-components": "0.8.4-main.422d1c7879",
75
- "@dxos/react-ui-graph": "0.8.4-main.422d1c7879",
76
- "@dxos/log": "0.8.4-main.422d1c7879",
77
- "@dxos/schema": "0.8.4-main.422d1c7879",
78
- "@dxos/react-ui-mosaic": "0.8.4-main.422d1c7879",
79
- "@dxos/react-ui-stack": "0.8.4-main.422d1c7879",
80
- "@dxos/types": "0.8.4-main.422d1c7879",
81
- "@dxos/util": "0.8.4-main.422d1c7879"
100
+ "@dxos/app-framework": "0.8.4-main.4f23b4e393",
101
+ "@dxos/app-toolkit": "0.8.4-main.4f23b4e393",
102
+ "@dxos/client": "0.8.4-main.4f23b4e393",
103
+ "@dxos/async": "0.8.4-main.4f23b4e393",
104
+ "@dxos/echo": "0.8.4-main.4f23b4e393",
105
+ "@dxos/graph": "0.8.4-main.4f23b4e393",
106
+ "@dxos/compute": "0.8.4-main.4f23b4e393",
107
+ "@dxos/echo-query": "0.8.4-main.4f23b4e393",
108
+ "@dxos/log": "0.8.4-main.4f23b4e393",
109
+ "@dxos/plugin-client": "0.8.4-main.4f23b4e393",
110
+ "@dxos/invariant": "0.8.4-main.4f23b4e393",
111
+ "@dxos/plugin-graph": "0.8.4-main.4f23b4e393",
112
+ "@dxos/plugin-search": "0.8.4-main.4f23b4e393",
113
+ "@dxos/plugin-space": "0.8.4-main.4f23b4e393",
114
+ "@dxos/react-client": "0.8.4-main.4f23b4e393",
115
+ "@dxos/react-ui-attention": "0.8.4-main.4f23b4e393",
116
+ "@dxos/react-ui-components": "0.8.4-main.4f23b4e393",
117
+ "@dxos/react-ui-graph": "0.8.4-main.4f23b4e393",
118
+ "@dxos/react-ui-mosaic": "0.8.4-main.4f23b4e393",
119
+ "@dxos/schema": "0.8.4-main.4f23b4e393",
120
+ "@dxos/react-ui-stack": "0.8.4-main.4f23b4e393",
121
+ "@dxos/types": "0.8.4-main.4f23b4e393",
122
+ "@dxos/util": "0.8.4-main.4f23b4e393"
82
123
  },
83
124
  "devDependencies": {
84
125
  "@types/d3": "^7.4.3",
@@ -90,19 +131,21 @@
90
131
  "@types/topojson-specification": "^1.0.5",
91
132
  "react": "~19.2.3",
92
133
  "react-dom": "~19.2.3",
93
- "vite": "^7.1.11",
94
- "@dxos/random": "0.8.4-main.422d1c7879",
95
- "@dxos/echo-generator": "0.8.4-main.422d1c7879",
96
- "@dxos/react-ui": "0.8.4-main.422d1c7879",
97
- "@dxos/storybook-utils": "0.8.4-main.422d1c7879",
98
- "@dxos/ui-theme": "0.8.4-main.422d1c7879"
134
+ "vite": "^8.0.10",
135
+ "@dxos/echo-generator": "0.8.4-main.4f23b4e393",
136
+ "@dxos/plugin-preview": "0.8.4-main.4f23b4e393",
137
+ "@dxos/plugin-testing": "0.8.4-main.4f23b4e393",
138
+ "@dxos/random": "0.8.4-main.4f23b4e393",
139
+ "@dxos/react-ui": "0.8.4-main.4f23b4e393",
140
+ "@dxos/storybook-utils": "0.8.4-main.4f23b4e393",
141
+ "@dxos/ui-theme": "0.8.4-main.4f23b4e393"
99
142
  },
100
143
  "peerDependencies": {
101
144
  "effect": "3.20.0",
102
145
  "react": "~19.2.3",
103
146
  "react-dom": "~19.2.3",
104
- "@dxos/react-ui": "0.8.4-main.422d1c7879",
105
- "@dxos/ui-theme": "0.8.4-main.422d1c7879"
147
+ "@dxos/react-ui": "0.8.4-main.4f23b4e393",
148
+ "@dxos/ui-theme": "0.8.4-main.4f23b4e393"
106
149
  },
107
150
  "publishConfig": {
108
151
  "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/plugin';
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('CreateObject'), moduleId('schema'), moduleId('ReactSurface')]),
24
+ );
25
+ });
26
+ });
@@ -2,49 +2,20 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import * as Effect from 'effect/Effect';
6
- import * as Option from 'effect/Option';
7
-
8
5
  import { Plugin } from '@dxos/app-framework';
9
6
  import { AppPlugin } from '@dxos/app-toolkit';
10
- import { Annotation, Type } from '@dxos/echo';
11
- import { Operation } from '@dxos/operation';
12
- import { SpaceOperation } from '@dxos/plugin-space/operations';
13
- import { type CreateObject } from '@dxos/plugin-space/types';
14
- import { ViewModel } from '@dxos/schema';
15
7
 
16
- import { ReactSurface } from '#capabilities';
8
+ import { CreateObject, ReactSurface } from '#capabilities';
17
9
  import { meta } from '#meta';
18
- import { ExplorerAction, Graph } from '#types';
19
-
20
- import { translations } from './translations';
10
+ import { translations } from '#translations';
11
+ import { Graph } from '#types';
21
12
 
22
13
  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
- },
45
- }),
14
+ AppPlugin.addCreateObjectModule({ activate: CreateObject }),
46
15
  AppPlugin.addSchemaModule({ schema: [Graph.Graph] }),
47
16
  AppPlugin.addSurfaceModule({ activate: ReactSurface }),
48
17
  AppPlugin.addTranslationsModule({ translations }),
49
18
  Plugin.make,
50
19
  );
20
+
21
+ export default ExplorerPlugin;
@@ -0,0 +1,36 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import * as Effect from 'effect/Effect';
6
+
7
+ import { Capability } from '@dxos/app-framework';
8
+ import { Operation } from '@dxos/compute';
9
+ import { Type } from '@dxos/echo';
10
+ import { SpaceOperation } from '@dxos/plugin-space';
11
+ import { SpaceCapabilities } from '@dxos/plugin-space';
12
+ import { ViewModel } from '@dxos/schema';
13
+
14
+ import { ExplorerAction, Graph } from '#types';
15
+
16
+ export default Capability.makeModule(
17
+ Effect.fnUntraced(function* () {
18
+ return Capability.contributes(SpaceCapabilities.CreateObjectEntry, {
19
+ id: Type.getTypename(Graph.Graph),
20
+ inputSchema: ExplorerAction.GraphProps,
21
+ createObject: (props, options) =>
22
+ Effect.gen(function* () {
23
+ const object = yield* Effect.promise(async () => {
24
+ const { view } = await ViewModel.makeFromDatabase({ db: options.db, typename: props.typename });
25
+ return Graph.make({ name: props.name, view });
26
+ });
27
+ return yield* Operation.invoke(SpaceOperation.AddObject, {
28
+ object,
29
+ target: options.target,
30
+ hidden: true,
31
+ targetNodeId: options.targetNodeId,
32
+ });
33
+ }),
34
+ });
35
+ }),
36
+ );
@@ -4,4 +4,5 @@
4
4
 
5
5
  import { Capability } from '@dxos/app-framework';
6
6
 
7
+ export const CreateObject = Capability.lazy('CreateObject', () => import('./create-object'));
7
8
  export const ReactSurface = Capability.lazy('ReactSurface', () => import('./react-surface'));
@@ -2,41 +2,35 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { type Meta } from '@storybook/react-vite';
5
+ import { type Meta, type StoryObj } from '@storybook/react-vite';
6
6
  import React from 'react';
7
7
 
8
- import { ClientRepeater } from '@dxos/react-client/testing';
9
8
  import { withLayout, withTheme } from '@dxos/react-ui/testing';
10
9
 
11
10
  import CitiesData from '../../../data/cities.js';
12
11
  import { Chart } from './Chart';
13
12
 
14
- // TODO(burdon): Generate data with geo lat/lng.
15
- // TODO(burdon): How to provide geo service via agent?
13
+ const items = CitiesData.features.map((feature: any) => ({
14
+ x: feature.geometry.coordinates[0],
15
+ y: feature.geometry.coordinates[1],
16
+ }));
16
17
 
17
- const Story = () => {
18
- if (!CitiesData) {
19
- return null;
20
- }
21
-
22
- const items = CitiesData.features.map((feature: any) => ({
23
- x: feature.geometry.coordinates[0],
24
- y: feature.geometry.coordinates[1],
25
- }));
26
-
27
- return <Chart items={items} accessor={(obj) => ({ x: obj.x, y: obj.y })} options={{ stroke: 'blue' }} />;
28
- };
29
-
30
- // TODO(burdon): Change to decorator.
31
- export const Default = () => <ClientRepeater component={Story} />;
18
+ const DefaultStory = () => (
19
+ <Chart items={items} accessor={(obj) => ({ x: obj.x, y: obj.y })} options={{ stroke: 'blue' }} />
20
+ );
32
21
 
33
22
  const meta = {
34
23
  title: 'plugins/plugin-explorer/components/Chart',
35
24
  component: Chart,
36
- decorators: [withTheme(), withLayout()],
25
+ render: DefaultStory,
26
+ decorators: [withTheme(), withLayout({ layout: 'fullscreen' })],
37
27
  parameters: {
38
28
  layout: 'fullscreen',
39
29
  },
40
30
  } satisfies Meta<typeof Chart>;
41
31
 
42
32
  export default meta;
33
+
34
+ type Story = StoryObj<typeof meta>;
35
+
36
+ export const Default: Story = {};
@@ -3,13 +3,12 @@
3
3
  //
4
4
 
5
5
  import { dot, geo, graticule, plot, sphere } from '@observablehq/plot';
6
- import { type Meta } from '@storybook/react-vite';
6
+ import { type Meta, type StoryObj } from '@storybook/react-vite';
7
7
  import { geoCircle } from 'd3';
8
8
  import React, { useEffect } from 'react';
9
9
  import { useResizeDetector } from 'react-resize-detector';
10
10
  import { feature } from 'topojson-client';
11
11
 
12
- import { ClientRepeater } from '@dxos/react-client/testing';
13
12
  import { withLayout, withTheme } from '@dxos/react-ui/testing';
14
13
 
15
14
  import CitiesData from '../../../data/cities.js';
@@ -19,14 +18,12 @@ import { Globe } from './Globe';
19
18
  // TODO(burdon): Generate data with geo lat/lng.
20
19
  // TODO(burdon): How to provide geo service via agent?
21
20
 
22
- const DefaultStory = () => {
23
- const items = CitiesData.features.map((feature: any) => ({
24
- lat: feature.geometry.coordinates[0],
25
- lng: feature.geometry.coordinates[1],
26
- }));
21
+ const items = CitiesData.features.map((feature: any) => ({
22
+ lat: feature.geometry.coordinates[0],
23
+ lng: feature.geometry.coordinates[1],
24
+ }));
27
25
 
28
- return <Globe items={items} />;
29
- };
26
+ const DefaultStory = () => <Globe items={items} />;
30
27
 
31
28
  const ExtendedStory = () => {
32
29
  const { ref: containerRef, width = 0, height = 0 } = useResizeDetector({ refreshRate: 200 });
@@ -36,11 +33,6 @@ const ExtendedStory = () => {
36
33
  }
37
34
 
38
35
  const land = feature(CountriesData as any, CountriesData.objects.land as any);
39
- const items = CitiesData.features.map((feature: any) => ({
40
- lat: feature.geometry.coordinates[0],
41
- lng: feature.geometry.coordinates[1],
42
- }));
43
-
44
36
  const city = items[0];
45
37
  const circle = geoCircle().center([city.lat, city.lng]).radius(16)();
46
38
 
@@ -49,7 +41,6 @@ const ExtendedStory = () => {
49
41
  const drawing = plot({
50
42
  // https://observablehq.com/plot/features/projections
51
43
  projection: { type: 'orthographic', rotate: [-city.lat + 30, -30] },
52
- // projection: { type: 'equirectangular', rotate: [-140, -30] },
53
44
  width,
54
45
  height,
55
46
  style: {
@@ -80,14 +71,21 @@ const ExtendedStory = () => {
80
71
 
81
72
  const meta = {
82
73
  title: 'plugins/plugin-explorer/components/Globe',
83
- decorators: [withTheme(), withLayout()],
74
+ component: Globe,
75
+ decorators: [withTheme(), withLayout({ layout: 'fullscreen' })],
84
76
  parameters: {
85
77
  layout: 'fullscreen',
86
78
  },
87
- } satisfies Meta;
79
+ } satisfies Meta<typeof Globe>;
88
80
 
89
81
  export default meta;
90
82
 
91
- export const Default = () => <ClientRepeater component={DefaultStory} createSpace />;
83
+ type Story = StoryObj<typeof meta>;
92
84
 
93
- export const Extended = () => <ClientRepeater component={ExtendedStory} createSpace />;
85
+ export const Default: Story = {
86
+ render: DefaultStory,
87
+ };
88
+
89
+ export const Extended: Story = {
90
+ render: ExtendedStory,
91
+ };
@@ -0,0 +1,83 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { type Meta, type StoryObj } from '@storybook/react-vite';
6
+ import * as Effect from 'effect/Effect';
7
+ import React from 'react';
8
+
9
+ import { withPluginManager } from '@dxos/app-framework/testing';
10
+ import { Type, View } from '@dxos/echo';
11
+ import { ClientPlugin } from '@dxos/plugin-client/plugin';
12
+ import { initializeIdentity } from '@dxos/plugin-client/testing';
13
+ import { corePlugins } from '@dxos/plugin-testing';
14
+ import { random } from '@dxos/random';
15
+ import { useSpaces } from '@dxos/react-client/echo';
16
+ import { Loading, withLayout, withTheme } from '@dxos/react-ui/testing';
17
+ import { ViewModel } from '@dxos/schema';
18
+ import { type ValueGenerator } from '@dxos/schema/testing';
19
+ import { HasRelationship, Organization, Person, Pipeline } from '@dxos/types';
20
+
21
+ import { useGraphModel } from '#hooks';
22
+ import { Graph } from '#types';
23
+
24
+ import { CanvasForceGraph } from './CanvasForceGraph';
25
+ import { generate } from './testing';
26
+
27
+ const generator = random as any as ValueGenerator;
28
+
29
+ random.seed(1);
30
+
31
+ const DefaultStory = () => {
32
+ const [space] = useSpaces();
33
+ const model = useGraphModel(space?.db);
34
+ if (!space || !model) {
35
+ return <Loading data={{ space: !!space, model: !!model }} />;
36
+ }
37
+
38
+ return <CanvasForceGraph model={model} />;
39
+ };
40
+
41
+ const meta = {
42
+ title: 'plugins/plugin-explorer/components/CanvasForceGraph',
43
+ component: CanvasForceGraph,
44
+ render: DefaultStory,
45
+ decorators: [
46
+ withTheme(),
47
+ withLayout({ layout: 'fullscreen' }),
48
+ withPluginManager({
49
+ plugins: [
50
+ ...corePlugins(),
51
+ ClientPlugin({
52
+ types: [
53
+ Graph.Graph,
54
+ View.View,
55
+ HasRelationship.HasRelationship,
56
+ Organization.Organization,
57
+ Pipeline.Pipeline,
58
+ Person.Person,
59
+ ],
60
+ onClientInitialized: ({ client }) =>
61
+ Effect.gen(function* () {
62
+ const { personalSpace } = yield* initializeIdentity(client);
63
+ yield* Effect.promise(() => generate(personalSpace, generator));
64
+ const { view } = yield* Effect.promise(() =>
65
+ ViewModel.makeFromDatabase({ db: personalSpace.db, typename: Type.getTypename(Graph.Graph) }),
66
+ );
67
+ personalSpace.db.add(Graph.make({ name: 'Test', view }));
68
+ yield* Effect.promise(() => personalSpace.db.flush({ indexes: true }));
69
+ }),
70
+ }),
71
+ ],
72
+ }),
73
+ ],
74
+ parameters: {
75
+ layout: 'fullscreen',
76
+ },
77
+ } satisfies Meta<typeof CanvasForceGraph>;
78
+
79
+ export default meta;
80
+
81
+ type Story = StoryObj<typeof meta>;
82
+
83
+ export const Default: Story = {};
@@ -0,0 +1,124 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { forceLink, forceManyBody } from 'd3';
6
+ import NativeForceGraph from 'force-graph';
7
+ import React, {
8
+ type ComponentPropsWithoutRef,
9
+ type Ref,
10
+ RefObject,
11
+ useCallback,
12
+ useEffect,
13
+ useRef,
14
+ useState,
15
+ } from 'react';
16
+ import { useResizeDetector } from 'react-resize-detector';
17
+
18
+ import { type SpaceGraphModel } from '@dxos/schema';
19
+ import { composable, composableProps } from '@dxos/ui-theme';
20
+
21
+ import { GraphAdapter } from './graph-adapter';
22
+
23
+ export type CanvasForceGraphProps = {
24
+ model?: SpaceGraphModel;
25
+ match?: RegExp;
26
+ };
27
+
28
+ /**
29
+ * More performance optimized version of the ForceGraph.
30
+ */
31
+ export const CanvasForceGraph = composable<HTMLDivElement, CanvasForceGraphProps>(
32
+ ({ model, match, onClick, ...props }, forwardedRef) => {
33
+ const { ref: resizeRef, width, height } = useResizeDetector({ refreshRate: 200 });
34
+ const setRef = useCallback(
35
+ (node: HTMLDivElement | null) => {
36
+ resizeRef(node);
37
+ assignRef(forwardedRef, node);
38
+ },
39
+ [resizeRef, forwardedRef],
40
+ );
41
+
42
+ const rootRef = useRef<HTMLDivElement>(null);
43
+ const forceGraph = useRef<NativeForceGraph>(null);
44
+
45
+ const [data, setData] = useState<GraphAdapter>();
46
+ useEffect(() => {
47
+ return model?.subscribe((model) => setData(new GraphAdapter(model.graph)));
48
+ }, [model]);
49
+
50
+ useEffect(() => {
51
+ if (rootRef.current) {
52
+ // https://github.com/vasturiano/force-graph
53
+ // https://github.com/vasturiano/3d-force-graph
54
+ forceGraph.current = new NativeForceGraph(rootRef.current)
55
+ // https://github.com/vasturiano/force-graph?tab=readme-ov-file#node-styling
56
+ .nodeRelSize(6)
57
+ .nodeLabel((node: any) => (node.type === 'schema' ? node.data.typename : (node.data.label ?? node.id)))
58
+ .nodeAutoColorBy((node: any) => (node.type === 'schema' ? 'schema' : node.data.typename))
59
+
60
+ // https://github.com/vasturiano/force-graph?tab=readme-ov-file#link-styling
61
+ .linkAutoColorBy((link: any) => link.type);
62
+ }
63
+
64
+ return () => {
65
+ forceGraph.current?.pauseAnimation().graphData({ nodes: [], links: [] });
66
+ forceGraph.current = null;
67
+ };
68
+ }, []);
69
+
70
+ useEffect(() => {
71
+ if (!data || !width || !height || !forceGraph.current) {
72
+ return;
73
+ }
74
+
75
+ // https://github.com/vasturiano/force-graph?tab=readme-ov-file#container-layout
76
+ forceGraph.current
77
+ .pauseAnimation()
78
+ .width(width)
79
+ .height(height)
80
+ .onEngineStop(() => handleZoomToFit())
81
+ .onNodeClick((node: any) => {
82
+ forceGraph.current?.emitParticle(node);
83
+ })
84
+
85
+ // https://github.com/vasturiano/force-graph?tab=readme-ov-file#force-engine-d3-force-configuration
86
+ // .d3Force('center', forceCenter().strength(0.9))
87
+ .d3Force('link', forceLink().distance(160).strength(0.5))
88
+ .d3Force('charge', forceManyBody().strength(-30))
89
+
90
+ .graphData(data)
91
+ .warmupTicks(100)
92
+ .cooldownTime(1_000)
93
+ .resumeAnimation();
94
+ }, [data, width, height]);
95
+
96
+ const handleZoomToFit = () => {
97
+ forceGraph.current?.zoomToFit(400, 40);
98
+ };
99
+
100
+ const handleClick = useCallback<NonNullable<ComponentPropsWithoutRef<'div'>['onClick']>>(
101
+ (event) => {
102
+ onClick?.(event);
103
+ if (!event.defaultPrevented) {
104
+ handleZoomToFit();
105
+ }
106
+ },
107
+ [onClick],
108
+ );
109
+
110
+ return (
111
+ <div {...composableProps(props, { classNames: 'relative grow' })} onClick={handleClick} ref={setRef}>
112
+ <div ref={rootRef} className='absolute inset-0' />
113
+ </div>
114
+ );
115
+ },
116
+ );
117
+
118
+ const assignRef = <T,>(ref: Ref<T> | undefined, value: T | null): void => {
119
+ if (typeof ref === 'function') {
120
+ ref(value);
121
+ } else if (ref) {
122
+ (ref as RefObject<T | null>).current = value;
123
+ }
124
+ };