@cardenelabs/dragon 0.36.4 → 0.37.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 +33 -2
- package/dist/cli.cjs +1126 -220
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +1118 -212
- package/dist/cli.js.map +1 -1
- package/dist/export.cjs +1043 -165
- package/dist/export.cjs.map +1 -1
- package/dist/export.d.cts +1 -1
- package/dist/export.d.ts +1 -1
- package/dist/export.js +1038 -160
- package/dist/export.js.map +1 -1
- package/dist/index.cjs +1133 -218
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +77 -3
- package/dist/index.d.ts +77 -3
- package/dist/index.js +1132 -219
- package/dist/index.js.map +1 -1
- package/dist/player.global.js +2 -2
- package/dist/{schema-9VLameDG.d.cts → schema-B2MTRv66.d.cts} +11 -2
- package/dist/{schema-9VLameDG.d.ts → schema-B2MTRv66.d.ts} +11 -2
- package/package.json +1 -1
- package/src/field-messages.ts +4 -0
- package/src/figure-text.ts +21 -0
- package/src/index.ts +8 -1
- package/src/layout/architecture.ts +1 -1
- package/src/layout/scene.ts +78 -8
- package/src/layout/sequence.ts +1 -1
- package/src/layout/state.ts +387 -0
- package/src/look/values.ts +40 -5
- package/src/messages.ts +14 -0
- package/src/parser.ts +45 -14
- package/src/printer.ts +6 -1
- package/src/render/icons.ts +4 -0
- package/src/render/parts.ts +170 -23
- package/src/render/svg.ts +78 -8
- package/src/schema.ts +22 -6
- package/src/schemas/diagram.schema.json +30 -4
- package/src/schemas/validate-diagram.js +1 -1
- package/src/timeline.ts +47 -0
- package/src/words.ts +8 -1
package/dist/cli.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var fs = require('fs');
|
|
5
|
-
var path = require('path');
|
|
5
|
+
var path$1 = require('path');
|
|
6
6
|
var util = require('util');
|
|
7
7
|
var module$1 = require('module');
|
|
8
8
|
var promises = require('fs/promises');
|
|
@@ -281,13 +281,46 @@ var LOOK = {
|
|
|
281
281
|
region: { pad: 18, gap: 10, radius: 14, inset: 14, icon: 24, iconRadius: 7, iconScale: 0.68, nameY: 58, line: 16, minH: 108 },
|
|
282
282
|
architecture: { columns: 4, columnGap: 56, maxColumnGap: 160, rowGap: 44, labelRoom: 16 },
|
|
283
283
|
sequence: { columnGap: 40, labelRoom: 16, firstRow: 22, rowGap: 14, stepGap: 8, minPitch: 40, tail: 18, selfW: 34, selfH: 18 },
|
|
284
|
-
|
|
284
|
+
/**
|
|
285
|
+
* 状態遷移図 (#3163)。状態は `columns` つずつ並べて次の段へ折り返し、段の間 (`rowGap`) の真ん中を、段をまたぐ線が通る。
|
|
286
|
+
* `start` と `end` は始まりと終わりの印の半径と、印の中の丸の半径。`drop` は最初の状態の上端から始まりの印の中心まで、
|
|
287
|
+
* `below` は状態の下端から終わりの印の中心まで、`beside` は状態の右端から右に置く終わりの印の中心まで、`text` は印の中心から字の左端まで。
|
|
288
|
+
* `loop` は同じ状態へ戻る輪の幅と深さ。`side` は脇道の囲みの内側の余白、1 段目の上端との間、脇道へ入る線が横に通る所の囲みの下端からの離れ、
|
|
289
|
+
* 点線の線が箱へ入る所を箱の端から離す幅。
|
|
290
|
+
* `ghost` は脇道の点線の札で、絵柄を左に、名前と下の字を右に並べる (#3171)。`h` は札の高さ、`pad` は左右の余白、`gap` は絵柄と字の間、
|
|
291
|
+
* `nameY` と `subY` は札の真ん中から名前と下の字の基準線まで。
|
|
292
|
+
* `done` は出た状態の右上の済んだ印の半径と、箱の右上の角からの離れ。
|
|
293
|
+
* `loop` の `samples` は同じ状態へ戻る弧を区切る点の数、`badgeAt` は弧の段の番号を弧の上端から深さのどこに置くかの割合。
|
|
294
|
+
* `pastLabel` は段が終わった後に薄く残す線の名前の濃さ (#3171)
|
|
295
|
+
*/
|
|
296
|
+
state: {
|
|
297
|
+
columns: 4,
|
|
298
|
+
columnGap: 64,
|
|
299
|
+
rowGap: 108,
|
|
300
|
+
labelRoom: 16,
|
|
301
|
+
start: 7,
|
|
302
|
+
end: { r: 9, inner: 5 },
|
|
303
|
+
drop: 56,
|
|
304
|
+
below: 64,
|
|
305
|
+
beside: 38,
|
|
306
|
+
text: 16,
|
|
307
|
+
loop: { w: 24, h: 34, samples: 12, badgeAt: 0.6 },
|
|
308
|
+
side: { pad: 16, gap: 76, lane: 30, entry: 28 },
|
|
309
|
+
ghost: { h: 52, pad: 12, gap: 10, nameY: -2, subY: 14 },
|
|
310
|
+
done: { r: 6.5, inset: 13 },
|
|
311
|
+
pastLabel: 0.85
|
|
312
|
+
},
|
|
313
|
+
/** `bend` は線の曲がりを丸める半径 (#3171) */
|
|
314
|
+
edge: { inset: 3, arrow: 6, arrowHalf: 3.5, parallel: 5, ghostDash: 5, flowDash: 9, bend: 12 },
|
|
285
315
|
label: { h: 20, padX: 9, radius: 10, offset: 22, side: 14, search: 4, searchMax: 400, soft: 6 },
|
|
286
316
|
action: { h: 22, padX: 10, radius: 11 },
|
|
287
317
|
badge: { r: 9.5, ring: 9, inset: 4, along: 14, short: 44 },
|
|
288
318
|
carrier: { envW: 24, envH: 17, coinR: 6.5, coinIn: 3.8, tagH: 18, tagPadX: 8, samples: 16 },
|
|
289
|
-
|
|
290
|
-
|
|
319
|
+
/**
|
|
320
|
+
* `trail` は状態遷移図の帯の最後の、通った状態の点 (#3171)。`r` は点の半径、`step` は点の中心どうしの間、`now` は変わった値の欄の名前の横の点の半径と、名前からの離れ
|
|
321
|
+
*/
|
|
322
|
+
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 } },
|
|
323
|
+
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 },
|
|
291
324
|
shadow: { near: 0.8, far: 4, nearY: 1, farY: 3 },
|
|
292
325
|
mini: { w: 168, pad: 8, title: 14, inset: 12, radius: 10 },
|
|
293
326
|
/**
|
|
@@ -301,9 +334,9 @@ var LOOK = {
|
|
|
301
334
|
*/
|
|
302
335
|
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 } },
|
|
303
336
|
/** 色を混ぜる割合 (%) */
|
|
304
|
-
mix: { icon: 14, regionIcon: 16, regionIconEdge: 34, cap: 12, capEdge: 42, badgePast: 14, badgePastEdge: 70, mini: 62, miniBand: 16, miniBandEdge: 36, view: 6 },
|
|
337
|
+
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 },
|
|
305
338
|
/** 字の並びの基準線を、置きたい高さの真ん中からどれだけ下げるか */
|
|
306
|
-
baseline: { label: 3.8, badge: 3.5, carrier: 3.7, stripTitle: 4.5, tag: 3.6, action: 3.8 },
|
|
339
|
+
baseline: { label: 3.8, badge: 3.5, carrier: 3.7, stripTitle: 4.5, tag: 3.6, action: 3.8, mark: 4 },
|
|
307
340
|
/** 浮いて出る物が下から上がる長さと、弾んで出る物の始まりの大きさ */
|
|
308
341
|
rise: 5,
|
|
309
342
|
popFrom: 0.4};
|
|
@@ -337,7 +370,9 @@ var MOTION = {
|
|
|
337
370
|
popFade: 0.4,
|
|
338
371
|
untilFade: 0.2,
|
|
339
372
|
/** 段の止め絵を撮る時刻を、段の終わりからどれだけ前にするか */
|
|
340
|
-
still: 0.45
|
|
373
|
+
still: 0.45,
|
|
374
|
+
/** 状態遷移図で、札が状態を出てから済んだ印が出るまで */
|
|
375
|
+
done: 0.3
|
|
341
376
|
};
|
|
342
377
|
var READABLE_PX = 10.5;
|
|
343
378
|
var EASE = {
|
|
@@ -355,7 +390,13 @@ var FIGURE_TEXT = {
|
|
|
355
390
|
pause: "\u6B62\u3081\u308B",
|
|
356
391
|
play: "\u52D5\u304B\u3059",
|
|
357
392
|
next: "\u6B21\u306E\u6BB5",
|
|
358
|
-
steps: (title) => `${title} \u306E\u6BB5
|
|
393
|
+
steps: (title) => `${title} \u306E\u6BB5`,
|
|
394
|
+
side: "\u8107\u9053",
|
|
395
|
+
sideNote: "\u4ECA\u56DE\u306F\u901A\u3089\u306A\u3044",
|
|
396
|
+
sideFrom: (count) => `${count} \u3064\u306E\u72B6\u614B\u304B\u3089\u5165\u308C\u308B`,
|
|
397
|
+
trail: "\u901A\u3063\u305F\u72B6\u614B",
|
|
398
|
+
start: "\u59CB\u307E\u308A",
|
|
399
|
+
end: "\u7D42\u308F\u308A"
|
|
359
400
|
},
|
|
360
401
|
en: {
|
|
361
402
|
cannotDraw: (detail2) => `Cannot draw the diagram: ${detail2}`,
|
|
@@ -364,7 +405,13 @@ var FIGURE_TEXT = {
|
|
|
364
405
|
pause: "Pause",
|
|
365
406
|
play: "Play",
|
|
366
407
|
next: "Next step",
|
|
367
|
-
steps: (title) => `Steps of ${title}
|
|
408
|
+
steps: (title) => `Steps of ${title}`,
|
|
409
|
+
side: "Side path",
|
|
410
|
+
sideNote: "Not taken this time",
|
|
411
|
+
sideFrom: (count) => `Enterable from ${count} ${count === 1 ? "state" : "states"}`,
|
|
412
|
+
trail: "States passed",
|
|
413
|
+
start: "Start",
|
|
414
|
+
end: "End"
|
|
368
415
|
}
|
|
369
416
|
};
|
|
370
417
|
|
|
@@ -459,12 +506,12 @@ function placeLabel(request, obstacles) {
|
|
|
459
506
|
const segment = longest(request.points);
|
|
460
507
|
const mx = (segment.a[0] + segment.b[0]) / 2;
|
|
461
508
|
const my = (segment.a[1] + segment.b[1]) / 2;
|
|
462
|
-
const
|
|
509
|
+
const side2 = request.side ?? (segment.vertical ? "right" : "above");
|
|
463
510
|
const { offset, side: sideGap } = LOOK.label;
|
|
464
|
-
const base =
|
|
465
|
-
const away =
|
|
511
|
+
const base = side2 === "above" ? { x: mx - w / 2, y: my - offset - h / 2, w, h } : side2 === "below" ? { x: mx - w / 2, y: my + offset - h / 2, w, h } : side2 === "left" ? { x: mx - sideGap - w, y: my - h / 2, w, h } : { x: mx + sideGap, y: my - h / 2, w, h };
|
|
512
|
+
const away = side2 === "above" ? [0, -1] : side2 === "below" ? [0, 1] : side2 === "left" ? [-1, 0] : [1, 0];
|
|
466
513
|
const slideAxis = [Math.abs(away[1]), Math.abs(away[0])];
|
|
467
|
-
const slideMax =
|
|
514
|
+
const slideMax = side2 === "above" || side2 === "below" ? w : h * 4;
|
|
468
515
|
const clear = (rect) => obstacles.hard.every((box) => gapBetween(rect, box) >= LOOK.gap) && obstacles.soft.every((other) => gapBetween(rect, other) >= LOOK.label.soft);
|
|
469
516
|
const { search, searchMax } = LOOK.label;
|
|
470
517
|
for (let d = 0; d <= searchMax; d += search) {
|
|
@@ -490,29 +537,36 @@ function fieldWidth(diagram, name) {
|
|
|
490
537
|
const both = value + (tag > 0 ? (value > 0 ? LOOK.strip.tagGap : 0) + tag : 0);
|
|
491
538
|
return Math.max(textWidth(name, TYPE.fieldName), both);
|
|
492
539
|
}
|
|
493
|
-
|
|
540
|
+
var trailWidth = (trail) => Math.max(textWidth(trail.title, TYPE.fieldName), trail.states.length * LOOK.strip.trail.step);
|
|
541
|
+
function stripNeed(diagram, trail) {
|
|
494
542
|
if (!diagram.strip) return 0;
|
|
495
543
|
const { titleX, fieldGap, pad: pad2 } = LOOK.strip;
|
|
496
544
|
const start = titleX + textWidth(diagram.strip.title, TYPE.stripTitle) + fieldGap;
|
|
497
|
-
|
|
545
|
+
const widths = [...diagram.strip.fields.map((name) => fieldWidth(diagram, name)), ...trail ? [trailWidth(trail)] : []];
|
|
546
|
+
return start + widths.reduce((sum, w) => sum + w + fieldGap, 0) - fieldGap + pad2;
|
|
498
547
|
}
|
|
499
|
-
function layoutStrip(diagram, x, y, width) {
|
|
548
|
+
function layoutStrip(diagram, x, y, width, trail) {
|
|
500
549
|
if (!diagram.strip) return void 0;
|
|
501
550
|
const { titleX, fieldGap, pad: pad2, line, h } = LOOK.strip;
|
|
502
551
|
const start = titleX + textWidth(diagram.strip.title, TYPE.stripTitle) + fieldGap;
|
|
503
552
|
const fields = [];
|
|
504
553
|
let cx = start;
|
|
505
554
|
let row = 0;
|
|
506
|
-
|
|
507
|
-
const w = fieldWidth(diagram, name);
|
|
555
|
+
const place = (w) => {
|
|
508
556
|
if (cx > start && cx + w > width - pad2) {
|
|
509
557
|
cx = start;
|
|
510
558
|
row++;
|
|
511
559
|
}
|
|
512
|
-
|
|
560
|
+
const at2 = { x: x + cx, y: y + row * line };
|
|
513
561
|
cx += w + fieldGap;
|
|
562
|
+
return at2;
|
|
563
|
+
};
|
|
564
|
+
for (const name of diagram.strip.fields) {
|
|
565
|
+
const w = fieldWidth(diagram, name);
|
|
566
|
+
fields.push({ name, ...place(w), w });
|
|
514
567
|
}
|
|
515
|
-
|
|
568
|
+
const laidTrail = trail ? { ...trail, ...place(trailWidth(trail)), w: trailWidth(trail) } : void 0;
|
|
569
|
+
return { x, y, w: width, h: h + row * line, title: diagram.strip.title, fields, ...laidTrail ? { trail: laidTrail } : {} };
|
|
516
570
|
}
|
|
517
571
|
function shiftContent(layout, dx, dy) {
|
|
518
572
|
const move = (rect) => {
|
|
@@ -538,6 +592,15 @@ function shiftContent(layout, dx, dy) {
|
|
|
538
592
|
if (edge2.settle) edge2.settle = [edge2.settle[0] + dx, edge2.settle[1] + dy];
|
|
539
593
|
}
|
|
540
594
|
for (const label2 of layout.labels) move(label2);
|
|
595
|
+
for (const path2 of layout.paths) {
|
|
596
|
+
path2.points = path2.points.map(([px, py]) => [px + dx, py + dy]);
|
|
597
|
+
if (path2.label) move(path2.label);
|
|
598
|
+
}
|
|
599
|
+
for (const end of layout.ends) {
|
|
600
|
+
end.x += dx;
|
|
601
|
+
end.y += dy;
|
|
602
|
+
}
|
|
603
|
+
if (layout.side) move(layout.side);
|
|
541
604
|
for (const action2 of layout.actions) move(action2);
|
|
542
605
|
for (const badge2 of layout.badges) {
|
|
543
606
|
badge2.x += dx;
|
|
@@ -549,6 +612,10 @@ function shiftContent(layout, dx, dy) {
|
|
|
549
612
|
field.x += dx;
|
|
550
613
|
field.y += dy;
|
|
551
614
|
}
|
|
615
|
+
if (layout.strip.trail) {
|
|
616
|
+
layout.strip.trail.x += dx;
|
|
617
|
+
layout.strip.trail.y += dy;
|
|
618
|
+
}
|
|
552
619
|
}
|
|
553
620
|
}
|
|
554
621
|
function cornerBadge(events, step, layout) {
|
|
@@ -580,7 +647,7 @@ function groupsOf(diagram) {
|
|
|
580
647
|
if (loose.length > 0) groups.push({ members: loose });
|
|
581
648
|
return groups;
|
|
582
649
|
}
|
|
583
|
-
var vertical = (
|
|
650
|
+
var vertical = (side2) => side2 === "left" || side2 === "right";
|
|
584
651
|
function placeBoxes(diagram, groups) {
|
|
585
652
|
const columns = LOOK.architecture.columns;
|
|
586
653
|
const edges = edgesOf(diagram).map((e) => e.edge);
|
|
@@ -827,7 +894,7 @@ function arrange(diagram, groups, slots, rooms) {
|
|
|
827
894
|
)
|
|
828
895
|
);
|
|
829
896
|
}
|
|
830
|
-
const layout = { kind: "architecture", width: 0, height: 0, regions, boxes, lifelines: [], edges: sceneEdges, labels, actions: [], badges: [] };
|
|
897
|
+
const layout = { kind: "architecture", width: 0, height: 0, regions, boxes, lifelines: [], edges: sceneEdges, labels, actions: [], badges: [], paths: [], ends: [] };
|
|
831
898
|
const shift = labels.length > 0 ? Math.max(0, margin + LOOK.label.soft - Math.min(...labels.map((l) => l.x))) : 0;
|
|
832
899
|
if (shift > 0) shiftContent(layout, shift, 0);
|
|
833
900
|
const contentRight = Math.max(...boxes.map((b) => b.x + b.w + R.pad), ...labels.map((l) => l.x + l.w + LOOK.label.soft), ...sceneEdges.flatMap((e) => e.points.map((p) => p[0] + R.pad)));
|
|
@@ -934,11 +1001,11 @@ function layoutSequence(diagram) {
|
|
|
934
1001
|
let above;
|
|
935
1002
|
let under;
|
|
936
1003
|
if (event.type === "edge") {
|
|
937
|
-
const
|
|
1004
|
+
const side2 = event.labelSide ?? "above";
|
|
938
1005
|
const self = event.from === event.to;
|
|
939
1006
|
const named = event.label !== void 0;
|
|
940
|
-
above = named &&
|
|
941
|
-
under = self ? Q.selfH + gap : named &&
|
|
1007
|
+
above = named && side2 === "above" ? L.offset + L.h / 2 : gap;
|
|
1008
|
+
under = self ? Q.selfH + gap : named && side2 === "below" ? L.offset + L.h / 2 : gap;
|
|
942
1009
|
} else {
|
|
943
1010
|
above = LOOK.action.h / 2;
|
|
944
1011
|
under = LOOK.action.h / 2;
|
|
@@ -985,7 +1052,7 @@ function layoutSequence(diagram) {
|
|
|
985
1052
|
const soft = [...labels.filter((l) => l.step === request.step), ...actions];
|
|
986
1053
|
labels.push(placeLabel(request, { hard: boxes, soft }));
|
|
987
1054
|
}
|
|
988
|
-
const layout = { kind: "sequence", width: 0, height: 0, regions: [], boxes, lifelines, edges, labels, actions, badges: [] };
|
|
1055
|
+
const layout = { kind: "sequence", width: 0, height: 0, regions: [], boxes, lifelines, edges, labels, actions, badges: [], paths: [], ends: [] };
|
|
989
1056
|
const lefts = [...boxes.map((b) => b.x), ...labels.map((l) => l.x), ...actions.map((a) => a.x)];
|
|
990
1057
|
const shift = Math.max(0, margin - Math.min(...lefts));
|
|
991
1058
|
if (shift > 0) shiftContent(layout, shift, 0);
|
|
@@ -1012,6 +1079,326 @@ function badges(diagram, layout) {
|
|
|
1012
1079
|
});
|
|
1013
1080
|
}
|
|
1014
1081
|
|
|
1082
|
+
// src/words.ts
|
|
1083
|
+
var keys = (table) => Object.keys(table);
|
|
1084
|
+
var KINDS = keys({ sequence: true, architecture: true, state: true });
|
|
1085
|
+
var STATE_ENDS = ["start", "finish"];
|
|
1086
|
+
var HEADS = ["group", "end", "box", "strip", "step", "say", "code", "act", "note", "set"];
|
|
1087
|
+
var AS = "as";
|
|
1088
|
+
var ATTRS = {
|
|
1089
|
+
diagram: ["view"],
|
|
1090
|
+
group: ["note", "color", "icon"],
|
|
1091
|
+
box: ["note", "color", "icon"],
|
|
1092
|
+
edge: ["carry", "tag", "side"],
|
|
1093
|
+
set: ["tag"]
|
|
1094
|
+
};
|
|
1095
|
+
var CARRIES = keys({ coin: true, none: true });
|
|
1096
|
+
var VIEWS = keys({ fixed: true, follow: true });
|
|
1097
|
+
var SIDES = keys({ above: true, below: true, left: true, right: true });
|
|
1098
|
+
var OLD_HEADS = {
|
|
1099
|
+
\u6642\u7CFB\u5217\u56F3: "sequence",
|
|
1100
|
+
\u69CB\u6210\u56F3: "architecture",
|
|
1101
|
+
\u533A\u753B: "group",
|
|
1102
|
+
\u898B\u305B\u65B9: "view",
|
|
1103
|
+
region: "group",
|
|
1104
|
+
view: "view"
|
|
1105
|
+
};
|
|
1106
|
+
|
|
1107
|
+
// src/layout/state.ts
|
|
1108
|
+
var isEnd = (id) => STATE_ENDS.includes(id);
|
|
1109
|
+
function visitOrder(diagram) {
|
|
1110
|
+
const order = [];
|
|
1111
|
+
const add = (id) => {
|
|
1112
|
+
if (!isEnd(id) && !order.includes(id)) order.push(id);
|
|
1113
|
+
};
|
|
1114
|
+
for (const { edge: edge2 } of edgesOf(diagram)) {
|
|
1115
|
+
add(edge2.from);
|
|
1116
|
+
add(edge2.to);
|
|
1117
|
+
}
|
|
1118
|
+
return order;
|
|
1119
|
+
}
|
|
1120
|
+
function carrierHalf(carry) {
|
|
1121
|
+
const C = LOOK.carrier;
|
|
1122
|
+
if (carry.kind === "tag") return (textWidth(carry.text, hasWide(carry.text) ? TYPE.carrierJa : TYPE.carrier) + C.tagPadX * 2) / 2;
|
|
1123
|
+
if (carry.kind === "coin") return C.coinR;
|
|
1124
|
+
return C.envW / 2;
|
|
1125
|
+
}
|
|
1126
|
+
var same = (a, b) => a.from === b.from && a.to === b.to;
|
|
1127
|
+
function layoutState(diagram, lang) {
|
|
1128
|
+
const { box: B, state: T, margin, gap } = LOOK;
|
|
1129
|
+
const inset = LOOK.edge.inset;
|
|
1130
|
+
const words = FIGURE_TEXT[lang];
|
|
1131
|
+
const colors = boxColors(diagram);
|
|
1132
|
+
const steps = edgesOf(diagram);
|
|
1133
|
+
const walked = visitOrder(diagram);
|
|
1134
|
+
const ghosts = diagram.boxes.map((b) => b.id).filter((id) => !walked.includes(id));
|
|
1135
|
+
const notTaken = (diagram.state?.paths ?? []).filter((p) => !steps.some(({ edge: edge2 }) => same(edge2, p)));
|
|
1136
|
+
const lines = [...steps.map(({ edge: edge2 }) => edge2), ...notTaken];
|
|
1137
|
+
const G = T.ghost;
|
|
1138
|
+
const ghostWidth = (id) => {
|
|
1139
|
+
const source = diagram.boxes.find((b) => b.id === id);
|
|
1140
|
+
return G.pad * 2 + B.icon + G.gap + Math.max(textWidth(source?.name ?? id, TYPE.boxName), textWidth(source?.sub ?? "", TYPE.boxSub));
|
|
1141
|
+
};
|
|
1142
|
+
const widths = new Map(diagram.boxes.map((b) => [b.id, ghosts.includes(b.id) ? ghostWidth(b.id) : boxWidth(diagram, b.id, true)]));
|
|
1143
|
+
const columnCount = Math.max(1, Math.min(T.columns, walked.length));
|
|
1144
|
+
const rowCount = Math.max(1, Math.ceil(walked.length / T.columns));
|
|
1145
|
+
const slot = new Map(
|
|
1146
|
+
walked.map((id, k) => {
|
|
1147
|
+
const row = Math.floor(k / T.columns);
|
|
1148
|
+
const at2 = k % T.columns;
|
|
1149
|
+
return [id, { row, col: row % 2 === 0 ? at2 : columnCount - 1 - at2 }];
|
|
1150
|
+
})
|
|
1151
|
+
);
|
|
1152
|
+
const colW = Array.from({ length: columnCount }, (_, c) => Math.max(B.minW, ...walked.filter((id) => slot.get(id)?.col === c).map((id) => widths.get(id) ?? B.minW)));
|
|
1153
|
+
const between = Array.from({ length: Math.max(0, columnCount - 1) }, () => T.columnGap);
|
|
1154
|
+
for (const line of lines) {
|
|
1155
|
+
const a = slot.get(line.from);
|
|
1156
|
+
const b = slot.get(line.to);
|
|
1157
|
+
if (!a || !b || line.label === void 0 || a.row !== b.row || Math.abs(a.col - b.col) !== 1) continue;
|
|
1158
|
+
const i = Math.min(a.col, b.col);
|
|
1159
|
+
between[i] = Math.max(between[i] ?? 0, textWidth(line.label, labelStyle(line.label)) + LOOK.label.padX * 2 + T.labelRoom * 2);
|
|
1160
|
+
}
|
|
1161
|
+
const colLeft = [];
|
|
1162
|
+
for (let c = 0; c < columnCount; c++) colLeft.push(c === 0 ? margin : colLeft[c - 1] + colW[c - 1] + between[c - 1]);
|
|
1163
|
+
const center = (c) => colLeft[c] + colW[c] / 2;
|
|
1164
|
+
const isGhost = (id) => ghosts.includes(id);
|
|
1165
|
+
const enteringFrom = new Set(notTaken.filter((p) => isGhost(p.to) && !isGhost(p.from) && !isEnd(p.from)).map((p) => p.from));
|
|
1166
|
+
const notes = [words.sideNote, ...enteringFrom.size > 0 ? [words.sideFrom(enteringFrom.size)] : []];
|
|
1167
|
+
const titleW = Math.max(textWidth(words.side, TYPE.regionName), ...notes.map((note) => textWidth(note, TYPE.regionNote)));
|
|
1168
|
+
const sideH = T.side.pad * 2 + Math.max(G.h, TYPE.regionName.size + LOOK.region.line * notes.length + T.side.pad / 4);
|
|
1169
|
+
const starts = lines.some((line) => line.from === "start");
|
|
1170
|
+
const top0 = margin + (ghosts.length > 0 ? sideH + T.side.gap : starts ? T.start + T.drop : 0);
|
|
1171
|
+
const rowY = (row) => top0 + row * (B.h + T.rowGap);
|
|
1172
|
+
const boxOf = (id, cx, y, ghost) => {
|
|
1173
|
+
const source = diagram.boxes.find((b) => b.id === id);
|
|
1174
|
+
const w = widths.get(id) ?? B.minW;
|
|
1175
|
+
const h = ghost ? G.h : B.h;
|
|
1176
|
+
return {
|
|
1177
|
+
id,
|
|
1178
|
+
name: source?.name ?? id,
|
|
1179
|
+
...source?.sub !== void 0 ? { sub: source.sub } : {},
|
|
1180
|
+
...source?.icon !== void 0 ? { icon: source.icon } : {},
|
|
1181
|
+
color: colors.get(id) ?? "slate",
|
|
1182
|
+
x: cx - w / 2,
|
|
1183
|
+
y,
|
|
1184
|
+
w,
|
|
1185
|
+
h,
|
|
1186
|
+
cx,
|
|
1187
|
+
cy: y + h / 2,
|
|
1188
|
+
...ghost ? { ghost: true } : {}
|
|
1189
|
+
};
|
|
1190
|
+
};
|
|
1191
|
+
const boxes = walked.map((id) => {
|
|
1192
|
+
const s = slot.get(id);
|
|
1193
|
+
return boxOf(id, center(s.col), rowY(s.row), false);
|
|
1194
|
+
});
|
|
1195
|
+
const byId = new Map(boxes.map((b) => [b.id, b]));
|
|
1196
|
+
const below = (box) => boxes.some((other) => other !== box && Math.abs(other.cx - box.cx) < 0.5 && other.y > box.y);
|
|
1197
|
+
const ends = [];
|
|
1198
|
+
const first = boxes[0];
|
|
1199
|
+
const contentRight = Math.max(...boxes.map((b) => b.x + b.w));
|
|
1200
|
+
let side2;
|
|
1201
|
+
const lane = margin + sideH + T.side.lane;
|
|
1202
|
+
if (ghosts.length > 0) {
|
|
1203
|
+
const sourcesOf = (id) => notTaken.filter((p) => p.to === id).flatMap((p) => byId.get(p.from) ?? []);
|
|
1204
|
+
const all = ghosts.flatMap(sourcesOf);
|
|
1205
|
+
const x = Math.max(margin, Math.min(...all.length > 0 ? all.map((b) => b.x) : [margin + T.side.pad]) - T.side.pad);
|
|
1206
|
+
let cursor = x + T.side.pad + titleW + gap * 2;
|
|
1207
|
+
const wanted = ghosts.map((id) => {
|
|
1208
|
+
const from = sourcesOf(id);
|
|
1209
|
+
return { id, cx: from.length > 0 ? from.reduce((sum, b) => sum + b.cx, 0) / from.length : cursor };
|
|
1210
|
+
});
|
|
1211
|
+
wanted.sort((a, b) => a.cx - b.cx);
|
|
1212
|
+
let right = x;
|
|
1213
|
+
for (const { id, cx } of wanted) {
|
|
1214
|
+
const w = widths.get(id) ?? B.minW;
|
|
1215
|
+
const left = Math.max(cx - w / 2, cursor);
|
|
1216
|
+
const ghost = boxOf(id, left + w / 2, margin + (sideH - G.h) / 2, true);
|
|
1217
|
+
boxes.push(ghost);
|
|
1218
|
+
byId.set(id, ghost);
|
|
1219
|
+
const finishes = notTaken.some((p) => p.from === id && p.to === "finish");
|
|
1220
|
+
if (finishes) ends.push({ kind: "finish", x: ghost.x + ghost.w + T.beside, y: ghost.cy, r: T.end.r, ghost: true, text: "", box: id });
|
|
1221
|
+
right = finishes ? ghost.x + ghost.w + T.beside + T.end.r : ghost.x + ghost.w;
|
|
1222
|
+
cursor = right + gap * 2;
|
|
1223
|
+
}
|
|
1224
|
+
const rightmost = Math.max(right + T.side.pad, contentRight);
|
|
1225
|
+
side2 = { x, y: margin, w: rightmost - x, h: sideH, title: words.side, notes };
|
|
1226
|
+
}
|
|
1227
|
+
if (first && starts) {
|
|
1228
|
+
const reach = first.cx + T.start + T.text + textWidth(words.start, TYPE.regionNote) + gap;
|
|
1229
|
+
const y = side2 && reach < side2.x ? side2.y + T.side.pad + T.start : first.y - T.drop;
|
|
1230
|
+
ends.unshift({ kind: "start", x: first.cx, y, r: T.start, ghost: false, text: words.start });
|
|
1231
|
+
}
|
|
1232
|
+
for (const box of boxes.filter((b) => !b.ghost && lines.some((line) => line.from === b.id && line.to === "finish"))) {
|
|
1233
|
+
ends.push(
|
|
1234
|
+
below(box) ? { kind: "finish", x: box.x + box.w + T.beside, y: box.cy, r: T.end.r, ghost: false, text: words.end, box: box.id } : { kind: "finish", x: box.cx, y: box.y + box.h + T.below, r: T.end.r, ghost: false, text: words.end, box: box.id }
|
|
1235
|
+
);
|
|
1236
|
+
}
|
|
1237
|
+
const between2 = (a, b) => {
|
|
1238
|
+
const sa = slot.get(a.id);
|
|
1239
|
+
const sb = slot.get(b.id);
|
|
1240
|
+
if (!sa || !sb) return [[a.cx, a.y + a.h], [b.cx, b.y - inset]];
|
|
1241
|
+
if (sa.row === sb.row && Math.abs(sa.col - sb.col) === 1) {
|
|
1242
|
+
return b.cx > a.cx ? [[a.x + a.w, a.cy], [b.x - inset, b.cy]] : [[a.x, a.cy], [b.x + b.w + inset, b.cy]];
|
|
1243
|
+
}
|
|
1244
|
+
if (sa.row === sb.row) {
|
|
1245
|
+
const y2 = a.y + a.h + T.rowGap / 4;
|
|
1246
|
+
return [[a.cx, a.y + a.h], [a.cx, y2], [b.cx, y2], [b.cx, b.y + b.h + inset]];
|
|
1247
|
+
}
|
|
1248
|
+
if (sb.row > sa.row) {
|
|
1249
|
+
if (Math.abs(a.cx - b.cx) < 0.5) return [[a.cx, a.y + a.h], [b.cx, b.y - inset]];
|
|
1250
|
+
const y2 = a.y + a.h + T.rowGap / 2;
|
|
1251
|
+
return [[a.cx, a.y + a.h], [a.cx, y2], [b.cx, y2], [b.cx, b.y - inset]];
|
|
1252
|
+
}
|
|
1253
|
+
if (Math.abs(a.cx - b.cx) < 0.5) return [[a.cx, a.y], [b.cx, b.y + b.h + inset]];
|
|
1254
|
+
const y = b.y + b.h + T.rowGap / 2;
|
|
1255
|
+
return [[a.cx, a.y], [a.cx, y], [b.cx, y], [b.cx, b.y + b.h + inset]];
|
|
1256
|
+
};
|
|
1257
|
+
const entryOf = (from, to) => {
|
|
1258
|
+
const sources = notTaken.filter((p) => p.to === to.id).flatMap((p) => byId.get(p.from) ?? []).sort((a, b) => a.cx - b.cx);
|
|
1259
|
+
const k = sources.findIndex((b) => b.id === from);
|
|
1260
|
+
if (sources.length <= 1) return Math.min(Math.max(sources[0]?.cx ?? to.cx, to.x + T.side.entry), to.x + to.w - T.side.entry);
|
|
1261
|
+
return to.x + T.side.entry + (to.w - T.side.entry * 2) * Math.max(0, k) / (sources.length - 1);
|
|
1262
|
+
};
|
|
1263
|
+
const exitX = (box) => starts && box === first ? box.cx + T.side.entry : box.cx;
|
|
1264
|
+
const finishOf = (id) => ends.find((e) => e.kind === "finish" && e.box === id);
|
|
1265
|
+
const loopOf = (box) => {
|
|
1266
|
+
const { w, h, samples } = T.loop;
|
|
1267
|
+
const bottom2 = box.y + box.h;
|
|
1268
|
+
const p0 = [box.cx + w / 2, bottom2];
|
|
1269
|
+
const c1 = [box.cx + w * 3 / 4, bottom2 + h * 4 / 3];
|
|
1270
|
+
const c2 = [box.cx - w * 3 / 4, bottom2 + h * 4 / 3];
|
|
1271
|
+
const p3 = [box.cx - w / 2, bottom2 + inset];
|
|
1272
|
+
return Array.from({ length: samples + 1 }, (_, k) => {
|
|
1273
|
+
const t = k / samples;
|
|
1274
|
+
const u = 1 - t;
|
|
1275
|
+
const at2 = (i) => u * u * u * p0[i] + 3 * u * u * t * c1[i] + 3 * u * t * t * c2[i] + t * t * t * p3[i];
|
|
1276
|
+
return [at2(0), at2(1)];
|
|
1277
|
+
});
|
|
1278
|
+
};
|
|
1279
|
+
const route = (from, to) => {
|
|
1280
|
+
if (from === "start") {
|
|
1281
|
+
const start = ends.find((e) => e.kind === "start");
|
|
1282
|
+
const target = byId.get(to);
|
|
1283
|
+
if (!start || !target) return [];
|
|
1284
|
+
return [[start.x, start.y + start.r], [target.cx, target.y - inset]];
|
|
1285
|
+
}
|
|
1286
|
+
const a = byId.get(from);
|
|
1287
|
+
if (!a) return [];
|
|
1288
|
+
if (to === "finish") {
|
|
1289
|
+
const end = finishOf(from);
|
|
1290
|
+
if (!end) return [];
|
|
1291
|
+
return Math.abs(end.x - a.cx) < 0.5 ? [[a.cx, a.y + a.h], [a.cx, end.y - end.r - inset]] : [[a.x + a.w, a.cy], [end.x - end.r - inset, a.cy]];
|
|
1292
|
+
}
|
|
1293
|
+
const b = byId.get(to);
|
|
1294
|
+
if (!b) return [];
|
|
1295
|
+
if (from === to) return loopOf(a);
|
|
1296
|
+
if (b.ghost && !a.ghost) {
|
|
1297
|
+
const sx = exitX(a);
|
|
1298
|
+
const ex = entryOf(from, b);
|
|
1299
|
+
return Math.abs(sx - ex) < 0.5 ? [[sx, a.y], [ex, b.y + b.h + inset]] : [[sx, a.y], [sx, lane], [ex, lane], [ex, b.y + b.h + inset]];
|
|
1300
|
+
}
|
|
1301
|
+
if (a.ghost && b.ghost) return [[a.x + a.w, a.cy], [b.x - inset, b.cy]];
|
|
1302
|
+
if (a.ghost) return [[a.cx, a.y + a.h], [a.cx, lane], [b.cx, lane], [b.cx, b.y - inset]];
|
|
1303
|
+
return between2(a, b);
|
|
1304
|
+
};
|
|
1305
|
+
const settleOf = (edge2) => {
|
|
1306
|
+
const target = byId.get(edge2.to);
|
|
1307
|
+
if (target) return [target.cx, target.cy + B.iconY];
|
|
1308
|
+
const end = edge2.to === "finish" ? finishOf(edge2.from) : void 0;
|
|
1309
|
+
if (!end) return void 0;
|
|
1310
|
+
const from = byId.get(edge2.from);
|
|
1311
|
+
return from && Math.abs(end.x - from.cx) < 0.5 ? [end.x - end.r - gap - carrierHalf(edge2.carry), end.y] : [end.x, end.y + end.r + gap + LOOK.carrier.tagH / 2];
|
|
1312
|
+
};
|
|
1313
|
+
const sceneEdges = steps.map(({ step, event, edge: edge2 }) => {
|
|
1314
|
+
const settle = settleOf(edge2);
|
|
1315
|
+
return {
|
|
1316
|
+
step,
|
|
1317
|
+
event,
|
|
1318
|
+
from: edge2.from,
|
|
1319
|
+
to: edge2.to,
|
|
1320
|
+
points: route(edge2.from, edge2.to),
|
|
1321
|
+
color: colorOf(edge2, colors),
|
|
1322
|
+
carry: edge2.carry,
|
|
1323
|
+
...settle ? { settle } : {}
|
|
1324
|
+
};
|
|
1325
|
+
});
|
|
1326
|
+
for (const e of sceneEdges) {
|
|
1327
|
+
if (e.points.length !== 2 || !sceneEdges.some((o) => o.from === e.to && o.to === e.from && o.points.length === 2)) continue;
|
|
1328
|
+
const [p, q] = e.points;
|
|
1329
|
+
const flat = Math.abs(q[1] - p[1]) < Math.abs(q[0] - p[0]);
|
|
1330
|
+
const d = (e.from < e.to ? 1 : -1) * LOOK.edge.parallel;
|
|
1331
|
+
e.points = e.points.map(([x, y]) => flat ? [x, y + d] : [x + d, y]);
|
|
1332
|
+
}
|
|
1333
|
+
const paths = notTaken.map((p) => ({ from: p.from, to: p.to, points: route(p.from, p.to) }));
|
|
1334
|
+
const labels = [];
|
|
1335
|
+
const soft = side2 ? [{ x: side2.x, y: side2.y, w: T.side.pad + titleW, h: side2.h }] : [];
|
|
1336
|
+
for (const e of sceneEdges) {
|
|
1337
|
+
const source = diagram.steps[e.step]?.events[e.event];
|
|
1338
|
+
if (source?.type !== "edge" || source.label === void 0) continue;
|
|
1339
|
+
const style = labelStyle(source.label);
|
|
1340
|
+
if (e.from === e.to) {
|
|
1341
|
+
const w = textWidth(source.label, style) + LOOK.label.padX * 2;
|
|
1342
|
+
const bottom2 = Math.max(...e.points.map(([, y]) => y));
|
|
1343
|
+
labels.push({ step: e.step, event: e.event, text: source.label, family: style.family, color: e.color, x: (e.points[0]?.[0] ?? 0) - T.loop.w / 2 - w / 2, y: bottom2 + LOOK.label.soft, w, h: LOOK.label.h });
|
|
1344
|
+
continue;
|
|
1345
|
+
}
|
|
1346
|
+
const side22 = source.labelSide ?? (e.to === "finish" ? "left" : void 0);
|
|
1347
|
+
labels.push(
|
|
1348
|
+
placeLabel(
|
|
1349
|
+
{ step: e.step, event: e.event, text: source.label, points: e.points, color: e.color, ...side22 ? { side: side22 } : {} },
|
|
1350
|
+
{ hard: boxes, soft: [...soft, ...labels.filter((l) => l.step === e.step)] }
|
|
1351
|
+
)
|
|
1352
|
+
);
|
|
1353
|
+
}
|
|
1354
|
+
notTaken.forEach((p, i) => {
|
|
1355
|
+
const path2 = paths[i];
|
|
1356
|
+
if (p.label === void 0 || path2.points.length === 0) return;
|
|
1357
|
+
const style = labelStyle(p.label);
|
|
1358
|
+
const into = byId.get(p.to)?.ghost === true && byId.get(p.from)?.ghost !== true;
|
|
1359
|
+
const rect = into ? { x: path2.points[0][0] + LOOK.label.soft, y: lane + LOOK.label.soft, w: textWidth(p.label, style) + LOOK.label.padX * 2, h: LOOK.label.h } : placeLabel({ step: -1, event: i, text: p.label, points: path2.points, color: "slate" }, { hard: boxes, soft });
|
|
1360
|
+
path2.label = { x: rect.x, y: rect.y, w: rect.w, h: rect.h, text: p.label, family: style.family };
|
|
1361
|
+
});
|
|
1362
|
+
const layout = { kind: "state", width: 0, height: 0, regions: [], boxes, lifelines: [], edges: sceneEdges, labels, actions: [], badges: [], paths, ends, ...side2 ? { side: side2 } : {} };
|
|
1363
|
+
const lefts = [...boxes.map((b) => b.x), ...labels.map((l) => l.x), ...paths.flatMap((p) => p.label ? [p.label.x] : [])];
|
|
1364
|
+
const shift = Math.max(0, margin - Math.min(...lefts));
|
|
1365
|
+
if (shift > 0) shiftContent(layout, shift, 0);
|
|
1366
|
+
const endRight = (e) => e.x + (e.text === "" ? e.r : T.text + textWidth(e.text, TYPE.regionNote));
|
|
1367
|
+
const rights = [
|
|
1368
|
+
...boxes.map((b) => b.x + b.w),
|
|
1369
|
+
...labels.map((l) => l.x + l.w),
|
|
1370
|
+
...ends.map(endRight),
|
|
1371
|
+
...sceneEdges.flatMap((e) => e.points.map((p) => p[0])),
|
|
1372
|
+
...paths.flatMap((p) => [...p.points.map((q) => q[0]), ...p.label ? [p.label.x + p.label.w] : []]),
|
|
1373
|
+
...side2 ? [side2.x + side2.w] : []
|
|
1374
|
+
];
|
|
1375
|
+
const bottoms = [...boxes.map((b) => b.y + b.h), ...labels.map((l) => l.y + l.h), ...ends.map((e) => e.y + e.r), ...sceneEdges.flatMap((e) => e.points.map((p) => p[1]))];
|
|
1376
|
+
const trail = { title: words.trail, states: walked.map((id) => ({ box: id, color: colors.get(id) ?? "slate" })) };
|
|
1377
|
+
const width = Math.max(Math.max(...rights) + margin, stripNeed(diagram, trail) + margin * 2);
|
|
1378
|
+
const bottom = Math.max(...bottoms, rowY(rowCount - 1) + B.h);
|
|
1379
|
+
const strip2 = layoutStrip(diagram, margin, bottom + gap, width - margin * 2, trail);
|
|
1380
|
+
layout.width = width;
|
|
1381
|
+
layout.height = (strip2 ? strip2.y + strip2.h : bottom) + margin;
|
|
1382
|
+
if (strip2) layout.strip = strip2;
|
|
1383
|
+
layout.badges = diagram.steps.map((step, s) => {
|
|
1384
|
+
const edge2 = sceneEdges.find((e) => e.step === s && e.points.length > 0);
|
|
1385
|
+
if (!edge2) return cornerBadge(step.events, s, layout);
|
|
1386
|
+
if (edge2.from === edge2.to) {
|
|
1387
|
+
const right = Math.max(...edge2.points.map(([px]) => px));
|
|
1388
|
+
const top = edge2.points[0][1];
|
|
1389
|
+
const deep = Math.max(...edge2.points.map(([, py]) => py));
|
|
1390
|
+
return { step: s, x: right + LOOK.badge.r + LOOK.badge.inset, y: top + (deep - top) * T.loop.badgeAt, color: edge2.color };
|
|
1391
|
+
}
|
|
1392
|
+
const [x, y] = badgeOnPath(edge2.points);
|
|
1393
|
+
return { step: s, x, y, color: edge2.color };
|
|
1394
|
+
});
|
|
1395
|
+
return layout;
|
|
1396
|
+
}
|
|
1397
|
+
function colorOf(edge2, colors) {
|
|
1398
|
+
if (edge2.carry.kind === "coin") return edgeColor(edge2, colors);
|
|
1399
|
+
return colors.get(edge2.to === "finish" ? edge2.from : edge2.to) ?? "slate";
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1015
1402
|
// src/field-messages.ts
|
|
1016
1403
|
var TYPES_JA = {
|
|
1017
1404
|
string: "\u6587\u5B57\u5217\u306B\u3059\u308B",
|
|
@@ -1043,6 +1430,7 @@ var ja = {
|
|
|
1043
1430
|
minimum: (limit) => `${limit} \u4EE5\u4E0A\u306B\u3059\u308B`,
|
|
1044
1431
|
const: (value) => `${value} \u306B\u3059\u308B`,
|
|
1045
1432
|
not: (allowed) => allowed ? `${allowed.field} \u306E\u6B04\u306F kind \u304C ${allowed.kind} \u306E\u6642\u3060\u3051\u66F8\u3051\u308B` : "\u3053\u306E\u6B04\u306E\u7D44\u307F\u5408\u308F\u305B\u306F\u66F8\u3051\u306A\u3044",
|
|
1433
|
+
reserved: (names) => `${names.join(" \u3068 ")} \u306F\u72B6\u614B\u9077\u79FB\u56F3\u306E\u59CB\u307E\u308A\u3068\u7D42\u308F\u308A\u306E\u5370\u306E\u540D\u524D\u3067\u3001\u7BB1\u306E\u540D\u672D\u306B\u4F7F\u3048\u306A\u3044`,
|
|
1046
1434
|
anyOf: (fields) => fields.length > 0 ? `${fields.join(" \u304B ")} \u306E${fields.length === 2 ? "\u3069\u3061\u3089\u304B" : "\u3069\u308C\u304B"}\u306E\u6B04\u304C\u8981\u308B` : "\u66F8\u3051\u308B\u5F62\u306E\u3069\u308C\u306B\u3082\u5408\u308F\u306A\u3044",
|
|
1047
1435
|
oneOf: "\u66F8\u3051\u308B\u5F62\u306E\u3069\u308C\u304B 1 \u3064\u3060\u3051\u306B\u5408\u308F\u305B\u308B",
|
|
1048
1436
|
discriminator: (tag, values) => `${tag} \u306F ${values.join(" / ")} \u306E\u3069\u308C\u304B\u306B\u3059\u308B`,
|
|
@@ -1059,6 +1447,7 @@ var en = {
|
|
|
1059
1447
|
minimum: (limit) => `Use ${limit} or greater`,
|
|
1060
1448
|
const: (value) => `Use ${value}`,
|
|
1061
1449
|
not: (allowed) => allowed ? `The ${allowed.field} field is allowed only when kind is ${allowed.kind}` : "This combination of fields is not allowed",
|
|
1450
|
+
reserved: (names) => `${names.join(" and ")} name the start and end marks of a state diagram and cannot be box ids`,
|
|
1062
1451
|
anyOf: (fields) => fields.length > 0 ? `Write one of the ${fields.join(" or ")} fields` : "Does not match any of the allowed shapes",
|
|
1063
1452
|
oneOf: "Match exactly one of the allowed shapes",
|
|
1064
1453
|
discriminator: (tag, values) => `${tag} is one of ${values.join(" / ")}`,
|
|
@@ -1073,7 +1462,7 @@ function ucs2length(str) {
|
|
|
1073
1462
|
return length;
|
|
1074
1463
|
}
|
|
1075
1464
|
var validate_diagram_default = validate10;
|
|
1076
|
-
var schema11 = { "properties": { "version": { "description": "\u5F62\u5F0F\u306E\u7248", "type": "integer", "minimum": 1 }, "kind": { "description": "\u56F3\u306E\u7A2E\u985E", "enum": ["sequence", "architecture"] }, "title": { "$ref": "#/definitions/text" }, "view": { "description": "\u898B\u305B\u65B9\u3002\u66F8\u304B\u306A\u3051\u308C\u3070\u5B57\u306E\u5927\u304D\u3055\u3067\u9078\u3076\u3002fixed \u306F\u5168\u4F53\u3092\u6B62\u3081\u3066\u4E2D\u3060\u3051\u52D5\u304B\u3057\u3001follow \u306F\u5BC4\u3063\u3066\u52D5\u304B\u3057\u5168\u4F53\u56F3\u3067\u4ECA\u3069\u3053\u304B\u3092\u793A\u3059", "enum": ["fixed", "follow"] }, "regions": { "type": "array", "items": { "$ref": "#/definitions/region" } }, "boxes": { "type": "array", "minItems": 1, "items": { "$ref": "#/definitions/box" } }, "strip": { "$ref": "#/definitions/strip" }, "steps": { "type": "array", "minItems": 1, "items": { "$ref": "#/definitions/step" } }, "sequence": { "$ref": "#/definitions/sequence" } }};
|
|
1465
|
+
var schema11 = { "properties": { "version": { "description": "\u5F62\u5F0F\u306E\u7248", "type": "integer", "minimum": 1 }, "kind": { "description": "\u56F3\u306E\u7A2E\u985E", "enum": ["sequence", "architecture", "state"] }, "title": { "$ref": "#/definitions/text" }, "view": { "description": "\u898B\u305B\u65B9\u3002\u66F8\u304B\u306A\u3051\u308C\u3070\u5B57\u306E\u5927\u304D\u3055\u3067\u9078\u3076\u3002fixed \u306F\u5168\u4F53\u3092\u6B62\u3081\u3066\u4E2D\u3060\u3051\u52D5\u304B\u3057\u3001follow \u306F\u5BC4\u3063\u3066\u52D5\u304B\u3057\u5168\u4F53\u56F3\u3067\u4ECA\u3069\u3053\u304B\u3092\u793A\u3059", "enum": ["fixed", "follow"] }, "regions": { "type": "array", "items": { "$ref": "#/definitions/region" } }, "boxes": { "type": "array", "minItems": 1, "items": { "$ref": "#/definitions/box" } }, "strip": { "$ref": "#/definitions/strip" }, "steps": { "type": "array", "minItems": 1, "items": { "$ref": "#/definitions/step" } }, "sequence": { "$ref": "#/definitions/sequence" }, "state": { "$ref": "#/definitions/state" } }};
|
|
1077
1466
|
var func2 = Object.prototype.hasOwnProperty;
|
|
1078
1467
|
var func3 = ucs2length;
|
|
1079
1468
|
var schema17 = { "enum": ["blue", "amber", "green", "violet", "rose", "slate", "coin"] };
|
|
@@ -2467,6 +2856,182 @@ function validate23(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
2467
2856
|
validate23.errors = vErrors;
|
|
2468
2857
|
return errors === 0;
|
|
2469
2858
|
}
|
|
2859
|
+
function validate26(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
|
|
2860
|
+
let vErrors = null;
|
|
2861
|
+
let errors = 0;
|
|
2862
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
2863
|
+
if (data.from === void 0) {
|
|
2864
|
+
const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "from" }, message: "must have required property 'from'" };
|
|
2865
|
+
if (vErrors === null) {
|
|
2866
|
+
vErrors = [err0];
|
|
2867
|
+
} else {
|
|
2868
|
+
vErrors.push(err0);
|
|
2869
|
+
}
|
|
2870
|
+
errors++;
|
|
2871
|
+
}
|
|
2872
|
+
if (data.to === void 0) {
|
|
2873
|
+
const err1 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "to" }, message: "must have required property 'to'" };
|
|
2874
|
+
if (vErrors === null) {
|
|
2875
|
+
vErrors = [err1];
|
|
2876
|
+
} else {
|
|
2877
|
+
vErrors.push(err1);
|
|
2878
|
+
}
|
|
2879
|
+
errors++;
|
|
2880
|
+
}
|
|
2881
|
+
for (const key0 in data) {
|
|
2882
|
+
if (!(key0 === "from" || key0 === "to" || key0 === "label")) {
|
|
2883
|
+
const err2 = { instancePath, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" };
|
|
2884
|
+
if (vErrors === null) {
|
|
2885
|
+
vErrors = [err2];
|
|
2886
|
+
} else {
|
|
2887
|
+
vErrors.push(err2);
|
|
2888
|
+
}
|
|
2889
|
+
errors++;
|
|
2890
|
+
}
|
|
2891
|
+
}
|
|
2892
|
+
if (data.from !== void 0) {
|
|
2893
|
+
let data0 = data.from;
|
|
2894
|
+
if (typeof data0 === "string") {
|
|
2895
|
+
if (!pattern0.test(data0)) {
|
|
2896
|
+
const err3 = { instancePath: instancePath + "/from", schemaPath: "#/definitions/id/pattern", keyword: "pattern", params: { pattern: "^[^\\s\\[\\]\u300C\u300D=:]+$" }, message: 'must match pattern "^[^\\s\\[\\]\u300C\u300D=:]+$"' };
|
|
2897
|
+
if (vErrors === null) {
|
|
2898
|
+
vErrors = [err3];
|
|
2899
|
+
} else {
|
|
2900
|
+
vErrors.push(err3);
|
|
2901
|
+
}
|
|
2902
|
+
errors++;
|
|
2903
|
+
}
|
|
2904
|
+
} else {
|
|
2905
|
+
const err4 = { instancePath: instancePath + "/from", schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
2906
|
+
if (vErrors === null) {
|
|
2907
|
+
vErrors = [err4];
|
|
2908
|
+
} else {
|
|
2909
|
+
vErrors.push(err4);
|
|
2910
|
+
}
|
|
2911
|
+
errors++;
|
|
2912
|
+
}
|
|
2913
|
+
}
|
|
2914
|
+
if (data.to !== void 0) {
|
|
2915
|
+
let data1 = data.to;
|
|
2916
|
+
if (typeof data1 === "string") {
|
|
2917
|
+
if (!pattern0.test(data1)) {
|
|
2918
|
+
const err5 = { instancePath: instancePath + "/to", schemaPath: "#/definitions/id/pattern", keyword: "pattern", params: { pattern: "^[^\\s\\[\\]\u300C\u300D=:]+$" }, message: 'must match pattern "^[^\\s\\[\\]\u300C\u300D=:]+$"' };
|
|
2919
|
+
if (vErrors === null) {
|
|
2920
|
+
vErrors = [err5];
|
|
2921
|
+
} else {
|
|
2922
|
+
vErrors.push(err5);
|
|
2923
|
+
}
|
|
2924
|
+
errors++;
|
|
2925
|
+
}
|
|
2926
|
+
} else {
|
|
2927
|
+
const err6 = { instancePath: instancePath + "/to", schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
2928
|
+
if (vErrors === null) {
|
|
2929
|
+
vErrors = [err6];
|
|
2930
|
+
} else {
|
|
2931
|
+
vErrors.push(err6);
|
|
2932
|
+
}
|
|
2933
|
+
errors++;
|
|
2934
|
+
}
|
|
2935
|
+
}
|
|
2936
|
+
if (data.label !== void 0) {
|
|
2937
|
+
let data2 = data.label;
|
|
2938
|
+
if (typeof data2 === "string") {
|
|
2939
|
+
if (func3(data2) < 1) {
|
|
2940
|
+
const err7 = { instancePath: instancePath + "/label", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
|
|
2941
|
+
if (vErrors === null) {
|
|
2942
|
+
vErrors = [err7];
|
|
2943
|
+
} else {
|
|
2944
|
+
vErrors.push(err7);
|
|
2945
|
+
}
|
|
2946
|
+
errors++;
|
|
2947
|
+
}
|
|
2948
|
+
} else {
|
|
2949
|
+
const err8 = { instancePath: instancePath + "/label", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
2950
|
+
if (vErrors === null) {
|
|
2951
|
+
vErrors = [err8];
|
|
2952
|
+
} else {
|
|
2953
|
+
vErrors.push(err8);
|
|
2954
|
+
}
|
|
2955
|
+
errors++;
|
|
2956
|
+
}
|
|
2957
|
+
}
|
|
2958
|
+
} else {
|
|
2959
|
+
const err9 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
2960
|
+
if (vErrors === null) {
|
|
2961
|
+
vErrors = [err9];
|
|
2962
|
+
} else {
|
|
2963
|
+
vErrors.push(err9);
|
|
2964
|
+
}
|
|
2965
|
+
errors++;
|
|
2966
|
+
}
|
|
2967
|
+
validate26.errors = vErrors;
|
|
2968
|
+
return errors === 0;
|
|
2969
|
+
}
|
|
2970
|
+
function validate25(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
|
|
2971
|
+
let vErrors = null;
|
|
2972
|
+
let errors = 0;
|
|
2973
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
2974
|
+
if (data.paths === void 0) {
|
|
2975
|
+
const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "paths" }, message: "must have required property 'paths'" };
|
|
2976
|
+
if (vErrors === null) {
|
|
2977
|
+
vErrors = [err0];
|
|
2978
|
+
} else {
|
|
2979
|
+
vErrors.push(err0);
|
|
2980
|
+
}
|
|
2981
|
+
errors++;
|
|
2982
|
+
}
|
|
2983
|
+
for (const key0 in data) {
|
|
2984
|
+
if (!(key0 === "paths")) {
|
|
2985
|
+
const err1 = { instancePath, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" };
|
|
2986
|
+
if (vErrors === null) {
|
|
2987
|
+
vErrors = [err1];
|
|
2988
|
+
} else {
|
|
2989
|
+
vErrors.push(err1);
|
|
2990
|
+
}
|
|
2991
|
+
errors++;
|
|
2992
|
+
}
|
|
2993
|
+
}
|
|
2994
|
+
if (data.paths !== void 0) {
|
|
2995
|
+
let data0 = data.paths;
|
|
2996
|
+
if (Array.isArray(data0)) {
|
|
2997
|
+
if (data0.length < 1) {
|
|
2998
|
+
const err2 = { instancePath: instancePath + "/paths", schemaPath: "#/properties/paths/minItems", keyword: "minItems", params: { limit: 1 }, message: "must NOT have fewer than 1 items" };
|
|
2999
|
+
if (vErrors === null) {
|
|
3000
|
+
vErrors = [err2];
|
|
3001
|
+
} else {
|
|
3002
|
+
vErrors.push(err2);
|
|
3003
|
+
}
|
|
3004
|
+
errors++;
|
|
3005
|
+
}
|
|
3006
|
+
const len0 = data0.length;
|
|
3007
|
+
for (let i0 = 0; i0 < len0; i0++) {
|
|
3008
|
+
if (!validate26(data0[i0], { instancePath: instancePath + "/paths/" + i0, parentData: data0, parentDataProperty: i0, rootData })) {
|
|
3009
|
+
vErrors = vErrors === null ? validate26.errors : vErrors.concat(validate26.errors);
|
|
3010
|
+
errors = vErrors.length;
|
|
3011
|
+
}
|
|
3012
|
+
}
|
|
3013
|
+
} else {
|
|
3014
|
+
const err3 = { instancePath: instancePath + "/paths", schemaPath: "#/properties/paths/type", keyword: "type", params: { type: "array" }, message: "must be array" };
|
|
3015
|
+
if (vErrors === null) {
|
|
3016
|
+
vErrors = [err3];
|
|
3017
|
+
} else {
|
|
3018
|
+
vErrors.push(err3);
|
|
3019
|
+
}
|
|
3020
|
+
errors++;
|
|
3021
|
+
}
|
|
3022
|
+
}
|
|
3023
|
+
} else {
|
|
3024
|
+
const err4 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
3025
|
+
if (vErrors === null) {
|
|
3026
|
+
vErrors = [err4];
|
|
3027
|
+
} else {
|
|
3028
|
+
vErrors.push(err4);
|
|
3029
|
+
}
|
|
3030
|
+
errors++;
|
|
3031
|
+
}
|
|
3032
|
+
validate25.errors = vErrors;
|
|
3033
|
+
return errors === 0;
|
|
3034
|
+
}
|
|
2470
3035
|
function validate10(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
|
|
2471
3036
|
let vErrors = null;
|
|
2472
3037
|
let errors = 0;
|
|
@@ -2508,9 +3073,11 @@ function validate10(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
2508
3073
|
let ifClause0;
|
|
2509
3074
|
if (_valid0) {
|
|
2510
3075
|
const _errs4 = errors;
|
|
3076
|
+
const _errs5 = errors;
|
|
3077
|
+
const _errs6 = errors;
|
|
2511
3078
|
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
2512
|
-
if (data.
|
|
2513
|
-
const err2 = {
|
|
3079
|
+
if (data.state === void 0 && ("state")) {
|
|
3080
|
+
const err2 = {};
|
|
2514
3081
|
if (vErrors === null) {
|
|
2515
3082
|
vErrors = [err2];
|
|
2516
3083
|
} else {
|
|
@@ -2519,227 +3086,391 @@ function validate10(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
2519
3086
|
errors++;
|
|
2520
3087
|
}
|
|
2521
3088
|
}
|
|
3089
|
+
var valid2 = _errs6 === errors;
|
|
3090
|
+
if (valid2) {
|
|
3091
|
+
const err3 = { instancePath, schemaPath: "#/then/not", keyword: "not", params: {}, message: "must NOT be valid" };
|
|
3092
|
+
if (vErrors === null) {
|
|
3093
|
+
vErrors = [err3];
|
|
3094
|
+
} else {
|
|
3095
|
+
vErrors.push(err3);
|
|
3096
|
+
}
|
|
3097
|
+
errors++;
|
|
3098
|
+
} else {
|
|
3099
|
+
errors = _errs5;
|
|
3100
|
+
if (vErrors !== null) {
|
|
3101
|
+
if (_errs5) {
|
|
3102
|
+
vErrors.length = _errs5;
|
|
3103
|
+
} else {
|
|
3104
|
+
vErrors = null;
|
|
3105
|
+
}
|
|
3106
|
+
}
|
|
3107
|
+
}
|
|
3108
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
3109
|
+
if (data.sequence === void 0) {
|
|
3110
|
+
const err4 = { instancePath, schemaPath: "#/then/required", keyword: "required", params: { missingProperty: "sequence" }, message: "must have required property 'sequence'" };
|
|
3111
|
+
if (vErrors === null) {
|
|
3112
|
+
vErrors = [err4];
|
|
3113
|
+
} else {
|
|
3114
|
+
vErrors.push(err4);
|
|
3115
|
+
}
|
|
3116
|
+
errors++;
|
|
3117
|
+
}
|
|
3118
|
+
}
|
|
2522
3119
|
var _valid0 = _errs4 === errors;
|
|
2523
3120
|
valid0 = _valid0;
|
|
2524
3121
|
ifClause0 = "then";
|
|
2525
3122
|
} else {
|
|
2526
|
-
const _errs5 = errors;
|
|
2527
|
-
const _errs6 = errors;
|
|
2528
3123
|
const _errs7 = errors;
|
|
3124
|
+
const _errs8 = errors;
|
|
3125
|
+
const _errs9 = errors;
|
|
2529
3126
|
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
2530
3127
|
if (data.sequence === void 0 && ("sequence")) {
|
|
2531
|
-
const
|
|
3128
|
+
const err5 = {};
|
|
2532
3129
|
if (vErrors === null) {
|
|
2533
|
-
vErrors = [
|
|
3130
|
+
vErrors = [err5];
|
|
2534
3131
|
} else {
|
|
2535
|
-
vErrors.push(
|
|
3132
|
+
vErrors.push(err5);
|
|
2536
3133
|
}
|
|
2537
3134
|
errors++;
|
|
2538
3135
|
}
|
|
2539
3136
|
}
|
|
2540
|
-
var
|
|
2541
|
-
if (
|
|
2542
|
-
const
|
|
3137
|
+
var valid3 = _errs9 === errors;
|
|
3138
|
+
if (valid3) {
|
|
3139
|
+
const err6 = { instancePath, schemaPath: "#/else/not", keyword: "not", params: {}, message: "must NOT be valid" };
|
|
2543
3140
|
if (vErrors === null) {
|
|
2544
|
-
vErrors = [
|
|
3141
|
+
vErrors = [err6];
|
|
2545
3142
|
} else {
|
|
2546
|
-
vErrors.push(
|
|
3143
|
+
vErrors.push(err6);
|
|
2547
3144
|
}
|
|
2548
3145
|
errors++;
|
|
2549
3146
|
} else {
|
|
2550
|
-
errors =
|
|
3147
|
+
errors = _errs8;
|
|
2551
3148
|
if (vErrors !== null) {
|
|
2552
|
-
if (
|
|
2553
|
-
vErrors.length =
|
|
3149
|
+
if (_errs8) {
|
|
3150
|
+
vErrors.length = _errs8;
|
|
2554
3151
|
} else {
|
|
2555
3152
|
vErrors = null;
|
|
2556
3153
|
}
|
|
2557
3154
|
}
|
|
2558
3155
|
}
|
|
2559
|
-
|
|
3156
|
+
const _errs10 = errors;
|
|
3157
|
+
let valid4 = true;
|
|
3158
|
+
const _errs11 = errors;
|
|
3159
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
3160
|
+
if (data.kind === void 0 && ("kind")) {
|
|
3161
|
+
const err7 = {};
|
|
3162
|
+
if (vErrors === null) {
|
|
3163
|
+
vErrors = [err7];
|
|
3164
|
+
} else {
|
|
3165
|
+
vErrors.push(err7);
|
|
3166
|
+
}
|
|
3167
|
+
errors++;
|
|
3168
|
+
} else {
|
|
3169
|
+
if (data.kind !== void 0) {
|
|
3170
|
+
if ("state" !== data.kind) {
|
|
3171
|
+
const err8 = {};
|
|
3172
|
+
if (vErrors === null) {
|
|
3173
|
+
vErrors = [err8];
|
|
3174
|
+
} else {
|
|
3175
|
+
vErrors.push(err8);
|
|
3176
|
+
}
|
|
3177
|
+
errors++;
|
|
3178
|
+
}
|
|
3179
|
+
}
|
|
3180
|
+
}
|
|
3181
|
+
}
|
|
3182
|
+
var _valid1 = _errs11 === errors;
|
|
3183
|
+
errors = _errs10;
|
|
3184
|
+
if (vErrors !== null) {
|
|
3185
|
+
if (_errs10) {
|
|
3186
|
+
vErrors.length = _errs10;
|
|
3187
|
+
} else {
|
|
3188
|
+
vErrors = null;
|
|
3189
|
+
}
|
|
3190
|
+
}
|
|
3191
|
+
let ifClause1;
|
|
3192
|
+
if (_valid1) {
|
|
3193
|
+
const _errs13 = errors;
|
|
3194
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
3195
|
+
if (data.boxes !== void 0) {
|
|
3196
|
+
let data2 = data.boxes;
|
|
3197
|
+
if (Array.isArray(data2)) {
|
|
3198
|
+
const len0 = data2.length;
|
|
3199
|
+
for (let i0 = 0; i0 < len0; i0++) {
|
|
3200
|
+
let data3 = data2[i0];
|
|
3201
|
+
if (data3 && typeof data3 == "object" && !Array.isArray(data3)) {
|
|
3202
|
+
if (data3.id !== void 0) {
|
|
3203
|
+
let data4 = data3.id;
|
|
3204
|
+
const _errs17 = errors;
|
|
3205
|
+
const _errs18 = errors;
|
|
3206
|
+
if (!(data4 === "start" || data4 === "finish")) {
|
|
3207
|
+
const err9 = {};
|
|
3208
|
+
if (vErrors === null) {
|
|
3209
|
+
vErrors = [err9];
|
|
3210
|
+
} else {
|
|
3211
|
+
vErrors.push(err9);
|
|
3212
|
+
}
|
|
3213
|
+
errors++;
|
|
3214
|
+
}
|
|
3215
|
+
var valid10 = _errs18 === errors;
|
|
3216
|
+
if (valid10) {
|
|
3217
|
+
const err10 = { instancePath: instancePath + "/boxes/" + i0 + "/id", schemaPath: "#/else/then/properties/boxes/items/properties/id/not", keyword: "not", params: {}, message: "must NOT be valid" };
|
|
3218
|
+
if (vErrors === null) {
|
|
3219
|
+
vErrors = [err10];
|
|
3220
|
+
} else {
|
|
3221
|
+
vErrors.push(err10);
|
|
3222
|
+
}
|
|
3223
|
+
errors++;
|
|
3224
|
+
} else {
|
|
3225
|
+
errors = _errs17;
|
|
3226
|
+
if (vErrors !== null) {
|
|
3227
|
+
if (_errs17) {
|
|
3228
|
+
vErrors.length = _errs17;
|
|
3229
|
+
} else {
|
|
3230
|
+
vErrors = null;
|
|
3231
|
+
}
|
|
3232
|
+
}
|
|
3233
|
+
}
|
|
3234
|
+
}
|
|
3235
|
+
}
|
|
3236
|
+
}
|
|
3237
|
+
}
|
|
3238
|
+
}
|
|
3239
|
+
}
|
|
3240
|
+
var _valid1 = _errs13 === errors;
|
|
3241
|
+
valid4 = _valid1;
|
|
3242
|
+
ifClause1 = "then";
|
|
3243
|
+
} else {
|
|
3244
|
+
const _errs19 = errors;
|
|
3245
|
+
const _errs20 = errors;
|
|
3246
|
+
const _errs21 = errors;
|
|
3247
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
3248
|
+
if (data.state === void 0 && ("state")) {
|
|
3249
|
+
const err11 = {};
|
|
3250
|
+
if (vErrors === null) {
|
|
3251
|
+
vErrors = [err11];
|
|
3252
|
+
} else {
|
|
3253
|
+
vErrors.push(err11);
|
|
3254
|
+
}
|
|
3255
|
+
errors++;
|
|
3256
|
+
}
|
|
3257
|
+
}
|
|
3258
|
+
var valid11 = _errs21 === errors;
|
|
3259
|
+
if (valid11) {
|
|
3260
|
+
const err12 = { instancePath, schemaPath: "#/else/else/not", keyword: "not", params: {}, message: "must NOT be valid" };
|
|
3261
|
+
if (vErrors === null) {
|
|
3262
|
+
vErrors = [err12];
|
|
3263
|
+
} else {
|
|
3264
|
+
vErrors.push(err12);
|
|
3265
|
+
}
|
|
3266
|
+
errors++;
|
|
3267
|
+
} else {
|
|
3268
|
+
errors = _errs20;
|
|
3269
|
+
if (vErrors !== null) {
|
|
3270
|
+
if (_errs20) {
|
|
3271
|
+
vErrors.length = _errs20;
|
|
3272
|
+
} else {
|
|
3273
|
+
vErrors = null;
|
|
3274
|
+
}
|
|
3275
|
+
}
|
|
3276
|
+
}
|
|
3277
|
+
var _valid1 = _errs19 === errors;
|
|
3278
|
+
valid4 = _valid1;
|
|
3279
|
+
ifClause1 = "else";
|
|
3280
|
+
}
|
|
3281
|
+
if (!valid4) {
|
|
3282
|
+
const err13 = { instancePath, schemaPath: "#/else/if", keyword: "if", params: { failingKeyword: ifClause1 }, message: 'must match "' + ifClause1 + '" schema' };
|
|
3283
|
+
if (vErrors === null) {
|
|
3284
|
+
vErrors = [err13];
|
|
3285
|
+
} else {
|
|
3286
|
+
vErrors.push(err13);
|
|
3287
|
+
}
|
|
3288
|
+
errors++;
|
|
3289
|
+
}
|
|
3290
|
+
var _valid0 = _errs7 === errors;
|
|
2560
3291
|
valid0 = _valid0;
|
|
2561
3292
|
ifClause0 = "else";
|
|
2562
3293
|
}
|
|
2563
3294
|
if (!valid0) {
|
|
2564
|
-
const
|
|
3295
|
+
const err14 = { instancePath, schemaPath: "#/if", keyword: "if", params: { failingKeyword: ifClause0 }, message: 'must match "' + ifClause0 + '" schema' };
|
|
2565
3296
|
if (vErrors === null) {
|
|
2566
|
-
vErrors = [
|
|
3297
|
+
vErrors = [err14];
|
|
2567
3298
|
} else {
|
|
2568
|
-
vErrors.push(
|
|
3299
|
+
vErrors.push(err14);
|
|
2569
3300
|
}
|
|
2570
3301
|
errors++;
|
|
2571
3302
|
}
|
|
2572
3303
|
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
2573
3304
|
if (data.version === void 0) {
|
|
2574
|
-
const
|
|
3305
|
+
const err15 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "version" }, message: "must have required property 'version'" };
|
|
2575
3306
|
if (vErrors === null) {
|
|
2576
|
-
vErrors = [
|
|
3307
|
+
vErrors = [err15];
|
|
2577
3308
|
} else {
|
|
2578
|
-
vErrors.push(
|
|
3309
|
+
vErrors.push(err15);
|
|
2579
3310
|
}
|
|
2580
3311
|
errors++;
|
|
2581
3312
|
}
|
|
2582
3313
|
if (data.kind === void 0) {
|
|
2583
|
-
const
|
|
3314
|
+
const err16 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "kind" }, message: "must have required property 'kind'" };
|
|
2584
3315
|
if (vErrors === null) {
|
|
2585
|
-
vErrors = [
|
|
3316
|
+
vErrors = [err16];
|
|
2586
3317
|
} else {
|
|
2587
|
-
vErrors.push(
|
|
3318
|
+
vErrors.push(err16);
|
|
2588
3319
|
}
|
|
2589
3320
|
errors++;
|
|
2590
3321
|
}
|
|
2591
3322
|
if (data.title === void 0) {
|
|
2592
|
-
const
|
|
3323
|
+
const err17 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "title" }, message: "must have required property 'title'" };
|
|
2593
3324
|
if (vErrors === null) {
|
|
2594
|
-
vErrors = [
|
|
3325
|
+
vErrors = [err17];
|
|
2595
3326
|
} else {
|
|
2596
|
-
vErrors.push(
|
|
3327
|
+
vErrors.push(err17);
|
|
2597
3328
|
}
|
|
2598
3329
|
errors++;
|
|
2599
3330
|
}
|
|
2600
3331
|
if (data.boxes === void 0) {
|
|
2601
|
-
const
|
|
3332
|
+
const err18 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "boxes" }, message: "must have required property 'boxes'" };
|
|
2602
3333
|
if (vErrors === null) {
|
|
2603
|
-
vErrors = [
|
|
3334
|
+
vErrors = [err18];
|
|
2604
3335
|
} else {
|
|
2605
|
-
vErrors.push(
|
|
3336
|
+
vErrors.push(err18);
|
|
2606
3337
|
}
|
|
2607
3338
|
errors++;
|
|
2608
3339
|
}
|
|
2609
3340
|
if (data.steps === void 0) {
|
|
2610
|
-
const
|
|
3341
|
+
const err19 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "steps" }, message: "must have required property 'steps'" };
|
|
2611
3342
|
if (vErrors === null) {
|
|
2612
|
-
vErrors = [
|
|
3343
|
+
vErrors = [err19];
|
|
2613
3344
|
} else {
|
|
2614
|
-
vErrors.push(
|
|
3345
|
+
vErrors.push(err19);
|
|
2615
3346
|
}
|
|
2616
3347
|
errors++;
|
|
2617
3348
|
}
|
|
2618
3349
|
for (const key0 in data) {
|
|
2619
3350
|
if (!func2.call(schema11.properties, key0)) {
|
|
2620
|
-
const
|
|
3351
|
+
const err20 = { instancePath, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" };
|
|
2621
3352
|
if (vErrors === null) {
|
|
2622
|
-
vErrors = [
|
|
3353
|
+
vErrors = [err20];
|
|
2623
3354
|
} else {
|
|
2624
|
-
vErrors.push(
|
|
3355
|
+
vErrors.push(err20);
|
|
2625
3356
|
}
|
|
2626
3357
|
errors++;
|
|
2627
3358
|
}
|
|
2628
3359
|
}
|
|
2629
3360
|
if (data.version !== void 0) {
|
|
2630
|
-
let
|
|
2631
|
-
if (!(typeof
|
|
2632
|
-
const
|
|
3361
|
+
let data5 = data.version;
|
|
3362
|
+
if (!(typeof data5 == "number" && (!(data5 % 1) && !isNaN(data5)) && isFinite(data5))) {
|
|
3363
|
+
const err21 = { instancePath: instancePath + "/version", schemaPath: "#/properties/version/type", keyword: "type", params: { type: "integer" }, message: "must be integer" };
|
|
2633
3364
|
if (vErrors === null) {
|
|
2634
|
-
vErrors = [
|
|
3365
|
+
vErrors = [err21];
|
|
2635
3366
|
} else {
|
|
2636
|
-
vErrors.push(
|
|
3367
|
+
vErrors.push(err21);
|
|
2637
3368
|
}
|
|
2638
3369
|
errors++;
|
|
2639
3370
|
}
|
|
2640
|
-
if (typeof
|
|
2641
|
-
if (
|
|
2642
|
-
const
|
|
3371
|
+
if (typeof data5 == "number" && isFinite(data5)) {
|
|
3372
|
+
if (data5 < 1 || isNaN(data5)) {
|
|
3373
|
+
const err22 = { instancePath: instancePath + "/version", schemaPath: "#/properties/version/minimum", keyword: "minimum", params: { comparison: ">=", limit: 1 }, message: "must be >= 1" };
|
|
2643
3374
|
if (vErrors === null) {
|
|
2644
|
-
vErrors = [
|
|
3375
|
+
vErrors = [err22];
|
|
2645
3376
|
} else {
|
|
2646
|
-
vErrors.push(
|
|
3377
|
+
vErrors.push(err22);
|
|
2647
3378
|
}
|
|
2648
3379
|
errors++;
|
|
2649
3380
|
}
|
|
2650
3381
|
}
|
|
2651
3382
|
}
|
|
2652
3383
|
if (data.kind !== void 0) {
|
|
2653
|
-
let
|
|
2654
|
-
if (!(
|
|
2655
|
-
const
|
|
3384
|
+
let data6 = data.kind;
|
|
3385
|
+
if (!(data6 === "sequence" || data6 === "architecture" || data6 === "state")) {
|
|
3386
|
+
const err23 = { instancePath: instancePath + "/kind", schemaPath: "#/properties/kind/enum", keyword: "enum", params: { allowedValues: schema11.properties.kind.enum }, message: "must be equal to one of the allowed values" };
|
|
2656
3387
|
if (vErrors === null) {
|
|
2657
|
-
vErrors = [
|
|
3388
|
+
vErrors = [err23];
|
|
2658
3389
|
} else {
|
|
2659
|
-
vErrors.push(
|
|
3390
|
+
vErrors.push(err23);
|
|
2660
3391
|
}
|
|
2661
3392
|
errors++;
|
|
2662
3393
|
}
|
|
2663
3394
|
}
|
|
2664
3395
|
if (data.title !== void 0) {
|
|
2665
|
-
let
|
|
2666
|
-
if (typeof
|
|
2667
|
-
if (func3(
|
|
2668
|
-
const
|
|
3396
|
+
let data7 = data.title;
|
|
3397
|
+
if (typeof data7 === "string") {
|
|
3398
|
+
if (func3(data7) < 1) {
|
|
3399
|
+
const err24 = { instancePath: instancePath + "/title", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
|
|
2669
3400
|
if (vErrors === null) {
|
|
2670
|
-
vErrors = [
|
|
3401
|
+
vErrors = [err24];
|
|
2671
3402
|
} else {
|
|
2672
|
-
vErrors.push(
|
|
3403
|
+
vErrors.push(err24);
|
|
2673
3404
|
}
|
|
2674
3405
|
errors++;
|
|
2675
3406
|
}
|
|
2676
3407
|
} else {
|
|
2677
|
-
const
|
|
3408
|
+
const err25 = { instancePath: instancePath + "/title", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
2678
3409
|
if (vErrors === null) {
|
|
2679
|
-
vErrors = [
|
|
3410
|
+
vErrors = [err25];
|
|
2680
3411
|
} else {
|
|
2681
|
-
vErrors.push(
|
|
3412
|
+
vErrors.push(err25);
|
|
2682
3413
|
}
|
|
2683
3414
|
errors++;
|
|
2684
3415
|
}
|
|
2685
3416
|
}
|
|
2686
3417
|
if (data.view !== void 0) {
|
|
2687
|
-
let
|
|
2688
|
-
if (!(
|
|
2689
|
-
const
|
|
3418
|
+
let data8 = data.view;
|
|
3419
|
+
if (!(data8 === "fixed" || data8 === "follow")) {
|
|
3420
|
+
const err26 = { instancePath: instancePath + "/view", schemaPath: "#/properties/view/enum", keyword: "enum", params: { allowedValues: schema11.properties.view.enum }, message: "must be equal to one of the allowed values" };
|
|
2690
3421
|
if (vErrors === null) {
|
|
2691
|
-
vErrors = [
|
|
3422
|
+
vErrors = [err26];
|
|
2692
3423
|
} else {
|
|
2693
|
-
vErrors.push(
|
|
3424
|
+
vErrors.push(err26);
|
|
2694
3425
|
}
|
|
2695
3426
|
errors++;
|
|
2696
3427
|
}
|
|
2697
3428
|
}
|
|
2698
3429
|
if (data.regions !== void 0) {
|
|
2699
|
-
let
|
|
2700
|
-
if (Array.isArray(
|
|
2701
|
-
const
|
|
2702
|
-
for (let
|
|
2703
|
-
if (!validate11(
|
|
3430
|
+
let data9 = data.regions;
|
|
3431
|
+
if (Array.isArray(data9)) {
|
|
3432
|
+
const len1 = data9.length;
|
|
3433
|
+
for (let i1 = 0; i1 < len1; i1++) {
|
|
3434
|
+
if (!validate11(data9[i1], { instancePath: instancePath + "/regions/" + i1, parentData: data9, parentDataProperty: i1, rootData })) {
|
|
2704
3435
|
vErrors = vErrors === null ? validate11.errors : vErrors.concat(validate11.errors);
|
|
2705
3436
|
errors = vErrors.length;
|
|
2706
3437
|
}
|
|
2707
3438
|
}
|
|
2708
3439
|
} else {
|
|
2709
|
-
const
|
|
3440
|
+
const err27 = { instancePath: instancePath + "/regions", schemaPath: "#/properties/regions/type", keyword: "type", params: { type: "array" }, message: "must be array" };
|
|
2710
3441
|
if (vErrors === null) {
|
|
2711
|
-
vErrors = [
|
|
3442
|
+
vErrors = [err27];
|
|
2712
3443
|
} else {
|
|
2713
|
-
vErrors.push(
|
|
3444
|
+
vErrors.push(err27);
|
|
2714
3445
|
}
|
|
2715
3446
|
errors++;
|
|
2716
3447
|
}
|
|
2717
3448
|
}
|
|
2718
3449
|
if (data.boxes !== void 0) {
|
|
2719
|
-
let
|
|
2720
|
-
if (Array.isArray(
|
|
2721
|
-
if (
|
|
2722
|
-
const
|
|
3450
|
+
let data11 = data.boxes;
|
|
3451
|
+
if (Array.isArray(data11)) {
|
|
3452
|
+
if (data11.length < 1) {
|
|
3453
|
+
const err28 = { instancePath: instancePath + "/boxes", schemaPath: "#/properties/boxes/minItems", keyword: "minItems", params: { limit: 1 }, message: "must NOT have fewer than 1 items" };
|
|
2723
3454
|
if (vErrors === null) {
|
|
2724
|
-
vErrors = [
|
|
3455
|
+
vErrors = [err28];
|
|
2725
3456
|
} else {
|
|
2726
|
-
vErrors.push(
|
|
3457
|
+
vErrors.push(err28);
|
|
2727
3458
|
}
|
|
2728
3459
|
errors++;
|
|
2729
3460
|
}
|
|
2730
|
-
const
|
|
2731
|
-
for (let
|
|
2732
|
-
if (!validate13(
|
|
3461
|
+
const len2 = data11.length;
|
|
3462
|
+
for (let i2 = 0; i2 < len2; i2++) {
|
|
3463
|
+
if (!validate13(data11[i2], { instancePath: instancePath + "/boxes/" + i2, parentData: data11, parentDataProperty: i2, rootData })) {
|
|
2733
3464
|
vErrors = vErrors === null ? validate13.errors : vErrors.concat(validate13.errors);
|
|
2734
3465
|
errors = vErrors.length;
|
|
2735
3466
|
}
|
|
2736
3467
|
}
|
|
2737
3468
|
} else {
|
|
2738
|
-
const
|
|
3469
|
+
const err29 = { instancePath: instancePath + "/boxes", schemaPath: "#/properties/boxes/type", keyword: "type", params: { type: "array" }, message: "must be array" };
|
|
2739
3470
|
if (vErrors === null) {
|
|
2740
|
-
vErrors = [
|
|
3471
|
+
vErrors = [err29];
|
|
2741
3472
|
} else {
|
|
2742
|
-
vErrors.push(
|
|
3473
|
+
vErrors.push(err29);
|
|
2743
3474
|
}
|
|
2744
3475
|
errors++;
|
|
2745
3476
|
}
|
|
@@ -2751,30 +3482,30 @@ function validate10(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
2751
3482
|
}
|
|
2752
3483
|
}
|
|
2753
3484
|
if (data.steps !== void 0) {
|
|
2754
|
-
let
|
|
2755
|
-
if (Array.isArray(
|
|
2756
|
-
if (
|
|
2757
|
-
const
|
|
3485
|
+
let data14 = data.steps;
|
|
3486
|
+
if (Array.isArray(data14)) {
|
|
3487
|
+
if (data14.length < 1) {
|
|
3488
|
+
const err30 = { instancePath: instancePath + "/steps", schemaPath: "#/properties/steps/minItems", keyword: "minItems", params: { limit: 1 }, message: "must NOT have fewer than 1 items" };
|
|
2758
3489
|
if (vErrors === null) {
|
|
2759
|
-
vErrors = [
|
|
3490
|
+
vErrors = [err30];
|
|
2760
3491
|
} else {
|
|
2761
|
-
vErrors.push(
|
|
3492
|
+
vErrors.push(err30);
|
|
2762
3493
|
}
|
|
2763
3494
|
errors++;
|
|
2764
3495
|
}
|
|
2765
|
-
const
|
|
2766
|
-
for (let
|
|
2767
|
-
if (!validate17(
|
|
3496
|
+
const len3 = data14.length;
|
|
3497
|
+
for (let i3 = 0; i3 < len3; i3++) {
|
|
3498
|
+
if (!validate17(data14[i3], { instancePath: instancePath + "/steps/" + i3, parentData: data14, parentDataProperty: i3, rootData })) {
|
|
2768
3499
|
vErrors = vErrors === null ? validate17.errors : vErrors.concat(validate17.errors);
|
|
2769
3500
|
errors = vErrors.length;
|
|
2770
3501
|
}
|
|
2771
3502
|
}
|
|
2772
3503
|
} else {
|
|
2773
|
-
const
|
|
3504
|
+
const err31 = { instancePath: instancePath + "/steps", schemaPath: "#/properties/steps/type", keyword: "type", params: { type: "array" }, message: "must be array" };
|
|
2774
3505
|
if (vErrors === null) {
|
|
2775
|
-
vErrors = [
|
|
3506
|
+
vErrors = [err31];
|
|
2776
3507
|
} else {
|
|
2777
|
-
vErrors.push(
|
|
3508
|
+
vErrors.push(err31);
|
|
2778
3509
|
}
|
|
2779
3510
|
errors++;
|
|
2780
3511
|
}
|
|
@@ -2785,12 +3516,18 @@ function validate10(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
2785
3516
|
errors = vErrors.length;
|
|
2786
3517
|
}
|
|
2787
3518
|
}
|
|
3519
|
+
if (data.state !== void 0) {
|
|
3520
|
+
if (!validate25(data.state, { instancePath: instancePath + "/state", parentData: data, parentDataProperty: "state", rootData })) {
|
|
3521
|
+
vErrors = vErrors === null ? validate25.errors : vErrors.concat(validate25.errors);
|
|
3522
|
+
errors = vErrors.length;
|
|
3523
|
+
}
|
|
3524
|
+
}
|
|
2788
3525
|
} else {
|
|
2789
|
-
const
|
|
3526
|
+
const err32 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
2790
3527
|
if (vErrors === null) {
|
|
2791
|
-
vErrors = [
|
|
3528
|
+
vErrors = [err32];
|
|
2792
3529
|
} else {
|
|
2793
|
-
vErrors.push(
|
|
3530
|
+
vErrors.push(err32);
|
|
2794
3531
|
}
|
|
2795
3532
|
errors++;
|
|
2796
3533
|
}
|
|
@@ -2801,10 +3538,15 @@ function validate10(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
2801
3538
|
// src/schema.ts
|
|
2802
3539
|
var COLORS = ["blue", "amber", "green", "violet", "rose", "slate", "coin"];
|
|
2803
3540
|
var EVENT_TYPES = ["edge", "action", "swap", "strip"];
|
|
3541
|
+
var ROOT_NOT_ALLOWED = {
|
|
3542
|
+
"#/else/not": { field: "sequence", kind: "sequence" },
|
|
3543
|
+
"#/then/not": { field: "state", kind: "state" },
|
|
3544
|
+
"#/else/else/not": { field: "state", kind: "state" }
|
|
3545
|
+
};
|
|
2804
3546
|
var NOT_ALLOWED = {
|
|
2805
|
-
"": { field: "sequence", kind: "sequence" },
|
|
2806
3547
|
carry: { field: "text", kind: "tag" }
|
|
2807
3548
|
};
|
|
3549
|
+
var RESERVED_ID = /\/boxes\/items\/properties\/id\/not$/u;
|
|
2808
3550
|
var escape = (key) => key.replaceAll("~", "~0").replaceAll("/", "~1");
|
|
2809
3551
|
function forbiddenOf(pattern) {
|
|
2810
3552
|
const inside = /^\^\[\^(.+)\]\+\$$/u.exec(pattern)?.[1];
|
|
@@ -2828,7 +3570,8 @@ function toFieldError(error, errors, m) {
|
|
|
2828
3570
|
return { pointer: `${at2}/${escape(key)}`, message: m.required(key) };
|
|
2829
3571
|
}
|
|
2830
3572
|
case "not": {
|
|
2831
|
-
|
|
3573
|
+
if (RESERVED_ID.test(error.schemaPath)) return { pointer: at2, message: m.reserved(STATE_ENDS) };
|
|
3574
|
+
const allowed = at2 === "" ? ROOT_NOT_ALLOWED[error.schemaPath] : NOT_ALLOWED[at2.slice(at2.lastIndexOf("/") + 1)];
|
|
2832
3575
|
return { pointer: allowed ? `${at2}/${allowed.field}` : at2, message: m.not(allowed) };
|
|
2833
3576
|
}
|
|
2834
3577
|
case "anyOf": {
|
|
@@ -2947,6 +3690,7 @@ function buildTimeline(diagram) {
|
|
|
2947
3690
|
const later = named[k + 2];
|
|
2948
3691
|
if (later) label2.end = Math.min(label2.end, later.start);
|
|
2949
3692
|
});
|
|
3693
|
+
if (diagram.kind === "state") for (const label2 of named) label2.after = { start: label2.end, end: last };
|
|
2950
3694
|
labels.push(...named);
|
|
2951
3695
|
for (const event of p.events) events.push({ step: s, event: event.event, at: span.start + event.at });
|
|
2952
3696
|
});
|
|
@@ -2970,6 +3714,7 @@ function buildTimeline(diagram) {
|
|
|
2970
3714
|
});
|
|
2971
3715
|
}
|
|
2972
3716
|
carriers.sort((x, y) => x.depart - y.depart);
|
|
3717
|
+
const states = diagram.kind === "state" ? stateTimes(diagram, edges, last) : void 0;
|
|
2973
3718
|
return {
|
|
2974
3719
|
total,
|
|
2975
3720
|
last,
|
|
@@ -2979,8 +3724,32 @@ function buildTimeline(diagram) {
|
|
|
2979
3724
|
labels,
|
|
2980
3725
|
badges: steps.map((span, s) => ({ step: s, appears: span.start })),
|
|
2981
3726
|
events,
|
|
2982
|
-
stills: steps.map((span) => span.end - MOTION.still)
|
|
3727
|
+
stills: steps.map((span) => span.end - MOTION.still),
|
|
3728
|
+
...states ? { states } : {}
|
|
3729
|
+
};
|
|
3730
|
+
}
|
|
3731
|
+
var isEnd2 = (id) => STATE_ENDS.includes(id);
|
|
3732
|
+
function stateTimes(diagram, edges, last) {
|
|
3733
|
+
const times = /* @__PURE__ */ new Map();
|
|
3734
|
+
const of = (box) => {
|
|
3735
|
+
const found = times.get(box) ?? { box, lit: [] };
|
|
3736
|
+
times.set(box, found);
|
|
3737
|
+
return found;
|
|
2983
3738
|
};
|
|
3739
|
+
let on;
|
|
3740
|
+
for (const edge2 of edges) {
|
|
3741
|
+
const event = diagram.steps[edge2.step]?.events[edge2.event];
|
|
3742
|
+
if (event?.type !== "edge" || event.from === event.to) continue;
|
|
3743
|
+
if (on) {
|
|
3744
|
+
const left = of(on.box);
|
|
3745
|
+
left.lit.push({ start: on.since, end: edge2.start });
|
|
3746
|
+
if (on.box === event.from && left.done === void 0) left.done = edge2.start + MOTION.done;
|
|
3747
|
+
on = void 0;
|
|
3748
|
+
}
|
|
3749
|
+
if (!isEnd2(event.to)) on = { box: event.to, since: edge2.drawn };
|
|
3750
|
+
}
|
|
3751
|
+
if (on) of(on.box).lit.push({ start: on.since, end: last });
|
|
3752
|
+
return [...times.values()];
|
|
2984
3753
|
}
|
|
2985
3754
|
|
|
2986
3755
|
// src/render/icons.ts
|
|
@@ -3015,6 +3784,8 @@ var ICONS = {
|
|
|
3015
3784
|
branch: "M -4 -4.5 v9 M 5 0.5 c0 4 -9 3 -9 6.5 M -6.2 -7 a2.2 2.2 0 1 0 4.4 0 a2.2 2.2 0 1 0 -4.4 0 M -6.2 7 a2.2 2.2 0 1 0 4.4 0 a2.2 2.2 0 1 0 -4.4 0 M 2.8 -2 a2.2 2.2 0 1 0 4.4 0 a2.2 2.2 0 1 0 -4.4 0",
|
|
3016
3785
|
cloud: "M -7 6 h13 a4.5 4.5 0 0 0 0.5 -9 a6 6 0 0 0 -11.5 -1 a4.5 4.5 0 0 0 -2 10 z",
|
|
3017
3786
|
refresh: "M 7 -3 a7.5 7.5 0 1 0 0.5 5 M 7.5 -8 v5 h-5",
|
|
3787
|
+
undo: "M -7 -2 h10 a5 5 0 0 1 0 10 h-6 M -3 -6 l-4 4 l4 4",
|
|
3788
|
+
yen: "M -6 -8 l6 7 l6 -7 M 0 -1 v9 M -5 1.5 h10 M -5 5 h10",
|
|
3018
3789
|
layers: "M 0 -8 l9 4.5 l-9 4.5 l-9 -4.5 z M -9 2.5 l9 4.5 l9 -4.5",
|
|
3019
3790
|
code: "M -4 -6 l-5 6 l5 6 M 4 -6 l5 6 l-5 6",
|
|
3020
3791
|
paint: "M -8 8 c 0 -3 2 -5 4.5 -5 l 9 -9 l 3.5 3.5 l -9 9 c 0 2.5 -2 4.5 -5 4.5 z",
|
|
@@ -3029,7 +3800,25 @@ function glyph(name, x, y, scale, cls = "dg-gl") {
|
|
|
3029
3800
|
const d = name === void 0 ? void 0 : ICONS[name];
|
|
3030
3801
|
return d ? `<path class="${cls}" transform="translate(${r1(x)} ${r1(y)}) scale(${scale})" d="${d}"/>` : "";
|
|
3031
3802
|
}
|
|
3032
|
-
|
|
3803
|
+
function pathOf(points) {
|
|
3804
|
+
const pts = points.filter((p, i) => i === 0 || p[0] !== points[i - 1][0] || p[1] !== points[i - 1][1]);
|
|
3805
|
+
const [x0, y0] = pts[0];
|
|
3806
|
+
let d = `M ${r1(x0)} ${r1(y0)}`;
|
|
3807
|
+
for (let i = 1; i < pts.length - 1; i++) {
|
|
3808
|
+
const [ax, ay] = pts[i - 1];
|
|
3809
|
+
const [bx, by] = pts[i];
|
|
3810
|
+
const [cx, cy] = pts[i + 1];
|
|
3811
|
+
const l1 = Math.hypot(bx - ax, by - ay);
|
|
3812
|
+
const l2 = Math.hypot(cx - bx, cy - by);
|
|
3813
|
+
const a = Math.min(LOOK.edge.bend, l1 / 2, l2 / 2);
|
|
3814
|
+
d += ` L ${r1(bx - (bx - ax) / l1 * a)} ${r1(by - (by - ay) / l1 * a)} Q ${r1(bx)} ${r1(by)} ${r1(bx + (cx - bx) / l2 * a)} ${r1(by + (cy - by) / l2 * a)}`;
|
|
3815
|
+
}
|
|
3816
|
+
if (pts.length > 1) {
|
|
3817
|
+
const [lx, ly] = pts[pts.length - 1];
|
|
3818
|
+
d += ` L ${r1(lx)} ${r1(ly)}`;
|
|
3819
|
+
}
|
|
3820
|
+
return d;
|
|
3821
|
+
}
|
|
3033
3822
|
function arrowHead(points) {
|
|
3034
3823
|
const [ex, ey] = points[points.length - 1];
|
|
3035
3824
|
const [px, py] = points[points.length - 2];
|
|
@@ -3076,10 +3865,10 @@ function cardFrame(box, ctx, act, y, h) {
|
|
|
3076
3865
|
const rect = (cls, extra = "") => `<rect class="${cls}" x="${r1(box.x)}" y="${r1(y)}" width="${r1(box.w)}" height="${h}" rx="${LOOK.box.radius}"${extra}/>`;
|
|
3077
3866
|
return `${act ? `<g class="dg-a" style="${act}">${rect("dg-halo")}</g>` : ""}${rect("dg-st", ` ${ctx.sh}`)}${act ? `<g class="dg-a" style="${act}">${rect("dg-on")}</g>` : ""}`;
|
|
3078
3867
|
}
|
|
3079
|
-
function card(box, ctx, on, changes) {
|
|
3868
|
+
function card(box, ctx, on, changes, lit) {
|
|
3080
3869
|
const { icon, iconRadius, iconScale, iconY, nameY, subY } = LOOK.box;
|
|
3081
3870
|
const subs = subLines(box, ctx.m, changes, box.cy + subY);
|
|
3082
|
-
const act = on.length > 0 ? activeKf(ctx, on) : void 0;
|
|
3871
|
+
const act = lit ? lit.length > 0 ? rangeKf(ctx.m, lit.map((s) => [s.start, s.end])) : void 0 : on.length > 0 ? activeKf(ctx, on) : void 0;
|
|
3083
3872
|
const mark = box.icon && ICONS[box.icon] ? `<rect class="dg-ic" x="${r1(box.cx - icon / 2)}" y="${r1(box.cy + iconY - icon / 2)}" width="${icon}" height="${icon}" rx="${iconRadius}"/>${glyph(box.icon, box.cx, box.cy + iconY, iconScale)}` : "";
|
|
3084
3873
|
return `<g style="${cs(box.color)}">${cardFrame(box, ctx, act, box.y, box.h)}${mark}<text class="dg-sn" x="${r1(box.cx)}" y="${r1(box.cy + nameY)}" text-anchor="middle">${esc(box.name)}</text>${subs}</g>`;
|
|
3085
3874
|
}
|
|
@@ -3089,15 +3878,54 @@ function headCard(box, ctx, on, changes) {
|
|
|
3089
3878
|
const act = on.length > 0 ? activeKf(ctx, on) : void 0;
|
|
3090
3879
|
return `<g style="${cs(box.color)}">${cardFrame(box, ctx, act, pad2, h)}<text class="dg-sn" x="${r1(box.cx)}" y="${r1(pad2 + nameY)}" text-anchor="middle">${esc(box.name)}</text>${subs}</g>`;
|
|
3091
3880
|
}
|
|
3881
|
+
function ghostCard(box) {
|
|
3882
|
+
const { icon, iconRadius, iconScale, radius } = LOOK.box;
|
|
3883
|
+
const G = LOOK.state.ghost;
|
|
3884
|
+
const ix = box.x + G.pad + icon / 2;
|
|
3885
|
+
const tx = box.x + G.pad + icon + G.gap;
|
|
3886
|
+
const mark = box.icon && ICONS[box.icon] ? `<rect class="dg-ic" x="${r1(ix - icon / 2)}" y="${r1(box.cy - icon / 2)}" width="${icon}" height="${icon}" rx="${iconRadius}"/>${glyph(box.icon, ix, box.cy, iconScale)}` : "";
|
|
3887
|
+
const nameY = box.sub ? G.nameY : LOOK.baseline.mark;
|
|
3888
|
+
const sub = box.sub ? `<text class="dg-ss" x="${r1(tx)}" y="${r1(box.cy + G.subY)}" text-anchor="start">${esc(box.sub)}</text>` : "";
|
|
3889
|
+
return `<g data-ghost="${esc(box.id)}" style="${cs(box.color)}"><rect class="dg-ghost" x="${r1(box.x)}" y="${r1(box.y)}" width="${r1(box.w)}" height="${box.h}" rx="${radius}"/>${mark}<text class="dg-sn" x="${r1(tx)}" y="${r1(box.cy + nameY)}" text-anchor="start">${esc(box.name)}</text>${sub}</g>`;
|
|
3890
|
+
}
|
|
3891
|
+
function doneMark(box, at2, ctx) {
|
|
3892
|
+
const { r, inset } = LOOK.state.done;
|
|
3893
|
+
const x = box.x + box.w - inset;
|
|
3894
|
+
const y = box.y + inset;
|
|
3895
|
+
return `<g class="dg-popc dg-a" data-done="${esc(box.id)}" style="${cs(box.color)};${ctx.m.pop(at2)}"><circle class="dg-done" cx="${r1(x)}" cy="${r1(y)}" r="${r}"/>${glyph("check", x, y, 0.5, "dg-done-ck")}</g>`;
|
|
3896
|
+
}
|
|
3897
|
+
function path(p, color) {
|
|
3898
|
+
const label2 = p.label ? `<text class="dg-path-t${p.label.family === "sans" ? " dg-path-tj" : ""}" x="${r1(p.label.x + LOOK.label.padX)}" y="${r1(p.label.y + p.label.h / 2 + LOOK.baseline.label)}">${esc(p.label.text)}</text>` : "";
|
|
3899
|
+
return `<g data-path="${esc(`${p.from}->${p.to}`)}" style="${cs(color)}"><path class="dg-path" d="${pathOf(p.points)}"/><path class="dg-path-h" d="${arrowHead(p.points)}"/>${label2}</g>`;
|
|
3900
|
+
}
|
|
3901
|
+
function side(s, color) {
|
|
3902
|
+
const { pad: pad2 } = LOOK.state.side;
|
|
3903
|
+
const title = s.y + pad2 + TYPE.regionName.size;
|
|
3904
|
+
const notes = s.notes.map((note, k) => `<text class="dg-side-n" x="${r1(s.x + pad2)}" y="${r1(title + LOOK.region.line * (k + 1))}">${esc(note)}</text>`).join("");
|
|
3905
|
+
return `<g style="${cs(color)}"><rect class="dg-side" x="${r1(s.x + 0.5)}" y="${r1(s.y + 0.5)}" width="${r1(s.w - 1)}" height="${r1(s.h - 1)}" rx="${LOOK.region.radius}"/><text class="dg-side-t" x="${r1(s.x + pad2)}" y="${r1(title)}">${esc(s.title)}</text>${notes}</g>`;
|
|
3906
|
+
}
|
|
3907
|
+
function endMark(e, color) {
|
|
3908
|
+
const { end } = LOOK.state;
|
|
3909
|
+
const text2 = e.text === "" ? "" : `<text class="dg-mark" x="${r1(e.x + LOOK.state.text)}" y="${r1(e.y + LOOK.baseline.mark)}">${esc(e.text)}</text>`;
|
|
3910
|
+
const x = r1(e.x);
|
|
3911
|
+
const y = r1(e.y);
|
|
3912
|
+
if (e.kind === "start") return `<g data-end="start"><circle class="dg-start" cx="${x}" cy="${y}" r="${e.r}"/>${text2}</g>`;
|
|
3913
|
+
if (e.ghost) return `<g data-end="finish" style="${cs(color)}"><circle class="dg-end-x" cx="${x}" cy="${y}" r="${e.r}"/><circle class="dg-end-xi" cx="${x}" cy="${y}" r="${end.inner}"/>${text2}</g>`;
|
|
3914
|
+
return `<g data-end="finish"><circle class="dg-end" cx="${x}" cy="${y}" r="${e.r}"/><circle class="dg-end-in" cx="${x}" cy="${y}" r="${end.inner}"/>${text2}</g>`;
|
|
3915
|
+
}
|
|
3092
3916
|
function lifeline(x, y1, y2) {
|
|
3093
3917
|
return `<line class="dg-ll" x1="${r1(x)}" y1="${r1(y1)}" x2="${r1(x)}" y2="${r1(y2)}"/>`;
|
|
3094
3918
|
}
|
|
3095
|
-
function edge(e, time, ctx) {
|
|
3919
|
+
function edge(e, time, ctx, past = false) {
|
|
3096
3920
|
const { m } = ctx;
|
|
3097
3921
|
const d = pathOf(e.points);
|
|
3098
3922
|
const head = arrowHead(e.points);
|
|
3099
3923
|
const { start: a, drawn: b, end } = time;
|
|
3100
|
-
const tail = [
|
|
3924
|
+
const tail = past ? [
|
|
3925
|
+
[end, { opacity: 1 }, EASE.inOut],
|
|
3926
|
+
[end + 0.4, { opacity: 0 }],
|
|
3927
|
+
[m.total, { opacity: 0 }]
|
|
3928
|
+
] : [
|
|
3101
3929
|
[end, { opacity: 1 }, EASE.inOut],
|
|
3102
3930
|
[end + 0.4, { opacity: 0.45 }],
|
|
3103
3931
|
[ctx.end + 0.3, { opacity: 0.45 }, EASE.inOut],
|
|
@@ -3124,15 +3952,19 @@ function edge(e, time, ctx) {
|
|
|
3124
3952
|
[end + 0.2, { opacity: 0, "stroke-dashoffset": run }],
|
|
3125
3953
|
[m.total, { opacity: 0, "stroke-dashoffset": run }]
|
|
3126
3954
|
]);
|
|
3955
|
+
const grey = past ? m.kf([[0, { opacity: 0 }], [end, { opacity: 0 }, EASE.inOut], [end + 0.4, { opacity: 1 }], [m.last, { opacity: 1 }, EASE.inOut], [m.total, { opacity: 0 }]]) : "";
|
|
3127
3956
|
return {
|
|
3128
|
-
base: `<path class="dg-e" d="${d}"/><path class="dg-eh" d="${head}"
|
|
3957
|
+
base: `<path class="dg-e" d="${d}"/><path class="dg-eh" d="${head}"/>${past ? `<path class="dg-e-past dg-a" d="${d}" style="${grey}"/><path class="dg-eh-past dg-a" d="${head}" style="${grey}"/>` : ""}`,
|
|
3129
3958
|
lit: `<g style="${cs(e.color)}"><path class="dg-e-on dg-a" pathLength="1" d="${d}" style="${line}"/><path class="dg-eh-on dg-a" d="${head}" style="${hk}"/><path class="dg-flow dg-a" d="${d}" style="${flow}"/></g>`
|
|
3130
3959
|
};
|
|
3131
3960
|
}
|
|
3132
3961
|
function label(l, time, ctx) {
|
|
3133
3962
|
const ja3 = l.family === "sans" ? " dg-capj" : "";
|
|
3134
3963
|
const { radius } = LOOK.label;
|
|
3135
|
-
|
|
3964
|
+
const x = r1(l.x + l.w / 2);
|
|
3965
|
+
const y = r1(l.y + l.h / 2 + LOOK.baseline.label);
|
|
3966
|
+
const past = time.after ? `<g class="dg-cap-past${l.family === "sans" ? " dg-cap-pastj" : ""} dg-a" style="${ctx.m.vis(time.after.start, time.after.end)}"><text x="${x}" y="${y}" text-anchor="middle">${esc(l.text)}</text></g>` : "";
|
|
3967
|
+
return `${past}<g class="dg-cap${ja3} dg-a" style="${cs(l.color)};${ctx.m.rise(time.start, time.end, true)}"><rect x="${r1(l.x)}" y="${r1(l.y)}" width="${r1(l.w)}" height="${l.h}" rx="${radius}"/><text x="${x}" y="${y}" text-anchor="middle">${esc(l.text)}</text></g>`;
|
|
3136
3968
|
}
|
|
3137
3969
|
function action(a, at2, until, ctx) {
|
|
3138
3970
|
return `<g class="dg-act dg-a" style="${cs(a.color)};${ctx.m.rise(at2, until, true)}"><rect x="${r1(a.x)}" y="${r1(a.y)}" width="${r1(a.w)}" height="${a.h}" rx="${LOOK.action.radius}"/><text x="${r1(a.x + a.w / 2)}" y="${r1(a.y + a.h / 2 + LOOK.baseline.action)}" text-anchor="middle">${esc(a.text)}</text></g>`;
|
|
@@ -3154,21 +3986,21 @@ function carrier(e, time, ctx) {
|
|
|
3154
3986
|
const n = LOOK.carrier.samples;
|
|
3155
3987
|
const length = pathLength(e.points);
|
|
3156
3988
|
const { depart: a, arrive: b, start: from, end: gone } = time;
|
|
3157
|
-
const
|
|
3989
|
+
const path2 = [];
|
|
3158
3990
|
for (let k = 0; k <= n; k++) {
|
|
3159
3991
|
const [x, y] = along(e.points, easeInOut(k / n) * length);
|
|
3160
|
-
|
|
3992
|
+
path2.push([a + (b - a) * k / n, x, y]);
|
|
3161
3993
|
}
|
|
3162
|
-
const first =
|
|
3163
|
-
const lastPoint =
|
|
3994
|
+
const first = path2[0];
|
|
3995
|
+
const lastPoint = path2[path2.length - 1];
|
|
3164
3996
|
const rest = e.settle ?? [lastPoint[1], lastPoint[2]];
|
|
3165
|
-
const pts = [[0, first[1], first[2]], ...
|
|
3997
|
+
const pts = [[0, first[1], first[2]], ...path2];
|
|
3166
3998
|
if (e.settle) pts.push([Math.min(b + 0.3, Math.max(gone, b + 0.01)), rest[0], rest[1]]);
|
|
3167
3999
|
pts.push([gone, rest[0], rest[1]], [m.total, rest[0], rest[1]]);
|
|
3168
4000
|
const fade = gone < m.last ? 0.05 : 0.18;
|
|
3169
4001
|
return `<g class="dg-a" style="${m.move(pts, m.blink(from + 0.02, gone, fade))}">${carrierShape(e, ctx.sh)}</g>`;
|
|
3170
4002
|
}
|
|
3171
|
-
function badge(b, ctx) {
|
|
4003
|
+
function badge(b, ctx, grey = false) {
|
|
3172
4004
|
const { m } = ctx;
|
|
3173
4005
|
const span = ctx.t.steps[b.step];
|
|
3174
4006
|
const a = span.start;
|
|
@@ -3194,9 +4026,9 @@ function badge(b, ctx) {
|
|
|
3194
4026
|
const y = r1(b.y);
|
|
3195
4027
|
const ty = r1(b.y + LOOK.baseline.badge);
|
|
3196
4028
|
const no = b.step + 1;
|
|
3197
|
-
return `<g class="dg-bd" data-step="${b.step}" style="${cs(b.color)}"><circle class="dg-bdr dg-popc dg-a" cx="${x}" cy="${y}" r="${rr}" style="${ring}"/><g class="dg-a" style="${past}"><circle class="dg-bdp" cx="${x}" cy="${y}" r="${rr}"/><text class="dg-bdpt" x="${x}" y="${ty}" text-anchor="middle">${no}</text></g><g class="dg-popc dg-a" style="${fill}"><circle class="dg-bdf" cx="${x}" cy="${y}" r="${r}"/><text class="dg-bdft" x="${x}" y="${ty}" text-anchor="middle">${no}</text></g></g>`;
|
|
4029
|
+
return `<g class="dg-bd" data-step="${b.step}" style="${cs(b.color)}"><circle class="dg-bdr dg-popc dg-a" cx="${x}" cy="${y}" r="${rr}" style="${ring}"/><g class="dg-a" style="${past}"><circle class="${grey ? "dg-bdp-g" : "dg-bdp"}" cx="${x}" cy="${y}" r="${rr}"/><text class="${grey ? "dg-bdpt-g" : "dg-bdpt"}" x="${x}" y="${ty}" text-anchor="middle">${no}</text></g><g class="dg-popc dg-a" style="${fill}"><circle class="dg-bdf" cx="${x}" cy="${y}" r="${r}"/><text class="dg-bdft" x="${x}" y="${ty}" text-anchor="middle">${no}</text></g></g>`;
|
|
3198
4030
|
}
|
|
3199
|
-
function strip(s, changes, ctx) {
|
|
4031
|
+
function strip(s, changes, ctx, now = false, arrivals = /* @__PURE__ */ new Map()) {
|
|
3200
4032
|
const { m, sh } = ctx;
|
|
3201
4033
|
const S2 = LOOK.strip;
|
|
3202
4034
|
const my = s.y + S2.h / 2;
|
|
@@ -3218,8 +4050,18 @@ function strip(s, changes, ctx) {
|
|
|
3218
4050
|
values.forEach((c, k) => {
|
|
3219
4051
|
const next = values[k + 1]?.at;
|
|
3220
4052
|
const value = c.value;
|
|
3221
|
-
const
|
|
3222
|
-
|
|
4053
|
+
const cls = hasWide(value) ? "dg-fvj" : "dg-fv";
|
|
4054
|
+
const textOf = (c2) => `<text class="${c2}" x="${r1(field.x)}" y="${r1(field.y + S2.valueY)}">${esc(value)}</text>`;
|
|
4055
|
+
const text2 = textOf(cls);
|
|
4056
|
+
if (!now) {
|
|
4057
|
+
const anim = next === void 0 ? m.rise(c.at) : m.rise(c.at, next - MOTION.untilFade);
|
|
4058
|
+
parts.push(`<g class="dg-a" style="${anim}">${text2}</g>`);
|
|
4059
|
+
return;
|
|
4060
|
+
}
|
|
4061
|
+
const until = Math.min(c.until, next ?? c.until);
|
|
4062
|
+
const dot = `<circle class="dg-fl-now" cx="${r1(field.x + textWidth(field.name, TYPE.fieldName) + S2.now.gap)}" cy="${r1(field.y + S2.nameY - TYPE.fieldName.size / 3)}" r="${S2.now.r}"/>`;
|
|
4063
|
+
parts.push(`<g class="dg-fv-now dg-a" data-step="${c.step}" style="${cs(c.color)};${m.rise(c.at, until - MOTION.untilFade)}">${textOf(`${cls} dg-fv-c`)}${dot}</g>`);
|
|
4064
|
+
if (next === void 0 || next > until) parts.push(`<g class="dg-a" style="${m.vis(until - MOTION.untilFade, next === void 0 ? m.last : next - MOTION.untilFade)}">${text2}</g>`);
|
|
3223
4065
|
});
|
|
3224
4066
|
tags.forEach((c, k) => {
|
|
3225
4067
|
const next = tags[k + 1]?.at;
|
|
@@ -3233,6 +4075,22 @@ function strip(s, changes, ctx) {
|
|
|
3233
4075
|
);
|
|
3234
4076
|
});
|
|
3235
4077
|
});
|
|
4078
|
+
if (s.trail) {
|
|
4079
|
+
const t = s.trail;
|
|
4080
|
+
const last = s.fields[s.fields.length - 1];
|
|
4081
|
+
if (last && last.y === t.y) {
|
|
4082
|
+
const sx = t.x - S2.fieldGap / 2;
|
|
4083
|
+
parts.push(`<line class="dg-sep" x1="${r1(sx)}" y1="${r1(t.y + S2.sepInset)}" x2="${r1(sx)}" y2="${r1(t.y + S2.h - S2.sepInset)}"/>`);
|
|
4084
|
+
}
|
|
4085
|
+
parts.push(`<text class="dg-fl" x="${r1(t.x)}" y="${r1(t.y + S2.nameY)}">${esc(t.title)}</text>`);
|
|
4086
|
+
const dy = t.y + S2.valueY - TYPE.fieldValue.size / 3;
|
|
4087
|
+
t.states.forEach((state, k) => {
|
|
4088
|
+
const cx = r1(t.x + S2.trail.r + k * S2.trail.step);
|
|
4089
|
+
const at2 = arrivals.get(state.box);
|
|
4090
|
+
const fill = at2 === void 0 ? "" : `<circle class="dg-tr-fill dg-a" cx="${cx}" cy="${r1(dy)}" r="${S2.trail.r}" style="${m.pop(at2)}"/>`;
|
|
4091
|
+
parts.push(`<g data-trail="${esc(state.box)}" style="${cs(state.color)}"><circle class="dg-tr-ring" cx="${cx}" cy="${r1(dy)}" r="${S2.trail.r}"/>${fill}</g>`);
|
|
4092
|
+
});
|
|
4093
|
+
}
|
|
3236
4094
|
return parts.join("");
|
|
3237
4095
|
}
|
|
3238
4096
|
|
|
@@ -3329,6 +4187,7 @@ var font = (t) => `font:${t.weight} ${t.size}px var(--${t.family})`;
|
|
|
3329
4187
|
var mix = (pct, base = "var(--surf)") => `color-mix(in srgb,var(--c) ${pct}%,${base})`;
|
|
3330
4188
|
var S = LOOK.stroke;
|
|
3331
4189
|
var X = LOOK.mix;
|
|
4190
|
+
var PAST = `color-mix(in srgb,var(--mute) ${X.past}%,var(--bg))`;
|
|
3332
4191
|
var PART_CSS = [
|
|
3333
4192
|
".dg{display:block;width:100%;height:auto;overflow:visible}",
|
|
3334
4193
|
".dg .dg-a{animation-duration:var(--T);animation-timing-function:linear;animation-iteration-count:infinite;animation-fill-mode:both;animation-delay:calc(var(--at,0) * -1s);animation-play-state:var(--play,running)}",
|
|
@@ -3353,15 +4212,21 @@ var PART_CSS = [
|
|
|
3353
4212
|
`.dg-e-on{fill:none;stroke:var(--c);stroke-width:${S.edgeOn};stroke-linecap:round;stroke-dasharray:1 2}`,
|
|
3354
4213
|
`.dg-eh-on{fill:none;stroke:var(--c);stroke-width:${S.edgeOn};stroke-linecap:round;stroke-linejoin:round}`,
|
|
3355
4214
|
`.dg-flow{fill:none;stroke:var(--surf);stroke-width:${S.flow};stroke-linecap:round;stroke-dasharray:1.5 ${LOOK.edge.flowDash}}`,
|
|
4215
|
+
`.dg-e-past{fill:none;stroke:${PAST};stroke-width:${S.edge};stroke-linecap:round}`,
|
|
4216
|
+
`.dg-eh-past{fill:none;stroke:${PAST};stroke-width:${S.arrow};stroke-linecap:round;stroke-linejoin:round}`,
|
|
3356
4217
|
".dg-bd{cursor:pointer}",
|
|
3357
4218
|
".dg-bdf{fill:var(--c)}",
|
|
3358
4219
|
`.dg-bdft{${font(TYPE.badge)};fill:var(--on-c)}`,
|
|
3359
4220
|
`.dg-bdr{fill:none;stroke:var(--c);stroke-width:${S.badgeRing}}`,
|
|
3360
4221
|
`.dg-bdp{fill:${mix(X.badgePast)};stroke:${mix(X.badgePastEdge, "transparent")};stroke-width:${S.hair}}`,
|
|
3361
4222
|
`.dg-bdpt{${font(TYPE.badge)};fill:var(--ct)}`,
|
|
4223
|
+
`.dg-bdp-g{fill:var(--surf);stroke:${PAST};stroke-width:${S.hair}}`,
|
|
4224
|
+
`.dg-bdpt-g{${font(TYPE.badge)};fill:var(--mute)}`,
|
|
3362
4225
|
`.dg-cap rect,.dg-act rect{fill:${mix(X.cap)};stroke:${mix(X.capEdge, "transparent")}}`,
|
|
3363
4226
|
`.dg-cap text{${font(TYPE.label)};fill:var(--ct)}`,
|
|
3364
4227
|
`.dg-capj text{${font(TYPE.labelJa)}}`,
|
|
4228
|
+
`.dg-cap-past text{${font(TYPE.label)};fill:var(--mute);fill-opacity:${LOOK.state.pastLabel}}`,
|
|
4229
|
+
`.dg-cap-pastj text{${font(TYPE.labelJa)}}`,
|
|
3365
4230
|
`.dg-act text{${font(TYPE.action)};fill:var(--ct)}`,
|
|
3366
4231
|
".dg-car{fill:var(--carry,var(--ink))}",
|
|
3367
4232
|
`.dg-car-t{${font(TYPE.carrier)};fill:var(--bg)}`,
|
|
@@ -3376,8 +4241,28 @@ var PART_CSS = [
|
|
|
3376
4241
|
`.dg-fl{${font(TYPE.fieldName)};fill:var(--mute)}`,
|
|
3377
4242
|
`.dg-fv{${font(TYPE.fieldValue)};fill:var(--ink)}`,
|
|
3378
4243
|
`.dg-fvj{${font(TYPE.fieldValueJa)};fill:var(--ink)}`,
|
|
4244
|
+
".dg-fv-c{fill:var(--ct)}",
|
|
4245
|
+
".dg-fl-now{fill:var(--c)}",
|
|
4246
|
+
`.dg-tr-ring{fill:none;stroke:var(--line);stroke-width:${S.trail}}`,
|
|
4247
|
+
".dg-tr-fill{fill:var(--c)}",
|
|
3379
4248
|
".dg-tg rect{fill:var(--c)}",
|
|
3380
4249
|
`.dg-tg text{${font(TYPE.tag)};fill:var(--on-c)}`,
|
|
4250
|
+
`.dg-side{fill:color-mix(in srgb,var(--c) ${X.side}%,var(--bg));stroke:${mix(X.sideEdge, "transparent")};stroke-dasharray:4 4}`,
|
|
4251
|
+
`.dg-side-t{${font(TYPE.regionName)};fill:var(--ct)}`,
|
|
4252
|
+
`.dg-side-n{${font(TYPE.regionNote)};fill:var(--mute)}`,
|
|
4253
|
+
`.dg-ghost{fill:var(--surf);stroke:${mix(X.ghostEdge, "transparent")};stroke-dasharray:4 3}`,
|
|
4254
|
+
`.dg-path{fill:none;stroke:${mix(X.path, "transparent")};stroke-width:${S.path};stroke-linecap:round;stroke-dasharray:0 ${LOOK.edge.ghostDash}}`,
|
|
4255
|
+
`.dg-path-h{fill:none;stroke:${mix(X.path, "transparent")};stroke-width:${S.arrow};stroke-linecap:round;stroke-linejoin:round}`,
|
|
4256
|
+
`.dg-path-t{${font(TYPE.label)};fill:var(--ct)}`,
|
|
4257
|
+
`.dg-path-tj{${font(TYPE.labelJa)}}`,
|
|
4258
|
+
".dg-start{fill:var(--ink)}",
|
|
4259
|
+
`.dg-end{fill:var(--bg);stroke:var(--ink);stroke-width:${S.end}}`,
|
|
4260
|
+
".dg-end-in{fill:var(--ink)}",
|
|
4261
|
+
`.dg-end-x{fill:var(--bg);stroke:${mix(X.path, "transparent")};stroke-width:${S.arrow};stroke-dasharray:2 2.5}`,
|
|
4262
|
+
`.dg-end-xi{fill:${mix(X.path, "transparent")}}`,
|
|
4263
|
+
`.dg-mark{${font(TYPE.regionNote)};fill:var(--mute)}`,
|
|
4264
|
+
`.dg-done{fill:var(--ink);stroke:var(--surf);stroke-width:${S.done}}`,
|
|
4265
|
+
`.dg-done-ck{fill:none;stroke:var(--surf);stroke-width:${S.glyph};stroke-linecap:round;stroke-linejoin:round}`,
|
|
3381
4266
|
".dg-vp-bg{fill:var(--bg)}",
|
|
3382
4267
|
".dg-vp-frame{fill:none;stroke:var(--hair)}",
|
|
3383
4268
|
".dg-hd-bg{fill:var(--bg)}",
|
|
@@ -3455,7 +4340,8 @@ function fieldChanges(diagram, timeline, layout) {
|
|
|
3455
4340
|
if (event?.type !== "strip") continue;
|
|
3456
4341
|
const color = layout.badges[time.step]?.color ?? "slate";
|
|
3457
4342
|
const list2 = out.get(event.field) ?? [];
|
|
3458
|
-
|
|
4343
|
+
const until = timeline.steps[time.step].end;
|
|
4344
|
+
list2.push({ at: time.at, color, step: time.step, until, ...event.value !== void 0 ? { value: event.value } : {}, ...event.tag !== void 0 ? { tag: event.tag } : {} });
|
|
3459
4345
|
out.set(event.field, list2);
|
|
3460
4346
|
}
|
|
3461
4347
|
return out;
|
|
@@ -3465,20 +4351,36 @@ function drawSvg(diagram, layout, timeline, palette, theme, follow) {
|
|
|
3465
4351
|
const m = new Motion(`dg${id}`, timeline.total, timeline.last);
|
|
3466
4352
|
const ctx = { m, t: timeline, sh: `filter="url(#dg-sh-${id})"`, end: timeline.steps[timeline.steps.length - 1].end };
|
|
3467
4353
|
const on = involved(diagram);
|
|
3468
|
-
const subs = subChanges(diagram, timeline, layout.kind
|
|
4354
|
+
const subs = subChanges(diagram, timeline, layout.kind !== "sequence");
|
|
3469
4355
|
const L = { band: [], base: [], lit: [], node: [], badge: [], top: [] };
|
|
3470
4356
|
for (const region of layout.regions) L.band.push(band(region));
|
|
3471
|
-
|
|
4357
|
+
const ghostColor = layout.boxes.find((b) => b.ghost)?.color ?? "slate";
|
|
4358
|
+
if (layout.side) L.band.push(side(layout.side, ghostColor));
|
|
4359
|
+
const boxColor = (id2, ghost) => layout.boxes.find((b) => b.id === id2 && (ghost === void 0 || b.ghost === ghost))?.color;
|
|
4360
|
+
for (const p of layout.paths) L.base.push(path(p, boxColor(p.to, true) ?? boxColor(p.from) ?? ghostColor));
|
|
4361
|
+
for (const e of layout.ends) L.node.push(endMark(e, ghostColor));
|
|
4362
|
+
const isState = layout.kind === "state";
|
|
4363
|
+
const arrivals = new Map((timeline.states ?? []).flatMap((s) => s.lit[0] ? [[s.box, s.lit[0].start]] : []));
|
|
4364
|
+
if (layout.strip) L.band.push(strip(layout.strip, fieldChanges(diagram, timeline, layout), ctx, isState, arrivals));
|
|
3472
4365
|
for (const line of layout.lifelines) L.base.push(lifeline(line.x, line.y1, line.y2));
|
|
3473
4366
|
for (const e of layout.edges) {
|
|
3474
4367
|
const time = timeline.edges.find((t) => t.step === e.step && t.event === e.event);
|
|
3475
4368
|
if (!time) continue;
|
|
3476
|
-
const drawn = edge(e, time, ctx);
|
|
4369
|
+
const drawn = edge(e, time, ctx, isState);
|
|
3477
4370
|
L.base.push(drawn.base);
|
|
3478
4371
|
L.lit.push(drawn.lit);
|
|
3479
4372
|
}
|
|
3480
|
-
|
|
3481
|
-
for (const
|
|
4373
|
+
const states = new Map((timeline.states ?? []).map((s) => [s.box, s]));
|
|
4374
|
+
for (const box of layout.boxes) {
|
|
4375
|
+
if (box.ghost) {
|
|
4376
|
+
L.node.push(ghostCard(box));
|
|
4377
|
+
continue;
|
|
4378
|
+
}
|
|
4379
|
+
const state = states.get(box.id);
|
|
4380
|
+
L.node.push(card(box, ctx, on.get(box.id) ?? [], subs.get(box.id) ?? [], isState ? state?.lit ?? [] : void 0));
|
|
4381
|
+
if (state?.done !== void 0) L.node.push(doneMark(box, state.done, ctx));
|
|
4382
|
+
}
|
|
4383
|
+
for (const b of layout.badges) L.badge.push(badge(b, ctx, isState));
|
|
3482
4384
|
for (const l of layout.labels) {
|
|
3483
4385
|
const time = timeline.labels.find((t) => t.step === l.step && t.event === l.event);
|
|
3484
4386
|
if (time) L.top.push(label(l, time, ctx));
|
|
@@ -3614,7 +4516,7 @@ function renderDiagram(input, options = {}) {
|
|
|
3614
4516
|
const diagram = read2.diagram;
|
|
3615
4517
|
const palette = resolvePalette(options.palette);
|
|
3616
4518
|
const theme = options.theme === "dark" ? "dark" : "light";
|
|
3617
|
-
const layout = diagram.kind === "sequence" ? layoutSequence(diagram) : layoutArchitecture(diagram);
|
|
4519
|
+
const layout = diagram.kind === "sequence" ? layoutSequence(diagram) : diagram.kind === "state" ? layoutState(diagram, lang) : layoutArchitecture(diagram);
|
|
3618
4520
|
const timeline = buildTimeline(diagram);
|
|
3619
4521
|
return {
|
|
3620
4522
|
svg: drawSvg(diagram, layout, timeline, palette, theme),
|
|
@@ -3643,7 +4545,7 @@ var pad = (n) => String(n).padStart(2, "0");
|
|
|
3643
4545
|
var stepNo = (step, count) => `${pad(step + 1)}/${pad(count)}`;
|
|
3644
4546
|
var require_ = module$1.createRequire(importMetaUrl);
|
|
3645
4547
|
var SCRIPTS = {
|
|
3646
|
-
"/mediabunny.js": path.join(path.dirname(require_.resolve("mediabunny")), "mediabunny.min.mjs"),
|
|
4548
|
+
"/mediabunny.js": path$1.join(path$1.dirname(require_.resolve("mediabunny")), "mediabunny.min.mjs"),
|
|
3647
4549
|
"/gifenc.js": require_.resolve("gifenc/dist/gifenc.esm.js")
|
|
3648
4550
|
};
|
|
3649
4551
|
var SCALE = 2;
|
|
@@ -3685,9 +4587,9 @@ async function stage(browser, svg, fontCss, body) {
|
|
|
3685
4587
|
const paused = svg.replace(/^<svg\b/, '<svg style="--play:paused;--at:0"');
|
|
3686
4588
|
const html = `<!doctype html><html><head><meta charset="utf-8"><style>${fontCss}html,body{margin:0}body{${body}}svg{display:block}</style><script type="module">import * as mb from "/mediabunny.js";import * as gif from "/gifenc.js";window.__tools={mb,gif};</script></head><body>${paused}</body></html>`;
|
|
3687
4589
|
await page.route("http://localhost/**", async (route) => {
|
|
3688
|
-
const
|
|
3689
|
-
if (
|
|
3690
|
-
const script = SCRIPTS[
|
|
4590
|
+
const path2 = new URL(route.request().url()).pathname;
|
|
4591
|
+
if (path2 === "/") return route.fulfill({ contentType: "text/html; charset=utf-8", body: html });
|
|
4592
|
+
const script = SCRIPTS[path2];
|
|
3691
4593
|
return script ? route.fulfill({ contentType: "text/javascript", body: fs.readFileSync(script) }) : route.fulfill({ status: 404 });
|
|
3692
4594
|
});
|
|
3693
4595
|
await page.goto("http://localhost/");
|
|
@@ -3864,8 +4766,8 @@ function charsOf(texts) {
|
|
|
3864
4766
|
async function fontFaces(chars) {
|
|
3865
4767
|
const faces = await Promise.all(
|
|
3866
4768
|
PACKAGES.flatMap(({ family, name }) => {
|
|
3867
|
-
const base = path.dirname(require_2.resolve(`@fontsource-variable/${name}/unicode.json`));
|
|
3868
|
-
const table = JSON.parse(fs.readFileSync(path.join(base, "unicode.json"), "utf8"));
|
|
4769
|
+
const base = path$1.dirname(require_2.resolve(`@fontsource-variable/${name}/unicode.json`));
|
|
4770
|
+
const table = JSON.parse(fs.readFileSync(path$1.join(base, "unicode.json"), "utf8"));
|
|
3869
4771
|
return Object.entries(table).map(async ([key, list2]) => {
|
|
3870
4772
|
const span = ranges(list2);
|
|
3871
4773
|
const own = chars.filter((char) => {
|
|
@@ -3873,7 +4775,7 @@ async function fontFaces(chars) {
|
|
|
3873
4775
|
return span.some(([from, to]) => code >= from && code <= to);
|
|
3874
4776
|
});
|
|
3875
4777
|
if (!own.length) return "";
|
|
3876
|
-
const file = path.join(base, "files", `${name}-${key.replace(/[[\]]/g, "")}-wght-normal.woff2`);
|
|
4778
|
+
const file = path$1.join(base, "files", `${name}-${key.replace(/[[\]]/g, "")}-wght-normal.woff2`);
|
|
3877
4779
|
const woff2 = await subsetFont(await promises.readFile(file), own.join(""), { targetFormat: "woff2", variationAxes: { wght: WEIGHT } });
|
|
3878
4780
|
const unicode = own.map((char) => hex(char.codePointAt(0) ?? 0)).join(",");
|
|
3879
4781
|
return `@font-face{font-family:"${family}";font-style:normal;font-display:block;font-weight:${WEIGHT.min} ${WEIGHT.max};src:url(data:font/woff2;base64,${woff2.toString("base64")}) format("woff2");unicode-range:${unicode}}`;
|
|
@@ -3965,9 +4867,9 @@ function writeOutputs(outDir, name, outputs) {
|
|
|
3965
4867
|
const files = {};
|
|
3966
4868
|
try {
|
|
3967
4869
|
for (const [format, data] of outputs) {
|
|
3968
|
-
const
|
|
3969
|
-
fs.writeFileSync(
|
|
3970
|
-
files[format] =
|
|
4870
|
+
const path2 = path$1.join(outDir, `${name}.${format}`);
|
|
4871
|
+
fs.writeFileSync(path2, data);
|
|
4872
|
+
files[format] = path2;
|
|
3971
4873
|
}
|
|
3972
4874
|
} catch (error) {
|
|
3973
4875
|
if (created !== void 0) fs.rmSync(created, { recursive: true, force: true });
|
|
@@ -3976,30 +4878,6 @@ function writeOutputs(outDir, name, outputs) {
|
|
|
3976
4878
|
return files;
|
|
3977
4879
|
}
|
|
3978
4880
|
|
|
3979
|
-
// src/words.ts
|
|
3980
|
-
var keys = (table) => Object.keys(table);
|
|
3981
|
-
var KINDS = keys({ sequence: true, architecture: true });
|
|
3982
|
-
var HEADS = ["group", "end", "box", "strip", "step", "say", "code", "act", "note", "set"];
|
|
3983
|
-
var AS = "as";
|
|
3984
|
-
var ATTRS = {
|
|
3985
|
-
diagram: ["view"],
|
|
3986
|
-
group: ["note", "color", "icon"],
|
|
3987
|
-
box: ["note", "color", "icon"],
|
|
3988
|
-
edge: ["carry", "tag", "side"],
|
|
3989
|
-
set: ["tag"]
|
|
3990
|
-
};
|
|
3991
|
-
var CARRIES = keys({ coin: true, none: true });
|
|
3992
|
-
var VIEWS = keys({ fixed: true, follow: true });
|
|
3993
|
-
var SIDES = keys({ above: true, below: true, left: true, right: true });
|
|
3994
|
-
var OLD_HEADS = {
|
|
3995
|
-
\u6642\u7CFB\u5217\u56F3: "sequence",
|
|
3996
|
-
\u69CB\u6210\u56F3: "architecture",
|
|
3997
|
-
\u533A\u753B: "group",
|
|
3998
|
-
\u898B\u305B\u65B9: "view",
|
|
3999
|
-
region: "group",
|
|
4000
|
-
view: "view"
|
|
4001
|
-
};
|
|
4002
|
-
|
|
4003
4881
|
// src/messages.ts
|
|
4004
4882
|
var list = (words) => words.join(" / ");
|
|
4005
4883
|
var ja2 = () => {
|
|
@@ -4064,7 +4942,11 @@ var ja2 = () => {
|
|
|
4064
4942
|
badView: `view \u306F ${list(VIEWS)} \u306E\u3069\u308C\u304B`,
|
|
4065
4943
|
badCarry: `carry \u306F ${list(CARRIES)} \u306E\u3069\u308C\u304B\u3002\u672D\u306F tag: <\u5024> \u3067\u66F8\u304F`,
|
|
4066
4944
|
badSide: `side \u306F ${list(SIDES)} \u306E\u3069\u308C\u304B`,
|
|
4067
|
-
carryTwice: "\u904B\u3076\u7269\u306F 1 \u672C\u306E\u7DDA\u306B 1 \u3064\u307E\u3067\u3002carry \u3068 tag \u306F\u4E00\u7DD2\u306B\u66F8\u304B\u306A\u3044"
|
|
4945
|
+
carryTwice: "\u904B\u3076\u7269\u306F 1 \u672C\u306E\u7DDA\u306B 1 \u3064\u307E\u3067\u3002carry \u3068 tag \u306F\u4E00\u7DD2\u306B\u66F8\u304B\u306A\u3044",
|
|
4946
|
+
reservedId: (id) => `${id} \u306F\u72B6\u614B\u9077\u79FB\u56F3\u306E\u59CB\u307E\u308A\u3068\u7D42\u308F\u308A\u306E\u5370\u306E\u540D\u524D\u3067\u3001\u7BB1\u306E\u540D\u672D\u306B\u4F7F\u3048\u306A\u3044`,
|
|
4947
|
+
intoStart: "start \u3078\u5165\u308B\u7DDA\u306F\u66F8\u3051\u306A\u3044\u3002start \u306F\u59CB\u307E\u308A\u306E\u5370\u3067\u3001\u7DDA\u306F start \u304B\u3089\u51FA\u308B",
|
|
4948
|
+
outOfFinish: "finish \u304B\u3089\u51FA\u308B\u7DDA\u306F\u66F8\u3051\u306A\u3044\u3002finish \u306F\u7D42\u308F\u308A\u306E\u5370\u3067\u3001\u7DDA\u306F finish \u3078\u5165\u308B",
|
|
4949
|
+
pathNoAttrs: "\u6700\u521D\u306E step \u3088\u308A\u524D\u306E\u7DDA\u306F\u4ECA\u56DE\u306F\u901A\u3089\u306A\u3044\u9053\u306A\u306E\u3067\u3001\u5C5E\u6027 (carry \u3068 tag \u3068 side) \u3092\u66F8\u3051\u306A\u3044"
|
|
4068
4950
|
};
|
|
4069
4951
|
};
|
|
4070
4952
|
var en2 = () => {
|
|
@@ -4129,7 +5011,11 @@ var en2 = () => {
|
|
|
4129
5011
|
badView: `view is one of ${list(VIEWS)}`,
|
|
4130
5012
|
badCarry: `carry is one of ${list(CARRIES)}. Write a tag as tag: <value>`,
|
|
4131
5013
|
badSide: `side is one of ${list(SIDES)}`,
|
|
4132
|
-
carryTwice: "A line carries one thing. Do not write carry and tag together"
|
|
5014
|
+
carryTwice: "A line carries one thing. Do not write carry and tag together",
|
|
5015
|
+
reservedId: (id) => `${id} names the start or end mark of a state diagram and cannot be a box id`,
|
|
5016
|
+
intoStart: "A line cannot go into start. start is the start mark, and lines leave it",
|
|
5017
|
+
outOfFinish: "A line cannot leave finish. finish is the end mark, and lines go into it",
|
|
5018
|
+
pathNoAttrs: "A line before the first step is a path not taken, so it takes no attributes (carry, tag, side)"
|
|
4133
5019
|
};
|
|
4134
5020
|
};
|
|
4135
5021
|
var MESSAGES = { ja: ja2(), en: en2() };
|
|
@@ -4307,8 +5193,10 @@ function parseLines(lines, m) {
|
|
|
4307
5193
|
const shown = titled.rest < head.text.length ? readAttrs(head, titled.rest, ATTRS.diagram, m).get("view") : void 0;
|
|
4308
5194
|
if (shown && !isOneOf(VIEWS, shown.value)) throw fail(head, shown.at, m.badView);
|
|
4309
5195
|
const view = shown?.value;
|
|
5196
|
+
const isState = kind === "state";
|
|
4310
5197
|
const regions = [];
|
|
4311
5198
|
const boxes = [];
|
|
5199
|
+
const paths = [];
|
|
4312
5200
|
const ids = /* @__PURE__ */ new Set();
|
|
4313
5201
|
let strip2;
|
|
4314
5202
|
const steps = [];
|
|
@@ -4322,6 +5210,14 @@ function parseLines(lines, m) {
|
|
|
4322
5210
|
if (!boxes.some((box) => box.id === id)) throw fail(source, at2, m.undeclaredBox(id));
|
|
4323
5211
|
return id;
|
|
4324
5212
|
};
|
|
5213
|
+
const endAt = (source, id, at2, side2) => {
|
|
5214
|
+
if (!isState || !isOneOf(STATE_ENDS, id)) return boxAt(source, id, at2);
|
|
5215
|
+
if (id === "start" !== (side2 === "from")) throw fail(source, at2, id === "start" ? m.intoStart : m.outOfFinish);
|
|
5216
|
+
return id;
|
|
5217
|
+
};
|
|
5218
|
+
const notReserved = (source, id, at2) => {
|
|
5219
|
+
if (isState && isOneOf(STATE_ENDS, id)) throw fail(source, at2, m.reservedId(id));
|
|
5220
|
+
};
|
|
4325
5221
|
const inStep = (source) => {
|
|
4326
5222
|
if (!building) throw fail(source, 0, m.stepLineBeforeStep);
|
|
4327
5223
|
return building;
|
|
@@ -4346,7 +5242,8 @@ function parseLines(lines, m) {
|
|
|
4346
5242
|
const text2 = source.text;
|
|
4347
5243
|
const edge2 = EDGE.exec(text2);
|
|
4348
5244
|
if (edge2) {
|
|
4349
|
-
|
|
5245
|
+
if (isState && !building) paths.push(readPath(source, edge2));
|
|
5246
|
+
else inStep(source).events.push(readEdge(source, edge2));
|
|
4350
5247
|
continue;
|
|
4351
5248
|
}
|
|
4352
5249
|
const word = text2.split(/\s/u)[0] ?? "";
|
|
@@ -4418,7 +5315,8 @@ function parseLines(lines, m) {
|
|
|
4418
5315
|
boxes,
|
|
4419
5316
|
...strip2 ? { strip: strip2 } : {},
|
|
4420
5317
|
steps,
|
|
4421
|
-
...kind === "sequence" ? { sequence: { lifelines: boxes.map((box) => box.id) } } : {}
|
|
5318
|
+
...kind === "sequence" ? { sequence: { lifelines: boxes.map((box) => box.id) } } : {},
|
|
5319
|
+
...paths.length > 0 ? { state: { paths } } : {}
|
|
4422
5320
|
};
|
|
4423
5321
|
function readGroup(source) {
|
|
4424
5322
|
beforeSteps(source);
|
|
@@ -4427,6 +5325,7 @@ function parseLines(lines, m) {
|
|
|
4427
5325
|
if (regions.some((region) => region.id === declared.id)) {
|
|
4428
5326
|
if (declared.name !== void 0 || declared.attrs.size > 0) throw fail(source, 0, m.regionReopened(declared.id));
|
|
4429
5327
|
} else {
|
|
5328
|
+
notReserved(source, declared.id, declared.idAt);
|
|
4430
5329
|
declare(source, declared.id, declared.idAt);
|
|
4431
5330
|
regions.push({ id: declared.id, name: declared.name ?? declared.id, ...lookOf(source, declared.attrs, m) });
|
|
4432
5331
|
}
|
|
@@ -4435,6 +5334,7 @@ function parseLines(lines, m) {
|
|
|
4435
5334
|
function readBox(source) {
|
|
4436
5335
|
beforeSteps(source);
|
|
4437
5336
|
const declared = readDeclared(source, "box", ATTRS.box, m);
|
|
5337
|
+
notReserved(source, declared.id, declared.idAt);
|
|
4438
5338
|
declare(source, declared.id, declared.idAt);
|
|
4439
5339
|
const { note, ...look } = lookOf(source, declared.attrs, m);
|
|
4440
5340
|
boxes.push({
|
|
@@ -4492,26 +5392,32 @@ function parseLines(lines, m) {
|
|
|
4492
5392
|
if (!found || idAt === void 0 || (found[2] ?? "") === "") throw fail(source, 0, shape);
|
|
4493
5393
|
return { box: boxAt(source, found[1] ?? "", idAt), text: found[2] ?? "" };
|
|
4494
5394
|
}
|
|
5395
|
+
function readLine(source, edge2) {
|
|
5396
|
+
const text2 = source.text;
|
|
5397
|
+
const from = endAt(source, edge2[1] ?? "", edge2.indices?.[1]?.[0] ?? 0, "from");
|
|
5398
|
+
const to = endAt(source, edge2[2] ?? "", edge2.indices?.[2]?.[0] ?? 0, "to");
|
|
5399
|
+
const at2 = skipSpaces(text2, edge2[0].length);
|
|
5400
|
+
if (text2[at2] !== ":") return { from, to, at: at2 };
|
|
5401
|
+
const named = readName(source, at2 + 1, m);
|
|
5402
|
+
if (named.value === "") throw fail(source, at2, m.emptyLabel);
|
|
5403
|
+
return { from, to, label: named.value, at: named.rest };
|
|
5404
|
+
}
|
|
5405
|
+
function readPath(source, edge2) {
|
|
5406
|
+
const { from, to, label: label2, at: at2 } = readLine(source, edge2);
|
|
5407
|
+
if (at2 < source.text.length) throw fail(source, at2, source.text[at2] === "[" ? m.pathNoAttrs : m.edgeShape);
|
|
5408
|
+
return { from, to, ...label2 !== void 0 ? { label: label2 } : {} };
|
|
5409
|
+
}
|
|
4495
5410
|
function readEdge(source, edge2) {
|
|
4496
5411
|
const text2 = source.text;
|
|
4497
|
-
const from
|
|
4498
|
-
const to = boxAt(source, edge2[2] ?? "", edge2.indices?.[2]?.[0] ?? 0);
|
|
4499
|
-
let at2 = skipSpaces(text2, edge2[0].length);
|
|
4500
|
-
let label2;
|
|
4501
|
-
if (text2[at2] === ":") {
|
|
4502
|
-
const named = readName(source, at2 + 1, m);
|
|
4503
|
-
if (named.value === "") throw fail(source, at2, m.emptyLabel);
|
|
4504
|
-
label2 = named.value;
|
|
4505
|
-
at2 = named.rest;
|
|
4506
|
-
}
|
|
5412
|
+
const { from, to, label: label2, at: at2 } = readLine(source, edge2);
|
|
4507
5413
|
if (at2 < text2.length && text2[at2] !== "[") throw fail(source, at2, m.edgeShape);
|
|
4508
5414
|
const attrs = at2 < text2.length ? readAttrs(source, at2, ATTRS.edge, m) : /* @__PURE__ */ new Map();
|
|
4509
5415
|
const tag = attrs.get("tag");
|
|
4510
5416
|
const carried = attrs.get("carry");
|
|
4511
5417
|
if (tag && carried) throw fail(source, Math.max(tag.at, carried.at), m.carryTwice);
|
|
4512
5418
|
if (carried && !isOneOf(CARRIES, carried.value)) throw fail(source, carried.at, m.badCarry);
|
|
4513
|
-
const
|
|
4514
|
-
if (
|
|
5419
|
+
const side2 = attrs.get("side");
|
|
5420
|
+
if (side2 && !isOneOf(SIDES, side2.value)) throw fail(source, side2.at, m.badSide);
|
|
4515
5421
|
let carry = { kind: "envelope" };
|
|
4516
5422
|
if (tag) carry = { kind: "tag", text: tag.value };
|
|
4517
5423
|
else if (carried) carry = carried.value === "coin" ? { kind: "coin" } : { kind: "none" };
|
|
@@ -4521,7 +5427,7 @@ function parseLines(lines, m) {
|
|
|
4521
5427
|
to,
|
|
4522
5428
|
...label2 !== void 0 ? { label: label2 } : {},
|
|
4523
5429
|
carry,
|
|
4524
|
-
...
|
|
5430
|
+
...side2 ? { labelSide: side2.value } : {}
|
|
4525
5431
|
};
|
|
4526
5432
|
}
|
|
4527
5433
|
function readSet(source) {
|
|
@@ -4597,10 +5503,10 @@ var CLI_TEXT = {
|
|
|
4597
5503
|
unknownOption: (name) => `\u77E5\u3089\u306A\u3044\u8A2D\u5B9A: ${name}`,
|
|
4598
5504
|
missingValue: (name) => `\u8A2D\u5B9A\u306B\u5024\u304C\u7121\u3044: ${name}`,
|
|
4599
5505
|
extraFiles: (extra) => `\u56F3\u306E file \u306F 1 \u3064\u3060\u3051\u6E21\u3059\u3002\u4F59\u5206\u306A\u5F15\u6570: ${extra.join(" ")}`,
|
|
4600
|
-
noFile: (
|
|
4601
|
-
unreadable: (
|
|
4602
|
-
badJson: (
|
|
4603
|
-
cannotWrite: (
|
|
5506
|
+
noFile: (path2) => `\u56F3\u306E file \u304C\u7121\u3044: ${path2}`,
|
|
5507
|
+
unreadable: (path2, detail2) => `\u56F3\u306E file \u3092\u8AAD\u3081\u306A\u3044: ${path2} (${detail2})`,
|
|
5508
|
+
badJson: (path2, detail2) => `JSON \u3068\u3057\u3066\u8AAD\u3081\u306A\u3044: ${path2} (${detail2})`,
|
|
5509
|
+
cannotWrite: (path2, detail2) => `\u66F8\u304D\u51FA\u305B\u306A\u3044: ${path2} (${detail2})`,
|
|
4604
5510
|
badValue: (option, value, allowed) => `\u4F7F\u3048\u306A\u3044\u5024: ${option} ${value} (${allowed})`,
|
|
4605
5511
|
allowed: { lang: "ja \u304B en", theme: "light \u304B dark", positive: "0 \u3088\u308A\u5927\u304D\u3044\u6570", format: `${FORMATS.join(" / ")} \u3092 , \u3067\u533A\u5207\u308B` }
|
|
4606
5512
|
},
|
|
@@ -4619,10 +5525,10 @@ var CLI_TEXT = {
|
|
|
4619
5525
|
unknownOption: (name) => `Unknown option: ${name}`,
|
|
4620
5526
|
missingValue: (name) => `Option needs a value: ${name}`,
|
|
4621
5527
|
extraFiles: (extra) => `Pass only one diagram file. Extra arguments: ${extra.join(" ")}`,
|
|
4622
|
-
noFile: (
|
|
4623
|
-
unreadable: (
|
|
4624
|
-
badJson: (
|
|
4625
|
-
cannotWrite: (
|
|
5528
|
+
noFile: (path2) => `No such diagram file: ${path2}`,
|
|
5529
|
+
unreadable: (path2, detail2) => `Cannot read the diagram file: ${path2} (${detail2})`,
|
|
5530
|
+
badJson: (path2, detail2) => `Cannot read as JSON: ${path2} (${detail2})`,
|
|
5531
|
+
cannotWrite: (path2, detail2) => `Cannot write: ${path2} (${detail2})`,
|
|
4626
5532
|
badValue: (option, value, allowed) => `Invalid value: ${option} ${value} (${allowed})`,
|
|
4627
5533
|
allowed: { lang: "ja or en", theme: "light or dark", positive: "a number above 0", format: `${FORMATS.join(" / ")} separated by ,` }
|
|
4628
5534
|
}
|
|
@@ -4672,7 +5578,7 @@ function read(file, text2, lang) {
|
|
|
4672
5578
|
const missing = error instanceof Error && "code" in error && error.code === "ENOENT";
|
|
4673
5579
|
throw new Error(missing ? text2.noFile(file) : text2.unreadable(file, detail(error)));
|
|
4674
5580
|
}
|
|
4675
|
-
if (path.extname(file) !== ".dragon") {
|
|
5581
|
+
if (path$1.extname(file) !== ".dragon") {
|
|
4676
5582
|
try {
|
|
4677
5583
|
return JSON.parse(source);
|
|
4678
5584
|
} catch (error) {
|
|
@@ -4722,8 +5628,8 @@ ${early.usage}`);
|
|
|
4722
5628
|
let result;
|
|
4723
5629
|
try {
|
|
4724
5630
|
result = await exportDiagram(diagram, {
|
|
4725
|
-
outDir: path.resolve(values.out ?? "."),
|
|
4726
|
-
name: path.basename(file, path.extname(file)),
|
|
5631
|
+
outDir: path$1.resolve(values.out ?? "."),
|
|
5632
|
+
name: path$1.basename(file, path$1.extname(file)),
|
|
4727
5633
|
...values.format ? { formats: values.format.split(",") } : {},
|
|
4728
5634
|
...width === void 0 ? {} : { width },
|
|
4729
5635
|
...values.palette ? { palette: values.palette } : {},
|
|
@@ -4733,11 +5639,11 @@ ${early.usage}`);
|
|
|
4733
5639
|
...gifFps === void 0 ? {} : { gifFps }
|
|
4734
5640
|
});
|
|
4735
5641
|
} catch (error) {
|
|
4736
|
-
const
|
|
4737
|
-
if (
|
|
5642
|
+
const path2 = failedPath(error);
|
|
5643
|
+
if (path2 !== void 0) throw new Error(CLI_TEXT[lang ?? "ja"].cannotWrite(path2, detail(error)));
|
|
4738
5644
|
throw error instanceof Error ? error : new Error(String(error));
|
|
4739
5645
|
}
|
|
4740
|
-
for (const
|
|
5646
|
+
for (const path2 of Object.values(result.files)) console.log(path2);
|
|
4741
5647
|
return 0;
|
|
4742
5648
|
}
|
|
4743
5649
|
main(process.argv.slice(2)).then(
|