@ogabrielluiz/patchflow 0.1.0 → 0.1.1
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/index.cjs +31 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +31 -24
- package/dist/index.js.map +1 -1
- package/package.json +11 -3
package/dist/index.cjs
CHANGED
|
@@ -4176,7 +4176,7 @@ function findPortPosition(block, portId, direction) {
|
|
|
4176
4176
|
}
|
|
4177
4177
|
function layout(graph, options = {}) {
|
|
4178
4178
|
const direction = options.direction ?? "LR";
|
|
4179
|
-
const rankSep = options.rankSep ??
|
|
4179
|
+
const rankSep = options.rankSep ?? 200;
|
|
4180
4180
|
const nodeSep = options.nodeSep ?? 40;
|
|
4181
4181
|
const allBlocks = [...graph.declaredBlocks, ...graph.stubBlocks];
|
|
4182
4182
|
const allConnections = [...graph.connections, ...graph.feedbackEdges];
|
|
@@ -4469,40 +4469,47 @@ function buildLabels(theme, blocks) {
|
|
|
4469
4469
|
return parts.join("");
|
|
4470
4470
|
}
|
|
4471
4471
|
function buildAnnotations(theme, connections) {
|
|
4472
|
+
const annotated = connections.filter((c) => c.annotation);
|
|
4473
|
+
if (annotated.length === 0) return "";
|
|
4472
4474
|
const parts = [];
|
|
4473
4475
|
const fontFamily = sanitizeForSvg(theme.annotation.fontFamily);
|
|
4474
|
-
const
|
|
4475
|
-
const
|
|
4476
|
-
|
|
4477
|
-
|
|
4476
|
+
const noteFontSize = theme.annotation.fontSize + 1;
|
|
4477
|
+
const markerFontFamily = fontFamily;
|
|
4478
|
+
annotated.forEach((conn, i) => {
|
|
4479
|
+
const num = i + 1;
|
|
4478
4480
|
const sx = conn.sourcePoint.x;
|
|
4479
4481
|
const sy = conn.sourcePoint.y;
|
|
4480
4482
|
const tx = conn.targetPoint.x;
|
|
4481
4483
|
const ty = conn.targetPoint.y;
|
|
4482
|
-
let
|
|
4483
|
-
let
|
|
4484
|
+
let mx;
|
|
4485
|
+
let my;
|
|
4484
4486
|
if (conn.isFeedback) {
|
|
4485
|
-
|
|
4486
|
-
|
|
4487
|
+
mx = (sx + tx) / 2;
|
|
4488
|
+
const match = conn.path.match(/L\s+\S+\s+\S+\s+L\s+\S+\s+(\S+)/);
|
|
4489
|
+
my = match ? parseFloat(match[1]) : Math.max(sy, ty) + 30;
|
|
4487
4490
|
} else {
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
}
|
|
4491
|
-
const prefix = conn.isFeedback ? "\u21BB " : "";
|
|
4492
|
-
let raw = conn.annotation;
|
|
4493
|
-
if (!conn.isFeedback) {
|
|
4494
|
-
const available = Math.abs(tx - sx);
|
|
4495
|
-
const prefixWidth = prefix.length * charWidth;
|
|
4496
|
-
const maxChars = Math.max(0, Math.floor((available - prefixWidth) / charWidth));
|
|
4497
|
-
if (maxChars > 0 && raw.length > maxChars) {
|
|
4498
|
-
raw = maxChars > 1 ? raw.slice(0, maxChars - 1) + "\u2026" : raw.slice(0, maxChars);
|
|
4499
|
-
}
|
|
4491
|
+
mx = (sx + tx) / 2;
|
|
4492
|
+
my = (sy + ty) / 2;
|
|
4500
4493
|
}
|
|
4501
|
-
const
|
|
4494
|
+
const markerStroke = conn.isFeedback ? theme.cable.colors[conn.signalType].stroke : theme.label.color;
|
|
4502
4495
|
parts.push(
|
|
4503
|
-
`<
|
|
4496
|
+
`<circle cx="${mx}" cy="${my}" r="8" fill="${theme.panel.highlight}" stroke="${markerStroke}" stroke-width="0.5" data-annotation-marker="${num}"/>`
|
|
4504
4497
|
);
|
|
4505
|
-
|
|
4498
|
+
parts.push(
|
|
4499
|
+
`<text x="${mx}" y="${my + 3}" text-anchor="middle" font-family="${markerFontFamily}" font-size="9" fill="${theme.label.color}">${num}</text>`
|
|
4500
|
+
);
|
|
4501
|
+
});
|
|
4502
|
+
const panelX = -120;
|
|
4503
|
+
let panelY = 20;
|
|
4504
|
+
const lineGap = 14;
|
|
4505
|
+
annotated.forEach((conn, i) => {
|
|
4506
|
+
const num = i + 1;
|
|
4507
|
+
const noteText = `${num}. ${sanitizeForSvg(conn.annotation)}`;
|
|
4508
|
+
parts.push(
|
|
4509
|
+
`<text x="${panelX}" y="${panelY}" font-family="${fontFamily}" font-size="${noteFontSize}" fill="${theme.annotation.color}">${noteText}</text>`
|
|
4510
|
+
);
|
|
4511
|
+
panelY += lineGap;
|
|
4512
|
+
});
|
|
4506
4513
|
return parts.join("");
|
|
4507
4514
|
}
|
|
4508
4515
|
function buildLegend(theme, layoutResult) {
|