@xyo-network/react-node-renderer 2.47.36 → 2.47.37
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/Cytoscape/CytoscapeElements.js +48 -0
- package/dist/cjs/Cytoscape/CytoscapeElements.js.map +1 -0
- package/dist/cjs/Cytoscape/CytoscapeIcons.js +18 -0
- package/dist/cjs/Cytoscape/CytoscapeIcons.js.map +1 -0
- package/dist/cjs/Cytoscape/CytoscapeStyles.js +39 -0
- package/dist/cjs/Cytoscape/CytoscapeStyles.js.map +1 -0
- package/dist/cjs/Cytoscape/index.js +7 -0
- package/dist/cjs/Cytoscape/index.js.map +1 -0
- package/dist/cjs/components/RelationalGraph.js +9 -4
- package/dist/cjs/components/RelationalGraph.js.map +1 -1
- package/dist/cjs/hooks/cytoscape/index.js +6 -0
- package/dist/cjs/hooks/cytoscape/index.js.map +1 -0
- package/dist/cjs/hooks/{useCytoscapeElements.js → cytoscape/useCytoscapeElements.js} +4 -39
- package/dist/cjs/hooks/cytoscape/useCytoscapeElements.js.map +1 -0
- package/dist/cjs/hooks/cytoscape/useCytoscapeLayout.js +13 -0
- package/dist/cjs/hooks/cytoscape/useCytoscapeLayout.js.map +1 -0
- package/dist/cjs/hooks/cytoscape/useCytoscapeOptions.js +18 -0
- package/dist/cjs/hooks/cytoscape/useCytoscapeOptions.js.map +1 -0
- package/dist/cjs/hooks/cytoscape/useCytoscapeStyle.js +19 -0
- package/dist/cjs/hooks/cytoscape/useCytoscapeStyle.js.map +1 -0
- package/dist/cjs/hooks/cytoscape/useIcons.js +22 -0
- package/dist/cjs/hooks/cytoscape/useIcons.js.map +1 -0
- package/dist/cjs/hooks/index.js +1 -2
- package/dist/cjs/hooks/index.js.map +1 -1
- package/dist/docs.json +214 -167
- package/dist/esm/Cytoscape/CytoscapeElements.js +40 -0
- package/dist/esm/Cytoscape/CytoscapeElements.js.map +1 -0
- package/dist/esm/Cytoscape/CytoscapeIcons.js +14 -0
- package/dist/esm/Cytoscape/CytoscapeIcons.js.map +1 -0
- package/dist/esm/Cytoscape/CytoscapeStyles.js +33 -0
- package/dist/esm/Cytoscape/CytoscapeStyles.js.map +1 -0
- package/dist/esm/Cytoscape/index.js +4 -0
- package/dist/esm/Cytoscape/index.js.map +1 -0
- package/dist/esm/components/RelationalGraph.js +10 -5
- package/dist/esm/components/RelationalGraph.js.map +1 -1
- package/dist/esm/hooks/cytoscape/index.js +3 -0
- package/dist/esm/hooks/cytoscape/index.js.map +1 -0
- package/dist/esm/hooks/{useCytoscapeElements.js → cytoscape/useCytoscapeElements.js} +4 -38
- package/dist/esm/hooks/cytoscape/useCytoscapeElements.js.map +1 -0
- package/dist/esm/hooks/cytoscape/useCytoscapeLayout.js +9 -0
- package/dist/esm/hooks/cytoscape/useCytoscapeLayout.js.map +1 -0
- package/dist/esm/hooks/cytoscape/useCytoscapeOptions.js +14 -0
- package/dist/esm/hooks/cytoscape/useCytoscapeOptions.js.map +1 -0
- package/dist/esm/hooks/cytoscape/useCytoscapeStyle.js +15 -0
- package/dist/esm/hooks/cytoscape/useCytoscapeStyle.js.map +1 -0
- package/dist/esm/hooks/cytoscape/useIcons.js +18 -0
- package/dist/esm/hooks/cytoscape/useIcons.js.map +1 -0
- package/dist/esm/hooks/index.js +1 -2
- package/dist/esm/hooks/index.js.map +1 -1
- package/dist/types/Cytoscape/CytoscapeElements.d.ts +18 -0
- package/dist/types/Cytoscape/CytoscapeElements.d.ts.map +1 -0
- package/dist/types/Cytoscape/CytoscapeIcons.d.ts +5 -0
- package/dist/types/Cytoscape/CytoscapeIcons.d.ts.map +1 -0
- package/dist/types/Cytoscape/CytoscapeStyles.d.ts +16 -0
- package/dist/types/Cytoscape/CytoscapeStyles.d.ts.map +1 -0
- package/dist/types/Cytoscape/index.d.ts +4 -0
- package/dist/types/Cytoscape/index.d.ts.map +1 -0
- package/dist/types/components/RelationalGraph.d.ts +1 -2
- package/dist/types/components/RelationalGraph.d.ts.map +1 -1
- package/dist/types/hooks/cytoscape/index.d.ts +3 -0
- package/dist/types/hooks/cytoscape/index.d.ts.map +1 -0
- package/dist/types/hooks/cytoscape/useCytoscapeElements.d.ts.map +1 -0
- package/dist/types/hooks/cytoscape/useCytoscapeLayout.d.ts +2 -0
- package/dist/types/hooks/cytoscape/useCytoscapeLayout.d.ts.map +1 -0
- package/dist/types/hooks/cytoscape/useCytoscapeOptions.d.ts +3 -0
- package/dist/types/hooks/cytoscape/useCytoscapeOptions.d.ts.map +1 -0
- package/dist/types/hooks/cytoscape/useCytoscapeStyle.d.ts +2 -0
- package/dist/types/hooks/cytoscape/useCytoscapeStyle.d.ts.map +1 -0
- package/dist/types/hooks/cytoscape/useIcons.d.ts +3 -0
- package/dist/types/hooks/cytoscape/useIcons.d.ts.map +1 -0
- package/dist/types/hooks/index.d.ts +1 -2
- package/dist/types/hooks/index.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/Cytoscape/CytoscapeElements.ts +46 -0
- package/src/Cytoscape/CytoscapeIcons.tsx +18 -0
- package/src/Cytoscape/CytoscapeStyles.ts +38 -0
- package/src/Cytoscape/index.ts +3 -0
- package/src/components/RelationalGraph.tsx +15 -7
- package/src/hooks/cytoscape/index.ts +2 -0
- package/src/hooks/{useCytoscapeElements.ts → cytoscape/useCytoscapeElements.ts} +5 -43
- package/src/hooks/cytoscape/useCytoscapeLayout.ts +14 -0
- package/src/hooks/cytoscape/useCytoscapeOptions.ts +25 -0
- package/src/hooks/cytoscape/useCytoscapeStyle.ts +22 -0
- package/src/hooks/cytoscape/useIcons.tsx +19 -0
- package/src/hooks/index.ts +1 -2
- package/dist/cjs/hooks/useCytoscapeElements.js.map +0 -1
- package/dist/cjs/hooks/useCytoscapeOptions.js +0 -54
- package/dist/cjs/hooks/useCytoscapeOptions.js.map +0 -1
- package/dist/cjs/hooks/useIcons.js +0 -35
- package/dist/cjs/hooks/useIcons.js.map +0 -1
- package/dist/esm/hooks/useCytoscapeElements.js.map +0 -1
- package/dist/esm/hooks/useCytoscapeOptions.js +0 -50
- package/dist/esm/hooks/useCytoscapeOptions.js.map +0 -1
- package/dist/esm/hooks/useIcons.js +0 -30
- package/dist/esm/hooks/useIcons.js.map +0 -1
- package/dist/types/hooks/useCytoscapeElements.d.ts.map +0 -1
- package/dist/types/hooks/useCytoscapeOptions.d.ts +0 -3
- package/dist/types/hooks/useCytoscapeOptions.d.ts.map +0 -1
- package/dist/types/hooks/useIcons.d.ts +0 -3
- package/dist/types/hooks/useIcons.d.ts.map +0 -1
- package/src/hooks/useCytoscapeOptions.ts +0 -57
- package/src/hooks/useIcons.tsx +0 -35
- /package/dist/types/hooks/{useCytoscapeElements.d.ts → cytoscape/useCytoscapeElements.d.ts} +0 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ModuleWrapper } from '@xyo-network/module';
|
|
2
|
+
import { parseModuleType } from '../lib';
|
|
3
|
+
export class CytoscapeElements {
|
|
4
|
+
static MaxNameLength = 20;
|
|
5
|
+
static buildChild = async (wrapper, address) => {
|
|
6
|
+
const [result] = await wrapper.resolveWrapped(ModuleWrapper, { address: [address] });
|
|
7
|
+
const description = await result.describe();
|
|
8
|
+
return CytoscapeElements.buildNode(description);
|
|
9
|
+
};
|
|
10
|
+
static buildEdge(rootNode, newNode) {
|
|
11
|
+
return {
|
|
12
|
+
data: {
|
|
13
|
+
id: `${rootNode.data.id}/${newNode.data.id}`,
|
|
14
|
+
source: rootNode.data.id,
|
|
15
|
+
target: newNode.data.id,
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
static buildNode(description) {
|
|
20
|
+
const newNodeId = CytoscapeElements.normalizeName(description.name) ?? description.address.substring(0, 8);
|
|
21
|
+
return {
|
|
22
|
+
data: {
|
|
23
|
+
id: newNodeId,
|
|
24
|
+
type: parseModuleType(description.queries),
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
static buildRootNode = async (wrapper) => {
|
|
29
|
+
const description = await wrapper?.describe();
|
|
30
|
+
return [description, CytoscapeElements.buildNode(description)];
|
|
31
|
+
};
|
|
32
|
+
static normalizeName(name) {
|
|
33
|
+
if (!name)
|
|
34
|
+
return;
|
|
35
|
+
if (name.length > this.MaxNameLength)
|
|
36
|
+
return `${name.substring(0, 20)}...`;
|
|
37
|
+
return name;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=CytoscapeElements.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CytoscapeElements.js","sourceRoot":"","sources":["../../../src/Cytoscape/CytoscapeElements.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAItE,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AAExC,MAAM,OAAO,iBAAiB;IAC5B,MAAM,CAAC,aAAa,GAAG,EAAE,CAAA;IAEzB,MAAM,CAAC,UAAU,GAAG,KAAK,EAAE,OAAoB,EAAE,OAAe,EAAE,EAAE;QAClE,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,OAAO,CAAC,cAAc,CAAC,aAAa,EAAE,EAAE,OAAO,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;QACpF,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,QAAQ,EAAE,CAAA;QAC3C,OAAO,iBAAiB,CAAC,SAAS,CAAC,WAAW,CAAC,CAAA;IACjD,CAAC,CAAA;IAED,MAAM,CAAC,SAAS,CAAC,QAA2B,EAAE,OAA0B;QACtE,OAAO;YACL,IAAI,EAAE;gBACJ,EAAE,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE;gBAC5C,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,EAAE;gBACxB,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE;aACxB;SACF,CAAA;IACH,CAAC;IAED,MAAM,CAAC,SAAS,CAAC,WAA8B;QAC7C,MAAM,SAAS,GAAG,iBAAiB,CAAC,aAAa,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,WAAW,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;QAC1G,OAAO;YACL,IAAI,EAAE;gBACJ,EAAE,EAAE,SAAS;gBACb,IAAI,EAAE,eAAe,CAAC,WAAW,CAAC,OAAO,CAAC;aAC3C;SACF,CAAA;IACH,CAAC;IAED,MAAM,CAAC,aAAa,GAAG,KAAK,EAAE,OAAoB,EAAmD,EAAE;QACrG,MAAM,WAAW,GAAG,MAAM,OAAO,EAAE,QAAQ,EAAE,CAAA;QAC7C,OAAO,CAAC,WAAW,EAAE,iBAAiB,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAAA;IAChE,CAAC,CAAA;IAED,MAAM,CAAC,aAAa,CAAC,IAAa;QAChC,IAAI,CAAC,IAAI;YAAE,OAAM;QACjB,IAAI,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,aAAa;YAAE,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAA;QAC1E,OAAO,IAAI,CAAA;IACb,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import CallMergeRoundedIcon from '@mui/icons-material/CallMergeRounded';
|
|
2
|
+
import GridViewRoundedIcon from '@mui/icons-material/GridViewRounded';
|
|
3
|
+
import HubIcon from '@mui/icons-material/Hub';
|
|
4
|
+
import QuestionMarkRoundedIcon from '@mui/icons-material/QuestionMarkRounded';
|
|
5
|
+
import VisibilityRoundedIcon from '@mui/icons-material/VisibilityRounded';
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
7
|
+
export const CyIconSet = {
|
|
8
|
+
archivist: GridViewRoundedIcon,
|
|
9
|
+
diviner: CallMergeRoundedIcon,
|
|
10
|
+
module: QuestionMarkRoundedIcon,
|
|
11
|
+
node: HubIcon,
|
|
12
|
+
witness: VisibilityRoundedIcon,
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=CytoscapeIcons.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CytoscapeIcons.js","sourceRoot":"","sources":["../../../src/Cytoscape/CytoscapeIcons.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;AAMzE,wDAAwD;AACxD,MAAM,CAAC,MAAM,SAAS,GAAyE;IAC7F,SAAS,EAAE,mBAAmB;IAC9B,OAAO,EAAE,oBAAoB;IAC7B,MAAM,EAAE,uBAAuB;IAC/B,IAAI,EAAE,OAAO;IACb,OAAO,EAAE,qBAAqB;CAC/B,CAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export const NodeIdStyles = (color) => ({
|
|
2
|
+
selector: 'node[id]',
|
|
3
|
+
style: {
|
|
4
|
+
color,
|
|
5
|
+
'font-family': 'Lexend Deca, Helvetica, sans-serif',
|
|
6
|
+
'font-size': 14,
|
|
7
|
+
'text-margin-y': -5,
|
|
8
|
+
},
|
|
9
|
+
});
|
|
10
|
+
export const NodeStyled = (icons, bgColor) => ({
|
|
11
|
+
selector: 'node',
|
|
12
|
+
style: {
|
|
13
|
+
'background-color': bgColor,
|
|
14
|
+
'background-height': '75%',
|
|
15
|
+
// TODO - make dynamic
|
|
16
|
+
'background-image': (elem) => icons[elem.data('type')],
|
|
17
|
+
'background-image-smoothing': 'yes',
|
|
18
|
+
'background-width': '75%',
|
|
19
|
+
label: 'data(id)',
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
export const EdgeStyled = (lineColor, targetArrowColor) => ({
|
|
23
|
+
selector: 'edge',
|
|
24
|
+
style: {
|
|
25
|
+
'curve-style': 'bezier',
|
|
26
|
+
'line-color': lineColor,
|
|
27
|
+
'line-opacity': 0.1,
|
|
28
|
+
'target-arrow-color': targetArrowColor,
|
|
29
|
+
'target-arrow-shape': 'triangle',
|
|
30
|
+
width: 3,
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=CytoscapeStyles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CytoscapeStyles.js","sourceRoot":"","sources":["../../../src/Cytoscape/CytoscapeStyles.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAc,EAAc,EAAE,CAAC,CAAC;IAC3D,QAAQ,EAAE,UAAU;IACpB,KAAK,EAAE;QACL,KAAK;QACL,aAAa,EAAE,oCAAoC;QACnD,WAAW,EAAE,EAAE;QACf,eAAe,EAAE,CAAC,CAAC;KACpB;CACF,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAkC,EAAE,OAAgB,EAAc,EAAE,CAAC,CAAC;IAC/F,QAAQ,EAAE,MAAM;IAChB,KAAK,EAAE;QACL,kBAAkB,EAAE,OAAO;QAC3B,mBAAmB,EAAE,KAAK;QAC1B,sBAAsB;QACtB,kBAAkB,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAgB,CAAC;QACrE,4BAA4B,EAAE,KAAK;QACnC,kBAAkB,EAAE,KAAK;QACzB,KAAK,EAAE,UAAU;KAClB;CACF,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,SAAkB,EAAE,gBAAyB,EAAE,EAAE,CAAC,CAAC;IAC5E,QAAQ,EAAE,MAAM;IAChB,KAAK,EAAE;QACL,aAAa,EAAE,QAAQ;QACvB,YAAY,EAAE,SAAS;QACvB,cAAc,EAAE,GAAG;QACnB,oBAAoB,EAAE,gBAAgB;QACtC,oBAAoB,EAAE,UAAU;QAChC,KAAK,EAAE,CAAC;KACT;CACF,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Cytoscape/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,kBAAkB,CAAA;AAChC,cAAc,mBAAmB,CAAA"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button, styled } from '@mui/material';
|
|
2
3
|
import { FlexCol } from '@xylabs/react-flexbox';
|
|
3
4
|
import { useShareForwardedRef } from '@xyo-network/react-shared';
|
|
4
5
|
import cytoscape from 'cytoscape';
|
|
5
6
|
import { forwardRef, useEffect, useState } from 'react';
|
|
6
|
-
export const NodeRelationalGraph = forwardRef(({
|
|
7
|
+
export const NodeRelationalGraph = forwardRef(({ options, ...props }, ref) => {
|
|
7
8
|
const sharedRef = useShareForwardedRef(ref);
|
|
8
|
-
// TODO - likely a value to stick in context
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
10
9
|
const [cy, setCy] = useState();
|
|
11
10
|
useEffect(() => {
|
|
12
11
|
if (sharedRef) {
|
|
@@ -16,7 +15,13 @@ export const NodeRelationalGraph = forwardRef(({ children, options, ...props },
|
|
|
16
15
|
}));
|
|
17
16
|
}
|
|
18
17
|
}, [options, sharedRef]);
|
|
19
|
-
return (
|
|
18
|
+
return (_jsxs(FlexCol, { ...props, children: [_jsx(ResetButton, { size: 'small', variant: 'contained', onClick: () => cy?.reset(), children: "Reset" }), _jsx(FlexCol, { alignItems: "stretch", height: "100%", position: "absolute", ref: sharedRef, width: "100%" })] }));
|
|
20
19
|
});
|
|
21
20
|
NodeRelationalGraph.displayName = 'NodeRelationalGraph';
|
|
21
|
+
const ResetButton = styled(Button, { name: 'ResetButton' })(() => ({
|
|
22
|
+
position: 'absolute',
|
|
23
|
+
right: '10px',
|
|
24
|
+
top: '10px',
|
|
25
|
+
zIndex: 2,
|
|
26
|
+
}));
|
|
22
27
|
//# sourceMappingURL=RelationalGraph.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelationalGraph.js","sourceRoot":"","sources":["../../../src/components/RelationalGraph.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAgB,OAAO,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"RelationalGraph.js","sourceRoot":"","sources":["../../../src/components/RelationalGraph.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,EAAgB,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,SAAqC,MAAM,WAAW,CAAA;AAC7D,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAMvD,MAAM,CAAC,MAAM,mBAAmB,GAAG,UAAU,CAAsC,CAAC,EAAE,OAAO,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE;IAChH,MAAM,SAAS,GAAG,oBAAoB,CAAC,GAAG,CAAC,CAAA;IAC3C,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,GAAG,QAAQ,EAAQ,CAAA;IAEpC,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,SAAS,EAAE;YACb,KAAK,CACH,SAAS,CAAC;gBACR,SAAS,EAAE,SAAS,CAAC,OAAO;gBAC5B,GAAG,OAAO;aACX,CAAC,CACH,CAAA;SACF;IACH,CAAC,EAAE,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAA;IAExB,OAAO,CACL,MAAC,OAAO,OAAK,KAAK,aAChB,KAAC,WAAW,IAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,sBAE9D,EACd,KAAC,OAAO,IAAC,UAAU,EAAC,SAAS,EAAC,MAAM,EAAC,MAAM,EAAC,QAAQ,EAAC,UAAU,EAAC,GAAG,EAAE,SAAS,EAAE,KAAK,EAAC,MAAM,GAAW,IAC/F,CACX,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,mBAAmB,CAAC,WAAW,GAAG,qBAAqB,CAAA;AAEvD,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;IACjE,QAAQ,EAAE,UAAU;IACpB,KAAK,EAAE,MAAM;IACb,GAAG,EAAE,MAAM;IACX,MAAM,EAAE,CAAC;CACV,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/hooks/cytoscape/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA"}
|
|
@@ -1,41 +1,7 @@
|
|
|
1
1
|
import { useAsyncEffect } from '@xylabs/react-shared';
|
|
2
|
-
import { ModuleWrapper } from '@xyo-network/module';
|
|
3
2
|
import { useProvidedWrappedNode } from '@xyo-network/react-node';
|
|
4
3
|
import { useEffect, useState } from 'react';
|
|
5
|
-
import {
|
|
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
|
-
};
|
|
4
|
+
import { CytoscapeElements } from '../../Cytoscape';
|
|
39
5
|
/**
|
|
40
6
|
* Note: Relies on describe but could eventually be converted to a discover call
|
|
41
7
|
* Logic would be similar to what the bridge does
|
|
@@ -49,16 +15,16 @@ export const useCytoscapeElements = () => {
|
|
|
49
15
|
async (mounted) => {
|
|
50
16
|
if (node && refresh) {
|
|
51
17
|
try {
|
|
52
|
-
const [description, newRootNode] = await buildRootNode(node);
|
|
18
|
+
const [description, newRootNode] = await CytoscapeElements.buildRootNode(node);
|
|
53
19
|
if (mounted())
|
|
54
20
|
setElements(() => [newRootNode]);
|
|
55
21
|
const children = description.children;
|
|
56
22
|
await Promise.allSettled((children ?? [])?.map(async (address) => {
|
|
57
23
|
try {
|
|
58
|
-
const newNode = await buildChild(node, address);
|
|
24
|
+
const newNode = await CytoscapeElements.buildChild(node, address);
|
|
59
25
|
if (mounted())
|
|
60
26
|
setElements((previous) => [...previous, newNode]);
|
|
61
|
-
const newEdge = buildEdge(newRootNode, newNode);
|
|
27
|
+
const newEdge = CytoscapeElements.buildEdge(newRootNode, newNode);
|
|
62
28
|
if (mounted())
|
|
63
29
|
setElements((previous) => [...previous, newEdge]);
|
|
64
30
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCytoscapeElements.js","sourceRoot":"","sources":["../../../../src/hooks/cytoscape/useCytoscapeElements.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAErD,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AAEhE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAE3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAEnD;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,EAAE;IACvC,MAAM,CAAC,IAAI,CAAC,GAAG,sBAAsB,EAAE,CAAA;IACvC,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAsB,EAAE,CAAC,CAAA;IACjE,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAA;IAEzC,cAAc;IACZ,uDAAuD;IACvD,KAAK,EAAE,OAAO,EAAE,EAAE;QAChB,IAAI,IAAI,IAAI,OAAO,EAAE;YACnB,IAAI;gBACF,MAAM,CAAC,WAAW,EAAE,WAAW,CAAC,GAAG,MAAM,iBAAiB,CAAC,aAAa,CAAC,IAAI,CAAC,CAAA;gBAC9E,IAAI,OAAO,EAAE;oBAAE,WAAW,CAAC,GAAG,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAA;gBAE/C,MAAM,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAA;gBACrC,MAAM,OAAO,CAAC,UAAU,CACtB,CAAC,QAAQ,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;oBACtC,IAAI;wBACF,MAAM,OAAO,GAAG,MAAM,iBAAiB,CAAC,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;wBACjE,IAAI,OAAO,EAAE;4BAAE,WAAW,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,GAAG,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAA;wBAEhE,MAAM,OAAO,GAAG,iBAAiB,CAAC,SAAS,CAAC,WAAW,EAAE,OAAO,CAAC,CAAA;wBACjE,IAAI,OAAO,EAAE;4BAAE,WAAW,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,GAAG,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAA;qBACjE;oBAAC,OAAO,CAAC,EAAE;wBACV,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,CAAC,CAAC,CAAA;qBAC3C;gBACH,CAAC,CAAC,CACH,CAAA;aACF;YAAC,OAAO,CAAC,EAAE;gBACV,OAAO,CAAC,KAAK,CAAC,mCAAmC,EAAE,CAAC,CAAC,CAAA;aACtD;SACF;IACH,CAAC,EACD,CAAC,IAAI,EAAE,OAAO,CAAC,CAChB,CAAA;IAED,SAAS,CAAC,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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCytoscapeLayout.js","sourceRoot":"","sources":["../../../../src/hooks/cytoscape/useCytoscapeLayout.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAE/B,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,EAAE;IACrC,MAAM,MAAM,GAA+B,OAAO,CAChD,GAAG,EAAE,CAAC,CAAC;QACL,cAAc,EAAE,EAAE;QAClB,IAAI,EAAE,YAAY;KACnB,CAAC,EACF,EAAE,CACH,CAAA;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { useCytoscapeLayout } from './useCytoscapeLayout';
|
|
3
|
+
import { useCytoscapeStyle } from './useCytoscapeStyle';
|
|
4
|
+
export const useCytoscapeOptions = (elements, style, layout) => {
|
|
5
|
+
const defaultStyle = useCytoscapeStyle();
|
|
6
|
+
const defaultLayout = useCytoscapeLayout();
|
|
7
|
+
const options = useMemo(() => ({
|
|
8
|
+
elements,
|
|
9
|
+
layout: layout ?? defaultLayout,
|
|
10
|
+
style: style ?? defaultStyle,
|
|
11
|
+
}), [defaultLayout, defaultStyle, elements, layout, style]);
|
|
12
|
+
return options;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=useCytoscapeOptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCytoscapeOptions.js","sourceRoot":"","sources":["../../../../src/hooks/cytoscape/useCytoscapeOptions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAE/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAEvD,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,QAAsC,EACtC,KAAiC,EACjC,MAAmC,EACnC,EAAE;IACF,MAAM,YAAY,GAAG,iBAAiB,EAAE,CAAA;IACxC,MAAM,aAAa,GAAG,kBAAkB,EAAE,CAAA;IAE1C,MAAM,OAAO,GAAG,OAAO,CACrB,GAAG,EAAE,CAAC,CAAC;QACL,QAAQ;QACR,MAAM,EAAE,MAAM,IAAI,aAAa;QAC/B,KAAK,EAAE,KAAK,IAAI,YAAY;KAC7B,CAAC,EACF,CAAC,aAAa,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,CACvD,CAAA;IAED,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useTheme } from '@mui/material';
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { EdgeStyled, NodeIdStyles, NodeStyled } from '../../Cytoscape';
|
|
4
|
+
import { useIcons } from './useIcons';
|
|
5
|
+
export const useCytoscapeStyle = () => {
|
|
6
|
+
const theme = useTheme();
|
|
7
|
+
const icons = useIcons();
|
|
8
|
+
const style = useMemo(() => [
|
|
9
|
+
NodeIdStyles(theme.palette.text.primary),
|
|
10
|
+
NodeStyled(icons, theme.palette.primary.main),
|
|
11
|
+
EdgeStyled(theme.palette.divider, theme.palette.divider),
|
|
12
|
+
], [icons, theme.palette.divider, theme.palette.primary.main, theme.palette.text.primary]);
|
|
13
|
+
return style;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=useCytoscapeStyle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCytoscapeStyle.js","sourceRoot":"","sources":["../../../../src/hooks/cytoscape/useCytoscapeStyle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAE/B,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAErC,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,EAAE;IACpC,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAA;IACxB,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAA;IAExB,MAAM,KAAK,GAA8B,OAAO,CAC9C,GAAG,EAAE,CAAC;QACJ,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC;QACxC,UAAU,CAAC,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;QAC7C,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;KACzD,EACD,CAAC,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CACvF,CAAA;IAED,OAAO,KAAK,CAAA;AACd,CAAC,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useTheme } from '@mui/material';
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import { CyIconSet } from '../../Cytoscape';
|
|
5
|
+
import { encodeSvg } from '../../lib';
|
|
6
|
+
export const useIcons = () => {
|
|
7
|
+
const theme = useTheme();
|
|
8
|
+
const icons = useMemo(() => {
|
|
9
|
+
const iconMap = { archivist: '', diviner: '', module: '', node: '', witness: '' };
|
|
10
|
+
return Object.entries(CyIconSet).reduce((acc, [name, IconComponent]) => {
|
|
11
|
+
const icon = _jsx(IconComponent, { fontSize: "small" });
|
|
12
|
+
acc[name] = encodeSvg(icon, theme.palette.getContrastText(theme.palette.text.primary));
|
|
13
|
+
return acc;
|
|
14
|
+
}, iconMap);
|
|
15
|
+
}, [theme.palette]);
|
|
16
|
+
return icons;
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=useIcons.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIcons.js","sourceRoot":"","sources":["../../../../src/hooks/cytoscape/useIcons.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAE/B,OAAO,EAAE,SAAS,EAAe,MAAM,iBAAiB,CAAA;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAErC,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,EAAE;IAC3B,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAA;IACxB,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,EAAE;QACzB,MAAM,OAAO,GAAgC,EAAE,SAAS,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,CAAA;QAC9G,OAAO,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,aAAa,CAAC,EAAE,EAAE;YACrE,MAAM,IAAI,GAAG,KAAC,aAAa,IAAC,QAAQ,EAAC,OAAO,GAAG,CAAA;YAC/C,GAAG,CAAC,IAAmB,CAAC,GAAG,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAA;YACrG,OAAO,GAAG,CAAA;QACZ,CAAC,EAAE,OAAO,CAAC,CAAA;IACb,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAA;IAEnB,OAAO,KAAK,CAAA;AACd,CAAC,CAAA"}
|
package/dist/esm/hooks/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ModuleDescription } from '@xyo-network/module';
|
|
2
|
+
import { NodeWrapper } from '@xyo-network/node';
|
|
3
|
+
import { ElementDefinition } from 'cytoscape';
|
|
4
|
+
export declare class CytoscapeElements {
|
|
5
|
+
static MaxNameLength: number;
|
|
6
|
+
static buildChild: (wrapper: NodeWrapper, address: string) => Promise<ElementDefinition>;
|
|
7
|
+
static buildEdge(rootNode: ElementDefinition, newNode: ElementDefinition): {
|
|
8
|
+
data: {
|
|
9
|
+
id: string;
|
|
10
|
+
source: string | undefined;
|
|
11
|
+
target: string | undefined;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
static buildNode(description: ModuleDescription): ElementDefinition;
|
|
15
|
+
static buildRootNode: (wrapper: NodeWrapper) => Promise<[ModuleDescription, ElementDefinition]>;
|
|
16
|
+
static normalizeName(name?: string): string | undefined;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=CytoscapeElements.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CytoscapeElements.d.ts","sourceRoot":"","sources":["../../../src/Cytoscape/CytoscapeElements.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAiB,MAAM,qBAAqB,CAAA;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAI7C,qBAAa,iBAAiB;IAC5B,MAAM,CAAC,aAAa,SAAK;IAEzB,MAAM,CAAC,UAAU,YAAmB,WAAW,WAAW,MAAM,gCAI/D;IAED,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,iBAAiB,EAAE,OAAO,EAAE,iBAAiB;;;;;;;IAUxE,MAAM,CAAC,SAAS,CAAC,WAAW,EAAE,iBAAiB,GAAG,iBAAiB;IAUnE,MAAM,CAAC,aAAa,YAAmB,WAAW,KAAG,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,CAAC,CAGnG;IAED,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,MAAM;CAKnC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { SvgIconTypeMap } from '@mui/material';
|
|
2
|
+
import { OverridableComponent } from '@mui/material/OverridableComponent';
|
|
3
|
+
export type CyNodeIcons = 'archivist' | 'diviner' | 'module' | 'node' | 'witness';
|
|
4
|
+
export declare const CyIconSet: Record<CyNodeIcons, OverridableComponent<SvgIconTypeMap<{}, 'svg'>>>;
|
|
5
|
+
//# sourceMappingURL=CytoscapeIcons.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CytoscapeIcons.d.ts","sourceRoot":"","sources":["../../../src/Cytoscape/CytoscapeIcons.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAA;AAEzE,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAA;AAGjF,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,WAAW,EAAE,oBAAoB,CAAC,cAAc,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,CAM1F,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Stylesheet } from 'cytoscape';
|
|
2
|
+
import { CyNodeIcons } from './CytoscapeIcons';
|
|
3
|
+
export declare const NodeIdStyles: (color?: string) => Stylesheet;
|
|
4
|
+
export declare const NodeStyled: (icons: Record<CyNodeIcons, string>, bgColor?: string) => Stylesheet;
|
|
5
|
+
export declare const EdgeStyled: (lineColor?: string, targetArrowColor?: string) => {
|
|
6
|
+
selector: string;
|
|
7
|
+
style: {
|
|
8
|
+
'curve-style': string;
|
|
9
|
+
'line-color': string | undefined;
|
|
10
|
+
'line-opacity': number;
|
|
11
|
+
'target-arrow-color': string | undefined;
|
|
12
|
+
'target-arrow-shape': string;
|
|
13
|
+
width: number;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=CytoscapeStyles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CytoscapeStyles.d.ts","sourceRoot":"","sources":["../../../src/Cytoscape/CytoscapeStyles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAEtC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,eAAO,MAAM,YAAY,WAAY,MAAM,KAAG,UAQ5C,CAAA;AAEF,eAAO,MAAM,UAAU,UAAW,OAAO,WAAW,EAAE,MAAM,CAAC,YAAY,MAAM,KAAG,UAWhF,CAAA;AAEF,eAAO,MAAM,UAAU,eAAgB,MAAM,qBAAqB,MAAM;;;;;;;;;;CAUtE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Cytoscape/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,kBAAkB,CAAA;AAChC,cAAc,mBAAmB,CAAA"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { FlexBoxProps } from '@xylabs/react-flexbox';
|
|
3
|
-
import { WithChildren } from '@xylabs/react-shared';
|
|
4
3
|
import { CytoscapeOptions } from 'cytoscape';
|
|
5
|
-
export interface NodeRelationalGraph extends
|
|
4
|
+
export interface NodeRelationalGraph extends FlexBoxProps {
|
|
6
5
|
options?: CytoscapeOptions;
|
|
7
6
|
}
|
|
8
7
|
export declare const NodeRelationalGraph: import("react").ForwardRefExoticComponent<NodeRelationalGraph & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelationalGraph.d.ts","sourceRoot":"","sources":["../../../src/components/RelationalGraph.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"RelationalGraph.d.ts","sourceRoot":"","sources":["../../../src/components/RelationalGraph.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAW,MAAM,uBAAuB,CAAA;AAE7D,OAAkB,EAAQ,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAG7D,MAAM,WAAW,mBAAoB,SAAQ,YAAY;IACvD,OAAO,CAAC,EAAE,gBAAgB,CAAA;CAC3B;AAED,eAAO,MAAM,mBAAmB,gHAuB9B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/cytoscape/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCytoscapeElements.d.ts","sourceRoot":"","sources":["../../../../src/hooks/cytoscape/useCytoscapeElements.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAK7C;;;GAGG;AACH,eAAO,MAAM,oBAAoB,2BA8ChC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCytoscapeLayout.d.ts","sourceRoot":"","sources":["../../../../src/hooks/cytoscape/useCytoscapeLayout.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,kBAAkB,2FAU9B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCytoscapeOptions.d.ts","sourceRoot":"","sources":["../../../../src/hooks/cytoscape/useCytoscapeOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAM5C,eAAO,MAAM,mBAAmB,aACpB,gBAAgB,CAAC,UAAU,CAAC,UAC9B,gBAAgB,CAAC,OAAO,CAAC,WACxB,gBAAgB,CAAC,QAAQ,CAAC,qBAepC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCytoscapeStyle.d.ts","sourceRoot":"","sources":["../../../../src/hooks/cytoscape/useCytoscapeStyle.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,iBAAiB,wCAc7B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIcons.d.ts","sourceRoot":"","sources":["../../../../src/hooks/cytoscape/useIcons.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAa,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAGxD,eAAO,MAAM,QAAQ,mCAYpB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,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.37",
|
|
18
|
+
"@xyo-network/react-shared": "^2.47.37",
|
|
19
19
|
"cytoscape": "^3.23.0"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"@xyo-network/id-plugin": "^2.53.34",
|
|
40
40
|
"@xyo-network/module": "^2.53.34",
|
|
41
41
|
"@xyo-network/node": "^2.53.34",
|
|
42
|
-
"@xyo-network/react-node": "^2.47.
|
|
43
|
-
"@xyo-network/react-storybook": "^2.47.
|
|
44
|
-
"@xyo-network/react-wallet": "^2.47.
|
|
42
|
+
"@xyo-network/react-node": "^2.47.37",
|
|
43
|
+
"@xyo-network/react-storybook": "^2.47.37",
|
|
44
|
+
"@xyo-network/react-wallet": "^2.47.37",
|
|
45
45
|
"require-from-string": "^2.0.2",
|
|
46
46
|
"typescript": "^4.9.5"
|
|
47
47
|
},
|
|
@@ -88,5 +88,5 @@
|
|
|
88
88
|
},
|
|
89
89
|
"sideEffects": false,
|
|
90
90
|
"types": "dist/types/index.d.ts",
|
|
91
|
-
"version": "2.47.
|
|
91
|
+
"version": "2.47.37"
|
|
92
92
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ModuleDescription, ModuleWrapper } from '@xyo-network/module'
|
|
2
|
+
import { NodeWrapper } from '@xyo-network/node'
|
|
3
|
+
import { ElementDefinition } from 'cytoscape'
|
|
4
|
+
|
|
5
|
+
import { parseModuleType } from '../lib'
|
|
6
|
+
|
|
7
|
+
export class CytoscapeElements {
|
|
8
|
+
static MaxNameLength = 20
|
|
9
|
+
|
|
10
|
+
static buildChild = async (wrapper: NodeWrapper, address: string) => {
|
|
11
|
+
const [result] = await wrapper.resolveWrapped(ModuleWrapper, { address: [address] })
|
|
12
|
+
const description = await result.describe()
|
|
13
|
+
return CytoscapeElements.buildNode(description)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
static buildEdge(rootNode: ElementDefinition, newNode: ElementDefinition) {
|
|
17
|
+
return {
|
|
18
|
+
data: {
|
|
19
|
+
id: `${rootNode.data.id}/${newNode.data.id}`,
|
|
20
|
+
source: rootNode.data.id,
|
|
21
|
+
target: newNode.data.id,
|
|
22
|
+
},
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
static buildNode(description: ModuleDescription): ElementDefinition {
|
|
27
|
+
const newNodeId = CytoscapeElements.normalizeName(description.name) ?? description.address.substring(0, 8)
|
|
28
|
+
return {
|
|
29
|
+
data: {
|
|
30
|
+
id: newNodeId,
|
|
31
|
+
type: parseModuleType(description.queries),
|
|
32
|
+
},
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
static buildRootNode = async (wrapper: NodeWrapper): Promise<[ModuleDescription, ElementDefinition]> => {
|
|
37
|
+
const description = await wrapper?.describe()
|
|
38
|
+
return [description, CytoscapeElements.buildNode(description)]
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
static normalizeName(name?: string) {
|
|
42
|
+
if (!name) return
|
|
43
|
+
if (name.length > this.MaxNameLength) return `${name.substring(0, 20)}...`
|
|
44
|
+
return name
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import CallMergeRoundedIcon from '@mui/icons-material/CallMergeRounded'
|
|
2
|
+
import GridViewRoundedIcon from '@mui/icons-material/GridViewRounded'
|
|
3
|
+
import HubIcon from '@mui/icons-material/Hub'
|
|
4
|
+
import QuestionMarkRoundedIcon from '@mui/icons-material/QuestionMarkRounded'
|
|
5
|
+
import VisibilityRoundedIcon from '@mui/icons-material/VisibilityRounded'
|
|
6
|
+
import { SvgIconTypeMap } from '@mui/material'
|
|
7
|
+
import { OverridableComponent } from '@mui/material/OverridableComponent'
|
|
8
|
+
|
|
9
|
+
export type CyNodeIcons = 'archivist' | 'diviner' | 'module' | 'node' | 'witness'
|
|
10
|
+
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
12
|
+
export const CyIconSet: Record<CyNodeIcons, OverridableComponent<SvgIconTypeMap<{}, 'svg'>>> = {
|
|
13
|
+
archivist: GridViewRoundedIcon,
|
|
14
|
+
diviner: CallMergeRoundedIcon,
|
|
15
|
+
module: QuestionMarkRoundedIcon,
|
|
16
|
+
node: HubIcon,
|
|
17
|
+
witness: VisibilityRoundedIcon,
|
|
18
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Stylesheet } from 'cytoscape'
|
|
2
|
+
|
|
3
|
+
import { CyNodeIcons } from './CytoscapeIcons'
|
|
4
|
+
|
|
5
|
+
export const NodeIdStyles = (color?: string): Stylesheet => ({
|
|
6
|
+
selector: 'node[id]',
|
|
7
|
+
style: {
|
|
8
|
+
color,
|
|
9
|
+
'font-family': 'Lexend Deca, Helvetica, sans-serif',
|
|
10
|
+
'font-size': 14,
|
|
11
|
+
'text-margin-y': -5,
|
|
12
|
+
},
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
export const NodeStyled = (icons: Record<CyNodeIcons, string>, bgColor?: string): Stylesheet => ({
|
|
16
|
+
selector: 'node',
|
|
17
|
+
style: {
|
|
18
|
+
'background-color': bgColor,
|
|
19
|
+
'background-height': '75%',
|
|
20
|
+
// TODO - make dynamic
|
|
21
|
+
'background-image': (elem) => icons[elem.data('type') as CyNodeIcons],
|
|
22
|
+
'background-image-smoothing': 'yes',
|
|
23
|
+
'background-width': '75%',
|
|
24
|
+
label: 'data(id)',
|
|
25
|
+
},
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
export const EdgeStyled = (lineColor?: string, targetArrowColor?: string) => ({
|
|
29
|
+
selector: 'edge',
|
|
30
|
+
style: {
|
|
31
|
+
'curve-style': 'bezier',
|
|
32
|
+
'line-color': lineColor,
|
|
33
|
+
'line-opacity': 0.1,
|
|
34
|
+
'target-arrow-color': targetArrowColor,
|
|
35
|
+
'target-arrow-shape': 'triangle',
|
|
36
|
+
width: 3,
|
|
37
|
+
},
|
|
38
|
+
})
|