@nesso-how/graph 0.1.0-alpha.28 → 0.1.0-alpha.29
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/NessoEdge.js +2 -9
- package/dist/geometry.d.ts +5 -0
- package/dist/geometry.js +13 -10
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +4 -4
package/dist/NessoEdge.js
CHANGED
|
@@ -5,7 +5,7 @@ import { useStore } from '@xyflow/react';
|
|
|
5
5
|
import { PALETTES, RELATION_TYPES } from '@nesso-how/relation-types';
|
|
6
6
|
import { GlyphSVG } from './GlyphSVG.js';
|
|
7
7
|
import { useGraphDisplay } from './context.js';
|
|
8
|
-
import { effectiveCurveFlip, flowNodeCenterX, flowNodeCenterY, nessoArcPath, rectExit, } from './geometry.js';
|
|
8
|
+
import { arcControlPoint, effectiveCurveFlip, flowNodeCenterX, flowNodeCenterY, nessoArcPath, rectExit, } from './geometry.js';
|
|
9
9
|
function asEdgeTypeName(value, fallback = 'causes') {
|
|
10
10
|
return typeof value === 'string' && value in RELATION_TYPES ? value : fallback;
|
|
11
11
|
}
|
|
@@ -61,7 +61,6 @@ export function NessoEdge({ id, source, target, data, selected }) {
|
|
|
61
61
|
const tcy = flowNodeCenterY(targetNode);
|
|
62
62
|
const curveFlip = effectiveCurveFlip(autoCurveFlip, data?.curveFlipPinned, data?.curveFlip, flowNodeCenterX(sourceNode), scy, flowNodeCenterX(targetNode), tcy);
|
|
63
63
|
const pad = 6;
|
|
64
|
-
const flipSign = curveFlip ? -1 : 1;
|
|
65
64
|
const { a, b } = (() => {
|
|
66
65
|
if (straight) {
|
|
67
66
|
return {
|
|
@@ -69,13 +68,7 @@ export function NessoEdge({ id, source, target, data, selected }) {
|
|
|
69
68
|
b: rectExit(tcx, tcy, tw + pad * 2, th + pad * 2, scx, scy),
|
|
70
69
|
};
|
|
71
70
|
}
|
|
72
|
-
const
|
|
73
|
-
const dist = Math.sqrt(dx * dx + dy * dy) || 1;
|
|
74
|
-
const nx = -dy / dist, ny = dx / dist;
|
|
75
|
-
const sibOff = (data?.siblingIdx ?? 0) * 14;
|
|
76
|
-
const bend = (Math.min(dist * 0.22, 90) + sibOff * 0.5) * flipSign;
|
|
77
|
-
const cpx = (scx + tcx) / 2 + nx * bend;
|
|
78
|
-
const cpy = (scy + tcy) / 2 + ny * bend;
|
|
71
|
+
const { cpx, cpy } = arcControlPoint(scx, scy, tcx, tcy, data?.siblingIdx ?? 0, curveFlip);
|
|
79
72
|
return {
|
|
80
73
|
a: rectExit(scx, scy, sw + pad * 2, sh + pad * 2, cpx, cpy),
|
|
81
74
|
b: rectExit(tcx, tcy, tw + pad * 2, th + pad * 2, cpx, cpy),
|
package/dist/geometry.d.ts
CHANGED
|
@@ -40,6 +40,11 @@ export declare function rectExit(cx: number, cy: number, w: number, h: number, t
|
|
|
40
40
|
x: number;
|
|
41
41
|
y: number;
|
|
42
42
|
};
|
|
43
|
+
/** Quadratic-curve control point shared by edge rendering and the connection line. */
|
|
44
|
+
export declare function arcControlPoint(sx: number, sy: number, tx: number, ty: number, siblingIdx?: number, curveFlip?: boolean): {
|
|
45
|
+
cpx: number;
|
|
46
|
+
cpy: number;
|
|
47
|
+
};
|
|
43
48
|
export declare function nessoArcPath(sx: number, sy: number, tx: number, ty: number, siblingIdx?: number, straight?: boolean, curveFlip?: boolean): {
|
|
44
49
|
path: string;
|
|
45
50
|
labelX: number;
|
package/dist/geometry.js
CHANGED
|
@@ -36,6 +36,18 @@ export function rectExit(cx, cy, w, h, tx, ty) {
|
|
|
36
36
|
const s = Math.min(sx, sy);
|
|
37
37
|
return { x: cx + dx * s, y: cy + dy * s };
|
|
38
38
|
}
|
|
39
|
+
/** Quadratic-curve control point shared by edge rendering and the connection line. */
|
|
40
|
+
export function arcControlPoint(sx, sy, tx, ty, siblingIdx = 0, curveFlip = false) {
|
|
41
|
+
const dx = tx - sx;
|
|
42
|
+
const dy = ty - sy;
|
|
43
|
+
const dist = Math.sqrt(dx * dx + dy * dy) || 1;
|
|
44
|
+
const nx = -dy / dist;
|
|
45
|
+
const ny = dx / dist;
|
|
46
|
+
const off = siblingIdx * 14;
|
|
47
|
+
const sign = curveFlip ? -1 : 1;
|
|
48
|
+
const bend = (Math.min(dist * 0.22, 90) + off * 0.5) * sign;
|
|
49
|
+
return { cpx: (sx + tx) / 2 + nx * bend, cpy: (sy + ty) / 2 + ny * bend };
|
|
50
|
+
}
|
|
39
51
|
export function nessoArcPath(sx, sy, tx, ty, siblingIdx = 0, straight = false, curveFlip = false) {
|
|
40
52
|
if (straight) {
|
|
41
53
|
const lx = (sx + tx) / 2;
|
|
@@ -47,16 +59,7 @@ export function nessoArcPath(sx, sy, tx, ty, siblingIdx = 0, straight = false, c
|
|
|
47
59
|
arrowAngle: Math.atan2(ty - sy, tx - sx),
|
|
48
60
|
};
|
|
49
61
|
}
|
|
50
|
-
const
|
|
51
|
-
const dy = ty - sy;
|
|
52
|
-
const dist = Math.sqrt(dx * dx + dy * dy) || 1;
|
|
53
|
-
const nx = -dy / dist;
|
|
54
|
-
const ny = dx / dist;
|
|
55
|
-
const off = siblingIdx * 14;
|
|
56
|
-
const sign = curveFlip ? -1 : 1;
|
|
57
|
-
const bend = (Math.min(dist * 0.22, 90) + off * 0.5) * sign;
|
|
58
|
-
const cpx = (sx + tx) / 2 + nx * bend;
|
|
59
|
-
const cpy = (sy + ty) / 2 + ny * bend;
|
|
62
|
+
const { cpx, cpy } = arcControlPoint(sx, sy, tx, ty, siblingIdx, curveFlip);
|
|
60
63
|
const path = `M ${sx} ${sy} Q ${cpx} ${cpy} ${tx} ${ty}`;
|
|
61
64
|
const labelX = cpx * 0.5 + (sx + tx) * 0.25;
|
|
62
65
|
const labelY = cpy * 0.5 + (sy + ty) * 0.25;
|
package/dist/index.d.ts
CHANGED
|
@@ -8,4 +8,4 @@ export { useGraphDisplay, GraphDisplayContext } from './context.js';
|
|
|
8
8
|
export type { NessoGraphDisplayContext, CategoryColorMode } from './context.js';
|
|
9
9
|
export { GlyphSVG } from './GlyphSVG.js';
|
|
10
10
|
export { ratingColor } from './ratingColor.js';
|
|
11
|
-
export { defaultCurveFlip, nodeCenterX, nodeCenterY, flowNodeCenterX, flowNodeCenterY, effectiveCurveFlip, rectExit, nessoArcPath, } from './geometry.js';
|
|
11
|
+
export { arcControlPoint, defaultCurveFlip, nodeCenterX, nodeCenterY, flowNodeCenterX, flowNodeCenterY, effectiveCurveFlip, rectExit, nessoArcPath, } from './geometry.js';
|
package/dist/index.js
CHANGED
|
@@ -7,4 +7,4 @@ export { useGraphDisplay, GraphDisplayContext } from './context.js';
|
|
|
7
7
|
// Shared canvas utilities — import from here to avoid duplication with the main app.
|
|
8
8
|
export { GlyphSVG } from './GlyphSVG.js';
|
|
9
9
|
export { ratingColor } from './ratingColor.js';
|
|
10
|
-
export { defaultCurveFlip, nodeCenterX, nodeCenterY, flowNodeCenterX, flowNodeCenterY, effectiveCurveFlip, rectExit, nessoArcPath, } from './geometry.js';
|
|
10
|
+
export { arcControlPoint, defaultCurveFlip, nodeCenterX, nodeCenterY, flowNodeCenterX, flowNodeCenterY, effectiveCurveFlip, rectExit, nessoArcPath, } from './geometry.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nesso-how/graph",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.29",
|
|
4
4
|
"description": "Embeddable read-only Nesso knowledge graph React component",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@nesso-how/formats": "0.1.0-alpha.
|
|
26
|
-
"@nesso-how/types": "0.1.0-alpha.
|
|
27
|
-
"@nesso-how/
|
|
25
|
+
"@nesso-how/formats": "0.1.0-alpha.29",
|
|
26
|
+
"@nesso-how/relation-types": "0.1.0-alpha.29",
|
|
27
|
+
"@nesso-how/types": "0.1.0-alpha.29"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"@xyflow/react": "^12.6.4",
|