@xyo-network/react-node-renderer 2.47.39 → 2.47.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/hooks/cytoscape/useCytoscapeElements.js +11 -35
- package/dist/cjs/hooks/cytoscape/useCytoscapeElements.js.map +1 -1
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/docs.json +1983 -265
- package/dist/esm/hooks/cytoscape/useCytoscapeElements.js +12 -36
- package/dist/esm/hooks/cytoscape/useCytoscapeElements.js.map +1 -1
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/types/hooks/cytoscape/useCytoscapeElements.d.ts +2 -1
- package/dist/types/hooks/cytoscape/useCytoscapeElements.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +5 -6
- package/src/components/RelationalGraph.stories.tsx +8 -5
- package/src/hooks/cytoscape/useCytoscapeElements.ts +12 -33
- package/src/index.ts +2 -0
|
@@ -3,66 +3,42 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useCytoscapeElements = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_shared_1 = require("@xylabs/react-shared");
|
|
6
|
-
const node_1 = require("@xyo-network/node");
|
|
7
|
-
const react_node_1 = require("@xyo-network/react-node");
|
|
8
6
|
const react_1 = require("react");
|
|
9
7
|
const Cytoscape_1 = require("../../Cytoscape");
|
|
10
8
|
/**
|
|
11
9
|
* Note: Relies on describe but could eventually be converted to a discover call
|
|
12
10
|
* Logic would be similar to what the bridge does
|
|
13
11
|
*/
|
|
14
|
-
const useCytoscapeElements = (
|
|
15
|
-
const [node] = (0, react_node_1.useProvidedWrappedNode)();
|
|
16
|
-
const [module, moduleError] = (0, react_node_1.useModule)(nodeAddressOrName);
|
|
12
|
+
const useCytoscapeElements = (targetNode) => {
|
|
17
13
|
const [elements, setElements] = (0, react_1.useState)([]);
|
|
18
|
-
const [refresh, setRefresh] = (0, react_1.useState)(1);
|
|
19
|
-
(0, react_1.useEffect)(() => {
|
|
20
|
-
if (moduleError)
|
|
21
|
-
onModuleError === null || onModuleError === void 0 ? void 0 : onModuleError(moduleError);
|
|
22
|
-
}, [moduleError, onModuleError]);
|
|
23
14
|
(0, react_shared_1.useAsyncEffect)(
|
|
24
15
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
25
|
-
(
|
|
16
|
+
() => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
26
17
|
var _a;
|
|
27
|
-
if (
|
|
28
|
-
const wrappedNode = nodeAddressOrName ? node_1.NodeWrapper.wrap(module) : node;
|
|
29
|
-
if (!wrappedNode) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
18
|
+
if (targetNode) {
|
|
32
19
|
try {
|
|
33
|
-
const [description, newRootNode] = yield Cytoscape_1.CytoscapeElements.buildRootNode(
|
|
34
|
-
|
|
35
|
-
setElements(() => [newRootNode]);
|
|
20
|
+
const [description, newRootNode] = yield Cytoscape_1.CytoscapeElements.buildRootNode(targetNode);
|
|
21
|
+
const newElements = [newRootNode];
|
|
36
22
|
const children = description.children;
|
|
37
23
|
yield Promise.allSettled((_a = (children !== null && children !== void 0 ? children : [])) === null || _a === void 0 ? void 0 : _a.map((address) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
38
24
|
try {
|
|
39
|
-
const newNode = yield Cytoscape_1.CytoscapeElements.buildChild(
|
|
40
|
-
|
|
41
|
-
setElements((previous) => [...previous, newNode]);
|
|
25
|
+
const newNode = yield Cytoscape_1.CytoscapeElements.buildChild(targetNode, address);
|
|
26
|
+
newElements.push(newNode);
|
|
42
27
|
const newEdge = Cytoscape_1.CytoscapeElements.buildEdge(newRootNode, newNode);
|
|
43
|
-
|
|
44
|
-
setElements((previous) => [...previous, newEdge]);
|
|
28
|
+
newElements.push(newEdge);
|
|
45
29
|
}
|
|
46
30
|
catch (e) {
|
|
47
31
|
console.error('Error parsing children', e);
|
|
48
32
|
}
|
|
49
33
|
})));
|
|
34
|
+
setElements(newElements);
|
|
50
35
|
}
|
|
51
36
|
catch (e) {
|
|
52
37
|
console.error('Error Getting initial description', e);
|
|
53
38
|
}
|
|
54
39
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
let listener;
|
|
58
|
-
if (node) {
|
|
59
|
-
listener = node.onAny((eventName) => {
|
|
60
|
-
if (eventName === 'moduleAttached')
|
|
61
|
-
setRefresh((previous) => previous + 1);
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
return () => listener === null || listener === void 0 ? void 0 : listener();
|
|
65
|
-
}, [node]);
|
|
40
|
+
return () => console.log('unmounted');
|
|
41
|
+
}), [targetNode]);
|
|
66
42
|
return elements;
|
|
67
43
|
};
|
|
68
44
|
exports.useCytoscapeElements = useCytoscapeElements;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCytoscapeElements.js","sourceRoot":"","sources":["../../../../src/hooks/cytoscape/useCytoscapeElements.ts"],"names":[],"mappings":";;;;AAAA,uDAAqD;
|
|
1
|
+
{"version":3,"file":"useCytoscapeElements.js","sourceRoot":"","sources":["../../../../src/hooks/cytoscape/useCytoscapeElements.ts"],"names":[],"mappings":";;;;AAAA,uDAAqD;AAGrD,iCAAgC;AAEhC,+CAAmD;AAEnD;;;GAGG;AACI,MAAM,oBAAoB,GAAG,CAAC,UAAwB,EAAE,EAAE;IAC/D,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,IAAA,gBAAQ,EAAsB,EAAE,CAAC,CAAA;IAEjE,IAAA,6BAAc;IACZ,uDAAuD;IACvD,GAAS,EAAE;;QACT,IAAI,UAAU,EAAE;YACd,IAAI;gBACF,MAAM,CAAC,WAAW,EAAE,WAAW,CAAC,GAAG,MAAM,6BAAiB,CAAC,aAAa,CAAC,UAAU,CAAC,CAAA;gBACpF,MAAM,WAAW,GAAG,CAAC,WAAW,CAAC,CAAA;gBAEjC,MAAM,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAA;gBACrC,MAAM,OAAO,CAAC,UAAU,CACtB,MAAA,CAAC,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,EAAE,CAAC,0CAAE,GAAG,CAAC,CAAO,OAAO,EAAE,EAAE;oBACtC,IAAI;wBACF,MAAM,OAAO,GAAG,MAAM,6BAAiB,CAAC,UAAU,CAAC,UAAU,EAAE,OAAO,CAAC,CAAA;wBACvE,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;wBAEzB,MAAM,OAAO,GAAG,6BAAiB,CAAC,SAAS,CAAC,WAAW,EAAE,OAAO,CAAC,CAAA;wBACjE,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;qBAC1B;oBAAC,OAAO,CAAC,EAAE;wBACV,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,CAAC,CAAC,CAAA;qBAC3C;gBACH,CAAC,CAAA,CAAC,CACH,CAAA;gBACD,WAAW,CAAC,WAAW,CAAC,CAAA;aACzB;YAAC,OAAO,CAAC,EAAE;gBACV,OAAO,CAAC,KAAK,CAAC,mCAAmC,EAAE,CAAC,CAAC,CAAA;aACtD;SACF;QACD,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;IACvC,CAAC,CAAA,EACD,CAAC,UAAU,CAAC,CACb,CAAA;IAED,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA;AApCY,QAAA,oBAAoB,wBAoChC"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -2,5 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./components"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./Cytoscape"), exports);
|
|
5
6
|
tslib_1.__exportStar(require("./hooks"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./lib"), exports);
|
|
6
8
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,uDAA4B;AAC5B,kDAAuB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,uDAA4B;AAC5B,sDAA2B;AAC3B,kDAAuB;AACvB,gDAAqB"}
|