@cardenelabs/cdl 0.17.1 → 0.18.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 +29 -1
- package/dist/index.cjs +22 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +21 -4
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +19 -3
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +19 -3
- package/dist/react.js.map +1 -1
- package/dist/{render-Dc5Pdf7e.d.cts → render-Czv0tUon.d.cts} +25 -1
- package/dist/{render-Dc5Pdf7e.d.ts → render-Czv0tUon.d.ts} +25 -1
- package/package.json +1 -1
- package/src/index.ts +3 -0
- package/src/layout.ts +2 -0
- package/src/render/stage.tsx +38 -4
- package/src/types.ts +27 -0
|
@@ -162,6 +162,12 @@ type EdgeHeadFill = "solid" | "hollow";
|
|
|
162
162
|
declare const EDGE_HEAD_FILL_DEFAULT: EdgeHeadFill;
|
|
163
163
|
/** 塗り方の全種。 marker の定義と検査の走査がこの並びを引く */
|
|
164
164
|
declare const EDGE_HEAD_FILLS: readonly EdgeHeadFill[];
|
|
165
|
+
/** 矢印をいつ出すか (#582)。 `CdlDiagram.edgeReveal` が取る値と 1 対 1 */
|
|
166
|
+
type EdgeReveal = "phase" | "all";
|
|
167
|
+
/** 書ける値の一覧 (#582)。 利用側はここから導く = 手で並べると増えた時に取り残される */
|
|
168
|
+
declare const EDGE_REVEALS: readonly EdgeReveal[];
|
|
169
|
+
/** 書かなかった時の値 (#582) */
|
|
170
|
+
declare const EDGE_REVEAL_DEFAULT: EdgeReveal;
|
|
165
171
|
/**
|
|
166
172
|
* 行き先と出どころの **両端に印を置ける** (#578)。
|
|
167
173
|
*
|
|
@@ -2409,6 +2415,22 @@ type CdlDiagram = {
|
|
|
2409
2415
|
* 既定は `"extract"` = 付け忘れても検知が緩まない向き。
|
|
2410
2416
|
*/
|
|
2411
2417
|
structuredData?: "extract" | "exclude";
|
|
2418
|
+
/**
|
|
2419
|
+
* 矢印をいつ出すか (既定 = `"phase"`、 #582)。
|
|
2420
|
+
*
|
|
2421
|
+
* - `"phase"` ... 段のどこかで光る矢印は、その段が来るまで描かない。 1 度出たら出したまま
|
|
2422
|
+
* - `"all"` ... 段に関わらず最初から全部描く
|
|
2423
|
+
*
|
|
2424
|
+
* 既定を `"phase"` にするのは、段を進めるごとに関係が 1 本ずつ増える図で、全ての矢印が
|
|
2425
|
+
* 1 段目から見えていたため (実測 = 段が矢印を引き直しても「増えた」 と読めず、無関係な線が
|
|
2426
|
+
* ちらついたようにしか見えない)。
|
|
2427
|
+
*
|
|
2428
|
+
* **段が矢印を 1 度も名指ししない図は `"phase"` でも隠さない**。 そういう図では矢印が骨格
|
|
2429
|
+
* そのもので、隠す理由が無い = 既定を変えても既存の図は動かない。
|
|
2430
|
+
*
|
|
2431
|
+
* `"all"` は「段で光らせはするが、線そのものは最初から見せたい」 図のための逃げ道。
|
|
2432
|
+
*/
|
|
2433
|
+
edgeReveal?: EdgeReveal;
|
|
2412
2434
|
/**
|
|
2413
2435
|
* interactive input widgets (v0.5+、 CAR #243)。
|
|
2414
2436
|
* builder chain の `.input.slider() / .number() / .dropdown() / .toggle()` で追加。
|
|
@@ -2619,6 +2641,8 @@ type LaidDiagram = {
|
|
|
2619
2641
|
phases: CdlPhase[];
|
|
2620
2642
|
/** 他の値から自動で決まる値 (`CdlDiagram.derived` をそのまま引き継ぐ) */
|
|
2621
2643
|
derived?: CdlDerivedValue[];
|
|
2644
|
+
/** 矢印をいつ出すか (`CdlDiagram.edgeReveal` をそのまま引き継ぐ、 #582) */
|
|
2645
|
+
edgeReveal?: EdgeReveal;
|
|
2622
2646
|
/**
|
|
2623
2647
|
* キャンバス全要素の bounding box list。
|
|
2624
2648
|
* engine が「ここに何があるか」 を全部把握、 衝突検証 / debug 表示 / validation で使う。
|
|
@@ -2786,4 +2810,4 @@ type CdlDiagramViewProps = {
|
|
|
2786
2810
|
};
|
|
2787
2811
|
declare function CdlDiagramView({ diagram, laid: laidProp, hideHeader, hideMiniPhaseIndicator, focusPhaseId, debug, emitGeometryWarn, headingLevel, interactiveHandlers }: CdlDiagramViewProps): JSX.Element;
|
|
2788
2812
|
|
|
2789
|
-
export {
|
|
2813
|
+
export { sequenceBoardMetrics as $, EDGE_STYLES as A, type BBox as B, type CdlDiagram as C, type EdgeReveal as D, type EdgeStyle as E, type InteractiveSignalsAccessor as F, type LaidLane as G, NODE_KINDS as H, type InteractiveHandlerMap as I, type JourneyEmotion as J, type ScrollProgressHandle as K, type LaidDiagram as L, TONES as M, type NodeKind as N, computeEventBindingKey as O, computeFormulaKey as P, type QuadrantKey as Q, type RowMark as R, type Signal as S, type Tone as T, computeInputSignalKey as U, computeScrollTriggerKey as V, computed as W, createInteractiveSignalsAccessor as X, createScrollProgressHandle as Y, createScrollProgressSignals as Z, hasInteractivePrimitives as _, type CdlInput as a, sequenceStepId as a0, signal as a1, type CdlLane as b, type CdlNode as c, type Side as d, type EdgeHead as e, type EdgeHeadFill as f, type CdlState as g, type CdlEventTarget as h, type Computed as i, type CdlDerivedValue as j, type CdlScrollTrigger as k, type CdlDiagramViewProps as l, type LaidEdge as m, type LaidNode as n, type CdlEdge as o, CdlDiagramView as p, type CdlEventBinding as q, type CdlEventKind as r, type CdlFormula as s, type CdlPhase as t, EDGE_HEADS as u, EDGE_HEAD_DEFAULT as v, EDGE_HEAD_FILLS as w, EDGE_HEAD_FILL_DEFAULT as x, EDGE_REVEALS as y, EDGE_REVEAL_DEFAULT as z };
|
|
@@ -162,6 +162,12 @@ type EdgeHeadFill = "solid" | "hollow";
|
|
|
162
162
|
declare const EDGE_HEAD_FILL_DEFAULT: EdgeHeadFill;
|
|
163
163
|
/** 塗り方の全種。 marker の定義と検査の走査がこの並びを引く */
|
|
164
164
|
declare const EDGE_HEAD_FILLS: readonly EdgeHeadFill[];
|
|
165
|
+
/** 矢印をいつ出すか (#582)。 `CdlDiagram.edgeReveal` が取る値と 1 対 1 */
|
|
166
|
+
type EdgeReveal = "phase" | "all";
|
|
167
|
+
/** 書ける値の一覧 (#582)。 利用側はここから導く = 手で並べると増えた時に取り残される */
|
|
168
|
+
declare const EDGE_REVEALS: readonly EdgeReveal[];
|
|
169
|
+
/** 書かなかった時の値 (#582) */
|
|
170
|
+
declare const EDGE_REVEAL_DEFAULT: EdgeReveal;
|
|
165
171
|
/**
|
|
166
172
|
* 行き先と出どころの **両端に印を置ける** (#578)。
|
|
167
173
|
*
|
|
@@ -2409,6 +2415,22 @@ type CdlDiagram = {
|
|
|
2409
2415
|
* 既定は `"extract"` = 付け忘れても検知が緩まない向き。
|
|
2410
2416
|
*/
|
|
2411
2417
|
structuredData?: "extract" | "exclude";
|
|
2418
|
+
/**
|
|
2419
|
+
* 矢印をいつ出すか (既定 = `"phase"`、 #582)。
|
|
2420
|
+
*
|
|
2421
|
+
* - `"phase"` ... 段のどこかで光る矢印は、その段が来るまで描かない。 1 度出たら出したまま
|
|
2422
|
+
* - `"all"` ... 段に関わらず最初から全部描く
|
|
2423
|
+
*
|
|
2424
|
+
* 既定を `"phase"` にするのは、段を進めるごとに関係が 1 本ずつ増える図で、全ての矢印が
|
|
2425
|
+
* 1 段目から見えていたため (実測 = 段が矢印を引き直しても「増えた」 と読めず、無関係な線が
|
|
2426
|
+
* ちらついたようにしか見えない)。
|
|
2427
|
+
*
|
|
2428
|
+
* **段が矢印を 1 度も名指ししない図は `"phase"` でも隠さない**。 そういう図では矢印が骨格
|
|
2429
|
+
* そのもので、隠す理由が無い = 既定を変えても既存の図は動かない。
|
|
2430
|
+
*
|
|
2431
|
+
* `"all"` は「段で光らせはするが、線そのものは最初から見せたい」 図のための逃げ道。
|
|
2432
|
+
*/
|
|
2433
|
+
edgeReveal?: EdgeReveal;
|
|
2412
2434
|
/**
|
|
2413
2435
|
* interactive input widgets (v0.5+、 CAR #243)。
|
|
2414
2436
|
* builder chain の `.input.slider() / .number() / .dropdown() / .toggle()` で追加。
|
|
@@ -2619,6 +2641,8 @@ type LaidDiagram = {
|
|
|
2619
2641
|
phases: CdlPhase[];
|
|
2620
2642
|
/** 他の値から自動で決まる値 (`CdlDiagram.derived` をそのまま引き継ぐ) */
|
|
2621
2643
|
derived?: CdlDerivedValue[];
|
|
2644
|
+
/** 矢印をいつ出すか (`CdlDiagram.edgeReveal` をそのまま引き継ぐ、 #582) */
|
|
2645
|
+
edgeReveal?: EdgeReveal;
|
|
2622
2646
|
/**
|
|
2623
2647
|
* キャンバス全要素の bounding box list。
|
|
2624
2648
|
* engine が「ここに何があるか」 を全部把握、 衝突検証 / debug 表示 / validation で使う。
|
|
@@ -2786,4 +2810,4 @@ type CdlDiagramViewProps = {
|
|
|
2786
2810
|
};
|
|
2787
2811
|
declare function CdlDiagramView({ diagram, laid: laidProp, hideHeader, hideMiniPhaseIndicator, focusPhaseId, debug, emitGeometryWarn, headingLevel, interactiveHandlers }: CdlDiagramViewProps): JSX.Element;
|
|
2788
2812
|
|
|
2789
|
-
export {
|
|
2813
|
+
export { sequenceBoardMetrics as $, EDGE_STYLES as A, type BBox as B, type CdlDiagram as C, type EdgeReveal as D, type EdgeStyle as E, type InteractiveSignalsAccessor as F, type LaidLane as G, NODE_KINDS as H, type InteractiveHandlerMap as I, type JourneyEmotion as J, type ScrollProgressHandle as K, type LaidDiagram as L, TONES as M, type NodeKind as N, computeEventBindingKey as O, computeFormulaKey as P, type QuadrantKey as Q, type RowMark as R, type Signal as S, type Tone as T, computeInputSignalKey as U, computeScrollTriggerKey as V, computed as W, createInteractiveSignalsAccessor as X, createScrollProgressHandle as Y, createScrollProgressSignals as Z, hasInteractivePrimitives as _, type CdlInput as a, sequenceStepId as a0, signal as a1, type CdlLane as b, type CdlNode as c, type Side as d, type EdgeHead as e, type EdgeHeadFill as f, type CdlState as g, type CdlEventTarget as h, type Computed as i, type CdlDerivedValue as j, type CdlScrollTrigger as k, type CdlDiagramViewProps as l, type LaidEdge as m, type LaidNode as n, type CdlEdge as o, CdlDiagramView as p, type CdlEventBinding as q, type CdlEventKind as r, type CdlFormula as s, type CdlPhase as t, EDGE_HEADS as u, EDGE_HEAD_DEFAULT as v, EDGE_HEAD_FILLS as w, EDGE_HEAD_FILL_DEFAULT as x, EDGE_REVEALS as y, EDGE_REVEAL_DEFAULT as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cardenelabs/cdl",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "CDL (Chainome Diagram Language). Mermaid-like declarative DSL that compiles to animated SVG diagrams. Built for blockchain / Solidity flows, generic enough for sequence / flow / state / ER / topology diagrams.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "cardene777",
|
package/src/index.ts
CHANGED
|
@@ -284,6 +284,7 @@ export type {
|
|
|
284
284
|
CdlState,
|
|
285
285
|
EdgeHead,
|
|
286
286
|
EdgeHeadFill,
|
|
287
|
+
EdgeReveal,
|
|
287
288
|
RowMark,
|
|
288
289
|
EdgeStyle,
|
|
289
290
|
LaidDiagram,
|
|
@@ -305,6 +306,8 @@ export {
|
|
|
305
306
|
EDGE_HEAD_DEFAULT,
|
|
306
307
|
EDGE_HEAD_FILLS,
|
|
307
308
|
EDGE_HEAD_FILL_DEFAULT,
|
|
309
|
+
EDGE_REVEALS,
|
|
310
|
+
EDGE_REVEAL_DEFAULT,
|
|
308
311
|
EDGE_STYLES,
|
|
309
312
|
} from "./types";
|
|
310
313
|
|
package/src/layout.ts
CHANGED
|
@@ -371,6 +371,8 @@ export function layout(diag: CdlDiagram): LaidDiagram {
|
|
|
371
371
|
states: diag.states,
|
|
372
372
|
phases: diag.phases,
|
|
373
373
|
...(diag.derived ? { derived: diag.derived } : {}),
|
|
374
|
+
// 矢印をいつ出すか (#582)。 描き手が読む欄なので、そのまま持ち越す
|
|
375
|
+
...(diag.edgeReveal ? { edgeReveal: diag.edgeReveal } : {}),
|
|
374
376
|
bboxes,
|
|
375
377
|
collisions,
|
|
376
378
|
nearCollisions,
|
package/src/render/stage.tsx
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { useMemo, type JSX } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
EDGE_HEADS,
|
|
4
|
+
EDGE_HEAD_FILLS,
|
|
5
|
+
EDGE_HEAD_FILL_DEFAULT,
|
|
6
|
+
EDGE_REVEAL_DEFAULT,
|
|
7
|
+
type CdlPhase,
|
|
8
|
+
type LaidDiagram,
|
|
9
|
+
} from "../types";
|
|
3
10
|
import { CdlEdgeView, CdlEdgeGlowView, CdlEdgeLabelView } from "./edges";
|
|
4
11
|
import { CdlNodeView } from "./nodes";
|
|
5
12
|
import { TONE, TONE_HEX } from "./tone";
|
|
@@ -27,6 +34,33 @@ export function CdlStage({
|
|
|
27
34
|
svgRef?: React.RefObject<SVGSVGElement | null>;
|
|
28
35
|
}): JSX.Element {
|
|
29
36
|
const activeSet = new Set(currentPhase?.activate ?? []);
|
|
37
|
+
/*
|
|
38
|
+
* まだ出番の来ていない矢印は描かない (#582)。
|
|
39
|
+
*
|
|
40
|
+
* 段を進めるごとに関係が 1 本ずつ増える図で、全ての矢印が 1 段目から見えていた。 段が進むと
|
|
41
|
+
* その矢印だけが引き直されるが、既に見えているので「増えた」 ようには読めず、無関係な線が
|
|
42
|
+
* ちらついたようにしか見えない (user 実機確認)。
|
|
43
|
+
*
|
|
44
|
+
* **段のどこかで光る矢印だけを対象にする**。 段が矢印を 1 度も名指ししない図では、矢印は
|
|
45
|
+
* 図の骨格そのものなので隠す理由が無い。 1 度出たら以降は出したままにする = 消える向きの
|
|
46
|
+
* 動きは、読み手が「戻った」 と読む。
|
|
47
|
+
*
|
|
48
|
+
* 著者が `edgeReveal: "all"` と書いた図では隠さない。
|
|
49
|
+
*/
|
|
50
|
+
const 出番の来た矢印 = useMemo(() => {
|
|
51
|
+
// 著者が「最初から全部見せる」 と書いた図では隠さない (#582)
|
|
52
|
+
if ((laid.edgeReveal ?? EDGE_REVEAL_DEFAULT) === "all") return () => true;
|
|
53
|
+
const 初出 = new Map<string, number>();
|
|
54
|
+
laid.phases.forEach((p, i) => {
|
|
55
|
+
for (const id of p.activate ?? []) if (!初出.has(id)) 初出.set(id, i);
|
|
56
|
+
});
|
|
57
|
+
const 今 = currentPhase === undefined ? -1 : laid.phases.findIndex((p) => p.id === currentPhase.id);
|
|
58
|
+
return (edgeId: string): boolean => {
|
|
59
|
+
const first = 初出.get(edgeId);
|
|
60
|
+
if (first === undefined) return true;
|
|
61
|
+
return 今 < 0 || 今 >= first;
|
|
62
|
+
};
|
|
63
|
+
}, [laid.phases, currentPhase]);
|
|
30
64
|
// この phase で左の起点から描き始める node (cdl#512)。 `activate` とは別集合で持つ =
|
|
31
65
|
// 焦点が当たり続ける図で毎 phase 引き直すことになるため、 光っているかを引き金にしない
|
|
32
66
|
const drawSet = new Set(currentPhase?.draw ?? []);
|
|
@@ -231,7 +265,7 @@ export function CdlStage({
|
|
|
231
265
|
))}
|
|
232
266
|
|
|
233
267
|
{/* edges (1st pass) */}
|
|
234
|
-
{laid.edges.map((edge) => (
|
|
268
|
+
{laid.edges.filter((edge) => 出番の来た矢印(edge.id)).map((edge) => (
|
|
235
269
|
<CdlEdgeView key={edge.id} edge={edge} active={activeSet.has(edge.id)} progress={progress} stateValues={stateValues} />
|
|
236
270
|
))}
|
|
237
271
|
|
|
@@ -256,13 +290,13 @@ export function CdlStage({
|
|
|
256
290
|
|
|
257
291
|
{/* 経由 node 貫通する dotted-flow edge の進行点 glow (3rd pass) */}
|
|
258
292
|
{laid.edges
|
|
259
|
-
.filter((edge) => Boolean(edge.dThrough))
|
|
293
|
+
.filter((edge) => Boolean(edge.dThrough) && 出番の来た矢印(edge.id))
|
|
260
294
|
.map((edge) => (
|
|
261
295
|
<CdlEdgeGlowView key={`glow-${edge.id}`} edge={edge} active={activeSet.has(edge.id)} />
|
|
262
296
|
))}
|
|
263
297
|
|
|
264
298
|
{/* edge labels (3rd pass) ... 全 edge の label を最前面に描画 */}
|
|
265
|
-
{laid.edges.map((edge) => (
|
|
299
|
+
{laid.edges.filter((edge) => 出番の来た矢印(edge.id)).map((edge) => (
|
|
266
300
|
<CdlEdgeLabelView
|
|
267
301
|
key={`label-${edge.id}`}
|
|
268
302
|
edge={edge}
|
package/src/types.ts
CHANGED
|
@@ -213,6 +213,15 @@ export const EDGE_HEAD_FILL_DEFAULT: EdgeHeadFill = "solid";
|
|
|
213
213
|
/** 塗り方の全種。 marker の定義と検査の走査がこの並びを引く */
|
|
214
214
|
export const EDGE_HEAD_FILLS: readonly EdgeHeadFill[] = ["solid", "hollow"];
|
|
215
215
|
|
|
216
|
+
/** 矢印をいつ出すか (#582)。 `CdlDiagram.edgeReveal` が取る値と 1 対 1 */
|
|
217
|
+
export type EdgeReveal = "phase" | "all";
|
|
218
|
+
|
|
219
|
+
/** 書ける値の一覧 (#582)。 利用側はここから導く = 手で並べると増えた時に取り残される */
|
|
220
|
+
export const EDGE_REVEALS: readonly EdgeReveal[] = ["phase", "all"];
|
|
221
|
+
|
|
222
|
+
/** 書かなかった時の値 (#582) */
|
|
223
|
+
export const EDGE_REVEAL_DEFAULT: EdgeReveal = "phase";
|
|
224
|
+
|
|
216
225
|
/**
|
|
217
226
|
* 行き先と出どころの **両端に印を置ける** (#578)。
|
|
218
227
|
*
|
|
@@ -2480,6 +2489,22 @@ export type CdlDiagram = {
|
|
|
2480
2489
|
* 既定は `"extract"` = 付け忘れても検知が緩まない向き。
|
|
2481
2490
|
*/
|
|
2482
2491
|
structuredData?: "extract" | "exclude";
|
|
2492
|
+
/**
|
|
2493
|
+
* 矢印をいつ出すか (既定 = `"phase"`、 #582)。
|
|
2494
|
+
*
|
|
2495
|
+
* - `"phase"` ... 段のどこかで光る矢印は、その段が来るまで描かない。 1 度出たら出したまま
|
|
2496
|
+
* - `"all"` ... 段に関わらず最初から全部描く
|
|
2497
|
+
*
|
|
2498
|
+
* 既定を `"phase"` にするのは、段を進めるごとに関係が 1 本ずつ増える図で、全ての矢印が
|
|
2499
|
+
* 1 段目から見えていたため (実測 = 段が矢印を引き直しても「増えた」 と読めず、無関係な線が
|
|
2500
|
+
* ちらついたようにしか見えない)。
|
|
2501
|
+
*
|
|
2502
|
+
* **段が矢印を 1 度も名指ししない図は `"phase"` でも隠さない**。 そういう図では矢印が骨格
|
|
2503
|
+
* そのもので、隠す理由が無い = 既定を変えても既存の図は動かない。
|
|
2504
|
+
*
|
|
2505
|
+
* `"all"` は「段で光らせはするが、線そのものは最初から見せたい」 図のための逃げ道。
|
|
2506
|
+
*/
|
|
2507
|
+
edgeReveal?: EdgeReveal;
|
|
2483
2508
|
/**
|
|
2484
2509
|
* interactive input widgets (v0.5+、 CAR #243)。
|
|
2485
2510
|
* builder chain の `.input.slider() / .number() / .dropdown() / .toggle()` で追加。
|
|
@@ -2692,6 +2717,8 @@ export type LaidDiagram = {
|
|
|
2692
2717
|
phases: CdlPhase[];
|
|
2693
2718
|
/** 他の値から自動で決まる値 (`CdlDiagram.derived` をそのまま引き継ぐ) */
|
|
2694
2719
|
derived?: CdlDerivedValue[];
|
|
2720
|
+
/** 矢印をいつ出すか (`CdlDiagram.edgeReveal` をそのまま引き継ぐ、 #582) */
|
|
2721
|
+
edgeReveal?: EdgeReveal;
|
|
2695
2722
|
/**
|
|
2696
2723
|
* キャンバス全要素の bounding box list。
|
|
2697
2724
|
* engine が「ここに何があるか」 を全部把握、 衝突検証 / debug 表示 / validation で使う。
|