@dxos/plugin-explorer 0.8.4-main.937b3ca → 0.8.4-main.9be5663bfe

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 (102) hide show
  1. package/dist/lib/browser/{chunk-YNQF4CPY.mjs → chunk-LSUP47BZ.mjs} +2 -2
  2. package/dist/lib/browser/{chunk-YNQF4CPY.mjs.map → chunk-LSUP47BZ.mjs.map} +1 -1
  3. package/dist/lib/browser/index.mjs +11331 -57
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/meta.mjs +1 -1
  7. package/dist/lib/browser/types/index.mjs +64 -4
  8. package/dist/lib/browser/types/index.mjs.map +4 -4
  9. package/dist/lib/node-esm/{chunk-DK77RB6M.mjs → chunk-EN3JZNEY.mjs} +2 -2
  10. package/dist/lib/node-esm/{chunk-DK77RB6M.mjs.map → chunk-EN3JZNEY.mjs.map} +1 -1
  11. package/dist/lib/node-esm/index.mjs +11331 -57
  12. package/dist/lib/node-esm/index.mjs.map +4 -4
  13. package/dist/lib/node-esm/meta.json +1 -1
  14. package/dist/lib/node-esm/meta.mjs +1 -1
  15. package/dist/lib/node-esm/types/index.mjs +64 -4
  16. package/dist/lib/node-esm/types/index.mjs.map +4 -4
  17. package/dist/types/src/ExplorerPlugin.d.ts.map +1 -1
  18. package/dist/types/src/capabilities/index.d.ts +2 -1
  19. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  20. package/dist/types/src/capabilities/react-surface.d.ts +5 -0
  21. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
  22. package/dist/types/src/components/Chart/Chart.stories.d.ts.map +1 -1
  23. package/dist/types/src/components/Globe/Globe.stories.d.ts.map +1 -1
  24. package/dist/types/src/components/Graph/D3ForceGraph.d.ts +6 -5
  25. package/dist/types/src/components/Graph/D3ForceGraph.d.ts.map +1 -1
  26. package/dist/types/src/components/Graph/D3ForceGraph.stories.d.ts +4 -2
  27. package/dist/types/src/components/Graph/D3ForceGraph.stories.d.ts.map +1 -1
  28. package/dist/types/src/components/Graph/ForceGraph.stories.d.ts +1 -1
  29. package/dist/types/src/components/Tree/Tree.stories.d.ts.map +1 -1
  30. package/dist/types/src/components/Tree/types/tree.d.ts +3 -3
  31. package/dist/types/src/components/Tree/types/tree.d.ts.map +1 -1
  32. package/dist/types/src/components/index.d.ts +0 -2
  33. package/dist/types/src/components/index.d.ts.map +1 -1
  34. package/dist/types/src/containers/ExplorerContainer/ExplorerContainer.d.ts +6 -0
  35. package/dist/types/src/containers/ExplorerContainer/ExplorerContainer.d.ts.map +1 -0
  36. package/dist/types/src/containers/ExplorerContainer/index.d.ts +2 -0
  37. package/dist/types/src/containers/ExplorerContainer/index.d.ts.map +1 -0
  38. package/dist/types/src/containers/index.d.ts +3 -0
  39. package/dist/types/src/containers/index.d.ts.map +1 -0
  40. package/dist/types/src/hooks/useGraphModel.d.ts.map +1 -1
  41. package/dist/types/src/translations.d.ts +28 -26
  42. package/dist/types/src/translations.d.ts.map +1 -1
  43. package/dist/types/src/types/ExplorerAction.d.ts.map +1 -1
  44. package/dist/types/src/types/Graph.d.ts +3 -10
  45. package/dist/types/src/types/Graph.d.ts.map +1 -1
  46. package/dist/types/tsconfig.tsbuildinfo +1 -1
  47. package/package.json +46 -37
  48. package/src/ExplorerPlugin.tsx +29 -16
  49. package/src/capabilities/index.ts +3 -1
  50. package/src/capabilities/react-surface.tsx +30 -0
  51. package/src/components/Chart/Chart.stories.tsx +2 -3
  52. package/src/components/Globe/Globe.stories.tsx +2 -3
  53. package/src/components/Graph/D3ForceGraph.stories.tsx +16 -16
  54. package/src/components/Graph/D3ForceGraph.tsx +82 -75
  55. package/src/components/Graph/ForceGraph.stories.tsx +16 -16
  56. package/src/components/Graph/testing.ts +2 -2
  57. package/src/components/Tree/Tree.stories.tsx +7 -5
  58. package/src/components/Tree/types/tree.test.ts +2 -3
  59. package/src/components/Tree/types/tree.ts +9 -9
  60. package/src/components/index.ts +0 -4
  61. package/src/containers/ExplorerContainer/ExplorerContainer.tsx +53 -0
  62. package/src/containers/ExplorerContainer/index.ts +5 -0
  63. package/src/containers/index.ts +7 -0
  64. package/src/hooks/useGraphModel.ts +18 -13
  65. package/src/meta.ts +1 -1
  66. package/src/translations.ts +13 -12
  67. package/src/types/ExplorerAction.ts +0 -1
  68. package/src/types/Graph.ts +11 -24
  69. package/src/typings.d.ts +8 -0
  70. package/dist/lib/browser/ExplorerContainer-BFAWRIAJ.mjs +0 -45
  71. package/dist/lib/browser/ExplorerContainer-BFAWRIAJ.mjs.map +0 -7
  72. package/dist/lib/browser/chunk-AGZAGILW.mjs +0 -11076
  73. package/dist/lib/browser/chunk-AGZAGILW.mjs.map +0 -7
  74. package/dist/lib/browser/chunk-BZMTFAP3.mjs +0 -34
  75. package/dist/lib/browser/chunk-BZMTFAP3.mjs.map +0 -7
  76. package/dist/lib/browser/chunk-DXORXPUJ.mjs +0 -83
  77. package/dist/lib/browser/chunk-DXORXPUJ.mjs.map +0 -7
  78. package/dist/lib/browser/chunk-MGBT2ZFU.mjs +0 -177
  79. package/dist/lib/browser/chunk-MGBT2ZFU.mjs.map +0 -7
  80. package/dist/lib/browser/react-surface-24INQLMB.mjs +0 -35
  81. package/dist/lib/browser/react-surface-24INQLMB.mjs.map +0 -7
  82. package/dist/lib/node-esm/ExplorerContainer-YQ2KKBVS.mjs +0 -46
  83. package/dist/lib/node-esm/ExplorerContainer-YQ2KKBVS.mjs.map +0 -7
  84. package/dist/lib/node-esm/chunk-IPIGIQHX.mjs +0 -36
  85. package/dist/lib/node-esm/chunk-IPIGIQHX.mjs.map +0 -7
  86. package/dist/lib/node-esm/chunk-QLMTN2XI.mjs +0 -11078
  87. package/dist/lib/node-esm/chunk-QLMTN2XI.mjs.map +0 -7
  88. package/dist/lib/node-esm/chunk-UCH3WYRD.mjs +0 -84
  89. package/dist/lib/node-esm/chunk-UCH3WYRD.mjs.map +0 -7
  90. package/dist/lib/node-esm/chunk-YWJBDETV.mjs +0 -179
  91. package/dist/lib/node-esm/chunk-YWJBDETV.mjs.map +0 -7
  92. package/dist/lib/node-esm/react-surface-F465WXH7.mjs +0 -36
  93. package/dist/lib/node-esm/react-surface-F465WXH7.mjs.map +0 -7
  94. package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
  95. package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
  96. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +0 -5
  97. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
  98. package/dist/types/src/components/ExplorerContainer.d.ts +0 -7
  99. package/dist/types/src/components/ExplorerContainer.d.ts.map +0 -1
  100. package/src/capabilities/react-surface/index.ts +0 -7
  101. package/src/capabilities/react-surface/react-surface.tsx +0 -30
  102. package/src/components/ExplorerContainer.tsx +0 -52
@@ -1,84 +0,0 @@
1
- import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
- import {
3
- __export
4
- } from "./chunk-HSLMI22Q.mjs";
5
-
6
- // src/types/ExplorerAction.ts
7
- var ExplorerAction_exports = {};
8
- __export(ExplorerAction_exports, {
9
- GraphProps: () => GraphProps
10
- });
11
- import * as Schema from "effect/Schema";
12
- import { TypeInputOptionsAnnotation } from "@dxos/plugin-space/types";
13
- var GraphProps = Schema.Struct({
14
- name: Schema.optional(Schema.String),
15
- // TODO(wittjosiah): This should be a query input instead.
16
- typename: Schema.String.pipe(Schema.annotations({
17
- title: "Select type"
18
- }), TypeInputOptionsAnnotation.set({
19
- location: [
20
- "database",
21
- "runtime"
22
- ],
23
- kind: [
24
- "user"
25
- ],
26
- registered: [
27
- "registered"
28
- ]
29
- }), Schema.optional)
30
- });
31
-
32
- // src/types/Graph.ts
33
- var Graph_exports = {};
34
- __export(Graph_exports, {
35
- Graph: () => Graph,
36
- GraphV1: () => GraphV1,
37
- make: () => make
38
- });
39
- import * as Schema2 from "effect/Schema";
40
- import { Filter, Obj, Query, QueryAST, Ref, Type } from "@dxos/echo";
41
- import { FormInputAnnotation, LabelAnnotation } from "@dxos/echo/internal";
42
- import { View, ViewAnnotation } from "@dxos/schema";
43
- var GraphSchema = Schema2.Struct({
44
- name: Schema2.optional(Schema2.String),
45
- view: Type.Ref(View.View).pipe(FormInputAnnotation.set(false)),
46
- query: Schema2.Struct({
47
- raw: Schema2.optional(Schema2.String),
48
- ast: QueryAST.Query
49
- }).pipe(Schema2.mutable, FormInputAnnotation.set(false))
50
- }).pipe(Type.object({
51
- typename: "dxos.org/type/Graph",
52
- version: "0.2.0"
53
- }), LabelAnnotation.set([
54
- "name"
55
- ]), ViewAnnotation.set(true));
56
- var Graph = GraphSchema;
57
- var make = ({ name, query = {
58
- raw: "",
59
- ast: Query.select(Filter.nothing()).ast
60
- }, view }) => {
61
- return Obj.make(Graph, {
62
- name,
63
- view: Ref.make(view),
64
- query
65
- });
66
- };
67
- var GraphV1 = Schema2.Struct({
68
- name: Schema2.optional(Schema2.String),
69
- query: Schema2.Struct({
70
- raw: Schema2.optional(Schema2.String),
71
- ast: QueryAST.Query
72
- }).pipe(Schema2.mutable)
73
- }).pipe(Type.object({
74
- typename: "dxos.org/type/Graph",
75
- version: "0.1.0"
76
- }), LabelAnnotation.set([
77
- "name"
78
- ]));
79
-
80
- export {
81
- ExplorerAction_exports,
82
- Graph_exports
83
- };
84
- //# sourceMappingURL=chunk-UCH3WYRD.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(Schema.mutable, 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 }).pipe(Schema.mutable),\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;IAC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ema", "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", "mutable", "object", "typename", "version", "LabelAnnotation", "ViewAnnotation", "Graph", "make", "select", "Filter", "nothing", "Obj", "GraphV1"]
7
- }
@@ -1,179 +0,0 @@
1
- import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
-
3
- // src/components/Graph/D3ForceGraph.tsx
4
- import React, { useCallback, useEffect, useMemo, useRef } from "react";
5
- import { Obj } from "@dxos/echo";
6
- import { SelectionModel } from "@dxos/graph";
7
- import { GraphForceProjector, SVG } from "@dxos/react-ui-graph";
8
- import { getHashStyles } from "@dxos/ui-theme";
9
- import "@dxos/react-ui-graph/styles/graph.css";
10
- var D3ForceGraph = ({ classNames, model, selection: _selection, grid, ...props }) => {
11
- const context = useRef(null);
12
- const projector = useMemo(() => {
13
- if (context.current) {
14
- return new GraphForceProjector(context.current, {
15
- attributes: {
16
- linkForce: (edge) => {
17
- return edge.data?.object?.active !== false;
18
- }
19
- },
20
- forces: {
21
- point: {
22
- strength: 0.01
23
- }
24
- }
25
- });
26
- }
27
- }, [
28
- context.current
29
- ]);
30
- const graph = useRef(null);
31
- const selection = useMemo(() => _selection ?? new SelectionModel(), [
32
- _selection
33
- ]);
34
- useEffect(() => selection.subscribe(() => graph.current?.repaint()), [
35
- selection
36
- ]);
37
- const handleSelect = useCallback((node) => {
38
- if (selection.contains(node.id)) {
39
- selection.remove(node.id);
40
- } else {
41
- selection.add(node.id);
42
- }
43
- }, [
44
- selection
45
- ]);
46
- return /* @__PURE__ */ React.createElement(SVG.Root, {
47
- ref: context,
48
- classNames
49
- }, /* @__PURE__ */ React.createElement(SVG.Markers, null), grid && /* @__PURE__ */ React.createElement(SVG.Grid, {
50
- axis: true
51
- }), /* @__PURE__ */ React.createElement(SVG.Zoom, {
52
- extent: [
53
- 1 / 2,
54
- 2
55
- ]
56
- }, /* @__PURE__ */ React.createElement(SVG.Graph, {
57
- ...props,
58
- ref: graph,
59
- model,
60
- projector,
61
- labels: {
62
- text: (node) => {
63
- return node.data?.data.label ?? node.id;
64
- }
65
- },
66
- attributes: {
67
- node: (node) => {
68
- const obj = node.data?.data.object;
69
- return {
70
- data: {
71
- color: getHashStyles(obj && Obj.getTypename(obj))?.hue
72
- },
73
- classes: {
74
- "dx-selected": selection.contains(node.id)
75
- }
76
- };
77
- }
78
- },
79
- onSelect: handleSelect
80
- })));
81
- };
82
-
83
- // src/components/Graph/ForceGraph.tsx
84
- import { forceLink, forceManyBody } from "d3";
85
- import NativeForceGraph from "force-graph";
86
- import React2, { useEffect as useEffect2, useRef as useRef2, useState } from "react";
87
- import { useResizeDetector } from "react-resize-detector";
88
- import { filterObjectsSync } from "@dxos/plugin-search";
89
-
90
- // src/components/Graph/adapter.ts
91
- var GraphAdapter = class {
92
- graph;
93
- _nodes = [];
94
- _links = [];
95
- constructor(graph) {
96
- this.graph = graph;
97
- this._nodes = graph.nodes.map((node) => ({
98
- id: node.id,
99
- type: node.type,
100
- data: node.data
101
- }));
102
- const nodeIds = new Set(this._nodes.map((node) => node.id));
103
- this._links = graph.edges.filter((edge) => nodeIds.has(edge.source) && nodeIds.has(edge.target)).map((edge) => ({
104
- type: edge.type,
105
- source: edge.source,
106
- target: edge.target,
107
- data: edge.data
108
- }));
109
- }
110
- get nodes() {
111
- return this._nodes;
112
- }
113
- get links() {
114
- return this._links;
115
- }
116
- };
117
-
118
- // src/components/Graph/ForceGraph.tsx
119
- var ForceGraph = ({ model, match }) => {
120
- const { ref, width, height } = useResizeDetector({
121
- refreshRate: 200
122
- });
123
- const rootRef = useRef2(null);
124
- const forceGraph = useRef2(null);
125
- const filteredRef = useRef2([]);
126
- filteredRef.current = filterObjectsSync(model?.objects ?? [], match);
127
- const [data, setData] = useState();
128
- useEffect2(() => {
129
- return model?.subscribe((model2) => {
130
- setData(new GraphAdapter(model2.graph));
131
- });
132
- }, [
133
- model
134
- ]);
135
- useEffect2(() => {
136
- if (rootRef.current) {
137
- forceGraph.current = new NativeForceGraph(rootRef.current).nodeRelSize(6).nodeLabel((node) => node.type === "schema" ? node.data.typename : node.data.label ?? node.id).nodeAutoColorBy((node) => node.type === "schema" ? "schema" : node.data.typename).linkAutoColorBy((link) => link.type);
138
- }
139
- return () => {
140
- forceGraph.current?.pauseAnimation().graphData({
141
- nodes: [],
142
- links: []
143
- });
144
- forceGraph.current = null;
145
- };
146
- }, []);
147
- useEffect2(() => {
148
- if (!data || !width || !height || !forceGraph.current) {
149
- return;
150
- }
151
- forceGraph.current.pauseAnimation().width(width).height(height).onEngineStop(() => {
152
- handleZoomToFit();
153
- }).onNodeClick((node) => {
154
- forceGraph.current?.emitParticle(node);
155
- }).d3Force("link", forceLink().distance(160).strength(0.5)).d3Force("charge", forceManyBody().strength(-30)).graphData(data).warmupTicks(100).cooldownTime(1e3).resumeAnimation();
156
- }, [
157
- data,
158
- width,
159
- height,
160
- forceGraph.current
161
- ]);
162
- const handleZoomToFit = () => {
163
- forceGraph.current?.zoomToFit(400, 40);
164
- };
165
- return /* @__PURE__ */ React2.createElement("div", {
166
- ref,
167
- className: "relative grow",
168
- onClick: handleZoomToFit
169
- }, /* @__PURE__ */ React2.createElement("div", {
170
- ref: rootRef,
171
- className: "absolute inset-0"
172
- }));
173
- };
174
-
175
- export {
176
- D3ForceGraph,
177
- ForceGraph
178
- };
179
- //# sourceMappingURL=chunk-YWJBDETV.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/Graph/D3ForceGraph.tsx", "../../../src/components/Graph/ForceGraph.tsx", "../../../src/components/Graph/adapter.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { useCallback, useEffect, useMemo, useRef } from 'react';\n\nimport { Obj } from '@dxos/echo';\nimport { SelectionModel } from '@dxos/graph';\nimport { type ThemedClassName } from '@dxos/react-ui';\nimport {\n type GraphController,\n GraphForceProjector,\n type GraphLayoutNode,\n type GraphProps,\n SVG,\n type SVGContext,\n} from '@dxos/react-ui-graph';\nimport { type SpaceGraphEdge, type SpaceGraphModel, type SpaceGraphNode } from '@dxos/schema';\nimport { getHashStyles } from '@dxos/ui-theme';\n\nimport '@dxos/react-ui-graph/styles/graph.css';\n\nexport type D3ForceGraphProps = ThemedClassName<\n {\n model?: SpaceGraphModel;\n match?: RegExp;\n selection?: SelectionModel;\n grid?: boolean;\n } & Pick<GraphProps, 'drag'>\n>;\n\nexport const D3ForceGraph = ({ classNames, model, selection: _selection, grid, ...props }: D3ForceGraphProps) => {\n const context = useRef<SVGContext>(null);\n const projector = useMemo<GraphForceProjector | undefined>(() => {\n if (context.current) {\n return new GraphForceProjector(context.current, {\n attributes: {\n linkForce: (edge) => {\n // TODO(burdon): Check type (currently assumes Employee property).\n // Edge shouldn't contribute to force if it's not active.\n return edge.data?.object?.active !== false;\n },\n },\n forces: {\n point: {\n strength: 0.01,\n },\n },\n });\n }\n }, [context.current]);\n\n const graph = useRef<GraphController>(null);\n const selection = useMemo(() => _selection ?? new SelectionModel(), [_selection]);\n useEffect(() => selection.subscribe(() => graph.current?.repaint()), [selection]);\n\n const handleSelect = useCallback<NonNullable<GraphProps['onSelect']>>(\n (node) => {\n if (selection.contains(node.id)) {\n selection.remove(node.id);\n } else {\n selection.add(node.id);\n }\n },\n [selection],\n );\n\n return (\n <SVG.Root ref={context} classNames={classNames}>\n <SVG.Markers />\n {grid && <SVG.Grid axis />}\n <SVG.Zoom extent={[1 / 2, 2]}>\n <SVG.Graph<SpaceGraphNode, SpaceGraphEdge>\n {...props}\n ref={graph}\n model={model}\n projector={projector}\n labels={{\n text: (node) => {\n return node.data?.data.label ?? node.id;\n },\n }}\n attributes={{\n node: (node: GraphLayoutNode<SpaceGraphNode>) => {\n const obj = node.data?.data.object;\n return {\n data: {\n color: getHashStyles(obj && Obj.getTypename(obj))?.hue,\n },\n classes: {\n 'dx-selected': selection.contains(node.id),\n },\n };\n },\n }}\n onSelect={handleSelect}\n />\n </SVG.Zoom>\n </SVG.Root>\n );\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { forceLink, forceManyBody } from 'd3';\nimport NativeForceGraph from 'force-graph';\nimport React, { type FC, useEffect, useRef, useState } from 'react';\nimport { useResizeDetector } from 'react-resize-detector';\n\nimport { type SearchResult, filterObjectsSync } from '@dxos/plugin-search';\nimport { type SpaceGraphModel } from '@dxos/schema';\n\nimport { GraphAdapter } from './adapter';\n\nexport type ForceGraphProps = {\n model?: SpaceGraphModel;\n match?: RegExp;\n};\n\nexport const ForceGraph: FC<ForceGraphProps> = ({ model, match }) => {\n const { ref, width, height } = useResizeDetector({ refreshRate: 200 });\n const rootRef = useRef<HTMLDivElement>(null);\n const forceGraph = useRef<NativeForceGraph>(null);\n\n const filteredRef = useRef<SearchResult[]>([]);\n filteredRef.current = filterObjectsSync(model?.objects ?? [], match);\n\n const [data, setData] = useState<GraphAdapter>();\n useEffect(() => {\n return model?.subscribe((model) => {\n setData(new GraphAdapter(model.graph));\n });\n }, [model]);\n\n useEffect(() => {\n if (rootRef.current) {\n // https://github.com/vasturiano/force-graph\n // https://github.com/vasturiano/3d-force-graph\n forceGraph.current = new NativeForceGraph(rootRef.current)\n // https://github.com/vasturiano/force-graph?tab=readme-ov-file#node-styling\n .nodeRelSize(6)\n .nodeLabel((node: any) => (node.type === 'schema' ? node.data.typename : (node.data.label ?? node.id)))\n .nodeAutoColorBy((node: any) => (node.type === 'schema' ? 'schema' : node.data.typename))\n\n // https://github.com/vasturiano/force-graph?tab=readme-ov-file#link-styling\n .linkAutoColorBy((link: any) => link.type);\n }\n\n return () => {\n forceGraph.current?.pauseAnimation().graphData({ nodes: [], links: [] });\n forceGraph.current = null;\n };\n }, []);\n\n useEffect(() => {\n if (!data || !width || !height || !forceGraph.current) {\n return;\n }\n\n // https://github.com/vasturiano/force-graph?tab=readme-ov-file#container-layout\n forceGraph.current\n .pauseAnimation()\n .width(width)\n .height(height)\n .onEngineStop(() => {\n handleZoomToFit();\n })\n .onNodeClick((node: any) => {\n forceGraph.current?.emitParticle(node);\n })\n\n // https://github.com/vasturiano/force-graph?tab=readme-ov-file#force-engine-d3-force-configuration\n // .d3Force('center', forceCenter().strength(0.9))\n .d3Force('link', forceLink().distance(160).strength(0.5))\n .d3Force('charge', forceManyBody().strength(-30))\n\n .graphData(data)\n .warmupTicks(100)\n .cooldownTime(1_000)\n .resumeAnimation();\n }, [data, width, height, forceGraph.current]);\n\n const handleZoomToFit = () => {\n forceGraph.current?.zoomToFit(400, 40);\n };\n\n return (\n <div ref={ref} className='relative grow' onClick={handleZoomToFit}>\n <div ref={rootRef} className='absolute inset-0' />\n </div>\n );\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Graph } from '@dxos/graph';\n\nexport type GraphNode = {\n id?: string;\n};\n\nexport type GraphLink = {\n source?: string;\n target?: string;\n};\n\nexport type GraphData = {\n nodes: GraphNode[];\n links: GraphLink[];\n};\n\n/**\n * Map common graph to force-graph format.\n */\nexport class GraphAdapter implements GraphData {\n private readonly _nodes: GraphNode[] = [];\n private readonly _links: GraphLink[] = [];\n\n constructor(private readonly graph: Graph.Any) {\n this._nodes = graph.nodes.map((node: Graph.Node.Any) => ({\n id: node.id,\n type: node.type,\n data: node.data,\n }));\n\n // Build a set of node IDs for efficient lookup.\n const nodeIds = new Set(this._nodes.map((node) => node.id));\n\n // Filter out edges where source or target node doesn't exist.\n this._links = graph.edges\n .filter((edge: Graph.Edge.Any) => nodeIds.has(edge.source) && nodeIds.has(edge.target))\n .map((edge: Graph.Edge.Any) => ({\n type: edge.type,\n source: edge.source,\n target: edge.target,\n data: edge.data,\n }));\n }\n\n get nodes() {\n return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EACd7B,MAAMA,KAAAA,EACNC,OAAOA,MAAAA,EACPgC,aAAa,MAAA;AACZC,sBAAAA;IACF,CAAA,EACCC,YAAY,CAACd,SAAAA;AACZf,iBAAWE,SAAS4B,aAAaf,IAAAA;IACnC,CAAA,EAICgB,QAAQ,QAAQC,UAAAA,EAAYC,SAAS,GAAA,EAAKC,SAAS,GAAA,CAAA,EACnDH,QAAQ,UAAUI,cAAAA,EAAgBD,SAAS,GAAC,CAAA,EAE5CV,UAAUnB,IAAAA,EACV+B,YAAY,GAAA,EACZC,aAAa,GAAA,EACbC,gBAAe;EACpB,GAAG;IAACjC;IAAMX;IAAOC;IAAQK,WAAWE;GAAQ;AAE5C,QAAM0B,kBAAkB,MAAA;AACtB5B,eAAWE,SAASqC,UAAU,KAAK,EAAA;EACrC;AAEA,SACE,gBAAAC,OAAA,cAACC,OAAAA;IAAIhD;IAAUiD,WAAU;IAAgBC,SAASf;KAChD,gBAAAY,OAAA,cAACC,OAAAA;IAAIhD,KAAKK;IAAS4C,WAAU;;AAGnC;",
6
- "names": ["React", "useCallback", "useEffect", "useMemo", "useRef", "Obj", "SelectionModel", "GraphForceProjector", "SVG", "getHashStyles", "D3ForceGraph", "classNames", "model", "selection", "_selection", "grid", "props", "context", "useRef", "projector", "useMemo", "current", "GraphForceProjector", "attributes", "linkForce", "edge", "data", "object", "active", "forces", "point", "strength", "graph", "SelectionModel", "useEffect", "subscribe", "repaint", "handleSelect", "useCallback", "node", "contains", "id", "remove", "add", "SVG", "Root", "ref", "Markers", "Grid", "axis", "Zoom", "extent", "Graph", "labels", "text", "label", "obj", "color", "getHashStyles", "Obj", "getTypename", "hue", "classes", "onSelect", "forceLink", "forceManyBody", "NativeForceGraph", "React", "useEffect", "useRef", "useState", "useResizeDetector", "filterObjectsSync", "GraphAdapter", "_nodes", "_links", "graph", "nodes", "map", "node", "id", "type", "data", "nodeIds", "Set", "edges", "filter", "edge", "has", "source", "target", "links", "ForceGraph", "model", "match", "ref", "width", "height", "useResizeDetector", "refreshRate", "rootRef", "useRef", "forceGraph", "filteredRef", "current", "filterObjectsSync", "objects", "data", "setData", "useState", "useEffect", "subscribe", "GraphAdapter", "graph", "NativeForceGraph", "nodeRelSize", "nodeLabel", "node", "type", "typename", "label", "id", "nodeAutoColorBy", "linkAutoColorBy", "link", "pauseAnimation", "graphData", "nodes", "links", "onEngineStop", "handleZoomToFit", "onNodeClick", "emitParticle", "d3Force", "forceLink", "distance", "strength", "forceManyBody", "warmupTicks", "cooldownTime", "resumeAnimation", "zoomToFit", "React", "div", "className", "onClick"]
7
- }
@@ -1,36 +0,0 @@
1
- import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
- import {
3
- ExplorerContainer
4
- } from "./chunk-QLMTN2XI.mjs";
5
- import {
6
- meta
7
- } from "./chunk-DK77RB6M.mjs";
8
- import {
9
- Graph_exports
10
- } from "./chunk-UCH3WYRD.mjs";
11
- import "./chunk-YWJBDETV.mjs";
12
- import "./chunk-HSLMI22Q.mjs";
13
-
14
- // src/capabilities/react-surface/react-surface.tsx
15
- import * as Effect from "effect/Effect";
16
- import React from "react";
17
- import { Capability, Common } from "@dxos/app-framework";
18
- import { Obj } from "@dxos/echo";
19
- var react_surface_default = Capability.makeModule(() => Effect.succeed(Capability.contributes(Common.Capability.ReactSurface, Common.createSurface({
20
- id: `${meta.id}/article`,
21
- role: [
22
- "article",
23
- "section"
24
- ],
25
- filter: (data) => Obj.instanceOf(Graph_exports.Graph, data.subject),
26
- component: ({ data, role }) => {
27
- return /* @__PURE__ */ React.createElement(ExplorerContainer, {
28
- role,
29
- subject: data.subject
30
- });
31
- }
32
- }))));
33
- export {
34
- react_surface_default as default
35
- };
36
- //# sourceMappingURL=react-surface-F465WXH7.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/capabilities/react-surface/react-surface.tsx"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport React from 'react';\n\nimport { Capability, Common } from '@dxos/app-framework';\nimport { Obj } from '@dxos/echo';\nimport { type View } from '@dxos/schema';\n\nimport { ExplorerContainer } from '../../components';\nimport { meta } from '../../meta';\nimport { Graph } from '../../types';\n\nexport default Capability.makeModule(() =>\n Effect.succeed(\n Capability.contributes(\n Common.Capability.ReactSurface,\n Common.createSurface({\n id: `${meta.id}/article`,\n role: ['article', 'section'],\n filter: (data): data is { subject: View.View } => Obj.instanceOf(Graph.Graph, data.subject),\n component: ({ data, role }) => {\n return <ExplorerContainer role={role} subject={data.subject} />;\n },\n }),\n ),\n ),\n);\n"],
5
- "mappings": ";;;;;;;;;;;;;;AAIA,YAAYA,YAAY;AACxB,OAAOC,WAAW;AAElB,SAASC,YAAYC,cAAc;AACnC,SAASC,WAAW;AAOpB,IAAA,wBAAeC,WAAWC,WAAW,MAC5BC,eACLF,WAAWG,YACTC,OAAOJ,WAAWK,cAClBD,OAAOE,cAAc;EACnBC,IAAI,GAAGC,KAAKD,EAAE;EACdE,MAAM;IAAC;IAAW;;EAClBC,QAAQ,CAACC,SAAyCC,IAAIC,WAAWC,cAAMA,OAAOH,KAAKI,OAAO;EAC1FC,WAAW,CAAC,EAAEL,MAAMF,KAAI,MAAE;AACxB,WAAO,sBAAA,cAACQ,mBAAAA;MAAkBR;MAAYM,SAASJ,KAAKI;;EACtD;AACF,CAAA,CAAA,CAAA,CAAA;",
6
- "names": ["Effect", "React", "Capability", "Common", "Obj", "Capability", "makeModule", "succeed", "contributes", "Common", "ReactSurface", "createSurface", "id", "meta", "role", "filter", "data", "Obj", "instanceOf", "Graph", "subject", "component", "ExplorerContainer"]
7
- }
@@ -1,3 +0,0 @@
1
- import { Capability } from '@dxos/app-framework';
2
- export declare const ReactSurface: Capability.LazyCapability<void, Capability.Capability<Capability.InterfaceDef<import("@dxos/app-framework/Common").Capability.ReactSurface>>, Error>;
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/capabilities/react-surface/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,eAAO,MAAM,YAAY,sJAAmE,CAAC"}
@@ -1,5 +0,0 @@
1
- import * as Effect from 'effect/Effect';
2
- import { Capability, Common } from '@dxos/app-framework';
3
- declare const _default: (props?: void | undefined) => Effect.Effect<Capability.Capability<Capability.InterfaceDef<Common.Capability.ReactSurface>>, never, never>;
4
- export default _default;
5
- //# sourceMappingURL=react-surface.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"react-surface.d.ts","sourceRoot":"","sources":["../../../../../src/capabilities/react-surface/react-surface.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAGxC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;;AAQzD,wBAcE"}
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
- import { type SurfaceComponentProps } from '@dxos/app-framework/react';
3
- import { type View } from '@dxos/schema';
4
- export type ExplorerContainerProps = SurfaceComponentProps<View.View>;
5
- declare const ExplorerContainer: ({ role, subject: view }: ExplorerContainerProps) => React.JSX.Element | null;
6
- export default ExplorerContainer;
7
- //# sourceMappingURL=ExplorerContainer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExplorerContainer.d.ts","sourceRoot":"","sources":["../../../../src/components/ExplorerContainer.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAE9D,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAQvE,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,cAAc,CAAC;AAMzC,MAAM,MAAM,sBAAsB,GAAG,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEtE,QAAA,MAAM,iBAAiB,GAAI,yBAAyB,sBAAsB,6BA2BzE,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
@@ -1,7 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { Capability } from '@dxos/app-framework';
6
-
7
- export const ReactSurface = Capability.lazy('ReactSurface', () => import('./react-surface'));
@@ -1,30 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import * as Effect from 'effect/Effect';
6
- import React from 'react';
7
-
8
- import { Capability, Common } from '@dxos/app-framework';
9
- import { Obj } from '@dxos/echo';
10
- import { type View } from '@dxos/schema';
11
-
12
- import { ExplorerContainer } from '../../components';
13
- import { meta } from '../../meta';
14
- import { Graph } from '../../types';
15
-
16
- export default Capability.makeModule(() =>
17
- Effect.succeed(
18
- Capability.contributes(
19
- Common.Capability.ReactSurface,
20
- Common.createSurface({
21
- id: `${meta.id}/article`,
22
- role: ['article', 'section'],
23
- filter: (data): data is { subject: View.View } => Obj.instanceOf(Graph.Graph, data.subject),
24
- component: ({ data, role }) => {
25
- return <ExplorerContainer role={role} subject={data.subject} />;
26
- },
27
- }),
28
- ),
29
- ),
30
- );
@@ -1,52 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import React, { useCallback, useMemo, useState } from 'react';
6
-
7
- import { type SurfaceComponentProps } from '@dxos/app-framework/react';
8
- import { type Filter } from '@dxos/echo';
9
- import { QueryBuilder } from '@dxos/echo-query';
10
- import { useGlobalSearch } from '@dxos/plugin-search';
11
- import { getSpace } from '@dxos/react-client/echo';
12
- import { Toolbar } from '@dxos/react-ui';
13
- import { QueryEditor, type QueryEditorProps } from '@dxos/react-ui-components';
14
- import { Layout } from '@dxos/react-ui-mosaic';
15
- import { type View } from '@dxos/schema';
16
-
17
- import { useGraphModel } from '../hooks';
18
-
19
- import { D3ForceGraph } from './Graph';
20
-
21
- export type ExplorerContainerProps = SurfaceComponentProps<View.View>;
22
-
23
- const ExplorerContainer = ({ role, subject: view }: ExplorerContainerProps) => {
24
- const space = getSpace(view);
25
- const [filter, setFilter] = useState<Filter.Any>();
26
- const model = useGraphModel(space, filter);
27
- const { match } = useGlobalSearch();
28
-
29
- const builder = useMemo(() => new QueryBuilder(), []);
30
- const handleChange = useCallback<NonNullable<QueryEditorProps['onChange']>>((value) => {
31
- setFilter(builder.build(value).filter);
32
- }, []);
33
-
34
- const showToolbar = role === 'article';
35
-
36
- if (!space || !model) {
37
- return null;
38
- }
39
-
40
- return (
41
- <Layout.Main role={role} toolbar={showToolbar}>
42
- {showToolbar && (
43
- <Toolbar.Root>
44
- <QueryEditor db={space.db} onChange={handleChange} />
45
- </Toolbar.Root>
46
- )}
47
- <D3ForceGraph model={model} match={match} />
48
- </Layout.Main>
49
- );
50
- };
51
-
52
- export default ExplorerContainer;