@cardenelabs/cdl 0.52.0 → 0.53.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/CHANGELOG.md +16 -1
- package/dist/index.cjs +88 -78
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +88 -78
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +88 -78
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +88 -78
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
- package/src/layout/head-label.ts +24 -0
- package/src/layout/nodes.ts +7 -3
package/dist/react.js
CHANGED
|
@@ -9224,6 +9224,87 @@ function requiredRowsWidth(rows, kind) {
|
|
|
9224
9224
|
return Math.ceil(kind === "storage" ? storage : generic);
|
|
9225
9225
|
}
|
|
9226
9226
|
|
|
9227
|
+
// src/layout/head-label.ts
|
|
9228
|
+
var \u7AEF\u306E\u5B57\u3092\u623B\u3059\u8DDD\u96E2 = 22;
|
|
9229
|
+
var \u7AEF\u306E\u5B57\u3068\u7DDA\u306E\u9699\u9593 = 8;
|
|
9230
|
+
var \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055 = EDGE_LABEL_TEXT.sub.fontSize;
|
|
9231
|
+
var \u7BB1\u306E\u9AD8\u3055 = Math.round(\u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055 * 1.2);
|
|
9232
|
+
var BASELINE_RATIO = 0.8;
|
|
9233
|
+
var \u4E21\u7AEF\u306E\u5B57\u306E\u9593 = \u7AEF\u306E\u5B57\u3092\u623B\u3059\u8DDD\u96E2 * 2;
|
|
9234
|
+
function \u7AEF\u306E\u5B57\u306B\u8981\u308B\u7DDA\u306E\u9577\u3055(edge) {
|
|
9235
|
+
const \u4E00\u3064\u5206 = \u7AEF\u306E\u5B57\u3092\u623B\u3059\u8DDD\u96E2 + \u7BB1\u306E\u9AD8\u3055;
|
|
9236
|
+
const \u6570 = [edge.headLabel, edge.tailLabel].filter((t) => t?.trim()).length;
|
|
9237
|
+
if (\u6570 === 0) return 0;
|
|
9238
|
+
if (\u6570 === 1) return \u4E00\u3064\u5206;
|
|
9239
|
+
return \u4E00\u3064\u5206 * 2 + \u4E21\u7AEF\u306E\u5B57\u306E\u9593;
|
|
9240
|
+
}
|
|
9241
|
+
function \u5411\u304D\u3092\u53D6\u308B(end, \u5019\u88DC) {
|
|
9242
|
+
for (const p of \u5019\u88DC) {
|
|
9243
|
+
if (!p) continue;
|
|
9244
|
+
const dx = end.x - p.x;
|
|
9245
|
+
const dy = end.y - p.y;
|
|
9246
|
+
const len = Math.hypot(dx, dy);
|
|
9247
|
+
if (len > 1e-6) return { end, ux: dx / len, uy: dy / len };
|
|
9248
|
+
}
|
|
9249
|
+
return null;
|
|
9250
|
+
}
|
|
9251
|
+
function \u7AEF\u3067\u306E\u5411\u304D(d, \u7AEF) {
|
|
9252
|
+
const segs = extractPathSegments(d);
|
|
9253
|
+
if (segs.length === 0) return null;
|
|
9254
|
+
if (\u7AEF === "head") {
|
|
9255
|
+
const last = segs[segs.length - 1];
|
|
9256
|
+
const end2 = { x: last.x2, y: last.y2 };
|
|
9257
|
+
const \u5019\u88DC2 = segs.slice().reverse().flatMap((s) => [s.cmd === "Q" ? s.ctrl?.[0] : s.cmd === "C" ? s.ctrl?.[1] : void 0, { x: s.x1, y: s.y1 }]);
|
|
9258
|
+
return \u5411\u304D\u3092\u53D6\u308B(end2, \u5019\u88DC2);
|
|
9259
|
+
}
|
|
9260
|
+
const first = segs[0];
|
|
9261
|
+
const end = { x: first.x1, y: first.y1 };
|
|
9262
|
+
const \u5019\u88DC = segs.flatMap((s) => [...s.ctrl ?? [], { x: s.x2, y: s.y2 }]);
|
|
9263
|
+
return \u5411\u304D\u3092\u53D6\u308B(end, \u5019\u88DC);
|
|
9264
|
+
}
|
|
9265
|
+
function \u7AEF\u306E\u5B57\u3092\u7F6E\u304F(edge, \u7AEF = "head") {
|
|
9266
|
+
const text = (\u7AEF === "head" ? edge.headLabel : edge.tailLabel)?.trim();
|
|
9267
|
+
if (!text) return null;
|
|
9268
|
+
const \u5411\u304D = \u7AEF\u3067\u306E\u5411\u304D(edge.d, \u7AEF);
|
|
9269
|
+
if (!\u5411\u304D) return null;
|
|
9270
|
+
const { end, ux, uy } = \u5411\u304D;
|
|
9271
|
+
const bx = end.x - ux * \u7AEF\u306E\u5B57\u3092\u623B\u3059\u8DDD\u96E2;
|
|
9272
|
+
const by = end.y - uy * \u7AEF\u306E\u5B57\u3092\u623B\u3059\u8DDD\u96E2;
|
|
9273
|
+
const w = measureTextWidth(text, {
|
|
9274
|
+
fontSize: \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055,
|
|
9275
|
+
fontWeight: EDGE_LABEL_TEXT.sub.fontWeight,
|
|
9276
|
+
fontFamily: "mono"
|
|
9277
|
+
});
|
|
9278
|
+
const h = \u7BB1\u306E\u9AD8\u3055;
|
|
9279
|
+
const \u672D = hasRenderedLabel(edge) && edge.labelX !== void 0 && edge.labelY !== void 0 ? { x: edge.labelX, y: edge.labelY } : null;
|
|
9280
|
+
let anchor;
|
|
9281
|
+
let box;
|
|
9282
|
+
if (Math.abs(ux) >= Math.abs(uy)) {
|
|
9283
|
+
const \u53F3\u3078\u9032\u3080 = ux > 0;
|
|
9284
|
+
const \u4E0A\u306B\u7F6E\u304F = \u672D !== null && \u672D.y > by;
|
|
9285
|
+
anchor = \u53F3\u3078\u9032\u3080 ? "end" : "start";
|
|
9286
|
+
box = {
|
|
9287
|
+
x: \u53F3\u3078\u9032\u3080 ? bx - w : bx,
|
|
9288
|
+
y: \u4E0A\u306B\u7F6E\u304F ? by - \u7AEF\u306E\u5B57\u3068\u7DDA\u306E\u9699\u9593 - h : by + \u7AEF\u306E\u5B57\u3068\u7DDA\u306E\u9699\u9593,
|
|
9289
|
+
w,
|
|
9290
|
+
h
|
|
9291
|
+
};
|
|
9292
|
+
} else {
|
|
9293
|
+
const \u4E0B\u3078\u9032\u3080 = uy > 0;
|
|
9294
|
+
const \u53F3\u306B\u7F6E\u304F = \u672D !== null && \u672D.x < bx;
|
|
9295
|
+
anchor = \u53F3\u306B\u7F6E\u304F ? "start" : "end";
|
|
9296
|
+
box = {
|
|
9297
|
+
x: \u53F3\u306B\u7F6E\u304F ? bx + \u7AEF\u306E\u5B57\u3068\u7DDA\u306E\u9699\u9593 : bx - \u7AEF\u306E\u5B57\u3068\u7DDA\u306E\u9699\u9593 - w,
|
|
9298
|
+
y: \u4E0B\u3078\u9032\u3080 ? by - h : by,
|
|
9299
|
+
w,
|
|
9300
|
+
h
|
|
9301
|
+
};
|
|
9302
|
+
}
|
|
9303
|
+
const x = anchor === "start" ? box.x : box.x + box.w;
|
|
9304
|
+
const y = box.y + (h - \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055) / 2 + \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055 * BASELINE_RATIO;
|
|
9305
|
+
return { x, y, anchor, box };
|
|
9306
|
+
}
|
|
9307
|
+
|
|
9227
9308
|
// src/layout/nodes.ts
|
|
9228
9309
|
function autoStorageHeight(n, defaultH) {
|
|
9229
9310
|
if (n.kind !== "storage") return n.h ?? defaultH;
|
|
@@ -9245,7 +9326,7 @@ function autoRowsWidth(n, defaultW) {
|
|
|
9245
9326
|
const required = requiredRowsWidth(n.rows, n.kind);
|
|
9246
9327
|
return Math.max(defaultW, required);
|
|
9247
9328
|
}
|
|
9248
|
-
function \u7BB1\u306E\u9AD8\
|
|
9329
|
+
function \u7BB1\u306E\u9AD8\u30552(n, \u65E2\u5B9Ah) {
|
|
9249
9330
|
if (n.h != null) return n.h;
|
|
9250
9331
|
if (n.kind === "storage") return autoStorageHeight(n, \u65E2\u5B9Ah);
|
|
9251
9332
|
return \u4E2D\u8EAB\u304B\u3089\u51FA\u3059\u9AD8\u3055(n.kind, \u65E2\u5B9Ah, {
|
|
@@ -9259,8 +9340,8 @@ function requiredStackGapForEdgeLabels(diag, allStacks) {
|
|
|
9259
9340
|
const byId = new Map(diag.nodes.map((n) => [n.id, n]));
|
|
9260
9341
|
const rankOf = new Map(allStacks.map((stack, i) => [stack, i]));
|
|
9261
9342
|
const pillHsByGap = /* @__PURE__ */ new Map();
|
|
9343
|
+
let \u7AEF\u306E\u5B57\u306E\u8981\u6C42 = 0;
|
|
9262
9344
|
for (const e of diag.edges) {
|
|
9263
|
-
if (!hasRenderedLabel(e)) continue;
|
|
9264
9345
|
const from = byId.get(e.from);
|
|
9265
9346
|
const to = byId.get(e.to);
|
|
9266
9347
|
if (!from || !to) continue;
|
|
@@ -9269,10 +9350,12 @@ function requiredStackGapForEdgeLabels(diag, allStacks) {
|
|
|
9269
9350
|
const toRank = rankOf.get(to.stack);
|
|
9270
9351
|
if (fromRank === void 0 || toRank === void 0) continue;
|
|
9271
9352
|
if (Math.abs(fromRank - toRank) !== 1) continue;
|
|
9353
|
+
\u7AEF\u306E\u5B57\u306E\u8981\u6C42 = Math.max(\u7AEF\u306E\u5B57\u306E\u8981\u6C42, \u7AEF\u306E\u5B57\u306B\u8981\u308B\u7DDA\u306E\u9577\u3055(e));
|
|
9354
|
+
if (!hasRenderedLabel(e)) continue;
|
|
9272
9355
|
const key = `${from.lane}::${Math.min(fromRank, toRank)}`;
|
|
9273
9356
|
pillHsByGap.set(key, [...pillHsByGap.get(key) ?? [], labelPillH(e.sub)]);
|
|
9274
9357
|
}
|
|
9275
|
-
let required =
|
|
9358
|
+
let required = \u7AEF\u306E\u5B57\u306E\u8981\u6C42;
|
|
9276
9359
|
for (const pillHs of pillHsByGap.values()) {
|
|
9277
9360
|
required = Math.max(required, requiredVerticalLabelGap(pillHs));
|
|
9278
9361
|
}
|
|
@@ -9284,7 +9367,7 @@ function layoutNodes(diag, lanes) {
|
|
|
9284
9367
|
const rowH = /* @__PURE__ */ new Map();
|
|
9285
9368
|
for (const stack of allStacks) {
|
|
9286
9369
|
const nodesAtStack = diag.nodes.filter((n) => n.stack === stack);
|
|
9287
|
-
const h = Math.max(...nodesAtStack.map((n) => \u7BB1\u306E\u9AD8\
|
|
9370
|
+
const h = Math.max(...nodesAtStack.map((n) => \u7BB1\u306E\u9AD8\u30552(n, NODE_SIZE[n.kind].h)));
|
|
9288
9371
|
rowH.set(stack, h);
|
|
9289
9372
|
}
|
|
9290
9373
|
const rowCy = /* @__PURE__ */ new Map();
|
|
@@ -9338,7 +9421,7 @@ function layoutNodes(diag, lanes) {
|
|
|
9338
9421
|
const \u6BB5\u306E\u82AF = rowCy.get(n.stack);
|
|
9339
9422
|
const \u6BB5\u306E\u9AD8\u3055 = rowH.get(n.stack);
|
|
9340
9423
|
const \u81EA\u524D\u306E\u9AD8\u3055 = n.rowMarks !== void 0;
|
|
9341
|
-
const h = n.h ?? (\u81EA\u524D\u306E\u9AD8\u3055 ? \u7BB1\u306E\u9AD8\
|
|
9424
|
+
const h = n.h ?? (\u81EA\u524D\u306E\u9AD8\u3055 ? \u7BB1\u306E\u9AD8\u30552(n, size.h) : \u6BB5\u306E\u9AD8\u3055);
|
|
9342
9425
|
const cy = \u6BB5\u306E\u82AF;
|
|
9343
9426
|
const w = autoRowsWidth(n, size.w);
|
|
9344
9427
|
out.push({
|
|
@@ -10412,79 +10495,6 @@ function \u7B49\u5E45\u306E\u5B57(text, fontSize) {
|
|
|
10412
10495
|
});
|
|
10413
10496
|
return out;
|
|
10414
10497
|
}
|
|
10415
|
-
|
|
10416
|
-
// src/layout/head-label.ts
|
|
10417
|
-
var \u7AEF\u306E\u5B57\u3092\u623B\u3059\u8DDD\u96E2 = 22;
|
|
10418
|
-
var \u7AEF\u306E\u5B57\u3068\u7DDA\u306E\u9699\u9593 = 8;
|
|
10419
|
-
var \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055 = EDGE_LABEL_TEXT.sub.fontSize;
|
|
10420
|
-
var \u7BB1\u306E\u9AD8\u30552 = Math.round(\u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055 * 1.2);
|
|
10421
|
-
var BASELINE_RATIO = 0.8;
|
|
10422
|
-
function \u5411\u304D\u3092\u53D6\u308B(end, \u5019\u88DC) {
|
|
10423
|
-
for (const p of \u5019\u88DC) {
|
|
10424
|
-
if (!p) continue;
|
|
10425
|
-
const dx = end.x - p.x;
|
|
10426
|
-
const dy = end.y - p.y;
|
|
10427
|
-
const len = Math.hypot(dx, dy);
|
|
10428
|
-
if (len > 1e-6) return { end, ux: dx / len, uy: dy / len };
|
|
10429
|
-
}
|
|
10430
|
-
return null;
|
|
10431
|
-
}
|
|
10432
|
-
function \u7AEF\u3067\u306E\u5411\u304D(d, \u7AEF) {
|
|
10433
|
-
const segs = extractPathSegments(d);
|
|
10434
|
-
if (segs.length === 0) return null;
|
|
10435
|
-
if (\u7AEF === "head") {
|
|
10436
|
-
const last = segs[segs.length - 1];
|
|
10437
|
-
const end2 = { x: last.x2, y: last.y2 };
|
|
10438
|
-
const \u5019\u88DC2 = segs.slice().reverse().flatMap((s) => [s.cmd === "Q" ? s.ctrl?.[0] : s.cmd === "C" ? s.ctrl?.[1] : void 0, { x: s.x1, y: s.y1 }]);
|
|
10439
|
-
return \u5411\u304D\u3092\u53D6\u308B(end2, \u5019\u88DC2);
|
|
10440
|
-
}
|
|
10441
|
-
const first = segs[0];
|
|
10442
|
-
const end = { x: first.x1, y: first.y1 };
|
|
10443
|
-
const \u5019\u88DC = segs.flatMap((s) => [...s.ctrl ?? [], { x: s.x2, y: s.y2 }]);
|
|
10444
|
-
return \u5411\u304D\u3092\u53D6\u308B(end, \u5019\u88DC);
|
|
10445
|
-
}
|
|
10446
|
-
function \u7AEF\u306E\u5B57\u3092\u7F6E\u304F(edge, \u7AEF = "head") {
|
|
10447
|
-
const text = (\u7AEF === "head" ? edge.headLabel : edge.tailLabel)?.trim();
|
|
10448
|
-
if (!text) return null;
|
|
10449
|
-
const \u5411\u304D = \u7AEF\u3067\u306E\u5411\u304D(edge.d, \u7AEF);
|
|
10450
|
-
if (!\u5411\u304D) return null;
|
|
10451
|
-
const { end, ux, uy } = \u5411\u304D;
|
|
10452
|
-
const bx = end.x - ux * \u7AEF\u306E\u5B57\u3092\u623B\u3059\u8DDD\u96E2;
|
|
10453
|
-
const by = end.y - uy * \u7AEF\u306E\u5B57\u3092\u623B\u3059\u8DDD\u96E2;
|
|
10454
|
-
const w = measureTextWidth(text, {
|
|
10455
|
-
fontSize: \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055,
|
|
10456
|
-
fontWeight: EDGE_LABEL_TEXT.sub.fontWeight,
|
|
10457
|
-
fontFamily: "mono"
|
|
10458
|
-
});
|
|
10459
|
-
const h = \u7BB1\u306E\u9AD8\u30552;
|
|
10460
|
-
const \u672D = hasRenderedLabel(edge) && edge.labelX !== void 0 && edge.labelY !== void 0 ? { x: edge.labelX, y: edge.labelY } : null;
|
|
10461
|
-
let anchor;
|
|
10462
|
-
let box;
|
|
10463
|
-
if (Math.abs(ux) >= Math.abs(uy)) {
|
|
10464
|
-
const \u53F3\u3078\u9032\u3080 = ux > 0;
|
|
10465
|
-
const \u4E0A\u306B\u7F6E\u304F = \u672D !== null && \u672D.y > by;
|
|
10466
|
-
anchor = \u53F3\u3078\u9032\u3080 ? "end" : "start";
|
|
10467
|
-
box = {
|
|
10468
|
-
x: \u53F3\u3078\u9032\u3080 ? bx - w : bx,
|
|
10469
|
-
y: \u4E0A\u306B\u7F6E\u304F ? by - \u7AEF\u306E\u5B57\u3068\u7DDA\u306E\u9699\u9593 - h : by + \u7AEF\u306E\u5B57\u3068\u7DDA\u306E\u9699\u9593,
|
|
10470
|
-
w,
|
|
10471
|
-
h
|
|
10472
|
-
};
|
|
10473
|
-
} else {
|
|
10474
|
-
const \u4E0B\u3078\u9032\u3080 = uy > 0;
|
|
10475
|
-
const \u53F3\u306B\u7F6E\u304F = \u672D !== null && \u672D.x < bx;
|
|
10476
|
-
anchor = \u53F3\u306B\u7F6E\u304F ? "start" : "end";
|
|
10477
|
-
box = {
|
|
10478
|
-
x: \u53F3\u306B\u7F6E\u304F ? bx + \u7AEF\u306E\u5B57\u3068\u7DDA\u306E\u9699\u9593 : bx - \u7AEF\u306E\u5B57\u3068\u7DDA\u306E\u9699\u9593 - w,
|
|
10479
|
-
y: \u4E0B\u3078\u9032\u3080 ? by - h : by,
|
|
10480
|
-
w,
|
|
10481
|
-
h
|
|
10482
|
-
};
|
|
10483
|
-
}
|
|
10484
|
-
const x = anchor === "start" ? box.x : box.x + box.w;
|
|
10485
|
-
const y = box.y + (h - \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055) / 2 + \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055 * BASELINE_RATIO;
|
|
10486
|
-
return { x, y, anchor, box };
|
|
10487
|
-
}
|
|
10488
10498
|
function defaultEdgeWidth(active) {
|
|
10489
10499
|
return active ? 2.5 : 1.25;
|
|
10490
10500
|
}
|