@dxos/plugin-explorer 0.8.4-main.1068cf700f → 0.8.4-main.1c7ec43d41

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 (146) 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/browser/{chunk-JZSBQYJQ.mjs → components/index.mjs} +217 -19
  4. package/dist/lib/{node-esm/chunk-K5BYG7BW.mjs.map → browser/components/index.mjs.map} +4 -4
  5. package/dist/lib/browser/{chunk-KIXHZZ2C.mjs → hooks/index.mjs} +18 -13
  6. package/dist/lib/browser/hooks/index.mjs.map +7 -0
  7. package/dist/lib/browser/index.mjs +4 -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/node-esm/{chunk-K5BYG7BW.mjs → components/index.mjs} +216 -19
  16. package/dist/lib/{browser/chunk-JZSBQYJQ.mjs.map → node-esm/components/index.mjs.map} +4 -4
  17. package/dist/lib/node-esm/{chunk-ASRWO2N5.mjs → hooks/index.mjs} +17 -13
  18. package/dist/lib/node-esm/hooks/index.mjs.map +7 -0
  19. package/dist/lib/node-esm/index.mjs +4 -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/create-object.d.ts +11 -0
  34. package/dist/types/src/capabilities/create-object.d.ts.map +1 -0
  35. package/dist/types/src/capabilities/index.d.ts +8 -1
  36. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  37. package/dist/types/src/capabilities/react-surface.d.ts +5 -0
  38. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
  39. package/dist/types/src/components/Chart/Chart.d.ts.map +1 -1
  40. package/dist/types/src/components/Chart/Chart.stories.d.ts +4 -1
  41. package/dist/types/src/components/Chart/Chart.stories.d.ts.map +1 -1
  42. package/dist/types/src/components/Globe/Globe.d.ts.map +1 -1
  43. package/dist/types/src/components/Globe/Globe.stories.d.ts +5 -2
  44. package/dist/types/src/components/Globe/Globe.stories.d.ts.map +1 -1
  45. package/dist/types/src/components/Graph/CanvasForceGraph.d.ts +13 -0
  46. package/dist/types/src/components/Graph/CanvasForceGraph.d.ts.map +1 -0
  47. package/dist/types/src/components/Graph/CanvasForceGraph.stories.d.ts +17 -0
  48. package/dist/types/src/components/Graph/CanvasForceGraph.stories.d.ts.map +1 -0
  49. package/dist/types/src/components/Graph/ForceGraph.d.ts +12 -5
  50. package/dist/types/src/components/Graph/ForceGraph.d.ts.map +1 -1
  51. package/dist/types/src/components/Graph/ForceGraph.stories.d.ts +4 -2
  52. package/dist/types/src/components/Graph/ForceGraph.stories.d.ts.map +1 -1
  53. package/dist/types/src/components/Graph/{adapter.d.ts → graph-adapter.d.ts} +1 -1
  54. package/dist/types/src/components/Graph/graph-adapter.d.ts.map +1 -0
  55. package/dist/types/src/components/Graph/index.d.ts +1 -1
  56. package/dist/types/src/components/Graph/index.d.ts.map +1 -1
  57. package/dist/types/src/components/Graph/testing.d.ts.map +1 -1
  58. package/dist/types/src/components/Tree/Tree.d.ts.map +1 -1
  59. package/dist/types/src/components/Tree/Tree.stories.d.ts +5 -1
  60. package/dist/types/src/components/Tree/Tree.stories.d.ts.map +1 -1
  61. package/dist/types/src/components/Tree/layout/HierarchicalEdgeBundling.d.ts.map +1 -1
  62. package/dist/types/src/components/Tree/layout/RadialTree.d.ts.map +1 -1
  63. package/dist/types/src/components/Tree/layout/TidyTree.d.ts.map +1 -1
  64. package/dist/types/src/components/Tree/testing/generator.d.ts.map +1 -1
  65. package/dist/types/src/components/Tree/types/tree.d.ts +7 -7
  66. package/dist/types/src/components/Tree/types/tree.d.ts.map +1 -1
  67. package/dist/types/src/components/Tree/types/types.d.ts.map +1 -1
  68. package/dist/types/src/components/index.d.ts +0 -2
  69. package/dist/types/src/components/index.d.ts.map +1 -1
  70. package/dist/types/src/components/plot.d.ts.map +1 -1
  71. package/dist/types/src/containers/ExplorerContainer/ExplorerContainer.d.ts +6 -0
  72. package/dist/types/src/containers/ExplorerContainer/ExplorerContainer.d.ts.map +1 -0
  73. package/dist/types/src/containers/ExplorerContainer/index.d.ts +2 -0
  74. package/dist/types/src/containers/ExplorerContainer/index.d.ts.map +1 -0
  75. package/dist/types/src/containers/index.d.ts +3 -0
  76. package/dist/types/src/containers/index.d.ts.map +1 -0
  77. package/dist/types/src/hooks/useGraphModel.d.ts.map +1 -1
  78. package/dist/types/src/index.d.ts +2 -3
  79. package/dist/types/src/index.d.ts.map +1 -1
  80. package/dist/types/src/translations.d.ts +28 -26
  81. package/dist/types/src/translations.d.ts.map +1 -1
  82. package/dist/types/src/types/ExplorerAction.d.ts.map +1 -1
  83. package/dist/types/src/types/Graph.d.ts +3 -10
  84. package/dist/types/src/types/Graph.d.ts.map +1 -1
  85. package/dist/types/tsconfig.tsbuildinfo +1 -1
  86. package/package.json +67 -47
  87. package/src/ExplorerPlugin.test.ts +26 -0
  88. package/src/ExplorerPlugin.tsx +7 -24
  89. package/src/capabilities/create-object.ts +36 -0
  90. package/src/capabilities/index.ts +4 -1
  91. package/src/capabilities/{react-surface/react-surface.tsx → react-surface.tsx} +10 -9
  92. package/src/components/Chart/Chart.stories.tsx +15 -22
  93. package/src/components/Globe/Globe.stories.tsx +18 -21
  94. package/src/components/Graph/CanvasForceGraph.stories.tsx +83 -0
  95. package/src/components/Graph/CanvasForceGraph.tsx +124 -0
  96. package/src/components/Graph/ForceGraph.stories.tsx +76 -44
  97. package/src/components/Graph/ForceGraph.tsx +104 -85
  98. package/src/components/Graph/index.ts +1 -1
  99. package/src/components/Tree/Tree.stories.tsx +44 -37
  100. package/src/components/Tree/testing/generator.ts +1 -1
  101. package/src/components/Tree/types/tree.test.ts +3 -4
  102. package/src/components/Tree/types/tree.ts +15 -15
  103. package/src/components/index.ts +0 -4
  104. package/src/{components → containers/ExplorerContainer}/ExplorerContainer.tsx +18 -19
  105. package/src/containers/ExplorerContainer/index.ts +5 -0
  106. package/src/containers/index.ts +7 -0
  107. package/src/hooks/useGraphModel.ts +14 -10
  108. package/src/index.ts +5 -3
  109. package/src/meta.ts +1 -1
  110. package/src/translations.ts +14 -13
  111. package/src/types/ExplorerAction.ts +0 -1
  112. package/src/types/Graph.ts +11 -24
  113. package/src/typings.d.ts +8 -0
  114. package/dist/lib/browser/ExplorerContainer-46BHUF6R.mjs +0 -45
  115. package/dist/lib/browser/ExplorerContainer-46BHUF6R.mjs.map +0 -7
  116. package/dist/lib/browser/chunk-HIFLWHXR.mjs +0 -83
  117. package/dist/lib/browser/chunk-HIFLWHXR.mjs.map +0 -7
  118. package/dist/lib/browser/chunk-KIXHZZ2C.mjs.map +0 -7
  119. package/dist/lib/browser/chunk-MGBT2ZFU.mjs +0 -177
  120. package/dist/lib/browser/chunk-MGBT2ZFU.mjs.map +0 -7
  121. package/dist/lib/browser/react-surface-TPQAT5EI.mjs +0 -36
  122. package/dist/lib/browser/react-surface-TPQAT5EI.mjs.map +0 -7
  123. package/dist/lib/node-esm/ExplorerContainer-OZNG47QB.mjs +0 -46
  124. package/dist/lib/node-esm/ExplorerContainer-OZNG47QB.mjs.map +0 -7
  125. package/dist/lib/node-esm/chunk-3OE6TBJI.mjs +0 -84
  126. package/dist/lib/node-esm/chunk-3OE6TBJI.mjs.map +0 -7
  127. package/dist/lib/node-esm/chunk-ASRWO2N5.mjs.map +0 -7
  128. package/dist/lib/node-esm/chunk-YWJBDETV.mjs +0 -179
  129. package/dist/lib/node-esm/chunk-YWJBDETV.mjs.map +0 -7
  130. package/dist/lib/node-esm/react-surface-CYHGJJDU.mjs +0 -37
  131. package/dist/lib/node-esm/react-surface-CYHGJJDU.mjs.map +0 -7
  132. package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
  133. package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
  134. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +0 -5
  135. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
  136. package/dist/types/src/components/ExplorerContainer.d.ts +0 -7
  137. package/dist/types/src/components/ExplorerContainer.d.ts.map +0 -1
  138. package/dist/types/src/components/Graph/D3ForceGraph.d.ts +0 -14
  139. package/dist/types/src/components/Graph/D3ForceGraph.d.ts.map +0 -1
  140. package/dist/types/src/components/Graph/D3ForceGraph.stories.d.ts +0 -15
  141. package/dist/types/src/components/Graph/D3ForceGraph.stories.d.ts.map +0 -1
  142. package/dist/types/src/components/Graph/adapter.d.ts.map +0 -1
  143. package/src/capabilities/react-surface/index.ts +0 -7
  144. package/src/components/Graph/D3ForceGraph.stories.tsx +0 -83
  145. package/src/components/Graph/D3ForceGraph.tsx +0 -101
  146. /package/src/components/Graph/{adapter.ts → graph-adapter.ts} +0 -0
@@ -4,7 +4,7 @@
4
4
 
5
5
  import * as Schema from 'effect/Schema';
6
6
 
7
- import { Key, Obj, Type } from '@dxos/echo';
7
+ import { Key, Obj, Ref, Type } from '@dxos/echo';
8
8
  import { TestSchema } from '@dxos/echo/testing';
9
9
  import { invariant } from '@dxos/invariant';
10
10
 
@@ -14,7 +14,7 @@ export const TreeNodeType = Schema.Struct({
14
14
  id: Key.ObjectId,
15
15
  children: Schema.mutable(Schema.Array(Key.ObjectId)),
16
16
  data: Schema.mutable(Schema.Record({ key: Schema.String, value: Schema.Any })),
17
- ref: Schema.optional(Type.Ref(TestSchema.Expando)),
17
+ ref: Schema.optional(Ref.Ref(TestSchema.Expando)),
18
18
  }).pipe(Schema.mutable);
19
19
 
20
20
  export interface TreeNodeType extends Schema.Schema.Type<typeof TreeNodeType> {}
@@ -24,7 +24,7 @@ export const TreeType = Schema.Struct({
24
24
  nodes: Schema.mutable(Schema.Record({ key: Key.ObjectId, value: TreeNodeType })),
25
25
  }).pipe(
26
26
  Type.object({
27
- typename: 'dxos.org/type/Tree',
27
+ typename: 'org.dxos.type.tree',
28
28
  version: '0.1.0',
29
29
  }),
30
30
  );
@@ -185,8 +185,8 @@ export class Tree {
185
185
  clear(): void {
186
186
  const root = this._tree.nodes[this._tree.root];
187
187
  root.children.length = 0;
188
- Obj.change(this._tree, (t) => {
189
- t.nodes = {
188
+ Obj.update(this._tree, (obj) => {
189
+ obj.nodes = {
190
190
  [root.id]: root,
191
191
  };
192
192
  });
@@ -202,8 +202,8 @@ export class Tree {
202
202
  }
203
203
 
204
204
  const nodeToAdd = node;
205
- Obj.change(this._tree, (t) => {
206
- t.nodes[nodeToAdd.id] = nodeToAdd;
205
+ Obj.update(this._tree, (obj) => {
206
+ obj.nodes[nodeToAdd.id] = nodeToAdd;
207
207
  parent.children.splice(index ?? parent.children.length, 0, nodeToAdd.id);
208
208
  });
209
209
  return node;
@@ -218,12 +218,12 @@ export class Tree {
218
218
  return undefined;
219
219
  }
220
220
 
221
- Obj.change(this._tree, (t) => {
222
- delete t.nodes[node.id];
221
+ Obj.update(this._tree, (obj) => {
222
+ delete obj.nodes[node.id];
223
223
  });
224
224
  const idx = parent.children.findIndex((child) => child === id);
225
225
  if (idx !== -1) {
226
- Obj.change(this._tree, () => {
226
+ Obj.update(this._tree, () => {
227
227
  parent.children.splice(idx, 1);
228
228
  });
229
229
  }
@@ -242,7 +242,7 @@ export class Tree {
242
242
  }
243
243
 
244
244
  const child = node.children[from];
245
- Obj.change(this._tree, () => {
245
+ Obj.update(this._tree, () => {
246
246
  node.children.splice(from, 1);
247
247
  node.children.splice(to, 0, child);
248
248
  });
@@ -264,7 +264,7 @@ export class Tree {
264
264
  }
265
265
 
266
266
  const previous = this.getNode(parent.children[idx - 1]);
267
- Obj.change(this._tree, () => {
267
+ Obj.update(this._tree, () => {
268
268
  parent.children.splice(idx, 1);
269
269
  previous.children.push(node.id);
270
270
  });
@@ -287,19 +287,19 @@ export class Tree {
287
287
  // Remove node from parent and get following siblings.
288
288
  const nodeIdx = parent.children.findIndex((id) => id === node.id);
289
289
  let rest: Key.ObjectId[] = [];
290
- Obj.change(this._tree, () => {
290
+ Obj.update(this._tree, () => {
291
291
  const removed = parent.children.splice(nodeIdx, parent.children.length - nodeIdx);
292
292
  rest = removed.slice(1); // Skip the node itself.
293
293
  });
294
294
 
295
295
  // Add to ancestor.
296
296
  const parentIdx = this.getChildNodes(ancestor).findIndex((n) => n.id === parent.id);
297
- Obj.change(this._tree, () => {
297
+ Obj.update(this._tree, () => {
298
298
  ancestor.children.splice(parentIdx + 1, 0, node.id);
299
299
  });
300
300
 
301
301
  // Transplant following siblings to current node.
302
- Obj.change(this._tree, () => {
302
+ Obj.update(this._tree, () => {
303
303
  node.children.push(...rest);
304
304
  });
305
305
  }
@@ -2,11 +2,7 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { type ComponentType, lazy } from 'react';
6
-
7
5
  export * from './Chart';
8
6
  export * from './Globe';
9
7
  export * from './Graph';
10
8
  export * from './Tree';
11
-
12
- export const ExplorerContainer: ComponentType<any> = lazy(() => import('./ExplorerContainer'));
@@ -4,27 +4,24 @@
4
4
 
5
5
  import React, { useCallback, useMemo, useState } from 'react';
6
6
 
7
- import { type SurfaceComponentProps } from '@dxos/app-toolkit/ui';
7
+ import { type AppSurface } from '@dxos/app-toolkit/ui';
8
8
  import { type Filter } from '@dxos/echo';
9
+ import { type View } from '@dxos/echo';
9
10
  import { QueryBuilder } from '@dxos/echo-query';
10
- import { useGlobalSearch } from '@dxos/plugin-search';
11
11
  import { getSpace, useObject } from '@dxos/react-client/echo';
12
- import { Layout, Toolbar } from '@dxos/react-ui';
12
+ import { Panel, Toolbar } from '@dxos/react-ui';
13
13
  import { QueryEditor, type QueryEditorProps } from '@dxos/react-ui-components';
14
- import { type View } from '@dxos/schema';
15
14
 
16
- import { useGraphModel } from '../hooks';
15
+ import { ForceGraph } from '#components';
16
+ import { useGraphModel } from '#hooks';
17
17
 
18
- import { D3ForceGraph } from './Graph';
18
+ export type ExplorerContainerProps = AppSurface.ObjectArticleProps<View.View>;
19
19
 
20
- export type ExplorerContainerProps = SurfaceComponentProps<View.View>;
21
-
22
- const ExplorerContainer = ({ role, subject: view }: ExplorerContainerProps) => {
23
- useObject(view);
20
+ export const ExplorerContainer = ({ role, subject, attendableId: _attendableId }: ExplorerContainerProps) => {
21
+ const [view] = useObject(subject);
24
22
  const space = view && getSpace(view);
25
23
  const [filter, setFilter] = useState<Filter.Any>();
26
24
  const model = useGraphModel(space, filter);
27
- const { match } = useGlobalSearch();
28
25
 
29
26
  const builder = useMemo(() => new QueryBuilder(), []);
30
27
  const handleChange = useCallback<NonNullable<QueryEditorProps['onChange']>>((value) => {
@@ -38,15 +35,17 @@ const ExplorerContainer = ({ role, subject: view }: ExplorerContainerProps) => {
38
35
  }
39
36
 
40
37
  return (
41
- <Layout.Main role={role} toolbar={showToolbar}>
38
+ <Panel.Root role={role}>
42
39
  {showToolbar && (
43
- <Toolbar.Root>
44
- <QueryEditor db={space.db} onChange={handleChange} />
45
- </Toolbar.Root>
40
+ <Panel.Toolbar asChild>
41
+ <Toolbar.Root>
42
+ <QueryEditor db={space.db} onChange={handleChange} />
43
+ </Toolbar.Root>
44
+ </Panel.Toolbar>
46
45
  )}
47
- <D3ForceGraph model={model} match={match} />
48
- </Layout.Main>
46
+ <Panel.Content asChild>
47
+ <ForceGraph model={model} />
48
+ </Panel.Content>
49
+ </Panel.Root>
49
50
  );
50
51
  };
51
-
52
- export default ExplorerContainer;
@@ -0,0 +1,5 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ export { ExplorerContainer as default } from './ExplorerContainer';
@@ -0,0 +1,7 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { type ComponentType, lazy } from 'react';
6
+
7
+ export const ExplorerContainer: ComponentType<any> = lazy(() => import('./ExplorerContainer'));
@@ -18,22 +18,26 @@ export const useGraphModel = (
18
18
  ): SpaceGraphModel | undefined => {
19
19
  const registry = useCapability(Capabilities.AtomRegistry);
20
20
  const [model, setModel] = useState<SpaceGraphModel | undefined>(undefined);
21
+
21
22
  useEffect(() => {
22
23
  if (!space) {
23
- void model?.close();
24
24
  setModel(undefined);
25
25
  return;
26
26
  }
27
27
 
28
- // TODO(burdon): Does this need to be a dependency?
29
- if (!model || model.queue !== queue) {
30
- const model = new SpaceGraphModel(registry).setFilter(filter).setOptions(options);
31
- void model.open(space.db, queue);
32
- setModel(model);
33
- } else {
34
- model.setFilter(filter).setOptions(options);
35
- }
36
- }, [space, filter, options, queue, registry]);
28
+ const newModel = new SpaceGraphModel(registry);
29
+ void newModel.open(space.db, queue);
30
+ setModel(newModel);
31
+
32
+ return () => {
33
+ setModel(undefined);
34
+ void newModel.close();
35
+ };
36
+ }, [space, registry, queue]);
37
+
38
+ useEffect(() => {
39
+ model?.setFilter(filter).setOptions(options);
40
+ }, [model, filter, options]);
37
41
 
38
42
  return model;
39
43
  };
package/src/index.ts CHANGED
@@ -2,8 +2,10 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- export * from './components';
6
- export * from './hooks';
5
+ import { Plugin } from '@dxos/app-framework';
6
+
7
+ import { meta } from './meta';
8
+
7
9
  export * from './meta';
8
10
 
9
- export * from './ExplorerPlugin';
11
+ export const ExplorerPlugin = Plugin.lazy(meta, () => import('#plugin'));
package/src/meta.ts CHANGED
@@ -6,7 +6,7 @@ import { type Plugin } from '@dxos/app-framework';
6
6
  import { trim } from '@dxos/util';
7
7
 
8
8
  export const meta: Plugin.Meta = {
9
- id: 'dxos.org/plugin/explorer',
9
+ id: 'org.dxos.plugin.explorer',
10
10
  name: 'Explorer',
11
11
  description: trim`
12
12
  Interactive hypergraph visualization that reveals relationships between objects in your workspace.
@@ -4,27 +4,28 @@
4
4
 
5
5
  import { Type } from '@dxos/echo';
6
6
  import { type Resource } from '@dxos/react-ui';
7
- import { translations as componentsTranslations } from '@dxos/react-ui-components';
7
+ import { translations as componentsTranslations } from '@dxos/react-ui-components/translations';
8
8
 
9
- import { meta } from './meta';
10
- import { Graph } from './types';
9
+ import { meta } from '#meta';
10
+ import { Graph } from '#types';
11
11
 
12
12
  export const translations = [
13
13
  {
14
14
  'en-US': {
15
15
  [Type.getTypename(Graph.Graph)]: {
16
- 'typename label': 'Explorer',
17
- 'typename label_zero': 'Explorers',
18
- 'typename label_one': 'Explorer',
19
- 'typename label_other': 'Explorers',
20
- 'object name placeholder': 'New explorer',
21
- 'rename object label': 'Rename explorer',
22
- 'delete object label': 'Delete explorer',
23
- 'object deleted label': 'Explorer deleted',
16
+ 'typename.label': 'Explorer',
17
+ 'typename.label_zero': 'Explorers',
18
+ 'typename.label_one': 'Explorer',
19
+ 'typename.label_other': 'Explorers',
20
+ 'object-name.placeholder': 'New explorer',
21
+ 'add-object.label': 'Add explorer',
22
+ 'rename-object.label': 'Rename explorer',
23
+ 'delete-object.label': 'Delete explorer',
24
+ 'object-deleted.label': 'Explorer deleted',
24
25
  },
25
26
  [meta.id]: {
26
- 'plugin name': 'Explorer',
27
- 'object title label': 'Title',
27
+ 'plugin.name': 'Explorer',
28
+ 'object-title.label': 'Title',
28
29
  },
29
30
  },
30
31
  },
@@ -14,7 +14,6 @@ export const GraphProps = Schema.Struct({
14
14
  TypeInputOptionsAnnotation.set({
15
15
  location: ['database', 'runtime'],
16
16
  kind: ['user'],
17
- registered: ['registered'],
18
17
  }),
19
18
  Schema.optional,
20
19
  ),
@@ -4,14 +4,15 @@
4
4
 
5
5
  import * as Schema from 'effect/Schema';
6
6
 
7
- import { Filter, Obj, Query, QueryAST, Ref, Type } from '@dxos/echo';
7
+ import { Annotation, Filter, Obj, Query, QueryAST, Ref, Type } from '@dxos/echo';
8
+ import { View } from '@dxos/echo';
8
9
  import { FormInputAnnotation, LabelAnnotation } from '@dxos/echo/internal';
9
- import { View, ViewAnnotation } from '@dxos/schema';
10
+ import { ViewAnnotation } from '@dxos/schema';
10
11
 
11
12
  const GraphSchema = Schema.Struct({
12
13
  name: Schema.optional(Schema.String),
13
14
 
14
- view: Type.Ref(View.View).pipe(FormInputAnnotation.set(false)),
15
+ view: Ref.Ref(View.View).pipe(FormInputAnnotation.set(false)),
15
16
 
16
17
  query: Schema.Struct({
17
18
  raw: Schema.optional(Schema.String),
@@ -19,11 +20,15 @@ const GraphSchema = Schema.Struct({
19
20
  }).pipe(FormInputAnnotation.set(false)),
20
21
  }).pipe(
21
22
  Type.object({
22
- typename: 'dxos.org/type/Graph',
23
- version: '0.2.0',
23
+ typename: 'org.dxos.type.graph',
24
+ version: '0.1.0',
24
25
  }),
25
26
  LabelAnnotation.set(['name']),
26
- ViewAnnotation.set(true),
27
+ ViewAnnotation.set(['view']),
28
+ Annotation.IconAnnotation.set({
29
+ icon: 'ph--graph--regular',
30
+ hue: 'green',
31
+ }),
27
32
  );
28
33
  export interface Graph extends Schema.Schema.Type<typeof GraphSchema> {}
29
34
  export const Graph: Type.Obj<Graph> = GraphSchema as any;
@@ -42,21 +47,3 @@ export const make = ({
42
47
  }: MakeProps): Graph => {
43
48
  return Obj.make(Graph, { name, view: Ref.make(view), query });
44
49
  };
45
-
46
- //
47
- // V1
48
- //
49
-
50
- export const GraphV1 = Schema.Struct({
51
- name: Schema.optional(Schema.String),
52
- query: Schema.Struct({
53
- raw: Schema.optional(Schema.String),
54
- ast: QueryAST.Query,
55
- }),
56
- }).pipe(
57
- Type.object({
58
- typename: 'dxos.org/type/Graph',
59
- version: '0.1.0',
60
- }),
61
- LabelAnnotation.set(['name']),
62
- );
@@ -0,0 +1,8 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ declare module '*.css' {
6
+ const content: undefined;
7
+ export default content;
8
+ }
@@ -1,45 +0,0 @@
1
- import {
2
- useGraphModel
3
- } from "./chunk-KIXHZZ2C.mjs";
4
- import {
5
- D3ForceGraph
6
- } from "./chunk-MGBT2ZFU.mjs";
7
- import "./chunk-J5LGTIGS.mjs";
8
-
9
- // src/components/ExplorerContainer.tsx
10
- import React, { useCallback, useMemo, useState } from "react";
11
- import { QueryBuilder } from "@dxos/echo-query";
12
- import { useGlobalSearch } from "@dxos/plugin-search";
13
- import { getSpace, useObject } from "@dxos/react-client/echo";
14
- import { Layout, Toolbar } from "@dxos/react-ui";
15
- import { QueryEditor } from "@dxos/react-ui-components";
16
- var ExplorerContainer = ({ role, subject: view }) => {
17
- useObject(view);
18
- const space = view && getSpace(view);
19
- const [filter, setFilter] = useState();
20
- const model = useGraphModel(space, filter);
21
- const { match } = useGlobalSearch();
22
- const builder = useMemo(() => new QueryBuilder(), []);
23
- const handleChange = useCallback((value) => {
24
- setFilter(builder.build(value).filter);
25
- }, []);
26
- const showToolbar = role === "article";
27
- if (!space || !model) {
28
- return null;
29
- }
30
- return /* @__PURE__ */ React.createElement(Layout.Main, {
31
- role,
32
- toolbar: showToolbar
33
- }, showToolbar && /* @__PURE__ */ React.createElement(Toolbar.Root, null, /* @__PURE__ */ React.createElement(QueryEditor, {
34
- db: space.db,
35
- onChange: handleChange
36
- })), /* @__PURE__ */ React.createElement(D3ForceGraph, {
37
- model,
38
- match
39
- }));
40
- };
41
- var ExplorerContainer_default = ExplorerContainer;
42
- export {
43
- ExplorerContainer_default as default
44
- };
45
- //# sourceMappingURL=ExplorerContainer-46BHUF6R.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/ExplorerContainer.tsx"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { useCallback, useMemo, useState } from 'react';\n\nimport { type SurfaceComponentProps } from '@dxos/app-toolkit/ui';\nimport { type Filter } from '@dxos/echo';\nimport { QueryBuilder } from '@dxos/echo-query';\nimport { useGlobalSearch } from '@dxos/plugin-search';\nimport { getSpace, useObject } from '@dxos/react-client/echo';\nimport { Layout, Toolbar } from '@dxos/react-ui';\nimport { QueryEditor, type QueryEditorProps } from '@dxos/react-ui-components';\nimport { type View } from '@dxos/schema';\n\nimport { useGraphModel } from '../hooks';\n\nimport { D3ForceGraph } from './Graph';\n\nexport type ExplorerContainerProps = SurfaceComponentProps<View.View>;\n\nconst ExplorerContainer = ({ role, subject: view }: ExplorerContainerProps) => {\n useObject(view);\n const space = view && getSpace(view);\n const [filter, setFilter] = useState<Filter.Any>();\n const model = useGraphModel(space, filter);\n const { match } = useGlobalSearch();\n\n const builder = useMemo(() => new QueryBuilder(), []);\n const handleChange = useCallback<NonNullable<QueryEditorProps['onChange']>>((value) => {\n setFilter(builder.build(value).filter);\n }, []);\n\n const showToolbar = role === 'article';\n\n if (!space || !model) {\n return null;\n }\n\n return (\n <Layout.Main role={role} toolbar={showToolbar}>\n {showToolbar && (\n <Toolbar.Root>\n <QueryEditor db={space.db} onChange={handleChange} />\n </Toolbar.Root>\n )}\n <D3ForceGraph model={model} match={match} />\n </Layout.Main>\n );\n};\n\nexport default ExplorerContainer;\n"],
5
- "mappings": ";;;;;;;;;AAIA,OAAOA,SAASC,aAAaC,SAASC,gBAAgB;AAItD,SAASC,oBAAoB;AAC7B,SAASC,uBAAuB;AAChC,SAASC,UAAUC,iBAAiB;AACpC,SAASC,QAAQC,eAAe;AAChC,SAASC,mBAA0C;AASnD,IAAMC,oBAAoB,CAAC,EAAEC,MAAMC,SAASC,KAAI,MAA0B;AACxEC,YAAUD,IAAAA;AACV,QAAME,QAAQF,QAAQG,SAASH,IAAAA;AAC/B,QAAM,CAACI,QAAQC,SAAAA,IAAaC,SAAAA;AAC5B,QAAMC,QAAQC,cAAcN,OAAOE,MAAAA;AACnC,QAAM,EAAEK,MAAK,IAAKC,gBAAAA;AAElB,QAAMC,UAAUC,QAAQ,MAAM,IAAIC,aAAAA,GAAgB,CAAA,CAAE;AACpD,QAAMC,eAAeC,YAAuD,CAACC,UAAAA;AAC3EX,cAAUM,QAAQM,MAAMD,KAAAA,EAAOZ,MAAM;EACvC,GAAG,CAAA,CAAE;AAEL,QAAMc,cAAcpB,SAAS;AAE7B,MAAI,CAACI,SAAS,CAACK,OAAO;AACpB,WAAO;EACT;AAEA,SACE,sBAAA,cAACY,OAAOC,MAAI;IAACtB;IAAYuB,SAASH;KAC/BA,eACC,sBAAA,cAACI,QAAQC,MAAI,MACX,sBAAA,cAACC,aAAAA;IAAYC,IAAIvB,MAAMuB;IAAIC,UAAUZ;OAGzC,sBAAA,cAACa,cAAAA;IAAapB;IAAcE;;AAGlC;AAEA,IAAA,4BAAeZ;",
6
- "names": ["React", "useCallback", "useMemo", "useState", "QueryBuilder", "useGlobalSearch", "getSpace", "useObject", "Layout", "Toolbar", "QueryEditor", "ExplorerContainer", "role", "subject", "view", "useObject", "space", "getSpace", "filter", "setFilter", "useState", "model", "useGraphModel", "match", "useGlobalSearch", "builder", "useMemo", "QueryBuilder", "handleChange", "useCallback", "value", "build", "showToolbar", "Layout", "Main", "toolbar", "Toolbar", "Root", "QueryEditor", "db", "onChange", "D3ForceGraph"]
7
- }
@@ -1,83 +0,0 @@
1
- import {
2
- __export
3
- } from "./chunk-J5LGTIGS.mjs";
4
-
5
- // src/types/ExplorerAction.ts
6
- var ExplorerAction_exports = {};
7
- __export(ExplorerAction_exports, {
8
- GraphProps: () => GraphProps
9
- });
10
- import * as Schema from "effect/Schema";
11
- import { TypeInputOptionsAnnotation } from "@dxos/plugin-space/types";
12
- var GraphProps = Schema.Struct({
13
- name: Schema.optional(Schema.String),
14
- // TODO(wittjosiah): This should be a query input instead.
15
- typename: Schema.String.pipe(Schema.annotations({
16
- title: "Select type"
17
- }), TypeInputOptionsAnnotation.set({
18
- location: [
19
- "database",
20
- "runtime"
21
- ],
22
- kind: [
23
- "user"
24
- ],
25
- registered: [
26
- "registered"
27
- ]
28
- }), Schema.optional)
29
- });
30
-
31
- // src/types/Graph.ts
32
- var Graph_exports = {};
33
- __export(Graph_exports, {
34
- Graph: () => Graph,
35
- GraphV1: () => GraphV1,
36
- make: () => make
37
- });
38
- import * as Schema2 from "effect/Schema";
39
- import { Filter, Obj, Query, QueryAST, Ref, Type } from "@dxos/echo";
40
- import { FormInputAnnotation, LabelAnnotation } from "@dxos/echo/internal";
41
- import { View, ViewAnnotation } from "@dxos/schema";
42
- var GraphSchema = Schema2.Struct({
43
- name: Schema2.optional(Schema2.String),
44
- view: Type.Ref(View.View).pipe(FormInputAnnotation.set(false)),
45
- query: Schema2.Struct({
46
- raw: Schema2.optional(Schema2.String),
47
- ast: QueryAST.Query
48
- }).pipe(FormInputAnnotation.set(false))
49
- }).pipe(Type.object({
50
- typename: "dxos.org/type/Graph",
51
- version: "0.2.0"
52
- }), LabelAnnotation.set([
53
- "name"
54
- ]), ViewAnnotation.set(true));
55
- var Graph = GraphSchema;
56
- var make = ({ name, query = {
57
- raw: "",
58
- ast: Query.select(Filter.nothing()).ast
59
- }, view }) => {
60
- return Obj.make(Graph, {
61
- name,
62
- view: Ref.make(view),
63
- query
64
- });
65
- };
66
- var GraphV1 = Schema2.Struct({
67
- name: Schema2.optional(Schema2.String),
68
- query: Schema2.Struct({
69
- raw: Schema2.optional(Schema2.String),
70
- ast: QueryAST.Query
71
- })
72
- }).pipe(Type.object({
73
- typename: "dxos.org/type/Graph",
74
- version: "0.1.0"
75
- }), LabelAnnotation.set([
76
- "name"
77
- ]));
78
-
79
- export {
80
- ExplorerAction_exports,
81
- Graph_exports
82
- };
83
- //# sourceMappingURL=chunk-HIFLWHXR.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/types/ExplorerAction.ts", "../../../src/types/Graph.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { TypeInputOptionsAnnotation } from '@dxos/plugin-space/types';\n\nexport const GraphProps = Schema.Struct({\n name: Schema.optional(Schema.String),\n // TODO(wittjosiah): This should be a query input instead.\n typename: Schema.String.pipe(\n Schema.annotations({ title: 'Select type' }),\n TypeInputOptionsAnnotation.set({\n location: ['database', 'runtime'],\n kind: ['user'],\n registered: ['registered'],\n }),\n Schema.optional,\n ),\n});\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { Filter, Obj, Query, QueryAST, Ref, Type } from '@dxos/echo';\nimport { FormInputAnnotation, LabelAnnotation } from '@dxos/echo/internal';\nimport { View, ViewAnnotation } from '@dxos/schema';\n\nconst GraphSchema = Schema.Struct({\n name: Schema.optional(Schema.String),\n\n view: Type.Ref(View.View).pipe(FormInputAnnotation.set(false)),\n\n query: Schema.Struct({\n raw: Schema.optional(Schema.String),\n ast: QueryAST.Query,\n }).pipe(FormInputAnnotation.set(false)),\n}).pipe(\n Type.object({\n typename: 'dxos.org/type/Graph',\n version: '0.2.0',\n }),\n LabelAnnotation.set(['name']),\n ViewAnnotation.set(true),\n);\nexport interface Graph extends Schema.Schema.Type<typeof GraphSchema> {}\nexport const Graph: Type.Obj<Graph> = GraphSchema as any;\n\ntype MakeProps = Omit<Partial<Obj.MakeProps<typeof Graph>>, 'view'> & {\n view: View.View;\n};\n\n/**\n * Make a graph as a view of a data set.\n */\nexport const make = ({\n name,\n query = { raw: '', ast: Query.select(Filter.nothing()).ast },\n view,\n}: MakeProps): Graph => {\n return Obj.make(Graph, { name, view: Ref.make(view), query });\n};\n\n//\n// V1\n//\n\nexport const GraphV1 = Schema.Struct({\n name: Schema.optional(Schema.String),\n query: Schema.Struct({\n raw: Schema.optional(Schema.String),\n ast: QueryAST.Query,\n }),\n}).pipe(\n Type.object({\n typename: 'dxos.org/type/Graph',\n version: '0.1.0',\n }),\n LabelAnnotation.set(['name']),\n);\n"],
5
- "mappings": ";;;;;AAAA;;;;AAIA,YAAYA,YAAY;AAExB,SAASC,kCAAkC;AAEpC,IAAMC,aAAoBC,cAAO;EACtCC,MAAaC,gBAAgBC,aAAM;;EAEnCC,UAAiBD,cAAOE,KACfC,mBAAY;IAAEC,OAAO;EAAc,CAAA,GAC1CC,2BAA2BC,IAAI;IAC7BC,UAAU;MAAC;MAAY;;IACvBC,MAAM;MAAC;;IACPC,YAAY;MAAC;;EACf,CAAA,GACOV,eAAQ;AAEnB,CAAA;;;ACpBA;;;;;;AAIA,YAAYW,aAAY;AAExB,SAASC,QAAQC,KAAKC,OAAOC,UAAUC,KAAKC,YAAY;AACxD,SAASC,qBAAqBC,uBAAuB;AACrD,SAASC,MAAMC,sBAAsB;AAErC,IAAMC,cAAqBC,eAAO;EAChCC,MAAaC,iBAAgBC,cAAM;EAEnCC,MAAMC,KAAKC,IAAIC,KAAKA,IAAI,EAAEC,KAAKC,oBAAoBC,IAAI,KAAA,CAAA;EAEvDC,OAAcX,eAAO;IACnBY,KAAYV,iBAAgBC,cAAM;IAClCU,KAAKC,SAASC;EAChB,CAAA,EAAGP,KAAKC,oBAAoBC,IAAI,KAAA,CAAA;AAClC,CAAA,EAAGF,KACDH,KAAKW,OAAO;EACVC,UAAU;EACVC,SAAS;AACX,CAAA,GACAC,gBAAgBT,IAAI;EAAC;CAAO,GAC5BU,eAAeV,IAAI,IAAA,CAAA;AAGd,IAAMW,QAAyBtB;AAS/B,IAAMuB,OAAO,CAAC,EACnBrB,MACAU,QAAQ;EAAEC,KAAK;EAAIC,KAAKE,MAAMQ,OAAOC,OAAOC,QAAO,CAAA,EAAIZ;AAAI,GAC3DT,KAAI,MACM;AACV,SAAOsB,IAAIJ,KAAKD,OAAO;IAAEpB;IAAMG,MAAME,IAAIgB,KAAKlB,IAAAA;IAAOO;EAAM,CAAA;AAC7D;AAMO,IAAMgB,UAAiB3B,eAAO;EACnCC,MAAaC,iBAAgBC,cAAM;EACnCQ,OAAcX,eAAO;IACnBY,KAAYV,iBAAgBC,cAAM;IAClCU,KAAKC,SAASC;EAChB,CAAA;AACF,CAAA,EAAGP,KACDH,KAAKW,OAAO;EACVC,UAAU;EACVC,SAAS;AACX,CAAA,GACAC,gBAAgBT,IAAI;EAAC;CAAO,CAAA;",
6
- "names": ["Schema", "TypeInputOptionsAnnotation", "GraphProps", "Struct", "name", "optional", "String", "typename", "pipe", "annotations", "title", "TypeInputOptionsAnnotation", "set", "location", "kind", "registered", "Schema", "Filter", "Obj", "Query", "QueryAST", "Ref", "Type", "FormInputAnnotation", "LabelAnnotation", "View", "ViewAnnotation", "GraphSchema", "Struct", "name", "optional", "String", "view", "Type", "Ref", "View", "pipe", "FormInputAnnotation", "set", "query", "raw", "ast", "QueryAST", "Query", "object", "typename", "version", "LabelAnnotation", "ViewAnnotation", "Graph", "make", "select", "Filter", "nothing", "Obj", "GraphV1"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/hooks/useGraphModel.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { useEffect, useState } from 'react';\n\nimport { Capabilities } from '@dxos/app-framework';\nimport { useCapability } from '@dxos/app-framework/ui';\nimport { type Filter, type Queue, type Space } from '@dxos/client/echo';\nimport { SpaceGraphModel, type SpaceGraphModelOptions } from '@dxos/schema';\n\n// TODO(burdon): Factor out.\nexport const useGraphModel = (\n space: Space | undefined,\n filter?: Filter.Any | undefined,\n options?: SpaceGraphModelOptions,\n queue?: Queue,\n): SpaceGraphModel | undefined => {\n const registry = useCapability(Capabilities.AtomRegistry);\n const [model, setModel] = useState<SpaceGraphModel | undefined>(undefined);\n useEffect(() => {\n if (!space) {\n void model?.close();\n setModel(undefined);\n return;\n }\n\n // TODO(burdon): Does this need to be a dependency?\n if (!model || model.queue !== queue) {\n const model = new SpaceGraphModel(registry).setFilter(filter).setOptions(options);\n void model.open(space.db, queue);\n setModel(model);\n } else {\n model.setFilter(filter).setOptions(options);\n }\n }, [space, filter, options, queue, registry]);\n\n return model;\n};\n"],
5
- "mappings": ";AAIA,SAASA,WAAWC,gBAAgB;AAEpC,SAASC,oBAAoB;AAC7B,SAASC,qBAAqB;AAE9B,SAASC,uBAAoD;AAGtD,IAAMC,gBAAgB,CAC3BC,OACAC,QACAC,SACAC,UAAAA;AAEA,QAAMC,WAAWC,cAAcC,aAAaC,YAAY;AACxD,QAAM,CAACC,OAAOC,QAAAA,IAAYC,SAAsCC,MAAAA;AAChEC,YAAU,MAAA;AACR,QAAI,CAACZ,OAAO;AACV,WAAKQ,OAAOK,MAAAA;AACZJ,eAASE,MAAAA;AACT;IACF;AAGA,QAAI,CAACH,SAASA,MAAML,UAAUA,OAAO;AACnC,YAAMK,SAAQ,IAAIM,gBAAgBV,QAAAA,EAAUW,UAAUd,MAAAA,EAAQe,WAAWd,OAAAA;AACzE,WAAKM,OAAMS,KAAKjB,MAAMkB,IAAIf,KAAAA;AAC1BM,eAASD,MAAAA;IACX,OAAO;AACLA,YAAMO,UAAUd,MAAAA,EAAQe,WAAWd,OAAAA;IACrC;EACF,GAAG;IAACF;IAAOC;IAAQC;IAASC;IAAOC;GAAS;AAE5C,SAAOI;AACT;",
6
- "names": ["useEffect", "useState", "Capabilities", "useCapability", "SpaceGraphModel", "useGraphModel", "space", "filter", "options", "queue", "registry", "useCapability", "Capabilities", "AtomRegistry", "model", "setModel", "useState", "undefined", "useEffect", "close", "SpaceGraphModel", "setFilter", "setOptions", "open", "db"]
7
- }