fastapi-voyager 0.12.5__py3-none-any.whl → 0.12.6__py3-none-any.whl

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.
@@ -1,2 +1,2 @@
1
1
  __all__ = ["__version__"]
2
- __version__ = "0.12.5"
2
+ __version__ = "0.12.6"
@@ -9,14 +9,31 @@ export class GraphUI {
9
9
  this._init();
10
10
  }
11
11
 
12
- _highlight() {
12
+ _highlight(mode = "bidirectional") {
13
13
  let highlightedNodes = $();
14
14
  for (const selection of this.currentSelection) {
15
- const nodes = this._getAffectedNodes(selection.set, "bidirectional");
15
+ const nodes = this._getAffectedNodes(selection.set, mode);
16
16
  highlightedNodes = highlightedNodes.add(nodes);
17
17
  }
18
18
  if (this.gv) {
19
19
  this.gv.highlight(highlightedNodes, true);
20
+ this.gv.bringToFront(highlightedNodes);
21
+ }
22
+ }
23
+
24
+ _highlightEdgeNodes() {
25
+ let highlightedNodes = $();
26
+ const [up, down, edge] = this.currentSelection
27
+ highlightedNodes = highlightedNodes.add(
28
+ this._getAffectedNodes(up.set, up.direction)
29
+ );
30
+ highlightedNodes = highlightedNodes.add(
31
+ this._getAffectedNodes(down.set, down.direction)
32
+ );
33
+ highlightedNodes = highlightedNodes.add(edge.set)
34
+ if (this.gv) {
35
+ this.gv.highlight(highlightedNodes, true);
36
+ this.gv.bringToFront(highlightedNodes);
20
37
  }
21
38
  }
22
39
 
@@ -65,6 +82,7 @@ export class GraphUI {
65
82
  }
66
83
  }
67
84
 
85
+
68
86
  _init() {
69
87
  const self = this;
70
88
  $(this.selector).graphviz({
@@ -93,13 +111,20 @@ export class GraphUI {
93
111
  });
94
112
 
95
113
  self.gv.edges().click(function (event) {
96
- // const set = $();
97
- // const downStreamNode = event.currentTarget.dataset.name.split("->")[1];
98
- // const nodes = self.gv.nodesByName();
99
- // set.push(nodes[downStreamNode]);
100
- // const obj = { set, direction: "single" };
101
- // self.currentSelection = [obj];
102
- // todo highlight edge and downstream node
114
+ const up = $();
115
+ const down = $();
116
+ const edge = $();
117
+ const [upStreamNode, downStreamNode] = event.currentTarget.dataset.name.split("->");
118
+ const nodes = self.gv.nodesByName();
119
+ up.push(nodes[upStreamNode]);
120
+ down.push(nodes[downStreamNode]);
121
+ edge.push(this)
122
+ const upObj = { set: up, direction: "upstream" };
123
+ const downObj = { set: down, direction: "downstream" };
124
+ const edgeOjb = { set: edge, direction: "single"};
125
+ self.currentSelection = [upObj, downObj, edgeOjb];
126
+
127
+ self._highlightEdgeNodes();
103
128
  })
104
129
 
105
130
  self.gv.nodes().click(function (event) {
@@ -127,15 +152,6 @@ export class GraphUI {
127
152
  }
128
153
  });
129
154
 
130
- self.gv.clusters().click(function (event) {
131
- const set = $();
132
- set.push(this);
133
- const obj = { set, direction: "single" };
134
- self.currentSelection = [obj];
135
- self._highlight();
136
- });
137
-
138
- // click background to reset highlight
139
155
  $(document)
140
156
  .off("click.graphui")
141
157
  .on("click.graphui", function (evt) {
@@ -150,9 +166,9 @@ export class GraphUI {
150
166
  }
151
167
 
152
168
  let isNode = false;
153
- const $nodes = self.gv.nodes();
169
+ const $everything = self.gv.$nodes.add(self.gv.$edges).add(self.gv.$clusters);
154
170
  const node = evt.target.parentNode;
155
- $nodes.each(function () {
171
+ $everything.each(function () {
156
172
  if (this === node) {
157
173
  isNode = true;
158
174
  }
@@ -21,6 +21,8 @@
21
21
  url: null,
22
22
  svg: null,
23
23
  shrink: "0.125pt",
24
+ edgeHitPadding: 12,
25
+ pointerCursor: true,
24
26
  tooltips: {
25
27
  init: function ($graph) {
26
28
  var $a = $(this);
@@ -168,9 +170,20 @@
168
170
  var that = this;
169
171
  var options = this.options;
170
172
 
173
+ if (type === "edge" && options.edgeHitPadding) {
174
+ this.ensureEdgeHitArea($el, options.edgeHitPadding);
175
+ }
176
+
177
+ if (options.pointerCursor && (type === "edge" || type === "node")) {
178
+ this.setInteractiveCursor($el, type === "edge");
179
+ }
180
+
171
181
  // save the colors of the paths, ellipses and polygons
172
182
  $el.find("polygon, ellipse, path").each(function () {
173
183
  var $this = $(this);
184
+ if ($this.attr("data-graphviz-hitbox") === "true") {
185
+ return;
186
+ }
174
187
  // save original colors
175
188
  $this.data("graphviz.svg.color", {
176
189
  fill: $this.attr("fill"),
@@ -314,6 +327,69 @@
314
327
  }
315
328
  };
316
329
 
330
+ GraphvizSvg.prototype.ensureEdgeHitArea = function ($edge, padding) {
331
+ var width = parseFloat(padding);
332
+ if (!isFinite(width) || width <= 0) {
333
+ return;
334
+ }
335
+ var $paths = $edge
336
+ .children("path")
337
+ .filter(function () {
338
+ return $(this).attr("data-graphviz-hitbox") !== "true";
339
+ });
340
+ if (!$paths.length) {
341
+ return;
342
+ }
343
+ $paths.each(function () {
344
+ var $path = $(this);
345
+ var $existing = $path.prev('[data-graphviz-hitbox="true"]');
346
+ if ($existing.length) {
347
+ $existing.attr("stroke-width", width);
348
+ return;
349
+ }
350
+ var clone = this.cloneNode(false);
351
+
352
+ /**
353
+ * gtp-5-codex:
354
+ * Cloning the edge paths without copying D3’s data binding caused those Cannot
355
+ * read properties of undefined (reading 'key') errors when d3-graphviz re-rendered.
356
+ * I now copy the original path’s bound datum (__data__) onto the transparent hitbox
357
+ * clone inside ensureEdgeHitArea, so D3 still finds the expected metadata.
358
+ */
359
+ if (this.__data__) {
360
+ clone.__data__ = this.__data__;
361
+ }
362
+
363
+ var $clone = $(clone);
364
+ $clone.attr({
365
+ "data-graphviz-hitbox": "true",
366
+ stroke: "transparent",
367
+ fill: "none",
368
+ "stroke-width": width,
369
+ });
370
+ $clone.attr("pointer-events", "stroke");
371
+ $clone.css("pointer-events", "stroke");
372
+ if (!$clone.attr("stroke-linecap")) {
373
+ $clone.attr("stroke-linecap", $path.attr("stroke-linecap") || "round");
374
+ }
375
+ $clone.insertBefore($path);
376
+ });
377
+ };
378
+
379
+ GraphvizSvg.prototype.setInteractiveCursor = function ($el, isEdge) {
380
+ $el.css("cursor", "pointer");
381
+ var selectors = "path, polygon, ellipse, rect, text";
382
+ $el.find(selectors).each(function () {
383
+ $(this).css("cursor", "pointer");
384
+ });
385
+ if (isEdge) {
386
+ $el.children('[data-graphviz-hitbox="true"]').css("cursor", "pointer");
387
+ }
388
+ $el.find("a").each(function () {
389
+ $(this).css("cursor", "pointer");
390
+ });
391
+ };
392
+
317
393
  GraphvizSvg.prototype.convertToPx = function (val) {
318
394
  var retval = val;
319
395
  if (typeof val == "string") {
@@ -372,6 +448,9 @@
372
448
  var bg = this.$element.css("background");
373
449
  $el.find("polygon, ellipse, path").each(function () {
374
450
  var $this = $(this);
451
+ if ($this.attr("data-graphviz-hitbox") === "true") {
452
+ return;
453
+ }
375
454
  var color = $this.data("graphviz.svg.color");
376
455
  if (color.fill && color.fill != "none") {
377
456
  $this.attr("fill", getColor(color.fill, bg)); // don't set fill if it's a path
@@ -386,6 +465,9 @@
386
465
  GraphvizSvg.prototype.restoreElement = function ($el) {
387
466
  $el.find("polygon, ellipse, path").each(function () {
388
467
  var $this = $(this);
468
+ if ($this.attr("data-graphviz-hitbox") === "true") {
469
+ return;
470
+ }
389
471
  var color = $this.data("graphviz.svg.color");
390
472
  if (color.fill && color.fill != "none") {
391
473
  $this.attr("fill", color.fill); // don't set fill if it's a path
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastapi-voyager
3
- Version: 0.12.5
3
+ Version: 0.12.6
4
4
  Summary: Visualize FastAPI application's routing tree and dependencies
5
5
  Project-URL: Homepage, https://github.com/allmonday/fastapi-voyager
6
6
  Project-URL: Source, https://github.com/allmonday/fastapi-voyager
@@ -6,11 +6,11 @@ fastapi_voyager/render.py,sha256=7jSChISqTV2agaO55thhwyrOhqVOMux4x7k8rSQROnU,996
6
6
  fastapi_voyager/server.py,sha256=MZNRpcXor2q8Rj3OSf6EH8NkgDChxfzUtnIY8ilRkaY,7053
7
7
  fastapi_voyager/type.py,sha256=7EL1zaIwKVRGpLig7fqaOrZGN5k0Rm31C9COfck3CSs,1750
8
8
  fastapi_voyager/type_helper.py,sha256=JXD_OE_xTARkGjWDsnO_xfvyZ0vcwViYyqCp6oEHBTM,9719
9
- fastapi_voyager/version.py,sha256=0gsRRMzt46OBC-7IuF0VTu6UPwKs_X7qmw7KMjDhIeo,49
9
+ fastapi_voyager/version.py,sha256=gCsZjglIeKj6Gr4eowqOBTgIdgKANz1jfSVP3qdkSn4,49
10
10
  fastapi_voyager/voyager.py,sha256=LiRUb0ZG2cfnyY_pwRqoeZjxb6Pu6xy_lqPiMupxoKM,13510
11
- fastapi_voyager/web/graph-ui.js,sha256=NiwUFHCZPE4C-Hx4qwFvHwPyXw_lu2ar3WnPkmVGQN0,5850
11
+ fastapi_voyager/web/graph-ui.js,sha256=wxKjmVEpaMJZXMTW7tJ4BiaACCI1oVN6cx7hSMI0K5U,6428
12
12
  fastapi_voyager/web/graphviz.svg.css,sha256=zDCjjpT0Idufu5YOiZI76PL70-avP3vTyzGPh9M85Do,1563
13
- fastapi_voyager/web/graphviz.svg.js,sha256=lvAdbjHc-lMSk4GQp-iqYA2PCFX4RKnW7dFaoe0LUHs,16005
13
+ fastapi_voyager/web/graphviz.svg.js,sha256=wZwz_lBztoXmujEN21P0w-HMpdmbqPwTQQ6Ebxd9rGo,18569
14
14
  fastapi_voyager/web/index.html,sha256=3HixCgVF9VtTx89G3usDXpEh7NZnLk_p9siz4OUVUHE,17444
15
15
  fastapi_voyager/web/quasar.min.css,sha256=F5jQe7X2XT54VlvAaa2V3GsBFdVD-vxDZeaPLf6U9CU,203145
16
16
  fastapi_voyager/web/quasar.min.js,sha256=h0ftyPMW_CRiyzeVfQqiup0vrVt4_QWojpqmpnpn07E,502974
@@ -28,8 +28,8 @@ fastapi_voyager/web/icon/favicon-16x16.png,sha256=JC07jEzfIYxBIoQn_FHXvyHuxESdhW
28
28
  fastapi_voyager/web/icon/favicon-32x32.png,sha256=C7v1h58cfWOsiLp9yOIZtlx-dLasBcq3NqpHVGRmpt4,1859
29
29
  fastapi_voyager/web/icon/favicon.ico,sha256=tZolYIXkkBcFiYl1A8ksaXN2VjGamzcSdes838dLvNc,15406
30
30
  fastapi_voyager/web/icon/site.webmanifest,sha256=ep4Hzh9zhmiZF2At3Fp1dQrYQuYF_3ZPZxc1KcGBvwQ,263
31
- fastapi_voyager-0.12.5.dist-info/METADATA,sha256=QO3zauma0JaAR_DyhX5yQqNkDf868_2cAw1mHHKY3o0,6523
32
- fastapi_voyager-0.12.5.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
33
- fastapi_voyager-0.12.5.dist-info/entry_points.txt,sha256=pEIKoUnIDXEtdMBq8EmXm70m16vELIu1VPz9-TBUFWM,53
34
- fastapi_voyager-0.12.5.dist-info/licenses/LICENSE,sha256=lNVRR3y_bFVoFKuK2JM8N4sFaj3m-7j29kvL3olFi5Y,1067
35
- fastapi_voyager-0.12.5.dist-info/RECORD,,
31
+ fastapi_voyager-0.12.6.dist-info/METADATA,sha256=sPfeuEuiQ4Wf_lOwdJL5BMTBIZXzT6Yk4zm175J_Pi4,6523
32
+ fastapi_voyager-0.12.6.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
33
+ fastapi_voyager-0.12.6.dist-info/entry_points.txt,sha256=pEIKoUnIDXEtdMBq8EmXm70m16vELIu1VPz9-TBUFWM,53
34
+ fastapi_voyager-0.12.6.dist-info/licenses/LICENSE,sha256=lNVRR3y_bFVoFKuK2JM8N4sFaj3m-7j29kvL3olFi5Y,1067
35
+ fastapi_voyager-0.12.6.dist-info/RECORD,,