@dxos/plugin-explorer 0.8.2-main.f11618f → 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 (161) 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-RRXH3JYB.mjs → chunk-73GQ46YO.mjs} +415 -155
  4. package/dist/lib/{node-esm/chunk-VNMYGDGZ.mjs.map → browser/chunk-73GQ46YO.mjs.map} +4 -4
  5. package/dist/lib/browser/{chunk-QLQLPZNI.mjs → chunk-73YTQHOT.mjs} +12 -11
  6. package/dist/lib/browser/chunk-73YTQHOT.mjs.map +7 -0
  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-P4YLQHXF.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-TPR4VUPE.mjs → react-surface-H3YDMXAQ.mjs} +5 -5
  19. package/dist/lib/browser/types/index.mjs +2 -2
  20. package/dist/lib/node/{ExplorerContainer-73AHSBAG.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-4QUNUHKB.cjs → chunk-72H5HBTK.cjs} +414 -153
  25. package/dist/lib/node/{chunk-4QUNUHKB.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-YLL7H7CZ.cjs → chunk-MLRYW4WQ.cjs} +15 -14
  29. package/dist/lib/node/chunk-MLRYW4WQ.cjs.map +7 -0
  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-T2R4PJVP.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-OLIOGYOK.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-VNMYGDGZ.mjs → chunk-34X2VFQN.mjs} +415 -154
  44. package/dist/lib/{browser/chunk-RRXH3JYB.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-QZH2GDN5.mjs → chunk-N6VEANUZ.mjs} +12 -11
  48. package/dist/lib/node-esm/chunk-N6VEANUZ.mjs.map +7 -0
  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-OMUHLTGU.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-QLB55AWT.mjs → react-surface-ZEVL3FXG.mjs} +5 -5
  59. package/dist/lib/node-esm/types/index.mjs +2 -2
  60. package/dist/types/src/components/Chart/Chart.d.ts.map +1 -1
  61. package/dist/types/src/components/ExplorerContainer.d.ts +4 -3
  62. package/dist/types/src/components/ExplorerContainer.d.ts.map +1 -1
  63. package/dist/types/src/components/Globe/Globe.d.ts.map +1 -1
  64. package/dist/types/src/components/Graph/D3ForceGraph.d.ts +14 -0
  65. package/dist/types/src/components/Graph/D3ForceGraph.d.ts.map +1 -0
  66. package/dist/types/src/components/Graph/D3ForceGraph.stories.d.ts +6 -0
  67. package/dist/types/src/components/Graph/D3ForceGraph.stories.d.ts.map +1 -0
  68. package/dist/types/src/components/Graph/ForceGraph.d.ts +8 -0
  69. package/dist/types/src/components/Graph/ForceGraph.d.ts.map +1 -0
  70. package/dist/types/src/components/Graph/{Graph.stories.d.ts → ForceGraph.stories.d.ts} +1 -1
  71. package/dist/types/src/components/Graph/ForceGraph.stories.d.ts.map +1 -0
  72. package/dist/types/src/components/Graph/adapter.d.ts +21 -0
  73. package/dist/types/src/components/Graph/adapter.d.ts.map +1 -0
  74. package/dist/types/src/components/Graph/index.d.ts +2 -2
  75. package/dist/types/src/components/Graph/index.d.ts.map +1 -1
  76. package/dist/types/src/components/Graph/testing.d.ts +14 -0
  77. package/dist/types/src/components/Graph/testing.d.ts.map +1 -0
  78. package/dist/types/src/components/Tree/Tree.d.ts.map +1 -1
  79. package/dist/types/src/components/Tree/layout/HierarchicalEdgeBundling.d.ts.map +1 -1
  80. package/dist/types/src/components/Tree/layout/RadialTree.d.ts.map +1 -1
  81. package/dist/types/src/components/Tree/layout/TidyTree.d.ts.map +1 -1
  82. package/dist/types/src/components/Tree/testing/generator.d.ts +8 -0
  83. package/dist/types/src/components/Tree/testing/generator.d.ts.map +1 -0
  84. package/dist/types/src/components/Tree/testing/index.d.ts +2 -0
  85. package/dist/types/src/components/Tree/testing/index.d.ts.map +1 -0
  86. package/dist/types/src/components/Tree/types/index.d.ts +3 -0
  87. package/dist/types/src/components/Tree/types/index.d.ts.map +1 -0
  88. package/dist/types/src/components/Tree/types/tree.d.ts +83 -0
  89. package/dist/types/src/components/Tree/types/tree.d.ts.map +1 -0
  90. package/dist/types/src/components/Tree/types/tree.test.d.ts +2 -0
  91. package/dist/types/src/components/Tree/types/tree.test.d.ts.map +1 -0
  92. package/dist/types/src/components/Tree/types/types.d.ts +8 -0
  93. package/dist/types/src/components/Tree/types/types.d.ts.map +1 -0
  94. package/dist/types/src/components/index.d.ts +2 -2
  95. package/dist/types/src/components/plot.d.ts.map +1 -1
  96. package/dist/types/src/hooks/index.d.ts +2 -0
  97. package/dist/types/src/hooks/index.d.ts.map +1 -0
  98. package/dist/types/src/hooks/useGraphModel.d.ts +4 -0
  99. package/dist/types/src/hooks/useGraphModel.d.ts.map +1 -0
  100. package/dist/types/src/index.d.ts +2 -1
  101. package/dist/types/src/index.d.ts.map +1 -1
  102. package/dist/types/src/translations.d.ts +2 -8
  103. package/dist/types/src/translations.d.ts.map +1 -1
  104. package/dist/types/src/types/schema.d.ts +6 -6
  105. package/dist/types/src/types/schema.d.ts.map +1 -1
  106. package/dist/types/src/types/types.d.ts +6 -6
  107. package/dist/types/src/types/types.d.ts.map +1 -1
  108. package/dist/types/tsconfig.tsbuildinfo +1 -1
  109. package/package.json +30 -27
  110. package/src/components/ExplorerContainer.tsx +11 -4
  111. package/src/components/Graph/D3ForceGraph.stories.tsx +64 -0
  112. package/src/components/Graph/D3ForceGraph.tsx +101 -0
  113. package/src/components/Graph/ForceGraph.stories.tsx +64 -0
  114. package/src/components/Graph/{Graph.tsx → ForceGraph.tsx} +19 -26
  115. package/src/components/Graph/adapter.ts +47 -0
  116. package/src/components/Graph/index.ts +2 -3
  117. package/src/components/Graph/testing.ts +57 -0
  118. package/src/components/Tree/Tree.stories.tsx +1 -1
  119. package/src/components/Tree/Tree.tsx +11 -18
  120. package/src/components/Tree/testing/generator.ts +46 -0
  121. package/src/components/Tree/testing/index.ts +5 -0
  122. package/src/components/Tree/types/index.ts +6 -0
  123. package/src/components/Tree/types/tree.test.ts +133 -0
  124. package/src/components/Tree/types/tree.ts +287 -0
  125. package/src/components/Tree/types/types.ts +41 -0
  126. package/src/hooks/index.ts +5 -0
  127. package/src/hooks/useGraphModel.ts +35 -0
  128. package/src/index.ts +2 -2
  129. package/src/meta.ts +2 -2
  130. package/src/types/schema.ts +5 -3
  131. package/src/types/types.ts +5 -5
  132. package/dist/lib/browser/ExplorerContainer-HL532ODG.mjs +0 -27
  133. package/dist/lib/browser/ExplorerContainer-HL532ODG.mjs.map +0 -7
  134. package/dist/lib/browser/chunk-QLQLPZNI.mjs.map +0 -7
  135. package/dist/lib/browser/chunk-SBLNE7FL.mjs +0 -205
  136. package/dist/lib/browser/chunk-SBLNE7FL.mjs.map +0 -7
  137. package/dist/lib/node/ExplorerContainer-73AHSBAG.cjs.map +0 -7
  138. package/dist/lib/node/chunk-OIHH6TVE.cjs +0 -236
  139. package/dist/lib/node/chunk-OIHH6TVE.cjs.map +0 -7
  140. package/dist/lib/node/chunk-YLL7H7CZ.cjs.map +0 -7
  141. package/dist/lib/node-esm/ExplorerContainer-NMI55PYM.mjs +0 -28
  142. package/dist/lib/node-esm/ExplorerContainer-NMI55PYM.mjs.map +0 -7
  143. package/dist/lib/node-esm/chunk-QZH2GDN5.mjs.map +0 -7
  144. package/dist/lib/node-esm/chunk-SZRRNWYT.mjs +0 -207
  145. package/dist/lib/node-esm/chunk-SZRRNWYT.mjs.map +0 -7
  146. package/dist/types/src/components/Graph/Graph.d.ts +0 -8
  147. package/dist/types/src/components/Graph/Graph.d.ts.map +0 -1
  148. package/dist/types/src/components/Graph/Graph.stories.d.ts.map +0 -1
  149. package/dist/types/src/components/Graph/graph-model.d.ts +0 -39
  150. package/dist/types/src/components/Graph/graph-model.d.ts.map +0 -1
  151. package/dist/types/src/components/Tree/types.d.ts +0 -8
  152. package/dist/types/src/components/Tree/types.d.ts.map +0 -1
  153. package/src/components/Graph/Graph.stories.tsx +0 -62
  154. package/src/components/Graph/graph-model.ts +0 -193
  155. package/src/components/Tree/types.ts +0 -40
  156. /package/dist/lib/browser/{intent-resolver-P4YLQHXF.mjs.map → intent-resolver-FJDVBDE3.mjs.map} +0 -0
  157. /package/dist/lib/browser/{react-surface-TPR4VUPE.mjs.map → react-surface-H3YDMXAQ.mjs.map} +0 -0
  158. /package/dist/lib/node/{intent-resolver-T2R4PJVP.cjs.map → intent-resolver-DRT67ZU4.cjs.map} +0 -0
  159. /package/dist/lib/node/{react-surface-OLIOGYOK.cjs.map → react-surface-6ESLSM33.cjs.map} +0 -0
  160. /package/dist/lib/node-esm/{intent-resolver-OMUHLTGU.mjs.map → intent-resolver-4RBV644N.mjs.map} +0 -0
  161. /package/dist/lib/node-esm/{react-surface-QLB55AWT.mjs.map → react-surface-ZEVL3FXG.mjs.map} +0 -0
@@ -1,27 +0,0 @@
1
- import {
2
- Graph
3
- } from "./chunk-SBLNE7FL.mjs";
4
-
5
- // packages/plugins/plugin-explorer/src/components/ExplorerContainer.tsx
6
- import React from "react";
7
- import { useGlobalSearch } from "@dxos/plugin-search";
8
- import { getSpace } from "@dxos/react-client/echo";
9
- import { StackItem } from "@dxos/react-ui-stack";
10
- var ExplorerContainer = ({ view, role }) => {
11
- const space = getSpace(view);
12
- const { match } = useGlobalSearch();
13
- if (!space) {
14
- return null;
15
- }
16
- return /* @__PURE__ */ React.createElement(StackItem.Content, {
17
- size: role === "section" ? "square" : "intrinsic"
18
- }, /* @__PURE__ */ React.createElement(Graph, {
19
- space,
20
- match
21
- }));
22
- };
23
- var ExplorerContainer_default = ExplorerContainer;
24
- export {
25
- ExplorerContainer_default as default
26
- };
27
- //# sourceMappingURL=ExplorerContainer-HL532ODG.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,7 +0,0 @@
1
- {
2
- "version": 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/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
- "mappings": ";;;;;AAIA,SAASA,GAAGC,mBAAmB;AAGxB,IAAMC,WAAN,cAAuBC,YAAY;EACxCC,UAAU;EACVC,SAAS;AACX,CAAA,EAAG;EACDC,MAAMC,EAAEC,SAASD,EAAEE,MAAM;EACzBC,MAAMH,EAAEE;AACV,CAAA,EAAA;AAAI;;;ACTJ,SAASE,KAAAA,UAAS;;UAKDC,iBAAAA;AACf,QAAMC,kBAAkB,GAAGC,eAAAA;EAEpB,MAAMC,eAAeC,GAAEC,YAAW,EAAW,GAAGJ,eAAAA,WAA0B;IAC/EK,OAAOF,GAAEG,OAAO;MACdC,MAAMJ,GAAEK,SAASL,GAAEM,MAAM;IAC3B,CAAA;IACAC,QAAQP,GAAEG,OAAO;MACfK,QAAQC;IACV,CAAA;EACF,CAAA,EAAA;EAAI;kBAPSV,SAAAA;AAQf,GAXiBH,mBAAAA,iBAAAA,CAAAA,EAAAA;",
6
- "names": ["S", "TypedObject", "ViewType", "TypedObject", "typename", "version", "name", "S", "optional", "String", "type", "S", "ExplorerAction", "EXPLORER_ACTION", "EXPLORER_PLUGIN", "Create", "S", "TaggedClass", "input", "Struct", "name", "optional", "String", "output", "object", "ViewType"]
7
- }
@@ -1,205 +0,0 @@
1
- // packages/plugins/plugin-explorer/src/components/Graph/graph-model.ts
2
- import { getSchema, getSchemaDXN, AST, ReferenceAnnotationId, SchemaValidator, StoredSchema } from "@dxos/echo-schema";
3
- import { GraphModel } from "@dxos/gem-spore";
4
- import { log } from "@dxos/log";
5
- import { CollectionType } from "@dxos/plugin-space/types";
6
- import { Filter } from "@dxos/react-client/echo";
7
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-explorer/src/components/Graph/graph-model.ts";
8
- var SpaceGraphModel = class extends GraphModel {
9
- constructor(_options = {}) {
10
- super();
11
- this._options = _options;
12
- this._graph = {
13
- nodes: [],
14
- links: []
15
- };
16
- }
17
- get graph() {
18
- return this._graph;
19
- }
20
- get objects() {
21
- return this._objects ?? [];
22
- }
23
- // TODO(burdon): Alternative diagram types:
24
- // - https://observablehq.com/@d3/radial-tree/2
25
- // - https://observablehq.com/@d3/disjoint-force-directed-graph/2
26
- // - https://observablehq.com/@mbostock/tadpoles
27
- // - https://observablehq.com/@d3/psr-b1919-21
28
- // - https://vasturiano.github.io/react-force-graph/example/basic (3D)
29
- async open(space, objectId) {
30
- if (!this._schemaSubscription) {
31
- const schemaaQuery = space.db.schemaRegistry.query({});
32
- const schemas = await schemaaQuery.run();
33
- const onSchemaUpdate = ({ results }) => this._schema = results;
34
- this._schemaSubscription = schemaaQuery.subscribe(onSchemaUpdate);
35
- onSchemaUpdate({
36
- results: schemas
37
- });
38
- this._objectsSubscription = space.db.query(Filter.not(Filter.or(Filter.schema(StoredSchema), Filter.schema(CollectionType)))).subscribe(({ objects }) => {
39
- this._objects = objects;
40
- const currentNodes = this._graph.nodes;
41
- this._graph.nodes = [];
42
- this._graph.links = [];
43
- const addSchema = (typename) => {
44
- const current = currentNodes.find((node) => node.id === typename);
45
- if (typename) {
46
- this._graph.nodes.push({
47
- ...current,
48
- id: typename,
49
- type: "schema",
50
- data: {
51
- typename
52
- }
53
- });
54
- }
55
- };
56
- space.db.graph.schemaRegistry.schemas.forEach((schema) => {
57
- const typename = getSchemaDXN(schema)?.typename;
58
- if (typename) {
59
- addSchema(typename);
60
- }
61
- });
62
- this._schema?.forEach((schema) => {
63
- const typename = getSchemaDXN(schema)?.typename;
64
- if (typename) {
65
- addSchema(typename);
66
- }
67
- });
68
- this._objects.forEach((object) => {
69
- const schema = getSchema(object);
70
- if (schema) {
71
- const typename = getSchemaDXN(schema)?.typename;
72
- if (typename) {
73
- const current = currentNodes.find((node) => node.id === object.id);
74
- this._graph.nodes.push({
75
- ...current,
76
- id: object.id,
77
- type: "object",
78
- data: {
79
- typename,
80
- object
81
- }
82
- });
83
- const schemaNode = this._graph.nodes.find((node) => node.type === "schema" && node.data.typename === typename);
84
- if (schemaNode) {
85
- this._graph.links.push({
86
- id: `${object.id}-${schemaNode.id}`,
87
- source: object.id,
88
- target: schemaNode.id
89
- });
90
- } else {
91
- log.info("schema node not found", {
92
- typename
93
- }, {
94
- F: __dxlog_file,
95
- L: 147,
96
- S: this,
97
- C: (f, a) => f(...a)
98
- });
99
- }
100
- AST.getPropertySignatures(schema.ast).forEach((prop) => {
101
- if (!SchemaValidator.hasTypeAnnotation(schema, prop.name.toString(), ReferenceAnnotationId)) {
102
- return;
103
- }
104
- const value = object[String(prop.name)];
105
- if (value) {
106
- const refs = Array.isArray(value) ? value : [
107
- value
108
- ];
109
- for (const ref of refs) {
110
- if (objects.findIndex((obj) => obj.id === ref.id) !== -1) {
111
- this._graph.links.push({
112
- id: `${object.id}-${String(prop.name)}-${ref.id}`,
113
- source: object.id,
114
- target: ref.id
115
- });
116
- }
117
- }
118
- }
119
- });
120
- }
121
- }
122
- });
123
- this.triggerUpdate();
124
- }, {
125
- fire: true
126
- });
127
- }
128
- this.setSelected(objectId);
129
- return this;
130
- }
131
- close() {
132
- this._schemaSubscription?.();
133
- this._schemaSubscription = void 0;
134
- this._objectsSubscription?.();
135
- this._objectsSubscription = void 0;
136
- return this;
137
- }
138
- };
139
-
140
- // packages/plugins/plugin-explorer/src/components/Graph/Graph.tsx
141
- import { forceLink, forceManyBody } from "d3";
142
- import ForceGraph from "force-graph";
143
- import React, { useEffect, useRef } from "react";
144
- import { useResizeDetector } from "react-resize-detector";
145
- import { filterObjectsSync } from "@dxos/plugin-search";
146
- import { useAsyncState } from "@dxos/react-ui";
147
- var Graph = ({ space, match }) => {
148
- const { ref, width, height } = useResizeDetector({
149
- refreshRate: 200
150
- });
151
- const rootRef = useRef(null);
152
- const forceGraph = useRef();
153
- const [model] = useAsyncState(async () => space ? new SpaceGraphModel({
154
- schema: true
155
- }).open(space) : void 0, [
156
- space
157
- ]);
158
- const filteredRef = useRef();
159
- filteredRef.current = filterObjectsSync(model?.objects ?? [], match);
160
- useEffect(() => {
161
- if (rootRef.current) {
162
- forceGraph.current = new ForceGraph(rootRef.current).nodeRelSize(6).nodeLabel((node) => {
163
- if (node.type === "schema") {
164
- return node.data.typename;
165
- }
166
- return node.id;
167
- }).nodeAutoColorBy((node) => node.type === "schema" ? "schema" : node.data.typename).linkColor(() => "rgba(255,255,255,0.25)");
168
- }
169
- return () => {
170
- forceGraph.current?.pauseAnimation().graphData({
171
- nodes: [],
172
- links: []
173
- });
174
- forceGraph.current = void 0;
175
- };
176
- }, []);
177
- useEffect(() => {
178
- if (forceGraph.current && width && height && model) {
179
- forceGraph.current.pauseAnimation().width(width).height(height).onEngineStop(() => {
180
- handleZoomToFit();
181
- }).d3Force("link", forceLink().distance(160).strength(0.5)).d3Force("charge", forceManyBody().strength(-30)).graphData(model.graph).warmupTicks(100).cooldownTime(1e3).resumeAnimation();
182
- }
183
- }, [
184
- model,
185
- width,
186
- height
187
- ]);
188
- const handleZoomToFit = () => {
189
- forceGraph.current?.zoomToFit(400, 40);
190
- };
191
- return /* @__PURE__ */ React.createElement("div", {
192
- ref,
193
- className: "relative grow",
194
- onClick: handleZoomToFit
195
- }, /* @__PURE__ */ React.createElement("div", {
196
- ref: rootRef,
197
- className: "absolute inset-0"
198
- }));
199
- };
200
-
201
- export {
202
- SpaceGraphModel,
203
- Graph
204
- };
205
- //# sourceMappingURL=chunk-SBLNE7FL.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 { type CleanupFn } 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 } 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: 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?: CleanupFn;\n private _objects?: ReactiveEchoObject<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(): 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)?.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 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 { 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": ";AAKA,SACEA,WACAC,cACAC,KAEAC,uBACAC,iBACAC,oBACK;AACP,SAAyBC,kBAAkB;AAC3C,SAASC,WAAW;AACpB,SAASC,sBAAsB;AAC/B,S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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", "schema", "currentNodes", "addSchema", "typename", "current", "find", "node", "id", "push", "type", "data", "forEach", "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,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,236 +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_OIHH6TVE_exports = {};
30
- __export(chunk_OIHH6TVE_exports, {
31
- Graph: () => Graph,
32
- SpaceGraphModel: () => SpaceGraphModel
33
- });
34
- module.exports = __toCommonJS(chunk_OIHH6TVE_exports);
35
- var import_echo_schema = require("@dxos/echo-schema");
36
- var import_gem_spore = require("@dxos/gem-spore");
37
- var import_log = require("@dxos/log");
38
- var import_types = require("@dxos/plugin-space/types");
39
- var import_echo = require("@dxos/react-client/echo");
40
- var import_d3 = require("d3");
41
- var import_force_graph = __toESM(require("force-graph"));
42
- var import_react = __toESM(require("react"));
43
- var import_react_resize_detector = require("react-resize-detector");
44
- var import_plugin_search = require("@dxos/plugin-search");
45
- var import_react_ui = require("@dxos/react-ui");
46
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-explorer/src/components/Graph/graph-model.ts";
47
- var SpaceGraphModel = class extends import_gem_spore.GraphModel {
48
- constructor(_options = {}) {
49
- super();
50
- this._options = _options;
51
- this._graph = {
52
- nodes: [],
53
- links: []
54
- };
55
- }
56
- get graph() {
57
- return this._graph;
58
- }
59
- get objects() {
60
- return this._objects ?? [];
61
- }
62
- // TODO(burdon): Alternative diagram types:
63
- // - https://observablehq.com/@d3/radial-tree/2
64
- // - https://observablehq.com/@d3/disjoint-force-directed-graph/2
65
- // - https://observablehq.com/@mbostock/tadpoles
66
- // - https://observablehq.com/@d3/psr-b1919-21
67
- // - https://vasturiano.github.io/react-force-graph/example/basic (3D)
68
- async open(space, objectId) {
69
- if (!this._schemaSubscription) {
70
- const schemaaQuery = space.db.schemaRegistry.query({});
71
- const schemas = await schemaaQuery.run();
72
- const onSchemaUpdate = ({ results }) => this._schema = results;
73
- this._schemaSubscription = schemaaQuery.subscribe(onSchemaUpdate);
74
- onSchemaUpdate({
75
- results: schemas
76
- });
77
- 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 }) => {
78
- this._objects = objects;
79
- const currentNodes = this._graph.nodes;
80
- this._graph.nodes = [];
81
- this._graph.links = [];
82
- const addSchema = (typename) => {
83
- const current = currentNodes.find((node) => node.id === typename);
84
- if (typename) {
85
- this._graph.nodes.push({
86
- ...current,
87
- id: typename,
88
- type: "schema",
89
- data: {
90
- typename
91
- }
92
- });
93
- }
94
- };
95
- space.db.graph.schemaRegistry.schemas.forEach((schema) => {
96
- const typename = (0, import_echo_schema.getSchemaDXN)(schema)?.typename;
97
- if (typename) {
98
- addSchema(typename);
99
- }
100
- });
101
- this._schema?.forEach((schema) => {
102
- const typename = (0, import_echo_schema.getSchemaDXN)(schema)?.typename;
103
- if (typename) {
104
- addSchema(typename);
105
- }
106
- });
107
- this._objects.forEach((object) => {
108
- const schema = (0, import_echo_schema.getSchema)(object);
109
- if (schema) {
110
- const typename = (0, import_echo_schema.getSchemaDXN)(schema)?.typename;
111
- if (typename) {
112
- const current = currentNodes.find((node) => node.id === object.id);
113
- this._graph.nodes.push({
114
- ...current,
115
- id: object.id,
116
- type: "object",
117
- data: {
118
- typename,
119
- object
120
- }
121
- });
122
- const schemaNode = this._graph.nodes.find((node) => node.type === "schema" && node.data.typename === typename);
123
- if (schemaNode) {
124
- this._graph.links.push({
125
- id: `${object.id}-${schemaNode.id}`,
126
- source: object.id,
127
- target: schemaNode.id
128
- });
129
- } else {
130
- import_log.log.info("schema node not found", {
131
- typename
132
- }, {
133
- F: __dxlog_file,
134
- L: 147,
135
- S: this,
136
- C: (f, a) => f(...a)
137
- });
138
- }
139
- import_echo_schema.AST.getPropertySignatures(schema.ast).forEach((prop) => {
140
- if (!import_echo_schema.SchemaValidator.hasTypeAnnotation(schema, prop.name.toString(), import_echo_schema.ReferenceAnnotationId)) {
141
- return;
142
- }
143
- const value = object[String(prop.name)];
144
- if (value) {
145
- const refs = Array.isArray(value) ? value : [
146
- value
147
- ];
148
- for (const ref of refs) {
149
- if (objects.findIndex((obj) => obj.id === ref.id) !== -1) {
150
- this._graph.links.push({
151
- id: `${object.id}-${String(prop.name)}-${ref.id}`,
152
- source: object.id,
153
- target: ref.id
154
- });
155
- }
156
- }
157
- }
158
- });
159
- }
160
- }
161
- });
162
- this.triggerUpdate();
163
- }, {
164
- fire: true
165
- });
166
- }
167
- this.setSelected(objectId);
168
- return this;
169
- }
170
- close() {
171
- this._schemaSubscription?.();
172
- this._schemaSubscription = void 0;
173
- this._objectsSubscription?.();
174
- this._objectsSubscription = void 0;
175
- return this;
176
- }
177
- };
178
- var Graph = ({ space, match }) => {
179
- const { ref, width, height } = (0, import_react_resize_detector.useResizeDetector)({
180
- refreshRate: 200
181
- });
182
- const rootRef = (0, import_react.useRef)(null);
183
- const forceGraph = (0, import_react.useRef)();
184
- const [model] = (0, import_react_ui.useAsyncState)(async () => space ? new SpaceGraphModel({
185
- schema: true
186
- }).open(space) : void 0, [
187
- space
188
- ]);
189
- const filteredRef = (0, import_react.useRef)();
190
- filteredRef.current = (0, import_plugin_search.filterObjectsSync)(model?.objects ?? [], match);
191
- (0, import_react.useEffect)(() => {
192
- if (rootRef.current) {
193
- forceGraph.current = new import_force_graph.default(rootRef.current).nodeRelSize(6).nodeLabel((node) => {
194
- if (node.type === "schema") {
195
- return node.data.typename;
196
- }
197
- return node.id;
198
- }).nodeAutoColorBy((node) => node.type === "schema" ? "schema" : node.data.typename).linkColor(() => "rgba(255,255,255,0.25)");
199
- }
200
- return () => {
201
- forceGraph.current?.pauseAnimation().graphData({
202
- nodes: [],
203
- links: []
204
- });
205
- forceGraph.current = void 0;
206
- };
207
- }, []);
208
- (0, import_react.useEffect)(() => {
209
- if (forceGraph.current && width && height && model) {
210
- forceGraph.current.pauseAnimation().width(width).height(height).onEngineStop(() => {
211
- handleZoomToFit();
212
- }).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();
213
- }
214
- }, [
215
- model,
216
- width,
217
- height
218
- ]);
219
- const handleZoomToFit = () => {
220
- forceGraph.current?.zoomToFit(400, 40);
221
- };
222
- return /* @__PURE__ */ import_react.default.createElement("div", {
223
- ref,
224
- className: "relative grow",
225
- onClick: handleZoomToFit
226
- }, /* @__PURE__ */ import_react.default.createElement("div", {
227
- ref: rootRef,
228
- className: "absolute inset-0"
229
- }));
230
- };
231
- // Annotate the CommonJS export names for ESM import in node:
232
- 0 && (module.exports = {
233
- Graph,
234
- SpaceGraphModel
235
- });
236
- //# sourceMappingURL=chunk-OIHH6TVE.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 { type CleanupFn } 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 } 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: 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?: CleanupFn;\n private _objects?: ReactiveEchoObject<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(): 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)?.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 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 { 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}>\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;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", "schema", "StoredSchema", "CollectionType", "currentNodes", "addSchema", "typename", "current", "find", "node", "id", "push", "type", "data", "forEach", "getSchemaDXN", "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", "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,7 +0,0 @@
1
- {
2
- "version": 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/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
- "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
- "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
- }
@@ -1,28 +0,0 @@
1
- import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
- import {
3
- Graph
4
- } from "./chunk-SZRRNWYT.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-NMI55PYM.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,7 +0,0 @@
1
- {
2
- "version": 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/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
- "mappings": ";;;;;;AAIA,SAASA,GAAGC,mBAAmB;AAGxB,IAAMC,WAAN,cAAuBC,YAAY;EACxCC,UAAU;EACVC,SAAS;AACX,CAAA,EAAG;EACDC,MAAMC,EAAEC,SAASD,EAAEE,MAAM;EACzBC,MAAMH,EAAEE;AACV,CAAA,EAAA;AAAI;;;ACTJ,SAASE,KAAAA,UAAS;;UAKDC,iBAAAA;AACf,QAAMC,kBAAkB,GAAGC,eAAAA;EAEpB,MAAMC,eAAeC,GAAEC,YAAW,EAAW,GAAGJ,eAAAA,WAA0B;IAC/EK,OAAOF,GAAEG,OAAO;MACdC,MAAMJ,GAAEK,SAASL,GAAEM,MAAM;IAC3B,CAAA;IACAC,QAAQP,GAAEG,OAAO;MACfK,QAAQC;IACV,CAAA;EACF,CAAA,EAAA;EAAI;kBAPSV,SAAAA;AAQf,GAXiBH,mBAAAA,iBAAAA,CAAAA,EAAAA;",
6
- "names": ["S", "TypedObject", "ViewType", "TypedObject", "typename", "version", "name", "S", "optional", "String", "type", "S", "ExplorerAction", "EXPLORER_ACTION", "EXPLORER_PLUGIN", "Create", "S", "TaggedClass", "input", "Struct", "name", "optional", "String", "output", "object", "ViewType"]
7
- }