@receptron/graphai_vue_cytoscape 0.0.16 → 0.2.0

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/README.md CHANGED
@@ -23,9 +23,7 @@ export default defineComponent({
23
23
 
24
24
  const run = async () => {
25
25
  const graphai = new GraphAI(selectdGraph.value, agents);
26
- graphai.onLogCallback = async ({ nodeId, state }) => {
27
- updateCytoscape(nodeId, state);
28
- };
26
+ graphai.registerCallback(updateCytoscape);
29
27
  await graphai.run();
30
28
  }
31
29
  run();
@@ -37,3 +35,6 @@ export default defineComponent({
37
35
  });
38
36
  ```
39
37
 
38
+ ### requirement
39
+
40
+ GraphAI 0.6.23 or above
@@ -1,11 +1,11 @@
1
1
  import { Ref, ComputedRef } from "vue";
2
- import { GraphData, NodeState } from "graphai";
2
+ import { GraphData, TransactionLog } from "graphai";
3
3
  import { DataSource } from "graphai/lib/type";
4
4
  export declare const inputs2dataSources: (inputs: any) => string[];
5
5
  export declare const dataSourceNodeIds: (sources: DataSource[]) => string[];
6
6
  export declare const useCytoscape: (selectedGraph: ComputedRef<GraphData> | Ref<GraphData>) => {
7
7
  cytoscapeRef: Ref<any, any>;
8
- updateCytoscape: (nodeId: string, state: NodeState) => Promise<void>;
8
+ updateCytoscape: (log: TransactionLog) => Promise<void>;
9
9
  resetCytoscape: () => void;
10
10
  layoutCytoscape: (key: string) => void;
11
11
  loadLayout: (key: string) => void;
package/lib/cytoscape.js CHANGED
@@ -270,12 +270,13 @@ var useCytoscape = function (selectedGraph) {
270
270
  var cytoscapeData = (0, vue_1.ref)(cytoscapeFromGraph((_a = selectedGraph.value) !== null && _a !== void 0 ? _a : { nodes: {} }));
271
271
  var cytoscapeRef = (0, vue_1.ref)();
272
272
  var zoomingEnabled = (0, vue_1.ref)(true);
273
- var updateCytoscape = function (nodeId, state) { return __awaiter(void 0, void 0, void 0, function () {
274
- var elements, graph, nodeData;
273
+ var updateCytoscape = function (log) { return __awaiter(void 0, void 0, void 0, function () {
274
+ var nodeId, state, elements, graph, nodeData;
275
275
  var _a, _b, _c;
276
276
  return __generator(this, function (_d) {
277
277
  switch (_d.label) {
278
278
  case 0:
279
+ nodeId = log.nodeId, state = log.state;
279
280
  if (![graphai_1.NodeState.Completed, graphai_1.NodeState.Waiting].includes(state)) return [3 /*break*/, 2];
280
281
  return [4 /*yield*/, (0, graphai_1.sleep)(100)];
281
282
  case 1:
@@ -283,9 +284,10 @@ var useCytoscape = function (selectedGraph) {
283
284
  _d.label = 2;
284
285
  case 2:
285
286
  elements = cytoscapeData.value.elements;
287
+ if (!elements.map[nodeId]) return [3 /*break*/, 4];
286
288
  elements.map[nodeId].data.color = colorMap[state];
287
289
  graph = selectedGraph.value;
288
- nodeData = (_b = ((_a = graph === null || graph === void 0 ? void 0 : graph.nodes) !== null && _a !== void 0 ? _a : {})[nodeId]) !== null && _b !== void 0 ? _b : [];
290
+ nodeData = (_b = ((_a = graph === null || graph === void 0 ? void 0 : graph.nodes) !== null && _a !== void 0 ? _a : {})[nodeId]) !== null && _b !== void 0 ? _b : {};
289
291
  if ("agent" in nodeData && state === graphai_1.NodeState.Queued && ((_c = nodeData.priority) !== null && _c !== void 0 ? _c : 0) > 0) {
290
292
  // computed node
291
293
  elements.map[nodeId].data.color = colorPriority;
@@ -344,7 +346,7 @@ var useCytoscape = function (selectedGraph) {
344
346
  }
345
347
  return prevName;
346
348
  }, layout);
347
- console.log("layout", name_1);
349
+ // console.log("layout", name);
348
350
  cy.layout({ name: name_1 }).run();
349
351
  cy.fit();
350
352
  if (!(name_1 === layout)) return [3 /*break*/, 2];
@@ -358,7 +360,7 @@ var useCytoscape = function (selectedGraph) {
358
360
  });
359
361
  }); };
360
362
  var storePositions = function () {
361
- console.log("storePositions");
363
+ // console.log("storePositions");
362
364
  if (cy) {
363
365
  cy.nodes().forEach(function (cynode) {
364
366
  var id = cynode.id();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@receptron/graphai_vue_cytoscape",
3
- "version": "0.0.16",
3
+ "version": "0.2.0",
4
4
  "main": "lib/cytoscape.js",
5
5
  "files": [
6
6
  "./lib"
@@ -30,19 +30,11 @@
30
30
  "cytoscape-klay": "^3.1.4"
31
31
  },
32
32
  "devDependencies": {
33
- "@babel/types": "^7.26.3",
34
- "@rushstack/eslint-patch": "^1.8.0",
35
- "@tsconfig/node20": "^20.1.4",
36
33
  "@types/cytoscape-klay": "^3.1.4",
37
34
  "@vitejs/plugin-vue": "^5.2.1",
38
35
  "@vue/tsconfig": "^0.7.0",
39
- "autoprefixer": "^10.4.19",
40
- "npm-run-all2": "^7.0.1",
41
- "postcss": "^8.4.49",
42
- "tailwindcss": "^3.4.16",
43
- "vite": "^6.0.3",
44
36
  "vue": "^3.5.13",
45
- "vue-tsc": "^2.1.10"
37
+ "vue-tsc": "^2.2.0"
46
38
  },
47
39
  "types": "./lib/cytoscape.d.ts",
48
40
  "directories": {