@cardenelabs/cdl 0.73.0 → 0.74.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/react.js CHANGED
@@ -2870,6 +2870,66 @@ function textWidth(s, size, \u5B57\u9001\u308A = 0) {
2870
2870
  }
2871
2871
  return \u5E45 * size + \u5B57\u9001\u308A * \u5B57\u6570;
2872
2872
  }
2873
+
2874
+ // src/kinds/row-align.ts
2875
+ var GENERIC_ROW_LEFT_SIZE_PX = 18;
2876
+ var GENERIC_ROW_RIGHT_SIZE_PX = 21;
2877
+ var MONO_ADVANCE_RATIO = 0.6;
2878
+ var STORAGE_CHAR_ADVANCE_PX = 26 * MONO_ADVANCE_RATIO;
2879
+ var ROW_PAD_X_PX = 26;
2880
+ var ROW_COL_GAP_PX = 16;
2881
+ var STORAGE_COL_GAP_PX = 32;
2882
+ var ROW_RIGHT_PAD_PX = 26;
2883
+ var DELIMITERS = [" -> ", " \u2192 ", " = ", ": ", ":"];
2884
+ function splitRow(row) {
2885
+ for (const d of DELIMITERS) {
2886
+ const idx = row.indexOf(d);
2887
+ if (idx > 0) {
2888
+ return {
2889
+ left: row.slice(0, idx).trim(),
2890
+ right: row.slice(idx + d.length).trim(),
2891
+ split: true
2892
+ };
2893
+ }
2894
+ }
2895
+ return { left: row.trim(), right: "", split: false };
2896
+ }
2897
+ function rowColumnWidth(text, size, mono) {
2898
+ return mono ? displayWidth(text) * size * MONO_ADVANCE_RATIO : textWidth(text, size);
2899
+ }
2900
+ function displayWidth(text) {
2901
+ let w = 0;
2902
+ for (const ch of text) {
2903
+ const code = ch.codePointAt(0) ?? 0;
2904
+ w += code >= 32 && code <= 126 ? 1 : 2;
2905
+ }
2906
+ return w;
2907
+ }
2908
+ function \u6841\u3067\u5272\u308B(text, \u6841) {
2909
+ let w = 0;
2910
+ let \u53D6\u3063\u305F = "";
2911
+ for (const ch of text) {
2912
+ const code = ch.codePointAt(0) ?? 0;
2913
+ const \u5B57\u306E\u6841 = code >= 32 && code <= 126 ? 1 : 2;
2914
+ if (w + \u5B57\u306E\u6841 > \u6841) break;
2915
+ w += \u5B57\u306E\u6841;
2916
+ \u53D6\u3063\u305F += ch;
2917
+ }
2918
+ return [\u53D6\u3063\u305F, text.slice(\u53D6\u3063\u305F.length)];
2919
+ }
2920
+ function \u6841\u3067\u7701\u304F(text, \u4E0A\u9650) {
2921
+ if (displayWidth(text) <= \u4E0A\u9650) return text;
2922
+ return `${\u6841\u3067\u5272\u308B(text, \u4E0A\u9650 - 1)[0]}\u2026`;
2923
+ }
2924
+ function requiredRowsWidth(rows, kind) {
2925
+ if (!rows || rows.length === 0) return 0;
2926
+ const splits = rows.map(splitRow);
2927
+ const \u4E00\u756A\u5E83\u3044 = (\u53D6\u308B) => splits.reduce((m, s) => Math.max(m, \u53D6\u308B(s)), 0);
2928
+ const storage = ROW_PAD_X_PX + \u4E00\u756A\u5E83\u3044((s) => rowColumnWidth(s.left, 26, true)) + STORAGE_COL_GAP_PX + \u4E00\u756A\u5E83\u3044((s) => rowColumnWidth(s.right, 26, true)) + ROW_RIGHT_PAD_PX;
2929
+ const generic = ROW_PAD_X_PX + \u4E00\u756A\u5E83\u3044((s) => rowColumnWidth(s.left, GENERIC_ROW_LEFT_SIZE_PX, false)) + ROW_COL_GAP_PX + \u4E00\u756A\u5E83\u3044((s) => rowColumnWidth(s.right, GENERIC_ROW_RIGHT_SIZE_PX, true)) + ROW_RIGHT_PAD_PX;
2930
+ if (kind === void 0) return Math.ceil(Math.max(storage, generic));
2931
+ return Math.ceil(kind === "storage" ? storage : generic);
2932
+ }
2873
2933
  var TITLE_MAX = 18;
2874
2934
  var TITLE_MIN = 9;
2875
2935
  var TITLE_RATIO = 0.17;
@@ -3050,7 +3110,38 @@ function fitArt(region, extent, art) {
3050
3110
  const dx = region.cx - s * \u7D75cx;
3051
3111
  const dy = region.cy - s * \u7D75cy;
3052
3112
  if (s >= 1 && dx === 0 && dy === 0) return \u7D44\u3080(1);
3053
- return /* @__PURE__ */ jsx("g", { transform: `translate(${dx} ${dy}) scale(${s})`, children: \u7D44\u3080(s) });
3113
+ return (
3114
+ /*
3115
+ * 包みに印を付ける (#886)。 **`scale(` を持つ変換は他にもある** = `event` は目立たせる
3116
+ * ための脈動を `scale(0.78)` から `scale(1)` で描き、絵を箱に収める縮小ではない。
3117
+ * 祖先の変換を正規表現で見る形だと、その脈動まで「絵の縮小」 として数える。
3118
+ */
3119
+ /* @__PURE__ */ jsx("g", { "data-cdl-art-fit": "1", transform: `translate(${dx} ${dy}) scale(${s})`, children: \u7D44\u3080(s) })
3120
+ );
3121
+ }
3122
+ var \u5E2F\u306E\u9AD8\u3055\u306B\u5BFE\u3059\u308B\u4E0A\u9650 = 0.8;
3123
+ function \u7D75\u306E\u4E2D\u306E\u5B57\u306E\u5E45(text, size, letterSpacing = 0) {
3124
+ return Math.max(
3125
+ displayWidth(text) * size * MONO_ADVANCE_RATIO,
3126
+ textWidth(text, size, letterSpacing)
3127
+ );
3128
+ }
3129
+ function \u6253\u3061\u6D88\u3057\u306E\u500D\u7387(\u500D\u7387, \u5B57\u3089) {
3130
+ const \u623B\u3057 = Number.isFinite(\u500D\u7387) && \u500D\u7387 > 0 ? 1 / \u500D\u7387 : 1;
3131
+ let \u4E0A\u9650 = Number.POSITIVE_INFINITY;
3132
+ for (const \u5B572 of \u5B57\u3089) {
3133
+ if (!(Number.isFinite(\u5B572.size) && \u5B572.size > 0)) continue;
3134
+ const { \u5E45, \u9AD8\u3055 } = \u5B572.\u5E2F;
3135
+ if (Number.isFinite(\u9AD8\u3055) && \u9AD8\u3055 > 0) {
3136
+ \u4E0A\u9650 = Math.min(\u4E0A\u9650, \u9AD8\u3055 * \u5E2F\u306E\u9AD8\u3055\u306B\u5BFE\u3059\u308B\u4E0A\u9650 / \u5B572.size);
3137
+ }
3138
+ const \u5B9F\u5E45 = \u7D75\u306E\u4E2D\u306E\u5B57\u306E\u5E45(\u5B572.text, \u5B572.size, \u5B572.letterSpacing ?? 0);
3139
+ if (Number.isFinite(\u5E45) && \u5E45 > 0 && \u5B9F\u5E45 > 0) {
3140
+ \u4E0A\u9650 = Math.min(\u4E0A\u9650, \u5E45 / \u5B9F\u5E45);
3141
+ }
3142
+ }
3143
+ if (!Number.isFinite(\u4E0A\u9650)) return 1;
3144
+ return Math.max(1, Math.min(\u623B\u3057, \u4E0A\u9650));
3054
3145
  }
3055
3146
 
3056
3147
  // src/kinds/compact-title.ts
@@ -9605,66 +9696,6 @@ function recomputeContainedLanes(lanes, nodes) {
9605
9696
  });
9606
9697
  }
9607
9698
 
9608
- // src/kinds/row-align.ts
9609
- var GENERIC_ROW_LEFT_SIZE_PX = 18;
9610
- var GENERIC_ROW_RIGHT_SIZE_PX = 21;
9611
- var MONO_ADVANCE_RATIO = 0.6;
9612
- var STORAGE_CHAR_ADVANCE_PX = 26 * MONO_ADVANCE_RATIO;
9613
- var ROW_PAD_X_PX = 26;
9614
- var ROW_COL_GAP_PX = 16;
9615
- var STORAGE_COL_GAP_PX = 32;
9616
- var ROW_RIGHT_PAD_PX = 26;
9617
- var DELIMITERS = [" -> ", " \u2192 ", " = ", ": ", ":"];
9618
- function splitRow(row) {
9619
- for (const d of DELIMITERS) {
9620
- const idx = row.indexOf(d);
9621
- if (idx > 0) {
9622
- return {
9623
- left: row.slice(0, idx).trim(),
9624
- right: row.slice(idx + d.length).trim(),
9625
- split: true
9626
- };
9627
- }
9628
- }
9629
- return { left: row.trim(), right: "", split: false };
9630
- }
9631
- function rowColumnWidth(text, size, mono) {
9632
- return mono ? displayWidth(text) * size * MONO_ADVANCE_RATIO : textWidth(text, size);
9633
- }
9634
- function displayWidth(text) {
9635
- let w = 0;
9636
- for (const ch of text) {
9637
- const code = ch.codePointAt(0) ?? 0;
9638
- w += code >= 32 && code <= 126 ? 1 : 2;
9639
- }
9640
- return w;
9641
- }
9642
- function \u6841\u3067\u5272\u308B(text, \u6841) {
9643
- let w = 0;
9644
- let \u53D6\u3063\u305F = "";
9645
- for (const ch of text) {
9646
- const code = ch.codePointAt(0) ?? 0;
9647
- const \u5B57\u306E\u6841 = code >= 32 && code <= 126 ? 1 : 2;
9648
- if (w + \u5B57\u306E\u6841 > \u6841) break;
9649
- w += \u5B57\u306E\u6841;
9650
- \u53D6\u3063\u305F += ch;
9651
- }
9652
- return [\u53D6\u3063\u305F, text.slice(\u53D6\u3063\u305F.length)];
9653
- }
9654
- function \u6841\u3067\u7701\u304F(text, \u4E0A\u9650) {
9655
- if (displayWidth(text) <= \u4E0A\u9650) return text;
9656
- return `${\u6841\u3067\u5272\u308B(text, \u4E0A\u9650 - 1)[0]}\u2026`;
9657
- }
9658
- function requiredRowsWidth(rows, kind) {
9659
- if (!rows || rows.length === 0) return 0;
9660
- const splits = rows.map(splitRow);
9661
- const \u4E00\u756A\u5E83\u3044 = (\u53D6\u308B) => splits.reduce((m, s) => Math.max(m, \u53D6\u308B(s)), 0);
9662
- const storage = ROW_PAD_X_PX + \u4E00\u756A\u5E83\u3044((s) => rowColumnWidth(s.left, 26, true)) + STORAGE_COL_GAP_PX + \u4E00\u756A\u5E83\u3044((s) => rowColumnWidth(s.right, 26, true)) + ROW_RIGHT_PAD_PX;
9663
- const generic = ROW_PAD_X_PX + \u4E00\u756A\u5E83\u3044((s) => rowColumnWidth(s.left, GENERIC_ROW_LEFT_SIZE_PX, false)) + ROW_COL_GAP_PX + \u4E00\u756A\u5E83\u3044((s) => rowColumnWidth(s.right, GENERIC_ROW_RIGHT_SIZE_PX, true)) + ROW_RIGHT_PAD_PX;
9664
- if (kind === void 0) return Math.ceil(Math.max(storage, generic));
9665
- return Math.ceil(kind === "storage" ? storage : generic);
9666
- }
9667
-
9668
9699
  // src/layout/head-label.ts
9669
9700
  var \u7AEF\u306E\u5B57\u3092\u623B\u3059\u8DDD\u96E2 = 22;
9670
9701
  var \u7AEF\u306E\u5B57\u3068\u7DDA\u306E\u9699\u9593 = 8;
@@ -17309,15 +17340,6 @@ var \u540D\u306E\u5B57 = 10.5;
17309
17340
  var \u5024\u306E\u5B57 = 11;
17310
17341
  var \u884C\u306E\u9593\u9694 = 22;
17311
17342
  var \u898B\u51FA\u3057\u306E\u5E2F = 32;
17312
- var \u5E2F\u306B\u5BFE\u3059\u308B\u4E0A\u9650 = 0.8;
17313
- function \u6253\u3061\u6D88\u3057\u306E\u500D\u7387(k) {
17314
- const \u623B\u3057 = Number.isFinite(k) && k > 0 ? 1 / k : 1;
17315
- const \u4E0A\u9650 = Math.min(
17316
- \u884C\u306E\u9593\u9694 * \u5E2F\u306B\u5BFE\u3059\u308B\u4E0A\u9650 / \u5024\u306E\u5B57,
17317
- \u898B\u51FA\u3057\u306E\u5E2F * \u5E2F\u306B\u5BFE\u3059\u308B\u4E0A\u9650 / \u898B\u51FA\u3057\u306E\u5B57
17318
- );
17319
- return Math.max(1, Math.min(\u623B\u3057, \u4E0A\u9650));
17320
- }
17321
17343
  var BLOCK_SHADOW = 6;
17322
17344
  var NFT_W = 220;
17323
17345
  var NFT_H = 240;
@@ -17464,7 +17486,7 @@ function ShapeSmartContractNode({ node, active, lang }) {
17464
17486
  bottomLabel2(node, r.cx, r.label)
17465
17487
  ] });
17466
17488
  }
17467
- var \u5B57\u306E\u5E45 = (text, size) => Math.max(displayWidth(text) * size * MONO_ADVANCE_RATIO, textWidth(text, size));
17489
+ var \u5B57\u306E\u5E45 = (text, size) => \u7D75\u306E\u4E2D\u306E\u5B57\u306E\u5E45(text, size);
17468
17490
  var BLOCK_DEFAULT_FIELDS = [
17469
17491
  { key: "hash", label: "blockchainBlock.hash", value: { text: "0xaf31c9d2..." } },
17470
17492
  { key: "prev", label: "blockchainBlock.prev", value: { text: "0x7b3f92c1..." } },
@@ -17493,8 +17515,19 @@ function ShapeBlockchainBlockNode({ node, active, lang }) {
17493
17515
  };
17494
17516
  });
17495
17517
  const \u898B\u51FA\u3057\u306E\u5E45 = bw - 14 - 30;
17518
+ const \u6253\u3061\u6D88\u3059\u5B57\u3089 = [
17519
+ { text: \u898B\u51FA\u3057, size: \u898B\u51FA\u3057\u306E\u5B57, \u5E2F: { \u5E45: \u898B\u51FA\u3057\u306E\u5E45, \u9AD8\u3055: \u898B\u51FA\u3057\u306E\u5E2F } },
17520
+ ...fields.flatMap((f) => [
17521
+ { text: f.label, size: \u540D\u306E\u5B57, \u5E2F: { \u5E45: bw - 28, \u9AD8\u3055: \u884C\u306E\u9593\u9694 } },
17522
+ {
17523
+ text: f.value,
17524
+ size: \u5024\u306E\u5B57,
17525
+ \u5E2F: { \u5E45: bw - 28 - \u5B57\u306E\u5E45(f.label, \u540D\u306E\u5B57) - 8, \u9AD8\u3055: \u884C\u306E\u9593\u9694 }
17526
+ }
17527
+ ])
17528
+ ];
17496
17529
  const art = (\u500D\u7387) => {
17497
- const \u500D = \u6253\u3061\u6D88\u3057\u306E\u500D\u7387(\u500D\u7387);
17530
+ const \u500D = \u6253\u3061\u6D88\u3057\u306E\u500D\u7387(\u500D\u7387, \u6253\u3061\u6D88\u3059\u5B57\u3089);
17498
17531
  const \u984C\u306E\u5927\u304D\u3055 = \u898B\u51FA\u3057\u306E\u5B57 * \u500D;
17499
17532
  const \u540D\u306E\u5927\u304D\u3055 = \u540D\u306E\u5B57 * \u500D;
17500
17533
  const \u5024\u306E\u5927\u304D\u3055 = \u5024\u306E\u5B57 * \u500D;
@@ -17502,11 +17535,11 @@ function ShapeBlockchainBlockNode({ node, active, lang }) {
17502
17535
  /* @__PURE__ */ jsx("rect", { x: x + 6, y: y + 6, width: bw, height: bh, rx: 8, fill: frame.stroke, opacity: 0.2, stroke: "none" }),
17503
17536
  /* @__PURE__ */ jsx("rect", { "data-cdl-role": "node-body", x, y, width: bw, height: bh, rx: 8, ...frame }),
17504
17537
  /* @__PURE__ */ jsx("path", { d: `M ${x} ${y + 32} L ${x} ${y + 8} Q ${x} ${y}, ${x + 8} ${y} L ${x + bw - 8} ${y} Q ${x + bw} ${y}, ${x + bw} ${y + 8} L ${x + bw} ${y + 32} Z`, fill: "var(--cdl-tone-accent, #2d6a8f)", fillOpacity: 0.9, stroke: "none" }),
17505
- /* @__PURE__ */ jsx("text", { "data-cdl-role": "blockchain-block-title", x: x + 14, y: y + 22, fontSize: \u984C\u306E\u5927\u304D\u3055, fontWeight: 700, fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace", fill: "#ffffff", children: \u5E45\u3067\u5207\u308B(\u898B\u51FA\u3057, \u984C\u306E\u5927\u304D\u3055, \u898B\u51FA\u3057\u306E\u5E45, \u5B57\u306E\u5E45) }),
17538
+ /* @__PURE__ */ jsx("text", { "data-cdl-role": "blockchain-block-title", "data-cdl-counter-scaled": "1", x: x + 14, y: y + 22, fontSize: \u984C\u306E\u5927\u304D\u3055, fontWeight: 700, fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace", fill: "#ffffff", children: \u5E45\u3067\u5207\u308B(\u898B\u51FA\u3057, \u984C\u306E\u5927\u304D\u3055, \u898B\u51FA\u3057\u306E\u5E45, \u5B57\u306E\u5E45) }),
17506
17539
  /* @__PURE__ */ jsx("circle", { cx: x + bw - 16, cy: y + 16, r: 5.5, fill: "#7cd88f", stroke: "#ffffff", strokeWidth: 1.5 }),
17507
17540
  fields.map((f, i) => /* @__PURE__ */ jsxs("g", { children: [
17508
- /* @__PURE__ */ jsx("text", { x: x + 14, y: y + 54 + i * \u884C\u306E\u9593\u9694, fontSize: \u540D\u306E\u5927\u304D\u3055, fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace", fill: "var(--cdl-text-dim, #5a6270)", children: f.label }),
17509
- /* @__PURE__ */ jsx("text", { "data-cdl-role": `blockchain-block-${f.key}`, x: x + bw - 14, y: y + 54 + i * \u884C\u306E\u9593\u9694, fontSize: \u5024\u306E\u5927\u304D\u3055, fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace", fontWeight: 600, textAnchor: "end", fill: "var(--cdl-text, #1a1f2a)", children: \u5E45\u3067\u5207\u308B(f.value, \u5024\u306E\u5927\u304D\u3055, bw - 28 - \u5B57\u306E\u5E45(f.label, \u540D\u306E\u5927\u304D\u3055) - 8, \u5B57\u306E\u5E45) }),
17541
+ /* @__PURE__ */ jsx("text", { "data-cdl-counter-scaled": "1", x: x + 14, y: y + 54 + i * \u884C\u306E\u9593\u9694, fontSize: \u540D\u306E\u5927\u304D\u3055, fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace", fill: "var(--cdl-text-dim, #5a6270)", children: f.label }),
17542
+ /* @__PURE__ */ jsx("text", { "data-cdl-role": `blockchain-block-${f.key}`, "data-cdl-counter-scaled": "1", x: x + bw - 14, y: y + 54 + i * \u884C\u306E\u9593\u9694, fontSize: \u5024\u306E\u5927\u304D\u3055, fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace", fontWeight: 600, textAnchor: "end", fill: "var(--cdl-text, #1a1f2a)", children: \u5E45\u3067\u5207\u308B(f.value, \u5024\u306E\u5927\u304D\u3055, bw - 28 - \u5B57\u306E\u5E45(f.label, \u540D\u306E\u5927\u304D\u3055) - 8, \u5B57\u306E\u5E45) }),
17510
17543
  /* @__PURE__ */ jsx("line", { x1: x + 14, y1: y + 60 + i * \u884C\u306E\u9593\u9694, x2: x + bw - 14, y2: y + 60 + i * \u884C\u306E\u9593\u9694, stroke: "var(--cdl-divider, #d4d4d8)", strokeWidth: 0.5, opacity: 0.5 })
17511
17544
  ] }, i)),
17512
17545
  /* @__PURE__ */ jsxs("g", { transform: `translate(${cx - 32}, ${y + bh - 26})`, children: [