@xyo-network/react-node-renderer 7.5.8 → 7.5.12
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/browser/Cytoscape/CytoscapeElements.d.ts +2 -6
- package/dist/browser/Cytoscape/CytoscapeElements.d.ts.map +1 -1
- package/dist/browser/components/module/graph/Popper.d.ts +3 -2
- package/dist/browser/components/module/graph/Popper.d.ts.map +1 -1
- package/dist/browser/components/module/graph/node/hooks/useNodeElement.d.ts +8 -5
- package/dist/browser/components/module/graph/node/hooks/useNodeElement.d.ts.map +1 -1
- package/dist/browser/components/relational/graph/Graph.d.ts.map +1 -1
- package/dist/browser/hooks/cytoscape/elements/useRenderNewElements.d.ts +1 -1
- package/dist/browser/hooks/cytoscape/elements/useRenderNewElements.d.ts.map +1 -1
- package/dist/browser/index.mjs +362 -423
- package/dist/browser/index.mjs.map +1 -1
- package/package.json +188 -59
- package/src/Cytoscape/CytoscapeElements.ts +0 -96
- package/src/Cytoscape/CytoscapeIcons.tsx +0 -23
- package/src/Cytoscape/CytoscapeStyles.ts +0 -46
- package/src/Cytoscape/index.ts +0 -4
- package/src/Cytoscape/lib/CyNodeModuleTypes.ts +0 -1
- package/src/Cytoscape/lib/encodeSvg.ts +0 -19
- package/src/Cytoscape/lib/iconMap.ts +0 -12
- package/src/Cytoscape/lib/index.ts +0 -5
- package/src/Cytoscape/lib/layout/ColaLayout.ts +0 -5
- package/src/Cytoscape/lib/layout/ConcentricLayout.ts +0 -12
- package/src/Cytoscape/lib/layout/index.ts +0 -2
- package/src/Cytoscape/lib/parseModuleType.ts +0 -29
- package/src/components/cytoscape-extensions/WithExtensions.tsx +0 -16
- package/src/components/cytoscape-extensions/index.ts +0 -1
- package/src/components/index.ts +0 -3
- package/src/components/lib/RelationalGraphProps.ts +0 -16
- package/src/components/lib/index.ts +0 -1
- package/src/components/module/CardParser.stories.tsx +0 -36
- package/src/components/module/CardParser.tsx +0 -24
- package/src/components/module/graph/DetailsFlexbox.tsx +0 -22
- package/src/components/module/graph/GraphFlexBox.stories.tsx +0 -118
- package/src/components/module/graph/GraphFlexBox.tsx +0 -84
- package/src/components/module/graph/Popper.tsx +0 -77
- package/src/components/module/graph/index.ts +0 -1
- package/src/components/module/graph/node/Hover.tsx +0 -38
- package/src/components/module/graph/node/hooks/index.ts +0 -1
- package/src/components/module/graph/node/hooks/useNodeElement.tsx +0 -41
- package/src/components/module/graph/node/index.ts +0 -1
- package/src/components/module/index.ts +0 -2
- package/src/components/relational/graph/Graph.stories.tsx +0 -201
- package/src/components/relational/graph/Graph.tsx +0 -200
- package/src/components/relational/graph/GraphCola.stories.tsx +0 -187
- package/src/components/relational/graph/GraphCoseBilkent.stories.tsx +0 -186
- package/src/components/relational/graph/GraphDagre.stories.tsx +0 -186
- package/src/components/relational/graph/GraphEuler.stories.tsx +0 -187
- package/src/components/relational/graph/GraphEvents.stories.tsx +0 -82
- package/src/components/relational/graph/ProvidedNodeRenderer.tsx +0 -23
- package/src/components/relational/graph/index.ts +0 -2
- package/src/components/relational/graph/story/TestData.tsx +0 -51
- package/src/components/relational/graph/story/index.ts +0 -1
- package/src/components/relational/index.ts +0 -1
- package/src/contexts/CytoscapeInstance/Context.ts +0 -5
- package/src/contexts/CytoscapeInstance/Provider.tsx +0 -24
- package/src/contexts/CytoscapeInstance/State.ts +0 -8
- package/src/contexts/CytoscapeInstance/index.ts +0 -4
- package/src/contexts/CytoscapeInstance/use.ts +0 -5
- package/src/contexts/index.ts +0 -1
- package/src/hooks/cytoscape/elements/index.ts +0 -2
- package/src/hooks/cytoscape/elements/useCytoscapeElements.ts +0 -47
- package/src/hooks/cytoscape/elements/useElements.tsx +0 -15
- package/src/hooks/cytoscape/elements/useHoveredNode.tsx +0 -34
- package/src/hooks/cytoscape/elements/useNewElements.tsx +0 -17
- package/src/hooks/cytoscape/elements/useRenderNewElements.tsx +0 -17
- package/src/hooks/cytoscape/elements/useSelectedElement.tsx +0 -25
- package/src/hooks/cytoscape/index.ts +0 -4
- package/src/hooks/cytoscape/useCytoscapeOptions.ts +0 -29
- package/src/hooks/cytoscape/useCytoscapeStyle.tsx +0 -34
- package/src/hooks/cytoscape/useIcons.tsx +0 -22
- package/src/hooks/cytoscape/useModuleDetails.tsx +0 -83
- package/src/hooks/cytoscape/useRelationalGraphOptions.tsx +0 -23
- package/src/hooks/index.ts +0 -1
- package/src/index.ts +0 -4
- package/src/types/global.d.ts +0 -19
- package/src/types/images.d.ts +0 -5
- package/src/types/theme.d.ts +0 -1
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import { Button, ButtonGroup } from '@mui/material'
|
|
2
|
-
import type {
|
|
3
|
-
Decorator, Meta, StoryFn,
|
|
4
|
-
} from '@storybook/react-vite'
|
|
5
|
-
import { useAsyncEffect } from '@xylabs/react-async-effect'
|
|
6
|
-
import { MemoryArchivist, MemoryArchivistConfigSchema } from '@xyo-network/archivist-memory'
|
|
7
|
-
import { HttpBridge, HttpBridgeConfigSchema } from '@xyo-network/bridge-http'
|
|
8
|
-
import { IdWitness, IdWitnessConfigSchema } from '@xyo-network/id-plugin'
|
|
9
|
-
import type { AttachableModuleInstance } from '@xyo-network/module-model'
|
|
10
|
-
import { MemoryNode } from '@xyo-network/node-memory'
|
|
11
|
-
import { NodeConfigSchema } from '@xyo-network/node-model'
|
|
12
|
-
import {
|
|
13
|
-
NodeProvider, useWeakNodeFromNode, useWeakProvidedNode,
|
|
14
|
-
} from '@xyo-network/react-node'
|
|
15
|
-
import { DefaultSeedPhrase } from '@xyo-network/react-storybook'
|
|
16
|
-
import { useWallet, WalletProvider } from '@xyo-network/react-wallet'
|
|
17
|
-
import { SentinelConfigSchema } from '@xyo-network/sentinel'
|
|
18
|
-
import { MemorySentinel } from '@xyo-network/sentinel-memory'
|
|
19
|
-
import React, { useState } from 'react'
|
|
20
|
-
|
|
21
|
-
import { CytoscapeInstanceProvider } from '../../../contexts/index.ts'
|
|
22
|
-
import { useCytoscapeElements, useCytoscapeOptions } from '../../../hooks/index.ts'
|
|
23
|
-
import { WithExtensions } from '../../cytoscape-extensions/index.ts'
|
|
24
|
-
import { NodeRelationalGraphFlexBox } from './Graph.tsx'
|
|
25
|
-
import { ProvidedNodeRenderer } from './ProvidedNodeRenderer.tsx'
|
|
26
|
-
import { options } from './story/index.ts'
|
|
27
|
-
|
|
28
|
-
const client = { url: 'http://localhost:8080/node' }
|
|
29
|
-
|
|
30
|
-
const MemoryNodeDecorator: Decorator = (Story, args) => {
|
|
31
|
-
const [node, setNode] = useState<MemoryNode>()
|
|
32
|
-
|
|
33
|
-
useAsyncEffect(
|
|
34
|
-
async () => {
|
|
35
|
-
try {
|
|
36
|
-
const node = await MemoryNode.create({ config: { name: 'GlobalNode', schema: NodeConfigSchema } })
|
|
37
|
-
const node1 = await MemoryNode.create({ config: { name: 'ChildNode', schema: NodeConfigSchema } })
|
|
38
|
-
const bridge = await HttpBridge.create({
|
|
39
|
-
config: {
|
|
40
|
-
name: 'Bridge', client, schema: HttpBridgeConfigSchema, security: { allowAnonymous: true },
|
|
41
|
-
},
|
|
42
|
-
})
|
|
43
|
-
await node.register(bridge)
|
|
44
|
-
await node.attach(bridge.address, true)
|
|
45
|
-
|
|
46
|
-
const archivist = await MemoryArchivist.create({ config: { name: 'RootStorageArchivist', schema: MemoryArchivistConfigSchema } })
|
|
47
|
-
await node.register(archivist)
|
|
48
|
-
await node.attach(archivist.address, true)
|
|
49
|
-
|
|
50
|
-
const sentinel = await MemorySentinel.create({
|
|
51
|
-
config: {
|
|
52
|
-
name: 'MemorySentinel', schema: SentinelConfigSchema, synchronous: true, tasks: [],
|
|
53
|
-
},
|
|
54
|
-
})
|
|
55
|
-
await node.register(sentinel)
|
|
56
|
-
await node.attach(sentinel.address, true)
|
|
57
|
-
|
|
58
|
-
const archivist1 = await MemoryArchivist.create({ config: { name: 'RootStorageArchivist1', schema: MemoryArchivistConfigSchema } })
|
|
59
|
-
await node1.register(archivist1)
|
|
60
|
-
await node1.attach(archivist1.address, true)
|
|
61
|
-
|
|
62
|
-
await node.register(node1)
|
|
63
|
-
await node.attach(node1.address, true)
|
|
64
|
-
|
|
65
|
-
setNode(node)
|
|
66
|
-
} catch (e) {
|
|
67
|
-
console.error('Error Creating MemoryNode', e)
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
[],
|
|
71
|
-
)
|
|
72
|
-
|
|
73
|
-
const [wallet] = useWallet({ mnemonic: DefaultSeedPhrase })
|
|
74
|
-
|
|
75
|
-
return (
|
|
76
|
-
<WalletProvider rootWallet={wallet}>
|
|
77
|
-
<NodeProvider node={node}>
|
|
78
|
-
<CytoscapeInstanceProvider>
|
|
79
|
-
<Story {...args} />
|
|
80
|
-
</CytoscapeInstanceProvider>
|
|
81
|
-
</NodeProvider>
|
|
82
|
-
</WalletProvider>
|
|
83
|
-
)
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export default {
|
|
87
|
-
component: NodeRelationalGraphFlexBox,
|
|
88
|
-
title: 'node/renderer/cola/NodeRelationalGraph',
|
|
89
|
-
} as Meta
|
|
90
|
-
|
|
91
|
-
const Template: StoryFn<typeof NodeRelationalGraphFlexBox> = props => <NodeRelationalGraphFlexBox layout="cola" {...props} />
|
|
92
|
-
|
|
93
|
-
const TemplateDescribe: StoryFn<typeof NodeRelationalGraphFlexBox> = (props) => {
|
|
94
|
-
const [node] = useWeakProvidedNode()
|
|
95
|
-
const elements = useCytoscapeElements(node)
|
|
96
|
-
const options = useCytoscapeOptions(elements)
|
|
97
|
-
return <NodeRelationalGraphFlexBox layout="cola" options={options} {...props} />
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const TemplateCustomAddress: StoryFn<typeof NodeRelationalGraphFlexBox> = (props) => {
|
|
101
|
-
const [node] = useWeakNodeFromNode('ChildNode')
|
|
102
|
-
const elements = useCytoscapeElements(node)
|
|
103
|
-
const options = useCytoscapeOptions(elements)
|
|
104
|
-
return <NodeRelationalGraphFlexBox layout="cola" options={options} {...props} />
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const TemplateProvidedNodeRenderer: StoryFn<typeof ProvidedNodeRenderer> = props => <ProvidedNodeRenderer layout="cola" {...props} />
|
|
108
|
-
|
|
109
|
-
const TemplateAttachDetach: StoryFn<typeof NodeRelationalGraphFlexBox> = (props) => {
|
|
110
|
-
const [node] = useWeakNodeFromNode('ChildNode')
|
|
111
|
-
const elements = useCytoscapeElements(node)
|
|
112
|
-
const options = useCytoscapeOptions(elements)
|
|
113
|
-
const [idWitness, setIdWitness] = useState<IdWitness>()
|
|
114
|
-
|
|
115
|
-
useAsyncEffect(
|
|
116
|
-
|
|
117
|
-
async () => {
|
|
118
|
-
const witnessModule = await IdWitness.create({
|
|
119
|
-
config: {
|
|
120
|
-
name: 'IdWitness', salt: 'test', schema: IdWitnessConfigSchema,
|
|
121
|
-
},
|
|
122
|
-
})
|
|
123
|
-
setIdWitness(witnessModule)
|
|
124
|
-
},
|
|
125
|
-
[],
|
|
126
|
-
)
|
|
127
|
-
|
|
128
|
-
const handleAddWitness = async () => {
|
|
129
|
-
if (node && idWitness) {
|
|
130
|
-
const memoryNode = node.deref() as MemoryNode | undefined
|
|
131
|
-
await memoryNode?.register(idWitness as unknown as AttachableModuleInstance)
|
|
132
|
-
await memoryNode?.attach(idWitness.address, true)
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
const handleRemoveWitness = async () => {
|
|
137
|
-
if (node && idWitness) {
|
|
138
|
-
const memoryNode = node.deref() as MemoryNode | undefined
|
|
139
|
-
if (((await memoryNode?.registered()) ?? []).includes(idWitness.address)) {
|
|
140
|
-
await memoryNode?.unregister(idWitness as unknown as AttachableModuleInstance)
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
return (
|
|
146
|
-
<>
|
|
147
|
-
<ButtonGroup>
|
|
148
|
-
<Button onClick={handleAddWitness}>Add Witness</Button>
|
|
149
|
-
<Button onClick={handleRemoveWitness}>Remove Witness</Button>
|
|
150
|
-
</ButtonGroup>
|
|
151
|
-
<WithExtensions>
|
|
152
|
-
<NodeRelationalGraphFlexBox layout="cola" options={options} {...props} />
|
|
153
|
-
</WithExtensions>
|
|
154
|
-
</>
|
|
155
|
-
)
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
const defaultProps = {
|
|
159
|
-
height: 'calc(100vh - 20px)',
|
|
160
|
-
width: '100%',
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
const Default = Template.bind({})
|
|
164
|
-
Default.args = {}
|
|
165
|
-
|
|
166
|
-
const WithData = Template.bind({})
|
|
167
|
-
WithData.args = { options, ...defaultProps }
|
|
168
|
-
|
|
169
|
-
const WithDescribe = TemplateDescribe.bind({})
|
|
170
|
-
WithDescribe.args = { ...defaultProps }
|
|
171
|
-
WithDescribe.decorators = [MemoryNodeDecorator]
|
|
172
|
-
|
|
173
|
-
const WithCustomAddress = TemplateCustomAddress.bind({})
|
|
174
|
-
WithCustomAddress.args = { ...defaultProps }
|
|
175
|
-
WithCustomAddress.decorators = [MemoryNodeDecorator]
|
|
176
|
-
|
|
177
|
-
const WithAttachDetach = TemplateAttachDetach.bind({})
|
|
178
|
-
WithAttachDetach.args = { ...defaultProps }
|
|
179
|
-
WithAttachDetach.decorators = [MemoryNodeDecorator]
|
|
180
|
-
|
|
181
|
-
const WithProvidedNodeRenderer = TemplateProvidedNodeRenderer.bind({})
|
|
182
|
-
WithProvidedNodeRenderer.args = { ...defaultProps }
|
|
183
|
-
WithProvidedNodeRenderer.decorators = [MemoryNodeDecorator]
|
|
184
|
-
|
|
185
|
-
export {
|
|
186
|
-
Default, WithAttachDetach, WithCustomAddress, WithData, WithDescribe, WithProvidedNodeRenderer,
|
|
187
|
-
}
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import { Button, ButtonGroup } from '@mui/material'
|
|
2
|
-
import type {
|
|
3
|
-
Decorator, Meta, StoryFn,
|
|
4
|
-
} from '@storybook/react-vite'
|
|
5
|
-
import { useAsyncEffect } from '@xylabs/react-async-effect'
|
|
6
|
-
import { MemoryArchivist, MemoryArchivistConfigSchema } from '@xyo-network/archivist-memory'
|
|
7
|
-
import { HttpBridge, HttpBridgeConfigSchema } from '@xyo-network/bridge-http'
|
|
8
|
-
import { IdWitness, IdWitnessConfigSchema } from '@xyo-network/id-plugin'
|
|
9
|
-
import type { AttachableModuleInstance } from '@xyo-network/module-model'
|
|
10
|
-
import { MemoryNode } from '@xyo-network/node-memory'
|
|
11
|
-
import { NodeConfigSchema } from '@xyo-network/node-model'
|
|
12
|
-
import {
|
|
13
|
-
NodeProvider, useWeakNodeFromNode, useWeakProvidedNode,
|
|
14
|
-
} from '@xyo-network/react-node'
|
|
15
|
-
import { DefaultSeedPhrase } from '@xyo-network/react-storybook'
|
|
16
|
-
import { useWallet, WalletProvider } from '@xyo-network/react-wallet'
|
|
17
|
-
import { SentinelConfigSchema } from '@xyo-network/sentinel'
|
|
18
|
-
import { MemorySentinel } from '@xyo-network/sentinel-memory'
|
|
19
|
-
import React, { useState } from 'react'
|
|
20
|
-
|
|
21
|
-
import { CytoscapeInstanceProvider } from '../../../contexts/index.ts'
|
|
22
|
-
import { useCytoscapeElements, useCytoscapeOptions } from '../../../hooks/index.ts'
|
|
23
|
-
import { WithExtensions } from '../../cytoscape-extensions/index.ts'
|
|
24
|
-
import { NodeRelationalGraphFlexBox } from './Graph.tsx'
|
|
25
|
-
import { ProvidedNodeRenderer } from './ProvidedNodeRenderer.tsx'
|
|
26
|
-
import { options } from './story/index.ts'
|
|
27
|
-
|
|
28
|
-
const client = { url: 'http://localhost:8080/node' }
|
|
29
|
-
|
|
30
|
-
const MemoryNodeDecorator: Decorator = (Story, args) => {
|
|
31
|
-
const [node, setNode] = useState<MemoryNode>()
|
|
32
|
-
|
|
33
|
-
useAsyncEffect(
|
|
34
|
-
async () => {
|
|
35
|
-
try {
|
|
36
|
-
const node = await MemoryNode.create({ config: { name: 'GlobalNode', schema: NodeConfigSchema } })
|
|
37
|
-
const node1 = await MemoryNode.create({ config: { name: 'ChildNode', schema: NodeConfigSchema } })
|
|
38
|
-
const bridge = await HttpBridge.create({
|
|
39
|
-
config: {
|
|
40
|
-
name: 'Bridge', client, schema: HttpBridgeConfigSchema, security: { allowAnonymous: true },
|
|
41
|
-
},
|
|
42
|
-
})
|
|
43
|
-
await node.register(bridge)
|
|
44
|
-
await node.attach(bridge.address, true)
|
|
45
|
-
|
|
46
|
-
const archivist = await MemoryArchivist.create({ config: { name: 'RootStorageArchivist', schema: MemoryArchivistConfigSchema } })
|
|
47
|
-
await node.register(archivist)
|
|
48
|
-
await node.attach(archivist.address, true)
|
|
49
|
-
|
|
50
|
-
const sentinel = await MemorySentinel.create({
|
|
51
|
-
config: {
|
|
52
|
-
name: 'MemorySentinel', schema: SentinelConfigSchema, synchronous: true, tasks: [],
|
|
53
|
-
},
|
|
54
|
-
})
|
|
55
|
-
await node.register(sentinel)
|
|
56
|
-
await node.attach(sentinel.address, true)
|
|
57
|
-
|
|
58
|
-
const archivist1 = await MemoryArchivist.create({ config: { name: 'RootStorageArchivist1', schema: MemoryArchivistConfigSchema } })
|
|
59
|
-
await node1.register(archivist1)
|
|
60
|
-
await node1.attach(archivist1.address, true)
|
|
61
|
-
|
|
62
|
-
await node.register(node1)
|
|
63
|
-
await node.attach(node1.address, true)
|
|
64
|
-
|
|
65
|
-
setNode(node)
|
|
66
|
-
} catch (e) {
|
|
67
|
-
console.error('Error Creating MemoryNode', e)
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
[],
|
|
71
|
-
)
|
|
72
|
-
|
|
73
|
-
const [wallet] = useWallet({ mnemonic: DefaultSeedPhrase })
|
|
74
|
-
|
|
75
|
-
return (
|
|
76
|
-
<WalletProvider rootWallet={wallet}>
|
|
77
|
-
<NodeProvider node={node}>
|
|
78
|
-
<CytoscapeInstanceProvider>
|
|
79
|
-
<Story {...args} />
|
|
80
|
-
</CytoscapeInstanceProvider>
|
|
81
|
-
</NodeProvider>
|
|
82
|
-
</WalletProvider>
|
|
83
|
-
)
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export default {
|
|
87
|
-
component: NodeRelationalGraphFlexBox,
|
|
88
|
-
title: 'node/renderer/coseBilkent/NodeRelationalGraph',
|
|
89
|
-
} as Meta
|
|
90
|
-
|
|
91
|
-
const Template: StoryFn<typeof NodeRelationalGraphFlexBox> = props => <NodeRelationalGraphFlexBox layout="cose-bilkent" {...props} />
|
|
92
|
-
|
|
93
|
-
const TemplateDescribe: StoryFn<typeof NodeRelationalGraphFlexBox> = (props) => {
|
|
94
|
-
const [node] = useWeakProvidedNode()
|
|
95
|
-
const elements = useCytoscapeElements(node)
|
|
96
|
-
const options = useCytoscapeOptions(elements)
|
|
97
|
-
return <NodeRelationalGraphFlexBox layout="cose-bilkent" options={options} {...props} />
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const TemplateCustomAddress: StoryFn<typeof NodeRelationalGraphFlexBox> = (props) => {
|
|
101
|
-
const [node] = useWeakNodeFromNode('ChildNode')
|
|
102
|
-
const elements = useCytoscapeElements(node)
|
|
103
|
-
const options = useCytoscapeOptions(elements)
|
|
104
|
-
return <NodeRelationalGraphFlexBox layout="cose-bilkent" options={options} {...props} />
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const TemplateProvidedNodeRenderer: StoryFn<typeof ProvidedNodeRenderer> = props => <ProvidedNodeRenderer layout="cose-bilkent" {...props} />
|
|
108
|
-
|
|
109
|
-
const TemplateAttachDetach: StoryFn<typeof NodeRelationalGraphFlexBox> = (props) => {
|
|
110
|
-
const [node] = useWeakNodeFromNode('ChildNode')
|
|
111
|
-
const elements = useCytoscapeElements(node)
|
|
112
|
-
const options = useCytoscapeOptions(elements)
|
|
113
|
-
const [idWitness, setIdWitness] = useState<IdWitness>()
|
|
114
|
-
|
|
115
|
-
useAsyncEffect(
|
|
116
|
-
async () => {
|
|
117
|
-
const witnessModule = await IdWitness.create({
|
|
118
|
-
config: {
|
|
119
|
-
name: 'IdWitness', salt: 'test', schema: IdWitnessConfigSchema,
|
|
120
|
-
},
|
|
121
|
-
})
|
|
122
|
-
setIdWitness(witnessModule)
|
|
123
|
-
},
|
|
124
|
-
[],
|
|
125
|
-
)
|
|
126
|
-
|
|
127
|
-
const handleAddWitness = async () => {
|
|
128
|
-
if (node && idWitness) {
|
|
129
|
-
const memoryNode = node.deref() as MemoryNode | undefined
|
|
130
|
-
await memoryNode?.register(idWitness as unknown as AttachableModuleInstance)
|
|
131
|
-
await memoryNode?.attach(idWitness.address, true)
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
const handleRemoveWitness = async () => {
|
|
136
|
-
if (node && idWitness) {
|
|
137
|
-
const memoryNode = node.deref() as MemoryNode | undefined
|
|
138
|
-
if (((await memoryNode?.registered()) ?? []).includes(idWitness.address)) {
|
|
139
|
-
await memoryNode?.unregister(idWitness as unknown as AttachableModuleInstance)
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
return (
|
|
145
|
-
<>
|
|
146
|
-
<ButtonGroup>
|
|
147
|
-
<Button onClick={handleAddWitness}>Add Witness</Button>
|
|
148
|
-
<Button onClick={handleRemoveWitness}>Remove Witness</Button>
|
|
149
|
-
</ButtonGroup>
|
|
150
|
-
<WithExtensions>
|
|
151
|
-
<NodeRelationalGraphFlexBox layout="cose-bilkent" options={options} {...props} />
|
|
152
|
-
</WithExtensions>
|
|
153
|
-
</>
|
|
154
|
-
)
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
const defaultProps = {
|
|
158
|
-
height: 'calc(100vh - 20px)',
|
|
159
|
-
width: '100%',
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
const Default = Template.bind({})
|
|
163
|
-
Default.args = {}
|
|
164
|
-
|
|
165
|
-
const WithData = Template.bind({})
|
|
166
|
-
WithData.args = { options, ...defaultProps }
|
|
167
|
-
|
|
168
|
-
const WithDescribe = TemplateDescribe.bind({})
|
|
169
|
-
WithDescribe.args = { ...defaultProps }
|
|
170
|
-
WithDescribe.decorators = [MemoryNodeDecorator]
|
|
171
|
-
|
|
172
|
-
const WithCustomAddress = TemplateCustomAddress.bind({})
|
|
173
|
-
WithCustomAddress.args = { ...defaultProps }
|
|
174
|
-
WithCustomAddress.decorators = [MemoryNodeDecorator]
|
|
175
|
-
|
|
176
|
-
const WithAttachDetach = TemplateAttachDetach.bind({})
|
|
177
|
-
WithAttachDetach.args = { ...defaultProps }
|
|
178
|
-
WithAttachDetach.decorators = [MemoryNodeDecorator]
|
|
179
|
-
|
|
180
|
-
const WithProvidedNodeRenderer = TemplateProvidedNodeRenderer.bind({})
|
|
181
|
-
WithProvidedNodeRenderer.args = { ...defaultProps }
|
|
182
|
-
WithProvidedNodeRenderer.decorators = [MemoryNodeDecorator]
|
|
183
|
-
|
|
184
|
-
export {
|
|
185
|
-
Default, WithAttachDetach, WithCustomAddress, WithData, WithDescribe, WithProvidedNodeRenderer,
|
|
186
|
-
}
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import { Button, ButtonGroup } from '@mui/material'
|
|
2
|
-
import type {
|
|
3
|
-
Decorator, Meta, StoryFn,
|
|
4
|
-
} from '@storybook/react-vite'
|
|
5
|
-
import { useAsyncEffect } from '@xylabs/react-async-effect'
|
|
6
|
-
import { MemoryArchivist, MemoryArchivistConfigSchema } from '@xyo-network/archivist-memory'
|
|
7
|
-
import { HttpBridge, HttpBridgeConfigSchema } from '@xyo-network/bridge-http'
|
|
8
|
-
import { IdWitness, IdWitnessConfigSchema } from '@xyo-network/id-plugin'
|
|
9
|
-
import { MemoryNode } from '@xyo-network/node-memory'
|
|
10
|
-
import { NodeConfigSchema } from '@xyo-network/node-model'
|
|
11
|
-
import {
|
|
12
|
-
NodeProvider, useWeakNodeFromNode, useWeakProvidedNode,
|
|
13
|
-
} from '@xyo-network/react-node'
|
|
14
|
-
import { DefaultSeedPhrase } from '@xyo-network/react-storybook'
|
|
15
|
-
import { useWallet, WalletProvider } from '@xyo-network/react-wallet'
|
|
16
|
-
import { SentinelConfigSchema } from '@xyo-network/sentinel'
|
|
17
|
-
import { MemorySentinel } from '@xyo-network/sentinel-memory'
|
|
18
|
-
import React, { useState } from 'react'
|
|
19
|
-
|
|
20
|
-
import { CytoscapeInstanceProvider } from '../../../contexts/index.ts'
|
|
21
|
-
import { useCytoscapeElements, useCytoscapeOptions } from '../../../hooks/index.ts'
|
|
22
|
-
import { WithExtensions } from '../../cytoscape-extensions/index.ts'
|
|
23
|
-
import { NodeRelationalGraphFlexBox } from './Graph.tsx'
|
|
24
|
-
import { ProvidedNodeRenderer } from './ProvidedNodeRenderer.tsx'
|
|
25
|
-
import { options } from './story/index.ts'
|
|
26
|
-
|
|
27
|
-
const client = { url: 'http://localhost:8080/node' }
|
|
28
|
-
|
|
29
|
-
const MemoryNodeDecorator: Decorator = (Story, args) => {
|
|
30
|
-
const [node, setNode] = useState<MemoryNode>()
|
|
31
|
-
|
|
32
|
-
useAsyncEffect(
|
|
33
|
-
async () => {
|
|
34
|
-
try {
|
|
35
|
-
const node = await MemoryNode.create({ config: { name: 'GlobalNode', schema: NodeConfigSchema } })
|
|
36
|
-
const node1 = await MemoryNode.create({ config: { name: 'ChildNode', schema: NodeConfigSchema } })
|
|
37
|
-
const bridge = await HttpBridge.create({
|
|
38
|
-
config: {
|
|
39
|
-
name: 'Bridge', client, schema: HttpBridgeConfigSchema, security: { allowAnonymous: true },
|
|
40
|
-
},
|
|
41
|
-
})
|
|
42
|
-
await node.register(bridge)
|
|
43
|
-
await node.attach(bridge.address, true)
|
|
44
|
-
|
|
45
|
-
const archivist = await MemoryArchivist.create({ config: { name: 'RootStorageArchivist', schema: MemoryArchivistConfigSchema } })
|
|
46
|
-
await node.register(archivist)
|
|
47
|
-
await node.attach(archivist.address, true)
|
|
48
|
-
|
|
49
|
-
const sentinel = await MemorySentinel.create({
|
|
50
|
-
config: {
|
|
51
|
-
name: 'MemorySentinel', schema: SentinelConfigSchema, synchronous: true, tasks: [],
|
|
52
|
-
},
|
|
53
|
-
})
|
|
54
|
-
await node.register(sentinel)
|
|
55
|
-
await node.attach(sentinel.address, true)
|
|
56
|
-
|
|
57
|
-
const archivist1 = await MemoryArchivist.create({ config: { name: 'RootStorageArchivist1', schema: MemoryArchivistConfigSchema } })
|
|
58
|
-
await node1.register(archivist1)
|
|
59
|
-
await node1.attach(archivist1.address, true)
|
|
60
|
-
|
|
61
|
-
await node.register(node1)
|
|
62
|
-
await node.attach(node1.address, true)
|
|
63
|
-
|
|
64
|
-
setNode(node)
|
|
65
|
-
} catch (e) {
|
|
66
|
-
console.error('Error Creating MemoryNode', e)
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
[],
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
const [wallet] = useWallet({ mnemonic: DefaultSeedPhrase })
|
|
73
|
-
|
|
74
|
-
return (
|
|
75
|
-
<WalletProvider rootWallet={wallet}>
|
|
76
|
-
<NodeProvider node={node}>
|
|
77
|
-
<CytoscapeInstanceProvider>
|
|
78
|
-
<Story {...args} />
|
|
79
|
-
</CytoscapeInstanceProvider>
|
|
80
|
-
</NodeProvider>
|
|
81
|
-
</WalletProvider>
|
|
82
|
-
)
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export default {
|
|
86
|
-
component: NodeRelationalGraphFlexBox,
|
|
87
|
-
title: 'node/renderer/dagre/NodeRelationalGraph',
|
|
88
|
-
} as Meta
|
|
89
|
-
|
|
90
|
-
const Template: StoryFn<typeof NodeRelationalGraphFlexBox> = props => <NodeRelationalGraphFlexBox layout="dagre" {...props} />
|
|
91
|
-
|
|
92
|
-
const TemplateDescribe: StoryFn<typeof NodeRelationalGraphFlexBox> = (props) => {
|
|
93
|
-
const [node] = useWeakProvidedNode()
|
|
94
|
-
const elements = useCytoscapeElements(node)
|
|
95
|
-
const options = useCytoscapeOptions(elements)
|
|
96
|
-
return <NodeRelationalGraphFlexBox layout="dagre" options={options} {...props} />
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const TemplateCustomAddress: StoryFn<typeof NodeRelationalGraphFlexBox> = (props) => {
|
|
100
|
-
const [node] = useWeakNodeFromNode('ChildNode')
|
|
101
|
-
const elements = useCytoscapeElements(node)
|
|
102
|
-
const options = useCytoscapeOptions(elements)
|
|
103
|
-
return <NodeRelationalGraphFlexBox layout="dagre" options={options} {...props} />
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const TemplateProvidedNodeRenderer: StoryFn<typeof ProvidedNodeRenderer> = props => <ProvidedNodeRenderer layout="dagre" {...props} />
|
|
107
|
-
|
|
108
|
-
const TemplateAttachDetach: StoryFn<typeof NodeRelationalGraphFlexBox> = (props) => {
|
|
109
|
-
const [node] = useWeakNodeFromNode('ChildNode')
|
|
110
|
-
const elements = useCytoscapeElements(node)
|
|
111
|
-
const options = useCytoscapeOptions(elements)
|
|
112
|
-
const [idWitness, setIdWitness] = useState<IdWitness>()
|
|
113
|
-
|
|
114
|
-
useAsyncEffect(
|
|
115
|
-
|
|
116
|
-
async () => {
|
|
117
|
-
const witnessModule = await IdWitness.create({
|
|
118
|
-
config: {
|
|
119
|
-
name: 'IdWitness', salt: 'test', schema: IdWitnessConfigSchema,
|
|
120
|
-
},
|
|
121
|
-
})
|
|
122
|
-
setIdWitness(witnessModule)
|
|
123
|
-
},
|
|
124
|
-
[],
|
|
125
|
-
)
|
|
126
|
-
|
|
127
|
-
const handleAddWitness = async () => {
|
|
128
|
-
if (node && idWitness) {
|
|
129
|
-
const memoryNode = node?.deref() as MemoryNode | undefined
|
|
130
|
-
await memoryNode?.register(idWitness)
|
|
131
|
-
await memoryNode?.attach(idWitness.address, true)
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
const handleRemoveWitness = async () => {
|
|
136
|
-
if (node && idWitness) {
|
|
137
|
-
const memoryNode = node?.deref() as MemoryNode | undefined
|
|
138
|
-
if (((await memoryNode?.registered()) ?? []).includes(idWitness.address)) {
|
|
139
|
-
await memoryNode?.unregister(idWitness)
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
return (
|
|
145
|
-
<>
|
|
146
|
-
<ButtonGroup>
|
|
147
|
-
<Button onClick={handleAddWitness}>Add Witness</Button>
|
|
148
|
-
<Button onClick={handleRemoveWitness}>Remove Witness</Button>
|
|
149
|
-
</ButtonGroup>
|
|
150
|
-
<WithExtensions>
|
|
151
|
-
<NodeRelationalGraphFlexBox layout="dagre" options={options} {...props} />
|
|
152
|
-
</WithExtensions>
|
|
153
|
-
</>
|
|
154
|
-
)
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
const defaultProps = {
|
|
158
|
-
height: 'calc(100vh - 20px)',
|
|
159
|
-
width: '100%',
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
const Default = Template.bind({})
|
|
163
|
-
Default.args = {}
|
|
164
|
-
|
|
165
|
-
const WithData = Template.bind({})
|
|
166
|
-
WithData.args = { options, ...defaultProps }
|
|
167
|
-
|
|
168
|
-
const WithDescribe = TemplateDescribe.bind({})
|
|
169
|
-
WithDescribe.args = { ...defaultProps }
|
|
170
|
-
WithDescribe.decorators = [MemoryNodeDecorator]
|
|
171
|
-
|
|
172
|
-
const WithCustomAddress = TemplateCustomAddress.bind({})
|
|
173
|
-
WithCustomAddress.args = { ...defaultProps }
|
|
174
|
-
WithCustomAddress.decorators = [MemoryNodeDecorator]
|
|
175
|
-
|
|
176
|
-
const WithAttachDetach = TemplateAttachDetach.bind({})
|
|
177
|
-
WithAttachDetach.args = { ...defaultProps }
|
|
178
|
-
WithAttachDetach.decorators = [MemoryNodeDecorator]
|
|
179
|
-
|
|
180
|
-
const WithProvidedNodeRenderer = TemplateProvidedNodeRenderer.bind({})
|
|
181
|
-
WithProvidedNodeRenderer.args = { ...defaultProps }
|
|
182
|
-
WithProvidedNodeRenderer.decorators = [MemoryNodeDecorator]
|
|
183
|
-
|
|
184
|
-
export {
|
|
185
|
-
Default, WithAttachDetach, WithCustomAddress, WithData, WithDescribe, WithProvidedNodeRenderer,
|
|
186
|
-
}
|