@xyo-network/react-node-renderer 2.47.35 → 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/cytoscape/useCytoscapeElements.js +59 -0
- 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/cjs/lib/utils.js +4 -0
- package/dist/cjs/lib/utils.js.map +1 -1
- package/dist/docs.json +221 -220
- 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/cytoscape/useCytoscapeElements.js +53 -0
- 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/{useIcons.js → cytoscape/useIcons.js} +3 -13
- 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/esm/lib/utils.js +4 -0
- package/dist/esm/lib/utils.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 +7 -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/dist/types/lib/utils.d.ts.map +1 -1
- package/package.json +7 -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.stories.tsx +5 -0
- package/src/components/RelationalGraph.tsx +15 -7
- package/src/hooks/cytoscape/index.ts +2 -0
- package/src/hooks/cytoscape/useCytoscapeElements.ts +59 -0
- 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/src/lib/utils.ts +4 -0
- package/dist/cjs/hooks/useCytoscapeElements.js +0 -68
- 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 -33
- package/dist/cjs/hooks/useIcons.js.map +0 -1
- package/dist/esm/hooks/useCytoscapeElements.js +0 -61
- 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.map +0 -1
- package/dist/types/hooks/useCytoscapeElements.d.ts +0 -6
- 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/useCytoscapeElements.ts +0 -67
- package/src/hooks/useCytoscapeOptions.ts +0 -57
- package/src/hooks/useIcons.tsx +0 -33
|
@@ -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
|
+
})
|
|
@@ -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,17 +1,15 @@
|
|
|
1
|
+
import { Button, styled } from '@mui/material'
|
|
1
2
|
import { FlexBoxProps, FlexCol } from '@xylabs/react-flexbox'
|
|
2
|
-
import { WithChildren } from '@xylabs/react-shared'
|
|
3
3
|
import { useShareForwardedRef } from '@xyo-network/react-shared'
|
|
4
4
|
import cytoscape, { Core, CytoscapeOptions } from 'cytoscape'
|
|
5
5
|
import { forwardRef, useEffect, useState } from 'react'
|
|
6
6
|
|
|
7
|
-
export interface NodeRelationalGraph extends
|
|
7
|
+
export interface NodeRelationalGraph extends FlexBoxProps {
|
|
8
8
|
options?: CytoscapeOptions
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export const NodeRelationalGraph = forwardRef<HTMLDivElement, NodeRelationalGraph>(({
|
|
11
|
+
export const NodeRelationalGraph = forwardRef<HTMLDivElement, NodeRelationalGraph>(({ options, ...props }, ref) => {
|
|
12
12
|
const sharedRef = useShareForwardedRef(ref)
|
|
13
|
-
// TODO - likely a value to stick in context
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
15
13
|
const [cy, setCy] = useState<Core>()
|
|
16
14
|
|
|
17
15
|
useEffect(() => {
|
|
@@ -26,10 +24,20 @@ export const NodeRelationalGraph = forwardRef<HTMLDivElement, NodeRelationalGrap
|
|
|
26
24
|
}, [options, sharedRef])
|
|
27
25
|
|
|
28
26
|
return (
|
|
29
|
-
<FlexCol
|
|
30
|
-
{
|
|
27
|
+
<FlexCol {...props}>
|
|
28
|
+
<ResetButton size={'small'} variant={'contained'} onClick={() => cy?.reset()}>
|
|
29
|
+
Reset
|
|
30
|
+
</ResetButton>
|
|
31
|
+
<FlexCol alignItems="stretch" height="100%" position="absolute" ref={sharedRef} width="100%"></FlexCol>
|
|
31
32
|
</FlexCol>
|
|
32
33
|
)
|
|
33
34
|
})
|
|
34
35
|
|
|
35
36
|
NodeRelationalGraph.displayName = 'NodeRelationalGraph'
|
|
37
|
+
|
|
38
|
+
const ResetButton = styled(Button, { name: 'ResetButton' })(() => ({
|
|
39
|
+
position: 'absolute',
|
|
40
|
+
right: '10px',
|
|
41
|
+
top: '10px',
|
|
42
|
+
zIndex: 2,
|
|
43
|
+
}))
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { useAsyncEffect } from '@xylabs/react-shared'
|
|
2
|
+
import { EventUnsubscribeFunction } from '@xyo-network/module'
|
|
3
|
+
import { useProvidedWrappedNode } from '@xyo-network/react-node'
|
|
4
|
+
import { ElementDefinition } from 'cytoscape'
|
|
5
|
+
import { useEffect, useState } from 'react'
|
|
6
|
+
|
|
7
|
+
import { CytoscapeElements } from '../../Cytoscape'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Note: Relies on describe but could eventually be converted to a discover call
|
|
11
|
+
* Logic would be similar to what the bridge does
|
|
12
|
+
*/
|
|
13
|
+
export const useCytoscapeElements = () => {
|
|
14
|
+
const [node] = useProvidedWrappedNode()
|
|
15
|
+
const [elements, setElements] = useState<ElementDefinition[]>([])
|
|
16
|
+
const [refresh, setRefresh] = useState(1)
|
|
17
|
+
|
|
18
|
+
useAsyncEffect(
|
|
19
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
20
|
+
async (mounted) => {
|
|
21
|
+
if (node && refresh) {
|
|
22
|
+
try {
|
|
23
|
+
const [description, newRootNode] = await CytoscapeElements.buildRootNode(node)
|
|
24
|
+
if (mounted()) setElements(() => [newRootNode])
|
|
25
|
+
|
|
26
|
+
const children = description.children
|
|
27
|
+
await Promise.allSettled(
|
|
28
|
+
(children ?? [])?.map(async (address) => {
|
|
29
|
+
try {
|
|
30
|
+
const newNode = await CytoscapeElements.buildChild(node, address)
|
|
31
|
+
if (mounted()) setElements((previous) => [...previous, newNode])
|
|
32
|
+
|
|
33
|
+
const newEdge = CytoscapeElements.buildEdge(newRootNode, newNode)
|
|
34
|
+
if (mounted()) setElements((previous) => [...previous, newEdge])
|
|
35
|
+
} catch (e) {
|
|
36
|
+
console.error('Error parsing children', e)
|
|
37
|
+
}
|
|
38
|
+
}),
|
|
39
|
+
)
|
|
40
|
+
} catch (e) {
|
|
41
|
+
console.error('Error Getting initial description', e)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
[node, refresh],
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
let listener: EventUnsubscribeFunction
|
|
50
|
+
if (node) {
|
|
51
|
+
listener = node.onAny((eventName) => {
|
|
52
|
+
if (eventName === 'moduleAttached') setRefresh((previous) => previous + 1)
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
return () => listener?.()
|
|
56
|
+
}, [node])
|
|
57
|
+
|
|
58
|
+
return elements
|
|
59
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CytoscapeOptions } from 'cytoscape'
|
|
2
|
+
import { useMemo } from 'react'
|
|
3
|
+
|
|
4
|
+
export const useCytoscapeLayout = () => {
|
|
5
|
+
const layout: CytoscapeOptions['layout'] = useMemo(
|
|
6
|
+
() => ({
|
|
7
|
+
minNodeSpacing: 75,
|
|
8
|
+
name: 'concentric',
|
|
9
|
+
}),
|
|
10
|
+
[],
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
return layout
|
|
14
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { CytoscapeOptions } from 'cytoscape'
|
|
2
|
+
import { useMemo } from 'react'
|
|
3
|
+
|
|
4
|
+
import { useCytoscapeLayout } from './useCytoscapeLayout'
|
|
5
|
+
import { useCytoscapeStyle } from './useCytoscapeStyle'
|
|
6
|
+
|
|
7
|
+
export const useCytoscapeOptions = (
|
|
8
|
+
elements: CytoscapeOptions['elements'],
|
|
9
|
+
style?: CytoscapeOptions['style'],
|
|
10
|
+
layout?: CytoscapeOptions['layout'],
|
|
11
|
+
) => {
|
|
12
|
+
const defaultStyle = useCytoscapeStyle()
|
|
13
|
+
const defaultLayout = useCytoscapeLayout()
|
|
14
|
+
|
|
15
|
+
const options = useMemo<CytoscapeOptions>(
|
|
16
|
+
() => ({
|
|
17
|
+
elements,
|
|
18
|
+
layout: layout ?? defaultLayout,
|
|
19
|
+
style: style ?? defaultStyle,
|
|
20
|
+
}),
|
|
21
|
+
[defaultLayout, defaultStyle, elements, layout, style],
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
return options
|
|
25
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useTheme } from '@mui/material'
|
|
2
|
+
import { CytoscapeOptions } from 'cytoscape'
|
|
3
|
+
import { useMemo } from 'react'
|
|
4
|
+
|
|
5
|
+
import { EdgeStyled, NodeIdStyles, NodeStyled } from '../../Cytoscape'
|
|
6
|
+
import { useIcons } from './useIcons'
|
|
7
|
+
|
|
8
|
+
export const useCytoscapeStyle = () => {
|
|
9
|
+
const theme = useTheme()
|
|
10
|
+
const icons = useIcons()
|
|
11
|
+
|
|
12
|
+
const style: CytoscapeOptions['style'] = useMemo(
|
|
13
|
+
() => [
|
|
14
|
+
NodeIdStyles(theme.palette.text.primary),
|
|
15
|
+
NodeStyled(icons, theme.palette.primary.main),
|
|
16
|
+
EdgeStyled(theme.palette.divider, theme.palette.divider),
|
|
17
|
+
],
|
|
18
|
+
[icons, theme.palette.divider, theme.palette.primary.main, theme.palette.text.primary],
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
return style
|
|
22
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useTheme } from '@mui/material'
|
|
2
|
+
import { useMemo } from 'react'
|
|
3
|
+
|
|
4
|
+
import { CyIconSet, CyNodeIcons } from '../../Cytoscape'
|
|
5
|
+
import { encodeSvg } from '../../lib'
|
|
6
|
+
|
|
7
|
+
export const useIcons = () => {
|
|
8
|
+
const theme = useTheme()
|
|
9
|
+
const icons = useMemo(() => {
|
|
10
|
+
const iconMap: Record<CyNodeIcons, string> = { archivist: '', diviner: '', module: '', node: '', witness: '' }
|
|
11
|
+
return Object.entries(CyIconSet).reduce((acc, [name, IconComponent]) => {
|
|
12
|
+
const icon = <IconComponent fontSize="small" />
|
|
13
|
+
acc[name as CyNodeIcons] = encodeSvg(icon, theme.palette.getContrastText(theme.palette.text.primary))
|
|
14
|
+
return acc
|
|
15
|
+
}, iconMap)
|
|
16
|
+
}, [theme.palette])
|
|
17
|
+
|
|
18
|
+
return icons
|
|
19
|
+
}
|
package/src/hooks/index.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './useCytoscapeOptions'
|
|
1
|
+
export * from './cytoscape'
|
package/src/lib/utils.ts
CHANGED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useCytoscapeElements = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const react_shared_1 = require("@xylabs/react-shared");
|
|
6
|
-
const module_1 = require("@xyo-network/module");
|
|
7
|
-
const node_1 = require("@xyo-network/node");
|
|
8
|
-
const react_node_1 = require("@xyo-network/react-node");
|
|
9
|
-
const react_1 = require("react");
|
|
10
|
-
const lib_1 = require("../lib");
|
|
11
|
-
/**
|
|
12
|
-
* Note: Relies on describe but could eventually be converted to a discover call
|
|
13
|
-
* Logic would be similar to what the bridge does
|
|
14
|
-
*/
|
|
15
|
-
const useCytoscapeElements = () => {
|
|
16
|
-
const [node] = (0, react_node_1.useProvidedWrappedNode)();
|
|
17
|
-
const [elements, setElements] = (0, react_1.useState)();
|
|
18
|
-
(0, react_shared_1.useAsyncEffect)(
|
|
19
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
20
|
-
() => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
-
var _a, _b;
|
|
22
|
-
if (node) {
|
|
23
|
-
try {
|
|
24
|
-
const newElements = [];
|
|
25
|
-
const wrapper = node_1.NodeWrapper.wrap(node);
|
|
26
|
-
const description = yield (wrapper === null || wrapper === void 0 ? void 0 : wrapper.describe());
|
|
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
|
-
});
|
|
31
|
-
const children = description.children;
|
|
32
|
-
yield Promise.all((_b = (children !== null && children !== void 0 ? children : [])) === null || _b === void 0 ? void 0 : _b.map((address) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
33
|
-
var _c;
|
|
34
|
-
const [result] = yield wrapper.resolveWrapped(module_1.ModuleWrapper, { address: [address] });
|
|
35
|
-
try {
|
|
36
|
-
const description = yield result.describe();
|
|
37
|
-
const newNodeId = (_c = description.name) !== null && _c !== void 0 ? _c : description.address.substring(0, 6);
|
|
38
|
-
const newNode = {
|
|
39
|
-
data: {
|
|
40
|
-
id: newNodeId,
|
|
41
|
-
type: (0, lib_1.parseModuleType)(description.queries),
|
|
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);
|
|
53
|
-
}
|
|
54
|
-
catch (e) {
|
|
55
|
-
console.error(e, result);
|
|
56
|
-
}
|
|
57
|
-
})));
|
|
58
|
-
setElements(newElements);
|
|
59
|
-
}
|
|
60
|
-
catch (e) {
|
|
61
|
-
console.error(e);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}), [node]);
|
|
65
|
-
return elements;
|
|
66
|
-
};
|
|
67
|
-
exports.useCytoscapeElements = useCytoscapeElements;
|
|
68
|
-
//# sourceMappingURL=useCytoscapeElements.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3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CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;oBACpF,IAAI;wBACF,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,QAAQ,EAAE,CAAA;wBAC3C,MAAM,SAAS,GAAG,MAAA,WAAW,CAAC,IAAI,mCAAI,WAAW,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;wBACzE,MAAM,OAAO,GAAG;4BACd,IAAI,EAAE;gCACJ,EAAE,EAAE,SAAS;gCACb,IAAI,EAAE,IAAA,qBAAe,EAAC,WAAW,CAAC,OAAO,CAAC;6BAC3C;yBACF,CAAA;wBACD,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;wBACzB,MAAM,OAAO,GAAG;4BACd,IAAI,EAAE;gCACJ,EAAE,EAAE,GAAG,UAAU,IAAI,SAAS,EAAE;gCAChC,MAAM,EAAE,UAAU;gCAClB,MAAM,EAAE,SAAS;6BAClB;yBACF,CAAA;wBACD,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;qBAC1B;oBAAC,OAAO,CAAC,EAAE;wBACV,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAA;qBACzB;gBACH,CAAC,CAAA,CAAC,CACH,CAAA;gBACD,WAAW,CAAC,WAAW,CAAC,CAAA;aACzB;YAAC,OAAO,CAAC,EAAE;gBACV,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;aACjB;SACF;IACH,CAAC,CAAA,EACD,CAAC,IAAI,CAAC,CACP,CAAA;IAED,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA;AArDY,QAAA,oBAAoB,wBAqDhC"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useCytoscapeOptions = void 0;
|
|
4
|
-
const material_1 = require("@mui/material");
|
|
5
|
-
const react_1 = require("react");
|
|
6
|
-
const useIcons_1 = require("./useIcons");
|
|
7
|
-
const useCytoscapeOptions = (elements) => {
|
|
8
|
-
const theme = (0, material_1.useTheme)();
|
|
9
|
-
const icons = (0, useIcons_1.useIcons)();
|
|
10
|
-
const options = (0, react_1.useMemo)(() => ({
|
|
11
|
-
elements,
|
|
12
|
-
layout: {
|
|
13
|
-
minNodeSpacing: 75,
|
|
14
|
-
name: 'concentric',
|
|
15
|
-
},
|
|
16
|
-
style: [
|
|
17
|
-
{
|
|
18
|
-
selector: 'node[id]',
|
|
19
|
-
style: {
|
|
20
|
-
color: theme.palette.text.primary,
|
|
21
|
-
'font-family': 'Lexend Deca, Helvetica, sans-serif',
|
|
22
|
-
'font-size': 14,
|
|
23
|
-
'text-margin-y': -5,
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
selector: 'node',
|
|
28
|
-
style: {
|
|
29
|
-
'background-color': theme.palette.primary.main,
|
|
30
|
-
'background-height': '75%',
|
|
31
|
-
// TODO - make dynamic
|
|
32
|
-
'background-image': (elem) => icons[elem.data('type')],
|
|
33
|
-
'background-image-smoothing': 'yes',
|
|
34
|
-
'background-width': '75%',
|
|
35
|
-
label: 'data(id)',
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
selector: 'edge',
|
|
40
|
-
style: {
|
|
41
|
-
'curve-style': 'bezier',
|
|
42
|
-
'line-color': theme.palette.divider,
|
|
43
|
-
'line-opacity': 0.1,
|
|
44
|
-
'target-arrow-color': theme.palette.divider,
|
|
45
|
-
'target-arrow-shape': 'triangle',
|
|
46
|
-
width: 3,
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
],
|
|
50
|
-
}), [elements, icons, theme.palette.divider, theme.palette.primary.main, theme.palette.text.primary]);
|
|
51
|
-
return options;
|
|
52
|
-
};
|
|
53
|
-
exports.useCytoscapeOptions = useCytoscapeOptions;
|
|
54
|
-
//# sourceMappingURL=useCytoscapeOptions.js.map
|
|
@@ -1 +0,0 @@
|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C3C,oBAAoB,EAAE,UAAU;oBAChC,KAAK,EAAE,CAAC;iBACT;aACF;SACF;KACF,CAAC,EACF,CAAC,QAAQ,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CACjG,CAAA;IAED,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAlDY,QAAA,mBAAmB,uBAkD/B"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useIcons = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
-
const GridViewRounded_1 = tslib_1.__importDefault(require("@mui/icons-material/GridViewRounded"));
|
|
7
|
-
const Hub_1 = tslib_1.__importDefault(require("@mui/icons-material/Hub"));
|
|
8
|
-
const QuestionMarkRounded_1 = tslib_1.__importDefault(require("@mui/icons-material/QuestionMarkRounded"));
|
|
9
|
-
const VisibilityRounded_1 = tslib_1.__importDefault(require("@mui/icons-material/VisibilityRounded"));
|
|
10
|
-
const material_1 = require("@mui/material");
|
|
11
|
-
const react_1 = require("react");
|
|
12
|
-
const lib_1 = require("../lib");
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
14
|
-
const CyIconSet = {
|
|
15
|
-
archivist: GridViewRounded_1.default,
|
|
16
|
-
diviner: VisibilityRounded_1.default,
|
|
17
|
-
module: QuestionMarkRounded_1.default,
|
|
18
|
-
node: Hub_1.default,
|
|
19
|
-
};
|
|
20
|
-
const useIcons = () => {
|
|
21
|
-
const theme = (0, material_1.useTheme)();
|
|
22
|
-
const icons = (0, react_1.useMemo)(() => {
|
|
23
|
-
const iconMap = { archivist: '', diviner: '', module: '', node: '' };
|
|
24
|
-
return Object.entries(CyIconSet).reduce((acc, [name, IconComponent]) => {
|
|
25
|
-
const icon = (0, jsx_runtime_1.jsx)(IconComponent, { fontSize: "small" });
|
|
26
|
-
acc[name] = (0, lib_1.encodeSvg)(icon, theme.palette.getContrastText(theme.palette.text.primary));
|
|
27
|
-
return acc;
|
|
28
|
-
}, iconMap);
|
|
29
|
-
}, [theme.palette]);
|
|
30
|
-
return icons;
|
|
31
|
-
};
|
|
32
|
-
exports.useIcons = useIcons;
|
|
33
|
-
//# sourceMappingURL=useIcons.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,2BAAqB;IAC9B,MAAM,EAAE,6BAAuB;IAC/B,IAAI,EAAE,aAAO;CACd,CAAA;AAEM,MAAM,QAAQ,GAAG,GAAG,EAAE;IAC3B,MAAM,KAAK,GAAG,IAAA,mBAAQ,GAAE,CAAA;IACxB,MAAM,KAAK,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE;QACzB,MAAM,OAAO,GAAgC,EAAE,SAAS,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAA;QACjG,OAAO,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,aAAa,CAAC,EAAE,EAAE;YACrE,MAAM,IAAI,GAAG,uBAAC,aAAa,IAAC,QAAQ,EAAC,OAAO,GAAG,CAAA;YAC/C,GAAG,CAAC,IAAmB,CAAC,GAAG,IAAA,eAAS,EAAC,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;AAZY,QAAA,QAAQ,YAYpB"}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { useAsyncEffect } from '@xylabs/react-shared';
|
|
2
|
-
import { ModuleWrapper } from '@xyo-network/module';
|
|
3
|
-
import { NodeWrapper } from '@xyo-network/node';
|
|
4
|
-
import { useProvidedWrappedNode } from '@xyo-network/react-node';
|
|
5
|
-
import { useState } from 'react';
|
|
6
|
-
import { parseModuleType } from '../lib';
|
|
7
|
-
/**
|
|
8
|
-
* Note: Relies on describe but could eventually be converted to a discover call
|
|
9
|
-
* Logic would be similar to what the bridge does
|
|
10
|
-
*/
|
|
11
|
-
export const useCytoscapeElements = () => {
|
|
12
|
-
const [node] = useProvidedWrappedNode();
|
|
13
|
-
const [elements, setElements] = useState();
|
|
14
|
-
useAsyncEffect(
|
|
15
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
16
|
-
async () => {
|
|
17
|
-
if (node) {
|
|
18
|
-
try {
|
|
19
|
-
const newElements = [];
|
|
20
|
-
const wrapper = NodeWrapper.wrap(node);
|
|
21
|
-
const description = await wrapper?.describe();
|
|
22
|
-
const rootNodeId = description.name ?? description.address.substring(0, 6);
|
|
23
|
-
newElements.push({
|
|
24
|
-
data: { id: rootNodeId, type: parseModuleType(description.queries) },
|
|
25
|
-
});
|
|
26
|
-
const children = description.children;
|
|
27
|
-
await Promise.all((children ?? [])?.map(async (address) => {
|
|
28
|
-
const [result] = await wrapper.resolveWrapped(ModuleWrapper, { address: [address] });
|
|
29
|
-
try {
|
|
30
|
-
const description = await result.describe();
|
|
31
|
-
const newNodeId = description.name ?? description.address.substring(0, 6);
|
|
32
|
-
const newNode = {
|
|
33
|
-
data: {
|
|
34
|
-
id: newNodeId,
|
|
35
|
-
type: parseModuleType(description.queries),
|
|
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);
|
|
47
|
-
}
|
|
48
|
-
catch (e) {
|
|
49
|
-
console.error(e, result);
|
|
50
|
-
}
|
|
51
|
-
}));
|
|
52
|
-
setElements(newElements);
|
|
53
|
-
}
|
|
54
|
-
catch (e) {
|
|
55
|
-
console.error(e);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}, [node]);
|
|
59
|
-
return elements;
|
|
60
|
-
};
|
|
61
|
-
//# sourceMappingURL=useCytoscapeElements.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useCytoscapeElements.js","sourceRoot":"","sources":["../../../src/hooks/useCytoscapeElements.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AAEhE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhC,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AAExC;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,EAAE;IACvC,MAAM,CAAC,IAAI,CAAC,GAAG,sBAAsB,EAAE,CAAA;IACvC,MAAM,CAAC,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AAC,OAAO,CAAC,CAAA;wBACzB,MAAM,OAAO,GAAG;4BACd,IAAI,EAAE;gCACJ,EAAE,EAAE,GAAG,UAAU,IAAI,SAAS,EAAE;gCAChC,MAAM,EAAE,UAAU;gCAClB,MAAM,EAAE,SAAS;6BAClB;yBACF,CAAA;wBACD,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;qBAC1B;oBAAC,OAAO,CAAC,EAAE;wBACV,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAA;qBACzB;gBACH,CAAC,CAAC,CACH,CAAA;gBACD,WAAW,CAAC,WAAW,CAAC,CAAA;aACzB;YAAC,OAAO,CAAC,EAAE;gBACV,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;aACjB;SACF;IACH,CAAC,EACD,CAAC,IAAI,CAAC,CACP,CAAA;IAED,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { useTheme } from '@mui/material';
|
|
2
|
-
import { useMemo } from 'react';
|
|
3
|
-
import { useIcons } from './useIcons';
|
|
4
|
-
export const useCytoscapeOptions = (elements) => {
|
|
5
|
-
const theme = useTheme();
|
|
6
|
-
const icons = useIcons();
|
|
7
|
-
const options = useMemo(() => ({
|
|
8
|
-
elements,
|
|
9
|
-
layout: {
|
|
10
|
-
minNodeSpacing: 75,
|
|
11
|
-
name: 'concentric',
|
|
12
|
-
},
|
|
13
|
-
style: [
|
|
14
|
-
{
|
|
15
|
-
selector: 'node[id]',
|
|
16
|
-
style: {
|
|
17
|
-
color: theme.palette.text.primary,
|
|
18
|
-
'font-family': 'Lexend Deca, Helvetica, sans-serif',
|
|
19
|
-
'font-size': 14,
|
|
20
|
-
'text-margin-y': -5,
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
selector: 'node',
|
|
25
|
-
style: {
|
|
26
|
-
'background-color': theme.palette.primary.main,
|
|
27
|
-
'background-height': '75%',
|
|
28
|
-
// TODO - make dynamic
|
|
29
|
-
'background-image': (elem) => icons[elem.data('type')],
|
|
30
|
-
'background-image-smoothing': 'yes',
|
|
31
|
-
'background-width': '75%',
|
|
32
|
-
label: 'data(id)',
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
selector: 'edge',
|
|
37
|
-
style: {
|
|
38
|
-
'curve-style': 'bezier',
|
|
39
|
-
'line-color': theme.palette.divider,
|
|
40
|
-
'line-opacity': 0.1,
|
|
41
|
-
'target-arrow-color': theme.palette.divider,
|
|
42
|
-
'target-arrow-shape': 'triangle',
|
|
43
|
-
width: 3,
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
],
|
|
47
|
-
}), [elements, icons, theme.palette.divider, theme.palette.primary.main, theme.palette.text.primary]);
|
|
48
|
-
return options;
|
|
49
|
-
};
|
|
50
|
-
//# sourceMappingURL=useCytoscapeOptions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useCytoscapeOptions.js","sourceRoot":"","sources":["../../../src/hooks/useCytoscapeOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAE/B,OAAO,EAAe,QAAQ,EAAE,MAAM,YAAY,CAAA;AAElD,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,QAAsC,EAAE,EAAE;IAC5E,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAA;IACxB,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAA;IAExB,MAAM,OAAO,GAAG,OAAO,CACrB,GAAG,EAAE,CAAC,CAAC;QACL,QAAQ;QACR,MAAM,EAAE;YACN,cAAc,EAAE,EAAE;YAClB,IAAI,EAAE,YAAY;SACnB;QACD,KAAK,EAAE;YACL;gBACE,QAAQ,EAAE,UAAU;gBACpB,KAAK,EAAE;oBACL,KAAK,EAA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|
3
|
-
* Logic would be similar to what the bridge does
|
|
4
|
-
*/
|
|
5
|
-
export declare const useCytoscapeElements: () => import("cytoscape").ElementsDefinition | import("cytoscape").ElementDefinition[] | Promise<import("cytoscape").ElementsDefinition> | Promise<import("cytoscape").ElementDefinition[]> | undefined;
|
|
6
|
-
//# sourceMappingURL=useCytoscapeElements.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useCytoscapeElements.d.ts","sourceRoot":"","sources":["../../../src/hooks/useCytoscapeElements.ts"],"names":[],"mappings":"AASA;;;GAGG;AACH,eAAO,MAAM,oBAAoB,yMAqDhC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useCytoscapeOptions.d.ts","sourceRoot":"","sources":["../../../src/hooks/useCytoscapeOptions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAK5C,eAAO,MAAM,mBAAmB,aAAc,gBAAgB,CAAC,UAAU,CAAC,qBAkDzE,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useIcons.d.ts","sourceRoot":"","sources":["../../../src/hooks/useIcons.tsx"],"names":[],"mappings":"AAUA,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,WAAW,GAAG,SAAS,GAAG,QAAQ,CAAA;AAUrE,eAAO,MAAM,QAAQ,mCAYpB,CAAA"}
|