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