@xyo-network/react-node-renderer 2.47.35 → 2.47.36
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.
- package/dist/cjs/hooks/useCytoscapeElements.js +62 -36
- package/dist/cjs/hooks/useCytoscapeElements.js.map +1 -1
- package/dist/cjs/hooks/useIcons.js +4 -2
- package/dist/cjs/hooks/useIcons.js.map +1 -1
- package/dist/cjs/lib/utils.js +4 -0
- package/dist/cjs/lib/utils.js.map +1 -1
- package/dist/docs.json +16 -62
- package/dist/esm/hooks/useCytoscapeElements.js +60 -34
- package/dist/esm/hooks/useCytoscapeElements.js.map +1 -1
- package/dist/esm/hooks/useIcons.js +4 -2
- package/dist/esm/hooks/useIcons.js.map +1 -1
- package/dist/esm/lib/utils.js +4 -0
- package/dist/esm/lib/utils.js.map +1 -1
- package/dist/types/hooks/useCytoscapeElements.d.ts +2 -1
- package/dist/types/hooks/useCytoscapeElements.d.ts.map +1 -1
- package/dist/types/hooks/useIcons.d.ts +1 -1
- package/dist/types/hooks/useIcons.d.ts.map +1 -1
- package/dist/types/lib/utils.d.ts.map +1 -1
- package/package.json +7 -6
- package/src/components/RelationalGraph.stories.tsx +5 -0
- package/src/hooks/useCytoscapeElements.ts +66 -36
- package/src/hooks/useIcons.tsx +5 -3
- package/src/lib/utils.ts +4 -0
|
@@ -4,64 +4,90 @@ exports.useCytoscapeElements = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_shared_1 = require("@xylabs/react-shared");
|
|
6
6
|
const module_1 = require("@xyo-network/module");
|
|
7
|
-
const node_1 = require("@xyo-network/node");
|
|
8
7
|
const react_node_1 = require("@xyo-network/react-node");
|
|
9
8
|
const react_1 = require("react");
|
|
10
9
|
const lib_1 = require("../lib");
|
|
10
|
+
const MaxNameLength = 20;
|
|
11
|
+
const normalizeName = (name) => {
|
|
12
|
+
if (!name)
|
|
13
|
+
return;
|
|
14
|
+
if (name.length > MaxNameLength)
|
|
15
|
+
return `${name.substring(0, 20)}...`;
|
|
16
|
+
return name;
|
|
17
|
+
};
|
|
18
|
+
const buildNode = (description) => {
|
|
19
|
+
var _a;
|
|
20
|
+
const newNodeId = (_a = normalizeName(description.name)) !== null && _a !== void 0 ? _a : description.address.substring(0, 8);
|
|
21
|
+
return {
|
|
22
|
+
data: {
|
|
23
|
+
id: newNodeId,
|
|
24
|
+
type: (0, lib_1.parseModuleType)(description.queries),
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
const buildEdge = (rootNode, newNode) => ({
|
|
29
|
+
data: {
|
|
30
|
+
id: `${rootNode.data.id}/${newNode.data.id}`,
|
|
31
|
+
source: rootNode.data.id,
|
|
32
|
+
target: newNode.data.id,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
const buildRootNode = (wrapper) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
+
const description = yield (wrapper === null || wrapper === void 0 ? void 0 : wrapper.describe());
|
|
37
|
+
return [description, buildNode(description)];
|
|
38
|
+
});
|
|
39
|
+
const buildChild = (wrapper, address) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
40
|
+
const [result] = yield wrapper.resolveWrapped(module_1.ModuleWrapper, { address: [address] });
|
|
41
|
+
const description = yield result.describe();
|
|
42
|
+
return buildNode(description);
|
|
43
|
+
});
|
|
11
44
|
/**
|
|
12
45
|
* Note: Relies on describe but could eventually be converted to a discover call
|
|
13
46
|
* Logic would be similar to what the bridge does
|
|
14
47
|
*/
|
|
15
48
|
const useCytoscapeElements = () => {
|
|
16
49
|
const [node] = (0, react_node_1.useProvidedWrappedNode)();
|
|
17
|
-
const [elements, setElements] = (0, react_1.useState)();
|
|
50
|
+
const [elements, setElements] = (0, react_1.useState)([]);
|
|
51
|
+
const [refresh, setRefresh] = (0, react_1.useState)(1);
|
|
18
52
|
(0, react_shared_1.useAsyncEffect)(
|
|
19
53
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
20
|
-
() => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
-
var _a
|
|
22
|
-
if (node) {
|
|
54
|
+
(mounted) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
55
|
+
var _a;
|
|
56
|
+
if (node && refresh) {
|
|
23
57
|
try {
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const rootNodeId = (_a = description.name) !== null && _a !== void 0 ? _a : description.address.substring(0, 6);
|
|
28
|
-
newElements.push({
|
|
29
|
-
data: { id: rootNodeId, type: (0, lib_1.parseModuleType)(description.queries) },
|
|
30
|
-
});
|
|
58
|
+
const [description, newRootNode] = yield buildRootNode(node);
|
|
59
|
+
if (mounted())
|
|
60
|
+
setElements(() => [newRootNode]);
|
|
31
61
|
const children = description.children;
|
|
32
|
-
yield Promise.
|
|
33
|
-
var _c;
|
|
34
|
-
const [result] = yield wrapper.resolveWrapped(module_1.ModuleWrapper, { address: [address] });
|
|
62
|
+
yield Promise.allSettled((_a = (children !== null && children !== void 0 ? children : [])) === null || _a === void 0 ? void 0 : _a.map((address) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
35
63
|
try {
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
newElements.push(newNode);
|
|
45
|
-
const newEdge = {
|
|
46
|
-
data: {
|
|
47
|
-
id: `${rootNodeId}/${newNodeId}`,
|
|
48
|
-
source: rootNodeId,
|
|
49
|
-
target: newNodeId,
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
newElements.push(newEdge);
|
|
64
|
+
const newNode = yield buildChild(node, address);
|
|
65
|
+
if (mounted())
|
|
66
|
+
setElements((previous) => [...previous, newNode]);
|
|
67
|
+
const newEdge = buildEdge(newRootNode, newNode);
|
|
68
|
+
if (mounted())
|
|
69
|
+
setElements((previous) => [...previous, newEdge]);
|
|
53
70
|
}
|
|
54
71
|
catch (e) {
|
|
55
|
-
console.error(
|
|
72
|
+
console.error('Error parsing children', e);
|
|
56
73
|
}
|
|
57
74
|
})));
|
|
58
|
-
setElements(newElements);
|
|
59
75
|
}
|
|
60
76
|
catch (e) {
|
|
61
|
-
console.error(e);
|
|
77
|
+
console.error('Error Getting initial description', e);
|
|
62
78
|
}
|
|
63
79
|
}
|
|
64
|
-
}), [node]);
|
|
80
|
+
}), [node, refresh]);
|
|
81
|
+
(0, react_1.useEffect)(() => {
|
|
82
|
+
let listener;
|
|
83
|
+
if (node) {
|
|
84
|
+
listener = node.onAny((eventName) => {
|
|
85
|
+
if (eventName === 'moduleAttached')
|
|
86
|
+
setRefresh((previous) => previous + 1);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
return () => listener === null || listener === void 0 ? void 0 : listener();
|
|
90
|
+
}, [node]);
|
|
65
91
|
return elements;
|
|
66
92
|
};
|
|
67
93
|
exports.useCytoscapeElements = useCytoscapeElements;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCytoscapeElements.js","sourceRoot":"","sources":["../../../src/hooks/useCytoscapeElements.ts"],"names":[],"mappings":";;;;AAAA,uDAAqD;AACrD,
|
|
1
|
+
{"version":3,"file":"useCytoscapeElements.js","sourceRoot":"","sources":["../../../src/hooks/useCytoscapeElements.ts"],"names":[],"mappings":";;;;AAAA,uDAAqD;AACrD,gDAAgG;AAEhG,wDAAgE;AAEhE,iCAA2C;AAE3C,gCAAwC;AAExC,MAAM,aAAa,GAAG,EAAE,CAAA;AAExB,MAAM,aAAa,GAAG,CAAC,IAAa,EAAE,EAAE;IACtC,IAAI,CAAC,IAAI;QAAE,OAAM;IACjB,IAAI,IAAI,CAAC,MAAM,GAAG,aAAa;QAAE,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAA;IACrE,OAAO,IAAI,CAAA;AACb,CAAC,CAAA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wBAAwB,EAAE,CAAC,CAAC,CAAA;qBAC3C;gBACH,CAAC,CAAA,CAAC,CACH,CAAA;aACF;YAAC,OAAO,CAAC,EAAE;gBACV,OAAO,CAAC,KAAK,CAAC,mCAAmC,EAAE,CAAC,CAAC,CAAA;aACtD;SACF;IACH,CAAC,CAAA,EACD,CAAC,IAAI,EAAE,OAAO,CAAC,CAChB,CAAA;IAED,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,QAAkC,CAAA;QACtC,IAAI,IAAI,EAAE;YACR,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,SAAS,EAAE,EAAE;gBAClC,IAAI,SAAS,KAAK,gBAAgB;oBAAE,UAAU,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAA;YAC5E,CAAC,CAAC,CAAA;SACH;QACD,OAAO,GAAG,EAAE,CAAC,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,EAAI,CAAA;IAC3B,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA;IAEV,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA;AA9CY,QAAA,oBAAoB,wBA8ChC"}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useIcons = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const CallMergeRounded_1 = tslib_1.__importDefault(require("@mui/icons-material/CallMergeRounded"));
|
|
6
7
|
const GridViewRounded_1 = tslib_1.__importDefault(require("@mui/icons-material/GridViewRounded"));
|
|
7
8
|
const Hub_1 = tslib_1.__importDefault(require("@mui/icons-material/Hub"));
|
|
8
9
|
const QuestionMarkRounded_1 = tslib_1.__importDefault(require("@mui/icons-material/QuestionMarkRounded"));
|
|
@@ -13,14 +14,15 @@ const lib_1 = require("../lib");
|
|
|
13
14
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
14
15
|
const CyIconSet = {
|
|
15
16
|
archivist: GridViewRounded_1.default,
|
|
16
|
-
diviner:
|
|
17
|
+
diviner: CallMergeRounded_1.default,
|
|
17
18
|
module: QuestionMarkRounded_1.default,
|
|
18
19
|
node: Hub_1.default,
|
|
20
|
+
witness: VisibilityRounded_1.default,
|
|
19
21
|
};
|
|
20
22
|
const useIcons = () => {
|
|
21
23
|
const theme = (0, material_1.useTheme)();
|
|
22
24
|
const icons = (0, react_1.useMemo)(() => {
|
|
23
|
-
const iconMap = { archivist: '', diviner: '', module: '', node: '' };
|
|
25
|
+
const iconMap = { archivist: '', diviner: '', module: '', node: '', witness: '' };
|
|
24
26
|
return Object.entries(CyIconSet).reduce((acc, [name, IconComponent]) => {
|
|
25
27
|
const icon = (0, jsx_runtime_1.jsx)(IconComponent, { fontSize: "small" });
|
|
26
28
|
acc[name] = (0, lib_1.encodeSvg)(icon, theme.palette.getContrastText(theme.palette.text.primary));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIcons.js","sourceRoot":"","sources":["../../../src/hooks/useIcons.tsx"],"names":[],"mappings":";;;;;AAAA,kGAAqE;AACrE,0EAA6C;AAC7C,0GAA6E;AAC7E,sGAAyE;AACzE,4CAAwD;AAExD,iCAA+B;AAE/B,gCAAkC;AAIlC,wDAAwD;AACxD,MAAM,SAAS,GAAyE;IACtF,SAAS,EAAE,yBAAmB;IAC9B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useIcons.js","sourceRoot":"","sources":["../../../src/hooks/useIcons.tsx"],"names":[],"mappings":";;;;;AAAA,oGAAuE;AACvE,kGAAqE;AACrE,0EAA6C;AAC7C,0GAA6E;AAC7E,sGAAyE;AACzE,4CAAwD;AAExD,iCAA+B;AAE/B,gCAAkC;AAIlC,wDAAwD;AACxD,MAAM,SAAS,GAAyE;IACtF,SAAS,EAAE,yBAAmB;IAC9B,OAAO,EAAE,0BAAoB;IAC7B,MAAM,EAAE,6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AChB,MAAK;aACN;YACD,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;gBAC/B,IAAI,GAAG,MAAM,CAAA;gBACb,MAAK;aACN;YACD,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;gBAClC,IAAI,GAAG,SAAS,CAAA;gBAChB,MAAK;aACN;YACD,IAAI,GAAG,QAAQ,CAAA;SAChB;QACD,OAAO,IAAI,CAAA;KACZ;AACH,CAAC,CAAA;AAxBY,QAAA,eAAe,mBAwB3B"}
|
package/dist/docs.json
CHANGED
|
@@ -12975,7 +12975,7 @@
|
|
|
12975
12975
|
"fileName": "packages/sdk/packages/node-renderer/src/components/RelationalGraph.tsx",
|
|
12976
12976
|
"line": 8,
|
|
12977
12977
|
"character": 2,
|
|
12978
|
-
"url": "https://github.com/XYOracleNetwork/sdk-xyo-react-js/blob/
|
|
12978
|
+
"url": "https://github.com/XYOracleNetwork/sdk-xyo-react-js/blob/3da224d36/packages/sdk/packages/node-renderer/src/components/RelationalGraph.tsx#L8"
|
|
12979
12979
|
}
|
|
12980
12980
|
],
|
|
12981
12981
|
"type": {
|
|
@@ -18398,13 +18398,13 @@
|
|
|
18398
18398
|
"fileName": "packages/sdk/packages/node-renderer/src/components/RelationalGraph.tsx",
|
|
18399
18399
|
"line": 7,
|
|
18400
18400
|
"character": 17,
|
|
18401
|
-
"url": "https://github.com/XYOracleNetwork/sdk-xyo-react-js/blob/
|
|
18401
|
+
"url": "https://github.com/XYOracleNetwork/sdk-xyo-react-js/blob/3da224d36/packages/sdk/packages/node-renderer/src/components/RelationalGraph.tsx#L7"
|
|
18402
18402
|
},
|
|
18403
18403
|
{
|
|
18404
18404
|
"fileName": "packages/sdk/packages/node-renderer/src/components/RelationalGraph.tsx",
|
|
18405
18405
|
"line": 11,
|
|
18406
18406
|
"character": 13,
|
|
18407
|
-
"url": "https://github.com/XYOracleNetwork/sdk-xyo-react-js/blob/
|
|
18407
|
+
"url": "https://github.com/XYOracleNetwork/sdk-xyo-react-js/blob/3da224d36/packages/sdk/packages/node-renderer/src/components/RelationalGraph.tsx#L11"
|
|
18408
18408
|
}
|
|
18409
18409
|
],
|
|
18410
18410
|
"extendedTypes": [
|
|
@@ -18435,13 +18435,13 @@
|
|
|
18435
18435
|
"fileName": "packages/sdk/packages/node-renderer/src/components/RelationalGraph.tsx",
|
|
18436
18436
|
"line": 7,
|
|
18437
18437
|
"character": 17,
|
|
18438
|
-
"url": "https://github.com/XYOracleNetwork/sdk-xyo-react-js/blob/
|
|
18438
|
+
"url": "https://github.com/XYOracleNetwork/sdk-xyo-react-js/blob/3da224d36/packages/sdk/packages/node-renderer/src/components/RelationalGraph.tsx#L7"
|
|
18439
18439
|
},
|
|
18440
18440
|
{
|
|
18441
18441
|
"fileName": "packages/sdk/packages/node-renderer/src/components/RelationalGraph.tsx",
|
|
18442
18442
|
"line": 11,
|
|
18443
18443
|
"character": 13,
|
|
18444
|
-
"url": "https://github.com/XYOracleNetwork/sdk-xyo-react-js/blob/
|
|
18444
|
+
"url": "https://github.com/XYOracleNetwork/sdk-xyo-react-js/blob/3da224d36/packages/sdk/packages/node-renderer/src/components/RelationalGraph.tsx#L11"
|
|
18445
18445
|
}
|
|
18446
18446
|
],
|
|
18447
18447
|
"signatures": [
|
|
@@ -18546,9 +18546,9 @@
|
|
|
18546
18546
|
"sources": [
|
|
18547
18547
|
{
|
|
18548
18548
|
"fileName": "packages/sdk/packages/node-renderer/src/hooks/useCytoscapeElements.ts",
|
|
18549
|
-
"line":
|
|
18549
|
+
"line": 51,
|
|
18550
18550
|
"character": 13,
|
|
18551
|
-
"url": "https://github.com/XYOracleNetwork/sdk-xyo-react-js/blob/
|
|
18551
|
+
"url": "https://github.com/XYOracleNetwork/sdk-xyo-react-js/blob/3da224d36/packages/sdk/packages/node-renderer/src/hooks/useCytoscapeElements.ts#L51"
|
|
18552
18552
|
}
|
|
18553
18553
|
],
|
|
18554
18554
|
"signatures": [
|
|
@@ -18567,59 +18567,13 @@
|
|
|
18567
18567
|
]
|
|
18568
18568
|
},
|
|
18569
18569
|
"type": {
|
|
18570
|
-
"type": "
|
|
18571
|
-
"
|
|
18572
|
-
|
|
18573
|
-
|
|
18574
|
-
|
|
18575
|
-
|
|
18576
|
-
|
|
18577
|
-
"type": "reference",
|
|
18578
|
-
"name": "ElementsDefinition",
|
|
18579
|
-
"qualifiedName": "cytoscape.ElementsDefinition",
|
|
18580
|
-
"package": "@types/cytoscape"
|
|
18581
|
-
},
|
|
18582
|
-
{
|
|
18583
|
-
"type": "array",
|
|
18584
|
-
"elementType": {
|
|
18585
|
-
"type": "reference",
|
|
18586
|
-
"name": "ElementDefinition",
|
|
18587
|
-
"qualifiedName": "cytoscape.ElementDefinition",
|
|
18588
|
-
"package": "@types/cytoscape"
|
|
18589
|
-
}
|
|
18590
|
-
},
|
|
18591
|
-
{
|
|
18592
|
-
"type": "reference",
|
|
18593
|
-
"typeArguments": [
|
|
18594
|
-
{
|
|
18595
|
-
"type": "reference",
|
|
18596
|
-
"name": "ElementsDefinition",
|
|
18597
|
-
"qualifiedName": "cytoscape.ElementsDefinition",
|
|
18598
|
-
"package": "@types/cytoscape"
|
|
18599
|
-
}
|
|
18600
|
-
],
|
|
18601
|
-
"name": "Promise",
|
|
18602
|
-
"qualifiedName": "Promise",
|
|
18603
|
-
"package": "typescript"
|
|
18604
|
-
},
|
|
18605
|
-
{
|
|
18606
|
-
"type": "reference",
|
|
18607
|
-
"typeArguments": [
|
|
18608
|
-
{
|
|
18609
|
-
"type": "array",
|
|
18610
|
-
"elementType": {
|
|
18611
|
-
"type": "reference",
|
|
18612
|
-
"name": "ElementDefinition",
|
|
18613
|
-
"qualifiedName": "cytoscape.ElementDefinition",
|
|
18614
|
-
"package": "@types/cytoscape"
|
|
18615
|
-
}
|
|
18616
|
-
}
|
|
18617
|
-
],
|
|
18618
|
-
"name": "Promise",
|
|
18619
|
-
"qualifiedName": "Promise",
|
|
18620
|
-
"package": "typescript"
|
|
18621
|
-
}
|
|
18622
|
-
]
|
|
18570
|
+
"type": "array",
|
|
18571
|
+
"elementType": {
|
|
18572
|
+
"type": "reference",
|
|
18573
|
+
"name": "ElementDefinition",
|
|
18574
|
+
"qualifiedName": "cytoscape.ElementDefinition",
|
|
18575
|
+
"package": "@types/cytoscape"
|
|
18576
|
+
}
|
|
18623
18577
|
}
|
|
18624
18578
|
}
|
|
18625
18579
|
]
|
|
@@ -18635,7 +18589,7 @@
|
|
|
18635
18589
|
"fileName": "packages/sdk/packages/node-renderer/src/hooks/useCytoscapeOptions.ts",
|
|
18636
18590
|
"line": 7,
|
|
18637
18591
|
"character": 13,
|
|
18638
|
-
"url": "https://github.com/XYOracleNetwork/sdk-xyo-react-js/blob/
|
|
18592
|
+
"url": "https://github.com/XYOracleNetwork/sdk-xyo-react-js/blob/3da224d36/packages/sdk/packages/node-renderer/src/hooks/useCytoscapeOptions.ts#L7"
|
|
18639
18593
|
}
|
|
18640
18594
|
],
|
|
18641
18595
|
"signatures": [
|
|
@@ -18740,7 +18694,7 @@
|
|
|
18740
18694
|
"fileName": "packages/sdk/packages/node-renderer/src/index.ts",
|
|
18741
18695
|
"line": 1,
|
|
18742
18696
|
"character": 0,
|
|
18743
|
-
"url": "https://github.com/XYOracleNetwork/sdk-xyo-react-js/blob/
|
|
18697
|
+
"url": "https://github.com/XYOracleNetwork/sdk-xyo-react-js/blob/3da224d36/packages/sdk/packages/node-renderer/src/index.ts#L1"
|
|
18744
18698
|
}
|
|
18745
18699
|
]
|
|
18746
18700
|
}
|
|
@@ -1,60 +1,86 @@
|
|
|
1
1
|
import { useAsyncEffect } from '@xylabs/react-shared';
|
|
2
2
|
import { ModuleWrapper } from '@xyo-network/module';
|
|
3
|
-
import { NodeWrapper } from '@xyo-network/node';
|
|
4
3
|
import { useProvidedWrappedNode } from '@xyo-network/react-node';
|
|
5
|
-
import { useState } from 'react';
|
|
4
|
+
import { useEffect, useState } from 'react';
|
|
6
5
|
import { parseModuleType } from '../lib';
|
|
6
|
+
const MaxNameLength = 20;
|
|
7
|
+
const normalizeName = (name) => {
|
|
8
|
+
if (!name)
|
|
9
|
+
return;
|
|
10
|
+
if (name.length > MaxNameLength)
|
|
11
|
+
return `${name.substring(0, 20)}...`;
|
|
12
|
+
return name;
|
|
13
|
+
};
|
|
14
|
+
const buildNode = (description) => {
|
|
15
|
+
const newNodeId = normalizeName(description.name) ?? description.address.substring(0, 8);
|
|
16
|
+
return {
|
|
17
|
+
data: {
|
|
18
|
+
id: newNodeId,
|
|
19
|
+
type: parseModuleType(description.queries),
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
const buildEdge = (rootNode, newNode) => ({
|
|
24
|
+
data: {
|
|
25
|
+
id: `${rootNode.data.id}/${newNode.data.id}`,
|
|
26
|
+
source: rootNode.data.id,
|
|
27
|
+
target: newNode.data.id,
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
const buildRootNode = async (wrapper) => {
|
|
31
|
+
const description = await wrapper?.describe();
|
|
32
|
+
return [description, buildNode(description)];
|
|
33
|
+
};
|
|
34
|
+
const buildChild = async (wrapper, address) => {
|
|
35
|
+
const [result] = await wrapper.resolveWrapped(ModuleWrapper, { address: [address] });
|
|
36
|
+
const description = await result.describe();
|
|
37
|
+
return buildNode(description);
|
|
38
|
+
};
|
|
7
39
|
/**
|
|
8
40
|
* Note: Relies on describe but could eventually be converted to a discover call
|
|
9
41
|
* Logic would be similar to what the bridge does
|
|
10
42
|
*/
|
|
11
43
|
export const useCytoscapeElements = () => {
|
|
12
44
|
const [node] = useProvidedWrappedNode();
|
|
13
|
-
const [elements, setElements] = useState();
|
|
45
|
+
const [elements, setElements] = useState([]);
|
|
46
|
+
const [refresh, setRefresh] = useState(1);
|
|
14
47
|
useAsyncEffect(
|
|
15
48
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
16
|
-
async () => {
|
|
17
|
-
if (node) {
|
|
49
|
+
async (mounted) => {
|
|
50
|
+
if (node && refresh) {
|
|
18
51
|
try {
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const rootNodeId = description.name ?? description.address.substring(0, 6);
|
|
23
|
-
newElements.push({
|
|
24
|
-
data: { id: rootNodeId, type: parseModuleType(description.queries) },
|
|
25
|
-
});
|
|
52
|
+
const [description, newRootNode] = await buildRootNode(node);
|
|
53
|
+
if (mounted())
|
|
54
|
+
setElements(() => [newRootNode]);
|
|
26
55
|
const children = description.children;
|
|
27
|
-
await Promise.
|
|
28
|
-
const [result] = await wrapper.resolveWrapped(ModuleWrapper, { address: [address] });
|
|
56
|
+
await Promise.allSettled((children ?? [])?.map(async (address) => {
|
|
29
57
|
try {
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
newElements.push(newNode);
|
|
39
|
-
const newEdge = {
|
|
40
|
-
data: {
|
|
41
|
-
id: `${rootNodeId}/${newNodeId}`,
|
|
42
|
-
source: rootNodeId,
|
|
43
|
-
target: newNodeId,
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
newElements.push(newEdge);
|
|
58
|
+
const newNode = await buildChild(node, address);
|
|
59
|
+
if (mounted())
|
|
60
|
+
setElements((previous) => [...previous, newNode]);
|
|
61
|
+
const newEdge = buildEdge(newRootNode, newNode);
|
|
62
|
+
if (mounted())
|
|
63
|
+
setElements((previous) => [...previous, newEdge]);
|
|
47
64
|
}
|
|
48
65
|
catch (e) {
|
|
49
|
-
console.error(
|
|
66
|
+
console.error('Error parsing children', e);
|
|
50
67
|
}
|
|
51
68
|
}));
|
|
52
|
-
setElements(newElements);
|
|
53
69
|
}
|
|
54
70
|
catch (e) {
|
|
55
|
-
console.error(e);
|
|
71
|
+
console.error('Error Getting initial description', e);
|
|
56
72
|
}
|
|
57
73
|
}
|
|
74
|
+
}, [node, refresh]);
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
let listener;
|
|
77
|
+
if (node) {
|
|
78
|
+
listener = node.onAny((eventName) => {
|
|
79
|
+
if (eventName === 'moduleAttached')
|
|
80
|
+
setRefresh((previous) => previous + 1);
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
return () => listener?.();
|
|
58
84
|
}, [node]);
|
|
59
85
|
return elements;
|
|
60
86
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCytoscapeElements.js","sourceRoot":"","sources":["../../../src/hooks/useCytoscapeElements.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,
|
|
1
|
+
{"version":3,"file":"useCytoscapeElements.js","sourceRoot":"","sources":["../../../src/hooks/useCytoscapeElements.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAA+C,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAEhG,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AAEhE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAE3C,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AAExC,MAAM,aAAa,GAAG,EAAE,CAAA;AAExB,MAAM,aAAa,GAAG,CAAC,IAAa,EAAE,EAAE;IACtC,IAAI,CAAC,IAAI;QAAE,OAAM;IACjB,IAAI,IAAI,CAAC,MAAM,GAAG,aAAa;QAAE,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAA;IACrE,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAED,MAAM,SAAS,GAAG,CAAC,WAA8B,EAAqB,EAAE;IACtE,MAAM,SAAS,GAAG,aAAa,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,WAAW,CAAC,OAAO,CAAC,SAAS,CA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AAC,GAAG,EAAE;QACb,IAAI,QAAkC,CAAA;QACtC,IAAI,IAAI,EAAE;YACR,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,SAAS,EAAE,EAAE;gBAClC,IAAI,SAAS,KAAK,gBAAgB;oBAAE,UAAU,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAA;YAC5E,CAAC,CAAC,CAAA;SACH;QACD,OAAO,GAAG,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAA;IAC3B,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA;IAEV,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import CallMergeRoundedIcon from '@mui/icons-material/CallMergeRounded';
|
|
2
3
|
import GridViewRoundedIcon from '@mui/icons-material/GridViewRounded';
|
|
3
4
|
import HubIcon from '@mui/icons-material/Hub';
|
|
4
5
|
import QuestionMarkRoundedIcon from '@mui/icons-material/QuestionMarkRounded';
|
|
@@ -9,14 +10,15 @@ import { encodeSvg } from '../lib';
|
|
|
9
10
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
10
11
|
const CyIconSet = {
|
|
11
12
|
archivist: GridViewRoundedIcon,
|
|
12
|
-
diviner:
|
|
13
|
+
diviner: CallMergeRoundedIcon,
|
|
13
14
|
module: QuestionMarkRoundedIcon,
|
|
14
15
|
node: HubIcon,
|
|
16
|
+
witness: VisibilityRoundedIcon,
|
|
15
17
|
};
|
|
16
18
|
export const useIcons = () => {
|
|
17
19
|
const theme = useTheme();
|
|
18
20
|
const icons = useMemo(() => {
|
|
19
|
-
const iconMap = { archivist: '', diviner: '', module: '', node: '' };
|
|
21
|
+
const iconMap = { archivist: '', diviner: '', module: '', node: '', witness: '' };
|
|
20
22
|
return Object.entries(CyIconSet).reduce((acc, [name, IconComponent]) => {
|
|
21
23
|
const icon = _jsx(IconComponent, { fontSize: "small" });
|
|
22
24
|
acc[name] = encodeSvg(icon, theme.palette.getContrastText(theme.palette.text.primary));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIcons.js","sourceRoot":"","sources":["../../../src/hooks/useIcons.tsx"],"names":[],"mappings":";AAAA,OAAO,mBAAmB,MAAM,qCAAqC,CAAA;AACrE,OAAO,OAAO,MAAM,yBAAyB,CAAA;AAC7C,OAAO,uBAAuB,MAAM,yCAAyC,CAAA;AAC7E,OAAO,qBAAqB,MAAM,uCAAuC,CAAA;AACzE,OAAO,EAAkB,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExD,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAE/B,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAIlC,wDAAwD;AACxD,MAAM,SAAS,GAAyE;IACtF,SAAS,EAAE,mBAAmB;IAC9B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useIcons.js","sourceRoot":"","sources":["../../../src/hooks/useIcons.tsx"],"names":[],"mappings":";AAAA,OAAO,oBAAoB,MAAM,sCAAsC,CAAA;AACvE,OAAO,mBAAmB,MAAM,qCAAqC,CAAA;AACrE,OAAO,OAAO,MAAM,yBAAyB,CAAA;AAC7C,OAAO,uBAAuB,MAAM,yCAAyC,CAAA;AAC7E,OAAO,qBAAqB,MAAM,uCAAuC,CAAA;AACzE,OAAO,EAAkB,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExD,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAE/B,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAIlC,wDAAwD;AACxD,MAAM,SAAS,GAAyE;IACtF,SAAS,EAAE,mBAAmB;IAC9B,OAAO,EAAE,oBAAoB;IAC7B,MAAM,EAAE,uBAAuB;IAC/B,IAAI,EAAE,OAAO;IACb,OAAO,EAAE,qBAAqB;CAC/B,CAAA;AAED,MA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AAM,CAAA;gBACb,MAAK;aACN;YACD,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;gBAClC,IAAI,GAAG,SAAS,CAAA;gBAChB,MAAK;aACN;YACD,IAAI,GAAG,QAAQ,CAAA;SAChB;QACD,OAAO,IAAI,CAAA;KACZ;AACH,CAAC,CAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { ElementDefinition } from 'cytoscape';
|
|
1
2
|
/**
|
|
2
3
|
* Note: Relies on describe but could eventually be converted to a discover call
|
|
3
4
|
* Logic would be similar to what the bridge does
|
|
4
5
|
*/
|
|
5
|
-
export declare const useCytoscapeElements: () =>
|
|
6
|
+
export declare const useCytoscapeElements: () => ElementDefinition[];
|
|
6
7
|
//# sourceMappingURL=useCytoscapeElements.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCytoscapeElements.d.ts","sourceRoot":"","sources":["../../../src/hooks/useCytoscapeElements.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCytoscapeElements.d.ts","sourceRoot":"","sources":["../../../src/hooks/useCytoscapeElements.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AA0C7C;;;GAGG;AACH,eAAO,MAAM,oBAAoB,2BA8ChC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIcons.d.ts","sourceRoot":"","sources":["../../../src/hooks/useIcons.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useIcons.d.ts","sourceRoot":"","sources":["../../../src/hooks/useIcons.tsx"],"names":[],"mappings":"AAWA,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAA;AAWjF,eAAO,MAAM,QAAQ,mCAYpB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAMpC,eAAO,MAAM,SAAS,iBAAkB,YAAY,UAAU,MAAM,WAYnE,CAAA;AAED,eAAO,MAAM,eAAe,aAAc,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAMpC,eAAO,MAAM,SAAS,iBAAkB,YAAY,UAAU,MAAM,WAYnE,CAAA;AAED,eAAO,MAAM,eAAe,aAAc,MAAM,EAAE,uBAwBjD,CAAA"}
|
package/package.json
CHANGED
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"@xylabs/react-shared": "^2.16.14",
|
|
15
15
|
"@xyo-network/module": "^2.53.36",
|
|
16
16
|
"@xyo-network/node": "^2.53.36",
|
|
17
|
-
"@xyo-network/react-node": "^2.47.
|
|
18
|
-
"@xyo-network/react-shared": "^2.47.
|
|
17
|
+
"@xyo-network/react-node": "^2.47.36",
|
|
18
|
+
"@xyo-network/react-shared": "^2.47.36",
|
|
19
19
|
"cytoscape": "^3.23.0"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
@@ -36,11 +36,12 @@
|
|
|
36
36
|
"@xyo-network/account": "^2.53.34",
|
|
37
37
|
"@xyo-network/archivist": "^2.53.34",
|
|
38
38
|
"@xyo-network/bridge": "^2.53.34",
|
|
39
|
+
"@xyo-network/id-plugin": "^2.53.34",
|
|
39
40
|
"@xyo-network/module": "^2.53.34",
|
|
40
41
|
"@xyo-network/node": "^2.53.34",
|
|
41
|
-
"@xyo-network/react-node": "^2.47.
|
|
42
|
-
"@xyo-network/react-storybook": "^2.47.
|
|
43
|
-
"@xyo-network/react-wallet": "^2.47.
|
|
42
|
+
"@xyo-network/react-node": "^2.47.36",
|
|
43
|
+
"@xyo-network/react-storybook": "^2.47.36",
|
|
44
|
+
"@xyo-network/react-wallet": "^2.47.36",
|
|
44
45
|
"require-from-string": "^2.0.2",
|
|
45
46
|
"typescript": "^4.9.5"
|
|
46
47
|
},
|
|
@@ -87,5 +88,5 @@
|
|
|
87
88
|
},
|
|
88
89
|
"sideEffects": false,
|
|
89
90
|
"types": "dist/types/index.d.ts",
|
|
90
|
-
"version": "2.47.
|
|
91
|
+
"version": "2.47.36"
|
|
91
92
|
}
|
|
@@ -3,6 +3,7 @@ import { useAsyncEffect } from '@xylabs/react-shared'
|
|
|
3
3
|
import { HDWallet } from '@xyo-network/account'
|
|
4
4
|
import { ArchivistConfigSchema, MemoryArchivist } from '@xyo-network/archivist'
|
|
5
5
|
import { HttpBridge, HttpBridgeConfigSchema } from '@xyo-network/bridge'
|
|
6
|
+
import { IdWitness, IdWitnessConfigSchema } from '@xyo-network/id-plugin'
|
|
6
7
|
import { MemoryNode, NodeConfigSchema } from '@xyo-network/node'
|
|
7
8
|
import { NodeProvider } from '@xyo-network/react-node'
|
|
8
9
|
import { DefaultSeedPhrase } from '@xyo-network/react-storybook'
|
|
@@ -38,6 +39,10 @@ export const MemoryNodeDecorator: DecoratorFn = (Story, args) => {
|
|
|
38
39
|
await node1.register(archivist1)
|
|
39
40
|
await node1.attach(archivist1.address, true)
|
|
40
41
|
|
|
42
|
+
const witnessModule = await IdWitness.create({ config: { name: 'IdWitness', salt: 'test', schema: IdWitnessConfigSchema } })
|
|
43
|
+
await node1.register(witnessModule)
|
|
44
|
+
await node1.attach(witnessModule.address, true)
|
|
45
|
+
|
|
41
46
|
await node.register(node1)
|
|
42
47
|
await node.attach(node1.address, true)
|
|
43
48
|
|
|
@@ -1,67 +1,97 @@
|
|
|
1
1
|
import { useAsyncEffect } from '@xylabs/react-shared'
|
|
2
|
-
import { ModuleWrapper } from '@xyo-network/module'
|
|
2
|
+
import { EventUnsubscribeFunction, ModuleDescription, ModuleWrapper } from '@xyo-network/module'
|
|
3
3
|
import { NodeWrapper } from '@xyo-network/node'
|
|
4
4
|
import { useProvidedWrappedNode } from '@xyo-network/react-node'
|
|
5
|
-
import {
|
|
6
|
-
import { useState } from 'react'
|
|
5
|
+
import { ElementDefinition } from 'cytoscape'
|
|
6
|
+
import { useEffect, useState } from 'react'
|
|
7
7
|
|
|
8
8
|
import { parseModuleType } from '../lib'
|
|
9
9
|
|
|
10
|
+
const MaxNameLength = 20
|
|
11
|
+
|
|
12
|
+
const normalizeName = (name?: string) => {
|
|
13
|
+
if (!name) return
|
|
14
|
+
if (name.length > MaxNameLength) return `${name.substring(0, 20)}...`
|
|
15
|
+
return name
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const buildNode = (description: ModuleDescription): ElementDefinition => {
|
|
19
|
+
const newNodeId = normalizeName(description.name) ?? description.address.substring(0, 8)
|
|
20
|
+
return {
|
|
21
|
+
data: {
|
|
22
|
+
id: newNodeId,
|
|
23
|
+
type: parseModuleType(description.queries),
|
|
24
|
+
},
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const buildEdge = (rootNode: ElementDefinition, newNode: ElementDefinition) => ({
|
|
29
|
+
data: {
|
|
30
|
+
id: `${rootNode.data.id}/${newNode.data.id}`,
|
|
31
|
+
source: rootNode.data.id,
|
|
32
|
+
target: newNode.data.id,
|
|
33
|
+
},
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
const buildRootNode = async (wrapper: NodeWrapper): Promise<[ModuleDescription, ElementDefinition]> => {
|
|
37
|
+
const description = await wrapper?.describe()
|
|
38
|
+
return [description, buildNode(description)]
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const buildChild = async (wrapper: NodeWrapper, address: string) => {
|
|
42
|
+
const [result] = await wrapper.resolveWrapped(ModuleWrapper, { address: [address] })
|
|
43
|
+
const description = await result.describe()
|
|
44
|
+
return buildNode(description)
|
|
45
|
+
}
|
|
46
|
+
|
|
10
47
|
/**
|
|
11
48
|
* Note: Relies on describe but could eventually be converted to a discover call
|
|
12
49
|
* Logic would be similar to what the bridge does
|
|
13
50
|
*/
|
|
14
51
|
export const useCytoscapeElements = () => {
|
|
15
52
|
const [node] = useProvidedWrappedNode()
|
|
16
|
-
const [elements, setElements] = useState<
|
|
53
|
+
const [elements, setElements] = useState<ElementDefinition[]>([])
|
|
54
|
+
const [refresh, setRefresh] = useState(1)
|
|
17
55
|
|
|
18
56
|
useAsyncEffect(
|
|
19
57
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
20
|
-
async () => {
|
|
21
|
-
if (node) {
|
|
58
|
+
async (mounted) => {
|
|
59
|
+
if (node && refresh) {
|
|
22
60
|
try {
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const rootNodeId = description.name ?? description.address.substring(0, 6)
|
|
27
|
-
newElements.push({
|
|
28
|
-
data: { id: rootNodeId, type: parseModuleType(description.queries) },
|
|
29
|
-
})
|
|
61
|
+
const [description, newRootNode] = await buildRootNode(node)
|
|
62
|
+
if (mounted()) setElements(() => [newRootNode])
|
|
63
|
+
|
|
30
64
|
const children = description.children
|
|
31
|
-
await Promise.
|
|
65
|
+
await Promise.allSettled(
|
|
32
66
|
(children ?? [])?.map(async (address) => {
|
|
33
|
-
const [result] = await wrapper.resolveWrapped(ModuleWrapper, { address: [address] })
|
|
34
67
|
try {
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
type: parseModuleType(description.queries),
|
|
41
|
-
},
|
|
42
|
-
}
|
|
43
|
-
newElements.push(newNode)
|
|
44
|
-
const newEdge = {
|
|
45
|
-
data: {
|
|
46
|
-
id: `${rootNodeId}/${newNodeId}`,
|
|
47
|
-
source: rootNodeId,
|
|
48
|
-
target: newNodeId,
|
|
49
|
-
},
|
|
50
|
-
}
|
|
51
|
-
newElements.push(newEdge)
|
|
68
|
+
const newNode = await buildChild(node, address)
|
|
69
|
+
if (mounted()) setElements((previous) => [...previous, newNode])
|
|
70
|
+
|
|
71
|
+
const newEdge = buildEdge(newRootNode, newNode)
|
|
72
|
+
if (mounted()) setElements((previous) => [...previous, newEdge])
|
|
52
73
|
} catch (e) {
|
|
53
|
-
console.error(
|
|
74
|
+
console.error('Error parsing children', e)
|
|
54
75
|
}
|
|
55
76
|
}),
|
|
56
77
|
)
|
|
57
|
-
setElements(newElements)
|
|
58
78
|
} catch (e) {
|
|
59
|
-
console.error(e)
|
|
79
|
+
console.error('Error Getting initial description', e)
|
|
60
80
|
}
|
|
61
81
|
}
|
|
62
82
|
},
|
|
63
|
-
[node],
|
|
83
|
+
[node, refresh],
|
|
64
84
|
)
|
|
65
85
|
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
let listener: EventUnsubscribeFunction
|
|
88
|
+
if (node) {
|
|
89
|
+
listener = node.onAny((eventName) => {
|
|
90
|
+
if (eventName === 'moduleAttached') setRefresh((previous) => previous + 1)
|
|
91
|
+
})
|
|
92
|
+
}
|
|
93
|
+
return () => listener?.()
|
|
94
|
+
}, [node])
|
|
95
|
+
|
|
66
96
|
return elements
|
|
67
97
|
}
|
package/src/hooks/useIcons.tsx
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import CallMergeRoundedIcon from '@mui/icons-material/CallMergeRounded'
|
|
1
2
|
import GridViewRoundedIcon from '@mui/icons-material/GridViewRounded'
|
|
2
3
|
import HubIcon from '@mui/icons-material/Hub'
|
|
3
4
|
import QuestionMarkRoundedIcon from '@mui/icons-material/QuestionMarkRounded'
|
|
@@ -8,20 +9,21 @@ import { useMemo } from 'react'
|
|
|
8
9
|
|
|
9
10
|
import { encodeSvg } from '../lib'
|
|
10
11
|
|
|
11
|
-
export type CyNodeIcons = '
|
|
12
|
+
export type CyNodeIcons = 'archivist' | 'diviner' | 'module' | 'node' | 'witness'
|
|
12
13
|
|
|
13
14
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
14
15
|
const CyIconSet: Record<CyNodeIcons, OverridableComponent<SvgIconTypeMap<{}, 'svg'>>> = {
|
|
15
16
|
archivist: GridViewRoundedIcon,
|
|
16
|
-
diviner:
|
|
17
|
+
diviner: CallMergeRoundedIcon,
|
|
17
18
|
module: QuestionMarkRoundedIcon,
|
|
18
19
|
node: HubIcon,
|
|
20
|
+
witness: VisibilityRoundedIcon,
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
export const useIcons = () => {
|
|
22
24
|
const theme = useTheme()
|
|
23
25
|
const icons = useMemo(() => {
|
|
24
|
-
const iconMap: Record<CyNodeIcons, string> = { archivist: '', diviner: '', module: '', node: '' }
|
|
26
|
+
const iconMap: Record<CyNodeIcons, string> = { archivist: '', diviner: '', module: '', node: '', witness: '' }
|
|
25
27
|
return Object.entries(CyIconSet).reduce((acc, [name, IconComponent]) => {
|
|
26
28
|
const icon = <IconComponent fontSize="small" />
|
|
27
29
|
acc[name as CyNodeIcons] = encodeSvg(icon, theme.palette.getContrastText(theme.palette.text.primary))
|