@cardenelabs/cdl 0.36.0 → 0.38.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 CHANGED
@@ -5,6 +5,50 @@ CDL (Chainome Diagram Language) の主要変更履歴。
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [0.38.0] - 2026-09-07
9
+
10
+ ### Fixed
11
+
12
+ - **図を描く動きが前半に寄って読めないのを直した** (#711)
13
+
14
+ 段の進みは `easeOutQuint` を通っており、`1.2s` の段で半分に達するのが 158 ms だった
15
+ (直線なら 600 ms)。 値が落ち着く動きには合う曲線だが、線を引く動きはペンの速さなので、
16
+ 同じ曲線を当てると飛び出して這う。
17
+
18
+ 折れ線は線の先が点に届いた時に値の字を出すが、5 点のうち 4 点が 292 ms の間に出て、
19
+ 最後の 1 点まで 908 ms 空いていた。「1 つずつ現れる」 という読ませ方が成立していない。
20
+
21
+ `Timeline` が曲げる前の進み (`phaseLinearProgress`) も持つようにし、描く動き
22
+ (`draw` の node と、その段で初めて出る矢印) だけがそれを読む。 値の補間は今までどおり
23
+ 曲げた進みで動く。
24
+
25
+ 直線にしたのは、5 点が等間隔の時刻に出る唯一の曲線だったため (実測 = 直線 294 ms 間隔、
26
+ `easeOut` は 188 / 219 / 275 / 518、`easeInOut` は真ん中の 3 点が寄る)。
27
+
28
+ `drawRatio` も直っている。 曲げた進みで割っていたため `0.4` と書くと段の 4.8% で
29
+ 描き終わっていた。 これからは書いた割合が実時間の割合になる。
30
+
31
+ ## [0.37.0] - 2026-09-07
32
+
33
+ ### Added
34
+
35
+ - **傾き図に縦の位置を順位にする見せ方を足した** (#707)
36
+
37
+ `chartSlopeForm` に `rank` を書くと、縦の位置が値ではなく順位の段 (等間隔) になる。
38
+
39
+ この図は「線の交差が順位の入れ替わり」 を読ませるが、縦の位置は値なので交差点の位置が
40
+ 順位と噛み合わなかった。 どの交差が本当に順位を変えた交差なのかは、値を読み比べないと
41
+ 決まらない。
42
+
43
+ 段を等間隔に置くと交差が入れ替わりと 1 対 1 になり、水平線が「順位が動かなかった」 を
44
+ 意味する。 軸の脇の字は値のままにして、量が図から消えないようにしている。
45
+
46
+ `rank` では「線の傾きが動いた量」 が成立しない (`+40` と `+30` がどちらも水平線)。
47
+ 書いた図だけに効く割り切りで、量は字を読む。
48
+
49
+ 同じ値の系列は同じ段に重なる。 系列が 1 本の図は縦の中央に置く。
50
+ 前の時点を持たない図と型の外の値は今までどおり `values` として描く。
51
+
8
52
  ## [0.36.0] - 2026-09-07
9
53
 
10
54
  ### Added
@@ -1696,7 +1740,9 @@ Initial OSS release.
1696
1740
  使わない = annotated tag を push しても GitHub Release は作られず、 Release を作っていない版で
1697
1741
  行き止まりになる。
1698
1742
 
1699
- [Unreleased]: https://github.com/cardene777/cdl/compare/v0.36.0...HEAD
1743
+ [Unreleased]: https://github.com/cardene777/cdl/compare/v0.38.0...HEAD
1744
+ [0.38.0]: https://github.com/cardene777/cdl/compare/v0.37.0...v0.38.0
1745
+ [0.37.0]: https://github.com/cardene777/cdl/compare/v0.36.0...v0.37.0
1700
1746
  [0.36.0]: https://github.com/cardene777/cdl/compare/v0.35.0...v0.36.0
1701
1747
  [0.35.0]: https://github.com/cardene777/cdl/compare/v0.34.0...v0.35.0
1702
1748
  [0.34.0]: https://github.com/cardene777/cdl/compare/v0.33.0...v0.34.0
package/README.md CHANGED
@@ -297,28 +297,51 @@ phase 切替に連動して `status: idle` → `status: running` のように描
297
297
  値だけに字体を当てられるようにするため。
298
298
  系列の名前はその線と同じ色で描く。 線を目で辿らずに名前と線の対応が取れる。
299
299
 
300
- ### 右の列に何を出すか
300
+ ### 傾き図の見せ方
301
301
 
302
- `chart-slope` は `chartSlopeForm` で右の列の中身を選ぶ。 欄を書かない図は `values` と同じ。
302
+ `chart-slope` は `chartSlopeForm` で見せ方を選ぶ。 欄を書かない図は `values` と同じ。
303
303
 
304
- | 値 | 右の列 | 向くもの |
305
- |---|---|---|
306
- | `values` (既定) | 今の値 | 2 時点の水準をそれぞれ読ませたい図 |
307
- | `delta` | 増減 (`+40` / `-90`) | どれがどれだけ動いたかを読ませたい図 |
304
+ | 値 | 縦の位置 | 右の列 | 向くもの |
305
+ |---|---|---|---|
306
+ | `values` (既定) | 値 | 今の値 | 2 時点の水準をそれぞれ読ませたい図 |
307
+ | `delta` | 値 | 増減 (`+40` / `-90`) | どれがどれだけ動いたかを読ませたい図 |
308
+ | `rank` | 順位の段 (等間隔) | 今の値 | 順位の入れ替わりを読ませたい図 |
308
309
 
309
310
  ```ts
310
311
  .node("move", { lane: "l", stack: 0, kind: "chart-slope", chartSlopeForm: "delta", chartData: [...] })
311
312
  ```
312
313
 
313
- 左の列はどちらでも前の値。 `前 + 増減 = 今` なので `delta` でも今の値は足せば戻る。
314
+ 左の列はどれでも前の値。
315
+
316
+ #### `delta` は右の列だけを変える
317
+
318
+ `前 + 増減 = 今` なので `delta` でも今の値は足せば戻る。
314
319
  3 つ目の数を足さないので、 名札の高さも線を引く幅も変わらない。
315
320
 
316
- `delta` の増減は `chart-slope-delta` で出す。 今の値とは意味が違い、 消費側が増減だけに色を
321
+ 増減は `chart-slope-delta` で出す。 今の値とは意味が違い、 消費側が増減だけに色を
317
322
  当てられるようにするため。 engine 側では色を分けない = 系列の色を名前に当てているので、
318
323
  増減にも色を当てると 1 つの図に 2 つの色の体系が混ざる。 向きは符号が持つ。
319
324
 
325
+ #### `rank` は縦の位置を変える
326
+
327
+ 段を等間隔に置くので、 **線の交差が順位の入れ替わりと 1 対 1** になり、 水平線が
328
+ 「順位が動かなかった」 を意味する。 既定 (値の尺) では交差点の位置が順位と噛み合わず、
329
+ どの交差が本当に順位を変えた交差なのかは値を読み比べないと決まらない。
330
+
331
+ 軸の脇の字は値のまま。 字も順位にすると `380 → 420` と `60 → 90` がどちらも同じ水平線に
332
+ なり、 量が図から完全に消える。 位置が順位を、 字が量を担う。
333
+
334
+ **`rank` では「線の傾きが動いた量」 が成立しない**。 `+40` と `+30` がどちらも水平線に
335
+ なるので、 量は字を読む。
336
+
337
+ 同じ値の系列は同じ段に重なる = 無理に 1 つずつずらすと、 書いていない差を絵が主張する。
338
+ 系列が 1 本の図は段が 1 つしか無いので縦の中央に置く。
339
+
340
+ #### どの形でも同じ扱い
341
+
320
342
  型の外の値を書いた図は `values` として描く。
321
- 前の時点を持たない図も `values` として描く = 引く相手がいないため。
343
+ 前の時点を持たない図も `values` として描く = `delta` は引く相手がいないため、
344
+ `rank` は軸が 1 本で並べ替える相手がいないため。
322
345
 
323
346
  ## 円グラフの見せ方
324
347
 
package/dist/index.cjs CHANGED
@@ -14158,6 +14158,8 @@ var Timeline = class {
14158
14158
  rafHandle = null;
14159
14159
  phaseIndex = 0;
14160
14160
  phaseProgress = 0;
14161
+ /** 曲線を通す前の進み (cdl#711)。 経過時間そのものの割合で、 描く動きが読む */
14162
+ phaseLinearProgress = 0;
14161
14163
  phaseStartedAt = 0;
14162
14164
  status = "idle";
14163
14165
  /**
@@ -14186,12 +14188,12 @@ var Timeline = class {
14186
14188
  const initial = options.initialPhaseIndex;
14187
14189
  if (initial != null && initial > 0 && initial < phases.length) {
14188
14190
  this.phaseIndex = initial;
14189
- this.phaseProgress = 1;
14191
+ this.setProgress(1);
14190
14192
  this.status = initial === phases.length - 1 ? "settled" : "paused";
14191
14193
  }
14192
14194
  this.initialState = {
14193
14195
  phaseIndex: this.phaseIndex,
14194
- phaseProgress: this.phaseProgress,
14196
+ phaseLinearProgress: this.phaseLinearProgress,
14195
14197
  status: this.status
14196
14198
  };
14197
14199
  }
@@ -14213,13 +14215,14 @@ var Timeline = class {
14213
14215
  }
14214
14216
  snapshot() {
14215
14217
  const cached = this.cachedSnapshot;
14216
- if (cached && cached.status === this.status && cached.phaseIndex === this.phaseIndex && cached.phaseProgress === this.phaseProgress && cached.totalPhases === this.phases.length) {
14218
+ if (cached && cached.status === this.status && cached.phaseIndex === this.phaseIndex && cached.phaseProgress === this.phaseProgress && cached.phaseLinearProgress === this.phaseLinearProgress && cached.totalPhases === this.phases.length) {
14217
14219
  return cached;
14218
14220
  }
14219
14221
  const next = {
14220
14222
  status: this.status,
14221
14223
  phaseIndex: this.phaseIndex,
14222
14224
  phaseProgress: this.phaseProgress,
14225
+ phaseLinearProgress: this.phaseLinearProgress,
14223
14226
  totalPhases: this.phases.length
14224
14227
  };
14225
14228
  this.cachedSnapshot = next;
@@ -14242,7 +14245,7 @@ var Timeline = class {
14242
14245
  const clamped = Math.max(0, Math.min(this.phases.length - 1, index));
14243
14246
  this.cancelRaf();
14244
14247
  this.phaseIndex = clamped;
14245
- this.phaseProgress = 1;
14248
+ this.setProgress(1);
14246
14249
  this.status = clamped === this.phases.length - 1 ? "settled" : "paused";
14247
14250
  this.emit();
14248
14251
  }
@@ -14282,14 +14285,14 @@ var Timeline = class {
14282
14285
  if (this.phaseIndex <= 0) return;
14283
14286
  this.cancelRaf();
14284
14287
  this.phaseIndex -= 1;
14285
- this.phaseProgress = 1;
14288
+ this.setProgress(1);
14286
14289
  this.status = "paused";
14287
14290
  this.emit();
14288
14291
  }
14289
14292
  reset() {
14290
14293
  this.cancelRaf();
14291
14294
  this.phaseIndex = 0;
14292
- this.phaseProgress = 0;
14295
+ this.setProgress(0);
14293
14296
  this.status = "idle";
14294
14297
  this.emit();
14295
14298
  }
@@ -14310,7 +14313,7 @@ var Timeline = class {
14310
14313
  this.subscribers.clear();
14311
14314
  this.status = this.initialState.status;
14312
14315
  this.phaseIndex = this.initialState.phaseIndex;
14313
- this.phaseProgress = this.initialState.phaseProgress;
14316
+ this.setProgress(this.initialState.phaseLinearProgress);
14314
14317
  }
14315
14318
  // ─── internals ───────────────────────────────────────────────
14316
14319
  advancePhase() {
@@ -14346,20 +14349,20 @@ var Timeline = class {
14346
14349
  }, ms);
14347
14350
  }
14348
14351
  beginPhaseTransition() {
14349
- this.phaseProgress = 0;
14352
+ this.setProgress(0);
14350
14353
  this.phaseStartedAt = performance.now();
14351
14354
  this.cancelRaf();
14352
14355
  const step = (now) => {
14353
14356
  const duration = this.autoAdvanceMsOverride ?? this.getPhase().durationMs ?? 600;
14354
14357
  const elapsed = now - this.phaseStartedAt;
14355
14358
  const linearT = clamp01(elapsed / duration);
14356
- this.phaseProgress = this.easing(linearT);
14359
+ this.setProgress(linearT);
14357
14360
  this.emit();
14358
14361
  if (linearT < 1) {
14359
14362
  this.rafHandle = requestAnimationFrame(step);
14360
14363
  return;
14361
14364
  }
14362
- this.phaseProgress = 1;
14365
+ this.setProgress(1);
14363
14366
  this.emit();
14364
14367
  if (this.status === "playing") {
14365
14368
  if (this.phaseIndex < this.phases.length - 1) {
@@ -14374,6 +14377,19 @@ var Timeline = class {
14374
14377
  };
14375
14378
  this.rafHandle = requestAnimationFrame(step);
14376
14379
  }
14380
+ /**
14381
+ * 段の進みを 2 つ同時に置く (cdl#711)。
14382
+ *
14383
+ * **代入する場所を 1 つに閉じる**。 曲げた進みと曲げる前の進みを別々に書くと、
14384
+ * どちらかを更新し忘れた経路が「前の段の値のまま」 で残る。
14385
+ *
14386
+ * 両端 (0 と 1) は曲線を通さず、 そのまま置く。 曲線は差し替えられる欄なので、
14387
+ * `easing(1)` が 1 を返す保証がない。 段の始まりと終わりの値は曲線に委ねない。
14388
+ */
14389
+ setProgress(linear2) {
14390
+ this.phaseLinearProgress = linear2;
14391
+ this.phaseProgress = linear2 <= 0 ? 0 : linear2 >= 1 ? 1 : this.easing(linear2);
14392
+ }
14377
14393
  cancelRaf() {
14378
14394
  if (this.rafHandle != null) {
14379
14395
  cancelAnimationFrame(this.rafHandle);
@@ -25527,7 +25543,12 @@ function ChartSlopeNode({
25527
25543
  const \u4E0A\u7AEF = PAD + (\u524D\u3042\u308A ? \u6642\u70B9\u306E\u7D1A + 12 : 0) + 6;
25528
25544
  const \u4E0B\u7AEF = Math.max(\u4E0A\u7AEF + 10, node.h - PAD - 6);
25529
25545
  const y\u3092\u53D6\u308B = (v) => \u5C3A\u306E\u5E45 > 0 ? \u4E0B\u7AEF - (v - \u6700\u5C0F) / \u5C3A\u306E\u5E45 * (\u4E0B\u7AEF - \u4E0A\u7AEF) : (\u4E0A\u7AEF + \u4E0B\u7AEF) / 2;
25530
- const \u5F62 = \u524D\u3042\u308A && node.chartSlopeForm === "delta" ? "delta" : "values";
25546
+ const \u66F8\u3044\u305F\u5F62 = node.chartSlopeForm;
25547
+ const \u5F62 = \u524D\u3042\u308A && (\u66F8\u3044\u305F\u5F62 === "delta" || \u66F8\u3044\u305F\u5F62 === "rank") ? \u66F8\u3044\u305F\u5F62 : "values";
25548
+ const \u9806\u4F4D\u3092\u53D6\u308B = (v, \u5168\u90E8) => \u5168\u90E8.filter((x) => x > v).length + 1;
25549
+ const \u524D\u306E\u9806\u4F4D = \u7CFB\u5217\u305F\u3061.map((s) => \u9806\u4F4D\u3092\u53D6\u308B(s.\u524D, \u7CFB\u5217\u305F\u3061.map((x) => x.\u524D)));
25550
+ const \u4ECA\u306E\u9806\u4F4D = \u7CFB\u5217\u305F\u3061.map((s) => \u9806\u4F4D\u3092\u53D6\u308B(s.\u4ECA, \u7CFB\u5217\u305F\u3061.map((x) => x.\u4ECA)));
25551
+ const \u6BB5\u306Ey\u3092\u53D6\u308B = (\u9806\u4F4D) => \u7CFB\u5217\u305F\u3061.length > 1 ? \u4E0A\u7AEF + (\u9806\u4F4D - 1) / (\u7CFB\u5217\u305F\u3061.length - 1) * (\u4E0B\u7AEF - \u4E0A\u7AEF) : (\u4E0A\u7AEF + \u4E0B\u7AEF) / 2;
25531
25552
  const \u5897\u6E1B\u8868\u8A18 = (\u524D, \u4ECA) => {
25532
25553
  const \u5DEE = \u4ECA - \u524D;
25533
25554
  return \u5DEE > 0 ? `+${\u5B9F\u5024\u8868\u8A18(\u5DEE)}` : \u5B9F\u5024\u8868\u8A18(\u5DEE);
@@ -25610,8 +25631,8 @@ function ChartSlopeNode({
25610
25631
  )
25611
25632
  ] }),
25612
25633
  \u7CFB\u5217\u305F\u3061.map((s, i) => {
25613
- const \u5DE6y = y\u3092\u53D6\u308B(s.\u524D);
25614
- const \u53F3y = y\u3092\u53D6\u308B(s.\u4ECA);
25634
+ const \u5DE6y = \u5F62 === "rank" ? \u6BB5\u306Ey\u3092\u53D6\u308B(\u524D\u306E\u9806\u4F4D[i]) : y\u3092\u53D6\u308B(s.\u524D);
25635
+ const \u53F3y = \u5F62 === "rank" ? \u6BB5\u306Ey\u3092\u53D6\u308B(\u4ECA\u306E\u9806\u4F4D[i]) : y\u3092\u53D6\u308B(s.\u4ECA);
25615
25636
  const \u672A\u89E3\u6C7A = s.\u672A\u89E3\u6C7A ? "true" : void 0;
25616
25637
  return /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
25617
25638
  \u524D\u3042\u308A && /* @__PURE__ */ jsxRuntime.jsx(
@@ -30642,6 +30663,7 @@ function CdlStage({
30642
30663
  laid,
30643
30664
  currentPhase,
30644
30665
  progress,
30666
+ drawProgress,
30645
30667
  stateValues,
30646
30668
  debug,
30647
30669
  compact = false,
@@ -30699,7 +30721,8 @@ function CdlStage({
30699
30721
  }
30700
30722
  return scales;
30701
30723
  }, [laid]);
30702
- const \u63CF\u304F\u9032\u307F = \u63CF\u304F\u9032\u307F\u306B\u76F4\u3059(progress, currentPhase?.drawRatio);
30724
+ const \u63CF\u304F\u7D20\u306E\u9032\u307F = drawProgress ?? progress;
30725
+ const \u63CF\u304F\u9032\u307F = \u63CF\u304F\u9032\u307F\u306B\u76F4\u3059(\u63CF\u304F\u7D20\u306E\u9032\u307F, currentPhase?.drawRatio);
30703
30726
  const { lifelineStarts, uniformFooterTop } = react.useMemo(() => {
30704
30727
  const starts = lifelineStartYs(laid.nodes);
30705
30728
  return {
@@ -30878,7 +30901,7 @@ function CdlStage({
30878
30901
  edge,
30879
30902
  active: activeSet.has(edge.id),
30880
30903
  drawing: \u77E2\u5370\u306E\u51FA\u756A.\u4F38\u3070\u3059\u304B(edge.id),
30881
- progress,
30904
+ progress: \u77E2\u5370\u306E\u51FA\u756A.\u4F38\u3070\u3059\u304B(edge.id) ? \u63CF\u304F\u9032\u307F : progress,
30882
30905
  stateValues
30883
30906
  },
30884
30907
  edge.id
@@ -31109,6 +31132,7 @@ function CdlDiagramView({ diagram: diagram2, laid: laidProp, hideHeader = false,
31109
31132
  const phaseIdx = focusPhaseId ? laid.phases.findIndex((p) => p.id === focusPhaseId) : state.phaseIndex;
31110
31133
  const currentPhase = laid.phases[Math.max(0, phaseIdx)] ?? laid.phases[0];
31111
31134
  const progress = reduced ? 1 : state.phaseProgress;
31135
+ const drawProgress = reduced ? 1 : state.phaseLinearProgress;
31112
31136
  const baseStateValues = computeStateValues(laid, phaseIdx, progress);
31113
31137
  const isInteractive = hasInteractivePrimitives(diagram2);
31114
31138
  const interactive = useInteractiveIntegration(
@@ -31150,7 +31174,7 @@ function CdlDiagramView({ diagram: diagram2, laid: laidProp, hideHeader = false,
31150
31174
  }
31151
31175
  ),
31152
31176
  isInteractive && interactive.panel,
31153
- /* @__PURE__ */ jsxRuntime.jsx(CdlStage, { laid, currentPhase, progress, stateValues, debug, compact: hideHeader, svgRef: isInteractive ? interactive.svgRef : void 0 }),
31177
+ /* @__PURE__ */ jsxRuntime.jsx(CdlStage, { laid, currentPhase, progress, drawProgress, stateValues, debug, compact: hideHeader, svgRef: isInteractive ? interactive.svgRef : void 0 }),
31154
31178
  hideHeader && !hideMiniPhaseIndicator && currentPhase && laid.phases.length > 1 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-3 border-t border-[var(--cdl-divider,#d4d4d8)]/40 bg-[var(--cdl-stage-bg,#f1f5f9)]/50 px-3 py-2 text-xs", children: [
31155
31179
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
31156
31180
  laid.phases.map((p, i) => /* @__PURE__ */ jsxRuntime.jsx(