@metronforge/concept-map 0.4.0 → 0.4.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/README.md +2 -2
- package/dist/layout/hints.d.ts +2 -2
- package/dist/layout/hints.d.ts.map +1 -1
- package/dist/layout/hints.js.map +1 -1
- package/dist/layout/index.d.ts +1 -6
- package/dist/layout/index.d.ts.map +1 -1
- package/dist/layout/index.js +1 -82
- package/dist/layout/index.js.map +1 -1
- package/dist/layout/layout.d.ts +7 -0
- package/dist/layout/layout.d.ts.map +1 -0
- package/dist/layout/layout.js +83 -0
- package/dist/layout/layout.js.map +1 -0
- package/dist/layout/place-sketch.d.ts +1 -1
- package/dist/layout/place-sketch.d.ts.map +1 -1
- package/dist/layout/place-sketch.js +5 -1
- package/dist/layout/place-sketch.js.map +1 -1
- package/dist/layout/relations/sketch-order.d.ts +3 -2
- package/dist/layout/relations/sketch-order.d.ts.map +1 -1
- package/dist/layout/relations/sketch-order.js +4 -3
- package/dist/layout/relations/sketch-order.js.map +1 -1
- package/dist/layout/relations/sketch-placement.d.ts +4 -3
- package/dist/layout/relations/sketch-placement.d.ts.map +1 -1
- package/dist/layout/relations/sketch-placement.js +8 -8
- package/dist/layout/relations/sketch-placement.js.map +1 -1
- package/dist/layout/sketch-conflicts.d.ts +8 -0
- package/dist/layout/sketch-conflicts.d.ts.map +1 -0
- package/dist/layout/sketch-conflicts.js +56 -0
- package/dist/layout/sketch-conflicts.js.map +1 -0
- package/dist/layout/sketch-route.d.ts +2 -1
- package/dist/layout/sketch-route.d.ts.map +1 -1
- package/dist/layout/sketch-route.js +6 -6
- package/dist/layout/sketch-route.js.map +1 -1
- package/dist/layout/stages/hints.d.ts.map +1 -1
- package/dist/layout/stages/hints.js +33 -15
- package/dist/layout/stages/hints.js.map +1 -1
- package/package.json +1 -1
- package/src/layout/hints.ts +2 -2
- package/src/layout/index.ts +1 -148
- package/src/layout/layout.ts +147 -0
- package/src/layout/place-sketch.ts +14 -9
- package/src/layout/relations/sketch-order.ts +12 -1
- package/src/layout/relations/sketch-placement.ts +11 -5
- package/src/layout/sketch-conflicts.ts +69 -0
- package/src/layout/sketch-route.ts +8 -5
- package/src/layout/stages/hints.ts +47 -19
package/README.md
CHANGED
|
@@ -55,11 +55,11 @@ Load the stylesheet, one module script and one element on an HTML page:
|
|
|
55
55
|
```html
|
|
56
56
|
<link
|
|
57
57
|
rel="stylesheet"
|
|
58
|
-
href="https://esm.sh/@metronforge/concept-map@0.4.
|
|
58
|
+
href="https://esm.sh/@metronforge/concept-map@0.4.1/css"
|
|
59
59
|
/>
|
|
60
60
|
<script
|
|
61
61
|
type="module"
|
|
62
|
-
src="https://esm.sh/@metronforge/concept-map@0.4.
|
|
62
|
+
src="https://esm.sh/@metronforge/concept-map@0.4.1/element"
|
|
63
63
|
></script>
|
|
64
64
|
<concept-map src="./map.json" layout="dagre"></concept-map>
|
|
65
65
|
```
|
package/dist/layout/hints.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SourceMap, ResolvedMap } from "../schema.js";
|
|
2
2
|
import type { Constraint } from "./problem.js";
|
|
3
|
-
import type { LayoutOptions, UnsupportedHint } from "./types.js";
|
|
3
|
+
import type { LayoutOptions, StatedHint, UnsupportedHint } from "./types.js";
|
|
4
4
|
export declare function statedHints(map: SourceMap | ResolvedMap): ({
|
|
5
5
|
origin: "stated";
|
|
6
6
|
path: string;
|
|
@@ -30,6 +30,6 @@ export declare function statedHints(map: SourceMap | ResolvedMap): ({
|
|
|
30
30
|
strength: "preferred" | "required";
|
|
31
31
|
})[];
|
|
32
32
|
/** Name source hints in capability refusals without losing their references. */
|
|
33
|
-
export declare function constraintName(constraint: Constraint): string;
|
|
33
|
+
export declare function constraintName(constraint: Constraint | StatedHint): string;
|
|
34
34
|
export declare function reportUnsupportedHints(constraints: readonly Constraint[], notify: LayoutOptions["onUnsupportedHints"], dropped?: readonly UnsupportedHint[]): void;
|
|
35
35
|
//# sourceMappingURL=hints.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hints.d.ts","sourceRoot":"","sources":["../../src/layout/hints.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"hints.d.ts","sourceRoot":"","sources":["../../src/layout/hints.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7E,wBAAgB,WAAW,CAAC,GAAG,EAAE,SAAS,GAAG,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;KAMvD;AAED,gFAAgF;AAChF,wBAAgB,cAAc,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,GAAG,MAAM,CAa1E;AAED,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,SAAS,UAAU,EAAE,EAClC,MAAM,EAAE,aAAa,CAAC,oBAAoB,CAAC,EAC3C,OAAO,GAAE,SAAS,eAAe,EAAO,GACvC,IAAI,CAuBN"}
|
package/dist/layout/hints.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hints.js","sourceRoot":"","sources":["../../src/layout/hints.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,WAAW,CAAC,GAA4B;IACtD,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CA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
-
import type { LayoutEngine, LayoutOptions } from "./types.js";
|
|
1
|
+
export { layout } from "./layout.js";
|
|
3
2
|
export { LayoutError, EngineFailedError, ResultRejectedError, UnsupportedConstraintsError, LayoutDefectsError, SameRankContradictionError, SameRankRoutingError, isSameRankContradictionError, isSameRankRoutingError, isLayoutError, isEngineFailedError, isResultRejectedError, isUnsupportedConstraintsError, isLayoutDefectsError, } from "./errors.js";
|
|
4
3
|
export type { SameRankHint, SameRankContradictionData, SameRankRoutingData, } from "./errors.js";
|
|
5
4
|
export type { Measurer } from "./ports.js";
|
|
@@ -11,8 +10,4 @@ export { measureLabel, fontTableMeasurer } from "./measure.js";
|
|
|
11
10
|
export { validateReferences } from "../schema/references.js";
|
|
12
11
|
export { check, describeDefects } from "./stages/report.js";
|
|
13
12
|
export type { Band, CheckOptions, Contact, LayoutReport, } from "./stages/report.js";
|
|
14
|
-
/** Validate first, then measure and lay out; complete hand geometry is retained.
|
|
15
|
-
* `layout` proposes a drawing; `check` judges it. Success here does not mean
|
|
16
|
-
* the drawing was checked unless `strict` is set. */
|
|
17
|
-
export declare function layout(input: unknown, engine: LayoutEngine, options?: LayoutOptions): Promise<ResolvedMap>;
|
|
18
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/layout/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/layout/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,mBAAmB,EACnB,2BAA2B,EAC3B,kBAAkB,EAClB,0BAA0B,EAC1B,oBAAoB,EACpB,4BAA4B,EAC5B,sBAAsB,EACtB,aAAa,EACb,mBAAmB,EACnB,qBAAqB,EACrB,6BAA6B,EAC7B,oBAAoB,GACrB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,YAAY,EACZ,yBAAyB,EACzB,mBAAmB,GACpB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,YAAY,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAChE,mBAAmB,YAAY,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC5D,YAAY,EACV,IAAI,EACJ,YAAY,EACZ,OAAO,EACP,YAAY,GACb,MAAM,oBAAoB,CAAC"}
|
package/dist/layout/index.js
CHANGED
|
@@ -1,89 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
import { parseMap } from "./check.js";
|
|
3
|
-
import { asMeasurer } from "./measure.js";
|
|
4
|
-
import { atWidth, needsWidthPass } from "./width.js";
|
|
5
|
-
import { refine } from "./stages/refine.js";
|
|
6
|
-
import { buildProblem, problemGraph } from "./build-problem.js";
|
|
7
|
-
import { reportUnsupportedHints } from "./hints.js";
|
|
8
|
-
import { asPlacer } from "./legacy.js";
|
|
9
|
-
import { placeWithHints } from "./place-with-hints.js";
|
|
10
|
-
import { checkConstraints } from "./stages/constraints.js";
|
|
11
|
-
import { resolveMeasured } from "./resolve-measured.js";
|
|
12
|
-
import { EngineFailedError, ResultRejectedError, UnsupportedConstraintsError, LayoutDefectsError, } from "./errors.js";
|
|
13
|
-
import { placeAnnotations } from "./stages/placement.js";
|
|
1
|
+
export { layout } from "./layout.js";
|
|
14
2
|
export { LayoutError, EngineFailedError, ResultRejectedError, UnsupportedConstraintsError, LayoutDefectsError, SameRankContradictionError, SameRankRoutingError, isSameRankContradictionError, isSameRankRoutingError, isLayoutError, isEngineFailedError, isResultRejectedError, isUnsupportedConstraintsError, isLayoutDefectsError, } from "./errors.js";
|
|
15
3
|
export { labelsInPanel } from "./stages/presentation.js";
|
|
16
4
|
export { refine } from "./stages/refine.js";
|
|
17
5
|
export { measureLabel, fontTableMeasurer } from "./measure.js";
|
|
18
6
|
export { validateReferences } from "../schema/references.js";
|
|
19
7
|
export { check, describeDefects } from "./stages/report.js";
|
|
20
|
-
/** Validate first, then measure and lay out; complete hand geometry is retained.
|
|
21
|
-
* `layout` proposes a drawing; `check` judges it. Success here does not mean
|
|
22
|
-
* the drawing was checked unless `strict` is set. */
|
|
23
|
-
export async function layout(input, engine, options = {}) {
|
|
24
|
-
const map = parseMap(input);
|
|
25
|
-
validateReferences(map);
|
|
26
|
-
if (options.widthEm !== undefined &&
|
|
27
|
-
(!Number.isFinite(options.widthEm) || options.widthEm <= 0))
|
|
28
|
-
throw new Error("widthEm must be a finite positive number");
|
|
29
|
-
const measurer = asMeasurer(options.measureLabel);
|
|
30
|
-
if ("viewBox" in map)
|
|
31
|
-
return strict(map, map, atWidth(measurer, map, options.widthEm).measure, options);
|
|
32
|
-
const resolved = await resolveAtWidth(map, engine, measurer, options);
|
|
33
|
-
return strict(map, resolved, atWidth(measurer, resolved, options.widthEm).measure, options);
|
|
34
|
-
}
|
|
35
|
-
async function resolveAtWidth(map, engine, measurer, options) {
|
|
36
|
-
let hints = [];
|
|
37
|
-
const collect = {
|
|
38
|
-
...options,
|
|
39
|
-
onUnsupportedHints: (items) => {
|
|
40
|
-
hints = items;
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
let resolved = await resolveSource(map, engine, measurer, collect);
|
|
44
|
-
if (options.widthEm !== undefined &&
|
|
45
|
-
needsWidthPass(resolved, options.widthEm)) {
|
|
46
|
-
hints = [];
|
|
47
|
-
resolved = await resolveSource(map, engine, atWidth(measurer, resolved, options.widthEm), collect, { measurer, widthEm: options.widthEm });
|
|
48
|
-
resolved = refine(resolved, atWidth(measurer, resolved, options.widthEm));
|
|
49
|
-
}
|
|
50
|
-
if (hints.length)
|
|
51
|
-
options.onUnsupportedHints?.(hints);
|
|
52
|
-
return resolved;
|
|
53
|
-
}
|
|
54
|
-
async function resolveSource(map, engine, measurer, options, refinement) {
|
|
55
|
-
const measure = measurer.measure.bind(measurer);
|
|
56
|
-
const problem = buildProblem(map, measure, options.intent);
|
|
57
|
-
const graph = problemGraph(problem);
|
|
58
|
-
const placer = asPlacer(engine);
|
|
59
|
-
const outcome = await placeWithHints(map, problem, placer, measurer, refinement, refinement ? undefined : options.widthEm);
|
|
60
|
-
if (outcome.kind === "engine-failed")
|
|
61
|
-
throw new EngineFailedError(outcome);
|
|
62
|
-
if (outcome.kind === "unsupported-constraints")
|
|
63
|
-
throw new UnsupportedConstraintsError(outcome);
|
|
64
|
-
reportUnsupportedHints(outcome.unsupported, options.onUnsupportedHints, outcome.dropped);
|
|
65
|
-
const resolved = resolveMeasured(map, graph, outcome.result, measurer);
|
|
66
|
-
checkRequired(map, resolved, placer.name);
|
|
67
|
-
validateReferences(resolved);
|
|
68
|
-
return placeAnnotations(resolved);
|
|
69
|
-
}
|
|
70
|
-
function checkRequired(map, resolved, placer) {
|
|
71
|
-
const rejected = checkConstraints(map, resolved).find((c) => c.strength === "required" && c.holds === false);
|
|
72
|
-
if (rejected)
|
|
73
|
-
throw new ResultRejectedError({
|
|
74
|
-
placer,
|
|
75
|
-
constraint: rejected.kind,
|
|
76
|
-
message: rejected.message,
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
/** The check is loaded only for `strict`, so plain layout stays small. */
|
|
80
|
-
async function strict(source, resolved, measure, options) {
|
|
81
|
-
if (!options.strict)
|
|
82
|
-
return resolved;
|
|
83
|
-
const { check, describeDefects } = await import("./stages/report.js");
|
|
84
|
-
const report = check(source, resolved, { measureLabel: measure });
|
|
85
|
-
if (!report.hard)
|
|
86
|
-
return resolved;
|
|
87
|
-
throw new LayoutDefectsError(report, `The layout has hard defects:\n${describeDefects(report).join("\n")}`);
|
|
88
|
-
}
|
|
89
8
|
//# sourceMappingURL=index.js.map
|
package/dist/layout/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/layout/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/layout/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,mBAAmB,EACnB,2BAA2B,EAC3B,kBAAkB,EAClB,0BAA0B,EAC1B,oBAAoB,EACpB,4BAA4B,EAC5B,sBAAsB,EACtB,aAAa,EACb,mBAAmB,EACnB,qBAAqB,EACrB,6BAA6B,EAC7B,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAOrB,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAG5C,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ResolvedMap } from "../schema.js";
|
|
2
|
+
import type { LayoutEngine, LayoutOptions } from "./types.js";
|
|
3
|
+
/** Validate first, then measure and lay out; complete hand geometry is retained.
|
|
4
|
+
* `layout` proposes a drawing; `check` judges it. Success here does not mean
|
|
5
|
+
* the drawing was checked unless `strict` is set. */
|
|
6
|
+
export declare function layout(input: unknown, engine: LayoutEngine, options?: LayoutOptions): Promise<ResolvedMap>;
|
|
7
|
+
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../src/layout/layout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAa,MAAM,cAAc,CAAC;AAc3D,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAmB,MAAM,YAAY,CAAC;AAQ/E;;qDAEqD;AACrD,wBAAsB,MAAM,CAC1B,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,YAAY,EACpB,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,WAAW,CAAC,CAuBtB"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { validateReferences } from "../schema/references.js";
|
|
2
|
+
import { parseMap } from "./check.js";
|
|
3
|
+
import { asMeasurer } from "./measure.js";
|
|
4
|
+
import { atWidth, needsWidthPass } from "./width.js";
|
|
5
|
+
import { refine } from "./stages/refine.js";
|
|
6
|
+
import { buildProblem, problemGraph } from "./build-problem.js";
|
|
7
|
+
import { reportUnsupportedHints } from "./hints.js";
|
|
8
|
+
import { asPlacer } from "./legacy.js";
|
|
9
|
+
import { placeWithHints } from "./place-with-hints.js";
|
|
10
|
+
import { checkConstraints } from "./stages/constraints.js";
|
|
11
|
+
import { resolveMeasured } from "./resolve-measured.js";
|
|
12
|
+
import { EngineFailedError, ResultRejectedError, UnsupportedConstraintsError, LayoutDefectsError, } from "./errors.js";
|
|
13
|
+
import { placeAnnotations } from "./stages/placement.js";
|
|
14
|
+
/** Validate first, then measure and lay out; complete hand geometry is retained.
|
|
15
|
+
* `layout` proposes a drawing; `check` judges it. Success here does not mean
|
|
16
|
+
* the drawing was checked unless `strict` is set. */
|
|
17
|
+
export async function layout(input, engine, options = {}) {
|
|
18
|
+
const map = parseMap(input);
|
|
19
|
+
validateReferences(map);
|
|
20
|
+
if (options.widthEm !== undefined &&
|
|
21
|
+
(!Number.isFinite(options.widthEm) || options.widthEm <= 0))
|
|
22
|
+
throw new Error("widthEm must be a finite positive number");
|
|
23
|
+
const measurer = asMeasurer(options.measureLabel);
|
|
24
|
+
if ("viewBox" in map)
|
|
25
|
+
return strict(map, map, atWidth(measurer, map, options.widthEm).measure, options);
|
|
26
|
+
const resolved = await resolveAtWidth(map, engine, measurer, options);
|
|
27
|
+
return strict(map, resolved, atWidth(measurer, resolved, options.widthEm).measure, options);
|
|
28
|
+
}
|
|
29
|
+
async function resolveAtWidth(map, engine, measurer, options) {
|
|
30
|
+
let hints = [];
|
|
31
|
+
const collect = {
|
|
32
|
+
...options,
|
|
33
|
+
onUnsupportedHints: (items) => {
|
|
34
|
+
hints = items;
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
let resolved = await resolveSource(map, engine, measurer, collect);
|
|
38
|
+
if (options.widthEm !== undefined &&
|
|
39
|
+
needsWidthPass(resolved, options.widthEm)) {
|
|
40
|
+
hints = [];
|
|
41
|
+
resolved = await resolveSource(map, engine, atWidth(measurer, resolved, options.widthEm), collect, { measurer, widthEm: options.widthEm });
|
|
42
|
+
resolved = refine(resolved, atWidth(measurer, resolved, options.widthEm));
|
|
43
|
+
}
|
|
44
|
+
if (hints.length)
|
|
45
|
+
options.onUnsupportedHints?.(hints);
|
|
46
|
+
return resolved;
|
|
47
|
+
}
|
|
48
|
+
async function resolveSource(map, engine, measurer, options, refinement) {
|
|
49
|
+
const measure = measurer.measure.bind(measurer);
|
|
50
|
+
const problem = buildProblem(map, measure, options.intent);
|
|
51
|
+
const graph = problemGraph(problem);
|
|
52
|
+
const placer = asPlacer(engine);
|
|
53
|
+
const outcome = await placeWithHints(map, problem, placer, measurer, refinement, refinement ? undefined : options.widthEm);
|
|
54
|
+
if (outcome.kind === "engine-failed")
|
|
55
|
+
throw new EngineFailedError(outcome);
|
|
56
|
+
if (outcome.kind === "unsupported-constraints")
|
|
57
|
+
throw new UnsupportedConstraintsError(outcome);
|
|
58
|
+
reportUnsupportedHints(outcome.unsupported, options.onUnsupportedHints, outcome.dropped);
|
|
59
|
+
const resolved = resolveMeasured(map, graph, outcome.result, measurer);
|
|
60
|
+
checkRequired(map, resolved, placer.name);
|
|
61
|
+
validateReferences(resolved);
|
|
62
|
+
return placeAnnotations(resolved);
|
|
63
|
+
}
|
|
64
|
+
function checkRequired(map, resolved, placer) {
|
|
65
|
+
const rejected = checkConstraints(map, resolved).find((c) => c.strength === "required" && c.holds === false);
|
|
66
|
+
if (rejected)
|
|
67
|
+
throw new ResultRejectedError({
|
|
68
|
+
placer,
|
|
69
|
+
constraint: rejected.kind,
|
|
70
|
+
message: rejected.message,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/** The check is loaded only for `strict`, so plain layout stays small. */
|
|
74
|
+
async function strict(source, resolved, measure, options) {
|
|
75
|
+
if (!options.strict)
|
|
76
|
+
return resolved;
|
|
77
|
+
const { check, describeDefects } = await import("./stages/report.js");
|
|
78
|
+
const report = check(source, resolved, { measureLabel: measure });
|
|
79
|
+
if (!report.hard)
|
|
80
|
+
return resolved;
|
|
81
|
+
throw new LayoutDefectsError(report, `The layout has hard defects:\n${describeDefects(report).join("\n")}`);
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.js","sourceRoot":"","sources":["../../src/layout/layout.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM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;AAC1E,KAAK,UAAU,MAAM,CACnB,MAA+B,EAC/B,QAAqB,EACrB,OAA2C,EAC3C,OAAsB;IAEtB,IAAI,CAAC,OAAO,CAAC,MAAM;QAAE,OAAO,QAAQ,CAAC;IACrC,MAAM,EAAE,KAAK,EAAE,eAAe,EAAE,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,CAAC;IACtE,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC,CAAC;IAClE,IAAI,CAAC,MAAM,CAAC,IAAI;QAAE,OAAO,QAAQ,CAAC;IAClC,MAAM,IAAI,kBAAkB,CAC1B,MAAM,EACN,iCAAiC,eAAe,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACtE,CAAC;AACJ,CAAC"}
|
|
@@ -4,6 +4,7 @@ import type { Measurer, Placer } from "./ports.js";
|
|
|
4
4
|
import type { RouteRefinement } from "./inspect-routes.js";
|
|
5
5
|
/** Optional preferred-pin pass after an engine places the boxes. */
|
|
6
6
|
export declare function placeSketch(source: SourceMap, problem: LayoutProblem, placer: Placer, measurer: Measurer, refinement?: RouteRefinement, sizingWidthEm?: number): Promise<import("./outcomes.js").EngineFailure | import("./outcomes.js").UnsupportedConstraints | {
|
|
7
|
+
dropped: import("./types.js").UnsupportedHint[];
|
|
7
8
|
unsupported: (({
|
|
8
9
|
strength: import("./problem.js").Strength;
|
|
9
10
|
origin?: "stated";
|
|
@@ -69,6 +70,5 @@ export declare function placeSketch(source: SourceMap, problem: LayoutProblem, p
|
|
|
69
70
|
}))[];
|
|
70
71
|
result: import("./types.js").LayoutResult;
|
|
71
72
|
kind: "placed";
|
|
72
|
-
dropped?: readonly import("./types.js").UnsupportedHint[];
|
|
73
73
|
}>;
|
|
74
74
|
//# sourceMappingURL=place-sketch.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"place-sketch.d.ts","sourceRoot":"","sources":["../../src/layout/place-sketch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"place-sketch.d.ts","sourceRoot":"","sources":["../../src/layout/place-sketch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAM3D,oEAAoE;AACpE,wBAAsB,WAAW,CAC/B,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,aAAa,EACtB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,UAAU,CAAC,EAAE,eAAe,EAC5B,aAAa,CAAC,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsBvB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { place } from "./place.js";
|
|
2
2
|
import { problemGraph } from "./build-problem.js";
|
|
3
|
+
import { sketchConflicts } from "./sketch-conflicts.js";
|
|
3
4
|
import { routeSketch } from "./sketch-route.js";
|
|
4
5
|
/** Optional preferred-pin pass after an engine places the boxes. */
|
|
5
6
|
export async function placeSketch(source, problem, placer, measurer, refinement, sizingWidthEm) {
|
|
@@ -7,10 +8,13 @@ export async function placeSketch(source, problem, placer, measurer, refinement,
|
|
|
7
8
|
if (outcome.kind !== "placed")
|
|
8
9
|
return outcome;
|
|
9
10
|
const graph = problemGraph(problem);
|
|
11
|
+
const diagnostics = sketchConflicts(problem);
|
|
12
|
+
const result = routeSketch(source, problem, graph, outcome.result, measurer, refinement, sizingWidthEm, diagnostics.record);
|
|
10
13
|
return {
|
|
11
14
|
...outcome,
|
|
15
|
+
dropped: diagnostics.hints,
|
|
12
16
|
unsupported: outcome.unsupported.filter((hint) => hint.kind !== "pin"),
|
|
13
|
-
result
|
|
17
|
+
result,
|
|
14
18
|
};
|
|
15
19
|
}
|
|
16
20
|
//# sourceMappingURL=place-sketch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"place-sketch.js","sourceRoot":"","sources":["../../src/layout/place-sketch.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,oEAAoE;AACpE,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAAiB,EACjB,OAAsB,EACtB,MAAc,EACd,QAAkB,EAClB,UAA4B,EAC5B,aAAsB;IAEtB,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC7C,IAAI,OAAO,CAAC,IAAI,KAAK,QAAQ;QAAE,OAAO,OAAO,CAAC;IAC9C,MAAM,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;IACpC,
|
|
1
|
+
{"version":3,"file":"place-sketch.js","sourceRoot":"","sources":["../../src/layout/place-sketch.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,oEAAoE;AACpE,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAAiB,EACjB,OAAsB,EACtB,MAAc,EACd,QAAkB,EAClB,UAA4B,EAC5B,aAAsB;IAEtB,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC7C,IAAI,OAAO,CAAC,IAAI,KAAK,QAAQ;QAAE,OAAO,OAAO,CAAC;IAC9C,MAAM,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;IACpC,MAAM,WAAW,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;IAC7C,MAAM,MAAM,GAAG,WAAW,CACxB,MAAM,EACN,OAAO,EACP,KAAK,EACL,OAAO,CAAC,MAAM,EACd,QAAQ,EACR,UAAU,EACV,aAAa,EACb,WAAW,CAAC,MAAM,CACnB,CAAC;IACF,OAAO;QACL,GAAG,OAAO;QACV,OAAO,EAAE,WAAW,CAAC,KAAK;QAC1B,WAAW,EAAE,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,KAAK,CAAC;QACtE,MAAM;KACP,CAAC;AACJ,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { LayoutProblem } from "../problem.js";
|
|
2
2
|
import type { DifferenceRelation, RelationSystem } from "./types.js";
|
|
3
|
+
export type RecordSketchConflict = (relation: DifferenceRelation, cycle: readonly string[]) => void;
|
|
3
4
|
/** Restore the engine bound for each sketch pair in a checked positive cycle. */
|
|
4
|
-
export declare function restoreConflicts(system: RelationSystem, originals: ReadonlyMap<string, DifferenceRelation | null
|
|
5
|
-
export declare function followSketchOrder(problem: LayoutProblem, system: RelationSystem, cross: 0 | 1, gap: number): DifferenceRelation[] | null;
|
|
5
|
+
export declare function restoreConflicts(system: RelationSystem, originals: ReadonlyMap<string, DifferenceRelation | null>, record?: RecordSketchConflict): DifferenceRelation[] | null;
|
|
6
|
+
export declare function followSketchOrder(problem: LayoutProblem, system: RelationSystem, cross: 0 | 1, gap: number, record?: RecordSketchConflict): DifferenceRelation[] | null;
|
|
6
7
|
//# sourceMappingURL=sketch-order.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sketch-order.d.ts","sourceRoot":"","sources":["../../../src/layout/relations/sketch-order.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAGnD,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAErE,iFAAiF;AACjF,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,cAAc,EACtB,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,kBAAkB,GAAG,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"sketch-order.d.ts","sourceRoot":"","sources":["../../../src/layout/relations/sketch-order.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAGnD,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAErE,MAAM,MAAM,oBAAoB,GAAG,CACjC,QAAQ,EAAE,kBAAkB,EAC5B,KAAK,EAAE,SAAS,MAAM,EAAE,KACrB,IAAI,CAAC;AAEV,iFAAiF;AACjF,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,cAAc,EACtB,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,kBAAkB,GAAG,IAAI,CAAC,EACzD,MAAM,CAAC,EAAE,oBAAoB,GAC5B,kBAAkB,EAAE,GAAG,IAAI,CAwB7B;AAYD,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,aAAa,EACtB,MAAM,EAAE,cAAc,EACtB,KAAK,EAAE,CAAC,GAAG,CAAC,EACZ,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,oBAAoB,GAC5B,kBAAkB,EAAE,GAAG,IAAI,CA+B7B"}
|
|
@@ -2,7 +2,7 @@ import { rankTick } from "./sketch-ranks.js";
|
|
|
2
2
|
import { checkRelations } from "./check.js";
|
|
3
3
|
import { solveRelations } from "./solve.js";
|
|
4
4
|
/** Restore the engine bound for each sketch pair in a checked positive cycle. */
|
|
5
|
-
export function restoreConflicts(system, originals) {
|
|
5
|
+
export function restoreConflicts(system, originals, record) {
|
|
6
6
|
const dropped = [];
|
|
7
7
|
for (;;) {
|
|
8
8
|
const result = solveRelations(system);
|
|
@@ -17,6 +17,7 @@ export function restoreConflicts(system, originals) {
|
|
|
17
17
|
if (engine === undefined || !pairs.has(relation.id))
|
|
18
18
|
return relation;
|
|
19
19
|
dropped.push(relation);
|
|
20
|
+
record?.(relation, result.cycle.map((source) => source.id));
|
|
20
21
|
return engine ?? [];
|
|
21
22
|
});
|
|
22
23
|
if (dropped.length === count)
|
|
@@ -29,7 +30,7 @@ function preferredPins(problem) {
|
|
|
29
30
|
? [[c.node, c.position]]
|
|
30
31
|
: []));
|
|
31
32
|
}
|
|
32
|
-
export function followSketchOrder(problem, system, cross, gap) {
|
|
33
|
+
export function followSketchOrder(problem, system, cross, gap, record) {
|
|
33
34
|
const rank = 1 - cross;
|
|
34
35
|
const pins = preferredPins(problem);
|
|
35
36
|
const originals = new Map();
|
|
@@ -61,6 +62,6 @@ export function followSketchOrder(problem, system, cross, gap) {
|
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
|
-
return restoreConflicts(system, originals);
|
|
65
|
+
return restoreConflicts(system, originals, record);
|
|
65
66
|
}
|
|
66
67
|
//# sourceMappingURL=sketch-order.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sketch-order.js","sourceRoot":"","sources":["../../../src/layout/relations/sketch-order.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,cAAc,EAAE,MAAM,Y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IAAI,EAAE,CAAC;YAC3B,IAAI,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC;gBACjE,SAAS;YACX,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,IAAI,EAAE,EAAE,CAAC;gBAAE,SAAS;YACpD,MAAM,EAAE,GAAG,UAAU,IAAI,IAAI,EAAE,EAAE,CAAC;YAClC,MAAM,KAAK,GAAuB;gBAChC,EAAE;gBACF,IAAI;gBACJ,EAAE;gBACF,IAAI,EAAE,SAAS;gBACf,GAAG;gBACH,IAAI,EAAE,IAAI;aACX,CAAC;YACF,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;YACtD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;gBAC1B,iEAAiE;gBACjE,SAAS,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;gBACxB,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC/B,CAAC;iBAAM,CAAC;gBACN,SAAS,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;gBAC7C,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC;YACpC,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;AACrD,CAAC"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import type { LayoutProblem } from "../problem.js";
|
|
2
2
|
import type { LayoutResult } from "../types.js";
|
|
3
|
+
import type { RecordSketchConflict } from "./sketch-order.js";
|
|
3
4
|
/** Propose certified cross-axis positions after engine placement. Rank
|
|
4
5
|
* coordinates stay fixed; boxes sharing a rank follow their sketch pins.
|
|
5
6
|
* Routing and quality inspection decide separately whether to use the result.
|
|
6
7
|
*/
|
|
7
|
-
export declare function sketchPlacement(problem: LayoutProblem, original: LayoutResult, minimum?: number, sketchOrder?: boolean): LayoutResult["nodes"] | null;
|
|
8
|
+
export declare function sketchPlacement(problem: LayoutProblem, original: LayoutResult, minimum?: number, sketchOrder?: boolean, record?: RecordSketchConflict): LayoutResult["nodes"] | null;
|
|
8
9
|
/** The rank axis fits pin centres subject to forward-arrow gaps. */
|
|
9
|
-
export declare function sketchRankPlacement(problem: LayoutProblem, original: LayoutResult, groupRanks?: boolean): {
|
|
10
|
+
export declare function sketchRankPlacement(problem: LayoutProblem, original: LayoutResult, groupRanks?: boolean, record?: RecordSketchConflict): {
|
|
10
11
|
[k: string]: import("../types.js").LayoutBox;
|
|
11
12
|
} | null;
|
|
12
|
-
export declare function sketchPlacements(problem: LayoutProblem, original: LayoutResult): (Record<string, import("../types.js").LayoutBox> | null)[];
|
|
13
|
+
export declare function sketchPlacements(problem: LayoutProblem, original: LayoutResult, record?: RecordSketchConflict): (Record<string, import("../types.js").LayoutBox> | null)[];
|
|
13
14
|
//# sourceMappingURL=sketch-placement.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sketch-placement.d.ts","sourceRoot":"","sources":["../../../src/layout/relations/sketch-placement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"sketch-placement.d.ts","sourceRoot":"","sources":["../../../src/layout/relations/sketch-placement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAShD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAwB9D;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,aAAa,EACtB,QAAQ,EAAE,YAAY,EACtB,OAAO,CAAC,EAAE,MAAM,EAChB,WAAW,UAAO,EAClB,MAAM,CAAC,EAAE,oBAAoB,GAC5B,YAAY,CAAC,OAAO,CAAC,GAAG,IAAI,CAiB9B;AA0CD,oEAAoE;AACpE,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,aAAa,EACtB,QAAQ,EAAE,YAAY,EACtB,UAAU,UAAQ,EAClB,MAAM,CAAC,EAAE,oBAAoB;;SAe9B;AAgCD,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,aAAa,EACtB,QAAQ,EAAE,YAAY,EACtB,MAAM,CAAC,EAAE,oBAAoB,8DAe9B"}
|
|
@@ -23,14 +23,14 @@ function pinObjective(problem, graph, axis) {
|
|
|
23
23
|
* coordinates stay fixed; boxes sharing a rank follow their sketch pins.
|
|
24
24
|
* Routing and quality inspection decide separately whether to use the result.
|
|
25
25
|
*/
|
|
26
|
-
export function sketchPlacement(problem, original, minimum, sketchOrder = true) {
|
|
26
|
+
export function sketchPlacement(problem, original, minimum, sketchOrder = true, record) {
|
|
27
27
|
const direction = problem.constraints.find((c) => c.kind === "direction");
|
|
28
28
|
const cross = direction?.direction === "right" ? 1 : 0;
|
|
29
29
|
const gap = 16;
|
|
30
30
|
const system = crossRelations(problem, original.nodes, gap, minimum);
|
|
31
31
|
containMembers(problem, original, system, cross);
|
|
32
32
|
if (sketchOrder
|
|
33
|
-
? !followSketchOrder(problem, system, cross, gap)
|
|
33
|
+
? !followSketchOrder(problem, system, cross, gap, record)
|
|
34
34
|
: solveRelations(system).status === "contradictory")
|
|
35
35
|
return null;
|
|
36
36
|
const graph = normalizeRelations(system);
|
|
@@ -70,7 +70,7 @@ function containMembers(problem, original, system, axis, preserveHeading = false
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
/** The rank axis fits pin centres subject to forward-arrow gaps. */
|
|
73
|
-
export function sketchRankPlacement(problem, original, groupRanks = false) {
|
|
73
|
+
export function sketchRankPlacement(problem, original, groupRanks = false, record) {
|
|
74
74
|
const direction = problem.constraints.find((c) => c.kind === "direction");
|
|
75
75
|
const rank = direction?.direction === "right" ? 0 : 1;
|
|
76
76
|
const system = rankRelations(problem, original.nodes, 64, 0);
|
|
@@ -79,7 +79,7 @@ export function sketchRankPlacement(problem, original, groupRanks = false) {
|
|
|
79
79
|
if (groupRanks && !groups.length)
|
|
80
80
|
return null;
|
|
81
81
|
system.relations.push(...groups);
|
|
82
|
-
if (!restoreConflicts(system, new Map(groups.map((r) => [r.id, null]))))
|
|
82
|
+
if (!restoreConflicts(system, new Map(groups.map((r) => [r.id, null])), record))
|
|
83
83
|
return null;
|
|
84
84
|
const graph = normalizeRelations(system);
|
|
85
85
|
return placeAxis(original, graph, rank, pinObjective(problem, graph, rank));
|
|
@@ -107,16 +107,16 @@ function placeAxis(original, graph, axis, terms) {
|
|
|
107
107
|
throw error;
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
-
export function sketchPlacements(problem, original) {
|
|
110
|
+
export function sketchPlacements(problem, original, record) {
|
|
111
111
|
const placements = [
|
|
112
112
|
sketchPlacement(problem, original, 0, false),
|
|
113
|
-
sketchPlacement(problem, original, 0),
|
|
113
|
+
sketchPlacement(problem, original, 0, true, record),
|
|
114
114
|
];
|
|
115
115
|
for (const grouped of [false, true]) {
|
|
116
|
-
const ranked = sketchRankPlacement(problem, original, grouped);
|
|
116
|
+
const ranked = sketchRankPlacement(problem, original, grouped, record);
|
|
117
117
|
if (!ranked)
|
|
118
118
|
continue;
|
|
119
|
-
placements.push(ranked, sketchPlacement(problem, { ...original, nodes: ranked }, 0));
|
|
119
|
+
placements.push(ranked, sketchPlacement(problem, { ...original, nodes: ranked }, 0, true, record));
|
|
120
120
|
}
|
|
121
121
|
return placements;
|
|
122
122
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sketch-placement.js","sourceRoot":"","sources":["../../../src/layout/relations/sketch-placement.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"sketch-placement.js","sourceRoot":"","sources":["../../../src/layout/relations/sketch-placement.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAExE,4EAA4E;AAC5E,SAAS,YAAY,CACnB,OAAsB,EACtB,KAAoB,EACpB,IAAW;IAEX,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACtE,OAAO,OAAO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
+
import type { RecordSketchConflict } from "./relations/sketch-order.js";
|
|
4
|
+
export declare function sketchConflicts(problem: LayoutProblem): {
|
|
5
|
+
hints: UnsupportedHint[];
|
|
6
|
+
record: RecordSketchConflict;
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=sketch-conflicts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sketch-conflicts.d.ts","sourceRoot":"","sources":["../../src/layout/sketch-conflicts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGlD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AA+BxE,wBAAgB,eAAe,CAAC,OAAO,EAAE,aAAa;;;EAiCrD"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { sketchRanks } from "./relations/sketch-ranks.js";
|
|
2
|
+
import { hintRelations } from "./relations/rank.js";
|
|
3
|
+
/** Translate checked solver cycles to the author's pin and lane paths. */
|
|
4
|
+
function conflictPaths(problem, pins) {
|
|
5
|
+
const pairs = new Map();
|
|
6
|
+
for (const from of pins.keys())
|
|
7
|
+
for (const to of pins.keys())
|
|
8
|
+
pairs.set(`sketch.${from}:${to}`, [from, to]);
|
|
9
|
+
const direction = problem.constraints.find((hint) => hint.kind === "direction");
|
|
10
|
+
for (const relation of hintRelations(sketchRanks(problem, direction?.direction === "right" ? 0 : 1)))
|
|
11
|
+
pairs.set(relation.id, [relation.from, relation.to]);
|
|
12
|
+
const paths = new Map([...pairs].map(([id, nodes]) => [
|
|
13
|
+
id,
|
|
14
|
+
nodes.map((node) => pins.get(node).path),
|
|
15
|
+
]));
|
|
16
|
+
for (const node of problem.nodes) {
|
|
17
|
+
if (!node.lane)
|
|
18
|
+
continue;
|
|
19
|
+
paths.set(`lane.start.${node.id}`, [`lanes.${node.lane}`]);
|
|
20
|
+
paths.set(`lane.end.${node.id}`, [`lanes.${node.lane}`]);
|
|
21
|
+
}
|
|
22
|
+
return paths;
|
|
23
|
+
}
|
|
24
|
+
export function sketchConflicts(problem) {
|
|
25
|
+
const pins = new Map(problem.constraints.flatMap((hint) => hint.kind === "pin" && hint.strength === "preferred" && hint.path
|
|
26
|
+
? [[hint.node, hint]]
|
|
27
|
+
: []));
|
|
28
|
+
const paths = conflictPaths(problem, pins);
|
|
29
|
+
const hints = [];
|
|
30
|
+
const seen = new Set();
|
|
31
|
+
const record = (relation, cycle) => {
|
|
32
|
+
const conflicts = cycle.flatMap((id) => paths.get(id) ?? [id]);
|
|
33
|
+
for (const node of [relation.from, relation.to]) {
|
|
34
|
+
const pin = pins.get(node);
|
|
35
|
+
if (!pin)
|
|
36
|
+
continue;
|
|
37
|
+
const hint = {
|
|
38
|
+
kind: "pin",
|
|
39
|
+
node,
|
|
40
|
+
at: [...pin.position],
|
|
41
|
+
strength: pin.strength,
|
|
42
|
+
origin: "stated",
|
|
43
|
+
path: pin.path,
|
|
44
|
+
reason: "contradiction",
|
|
45
|
+
conflicts,
|
|
46
|
+
};
|
|
47
|
+
const key = JSON.stringify(hint);
|
|
48
|
+
if (seen.has(key))
|
|
49
|
+
continue;
|
|
50
|
+
seen.add(key);
|
|
51
|
+
hints.push(hint);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
return { hints, record };
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=sketch-conflicts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sketch-conflicts.js","sourceRoot":"","sources":["../../src/layout/sketch-conflicts.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,0EAA0E;AAC1E,SAAS,aAAa,CACpB,OAAsB,EACtB,IAA4C;IAE5C,MAAM,KAAK,GAAG,IAA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