@dxos/diagram 0.13.0 → 0.14.0
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/lib/chunk-parse.mjs +20 -10
- package/dist/lib/chunk-parse.mjs.map +1 -1
- package/dist/types/src/nudge.d.ts.map +1 -1
- package/dist/types/src/scene.d.ts +9 -9
- package/dist/types/src/scene.d.ts.map +1 -1
- package/dist/types/src/semantic-engine.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/dsl/semantic.test.ts +16 -0
- package/src/nudge.test.ts +31 -0
- package/src/nudge.ts +4 -2
- package/src/scene.ts +2 -2
- package/src/semantic-engine.ts +9 -6
- package/src/view.ts +1 -1
package/dist/lib/chunk-parse.mjs
CHANGED
|
@@ -180,7 +180,11 @@ var ArrowHead = Schema.Literals([
|
|
|
180
180
|
"crowsfoot",
|
|
181
181
|
"none"
|
|
182
182
|
]);
|
|
183
|
-
var ArrowTail = Schema.Literals([
|
|
183
|
+
var ArrowTail = Schema.Literals([
|
|
184
|
+
"none",
|
|
185
|
+
"circle",
|
|
186
|
+
"arrow"
|
|
187
|
+
]);
|
|
184
188
|
/**
|
|
185
189
|
* What a connector means, in UML and ER terms; renderers derive its end markers and dash from it.
|
|
186
190
|
* The source end is the subtype (inheritance, implementation), the whole (composition), the owner
|
|
@@ -264,7 +268,7 @@ var Arrow = Schema.Struct({
|
|
|
264
268
|
end: Schema.optional(Point).annotate({ description: "Explicit end (used when `to` is omitted)." }),
|
|
265
269
|
text: Schema.optional(Schema.String).annotate({ description: "Label at the arrow midpoint." }),
|
|
266
270
|
head: Schema.optional(ArrowHead).annotate({ description: "Marker at the target end (default arrow): triangle for inheritance, crowsfoot for has-many." }),
|
|
267
|
-
tail: Schema.optional(ArrowTail).annotate({ description: "Marker at the source end (default none): circle for containment." }),
|
|
271
|
+
tail: Schema.optional(ArrowTail).annotate({ description: "Marker at the source end (default none): circle for containment, arrow for a two-way connector." }),
|
|
268
272
|
relation: Schema.optional(Relation).annotate({ description: "What the connector means; sets its markers: inheritance and implementation (hollow triangle at the target), composition and aggregation (filled or hollow diamond at the source, the whole), one-to-many (bar at the source, crow’s foot at the target), many-to-many, dependency (dashed, open arrow), association." }),
|
|
269
273
|
...styleFields
|
|
270
274
|
});
|
|
@@ -2807,7 +2811,10 @@ var HEADS = {
|
|
|
2807
2811
|
crowsfoot: "crow's foot head",
|
|
2808
2812
|
none: "no head"
|
|
2809
2813
|
};
|
|
2810
|
-
var TAILS = {
|
|
2814
|
+
var TAILS = {
|
|
2815
|
+
circle: "dot at the start",
|
|
2816
|
+
arrow: "arrowhead at the start"
|
|
2817
|
+
};
|
|
2811
2818
|
/** A path's markers in words, e.g. "dashed, hollow triangle head", or undefined for a plain arrow. */
|
|
2812
2819
|
var describe = (style) => {
|
|
2813
2820
|
const parts = [
|
|
@@ -4047,7 +4054,8 @@ var separate$1 = (lines, channel, paths, obstacles, spacing, margin) => {
|
|
|
4047
4054
|
if (!valid) continue;
|
|
4048
4055
|
const overlaps = pairCount(candidate, changed, shared, true);
|
|
4049
4056
|
const crossings = pairCount(candidate, changed, crosses$1);
|
|
4050
|
-
|
|
4057
|
+
const overlapsBefore = pairCount(lines, changed, shared, true);
|
|
4058
|
+
if (overlaps >= overlapsBefore || crossings - pairCount(lines, changed, crosses$1) > overlapsBefore - overlaps || obstructed(candidate, changed) > obstructed(lines, changed)) continue;
|
|
4051
4059
|
const travel = [...offsets.values()].reduce((total, offset) => total + Math.abs(offset), 0);
|
|
4052
4060
|
if (!best || overlaps < best.overlaps || overlaps === best.overlaps && (crossings < best.crossings || crossings === best.crossings && (reversed < best.reversed || reversed === best.reversed && travel < best.travel))) best = {
|
|
4053
4061
|
lines: candidate,
|
|
@@ -7764,8 +7772,9 @@ var MAX_W = 192;
|
|
|
7764
7772
|
var MIN_H = 96;
|
|
7765
7773
|
var PAD_X = 32;
|
|
7766
7774
|
var PAD_Y = 16;
|
|
7767
|
-
/** Frame inset around a group's members
|
|
7775
|
+
/** Frame inset around a group's members, the same on every side; the title sits in the top inset. */
|
|
7768
7776
|
var FRAME_PAD = 32;
|
|
7777
|
+
/** Room a frame's title takes above its members, when sizing the default pitch. */
|
|
7769
7778
|
var FRAME_LABEL_H = 32;
|
|
7770
7779
|
/** Extra gutter where two frames face each other across a row gutter, so packages read as separate. */
|
|
7771
7780
|
var FRAME_STACK_GAP = 64;
|
|
@@ -7870,15 +7879,16 @@ var geometry = (diagram, cells, box, pitch) => {
|
|
|
7870
7879
|
});
|
|
7871
7880
|
return Math.max(stacked ? FRAME_STACK_GAP : 0, ...gaps);
|
|
7872
7881
|
};
|
|
7882
|
+
const whole = (extra, step) => diagram.grid && extra > 0 ? Math.ceil(extra / step) * step : extra;
|
|
7873
7883
|
const colX = /* @__PURE__ */ new Map();
|
|
7874
7884
|
for (let col = minCol, x = minCol * pitch.w; col <= maxCol; col++) {
|
|
7875
7885
|
colX.set(col, x);
|
|
7876
|
-
x += pitch.w + extraAfterCol(col);
|
|
7886
|
+
x += pitch.w + whole(extraAfterCol(col), pitch.w);
|
|
7877
7887
|
}
|
|
7878
7888
|
const rowY = /* @__PURE__ */ new Map();
|
|
7879
7889
|
for (let row = minRow, y = minRow * pitch.h; row <= maxRow; row++) {
|
|
7880
7890
|
rowY.set(row, y);
|
|
7881
|
-
y += pitch.h + extraAfterRow(row);
|
|
7891
|
+
y += pitch.h + whole(extraAfterRow(row), pitch.h);
|
|
7882
7892
|
}
|
|
7883
7893
|
const at = (lookup, min, max, step, value) => value < min ? (lookup.get(min) ?? 0) - (min - value) * step : value > max ? (lookup.get(max) ?? 0) + (value - max) * step : lookup.get(value) ?? 0;
|
|
7884
7894
|
const fractional = (lookup, min, max, step, size) => (value) => {
|
|
@@ -7910,7 +7920,7 @@ var geometry = (diagram, cells, box, pitch) => {
|
|
|
7910
7920
|
const members = diagram.nodes.filter((node) => node.group === group.id).flatMap((node) => rects.get(node.id) ?? []);
|
|
7911
7921
|
if (members.length === 0) continue;
|
|
7912
7922
|
const x = Math.min(...members.map((rect) => rect.x)) - FRAME_PAD;
|
|
7913
|
-
const y = Math.min(...members.map((rect) => rect.y)) - FRAME_PAD
|
|
7923
|
+
const y = Math.min(...members.map((rect) => rect.y)) - FRAME_PAD;
|
|
7914
7924
|
const right = Math.max(...members.map((rect) => rect.x + rect.w)) + FRAME_PAD;
|
|
7915
7925
|
const bottom = Math.max(...members.map((rect) => rect.y + rect.h)) + FRAME_PAD;
|
|
7916
7926
|
frames.set(group.id, {
|
|
@@ -7925,7 +7935,7 @@ var geometry = (diagram, cells, box, pitch) => {
|
|
|
7925
7935
|
const frame = frames.get(group.id);
|
|
7926
7936
|
return frame && group.label.trim() ? [{
|
|
7927
7937
|
x: frame.x + FRAME_PAD / 2,
|
|
7928
|
-
y: frame.y + (
|
|
7938
|
+
y: frame.y + (FRAME_PAD - LABEL_FONT.lineH) / 2,
|
|
7929
7939
|
w: group.label.length * LABEL_FONT.charW,
|
|
7930
7940
|
h: LABEL_FONT.lineH
|
|
7931
7941
|
}] : [];
|
|
@@ -8065,7 +8075,7 @@ var draw = (diagram, geometry) => {
|
|
|
8065
8075
|
kind: "text",
|
|
8066
8076
|
id: "label",
|
|
8067
8077
|
x: FRAME_PAD / 2,
|
|
8068
|
-
y: (
|
|
8078
|
+
y: (FRAME_PAD - LABEL_FONT.lineH) / 2,
|
|
8069
8079
|
text: group.label,
|
|
8070
8080
|
weight: "s",
|
|
8071
8081
|
color: "grey"
|