@xyo-network/react-node-renderer 2.48.1 → 2.48.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/dist/cjs/Cytoscape/CytoscapeElements.js +33 -6
  2. package/dist/cjs/Cytoscape/CytoscapeElements.js.map +1 -1
  3. package/dist/cjs/Cytoscape/CytoscapeIcons.js +2 -0
  4. package/dist/cjs/Cytoscape/CytoscapeIcons.js.map +1 -1
  5. package/dist/cjs/Cytoscape/CytoscapeStyles.js.map +1 -1
  6. package/dist/cjs/Cytoscape/index.js +1 -0
  7. package/dist/cjs/Cytoscape/index.js.map +1 -1
  8. package/dist/cjs/Cytoscape/lib/CyNodeModuleTypes.js +3 -0
  9. package/dist/cjs/Cytoscape/lib/CyNodeModuleTypes.js.map +1 -0
  10. package/dist/cjs/Cytoscape/lib/encodeSvg.js +19 -0
  11. package/dist/cjs/Cytoscape/lib/encodeSvg.js.map +1 -0
  12. package/dist/cjs/Cytoscape/lib/iconMap.js +14 -0
  13. package/dist/cjs/Cytoscape/lib/iconMap.js.map +1 -0
  14. package/dist/cjs/Cytoscape/lib/index.js +8 -0
  15. package/dist/cjs/Cytoscape/lib/index.js.map +1 -0
  16. package/dist/cjs/{lib/utils.js → Cytoscape/lib/parseModuleType.js} +6 -17
  17. package/dist/cjs/Cytoscape/lib/parseModuleType.js.map +1 -0
  18. package/dist/cjs/hooks/cytoscape/useCytoscapeElements.js +13 -30
  19. package/dist/cjs/hooks/cytoscape/useCytoscapeElements.js.map +1 -1
  20. package/dist/cjs/hooks/cytoscape/useIcons.js +2 -3
  21. package/dist/cjs/hooks/cytoscape/useIcons.js.map +1 -1
  22. package/dist/cjs/index.js +0 -1
  23. package/dist/cjs/index.js.map +1 -1
  24. package/dist/docs.json +442 -136
  25. package/dist/esm/Cytoscape/CytoscapeElements.js +25 -3
  26. package/dist/esm/Cytoscape/CytoscapeElements.js.map +1 -1
  27. package/dist/esm/Cytoscape/CytoscapeIcons.js +2 -0
  28. package/dist/esm/Cytoscape/CytoscapeIcons.js.map +1 -1
  29. package/dist/esm/Cytoscape/CytoscapeStyles.js.map +1 -1
  30. package/dist/esm/Cytoscape/index.js +1 -0
  31. package/dist/esm/Cytoscape/index.js.map +1 -1
  32. package/dist/esm/Cytoscape/lib/CyNodeModuleTypes.js +2 -0
  33. package/dist/esm/Cytoscape/lib/CyNodeModuleTypes.js.map +1 -0
  34. package/dist/esm/Cytoscape/lib/encodeSvg.js +15 -0
  35. package/dist/esm/Cytoscape/lib/encodeSvg.js.map +1 -0
  36. package/dist/esm/Cytoscape/lib/iconMap.js +10 -0
  37. package/dist/esm/Cytoscape/lib/iconMap.js.map +1 -0
  38. package/dist/esm/Cytoscape/lib/index.js +5 -0
  39. package/dist/esm/Cytoscape/lib/index.js.map +1 -0
  40. package/dist/esm/{lib/utils.js → Cytoscape/lib/parseModuleType.js} +5 -15
  41. package/dist/esm/Cytoscape/lib/parseModuleType.js.map +1 -0
  42. package/dist/esm/hooks/cytoscape/useCytoscapeElements.js +10 -29
  43. package/dist/esm/hooks/cytoscape/useCytoscapeElements.js.map +1 -1
  44. package/dist/esm/hooks/cytoscape/useIcons.js +2 -3
  45. package/dist/esm/hooks/cytoscape/useIcons.js.map +1 -1
  46. package/dist/esm/index.js +0 -1
  47. package/dist/esm/index.js.map +1 -1
  48. package/dist/types/Cytoscape/CytoscapeElements.d.ts +2 -1
  49. package/dist/types/Cytoscape/CytoscapeElements.d.ts.map +1 -1
  50. package/dist/types/Cytoscape/CytoscapeIcons.d.ts +2 -2
  51. package/dist/types/Cytoscape/CytoscapeIcons.d.ts.map +1 -1
  52. package/dist/types/Cytoscape/CytoscapeStyles.d.ts +2 -2
  53. package/dist/types/Cytoscape/CytoscapeStyles.d.ts.map +1 -1
  54. package/dist/types/Cytoscape/index.d.ts +1 -0
  55. package/dist/types/Cytoscape/index.d.ts.map +1 -1
  56. package/dist/types/Cytoscape/lib/CyNodeModuleTypes.d.ts +2 -0
  57. package/dist/types/Cytoscape/lib/CyNodeModuleTypes.d.ts.map +1 -0
  58. package/dist/types/Cytoscape/lib/encodeSvg.d.ts +3 -0
  59. package/dist/types/Cytoscape/lib/encodeSvg.d.ts.map +1 -0
  60. package/dist/types/Cytoscape/lib/iconMap.d.ts +3 -0
  61. package/dist/types/Cytoscape/lib/iconMap.d.ts.map +1 -0
  62. package/dist/types/Cytoscape/lib/index.d.ts +5 -0
  63. package/dist/types/Cytoscape/lib/index.d.ts.map +1 -0
  64. package/dist/types/Cytoscape/lib/parseModuleType.d.ts +3 -0
  65. package/dist/types/Cytoscape/lib/parseModuleType.d.ts.map +1 -0
  66. package/dist/types/contexts/CytoscapeInstance/Provider.d.ts +1 -1
  67. package/dist/types/contexts/CytoscapeInstance/Provider.d.ts.map +1 -1
  68. package/dist/types/hooks/cytoscape/useCytoscapeElements.d.ts.map +1 -1
  69. package/dist/types/hooks/cytoscape/useIcons.d.ts +2 -2
  70. package/dist/types/hooks/cytoscape/useIcons.d.ts.map +1 -1
  71. package/dist/types/index.d.ts +0 -1
  72. package/dist/types/index.d.ts.map +1 -1
  73. package/package.json +9 -8
  74. package/src/Cytoscape/CytoscapeElements.ts +27 -2
  75. package/src/Cytoscape/CytoscapeIcons.tsx +4 -2
  76. package/src/Cytoscape/CytoscapeStyles.ts +3 -3
  77. package/src/Cytoscape/index.ts +1 -0
  78. package/src/Cytoscape/lib/CyNodeModuleTypes.ts +1 -0
  79. package/src/Cytoscape/lib/encodeSvg.ts +19 -0
  80. package/src/Cytoscape/lib/iconMap.ts +11 -0
  81. package/src/Cytoscape/lib/index.ts +4 -0
  82. package/src/Cytoscape/lib/parseModuleType.ts +36 -0
  83. package/src/components/RelationalGraph.stories.tsx +10 -8
  84. package/src/components/RelationalGraphEvents.stories.tsx +4 -4
  85. package/src/contexts/CytoscapeInstance/Provider.tsx +1 -1
  86. package/src/hooks/cytoscape/useCytoscapeElements.ts +10 -32
  87. package/src/hooks/cytoscape/useIcons.tsx +3 -4
  88. package/src/index.ts +0 -1
  89. package/dist/cjs/lib/index.js +0 -5
  90. package/dist/cjs/lib/index.js.map +0 -1
  91. package/dist/cjs/lib/utils.js.map +0 -1
  92. package/dist/esm/lib/index.js +0 -2
  93. package/dist/esm/lib/index.js.map +0 -1
  94. package/dist/esm/lib/utils.js.map +0 -1
  95. package/dist/types/lib/index.d.ts +0 -2
  96. package/dist/types/lib/index.d.ts.map +0 -1
  97. package/dist/types/lib/utils.d.ts +0 -5
  98. package/dist/types/lib/utils.d.ts.map +0 -1
  99. package/src/lib/index.ts +0 -1
  100. package/src/lib/utils.ts +0 -52
@@ -1,6 +1,6 @@
1
1
  import { Stylesheet } from 'cytoscape'
2
2
 
3
- import { CyNodeIcons } from './CytoscapeIcons'
3
+ import { CyNodeModuleTypes } from './lib'
4
4
 
5
5
  export const NodeIdStyles = (color?: string): Stylesheet => ({
6
6
  selector: 'node[id]',
@@ -12,13 +12,13 @@ export const NodeIdStyles = (color?: string): Stylesheet => ({
12
12
  },
13
13
  })
14
14
 
15
- export const NodeStyled = (icons: Record<CyNodeIcons, string>, bgColor?: string): Stylesheet => ({
15
+ export const NodeStyled = (icons: Record<CyNodeModuleTypes, string>, bgColor?: string): Stylesheet => ({
16
16
  selector: 'node',
17
17
  style: {
18
18
  'background-color': bgColor,
19
19
  'background-height': '75%',
20
20
  // TODO - make dynamic
21
- 'background-image': (elem) => icons[elem.data('type') as CyNodeIcons],
21
+ 'background-image': (elem) => icons[elem.data('type') as CyNodeModuleTypes],
22
22
  'background-image-smoothing': 'yes',
23
23
  'background-width': '75%',
24
24
  label: 'data(id)',
@@ -1,3 +1,4 @@
1
1
  export * from './CytoscapeElements'
2
2
  export * from './CytoscapeIcons'
3
3
  export * from './CytoscapeStyles'
4
+ export * from './lib'
@@ -0,0 +1 @@
1
+ export type CyNodeModuleTypes = 'archivist' | 'bridge' | 'diviner' | 'module' | 'node' | 'witness' | 'sentinel'
@@ -0,0 +1,19 @@
1
+ import { ReactElement } from 'react'
2
+ // eslint-disable-next-line import/no-internal-modules
3
+ import { renderToStaticMarkup } from 'react-dom/server'
4
+
5
+ const dataUri = 'data:image/svg+xml,'
6
+
7
+ export const encodeSvg = (reactElement: ReactElement, color?: string) => {
8
+ const svgString = renderToStaticMarkup(reactElement)
9
+
10
+ const doc = new DOMParser().parseFromString(svgString, 'text/html')
11
+ const svgElement = doc.getElementsByTagName('svg')[0]
12
+ if (svgElement) {
13
+ svgElement.setAttribute('xmlns', 'http://www.w3.org/2000/svg')
14
+ svgElement.setAttribute('height', '100')
15
+ svgElement.style.fill = color ?? 'black'
16
+ }
17
+
18
+ return `${dataUri}${window.encodeURIComponent(svgElement.outerHTML)}`
19
+ }
@@ -0,0 +1,11 @@
1
+ import { CyNodeModuleTypes } from './CyNodeModuleTypes'
2
+
3
+ export const generateIconMap: () => Record<CyNodeModuleTypes, string> = () => ({
4
+ archivist: '',
5
+ bridge: '',
6
+ diviner: '',
7
+ module: '',
8
+ node: '',
9
+ sentinel: '',
10
+ witness: '',
11
+ })
@@ -0,0 +1,4 @@
1
+ export * from './CyNodeModuleTypes'
2
+ export * from './encodeSvg'
3
+ export * from './iconMap'
4
+ export * from './parseModuleType'
@@ -0,0 +1,36 @@
1
+ import { CyNodeModuleTypes } from './CyNodeModuleTypes'
2
+
3
+ export const parseModuleType = (queries?: string[]): CyNodeModuleTypes => {
4
+ let type: CyNodeModuleTypes = 'module'
5
+ if (queries) {
6
+ for (let i = 0; i < queries.length; i++) {
7
+ if (queries[i].includes('archivist')) {
8
+ type = 'archivist'
9
+ break
10
+ }
11
+ if (queries[i].includes('bridge')) {
12
+ type = 'bridge'
13
+ break
14
+ }
15
+ if (queries[i].includes('diviner')) {
16
+ type = 'diviner'
17
+ break
18
+ }
19
+ if (queries[i].includes('node')) {
20
+ type = 'node'
21
+ break
22
+ }
23
+ if (queries[i].includes('sentinel')) {
24
+ type = 'sentinel'
25
+ break
26
+ }
27
+ if (queries[i].includes('witness')) {
28
+ type = 'witness'
29
+ break
30
+ }
31
+ type = 'module'
32
+ }
33
+ return type
34
+ }
35
+ return 'module'
36
+ }
@@ -1,6 +1,6 @@
1
1
  import { Button, ButtonGroup } from '@mui/material'
2
- import { ComponentStory, DecoratorFn, Meta } from '@storybook/react'
3
- import { useAsyncEffect } from '@xylabs/react-shared'
2
+ import { Decorator, Meta, StoryFn } from '@storybook/react'
3
+ import { useAsyncEffect } from '@xylabs/react-async-effect'
4
4
  import { HDWallet } from '@xyo-network/account'
5
5
  import { ArchivistConfigSchema, MemoryArchivist } from '@xyo-network/archivist'
6
6
  import { HttpBridge, HttpBridgeConfigSchema } from '@xyo-network/bridge'
@@ -19,7 +19,7 @@ import { options } from './story'
19
19
  const nodeUrl = 'http://localhost:8080/node'
20
20
  const randomWallet = HDWallet.fromMnemonic(DefaultSeedPhrase)
21
21
 
22
- export const MemoryNodeDecorator: DecoratorFn = (Story, args) => {
22
+ export const MemoryNodeDecorator: Decorator = (Story, args) => {
23
23
  const [node, setNode] = useState<MemoryNode>()
24
24
 
25
25
  useAsyncEffect(
@@ -72,16 +72,16 @@ export default {
72
72
  title: 'node/renderer/NodeRelationalGraph',
73
73
  } as Meta
74
74
 
75
- const Template: ComponentStory<typeof NodeRelationalGraph> = (props) => <NodeRelationalGraph {...props} />
75
+ const Template: StoryFn<typeof NodeRelationalGraph> = (props) => <NodeRelationalGraph {...props} />
76
76
 
77
- const TemplateDescribe: ComponentStory<typeof NodeRelationalGraph> = (props) => {
77
+ const TemplateDescribe: StoryFn<typeof NodeRelationalGraph> = (props) => {
78
78
  const [node] = useProvidedWrappedNode()
79
79
  const elements = useCytoscapeElements(node)
80
80
  const options = useCytoscapeOptions(elements)
81
81
  return <NodeRelationalGraph options={options} {...props} />
82
82
  }
83
83
 
84
- const TemplateCustomAddress: ComponentStory<typeof NodeRelationalGraph> = (props) => {
84
+ const TemplateCustomAddress: StoryFn<typeof NodeRelationalGraph> = (props) => {
85
85
  const [node] = useModule('ChildNode')
86
86
  const wrappedNode = useMemo(() => (node ? NodeWrapper.wrap(node) : undefined), [node])
87
87
  const elements = useCytoscapeElements(wrappedNode)
@@ -89,7 +89,7 @@ const TemplateCustomAddress: ComponentStory<typeof NodeRelationalGraph> = (props
89
89
  return <NodeRelationalGraph options={options} {...props} />
90
90
  }
91
91
 
92
- const TemplateAttachDetach: ComponentStory<typeof NodeRelationalGraph> = (props) => {
92
+ const TemplateAttachDetach: StoryFn<typeof NodeRelationalGraph> = (props) => {
93
93
  const [node] = useModule('ChildNode')
94
94
  const wrappedNode = useMemo(() => (node ? NodeWrapper.wrap(node) : undefined), [node])
95
95
  const elements = useCytoscapeElements(wrappedNode)
@@ -116,7 +116,9 @@ const TemplateAttachDetach: ComponentStory<typeof NodeRelationalGraph> = (props)
116
116
  const handleRemoveWitness = async () => {
117
117
  if (wrappedNode && idWitness) {
118
118
  const memoryNode = wrappedNode as NodeWrapper<MemoryNode>
119
- await memoryNode.module.unregister(idWitness)
119
+ if (await (await memoryNode.registered()).includes(idWitness.address)) {
120
+ await memoryNode.module.unregister(idWitness)
121
+ }
120
122
  }
121
123
  }
122
124
 
@@ -1,5 +1,5 @@
1
- import { ComponentStory, DecoratorFn, Meta } from '@storybook/react'
2
- import { useAsyncEffect } from '@xylabs/react-shared'
1
+ import { Decorator, Meta, StoryFn } from '@storybook/react'
2
+ import { useAsyncEffect } from '@xylabs/react-async-effect'
3
3
  import { HDWallet } from '@xyo-network/account'
4
4
  import { ArchivistConfigSchema, MemoryArchivist } from '@xyo-network/archivist'
5
5
  import { MemoryNode, NodeConfigSchema } from '@xyo-network/node'
@@ -15,7 +15,7 @@ import { NodeRelationalGraph } from './RelationalGraph'
15
15
 
16
16
  const randomWallet = HDWallet.fromMnemonic(DefaultSeedPhrase)
17
17
 
18
- const MemoryNodeDecorator: DecoratorFn = (Story, args) => {
18
+ const MemoryNodeDecorator: Decorator = (Story, args) => {
19
19
  const [node, setNode] = useState<MemoryNode>()
20
20
 
21
21
  useAsyncEffect(
@@ -49,7 +49,7 @@ export default {
49
49
  title: 'node/renderer/NodeRelationalGraphEvents',
50
50
  } as Meta
51
51
 
52
- const Template: ComponentStory<typeof NodeRelationalGraph> = (props) => {
52
+ const Template: StoryFn<typeof NodeRelationalGraph> = (props) => {
53
53
  const [node] = useProvidedWrappedNode()
54
54
  const elements = useCytoscapeElements(node)
55
55
  const options = useCytoscapeOptions(elements)
@@ -1,4 +1,4 @@
1
- import { WithChildren } from '@xylabs/react-shared'
1
+ import type { WithChildren } from '@xylabs/react-shared'
2
2
  import { Core } from 'cytoscape'
3
3
  import { useEffect, useState } from 'react'
4
4
 
@@ -1,8 +1,8 @@
1
- import { useAsyncEffect } from '@xylabs/react-shared'
1
+ import { useAsyncEffect } from '@xylabs/react-async-effect'
2
2
  import { EventUnsubscribeFunction } from '@xyo-network/module'
3
3
  import { NodeWrapper } from '@xyo-network/node'
4
4
  import { ElementDefinition } from 'cytoscape'
5
- import { useCallback, useEffect, useState } from 'react'
5
+ import { useEffect, useState } from 'react'
6
6
 
7
7
  import { CytoscapeElements } from '../../Cytoscape'
8
8
 
@@ -13,39 +13,15 @@ import { CytoscapeElements } from '../../Cytoscape'
13
13
  export const useCytoscapeElements = (targetNode?: NodeWrapper) => {
14
14
  const [elements, setElements] = useState<ElementDefinition[]>([])
15
15
 
16
- const buildElements = useCallback(async (wrapper: NodeWrapper) => {
17
- try {
18
- const [description, newRootNode] = await CytoscapeElements.buildRootNode(wrapper)
19
- const newElements = [newRootNode]
20
-
21
- const children = description.children
22
- await Promise.allSettled(
23
- (children ?? [])?.map(async (address) => {
24
- try {
25
- const newNode = await CytoscapeElements.buildChild(wrapper, address)
26
- newElements.push(newNode)
27
-
28
- const newEdge = CytoscapeElements.buildEdge(newRootNode, newNode)
29
- newElements.push(newEdge)
30
- } catch (e) {
31
- console.error('Error parsing children', e)
32
- }
33
- }),
34
- )
35
- setElements(newElements)
36
- } catch (e) {
37
- console.error('Error Getting initial description', e)
38
- }
39
- }, [])
40
-
41
16
  useAsyncEffect(
42
17
  // eslint-disable-next-line react-hooks/exhaustive-deps
43
18
  async () => {
44
19
  if (targetNode) {
45
- await buildElements(targetNode)
20
+ const newElements = (await CytoscapeElements.buildElements(targetNode)) ?? []
21
+ setElements(newElements)
46
22
  }
47
23
  },
48
- [buildElements, targetNode],
24
+ [targetNode],
49
25
  )
50
26
 
51
27
  useEffect(() => {
@@ -54,10 +30,12 @@ export const useCytoscapeElements = (targetNode?: NodeWrapper) => {
54
30
 
55
31
  if (targetNode) {
56
32
  attachedListener = targetNode.on('moduleAttached', async () => {
57
- await buildElements(targetNode)
33
+ const newElements = (await CytoscapeElements.buildElements(targetNode)) ?? []
34
+ setElements(newElements)
58
35
  })
59
36
  detachedListener = targetNode.on('moduleDetached', async () => {
60
- await buildElements(targetNode)
37
+ const newElements = (await CytoscapeElements.buildElements(targetNode)) ?? []
38
+ setElements(newElements)
61
39
  })
62
40
  }
63
41
 
@@ -65,7 +43,7 @@ export const useCytoscapeElements = (targetNode?: NodeWrapper) => {
65
43
  attachedListener?.()
66
44
  detachedListener?.()
67
45
  }
68
- }, [buildElements, targetNode])
46
+ }, [targetNode])
69
47
 
70
48
  return elements
71
49
  }
@@ -1,16 +1,15 @@
1
1
  import { useTheme } from '@mui/material'
2
2
  import { useMemo } from 'react'
3
3
 
4
- import { CyIconSet, CyNodeIcons } from '../../Cytoscape'
5
- import { encodeSvg } from '../../lib'
4
+ import { CyIconSet, CyNodeModuleTypes, encodeSvg, generateIconMap } from '../../Cytoscape'
6
5
 
7
6
  export const useIcons = () => {
8
7
  const theme = useTheme()
9
8
  const icons = useMemo(() => {
10
- const iconMap: Record<CyNodeIcons, string> = { archivist: '', diviner: '', module: '', node: '', sentinel: '', witness: '' }
9
+ const iconMap = generateIconMap()
11
10
  return Object.entries(CyIconSet).reduce((acc, [name, IconComponent]) => {
12
11
  const icon = <IconComponent fontSize="small" />
13
- acc[name as CyNodeIcons] = encodeSvg(icon, theme.palette.getContrastText(theme.palette.text.primary))
12
+ acc[name as CyNodeModuleTypes] = encodeSvg(icon, theme.palette.getContrastText(theme.palette.text.primary))
14
13
  return acc
15
14
  }, iconMap)
16
15
  }, [theme.palette])
package/src/index.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  export * from './components'
2
2
  export * from './Cytoscape'
3
3
  export * from './hooks'
4
- export * from './lib'
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./utils"), exports);
5
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/index.ts"],"names":[],"mappings":";;;AAAA,kDAAuB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/lib/utils.ts"],"names":[],"mappings":";;;AACA,sDAAsD;AACtD,6CAAuD;AAIvD,MAAM,OAAO,GAAG,qBAAqB,CAAA;AAE9B,MAAM,SAAS,GAAG,CAAC,YAA0B,EAAE,KAAc,EAAE,EAAE;IACtE,MAAM,SAAS,GAAG,IAAA,6BAAoB,EAAC,YAAY,CAAC,CAAA;IAEpD,MAAM,GAAG,GAAG,IAAI,SAAS,EAAE,CAAC,eAAe,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;IACnE,MAAM,UAAU,GAAG,GAAG,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;IACrD,IAAI,UAAU,EAAE;QACd,UAAU,CAAC,YAAY,CAAC,OAAO,EAAE,4BAA4B,CAAC,CAAA;QAC9D,UAAU,CAAC,YAAY,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAA;QACxC,UAAU,CAAC,KAAK,CAAC,IAAI,GAAG,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,OAAO,CAAA;KACzC;IAED,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC,kBAAkB,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAA;AACvE,CAAC,CAAA;AAZY,QAAA,SAAS,aAYrB;AAEM,MAAM,eAAe,GAAG,CAAC,OAAkB,EAAe,EAAE;IACjE,IAAI,IAAI,GAAgB,QAAQ,CAAA;IAChC,IAAI,OAAO,EAAE;QACX,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACvC,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;gBACpC,IAAI,GAAG,WAAW,CAAA;gBAClB,MAAK;aACN;YACD,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;gBAClC,IAAI,GAAG,SAAS,CAAA;gBAChB,MAAK;aACN;YACD,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;gBAC/B,IAAI,GAAG,MAAM,CAAA;gBACb,MAAK;aACN;YACD,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;gBACnC,IAAI,GAAG,UAAU,CAAA;gBACjB,MAAK;aACN;YACD,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;gBAClC,IAAI,GAAG,SAAS,CAAA;gBAChB,MAAK;aACN;YACD,IAAI,GAAG,QAAQ,CAAA;SAChB;QACD,OAAO,IAAI,CAAA;KACZ;IACD,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA;AA7BY,QAAA,eAAe,mBA6B3B"}
@@ -1,2 +0,0 @@
1
- export * from './utils';
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/lib/utils.ts"],"names":[],"mappings":"AACA,sDAAsD;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAIvD,MAAM,OAAO,GAAG,qBAAqB,CAAA;AAErC,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,YAA0B,EAAE,KAAc,EAAE,EAAE;IACtE,MAAM,SAAS,GAAG,oBAAoB,CAAC,YAAY,CAAC,CAAA;IAEpD,MAAM,GAAG,GAAG,IAAI,SAAS,EAAE,CAAC,eAAe,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;IACnE,MAAM,UAAU,GAAG,GAAG,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;IACrD,IAAI,UAAU,EAAE;QACd,UAAU,CAAC,YAAY,CAAC,OAAO,EAAE,4BAA4B,CAAC,CAAA;QAC9D,UAAU,CAAC,YAAY,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAA;QACxC,UAAU,CAAC,KAAK,CAAC,IAAI,GAAG,KAAK,IAAI,OAAO,CAAA;KACzC;IAED,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC,kBAAkB,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAA;AACvE,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,OAAkB,EAAe,EAAE;IACjE,IAAI,IAAI,GAAgB,QAAQ,CAAA;IAChC,IAAI,OAAO,EAAE;QACX,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACvC,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;gBACpC,IAAI,GAAG,WAAW,CAAA;gBAClB,MAAK;aACN;YACD,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;gBAClC,IAAI,GAAG,SAAS,CAAA;gBAChB,MAAK;aACN;YACD,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;gBAC/B,IAAI,GAAG,MAAM,CAAA;gBACb,MAAK;aACN;YACD,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;gBACnC,IAAI,GAAG,UAAU,CAAA;gBACjB,MAAK;aACN;YACD,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;gBAClC,IAAI,GAAG,SAAS,CAAA;gBAChB,MAAK;aACN;YACD,IAAI,GAAG,QAAQ,CAAA;SAChB;QACD,OAAO,IAAI,CAAA;KACZ;IACD,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA"}
@@ -1,2 +0,0 @@
1
- export * from './utils';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA"}
@@ -1,5 +0,0 @@
1
- import { ReactElement } from 'react';
2
- import { CyNodeIcons } from '../Cytoscape';
3
- export declare const encodeSvg: (reactElement: ReactElement, color?: string) => string;
4
- export declare const parseModuleType: (queries?: string[]) => CyNodeIcons;
5
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAIpC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAI1C,eAAO,MAAM,SAAS,iBAAkB,YAAY,UAAU,MAAM,WAYnE,CAAA;AAED,eAAO,MAAM,eAAe,aAAc,MAAM,EAAE,KAAG,WA6BpD,CAAA"}
package/src/lib/index.ts DELETED
@@ -1 +0,0 @@
1
- export * from './utils'
package/src/lib/utils.ts DELETED
@@ -1,52 +0,0 @@
1
- import { ReactElement } from 'react'
2
- // eslint-disable-next-line import/no-internal-modules
3
- import { renderToStaticMarkup } from 'react-dom/server'
4
-
5
- import { CyNodeIcons } from '../Cytoscape'
6
-
7
- const dataUri = 'data:image/svg+xml,'
8
-
9
- export const encodeSvg = (reactElement: ReactElement, color?: string) => {
10
- const svgString = renderToStaticMarkup(reactElement)
11
-
12
- const doc = new DOMParser().parseFromString(svgString, 'text/html')
13
- const svgElement = doc.getElementsByTagName('svg')[0]
14
- if (svgElement) {
15
- svgElement.setAttribute('xmlns', 'http://www.w3.org/2000/svg')
16
- svgElement.setAttribute('height', '100')
17
- svgElement.style.fill = color ?? 'black'
18
- }
19
-
20
- return `${dataUri}${window.encodeURIComponent(svgElement.outerHTML)}`
21
- }
22
-
23
- export const parseModuleType = (queries?: string[]): CyNodeIcons => {
24
- let type: CyNodeIcons = 'module'
25
- if (queries) {
26
- for (let i = 0; i < queries.length; i++) {
27
- if (queries[i].includes('archivist')) {
28
- type = 'archivist'
29
- break
30
- }
31
- if (queries[i].includes('diviner')) {
32
- type = 'diviner'
33
- break
34
- }
35
- if (queries[i].includes('node')) {
36
- type = 'node'
37
- break
38
- }
39
- if (queries[i].includes('sentinel')) {
40
- type = 'sentinel'
41
- break
42
- }
43
- if (queries[i].includes('witness')) {
44
- type = 'witness'
45
- break
46
- }
47
- type = 'module'
48
- }
49
- return type
50
- }
51
- return 'module'
52
- }