@dxos/plugin-explorer 0.7.5-main.9d2a38b → 0.7.5-main.e94eead

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 (100) hide show
  1. package/dist/lib/browser/{ExplorerContainer-A7UBZ3QP.mjs → ExplorerContainer-GJTCBEM4.mjs} +2 -2
  2. package/dist/lib/browser/{chunk-Q4MVJ6YE.mjs → chunk-PMHCTMKT.mjs} +3 -3
  3. package/dist/lib/browser/{chunk-Q4MVJ6YE.mjs.map → chunk-PMHCTMKT.mjs.map} +1 -1
  4. package/dist/lib/browser/{chunk-D67EYME2.mjs → chunk-QOKAZK4V.mjs} +5 -2
  5. package/dist/lib/browser/chunk-QOKAZK4V.mjs.map +7 -0
  6. package/dist/lib/browser/{chunk-DTAFIUA7.mjs → chunk-S3QNIEBS.mjs} +2 -2
  7. package/dist/lib/browser/{chunk-5GTLMW4Q.mjs → chunk-YQL7YE6N.mjs} +171 -100
  8. package/dist/lib/browser/chunk-YQL7YE6N.mjs.map +7 -0
  9. package/dist/lib/browser/index.mjs +24 -12
  10. package/dist/lib/browser/index.mjs.map +3 -3
  11. package/dist/lib/browser/{intent-resolver-DADUM6T5.mjs → intent-resolver-UJNDAIDZ.mjs} +14 -11
  12. package/dist/lib/browser/{intent-resolver-DADUM6T5.mjs.map → intent-resolver-UJNDAIDZ.mjs.map} +3 -3
  13. package/dist/lib/browser/meta.json +1 -1
  14. package/dist/lib/browser/meta.mjs +1 -1
  15. package/dist/lib/browser/{react-surface-FW4Q2UQM.mjs → react-surface-3X2V3VPN.mjs} +5 -5
  16. package/dist/lib/browser/types/index.mjs +2 -2
  17. package/dist/lib/node/{ExplorerContainer-ZV2YKOUE.cjs → ExplorerContainer-RJT54IOS.cjs} +6 -6
  18. package/dist/lib/node/{chunk-34MGVWOY.cjs → chunk-5MTMJYC4.cjs} +8 -5
  19. package/dist/lib/node/{chunk-34MGVWOY.cjs.map → chunk-5MTMJYC4.cjs.map} +3 -3
  20. package/dist/lib/node/{chunk-4H2Y5RER.cjs → chunk-VSACDC6F.cjs} +5 -5
  21. package/dist/lib/node/{chunk-WHMJ2VQ2.cjs → chunk-YH4QYCZH.cjs} +168 -97
  22. package/dist/lib/node/chunk-YH4QYCZH.cjs.map +7 -0
  23. package/dist/lib/node/{chunk-SFG2GX7G.cjs → chunk-YUY7P7R2.cjs} +7 -7
  24. package/dist/lib/node/{chunk-SFG2GX7G.cjs.map → chunk-YUY7P7R2.cjs.map} +1 -1
  25. package/dist/lib/node/index.cjs +42 -30
  26. package/dist/lib/node/index.cjs.map +3 -3
  27. package/dist/lib/node/{intent-resolver-2V3P4L25.cjs → intent-resolver-XQV24IAA.cjs} +17 -14
  28. package/dist/lib/node/{intent-resolver-2V3P4L25.cjs.map → intent-resolver-XQV24IAA.cjs.map} +3 -3
  29. package/dist/lib/node/meta.cjs +3 -3
  30. package/dist/lib/node/meta.cjs.map +1 -1
  31. package/dist/lib/node/meta.json +1 -1
  32. package/dist/lib/node/{react-surface-7J4K5DDX.cjs → react-surface-36YIY7NA.cjs} +11 -11
  33. package/dist/lib/node/types/index.cjs +4 -4
  34. package/dist/lib/node/types/index.cjs.map +1 -1
  35. package/dist/lib/node-esm/{ExplorerContainer-JXY6XN2D.mjs → ExplorerContainer-TM3VIXVK.mjs} +2 -2
  36. package/dist/lib/node-esm/{chunk-WTGQFG6L.mjs → chunk-3KRWHGBM.mjs} +171 -100
  37. package/dist/lib/node-esm/chunk-3KRWHGBM.mjs.map +7 -0
  38. package/dist/lib/node-esm/{chunk-7NVKKFPI.mjs → chunk-57K7ORAW.mjs} +3 -3
  39. package/dist/lib/node-esm/{chunk-7NVKKFPI.mjs.map → chunk-57K7ORAW.mjs.map} +1 -1
  40. package/dist/lib/node-esm/{chunk-HIMBUOZ3.mjs → chunk-BRJI3QC2.mjs} +2 -2
  41. package/dist/lib/node-esm/{chunk-ZEM6ZU5V.mjs → chunk-UHJZUVRI.mjs} +5 -2
  42. package/dist/lib/node-esm/chunk-UHJZUVRI.mjs.map +7 -0
  43. package/dist/lib/node-esm/index.mjs +24 -12
  44. package/dist/lib/node-esm/index.mjs.map +3 -3
  45. package/dist/lib/node-esm/{intent-resolver-3BG74H5K.mjs → intent-resolver-RZQ3EEOE.mjs} +14 -11
  46. package/dist/lib/node-esm/{intent-resolver-3BG74H5K.mjs.map → intent-resolver-RZQ3EEOE.mjs.map} +3 -3
  47. package/dist/lib/node-esm/meta.json +1 -1
  48. package/dist/lib/node-esm/meta.mjs +1 -1
  49. package/dist/lib/node-esm/{react-surface-7ZTSGXJO.mjs → react-surface-YDY7IBMY.mjs} +5 -5
  50. package/dist/lib/node-esm/types/index.mjs +2 -2
  51. package/dist/types/src/ExplorerPlugin.d.ts.map +1 -1
  52. package/dist/types/src/capabilities/index.d.ts +2 -2
  53. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  54. package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
  55. package/dist/types/src/components/Chart/Chart.d.ts +1 -2
  56. package/dist/types/src/components/Chart/Chart.d.ts.map +1 -1
  57. package/dist/types/src/components/Chart/Chart.stories.d.ts +1 -2
  58. package/dist/types/src/components/Chart/Chart.stories.d.ts.map +1 -1
  59. package/dist/types/src/components/ExplorerContainer.d.ts +1 -2
  60. package/dist/types/src/components/ExplorerContainer.d.ts.map +1 -1
  61. package/dist/types/src/components/Globe/Globe.d.ts +1 -2
  62. package/dist/types/src/components/Globe/Globe.d.ts.map +1 -1
  63. package/dist/types/src/components/Globe/Globe.stories.d.ts +2 -3
  64. package/dist/types/src/components/Globe/Globe.stories.d.ts.map +1 -1
  65. package/dist/types/src/components/Graph/Graph.d.ts +2 -0
  66. package/dist/types/src/components/Graph/Graph.d.ts.map +1 -1
  67. package/dist/types/src/components/Graph/graph-model.d.ts +16 -10
  68. package/dist/types/src/components/Graph/graph-model.d.ts.map +1 -1
  69. package/dist/types/src/components/Tree/Tree.d.ts +1 -2
  70. package/dist/types/src/components/Tree/Tree.d.ts.map +1 -1
  71. package/dist/types/src/components/index.d.ts +1 -1
  72. package/dist/types/src/components/index.d.ts.map +1 -1
  73. package/dist/types/src/meta.d.ts +1 -0
  74. package/dist/types/src/meta.d.ts.map +1 -1
  75. package/dist/types/src/translations.d.ts +13 -0
  76. package/dist/types/src/translations.d.ts.map +1 -1
  77. package/dist/types/src/types/schema.d.ts +2 -2
  78. package/package.json +26 -24
  79. package/src/ExplorerPlugin.tsx +19 -14
  80. package/src/capabilities/intent-resolver.ts +6 -3
  81. package/src/components/Graph/Graph.tsx +92 -26
  82. package/src/components/Graph/graph-model.ts +127 -73
  83. package/src/components/Tree/Tree.tsx +7 -2
  84. package/src/meta.ts +2 -1
  85. package/src/translations.ts +4 -0
  86. package/src/types/schema.ts +1 -1
  87. package/dist/lib/browser/chunk-5GTLMW4Q.mjs.map +0 -7
  88. package/dist/lib/browser/chunk-D67EYME2.mjs.map +0 -7
  89. package/dist/lib/node/chunk-WHMJ2VQ2.cjs.map +0 -7
  90. package/dist/lib/node-esm/chunk-WTGQFG6L.mjs.map +0 -7
  91. package/dist/lib/node-esm/chunk-ZEM6ZU5V.mjs.map +0 -7
  92. /package/dist/lib/browser/{ExplorerContainer-A7UBZ3QP.mjs.map → ExplorerContainer-GJTCBEM4.mjs.map} +0 -0
  93. /package/dist/lib/browser/{chunk-DTAFIUA7.mjs.map → chunk-S3QNIEBS.mjs.map} +0 -0
  94. /package/dist/lib/browser/{react-surface-FW4Q2UQM.mjs.map → react-surface-3X2V3VPN.mjs.map} +0 -0
  95. /package/dist/lib/node/{ExplorerContainer-ZV2YKOUE.cjs.map → ExplorerContainer-RJT54IOS.cjs.map} +0 -0
  96. /package/dist/lib/node/{chunk-4H2Y5RER.cjs.map → chunk-VSACDC6F.cjs.map} +0 -0
  97. /package/dist/lib/node/{react-surface-7J4K5DDX.cjs.map → react-surface-36YIY7NA.cjs.map} +0 -0
  98. /package/dist/lib/node-esm/{ExplorerContainer-JXY6XN2D.mjs.map → ExplorerContainer-TM3VIXVK.mjs.map} +0 -0
  99. /package/dist/lib/node-esm/{chunk-HIMBUOZ3.mjs.map → chunk-BRJI3QC2.mjs.map} +0 -0
  100. /package/dist/lib/node-esm/{react-surface-7ZTSGXJO.mjs.map → react-surface-YDY7IBMY.mjs.map} +0 -0
@@ -26,14 +26,14 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var chunk_WHMJ2VQ2_exports = {};
30
- __export(chunk_WHMJ2VQ2_exports, {
29
+ var chunk_YH4QYCZH_exports = {};
30
+ __export(chunk_YH4QYCZH_exports, {
31
31
  Graph: () => Graph,
32
32
  SpaceGraphModel: () => SpaceGraphModel,
33
33
  Tree: () => Tree,
34
34
  defaultTreeLayoutSlots: () => defaultTreeLayoutSlots
35
35
  });
36
- module.exports = __toCommonJS(chunk_WHMJ2VQ2_exports);
36
+ module.exports = __toCommonJS(chunk_YH4QYCZH_exports);
37
37
  var import_echo_schema = require("@dxos/echo-schema");
38
38
  var import_gem_spore = require("@dxos/gem-spore");
39
39
  var import_log = require("@dxos/log");
@@ -42,15 +42,19 @@ var import_echo = require("@dxos/react-client/echo");
42
42
  var import_react = __toESM(require("react"));
43
43
  var import_react_resize_detector = require("react-resize-detector");
44
44
  var import_gem_core = require("@dxos/gem-core");
45
+ var import_react_ui = require("@dxos/react-ui");
45
46
  var d3 = __toESM(require("d3"));
46
47
  var d32 = __toESM(require("d3"));
47
48
  var d33 = __toESM(require("d3"));
49
+ var import_d3 = require("d3");
50
+ var import_force_graph = __toESM(require("force-graph"));
48
51
  var import_react2 = __toESM(require("react"));
52
+ var import_react_resize_detector2 = require("react-resize-detector");
49
53
  var import_echo2 = require("@dxos/client/echo");
50
54
  var import_gem_core2 = require("@dxos/gem-core");
51
55
  var import_gem_spore2 = require("@dxos/gem-spore");
52
56
  var import_plugin_search = require("@dxos/plugin-search");
53
- var import_react_ui = require("@dxos/react-ui");
57
+ var import_react_ui2 = require("@dxos/react-ui");
54
58
  var import_react_ui_theme = require("@dxos/react-ui-theme");
55
59
  var import_styles = require("@dxos/gem-spore/styles");
56
60
  var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-explorer/src/components/Graph/graph-model.ts";
@@ -69,79 +73,106 @@ var SpaceGraphModel = class extends import_gem_spore.GraphModel {
69
73
  get objects() {
70
74
  return this._objects ?? [];
71
75
  }
72
- open(space, objectId) {
73
- if (!this._subscription) {
74
- const query = space.db.query((object) => !(object instanceof import_types.CollectionType));
75
- this._subscription = query.subscribe(({ objects }) => {
76
+ // TODO(burdon): Alternative diagram types:
77
+ // - https://observablehq.com/@d3/radial-tree/2
78
+ // - https://observablehq.com/@d3/disjoint-force-directed-graph/2
79
+ // - https://observablehq.com/@mbostock/tadpoles
80
+ // - https://observablehq.com/@d3/psr-b1919-21
81
+ // - https://vasturiano.github.io/react-force-graph/example/basic (3D)
82
+ async open(space, objectId) {
83
+ if (!this._schemaSubscription) {
84
+ const schemaaQuery = space.db.schemaRegistry.query({});
85
+ const schemas = await schemaaQuery.run();
86
+ const onSchemaUpdate = ({ results }) => this._schema = results;
87
+ this._schemaSubscription = schemaaQuery.subscribe(onSchemaUpdate);
88
+ onSchemaUpdate({
89
+ results: schemas
90
+ });
91
+ this._objectsSubscription = space.db.query(import_echo.Filter.not(import_echo.Filter.or(import_echo.Filter.schema(import_echo_schema.StoredSchema), import_echo.Filter.schema(import_types.CollectionType)))).subscribe(({ objects }) => {
76
92
  this._objects = objects;
77
- this._graph.nodes = objects.map((object) => {
78
- if (object instanceof import_echo_schema.StoredSchema) {
79
- const effectSchema = space.db.schemaRegistry.getSchemaById(object.id);
80
- return {
93
+ const currentNodes = this._graph.nodes;
94
+ this._graph.nodes = [];
95
+ this._graph.links = [];
96
+ const addSchema = (typename) => {
97
+ const current = currentNodes.find((node) => node.id === typename);
98
+ if (typename) {
99
+ this._graph.nodes.push({
100
+ ...current,
101
+ id: typename,
81
102
  type: "schema",
82
- id: object.id,
83
- schema: effectSchema.schema
84
- };
85
- }
86
- return {
87
- type: "echo-object",
88
- id: object.id,
89
- object
90
- };
91
- });
92
- this._graph.links = objects.reduce((links, object) => {
93
- const objectSchema = (0, import_echo.getSchema)(object);
94
- const typename = (0, import_echo.getType)(object)?.objectId;
95
- if (objectSchema == null || typename == null) {
96
- import_log.log.info("no schema for object:", {
97
- id: object.id.slice(0, 8)
98
- }, {
99
- F: __dxlog_file,
100
- L: 72,
101
- S: this,
102
- C: (f, a) => f(...a)
103
+ data: {
104
+ typename
105
+ }
103
106
  });
104
- return links;
105
107
  }
106
- if (!(objectSchema instanceof import_echo_schema.EchoSchema)) {
107
- const idx = objects.findIndex((obj) => obj.id === typename);
108
- if (idx === -1) {
109
- this._graph.nodes.push({
110
- id: typename,
111
- type: "schema",
112
- schema: objectSchema
113
- });
114
- }
108
+ };
109
+ space.db.graph.schemaRegistry.schemas.forEach((schema) => {
110
+ const typename = (0, import_echo_schema.getSchemaDXN)(schema)?.toTypename();
111
+ if (typename) {
112
+ addSchema(typename);
115
113
  }
116
- if (this._options.schema) {
117
- links.push({
118
- id: `${object.id}-${typename}`,
119
- source: object.id,
120
- target: typename
121
- });
114
+ });
115
+ this._schema?.forEach((schema) => {
116
+ const typename = (0, import_echo_schema.getSchemaDXN)(schema)?.toTypename();
117
+ if (typename) {
118
+ addSchema(typename);
122
119
  }
123
- import_echo_schema.AST.getPropertySignatures(objectSchema.ast).forEach((prop) => {
124
- if (!import_echo_schema.SchemaValidator.hasTypeAnnotation(objectSchema, prop.name.toString(), import_echo_schema.ReferenceAnnotationId)) {
125
- return;
126
- }
127
- const value = object[String(prop.name)];
128
- if (value) {
129
- const refs = Array.isArray(value) ? value : [
130
- value
131
- ];
132
- for (const ref of refs) {
133
- if (objects.findIndex((obj) => obj.id === ref.id) !== -1) {
134
- links.push({
135
- id: `${object.id}-${String(prop.name)}-${ref.id}`,
136
- source: object.id,
137
- target: ref.id
138
- });
120
+ });
121
+ this._objects.forEach((object) => {
122
+ const schema = (0, import_echo_schema.getSchema)(object);
123
+ if (schema) {
124
+ const typename = (0, import_echo_schema.getSchemaDXN)(schema)?.toTypename();
125
+ if (typename) {
126
+ const current = currentNodes.find((node) => node.id === object.id);
127
+ this._graph.nodes.push({
128
+ ...current,
129
+ id: object.id,
130
+ type: "object",
131
+ data: {
132
+ typename,
133
+ object
139
134
  }
135
+ });
136
+ const schemaNode = this._graph.nodes.find((node) => node.type === "schema" && node.data.typename === typename);
137
+ if (schemaNode) {
138
+ this._graph.links.push({
139
+ id: `${object.id}-${schemaNode.id}`,
140
+ source: object.id,
141
+ target: schemaNode.id
142
+ });
143
+ } else {
144
+ import_log.log.info("schema node not found", {
145
+ typename
146
+ }, {
147
+ F: __dxlog_file,
148
+ L: 145,
149
+ S: this,
150
+ C: (f, a) => f(...a)
151
+ });
140
152
  }
153
+ import_echo_schema.AST.getPropertySignatures(schema.ast).forEach((prop) => {
154
+ if (!import_echo_schema.SchemaValidator.hasTypeAnnotation(schema, prop.name.toString(), import_echo_schema.ReferenceAnnotationId)) {
155
+ return;
156
+ }
157
+ const value = object[String(prop.name)];
158
+ if (value) {
159
+ const refs = Array.isArray(value) ? value : [
160
+ value
161
+ ];
162
+ for (const ref of refs) {
163
+ if (objects.findIndex((obj) => obj.id === ref.id) !== -1) {
164
+ this._graph.links.push({
165
+ id: `${object.id}-${String(prop.name)}-${ref.id}`,
166
+ source: object.id,
167
+ target: ref.id
168
+ });
169
+ }
170
+ }
171
+ }
172
+ });
141
173
  }
142
- });
143
- return links;
144
- }, []);
174
+ }
175
+ });
145
176
  this.triggerUpdate();
146
177
  }, {
147
178
  fire: true
@@ -151,10 +182,10 @@ var SpaceGraphModel = class extends import_gem_spore.GraphModel {
151
182
  return this;
152
183
  }
153
184
  close() {
154
- if (this._subscription) {
155
- this._subscription();
156
- this._subscription = void 0;
157
- }
185
+ this._schemaSubscription?.();
186
+ this._schemaSubscription = void 0;
187
+ this._objectsSubscription?.();
188
+ this._objectsSubscription = void 0;
158
189
  return this;
159
190
  }
160
191
  };
@@ -316,14 +347,14 @@ var colors = [
316
347
  "[&>circle]:!fill-teal-300 [&>circle]:!stroke-teal-600",
317
348
  "[&>circle]:!fill-indigo-300 [&>circle]:!stroke-indigo-600"
318
349
  ];
319
- var Graph = ({ space, match }) => {
320
- const model = (0, import_react2.useMemo)(() => space ? new SpaceGraphModel({
350
+ var Graph = ({ space, match, grid, svg }) => {
351
+ const { themeMode } = (0, import_react_ui2.useThemeContext)();
352
+ const [selected, setSelected] = (0, import_react2.useState)();
353
+ const [model] = (0, import_react_ui2.useAsyncState)(async () => space ? new SpaceGraphModel({
321
354
  schema: true
322
355
  }).open(space) : void 0, [
323
356
  space
324
357
  ]);
325
- const [selected, setSelected] = (0, import_react2.useState)();
326
- const { themeMode } = (0, import_react_ui.useThemeContext)();
327
358
  const context = (0, import_gem_core2.createSvgContext)();
328
359
  const projector = (0, import_react2.useMemo)(() => new import_gem_spore2.GraphForceProjector(context, {
329
360
  forces: {
@@ -331,15 +362,15 @@ var Graph = ({ space, match }) => {
331
362
  strength: -100
332
363
  },
333
364
  link: {
334
- distance: 180
365
+ distance: 100
335
366
  },
336
367
  radial: {
337
- radius: 200,
368
+ radius: 150,
338
369
  strength: 0.05
339
370
  }
340
371
  },
341
372
  attributes: {
342
- radius: (node) => node.data?.type === "schema" ? 24 : 12
373
+ radius: (node) => node.data?.type === "schema" ? 12 : 8
343
374
  }
344
375
  }), []);
345
376
  const filteredRef = (0, import_react2.useRef)();
@@ -350,8 +381,49 @@ var Graph = ({ space, match }) => {
350
381
  match
351
382
  ]);
352
383
  const [colorMap] = (0, import_react2.useState)(/* @__PURE__ */ new Map());
353
- if (!model) {
354
- return null;
384
+ const { ref, width, height } = (0, import_react_resize_detector2.useResizeDetector)();
385
+ const rootRef = (0, import_react2.useRef)(null);
386
+ const forceGraph = (0, import_react2.useRef)();
387
+ (0, import_react2.useEffect)(() => {
388
+ if (rootRef.current) {
389
+ forceGraph.current = new import_force_graph.default(rootRef.current).nodeRelSize(6).nodeLabel((node) => {
390
+ if (node.type === "schema") {
391
+ return node.data.typename;
392
+ }
393
+ return node.id;
394
+ }).nodeAutoColorBy((node) => node.type === "schema" ? "schema" : node.data.typename).linkColor(() => "rgba(255,255,255,0.25)");
395
+ }
396
+ return () => {
397
+ forceGraph.current?.pauseAnimation().graphData({
398
+ nodes: [],
399
+ links: []
400
+ });
401
+ forceGraph.current = void 0;
402
+ };
403
+ }, []);
404
+ (0, import_react2.useEffect)(() => {
405
+ if (forceGraph.current && width && height && model) {
406
+ forceGraph.current.pauseAnimation().width(width).height(height).onEngineStop(() => {
407
+ forceGraph.current?.zoomToFit(400, 40);
408
+ }).d3Force("link", (0, import_d3.forceLink)().distance(160).strength(0.5)).d3Force("charge", (0, import_d3.forceManyBody)().strength(-30)).warmupTicks(100).graphData(model.graph).resumeAnimation();
409
+ }
410
+ }, [
411
+ model,
412
+ width,
413
+ height
414
+ ]);
415
+ const handleZoomToFit = () => {
416
+ forceGraph.current?.zoomToFit(400, 40);
417
+ };
418
+ if (!svg) {
419
+ return /* @__PURE__ */ import_react2.default.createElement("div", {
420
+ ref,
421
+ className: "relative grow",
422
+ onClick: handleZoomToFit
423
+ }, /* @__PURE__ */ import_react2.default.createElement("div", {
424
+ ref: rootRef,
425
+ className: "absolute inset-0"
426
+ }));
355
427
  }
356
428
  if (selected) {
357
429
  return /* @__PURE__ */ import_react2.default.createElement(Tree, {
@@ -367,7 +439,7 @@ var Graph = ({ space, match }) => {
367
439
  className: (0, import_react_ui_theme.mx)(import_gem_spore2.defaultStyles, slots?.root?.className)
368
440
  }, /* @__PURE__ */ import_react2.default.createElement(import_gem_spore2.Markers, {
369
441
  arrowSize: 6
370
- }), /* @__PURE__ */ import_react2.default.createElement(import_gem_core2.Grid, {
442
+ }), grid && /* @__PURE__ */ import_react2.default.createElement(import_gem_core2.Grid, {
371
443
  className: slots?.grid?.className ?? (0, import_gem_core2.defaultGridStyles)(themeMode)
372
444
  }), /* @__PURE__ */ import_react2.default.createElement(import_gem_core2.Zoom, {
373
445
  extent: [
@@ -392,27 +464,26 @@ var Graph = ({ space, match }) => {
392
464
  node: (node) => {
393
465
  let className;
394
466
  if (node.data) {
395
- const typename = (0, import_echo2.getType)(node.data)?.objectId;
396
- if (typename) {
397
- className = colorMap.get(typename);
398
- if (!className) {
399
- className = colors[colorMap.size % colors.length];
400
- colorMap.set(typename, className);
467
+ const { object } = node.data;
468
+ if (object) {
469
+ const typename = (0, import_echo2.getTypename)(object);
470
+ if (typename) {
471
+ className = colorMap.get(typename);
472
+ if (!className) {
473
+ className = colors[colorMap.size % colors.length];
474
+ colorMap.set(typename, className);
475
+ }
401
476
  }
402
477
  }
403
478
  }
404
479
  const selected2 = filteredRef.current?.some((object) => object.id === node.data?.id);
480
+ const blur = !selected2 && !!filteredRef.current?.length;
405
481
  return {
406
- class: (0, import_react_ui_theme.mx)(filteredRef.current?.length ? selected2 ? [
407
- className
408
- ] : "[&>text]:!fill-neutral-300" : [
409
- "[&>text]:!fill-neutral-700",
410
- className
411
- ])
482
+ class: (0, import_react_ui_theme.mx)(className, blur && "opacity-70")
412
483
  };
413
484
  },
414
485
  link: () => ({
415
- class: "[&>path]:!stroke-neutral-300"
486
+ class: "[&>path]:!stroke-neutral-300 dark:[&>path]:!stroke-neutral-700"
416
487
  })
417
488
  }
418
489
  }))));
@@ -437,7 +508,7 @@ var renderers = /* @__PURE__ */ new Map([
437
508
  ]
438
509
  ]);
439
510
  var Tree = ({ space, selected, variant = "tidy", onNodeClick }) => {
440
- const model = (0, import_react.useMemo)(() => space ? new SpaceGraphModel().open(space, selected) : void 0, [
511
+ const [model] = (0, import_react_ui.useAsyncState)(async () => space ? new SpaceGraphModel().open(space, selected) : void 0, [
441
512
  space,
442
513
  selected
443
514
  ]);
@@ -493,4 +564,4 @@ var Tree = ({ space, selected, variant = "tidy", onNodeClick }) => {
493
564
  Tree,
494
565
  defaultTreeLayoutSlots
495
566
  });
496
- //# sourceMappingURL=chunk-WHMJ2VQ2.cjs.map
567
+ //# sourceMappingURL=chunk-YH4QYCZH.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/Graph/graph-model.ts", "../../../src/components/Tree/Tree.tsx", "../../../src/components/Tree/layout/HierarchicalEdgeBundling.ts", "../../../src/components/Tree/layout/RadialTree.ts", "../../../src/components/Tree/layout/TidyTree.ts", "../../../src/components/Tree/types.ts", "../../../src/components/Graph/Graph.tsx"],
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type UnsubscribeCallback } from '@dxos/async';\nimport {\n getSchema,\n getSchemaDXN,\n AST,\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 ReactiveEchoObject, type Space, type Subscription } from '@dxos/react-client/echo';\n\nexport type SpaceGraphModelOptions = {\n schema?: boolean;\n};\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: ReactiveEchoObject<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?: UnsubscribeCallback;\n private _objects?: ReactiveEchoObject<any>[];\n private _objectsSubscription?: Subscription;\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(): ReactiveEchoObject<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.schema(StoredSchema), Filter.schema(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)?.toTypename();\n if (typename) {\n addSchema(typename);\n }\n });\n\n // Database Schema.\n this._schema?.forEach((schema) => {\n const typename = getSchemaDXN(schema)?.toTypename();\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)?.toTypename();\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 AST.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 React, { useEffect, useState } from 'react';\nimport { useResizeDetector } from 'react-resize-detector';\n\nimport { type Space } from '@dxos/client/echo';\nimport { createSvgContext, SVG, SVGRoot } from '@dxos/gem-core';\nimport { useAsyncState } from '@dxos/react-ui';\n\nimport { HierarchicalEdgeBundling, RadialTree, TidyTree } from './layout';\nimport { mapGraphToTreeData, type TreeNode } from './types';\nimport { SpaceGraphModel } from '../Graph';\n\n// TODO(burdon): Create dge bundling graph using d3.hierarchy.\n// https://observablehq.com/@d3/hierarchical-edge-bundling?intent=fork\n\ntype Renderer = (svg: SVGSVGElement, data: any, options: any) => void;\n\nexport type LayoutVariant = 'tidy' | 'radial' | 'edge';\n\n// TODO(burdon): Remove slots?\nexport type TreeLayoutSlots = {\n node?: string;\n path?: string;\n text?: string;\n};\n\nexport type TreeOptions = {\n label: (d: any) => string;\n\n slots?: TreeLayoutSlots;\n radius?: number;\n\n width: number;\n height: number;\n margin?: number;\n\n padding?: number;\n // Radius of nodes.\n r?: number;\n};\n\nexport const defaultTreeLayoutSlots: TreeLayoutSlots = {\n node: 'fill-blue-600',\n path: 'fill-none stroke-blue-400 stroke-[0.5px]',\n text: 'stroke-[0.5px] stroke-neutral-700 text-xs', // TODO(burdon): Create box instead of halo.\n};\n\nconst renderers = new Map<LayoutVariant, Renderer>([\n ['tidy', TidyTree],\n ['radial', RadialTree],\n ['edge', HierarchicalEdgeBundling],\n]);\n\nexport type TreeComponentProps<N = unknown> = {\n space: Space;\n selected?: string;\n variant?: LayoutVariant;\n onNodeClick?: (node?: N) => void;\n};\n\n// TODO(burdon): Label accessor.\nexport const Tree = <N,>({ space, selected, variant = 'tidy', onNodeClick }: TreeComponentProps<N>) => {\n const [model] = useAsyncState(\n async () => (space ? new SpaceGraphModel().open(space, selected) : undefined),\n [space, selected],\n );\n\n const [tree, setTree] = useState<TreeNode>();\n useEffect(() => {\n return model?.subscribe(() => {\n const tree = mapGraphToTreeData(model);\n setTree(tree);\n }, true);\n }, [model]);\n\n const context = createSvgContext();\n const { ref, width = 0, height = 0 } = useResizeDetector();\n\n useEffect(() => {\n if (width && height) {\n const size = Math.min(width, height);\n const radius = size * 0.4;\n const options = {\n // TODO(burdon): Type.\n label: (d: any) => d.label ?? d.id,\n width,\n height,\n radius,\n marginLeft: (width - radius * 2) / 2,\n marginRight: (width - radius * 2) / 2,\n marginTop: (height - radius * 2) / 2,\n marginBottom: (height - radius * 2) / 2,\n slots: defaultTreeLayoutSlots,\n };\n\n if (tree) {\n const renderer = renderers.get(variant);\n renderer?.(context.ref.current!, tree, options);\n }\n }\n }, [tree, width, height]);\n\n // TODO(burdon): Provider should expand.\n return (\n <div ref={ref} className='flex grow overflow-hidden' onClick={() => onNodeClick?.()}>\n <SVGRoot context={context}>\n <SVG />\n </SVGRoot>\n </div>\n );\n};\n", "//\n// Copyright 2023 DXOS.org\n// Copyright 2022 Observable, Inc.\n//\n\nimport * as d3 from 'd3';\nimport { type HierarchyNode } from 'd3-hierarchy';\n\nimport { type TreeOptions } from '../Tree';\nimport { type TreeNode } from '../types';\n\n// Create hierarchical ID.\n// eslint-disable-next-line unused-imports/no-unused-vars\nconst getId = (node: HierarchyNode<TreeNode>): string =>\n `${node.parent ? getId(node.parent) + '/' : ''}${node.data.id.slice(0, 4)}`;\n\n// https://github.com/d3/d3-hierarchy\n// https://observablehq.com/@d3/hierarchical-edge-bundling?intent=fork\nconst HierarchicalEdgeBundling = (s: SVGSVGElement, data: TreeNode, options: TreeOptions) => {\n const svg = d3.select(s);\n svg.selectAll('*').remove();\n\n const { radius = 600, padding = 100, slots } = options;\n\n // https://d3js.org/d3-hierarchy/hierarchy\n const root = d3.hierarchy(flatten(data));\n // .sort((a, b) => d3.ascending(a.height, b.height) || d3.ascending(getName(a.data), getName(b.data)));\n\n const tree = d3.cluster<TreeNode>().size([2 * Math.PI, radius - padding]);\n const layout = tree(addLinks(root));\n\n // eslint-disable-next-line unused-imports/no-unused-vars\n const node = svg\n .append('g')\n .selectAll()\n .data(layout.leaves())\n .join('g')\n .attr('transform', (d) => `rotate(${d.x * (180 / Math.PI) - 90}) translate(${d.y},0)`)\n .append('text')\n .attr('class', slots?.text ?? '')\n .attr('dy', '0.31em') // TODO(burdon): Based on font size.\n .attr('x', (d) => (d.x < Math.PI ? 6 : -6))\n .attr('text-anchor', (d) => (d.x < Math.PI ? 'start' : 'end'))\n .attr('transform', (d) => (d.x >= Math.PI ? 'rotate(180)' : null))\n // .text((d: any) => d.data.id)\n // .each(function (d: any) {\n // d.text = this;\n // })\n // .on('mouseover', overed)\n // .on('mouseout', outed)\n .call(\n (text) => text.text((d: any) => d.data.id.slice(0, 8)),\n // .text((d: any) => `${getId(d)} [${[(d as any).outgoing?.length ?? 0]}]`),\n );\n\n // https://d3js.org/d3-shape/radial-line\n const line = d3\n .lineRadial()\n .curve(d3.curveBundle.beta(0.85))\n .radius((d: any) => d.y)\n .angle((d: any) => d.x);\n\n // eslint-disable-next-line unused-imports/no-unused-vars\n const links = svg\n .append('g')\n .selectAll()\n .data(layout.leaves().flatMap((leaf: any) => leaf.outgoing))\n .join('path')\n .style('mix-blend-mode', 'multiply')\n .attr('class', slots?.path ?? '')\n .attr('d', ([i, o]) => {\n return line(i.path(o));\n })\n .each(function (d) {\n d.path = this;\n });\n\n // function overed(event: any, d: X) {\n // link.style('mix-blend-mode', null);\n // d3.select(this).attr('font-weight', 'bold');\n // d3.selectAll(d.incoming.map((d) => d.path))\n // .attr('stroke', color.in)\n // .raise();\n // d3.selectAll((d as any).incoming.map(([d]) => d.text))\n // .attr('fill', color.in)\n // .attr('font-weight', 'bold');\n // d3.selectAll(d.outgoing.map((d) => d.path))\n // .attr('stroke', color.out)\n // .raise();\n // d3.selectAll(d.outgoing.map(([, d]) => d.text))\n // .attr('fill', color.out)\n // .attr('font-weight', 'bold');\n // }\n\n // function outed(event: any, d: HierarchyNode<Datum>) {\n // // @ts-ignore\n // d3.select(this).attr('font-weight', null);\n // d3.selectAll(d.incoming.map((d) => d.path)).attr('stroke', null);\n // d3.selectAll(d.incoming.map(([d]) => d.text))\n // .attr('fill', null)\n // .attr('font-weight', null);\n // d3.selectAll(d.outgoing.map((d) => d.path)).attr('stroke', null);\n // d3.selectAll(d.outgoing.map(([, d]) => d.text))\n // .attr('fill', null)\n // .attr('font-weight', null);\n // }\n};\n\n// Monkey-patch with incoming/outgoing nodes.\nconst addLinks = (root: HierarchyNode<TreeNode>) => {\n // Map of nodes indexed by ID.\n const nodes = new Map(root.descendants().map((d) => [d.data.id, d]));\n const parents = root.descendants().reduce((map, d) => {\n if (d.children?.length) {\n map.set(d.data.id, d);\n }\n return map;\n }, new Map<string, HierarchyNode<TreeNode>>());\n\n for (const d of root.leaves()) {\n // (d as any).incoming = [];\n\n const parent = parents.get(d.data.id);\n if (parent) {\n // Skip the first node which is a placeholder created by flatten().\n (d as any).outgoing =\n parent.data.children?.slice(1).map((child) => {\n return [d, nodes.get(child.id)!];\n }) ?? [];\n } else {\n (d as any).outgoing = [];\n }\n }\n\n // for (const d of root.leaves()) {\n // for (const [_, o] of (d as any).outgoing) {\n // o.incoming.push(o);\n // }\n // }\n\n return root;\n};\n\n/**\n * We are using a hierarchy in order to group nodes by parent, but we want the parent\n * nodes to be positioned at the first level along with all descendents.\n * So we add a placeholder for all parents at the head of each group.\n * @param node\n */\nconst flatten = (node: TreeNode) => {\n const clone: TreeNode = {\n id: node.id,\n };\n\n // TODO(burdon): NOTE: Should exclude schema (since requires a tree).\n if (node.children?.length) {\n const children = node.children.map((child) => flatten(child));\n clone.children = [{ id: node.id }, ...children];\n }\n\n return clone;\n};\n\nexport default HierarchicalEdgeBundling;\n", "//\n// Copyright 2023 DXOS.org\n// Copyright 2022 Observable, Inc.\n//\n\nimport * as d3 from 'd3';\n\nimport { type TreeOptions } from '../Tree';\n\n// Released under the ISC license.\n// https://observablehq.com/@d3/radial-tree\n// https://observablehq.com/@d3/tree\nconst RadialTree = (s: SVGSVGElement, data: any, options: TreeOptions) => {\n const svg = d3.select(s);\n svg.selectAll('*').remove();\n\n const {\n label, // given a node d, returns the display name\n radius = 400,\n r = 4, // radius of nodes\n slots,\n } = options;\n\n const arc = 2 * Math.PI;\n\n const root = d3.hierarchy(data);\n\n // Sort the nodes.\n // if (sort) {\n // root.sort(sort);\n // }\n\n // Compute labels and titles.\n const descendants = root.descendants();\n const getLabel = label === null ? null : descendants.map((d) => label(d.data));\n\n // Compute the layout.\n const layout = d3\n .tree()\n .size([arc, radius])\n .separation((a: any, b: any) => (a.parent === b.parent ? 1 : 2) / a.depth);\n layout(root);\n\n // Links.\n svg\n .append('g')\n .selectAll('path')\n .data(root.links())\n .join('path')\n .attr('class', slots?.path ?? '')\n .attr(\n 'd',\n d3\n .linkRadial()\n .angle((d: any) => d.x + Math.PI / 2)\n .radius((d: any) => d.y) as any,\n );\n\n // Nodes.\n const node = svg\n .append('g')\n .selectAll('a')\n .data(root.descendants())\n .join('a')\n // .attr('xlink:href', link == null ? null : (d) => link(d.data, d))\n // .attr('target', link == null ? null : linkTarget)\n .attr('transform', (d: any) => `rotate(${(d.x * 180) / Math.PI}) translate(${d.y},0)`);\n\n node\n .append('circle')\n .attr('class', slots?.node ?? '')\n .attr('r', r);\n\n // if (title != null) {\n // node.append('title').text((d) => title(d.data, d));\n // }\n\n // Text.\n if (getLabel) {\n node\n .append('text')\n .attr('transform', (d: any) => `rotate(${d.x >= Math.PI ? 180 : 0})`)\n .attr('dy', '0.32em')\n // eslint-disable-next-line no-mixed-operators\n .attr('x', (d: any) => (d.x < Math.PI === !d.children ? 6 : -6))\n // eslint-disable-next-line no-mixed-operators\n .attr('text-anchor', (d: any) => (d.x < Math.PI === !d.children ? 'start' : 'end'))\n // .attr('paint-order', 'stroke')\n .attr('class', slots?.text ?? '')\n .text((d, i) => getLabel[i]);\n }\n\n return svg.node();\n};\n\nexport default RadialTree;\n", "//\n// Copyright 2023 DXOS.org\n// Copyright 2021 Observable, Inc.\n//\n\nimport * as d3 from 'd3';\n\nimport { type TreeOptions } from '../Tree';\n\n// Released under the ISC license.\n// https://observablehq.com/@d3/tree\nconst TidyTree = (s: SVGSVGElement, data: any, options: TreeOptions) => {\n const svg = d3.select(s);\n svg.selectAll('*').remove();\n\n const { label, width, height, r = 4, padding = 4, margin = 60, slots } = options;\n\n const root = d3.hierarchy(data);\n\n // Compute labels and titles.\n const descendants = root.descendants();\n const getLabel = label == null ? null : descendants.map((d) => label(d.data));\n\n // Compute the layout.\n const dx = 16;\n const dy = width / (root.height + padding);\n const layout = d3.tree().nodeSize([dx, dy]);\n layout(root);\n\n // Center the tree.\n let x0 = Infinity;\n let x1 = -x0;\n let y0 = Infinity;\n let y1 = -y0;\n root.each((d: any) => {\n if (d.x > x1) {\n x1 = d.x;\n }\n if (d.x < x0) {\n x0 = d.x;\n }\n if (d.y > y1) {\n y1 = d.y;\n }\n if (d.y < y0) {\n y0 = d.y;\n }\n });\n\n // TODO(burdon): Option to expand.\n // NOTE: x and y are flipped.\n const sx = Math.min(2, Math.max(1, (height - margin * 2) / (x1 - x0)));\n const oy = -(width - (y1 - y0)) / 2;\n\n // Links.\n svg\n .append('g')\n .selectAll('path')\n .data(root.links())\n .join('path')\n .attr('class', slots?.path ?? '')\n .attr(\n 'd',\n d3\n .link(d3.curveBumpX)\n .x((d: any) => d.y + oy)\n .y((d: any) => d.x * sx) as any,\n );\n\n // Nodes.\n const node = svg\n .append('g')\n .selectAll('a')\n .data(root.descendants())\n .join('a')\n // .attr('xlink:href', link == null ? null : (d) => link(d.data, d))\n // .attr('target', link == null ? null : linkTarget)\n .attr('transform', (d: any) => `translate(${d.y + oy},${d.x * sx})`);\n\n node\n .append('circle')\n .attr('class', slots?.node ?? '')\n .attr('r', r);\n\n // if (title != null) {\n // node.append('title').text((d) => title(d.data, d));\n // }\n\n if (getLabel) {\n node\n .append('text')\n\n .attr('dy', '0.32em')\n .attr('x', (d) => (d.children ? -6 : 6))\n .attr('text-anchor', (d) => (d.children ? 'end' : 'start'))\n // .attr('paint-order', 'stroke')\n .attr('class', slots?.text ?? '')\n .text((d, i) => getLabel[i]);\n }\n};\n\nexport default TidyTree;\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport type { GraphModel } from '@dxos/gem-spore';\n\nexport type TreeNode = {\n id: string;\n label?: string;\n children?: TreeNode[];\n};\n\nexport const mapGraphToTreeData = <N>(model: GraphModel<N>, maxDepth = 8): TreeNode | undefined => {\n const mapNode = (node: N, depth = 0): TreeNode => {\n const treeNode: TreeNode = {\n id: model.idAccessor(node),\n label: model.idAccessor(node).slice(0, 8),\n };\n\n const links = model.graph.links.filter((link) => link.source === treeNode.id);\n if (depth < maxDepth) {\n treeNode.children = links.map((link) =>\n mapNode(model.graph.nodes.find((node) => model.idAccessor(node) === link.target)!, depth + 1),\n );\n }\n\n return treeNode;\n };\n\n let data: TreeNode | undefined;\n if (model.selected) {\n const node = model.graph.nodes.find((node) => model.idAccessor(node) === model.selected);\n if (node) {\n data = mapNode(node);\n }\n }\n\n return data;\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { forceLink, forceManyBody } from 'd3';\nimport ForceGraph from 'force-graph';\nimport React, { type FC, useEffect, useMemo, useRef, useState } from 'react';\nimport { useResizeDetector } from 'react-resize-detector';\n\nimport { getTypename, type ReactiveEchoObject, type Space } from '@dxos/client/echo';\nimport { createSvgContext, defaultGridStyles, Grid, SVG, SVGRoot, Zoom } from '@dxos/gem-core';\nimport {\n defaultStyles,\n Graph as GraphComponent,\n GraphForceProjector,\n type GraphLayoutNode,\n Markers,\n} from '@dxos/gem-spore';\nimport { filterObjectsSync, type SearchResult } from '@dxos/plugin-search';\nimport { useAsyncState, useThemeContext } from '@dxos/react-ui';\nimport { mx } from '@dxos/react-ui-theme';\nimport '@dxos/gem-spore/styles';\n\nimport { type EchoGraphNode, SpaceGraphModel } from './graph-model';\nimport { Tree } from '../Tree';\n\ntype Slots = {\n root?: { className?: string };\n grid?: { className?: string };\n};\n\nconst slots: Slots = {};\n\nconst colors = [\n '[&>circle]:!fill-black-300 [&>circle]:!stroke-black-600',\n '[&>circle]:!fill-slate-300 [&>circle]:!stroke-slate-600',\n '[&>circle]:!fill-green-300 [&>circle]:!stroke-green-600',\n '[&>circle]:!fill-sky-300 [&>circle]:!stroke-sky-600',\n '[&>circle]:!fill-cyan-300 [&>circle]:!stroke-cyan-600',\n '[&>circle]:!fill-rose-300 [&>circle]:!stroke-rose-600',\n '[&>circle]:!fill-purple-300 [&>circle]:!stroke-purple-600',\n '[&>circle]:!fill-orange-300 [&>circle]:!stroke-orange-600',\n '[&>circle]:!fill-teal-300 [&>circle]:!stroke-teal-600',\n '[&>circle]:!fill-indigo-300 [&>circle]:!stroke-indigo-600',\n];\n\nexport type GraphProps = {\n space: Space;\n match?: RegExp;\n grid?: boolean;\n svg?: boolean;\n};\n\nexport const Graph: FC<GraphProps> = ({ space, match, grid, svg }) => {\n const { themeMode } = useThemeContext();\n const [selected, setSelected] = useState<string>();\n\n const [model] = useAsyncState(\n async () => (space ? new SpaceGraphModel({ schema: true }).open(space) : undefined),\n [space],\n );\n\n const context = createSvgContext();\n const projector = useMemo(\n () =>\n new GraphForceProjector<EchoGraphNode>(context, {\n forces: {\n manyBody: {\n strength: -100,\n },\n link: {\n distance: 100,\n },\n radial: {\n radius: 150,\n strength: 0.05,\n },\n },\n attributes: {\n radius: (node: GraphLayoutNode<EchoGraphNode>) => (node.data?.type === 'schema' ? 12 : 8),\n },\n }),\n [],\n );\n\n const filteredRef = useRef<SearchResult[]>();\n filteredRef.current = filterObjectsSync(model?.objects ?? [], match);\n useEffect(() => {\n void projector.start();\n }, [match]);\n\n const [colorMap] = useState(new Map<string, string>());\n\n // https://github.com/vasturiano/force-graph\n const { ref, width, height } = useResizeDetector();\n const rootRef = useRef<HTMLDivElement>(null);\n const forceGraph = useRef<ForceGraph>();\n\n useEffect(() => {\n if (rootRef.current) {\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 // Update.\n useEffect(() => {\n if (forceGraph.current && width && height && model) {\n forceGraph.current\n .pauseAnimation()\n .width(width)\n .height(height)\n .onEngineStop(() => {\n forceGraph.current?.zoomToFit(400, 40);\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 .warmupTicks(100)\n // .cooldownTime(1000)\n\n //\n .graphData(model.graph)\n .resumeAnimation();\n }\n }, [model, width, height]);\n\n const handleZoomToFit = () => {\n forceGraph.current?.zoomToFit(400, 40);\n };\n\n if (!svg) {\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 if (selected) {\n return <Tree space={space} selected={selected} variant='tidy' onNodeClick={() => setSelected(undefined)} />;\n }\n\n return (\n <SVGRoot context={context}>\n <SVG className={mx(defaultStyles, slots?.root?.className)}>\n <Markers arrowSize={6} />\n {grid && <Grid className={slots?.grid?.className ?? defaultGridStyles(themeMode)} />}\n <Zoom extent={[1 / 2, 4]}>\n <GraphComponent\n model={model}\n projector={projector}\n drag\n arrows\n onSelect={(node) => setSelected(node?.data?.id)}\n labels={{\n text: (node: GraphLayoutNode<ReactiveEchoObject<any>>) => {\n if (filteredRef.current?.length && !filteredRef.current.some((object) => object.id === node.data?.id)) {\n return undefined;\n }\n\n // TODO(burdon): Use schema.\n return node.data?.label ?? node.data?.title ?? node.data?.name ?? node.data?.id.slice(0, 8);\n },\n }}\n attributes={{\n node: (node: GraphLayoutNode<ReactiveEchoObject<any>>) => {\n let className: string | undefined;\n if (node.data) {\n const { object } = node.data;\n if (object) {\n const typename = getTypename(object);\n if (typename) {\n className = colorMap.get(typename);\n if (!className) {\n className = colors[colorMap.size % colors.length];\n colorMap.set(typename, className);\n }\n }\n }\n }\n\n const selected = filteredRef.current?.some((object) => object.id === node.data?.id);\n const blur = !selected && !!filteredRef.current?.length;\n return {\n class: mx(className, blur && 'opacity-70'),\n };\n },\n link: () => ({\n class: '[&>path]:!stroke-neutral-300 dark:[&>path]:!stroke-neutral-700',\n }),\n }}\n />\n </Zoom>\n </SVG>\n </SVGRoot>\n );\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,yBAQO;AACP,uBAA2C;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AAMsD;IAAOC;GAAO;AAGxB,SACEmE,6BAAAA,QAAA,cAACC,OAAAA;IAAIhJ;IAAUiJ,WAAU;IAA4BC,SAAS,MAAMG,cAAAA;KAClEN,6BAAAA,QAAA,cAACO,gBAAAA,SAAAA;IAAQ1C;KACPmC,6BAAAA,QAAA,cAACQ,gBAAAA,KAAAA,IAAAA,CAAAA,CAAAA;AAIT;",
6
+ "names": ["import_react", "import_react_resize_detector", "import_echo", "import_gem_core", "import_gem_spore", "import_react_ui", "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", "schema", "StoredSchema", "CollectionType", "currentNodes", "addSchema", "typename", "current", "find", "node", "id", "push", "type", "data", "forEach", "getSchemaDXN", "toTypename", "object", "getSchema", "schemaNode", "source", "target", "log", "info", "AST", "getPropertySignatures", "ast", "prop", "SchemaValidator", "hasTypeAnnotation", "name", "toString", "ReferenceAnnotationId", "value", "String", "refs", "Array", "isArray", "ref", "findIndex", "obj", "triggerUpdate", "fire", "setSelected", "close", "undefined", "HierarchicalEdgeBundling", "s", "options", "svg", "select", "selectAll", "remove", "radius", "padding", "slots", "root", "hierarchy", "flatten", "tree", "cluster", "size", "Math", "PI", "layout", "addLinks", "append", "leaves", "join", "attr", "d", "x", "y", "text", "call", "slice", "line", "lineRadial", "curve", "curveBundle", "beta", "angle", "flatMap", "leaf", "outgoing", "style", "path", "i", "o", "each", "Map", "descendants", "map", "parents", "reduce", "children", "length", "set", "parent", "get", "child", "clone", "RadialTree", "label", "r", "arc", "getLabel", "separation", "a", "b", "depth", "linkRadial", "TidyTree", "width", "height", "margin", "dx", "dy", "nodeSize", "x0", "Infinity", "x1", "y0", "y1", "sx", "min", "max", "oy", "link", "curveBumpX", "mapGraphToTreeData", "model", "maxDepth", "mapNode", "treeNode", "idAccessor", "filter", "selected", "colors", "Graph", "match", "grid", "themeMode", "useThemeContext", "useState", "useAsyncState", "context", "createSvgContext", "projector", "useMemo", "GraphForceProjector", "forces", "manyBody", "strength", "distance", "radial", "attributes", "filteredRef", "useRef", "filterObjectsSync", "useEffect", "start", "colorMap", "useResizeDetector", "rootRef", "forceGraph", "ForceGraph", "nodeRelSize", "nodeLabel", "nodeAutoColorBy", "linkColor", "pauseAnimation", "graphData", "onEngineStop", "zoomToFit", "d3Force", "forceLink", "forceManyBody", "warmupTicks", "resumeAnimation", "handleZoomToFit", "React", "div", "className", "onClick", "Tree", "variant", "onNodeClick", "SVGRoot", "SVG", "mx", "defaultStyles", "Markers", "arrowSize", "Grid", "defaultGridStyles", "Zoom", "extent", "GraphComponent", "drag", "arrows", "onSelect", "labels", "some", "title", "getTypename", "blur", "class", "defaultTreeLayoutSlots", "renderers", "setTree", "marginLeft", "marginRight", "marginTop", "marginBottom", "renderer"]
7
+ }
@@ -16,17 +16,17 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var chunk_SFG2GX7G_exports = {};
20
- __export(chunk_SFG2GX7G_exports, {
19
+ var chunk_YUY7P7R2_exports = {};
20
+ __export(chunk_YUY7P7R2_exports, {
21
21
  ExplorerAction: () => ExplorerAction,
22
22
  ViewType: () => ViewType
23
23
  });
24
- module.exports = __toCommonJS(chunk_SFG2GX7G_exports);
25
- var import_chunk_34MGVWOY = require("./chunk-34MGVWOY.cjs");
24
+ module.exports = __toCommonJS(chunk_YUY7P7R2_exports);
25
+ var import_chunk_5MTMJYC4 = require("./chunk-5MTMJYC4.cjs");
26
26
  var import_echo_schema = require("@dxos/echo-schema");
27
27
  var import_echo_schema2 = require("@dxos/echo-schema");
28
28
  var ViewType = class extends (0, import_echo_schema.TypedObject)({
29
- typename: "dxos.org/type/View",
29
+ typename: "dxos.org/type/ExplorerView",
30
30
  version: "0.1.0"
31
31
  })({
32
32
  name: import_echo_schema.S.optional(import_echo_schema.S.String),
@@ -35,7 +35,7 @@ var ViewType = class extends (0, import_echo_schema.TypedObject)({
35
35
  };
36
36
  var ExplorerAction;
37
37
  (function(ExplorerAction2) {
38
- const EXPLORER_ACTION = `${import_chunk_34MGVWOY.EXPLORER_PLUGIN}/action`;
38
+ const EXPLORER_ACTION = `${import_chunk_5MTMJYC4.EXPLORER_PLUGIN}/action`;
39
39
  class Create extends import_echo_schema2.S.TaggedClass()(`${EXPLORER_ACTION}/create`, {
40
40
  input: import_echo_schema2.S.Struct({
41
41
  name: import_echo_schema2.S.optional(import_echo_schema2.S.String)
@@ -52,4 +52,4 @@ var ExplorerAction;
52
52
  ExplorerAction,
53
53
  ViewType
54
54
  });
55
- //# sourceMappingURL=chunk-SFG2GX7G.cjs.map
55
+ //# sourceMappingURL=chunk-YUY7P7R2.cjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/types/schema.ts", "../../../src/types/types.ts"],
4
- "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { S, TypedObject } from '@dxos/echo-schema';\n\n// TODO(burdon): Clashes with sdk/view.\nexport class ViewType extends TypedObject({\n typename: 'dxos.org/type/View',\n version: '0.1.0',\n})({\n name: S.optional(S.String),\n type: S.String,\n}) {}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { S } from '@dxos/echo-schema';\n\nimport { ViewType } from './schema';\nimport { EXPLORER_PLUGIN } from '../meta';\n\nexport namespace ExplorerAction {\n const EXPLORER_ACTION = `${EXPLORER_PLUGIN}/action`;\n\n export class Create extends S.TaggedClass<Create>()(`${EXPLORER_ACTION}/create`, {\n input: S.Struct({\n name: S.optional(S.String),\n }),\n output: S.Struct({\n object: ViewType,\n }),\n }) {}\n}\n"],
4
+ "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { S, TypedObject } from '@dxos/echo-schema';\n\n// TODO(burdon): Clashes with sdk/view.\nexport class ViewType extends TypedObject({\n typename: 'dxos.org/type/ExplorerView',\n version: '0.1.0',\n})({\n name: S.optional(S.String),\n type: S.String,\n}) {}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { S } from '@dxos/echo-schema';\n\nimport { ViewType } from './schema';\nimport { EXPLORER_PLUGIN } from '../meta';\n\nexport namespace ExplorerAction {\n const EXPLORER_ACTION = `${EXPLORER_PLUGIN}/action`;\n\n export class Create extends S.TaggedClass<Create>()(`${EXPLORER_ACTION}/create`, {\n input: S.Struct({\n name: S.optional(S.String),\n }),\n output: S.Struct({\n object: ViewType,\n }),\n }) {}\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAIA,yBAA+B;ACA/B,IAAAA,sBAAkB;ADGX,IAAMC,WAAN,kBAAuBC,gCAAY;EACxCC,UAAU;EACVC,SAAS;AACX,CAAA,EAAG;EACDC,MAAMC,qBAAEC,SAASD,qBAAEE,MAAM;EACzBC,MAAMH,qBAAEE;AACV,CAAA,EAAA;AAAI;;UCJaE,iBAAAA;AACf,QAAMC,kBAAkB,GAAGC,qCAAAA;EAEpB,MAAMC,eAAeP,oBAAAA,EAAEQ,YAAW,EAAW,GAAGH,eAAAA,WAA0B;IAC/EI,OAAOT,oBAAAA,EAAEU,OAAO;MACdX,MAAMC,oBAAAA,EAAEC,SAASD,oBAAAA,EAAEE,MAAM;IAC3B,CAAA;IACAS,QAAQX,oBAAAA,EAAEU,OAAO;MACfE,QAAQjB;IACV,CAAA;EACF,CAAA,EAAA;EAAI;kBAPSY,SAAAA;AAQf,GAXiBH,mBAAAA,iBAAAA,CAAAA,EAAAA;",
6
6
  "names": ["import_echo_schema", "ViewType", "TypedObject", "typename", "version", "name", "S", "optional", "String", "type", "ExplorerAction", "EXPLORER_ACTION", "EXPLORER_PLUGIN", "Create", "TaggedClass", "input", "Struct", "output", "object"]
7
7
  }