@crazyhappyone/auto-graph 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/cli/index.cjs +75 -21
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +75 -21
- package/dist/cli/index.js.map +1 -1
- package/dist/index.cjs +76 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.js +76 -22
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3750,6 +3750,15 @@ function indent(value) {
|
|
|
3750
3750
|
function indentLines(values) {
|
|
3751
3751
|
return values.map(indent);
|
|
3752
3752
|
}
|
|
3753
|
+
|
|
3754
|
+
// src/ir/diagnostics.ts
|
|
3755
|
+
var DELIVERABILITY_DIAGNOSTIC_CODES = /* @__PURE__ */ new Set([
|
|
3756
|
+
"constraints.locked-target-not-moved",
|
|
3757
|
+
"routing.evidence.crossing_forbidden",
|
|
3758
|
+
"routing.obstacle.unavoidable",
|
|
3759
|
+
"route_obstacle_fallback",
|
|
3760
|
+
"routing.text-clearance.unresolved"
|
|
3761
|
+
]);
|
|
3753
3762
|
var DEFAULT_OPTIONS = {
|
|
3754
3763
|
nodesep: 80,
|
|
3755
3764
|
ranksep: 100,
|
|
@@ -3996,21 +4005,29 @@ function routeEdge(input) {
|
|
|
3996
4005
|
}
|
|
3997
4006
|
function finalizeRoute(points, softObstacles, hardObstacles, diagnostics) {
|
|
3998
4007
|
const simplified = simplifyRoute(points);
|
|
4008
|
+
if (simplified.length >= 3) {
|
|
4009
|
+
return simplified;
|
|
4010
|
+
}
|
|
3999
4011
|
const crossesHardObstacles = routeCrossesBoxes(simplified, hardObstacles);
|
|
4000
4012
|
const crossesSoftObstacles = routeCrossesBoxes(simplified, softObstacles);
|
|
4001
|
-
if (
|
|
4013
|
+
if (!crossesHardObstacles && !crossesSoftObstacles) {
|
|
4014
|
+
return simplified;
|
|
4015
|
+
}
|
|
4016
|
+
const expanded = expandFallbackRoute(simplified, [
|
|
4017
|
+
...softObstacles,
|
|
4018
|
+
...hardObstacles
|
|
4019
|
+
]);
|
|
4020
|
+
const expandedCrossesHard = routeCrossesBoxes(expanded, hardObstacles);
|
|
4021
|
+
const expandedCrossesSoft = routeCrossesBoxes(expanded, softObstacles);
|
|
4022
|
+
if (expandedCrossesHard || expandedCrossesSoft) {
|
|
4002
4023
|
diagnostics.push({
|
|
4003
|
-
severity:
|
|
4024
|
+
severity: expandedCrossesHard ? "error" : "warning",
|
|
4004
4025
|
code: "route_obstacle_fallback",
|
|
4005
4026
|
message: "Obstacle-aware routing fell back to fewer than three route points.",
|
|
4006
4027
|
detail: { pointCount: simplified.length }
|
|
4007
4028
|
});
|
|
4008
|
-
return expandFallbackRoute(simplified, [
|
|
4009
|
-
...softObstacles,
|
|
4010
|
-
...hardObstacles
|
|
4011
|
-
]);
|
|
4012
4029
|
}
|
|
4013
|
-
return
|
|
4030
|
+
return expanded;
|
|
4014
4031
|
}
|
|
4015
4032
|
function expandFallbackRoute(points, obstacles) {
|
|
4016
4033
|
if (points.length !== 2) {
|
|
@@ -4041,12 +4058,12 @@ function expandFallbackRoute(points, obstacles) {
|
|
|
4041
4058
|
const hv = diagonalDetourHV(source, target, obstacles);
|
|
4042
4059
|
const vh = diagonalDetourVH(source, target, obstacles);
|
|
4043
4060
|
const viable = [hv, vh].filter((c) => !routeCrossesBoxes(c, obstacles));
|
|
4044
|
-
|
|
4061
|
+
const [firstViable, ...remainingViable] = viable;
|
|
4062
|
+
if (firstViable !== void 0) {
|
|
4045
4063
|
const directLen = Math.hypot(target.x - source.x, target.y - source.y);
|
|
4046
|
-
let best =
|
|
4047
|
-
for (
|
|
4048
|
-
|
|
4049
|
-
if (cand !== void 0 && pathLength(cand) - directLen < pathLength(best) - directLen) {
|
|
4064
|
+
let best = firstViable;
|
|
4065
|
+
for (const cand of remainingViable) {
|
|
4066
|
+
if (pathLength(cand) - directLen < pathLength(best) - directLen) {
|
|
4050
4067
|
best = cand;
|
|
4051
4068
|
}
|
|
4052
4069
|
}
|
|
@@ -4632,6 +4649,7 @@ function solveDiagram(diagram, options = {}) {
|
|
|
4632
4649
|
];
|
|
4633
4650
|
const initialContentBounds = layoutBoxes.length === 0 ? { x: 0, y: 0, width: 0} : unionBoxes(layoutBoxes);
|
|
4634
4651
|
placeEvidenceBlocks(
|
|
4652
|
+
options.obstacleMargin ?? 0,
|
|
4635
4653
|
[
|
|
4636
4654
|
...coordinatedMatrices,
|
|
4637
4655
|
...coordinatedTables,
|
|
@@ -4698,17 +4716,33 @@ function solveDiagram(diagram, options = {}) {
|
|
|
4698
4716
|
...baseTextAnnotations.filter(isPreRouteTextObstacle),
|
|
4699
4717
|
...frameTextAnnotation.filter(isPreRouteTextObstacle)
|
|
4700
4718
|
];
|
|
4719
|
+
const margin = options.obstacleMargin ?? 0;
|
|
4720
|
+
const softObstacles = [
|
|
4721
|
+
...coordinatedTables.map((table) => expandBox(table.box, margin)),
|
|
4722
|
+
...coordinatedEvidencePanels.map((panel) => expandBox(panel.box, margin))
|
|
4723
|
+
];
|
|
4724
|
+
const hardObstacles = coordinatedMatrices.map(
|
|
4725
|
+
(matrix) => expandBox(matrix.box, margin)
|
|
4726
|
+
);
|
|
4727
|
+
const titleBarObstacles = [];
|
|
4728
|
+
if (frame !== void 0) {
|
|
4729
|
+
titleBarObstacles.push(expandBox(frame.titleBox, margin));
|
|
4730
|
+
}
|
|
4731
|
+
for (const swimlane of coordinatedSwimlanes) {
|
|
4732
|
+
for (const lane of swimlane.lanes) {
|
|
4733
|
+
if (lane.headerBox !== void 0 && lane.headerBox.width > 0 && lane.headerBox.height > 0) {
|
|
4734
|
+
titleBarObstacles.push(expandBox(lane.headerBox, margin));
|
|
4735
|
+
}
|
|
4736
|
+
}
|
|
4737
|
+
}
|
|
4701
4738
|
const coordinatedEdges = coordinateEdges(
|
|
4702
4739
|
styledEdges,
|
|
4703
4740
|
nodeGeometryById,
|
|
4704
4741
|
coordinatedNodes,
|
|
4705
4742
|
[...nodeGeometryById.values()].map((geometry) => geometry.obstacleBox),
|
|
4706
|
-
[
|
|
4707
|
-
...coordinatedTables.map((table) => table.box),
|
|
4708
|
-
...coordinatedEvidencePanels.map((panel) => panel.box)
|
|
4709
|
-
],
|
|
4743
|
+
[...softObstacles, ...titleBarObstacles],
|
|
4710
4744
|
routingTextObstacles,
|
|
4711
|
-
|
|
4745
|
+
hardObstacles,
|
|
4712
4746
|
diagram.direction,
|
|
4713
4747
|
options,
|
|
4714
4748
|
diagnostics
|
|
@@ -4743,6 +4777,16 @@ function solveDiagram(diagram, options = {}) {
|
|
|
4743
4777
|
options.pageBounds
|
|
4744
4778
|
)
|
|
4745
4779
|
);
|
|
4780
|
+
let degraded = false;
|
|
4781
|
+
const resultDiagnostics = diagnostics.map((diagnostic) => {
|
|
4782
|
+
if (DELIVERABILITY_DIAGNOSTIC_CODES.has(diagnostic.code)) {
|
|
4783
|
+
degraded = true;
|
|
4784
|
+
if (options.strict) {
|
|
4785
|
+
return { ...diagnostic, severity: "error" };
|
|
4786
|
+
}
|
|
4787
|
+
}
|
|
4788
|
+
return diagnostic;
|
|
4789
|
+
});
|
|
4746
4790
|
return {
|
|
4747
4791
|
id: diagram.id,
|
|
4748
4792
|
...diagram.title === void 0 ? {} : { title: diagram.title },
|
|
@@ -4754,7 +4798,8 @@ function solveDiagram(diagram, options = {}) {
|
|
|
4754
4798
|
...coordinatedMatrices.length === 0 ? {} : { matrices: coordinatedMatrices },
|
|
4755
4799
|
...coordinatedTables.length === 0 ? {} : { tables: coordinatedTables },
|
|
4756
4800
|
...coordinatedEvidencePanels.length === 0 ? {} : { evidencePanels: coordinatedEvidencePanels },
|
|
4757
|
-
diagnostics,
|
|
4801
|
+
diagnostics: resultDiagnostics,
|
|
4802
|
+
degraded,
|
|
4758
4803
|
bounds: frame === void 0 ? unionBoxes(boundsBase) : unionBoxes([...boundsBase, frame.box, frame.titleBox]),
|
|
4759
4804
|
...frame === void 0 ? {} : { frame },
|
|
4760
4805
|
...textAnnotations.length === 0 ? {} : { textAnnotations },
|
|
@@ -6143,16 +6188,25 @@ function blockBox(block, defaultSize) {
|
|
|
6143
6188
|
height: block.size?.height ?? defaultSize.height
|
|
6144
6189
|
};
|
|
6145
6190
|
}
|
|
6146
|
-
function placeEvidenceBlocks(blocks, contentBounds) {
|
|
6191
|
+
function placeEvidenceBlocks(obstacleMargin, blocks, contentBounds) {
|
|
6192
|
+
const margin = normalizeInsets(obstacleMargin);
|
|
6193
|
+
const horizontalGap = Math.max(
|
|
6194
|
+
DEFAULT_EVIDENCE_BLOCK_GAP,
|
|
6195
|
+
margin.right + margin.left
|
|
6196
|
+
);
|
|
6197
|
+
const verticalGap = Math.max(
|
|
6198
|
+
DEFAULT_EVIDENCE_BLOCK_GAP,
|
|
6199
|
+
margin.bottom + margin.top
|
|
6200
|
+
);
|
|
6147
6201
|
let nextY = contentBounds.y;
|
|
6148
|
-
const x = contentBounds.x + contentBounds.width +
|
|
6202
|
+
const x = contentBounds.x + contentBounds.width + horizontalGap;
|
|
6149
6203
|
for (const block of blocks) {
|
|
6150
6204
|
if (block.position !== void 0) {
|
|
6151
6205
|
continue;
|
|
6152
6206
|
}
|
|
6153
6207
|
block.box.x = x;
|
|
6154
6208
|
block.box.y = nextY;
|
|
6155
|
-
nextY += block.box.height +
|
|
6209
|
+
nextY += block.box.height + verticalGap;
|
|
6156
6210
|
}
|
|
6157
6211
|
}
|
|
6158
6212
|
function columnXOffsets(table, box) {
|
|
@@ -7383,6 +7437,7 @@ function isPointLikeRecord(value) {
|
|
|
7383
7437
|
|
|
7384
7438
|
exports.DEFAULT_CANONICAL_PRECISION = DEFAULT_CANONICAL_PRECISION;
|
|
7385
7439
|
exports.DEFAULT_DSL_MAX_BYTES = DEFAULT_DSL_MAX_BYTES;
|
|
7440
|
+
exports.DELIVERABILITY_DIAGNOSTIC_CODES = DELIVERABILITY_DIAGNOSTIC_CODES;
|
|
7386
7441
|
exports.DeterministicTextMeasurer = DeterministicTextMeasurer;
|
|
7387
7442
|
exports.LabelFitter = LabelFitter;
|
|
7388
7443
|
exports.PretextTextMeasurer = PretextTextMeasurer;
|