@cardenelabs/dragon 0.41.0 → 0.42.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.
Files changed (47) hide show
  1. package/README.md +21 -1
  2. package/dist/cli.cjs +4122 -969
  3. package/dist/cli.cjs.map +1 -1
  4. package/dist/cli.js +4122 -969
  5. package/dist/cli.js.map +1 -1
  6. package/dist/export.cjs +3704 -942
  7. package/dist/export.cjs.map +1 -1
  8. package/dist/export.d.cts +1 -1
  9. package/dist/export.d.ts +1 -1
  10. package/dist/export.js +3704 -942
  11. package/dist/export.js.map +1 -1
  12. package/dist/index.cjs +4016 -815
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.cts +159 -3
  15. package/dist/index.d.ts +159 -3
  16. package/dist/index.js +4016 -815
  17. package/dist/index.js.map +1 -1
  18. package/dist/{ink-B_7OXxtb.d.cts → ink-B8EZL7JV.d.cts} +95 -3
  19. package/dist/{ink-B_7OXxtb.d.ts → ink-B8EZL7JV.d.ts} +95 -3
  20. package/dist/node.cjs +2461 -726
  21. package/dist/node.cjs.map +1 -1
  22. package/dist/node.js +2461 -726
  23. package/dist/node.js.map +1 -1
  24. package/dist/player.global.js +2 -2
  25. package/package.json +1 -1
  26. package/src/export/capture.ts +17 -5
  27. package/src/export/fonts.ts +19 -1
  28. package/src/export/index.ts +2 -2
  29. package/src/field-messages.ts +12 -0
  30. package/src/figure-text.ts +26 -0
  31. package/src/index.ts +11 -1
  32. package/src/layout/scene.ts +23 -2
  33. package/src/layout/time.ts +680 -0
  34. package/src/look/values.ts +142 -2
  35. package/src/messages.ts +108 -5
  36. package/src/parser.ts +427 -6
  37. package/src/player.ts +48 -10
  38. package/src/printer.ts +63 -12
  39. package/src/render/icons.ts +2 -0
  40. package/src/render/parts.ts +29 -9
  41. package/src/render/svg.ts +129 -21
  42. package/src/render/time.ts +291 -0
  43. package/src/schema.ts +109 -10
  44. package/src/schemas/diagram.schema.json +224 -12
  45. package/src/schemas/validate-diagram.js +1 -1
  46. package/src/timeline.ts +147 -10
  47. package/src/words.ts +39 -6
@@ -24,6 +24,15 @@ declare const DEFAULT_PALETTE = "paper";
24
24
  declare const PALETTES: Readonly<Record<string, Palette>>;
25
25
  /** 名前から色味を引く。指定が無いか、知らない名前 (外した墨と朱の `ink` を含む) なら紙と墨。 */
26
26
  declare function resolvePalette(id?: string): Palette;
27
+ /**
28
+ * 色味が持つ色の変数の名前 (#3198)。呼ぶ側が `colors` で値を渡せる鍵。
29
+ * 外へ出す型を `palettes.json` から作ると、束ねた型の file に JSON の中身が初期値付きで写り、型の検査を通らなくなるため、名前を並べて作る。
30
+ * 並びが `palettes.json` の明るい背景の名前と食い違うと、下の 2 つの `_` で始まる型が、余る名前か足りない名前を挙げて型の検査で落ちる
31
+ */
32
+ declare const COLOR_NAMES: readonly ["page", "bg", "surf", "sunk", "ink", "ink2", "mute", "hair", "line", "sh", "on-c", "c-blue", "t-blue", "c-amber", "t-amber", "c-green", "t-green", "c-violet", "t-violet", "c-rose", "t-rose", "c-slate", "t-slate", "coin", "coint", "coinin", "tint", "edge", "shA", "shB", "carry"];
33
+ type ColorName = (typeof COLOR_NAMES)[number];
34
+ /** 名前で選んだ色味に重ねる色の値。渡さない色は色味の値のまま残る (#3198) */
35
+ type Colors = Partial<Record<ColorName, string>>;
27
36
  /** 区画や箱を分ける色の役。灰 (slate) と硬貨 (coin) は分類の色として順に配らない。 */
28
37
  declare const COLOR_ORDER: readonly ["blue", "amber", "green", "violet", "rose"];
29
38
  type ColorKey = (typeof COLOR_ORDER)[number] | "slate" | "coin";
@@ -59,6 +68,8 @@ interface Box {
59
68
  color?: Color;
60
69
  icon?: string;
61
70
  region?: string;
71
+ /** 飛び先。描いた図ではこの箱がここへの link になる。`/` で始まる path か、http:// か https:// で始まる URL (#3199) */
72
+ link?: string;
62
73
  }
63
74
  type Carry = {
64
75
  kind: "envelope";
@@ -80,6 +91,8 @@ type DiagramEvent = {
80
91
  label?: string;
81
92
  carry: Carry;
82
93
  labelSide?: LabelSide;
94
+ at?: number;
95
+ into?: number;
83
96
  } | {
84
97
  type: "action";
85
98
  box: string;
@@ -88,6 +101,7 @@ type DiagramEvent = {
88
101
  type: "swap";
89
102
  box: string;
90
103
  text: string;
104
+ color?: Color;
91
105
  } | {
92
106
  type: "strip";
93
107
  field: string;
@@ -97,7 +111,69 @@ type DiagramEvent = {
97
111
  type: "branch";
98
112
  branch: string;
99
113
  from: string;
100
- };
114
+ } | {
115
+ type: "now";
116
+ to: number;
117
+ } | TimeMarkEvent | TimeSpanEvent;
118
+ /** 時間軸の図 (#3165) の、印の列 `row` の `from` から `to` の目盛りの印の色を変える出来事 */
119
+ interface TimeMarkEvent {
120
+ type: "mark";
121
+ row: string;
122
+ from: number;
123
+ to: number;
124
+ color: Color;
125
+ }
126
+ /** 時間軸の図の、`from` から `to` の目盛りの括弧と字。`shape` が `box` なら印の列を囲み、字を縁の札にする */
127
+ interface TimeSpanEvent {
128
+ type: "span";
129
+ from: number;
130
+ to: number;
131
+ text: string;
132
+ shape?: "box";
133
+ color?: Color;
134
+ }
135
+ /** 時間軸の図の目盛り。`unit` の名前の目盛りを `length` の長さ (`12s` など) で `count` 個並べ、最初の目盛りの番号を `from` にする */
136
+ interface TimeScale {
137
+ unit: string;
138
+ length: string;
139
+ count: number;
140
+ from?: number;
141
+ }
142
+ /** 時間軸の図の区切り。目盛り `length` 個ごとに `name` の区切りを置き、最初の区切りの番号を `from` にする */
143
+ interface TimePeriod {
144
+ name: string;
145
+ length: number;
146
+ from?: number;
147
+ }
148
+ /** 時間軸の図の印の列。目盛りごとに印を 1 つ置き、`empty` の目盛りは空きの印にする */
149
+ interface TimeRow {
150
+ id: string;
151
+ name: string;
152
+ color?: Color;
153
+ empty?: number[];
154
+ }
155
+ /** 時間軸の図の節目。`at` の目盛りの印の下に旗の丸と名札を置く */
156
+ interface TimePoint {
157
+ id: string;
158
+ at: number;
159
+ }
160
+ /** 時間軸の図の種類の欄 */
161
+ interface TimeSpec {
162
+ scale: TimeScale;
163
+ period?: TimePeriod;
164
+ rows: TimeRow[];
165
+ points?: TimePoint[];
166
+ /** 拡大の帯に列を作る目盛りの範囲 */
167
+ zoom?: {
168
+ from: number;
169
+ to: number;
170
+ };
171
+ }
172
+ /** 中身の帯の物差しの欄。`line` の割合 (`2/3` か `97%`) の所に線を引く */
173
+ interface StripMeter {
174
+ field: string;
175
+ line: string;
176
+ }
101
177
  /**
102
178
  * 枝分かれの図 (#3164) の commit を積む出来事。積んだ枝の札と、その枝を指す HEAD が新しい commit へ進む。
103
179
  * 当て直し (`copy`) は枝の札を動かさず、merge commit (`merge`) は取り込む枝の先端も親に持つ
@@ -122,15 +198,22 @@ interface StatePath {
122
198
  to: string;
123
199
  label?: string;
124
200
  }
201
+ /** 段の出典。読み上げの段の一覧に、名前を URL への link にして出す。URL の形は箱の飛び先と同じ (#3199) */
202
+ interface StepSource {
203
+ name: string;
204
+ url: string;
205
+ }
125
206
  interface Step {
126
207
  title: string;
127
208
  body: string;
128
209
  code?: string;
210
+ /** 書いた順の出典。書かない段は欄を持たない */
211
+ sources?: StepSource[];
129
212
  events: DiagramEvent[];
130
213
  }
131
214
  interface Diagram {
132
215
  version: number;
133
- kind: "sequence" | "architecture" | "state" | "git";
216
+ kind: "sequence" | "architecture" | "state" | "git" | "time";
134
217
  title: string;
135
218
  view?: ViewMode;
136
219
  regions?: Region[];
@@ -138,6 +221,7 @@ interface Diagram {
138
221
  strip?: {
139
222
  title: string;
140
223
  fields: string[];
224
+ meters?: StripMeter[];
141
225
  };
142
226
  steps: Step[];
143
227
  sequence?: {
@@ -149,6 +233,7 @@ interface Diagram {
149
233
  git?: {
150
234
  branches: GitBranch[];
151
235
  };
236
+ time?: TimeSpec;
152
237
  }
153
238
  interface FieldError {
154
239
  /** 誤った欄の場所 (JSON Pointer) */
@@ -278,6 +363,13 @@ interface SceneField {
278
363
  x: number;
279
364
  y: number;
280
365
  w: number;
366
+ /** 時間軸の図の物差しの欄 (#3165)。`line` の割合の所に線を引き、線の字 `text` を添える。棒は `x` から幅 `w` */
367
+ meter?: {
368
+ line: number;
369
+ text: string;
370
+ x: number;
371
+ w: number;
372
+ };
281
373
  }
282
374
  /** 状態遷移図の帯の最後の欄。段が辿り着く順に状態を点で並べ、着いた状態を塗る (#3171) */
283
375
  interface SceneTrail {
@@ -357,4 +449,4 @@ type Overlap = {
357
449
  */
358
450
  declare function describeOverlap(overlap: Overlap, lang?: NotationLang): string;
359
451
 
360
- export { type SceneTrail as A, type Box as B, type CheckOptions as C, type Diagram as D, type StatePath as E, type FieldError as F, type GitBranch as G, type Step as H, type InkPart as I, describeOverlap as J, resolvePalette as K, type Layout as L, validateDiagram as M, type NotationLang as N, type Overlap as O, PALETTES as P, type Rect as R, type SceneAction as S, type Theme as T, type ViewMode as V, type Carry as a, type Checked as b, type Color as c, type ColorKey as d, DEFAULT_PALETTE as e, type DiagramEvent as f, FONTS as g, type Family as h, type GitCommit as i, type LabelSide as j, type OverlapSpot as k, type Palette as l, type Point as m, READABLE_PX as n, type Region as o, type SceneBadge as p, type SceneBox as q, type SceneEdge as r, type SceneEnd as s, type SceneField as t, type SceneLabel as u, type SceneLifeline as v, type ScenePath as w, type SceneRegion as x, type SceneSide as y, type SceneStrip as z };
452
+ export { type TimeSpec as $, type SceneSide as A, type Box as B, type CheckOptions as C, type Diagram as D, type SceneStrip as E, type FieldError as F, type GitBranch as G, type SceneTrail as H, type InkPart as I, type StatePath as J, type Step as K, type Layout as L, type StepSource as M, type NotationLang as N, type Overlap as O, type Point as P, type StripMeter as Q, type Rect as R, type SceneBox as S, type Theme as T, type TimeMarkEvent as U, type ViewMode as V, type TimePeriod as W, type TimePoint as X, type TimeRow as Y, type TimeScale as Z, type TimeSpanEvent as _, type ColorKey as a, describeOverlap as a0, resolvePalette as a1, validateDiagram as a2, type Colors as b, type Carry as c, type Checked as d, type Color as e, type ColorName as f, DEFAULT_PALETTE as g, type DiagramEvent as h, FONTS as i, type Family as j, type GitCommit as k, type LabelSide as l, type OverlapSpot as m, PALETTES as n, type Palette as o, READABLE_PX as p, type Region as q, type SceneAction as r, type SceneBadge as s, type SceneEdge as t, type SceneEnd as u, type SceneField as v, type SceneLabel as w, type SceneLifeline as x, type ScenePath as y, type SceneRegion as z };
@@ -24,6 +24,15 @@ declare const DEFAULT_PALETTE = "paper";
24
24
  declare const PALETTES: Readonly<Record<string, Palette>>;
25
25
  /** 名前から色味を引く。指定が無いか、知らない名前 (外した墨と朱の `ink` を含む) なら紙と墨。 */
26
26
  declare function resolvePalette(id?: string): Palette;
27
+ /**
28
+ * 色味が持つ色の変数の名前 (#3198)。呼ぶ側が `colors` で値を渡せる鍵。
29
+ * 外へ出す型を `palettes.json` から作ると、束ねた型の file に JSON の中身が初期値付きで写り、型の検査を通らなくなるため、名前を並べて作る。
30
+ * 並びが `palettes.json` の明るい背景の名前と食い違うと、下の 2 つの `_` で始まる型が、余る名前か足りない名前を挙げて型の検査で落ちる
31
+ */
32
+ declare const COLOR_NAMES: readonly ["page", "bg", "surf", "sunk", "ink", "ink2", "mute", "hair", "line", "sh", "on-c", "c-blue", "t-blue", "c-amber", "t-amber", "c-green", "t-green", "c-violet", "t-violet", "c-rose", "t-rose", "c-slate", "t-slate", "coin", "coint", "coinin", "tint", "edge", "shA", "shB", "carry"];
33
+ type ColorName = (typeof COLOR_NAMES)[number];
34
+ /** 名前で選んだ色味に重ねる色の値。渡さない色は色味の値のまま残る (#3198) */
35
+ type Colors = Partial<Record<ColorName, string>>;
27
36
  /** 区画や箱を分ける色の役。灰 (slate) と硬貨 (coin) は分類の色として順に配らない。 */
28
37
  declare const COLOR_ORDER: readonly ["blue", "amber", "green", "violet", "rose"];
29
38
  type ColorKey = (typeof COLOR_ORDER)[number] | "slate" | "coin";
@@ -59,6 +68,8 @@ interface Box {
59
68
  color?: Color;
60
69
  icon?: string;
61
70
  region?: string;
71
+ /** 飛び先。描いた図ではこの箱がここへの link になる。`/` で始まる path か、http:// か https:// で始まる URL (#3199) */
72
+ link?: string;
62
73
  }
63
74
  type Carry = {
64
75
  kind: "envelope";
@@ -80,6 +91,8 @@ type DiagramEvent = {
80
91
  label?: string;
81
92
  carry: Carry;
82
93
  labelSide?: LabelSide;
94
+ at?: number;
95
+ into?: number;
83
96
  } | {
84
97
  type: "action";
85
98
  box: string;
@@ -88,6 +101,7 @@ type DiagramEvent = {
88
101
  type: "swap";
89
102
  box: string;
90
103
  text: string;
104
+ color?: Color;
91
105
  } | {
92
106
  type: "strip";
93
107
  field: string;
@@ -97,7 +111,69 @@ type DiagramEvent = {
97
111
  type: "branch";
98
112
  branch: string;
99
113
  from: string;
100
- };
114
+ } | {
115
+ type: "now";
116
+ to: number;
117
+ } | TimeMarkEvent | TimeSpanEvent;
118
+ /** 時間軸の図 (#3165) の、印の列 `row` の `from` から `to` の目盛りの印の色を変える出来事 */
119
+ interface TimeMarkEvent {
120
+ type: "mark";
121
+ row: string;
122
+ from: number;
123
+ to: number;
124
+ color: Color;
125
+ }
126
+ /** 時間軸の図の、`from` から `to` の目盛りの括弧と字。`shape` が `box` なら印の列を囲み、字を縁の札にする */
127
+ interface TimeSpanEvent {
128
+ type: "span";
129
+ from: number;
130
+ to: number;
131
+ text: string;
132
+ shape?: "box";
133
+ color?: Color;
134
+ }
135
+ /** 時間軸の図の目盛り。`unit` の名前の目盛りを `length` の長さ (`12s` など) で `count` 個並べ、最初の目盛りの番号を `from` にする */
136
+ interface TimeScale {
137
+ unit: string;
138
+ length: string;
139
+ count: number;
140
+ from?: number;
141
+ }
142
+ /** 時間軸の図の区切り。目盛り `length` 個ごとに `name` の区切りを置き、最初の区切りの番号を `from` にする */
143
+ interface TimePeriod {
144
+ name: string;
145
+ length: number;
146
+ from?: number;
147
+ }
148
+ /** 時間軸の図の印の列。目盛りごとに印を 1 つ置き、`empty` の目盛りは空きの印にする */
149
+ interface TimeRow {
150
+ id: string;
151
+ name: string;
152
+ color?: Color;
153
+ empty?: number[];
154
+ }
155
+ /** 時間軸の図の節目。`at` の目盛りの印の下に旗の丸と名札を置く */
156
+ interface TimePoint {
157
+ id: string;
158
+ at: number;
159
+ }
160
+ /** 時間軸の図の種類の欄 */
161
+ interface TimeSpec {
162
+ scale: TimeScale;
163
+ period?: TimePeriod;
164
+ rows: TimeRow[];
165
+ points?: TimePoint[];
166
+ /** 拡大の帯に列を作る目盛りの範囲 */
167
+ zoom?: {
168
+ from: number;
169
+ to: number;
170
+ };
171
+ }
172
+ /** 中身の帯の物差しの欄。`line` の割合 (`2/3` か `97%`) の所に線を引く */
173
+ interface StripMeter {
174
+ field: string;
175
+ line: string;
176
+ }
101
177
  /**
102
178
  * 枝分かれの図 (#3164) の commit を積む出来事。積んだ枝の札と、その枝を指す HEAD が新しい commit へ進む。
103
179
  * 当て直し (`copy`) は枝の札を動かさず、merge commit (`merge`) は取り込む枝の先端も親に持つ
@@ -122,15 +198,22 @@ interface StatePath {
122
198
  to: string;
123
199
  label?: string;
124
200
  }
201
+ /** 段の出典。読み上げの段の一覧に、名前を URL への link にして出す。URL の形は箱の飛び先と同じ (#3199) */
202
+ interface StepSource {
203
+ name: string;
204
+ url: string;
205
+ }
125
206
  interface Step {
126
207
  title: string;
127
208
  body: string;
128
209
  code?: string;
210
+ /** 書いた順の出典。書かない段は欄を持たない */
211
+ sources?: StepSource[];
129
212
  events: DiagramEvent[];
130
213
  }
131
214
  interface Diagram {
132
215
  version: number;
133
- kind: "sequence" | "architecture" | "state" | "git";
216
+ kind: "sequence" | "architecture" | "state" | "git" | "time";
134
217
  title: string;
135
218
  view?: ViewMode;
136
219
  regions?: Region[];
@@ -138,6 +221,7 @@ interface Diagram {
138
221
  strip?: {
139
222
  title: string;
140
223
  fields: string[];
224
+ meters?: StripMeter[];
141
225
  };
142
226
  steps: Step[];
143
227
  sequence?: {
@@ -149,6 +233,7 @@ interface Diagram {
149
233
  git?: {
150
234
  branches: GitBranch[];
151
235
  };
236
+ time?: TimeSpec;
152
237
  }
153
238
  interface FieldError {
154
239
  /** 誤った欄の場所 (JSON Pointer) */
@@ -278,6 +363,13 @@ interface SceneField {
278
363
  x: number;
279
364
  y: number;
280
365
  w: number;
366
+ /** 時間軸の図の物差しの欄 (#3165)。`line` の割合の所に線を引き、線の字 `text` を添える。棒は `x` から幅 `w` */
367
+ meter?: {
368
+ line: number;
369
+ text: string;
370
+ x: number;
371
+ w: number;
372
+ };
281
373
  }
282
374
  /** 状態遷移図の帯の最後の欄。段が辿り着く順に状態を点で並べ、着いた状態を塗る (#3171) */
283
375
  interface SceneTrail {
@@ -357,4 +449,4 @@ type Overlap = {
357
449
  */
358
450
  declare function describeOverlap(overlap: Overlap, lang?: NotationLang): string;
359
451
 
360
- export { type SceneTrail as A, type Box as B, type CheckOptions as C, type Diagram as D, type StatePath as E, type FieldError as F, type GitBranch as G, type Step as H, type InkPart as I, describeOverlap as J, resolvePalette as K, type Layout as L, validateDiagram as M, type NotationLang as N, type Overlap as O, PALETTES as P, type Rect as R, type SceneAction as S, type Theme as T, type ViewMode as V, type Carry as a, type Checked as b, type Color as c, type ColorKey as d, DEFAULT_PALETTE as e, type DiagramEvent as f, FONTS as g, type Family as h, type GitCommit as i, type LabelSide as j, type OverlapSpot as k, type Palette as l, type Point as m, READABLE_PX as n, type Region as o, type SceneBadge as p, type SceneBox as q, type SceneEdge as r, type SceneEnd as s, type SceneField as t, type SceneLabel as u, type SceneLifeline as v, type ScenePath as w, type SceneRegion as x, type SceneSide as y, type SceneStrip as z };
452
+ export { type TimeSpec as $, type SceneSide as A, type Box as B, type CheckOptions as C, type Diagram as D, type SceneStrip as E, type FieldError as F, type GitBranch as G, type SceneTrail as H, type InkPart as I, type StatePath as J, type Step as K, type Layout as L, type StepSource as M, type NotationLang as N, type Overlap as O, type Point as P, type StripMeter as Q, type Rect as R, type SceneBox as S, type Theme as T, type TimeMarkEvent as U, type ViewMode as V, type TimePeriod as W, type TimePoint as X, type TimeRow as Y, type TimeScale as Z, type TimeSpanEvent as _, type ColorKey as a, describeOverlap as a0, resolvePalette as a1, validateDiagram as a2, type Colors as b, type Carry as c, type Checked as d, type Color as e, type ColorName as f, DEFAULT_PALETTE as g, type DiagramEvent as h, FONTS as i, type Family as j, type GitCommit as k, type LabelSide as l, type OverlapSpot as m, PALETTES as n, type Palette as o, READABLE_PX as p, type Region as q, type SceneAction as r, type SceneBadge as s, type SceneEdge as t, type SceneEnd as u, type SceneField as v, type SceneLabel as w, type SceneLifeline as x, type ScenePath as y, type SceneRegion as z };