@dxos/plugin-explorer 0.8.2-main.fbd8ed0 → 0.8.2-staging.42af850

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 (143) hide show
  1. package/dist/lib/browser/ExplorerContainer-BBZ54DJS.mjs +37 -0
  2. package/dist/lib/browser/ExplorerContainer-BBZ54DJS.mjs.map +7 -0
  3. package/dist/lib/browser/{chunk-JL7ZGOFE.mjs → chunk-73GQ46YO.mjs} +415 -155
  4. package/dist/lib/{node-esm/chunk-MUHCE377.mjs.map → browser/chunk-73GQ46YO.mjs.map} +4 -4
  5. package/dist/lib/browser/{chunk-HKQSZX7S.mjs → chunk-73YTQHOT.mjs} +3 -3
  6. package/dist/lib/browser/{chunk-HKQSZX7S.mjs.map → chunk-73YTQHOT.mjs.map} +1 -1
  7. package/dist/lib/browser/chunk-M2BGAY6H.mjs +177 -0
  8. package/dist/lib/browser/chunk-M2BGAY6H.mjs.map +7 -0
  9. package/dist/lib/browser/{chunk-Z2SDLMQM.mjs → chunk-OBAFAA5V.mjs} +3 -3
  10. package/dist/lib/browser/{chunk-Z2SDLMQM.mjs.map → chunk-OBAFAA5V.mjs.map} +1 -1
  11. package/dist/lib/browser/chunk-SLB2F5AO.mjs +30 -0
  12. package/dist/lib/browser/chunk-SLB2F5AO.mjs.map +7 -0
  13. package/dist/lib/browser/index.mjs +15 -11
  14. package/dist/lib/browser/index.mjs.map +1 -1
  15. package/dist/lib/browser/{intent-resolver-7JF4DU2C.mjs → intent-resolver-FJDVBDE3.mjs} +3 -3
  16. package/dist/lib/browser/meta.json +1 -1
  17. package/dist/lib/browser/meta.mjs +1 -1
  18. package/dist/lib/browser/{react-surface-JLE6GLG6.mjs → react-surface-H3YDMXAQ.mjs} +5 -5
  19. package/dist/lib/browser/types/index.mjs +2 -2
  20. package/dist/lib/node/{ExplorerContainer-4RMWCWRX.cjs → ExplorerContainer-MVP2AM7R.cjs} +24 -16
  21. package/dist/lib/node/ExplorerContainer-MVP2AM7R.cjs.map +7 -0
  22. package/dist/lib/node/chunk-4T4LCT5R.cjs +52 -0
  23. package/dist/lib/node/chunk-4T4LCT5R.cjs.map +7 -0
  24. package/dist/lib/node/{chunk-R4TOGRPE.cjs → chunk-72H5HBTK.cjs} +414 -153
  25. package/dist/lib/node/{chunk-R4TOGRPE.cjs.map → chunk-72H5HBTK.cjs.map} +4 -4
  26. package/dist/lib/node/{chunk-VB3QE6XY.cjs → chunk-BCDVG2CH.cjs} +6 -6
  27. package/dist/lib/node/{chunk-VB3QE6XY.cjs.map → chunk-BCDVG2CH.cjs.map} +1 -1
  28. package/dist/lib/node/{chunk-6R5P3UVS.cjs → chunk-MLRYW4WQ.cjs} +7 -7
  29. package/dist/lib/node/{chunk-6R5P3UVS.cjs.map → chunk-MLRYW4WQ.cjs.map} +1 -1
  30. package/dist/lib/node/chunk-NELWWGBU.cjs +204 -0
  31. package/dist/lib/node/chunk-NELWWGBU.cjs.map +7 -0
  32. package/dist/lib/node/index.cjs +34 -31
  33. package/dist/lib/node/index.cjs.map +1 -1
  34. package/dist/lib/node/{intent-resolver-VDAHQEE7.cjs → intent-resolver-DRT67ZU4.cjs} +8 -8
  35. package/dist/lib/node/meta.cjs +3 -3
  36. package/dist/lib/node/meta.cjs.map +1 -1
  37. package/dist/lib/node/meta.json +1 -1
  38. package/dist/lib/node/{react-surface-F66QYWDR.cjs → react-surface-6ESLSM33.cjs} +11 -11
  39. package/dist/lib/node/types/index.cjs +4 -4
  40. package/dist/lib/node/types/index.cjs.map +1 -1
  41. package/dist/lib/node-esm/ExplorerContainer-APGUQI4M.mjs +38 -0
  42. package/dist/lib/node-esm/ExplorerContainer-APGUQI4M.mjs.map +7 -0
  43. package/dist/lib/node-esm/{chunk-MUHCE377.mjs → chunk-34X2VFQN.mjs} +415 -154
  44. package/dist/lib/{browser/chunk-JL7ZGOFE.mjs.map → node-esm/chunk-34X2VFQN.mjs.map} +4 -4
  45. package/dist/lib/node-esm/{chunk-PUFSCMN4.mjs → chunk-3CMBLK6W.mjs} +3 -3
  46. package/dist/lib/node-esm/{chunk-PUFSCMN4.mjs.map → chunk-3CMBLK6W.mjs.map} +1 -1
  47. package/dist/lib/node-esm/{chunk-QOJSLABX.mjs → chunk-N6VEANUZ.mjs} +3 -3
  48. package/dist/lib/node-esm/{chunk-QOJSLABX.mjs.map → chunk-N6VEANUZ.mjs.map} +1 -1
  49. package/dist/lib/node-esm/chunk-PVII2K2B.mjs +179 -0
  50. package/dist/lib/node-esm/chunk-PVII2K2B.mjs.map +7 -0
  51. package/dist/lib/node-esm/chunk-VSORIAHH.mjs +32 -0
  52. package/dist/lib/node-esm/chunk-VSORIAHH.mjs.map +7 -0
  53. package/dist/lib/node-esm/index.mjs +15 -11
  54. package/dist/lib/node-esm/index.mjs.map +1 -1
  55. package/dist/lib/node-esm/{intent-resolver-XWRVHP6H.mjs → intent-resolver-4RBV644N.mjs} +3 -3
  56. package/dist/lib/node-esm/meta.json +1 -1
  57. package/dist/lib/node-esm/meta.mjs +1 -1
  58. package/dist/lib/node-esm/{react-surface-4ZT5BQP6.mjs → react-surface-ZEVL3FXG.mjs} +5 -5
  59. package/dist/lib/node-esm/types/index.mjs +2 -2
  60. package/dist/types/src/components/ExplorerContainer.d.ts +4 -3
  61. package/dist/types/src/components/ExplorerContainer.d.ts.map +1 -1
  62. package/dist/types/src/components/Graph/D3ForceGraph.d.ts +14 -0
  63. package/dist/types/src/components/Graph/D3ForceGraph.d.ts.map +1 -0
  64. package/dist/types/src/components/Graph/D3ForceGraph.stories.d.ts +6 -0
  65. package/dist/types/src/components/Graph/D3ForceGraph.stories.d.ts.map +1 -0
  66. package/dist/types/src/components/Graph/ForceGraph.d.ts +8 -0
  67. package/dist/types/src/components/Graph/ForceGraph.d.ts.map +1 -0
  68. package/dist/types/src/components/Graph/{Graph.stories.d.ts → ForceGraph.stories.d.ts} +1 -1
  69. package/dist/types/src/components/Graph/ForceGraph.stories.d.ts.map +1 -0
  70. package/dist/types/src/components/Graph/adapter.d.ts +21 -0
  71. package/dist/types/src/components/Graph/adapter.d.ts.map +1 -0
  72. package/dist/types/src/components/Graph/index.d.ts +2 -2
  73. package/dist/types/src/components/Graph/index.d.ts.map +1 -1
  74. package/dist/types/src/components/Graph/testing.d.ts +14 -0
  75. package/dist/types/src/components/Graph/testing.d.ts.map +1 -0
  76. package/dist/types/src/components/Tree/Tree.d.ts.map +1 -1
  77. package/dist/types/src/components/Tree/testing/generator.d.ts +8 -0
  78. package/dist/types/src/components/Tree/testing/generator.d.ts.map +1 -0
  79. package/dist/types/src/components/Tree/testing/index.d.ts +2 -0
  80. package/dist/types/src/components/Tree/testing/index.d.ts.map +1 -0
  81. package/dist/types/src/components/Tree/types/index.d.ts +3 -0
  82. package/dist/types/src/components/Tree/types/index.d.ts.map +1 -0
  83. package/dist/types/src/components/Tree/types/tree.d.ts +83 -0
  84. package/dist/types/src/components/Tree/types/tree.d.ts.map +1 -0
  85. package/dist/types/src/components/Tree/types/tree.test.d.ts +2 -0
  86. package/dist/types/src/components/Tree/types/tree.test.d.ts.map +1 -0
  87. package/dist/types/src/components/Tree/types/types.d.ts +8 -0
  88. package/dist/types/src/components/Tree/types/types.d.ts.map +1 -0
  89. package/dist/types/src/components/index.d.ts +2 -2
  90. package/dist/types/src/hooks/index.d.ts +2 -0
  91. package/dist/types/src/hooks/index.d.ts.map +1 -0
  92. package/dist/types/src/hooks/useGraphModel.d.ts +4 -0
  93. package/dist/types/src/hooks/useGraphModel.d.ts.map +1 -0
  94. package/dist/types/src/index.d.ts +2 -1
  95. package/dist/types/src/index.d.ts.map +1 -1
  96. package/package.json +28 -28
  97. package/src/components/ExplorerContainer.tsx +11 -4
  98. package/src/components/Graph/D3ForceGraph.stories.tsx +64 -0
  99. package/src/components/Graph/D3ForceGraph.tsx +101 -0
  100. package/src/components/Graph/ForceGraph.stories.tsx +64 -0
  101. package/src/components/Graph/{Graph.tsx → ForceGraph.tsx} +19 -26
  102. package/src/components/Graph/adapter.ts +47 -0
  103. package/src/components/Graph/index.ts +2 -3
  104. package/src/components/Graph/testing.ts +57 -0
  105. package/src/components/Tree/Tree.stories.tsx +1 -1
  106. package/src/components/Tree/Tree.tsx +11 -18
  107. package/src/components/Tree/testing/generator.ts +46 -0
  108. package/src/components/Tree/testing/index.ts +5 -0
  109. package/src/components/Tree/types/index.ts +6 -0
  110. package/src/components/Tree/types/tree.test.ts +133 -0
  111. package/src/components/Tree/types/tree.ts +287 -0
  112. package/src/components/Tree/types/types.ts +41 -0
  113. package/src/hooks/index.ts +5 -0
  114. package/src/hooks/useGraphModel.ts +35 -0
  115. package/src/index.ts +2 -2
  116. package/src/meta.ts +2 -2
  117. package/dist/lib/browser/ExplorerContainer-6U4GS62Q.mjs +0 -27
  118. package/dist/lib/browser/ExplorerContainer-6U4GS62Q.mjs.map +0 -7
  119. package/dist/lib/browser/chunk-QRPUL5AH.mjs +0 -206
  120. package/dist/lib/browser/chunk-QRPUL5AH.mjs.map +0 -7
  121. package/dist/lib/node/ExplorerContainer-4RMWCWRX.cjs.map +0 -7
  122. package/dist/lib/node/chunk-4ZUNNUQD.cjs +0 -237
  123. package/dist/lib/node/chunk-4ZUNNUQD.cjs.map +0 -7
  124. package/dist/lib/node-esm/ExplorerContainer-3GOCCL7Q.mjs +0 -28
  125. package/dist/lib/node-esm/ExplorerContainer-3GOCCL7Q.mjs.map +0 -7
  126. package/dist/lib/node-esm/chunk-BJZBPCC3.mjs +0 -208
  127. package/dist/lib/node-esm/chunk-BJZBPCC3.mjs.map +0 -7
  128. package/dist/types/src/components/Graph/Graph.d.ts +0 -8
  129. package/dist/types/src/components/Graph/Graph.d.ts.map +0 -1
  130. package/dist/types/src/components/Graph/Graph.stories.d.ts.map +0 -1
  131. package/dist/types/src/components/Graph/graph-model.d.ts +0 -39
  132. package/dist/types/src/components/Graph/graph-model.d.ts.map +0 -1
  133. package/dist/types/src/components/Tree/types.d.ts +0 -8
  134. package/dist/types/src/components/Tree/types.d.ts.map +0 -1
  135. package/src/components/Graph/Graph.stories.tsx +0 -62
  136. package/src/components/Graph/graph-model.ts +0 -194
  137. package/src/components/Tree/types.ts +0 -40
  138. /package/dist/lib/browser/{intent-resolver-7JF4DU2C.mjs.map → intent-resolver-FJDVBDE3.mjs.map} +0 -0
  139. /package/dist/lib/browser/{react-surface-JLE6GLG6.mjs.map → react-surface-H3YDMXAQ.mjs.map} +0 -0
  140. /package/dist/lib/node/{intent-resolver-VDAHQEE7.cjs.map → intent-resolver-DRT67ZU4.cjs.map} +0 -0
  141. /package/dist/lib/node/{react-surface-F66QYWDR.cjs.map → react-surface-6ESLSM33.cjs.map} +0 -0
  142. /package/dist/lib/node-esm/{intent-resolver-XWRVHP6H.mjs.map → intent-resolver-4RBV644N.mjs.map} +0 -0
  143. /package/dist/lib/node-esm/{react-surface-4ZT5BQP6.mjs.map → react-surface-ZEVL3FXG.mjs.map} +0 -0
@@ -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 from 'react';\n\nimport { useGlobalSearch } from '@dxos/plugin-search';\nimport { getSpace } from '@dxos/react-client/echo';\nimport { StackItem } from '@dxos/react-ui-stack';\n\nimport { Graph } from './Graph';\nimport { type ViewType } from '../types';\n\nconst ExplorerContainer = ({ view, role }: { view: ViewType; role: string }) => {\n const space = getSpace(view);\n const { match } = useGlobalSearch();\n\n if (!space) {\n return null;\n }\n\n return (\n <StackItem.Content size={role === 'section' ? 'square' : 'intrinsic'}>\n <Graph space={space} match={match} />\n </StackItem.Content>\n );\n};\n\nexport default ExplorerContainer;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,mBAAkB;AAElB,2BAAgC;AAChC,kBAAyB;AACzB,4BAA0B;AAK1B,IAAMA,oBAAoB,CAAC,EAAEC,MAAMC,KAAI,MAAoC;AACzE,QAAMC,YAAQC,sBAASH,IAAAA;AACvB,QAAM,EAAEI,MAAK,QAAKC,sCAAAA;AAElB,MAAI,CAACH,OAAO;AACV,WAAO;EACT;AAEA,SACE,6BAAAI,QAAA,cAACC,gCAAUC,SAAO;IAACC,MAAMR,SAAS,YAAY,WAAW;KACvD,6BAAAK,QAAA,cAACI,6BAAAA;IAAMR;IAAcE;;AAG3B;AAEA,IAAA,4BAAeL;",
6
- "names": ["ExplorerContainer", "view", "role", "space", "getSpace", "match", "useGlobalSearch", "React", "StackItem", "Content", "size", "Graph"]
7
- }
@@ -1,237 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var chunk_4ZUNNUQD_exports = {};
30
- __export(chunk_4ZUNNUQD_exports, {
31
- Graph: () => Graph,
32
- SpaceGraphModel: () => SpaceGraphModel
33
- });
34
- module.exports = __toCommonJS(chunk_4ZUNNUQD_exports);
35
- var import_effect = require("effect");
36
- var import_echo_schema = require("@dxos/echo-schema");
37
- var import_gem_spore = require("@dxos/gem-spore");
38
- var import_log = require("@dxos/log");
39
- var import_types = require("@dxos/plugin-space/types");
40
- var import_echo = require("@dxos/react-client/echo");
41
- var import_d3 = require("d3");
42
- var import_force_graph = __toESM(require("force-graph"));
43
- var import_react = __toESM(require("react"));
44
- var import_react_resize_detector = require("react-resize-detector");
45
- var import_plugin_search = require("@dxos/plugin-search");
46
- var import_react_ui = require("@dxos/react-ui");
47
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-explorer/src/components/Graph/graph-model.ts";
48
- var SpaceGraphModel = class extends import_gem_spore.GraphModel {
49
- constructor(_options = {}) {
50
- super();
51
- this._options = _options;
52
- this._graph = {
53
- nodes: [],
54
- links: []
55
- };
56
- }
57
- get graph() {
58
- return this._graph;
59
- }
60
- get objects() {
61
- return this._objects ?? [];
62
- }
63
- // TODO(burdon): Alternative diagram types:
64
- // - https://observablehq.com/@d3/radial-tree/2
65
- // - https://observablehq.com/@d3/disjoint-force-directed-graph/2
66
- // - https://observablehq.com/@mbostock/tadpoles
67
- // - https://observablehq.com/@d3/psr-b1919-21
68
- // - https://vasturiano.github.io/react-force-graph/example/basic (3D)
69
- async open(space, objectId) {
70
- if (!this._schemaSubscription) {
71
- const schemaaQuery = space.db.schemaRegistry.query({});
72
- const schemas = await schemaaQuery.run();
73
- const onSchemaUpdate = ({ results }) => this._schema = results;
74
- this._schemaSubscription = schemaaQuery.subscribe(onSchemaUpdate);
75
- onSchemaUpdate({
76
- results: schemas
77
- });
78
- this._objectsSubscription = space.db.query(import_echo.Filter.not(import_echo.Filter.or(import_echo.Filter.type(import_echo_schema.StoredSchema), import_echo.Filter.type(import_types.CollectionType)))).subscribe(({ objects }) => {
79
- this._objects = objects;
80
- const currentNodes = this._graph.nodes;
81
- this._graph.nodes = [];
82
- this._graph.links = [];
83
- const addSchema = (typename) => {
84
- const current = currentNodes.find((node) => node.id === typename);
85
- if (typename) {
86
- this._graph.nodes.push({
87
- ...current,
88
- id: typename,
89
- type: "schema",
90
- data: {
91
- typename
92
- }
93
- });
94
- }
95
- };
96
- space.db.graph.schemaRegistry.schemas.forEach((schema) => {
97
- const typename = (0, import_echo_schema.getSchemaDXN)(schema)?.typename;
98
- if (typename) {
99
- addSchema(typename);
100
- }
101
- });
102
- this._schema?.forEach((schema) => {
103
- const typename = (0, import_echo_schema.getSchemaDXN)(schema)?.typename;
104
- if (typename) {
105
- addSchema(typename);
106
- }
107
- });
108
- this._objects.forEach((object) => {
109
- const schema = (0, import_echo_schema.getSchema)(object);
110
- if (schema) {
111
- const typename = (0, import_echo_schema.getSchemaDXN)(schema)?.typename;
112
- if (typename) {
113
- const current = currentNodes.find((node) => node.id === object.id);
114
- this._graph.nodes.push({
115
- ...current,
116
- id: object.id,
117
- type: "object",
118
- data: {
119
- typename,
120
- object
121
- }
122
- });
123
- const schemaNode = this._graph.nodes.find((node) => node.type === "schema" && node.data.typename === typename);
124
- if (schemaNode) {
125
- this._graph.links.push({
126
- id: `${object.id}-${schemaNode.id}`,
127
- source: object.id,
128
- target: schemaNode.id
129
- });
130
- } else {
131
- import_log.log.info("schema node not found", {
132
- typename
133
- }, {
134
- F: __dxlog_file,
135
- L: 148,
136
- S: this,
137
- C: (f, a) => f(...a)
138
- });
139
- }
140
- import_effect.SchemaAST.getPropertySignatures(schema.ast).forEach((prop) => {
141
- if (!import_echo_schema.SchemaValidator.hasTypeAnnotation(schema, prop.name.toString(), import_echo_schema.ReferenceAnnotationId)) {
142
- return;
143
- }
144
- const value = object[String(prop.name)];
145
- if (value) {
146
- const refs = Array.isArray(value) ? value : [
147
- value
148
- ];
149
- for (const ref of refs) {
150
- if (objects.findIndex((obj) => obj.id === ref.id) !== -1) {
151
- this._graph.links.push({
152
- id: `${object.id}-${String(prop.name)}-${ref.id}`,
153
- source: object.id,
154
- target: ref.id
155
- });
156
- }
157
- }
158
- }
159
- });
160
- }
161
- }
162
- });
163
- this.triggerUpdate();
164
- }, {
165
- fire: true
166
- });
167
- }
168
- this.setSelected(objectId);
169
- return this;
170
- }
171
- close() {
172
- this._schemaSubscription?.();
173
- this._schemaSubscription = void 0;
174
- this._objectsSubscription?.();
175
- this._objectsSubscription = void 0;
176
- return this;
177
- }
178
- };
179
- var Graph = ({ space, match }) => {
180
- const { ref, width, height } = (0, import_react_resize_detector.useResizeDetector)({
181
- refreshRate: 200
182
- });
183
- const rootRef = (0, import_react.useRef)(null);
184
- const forceGraph = (0, import_react.useRef)();
185
- const [model] = (0, import_react_ui.useAsyncState)(async () => space ? new SpaceGraphModel({
186
- schema: true
187
- }).open(space) : void 0, [
188
- space
189
- ]);
190
- const filteredRef = (0, import_react.useRef)();
191
- filteredRef.current = (0, import_plugin_search.filterObjectsSync)(model?.objects ?? [], match);
192
- (0, import_react.useEffect)(() => {
193
- if (rootRef.current) {
194
- forceGraph.current = new import_force_graph.default(rootRef.current).nodeRelSize(6).nodeLabel((node) => {
195
- if (node.type === "schema") {
196
- return node.data.typename;
197
- }
198
- return node.id;
199
- }).nodeAutoColorBy((node) => node.type === "schema" ? "schema" : node.data.typename).linkColor(() => "rgba(255,255,255,0.25)");
200
- }
201
- return () => {
202
- forceGraph.current?.pauseAnimation().graphData({
203
- nodes: [],
204
- links: []
205
- });
206
- forceGraph.current = void 0;
207
- };
208
- }, []);
209
- (0, import_react.useEffect)(() => {
210
- if (forceGraph.current && width && height && model) {
211
- forceGraph.current.pauseAnimation().width(width).height(height).onEngineStop(() => {
212
- handleZoomToFit();
213
- }).d3Force("link", (0, import_d3.forceLink)().distance(160).strength(0.5)).d3Force("charge", (0, import_d3.forceManyBody)().strength(-30)).graphData(model.graph).warmupTicks(100).cooldownTime(1e3).resumeAnimation();
214
- }
215
- }, [
216
- model,
217
- width,
218
- height
219
- ]);
220
- const handleZoomToFit = () => {
221
- forceGraph.current?.zoomToFit(400, 40);
222
- };
223
- return /* @__PURE__ */ import_react.default.createElement("div", {
224
- ref,
225
- className: "relative grow",
226
- onClick: handleZoomToFit
227
- }, /* @__PURE__ */ import_react.default.createElement("div", {
228
- ref: rootRef,
229
- className: "absolute inset-0"
230
- }));
231
- };
232
- // Annotate the CommonJS export names for ESM import in node:
233
- 0 && (module.exports = {
234
- Graph,
235
- SpaceGraphModel
236
- });
237
- //# sourceMappingURL=chunk-4ZUNNUQD.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/Graph/graph-model.ts", "../../../src/components/Graph/Graph.tsx"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { SchemaAST } from 'effect';\n\nimport { type CleanupFn } from '@dxos/async';\nimport {\n getSchema,\n getSchemaDXN,\n type EchoSchema,\n ReferenceAnnotationId,\n SchemaValidator,\n StoredSchema,\n} from '@dxos/echo-schema';\nimport { type GraphData, GraphModel } from '@dxos/gem-spore';\nimport { log } from '@dxos/log';\nimport { CollectionType } from '@dxos/plugin-space/types';\nimport { Filter, type AnyLiveObject, type Space } from '@dxos/react-client/echo';\n\nexport type SpaceGraphModelOptions = {\n schema?: boolean;\n};\n\n// TODO(burdon): Convert to common/graph.\n\ntype SchemaGraphNode = {\n id: string;\n type: 'schema';\n data: { typename: string };\n};\n\ntype ObjectGraphNode = {\n id: string;\n type: 'object';\n data: { typename: string; object: AnyLiveObject<any> };\n};\n\nexport type EchoGraphNode = SchemaGraphNode | ObjectGraphNode;\n\n/**\n * Converts ECHO objects to a graph.\n */\nexport class SpaceGraphModel extends GraphModel<EchoGraphNode> {\n private readonly _graph: GraphData<EchoGraphNode> = {\n nodes: [],\n links: [],\n };\n\n private _schema?: EchoSchema[];\n private _schemaSubscription?: CleanupFn;\n private _objects?: AnyLiveObject<any>[];\n private _objectsSubscription?: CleanupFn;\n\n constructor(private readonly _options: SpaceGraphModelOptions = {}) {\n super();\n }\n\n override get graph(): GraphData<EchoGraphNode> {\n return this._graph;\n }\n\n get objects(): AnyLiveObject<any>[] {\n return this._objects ?? [];\n }\n\n // TODO(burdon): Alternative diagram types:\n // - https://observablehq.com/@d3/radial-tree/2\n // - https://observablehq.com/@d3/disjoint-force-directed-graph/2\n // - https://observablehq.com/@mbostock/tadpoles\n // - https://observablehq.com/@d3/psr-b1919-21\n // - https://vasturiano.github.io/react-force-graph/example/basic (3D)\n\n async open(space: Space, objectId?: string) {\n // TODO(burdon): Factor out graph builder to lib (use common/graph abstraction).\n if (!this._schemaSubscription) {\n // TODO(burdon): Normalize unsubscribe callbacks and merge handlers.\n // TODO(burdon): Trigger initial subscription update.\n // TODO(burdon): Normalize subscription cb for objects, schema, etc.\n\n const schemaaQuery = space.db.schemaRegistry.query({});\n const schemas = await schemaaQuery.run();\n const onSchemaUpdate = ({ results }: { results: EchoSchema[] }) => (this._schema = results);\n this._schemaSubscription = schemaaQuery.subscribe(onSchemaUpdate);\n onSchemaUpdate({ results: schemas });\n\n this._objectsSubscription = space.db\n // TODO(burdon): ERROR: Cannot mix type and or filters.\n .query(Filter.not(Filter.or(Filter.type(StoredSchema), Filter.type(CollectionType))))\n .subscribe(\n ({ objects }) => {\n this._objects = objects;\n\n // Merge with current nodes.\n const currentNodes = this._graph.nodes;\n\n this._graph.nodes = [];\n this._graph.links = [];\n\n const addSchema = (typename: string) => {\n const current = currentNodes.find((node) => node.id === typename);\n if (typename) {\n this._graph.nodes.push({\n ...current,\n id: typename,\n type: 'schema',\n data: { typename },\n });\n }\n };\n\n // Runtime schema.\n space.db.graph.schemaRegistry.schemas.forEach((schema) => {\n const typename = getSchemaDXN(schema)?.typename;\n if (typename) {\n addSchema(typename);\n }\n });\n\n // Database Schema.\n this._schema?.forEach((schema) => {\n const typename = getSchemaDXN(schema)?.typename;\n if (typename) {\n addSchema(typename);\n }\n });\n\n // Database Objects.\n this._objects.forEach((object) => {\n const schema = getSchema(object);\n if (schema) {\n const typename = getSchemaDXN(schema)?.typename;\n if (typename) {\n const current = currentNodes.find((node) => node.id === object.id);\n this._graph.nodes.push({ ...current, id: object.id, type: 'object', data: { typename, object } });\n\n // Link to schema.\n const schemaNode = this._graph.nodes.find(\n (node) => node.type === 'schema' && node.data.typename === typename,\n );\n if (schemaNode) {\n this._graph.links.push({\n id: `${object.id}-${schemaNode.id}`,\n source: object.id,\n target: schemaNode.id,\n });\n } else {\n log.info('schema node not found', { typename });\n }\n\n // Link ot refs.\n // TODO(burdon): This isn't working.\n SchemaAST.getPropertySignatures(schema.ast).forEach((prop) => {\n if (!SchemaValidator.hasTypeAnnotation(schema, prop.name.toString(), ReferenceAnnotationId)) {\n return;\n }\n\n const value = object[String(prop.name)];\n if (value) {\n const refs = Array.isArray(value) ? value : [value];\n for (const ref of refs) {\n if (objects.findIndex((obj) => obj.id === ref.id) !== -1) {\n this._graph.links.push({\n id: `${object.id}-${String(prop.name)}-${ref.id}`,\n source: object.id,\n target: ref.id,\n });\n }\n }\n }\n });\n }\n }\n });\n\n this.triggerUpdate();\n },\n { fire: true },\n );\n }\n\n this.setSelected(objectId);\n return this;\n }\n\n close() {\n this._schemaSubscription?.();\n this._schemaSubscription = undefined;\n this._objectsSubscription?.();\n this._objectsSubscription = undefined;\n\n return this;\n }\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { forceLink, forceManyBody } from 'd3';\nimport ForceGraph from 'force-graph';\nimport React, { type FC, useEffect, useRef } from 'react';\nimport { useResizeDetector } from 'react-resize-detector';\n\nimport { type Space } from '@dxos/client/echo';\nimport { filterObjectsSync, type SearchResult } from '@dxos/plugin-search';\nimport { useAsyncState } from '@dxos/react-ui';\n\nimport { SpaceGraphModel } from './graph-model';\n\nexport type GraphProps = {\n space: Space;\n match?: RegExp;\n};\n\nexport const Graph: FC<GraphProps> = ({ space, match }) => {\n const { ref, width, height } = useResizeDetector({ refreshRate: 200 });\n const rootRef = useRef<HTMLDivElement>(null);\n const forceGraph = useRef<ForceGraph>();\n\n const [model] = useAsyncState(\n async () => (space ? new SpaceGraphModel({ schema: true }).open(space) : undefined),\n [space],\n );\n\n const filteredRef = useRef<SearchResult[]>();\n filteredRef.current = filterObjectsSync(model?.objects ?? [], match);\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 ForceGraph(rootRef.current)\n .nodeRelSize(6)\n .nodeLabel((node: any) => {\n if (node.type === 'schema') {\n return node.data.typename;\n }\n\n return node.id;\n })\n .nodeAutoColorBy((node: any) => (node.type === 'schema' ? 'schema' : node.data.typename))\n .linkColor(() => 'rgba(255,255,255,0.25)');\n }\n\n return () => {\n forceGraph.current?.pauseAnimation().graphData({ nodes: [], links: [] });\n forceGraph.current = undefined;\n };\n }, []);\n\n useEffect(() => {\n if (forceGraph.current && width && height && model) {\n forceGraph.current\n .pauseAnimation()\n .width(width)\n .height(height)\n .onEngineStop(() => {\n handleZoomToFit();\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 // .d3AlphaDecay(0.0228)\n // .d3VelocityDecay(0.4)\n\n .graphData(model.graph)\n .warmupTicks(100)\n .cooldownTime(1000)\n .resumeAnimation();\n }\n }, [model, width, height]);\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"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,oBAA0B;AAG1B,yBAOO;AACP,uBAA2C;AAC3C,iBAAoB;AACpB,mBAA+B;AAC/B,kBAAuD;ACdvD,gBAAyC;AACzC,yBAAuB;AACvB,mBAAkD;AAClD,mCAAkC;AAGlC,2BAAqD;AACrD,sBAA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,CAAA,EACZC,UAAU,CAACpD,SAAAA;AACV,YAAIA,KAAKR,SAAS,UAAU;AAC1B,iBAAOQ,KAAKG,KAAKN;QACnB;AAEA,eAAOG,KAAKC;MACd,CAAA,EACCoD,gBAAgB,CAACrD,SAAeA,KAAKR,SAAS,WAAW,WAAWQ,KAAKG,KAAKN,QAAQ,EACtFyD,UAAU,MAAM,wBAAA;IACrB;AAEA,WAAO,MAAA;AACLV,iBAAW9C,SAASyD,eAAAA,EAAiBC,UAAU;QAAEvF,OAAO,CAAA;QAAIC,OAAO,CAAA;MAAG,CAAA;AACtE0E,iBAAW9C,UAAUqC;IACvB;EACF,GAAG,CAAA,CAAE;AAELc,8BAAU,MAAA;AACR,QAAIL,WAAW9C,WAAWwC,SAASC,UAAUM,OAAO;AAClDD,iBAAW9C,QACRyD,eAAc,EACdjB,MAAMA,KAAAA,EACNC,OAAOA,MAAAA,EACPkB,aAAa,MAAA;AACZC,wBAAAA;MACF,CAAA,EAICC,QAAQ,YAAQC,qBAAAA,EAAYC,SAAS,GAAA,EAAKC,SAAS,GAAA,CAAA,EACnDH,QAAQ,cAAUI,yBAAAA,EAAgBD,SAAS,GAAC,CAAA,EAI5CN,UAAUX,MAAM1E,KAAK,EACrB6F,YAAY,GAAA,EACZC,aAAa,GAAA,EACbC,gBAAe;IACpB;EACF,GAAG;IAACrB;IAAOP;IAAOC;GAAO;AAEzB,QAAMmB,kBAAkB,MAAA;AACtBd,eAAW9C,SAASqE,UAAU,KAAK,EAAA;EACrC;AAEA,SACE,6BAAAC,QAAA,cAACC,OAAAA;IAAIzC;IAAU0C,WAAU;IAAgBC,SAASb;KAChD,6BAAAU,QAAA,cAACC,OAAAA;IAAIzC,KAAKc;IAAS4B,WAAU;;AAGnC;",
6
- "names": ["SpaceGraphModel", "GraphModel", "constructor", "_options", "_graph", "nodes", "links", "graph", "objects", "_objects", "open", "space", "objectId", "_schemaSubscription", "schemaaQuery", "db", "schemaRegistry", "query", "schemas", "run", "onSchemaUpdate", "results", "_schema", "subscribe", "_objectsSubscription", "Filter", "not", "or", "type", "StoredSchema", "CollectionType", "currentNodes", "addSchema", "typename", "current", "find", "node", "id", "push", "data", "forEach", "schema", "getSchemaDXN", "object", "getSchema", "schemaNode", "source", "target", "log", "info", "SchemaAST", "getPropertySignatures", "ast", "prop", "SchemaValidator", "hasTypeAnnotation", "name", "toString", "ReferenceAnnotationId", "value", "String", "refs", "Array", "isArray", "ref", "findIndex", "obj", "triggerUpdate", "fire", "setSelected", "close", "undefined", "Graph", "match", "width", "height", "useResizeDetector", "refreshRate", "rootRef", "useRef", "forceGraph", "model", "useAsyncState", "filteredRef", "filterObjectsSync", "useEffect", "ForceGraph", "nodeRelSize", "nodeLabel", "nodeAutoColorBy", "linkColor", "pauseAnimation", "graphData", "onEngineStop", "handleZoomToFit", "d3Force", "forceLink", "distance", "strength", "forceManyBody", "warmupTicks", "cooldownTime", "resumeAnimation", "zoomToFit", "React", "div", "className", "onClick"]
7
- }
@@ -1,28 +0,0 @@
1
- import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
- import {
3
- Graph
4
- } from "./chunk-BJZBPCC3.mjs";
5
-
6
- // packages/plugins/plugin-explorer/src/components/ExplorerContainer.tsx
7
- import React from "react";
8
- import { useGlobalSearch } from "@dxos/plugin-search";
9
- import { getSpace } from "@dxos/react-client/echo";
10
- import { StackItem } from "@dxos/react-ui-stack";
11
- var ExplorerContainer = ({ view, role }) => {
12
- const space = getSpace(view);
13
- const { match } = useGlobalSearch();
14
- if (!space) {
15
- return null;
16
- }
17
- return /* @__PURE__ */ React.createElement(StackItem.Content, {
18
- size: role === "section" ? "square" : "intrinsic"
19
- }, /* @__PURE__ */ React.createElement(Graph, {
20
- space,
21
- match
22
- }));
23
- };
24
- var ExplorerContainer_default = ExplorerContainer;
25
- export {
26
- ExplorerContainer_default as default
27
- };
28
- //# sourceMappingURL=ExplorerContainer-3GOCCL7Q.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 from 'react';\n\nimport { useGlobalSearch } from '@dxos/plugin-search';\nimport { getSpace } from '@dxos/react-client/echo';\nimport { StackItem } from '@dxos/react-ui-stack';\n\nimport { Graph } from './Graph';\nimport { type ViewType } from '../types';\n\nconst ExplorerContainer = ({ view, role }: { view: ViewType; role: string }) => {\n const space = getSpace(view);\n const { match } = useGlobalSearch();\n\n if (!space) {\n return null;\n }\n\n return (\n <StackItem.Content size={role === 'section' ? 'square' : 'intrinsic'}>\n <Graph space={space} match={match} />\n </StackItem.Content>\n );\n};\n\nexport default ExplorerContainer;\n"],
5
- "mappings": ";;;;;;AAIA,OAAOA,WAAW;AAElB,SAASC,uBAAuB;AAChC,SAASC,gBAAgB;AACzB,SAASC,iBAAiB;AAK1B,IAAMC,oBAAoB,CAAC,EAAEC,MAAMC,KAAI,MAAoC;AACzE,QAAMC,QAAQC,SAASH,IAAAA;AACvB,QAAM,EAAEI,MAAK,IAAKC,gBAAAA;AAElB,MAAI,CAACH,OAAO;AACV,WAAO;EACT;AAEA,SACE,sBAAA,cAACI,UAAUC,SAAO;IAACC,MAAMP,SAAS,YAAY,WAAW;KACvD,sBAAA,cAACQ,OAAAA;IAAMP;IAAcE;;AAG3B;AAEA,IAAA,4BAAeL;",
6
- "names": ["React", "useGlobalSearch", "getSpace", "StackItem", "ExplorerContainer", "view", "role", "space", "getSpace", "match", "useGlobalSearch", "StackItem", "Content", "size", "Graph"]
7
- }
@@ -1,208 +0,0 @@
1
- import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
-
3
- // packages/plugins/plugin-explorer/src/components/Graph/graph-model.ts
4
- import { SchemaAST } from "effect";
5
- import { getSchema, getSchemaDXN, ReferenceAnnotationId, SchemaValidator, StoredSchema } from "@dxos/echo-schema";
6
- import { GraphModel } from "@dxos/gem-spore";
7
- import { log } from "@dxos/log";
8
- import { CollectionType } from "@dxos/plugin-space/types";
9
- import { Filter } from "@dxos/react-client/echo";
10
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-explorer/src/components/Graph/graph-model.ts";
11
- var SpaceGraphModel = class extends GraphModel {
12
- constructor(_options = {}) {
13
- super();
14
- this._options = _options;
15
- this._graph = {
16
- nodes: [],
17
- links: []
18
- };
19
- }
20
- get graph() {
21
- return this._graph;
22
- }
23
- get objects() {
24
- return this._objects ?? [];
25
- }
26
- // TODO(burdon): Alternative diagram types:
27
- // - https://observablehq.com/@d3/radial-tree/2
28
- // - https://observablehq.com/@d3/disjoint-force-directed-graph/2
29
- // - https://observablehq.com/@mbostock/tadpoles
30
- // - https://observablehq.com/@d3/psr-b1919-21
31
- // - https://vasturiano.github.io/react-force-graph/example/basic (3D)
32
- async open(space, objectId) {
33
- if (!this._schemaSubscription) {
34
- const schemaaQuery = space.db.schemaRegistry.query({});
35
- const schemas = await schemaaQuery.run();
36
- const onSchemaUpdate = ({ results }) => this._schema = results;
37
- this._schemaSubscription = schemaaQuery.subscribe(onSchemaUpdate);
38
- onSchemaUpdate({
39
- results: schemas
40
- });
41
- this._objectsSubscription = space.db.query(Filter.not(Filter.or(Filter.type(StoredSchema), Filter.type(CollectionType)))).subscribe(({ objects }) => {
42
- this._objects = objects;
43
- const currentNodes = this._graph.nodes;
44
- this._graph.nodes = [];
45
- this._graph.links = [];
46
- const addSchema = (typename) => {
47
- const current = currentNodes.find((node) => node.id === typename);
48
- if (typename) {
49
- this._graph.nodes.push({
50
- ...current,
51
- id: typename,
52
- type: "schema",
53
- data: {
54
- typename
55
- }
56
- });
57
- }
58
- };
59
- space.db.graph.schemaRegistry.schemas.forEach((schema) => {
60
- const typename = getSchemaDXN(schema)?.typename;
61
- if (typename) {
62
- addSchema(typename);
63
- }
64
- });
65
- this._schema?.forEach((schema) => {
66
- const typename = getSchemaDXN(schema)?.typename;
67
- if (typename) {
68
- addSchema(typename);
69
- }
70
- });
71
- this._objects.forEach((object) => {
72
- const schema = getSchema(object);
73
- if (schema) {
74
- const typename = getSchemaDXN(schema)?.typename;
75
- if (typename) {
76
- const current = currentNodes.find((node) => node.id === object.id);
77
- this._graph.nodes.push({
78
- ...current,
79
- id: object.id,
80
- type: "object",
81
- data: {
82
- typename,
83
- object
84
- }
85
- });
86
- const schemaNode = this._graph.nodes.find((node) => node.type === "schema" && node.data.typename === typename);
87
- if (schemaNode) {
88
- this._graph.links.push({
89
- id: `${object.id}-${schemaNode.id}`,
90
- source: object.id,
91
- target: schemaNode.id
92
- });
93
- } else {
94
- log.info("schema node not found", {
95
- typename
96
- }, {
97
- F: __dxlog_file,
98
- L: 148,
99
- S: this,
100
- C: (f, a) => f(...a)
101
- });
102
- }
103
- SchemaAST.getPropertySignatures(schema.ast).forEach((prop) => {
104
- if (!SchemaValidator.hasTypeAnnotation(schema, prop.name.toString(), ReferenceAnnotationId)) {
105
- return;
106
- }
107
- const value = object[String(prop.name)];
108
- if (value) {
109
- const refs = Array.isArray(value) ? value : [
110
- value
111
- ];
112
- for (const ref of refs) {
113
- if (objects.findIndex((obj) => obj.id === ref.id) !== -1) {
114
- this._graph.links.push({
115
- id: `${object.id}-${String(prop.name)}-${ref.id}`,
116
- source: object.id,
117
- target: ref.id
118
- });
119
- }
120
- }
121
- }
122
- });
123
- }
124
- }
125
- });
126
- this.triggerUpdate();
127
- }, {
128
- fire: true
129
- });
130
- }
131
- this.setSelected(objectId);
132
- return this;
133
- }
134
- close() {
135
- this._schemaSubscription?.();
136
- this._schemaSubscription = void 0;
137
- this._objectsSubscription?.();
138
- this._objectsSubscription = void 0;
139
- return this;
140
- }
141
- };
142
-
143
- // packages/plugins/plugin-explorer/src/components/Graph/Graph.tsx
144
- import { forceLink, forceManyBody } from "d3";
145
- import ForceGraph from "force-graph";
146
- import React, { useEffect, useRef } from "react";
147
- import { useResizeDetector } from "react-resize-detector";
148
- import { filterObjectsSync } from "@dxos/plugin-search";
149
- import { useAsyncState } from "@dxos/react-ui";
150
- var Graph = ({ space, match }) => {
151
- const { ref, width, height } = useResizeDetector({
152
- refreshRate: 200
153
- });
154
- const rootRef = useRef(null);
155
- const forceGraph = useRef();
156
- const [model] = useAsyncState(async () => space ? new SpaceGraphModel({
157
- schema: true
158
- }).open(space) : void 0, [
159
- space
160
- ]);
161
- const filteredRef = useRef();
162
- filteredRef.current = filterObjectsSync(model?.objects ?? [], match);
163
- useEffect(() => {
164
- if (rootRef.current) {
165
- forceGraph.current = new ForceGraph(rootRef.current).nodeRelSize(6).nodeLabel((node) => {
166
- if (node.type === "schema") {
167
- return node.data.typename;
168
- }
169
- return node.id;
170
- }).nodeAutoColorBy((node) => node.type === "schema" ? "schema" : node.data.typename).linkColor(() => "rgba(255,255,255,0.25)");
171
- }
172
- return () => {
173
- forceGraph.current?.pauseAnimation().graphData({
174
- nodes: [],
175
- links: []
176
- });
177
- forceGraph.current = void 0;
178
- };
179
- }, []);
180
- useEffect(() => {
181
- if (forceGraph.current && width && height && model) {
182
- forceGraph.current.pauseAnimation().width(width).height(height).onEngineStop(() => {
183
- handleZoomToFit();
184
- }).d3Force("link", forceLink().distance(160).strength(0.5)).d3Force("charge", forceManyBody().strength(-30)).graphData(model.graph).warmupTicks(100).cooldownTime(1e3).resumeAnimation();
185
- }
186
- }, [
187
- model,
188
- width,
189
- height
190
- ]);
191
- const handleZoomToFit = () => {
192
- forceGraph.current?.zoomToFit(400, 40);
193
- };
194
- return /* @__PURE__ */ React.createElement("div", {
195
- ref,
196
- className: "relative grow",
197
- onClick: handleZoomToFit
198
- }, /* @__PURE__ */ React.createElement("div", {
199
- ref: rootRef,
200
- className: "absolute inset-0"
201
- }));
202
- };
203
-
204
- export {
205
- SpaceGraphModel,
206
- Graph
207
- };
208
- //# sourceMappingURL=chunk-BJZBPCC3.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/Graph/graph-model.ts", "../../../src/components/Graph/Graph.tsx"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { SchemaAST } from 'effect';\n\nimport { type CleanupFn } from '@dxos/async';\nimport {\n getSchema,\n getSchemaDXN,\n type EchoSchema,\n ReferenceAnnotationId,\n SchemaValidator,\n StoredSchema,\n} from '@dxos/echo-schema';\nimport { type GraphData, GraphModel } from '@dxos/gem-spore';\nimport { log } from '@dxos/log';\nimport { CollectionType } from '@dxos/plugin-space/types';\nimport { Filter, type AnyLiveObject, type Space } from '@dxos/react-client/echo';\n\nexport type SpaceGraphModelOptions = {\n schema?: boolean;\n};\n\n// TODO(burdon): Convert to common/graph.\n\ntype SchemaGraphNode = {\n id: string;\n type: 'schema';\n data: { typename: string };\n};\n\ntype ObjectGraphNode = {\n id: string;\n type: 'object';\n data: { typename: string; object: AnyLiveObject<any> };\n};\n\nexport type EchoGraphNode = SchemaGraphNode | ObjectGraphNode;\n\n/**\n * Converts ECHO objects to a graph.\n */\nexport class SpaceGraphModel extends GraphModel<EchoGraphNode> {\n private readonly _graph: GraphData<EchoGraphNode> = {\n nodes: [],\n links: [],\n };\n\n private _schema?: EchoSchema[];\n private _schemaSubscription?: CleanupFn;\n private _objects?: AnyLiveObject<any>[];\n private _objectsSubscription?: CleanupFn;\n\n constructor(private readonly _options: SpaceGraphModelOptions = {}) {\n super();\n }\n\n override get graph(): GraphData<EchoGraphNode> {\n return this._graph;\n }\n\n get objects(): AnyLiveObject<any>[] {\n return this._objects ?? [];\n }\n\n // TODO(burdon): Alternative diagram types:\n // - https://observablehq.com/@d3/radial-tree/2\n // - https://observablehq.com/@d3/disjoint-force-directed-graph/2\n // - https://observablehq.com/@mbostock/tadpoles\n // - https://observablehq.com/@d3/psr-b1919-21\n // - https://vasturiano.github.io/react-force-graph/example/basic (3D)\n\n async open(space: Space, objectId?: string) {\n // TODO(burdon): Factor out graph builder to lib (use common/graph abstraction).\n if (!this._schemaSubscription) {\n // TODO(burdon): Normalize unsubscribe callbacks and merge handlers.\n // TODO(burdon): Trigger initial subscription update.\n // TODO(burdon): Normalize subscription cb for objects, schema, etc.\n\n const schemaaQuery = space.db.schemaRegistry.query({});\n const schemas = await schemaaQuery.run();\n const onSchemaUpdate = ({ results }: { results: EchoSchema[] }) => (this._schema = results);\n this._schemaSubscription = schemaaQuery.subscribe(onSchemaUpdate);\n onSchemaUpdate({ results: schemas });\n\n this._objectsSubscription = space.db\n // TODO(burdon): ERROR: Cannot mix type and or filters.\n .query(Filter.not(Filter.or(Filter.type(StoredSchema), Filter.type(CollectionType))))\n .subscribe(\n ({ objects }) => {\n this._objects = objects;\n\n // Merge with current nodes.\n const currentNodes = this._graph.nodes;\n\n this._graph.nodes = [];\n this._graph.links = [];\n\n const addSchema = (typename: string) => {\n const current = currentNodes.find((node) => node.id === typename);\n if (typename) {\n this._graph.nodes.push({\n ...current,\n id: typename,\n type: 'schema',\n data: { typename },\n });\n }\n };\n\n // Runtime schema.\n space.db.graph.schemaRegistry.schemas.forEach((schema) => {\n const typename = getSchemaDXN(schema)?.typename;\n if (typename) {\n addSchema(typename);\n }\n });\n\n // Database Schema.\n this._schema?.forEach((schema) => {\n const typename = getSchemaDXN(schema)?.typename;\n if (typename) {\n addSchema(typename);\n }\n });\n\n // Database Objects.\n this._objects.forEach((object) => {\n const schema = getSchema(object);\n if (schema) {\n const typename = getSchemaDXN(schema)?.typename;\n if (typename) {\n const current = currentNodes.find((node) => node.id === object.id);\n this._graph.nodes.push({ ...current, id: object.id, type: 'object', data: { typename, object } });\n\n // Link to schema.\n const schemaNode = this._graph.nodes.find(\n (node) => node.type === 'schema' && node.data.typename === typename,\n );\n if (schemaNode) {\n this._graph.links.push({\n id: `${object.id}-${schemaNode.id}`,\n source: object.id,\n target: schemaNode.id,\n });\n } else {\n log.info('schema node not found', { typename });\n }\n\n // Link ot refs.\n // TODO(burdon): This isn't working.\n SchemaAST.getPropertySignatures(schema.ast).forEach((prop) => {\n if (!SchemaValidator.hasTypeAnnotation(schema, prop.name.toString(), ReferenceAnnotationId)) {\n return;\n }\n\n const value = object[String(prop.name)];\n if (value) {\n const refs = Array.isArray(value) ? value : [value];\n for (const ref of refs) {\n if (objects.findIndex((obj) => obj.id === ref.id) !== -1) {\n this._graph.links.push({\n id: `${object.id}-${String(prop.name)}-${ref.id}`,\n source: object.id,\n target: ref.id,\n });\n }\n }\n }\n });\n }\n }\n });\n\n this.triggerUpdate();\n },\n { fire: true },\n );\n }\n\n this.setSelected(objectId);\n return this;\n }\n\n close() {\n this._schemaSubscription?.();\n this._schemaSubscription = undefined;\n this._objectsSubscription?.();\n this._objectsSubscription = undefined;\n\n return this;\n }\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { forceLink, forceManyBody } from 'd3';\nimport ForceGraph from 'force-graph';\nimport React, { type FC, useEffect, useRef } from 'react';\nimport { useResizeDetector } from 'react-resize-detector';\n\nimport { type Space } from '@dxos/client/echo';\nimport { filterObjectsSync, type SearchResult } from '@dxos/plugin-search';\nimport { useAsyncState } from '@dxos/react-ui';\n\nimport { SpaceGraphModel } from './graph-model';\n\nexport type GraphProps = {\n space: Space;\n match?: RegExp;\n};\n\nexport const Graph: FC<GraphProps> = ({ space, match }) => {\n const { ref, width, height } = useResizeDetector({ refreshRate: 200 });\n const rootRef = useRef<HTMLDivElement>(null);\n const forceGraph = useRef<ForceGraph>();\n\n const [model] = useAsyncState(\n async () => (space ? new SpaceGraphModel({ schema: true }).open(space) : undefined),\n [space],\n );\n\n const filteredRef = useRef<SearchResult[]>();\n filteredRef.current = filterObjectsSync(model?.objects ?? [], match);\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 ForceGraph(rootRef.current)\n .nodeRelSize(6)\n .nodeLabel((node: any) => {\n if (node.type === 'schema') {\n return node.data.typename;\n }\n\n return node.id;\n })\n .nodeAutoColorBy((node: any) => (node.type === 'schema' ? 'schema' : node.data.typename))\n .linkColor(() => 'rgba(255,255,255,0.25)');\n }\n\n return () => {\n forceGraph.current?.pauseAnimation().graphData({ nodes: [], links: [] });\n forceGraph.current = undefined;\n };\n }, []);\n\n useEffect(() => {\n if (forceGraph.current && width && height && model) {\n forceGraph.current\n .pauseAnimation()\n .width(width)\n .height(height)\n .onEngineStop(() => {\n handleZoomToFit();\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 // .d3AlphaDecay(0.0228)\n // .d3VelocityDecay(0.4)\n\n .graphData(model.graph)\n .warmupTicks(100)\n .cooldownTime(1000)\n .resumeAnimation();\n }\n }, [model, width, height]);\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"],
5
- "mappings": ";;;AAIA,SAASA,iBAAiB;AAG1B,SACEC,WACAC,cAEAC,uBACAC,iBACAC,oBACK;AACP,SAAyBC,kBAAkB;AAC3C,SAASC,WAAW;AACpB,SAASC,sBAAsB;AAC/B,SAASC,cAA8C;;AAyBhD,IAAMC,kBAAN,cAA8BJ,WAAAA;EAWnCK,YAA6BC,WAAmC,CAAC,GAAG;AAClE,UAAK;SADsBA,WAAAA;SAVZC,SAAmC;MAClDC,OAAO,CAAA;MACPC,OAAO,CAAA;IACT;EASA;EAEA,IAAaC,QAAkC;AAC7C,WAAO,KAAKH;EACd;EAEA,IAAII,UAAgC;AAClC,WAAO,KAAKC,YAAY,CAAA;EAC1B;;;;;;;EASA,MAAMC,KAAKC,OAAcC,UAAmB;AAE1C,QAAI,CAAC,KAAKC,qBAAqB;AAK7B,YAAMC,eAAeH,MAAMI,GAAGC,eAAeC,MAAM,CAAC,CAAA;AACpD,YAAMC,UAAU,MAAMJ,aAAaK,IAAG;AACtC,YAAMC,iBAAiB,CAAC,EAAEC,QAAO,MAAmC,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,UAAUF;IACvB;EACF,GAAG,CAAA,CAAE;AAELK,YAAU,MAAA;AACR,QAAIX,WAAWQ,WAAWd,SAASC,UAAUM,OAAO;AAClDD,iBAAWQ,QACRc,eAAc,EACd5B,MAAMA,KAAAA,EACNC,OAAOA,MAAAA,EACP+B,aAAa,MAAA;AACZC,wBAAAA;MACF,CAAA,EAICC,QAAQ,QAAQC,UAAAA,EAAYC,SAAS,GAAA,EAAKC,SAAS,GAAA,CAAA,EACnDH,QAAQ,UAAUI,cAAAA,EAAgBD,SAAS,GAAC,CAAA,EAI5CR,UAAUtB,MAAMgC,KAAK,EACrBC,YAAY,GAAA,EACZC,aAAa,GAAA,EACbC,gBAAe;IACpB;EACF,GAAG;IAACnC;IAAOP;IAAOC;GAAO;AAEzB,QAAMgC,kBAAkB,MAAA;AACtB3B,eAAWQ,SAAS6B,UAAU,KAAK,EAAA;EACrC;AAEA,SACE,sBAAA,cAACC,OAAAA;IAAI7C;IAAU8C,WAAU;IAAgBC,SAASb;KAChD,sBAAA,cAACW,OAAAA;IAAI7C,KAAKK;IAASyC,WAAU;;AAGnC;",
6
- "names": ["SchemaAST", "getSchema", "getSchemaDXN", "ReferenceAnnotationId", "SchemaValidator", "StoredSchema", "GraphModel", "log", "CollectionType", "Filter", "SpaceGraphModel", "constructor", "_options", "_graph", "nodes", "links", "graph", "objects", "_objects", "open", "space", "objectId", "_schemaSubscription", "schemaaQuery", "db", "schemaRegistry", "query", "schemas", "run", "onSchemaUpdate", "results", "_schema", "subscribe", "_objectsSubscription", "not", "or", "type", "currentNodes", "addSchema", "typename", "current", "find", "node", "id", "push", "data", "forEach", "schema", "object", "schemaNode", "source", "target", "info", "getPropertySignatures", "ast", "prop", "hasTypeAnnotation", "name", "toString", "value", "String", "refs", "Array", "isArray", "ref", "findIndex", "obj", "triggerUpdate", "fire", "setSelected", "close", "undefined", "forceLink", "forceManyBody", "ForceGraph", "React", "useEffect", "useRef", "useResizeDetector", "filterObjectsSync", "useAsyncState", "Graph", "space", "match", "ref", "width", "height", "useResizeDetector", "refreshRate", "rootRef", "useRef", "forceGraph", "model", "useAsyncState", "SpaceGraphModel", "schema", "open", "undefined", "filteredRef", "current", "filterObjectsSync", "objects", "useEffect", "ForceGraph", "nodeRelSize", "nodeLabel", "node", "type", "data", "typename", "id", "nodeAutoColorBy", "linkColor", "pauseAnimation", "graphData", "nodes", "links", "onEngineStop", "handleZoomToFit", "d3Force", "forceLink", "distance", "strength", "forceManyBody", "graph", "warmupTicks", "cooldownTime", "resumeAnimation", "zoomToFit", "div", "className", "onClick"]
7
- }
@@ -1,8 +0,0 @@
1
- import { type FC } from 'react';
2
- import { type Space } from '@dxos/client/echo';
3
- export type GraphProps = {
4
- space: Space;
5
- match?: RegExp;
6
- };
7
- export declare const Graph: FC<GraphProps>;
8
- //# sourceMappingURL=Graph.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Graph.d.ts","sourceRoot":"","sources":["../../../../../src/components/Graph/Graph.tsx"],"names":[],"mappings":"AAMA,OAAc,EAAE,KAAK,EAAE,EAAqB,MAAM,OAAO,CAAC;AAG1D,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAM/C,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,EAAE,KAAK,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,EAAE,CAAC,UAAU,CAqEhC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"Graph.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/Graph/Graph.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAErB,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,kBAAkB,CAAC;AA2C7C,QAAA,MAAM,IAAI,EAAE,IAQX,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,eAAO,MAAM,OAAO,IAAK,CAAC"}
@@ -1,39 +0,0 @@
1
- import { type GraphData, GraphModel } from '@dxos/gem-spore';
2
- import { type AnyLiveObject, type Space } from '@dxos/react-client/echo';
3
- export type SpaceGraphModelOptions = {
4
- schema?: boolean;
5
- };
6
- type SchemaGraphNode = {
7
- id: string;
8
- type: 'schema';
9
- data: {
10
- typename: string;
11
- };
12
- };
13
- type ObjectGraphNode = {
14
- id: string;
15
- type: 'object';
16
- data: {
17
- typename: string;
18
- object: AnyLiveObject<any>;
19
- };
20
- };
21
- export type EchoGraphNode = SchemaGraphNode | ObjectGraphNode;
22
- /**
23
- * Converts ECHO objects to a graph.
24
- */
25
- export declare class SpaceGraphModel extends GraphModel<EchoGraphNode> {
26
- private readonly _options;
27
- private readonly _graph;
28
- private _schema?;
29
- private _schemaSubscription?;
30
- private _objects?;
31
- private _objectsSubscription?;
32
- constructor(_options?: SpaceGraphModelOptions);
33
- get graph(): GraphData<EchoGraphNode>;
34
- get objects(): AnyLiveObject<any>[];
35
- open(space: Space, objectId?: string): Promise<this>;
36
- close(): this;
37
- }
38
- export {};
39
- //# sourceMappingURL=graph-model.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"graph-model.d.ts","sourceRoot":"","sources":["../../../../../src/components/Graph/graph-model.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,KAAK,SAAS,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7D,OAAO,EAAU,KAAK,aAAa,EAAE,KAAK,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAEjF,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAIF,KAAK,eAAe,GAAG;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;CAC5B,CAAC;AAEF,KAAK,eAAe,GAAG;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,aAAa,CAAC,GAAG,CAAC,CAAA;KAAE,CAAC;CACxD,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,eAAe,GAAG,eAAe,CAAC;AAE9D;;GAEG;AACH,qBAAa,eAAgB,SAAQ,UAAU,CAAC,aAAa,CAAC;IAWhD,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAVrC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAGrB;IAEF,OAAO,CAAC,OAAO,CAAC,CAAe;IAC/B,OAAO,CAAC,mBAAmB,CAAC,CAAY;IACxC,OAAO,CAAC,QAAQ,CAAC,CAAuB;IACxC,OAAO,CAAC,oBAAoB,CAAC,CAAY;gBAEZ,QAAQ,GAAE,sBAA2B;IAIlE,IAAa,KAAK,IAAI,SAAS,CAAC,aAAa,CAAC,CAE7C;IAED,IAAI,OAAO,IAAI,aAAa,CAAC,GAAG,CAAC,EAAE,CAElC;IASK,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,EAAE,MAAM;IAgH1C,KAAK;CAQN"}
@@ -1,8 +0,0 @@
1
- import { type GraphModel } from '@dxos/gem-spore';
2
- export type TreeNode = {
3
- id: string;
4
- label?: string;
5
- children?: TreeNode[];
6
- };
7
- export declare const mapGraphToTreeData: <N>(model: GraphModel<N>, maxDepth?: number) => TreeNode | undefined;
8
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/components/Tree/types.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,MAAM,QAAQ,GAAG;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,CAAC,EAAE,OAAO,UAAU,CAAC,CAAC,CAAC,EAAE,iBAAY,KAAG,QAAQ,GAAG,SA0BrF,CAAC"}