@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.d.cts
CHANGED
|
@@ -80,6 +80,14 @@ interface Diagnostic {
|
|
|
80
80
|
path?: DiagnosticPathSegment[];
|
|
81
81
|
detail?: JsonObject;
|
|
82
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Diagnostic codes that indicate the solver produced a degraded
|
|
85
|
+
* (non-deliverable) layout. Downstream consumers can gate on the
|
|
86
|
+
* {@link CoordinatedDiagram.degraded} flag or use the
|
|
87
|
+
* {@link SolveDiagramOptions.strict} option to promote these to
|
|
88
|
+
* errors.
|
|
89
|
+
*/
|
|
90
|
+
declare const DELIVERABILITY_DIAGNOSTIC_CODES: ReadonlySet<string>;
|
|
83
91
|
|
|
84
92
|
interface TextStyleOptions {
|
|
85
93
|
fontFamily: string;
|
|
@@ -486,6 +494,8 @@ interface CoordinatedDiagram {
|
|
|
486
494
|
evidencePanels?: CoordinatedEvidencePanel[];
|
|
487
495
|
textAnnotations?: SolvedTextAnnotation[];
|
|
488
496
|
diagnostics: Diagnostic[];
|
|
497
|
+
/** True when any deliverability-breaking diagnostic was emitted. */
|
|
498
|
+
degraded: boolean;
|
|
489
499
|
bounds: Box;
|
|
490
500
|
frame?: CoordinatedFrame;
|
|
491
501
|
metadata?: DiagramMetadata;
|
|
@@ -715,6 +725,8 @@ interface SolveDiagramOptions {
|
|
|
715
725
|
cjkFontFamily?: string | false;
|
|
716
726
|
minCjkFontSize?: number | false;
|
|
717
727
|
textMeasurer?: TextMeasurer;
|
|
728
|
+
/** When true, promote deliverability-breaking diagnostics to errors. */
|
|
729
|
+
strict?: boolean;
|
|
718
730
|
}
|
|
719
731
|
interface PortShiftingOptions {
|
|
720
732
|
enabled?: boolean;
|
|
@@ -732,4 +744,4 @@ declare function solveDiagram(diagram: NormalizedDiagram, options?: SolveDiagram
|
|
|
732
744
|
*/
|
|
733
745
|
declare function solveDiagramSafe(diagram: NormalizedDiagram, options?: SolveDiagramOptions): CoordinatedDiagram;
|
|
734
746
|
|
|
735
|
-
export { type AlignConstraint, type AlignmentAxis, type AnchorName, type AnchorPoint, type Arrowhead, type Box, type CanonicalJson, type CanonicalizeOptions, type Constraint, type ConstraintBase, type ConstraintSolverInput, type ConstraintSolverResult, type ConstraintTarget, type ConstraintTargetKind, type ContainerGeometry, type ContainerGeometryInput, type ContainmentConstraint, type CoordinatedDiagram, type CoordinatedEdge, type CoordinatedEvidencePanel, type CoordinatedFrame, type CoordinatedGroup, type CoordinatedMatrixBlock, type CoordinatedNode, type CoordinatedPort, type CoordinatedTableBlock, DEFAULT_CANONICAL_PRECISION, DEFAULT_DSL_MAX_BYTES, type DagreLayoutEdge, type DagreLayoutInput, type DagreLayoutNode, type DagreLayoutOptions, type DefaultTextMeasurerOptions, DeterministicTextMeasurer, type Diagnostic, type DiagnosticPathSegment, type DiagnosticSeverity, type DiagramDirection, type DiagramFrame, type DiagramMetadata, type DiagramStage, type DistributeConstraint, type DistributionAxis, type DslDiagnostic, type DslDiagnosticLayer, type DslOutputFormat, type EdgeArrowhead, type EdgeEndpoint, type EdgeStrokeStyle, type EvidenceCell, type EvidencePanel, type EvidencePanelItem, type EvidencePanelKind, type EvidenceTextLayout, type ExactPositionConstraint, type ExportFormat, type ExportOptions, type ExportResult, type InitialLayoutResult, type Insets, type IntentDiagram, type IntentEdge, type IntentGroup, type IntentNode, type JsonObject, type JsonPrimitive, type JsonValue, type Label, type LabelFitOptions, LabelFitter, type LabelLayout, type LabelLineLayout, type LayoutLock, type LayoutLockSource, type MatrixBlock, type NodeBase, type NodeCompartments, type NodePort, type NodeShape, type NormalizeDiagramDslOptions, type NormalizeDiagramDslResult, type NormalizedDiagram, type NormalizedEdge, type NormalizedGroup, type NormalizedNode, type ParseDiagramDslOptions, type ParseDiagramDslResult, type ParsedEdgeShorthand, type Point, type PortKind, type PortShiftingOptions, type PortSide, type PreparedText, PretextTextMeasurer, type RelativePositionConstraint, type RelativePositionRelation, type RenderDiagramDslOptions, type RenderDiagramDslResult, type RouteEdgeInput, type RouteEdgeResult, type RouteKind, type ShapeGeometry, type ShapeGeometryInput, type Size, type SolveDiagramOptions, type SolvedTextAnnotation, type Swimlane, type SwimlaneLane, type SwimlaneLayout, type SwimlaneOrientation, type TableBlock, type TableColumn, type TableRow, type TextCursor, type TextLayout, type TextLayoutLine, type TextMeasurementBackend, type TextMeasurer, type TextStyleOptions, type TextSurfaceKind, type VisualStyle, applyLayoutConstraints, assertFiniteNonNegative, assertFinitePositive, boxCenter, canonicalize, computeArrowhead, computeContainerGeometry, computeShapeGeometry, createDefaultTextMeasurer, expandBox, exportExcalidraw, exportSvg, fitLabel, getEdgePort, installNodeCanvasRuntime, intersectsAabb, isPretextRuntimeAvailable, normalizeDiagramDsl, normalizeInsets, parseDiagramDsl, parseEdgeShorthand, renderDiagramDsl, resolveLineHeight, resolveOutputFormat, routeEdge, runDagreInitialLayout, simplifyRoute, solveDiagram, solveDiagramSafe, sortDslDiagnostics, stringifyCanonical, toCanvasFont, unionBoxes, validateBox, validateTextStyle };
|
|
747
|
+
export { type AlignConstraint, type AlignmentAxis, type AnchorName, type AnchorPoint, type Arrowhead, type Box, type CanonicalJson, type CanonicalizeOptions, type Constraint, type ConstraintBase, type ConstraintSolverInput, type ConstraintSolverResult, type ConstraintTarget, type ConstraintTargetKind, type ContainerGeometry, type ContainerGeometryInput, type ContainmentConstraint, type CoordinatedDiagram, type CoordinatedEdge, type CoordinatedEvidencePanel, type CoordinatedFrame, type CoordinatedGroup, type CoordinatedMatrixBlock, type CoordinatedNode, type CoordinatedPort, type CoordinatedTableBlock, DEFAULT_CANONICAL_PRECISION, DEFAULT_DSL_MAX_BYTES, DELIVERABILITY_DIAGNOSTIC_CODES, type DagreLayoutEdge, type DagreLayoutInput, type DagreLayoutNode, type DagreLayoutOptions, type DefaultTextMeasurerOptions, DeterministicTextMeasurer, type Diagnostic, type DiagnosticPathSegment, type DiagnosticSeverity, type DiagramDirection, type DiagramFrame, type DiagramMetadata, type DiagramStage, type DistributeConstraint, type DistributionAxis, type DslDiagnostic, type DslDiagnosticLayer, type DslOutputFormat, type EdgeArrowhead, type EdgeEndpoint, type EdgeStrokeStyle, type EvidenceCell, type EvidencePanel, type EvidencePanelItem, type EvidencePanelKind, type EvidenceTextLayout, type ExactPositionConstraint, type ExportFormat, type ExportOptions, type ExportResult, type InitialLayoutResult, type Insets, type IntentDiagram, type IntentEdge, type IntentGroup, type IntentNode, type JsonObject, type JsonPrimitive, type JsonValue, type Label, type LabelFitOptions, LabelFitter, type LabelLayout, type LabelLineLayout, type LayoutLock, type LayoutLockSource, type MatrixBlock, type NodeBase, type NodeCompartments, type NodePort, type NodeShape, type NormalizeDiagramDslOptions, type NormalizeDiagramDslResult, type NormalizedDiagram, type NormalizedEdge, type NormalizedGroup, type NormalizedNode, type ParseDiagramDslOptions, type ParseDiagramDslResult, type ParsedEdgeShorthand, type Point, type PortKind, type PortShiftingOptions, type PortSide, type PreparedText, PretextTextMeasurer, type RelativePositionConstraint, type RelativePositionRelation, type RenderDiagramDslOptions, type RenderDiagramDslResult, type RouteEdgeInput, type RouteEdgeResult, type RouteKind, type ShapeGeometry, type ShapeGeometryInput, type Size, type SolveDiagramOptions, type SolvedTextAnnotation, type Swimlane, type SwimlaneLane, type SwimlaneLayout, type SwimlaneOrientation, type TableBlock, type TableColumn, type TableRow, type TextCursor, type TextLayout, type TextLayoutLine, type TextMeasurementBackend, type TextMeasurer, type TextStyleOptions, type TextSurfaceKind, type VisualStyle, applyLayoutConstraints, assertFiniteNonNegative, assertFinitePositive, boxCenter, canonicalize, computeArrowhead, computeContainerGeometry, computeShapeGeometry, createDefaultTextMeasurer, expandBox, exportExcalidraw, exportSvg, fitLabel, getEdgePort, installNodeCanvasRuntime, intersectsAabb, isPretextRuntimeAvailable, normalizeDiagramDsl, normalizeInsets, parseDiagramDsl, parseEdgeShorthand, renderDiagramDsl, resolveLineHeight, resolveOutputFormat, routeEdge, runDagreInitialLayout, simplifyRoute, solveDiagram, solveDiagramSafe, sortDslDiagnostics, stringifyCanonical, toCanvasFont, unionBoxes, validateBox, validateTextStyle };
|
package/dist/index.d.ts
CHANGED
|
@@ -80,6 +80,14 @@ interface Diagnostic {
|
|
|
80
80
|
path?: DiagnosticPathSegment[];
|
|
81
81
|
detail?: JsonObject;
|
|
82
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Diagnostic codes that indicate the solver produced a degraded
|
|
85
|
+
* (non-deliverable) layout. Downstream consumers can gate on the
|
|
86
|
+
* {@link CoordinatedDiagram.degraded} flag or use the
|
|
87
|
+
* {@link SolveDiagramOptions.strict} option to promote these to
|
|
88
|
+
* errors.
|
|
89
|
+
*/
|
|
90
|
+
declare const DELIVERABILITY_DIAGNOSTIC_CODES: ReadonlySet<string>;
|
|
83
91
|
|
|
84
92
|
interface TextStyleOptions {
|
|
85
93
|
fontFamily: string;
|
|
@@ -486,6 +494,8 @@ interface CoordinatedDiagram {
|
|
|
486
494
|
evidencePanels?: CoordinatedEvidencePanel[];
|
|
487
495
|
textAnnotations?: SolvedTextAnnotation[];
|
|
488
496
|
diagnostics: Diagnostic[];
|
|
497
|
+
/** True when any deliverability-breaking diagnostic was emitted. */
|
|
498
|
+
degraded: boolean;
|
|
489
499
|
bounds: Box;
|
|
490
500
|
frame?: CoordinatedFrame;
|
|
491
501
|
metadata?: DiagramMetadata;
|
|
@@ -715,6 +725,8 @@ interface SolveDiagramOptions {
|
|
|
715
725
|
cjkFontFamily?: string | false;
|
|
716
726
|
minCjkFontSize?: number | false;
|
|
717
727
|
textMeasurer?: TextMeasurer;
|
|
728
|
+
/** When true, promote deliverability-breaking diagnostics to errors. */
|
|
729
|
+
strict?: boolean;
|
|
718
730
|
}
|
|
719
731
|
interface PortShiftingOptions {
|
|
720
732
|
enabled?: boolean;
|
|
@@ -732,4 +744,4 @@ declare function solveDiagram(diagram: NormalizedDiagram, options?: SolveDiagram
|
|
|
732
744
|
*/
|
|
733
745
|
declare function solveDiagramSafe(diagram: NormalizedDiagram, options?: SolveDiagramOptions): CoordinatedDiagram;
|
|
734
746
|
|
|
735
|
-
export { type AlignConstraint, type AlignmentAxis, type AnchorName, type AnchorPoint, type Arrowhead, type Box, type CanonicalJson, type CanonicalizeOptions, type Constraint, type ConstraintBase, type ConstraintSolverInput, type ConstraintSolverResult, type ConstraintTarget, type ConstraintTargetKind, type ContainerGeometry, type ContainerGeometryInput, type ContainmentConstraint, type CoordinatedDiagram, type CoordinatedEdge, type CoordinatedEvidencePanel, type CoordinatedFrame, type CoordinatedGroup, type CoordinatedMatrixBlock, type CoordinatedNode, type CoordinatedPort, type CoordinatedTableBlock, DEFAULT_CANONICAL_PRECISION, DEFAULT_DSL_MAX_BYTES, type DagreLayoutEdge, type DagreLayoutInput, type DagreLayoutNode, type DagreLayoutOptions, type DefaultTextMeasurerOptions, DeterministicTextMeasurer, type Diagnostic, type DiagnosticPathSegment, type DiagnosticSeverity, type DiagramDirection, type DiagramFrame, type DiagramMetadata, type DiagramStage, type DistributeConstraint, type DistributionAxis, type DslDiagnostic, type DslDiagnosticLayer, type DslOutputFormat, type EdgeArrowhead, type EdgeEndpoint, type EdgeStrokeStyle, type EvidenceCell, type EvidencePanel, type EvidencePanelItem, type EvidencePanelKind, type EvidenceTextLayout, type ExactPositionConstraint, type ExportFormat, type ExportOptions, type ExportResult, type InitialLayoutResult, type Insets, type IntentDiagram, type IntentEdge, type IntentGroup, type IntentNode, type JsonObject, type JsonPrimitive, type JsonValue, type Label, type LabelFitOptions, LabelFitter, type LabelLayout, type LabelLineLayout, type LayoutLock, type LayoutLockSource, type MatrixBlock, type NodeBase, type NodeCompartments, type NodePort, type NodeShape, type NormalizeDiagramDslOptions, type NormalizeDiagramDslResult, type NormalizedDiagram, type NormalizedEdge, type NormalizedGroup, type NormalizedNode, type ParseDiagramDslOptions, type ParseDiagramDslResult, type ParsedEdgeShorthand, type Point, type PortKind, type PortShiftingOptions, type PortSide, type PreparedText, PretextTextMeasurer, type RelativePositionConstraint, type RelativePositionRelation, type RenderDiagramDslOptions, type RenderDiagramDslResult, type RouteEdgeInput, type RouteEdgeResult, type RouteKind, type ShapeGeometry, type ShapeGeometryInput, type Size, type SolveDiagramOptions, type SolvedTextAnnotation, type Swimlane, type SwimlaneLane, type SwimlaneLayout, type SwimlaneOrientation, type TableBlock, type TableColumn, type TableRow, type TextCursor, type TextLayout, type TextLayoutLine, type TextMeasurementBackend, type TextMeasurer, type TextStyleOptions, type TextSurfaceKind, type VisualStyle, applyLayoutConstraints, assertFiniteNonNegative, assertFinitePositive, boxCenter, canonicalize, computeArrowhead, computeContainerGeometry, computeShapeGeometry, createDefaultTextMeasurer, expandBox, exportExcalidraw, exportSvg, fitLabel, getEdgePort, installNodeCanvasRuntime, intersectsAabb, isPretextRuntimeAvailable, normalizeDiagramDsl, normalizeInsets, parseDiagramDsl, parseEdgeShorthand, renderDiagramDsl, resolveLineHeight, resolveOutputFormat, routeEdge, runDagreInitialLayout, simplifyRoute, solveDiagram, solveDiagramSafe, sortDslDiagnostics, stringifyCanonical, toCanvasFont, unionBoxes, validateBox, validateTextStyle };
|
|
747
|
+
export { type AlignConstraint, type AlignmentAxis, type AnchorName, type AnchorPoint, type Arrowhead, type Box, type CanonicalJson, type CanonicalizeOptions, type Constraint, type ConstraintBase, type ConstraintSolverInput, type ConstraintSolverResult, type ConstraintTarget, type ConstraintTargetKind, type ContainerGeometry, type ContainerGeometryInput, type ContainmentConstraint, type CoordinatedDiagram, type CoordinatedEdge, type CoordinatedEvidencePanel, type CoordinatedFrame, type CoordinatedGroup, type CoordinatedMatrixBlock, type CoordinatedNode, type CoordinatedPort, type CoordinatedTableBlock, DEFAULT_CANONICAL_PRECISION, DEFAULT_DSL_MAX_BYTES, DELIVERABILITY_DIAGNOSTIC_CODES, type DagreLayoutEdge, type DagreLayoutInput, type DagreLayoutNode, type DagreLayoutOptions, type DefaultTextMeasurerOptions, DeterministicTextMeasurer, type Diagnostic, type DiagnosticPathSegment, type DiagnosticSeverity, type DiagramDirection, type DiagramFrame, type DiagramMetadata, type DiagramStage, type DistributeConstraint, type DistributionAxis, type DslDiagnostic, type DslDiagnosticLayer, type DslOutputFormat, type EdgeArrowhead, type EdgeEndpoint, type EdgeStrokeStyle, type EvidenceCell, type EvidencePanel, type EvidencePanelItem, type EvidencePanelKind, type EvidenceTextLayout, type ExactPositionConstraint, type ExportFormat, type ExportOptions, type ExportResult, type InitialLayoutResult, type Insets, type IntentDiagram, type IntentEdge, type IntentGroup, type IntentNode, type JsonObject, type JsonPrimitive, type JsonValue, type Label, type LabelFitOptions, LabelFitter, type LabelLayout, type LabelLineLayout, type LayoutLock, type LayoutLockSource, type MatrixBlock, type NodeBase, type NodeCompartments, type NodePort, type NodeShape, type NormalizeDiagramDslOptions, type NormalizeDiagramDslResult, type NormalizedDiagram, type NormalizedEdge, type NormalizedGroup, type NormalizedNode, type ParseDiagramDslOptions, type ParseDiagramDslResult, type ParsedEdgeShorthand, type Point, type PortKind, type PortShiftingOptions, type PortSide, type PreparedText, PretextTextMeasurer, type RelativePositionConstraint, type RelativePositionRelation, type RenderDiagramDslOptions, type RenderDiagramDslResult, type RouteEdgeInput, type RouteEdgeResult, type RouteKind, type ShapeGeometry, type ShapeGeometryInput, type Size, type SolveDiagramOptions, type SolvedTextAnnotation, type Swimlane, type SwimlaneLane, type SwimlaneLayout, type SwimlaneOrientation, type TableBlock, type TableColumn, type TableRow, type TextCursor, type TextLayout, type TextLayoutLine, type TextMeasurementBackend, type TextMeasurer, type TextStyleOptions, type TextSurfaceKind, type VisualStyle, applyLayoutConstraints, assertFiniteNonNegative, assertFinitePositive, boxCenter, canonicalize, computeArrowhead, computeContainerGeometry, computeShapeGeometry, createDefaultTextMeasurer, expandBox, exportExcalidraw, exportSvg, fitLabel, getEdgePort, installNodeCanvasRuntime, intersectsAabb, isPretextRuntimeAvailable, normalizeDiagramDsl, normalizeInsets, parseDiagramDsl, parseEdgeShorthand, renderDiagramDsl, resolveLineHeight, resolveOutputFormat, routeEdge, runDagreInitialLayout, simplifyRoute, solveDiagram, solveDiagramSafe, sortDslDiagnostics, stringifyCanonical, toCanvasFont, unionBoxes, validateBox, validateTextStyle };
|
package/dist/index.js
CHANGED
|
@@ -3747,6 +3747,15 @@ function indent(value) {
|
|
|
3747
3747
|
function indentLines(values) {
|
|
3748
3748
|
return values.map(indent);
|
|
3749
3749
|
}
|
|
3750
|
+
|
|
3751
|
+
// src/ir/diagnostics.ts
|
|
3752
|
+
var DELIVERABILITY_DIAGNOSTIC_CODES = /* @__PURE__ */ new Set([
|
|
3753
|
+
"constraints.locked-target-not-moved",
|
|
3754
|
+
"routing.evidence.crossing_forbidden",
|
|
3755
|
+
"routing.obstacle.unavoidable",
|
|
3756
|
+
"route_obstacle_fallback",
|
|
3757
|
+
"routing.text-clearance.unresolved"
|
|
3758
|
+
]);
|
|
3750
3759
|
var DEFAULT_OPTIONS = {
|
|
3751
3760
|
nodesep: 80,
|
|
3752
3761
|
ranksep: 100,
|
|
@@ -3993,21 +4002,29 @@ function routeEdge(input) {
|
|
|
3993
4002
|
}
|
|
3994
4003
|
function finalizeRoute(points, softObstacles, hardObstacles, diagnostics) {
|
|
3995
4004
|
const simplified = simplifyRoute(points);
|
|
4005
|
+
if (simplified.length >= 3) {
|
|
4006
|
+
return simplified;
|
|
4007
|
+
}
|
|
3996
4008
|
const crossesHardObstacles = routeCrossesBoxes(simplified, hardObstacles);
|
|
3997
4009
|
const crossesSoftObstacles = routeCrossesBoxes(simplified, softObstacles);
|
|
3998
|
-
if (
|
|
4010
|
+
if (!crossesHardObstacles && !crossesSoftObstacles) {
|
|
4011
|
+
return simplified;
|
|
4012
|
+
}
|
|
4013
|
+
const expanded = expandFallbackRoute(simplified, [
|
|
4014
|
+
...softObstacles,
|
|
4015
|
+
...hardObstacles
|
|
4016
|
+
]);
|
|
4017
|
+
const expandedCrossesHard = routeCrossesBoxes(expanded, hardObstacles);
|
|
4018
|
+
const expandedCrossesSoft = routeCrossesBoxes(expanded, softObstacles);
|
|
4019
|
+
if (expandedCrossesHard || expandedCrossesSoft) {
|
|
3999
4020
|
diagnostics.push({
|
|
4000
|
-
severity:
|
|
4021
|
+
severity: expandedCrossesHard ? "error" : "warning",
|
|
4001
4022
|
code: "route_obstacle_fallback",
|
|
4002
4023
|
message: "Obstacle-aware routing fell back to fewer than three route points.",
|
|
4003
4024
|
detail: { pointCount: simplified.length }
|
|
4004
4025
|
});
|
|
4005
|
-
return expandFallbackRoute(simplified, [
|
|
4006
|
-
...softObstacles,
|
|
4007
|
-
...hardObstacles
|
|
4008
|
-
]);
|
|
4009
4026
|
}
|
|
4010
|
-
return
|
|
4027
|
+
return expanded;
|
|
4011
4028
|
}
|
|
4012
4029
|
function expandFallbackRoute(points, obstacles) {
|
|
4013
4030
|
if (points.length !== 2) {
|
|
@@ -4038,12 +4055,12 @@ function expandFallbackRoute(points, obstacles) {
|
|
|
4038
4055
|
const hv = diagonalDetourHV(source, target, obstacles);
|
|
4039
4056
|
const vh = diagonalDetourVH(source, target, obstacles);
|
|
4040
4057
|
const viable = [hv, vh].filter((c) => !routeCrossesBoxes(c, obstacles));
|
|
4041
|
-
|
|
4058
|
+
const [firstViable, ...remainingViable] = viable;
|
|
4059
|
+
if (firstViable !== void 0) {
|
|
4042
4060
|
const directLen = Math.hypot(target.x - source.x, target.y - source.y);
|
|
4043
|
-
let best =
|
|
4044
|
-
for (
|
|
4045
|
-
|
|
4046
|
-
if (cand !== void 0 && pathLength(cand) - directLen < pathLength(best) - directLen) {
|
|
4061
|
+
let best = firstViable;
|
|
4062
|
+
for (const cand of remainingViable) {
|
|
4063
|
+
if (pathLength(cand) - directLen < pathLength(best) - directLen) {
|
|
4047
4064
|
best = cand;
|
|
4048
4065
|
}
|
|
4049
4066
|
}
|
|
@@ -4629,6 +4646,7 @@ function solveDiagram(diagram, options = {}) {
|
|
|
4629
4646
|
];
|
|
4630
4647
|
const initialContentBounds = layoutBoxes.length === 0 ? { x: 0, y: 0, width: 0} : unionBoxes(layoutBoxes);
|
|
4631
4648
|
placeEvidenceBlocks(
|
|
4649
|
+
options.obstacleMargin ?? 0,
|
|
4632
4650
|
[
|
|
4633
4651
|
...coordinatedMatrices,
|
|
4634
4652
|
...coordinatedTables,
|
|
@@ -4695,17 +4713,33 @@ function solveDiagram(diagram, options = {}) {
|
|
|
4695
4713
|
...baseTextAnnotations.filter(isPreRouteTextObstacle),
|
|
4696
4714
|
...frameTextAnnotation.filter(isPreRouteTextObstacle)
|
|
4697
4715
|
];
|
|
4716
|
+
const margin = options.obstacleMargin ?? 0;
|
|
4717
|
+
const softObstacles = [
|
|
4718
|
+
...coordinatedTables.map((table) => expandBox(table.box, margin)),
|
|
4719
|
+
...coordinatedEvidencePanels.map((panel) => expandBox(panel.box, margin))
|
|
4720
|
+
];
|
|
4721
|
+
const hardObstacles = coordinatedMatrices.map(
|
|
4722
|
+
(matrix) => expandBox(matrix.box, margin)
|
|
4723
|
+
);
|
|
4724
|
+
const titleBarObstacles = [];
|
|
4725
|
+
if (frame !== void 0) {
|
|
4726
|
+
titleBarObstacles.push(expandBox(frame.titleBox, margin));
|
|
4727
|
+
}
|
|
4728
|
+
for (const swimlane of coordinatedSwimlanes) {
|
|
4729
|
+
for (const lane of swimlane.lanes) {
|
|
4730
|
+
if (lane.headerBox !== void 0 && lane.headerBox.width > 0 && lane.headerBox.height > 0) {
|
|
4731
|
+
titleBarObstacles.push(expandBox(lane.headerBox, margin));
|
|
4732
|
+
}
|
|
4733
|
+
}
|
|
4734
|
+
}
|
|
4698
4735
|
const coordinatedEdges = coordinateEdges(
|
|
4699
4736
|
styledEdges,
|
|
4700
4737
|
nodeGeometryById,
|
|
4701
4738
|
coordinatedNodes,
|
|
4702
4739
|
[...nodeGeometryById.values()].map((geometry) => geometry.obstacleBox),
|
|
4703
|
-
[
|
|
4704
|
-
...coordinatedTables.map((table) => table.box),
|
|
4705
|
-
...coordinatedEvidencePanels.map((panel) => panel.box)
|
|
4706
|
-
],
|
|
4740
|
+
[...softObstacles, ...titleBarObstacles],
|
|
4707
4741
|
routingTextObstacles,
|
|
4708
|
-
|
|
4742
|
+
hardObstacles,
|
|
4709
4743
|
diagram.direction,
|
|
4710
4744
|
options,
|
|
4711
4745
|
diagnostics
|
|
@@ -4740,6 +4774,16 @@ function solveDiagram(diagram, options = {}) {
|
|
|
4740
4774
|
options.pageBounds
|
|
4741
4775
|
)
|
|
4742
4776
|
);
|
|
4777
|
+
let degraded = false;
|
|
4778
|
+
const resultDiagnostics = diagnostics.map((diagnostic) => {
|
|
4779
|
+
if (DELIVERABILITY_DIAGNOSTIC_CODES.has(diagnostic.code)) {
|
|
4780
|
+
degraded = true;
|
|
4781
|
+
if (options.strict) {
|
|
4782
|
+
return { ...diagnostic, severity: "error" };
|
|
4783
|
+
}
|
|
4784
|
+
}
|
|
4785
|
+
return diagnostic;
|
|
4786
|
+
});
|
|
4743
4787
|
return {
|
|
4744
4788
|
id: diagram.id,
|
|
4745
4789
|
...diagram.title === void 0 ? {} : { title: diagram.title },
|
|
@@ -4751,7 +4795,8 @@ function solveDiagram(diagram, options = {}) {
|
|
|
4751
4795
|
...coordinatedMatrices.length === 0 ? {} : { matrices: coordinatedMatrices },
|
|
4752
4796
|
...coordinatedTables.length === 0 ? {} : { tables: coordinatedTables },
|
|
4753
4797
|
...coordinatedEvidencePanels.length === 0 ? {} : { evidencePanels: coordinatedEvidencePanels },
|
|
4754
|
-
diagnostics,
|
|
4798
|
+
diagnostics: resultDiagnostics,
|
|
4799
|
+
degraded,
|
|
4755
4800
|
bounds: frame === void 0 ? unionBoxes(boundsBase) : unionBoxes([...boundsBase, frame.box, frame.titleBox]),
|
|
4756
4801
|
...frame === void 0 ? {} : { frame },
|
|
4757
4802
|
...textAnnotations.length === 0 ? {} : { textAnnotations },
|
|
@@ -6140,16 +6185,25 @@ function blockBox(block, defaultSize) {
|
|
|
6140
6185
|
height: block.size?.height ?? defaultSize.height
|
|
6141
6186
|
};
|
|
6142
6187
|
}
|
|
6143
|
-
function placeEvidenceBlocks(blocks, contentBounds) {
|
|
6188
|
+
function placeEvidenceBlocks(obstacleMargin, blocks, contentBounds) {
|
|
6189
|
+
const margin = normalizeInsets(obstacleMargin);
|
|
6190
|
+
const horizontalGap = Math.max(
|
|
6191
|
+
DEFAULT_EVIDENCE_BLOCK_GAP,
|
|
6192
|
+
margin.right + margin.left
|
|
6193
|
+
);
|
|
6194
|
+
const verticalGap = Math.max(
|
|
6195
|
+
DEFAULT_EVIDENCE_BLOCK_GAP,
|
|
6196
|
+
margin.bottom + margin.top
|
|
6197
|
+
);
|
|
6144
6198
|
let nextY = contentBounds.y;
|
|
6145
|
-
const x = contentBounds.x + contentBounds.width +
|
|
6199
|
+
const x = contentBounds.x + contentBounds.width + horizontalGap;
|
|
6146
6200
|
for (const block of blocks) {
|
|
6147
6201
|
if (block.position !== void 0) {
|
|
6148
6202
|
continue;
|
|
6149
6203
|
}
|
|
6150
6204
|
block.box.x = x;
|
|
6151
6205
|
block.box.y = nextY;
|
|
6152
|
-
nextY += block.box.height +
|
|
6206
|
+
nextY += block.box.height + verticalGap;
|
|
6153
6207
|
}
|
|
6154
6208
|
}
|
|
6155
6209
|
function columnXOffsets(table, box) {
|
|
@@ -7378,6 +7432,6 @@ function isPointLikeRecord(value) {
|
|
|
7378
7432
|
return isPlainObject(value) && typeof value.x === "number" && typeof value.y === "number";
|
|
7379
7433
|
}
|
|
7380
7434
|
|
|
7381
|
-
export { DEFAULT_CANONICAL_PRECISION, DEFAULT_DSL_MAX_BYTES, DeterministicTextMeasurer, LabelFitter, PretextTextMeasurer, applyLayoutConstraints, assertFiniteNonNegative, assertFinitePositive, boxCenter, canonicalize, computeArrowhead, computeContainerGeometry, computeShapeGeometry, createDefaultTextMeasurer, expandBox, exportExcalidraw, exportSvg, fitLabel, getEdgePort, installNodeCanvasRuntime, intersectsAabb, isPretextRuntimeAvailable, normalizeDiagramDsl, normalizeInsets, parseDiagramDsl, parseEdgeShorthand, renderDiagramDsl, resolveLineHeight, resolveOutputFormat, routeEdge, runDagreInitialLayout, simplifyRoute, solveDiagram, solveDiagramSafe, sortDslDiagnostics, stringifyCanonical, toCanvasFont, unionBoxes, validateBox, validateTextStyle };
|
|
7435
|
+
export { DEFAULT_CANONICAL_PRECISION, DEFAULT_DSL_MAX_BYTES, DELIVERABILITY_DIAGNOSTIC_CODES, DeterministicTextMeasurer, LabelFitter, PretextTextMeasurer, applyLayoutConstraints, assertFiniteNonNegative, assertFinitePositive, boxCenter, canonicalize, computeArrowhead, computeContainerGeometry, computeShapeGeometry, createDefaultTextMeasurer, expandBox, exportExcalidraw, exportSvg, fitLabel, getEdgePort, installNodeCanvasRuntime, intersectsAabb, isPretextRuntimeAvailable, normalizeDiagramDsl, normalizeInsets, parseDiagramDsl, parseEdgeShorthand, renderDiagramDsl, resolveLineHeight, resolveOutputFormat, routeEdge, runDagreInitialLayout, simplifyRoute, solveDiagram, solveDiagramSafe, sortDslDiagnostics, stringifyCanonical, toCanvasFont, unionBoxes, validateBox, validateTextStyle };
|
|
7382
7436
|
//# sourceMappingURL=index.js.map
|
|
7383
7437
|
//# sourceMappingURL=index.js.map
|