@cardenelabs/dragon 0.43.0 → 0.44.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/dist/cli.cjs +2337 -627
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +2337 -627
- package/dist/cli.js.map +1 -1
- package/dist/export.cjs +2193 -619
- 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 +2193 -619
- package/dist/export.js.map +1 -1
- package/dist/index.cjs +2377 -644
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +55 -3
- package/dist/index.d.ts +55 -3
- package/dist/index.js +2377 -644
- package/dist/index.js.map +1 -1
- package/dist/{ink-B6s_SMXG.d.cts → ink-DeDtzaTL.d.cts} +27 -3
- package/dist/{ink-B6s_SMXG.d.ts → ink-DeDtzaTL.d.ts} +27 -3
- package/dist/node.cjs +1932 -680
- package/dist/node.cjs.map +1 -1
- package/dist/node.js +1932 -680
- package/dist/node.js.map +1 -1
- package/dist/player.global.js +3 -3
- package/package.json +1 -1
- package/src/field-messages.ts +6 -0
- package/src/index.ts +4 -0
- package/src/layout/lineup.ts +219 -0
- package/src/look/values.ts +31 -2
- package/src/messages.ts +54 -0
- package/src/parser.ts +123 -1
- package/src/printer.ts +30 -1
- package/src/render/lineup.ts +184 -0
- package/src/render/parts.ts +16 -7
- package/src/render/svg.ts +34 -6
- package/src/render/tree.ts +3 -2
- package/src/schema.ts +52 -4
- package/src/schemas/diagram.schema.json +145 -22
- package/src/schemas/validate-diagram.js +1 -1
- package/src/timeline.ts +14 -0
- package/src/words.ts +15 -2
package/src/printer.ts
CHANGED
|
@@ -14,9 +14,10 @@
|
|
|
14
14
|
* 時間軸の図 (#3165) は、目盛りと区切りと印の列と節目と拡大の範囲の行を箱より前に書き、物差しの欄の後ろに `[meter: <割合>]` を書く。
|
|
15
15
|
* 時間軸の図の `note` は属性を持てるので、`[` を含む字を `"` で囲む。
|
|
16
16
|
* 木の図 (#3233) の葉と親は、段の中に `leaf` と `node … of …` の行で書く。
|
|
17
|
+
* 列の図 (#3239) のチップは箱の後ろに `item` の行で書き、色が同じで字を持たないチップが続く所は 1 行に並べる。
|
|
17
18
|
* 段の出典 (#3199) は `say` と `code` の後ろ、段の中で起きることより前に、JSON の並びのまま 1 つずつ `source` の行に書く。
|
|
18
19
|
*/
|
|
19
|
-
import type { Box, Diagram, DiagramEvent, Region, TimeSpec } from "./schema";
|
|
20
|
+
import type { Box, Diagram, DiagramEvent, LineupItem, Region, TimeSpec } from "./schema";
|
|
20
21
|
import { AT, COPY, FROM, MERGE, NOW, OF, ON } from "./words";
|
|
21
22
|
|
|
22
23
|
const quote = (text: string): string => `"${text.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
@@ -94,9 +95,36 @@ function event(e: DiagramEvent, kind: Diagram["kind"]): string {
|
|
|
94
95
|
return `leaf ${e.id}${attrs([["hash", e.hash]])}`;
|
|
95
96
|
case "node":
|
|
96
97
|
return `node ${e.id} ${OF} ${e.children.join(", ")}${attrs([["hash", e.hash]])}`;
|
|
98
|
+
case "line":
|
|
99
|
+
return `line ${e.box}: ${e.items.join(", ")}`;
|
|
100
|
+
case "seal":
|
|
101
|
+
case "open":
|
|
102
|
+
case "pick":
|
|
103
|
+
return `${e.type} ${e.box}`;
|
|
104
|
+
case "stamp":
|
|
105
|
+
return `stamp ${e.box}: ${name(e.text)}`;
|
|
97
106
|
}
|
|
98
107
|
}
|
|
99
108
|
|
|
109
|
+
/** 列の図のチップの宣言の行。色が同じで字を持たないチップが続く所は 1 行に並べる */
|
|
110
|
+
function itemLines(items: LineupItem[]): string {
|
|
111
|
+
const rows: LineupItem[][] = [];
|
|
112
|
+
for (const item of items) {
|
|
113
|
+
const row = rows.at(-1);
|
|
114
|
+
if (row && item.label === undefined && row[0]?.label === undefined && row[0]?.color === item.color) row.push(item);
|
|
115
|
+
else rows.push([item]);
|
|
116
|
+
}
|
|
117
|
+
return rows
|
|
118
|
+
.map(
|
|
119
|
+
(row) =>
|
|
120
|
+
`item ${row.map((item) => item.id).join(", ")}${attrs([
|
|
121
|
+
["color", row[0]?.color],
|
|
122
|
+
["label", row[0]?.label],
|
|
123
|
+
])}`,
|
|
124
|
+
)
|
|
125
|
+
.join("\n");
|
|
126
|
+
}
|
|
127
|
+
|
|
100
128
|
/** 時間軸の図の目盛りと区切りと印の列と節目と拡大の範囲の宣言の塊 */
|
|
101
129
|
function timeBlocks(time: TimeSpec): string[] {
|
|
102
130
|
const head = [
|
|
@@ -155,6 +183,7 @@ export function printNotation(diagram: Diagram): string {
|
|
|
155
183
|
...(branches.length > 0 ? [branches.join("\n")] : []),
|
|
156
184
|
...(diagram.time ? timeBlocks(diagram.time) : []),
|
|
157
185
|
...declarations(diagram),
|
|
186
|
+
...(diagram.lineup && diagram.lineup.items.length > 0 ? [itemLines(diagram.lineup.items)] : []),
|
|
158
187
|
];
|
|
159
188
|
if (diagram.strip) {
|
|
160
189
|
const meters = new Map((diagram.strip.meters ?? []).map((m) => [m.field, m.line]));
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 列の図 (#3239) を描く部品。見た目の元は step 2 で本人が選んだ見本の「列の図」。
|
|
3
|
+
*
|
|
4
|
+
* 列の地と字は下の層に、チップと封と札は上の層に描く。チップが別の列へ滑る時に、途中の列の地の下へ隠れないため。
|
|
5
|
+
* チップは席に居る間ごとに 1 つの部品で、座った時に滑り始める所から席へ滑るか、弾んで現れる。席を離れる時は、同じ段で別の席へ滑るなら滑り始める時に一瞬で替わり、
|
|
6
|
+
* 別の席へ滑らないなら消えていく。
|
|
7
|
+
* 封は列の左から右へ伸び、覆い終えた時に列のチップを隠す。開ける時はチップを出してから封を消す。
|
|
8
|
+
* 列を選ぶと選んだ列の縁に色が付き、ほかの列を薄くする。薄くした列は、後の段で並びを書き換えるか選ぶと濃く戻る。
|
|
9
|
+
*/
|
|
10
|
+
import type { LineupAt, LineupLayout, LineupPick, LineupSeal, LineupSeat } from "../layout/lineup";
|
|
11
|
+
import { EASE, LOOK, MOTION, TYPE } from "../look/values";
|
|
12
|
+
import type { Diagram } from "../schema";
|
|
13
|
+
import type { Timeline } from "../timeline";
|
|
14
|
+
import { ALWAYS, type Shown } from "./ink";
|
|
15
|
+
import type { Frame } from "./motion";
|
|
16
|
+
import { type Ctx, cs, esc, type SubChange, subLines, write } from "./parts";
|
|
17
|
+
|
|
18
|
+
const r1 = (v: number): number => Math.round(v * 100) / 100;
|
|
19
|
+
|
|
20
|
+
/** 席から `(dx, dy)` ずらして大きさを `scale` 倍にした時の `transform` */
|
|
21
|
+
const place = (dx: number, dy: number, scale = 1): string => `translate(${r1(dx)}px,${r1(dy)}px) scale(${scale})`;
|
|
22
|
+
|
|
23
|
+
/** `span` から `holes` の間を抜いた間 */
|
|
24
|
+
const without = (span: Shown, holes: Shown[]): Shown[] =>
|
|
25
|
+
holes.reduce<Shown[]>((rest, [x, y]) => rest.flatMap(([a, b]): Shown[] => (y <= a || x >= b ? [[a, b]] : [...(a < x ? ([[a, x]] as Shown[]) : []), ...(y < b ? ([[y, b]] as Shown[]) : [])])), [span]);
|
|
26
|
+
|
|
27
|
+
export function drawLineup(layout: LineupLayout, diagram: Diagram, timeline: Timeline, ctx: Ctx, subs: Map<string, SubChange[]>): { lanes: string; chips: string } {
|
|
28
|
+
const { m } = ctx;
|
|
29
|
+
const N = LOOK.lineup;
|
|
30
|
+
const cut = MOTION.lineup.cut;
|
|
31
|
+
const timeOf = (at: LineupAt): { start: number; drawn: number } => timeline.edges.find((t) => t.step === at.step && t.event === at.event) ?? { start: 0, drawn: 0 };
|
|
32
|
+
const items = new Map((diagram.lineup?.items ?? []).map((item) => [item.id, item]));
|
|
33
|
+
|
|
34
|
+
// 列ごとの、薄くなるか濃く戻る時刻。列を選ぶ時に薄くし、並びを書き換えるか選ぶ時に濃く戻す
|
|
35
|
+
const turns = new Map<string, [number, boolean][]>(layout.lanes.map((lane) => [lane.id, []]));
|
|
36
|
+
const faint = new Set<string>();
|
|
37
|
+
const turn = (id: string, at: number, to: boolean): void => {
|
|
38
|
+
if (faint.has(id) === to) return;
|
|
39
|
+
if (to) faint.add(id);
|
|
40
|
+
else faint.delete(id);
|
|
41
|
+
turns.get(id)?.push([at, to]);
|
|
42
|
+
};
|
|
43
|
+
for (const time of [...timeline.edges].sort((a, b) => a.start - b.start)) {
|
|
44
|
+
const e = diagram.steps[time.step]?.events[time.event];
|
|
45
|
+
if (e?.type === "line") turn(e.box, time.start, false);
|
|
46
|
+
if (e?.type === "pick") for (const lane of layout.lanes) turn(lane.id, time.start, lane.id !== e.box);
|
|
47
|
+
}
|
|
48
|
+
/** 列の濃さの動き。薄くならない列は `undefined` */
|
|
49
|
+
const fadeOf = (id: string): string | undefined => {
|
|
50
|
+
const list = turns.get(id) ?? [];
|
|
51
|
+
if (list.length === 0) return undefined;
|
|
52
|
+
const frames: Frame[] = [[0, { opacity: 1 }]];
|
|
53
|
+
let now: number = 1;
|
|
54
|
+
for (const [t, to] of list) {
|
|
55
|
+
const next = to ? N.faint : 1;
|
|
56
|
+
frames.push([t, { opacity: now }, EASE.inOut], [t + MOTION.fade, { opacity: next }]);
|
|
57
|
+
now = next;
|
|
58
|
+
}
|
|
59
|
+
frames.push([m.last, { opacity: now }, EASE.inOut], [m.total, { opacity: 1 }]);
|
|
60
|
+
return m.kf(frames);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/** 封が列を隠す間。覆い終えてから開けるまで */
|
|
64
|
+
const closedOf = (seal: LineupSeal): Shown => [timeOf(seal).drawn, seal.until ? timeOf(seal.until).start : Number.POSITIVE_INFINITY];
|
|
65
|
+
|
|
66
|
+
/** 列のチップを隠す動き。封の無い列は `undefined` */
|
|
67
|
+
const hideOf = (seals: LineupSeal[]): string | undefined => {
|
|
68
|
+
if (seals.length === 0) return undefined;
|
|
69
|
+
const frames: Frame[] = [[0, { opacity: 1 }]];
|
|
70
|
+
for (const seal of seals) {
|
|
71
|
+
const [a, b] = closedOf(seal);
|
|
72
|
+
frames.push([a, { opacity: 1 }], [a + cut, { opacity: 0 }]);
|
|
73
|
+
if (seal.until) frames.push([b, { opacity: 0 }], [b + cut, { opacity: 1 }]);
|
|
74
|
+
}
|
|
75
|
+
frames.push([m.total - cut, { opacity: seals.at(-1)?.until ? 1 : 0 }], [m.total, { opacity: 1 }]);
|
|
76
|
+
return m.kf(frames);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const sealKf = (seal: LineupSeal): string => {
|
|
80
|
+
const { start, drawn } = timeOf(seal);
|
|
81
|
+
const none = { opacity: 0, transform: "scaleX(0)" };
|
|
82
|
+
const end: Frame[] = seal.until
|
|
83
|
+
? [
|
|
84
|
+
[timeOf(seal.until).start, { opacity: 1 }, EASE.inOut],
|
|
85
|
+
[timeOf(seal.until).start + MOTION.fade, { opacity: 0 }],
|
|
86
|
+
[m.total, { opacity: 0 }],
|
|
87
|
+
]
|
|
88
|
+
: [
|
|
89
|
+
[m.last, { opacity: 1 }, EASE.inOut],
|
|
90
|
+
[m.total, { opacity: 0 }],
|
|
91
|
+
];
|
|
92
|
+
return m.kf([[0, none], [start - cut, none], [start, { opacity: 1, transform: "scaleX(0)" }, EASE.inOut], [drawn, { transform: "scaleX(1)" }], ...end]);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/** 席を離れた同じ出来事で、別の席へ滑るチップか */
|
|
96
|
+
/**
|
|
97
|
+
* チップが席を離れる時刻と、別の席へ滑って離れるか。席を離れる段の中で、この席から滑り始めるチップが在れば、滑り始める時に一瞬で替わる。
|
|
98
|
+
* 列の並びを書き換える出来事と、別の列へ滑る出来事の順は問わない。どちらが先でも、同じチップが 2 枚見える間と、1 枚も見えない間を作らない
|
|
99
|
+
*/
|
|
100
|
+
const leaving = (c: LineupSeat): { at: number; moved: boolean } | undefined => {
|
|
101
|
+
if (!c.until) return undefined;
|
|
102
|
+
const until = c.until;
|
|
103
|
+
const next = layout.chips.find((n) => n !== c && n.id === c.id && n.step === until.step && n.from?.[0] === c.x && n.from?.[1] === c.y);
|
|
104
|
+
return next ? { at: timeOf(next).start, moved: true } : { at: timeOf(until).start, moved: false };
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const chipKf = (c: LineupSeat): string => {
|
|
108
|
+
const a = timeOf(c).start;
|
|
109
|
+
const rest = place(0, 0);
|
|
110
|
+
const frames: Frame[] = [];
|
|
111
|
+
if (c.from) {
|
|
112
|
+
const off = place(c.from[0] - c.x, c.from[1] - c.y);
|
|
113
|
+
frames.push([0, { opacity: 0, transform: off }], [a - cut, { opacity: 0, transform: off }], [a, { opacity: 1, transform: off }, EASE.inOut], [a + MOTION.lineup.slide, { transform: rest }]);
|
|
114
|
+
} else {
|
|
115
|
+
const off = place(0, 0, LOOK.popFrom);
|
|
116
|
+
frames.push([0, { opacity: 0, transform: off }], [a, { opacity: 0, transform: off }, EASE.pop], [a + MOTION.popFade, { opacity: 1, transform: rest }]);
|
|
117
|
+
}
|
|
118
|
+
const leaves = leaving(c);
|
|
119
|
+
if (leaves) {
|
|
120
|
+
frames.push([leaves.at, { opacity: 1 }, EASE.inOut], [leaves.at + (leaves.moved ? cut : MOTION.fade), { opacity: 0 }], [m.total, { opacity: 0 }]);
|
|
121
|
+
} else {
|
|
122
|
+
frames.push([m.last, { opacity: 1 }, EASE.inOut], [m.total, { opacity: 0 }]);
|
|
123
|
+
}
|
|
124
|
+
return m.kf(frames);
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const chip = (c: LineupSeat, closed: Shown[]): string => {
|
|
128
|
+
const item = items.get(c.id);
|
|
129
|
+
const color = item?.color;
|
|
130
|
+
const rect = `<rect class="${color ? "dg-ln-chip" : "dg-ln-plain"}" x="${r1(c.x)}" y="${r1(c.y)}" width="${r1(c.w)}" height="${c.h}" rx="${N.chip.radius}"/>`;
|
|
131
|
+
const shown = without([timeOf(c).start + MOTION.lineup.slide, leaving(c)?.at ?? Number.POSITIVE_INFINITY], closed);
|
|
132
|
+
const text = item?.label === undefined ? "" : write(ctx.ink, color ? "dg-ln-t" : "dg-ln-tp", c.x + c.w / 2, c.y + c.h / 2 + LOOK.baseline.tag, item.label, TYPE.chip, shown, "middle");
|
|
133
|
+
return `<g class="dg-popc dg-a" data-lineup-chip="${esc(c.id)}" data-lineup-on="${esc(c.lane)}" data-lineup-seat="${c.index}" style="${color ? `${cs(color)};` : ""}${chipKf(c)}">${rect}${text}</g>`;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
/** 選んだ列の縁の色が見える間。次に別の列を選ぶまで */
|
|
137
|
+
const ring = (pick: LineupPick, next: LineupPick | undefined, frame: string): string =>
|
|
138
|
+
`<g class="dg-a" data-lineup-ring="${esc(pick.lane)}" style="${m.vis(timeOf(pick).start, next ? timeOf(next).start : m.last)}">${frame}</g>`;
|
|
139
|
+
|
|
140
|
+
const faded = new Map(layout.lanes.map((lane) => [lane.id, fadeOf(lane.id)]));
|
|
141
|
+
|
|
142
|
+
const lanes = layout.lanes
|
|
143
|
+
.map((lane) => {
|
|
144
|
+
const rect = (cls: string, extra = ""): string => `<rect class="${cls}" x="${r1(lane.x)}" y="${r1(lane.y)}" width="${r1(lane.w)}" height="${lane.h}" rx="${N.radius}"${extra}/>`;
|
|
145
|
+
const rings = layout.picks.flatMap((pick, k) => (pick.lane === lane.id ? [ring(pick, layout.picks[k + 1], `${rect("dg-halo")}${rect("dg-on")}`)] : [])).join("");
|
|
146
|
+
const notes = subLines(lane, m, subs.get(lane.id) ?? [], lane.title.baseline, ctx.ink, lane.noteRight);
|
|
147
|
+
const fade = faded.get(lane.id);
|
|
148
|
+
return (
|
|
149
|
+
`<g${fade ? ' class="dg-a"' : ""} data-lineup-lane="${esc(lane.id)}" style="${cs(lane.color)}${fade ? `;${fade}` : ""}">` +
|
|
150
|
+
`${rect("dg-st", ` ${ctx.sh}`)}${rings}${write(ctx.ink, "dg-sn", lane.title.x, lane.title.baseline, lane.name, TYPE.boxName, ALWAYS)}${notes}</g>`
|
|
151
|
+
);
|
|
152
|
+
})
|
|
153
|
+
.join("");
|
|
154
|
+
|
|
155
|
+
const stripes = N.seal.stripe;
|
|
156
|
+
const pattern = `<defs><pattern id="dg-seal-${ctx.id}" patternUnits="userSpaceOnUse" width="${stripes * 2}" height="${stripes * 2}" patternTransform="rotate(45)"><rect class="dg-ln-sl" width="${stripes * 2}" height="${stripes * 2}"/><rect class="dg-ln-sd" width="${stripes}" height="${stripes * 2}"/></pattern></defs>`;
|
|
157
|
+
|
|
158
|
+
const chips = layout.lanes
|
|
159
|
+
.map((lane) => {
|
|
160
|
+
const seals = layout.seals.filter((s) => s.lane === lane.id);
|
|
161
|
+
const closed = seals.map(closedOf);
|
|
162
|
+
const seats = layout.chips.filter((c) => c.lane === lane.id).map((c) => chip(c, closed)).join("");
|
|
163
|
+
const hide = hideOf(seals);
|
|
164
|
+
const track = `<g${hide ? ' class="dg-a"' : ""} data-lineup-track="${esc(lane.id)}"${hide ? ` style="${hide}"` : ""}>${seats}</g>`;
|
|
165
|
+
const covers = seals
|
|
166
|
+
.map((s) => `<rect class="dg-ln-seal dg-a" data-lineup-seal="${esc(lane.id)}" x="${r1(s.x)}" y="${r1(s.y)}" width="${r1(s.w)}" height="${r1(s.h)}" rx="${N.seal.radius}" fill="url(#dg-seal-${ctx.id})" style="${sealKf(s)}"/>`)
|
|
167
|
+
.join("");
|
|
168
|
+
const stamps = layout.stamps
|
|
169
|
+
.filter((s) => s.lane === lane.id)
|
|
170
|
+
.map((s) => {
|
|
171
|
+
const at = timeOf(s).start;
|
|
172
|
+
const cx = s.x + s.w / 2;
|
|
173
|
+
const cy = s.y + s.h / 2;
|
|
174
|
+
const text = write(ctx.ink, "dg-ln-st", cx, cy + LOOK.baseline.tag, s.text, TYPE.stamp, [[at, Number.POSITIVE_INFINITY]], "middle");
|
|
175
|
+
return `<g class="dg-popc dg-a" data-lineup-stamp="${esc(lane.id)}" style="${cs(N.stamp.color)};${m.pop(at)}"><g transform="rotate(${N.stamp.tilt} ${r1(cx)} ${r1(cy)})"><rect class="dg-ln-stamp" x="${r1(s.x)}" y="${r1(s.y)}" width="${r1(s.w)}" height="${s.h}" rx="${N.stamp.radius}"/>${text}</g></g>`;
|
|
176
|
+
})
|
|
177
|
+
.join("");
|
|
178
|
+
const fade = faded.get(lane.id);
|
|
179
|
+
return `<g${fade ? ` class="dg-a" style="${fade}"` : ""}>${track}${covers}${stamps}</g>`;
|
|
180
|
+
})
|
|
181
|
+
.join("");
|
|
182
|
+
|
|
183
|
+
return { lanes, chips: `${pattern}${chips}` };
|
|
184
|
+
}
|
package/src/render/parts.ts
CHANGED
|
@@ -87,6 +87,8 @@ export function arrowHead(points: Point[]): string {
|
|
|
87
87
|
export interface Ctx {
|
|
88
88
|
m: Motion;
|
|
89
89
|
t: Timeline;
|
|
90
|
+
/** 図の名前。図の中の定義 (影の filter、封の縞) の名札に使う */
|
|
91
|
+
id: string;
|
|
90
92
|
/** 影の filter を付ける属性 */
|
|
91
93
|
sh: string;
|
|
92
94
|
/** 最後の段の終わり */
|
|
@@ -138,8 +140,11 @@ export function band(region: SceneRegion, ink: Ink[]): string {
|
|
|
138
140
|
/** 箱の下の小さな字の移り変わり。`[時刻, 字, class]` の並びで、最初は元の字。 */
|
|
139
141
|
export type SubChange = [number, string, string];
|
|
140
142
|
|
|
141
|
-
/**
|
|
142
|
-
|
|
143
|
+
/**
|
|
144
|
+
* 箱の下の小さな字。基準線を `y` に置き、起きたことに合わせて書き換わる。
|
|
145
|
+
* `right` を渡すと、箱の真ん中でなく字の右端を `right` に揃える (列の図の列の右上の字、#3239)
|
|
146
|
+
*/
|
|
147
|
+
export function subLines(box: SceneBox, m: Motion, changes: SubChange[], y: number, ink?: Ink[], right?: number): string {
|
|
143
148
|
const seq: SubChange[] = [[0, box.sub ?? "", "dg-ss"], ...changes];
|
|
144
149
|
return seq
|
|
145
150
|
.map(([t, text, cls], k) => {
|
|
@@ -147,7 +152,9 @@ function subLines(box: SceneBox, m: Motion, changes: SubChange[], y: number, ink
|
|
|
147
152
|
const anim = k === 0 ? (next === undefined ? "" : m.until(next - MOTION.untilFade)) : next === undefined ? m.rise(t) : m.rise(t, next - MOTION.untilFade);
|
|
148
153
|
if (text === "") return "";
|
|
149
154
|
const shown: Shown[] = [[k === 0 ? 0 : t, next === undefined ? Number.POSITIVE_INFINITY : next - MOTION.untilFade]];
|
|
150
|
-
|
|
155
|
+
const style = cls === "dg-ss" ? TYPE.boxSub : TYPE.boxSubStrong;
|
|
156
|
+
const drawn = right === undefined ? write(ink, cls, box.cx, y, text, style, shown, "middle") : write(ink, cls, right - textWidth(text, style), y, text, style, shown);
|
|
157
|
+
return `<g${anim ? ` class="dg-a" style="${anim}"` : ""}>${drawn}</g>`;
|
|
151
158
|
})
|
|
152
159
|
.join("");
|
|
153
160
|
}
|
|
@@ -256,11 +263,12 @@ export function lifeline(x: number, y1: number, y2: number): string {
|
|
|
256
263
|
* 線。点線で道を見せておき、その段で色の線を引いて、段の終わりまで流れる点で向きを見せる。
|
|
257
264
|
* 済んだ段は薄く残し、最後の段の後に通った道を全て濃くし直す。
|
|
258
265
|
* `past` を立てると (状態遷移図、#3171)、段が終わった後は色の線を消して灰の実線に替え、最後の段まで残す。
|
|
266
|
+
* `since` を渡すと (木の図の後から現れる箱へ向かう線、#3240)、点線の道をその時刻から出す。
|
|
259
267
|
*/
|
|
260
|
-
export function edge(e: SceneEdge, time: EdgeTime, ctx: Ctx, past = false): { base: string; lit: string } {
|
|
268
|
+
export function edge(e: SceneEdge, time: EdgeTime, ctx: Ctx, past = false, since = 0): { base: string; lit: string } {
|
|
261
269
|
const { m } = ctx;
|
|
262
|
-
//
|
|
263
|
-
ctx.traces.push({ from: e.from, to: e.to, points: e.points, shown: ALWAYS });
|
|
270
|
+
// 点線の道は `since` から最後まで見えている。`since` が 0 なら初めから見えている
|
|
271
|
+
ctx.traces.push({ from: e.from, to: e.to, points: e.points, shown: since > 0 ? [[since, Number.POSITIVE_INFINITY]] : ALWAYS });
|
|
264
272
|
const d = pathOf(e.points);
|
|
265
273
|
const head = arrowHead(e.points);
|
|
266
274
|
const { start: a, drawn: b, end } = time;
|
|
@@ -298,8 +306,9 @@ export function edge(e: SceneEdge, time: EdgeTime, ctx: Ctx, past = false): { ba
|
|
|
298
306
|
[m.total, { opacity: 0, "stroke-dashoffset": run }],
|
|
299
307
|
]);
|
|
300
308
|
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 }]]) : "";
|
|
309
|
+
const path = `<path class="dg-e" d="${d}"/><path class="dg-eh" d="${head}"/>`;
|
|
301
310
|
return {
|
|
302
|
-
base: `<
|
|
311
|
+
base: `${since > 0 ? `<g class="dg-a" style="${m.vis(since)}">${path}</g>` : path}${past ? `<path class="dg-e-past dg-a" d="${d}" style="${grey}"/><path class="dg-eh-past dg-a" d="${head}" style="${grey}"/>` : ""}`,
|
|
303
312
|
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>`,
|
|
304
313
|
};
|
|
305
314
|
}
|
package/src/render/svg.ts
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import { FIGURE_TEXT } from "../figure-text";
|
|
10
10
|
import { layoutArchitecture } from "../layout/architecture";
|
|
11
11
|
import { isGitLayout, layoutGit } from "../layout/git";
|
|
12
|
+
import { isLineupLayout, layoutLineup } from "../layout/lineup";
|
|
12
13
|
import { textWidth } from "../layout/measure";
|
|
13
14
|
import type { Layout, Rect, SceneField, SceneLabel } from "../layout/scene";
|
|
14
15
|
import { layoutSequence } from "../layout/sequence";
|
|
@@ -45,6 +46,7 @@ import {
|
|
|
45
46
|
type SubChange,
|
|
46
47
|
} from "./parts";
|
|
47
48
|
import { drawGit } from "./git";
|
|
49
|
+
import { drawLineup } from "./lineup";
|
|
48
50
|
import { drawTime, meterField, sansOf, timeFocus } from "./time";
|
|
49
51
|
import { drawTree } from "./tree";
|
|
50
52
|
import { findOverlaps, type Ink, type Overlap, type Trace } from "./ink";
|
|
@@ -187,6 +189,16 @@ const PART_CSS = [
|
|
|
187
189
|
`.dg-tree-one{${font(TYPE.boxName)};fill:var(--ink)}`,
|
|
188
190
|
`.dg-tree-rh{${font(TYPE.rootHash)};fill:var(--ink)}`,
|
|
189
191
|
`.dg-tree-rn{${font(TYPE.rootName)};fill:var(--mute)}`,
|
|
192
|
+
// 列の図 (#3239)。封は列の左端から右へ伸びる
|
|
193
|
+
".dg-ln-chip{fill:var(--c)}",
|
|
194
|
+
`.dg-ln-plain{fill:color-mix(in srgb,var(--mute) ${X.chipPlain}%,var(--surf))}`,
|
|
195
|
+
`.dg-ln-t{${font(TYPE.chip)};fill:var(--on-c)}`,
|
|
196
|
+
`.dg-ln-tp{${font(TYPE.chip)};fill:var(--ink)}`,
|
|
197
|
+
".dg-ln-seal{transform-box:fill-box;transform-origin:0 50%}",
|
|
198
|
+
`.dg-ln-sd{fill:color-mix(in srgb,var(--mute) ${X.sealDark}%,var(--surf))}`,
|
|
199
|
+
`.dg-ln-sl{fill:color-mix(in srgb,var(--mute) ${X.sealLight}%,var(--surf))}`,
|
|
200
|
+
`.dg-ln-stamp{fill:var(--surf);stroke:var(--c);stroke-width:${S.stamp}}`,
|
|
201
|
+
`.dg-ln-st{${font(TYPE.stamp)};fill:var(--ct)}`,
|
|
190
202
|
// 時間軸の図 (#3165)。和文を含む字は、末尾に j を付けた class で同じ大きさと太さの和文の字にする
|
|
191
203
|
`.dg-tm-ep{fill:color-mix(in srgb,var(--ink) ${X.timeShade}%,transparent)}`,
|
|
192
204
|
`.dg-tm-sep{stroke:var(--hair);stroke-width:${S.hair};stroke-dasharray:2 4}`,
|
|
@@ -356,7 +368,7 @@ export function drawSvg(diagram: Diagram, layout: Layout, timeline: Timeline, pa
|
|
|
356
368
|
const vars = paletteVars(palette, theme);
|
|
357
369
|
const id = nameOf(`${JSON.stringify(diagram)}|${vars}|${follow ? `${follow.width}|${follow.lang}` : ""}`);
|
|
358
370
|
const m = new Motion(`dg${id}`, timeline.total, timeline.last);
|
|
359
|
-
const ctx: Ctx = { m, t: timeline, sh: `filter="url(#dg-sh-${id})"`, end: (timeline.steps[timeline.steps.length - 1] as Span).end, ink, traces };
|
|
371
|
+
const ctx: Ctx = { m, t: timeline, id, sh: `filter="url(#dg-sh-${id})"`, end: (timeline.steps[timeline.steps.length - 1] as Span).end, ink, traces };
|
|
360
372
|
const on = involved(diagram);
|
|
361
373
|
// 時系列図の処理は生存線の上の札に出し、他の図の種類は箱の下の字に出す
|
|
362
374
|
const subs = subChanges(diagram, timeline, layout.kind !== "sequence");
|
|
@@ -387,13 +399,20 @@ export function drawSvg(diagram: Diagram, layout: Layout, timeline: Timeline, pa
|
|
|
387
399
|
}
|
|
388
400
|
// 木の図の木の線と通った跡と木の箱と札は、木の図を描く部品が描く (#3233)。木の線を走る線は通った跡が見せるので、ほかの線と同じ線で描かない
|
|
389
401
|
const treeLayout = isTreeLayout(layout) ? layout : undefined;
|
|
390
|
-
|
|
391
|
-
|
|
402
|
+
const tree = treeLayout ? drawTree(treeLayout, diagram, timeline, ctx) : undefined;
|
|
403
|
+
if (tree) {
|
|
392
404
|
L.base.push(tree.links);
|
|
393
405
|
L.lit.push(tree.trails);
|
|
394
406
|
L.node.push(tree.nodes);
|
|
395
407
|
}
|
|
396
408
|
const runs = new Set((treeLayout?.runs ?? []).map((r) => `${r.step}/${r.event}`));
|
|
409
|
+
// 列の図の列とチップと封と札は、列の図を描く部品が描く (#3239)
|
|
410
|
+
const lineupLayout = isLineupLayout(layout) ? layout : undefined;
|
|
411
|
+
if (lineupLayout) {
|
|
412
|
+
const lineup = drawLineup(lineupLayout, diagram, timeline, ctx, subs);
|
|
413
|
+
L.base.push(lineup.lanes);
|
|
414
|
+
L.node.push(lineup.chips);
|
|
415
|
+
}
|
|
397
416
|
// 時間軸の図の目盛りと印と拡大の帯の箱と節目は、時間軸の図を描く部品が描く (#3165)。拡大の帯の線は他の図と同じ線で描く
|
|
398
417
|
const timeLayout = isTimeLayout(layout) ? layout : undefined;
|
|
399
418
|
if (timeLayout) {
|
|
@@ -407,7 +426,9 @@ export function drawSvg(diagram: Diagram, layout: Layout, timeline: Timeline, pa
|
|
|
407
426
|
for (const e of layout.edges) {
|
|
408
427
|
const time = timeline.edges.find((t) => t.step === e.step && t.event === e.event);
|
|
409
428
|
if (!time || (timeLayout && !wired.has(`${e.step}/${e.event}`)) || runs.has(`${e.step}/${e.event}`)) continue;
|
|
410
|
-
|
|
429
|
+
// 木の図の箱は段ごとに現れるので、木の線を走らない線の点線は、両端の木の箱が現れてから出す (#3240)
|
|
430
|
+
const since = Math.max(tree?.appear.get(e.from) ?? 0, tree?.appear.get(e.to) ?? 0);
|
|
431
|
+
const drawn = edge(e, time, ctx, isState, since);
|
|
411
432
|
L.base.push(drawn.base);
|
|
412
433
|
L.lit.push(drawn.lit);
|
|
413
434
|
}
|
|
@@ -415,7 +436,7 @@ export function drawSvg(diagram: Diagram, layout: Layout, timeline: Timeline, pa
|
|
|
415
436
|
// 飛び先を持つ箱は、箱の札をその飛び先への link で包む (#3199)。時間軸の図の箱は時間軸の図を描く部品が包む
|
|
416
437
|
const links = new Map(diagram.boxes.flatMap((b) => (b.link === undefined ? [] : [[b.id, b.link] as [string, string]])));
|
|
417
438
|
const linked = (id: string, markup: string): string => linkTo(links.get(id), markup);
|
|
418
|
-
for (const box of timeLayout ? [] : layout.boxes) {
|
|
439
|
+
for (const box of timeLayout || lineupLayout ? [] : layout.boxes) {
|
|
419
440
|
if (box.ghost) {
|
|
420
441
|
L.node.push(linked(box.id, ghostCard(box, ink)));
|
|
421
442
|
continue;
|
|
@@ -506,6 +527,11 @@ function focusParts(layout: Layout, diagram: Diagram, step: number): Rect[] {
|
|
|
506
527
|
rects.push({ x: Math.min(...xs), y: Math.min(...ys), w: Math.max(...xs) - Math.min(...xs), h: Math.max(...ys) - Math.min(...ys) });
|
|
507
528
|
}
|
|
508
529
|
}
|
|
530
|
+
// 列の図は、その段で変わる列を見る (#3239)
|
|
531
|
+
if (isLineupLayout(layout)) {
|
|
532
|
+
const changed = new Set((diagram.steps[step]?.events ?? []).flatMap((e) => ("box" in e ? [e.box] : [])));
|
|
533
|
+
rects.push(...layout.lanes.filter((lane) => changed.has(lane.id)));
|
|
534
|
+
}
|
|
509
535
|
for (const event of diagram.steps[step]?.events ?? []) {
|
|
510
536
|
const ids = event.type === "edge" ? [event.from, event.to] : event.type === "action" || event.type === "swap" ? [event.box] : [];
|
|
511
537
|
for (const id of ids) {
|
|
@@ -672,7 +698,9 @@ export function renderDiagram(input: unknown, options: RenderOptions = {}): Rend
|
|
|
672
698
|
? layoutTime(diagram, lang)
|
|
673
699
|
: diagram.kind === "tree"
|
|
674
700
|
? layoutTree(diagram)
|
|
675
|
-
:
|
|
701
|
+
: diagram.kind === "lineup"
|
|
702
|
+
? layoutLineup(diagram)
|
|
703
|
+
: layoutArchitecture(diagram);
|
|
676
704
|
return renderLayout(diagram, layout, buildTimeline(diagram, options.still === true), options);
|
|
677
705
|
}
|
|
678
706
|
|
package/src/render/tree.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* 木の線を走る運ぶ物は着いた所で消え、通った木の線を運ぶ物の色で最後まで残す (`data-tree-trail`)。
|
|
7
7
|
* 木の線を運ぶ物が初めて通った段から後は、それまでに運ぶ物を送るか受けた木の箱だけを濃く出し、ほかの木の箱と札と木の線を薄く出す。
|
|
8
8
|
* 線の両端になった木の箱は、その段の間だけ縁に色を付ける。
|
|
9
|
+
* 木の箱が現れる時刻 (`appear`) を返し、木の線を走らない線の点線はその時刻から出す (#3240)。
|
|
9
10
|
*/
|
|
10
11
|
import type { TreeLayout } from "../layout/tree";
|
|
11
12
|
import { EASE, LOOK, MOTION, TYPE } from "../look/values";
|
|
@@ -17,7 +18,7 @@ import { activeKf, arrowHead, type Ctx, cs, esc, glyph, pathOf, write } from "./
|
|
|
17
18
|
|
|
18
19
|
const r1 = (v: number): number => Math.round(v * 100) / 100;
|
|
19
20
|
|
|
20
|
-
export function drawTree(layout: TreeLayout, diagram: Diagram, timeline: Timeline, ctx: Ctx): { links: string; trails: string; nodes: string } {
|
|
21
|
+
export function drawTree(layout: TreeLayout, diagram: Diagram, timeline: Timeline, ctx: Ctx): { links: string; trails: string; nodes: string; appear: Map<string, number> } {
|
|
21
22
|
const { m } = ctx;
|
|
22
23
|
const T = LOOK.tree;
|
|
23
24
|
const B = LOOK.box;
|
|
@@ -160,5 +161,5 @@ export function drawTree(layout: TreeLayout, diagram: Diagram, timeline: Timelin
|
|
|
160
161
|
})
|
|
161
162
|
.join("");
|
|
162
163
|
|
|
163
|
-
return { links: links + ties, trails, nodes: cards + nodes };
|
|
164
|
+
return { links: links + ties, trails, nodes: cards + nodes, appear: drawnAt };
|
|
164
165
|
}
|
package/src/schema.ts
CHANGED
|
@@ -55,7 +55,10 @@ export type DiagramEvent =
|
|
|
55
55
|
| TimeMarkEvent
|
|
56
56
|
| TimeSpanEvent
|
|
57
57
|
| TreeLeaf
|
|
58
|
-
| TreeNode
|
|
58
|
+
| TreeNode
|
|
59
|
+
| LineupOrder
|
|
60
|
+
| { type: "seal" | "open" | "pick"; box: string }
|
|
61
|
+
| LineupStamp;
|
|
59
62
|
|
|
60
63
|
/** 時間軸の図 (#3165) の、印の列 `row` の `from` から `to` の目盛りの印の色を変える出来事 */
|
|
61
64
|
export interface TimeMarkEvent {
|
|
@@ -152,6 +155,27 @@ export interface TreeNode {
|
|
|
152
155
|
hash?: string;
|
|
153
156
|
}
|
|
154
157
|
|
|
158
|
+
/** 列の図 (#3239) の、列 `box` の並びを `items` に書き換える出来事。前の段との差分を描く部品が滑る動きに変える */
|
|
159
|
+
export interface LineupOrder {
|
|
160
|
+
type: "line";
|
|
161
|
+
box: string;
|
|
162
|
+
items: string[];
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** 列の図の、列 `box` の右に `text` の札を押す出来事 */
|
|
166
|
+
export interface LineupStamp {
|
|
167
|
+
type: "stamp";
|
|
168
|
+
box: string;
|
|
169
|
+
text: string;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** 列の図のチップ。`color` を書かないチップは薄い色で、`label` を書かないチップは色だけで出す */
|
|
173
|
+
export interface LineupItem {
|
|
174
|
+
id: string;
|
|
175
|
+
color?: Color;
|
|
176
|
+
label?: string;
|
|
177
|
+
}
|
|
178
|
+
|
|
155
179
|
/** 枝分かれの図の枝。上から宣言した順に帯を並べる */
|
|
156
180
|
export interface GitBranch {
|
|
157
181
|
id: string;
|
|
@@ -182,7 +206,7 @@ export interface Step {
|
|
|
182
206
|
|
|
183
207
|
export interface Diagram {
|
|
184
208
|
version: number;
|
|
185
|
-
kind: "sequence" | "architecture" | "state" | "git" | "time" | "tree";
|
|
209
|
+
kind: "sequence" | "architecture" | "state" | "git" | "time" | "tree" | "lineup";
|
|
186
210
|
title: string;
|
|
187
211
|
view?: ViewMode;
|
|
188
212
|
regions?: Region[];
|
|
@@ -193,6 +217,7 @@ export interface Diagram {
|
|
|
193
217
|
state?: { paths: StatePath[] };
|
|
194
218
|
git?: { branches: GitBranch[] };
|
|
195
219
|
time?: TimeSpec;
|
|
220
|
+
lineup?: { items: LineupItem[] };
|
|
196
221
|
}
|
|
197
222
|
|
|
198
223
|
export interface FieldError {
|
|
@@ -209,7 +234,7 @@ export interface CheckOptions {
|
|
|
209
234
|
}
|
|
210
235
|
|
|
211
236
|
/** 段の中で起きることの種類。schema の event の `discriminator` が見る `type` の値 */
|
|
212
|
-
const EVENT_TYPES = ["edge", "action", "swap", "strip", "commit", "branch", "now", "mark", "span", "leaf", "node"] as const satisfies readonly DiagramEvent["type"][];
|
|
237
|
+
const EVENT_TYPES = ["edge", "action", "swap", "strip", "commit", "branch", "now", "mark", "span", "leaf", "node", "line", "seal", "open", "pick", "stamp"] as const satisfies readonly DiagramEvent["type"][];
|
|
213
238
|
|
|
214
239
|
/**
|
|
215
240
|
* その種類の図に書けない根の欄を書いた時の決まりの場所 (#3164)。根の欄に `not: {}` を置く決まり (`absent`) を指し、
|
|
@@ -220,7 +245,16 @@ const ABSENT = "#/definitions/absent/not";
|
|
|
220
245
|
* 種類の欄でない欄を書ける図の種類。区画は枝分かれの図と時間軸の図に書けない。
|
|
221
246
|
* 線の列 (`at` と `into`)、節目の丸の色 (`color`)、物差し (`meters`) は時間軸の図だけが書ける (#3165)
|
|
222
247
|
*/
|
|
223
|
-
const ABSENT_KINDS: Record<string, string> = {
|
|
248
|
+
const ABSENT_KINDS: Record<string, string> = {
|
|
249
|
+
regions: "sequence / architecture / state",
|
|
250
|
+
at: "time",
|
|
251
|
+
into: "time",
|
|
252
|
+
color: "time",
|
|
253
|
+
meters: "time",
|
|
254
|
+
region: "sequence / architecture / state",
|
|
255
|
+
icon: "sequence / architecture / state / git / time / tree",
|
|
256
|
+
link: "sequence / architecture / state / git / time / tree",
|
|
257
|
+
};
|
|
224
258
|
/** 運ぶ物の書けない組み合わせ (`not: { required: [欄] }`)。誤りの場所の最後の欄で引く */
|
|
225
259
|
const NOT_ALLOWED: Record<string, Allowed> = {
|
|
226
260
|
carry: { field: "text", kind: "tag" },
|
|
@@ -240,6 +274,14 @@ const TIME_EVENTS = ["now", "mark", "span"] as const satisfies readonly DiagramE
|
|
|
240
274
|
const TREE_EVENT = /\/events\/items\/allOf\/0\/not$/u;
|
|
241
275
|
/** 木の図だけが書ける出来事 */
|
|
242
276
|
const TREE_EVENTS = ["leaf", "node"] as const satisfies readonly DiagramEvent["type"][];
|
|
277
|
+
/** 列の図でない図に、列の図だけの出来事を書いた時の決まりの場所 (#3239) */
|
|
278
|
+
const LINEUP_EVENT = "#/definitions/notLineupEvent/not";
|
|
279
|
+
/** 列の図だけが書ける出来事 */
|
|
280
|
+
const LINEUP_EVENTS = ["line", "seal", "open", "pick", "stamp"] as const satisfies readonly DiagramEvent["type"][];
|
|
281
|
+
/** 列の図に、線と処理の出来事を書いた時の決まりの場所 (#3239) */
|
|
282
|
+
const WIRED_EVENT = "#/definitions/notWiredEvent/not";
|
|
283
|
+
/** 列の図が書けない、箱と線の図の出来事 */
|
|
284
|
+
const WIRED_EVENTS = ["edge", "action"] as const satisfies readonly DiagramEvent["type"][];
|
|
243
285
|
/** 時間軸の図の目盛りの長さの決まり (`^[0-9]+(\.[0-9]+)?(<単位>|<単位>)$`)。書ける単位を読む */
|
|
244
286
|
const DURATION = /^\^\[0-9\]\+\(\\\.\[0-9\]\+\)\?\(([a-z|]+)\)\$$/u;
|
|
245
287
|
/** 割合の決まり。百分率の `%` を持つ */
|
|
@@ -287,6 +329,8 @@ function toFieldError(error: ErrorObject, errors: readonly ErrorObject[], m: Fie
|
|
|
287
329
|
if (GIT_EVENT.test(error.schemaPath)) return { pointer: at, message: m.kindOnly(GIT_EVENTS, "git") };
|
|
288
330
|
if (TIME_EVENT.test(error.schemaPath)) return { pointer: `${at}/type`, message: m.kindOnly(TIME_EVENTS, "time") };
|
|
289
331
|
if (TREE_EVENT.test(error.schemaPath)) return { pointer: `${at}/type`, message: m.kindOnly(TREE_EVENTS, "tree") };
|
|
332
|
+
if (error.schemaPath === LINEUP_EVENT) return { pointer: `${at}/type`, message: m.kindOnly(LINEUP_EVENTS, "lineup") };
|
|
333
|
+
if (error.schemaPath === WIRED_EVENT) return { pointer: `${at}/type`, message: m.kindOnly(WIRED_EVENTS, "sequence / architecture / state / git / time / tree") };
|
|
290
334
|
const last = at.slice(at.lastIndexOf("/") + 1);
|
|
291
335
|
if (error.schemaPath === ABSENT) return { pointer: at, message: m.not({ field: last, kind: ABSENT_KINDS[last] ?? last }) };
|
|
292
336
|
const allowed = NOT_ALLOWED[last];
|
|
@@ -307,6 +351,8 @@ function toFieldError(error: ErrorObject, errors: readonly ErrorObject[], m: Fie
|
|
|
307
351
|
return { pointer: at, message: m.type(String(params.type)) };
|
|
308
352
|
case "minLength":
|
|
309
353
|
return { pointer: at, message: m.minLength(Number(params.limit)) };
|
|
354
|
+
case "maxLength":
|
|
355
|
+
return { pointer: at, message: m.maxLength(Number(params.limit)) };
|
|
310
356
|
case "pattern": {
|
|
311
357
|
if (error.schemaPath === URL_RULE) return { pointer: at, message: m.url };
|
|
312
358
|
const pattern = String(params.pattern);
|
|
@@ -319,6 +365,8 @@ function toFieldError(error: ErrorObject, errors: readonly ErrorObject[], m: Fie
|
|
|
319
365
|
}
|
|
320
366
|
case "minItems":
|
|
321
367
|
return { pointer: at, message: m.minItems(Number(params.limit)) };
|
|
368
|
+
case "maxItems":
|
|
369
|
+
return { pointer: at, message: m.maxItems(Number(params.limit)) };
|
|
322
370
|
case "minimum":
|
|
323
371
|
return { pointer: at, message: m.minimum(Number(params.limit)) };
|
|
324
372
|
case "const":
|