@cardenelabs/dragon 0.37.0 → 0.40.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/README.md +38 -1
- package/dist/cli.cjs +2403 -550
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +2408 -555
- package/dist/cli.js.map +1 -1
- package/dist/export.cjs +2252 -537
- package/dist/export.cjs.map +1 -1
- package/dist/export.d.cts +3 -1
- package/dist/export.d.ts +3 -1
- package/dist/export.js +2257 -542
- package/dist/export.js.map +1 -1
- package/dist/index.cjs +2387 -495
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -154
- package/dist/index.d.ts +11 -154
- package/dist/index.js +2387 -496
- package/dist/index.js.map +1 -1
- package/dist/ink-B_7OXxtb.d.cts +360 -0
- package/dist/ink-B_7OXxtb.d.ts +360 -0
- package/dist/player.global.js +2 -2
- package/package.json +1 -1
- package/src/cli.ts +9 -0
- package/src/export/index.ts +4 -1
- package/src/field-messages.ts +8 -0
- package/src/figure-text.ts +28 -0
- package/src/index.ts +3 -0
- package/src/layout/architecture.ts +123 -44
- package/src/layout/git.ts +728 -0
- package/src/layout/measure.ts +10 -0
- package/src/layout/scene.ts +300 -19
- package/src/layout/sequence.ts +29 -11
- package/src/layout/state.ts +82 -62
- package/src/look/values.ts +57 -4
- package/src/messages.ts +47 -4
- package/src/parser.ts +142 -7
- package/src/player.ts +44 -0
- package/src/printer.ts +16 -4
- package/src/render/git.ts +161 -0
- package/src/render/ink.ts +104 -0
- package/src/render/parts.ts +103 -36
- package/src/render/svg.ts +63 -15
- package/src/schema.ts +47 -13
- package/src/schemas/diagram.schema.json +75 -8
- package/src/schemas/validate-diagram.js +1 -1
- package/src/timeline.ts +18 -3
- package/src/words.ts +19 -3
- package/dist/schema-B2MTRv66.d.cts +0 -133
- package/dist/schema-B2MTRv66.d.ts +0 -133
package/src/layout/state.ts
CHANGED
|
@@ -13,22 +13,32 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import { FIGURE_TEXT } from "../figure-text";
|
|
15
15
|
import { LOOK, TYPE } from "../look/values";
|
|
16
|
-
import type {
|
|
16
|
+
import type { Diagram, LabelSide, StatePath } from "../schema";
|
|
17
17
|
import { type NotationLang, STATE_ENDS } from "../words";
|
|
18
|
-
import {
|
|
18
|
+
import { textBox, textWidth } from "./measure";
|
|
19
19
|
import {
|
|
20
20
|
badgeOnPath,
|
|
21
|
+
badgeRect,
|
|
21
22
|
boxColors,
|
|
22
23
|
boxWidth,
|
|
24
|
+
carrierHalf,
|
|
23
25
|
cornerBadge,
|
|
24
26
|
edgeColor,
|
|
25
27
|
edgesOf,
|
|
26
28
|
type EdgeEvent,
|
|
27
29
|
labelStyle,
|
|
28
30
|
type Layout,
|
|
31
|
+
lineBadges,
|
|
32
|
+
lineKey,
|
|
33
|
+
loopBadge,
|
|
34
|
+
loopLabelBase,
|
|
35
|
+
loopUnder,
|
|
36
|
+
replaceSameSpot,
|
|
29
37
|
layoutStrip,
|
|
38
|
+
markText,
|
|
30
39
|
type Point,
|
|
31
40
|
placeLabel,
|
|
41
|
+
placeSlot,
|
|
32
42
|
type Rect,
|
|
33
43
|
type SceneBox,
|
|
34
44
|
type SceneEdge,
|
|
@@ -36,7 +46,10 @@ import {
|
|
|
36
46
|
type SceneLabel,
|
|
37
47
|
type ScenePath,
|
|
38
48
|
type SceneSide,
|
|
49
|
+
seatCarriers,
|
|
39
50
|
shiftContent,
|
|
51
|
+
slotBoxWidth,
|
|
52
|
+
slotRooms,
|
|
40
53
|
stripNeed,
|
|
41
54
|
} from "./scene";
|
|
42
55
|
|
|
@@ -55,14 +68,6 @@ export function visitOrder(diagram: Diagram): string[] {
|
|
|
55
68
|
return order;
|
|
56
69
|
}
|
|
57
70
|
|
|
58
|
-
/** 運ぶ物の幅の半分 */
|
|
59
|
-
function carrierHalf(carry: Carry): number {
|
|
60
|
-
const C = LOOK.carrier;
|
|
61
|
-
if (carry.kind === "tag") return (textWidth(carry.text, hasWide(carry.text) ? TYPE.carrierJa : TYPE.carrier) + C.tagPadX * 2) / 2;
|
|
62
|
-
if (carry.kind === "coin") return C.coinR;
|
|
63
|
-
return C.envW / 2;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
71
|
/** 線の両端が同じ 2 つの線か */
|
|
67
72
|
const same = (a: { from: string; to: string }, b: { from: string; to: string }): boolean => a.from === b.from && a.to === b.to;
|
|
68
73
|
|
|
@@ -82,7 +87,12 @@ export function layoutState(diagram: Diagram, lang: NotationLang): Layout {
|
|
|
82
87
|
const source = diagram.boxes.find((b) => b.id === id);
|
|
83
88
|
return G.pad * 2 + B.icon + G.gap + Math.max(textWidth(source?.name ?? id, TYPE.boxName), textWidth(source?.sub ?? "", TYPE.boxSub));
|
|
84
89
|
};
|
|
85
|
-
|
|
90
|
+
// 運ぶ物を出し入れする状態は、絵柄の横に置き場を並べ、置き場の枠を右上の済んだ印から離せる幅にする (#3176)
|
|
91
|
+
const carriedIn = slotRooms(diagram);
|
|
92
|
+
const doneSide = Math.max(B.padX, T.done.inset + T.done.r + LOOK.slot.clear);
|
|
93
|
+
const widths = new Map(
|
|
94
|
+
diagram.boxes.map((b) => [b.id, ghosts.includes(b.id) ? ghostWidth(b.id) : Math.max(boxWidth(diagram, b.id, true), slotBoxWidth(carriedIn.get(b.id), b.icon !== undefined, doneSide))]),
|
|
95
|
+
);
|
|
86
96
|
const columnCount = Math.max(1, Math.min(T.columns, walked.length));
|
|
87
97
|
const rowCount = Math.max(1, Math.ceil(walked.length / T.columns));
|
|
88
98
|
// 奇数番目の段は右から左へ並べ、段の最後の状態の真下から次の段を始める
|
|
@@ -142,6 +152,7 @@ export function layoutState(diagram: Diagram, lang: NotationLang): Layout {
|
|
|
142
152
|
const s = slot.get(id) as { row: number; col: number };
|
|
143
153
|
return boxOf(id, center(s.col), rowY(s.row), false);
|
|
144
154
|
});
|
|
155
|
+
for (const box of boxes) placeSlot(box, carriedIn.get(box.id), doneSide);
|
|
145
156
|
const byId = new Map(boxes.map((b) => [b.id, b]));
|
|
146
157
|
const below = (box: SceneBox): boolean => boxes.some((other) => other !== box && Math.abs(other.cx - box.cx) < 0.5 && other.y > box.y);
|
|
147
158
|
|
|
@@ -229,21 +240,6 @@ export function layoutState(diagram: Diagram, lang: NotationLang): Layout {
|
|
|
229
240
|
const exitX = (box: SceneBox): number => (starts && box === first ? box.cx + T.side.entry : box.cx);
|
|
230
241
|
|
|
231
242
|
const finishOf = (id: string): SceneEnd | undefined => ends.find((e) => e.kind === "finish" && e.box === id);
|
|
232
|
-
/** 同じ状態へ戻る線。箱の下端の右から出て、下へ膨らむ弧を描いて左から箱へ戻る。運ぶ物が弧の上を走れるよう、点で区切る */
|
|
233
|
-
const loopOf = (box: SceneBox): Point[] => {
|
|
234
|
-
const { w, h, samples } = T.loop;
|
|
235
|
-
const bottom = box.y + box.h;
|
|
236
|
-
const p0: Point = [box.cx + w / 2, bottom];
|
|
237
|
-
const c1: Point = [box.cx + (w * 3) / 4, bottom + (h * 4) / 3];
|
|
238
|
-
const c2: Point = [box.cx - (w * 3) / 4, bottom + (h * 4) / 3];
|
|
239
|
-
const p3: Point = [box.cx - w / 2, bottom + inset];
|
|
240
|
-
return Array.from({ length: samples + 1 }, (_, k): Point => {
|
|
241
|
-
const t = k / samples;
|
|
242
|
-
const u = 1 - t;
|
|
243
|
-
const at = (i: 0 | 1): number => u * u * u * p0[i] + 3 * u * u * t * c1[i] + 3 * u * t * t * c2[i] + t * t * t * p3[i];
|
|
244
|
-
return [at(0), at(1)];
|
|
245
|
-
});
|
|
246
|
-
};
|
|
247
243
|
const route = (from: string, to: string): Point[] => {
|
|
248
244
|
if (from === "start") {
|
|
249
245
|
const start = ends.find((e) => e.kind === "start");
|
|
@@ -260,7 +256,7 @@ export function layoutState(diagram: Diagram, lang: NotationLang): Layout {
|
|
|
260
256
|
}
|
|
261
257
|
const b = byId.get(to);
|
|
262
258
|
if (!b) return [];
|
|
263
|
-
if (from === to) return
|
|
259
|
+
if (from === to) return loopUnder(a);
|
|
264
260
|
if (b.ghost && !a.ghost) {
|
|
265
261
|
const sx = exitX(a);
|
|
266
262
|
const ex = entryOf(from, b);
|
|
@@ -272,20 +268,24 @@ export function layoutState(diagram: Diagram, lang: NotationLang): Layout {
|
|
|
272
268
|
};
|
|
273
269
|
|
|
274
270
|
/**
|
|
275
|
-
*
|
|
276
|
-
*
|
|
271
|
+
* 終わりへ着いた札が留まる所。終わりの印と字に掛からないよう、下に置いた印なら左、右に置いた印なら下に留まる。
|
|
272
|
+
* 状態へ着いた札は、その状態の置き場に留まる (同じ状態へ戻る輪も、回った後に置き場へ戻る)
|
|
277
273
|
*/
|
|
278
274
|
const settleOf = (edge: EdgeEvent): Point | undefined => {
|
|
279
|
-
const target = byId.get(edge.to);
|
|
280
|
-
if (target) return [target.cx, target.cy + B.iconY];
|
|
281
275
|
const end = edge.to === "finish" ? finishOf(edge.from) : undefined;
|
|
282
276
|
if (!end) return undefined;
|
|
283
277
|
const from = byId.get(edge.from);
|
|
284
|
-
return from && Math.abs(end.x - from.cx) < 0.5 ? [end.x - end.r - gap - carrierHalf(edge.carry), end.y] : [end.x, end.y + end.r + gap + LOOK.carrier.tagH / 2];
|
|
278
|
+
return from && Math.abs(end.x - from.cx) < 0.5 ? [end.x - end.r - gap - carrierHalf(edge.carry)[0], end.y] : [end.x, end.y + end.r + gap + LOOK.carrier.tagH / 2];
|
|
279
|
+
};
|
|
280
|
+
/** 始まりの印から出る札は、印の右の字に掛からないよう、印の左で走り出しを待つ。段の番号を載せた線の上では待たない */
|
|
281
|
+
const waitOf = (edge: EdgeEvent): Point | undefined => {
|
|
282
|
+
const start = edge.from === "start" ? ends.find((e) => e.kind === "start") : undefined;
|
|
283
|
+
return start ? [start.x - start.r - LOOK.slot.mark - carrierHalf(edge.carry)[0], start.y] : undefined;
|
|
285
284
|
};
|
|
286
285
|
|
|
287
286
|
const sceneEdges: SceneEdge[] = steps.map(({ step, event, edge }) => {
|
|
288
287
|
const settle = settleOf(edge);
|
|
288
|
+
const wait = edge.carry.kind === "none" ? undefined : waitOf(edge);
|
|
289
289
|
return {
|
|
290
290
|
step,
|
|
291
291
|
event,
|
|
@@ -295,57 +295,81 @@ export function layoutState(diagram: Diagram, lang: NotationLang): Layout {
|
|
|
295
295
|
color: colorOf(edge, colors),
|
|
296
296
|
carry: edge.carry,
|
|
297
297
|
...(settle ? { settle } : {}),
|
|
298
|
+
...(wait ? { wait } : {}),
|
|
298
299
|
};
|
|
299
300
|
});
|
|
300
|
-
//
|
|
301
|
+
// 状態を出入りする運ぶ物は、着いた状態の置き場に留まり、出る状態の置き場で走り出しを待つ (#3176)
|
|
302
|
+
seatCarriers(sceneEdges, byId, carriedIn);
|
|
303
|
+
// 同じ 2 つの状態を行きと帰りで結ぶまっすぐな線は、少しずらして重ならないようにする。
|
|
304
|
+
// ずらした線の名前は、ずらした側 (もう一方の線の反対側) に置き、どちらの線の名前かを取り違えないようにする (#3175)
|
|
305
|
+
const outward = new Map<SceneEdge, LabelSide>();
|
|
301
306
|
for (const e of sceneEdges) {
|
|
302
307
|
if (e.points.length !== 2 || !sceneEdges.some((o) => o.from === e.to && o.to === e.from && o.points.length === 2)) continue;
|
|
303
308
|
const [p, q] = e.points as [Point, Point];
|
|
304
309
|
const flat = Math.abs(q[1] - p[1]) < Math.abs(q[0] - p[0]);
|
|
305
310
|
const d = (e.from < e.to ? 1 : -1) * LOOK.edge.parallel;
|
|
306
311
|
e.points = e.points.map(([x, y]) => (flat ? [x, y + d] : [x + d, y]));
|
|
312
|
+
outward.set(e, flat ? (d > 0 ? "below" : "above") : d > 0 ? "right" : "left");
|
|
307
313
|
}
|
|
308
314
|
|
|
309
315
|
const paths: ScenePath[] = notTaken.map((p) => ({ from: p.from, to: p.to, points: route(p.from, p.to) }));
|
|
310
316
|
|
|
311
|
-
//
|
|
317
|
+
// 線の名前。同じ状態へ戻る輪は輪の下に置き、終わりへ移る線は印の字と反対の左に置く。
|
|
318
|
+
// 段が終わった名前も薄く残るので、段を問わず先に置いた全ての名前と、印に添えた字を避ける (#3175)
|
|
319
|
+
// 段の番号も済んだ後まで残るので、全ての番号を避ける。同じ状態へ戻る弧の番号は、弧に重ねず弧の右に置く
|
|
320
|
+
const badgeAt = (edge: SceneEdge, taken: Point[], lines: Point[][]): Point => (edge.from === edge.to ? loopBadge(edge.points) : badgeOnPath(edge.points, taken, lines));
|
|
312
321
|
const labels: SceneLabel[] = [];
|
|
313
|
-
const
|
|
322
|
+
const marks: Rect[] = ends.flatMap((e) => (e.text === "" ? [] : [textBox(e.text, ...markText(e), TYPE.regionNote)]));
|
|
323
|
+
const badgeRects = [...lineBadges(sceneEdges, diagram.steps.length, badgeAt).values()].map((b) => badgeRect(b.point));
|
|
324
|
+
const soft: Rect[] = [...(side ? [{ x: side.x, y: side.y, w: T.side.pad + titleW, h: side.h }] : []), ...marks];
|
|
325
|
+
// 名前は段が終わると札を外した薄い字で残り、通らない道の名前は初めから札を持たないので、自分の線より他の線と道に横切らせない
|
|
326
|
+
const others = (own: Point[]): Point[][] => [...sceneEdges.map((o) => o.points), ...paths.map((o) => o.points)].filter((line) => line !== own);
|
|
314
327
|
for (const e of sceneEdges) {
|
|
315
328
|
const source = diagram.steps[e.step]?.events[e.event];
|
|
316
329
|
if (source?.type !== "edge" || source.label === undefined) continue;
|
|
317
|
-
const
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
330
|
+
const loop = e.from === e.to;
|
|
331
|
+
// 同じ線に同じ名前を置いた段が前に在れば、その名前の所に重ねて名前を 1 つにまとめる。前の段の薄い名前はこの段が始まると消す (#3184)
|
|
332
|
+
const key = lineKey(e);
|
|
333
|
+
const named = labels.filter((l) => l.text === source.label && sceneEdges.some((o) => o.step === l.step && o.event === l.event && lineKey(o) === key));
|
|
334
|
+
const same = named[named.length - 1];
|
|
335
|
+
if (same) {
|
|
336
|
+
same.until = e.step;
|
|
337
|
+
labels.push({ x: same.x, y: same.y, w: same.w, h: same.h, step: e.step, event: e.event, text: same.text, family: same.family, color: e.color });
|
|
322
338
|
continue;
|
|
323
339
|
}
|
|
324
|
-
const
|
|
340
|
+
const w = textWidth(source.label, labelStyle(source.label)) + LOOK.label.padX * 2;
|
|
341
|
+
// 輪の名前は輪の下から探し、空いていなければ横へずらす
|
|
342
|
+
const below = loop ? { side: "below" as const, base: loopLabelBase(e.points, w) } : {};
|
|
343
|
+
// 指示の無い線の名前は、空いていなければ反対の側も探す。ずらした線は自分の側だけを探す
|
|
344
|
+
const side2 = source.labelSide ?? (e.to === "finish" ? "left" : outward.get(e));
|
|
325
345
|
labels.push(
|
|
326
346
|
placeLabel(
|
|
327
|
-
{ step: e.step, event: e.event, text: source.label, points: e.points, color: e.color, ...(side2 ? { side: side2 } : {}) },
|
|
328
|
-
{ hard: boxes, soft: [...soft, ...labels
|
|
347
|
+
{ step: e.step, event: e.event, text: source.label, points: e.points, color: e.color, ...(side2 ? { side: side2 } : loop ? {} : { flip: true }), ...below },
|
|
348
|
+
{ hard: boxes, soft: [...soft, ...labels], touch: badgeRects, lines: others(e.points) },
|
|
329
349
|
),
|
|
330
350
|
);
|
|
331
351
|
}
|
|
332
|
-
//
|
|
352
|
+
// 脇道へ入る線の名前は、横に通る所の下の、状態から上へ出る所の右に置く。他の名前に重なる時は、横に通る所に沿って右か左へずらす (#3175)
|
|
353
|
+
const placed: Rect[] = [];
|
|
333
354
|
notTaken.forEach((p, i) => {
|
|
334
355
|
const path = paths[i] as ScenePath;
|
|
335
356
|
if (p.label === undefined || path.points.length === 0) return;
|
|
336
357
|
const style = labelStyle(p.label);
|
|
337
358
|
const into = byId.get(p.to)?.ghost === true && byId.get(p.from)?.ghost !== true;
|
|
338
|
-
const
|
|
339
|
-
|
|
340
|
-
|
|
359
|
+
const x0 = (path.points[0] as Point)[0];
|
|
360
|
+
const lead = into ? { side: "below" as const, base: { x: x0 + LOOK.label.soft, y: lane + LOOK.label.soft }, slide: Math.max(...path.points.map(([x]) => Math.abs(x - x0))) } : {};
|
|
361
|
+
const rect = placeLabel({ step: -1, event: i, text: p.label, points: path.points, color: "slate", ...lead }, { hard: boxes, soft: [...soft, ...labels, ...placed], touch: badgeRects, lines: others(path.points) });
|
|
362
|
+
placed.push(rect);
|
|
341
363
|
path.label = { x: rect.x, y: rect.y, w: rect.w, h: rect.h, text: p.label, family: style.family };
|
|
342
364
|
});
|
|
343
365
|
|
|
344
366
|
const layout: Layout = { kind: "state", width: 0, height: 0, regions: [], boxes, lifelines: [], edges: sceneEdges, labels, actions: [], badges: [], paths, ends, ...(side ? { side } : {}) };
|
|
345
|
-
//
|
|
367
|
+
// 名前が左か上へ出たら、全体を右か下へ寄せる
|
|
346
368
|
const lefts = [...boxes.map((b) => b.x), ...labels.map((l) => l.x), ...paths.flatMap((p) => (p.label ? [p.label.x] : []))];
|
|
369
|
+
const tops = [...labels.map((l) => l.y), ...paths.flatMap((p) => (p.label ? [p.label.y] : []))];
|
|
347
370
|
const shift = Math.max(0, margin - Math.min(...lefts));
|
|
348
|
-
|
|
371
|
+
const drop = tops.length > 0 ? Math.max(0, margin - Math.min(...tops)) : 0;
|
|
372
|
+
if (shift > 0 || drop > 0) shiftContent(layout, shift, drop);
|
|
349
373
|
const endRight = (e: SceneEnd): number => e.x + (e.text === "" ? e.r : T.text + textWidth(e.text, TYPE.regionNote));
|
|
350
374
|
const rights = [
|
|
351
375
|
...boxes.map((b) => b.x + b.w),
|
|
@@ -364,19 +388,15 @@ export function layoutState(diagram: Diagram, lang: NotationLang): Layout {
|
|
|
364
388
|
layout.width = width;
|
|
365
389
|
layout.height = (strip ? strip.y + strip.h : bottom) + margin;
|
|
366
390
|
if (strip) layout.strip = strip;
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
}
|
|
377
|
-
const [x, y] = badgeOnPath(edge.points);
|
|
378
|
-
return { step: s, x, y, color: edge.color };
|
|
379
|
-
});
|
|
391
|
+
const placedBadges = lineBadges(sceneEdges, diagram.steps.length, badgeAt);
|
|
392
|
+
// 同じ所に置いた番号は、後の段が始まると入れ替える (#3184)
|
|
393
|
+
layout.badges = replaceSameSpot(
|
|
394
|
+
diagram.steps.map((step, s) => {
|
|
395
|
+
const line = placedBadges.get(s);
|
|
396
|
+
if (!line) return cornerBadge(step.events, s, layout);
|
|
397
|
+
return { step: s, x: line.point[0], y: line.point[1], color: line.edge.color };
|
|
398
|
+
}),
|
|
399
|
+
);
|
|
380
400
|
return layout;
|
|
381
401
|
}
|
|
382
402
|
|
package/src/look/values.ts
CHANGED
|
@@ -76,6 +76,10 @@ export const TYPE = {
|
|
|
76
76
|
stepBody: text(13.5, 500),
|
|
77
77
|
stepNo: text(13, 700, "mono"),
|
|
78
78
|
button: text(14, 700),
|
|
79
|
+
/** 枝分かれの図 (#3164) の、丸の中の commit の名札と、丸の外に添える hash と一言 */
|
|
80
|
+
gitId: text(11, 700),
|
|
81
|
+
gitHash: text(10.5, 600, "mono"),
|
|
82
|
+
gitNote: text(10.5, 650),
|
|
79
83
|
} as const;
|
|
80
84
|
|
|
81
85
|
/** 置き場所と部品の大きさ。単位は図の座標 (字が原寸の時の px)。 */
|
|
@@ -87,7 +91,11 @@ export const LOOK = {
|
|
|
87
91
|
box: { h: 72, minW: 92, padX: 12, radius: 12, icon: 24, iconRadius: 7, iconY: -16, iconScale: 0.74, nameY: 12, subY: 27 },
|
|
88
92
|
region: { pad: 18, gap: 10, radius: 14, inset: 14, icon: 24, iconRadius: 7, iconScale: 0.68, nameY: 58, line: 16, minH: 108 },
|
|
89
93
|
architecture: { columns: 4, columnGap: 56, maxColumnGap: 160, rowGap: 44, labelRoom: 16 },
|
|
90
|
-
|
|
94
|
+
/**
|
|
95
|
+
* 時系列図。線の名前の札は、構成図と状態遷移図より線に寄せる (`labelOffset` は線から札の真ん中まで)。
|
|
96
|
+
* 札と線の離れが図の他の空きと同じ 6 になり、行を詰めても札がどの線の名前かが分かる (#3177)。
|
|
97
|
+
*/
|
|
98
|
+
sequence: { columnGap: 40, labelRoom: 16, labelOffset: 16, firstRow: 10, rowGap: 6, stepGap: 6, minPitch: 32, tail: 10, selfW: 34, selfH: 18 },
|
|
91
99
|
/**
|
|
92
100
|
* 状態遷移図 (#3163)。状態は `columns` つずつ並べて次の段へ折り返し、段の間 (`rowGap`) の真ん中を、段をまたぐ線が通る。
|
|
93
101
|
* `start` と `end` は始まりと終わりの印の半径と、印の中の丸の半径。`drop` は最初の状態の上端から始まりの印の中心まで、
|
|
@@ -117,17 +125,62 @@ export const LOOK = {
|
|
|
117
125
|
done: { r: 6.5, inset: 13 },
|
|
118
126
|
pastLabel: 0.85,
|
|
119
127
|
},
|
|
128
|
+
/**
|
|
129
|
+
* 枝分かれの図 (#3164)。見本帳の試作 (`scenes/git.js`) の寸法を写す。
|
|
130
|
+
* commit は列ごとに `pitch` ずつ右へ並べ、一番上でない帯の commit は列の半分だけ右へずらす。`x0` は最初の列の真ん中の x の下限、
|
|
131
|
+
* `textGap` は隣の列の hash と一言の間に空ける最小の隙間。`r` は丸の半径、`orphan` はどの札からも辿れなくなった commit の点線の丸の半径。
|
|
132
|
+
* `topLine` と `line` は帯の上端から丸を並べる線まで (一番上の帯と、それより下の帯)、`topBelow` と `below` は線から帯の下端まで。
|
|
133
|
+
* `bare` は線の名前を下に置かない帯の、線から帯の下端まで。
|
|
134
|
+
* hash と一言は一番上の帯では丸の上に、ほかの帯では丸の下に置き、`above` と `under` は丸の真ん中から丸に近い行の基準線まで、`lineStep` は行の間。
|
|
135
|
+
* 札は丸の上に段を重ねて置き、`tagTop` と `tag` は丸の真ん中から 1 段目の札の真ん中まで (一番上の帯と、ほかの帯)、`row` は札の段の間。
|
|
136
|
+
* 札の段が 2 段より多い commit がある帯は、多い段の分だけ線を下げる。
|
|
137
|
+
* `turn` は枝へ分かれる線と枝から入る線が曲がり終えて横へ進むまでの長さ、`samples` は曲がりを区切る点の数、`boxGap` は commit の並びと箱の間。
|
|
138
|
+
* `labelUnder` はほかの帯で、丸の真ん中から線の名前の札の上端まで。`colors` は帯の色を上から配る順
|
|
139
|
+
*/
|
|
140
|
+
git: {
|
|
141
|
+
x0: 120,
|
|
142
|
+
pitch: 90,
|
|
143
|
+
textGap: 12,
|
|
144
|
+
r: 12,
|
|
145
|
+
orphan: 13.5,
|
|
146
|
+
topLine: 120,
|
|
147
|
+
line: 90,
|
|
148
|
+
topBelow: 30,
|
|
149
|
+
below: 82,
|
|
150
|
+
bare: 62,
|
|
151
|
+
above: 18,
|
|
152
|
+
under: 27,
|
|
153
|
+
lineStep: 13,
|
|
154
|
+
tagTop: 58,
|
|
155
|
+
tag: 30,
|
|
156
|
+
row: 22,
|
|
157
|
+
turn: 60,
|
|
158
|
+
samples: 12,
|
|
159
|
+
boxGap: 24,
|
|
160
|
+
labelUnder: 50,
|
|
161
|
+
colors: ["blue", "violet", "green", "amber", "rose"],
|
|
162
|
+
},
|
|
120
163
|
/** `bend` は線の曲がりを丸める半径 (#3171) */
|
|
121
164
|
edge: { inset: 3, arrow: 6, arrowHalf: 3.5, parallel: 5, ghostDash: 5, flowDash: 9, bend: 12 },
|
|
122
|
-
|
|
165
|
+
/** `touch` は線の名前と、同じ時刻に見えている段の番号の丸の間に空ける最小の隙間 (#3175) */
|
|
166
|
+
label: { h: 20, padX: 9, radius: 10, offset: 22, side: 14, search: 4, searchMax: 400, soft: 6, touch: 2 },
|
|
123
167
|
action: { h: 22, padX: 10, radius: 11 },
|
|
124
168
|
badge: { r: 9.5, ring: 9, inset: 4, along: 14, short: 44 },
|
|
125
169
|
carrier: { envW: 24, envH: 17, coinR: 6.5, coinIn: 3.8, tagH: 18, tagPadX: 8, samples: 16 },
|
|
170
|
+
/**
|
|
171
|
+
* 運ぶ物の置き場 (#3176)。運ぶ物を出し入れする箱は、絵柄の右に点線の枠を持ち、運ぶ物は着いた後と走り出す前にそこで待つ。
|
|
172
|
+
* `gap` は絵柄と枠の間、`pad` は枠と運ぶ物の間、`spread` は枠の中に横に並べた運ぶ物の間、`h` と `radius` は枠の高さと角の丸み。
|
|
173
|
+
* `clear` は状態遷移図の右上の済んだ印と枠の間に空ける最小の隙間。`lifeline` は時系列図で生存線と運ぶ物の間、
|
|
174
|
+
* `mark` は状態遷移図の始まりの印と、その左で走り出しを待つ運ぶ物の間
|
|
175
|
+
*/
|
|
176
|
+
slot: { gap: 6, pad: 3, spread: 4, h: 24, radius: 7, clear: 2, lifeline: 5, mark: 4 },
|
|
177
|
+
/** 編集画面が重なる字を囲む点線の四角 (#3178)。`pad` は字の四角の外へ広げる幅、`dash` と `gap` は点線の線と隙間の長さ */
|
|
178
|
+
mark: { pad: 3, radius: 5, dash: 4, gap: 3 },
|
|
126
179
|
/**
|
|
127
180
|
* `trail` は状態遷移図の帯の最後の、通った状態の点 (#3171)。`r` は点の半径、`step` は点の中心どうしの間、`now` は変わった値の欄の名前の横の点の半径と、名前からの離れ
|
|
128
181
|
*/
|
|
129
182
|
strip: { h: 72, line: 44, pad: 12, icon: 24, titleX: 44, fieldGap: 22, sepInset: 14, tagGap: 6, tagH: 15, tagPadX: 7, nameY: 22, valueY: 43, trail: { r: 5.4, step: 16 }, now: { r: 3, gap: 7 } },
|
|
130
|
-
stroke: { hair: 1, edge: 1.7, edgeOn: 2.25, arrow: 1.5, flow: 1.3, halo: 7, on: 1.75, glyph: 2, lifeline: 1.2, envelope: 1.5, badgeRing: 1.5, path: 1.6, end: 1.6, done: 1.2, trail: 1.2 },
|
|
183
|
+
stroke: { git: 2.25, gitOrphan: 1.5, mark: 1.6, slot: 1.2, hair: 1, edge: 1.7, edgeOn: 2.25, arrow: 1.5, flow: 1.3, halo: 7, on: 1.75, glyph: 2, lifeline: 1.2, envelope: 1.5, badgeRing: 1.5, path: 1.6, end: 1.6, done: 1.2, trail: 1.2 },
|
|
131
184
|
shadow: { near: 0.8, far: 4, nearY: 1, farY: 3 },
|
|
132
185
|
mini: { w: 168, pad: 8, title: 14, inset: 12, radius: 10 },
|
|
133
186
|
/**
|
|
@@ -141,7 +194,7 @@ export const LOOK = {
|
|
|
141
194
|
*/
|
|
142
195
|
follow: { aspect: 0.75, minH: 320, fitMinH: 160, ease: 0.6, narrow: 440, badgeRoom: 8, headRoom: 10, head: { pad: 8, h: 40, nameY: 17, subY: 31 } },
|
|
143
196
|
/** 色を混ぜる割合 (%) */
|
|
144
|
-
mix: { icon: 14, regionIcon: 16, regionIconEdge: 34, cap: 12, capEdge: 42, badgePast: 14, badgePastEdge: 70, mini: 62, miniBand: 16, miniBandEdge: 36, view: 6, side: 4, sideEdge: 36, ghostEdge: 60, path: 55, past: 72 },
|
|
197
|
+
mix: { slot: 45, icon: 14, regionIcon: 16, regionIconEdge: 34, cap: 12, capEdge: 42, badgePast: 14, badgePastEdge: 70, mini: 62, miniBand: 16, miniBandEdge: 36, view: 6, side: 4, sideEdge: 36, ghostEdge: 60, path: 55, past: 72 },
|
|
145
198
|
/** 字の並びの基準線を、置きたい高さの真ん中からどれだけ下げるか */
|
|
146
199
|
baseline: { label: 3.8, badge: 3.5, carrier: 3.7, stripTitle: 4.5, tag: 3.6, action: 3.8, mark: 4 },
|
|
147
200
|
/** 浮いて出る物が下から上がる長さと、弾んで出る物の始まりの大きさ */
|
package/src/messages.ts
CHANGED
|
@@ -65,6 +65,23 @@ export interface Messages {
|
|
|
65
65
|
outOfFinish: string;
|
|
66
66
|
/** 状態遷移図の最初の step より前の線に、属性を書いた */
|
|
67
67
|
pathNoAttrs: string;
|
|
68
|
+
/** 枝分かれの図だけの行 (`branch` と `commit`) を、別の種類の図に書いた (#3164) */
|
|
69
|
+
gitOnly: (word: string) => string;
|
|
70
|
+
gitNoGroup: string;
|
|
71
|
+
noBranches: string;
|
|
72
|
+
branchShape: string;
|
|
73
|
+
commitShape: string;
|
|
74
|
+
fromShape: string;
|
|
75
|
+
undeclaredBranch: (id: string) => string;
|
|
76
|
+
/** 札を動かす線の送る側が、枝の名札でも HEAD でもない */
|
|
77
|
+
undeclaredRef: (id: string) => string;
|
|
78
|
+
noCommit: (id: string) => string;
|
|
79
|
+
/** 取り込む枝が、まだどの commit も指していない */
|
|
80
|
+
emptyBranch: (id: string) => string;
|
|
81
|
+
mergeSelf: (id: string) => string;
|
|
82
|
+
/** 枝分かれの図で、今いる場所の札の名前 (`name`) を名札にした */
|
|
83
|
+
headReserved: (name: string) => string;
|
|
84
|
+
badHash: string;
|
|
68
85
|
}
|
|
69
86
|
|
|
70
87
|
const list = (words: readonly string[]): string => words.join(" / ");
|
|
@@ -102,8 +119,8 @@ const ja = (): Messages => {
|
|
|
102
119
|
sayTwice: "1 つの段に say は 1 つまで。長い本文は say の下に字下げして続ける",
|
|
103
120
|
codeTwice: "1 つの段に code は 1 行まで",
|
|
104
121
|
emptyCode: "code の後ろに命令を書く",
|
|
105
|
-
declarationInStep: "group と box と strip は最初の step より前に書く",
|
|
106
|
-
stepLineBeforeStep: "線と say と code と act と note と set
|
|
122
|
+
declarationInStep: "group と box と strip と branch は最初の step より前に書く",
|
|
123
|
+
stepLineBeforeStep: "線と say と code と act と note と set と commit と枝を切る行は step の下に書く",
|
|
107
124
|
nestedGroup: "group の中に group は書けない。先に end で閉じる",
|
|
108
125
|
strayEnd: "end の前に、閉じる group が無い",
|
|
109
126
|
endTakesNothing: "end の後ろには何も書かない",
|
|
@@ -136,6 +153,19 @@ const ja = (): Messages => {
|
|
|
136
153
|
intoStart: "start へ入る線は書けない。start は始まりの印で、線は start から出る",
|
|
137
154
|
outOfFinish: "finish から出る線は書けない。finish は終わりの印で、線は finish へ入る",
|
|
138
155
|
pathNoAttrs: "最初の step より前の線は今回は通らない道なので、属性 (carry と tag と side) を書けない",
|
|
156
|
+
gitOnly: (word) => `${word} の行は git (枝分かれの図) でだけ書ける`,
|
|
157
|
+
gitNoGroup: "git (枝分かれの図) には group を書けない。枝は branch の行で宣言する",
|
|
158
|
+
noBranches: "branch の行で枝を 1 つ以上宣言する",
|
|
159
|
+
branchShape: "branch は branch <名札> [note: <添え書き>] の形で書く",
|
|
160
|
+
commitShape: "commit は commit <名札> on <枝> [hash: <hash>, note: <一言>] の形で書く。当て直しは copy <commit> を、取り込みは merge <枝> を on <枝> の後ろに書く",
|
|
161
|
+
fromShape: "枝を切る行は <枝> from <commit> の形で書く",
|
|
162
|
+
undeclaredBranch: (id) => `${id} という枝は宣言していない`,
|
|
163
|
+
undeclaredRef: (id) => `${id} という枝は宣言していない。札を動かす線は枝の名札か HEAD から引く`,
|
|
164
|
+
noCommit: (id) => `${id} という commit はまだ積んでいない`,
|
|
165
|
+
emptyBranch: (id) => `${id} の枝はまだどの commit も指していないので取り込めない`,
|
|
166
|
+
mergeSelf: (id) => `${id} は積む枝なので、取り込む枝にできない`,
|
|
167
|
+
headReserved: (name) => `${name} は枝分かれの図で今いる場所の札の名前で、名札に使えない`,
|
|
168
|
+
badHash: "hash は 0 から 9 と a から f の字で 4 から 40 字にする",
|
|
139
169
|
};
|
|
140
170
|
};
|
|
141
171
|
|
|
@@ -172,8 +202,8 @@ const en = (): Messages => {
|
|
|
172
202
|
sayTwice: "A step takes one say. Continue a long body on indented lines below it",
|
|
173
203
|
codeTwice: "A step takes at most one code line",
|
|
174
204
|
emptyCode: "Write the command after code",
|
|
175
|
-
declarationInStep: "Write group, box and
|
|
176
|
-
stepLineBeforeStep: "Write lines, say, code, act, note and
|
|
205
|
+
declarationInStep: "Write group, box, strip and branch before the first step",
|
|
206
|
+
stepLineBeforeStep: "Write lines, say, code, act, note, set, commit and branch cuts under a step",
|
|
177
207
|
nestedGroup: "A group cannot hold another group. Close it with end first",
|
|
178
208
|
strayEnd: "There is no group for this end to close",
|
|
179
209
|
endTakesNothing: "Write nothing after end",
|
|
@@ -206,6 +236,19 @@ const en = (): Messages => {
|
|
|
206
236
|
intoStart: "A line cannot go into start. start is the start mark, and lines leave it",
|
|
207
237
|
outOfFinish: "A line cannot leave finish. finish is the end mark, and lines go into it",
|
|
208
238
|
pathNoAttrs: "A line before the first step is a path not taken, so it takes no attributes (carry, tag, side)",
|
|
239
|
+
gitOnly: (word) => `${word} lines can be written only in git diagrams`,
|
|
240
|
+
gitNoGroup: "A git diagram takes no group. Declare branches with branch lines",
|
|
241
|
+
noBranches: "Declare at least one branch with a branch line",
|
|
242
|
+
branchShape: "Write a branch as branch <id> [note: <note>]",
|
|
243
|
+
commitShape: "Write a commit as commit <id> on <branch> [hash: <hash>, note: <note>]. For a replayed commit add copy <commit>, and for a merge commit add merge <branch>, after on <branch>",
|
|
244
|
+
fromShape: "Write a branch cut as <branch> from <commit>",
|
|
245
|
+
undeclaredBranch: (id) => `No branch named ${id} is declared`,
|
|
246
|
+
undeclaredRef: (id) => `No branch named ${id} is declared. A line that moves a ref starts from a branch id or HEAD`,
|
|
247
|
+
noCommit: (id) => `No commit named ${id} has been made yet`,
|
|
248
|
+
emptyBranch: (id) => `Branch ${id} does not point at any commit yet, so it cannot be merged`,
|
|
249
|
+
mergeSelf: (id) => `${id} is the branch being committed to, so it cannot be the branch merged in`,
|
|
250
|
+
headReserved: (name) => `${name} names where you are in a git diagram and cannot be an id`,
|
|
251
|
+
badHash: "Write a hash as 4 to 40 characters of 0-9 and a-f",
|
|
209
252
|
};
|
|
210
253
|
};
|
|
211
254
|
|