@cardenelabs/cdl 0.104.0 → 0.106.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/index.js CHANGED
@@ -12375,6 +12375,71 @@ var KINDS_FITTING_OWN_TITLE = /* @__PURE__ */ new Set([
12375
12375
  function fitsOwnTitleWidth(kind) {
12376
12376
  return KINDS_FITTING_OWN_TITLE.has(kind ?? "");
12377
12377
  }
12378
+ var KINDS_DRAWING_TITLE_OUTSIDE = /* @__PURE__ */ new Set([
12379
+ "dyn-rect",
12380
+ "dyn-circle",
12381
+ "dyn-arc",
12382
+ "dyn-wave",
12383
+ "dyn-polygon",
12384
+ ...KINDS_DRAWING_OWN_PAYLOAD
12385
+ ]);
12386
+ function drawsTitleOutsideBox(kind) {
12387
+ return KINDS_DRAWING_TITLE_OUTSIDE.has(kind ?? "");
12388
+ }
12389
+ var TITLE_FONT_SIZE_DEFAULT = 18;
12390
+ var TITLE_FONT_SIZE = new Map([
12391
+ ...["dyn-rect", "dyn-circle", "dyn-arc", "dyn-wave", "dyn-polygon"].map(
12392
+ (k) => [k, 13]
12393
+ ),
12394
+ ...[
12395
+ "shape-code-block",
12396
+ "shape-cylinder",
12397
+ "shape-diamond",
12398
+ "shape-iot-sensor",
12399
+ "shape-robot-arm",
12400
+ "shape-stack",
12401
+ "shape-terminal"
12402
+ ].map((k) => [k, 15]),
12403
+ ...[
12404
+ "shape-cloud",
12405
+ "shape-file",
12406
+ "shape-folder",
12407
+ "shape-hexagon",
12408
+ "shape-message-bubble",
12409
+ "shape-window"
12410
+ ].map((k) => [k, 16]),
12411
+ ["shape-kanban-card", 17],
12412
+ ...[
12413
+ "admin",
12414
+ "api",
12415
+ "backend",
12416
+ "cache",
12417
+ "cdn",
12418
+ "cloud",
12419
+ "database",
12420
+ "decision",
12421
+ "developer",
12422
+ "external-user",
12423
+ "frontend",
12424
+ "merkle-tree",
12425
+ "message-bus",
12426
+ "microservice",
12427
+ "oracle",
12428
+ "person",
12429
+ "queue",
12430
+ "service",
12431
+ "signer",
12432
+ "user-group",
12433
+ "webhook"
12434
+ ].map((k) => [k, 20]),
12435
+ ...["card", "event", "function"].map((k) => [k, 24]),
12436
+ ["actor", 32],
12437
+ ["storage", 34]
12438
+ ]);
12439
+ function titleFontSize(kind) {
12440
+ return TITLE_FONT_SIZE.get(kind ?? "") ?? TITLE_FONT_SIZE_DEFAULT;
12441
+ }
12442
+ var TITLE_BOX_PADDING = 52;
12378
12443
  var KINDS_DRAWN_BY_GENERIC = [
12379
12444
  "person",
12380
12445
  "user-group",
@@ -17158,12 +17223,12 @@ function runAxes(laid, diag, violations, counts, push, profile, skippedAxes, \u5
17158
17223
  if (!isRenderedNode(n)) continue;
17159
17224
  const titleTrimmed = n.title?.trim() ?? "";
17160
17225
  if (!titleTrimmed) continue;
17161
- const titleLen = titleTrimmed.length;
17162
- const expectedW = titleLen * 22 + 52;
17226
+ const expectedW = measureTextWidth(titleTrimmed, { fontSize: titleFontSize(n.kind) }) + (drawsTitleOutsideBox(n.kind) ? 0 : TITLE_BOX_PADDING);
17163
17227
  if (expectedW > n.w + 8) {
17164
17228
  push(
17165
17229
  "text-readability",
17166
- `node "${n.id}" title "${n.title}" \u304C node \u5E45 ${n.w}px \u3092\u8D85\u904E\u3059\u308B\u53EF\u80FD\u6027 (\u671F\u5F85 ${expectedW}px)`,
17230
+ // 字ごとの実幅は小数になるので、読む人に出す時だけ丸める (判定は丸めない)
17231
+ `node "${n.id}" title "${n.title}" \u304C node \u5E45 ${n.w}px \u3092\u8D85\u904E\u3059\u308B\u53EF\u80FD\u6027 (\u671F\u5F85 ${Math.round(expectedW)}px)`,
17167
17232
  "warn"
17168
17233
  );
17169
17234
  }