@cardenelabs/cdl 0.37.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/dist/react.js CHANGED
@@ -64,6 +64,8 @@ var Timeline = class {
64
64
  rafHandle = null;
65
65
  phaseIndex = 0;
66
66
  phaseProgress = 0;
67
+ /** 曲線を通す前の進み (cdl#711)。 経過時間そのものの割合で、 描く動きが読む */
68
+ phaseLinearProgress = 0;
67
69
  phaseStartedAt = 0;
68
70
  status = "idle";
69
71
  /**
@@ -92,12 +94,12 @@ var Timeline = class {
92
94
  const initial = options.initialPhaseIndex;
93
95
  if (initial != null && initial > 0 && initial < phases.length) {
94
96
  this.phaseIndex = initial;
95
- this.phaseProgress = 1;
97
+ this.setProgress(1);
96
98
  this.status = initial === phases.length - 1 ? "settled" : "paused";
97
99
  }
98
100
  this.initialState = {
99
101
  phaseIndex: this.phaseIndex,
100
- phaseProgress: this.phaseProgress,
102
+ phaseLinearProgress: this.phaseLinearProgress,
101
103
  status: this.status
102
104
  };
103
105
  }
@@ -119,13 +121,14 @@ var Timeline = class {
119
121
  }
120
122
  snapshot() {
121
123
  const cached = this.cachedSnapshot;
122
- if (cached && cached.status === this.status && cached.phaseIndex === this.phaseIndex && cached.phaseProgress === this.phaseProgress && cached.totalPhases === this.phases.length) {
124
+ if (cached && cached.status === this.status && cached.phaseIndex === this.phaseIndex && cached.phaseProgress === this.phaseProgress && cached.phaseLinearProgress === this.phaseLinearProgress && cached.totalPhases === this.phases.length) {
123
125
  return cached;
124
126
  }
125
127
  const next = {
126
128
  status: this.status,
127
129
  phaseIndex: this.phaseIndex,
128
130
  phaseProgress: this.phaseProgress,
131
+ phaseLinearProgress: this.phaseLinearProgress,
129
132
  totalPhases: this.phases.length
130
133
  };
131
134
  this.cachedSnapshot = next;
@@ -148,7 +151,7 @@ var Timeline = class {
148
151
  const clamped = Math.max(0, Math.min(this.phases.length - 1, index));
149
152
  this.cancelRaf();
150
153
  this.phaseIndex = clamped;
151
- this.phaseProgress = 1;
154
+ this.setProgress(1);
152
155
  this.status = clamped === this.phases.length - 1 ? "settled" : "paused";
153
156
  this.emit();
154
157
  }
@@ -188,14 +191,14 @@ var Timeline = class {
188
191
  if (this.phaseIndex <= 0) return;
189
192
  this.cancelRaf();
190
193
  this.phaseIndex -= 1;
191
- this.phaseProgress = 1;
194
+ this.setProgress(1);
192
195
  this.status = "paused";
193
196
  this.emit();
194
197
  }
195
198
  reset() {
196
199
  this.cancelRaf();
197
200
  this.phaseIndex = 0;
198
- this.phaseProgress = 0;
201
+ this.setProgress(0);
199
202
  this.status = "idle";
200
203
  this.emit();
201
204
  }
@@ -216,7 +219,7 @@ var Timeline = class {
216
219
  this.subscribers.clear();
217
220
  this.status = this.initialState.status;
218
221
  this.phaseIndex = this.initialState.phaseIndex;
219
- this.phaseProgress = this.initialState.phaseProgress;
222
+ this.setProgress(this.initialState.phaseLinearProgress);
220
223
  }
221
224
  // ─── internals ───────────────────────────────────────────────
222
225
  advancePhase() {
@@ -252,20 +255,20 @@ var Timeline = class {
252
255
  }, ms);
253
256
  }
254
257
  beginPhaseTransition() {
255
- this.phaseProgress = 0;
258
+ this.setProgress(0);
256
259
  this.phaseStartedAt = performance.now();
257
260
  this.cancelRaf();
258
261
  const step = (now) => {
259
262
  const duration = this.autoAdvanceMsOverride ?? this.getPhase().durationMs ?? 600;
260
263
  const elapsed = now - this.phaseStartedAt;
261
264
  const linearT = clamp01(elapsed / duration);
262
- this.phaseProgress = this.easing(linearT);
265
+ this.setProgress(linearT);
263
266
  this.emit();
264
267
  if (linearT < 1) {
265
268
  this.rafHandle = requestAnimationFrame(step);
266
269
  return;
267
270
  }
268
- this.phaseProgress = 1;
271
+ this.setProgress(1);
269
272
  this.emit();
270
273
  if (this.status === "playing") {
271
274
  if (this.phaseIndex < this.phases.length - 1) {
@@ -280,6 +283,19 @@ var Timeline = class {
280
283
  };
281
284
  this.rafHandle = requestAnimationFrame(step);
282
285
  }
286
+ /**
287
+ * 段の進みを 2 つ同時に置く (cdl#711)。
288
+ *
289
+ * **代入する場所を 1 つに閉じる**。 曲げた進みと曲げる前の進みを別々に書くと、
290
+ * どちらかを更新し忘れた経路が「前の段の値のまま」 で残る。
291
+ *
292
+ * 両端 (0 と 1) は曲線を通さず、 そのまま置く。 曲線は差し替えられる欄なので、
293
+ * `easing(1)` が 1 を返す保証がない。 段の始まりと終わりの値は曲線に委ねない。
294
+ */
295
+ setProgress(linear2) {
296
+ this.phaseLinearProgress = linear2;
297
+ this.phaseProgress = linear2 <= 0 ? 0 : linear2 >= 1 ? 1 : this.easing(linear2);
298
+ }
283
299
  cancelRaf() {
284
300
  if (this.rafHandle != null) {
285
301
  cancelAnimationFrame(this.rafHandle);
@@ -18146,6 +18162,7 @@ function CdlStage({
18146
18162
  laid,
18147
18163
  currentPhase,
18148
18164
  progress,
18165
+ drawProgress,
18149
18166
  stateValues,
18150
18167
  debug,
18151
18168
  compact = false,
@@ -18203,7 +18220,8 @@ function CdlStage({
18203
18220
  }
18204
18221
  return scales;
18205
18222
  }, [laid]);
18206
- const \u63CF\u304F\u9032\u307F = \u63CF\u304F\u9032\u307F\u306B\u76F4\u3059(progress, currentPhase?.drawRatio);
18223
+ const \u63CF\u304F\u7D20\u306E\u9032\u307F = drawProgress ?? progress;
18224
+ const \u63CF\u304F\u9032\u307F = \u63CF\u304F\u9032\u307F\u306B\u76F4\u3059(\u63CF\u304F\u7D20\u306E\u9032\u307F, currentPhase?.drawRatio);
18207
18225
  const { lifelineStarts, uniformFooterTop } = useMemo(() => {
18208
18226
  const starts = lifelineStartYs(laid.nodes);
18209
18227
  return {
@@ -18382,7 +18400,7 @@ function CdlStage({
18382
18400
  edge,
18383
18401
  active: activeSet.has(edge.id),
18384
18402
  drawing: \u77E2\u5370\u306E\u51FA\u756A.\u4F38\u3070\u3059\u304B(edge.id),
18385
- progress,
18403
+ progress: \u77E2\u5370\u306E\u51FA\u756A.\u4F38\u3070\u3059\u304B(edge.id) ? \u63CF\u304F\u9032\u307F : progress,
18386
18404
  stateValues
18387
18405
  },
18388
18406
  edge.id
@@ -27215,6 +27233,7 @@ function CdlDiagramView({ diagram, laid: laidProp, hideHeader = false, hideMiniP
27215
27233
  const phaseIdx = focusPhaseId ? laid.phases.findIndex((p) => p.id === focusPhaseId) : state.phaseIndex;
27216
27234
  const currentPhase = laid.phases[Math.max(0, phaseIdx)] ?? laid.phases[0];
27217
27235
  const progress = reduced ? 1 : state.phaseProgress;
27236
+ const drawProgress = reduced ? 1 : state.phaseLinearProgress;
27218
27237
  const baseStateValues = computeStateValues(laid, phaseIdx, progress);
27219
27238
  const isInteractive = hasInteractivePrimitives(diagram);
27220
27239
  const interactive = useInteractiveIntegration(
@@ -27256,7 +27275,7 @@ function CdlDiagramView({ diagram, laid: laidProp, hideHeader = false, hideMiniP
27256
27275
  }
27257
27276
  ),
27258
27277
  isInteractive && interactive.panel,
27259
- /* @__PURE__ */ jsx(CdlStage, { laid, currentPhase, progress, stateValues, debug, compact: hideHeader, svgRef: isInteractive ? interactive.svgRef : void 0 }),
27278
+ /* @__PURE__ */ jsx(CdlStage, { laid, currentPhase, progress, drawProgress, stateValues, debug, compact: hideHeader, svgRef: isInteractive ? interactive.svgRef : void 0 }),
27260
27279
  hideHeader && !hideMiniPhaseIndicator && currentPhase && laid.phases.length > 1 && /* @__PURE__ */ 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: [
27261
27280
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
27262
27281
  laid.phases.map((p, i) => /* @__PURE__ */ jsx(