@receptron/graphai_vue_cytoscape 0.0.1 → 0.0.2

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.
@@ -0,0 +1,7 @@
1
+ import { Ref, ComputedRef } from "vue";
2
+ import { GraphData, NodeState } from "graphai";
3
+ export declare const useCytoscape: (selectedGraph: ComputedRef<GraphData> | Ref<GraphData>) => {
4
+ cytoscapeRef: Ref<any>;
5
+ updateCytoscape: (nodeId: string, state: NodeState) => Promise<void>;
6
+ resetCytoscape: () => void;
7
+ };
@@ -40,7 +40,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
40
40
  };
41
41
  var _a;
42
42
  Object.defineProperty(exports, "__esModule", { value: true });
43
- exports.useCytoscope = void 0;
43
+ exports.useCytoscape = void 0;
44
44
  var vue_1 = require("vue");
45
45
  var graphai_1 = require("graphai");
46
46
  var cytoscape_1 = __importDefault(require("cytoscape"));
@@ -162,11 +162,11 @@ var cytoscapeFromGraph = function (graph_data) {
162
162
  }, { nodes: [], edges: [], map: {} });
163
163
  return { elements: elements };
164
164
  };
165
- var useCytoscope = function (selectedGraph) {
165
+ var useCytoscape = function (selectedGraph) {
166
166
  var cy = null;
167
- var cytoscopeData = (0, vue_1.ref)(cytoscapeFromGraph(selectedGraph.value));
168
- var cytoscopeRef = (0, vue_1.ref)();
169
- var updateCytoscope = function (nodeId, state) { return __awaiter(void 0, void 0, void 0, function () {
167
+ var cytoscapeData = (0, vue_1.ref)(cytoscapeFromGraph(selectedGraph.value));
168
+ var cytoscapeRef = (0, vue_1.ref)();
169
+ var updateCytoscape = function (nodeId, state) { return __awaiter(void 0, void 0, void 0, function () {
170
170
  var elements, graph, nodeData;
171
171
  var _a;
172
172
  return __generator(this, function (_b) {
@@ -178,7 +178,7 @@ var useCytoscope = function (selectedGraph) {
178
178
  _b.sent();
179
179
  _b.label = 2;
180
180
  case 2:
181
- elements = cytoscopeData.value.elements;
181
+ elements = cytoscapeData.value.elements;
182
182
  elements.map[nodeId].data.color = colorMap[state];
183
183
  graph = selectedGraph.value;
184
184
  nodeData = graph.nodes[nodeId];
@@ -192,22 +192,22 @@ var useCytoscope = function (selectedGraph) {
192
192
  elements.map[nodeId].data.color = colorStatic;
193
193
  }
194
194
  }
195
- cytoscopeData.value = { elements: elements };
195
+ cytoscapeData.value = { elements: elements };
196
196
  if (!(state === graphai_1.NodeState.Injected)) return [3 /*break*/, 4];
197
197
  return [4 /*yield*/, (0, graphai_1.sleep)(100)];
198
198
  case 3:
199
199
  _b.sent();
200
200
  elements.map[nodeId].data.color = colorStatic;
201
- cytoscopeData.value = { elements: elements };
201
+ cytoscapeData.value = { elements: elements };
202
202
  _b.label = 4;
203
203
  case 4: return [2 /*return*/];
204
204
  }
205
205
  });
206
206
  }); };
207
- var createCytoscope = function () {
207
+ var createCytoscape = function () {
208
208
  try {
209
209
  cy = (0, cytoscape_1.default)({
210
- container: cytoscopeRef.value,
210
+ container: cytoscapeRef.value,
211
211
  style: cyStyle,
212
212
  layout: {
213
213
  name: layout,
@@ -235,8 +235,8 @@ var useCytoscope = function (selectedGraph) {
235
235
  case 0:
236
236
  if (!cy) return [3 /*break*/, 2];
237
237
  cy.elements().remove();
238
- cy.add(cytoscopeData.value.elements);
239
- name_1 = cytoscopeData.value.elements.nodes.reduce(function (prevName, node) {
238
+ cy.add(cytoscapeData.value.elements);
239
+ name_1 = cytoscapeData.value.elements.nodes.reduce(function (prevName, node) {
240
240
  if (node.position) {
241
241
  return "preset";
242
242
  }
@@ -261,35 +261,35 @@ var useCytoscope = function (selectedGraph) {
261
261
  cy.nodes().forEach(function (cynode) {
262
262
  var id = cynode.id();
263
263
  var pos = cynode.position();
264
- var node = cytoscopeData.value.elements.map[id];
264
+ var node = cytoscapeData.value.elements.map[id];
265
265
  node.position = pos;
266
266
  });
267
267
  }
268
268
  };
269
- var resetCytoscope = function () {
270
- var elements = cytoscopeData.value.elements;
269
+ var resetCytoscape = function () {
270
+ var elements = cytoscapeData.value.elements;
271
271
  Object.keys(elements.map).forEach(function (nodeId) {
272
272
  var graph = selectedGraph.value;
273
273
  var nodeData = graph.nodes[nodeId];
274
274
  elements.map[nodeId].data.color = "value" in nodeData ? colorStatic : colorMap[graphai_1.NodeState.Waiting];
275
275
  });
276
- cytoscopeData.value = { elements: elements };
276
+ cytoscapeData.value = { elements: elements };
277
277
  };
278
- (0, vue_1.watch)(cytoscopeData, function () {
278
+ (0, vue_1.watch)(cytoscapeData, function () {
279
279
  console.log("updated");
280
280
  updateGraphData();
281
281
  });
282
282
  (0, vue_1.watch)(selectedGraph, function () {
283
- cytoscopeData.value = cytoscapeFromGraph(selectedGraph.value);
283
+ cytoscapeData.value = cytoscapeFromGraph(selectedGraph.value);
284
284
  });
285
285
  (0, vue_1.onMounted)(function () {
286
- createCytoscope();
286
+ createCytoscape();
287
287
  updateGraphData();
288
288
  });
289
289
  return {
290
- cytoscopeRef: cytoscopeRef,
291
- updateCytoscope: updateCytoscope,
292
- resetCytoscope: resetCytoscope,
290
+ cytoscapeRef: cytoscapeRef,
291
+ updateCytoscape: updateCytoscape,
292
+ resetCytoscape: resetCytoscape,
293
293
  };
294
294
  };
295
- exports.useCytoscope = useCytoscope;
295
+ exports.useCytoscape = useCytoscape;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@receptron/graphai_vue_cytoscape",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "main": "lib/cytoscape.js",
5
5
  "files": [
6
6
  "./lib"
@@ -1,7 +0,0 @@
1
- import { Ref, ComputedRef } from "vue";
2
- import { GraphData, NodeState } from "graphai";
3
- export declare const useCytoscope: (selectedGraph: ComputedRef<GraphData> | Ref<GraphData>) => {
4
- cytoscopeRef: Ref<any>;
5
- updateCytoscope: (nodeId: string, state: NodeState) => Promise<void>;
6
- resetCytoscope: () => void;
7
- };