@cardenelabs/dragon 0.34.0 → 0.35.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 +39 -720
- package/dist/cli.cjs +4529 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.js +4523 -0
- package/dist/cli.js.map +1 -0
- package/dist/export.cjs +3912 -0
- package/dist/export.cjs.map +1 -0
- package/dist/export.d.cts +36 -0
- package/dist/export.d.ts +36 -0
- package/dist/export.js +3907 -0
- package/dist/export.js.map +1 -0
- package/dist/fonts.cjs +7 -0
- package/dist/fonts.cjs.map +1 -0
- package/dist/fonts.js +4 -0
- package/dist/fonts.js.map +1 -0
- package/dist/index.cjs +4105 -20356
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +227 -5522
- package/dist/index.d.ts +227 -5522
- package/dist/index.js +4091 -20283
- package/dist/index.js.map +1 -1
- package/dist/player.global.js +2 -0
- package/dist/schema-BBWfniwH.d.cts +112 -0
- package/dist/schema-BBWfniwH.d.ts +112 -0
- package/package.json +39 -24
- package/src/cli.ts +237 -0
- package/src/export/capture.ts +277 -0
- package/src/export/fonts.ts +68 -0
- package/src/export/html.ts +32 -0
- package/src/export/index.ts +146 -0
- package/src/field-messages.ts +104 -0
- package/src/figure-text.ts +42 -0
- package/src/index.ts +30 -283
- package/src/layout/architecture.ts +381 -0
- package/src/layout/measure.ts +21 -0
- package/src/layout/scene.ts +353 -0
- package/src/layout/sequence.ts +189 -0
- package/src/load-fonts.ts +8 -0
- package/src/look/fonts.ts +33 -0
- package/src/look/palettes.json +209 -0
- package/src/look/values.ts +155 -0
- package/src/markdown.ts +35 -0
- package/src/messages.ts +122 -0
- package/src/parser.ts +342 -310
- package/src/player-global.ts +4 -0
- package/src/player.ts +271 -0
- package/src/printer.ts +76 -0
- package/src/render/icons.ts +41 -0
- package/src/render/motion.ts +106 -0
- package/src/render/parts.ts +279 -0
- package/src/render/svg.ts +341 -0
- package/src/schema.ts +161 -16
- package/src/schemas/diagram.schema.json +150 -0
- package/src/schemas/validate-diagram.d.ts +12 -0
- package/src/schemas/validate-diagram.js +8 -0
- package/src/timeline.ts +166 -0
- package/src/tokenize.ts +20 -281
- package/src/version.ts +55 -0
- package/src/view.ts +16 -0
- package/src/words.ts +79 -0
- package/examples/quick-start.md +0 -142
- package/src/canvas-bounds.ts +0 -52
- package/src/color.ts +0 -197
- package/src/compile/actor-ids.ts +0 -297
- package/src/compile/actor-option-notice.ts +0 -379
- package/src/compile/actors.ts +0 -103
- package/src/compile/c4.ts +0 -74
- package/src/compile/chain.ts +0 -93
- package/src/compile/chart-fields.ts +0 -193
- package/src/compile/deep-rewrite.ts +0 -30
- package/src/compile/derived-source.ts +0 -18
- package/src/compile/direction.ts +0 -102
- package/src/compile/edge-option-notice.ts +0 -112
- package/src/compile/er-relation.ts +0 -200
- package/src/compile/flow.ts +0 -54
- package/src/compile/flowchart.ts +0 -344
- package/src/compile/funnel.ts +0 -87
- package/src/compile/gantt.ts +0 -337
- package/src/compile/generic.ts +0 -696
- package/src/compile/hierarchy.ts +0 -92
- package/src/compile/journey.ts +0 -93
- package/src/compile/kinds.ts +0 -139
- package/src/compile/lanes.ts +0 -138
- package/src/compile/metro.ts +0 -271
- package/src/compile/mind.ts +0 -393
- package/src/compile/node-title.ts +0 -24
- package/src/compile/notice.ts +0 -141
- package/src/compile/order.ts +0 -57
- package/src/compile/parts-lookup.ts +0 -17
- package/src/compile/parts.ts +0 -2709
- package/src/compile/placement-apply.ts +0 -689
- package/src/compile/placement.ts +0 -15
- package/src/compile/quadrant.ts +0 -265
- package/src/compile/record.ts +0 -75
- package/src/compile/row-marks.ts +0 -128
- package/src/compile/rows.ts +0 -40
- package/src/compile/sequence.ts +0 -305
- package/src/compile/slug.ts +0 -37
- package/src/compile/stages.ts +0 -247
- package/src/compile/subtitle.ts +0 -35
- package/src/compile/swimlane-marks.ts +0 -87
- package/src/compile/swimlane.ts +0 -82
- package/src/compile/timeline.ts +0 -213
- package/src/compile/topology.ts +0 -44
- package/src/compile/tree.ts +0 -69
- package/src/compile/value-chart.ts +0 -337
- package/src/compile/values.ts +0 -432
- package/src/compile/word-state.ts +0 -82
- package/src/compile.ts +0 -3168
- package/src/focus.ts +0 -46
- package/src/input-size.ts +0 -181
- package/src/json-line-map.ts +0 -30
- package/src/json-parser.ts +0 -4306
- package/src/keywords.ts +0 -417
- package/src/near-name.ts +0 -42
- package/src/notation-lint.ts +0 -342
- package/src/relative-pos.ts +0 -251
- package/src/schemas/diagram.json +0 -3088
- package/src/types.ts +0 -1009
- package/src/v05/index.ts +0 -9
- package/src/v05/input-table.generated.ts +0 -138
- package/src/v05/parser-types.ts +0 -32
- package/src/v05/parser.ts +0 -6668
- package/src/v05/readout-table.generated.ts +0 -1088
- package/src/v05/removed-syntax.ts +0 -115
- package/src/value-syntax.ts +0 -313
- package/src/write-position.ts +0 -270
package/dist/export.js
ADDED
|
@@ -0,0 +1,3907 @@
|
|
|
1
|
+
import { mkdirSync, writeFileSync, rmSync, readFileSync } from 'fs';
|
|
2
|
+
import { join, dirname } from 'path';
|
|
3
|
+
import { createRequire } from 'module';
|
|
4
|
+
import { readFile } from 'fs/promises';
|
|
5
|
+
|
|
6
|
+
// src/export/index.ts
|
|
7
|
+
|
|
8
|
+
// src/look/palettes.json
|
|
9
|
+
var palettes_default = {
|
|
10
|
+
clear: {
|
|
11
|
+
name: "\u6F84\u3093\u3060\u8272",
|
|
12
|
+
note: "\u767D\u3044\u5730\u306B\u3001\u4E2D\u304F\u3089\u3044\u306E\u660E\u308B\u3055\u306E\u9BAE\u3084\u304B\u306A 6 \u8272\u3002\u4ECA\u306E\u898B\u672C\u5E33\u306E\u8272",
|
|
13
|
+
light: {
|
|
14
|
+
page: "#f3f4f7",
|
|
15
|
+
bg: "#ffffff",
|
|
16
|
+
surf: "#ffffff",
|
|
17
|
+
sunk: "#f5f6f8",
|
|
18
|
+
ink: "#12141a",
|
|
19
|
+
ink2: "#3f4451",
|
|
20
|
+
mute: "#6b7180",
|
|
21
|
+
hair: "#12141a1c",
|
|
22
|
+
line: "#12141a40",
|
|
23
|
+
sh: "#101828",
|
|
24
|
+
"on-c": "#ffffff",
|
|
25
|
+
"c-blue": "#467deb",
|
|
26
|
+
"t-blue": "#2e62ce",
|
|
27
|
+
"c-amber": "#d28008",
|
|
28
|
+
"t-amber": "#975b04",
|
|
29
|
+
"c-green": "#0ea886",
|
|
30
|
+
"t-green": "#07775e",
|
|
31
|
+
"c-violet": "#6c3bb2",
|
|
32
|
+
"t-violet": "#6c3bb2",
|
|
33
|
+
"c-rose": "#ba3e40",
|
|
34
|
+
"t-rose": "#b83c3f",
|
|
35
|
+
"c-slate": "#5d6677",
|
|
36
|
+
"t-slate": "#5d6677",
|
|
37
|
+
coin: "#e9b114",
|
|
38
|
+
coint: "#856300",
|
|
39
|
+
coinin: "#a8740c",
|
|
40
|
+
tint: "5%",
|
|
41
|
+
edge: "20%",
|
|
42
|
+
shA: ".05",
|
|
43
|
+
shB: ".08",
|
|
44
|
+
carry: "#65686f"
|
|
45
|
+
},
|
|
46
|
+
dark: {
|
|
47
|
+
page: "#08090c",
|
|
48
|
+
bg: "#0d0e12",
|
|
49
|
+
surf: "#17191f",
|
|
50
|
+
sunk: "#121419",
|
|
51
|
+
ink: "#eceef3",
|
|
52
|
+
ink2: "#c4c8d2",
|
|
53
|
+
mute: "#9198a6",
|
|
54
|
+
hair: "#eceef31f",
|
|
55
|
+
line: "#eceef340",
|
|
56
|
+
sh: "#000000",
|
|
57
|
+
"on-c": "#0d0e12",
|
|
58
|
+
"c-blue": "#7e7ef6",
|
|
59
|
+
"t-blue": "#989cfd",
|
|
60
|
+
"c-amber": "#c78135",
|
|
61
|
+
"t-amber": "#dd954b",
|
|
62
|
+
"c-green": "#20ac7a",
|
|
63
|
+
"t-green": "#35b986",
|
|
64
|
+
"c-violet": "#695b9f",
|
|
65
|
+
"t-violet": "#a79ae3",
|
|
66
|
+
"c-rose": "#bc434b",
|
|
67
|
+
"t-rose": "#fd7d81",
|
|
68
|
+
"c-slate": "#9ba3b2",
|
|
69
|
+
"t-slate": "#9da5b4",
|
|
70
|
+
coin: "#f0c040",
|
|
71
|
+
coint: "#f0c040",
|
|
72
|
+
coinin: "#9a6a0c",
|
|
73
|
+
tint: "6%",
|
|
74
|
+
edge: "19%",
|
|
75
|
+
shA: ".45",
|
|
76
|
+
shB: ".35"
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
paper: {
|
|
80
|
+
name: "\u7D19\u3068\u58A8",
|
|
81
|
+
note: "\u751F\u6210\u308A\u306E\u7D19\u306E\u5730\u306B\u3001\u85CD / \u9EC4\u571F / \u82D4 / \u8461\u8404 / \u6731 / \u920D\u306E\u304F\u3059\u3093\u3060 6 \u8272",
|
|
82
|
+
light: {
|
|
83
|
+
page: "#ece7dd",
|
|
84
|
+
bg: "#f9f6f0",
|
|
85
|
+
surf: "#fffcf6",
|
|
86
|
+
sunk: "#f2ede4",
|
|
87
|
+
ink: "#221e18",
|
|
88
|
+
ink2: "#4b453b",
|
|
89
|
+
mute: "#7b7366",
|
|
90
|
+
hair: "#221e181f",
|
|
91
|
+
line: "#221e1847",
|
|
92
|
+
sh: "#3a2a10",
|
|
93
|
+
"on-c": "#fffcf6",
|
|
94
|
+
"c-blue": "#487dd5",
|
|
95
|
+
"t-blue": "#2d60b5",
|
|
96
|
+
"c-amber": "#c38405",
|
|
97
|
+
"t-amber": "#885a01",
|
|
98
|
+
"c-green": "#57a271",
|
|
99
|
+
"t-green": "#237143",
|
|
100
|
+
"c-violet": "#904698",
|
|
101
|
+
"t-violet": "#904698",
|
|
102
|
+
"c-rose": "#a9513e",
|
|
103
|
+
"t-rose": "#9f4836",
|
|
104
|
+
"c-slate": "#6a645a",
|
|
105
|
+
"t-slate": "#696359",
|
|
106
|
+
coin: "#d4a52a",
|
|
107
|
+
coint: "#7d5e05",
|
|
108
|
+
coinin: "#9a7016",
|
|
109
|
+
tint: "6%",
|
|
110
|
+
edge: "22%",
|
|
111
|
+
shA: ".06",
|
|
112
|
+
shB: ".07",
|
|
113
|
+
carry: "#68635c"
|
|
114
|
+
},
|
|
115
|
+
dark: {
|
|
116
|
+
page: "#0e0d0b",
|
|
117
|
+
bg: "#15130f",
|
|
118
|
+
surf: "#1e1b17",
|
|
119
|
+
sunk: "#191612",
|
|
120
|
+
ink: "#ede6d8",
|
|
121
|
+
ink2: "#cbc2b1",
|
|
122
|
+
mute: "#9c9283",
|
|
123
|
+
hair: "#ede6d81f",
|
|
124
|
+
line: "#ede6d842",
|
|
125
|
+
sh: "#000000",
|
|
126
|
+
"on-c": "#15130f",
|
|
127
|
+
"c-blue": "#5785d5",
|
|
128
|
+
"t-blue": "#76a6f9",
|
|
129
|
+
"c-amber": "#be8802",
|
|
130
|
+
"t-amber": "#d59e2f",
|
|
131
|
+
"c-green": "#52aa71",
|
|
132
|
+
"t-green": "#61b87e",
|
|
133
|
+
"c-violet": "#90529b",
|
|
134
|
+
"t-violet": "#d08edb",
|
|
135
|
+
"c-rose": "#bb4e3d",
|
|
136
|
+
"t-rose": "#f98672",
|
|
137
|
+
"c-slate": "#a9a295",
|
|
138
|
+
"t-slate": "#aca598",
|
|
139
|
+
coin: "#dcb24e",
|
|
140
|
+
coint: "#dcb24e",
|
|
141
|
+
coinin: "#8a6a14",
|
|
142
|
+
tint: "6%",
|
|
143
|
+
edge: "19%",
|
|
144
|
+
shA: ".45",
|
|
145
|
+
shB: ".35"
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
night: {
|
|
149
|
+
name: "\u591C\u306E\u8A08\u5668",
|
|
150
|
+
note: "\u9752\u307F\u306E\u9ED2\u306E\u5730\u306B\u3001\u5149\u308B\u6C34\u8272 / \u7425\u73C0 / \u82E5\u7DD1 / \u83EB / \u6843 \u306E 6 \u8272\u3002\u660E\u308B\u3044\u5074\u306F\u9752\u7070\u306E\u5730",
|
|
151
|
+
light: {
|
|
152
|
+
page: "#e9eef5",
|
|
153
|
+
bg: "#f6f9fc",
|
|
154
|
+
surf: "#ffffff",
|
|
155
|
+
sunk: "#eef3f8",
|
|
156
|
+
ink: "#0b1424",
|
|
157
|
+
ink2: "#34425a",
|
|
158
|
+
mute: "#64748b",
|
|
159
|
+
hair: "#0b14241c",
|
|
160
|
+
line: "#0b142440",
|
|
161
|
+
sh: "#0b1424",
|
|
162
|
+
"on-c": "#ffffff",
|
|
163
|
+
"c-blue": "#0385cd",
|
|
164
|
+
"t-blue": "#086aa3",
|
|
165
|
+
"c-amber": "#ba8e0f",
|
|
166
|
+
"t-amber": "#7f5f04",
|
|
167
|
+
"c-green": "#0a8857",
|
|
168
|
+
"t-green": "#027449",
|
|
169
|
+
"c-violet": "#5839ba",
|
|
170
|
+
"t-violet": "#5839ba",
|
|
171
|
+
"c-rose": "#dd4a94",
|
|
172
|
+
"t-rose": "#b82375",
|
|
173
|
+
"c-slate": "#64748b",
|
|
174
|
+
"t-slate": "#56667c",
|
|
175
|
+
coin: "#eab308",
|
|
176
|
+
coint: "#7e6005",
|
|
177
|
+
coinin: "#a16207",
|
|
178
|
+
tint: "5%",
|
|
179
|
+
edge: "22%",
|
|
180
|
+
shA: ".06",
|
|
181
|
+
shB: ".09",
|
|
182
|
+
carry: "#596579"
|
|
183
|
+
},
|
|
184
|
+
dark: {
|
|
185
|
+
page: "#060a12",
|
|
186
|
+
bg: "#0a101c",
|
|
187
|
+
surf: "#111a2a",
|
|
188
|
+
sunk: "#0d1522",
|
|
189
|
+
ink: "#e6edf7",
|
|
190
|
+
ink2: "#b8c4d6",
|
|
191
|
+
mute: "#8090a8",
|
|
192
|
+
hair: "#e6edf71c",
|
|
193
|
+
line: "#9fb3d145",
|
|
194
|
+
sh: "#000000",
|
|
195
|
+
"on-c": "#0a101c",
|
|
196
|
+
"c-blue": "#3884b6",
|
|
197
|
+
"t-blue": "#62ace1",
|
|
198
|
+
"c-amber": "#be8533",
|
|
199
|
+
"t-amber": "#d59b4b",
|
|
200
|
+
"c-green": "#3ba774",
|
|
201
|
+
"t-green": "#4fb884",
|
|
202
|
+
"c-violet": "#7d4ecd",
|
|
203
|
+
"t-violet": "#b494fd",
|
|
204
|
+
"c-rose": "#bc3a74",
|
|
205
|
+
"t-rose": "#ff77ad",
|
|
206
|
+
"c-slate": "#96a3b5",
|
|
207
|
+
"t-slate": "#99a6b8",
|
|
208
|
+
coin: "#facc15",
|
|
209
|
+
coint: "#facc15",
|
|
210
|
+
coinin: "#a16207",
|
|
211
|
+
tint: "6%",
|
|
212
|
+
edge: "19%",
|
|
213
|
+
shA: ".5",
|
|
214
|
+
shB: ".4"
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
// src/look/fonts.ts
|
|
220
|
+
var FONTS = { sans: "Noto Sans JP Variable", mono: "JetBrains Mono Variable" };
|
|
221
|
+
var SANS_ADVANCE = { "0": 590, "1": 590, "2": 590, "3": 590, "4": 590, "5": 590, "6": 590, "7": 590, "8": 590, "9": 590, " ": 228, "!": 371, '"': 575, "#": 590, "$": 590, "%": 963, "&": 740, "'": 325, "(": 378, ")": 378, "*": 507, "+": 590, ",": 325, "-": 371, ".": 325, "/": 390, ":": 325, ";": 325, "<": 590, "=": 590, ">": 590, "?": 514, "@": 1007, "A": 642, "B": 682, "C": 657, "D": 715, "E": 616, "F": 586, "G": 718, "H": 758, "I": 330, "J": 568, "K": 686, "L": 579, "M": 854, "N": 750, "O": 771, "P": 668, "Q": 771, "R": 682, "S": 624, "T": 626, "U": 748, "V": 619, "W": 915, "X": 627, "Y": 581, "Z": 614, "[": 378, "\\": 390, "]": 378, "^": 590, "_": 568, "`": 626, "a": 591, "b": 644, "c": 528, "d": 645, "e": 581, "f": 372, "g": 598, "h": 640, "i": 305, "j": 306, "k": 605, "l": 315, "m": 964, "n": 641, "o": 626, "p": 645, "q": 645, "r": 437, "s": 495, "t": 421, "u": 638, "v": 576, "w": 863, "x": 562, "y": 575, "z": 512, "{": 378, "|": 297, "}": 378, "~": 590, "\u2026": 1e3, "\u2212": 590, "\xD7": 1e3, "\u2192": 1e3, "\u2190": 1e3, "\u2191": 1e3, "\u2193": 1e3, "\u2013": 545, "\u2014": 908, "\u2018": 325, "\u2019": 325, "\u201C": 575, "\u201D": 575, "\xB0": 404, "\xB1": 1e3, "\xB7": 593, "\u2022": 379 };
|
|
222
|
+
var MONO_ADVANCE = 600;
|
|
223
|
+
var WIDE_FROM = 11904;
|
|
224
|
+
var EM = 1e3;
|
|
225
|
+
function advance(ch, family) {
|
|
226
|
+
if ((ch.codePointAt(0) ?? 0) >= WIDE_FROM) return EM;
|
|
227
|
+
if (family === "mono") return MONO_ADVANCE;
|
|
228
|
+
return SANS_ADVANCE[ch] ?? EM;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// src/look/values.ts
|
|
232
|
+
var DEFAULT_PALETTE = "paper";
|
|
233
|
+
var PALETTES = Object.fromEntries(
|
|
234
|
+
Object.entries(palettes_default).map(([id, p]) => [id, { id, ...p }])
|
|
235
|
+
);
|
|
236
|
+
function resolvePalette(id) {
|
|
237
|
+
const found = id !== void 0 && Object.hasOwn(PALETTES, id) ? PALETTES[id] : void 0;
|
|
238
|
+
return found ?? PALETTES[DEFAULT_PALETTE];
|
|
239
|
+
}
|
|
240
|
+
function paletteVars(palette, theme) {
|
|
241
|
+
return Object.entries(palette[theme]).map(([key, value]) => `--${key}:${value}`).join(";");
|
|
242
|
+
}
|
|
243
|
+
var FONT_VARS = `--sans:"${FONTS.sans}";--mono:"${FONTS.mono}"`;
|
|
244
|
+
var COLOR_ORDER = ["blue", "amber", "green", "violet", "rose"];
|
|
245
|
+
var text = (size, weight, family = "sans") => ({ size, weight, family });
|
|
246
|
+
var TYPE = {
|
|
247
|
+
boxName: text(13, 650),
|
|
248
|
+
boxSub: text(11, 500),
|
|
249
|
+
boxSubStrong: text(11, 700),
|
|
250
|
+
regionName: text(12.5, 700),
|
|
251
|
+
regionNote: text(11, 500),
|
|
252
|
+
label: text(11, 600, "mono"),
|
|
253
|
+
labelJa: text(11, 650),
|
|
254
|
+
action: text(11, 650),
|
|
255
|
+
badge: text(10.5, 700, "mono"),
|
|
256
|
+
carrier: text(10.5, 700, "mono"),
|
|
257
|
+
carrierJa: text(10.5, 700),
|
|
258
|
+
stripTitle: text(12.5, 700),
|
|
259
|
+
fieldName: text(10.5, 600),
|
|
260
|
+
fieldValue: text(12, 600, "mono"),
|
|
261
|
+
fieldValueJa: text(12, 600),
|
|
262
|
+
tag: text(10.5, 700),
|
|
263
|
+
miniTitle: text(10.5, 700),
|
|
264
|
+
stepTitle: text(15, 700),
|
|
265
|
+
stepBody: text(13.5, 500),
|
|
266
|
+
stepNo: text(13, 700, "mono"),
|
|
267
|
+
button: text(14, 700)
|
|
268
|
+
};
|
|
269
|
+
var LOOK = {
|
|
270
|
+
/** 部品どうしの最小の隙間 */
|
|
271
|
+
gap: 10,
|
|
272
|
+
/** 図の外周の余白 */
|
|
273
|
+
margin: 14,
|
|
274
|
+
box: { h: 72, minW: 92, padX: 12, radius: 12, icon: 24, iconRadius: 7, iconY: -16, iconScale: 0.74, nameY: 12, subY: 27 },
|
|
275
|
+
region: { pad: 18, gap: 10, radius: 14, inset: 14, icon: 24, iconRadius: 7, iconScale: 0.68, nameY: 58, line: 16, minH: 108 },
|
|
276
|
+
architecture: { columns: 4, columnGap: 56, maxColumnGap: 160, rowGap: 44, labelRoom: 16 },
|
|
277
|
+
sequence: { columnGap: 40, labelRoom: 16, firstRow: 22, rowGap: 14, stepGap: 8, minPitch: 40, tail: 18, selfW: 34, selfH: 18 },
|
|
278
|
+
edge: { inset: 3, arrow: 6, arrowHalf: 3.5, parallel: 5, ghostDash: 5, flowDash: 9 },
|
|
279
|
+
label: { h: 20, padX: 9, radius: 10, offset: 22, side: 14, search: 4, searchMax: 400, soft: 6 },
|
|
280
|
+
action: { h: 22, padX: 10, radius: 11 },
|
|
281
|
+
badge: { r: 9.5, ring: 9, inset: 4, along: 14, short: 44 },
|
|
282
|
+
carrier: { envW: 24, envH: 17, coinR: 6.5, coinIn: 3.8, tagH: 18, tagPadX: 8, samples: 16 },
|
|
283
|
+
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 },
|
|
284
|
+
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 },
|
|
285
|
+
shadow: { near: 0.8, far: 4, nearY: 1, farY: 3 },
|
|
286
|
+
mini: { w: 168, pad: 8, title: 14, inset: 12, radius: 10 },
|
|
287
|
+
/** 寄って追う見せ方の窓の高さの、幅に対する割合と下限 */
|
|
288
|
+
follow: { aspect: 0.75, minH: 320, ease: 0.6 },
|
|
289
|
+
/** 色を混ぜる割合 (%) */
|
|
290
|
+
mix: { icon: 14, regionIcon: 16, regionIconEdge: 34, cap: 12, capEdge: 42, badgePast: 14, badgePastEdge: 70, mini: 62, miniBand: 16, miniBandEdge: 36, view: 6 },
|
|
291
|
+
/** 字の並びの基準線を、置きたい高さの真ん中からどれだけ下げるか */
|
|
292
|
+
baseline: { label: 3.8, badge: 3.5, carrier: 3.7, stripTitle: 4.5, tag: 3.6, action: 3.8 },
|
|
293
|
+
/** 浮いて出る物が下から上がる長さと、弾んで出る物の始まりの大きさ */
|
|
294
|
+
rise: 5,
|
|
295
|
+
popFrom: 0.4};
|
|
296
|
+
var MOTION = {
|
|
297
|
+
/** 最初の段の前に全体を見せる長さ */
|
|
298
|
+
intro: 1.4,
|
|
299
|
+
/** 最後の段の後に全体を見せる長さ */
|
|
300
|
+
outro: 4.6,
|
|
301
|
+
/** 繰り返す前に消えていく長さ */
|
|
302
|
+
tail: 0.6,
|
|
303
|
+
/** 段の長さ。本文の字数で伸ばし、段で起きることが全部見えてから dwell 秒は留める */
|
|
304
|
+
stepBase: 1.2,
|
|
305
|
+
perChar: 0.025,
|
|
306
|
+
stepMin: 2.2,
|
|
307
|
+
stepMax: 5,
|
|
308
|
+
dwell: 1.2,
|
|
309
|
+
/** 段の中で最初の線を引き始めるまでと、続く線を引き始める間 */
|
|
310
|
+
edgeAt: 0.1,
|
|
311
|
+
stagger: 0.5,
|
|
312
|
+
/** 線を引く長さ。運ぶ物を載せた線は運ぶ物が走るので長い */
|
|
313
|
+
draw: 0.55,
|
|
314
|
+
drawCarry: 0.9,
|
|
315
|
+
/** 処理を読む間 (次の線と書き換えはこれだけ待つ) と、書き換えが続く間 */
|
|
316
|
+
action: 0.9,
|
|
317
|
+
change: 0.12,
|
|
318
|
+
/** 箱の下の字が見えている短さの下限。これより早く次の字に替わる字は出さない */
|
|
319
|
+
minShow: 0.8,
|
|
320
|
+
/** 線の名前が線より遅れて出る長さと、出入りの長さ */
|
|
321
|
+
labelDelay: 0.15,
|
|
322
|
+
fade: 0.3,
|
|
323
|
+
popFade: 0.4,
|
|
324
|
+
untilFade: 0.2,
|
|
325
|
+
/** 段の止め絵を撮る時刻を、段の終わりからどれだけ前にするか */
|
|
326
|
+
still: 0.45
|
|
327
|
+
};
|
|
328
|
+
var READABLE_PX = 10.5;
|
|
329
|
+
var EASE = {
|
|
330
|
+
inOut: "cubic-bezier(.65,0,.35,1)",
|
|
331
|
+
out: "cubic-bezier(.22,1,.36,1)",
|
|
332
|
+
pop: "cubic-bezier(.34,1.56,.64,1)"
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
// src/figure-text.ts
|
|
336
|
+
var FIGURE_TEXT = {
|
|
337
|
+
ja: {
|
|
338
|
+
cannotDraw: (detail) => `\u56F3\u3092\u63CF\u3051\u306A\u3044: ${detail}`,
|
|
339
|
+
overview: "\u5168\u4F53\u56F3",
|
|
340
|
+
prev: "\u524D\u306E\u6BB5",
|
|
341
|
+
pause: "\u6B62\u3081\u308B",
|
|
342
|
+
play: "\u52D5\u304B\u3059",
|
|
343
|
+
next: "\u6B21\u306E\u6BB5",
|
|
344
|
+
steps: (title) => `${title} \u306E\u6BB5`
|
|
345
|
+
},
|
|
346
|
+
en: {
|
|
347
|
+
cannotDraw: (detail) => `Cannot draw the diagram: ${detail}`,
|
|
348
|
+
overview: "Overview",
|
|
349
|
+
prev: "Previous step",
|
|
350
|
+
pause: "Pause",
|
|
351
|
+
play: "Play",
|
|
352
|
+
next: "Next step",
|
|
353
|
+
steps: (title) => `Steps of ${title}`
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
// src/layout/measure.ts
|
|
358
|
+
var hasWide = (text2) => [...text2].some((ch) => (ch.codePointAt(0) ?? 0) >= 11904);
|
|
359
|
+
function familyFor(text2, preferred) {
|
|
360
|
+
return preferred === "mono" && hasWide(text2) ? "sans" : preferred;
|
|
361
|
+
}
|
|
362
|
+
function textWidth(text2, style) {
|
|
363
|
+
const family = familyFor(text2, style.family);
|
|
364
|
+
let sum = 0;
|
|
365
|
+
for (const ch of text2) sum += advance(ch, family);
|
|
366
|
+
return sum * style.size / EM;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
// src/layout/scene.ts
|
|
370
|
+
function edgesOf(diagram) {
|
|
371
|
+
return diagram.steps.flatMap(
|
|
372
|
+
(step, s) => step.events.flatMap((event, e) => event.type === "edge" ? [{ step: s, event: e, edge: event }] : [])
|
|
373
|
+
);
|
|
374
|
+
}
|
|
375
|
+
function boxColors(diagram) {
|
|
376
|
+
const regions = regionColors(diagram);
|
|
377
|
+
const colors = /* @__PURE__ */ new Map();
|
|
378
|
+
diagram.boxes.forEach((box, i) => {
|
|
379
|
+
const fromRegion = box.region === void 0 ? void 0 : regions.get(box.region);
|
|
380
|
+
colors.set(box.id, box.color ?? fromRegion ?? COLOR_ORDER[i % COLOR_ORDER.length]);
|
|
381
|
+
});
|
|
382
|
+
return colors;
|
|
383
|
+
}
|
|
384
|
+
function regionColors(diagram) {
|
|
385
|
+
const colors = /* @__PURE__ */ new Map();
|
|
386
|
+
(diagram.regions ?? []).forEach((region, i) => colors.set(region.id, region.color ?? COLOR_ORDER[i % COLOR_ORDER.length]));
|
|
387
|
+
return colors;
|
|
388
|
+
}
|
|
389
|
+
var edgeColor = (edge2, colors) => edge2.carry.kind === "coin" ? "coin" : colors.get(edge2.from) ?? "slate";
|
|
390
|
+
function boxWidth(diagram, id, withActions) {
|
|
391
|
+
const box = diagram.boxes.find((b) => b.id === id);
|
|
392
|
+
if (!box) return LOOK.box.minW;
|
|
393
|
+
const lines = [textWidth(box.name, TYPE.boxName), textWidth(box.sub ?? "", TYPE.boxSub)];
|
|
394
|
+
for (const step of diagram.steps) {
|
|
395
|
+
for (const event of step.events) {
|
|
396
|
+
if (event.type === "swap" && event.box === id) lines.push(textWidth(event.text, TYPE.boxSubStrong));
|
|
397
|
+
if (withActions && event.type === "action" && event.box === id) lines.push(textWidth(event.label, TYPE.boxSubStrong));
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
return Math.max(LOOK.box.minW, Math.max(...lines) + LOOK.box.padX * 2);
|
|
401
|
+
}
|
|
402
|
+
function gapBetween(a, b) {
|
|
403
|
+
const dx = Math.max(b.x - (a.x + a.w), a.x - (b.x + b.w));
|
|
404
|
+
const dy = Math.max(b.y - (a.y + a.h), a.y - (b.y + b.h));
|
|
405
|
+
return Math.max(dx, dy);
|
|
406
|
+
}
|
|
407
|
+
function longest(points) {
|
|
408
|
+
let best = { a: points[0], b: points[1] ?? points[0], length: -1 };
|
|
409
|
+
for (let i = 1; i < points.length; i++) {
|
|
410
|
+
const a = points[i - 1];
|
|
411
|
+
const b = points[i];
|
|
412
|
+
const length = Math.hypot(b[0] - a[0], b[1] - a[1]);
|
|
413
|
+
if (length > best.length) best = { a, b, length };
|
|
414
|
+
}
|
|
415
|
+
return { a: best.a, b: best.b, vertical: Math.abs(best.b[0] - best.a[0]) < Math.abs(best.b[1] - best.a[1]) };
|
|
416
|
+
}
|
|
417
|
+
function along(points, distance) {
|
|
418
|
+
let left = distance;
|
|
419
|
+
for (let i = 1; i < points.length; i++) {
|
|
420
|
+
const a = points[i - 1];
|
|
421
|
+
const b = points[i];
|
|
422
|
+
const length = Math.hypot(b[0] - a[0], b[1] - a[1]);
|
|
423
|
+
if (left <= length && length > 0) return [a[0] + (b[0] - a[0]) * left / length, a[1] + (b[1] - a[1]) * left / length];
|
|
424
|
+
left -= length;
|
|
425
|
+
}
|
|
426
|
+
return points[points.length - 1];
|
|
427
|
+
}
|
|
428
|
+
function pathLength(points) {
|
|
429
|
+
let sum = 0;
|
|
430
|
+
for (let i = 1; i < points.length; i++) {
|
|
431
|
+
const a = points[i - 1];
|
|
432
|
+
const b = points[i];
|
|
433
|
+
sum += Math.hypot(b[0] - a[0], b[1] - a[1]);
|
|
434
|
+
}
|
|
435
|
+
return sum;
|
|
436
|
+
}
|
|
437
|
+
function badgeOnPath(points) {
|
|
438
|
+
const length = pathLength(points);
|
|
439
|
+
return along(points, length < LOOK.badge.short ? length / 2 : LOOK.badge.along);
|
|
440
|
+
}
|
|
441
|
+
var labelStyle = (text2) => hasWide(text2) ? TYPE.labelJa : TYPE.label;
|
|
442
|
+
function placeLabel(request, obstacles) {
|
|
443
|
+
const w = textWidth(request.text, labelStyle(request.text)) + LOOK.label.padX * 2;
|
|
444
|
+
const h = LOOK.label.h;
|
|
445
|
+
const segment = longest(request.points);
|
|
446
|
+
const mx = (segment.a[0] + segment.b[0]) / 2;
|
|
447
|
+
const my = (segment.a[1] + segment.b[1]) / 2;
|
|
448
|
+
const side = request.side ?? (segment.vertical ? "right" : "above");
|
|
449
|
+
const { offset, side: sideGap } = LOOK.label;
|
|
450
|
+
const base = side === "above" ? { x: mx - w / 2, y: my - offset - h / 2, w, h } : side === "below" ? { x: mx - w / 2, y: my + offset - h / 2, w, h } : side === "left" ? { x: mx - sideGap - w, y: my - h / 2, w, h } : { x: mx + sideGap, y: my - h / 2, w, h };
|
|
451
|
+
const away = side === "above" ? [0, -1] : side === "below" ? [0, 1] : side === "left" ? [-1, 0] : [1, 0];
|
|
452
|
+
const slideAxis = [Math.abs(away[1]), Math.abs(away[0])];
|
|
453
|
+
const slideMax = side === "above" || side === "below" ? w : h * 4;
|
|
454
|
+
const clear = (rect) => obstacles.hard.every((box) => gapBetween(rect, box) >= LOOK.gap) && obstacles.soft.every((other) => gapBetween(rect, other) >= LOOK.label.soft);
|
|
455
|
+
const { search, searchMax } = LOOK.label;
|
|
456
|
+
for (let d = 0; d <= searchMax; d += search) {
|
|
457
|
+
for (let s = 0; s <= slideMax; s += search) {
|
|
458
|
+
for (const sign of s === 0 ? [1] : [1, -1]) {
|
|
459
|
+
const rect = { x: base.x + away[0] * d + slideAxis[0] * s * sign, y: base.y + away[1] * d + slideAxis[1] * s * sign, w, h };
|
|
460
|
+
if (clear(rect)) return { ...rect, step: request.step, event: request.event, text: request.text, family: labelStyle(request.text).family, color: request.color };
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
return { ...base, step: request.step, event: request.event, text: request.text, family: labelStyle(request.text).family, color: request.color };
|
|
465
|
+
}
|
|
466
|
+
function fieldWidth(diagram, name) {
|
|
467
|
+
let value = 0;
|
|
468
|
+
let tag = 0;
|
|
469
|
+
for (const step of diagram.steps) {
|
|
470
|
+
for (const event of step.events) {
|
|
471
|
+
if (event.type !== "strip" || event.field !== name) continue;
|
|
472
|
+
if (event.value !== void 0) value = Math.max(value, textWidth(event.value, hasWide(event.value) ? TYPE.fieldValueJa : TYPE.fieldValue));
|
|
473
|
+
if (event.tag !== void 0) tag = Math.max(tag, textWidth(event.tag, TYPE.tag) + LOOK.strip.tagPadX * 2);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
const both = value + (tag > 0 ? (value > 0 ? LOOK.strip.tagGap : 0) + tag : 0);
|
|
477
|
+
return Math.max(textWidth(name, TYPE.fieldName), both);
|
|
478
|
+
}
|
|
479
|
+
function stripNeed(diagram) {
|
|
480
|
+
if (!diagram.strip) return 0;
|
|
481
|
+
const { titleX, fieldGap, pad: pad2 } = LOOK.strip;
|
|
482
|
+
const start = titleX + textWidth(diagram.strip.title, TYPE.stripTitle) + fieldGap;
|
|
483
|
+
return start + diagram.strip.fields.reduce((sum, name) => sum + fieldWidth(diagram, name) + fieldGap, 0) - fieldGap + pad2;
|
|
484
|
+
}
|
|
485
|
+
function layoutStrip(diagram, x, y, width) {
|
|
486
|
+
if (!diagram.strip) return void 0;
|
|
487
|
+
const { titleX, fieldGap, pad: pad2, line, h } = LOOK.strip;
|
|
488
|
+
const start = titleX + textWidth(diagram.strip.title, TYPE.stripTitle) + fieldGap;
|
|
489
|
+
const fields = [];
|
|
490
|
+
let cx = start;
|
|
491
|
+
let row = 0;
|
|
492
|
+
for (const name of diagram.strip.fields) {
|
|
493
|
+
const w = fieldWidth(diagram, name);
|
|
494
|
+
if (cx > start && cx + w > width - pad2) {
|
|
495
|
+
cx = start;
|
|
496
|
+
row++;
|
|
497
|
+
}
|
|
498
|
+
fields.push({ name, x: x + cx, y: y + row * line, w });
|
|
499
|
+
cx += w + fieldGap;
|
|
500
|
+
}
|
|
501
|
+
return { x, y, w: width, h: h + row * line, title: diagram.strip.title, fields };
|
|
502
|
+
}
|
|
503
|
+
function shiftContent(layout, dx, dy) {
|
|
504
|
+
const move = (rect) => {
|
|
505
|
+
rect.x += dx;
|
|
506
|
+
rect.y += dy;
|
|
507
|
+
};
|
|
508
|
+
for (const box of layout.boxes) {
|
|
509
|
+
move(box);
|
|
510
|
+
box.cx += dx;
|
|
511
|
+
box.cy += dy;
|
|
512
|
+
}
|
|
513
|
+
for (const region of layout.regions) {
|
|
514
|
+
region.y += dy;
|
|
515
|
+
move(region.header);
|
|
516
|
+
}
|
|
517
|
+
for (const line of layout.lifelines) {
|
|
518
|
+
line.x += dx;
|
|
519
|
+
line.y1 += dy;
|
|
520
|
+
line.y2 += dy;
|
|
521
|
+
}
|
|
522
|
+
for (const edge2 of layout.edges) {
|
|
523
|
+
edge2.points = edge2.points.map(([px, py]) => [px + dx, py + dy]);
|
|
524
|
+
if (edge2.settle) edge2.settle = [edge2.settle[0] + dx, edge2.settle[1] + dy];
|
|
525
|
+
}
|
|
526
|
+
for (const label2 of layout.labels) move(label2);
|
|
527
|
+
for (const action2 of layout.actions) move(action2);
|
|
528
|
+
for (const badge2 of layout.badges) {
|
|
529
|
+
badge2.x += dx;
|
|
530
|
+
badge2.y += dy;
|
|
531
|
+
}
|
|
532
|
+
if (layout.strip) {
|
|
533
|
+
layout.strip.y += dy;
|
|
534
|
+
for (const field of layout.strip.fields) {
|
|
535
|
+
field.x += dx;
|
|
536
|
+
field.y += dy;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
function cornerBadge(events, step, layout) {
|
|
541
|
+
const { inset } = LOOK.badge;
|
|
542
|
+
for (const event of events) {
|
|
543
|
+
const id = event.type === "swap" || event.type === "action" ? event.box : void 0;
|
|
544
|
+
const box2 = layout.boxes.find((b) => b.id === id);
|
|
545
|
+
if (box2) return { step, x: box2.x + inset, y: box2.y + inset, color: box2.color };
|
|
546
|
+
}
|
|
547
|
+
if (layout.strip && events.some((event) => event.type === "strip")) return { step, x: layout.strip.x + inset, y: layout.strip.y + inset, color: "slate" };
|
|
548
|
+
const box = layout.boxes[0];
|
|
549
|
+
return { step, x: box.x + inset, y: box.y + inset, color: box.color };
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
// src/layout/architecture.ts
|
|
553
|
+
function layoutArchitecture(diagram) {
|
|
554
|
+
const groups = groupsOf(diagram);
|
|
555
|
+
const slots = placeBoxes(diagram, groups);
|
|
556
|
+
const rooms = groups.map(() => ({ top: 0, bottom: 0 }));
|
|
557
|
+
let layout = arrange(diagram, groups, slots, rooms);
|
|
558
|
+
for (let pass = 0; pass < 3 && grow(layout, groups, slots, rooms); pass++) layout = arrange(diagram, groups, slots, rooms);
|
|
559
|
+
return layout;
|
|
560
|
+
}
|
|
561
|
+
function groupsOf(diagram) {
|
|
562
|
+
const regions = diagram.regions ?? [];
|
|
563
|
+
const known = new Set(regions.map((r) => r.id));
|
|
564
|
+
const groups = regions.map((region) => ({ region, members: diagram.boxes.filter((b) => b.region === region.id).map((b) => b.id) }));
|
|
565
|
+
const loose = diagram.boxes.filter((b) => b.region === void 0 || !known.has(b.region)).map((b) => b.id);
|
|
566
|
+
if (loose.length > 0) groups.push({ members: loose });
|
|
567
|
+
return groups;
|
|
568
|
+
}
|
|
569
|
+
var vertical = (side) => side === "left" || side === "right";
|
|
570
|
+
function placeBoxes(diagram, groups) {
|
|
571
|
+
const columns = LOOK.architecture.columns;
|
|
572
|
+
const edges = edgesOf(diagram).map((e) => e.edge);
|
|
573
|
+
const slots = /* @__PURE__ */ new Map();
|
|
574
|
+
groups.forEach((group, g) => {
|
|
575
|
+
const inGroup = new Set(group.members);
|
|
576
|
+
const taken = /* @__PURE__ */ new Set();
|
|
577
|
+
const free = (col, row) => col >= 0 && col < columns && !taken.has(`${col},${row}`);
|
|
578
|
+
const near = (col, row) => {
|
|
579
|
+
const start = Math.min(columns - 1, Math.max(0, col));
|
|
580
|
+
for (let r = row; ; r++) {
|
|
581
|
+
for (let d = 0; d < columns; d++) {
|
|
582
|
+
for (const c of [start + d, start - d]) if (free(c, r)) return [c, r];
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
};
|
|
586
|
+
const put = (id, col, row) => {
|
|
587
|
+
slots.set(id, { group: g, col, row });
|
|
588
|
+
taken.add(`${col},${row}`);
|
|
589
|
+
};
|
|
590
|
+
let dir = 1;
|
|
591
|
+
const visit = (id) => {
|
|
592
|
+
for (const edge2 of edges) {
|
|
593
|
+
const partner = edge2.from === id ? edge2.to : edge2.to === id ? edge2.from : void 0;
|
|
594
|
+
if (partner === void 0 || !inGroup.has(partner) || slots.has(partner)) continue;
|
|
595
|
+
const me = slots.get(id);
|
|
596
|
+
const [c, r] = vertical(edge2.labelSide) ? near(me.col, me.row + 1) : free(me.col + dir, me.row) ? [me.col + dir, me.row] : near(me.col + dir, me.row);
|
|
597
|
+
put(partner, c, r);
|
|
598
|
+
visit(partner);
|
|
599
|
+
}
|
|
600
|
+
};
|
|
601
|
+
const anchorOf = (id) => {
|
|
602
|
+
for (let i = 0; i < edges.length; i++) {
|
|
603
|
+
const edge2 = edges[i];
|
|
604
|
+
const partner = edge2?.from === id ? edge2.to : edge2?.to === id ? edge2.from : void 0;
|
|
605
|
+
const slot = partner === void 0 ? void 0 : slots.get(partner);
|
|
606
|
+
if (slot && slot.group < g) return { order: i, col: slot.col };
|
|
607
|
+
}
|
|
608
|
+
return void 0;
|
|
609
|
+
};
|
|
610
|
+
let placed = 0;
|
|
611
|
+
for (; ; ) {
|
|
612
|
+
const rest = group.members.filter((id) => !slots.has(id));
|
|
613
|
+
if (rest.length === 0) break;
|
|
614
|
+
const anchored = rest.map((id) => ({ id, anchor: anchorOf(id) })).filter((a) => a.anchor !== void 0);
|
|
615
|
+
anchored.sort((a, b) => (a.anchor?.order ?? 0) - (b.anchor?.order ?? 0));
|
|
616
|
+
const pick = anchored[0] ?? { id: rest[0], anchor: void 0 };
|
|
617
|
+
const want = pick.anchor?.col ?? 0;
|
|
618
|
+
if (placed === 0) dir = want >= (columns - 1) / 2 ? -1 : 1;
|
|
619
|
+
const [c, r] = free(want, 0) ? [want, 0] : near(want, 0);
|
|
620
|
+
put(pick.id, c, r);
|
|
621
|
+
visit(pick.id);
|
|
622
|
+
placed++;
|
|
623
|
+
}
|
|
624
|
+
});
|
|
625
|
+
const used = [...new Set([...slots.values()].map((s) => s.col))].sort((a, b) => a - b);
|
|
626
|
+
for (const slot of slots.values()) slot.col = used.indexOf(slot.col);
|
|
627
|
+
return slots;
|
|
628
|
+
}
|
|
629
|
+
function nameLines(name) {
|
|
630
|
+
const spaces = [...name.matchAll(/ /g)].map((m) => m.index);
|
|
631
|
+
if (spaces.length === 0) return [name];
|
|
632
|
+
const at2 = spaces.reduce((best, i) => Math.abs(i - name.length / 2) < Math.abs(best - name.length / 2) ? i : best);
|
|
633
|
+
return [name.slice(0, at2), name.slice(at2 + 1)];
|
|
634
|
+
}
|
|
635
|
+
function headerSize(region) {
|
|
636
|
+
const { icon, nameY, line, inset } = LOOK.region;
|
|
637
|
+
const lines = nameLines(region.name);
|
|
638
|
+
const w = Math.max(icon, ...lines.map((l) => textWidth(l, TYPE.regionName)), textWidth(region.note ?? "", TYPE.regionNote));
|
|
639
|
+
const h = nameY - inset + (lines.length - 1) * line + (region.note ? line : 0) + LOOK.gap / 2;
|
|
640
|
+
return { w, h, lines };
|
|
641
|
+
}
|
|
642
|
+
function arrange(diagram, groups, slots, rooms) {
|
|
643
|
+
const { box: B, region: R, architecture: A, margin, gap } = LOOK;
|
|
644
|
+
const colors = boxColors(diagram);
|
|
645
|
+
const regionColor = regionColors(diagram);
|
|
646
|
+
const edges = edgesOf(diagram);
|
|
647
|
+
const columnCount = Math.max(1, ...[...slots.values()].map((s) => s.col + 1));
|
|
648
|
+
const widths = new Map(diagram.boxes.map((b) => [b.id, boxWidth(diagram, b.id, true)]));
|
|
649
|
+
const colW = Array.from({ length: columnCount }, (_, c) => Math.max(B.minW, ...[...slots].filter(([, s]) => s.col === c).map(([id]) => widths.get(id) ?? B.minW)));
|
|
650
|
+
const between = Array.from({ length: Math.max(0, columnCount - 1) }, () => A.columnGap);
|
|
651
|
+
for (const { edge: edge2 } of edges) {
|
|
652
|
+
const a = slots.get(edge2.from);
|
|
653
|
+
const b = slots.get(edge2.to);
|
|
654
|
+
if (!a || !b || edge2.label === void 0 || a.group !== b.group || a.row !== b.row || Math.abs(a.col - b.col) !== 1 || vertical(edge2.labelSide)) continue;
|
|
655
|
+
const need = textWidth(edge2.label, labelStyle(edge2.label)) + LOOK.label.padX * 2 + A.labelRoom * 2;
|
|
656
|
+
const i = Math.min(a.col, b.col);
|
|
657
|
+
if (need <= A.maxColumnGap) between[i] = Math.max(between[i] ?? 0, need);
|
|
658
|
+
}
|
|
659
|
+
const headers = groups.map((g) => g.region ? headerSize(g.region) : void 0);
|
|
660
|
+
const headerW = Math.max(0, ...headers.map((h) => h ? h.w + R.inset * 2 : 0));
|
|
661
|
+
const colLeft = [];
|
|
662
|
+
for (let c = 0; c < columnCount; c++) colLeft.push(c === 0 ? margin + (headerW > 0 ? headerW : R.pad) : colLeft[c - 1] + colW[c - 1] + between[c - 1]);
|
|
663
|
+
const center = (c) => colLeft[c] + colW[c] / 2;
|
|
664
|
+
const boxes = [];
|
|
665
|
+
const bands = [];
|
|
666
|
+
let cursor = margin;
|
|
667
|
+
groups.forEach((group, g) => {
|
|
668
|
+
const rows = Math.max(1, ...group.members.map((id) => (slots.get(id)?.row ?? 0) + 1));
|
|
669
|
+
const room = rooms[g];
|
|
670
|
+
const top = cursor + R.pad + room.top;
|
|
671
|
+
for (const id of group.members) {
|
|
672
|
+
const slot = slots.get(id);
|
|
673
|
+
const source = diagram.boxes.find((b) => b.id === id);
|
|
674
|
+
const w = widths.get(id) ?? B.minW;
|
|
675
|
+
const cx = center(slot.col);
|
|
676
|
+
const y = top + slot.row * (B.h + A.rowGap);
|
|
677
|
+
boxes.push({
|
|
678
|
+
id,
|
|
679
|
+
name: source?.name ?? id,
|
|
680
|
+
...source?.sub !== void 0 ? { sub: source.sub } : {},
|
|
681
|
+
...source?.icon !== void 0 ? { icon: source.icon } : {},
|
|
682
|
+
color: colors.get(id) ?? "slate",
|
|
683
|
+
x: cx - w / 2,
|
|
684
|
+
y,
|
|
685
|
+
w,
|
|
686
|
+
h: B.h,
|
|
687
|
+
cx,
|
|
688
|
+
cy: y + B.h / 2
|
|
689
|
+
});
|
|
690
|
+
}
|
|
691
|
+
const contentBottom = top + rows * B.h + (rows - 1) * A.rowGap;
|
|
692
|
+
const header = headers[g];
|
|
693
|
+
const h = Math.max(contentBottom + R.pad + room.bottom - cursor, header ? header.h + R.inset * 2 : 0, group.region ? R.minH : 0);
|
|
694
|
+
bands.push({ group: g, y: cursor, h, rows });
|
|
695
|
+
cursor += h + R.gap;
|
|
696
|
+
});
|
|
697
|
+
const bandsBottom = cursor - R.gap;
|
|
698
|
+
const byId = new Map(boxes.map((b) => [b.id, b]));
|
|
699
|
+
const bandOf = (id) => bands[slots.get(id)?.group ?? 0];
|
|
700
|
+
const blocked = (points, a, b) => boxes.some((box) => {
|
|
701
|
+
if (box.id === a || box.id === b) return false;
|
|
702
|
+
const pad2 = LOOK.label.search;
|
|
703
|
+
for (let i = 1; i < points.length; i++) {
|
|
704
|
+
const [x1, y1] = points[i - 1];
|
|
705
|
+
const [x2, y2] = points[i];
|
|
706
|
+
if (Math.min(x1, x2) <= box.x + box.w + pad2 && Math.max(x1, x2) >= box.x - pad2 && Math.min(y1, y2) <= box.y + box.h + pad2 && Math.max(y1, y2) >= box.y - pad2) return true;
|
|
707
|
+
}
|
|
708
|
+
return false;
|
|
709
|
+
});
|
|
710
|
+
const laneBelow = (id) => {
|
|
711
|
+
const box = byId.get(id);
|
|
712
|
+
const band2 = bandOf(id);
|
|
713
|
+
return (slots.get(id)?.row ?? 0) < band2.rows - 1 ? box.y + box.h + A.rowGap / 2 : Math.min(box.y + box.h + R.pad / 2, band2.y + band2.h - LOOK.edge.inset);
|
|
714
|
+
};
|
|
715
|
+
const laneAbove = (id) => {
|
|
716
|
+
const box = byId.get(id);
|
|
717
|
+
const band2 = bandOf(id);
|
|
718
|
+
return (slots.get(id)?.row ?? 0) > 0 ? box.y - A.rowGap / 2 : Math.max(box.y - R.pad / 2, band2.y + LOOK.edge.inset);
|
|
719
|
+
};
|
|
720
|
+
const inset = LOOK.edge.inset;
|
|
721
|
+
const route = (from, to) => {
|
|
722
|
+
const a = byId.get(from);
|
|
723
|
+
const b = byId.get(to);
|
|
724
|
+
const sa = slots.get(from);
|
|
725
|
+
const sb = slots.get(to);
|
|
726
|
+
if (sa.group === sb.group && sa.row === sb.row) {
|
|
727
|
+
const right2 = b.cx > a.cx;
|
|
728
|
+
const straight = [
|
|
729
|
+
[right2 ? a.x + a.w : a.x, a.cy],
|
|
730
|
+
[right2 ? b.x - inset : b.x + b.w + inset, b.cy]
|
|
731
|
+
];
|
|
732
|
+
if (!blocked(straight, from, to)) return straight;
|
|
733
|
+
const lane2 = laneBelow(from);
|
|
734
|
+
return [
|
|
735
|
+
[a.cx, a.y + a.h],
|
|
736
|
+
[a.cx, lane2],
|
|
737
|
+
[b.cx, lane2],
|
|
738
|
+
[b.cx, b.y + b.h + inset]
|
|
739
|
+
];
|
|
740
|
+
}
|
|
741
|
+
const down = b.cy > a.cy;
|
|
742
|
+
const leave = [a.cx, down ? a.y + a.h : a.y];
|
|
743
|
+
const enter = [b.cx, down ? b.y - inset : b.y + b.h + inset];
|
|
744
|
+
if (sa.col === sb.col) {
|
|
745
|
+
const straight = [leave, enter];
|
|
746
|
+
if (!blocked(straight, from, to)) return straight;
|
|
747
|
+
const x = a.x + a.w + (between[sa.col] ?? A.columnGap) / 2;
|
|
748
|
+
return [
|
|
749
|
+
[a.x + a.w, a.cy],
|
|
750
|
+
[x, a.cy],
|
|
751
|
+
[x, b.cy],
|
|
752
|
+
[b.x + b.w + inset, b.cy]
|
|
753
|
+
];
|
|
754
|
+
}
|
|
755
|
+
const right = b.cx > a.cx;
|
|
756
|
+
const lane = down ? laneBelow(from) : laneAbove(from);
|
|
757
|
+
const candidates = [
|
|
758
|
+
[leave, [a.cx, b.cy], [right ? b.x - inset : b.x + b.w + inset, b.cy]],
|
|
759
|
+
[[right ? a.x + a.w : a.x, a.cy], [b.cx, a.cy], enter],
|
|
760
|
+
[leave, [a.cx, lane], [b.cx, lane], enter]
|
|
761
|
+
];
|
|
762
|
+
return candidates.find((points) => !blocked(points, from, to)) ?? candidates[2];
|
|
763
|
+
};
|
|
764
|
+
const sceneEdges = edges.map(({ step, event, edge: edge2 }) => {
|
|
765
|
+
const target = byId.get(edge2.to);
|
|
766
|
+
return {
|
|
767
|
+
step,
|
|
768
|
+
event,
|
|
769
|
+
from: edge2.from,
|
|
770
|
+
to: edge2.to,
|
|
771
|
+
points: route(edge2.from, edge2.to),
|
|
772
|
+
color: edgeColor(edge2, colors),
|
|
773
|
+
carry: edge2.carry,
|
|
774
|
+
settle: [target.cx, target.cy + B.iconY]
|
|
775
|
+
};
|
|
776
|
+
});
|
|
777
|
+
for (const edge2 of sceneEdges) {
|
|
778
|
+
if (edge2.points.length !== 2) continue;
|
|
779
|
+
const back = sceneEdges.some((other) => other.from === edge2.to && other.to === edge2.from && other.points.length === 2);
|
|
780
|
+
if (!back) continue;
|
|
781
|
+
const [p, q] = edge2.points;
|
|
782
|
+
const flat = Math.abs(q[1] - p[1]) < Math.abs(q[0] - p[0]);
|
|
783
|
+
const d = (edge2.from < edge2.to ? 1 : -1) * LOOK.edge.parallel;
|
|
784
|
+
edge2.points = edge2.points.map(([x, y]) => flat ? [x, y + d] : [x + d, y]);
|
|
785
|
+
}
|
|
786
|
+
const regions = [];
|
|
787
|
+
groups.forEach((group, g) => {
|
|
788
|
+
const band2 = bands[g];
|
|
789
|
+
const header = headers[g];
|
|
790
|
+
if (!group.region || !header) return;
|
|
791
|
+
regions.push({
|
|
792
|
+
id: group.region.id,
|
|
793
|
+
lines: header.lines,
|
|
794
|
+
...group.region.note !== void 0 ? { note: group.region.note } : {},
|
|
795
|
+
...group.region.icon !== void 0 ? { icon: group.region.icon } : {},
|
|
796
|
+
color: regionColor.get(group.region.id) ?? "slate",
|
|
797
|
+
x: margin,
|
|
798
|
+
y: band2.y,
|
|
799
|
+
w: 0,
|
|
800
|
+
h: band2.h,
|
|
801
|
+
header: { x: margin + R.inset, y: band2.y + R.inset, w: header.w, h: header.h }
|
|
802
|
+
});
|
|
803
|
+
});
|
|
804
|
+
const labels = [];
|
|
805
|
+
for (const edge2 of sceneEdges) {
|
|
806
|
+
const source = diagram.steps[edge2.step]?.events[edge2.event];
|
|
807
|
+
if (source?.type !== "edge" || source.label === void 0) continue;
|
|
808
|
+
const soft = [...regions.map((r) => r.header), ...labels.filter((l) => l.step === edge2.step)];
|
|
809
|
+
labels.push(
|
|
810
|
+
placeLabel(
|
|
811
|
+
{ step: edge2.step, event: edge2.event, text: source.label, points: edge2.points, color: edge2.color, ...source.labelSide ? { side: source.labelSide } : {} },
|
|
812
|
+
{ hard: boxes, soft }
|
|
813
|
+
)
|
|
814
|
+
);
|
|
815
|
+
}
|
|
816
|
+
const layout = { kind: "architecture", width: 0, height: 0, regions, boxes, lifelines: [], edges: sceneEdges, labels, actions: [], badges: [] };
|
|
817
|
+
const shift = labels.length > 0 ? Math.max(0, margin + LOOK.label.soft - Math.min(...labels.map((l) => l.x))) : 0;
|
|
818
|
+
if (shift > 0) shiftContent(layout, shift, 0);
|
|
819
|
+
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)));
|
|
820
|
+
const width = Math.max(contentRight + margin, stripNeed(diagram) + margin * 2);
|
|
821
|
+
for (const region of regions) region.w = width - margin * 2;
|
|
822
|
+
const strip2 = layoutStrip(diagram, margin, bandsBottom + gap, width - margin * 2);
|
|
823
|
+
layout.width = width;
|
|
824
|
+
layout.height = (strip2 ? strip2.y + strip2.h : bandsBottom) + margin;
|
|
825
|
+
if (strip2) layout.strip = strip2;
|
|
826
|
+
layout.badges = diagram.steps.map((step, s) => {
|
|
827
|
+
const edge2 = sceneEdges.find((e) => e.step === s);
|
|
828
|
+
if (!edge2) return cornerBadge(step.events, s, layout);
|
|
829
|
+
const [x, y] = badgeOnPath(edge2.points);
|
|
830
|
+
return { step: s, x, y, color: edge2.color };
|
|
831
|
+
});
|
|
832
|
+
return layout;
|
|
833
|
+
}
|
|
834
|
+
function grow(layout, groups, slots, rooms) {
|
|
835
|
+
let grown = false;
|
|
836
|
+
const soft = LOOK.label.soft;
|
|
837
|
+
for (const label2 of layout.labels) {
|
|
838
|
+
const edge2 = layout.edges.find((e) => e.step === label2.step && e.event === label2.event);
|
|
839
|
+
const a = edge2 && slots.get(edge2.from);
|
|
840
|
+
const b = edge2 && slots.get(edge2.to);
|
|
841
|
+
if (!a || !b || a.group !== b.group || !groups[a.group]?.region) continue;
|
|
842
|
+
const region = layout.regions.find((r) => r.id === groups[a.group]?.region?.id);
|
|
843
|
+
const room = rooms[a.group];
|
|
844
|
+
if (!region || !room) continue;
|
|
845
|
+
const over = region.y + soft - label2.y;
|
|
846
|
+
const under = label2.y + label2.h - (region.y + region.h - soft);
|
|
847
|
+
if (over > 0) {
|
|
848
|
+
room.top += over;
|
|
849
|
+
grown = true;
|
|
850
|
+
}
|
|
851
|
+
if (under > 0) {
|
|
852
|
+
room.bottom += under;
|
|
853
|
+
grown = true;
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
return grown;
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
// src/layout/sequence.ts
|
|
860
|
+
function layoutSequence(diagram) {
|
|
861
|
+
const { box: B, sequence: Q, label: L, margin, gap } = LOOK;
|
|
862
|
+
const colors = boxColors(diagram);
|
|
863
|
+
const listed = diagram.sequence?.lifelines ?? [];
|
|
864
|
+
const order = [...listed, ...diagram.boxes.map((b) => b.id).filter((id) => !listed.includes(id))];
|
|
865
|
+
const column = new Map(order.map((id, i) => [id, i]));
|
|
866
|
+
const widths = order.map((id) => boxWidth(diagram, id, false));
|
|
867
|
+
const spacing = widths.slice(1).map((w, i) => widths[i] / 2 + w / 2 + Q.columnGap);
|
|
868
|
+
const needs = [];
|
|
869
|
+
for (const step of diagram.steps) {
|
|
870
|
+
for (const event of step.events) {
|
|
871
|
+
if (event.type !== "edge" || event.label === void 0) continue;
|
|
872
|
+
const a = column.get(event.from) ?? 0;
|
|
873
|
+
const b = column.get(event.to) ?? 0;
|
|
874
|
+
const w = textWidth(event.label, labelStyle(event.label)) + L.padX * 2;
|
|
875
|
+
if (a === b) {
|
|
876
|
+
if (a < spacing.length) needs.push({ from: a, to: a + 1, need: Q.selfW + L.side + w + Q.labelRoom });
|
|
877
|
+
} else {
|
|
878
|
+
needs.push({ from: Math.min(a, b), to: Math.max(a, b), need: w + Q.labelRoom * 2 });
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
needs.sort((x, y2) => x.to - x.from - (y2.to - y2.from));
|
|
883
|
+
for (const { from, to, need } of needs) {
|
|
884
|
+
let have = 0;
|
|
885
|
+
for (let i = from; i < to; i++) have += spacing[i] ?? 0;
|
|
886
|
+
if (have >= need) continue;
|
|
887
|
+
const add = (need - have) / (to - from);
|
|
888
|
+
for (let i = from; i < to; i++) spacing[i] = (spacing[i] ?? 0) + add;
|
|
889
|
+
}
|
|
890
|
+
const xs = [];
|
|
891
|
+
order.forEach((_, i) => xs.push(i === 0 ? margin + widths[0] / 2 : xs[i - 1] + spacing[i - 1]));
|
|
892
|
+
const boxes = order.map((id, i) => {
|
|
893
|
+
const source = diagram.boxes.find((b) => b.id === id);
|
|
894
|
+
const w = widths[i];
|
|
895
|
+
const cx = xs[i];
|
|
896
|
+
return {
|
|
897
|
+
id,
|
|
898
|
+
name: source?.name ?? id,
|
|
899
|
+
...source?.sub !== void 0 ? { sub: source.sub } : {},
|
|
900
|
+
...source?.icon !== void 0 ? { icon: source.icon } : {},
|
|
901
|
+
color: colors.get(id) ?? "slate",
|
|
902
|
+
x: cx - w / 2,
|
|
903
|
+
y: margin,
|
|
904
|
+
w,
|
|
905
|
+
h: B.h,
|
|
906
|
+
cx,
|
|
907
|
+
cy: margin + B.h / 2
|
|
908
|
+
};
|
|
909
|
+
});
|
|
910
|
+
const headBottom = margin + B.h;
|
|
911
|
+
const edges = [];
|
|
912
|
+
const actions = [];
|
|
913
|
+
const requests = [];
|
|
914
|
+
let y = headBottom + Q.firstRow;
|
|
915
|
+
let below = 0;
|
|
916
|
+
let first = true;
|
|
917
|
+
diagram.steps.forEach((step, s) => {
|
|
918
|
+
step.events.forEach((event, e) => {
|
|
919
|
+
if (event.type !== "edge" && event.type !== "action") return;
|
|
920
|
+
let above;
|
|
921
|
+
let under;
|
|
922
|
+
if (event.type === "edge") {
|
|
923
|
+
const side = event.labelSide ?? "above";
|
|
924
|
+
const self = event.from === event.to;
|
|
925
|
+
const named = event.label !== void 0;
|
|
926
|
+
above = named && side === "above" ? L.offset + L.h / 2 : gap;
|
|
927
|
+
under = self ? Q.selfH + gap : named && side === "below" ? L.offset + L.h / 2 : gap;
|
|
928
|
+
} else {
|
|
929
|
+
above = LOOK.action.h / 2;
|
|
930
|
+
under = LOOK.action.h / 2;
|
|
931
|
+
}
|
|
932
|
+
y = first ? y + above : y + Math.max(Q.minPitch, below + Q.rowGap + above) + (e === 0 && s > 0 ? Q.stepGap : 0);
|
|
933
|
+
first = false;
|
|
934
|
+
below = under;
|
|
935
|
+
if (event.type === "edge") {
|
|
936
|
+
const xf = xs[column.get(event.from) ?? 0];
|
|
937
|
+
const xt = xs[column.get(event.to) ?? 0];
|
|
938
|
+
const dir = Math.sign(xt - xf) || 1;
|
|
939
|
+
const points = xf === xt ? [
|
|
940
|
+
[xf, y],
|
|
941
|
+
[xf + Q.selfW, y],
|
|
942
|
+
[xf + Q.selfW, y + Q.selfH],
|
|
943
|
+
[xf + LOOK.edge.inset, y + Q.selfH]
|
|
944
|
+
] : [
|
|
945
|
+
[xf, y],
|
|
946
|
+
[xt - dir * LOOK.edge.inset, y]
|
|
947
|
+
];
|
|
948
|
+
const color = edgeColor(event, colors);
|
|
949
|
+
edges.push({ step: s, event: e, from: event.from, to: event.to, points, color, carry: event.carry });
|
|
950
|
+
if (event.label !== void 0) {
|
|
951
|
+
requests.push({
|
|
952
|
+
step: s,
|
|
953
|
+
event: e,
|
|
954
|
+
text: event.label,
|
|
955
|
+
points,
|
|
956
|
+
color,
|
|
957
|
+
...event.labelSide ? { side: event.labelSide } : xf === xt ? { side: "right" } : {}
|
|
958
|
+
});
|
|
959
|
+
}
|
|
960
|
+
} else {
|
|
961
|
+
const x = xs[column.get(event.box) ?? 0];
|
|
962
|
+
const w = textWidth(event.label, TYPE.action) + LOOK.action.padX * 2;
|
|
963
|
+
actions.push({ step: s, event: e, box: event.box, text: event.label, color: colors.get(event.box) ?? "slate", x: x + LOOK.badge.r + 4, y: y - LOOK.action.h / 2, w, h: LOOK.action.h });
|
|
964
|
+
}
|
|
965
|
+
});
|
|
966
|
+
});
|
|
967
|
+
const bottom = (first ? headBottom : y + below) + Q.tail;
|
|
968
|
+
const lifelines = order.map((id, i) => ({ id, x: xs[i], y1: headBottom, y2: bottom }));
|
|
969
|
+
const labels = [];
|
|
970
|
+
for (const request of requests) {
|
|
971
|
+
const soft = [...labels.filter((l) => l.step === request.step), ...actions];
|
|
972
|
+
labels.push(placeLabel(request, { hard: boxes, soft }));
|
|
973
|
+
}
|
|
974
|
+
const layout = { kind: "sequence", width: 0, height: 0, regions: [], boxes, lifelines, edges, labels, actions, badges: [] };
|
|
975
|
+
const lefts = [...boxes.map((b) => b.x), ...labels.map((l) => l.x), ...actions.map((a) => a.x)];
|
|
976
|
+
const shift = Math.max(0, margin - Math.min(...lefts));
|
|
977
|
+
if (shift > 0) shiftContent(layout, shift, 0);
|
|
978
|
+
const rights = [...boxes.map((b) => b.x + b.w), ...labels.map((l) => l.x + l.w), ...actions.map((a) => a.x + a.w), ...edges.flatMap((edge2) => edge2.points.map((p) => p[0]))];
|
|
979
|
+
const width = Math.max(Math.max(...rights) + margin, stripNeed(diagram) + margin * 2);
|
|
980
|
+
const strip2 = layoutStrip(diagram, margin, bottom + gap, width - margin * 2);
|
|
981
|
+
layout.width = width;
|
|
982
|
+
layout.height = (strip2 ? strip2.y + strip2.h : bottom) + margin;
|
|
983
|
+
if (strip2) layout.strip = strip2;
|
|
984
|
+
layout.badges = badges(diagram, layout);
|
|
985
|
+
return layout;
|
|
986
|
+
}
|
|
987
|
+
function badges(diagram, layout) {
|
|
988
|
+
return diagram.steps.map((step, s) => {
|
|
989
|
+
const edge2 = layout.edges.find((e) => e.step === s);
|
|
990
|
+
if (edge2) {
|
|
991
|
+
const [x, y] = badgeOnPath(edge2.points);
|
|
992
|
+
return { step: s, x, y, color: edge2.color };
|
|
993
|
+
}
|
|
994
|
+
const action2 = layout.actions.find((a) => a.step === s);
|
|
995
|
+
const lifeline2 = action2 && layout.lifelines.find((l) => l.id === action2.box);
|
|
996
|
+
if (action2 && lifeline2) return { step: s, x: lifeline2.x, y: action2.y + action2.h / 2, color: action2.color };
|
|
997
|
+
return cornerBadge(step.events, s, layout);
|
|
998
|
+
});
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
// src/field-messages.ts
|
|
1002
|
+
var TYPES_JA = {
|
|
1003
|
+
string: "\u6587\u5B57\u5217\u306B\u3059\u308B",
|
|
1004
|
+
integer: "\u6574\u6570\u306B\u3059\u308B",
|
|
1005
|
+
number: "\u6570\u306B\u3059\u308B",
|
|
1006
|
+
object: "\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u306B\u3059\u308B",
|
|
1007
|
+
array: "\u914D\u5217\u306B\u3059\u308B",
|
|
1008
|
+
boolean: "true \u304B false \u306B\u3059\u308B",
|
|
1009
|
+
null: "null \u306B\u3059\u308B"
|
|
1010
|
+
};
|
|
1011
|
+
var TYPES_EN = {
|
|
1012
|
+
string: "Use a string",
|
|
1013
|
+
integer: "Use an integer",
|
|
1014
|
+
number: "Use a number",
|
|
1015
|
+
object: "Use an object",
|
|
1016
|
+
array: "Use an array",
|
|
1017
|
+
boolean: "Use true or false",
|
|
1018
|
+
null: "Use null"
|
|
1019
|
+
};
|
|
1020
|
+
var plural = (count, word) => `${count} ${word}${count === 1 ? "" : "s"}`;
|
|
1021
|
+
var ja = {
|
|
1022
|
+
additionalProperties: (key) => `${key} \u3068\u3044\u3046\u6B04\u306F\u66F8\u3051\u306A\u3044`,
|
|
1023
|
+
required: (key) => `${key} \u306E\u6B04\u304C\u8981\u308B`,
|
|
1024
|
+
enum: (values) => `${values.join(" / ")} \u306E\u3069\u308C\u304B\u306B\u3059\u308B`,
|
|
1025
|
+
type: (type) => TYPES_JA[type] ?? `${type} \u306B\u3059\u308B`,
|
|
1026
|
+
minLength: (limit) => `${limit} \u5B57\u4EE5\u4E0A\u66F8\u304F`,
|
|
1027
|
+
pattern: (forbidden) => forbidden ? `${forbidden.space ? "\u7A7A\u767D\u3068 " : ""}${forbidden.chars.join(" ")} \u306F\u4F7F\u3048\u306A\u3044` : "\u4F7F\u3048\u306A\u3044\u5B57\u304C\u5165\u3063\u3066\u3044\u308B",
|
|
1028
|
+
minItems: (limit) => `${limit} \u3064\u4EE5\u4E0A\u66F8\u304F`,
|
|
1029
|
+
minimum: (limit) => `${limit} \u4EE5\u4E0A\u306B\u3059\u308B`,
|
|
1030
|
+
const: (value) => `${value} \u306B\u3059\u308B`,
|
|
1031
|
+
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",
|
|
1032
|
+
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",
|
|
1033
|
+
oneOf: "\u66F8\u3051\u308B\u5F62\u306E\u3069\u308C\u304B 1 \u3064\u3060\u3051\u306B\u5408\u308F\u305B\u308B",
|
|
1034
|
+
discriminator: (tag, values) => `${tag} \u306F ${values.join(" / ")} \u306E\u3069\u308C\u304B\u306B\u3059\u308B`,
|
|
1035
|
+
newer: (version, tool) => `\u7248 ${version} \u306E\u56F3\u306F\u3001\u3053\u306E\u9053\u5177 (\u7248 ${tool}) \u3088\u308A\u65B0\u3057\u3044\u306E\u3067\u8AAD\u3081\u306A\u3044\u3002\u9053\u5177\u3092\u65B0\u3057\u304F\u3059\u308B`
|
|
1036
|
+
};
|
|
1037
|
+
var en = {
|
|
1038
|
+
additionalProperties: (key) => `The ${key} field is not allowed`,
|
|
1039
|
+
required: (key) => `The ${key} field is required`,
|
|
1040
|
+
enum: (values) => `Use one of ${values.join(" / ")}`,
|
|
1041
|
+
type: (type) => TYPES_EN[type] ?? `Use ${type}`,
|
|
1042
|
+
minLength: (limit) => `Write at least ${plural(limit, "character")}`,
|
|
1043
|
+
pattern: (forbidden) => forbidden ? `Cannot contain ${forbidden.space ? "spaces or " : ""}${forbidden.chars.join(" ")}` : "Contains characters that are not allowed",
|
|
1044
|
+
minItems: (limit) => `Write at least ${plural(limit, "item")}`,
|
|
1045
|
+
minimum: (limit) => `Use ${limit} or greater`,
|
|
1046
|
+
const: (value) => `Use ${value}`,
|
|
1047
|
+
not: (allowed) => allowed ? `The ${allowed.field} field is allowed only when kind is ${allowed.kind}` : "This combination of fields is not allowed",
|
|
1048
|
+
anyOf: (fields) => fields.length > 0 ? `Write one of the ${fields.join(" or ")} fields` : "Does not match any of the allowed shapes",
|
|
1049
|
+
oneOf: "Match exactly one of the allowed shapes",
|
|
1050
|
+
discriminator: (tag, values) => `${tag} is one of ${values.join(" / ")}`,
|
|
1051
|
+
newer: (version, tool) => `Version ${version} diagrams are newer than this tool (version ${tool}) and cannot be read. Update the tool`
|
|
1052
|
+
};
|
|
1053
|
+
var FIELD_MESSAGES = { ja, en };
|
|
1054
|
+
|
|
1055
|
+
// src/schemas/validate-diagram.js
|
|
1056
|
+
function ucs2length(str) {
|
|
1057
|
+
let length = 0;
|
|
1058
|
+
for (const _ of str) length++;
|
|
1059
|
+
return length;
|
|
1060
|
+
}
|
|
1061
|
+
var validate_diagram_default = validate10;
|
|
1062
|
+
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" } }};
|
|
1063
|
+
var func2 = Object.prototype.hasOwnProperty;
|
|
1064
|
+
var func3 = ucs2length;
|
|
1065
|
+
var schema17 = { "enum": ["blue", "amber", "green", "violet", "rose", "slate", "coin"] };
|
|
1066
|
+
var pattern0 = new RegExp("^[^\\s\\[\\]\u300C\u300D=:]+$", "u");
|
|
1067
|
+
function validate11(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
|
|
1068
|
+
let vErrors = null;
|
|
1069
|
+
let errors = 0;
|
|
1070
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
1071
|
+
if (data.id === void 0) {
|
|
1072
|
+
const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "id" }, message: "must have required property 'id'" };
|
|
1073
|
+
if (vErrors === null) {
|
|
1074
|
+
vErrors = [err0];
|
|
1075
|
+
} else {
|
|
1076
|
+
vErrors.push(err0);
|
|
1077
|
+
}
|
|
1078
|
+
errors++;
|
|
1079
|
+
}
|
|
1080
|
+
if (data.name === void 0) {
|
|
1081
|
+
const err1 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "name" }, message: "must have required property 'name'" };
|
|
1082
|
+
if (vErrors === null) {
|
|
1083
|
+
vErrors = [err1];
|
|
1084
|
+
} else {
|
|
1085
|
+
vErrors.push(err1);
|
|
1086
|
+
}
|
|
1087
|
+
errors++;
|
|
1088
|
+
}
|
|
1089
|
+
for (const key0 in data) {
|
|
1090
|
+
if (!(key0 === "id" || key0 === "name" || key0 === "note" || key0 === "color" || key0 === "icon")) {
|
|
1091
|
+
const err2 = { instancePath, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" };
|
|
1092
|
+
if (vErrors === null) {
|
|
1093
|
+
vErrors = [err2];
|
|
1094
|
+
} else {
|
|
1095
|
+
vErrors.push(err2);
|
|
1096
|
+
}
|
|
1097
|
+
errors++;
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
if (data.id !== void 0) {
|
|
1101
|
+
let data0 = data.id;
|
|
1102
|
+
if (typeof data0 === "string") {
|
|
1103
|
+
if (!pattern0.test(data0)) {
|
|
1104
|
+
const err3 = { instancePath: instancePath + "/id", schemaPath: "#/definitions/id/pattern", keyword: "pattern", params: { pattern: "^[^\\s\\[\\]\u300C\u300D=:]+$" }, message: 'must match pattern "^[^\\s\\[\\]\u300C\u300D=:]+$"' };
|
|
1105
|
+
if (vErrors === null) {
|
|
1106
|
+
vErrors = [err3];
|
|
1107
|
+
} else {
|
|
1108
|
+
vErrors.push(err3);
|
|
1109
|
+
}
|
|
1110
|
+
errors++;
|
|
1111
|
+
}
|
|
1112
|
+
} else {
|
|
1113
|
+
const err4 = { instancePath: instancePath + "/id", schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1114
|
+
if (vErrors === null) {
|
|
1115
|
+
vErrors = [err4];
|
|
1116
|
+
} else {
|
|
1117
|
+
vErrors.push(err4);
|
|
1118
|
+
}
|
|
1119
|
+
errors++;
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
if (data.name !== void 0) {
|
|
1123
|
+
let data1 = data.name;
|
|
1124
|
+
if (typeof data1 === "string") {
|
|
1125
|
+
if (func3(data1) < 1) {
|
|
1126
|
+
const err5 = { instancePath: instancePath + "/name", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
|
|
1127
|
+
if (vErrors === null) {
|
|
1128
|
+
vErrors = [err5];
|
|
1129
|
+
} else {
|
|
1130
|
+
vErrors.push(err5);
|
|
1131
|
+
}
|
|
1132
|
+
errors++;
|
|
1133
|
+
}
|
|
1134
|
+
} else {
|
|
1135
|
+
const err6 = { instancePath: instancePath + "/name", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1136
|
+
if (vErrors === null) {
|
|
1137
|
+
vErrors = [err6];
|
|
1138
|
+
} else {
|
|
1139
|
+
vErrors.push(err6);
|
|
1140
|
+
}
|
|
1141
|
+
errors++;
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
if (data.note !== void 0) {
|
|
1145
|
+
let data2 = data.note;
|
|
1146
|
+
if (typeof data2 === "string") {
|
|
1147
|
+
if (func3(data2) < 1) {
|
|
1148
|
+
const err7 = { instancePath: instancePath + "/note", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
|
|
1149
|
+
if (vErrors === null) {
|
|
1150
|
+
vErrors = [err7];
|
|
1151
|
+
} else {
|
|
1152
|
+
vErrors.push(err7);
|
|
1153
|
+
}
|
|
1154
|
+
errors++;
|
|
1155
|
+
}
|
|
1156
|
+
} else {
|
|
1157
|
+
const err8 = { instancePath: instancePath + "/note", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1158
|
+
if (vErrors === null) {
|
|
1159
|
+
vErrors = [err8];
|
|
1160
|
+
} else {
|
|
1161
|
+
vErrors.push(err8);
|
|
1162
|
+
}
|
|
1163
|
+
errors++;
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
if (data.color !== void 0) {
|
|
1167
|
+
let data3 = data.color;
|
|
1168
|
+
if (!(data3 === "blue" || data3 === "amber" || data3 === "green" || data3 === "violet" || data3 === "rose" || data3 === "slate" || data3 === "coin")) {
|
|
1169
|
+
const err9 = { instancePath: instancePath + "/color", schemaPath: "#/definitions/color/enum", keyword: "enum", params: { allowedValues: schema17.enum }, message: "must be equal to one of the allowed values" };
|
|
1170
|
+
if (vErrors === null) {
|
|
1171
|
+
vErrors = [err9];
|
|
1172
|
+
} else {
|
|
1173
|
+
vErrors.push(err9);
|
|
1174
|
+
}
|
|
1175
|
+
errors++;
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
if (data.icon !== void 0) {
|
|
1179
|
+
let data4 = data.icon;
|
|
1180
|
+
if (typeof data4 === "string") {
|
|
1181
|
+
if (func3(data4) < 1) {
|
|
1182
|
+
const err10 = { instancePath: instancePath + "/icon", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
|
|
1183
|
+
if (vErrors === null) {
|
|
1184
|
+
vErrors = [err10];
|
|
1185
|
+
} else {
|
|
1186
|
+
vErrors.push(err10);
|
|
1187
|
+
}
|
|
1188
|
+
errors++;
|
|
1189
|
+
}
|
|
1190
|
+
} else {
|
|
1191
|
+
const err11 = { instancePath: instancePath + "/icon", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1192
|
+
if (vErrors === null) {
|
|
1193
|
+
vErrors = [err11];
|
|
1194
|
+
} else {
|
|
1195
|
+
vErrors.push(err11);
|
|
1196
|
+
}
|
|
1197
|
+
errors++;
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
} else {
|
|
1201
|
+
const err12 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
1202
|
+
if (vErrors === null) {
|
|
1203
|
+
vErrors = [err12];
|
|
1204
|
+
} else {
|
|
1205
|
+
vErrors.push(err12);
|
|
1206
|
+
}
|
|
1207
|
+
errors++;
|
|
1208
|
+
}
|
|
1209
|
+
validate11.errors = vErrors;
|
|
1210
|
+
return errors === 0;
|
|
1211
|
+
}
|
|
1212
|
+
function validate13(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
|
|
1213
|
+
let vErrors = null;
|
|
1214
|
+
let errors = 0;
|
|
1215
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
1216
|
+
if (data.id === void 0) {
|
|
1217
|
+
const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "id" }, message: "must have required property 'id'" };
|
|
1218
|
+
if (vErrors === null) {
|
|
1219
|
+
vErrors = [err0];
|
|
1220
|
+
} else {
|
|
1221
|
+
vErrors.push(err0);
|
|
1222
|
+
}
|
|
1223
|
+
errors++;
|
|
1224
|
+
}
|
|
1225
|
+
if (data.name === void 0) {
|
|
1226
|
+
const err1 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "name" }, message: "must have required property 'name'" };
|
|
1227
|
+
if (vErrors === null) {
|
|
1228
|
+
vErrors = [err1];
|
|
1229
|
+
} else {
|
|
1230
|
+
vErrors.push(err1);
|
|
1231
|
+
}
|
|
1232
|
+
errors++;
|
|
1233
|
+
}
|
|
1234
|
+
for (const key0 in data) {
|
|
1235
|
+
if (!(key0 === "id" || key0 === "name" || key0 === "sub" || key0 === "color" || key0 === "icon" || key0 === "region")) {
|
|
1236
|
+
const err2 = { instancePath, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" };
|
|
1237
|
+
if (vErrors === null) {
|
|
1238
|
+
vErrors = [err2];
|
|
1239
|
+
} else {
|
|
1240
|
+
vErrors.push(err2);
|
|
1241
|
+
}
|
|
1242
|
+
errors++;
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
if (data.id !== void 0) {
|
|
1246
|
+
let data0 = data.id;
|
|
1247
|
+
if (typeof data0 === "string") {
|
|
1248
|
+
if (!pattern0.test(data0)) {
|
|
1249
|
+
const err3 = { instancePath: instancePath + "/id", schemaPath: "#/definitions/id/pattern", keyword: "pattern", params: { pattern: "^[^\\s\\[\\]\u300C\u300D=:]+$" }, message: 'must match pattern "^[^\\s\\[\\]\u300C\u300D=:]+$"' };
|
|
1250
|
+
if (vErrors === null) {
|
|
1251
|
+
vErrors = [err3];
|
|
1252
|
+
} else {
|
|
1253
|
+
vErrors.push(err3);
|
|
1254
|
+
}
|
|
1255
|
+
errors++;
|
|
1256
|
+
}
|
|
1257
|
+
} else {
|
|
1258
|
+
const err4 = { instancePath: instancePath + "/id", schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1259
|
+
if (vErrors === null) {
|
|
1260
|
+
vErrors = [err4];
|
|
1261
|
+
} else {
|
|
1262
|
+
vErrors.push(err4);
|
|
1263
|
+
}
|
|
1264
|
+
errors++;
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
if (data.name !== void 0) {
|
|
1268
|
+
let data1 = data.name;
|
|
1269
|
+
if (typeof data1 === "string") {
|
|
1270
|
+
if (func3(data1) < 1) {
|
|
1271
|
+
const err5 = { instancePath: instancePath + "/name", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
|
|
1272
|
+
if (vErrors === null) {
|
|
1273
|
+
vErrors = [err5];
|
|
1274
|
+
} else {
|
|
1275
|
+
vErrors.push(err5);
|
|
1276
|
+
}
|
|
1277
|
+
errors++;
|
|
1278
|
+
}
|
|
1279
|
+
} else {
|
|
1280
|
+
const err6 = { instancePath: instancePath + "/name", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1281
|
+
if (vErrors === null) {
|
|
1282
|
+
vErrors = [err6];
|
|
1283
|
+
} else {
|
|
1284
|
+
vErrors.push(err6);
|
|
1285
|
+
}
|
|
1286
|
+
errors++;
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
if (data.sub !== void 0) {
|
|
1290
|
+
let data2 = data.sub;
|
|
1291
|
+
if (typeof data2 === "string") {
|
|
1292
|
+
if (func3(data2) < 1) {
|
|
1293
|
+
const err7 = { instancePath: instancePath + "/sub", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
|
|
1294
|
+
if (vErrors === null) {
|
|
1295
|
+
vErrors = [err7];
|
|
1296
|
+
} else {
|
|
1297
|
+
vErrors.push(err7);
|
|
1298
|
+
}
|
|
1299
|
+
errors++;
|
|
1300
|
+
}
|
|
1301
|
+
} else {
|
|
1302
|
+
const err8 = { instancePath: instancePath + "/sub", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1303
|
+
if (vErrors === null) {
|
|
1304
|
+
vErrors = [err8];
|
|
1305
|
+
} else {
|
|
1306
|
+
vErrors.push(err8);
|
|
1307
|
+
}
|
|
1308
|
+
errors++;
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
if (data.color !== void 0) {
|
|
1312
|
+
let data3 = data.color;
|
|
1313
|
+
if (!(data3 === "blue" || data3 === "amber" || data3 === "green" || data3 === "violet" || data3 === "rose" || data3 === "slate" || data3 === "coin")) {
|
|
1314
|
+
const err9 = { instancePath: instancePath + "/color", schemaPath: "#/definitions/color/enum", keyword: "enum", params: { allowedValues: schema17.enum }, message: "must be equal to one of the allowed values" };
|
|
1315
|
+
if (vErrors === null) {
|
|
1316
|
+
vErrors = [err9];
|
|
1317
|
+
} else {
|
|
1318
|
+
vErrors.push(err9);
|
|
1319
|
+
}
|
|
1320
|
+
errors++;
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
if (data.icon !== void 0) {
|
|
1324
|
+
let data4 = data.icon;
|
|
1325
|
+
if (typeof data4 === "string") {
|
|
1326
|
+
if (func3(data4) < 1) {
|
|
1327
|
+
const err10 = { instancePath: instancePath + "/icon", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
|
|
1328
|
+
if (vErrors === null) {
|
|
1329
|
+
vErrors = [err10];
|
|
1330
|
+
} else {
|
|
1331
|
+
vErrors.push(err10);
|
|
1332
|
+
}
|
|
1333
|
+
errors++;
|
|
1334
|
+
}
|
|
1335
|
+
} else {
|
|
1336
|
+
const err11 = { instancePath: instancePath + "/icon", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1337
|
+
if (vErrors === null) {
|
|
1338
|
+
vErrors = [err11];
|
|
1339
|
+
} else {
|
|
1340
|
+
vErrors.push(err11);
|
|
1341
|
+
}
|
|
1342
|
+
errors++;
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
if (data.region !== void 0) {
|
|
1346
|
+
let data5 = data.region;
|
|
1347
|
+
if (typeof data5 === "string") {
|
|
1348
|
+
if (!pattern0.test(data5)) {
|
|
1349
|
+
const err12 = { instancePath: instancePath + "/region", schemaPath: "#/definitions/id/pattern", keyword: "pattern", params: { pattern: "^[^\\s\\[\\]\u300C\u300D=:]+$" }, message: 'must match pattern "^[^\\s\\[\\]\u300C\u300D=:]+$"' };
|
|
1350
|
+
if (vErrors === null) {
|
|
1351
|
+
vErrors = [err12];
|
|
1352
|
+
} else {
|
|
1353
|
+
vErrors.push(err12);
|
|
1354
|
+
}
|
|
1355
|
+
errors++;
|
|
1356
|
+
}
|
|
1357
|
+
} else {
|
|
1358
|
+
const err13 = { instancePath: instancePath + "/region", schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1359
|
+
if (vErrors === null) {
|
|
1360
|
+
vErrors = [err13];
|
|
1361
|
+
} else {
|
|
1362
|
+
vErrors.push(err13);
|
|
1363
|
+
}
|
|
1364
|
+
errors++;
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
} else {
|
|
1368
|
+
const err14 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
1369
|
+
if (vErrors === null) {
|
|
1370
|
+
vErrors = [err14];
|
|
1371
|
+
} else {
|
|
1372
|
+
vErrors.push(err14);
|
|
1373
|
+
}
|
|
1374
|
+
errors++;
|
|
1375
|
+
}
|
|
1376
|
+
validate13.errors = vErrors;
|
|
1377
|
+
return errors === 0;
|
|
1378
|
+
}
|
|
1379
|
+
function validate15(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
|
|
1380
|
+
let vErrors = null;
|
|
1381
|
+
let errors = 0;
|
|
1382
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
1383
|
+
if (data.title === void 0) {
|
|
1384
|
+
const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "title" }, message: "must have required property 'title'" };
|
|
1385
|
+
if (vErrors === null) {
|
|
1386
|
+
vErrors = [err0];
|
|
1387
|
+
} else {
|
|
1388
|
+
vErrors.push(err0);
|
|
1389
|
+
}
|
|
1390
|
+
errors++;
|
|
1391
|
+
}
|
|
1392
|
+
if (data.fields === void 0) {
|
|
1393
|
+
const err1 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "fields" }, message: "must have required property 'fields'" };
|
|
1394
|
+
if (vErrors === null) {
|
|
1395
|
+
vErrors = [err1];
|
|
1396
|
+
} else {
|
|
1397
|
+
vErrors.push(err1);
|
|
1398
|
+
}
|
|
1399
|
+
errors++;
|
|
1400
|
+
}
|
|
1401
|
+
for (const key0 in data) {
|
|
1402
|
+
if (!(key0 === "title" || key0 === "fields")) {
|
|
1403
|
+
const err2 = { instancePath, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" };
|
|
1404
|
+
if (vErrors === null) {
|
|
1405
|
+
vErrors = [err2];
|
|
1406
|
+
} else {
|
|
1407
|
+
vErrors.push(err2);
|
|
1408
|
+
}
|
|
1409
|
+
errors++;
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
if (data.title !== void 0) {
|
|
1413
|
+
let data0 = data.title;
|
|
1414
|
+
if (typeof data0 === "string") {
|
|
1415
|
+
if (func3(data0) < 1) {
|
|
1416
|
+
const err3 = { instancePath: instancePath + "/title", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
|
|
1417
|
+
if (vErrors === null) {
|
|
1418
|
+
vErrors = [err3];
|
|
1419
|
+
} else {
|
|
1420
|
+
vErrors.push(err3);
|
|
1421
|
+
}
|
|
1422
|
+
errors++;
|
|
1423
|
+
}
|
|
1424
|
+
} else {
|
|
1425
|
+
const err4 = { instancePath: instancePath + "/title", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1426
|
+
if (vErrors === null) {
|
|
1427
|
+
vErrors = [err4];
|
|
1428
|
+
} else {
|
|
1429
|
+
vErrors.push(err4);
|
|
1430
|
+
}
|
|
1431
|
+
errors++;
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
if (data.fields !== void 0) {
|
|
1435
|
+
let data1 = data.fields;
|
|
1436
|
+
if (Array.isArray(data1)) {
|
|
1437
|
+
if (data1.length < 1) {
|
|
1438
|
+
const err5 = { instancePath: instancePath + "/fields", schemaPath: "#/properties/fields/minItems", keyword: "minItems", params: { limit: 1 }, message: "must NOT have fewer than 1 items" };
|
|
1439
|
+
if (vErrors === null) {
|
|
1440
|
+
vErrors = [err5];
|
|
1441
|
+
} else {
|
|
1442
|
+
vErrors.push(err5);
|
|
1443
|
+
}
|
|
1444
|
+
errors++;
|
|
1445
|
+
}
|
|
1446
|
+
const len0 = data1.length;
|
|
1447
|
+
for (let i0 = 0; i0 < len0; i0++) {
|
|
1448
|
+
let data2 = data1[i0];
|
|
1449
|
+
if (typeof data2 === "string") {
|
|
1450
|
+
if (func3(data2) < 1) {
|
|
1451
|
+
const err6 = { instancePath: instancePath + "/fields/" + i0, schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
|
|
1452
|
+
if (vErrors === null) {
|
|
1453
|
+
vErrors = [err6];
|
|
1454
|
+
} else {
|
|
1455
|
+
vErrors.push(err6);
|
|
1456
|
+
}
|
|
1457
|
+
errors++;
|
|
1458
|
+
}
|
|
1459
|
+
} else {
|
|
1460
|
+
const err7 = { instancePath: instancePath + "/fields/" + i0, schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1461
|
+
if (vErrors === null) {
|
|
1462
|
+
vErrors = [err7];
|
|
1463
|
+
} else {
|
|
1464
|
+
vErrors.push(err7);
|
|
1465
|
+
}
|
|
1466
|
+
errors++;
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
} else {
|
|
1470
|
+
const err8 = { instancePath: instancePath + "/fields", schemaPath: "#/properties/fields/type", keyword: "type", params: { type: "array" }, message: "must be array" };
|
|
1471
|
+
if (vErrors === null) {
|
|
1472
|
+
vErrors = [err8];
|
|
1473
|
+
} else {
|
|
1474
|
+
vErrors.push(err8);
|
|
1475
|
+
}
|
|
1476
|
+
errors++;
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1479
|
+
} else {
|
|
1480
|
+
const err9 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
1481
|
+
if (vErrors === null) {
|
|
1482
|
+
vErrors = [err9];
|
|
1483
|
+
} else {
|
|
1484
|
+
vErrors.push(err9);
|
|
1485
|
+
}
|
|
1486
|
+
errors++;
|
|
1487
|
+
}
|
|
1488
|
+
validate15.errors = vErrors;
|
|
1489
|
+
return errors === 0;
|
|
1490
|
+
}
|
|
1491
|
+
var schema33 = { "oneOf": [{ "description": "\u7DDA\u3002\u904B\u3076\u7269\u3092\u8F09\u305B\u3066\u9001\u308B\u5074\u304B\u3089\u53D7\u3051\u308B\u5074\u3078\u8D70\u308B", "type": "object", "additionalProperties": false, "required": ["type", "from", "to", "carry"], "properties": { "type": { "const": "edge" }, "from": { "$ref": "#/definitions/id" }, "to": { "$ref": "#/definitions/id" }, "label": { "$ref": "#/definitions/text" }, "carry": { "$ref": "#/definitions/carry" }, "labelSide": { "description": "\u7DDA\u306E\u540D\u524D\u3092\u7F6E\u304F\u5074 (\u5BC4\u305B\u306E\u6307\u793A)", "enum": ["above", "below", "left", "right"] } } }, { "description": "\u7BB1\u306E\u4E2D\u306E\u51E6\u7406", "type": "object", "additionalProperties": false, "required": ["type", "box", "label"], "properties": { "type": { "const": "action" }, "box": { "$ref": "#/definitions/id" }, "label": { "$ref": "#/definitions/text" } } }, { "description": "\u7BB1\u306E\u4E0B\u306E\u5C0F\u3055\u306A\u5B57\u306E\u66F8\u304D\u63DB\u3048", "type": "object", "additionalProperties": false, "required": ["type", "box", "text"], "properties": { "type": { "const": "swap" }, "box": { "$ref": "#/definitions/id" }, "text": { "$ref": "#/definitions/text" } } }, { "description": "\u4E2D\u8EAB\u306E\u5E2F\u306E\u6B04\u306E\u5024\u3068\u672D", "type": "object", "additionalProperties": false, "required": ["type", "field"], "anyOf": [{ "required": ["value"] }, { "required": ["tag"] }], "properties": { "type": { "const": "strip" }, "field": { "$ref": "#/definitions/text" }, "value": { "$ref": "#/definitions/text" }, "tag": { "$ref": "#/definitions/text" } } }] };
|
|
1492
|
+
var schema37 = { "properties": { "kind": { "enum": ["envelope", "tag", "coin", "none"] }}};
|
|
1493
|
+
function validate19(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
|
|
1494
|
+
let vErrors = null;
|
|
1495
|
+
let errors = 0;
|
|
1496
|
+
const _errs1 = errors;
|
|
1497
|
+
let valid0 = true;
|
|
1498
|
+
const _errs2 = errors;
|
|
1499
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
1500
|
+
if (data.kind === void 0 && ("kind")) {
|
|
1501
|
+
const err0 = {};
|
|
1502
|
+
if (vErrors === null) {
|
|
1503
|
+
vErrors = [err0];
|
|
1504
|
+
} else {
|
|
1505
|
+
vErrors.push(err0);
|
|
1506
|
+
}
|
|
1507
|
+
errors++;
|
|
1508
|
+
} else {
|
|
1509
|
+
if (data.kind !== void 0) {
|
|
1510
|
+
if ("tag" !== data.kind) {
|
|
1511
|
+
const err1 = {};
|
|
1512
|
+
if (vErrors === null) {
|
|
1513
|
+
vErrors = [err1];
|
|
1514
|
+
} else {
|
|
1515
|
+
vErrors.push(err1);
|
|
1516
|
+
}
|
|
1517
|
+
errors++;
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1521
|
+
}
|
|
1522
|
+
var _valid0 = _errs2 === errors;
|
|
1523
|
+
errors = _errs1;
|
|
1524
|
+
if (vErrors !== null) {
|
|
1525
|
+
if (_errs1) {
|
|
1526
|
+
vErrors.length = _errs1;
|
|
1527
|
+
} else {
|
|
1528
|
+
vErrors = null;
|
|
1529
|
+
}
|
|
1530
|
+
}
|
|
1531
|
+
let ifClause0;
|
|
1532
|
+
if (_valid0) {
|
|
1533
|
+
const _errs4 = errors;
|
|
1534
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
1535
|
+
if (data.text === void 0) {
|
|
1536
|
+
const err2 = { instancePath, schemaPath: "#/then/required", keyword: "required", params: { missingProperty: "text" }, message: "must have required property 'text'" };
|
|
1537
|
+
if (vErrors === null) {
|
|
1538
|
+
vErrors = [err2];
|
|
1539
|
+
} else {
|
|
1540
|
+
vErrors.push(err2);
|
|
1541
|
+
}
|
|
1542
|
+
errors++;
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
var _valid0 = _errs4 === errors;
|
|
1546
|
+
valid0 = _valid0;
|
|
1547
|
+
ifClause0 = "then";
|
|
1548
|
+
} else {
|
|
1549
|
+
const _errs5 = errors;
|
|
1550
|
+
const _errs6 = errors;
|
|
1551
|
+
const _errs7 = errors;
|
|
1552
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
1553
|
+
if (data.text === void 0 && ("text")) {
|
|
1554
|
+
const err3 = {};
|
|
1555
|
+
if (vErrors === null) {
|
|
1556
|
+
vErrors = [err3];
|
|
1557
|
+
} else {
|
|
1558
|
+
vErrors.push(err3);
|
|
1559
|
+
}
|
|
1560
|
+
errors++;
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
var valid2 = _errs7 === errors;
|
|
1564
|
+
if (valid2) {
|
|
1565
|
+
const err4 = { instancePath, schemaPath: "#/else/not", keyword: "not", params: {}, message: "must NOT be valid" };
|
|
1566
|
+
if (vErrors === null) {
|
|
1567
|
+
vErrors = [err4];
|
|
1568
|
+
} else {
|
|
1569
|
+
vErrors.push(err4);
|
|
1570
|
+
}
|
|
1571
|
+
errors++;
|
|
1572
|
+
} else {
|
|
1573
|
+
errors = _errs6;
|
|
1574
|
+
if (vErrors !== null) {
|
|
1575
|
+
if (_errs6) {
|
|
1576
|
+
vErrors.length = _errs6;
|
|
1577
|
+
} else {
|
|
1578
|
+
vErrors = null;
|
|
1579
|
+
}
|
|
1580
|
+
}
|
|
1581
|
+
}
|
|
1582
|
+
var _valid0 = _errs5 === errors;
|
|
1583
|
+
valid0 = _valid0;
|
|
1584
|
+
ifClause0 = "else";
|
|
1585
|
+
}
|
|
1586
|
+
if (!valid0) {
|
|
1587
|
+
const err5 = { instancePath, schemaPath: "#/if", keyword: "if", params: { failingKeyword: ifClause0 }, message: 'must match "' + ifClause0 + '" schema' };
|
|
1588
|
+
if (vErrors === null) {
|
|
1589
|
+
vErrors = [err5];
|
|
1590
|
+
} else {
|
|
1591
|
+
vErrors.push(err5);
|
|
1592
|
+
}
|
|
1593
|
+
errors++;
|
|
1594
|
+
}
|
|
1595
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
1596
|
+
if (data.kind === void 0) {
|
|
1597
|
+
const err6 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "kind" }, message: "must have required property 'kind'" };
|
|
1598
|
+
if (vErrors === null) {
|
|
1599
|
+
vErrors = [err6];
|
|
1600
|
+
} else {
|
|
1601
|
+
vErrors.push(err6);
|
|
1602
|
+
}
|
|
1603
|
+
errors++;
|
|
1604
|
+
}
|
|
1605
|
+
for (const key0 in data) {
|
|
1606
|
+
if (!(key0 === "kind" || key0 === "text")) {
|
|
1607
|
+
const err7 = { instancePath, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" };
|
|
1608
|
+
if (vErrors === null) {
|
|
1609
|
+
vErrors = [err7];
|
|
1610
|
+
} else {
|
|
1611
|
+
vErrors.push(err7);
|
|
1612
|
+
}
|
|
1613
|
+
errors++;
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
if (data.kind !== void 0) {
|
|
1617
|
+
let data1 = data.kind;
|
|
1618
|
+
if (!(data1 === "envelope" || data1 === "tag" || data1 === "coin" || data1 === "none")) {
|
|
1619
|
+
const err8 = { instancePath: instancePath + "/kind", schemaPath: "#/properties/kind/enum", keyword: "enum", params: { allowedValues: schema37.properties.kind.enum }, message: "must be equal to one of the allowed values" };
|
|
1620
|
+
if (vErrors === null) {
|
|
1621
|
+
vErrors = [err8];
|
|
1622
|
+
} else {
|
|
1623
|
+
vErrors.push(err8);
|
|
1624
|
+
}
|
|
1625
|
+
errors++;
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1628
|
+
if (data.text !== void 0) {
|
|
1629
|
+
let data2 = data.text;
|
|
1630
|
+
if (typeof data2 === "string") {
|
|
1631
|
+
if (func3(data2) < 1) {
|
|
1632
|
+
const err9 = { instancePath: instancePath + "/text", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
|
|
1633
|
+
if (vErrors === null) {
|
|
1634
|
+
vErrors = [err9];
|
|
1635
|
+
} else {
|
|
1636
|
+
vErrors.push(err9);
|
|
1637
|
+
}
|
|
1638
|
+
errors++;
|
|
1639
|
+
}
|
|
1640
|
+
} else {
|
|
1641
|
+
const err10 = { instancePath: instancePath + "/text", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1642
|
+
if (vErrors === null) {
|
|
1643
|
+
vErrors = [err10];
|
|
1644
|
+
} else {
|
|
1645
|
+
vErrors.push(err10);
|
|
1646
|
+
}
|
|
1647
|
+
errors++;
|
|
1648
|
+
}
|
|
1649
|
+
}
|
|
1650
|
+
} else {
|
|
1651
|
+
const err11 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
1652
|
+
if (vErrors === null) {
|
|
1653
|
+
vErrors = [err11];
|
|
1654
|
+
} else {
|
|
1655
|
+
vErrors.push(err11);
|
|
1656
|
+
}
|
|
1657
|
+
errors++;
|
|
1658
|
+
}
|
|
1659
|
+
validate19.errors = vErrors;
|
|
1660
|
+
return errors === 0;
|
|
1661
|
+
}
|
|
1662
|
+
function validate18(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
|
|
1663
|
+
let vErrors = null;
|
|
1664
|
+
let errors = 0;
|
|
1665
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
1666
|
+
if (data.type === void 0) {
|
|
1667
|
+
const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "type" }, message: "must have required property 'type'" };
|
|
1668
|
+
if (vErrors === null) {
|
|
1669
|
+
vErrors = [err0];
|
|
1670
|
+
} else {
|
|
1671
|
+
vErrors.push(err0);
|
|
1672
|
+
}
|
|
1673
|
+
errors++;
|
|
1674
|
+
}
|
|
1675
|
+
const tag0 = data.type;
|
|
1676
|
+
if (typeof tag0 == "string") {
|
|
1677
|
+
if (tag0 === "edge") {
|
|
1678
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
1679
|
+
if (data.type === void 0) {
|
|
1680
|
+
const err1 = { instancePath, schemaPath: "#/oneOf/0/required", keyword: "required", params: { missingProperty: "type" }, message: "must have required property 'type'" };
|
|
1681
|
+
if (vErrors === null) {
|
|
1682
|
+
vErrors = [err1];
|
|
1683
|
+
} else {
|
|
1684
|
+
vErrors.push(err1);
|
|
1685
|
+
}
|
|
1686
|
+
errors++;
|
|
1687
|
+
}
|
|
1688
|
+
if (data.from === void 0) {
|
|
1689
|
+
const err2 = { instancePath, schemaPath: "#/oneOf/0/required", keyword: "required", params: { missingProperty: "from" }, message: "must have required property 'from'" };
|
|
1690
|
+
if (vErrors === null) {
|
|
1691
|
+
vErrors = [err2];
|
|
1692
|
+
} else {
|
|
1693
|
+
vErrors.push(err2);
|
|
1694
|
+
}
|
|
1695
|
+
errors++;
|
|
1696
|
+
}
|
|
1697
|
+
if (data.to === void 0) {
|
|
1698
|
+
const err3 = { instancePath, schemaPath: "#/oneOf/0/required", keyword: "required", params: { missingProperty: "to" }, message: "must have required property 'to'" };
|
|
1699
|
+
if (vErrors === null) {
|
|
1700
|
+
vErrors = [err3];
|
|
1701
|
+
} else {
|
|
1702
|
+
vErrors.push(err3);
|
|
1703
|
+
}
|
|
1704
|
+
errors++;
|
|
1705
|
+
}
|
|
1706
|
+
if (data.carry === void 0) {
|
|
1707
|
+
const err4 = { instancePath, schemaPath: "#/oneOf/0/required", keyword: "required", params: { missingProperty: "carry" }, message: "must have required property 'carry'" };
|
|
1708
|
+
if (vErrors === null) {
|
|
1709
|
+
vErrors = [err4];
|
|
1710
|
+
} else {
|
|
1711
|
+
vErrors.push(err4);
|
|
1712
|
+
}
|
|
1713
|
+
errors++;
|
|
1714
|
+
}
|
|
1715
|
+
for (const key0 in data) {
|
|
1716
|
+
if (!(key0 === "type" || key0 === "from" || key0 === "to" || key0 === "label" || key0 === "carry" || key0 === "labelSide")) {
|
|
1717
|
+
const err5 = { instancePath, schemaPath: "#/oneOf/0/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" };
|
|
1718
|
+
if (vErrors === null) {
|
|
1719
|
+
vErrors = [err5];
|
|
1720
|
+
} else {
|
|
1721
|
+
vErrors.push(err5);
|
|
1722
|
+
}
|
|
1723
|
+
errors++;
|
|
1724
|
+
}
|
|
1725
|
+
}
|
|
1726
|
+
if (data.type !== void 0) {
|
|
1727
|
+
if ("edge" !== data.type) {
|
|
1728
|
+
const err6 = { instancePath: instancePath + "/type", schemaPath: "#/oneOf/0/properties/type/const", keyword: "const", params: { allowedValue: "edge" }, message: "must be equal to constant" };
|
|
1729
|
+
if (vErrors === null) {
|
|
1730
|
+
vErrors = [err6];
|
|
1731
|
+
} else {
|
|
1732
|
+
vErrors.push(err6);
|
|
1733
|
+
}
|
|
1734
|
+
errors++;
|
|
1735
|
+
}
|
|
1736
|
+
}
|
|
1737
|
+
if (data.from !== void 0) {
|
|
1738
|
+
let data1 = data.from;
|
|
1739
|
+
if (typeof data1 === "string") {
|
|
1740
|
+
if (!pattern0.test(data1)) {
|
|
1741
|
+
const err7 = { instancePath: instancePath + "/from", schemaPath: "#/definitions/id/pattern", keyword: "pattern", params: { pattern: "^[^\\s\\[\\]\u300C\u300D=:]+$" }, message: 'must match pattern "^[^\\s\\[\\]\u300C\u300D=:]+$"' };
|
|
1742
|
+
if (vErrors === null) {
|
|
1743
|
+
vErrors = [err7];
|
|
1744
|
+
} else {
|
|
1745
|
+
vErrors.push(err7);
|
|
1746
|
+
}
|
|
1747
|
+
errors++;
|
|
1748
|
+
}
|
|
1749
|
+
} else {
|
|
1750
|
+
const err8 = { instancePath: instancePath + "/from", schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1751
|
+
if (vErrors === null) {
|
|
1752
|
+
vErrors = [err8];
|
|
1753
|
+
} else {
|
|
1754
|
+
vErrors.push(err8);
|
|
1755
|
+
}
|
|
1756
|
+
errors++;
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1759
|
+
if (data.to !== void 0) {
|
|
1760
|
+
let data2 = data.to;
|
|
1761
|
+
if (typeof data2 === "string") {
|
|
1762
|
+
if (!pattern0.test(data2)) {
|
|
1763
|
+
const err9 = { instancePath: instancePath + "/to", schemaPath: "#/definitions/id/pattern", keyword: "pattern", params: { pattern: "^[^\\s\\[\\]\u300C\u300D=:]+$" }, message: 'must match pattern "^[^\\s\\[\\]\u300C\u300D=:]+$"' };
|
|
1764
|
+
if (vErrors === null) {
|
|
1765
|
+
vErrors = [err9];
|
|
1766
|
+
} else {
|
|
1767
|
+
vErrors.push(err9);
|
|
1768
|
+
}
|
|
1769
|
+
errors++;
|
|
1770
|
+
}
|
|
1771
|
+
} else {
|
|
1772
|
+
const err10 = { instancePath: instancePath + "/to", schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1773
|
+
if (vErrors === null) {
|
|
1774
|
+
vErrors = [err10];
|
|
1775
|
+
} else {
|
|
1776
|
+
vErrors.push(err10);
|
|
1777
|
+
}
|
|
1778
|
+
errors++;
|
|
1779
|
+
}
|
|
1780
|
+
}
|
|
1781
|
+
if (data.label !== void 0) {
|
|
1782
|
+
let data3 = data.label;
|
|
1783
|
+
if (typeof data3 === "string") {
|
|
1784
|
+
if (func3(data3) < 1) {
|
|
1785
|
+
const err11 = { instancePath: instancePath + "/label", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
|
|
1786
|
+
if (vErrors === null) {
|
|
1787
|
+
vErrors = [err11];
|
|
1788
|
+
} else {
|
|
1789
|
+
vErrors.push(err11);
|
|
1790
|
+
}
|
|
1791
|
+
errors++;
|
|
1792
|
+
}
|
|
1793
|
+
} else {
|
|
1794
|
+
const err12 = { instancePath: instancePath + "/label", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1795
|
+
if (vErrors === null) {
|
|
1796
|
+
vErrors = [err12];
|
|
1797
|
+
} else {
|
|
1798
|
+
vErrors.push(err12);
|
|
1799
|
+
}
|
|
1800
|
+
errors++;
|
|
1801
|
+
}
|
|
1802
|
+
}
|
|
1803
|
+
if (data.carry !== void 0) {
|
|
1804
|
+
if (!validate19(data.carry, { instancePath: instancePath + "/carry", parentData: data, parentDataProperty: "carry", rootData })) {
|
|
1805
|
+
vErrors = vErrors === null ? validate19.errors : vErrors.concat(validate19.errors);
|
|
1806
|
+
errors = vErrors.length;
|
|
1807
|
+
}
|
|
1808
|
+
}
|
|
1809
|
+
if (data.labelSide !== void 0) {
|
|
1810
|
+
let data5 = data.labelSide;
|
|
1811
|
+
if (!(data5 === "above" || data5 === "below" || data5 === "left" || data5 === "right")) {
|
|
1812
|
+
const err13 = { instancePath: instancePath + "/labelSide", schemaPath: "#/oneOf/0/properties/labelSide/enum", keyword: "enum", params: { allowedValues: schema33.oneOf[0].properties.labelSide.enum }, message: "must be equal to one of the allowed values" };
|
|
1813
|
+
if (vErrors === null) {
|
|
1814
|
+
vErrors = [err13];
|
|
1815
|
+
} else {
|
|
1816
|
+
vErrors.push(err13);
|
|
1817
|
+
}
|
|
1818
|
+
errors++;
|
|
1819
|
+
}
|
|
1820
|
+
}
|
|
1821
|
+
} else {
|
|
1822
|
+
const err14 = { instancePath, schemaPath: "#/oneOf/0/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
1823
|
+
if (vErrors === null) {
|
|
1824
|
+
vErrors = [err14];
|
|
1825
|
+
} else {
|
|
1826
|
+
vErrors.push(err14);
|
|
1827
|
+
}
|
|
1828
|
+
errors++;
|
|
1829
|
+
}
|
|
1830
|
+
} else if (tag0 === "action") {
|
|
1831
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
1832
|
+
if (data.type === void 0) {
|
|
1833
|
+
const err15 = { instancePath, schemaPath: "#/oneOf/1/required", keyword: "required", params: { missingProperty: "type" }, message: "must have required property 'type'" };
|
|
1834
|
+
if (vErrors === null) {
|
|
1835
|
+
vErrors = [err15];
|
|
1836
|
+
} else {
|
|
1837
|
+
vErrors.push(err15);
|
|
1838
|
+
}
|
|
1839
|
+
errors++;
|
|
1840
|
+
}
|
|
1841
|
+
if (data.box === void 0) {
|
|
1842
|
+
const err16 = { instancePath, schemaPath: "#/oneOf/1/required", keyword: "required", params: { missingProperty: "box" }, message: "must have required property 'box'" };
|
|
1843
|
+
if (vErrors === null) {
|
|
1844
|
+
vErrors = [err16];
|
|
1845
|
+
} else {
|
|
1846
|
+
vErrors.push(err16);
|
|
1847
|
+
}
|
|
1848
|
+
errors++;
|
|
1849
|
+
}
|
|
1850
|
+
if (data.label === void 0) {
|
|
1851
|
+
const err17 = { instancePath, schemaPath: "#/oneOf/1/required", keyword: "required", params: { missingProperty: "label" }, message: "must have required property 'label'" };
|
|
1852
|
+
if (vErrors === null) {
|
|
1853
|
+
vErrors = [err17];
|
|
1854
|
+
} else {
|
|
1855
|
+
vErrors.push(err17);
|
|
1856
|
+
}
|
|
1857
|
+
errors++;
|
|
1858
|
+
}
|
|
1859
|
+
for (const key1 in data) {
|
|
1860
|
+
if (!(key1 === "type" || key1 === "box" || key1 === "label")) {
|
|
1861
|
+
const err18 = { instancePath, schemaPath: "#/oneOf/1/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key1 }, message: "must NOT have additional properties" };
|
|
1862
|
+
if (vErrors === null) {
|
|
1863
|
+
vErrors = [err18];
|
|
1864
|
+
} else {
|
|
1865
|
+
vErrors.push(err18);
|
|
1866
|
+
}
|
|
1867
|
+
errors++;
|
|
1868
|
+
}
|
|
1869
|
+
}
|
|
1870
|
+
if (data.type !== void 0) {
|
|
1871
|
+
if ("action" !== data.type) {
|
|
1872
|
+
const err19 = { instancePath: instancePath + "/type", schemaPath: "#/oneOf/1/properties/type/const", keyword: "const", params: { allowedValue: "action" }, message: "must be equal to constant" };
|
|
1873
|
+
if (vErrors === null) {
|
|
1874
|
+
vErrors = [err19];
|
|
1875
|
+
} else {
|
|
1876
|
+
vErrors.push(err19);
|
|
1877
|
+
}
|
|
1878
|
+
errors++;
|
|
1879
|
+
}
|
|
1880
|
+
}
|
|
1881
|
+
if (data.box !== void 0) {
|
|
1882
|
+
let data7 = data.box;
|
|
1883
|
+
if (typeof data7 === "string") {
|
|
1884
|
+
if (!pattern0.test(data7)) {
|
|
1885
|
+
const err20 = { instancePath: instancePath + "/box", schemaPath: "#/definitions/id/pattern", keyword: "pattern", params: { pattern: "^[^\\s\\[\\]\u300C\u300D=:]+$" }, message: 'must match pattern "^[^\\s\\[\\]\u300C\u300D=:]+$"' };
|
|
1886
|
+
if (vErrors === null) {
|
|
1887
|
+
vErrors = [err20];
|
|
1888
|
+
} else {
|
|
1889
|
+
vErrors.push(err20);
|
|
1890
|
+
}
|
|
1891
|
+
errors++;
|
|
1892
|
+
}
|
|
1893
|
+
} else {
|
|
1894
|
+
const err21 = { instancePath: instancePath + "/box", schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1895
|
+
if (vErrors === null) {
|
|
1896
|
+
vErrors = [err21];
|
|
1897
|
+
} else {
|
|
1898
|
+
vErrors.push(err21);
|
|
1899
|
+
}
|
|
1900
|
+
errors++;
|
|
1901
|
+
}
|
|
1902
|
+
}
|
|
1903
|
+
if (data.label !== void 0) {
|
|
1904
|
+
let data8 = data.label;
|
|
1905
|
+
if (typeof data8 === "string") {
|
|
1906
|
+
if (func3(data8) < 1) {
|
|
1907
|
+
const err22 = { instancePath: instancePath + "/label", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
|
|
1908
|
+
if (vErrors === null) {
|
|
1909
|
+
vErrors = [err22];
|
|
1910
|
+
} else {
|
|
1911
|
+
vErrors.push(err22);
|
|
1912
|
+
}
|
|
1913
|
+
errors++;
|
|
1914
|
+
}
|
|
1915
|
+
} else {
|
|
1916
|
+
const err23 = { instancePath: instancePath + "/label", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1917
|
+
if (vErrors === null) {
|
|
1918
|
+
vErrors = [err23];
|
|
1919
|
+
} else {
|
|
1920
|
+
vErrors.push(err23);
|
|
1921
|
+
}
|
|
1922
|
+
errors++;
|
|
1923
|
+
}
|
|
1924
|
+
}
|
|
1925
|
+
} else {
|
|
1926
|
+
const err24 = { instancePath, schemaPath: "#/oneOf/1/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
1927
|
+
if (vErrors === null) {
|
|
1928
|
+
vErrors = [err24];
|
|
1929
|
+
} else {
|
|
1930
|
+
vErrors.push(err24);
|
|
1931
|
+
}
|
|
1932
|
+
errors++;
|
|
1933
|
+
}
|
|
1934
|
+
} else if (tag0 === "swap") {
|
|
1935
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
1936
|
+
if (data.type === void 0) {
|
|
1937
|
+
const err25 = { instancePath, schemaPath: "#/oneOf/2/required", keyword: "required", params: { missingProperty: "type" }, message: "must have required property 'type'" };
|
|
1938
|
+
if (vErrors === null) {
|
|
1939
|
+
vErrors = [err25];
|
|
1940
|
+
} else {
|
|
1941
|
+
vErrors.push(err25);
|
|
1942
|
+
}
|
|
1943
|
+
errors++;
|
|
1944
|
+
}
|
|
1945
|
+
if (data.box === void 0) {
|
|
1946
|
+
const err26 = { instancePath, schemaPath: "#/oneOf/2/required", keyword: "required", params: { missingProperty: "box" }, message: "must have required property 'box'" };
|
|
1947
|
+
if (vErrors === null) {
|
|
1948
|
+
vErrors = [err26];
|
|
1949
|
+
} else {
|
|
1950
|
+
vErrors.push(err26);
|
|
1951
|
+
}
|
|
1952
|
+
errors++;
|
|
1953
|
+
}
|
|
1954
|
+
if (data.text === void 0) {
|
|
1955
|
+
const err27 = { instancePath, schemaPath: "#/oneOf/2/required", keyword: "required", params: { missingProperty: "text" }, message: "must have required property 'text'" };
|
|
1956
|
+
if (vErrors === null) {
|
|
1957
|
+
vErrors = [err27];
|
|
1958
|
+
} else {
|
|
1959
|
+
vErrors.push(err27);
|
|
1960
|
+
}
|
|
1961
|
+
errors++;
|
|
1962
|
+
}
|
|
1963
|
+
for (const key2 in data) {
|
|
1964
|
+
if (!(key2 === "type" || key2 === "box" || key2 === "text")) {
|
|
1965
|
+
const err28 = { instancePath, schemaPath: "#/oneOf/2/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key2 }, message: "must NOT have additional properties" };
|
|
1966
|
+
if (vErrors === null) {
|
|
1967
|
+
vErrors = [err28];
|
|
1968
|
+
} else {
|
|
1969
|
+
vErrors.push(err28);
|
|
1970
|
+
}
|
|
1971
|
+
errors++;
|
|
1972
|
+
}
|
|
1973
|
+
}
|
|
1974
|
+
if (data.type !== void 0) {
|
|
1975
|
+
if ("swap" !== data.type) {
|
|
1976
|
+
const err29 = { instancePath: instancePath + "/type", schemaPath: "#/oneOf/2/properties/type/const", keyword: "const", params: { allowedValue: "swap" }, message: "must be equal to constant" };
|
|
1977
|
+
if (vErrors === null) {
|
|
1978
|
+
vErrors = [err29];
|
|
1979
|
+
} else {
|
|
1980
|
+
vErrors.push(err29);
|
|
1981
|
+
}
|
|
1982
|
+
errors++;
|
|
1983
|
+
}
|
|
1984
|
+
}
|
|
1985
|
+
if (data.box !== void 0) {
|
|
1986
|
+
let data10 = data.box;
|
|
1987
|
+
if (typeof data10 === "string") {
|
|
1988
|
+
if (!pattern0.test(data10)) {
|
|
1989
|
+
const err30 = { instancePath: instancePath + "/box", schemaPath: "#/definitions/id/pattern", keyword: "pattern", params: { pattern: "^[^\\s\\[\\]\u300C\u300D=:]+$" }, message: 'must match pattern "^[^\\s\\[\\]\u300C\u300D=:]+$"' };
|
|
1990
|
+
if (vErrors === null) {
|
|
1991
|
+
vErrors = [err30];
|
|
1992
|
+
} else {
|
|
1993
|
+
vErrors.push(err30);
|
|
1994
|
+
}
|
|
1995
|
+
errors++;
|
|
1996
|
+
}
|
|
1997
|
+
} else {
|
|
1998
|
+
const err31 = { instancePath: instancePath + "/box", schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1999
|
+
if (vErrors === null) {
|
|
2000
|
+
vErrors = [err31];
|
|
2001
|
+
} else {
|
|
2002
|
+
vErrors.push(err31);
|
|
2003
|
+
}
|
|
2004
|
+
errors++;
|
|
2005
|
+
}
|
|
2006
|
+
}
|
|
2007
|
+
if (data.text !== void 0) {
|
|
2008
|
+
let data11 = data.text;
|
|
2009
|
+
if (typeof data11 === "string") {
|
|
2010
|
+
if (func3(data11) < 1) {
|
|
2011
|
+
const err32 = { instancePath: instancePath + "/text", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
|
|
2012
|
+
if (vErrors === null) {
|
|
2013
|
+
vErrors = [err32];
|
|
2014
|
+
} else {
|
|
2015
|
+
vErrors.push(err32);
|
|
2016
|
+
}
|
|
2017
|
+
errors++;
|
|
2018
|
+
}
|
|
2019
|
+
} else {
|
|
2020
|
+
const err33 = { instancePath: instancePath + "/text", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
2021
|
+
if (vErrors === null) {
|
|
2022
|
+
vErrors = [err33];
|
|
2023
|
+
} else {
|
|
2024
|
+
vErrors.push(err33);
|
|
2025
|
+
}
|
|
2026
|
+
errors++;
|
|
2027
|
+
}
|
|
2028
|
+
}
|
|
2029
|
+
} else {
|
|
2030
|
+
const err34 = { instancePath, schemaPath: "#/oneOf/2/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
2031
|
+
if (vErrors === null) {
|
|
2032
|
+
vErrors = [err34];
|
|
2033
|
+
} else {
|
|
2034
|
+
vErrors.push(err34);
|
|
2035
|
+
}
|
|
2036
|
+
errors++;
|
|
2037
|
+
}
|
|
2038
|
+
} else if (tag0 === "strip") {
|
|
2039
|
+
const _errs39 = errors;
|
|
2040
|
+
let valid15 = false;
|
|
2041
|
+
const _errs40 = errors;
|
|
2042
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
2043
|
+
if (data.value === void 0) {
|
|
2044
|
+
const err35 = { instancePath, schemaPath: "#/oneOf/3/anyOf/0/required", keyword: "required", params: { missingProperty: "value" }, message: "must have required property 'value'" };
|
|
2045
|
+
if (vErrors === null) {
|
|
2046
|
+
vErrors = [err35];
|
|
2047
|
+
} else {
|
|
2048
|
+
vErrors.push(err35);
|
|
2049
|
+
}
|
|
2050
|
+
errors++;
|
|
2051
|
+
}
|
|
2052
|
+
}
|
|
2053
|
+
var _valid0 = _errs40 === errors;
|
|
2054
|
+
valid15 = valid15 || _valid0;
|
|
2055
|
+
if (!valid15) {
|
|
2056
|
+
const _errs41 = errors;
|
|
2057
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
2058
|
+
if (data.tag === void 0) {
|
|
2059
|
+
const err36 = { instancePath, schemaPath: "#/oneOf/3/anyOf/1/required", keyword: "required", params: { missingProperty: "tag" }, message: "must have required property 'tag'" };
|
|
2060
|
+
if (vErrors === null) {
|
|
2061
|
+
vErrors = [err36];
|
|
2062
|
+
} else {
|
|
2063
|
+
vErrors.push(err36);
|
|
2064
|
+
}
|
|
2065
|
+
errors++;
|
|
2066
|
+
}
|
|
2067
|
+
}
|
|
2068
|
+
var _valid0 = _errs41 === errors;
|
|
2069
|
+
valid15 = valid15 || _valid0;
|
|
2070
|
+
}
|
|
2071
|
+
if (!valid15) {
|
|
2072
|
+
const err37 = { instancePath, schemaPath: "#/oneOf/3/anyOf", keyword: "anyOf", params: {}, message: "must match a schema in anyOf" };
|
|
2073
|
+
if (vErrors === null) {
|
|
2074
|
+
vErrors = [err37];
|
|
2075
|
+
} else {
|
|
2076
|
+
vErrors.push(err37);
|
|
2077
|
+
}
|
|
2078
|
+
errors++;
|
|
2079
|
+
} else {
|
|
2080
|
+
errors = _errs39;
|
|
2081
|
+
if (vErrors !== null) {
|
|
2082
|
+
if (_errs39) {
|
|
2083
|
+
vErrors.length = _errs39;
|
|
2084
|
+
} else {
|
|
2085
|
+
vErrors = null;
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
}
|
|
2089
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
2090
|
+
if (data.type === void 0) {
|
|
2091
|
+
const err38 = { instancePath, schemaPath: "#/oneOf/3/required", keyword: "required", params: { missingProperty: "type" }, message: "must have required property 'type'" };
|
|
2092
|
+
if (vErrors === null) {
|
|
2093
|
+
vErrors = [err38];
|
|
2094
|
+
} else {
|
|
2095
|
+
vErrors.push(err38);
|
|
2096
|
+
}
|
|
2097
|
+
errors++;
|
|
2098
|
+
}
|
|
2099
|
+
if (data.field === void 0) {
|
|
2100
|
+
const err39 = { instancePath, schemaPath: "#/oneOf/3/required", keyword: "required", params: { missingProperty: "field" }, message: "must have required property 'field'" };
|
|
2101
|
+
if (vErrors === null) {
|
|
2102
|
+
vErrors = [err39];
|
|
2103
|
+
} else {
|
|
2104
|
+
vErrors.push(err39);
|
|
2105
|
+
}
|
|
2106
|
+
errors++;
|
|
2107
|
+
}
|
|
2108
|
+
for (const key3 in data) {
|
|
2109
|
+
if (!(key3 === "type" || key3 === "field" || key3 === "value" || key3 === "tag")) {
|
|
2110
|
+
const err40 = { instancePath, schemaPath: "#/oneOf/3/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key3 }, message: "must NOT have additional properties" };
|
|
2111
|
+
if (vErrors === null) {
|
|
2112
|
+
vErrors = [err40];
|
|
2113
|
+
} else {
|
|
2114
|
+
vErrors.push(err40);
|
|
2115
|
+
}
|
|
2116
|
+
errors++;
|
|
2117
|
+
}
|
|
2118
|
+
}
|
|
2119
|
+
if (data.type !== void 0) {
|
|
2120
|
+
if ("strip" !== data.type) {
|
|
2121
|
+
const err41 = { instancePath: instancePath + "/type", schemaPath: "#/oneOf/3/properties/type/const", keyword: "const", params: { allowedValue: "strip" }, message: "must be equal to constant" };
|
|
2122
|
+
if (vErrors === null) {
|
|
2123
|
+
vErrors = [err41];
|
|
2124
|
+
} else {
|
|
2125
|
+
vErrors.push(err41);
|
|
2126
|
+
}
|
|
2127
|
+
errors++;
|
|
2128
|
+
}
|
|
2129
|
+
}
|
|
2130
|
+
if (data.field !== void 0) {
|
|
2131
|
+
let data13 = data.field;
|
|
2132
|
+
if (typeof data13 === "string") {
|
|
2133
|
+
if (func3(data13) < 1) {
|
|
2134
|
+
const err42 = { instancePath: instancePath + "/field", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
|
|
2135
|
+
if (vErrors === null) {
|
|
2136
|
+
vErrors = [err42];
|
|
2137
|
+
} else {
|
|
2138
|
+
vErrors.push(err42);
|
|
2139
|
+
}
|
|
2140
|
+
errors++;
|
|
2141
|
+
}
|
|
2142
|
+
} else {
|
|
2143
|
+
const err43 = { instancePath: instancePath + "/field", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
2144
|
+
if (vErrors === null) {
|
|
2145
|
+
vErrors = [err43];
|
|
2146
|
+
} else {
|
|
2147
|
+
vErrors.push(err43);
|
|
2148
|
+
}
|
|
2149
|
+
errors++;
|
|
2150
|
+
}
|
|
2151
|
+
}
|
|
2152
|
+
if (data.value !== void 0) {
|
|
2153
|
+
let data14 = data.value;
|
|
2154
|
+
if (typeof data14 === "string") {
|
|
2155
|
+
if (func3(data14) < 1) {
|
|
2156
|
+
const err44 = { instancePath: instancePath + "/value", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
|
|
2157
|
+
if (vErrors === null) {
|
|
2158
|
+
vErrors = [err44];
|
|
2159
|
+
} else {
|
|
2160
|
+
vErrors.push(err44);
|
|
2161
|
+
}
|
|
2162
|
+
errors++;
|
|
2163
|
+
}
|
|
2164
|
+
} else {
|
|
2165
|
+
const err45 = { instancePath: instancePath + "/value", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
2166
|
+
if (vErrors === null) {
|
|
2167
|
+
vErrors = [err45];
|
|
2168
|
+
} else {
|
|
2169
|
+
vErrors.push(err45);
|
|
2170
|
+
}
|
|
2171
|
+
errors++;
|
|
2172
|
+
}
|
|
2173
|
+
}
|
|
2174
|
+
if (data.tag !== void 0) {
|
|
2175
|
+
let data15 = data.tag;
|
|
2176
|
+
if (typeof data15 === "string") {
|
|
2177
|
+
if (func3(data15) < 1) {
|
|
2178
|
+
const err46 = { instancePath: instancePath + "/tag", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
|
|
2179
|
+
if (vErrors === null) {
|
|
2180
|
+
vErrors = [err46];
|
|
2181
|
+
} else {
|
|
2182
|
+
vErrors.push(err46);
|
|
2183
|
+
}
|
|
2184
|
+
errors++;
|
|
2185
|
+
}
|
|
2186
|
+
} else {
|
|
2187
|
+
const err47 = { instancePath: instancePath + "/tag", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
2188
|
+
if (vErrors === null) {
|
|
2189
|
+
vErrors = [err47];
|
|
2190
|
+
} else {
|
|
2191
|
+
vErrors.push(err47);
|
|
2192
|
+
}
|
|
2193
|
+
errors++;
|
|
2194
|
+
}
|
|
2195
|
+
}
|
|
2196
|
+
} else {
|
|
2197
|
+
const err48 = { instancePath, schemaPath: "#/oneOf/3/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
2198
|
+
if (vErrors === null) {
|
|
2199
|
+
vErrors = [err48];
|
|
2200
|
+
} else {
|
|
2201
|
+
vErrors.push(err48);
|
|
2202
|
+
}
|
|
2203
|
+
errors++;
|
|
2204
|
+
}
|
|
2205
|
+
} else {
|
|
2206
|
+
const err49 = { instancePath, schemaPath: "#/discriminator", keyword: "discriminator", params: { error: "mapping", tag: "type", tagValue: tag0 }, message: 'value of tag "type" must be in oneOf' };
|
|
2207
|
+
if (vErrors === null) {
|
|
2208
|
+
vErrors = [err49];
|
|
2209
|
+
} else {
|
|
2210
|
+
vErrors.push(err49);
|
|
2211
|
+
}
|
|
2212
|
+
errors++;
|
|
2213
|
+
}
|
|
2214
|
+
} else {
|
|
2215
|
+
const err50 = { instancePath, schemaPath: "#/discriminator", keyword: "discriminator", params: { error: "tag", tag: "type", tagValue: tag0 }, message: 'tag "type" must be string' };
|
|
2216
|
+
if (vErrors === null) {
|
|
2217
|
+
vErrors = [err50];
|
|
2218
|
+
} else {
|
|
2219
|
+
vErrors.push(err50);
|
|
2220
|
+
}
|
|
2221
|
+
errors++;
|
|
2222
|
+
}
|
|
2223
|
+
} else {
|
|
2224
|
+
const err51 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
2225
|
+
if (vErrors === null) {
|
|
2226
|
+
vErrors = [err51];
|
|
2227
|
+
} else {
|
|
2228
|
+
vErrors.push(err51);
|
|
2229
|
+
}
|
|
2230
|
+
errors++;
|
|
2231
|
+
}
|
|
2232
|
+
validate18.errors = vErrors;
|
|
2233
|
+
return errors === 0;
|
|
2234
|
+
}
|
|
2235
|
+
function validate17(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
|
|
2236
|
+
let vErrors = null;
|
|
2237
|
+
let errors = 0;
|
|
2238
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
2239
|
+
if (data.title === void 0) {
|
|
2240
|
+
const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "title" }, message: "must have required property 'title'" };
|
|
2241
|
+
if (vErrors === null) {
|
|
2242
|
+
vErrors = [err0];
|
|
2243
|
+
} else {
|
|
2244
|
+
vErrors.push(err0);
|
|
2245
|
+
}
|
|
2246
|
+
errors++;
|
|
2247
|
+
}
|
|
2248
|
+
if (data.body === void 0) {
|
|
2249
|
+
const err1 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "body" }, message: "must have required property 'body'" };
|
|
2250
|
+
if (vErrors === null) {
|
|
2251
|
+
vErrors = [err1];
|
|
2252
|
+
} else {
|
|
2253
|
+
vErrors.push(err1);
|
|
2254
|
+
}
|
|
2255
|
+
errors++;
|
|
2256
|
+
}
|
|
2257
|
+
if (data.events === void 0) {
|
|
2258
|
+
const err2 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "events" }, message: "must have required property 'events'" };
|
|
2259
|
+
if (vErrors === null) {
|
|
2260
|
+
vErrors = [err2];
|
|
2261
|
+
} else {
|
|
2262
|
+
vErrors.push(err2);
|
|
2263
|
+
}
|
|
2264
|
+
errors++;
|
|
2265
|
+
}
|
|
2266
|
+
for (const key0 in data) {
|
|
2267
|
+
if (!(key0 === "title" || key0 === "body" || key0 === "code" || key0 === "events")) {
|
|
2268
|
+
const err3 = { instancePath, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" };
|
|
2269
|
+
if (vErrors === null) {
|
|
2270
|
+
vErrors = [err3];
|
|
2271
|
+
} else {
|
|
2272
|
+
vErrors.push(err3);
|
|
2273
|
+
}
|
|
2274
|
+
errors++;
|
|
2275
|
+
}
|
|
2276
|
+
}
|
|
2277
|
+
if (data.title !== void 0) {
|
|
2278
|
+
let data0 = data.title;
|
|
2279
|
+
if (typeof data0 === "string") {
|
|
2280
|
+
if (func3(data0) < 1) {
|
|
2281
|
+
const err4 = { instancePath: instancePath + "/title", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
|
|
2282
|
+
if (vErrors === null) {
|
|
2283
|
+
vErrors = [err4];
|
|
2284
|
+
} else {
|
|
2285
|
+
vErrors.push(err4);
|
|
2286
|
+
}
|
|
2287
|
+
errors++;
|
|
2288
|
+
}
|
|
2289
|
+
} else {
|
|
2290
|
+
const err5 = { instancePath: instancePath + "/title", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
2291
|
+
if (vErrors === null) {
|
|
2292
|
+
vErrors = [err5];
|
|
2293
|
+
} else {
|
|
2294
|
+
vErrors.push(err5);
|
|
2295
|
+
}
|
|
2296
|
+
errors++;
|
|
2297
|
+
}
|
|
2298
|
+
}
|
|
2299
|
+
if (data.body !== void 0) {
|
|
2300
|
+
let data1 = data.body;
|
|
2301
|
+
if (typeof data1 === "string") {
|
|
2302
|
+
if (func3(data1) < 1) {
|
|
2303
|
+
const err6 = { instancePath: instancePath + "/body", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
|
|
2304
|
+
if (vErrors === null) {
|
|
2305
|
+
vErrors = [err6];
|
|
2306
|
+
} else {
|
|
2307
|
+
vErrors.push(err6);
|
|
2308
|
+
}
|
|
2309
|
+
errors++;
|
|
2310
|
+
}
|
|
2311
|
+
} else {
|
|
2312
|
+
const err7 = { instancePath: instancePath + "/body", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
2313
|
+
if (vErrors === null) {
|
|
2314
|
+
vErrors = [err7];
|
|
2315
|
+
} else {
|
|
2316
|
+
vErrors.push(err7);
|
|
2317
|
+
}
|
|
2318
|
+
errors++;
|
|
2319
|
+
}
|
|
2320
|
+
}
|
|
2321
|
+
if (data.code !== void 0) {
|
|
2322
|
+
let data2 = data.code;
|
|
2323
|
+
if (typeof data2 === "string") {
|
|
2324
|
+
if (func3(data2) < 1) {
|
|
2325
|
+
const err8 = { instancePath: instancePath + "/code", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
|
|
2326
|
+
if (vErrors === null) {
|
|
2327
|
+
vErrors = [err8];
|
|
2328
|
+
} else {
|
|
2329
|
+
vErrors.push(err8);
|
|
2330
|
+
}
|
|
2331
|
+
errors++;
|
|
2332
|
+
}
|
|
2333
|
+
} else {
|
|
2334
|
+
const err9 = { instancePath: instancePath + "/code", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
2335
|
+
if (vErrors === null) {
|
|
2336
|
+
vErrors = [err9];
|
|
2337
|
+
} else {
|
|
2338
|
+
vErrors.push(err9);
|
|
2339
|
+
}
|
|
2340
|
+
errors++;
|
|
2341
|
+
}
|
|
2342
|
+
}
|
|
2343
|
+
if (data.events !== void 0) {
|
|
2344
|
+
let data3 = data.events;
|
|
2345
|
+
if (Array.isArray(data3)) {
|
|
2346
|
+
const len0 = data3.length;
|
|
2347
|
+
for (let i0 = 0; i0 < len0; i0++) {
|
|
2348
|
+
if (!validate18(data3[i0], { instancePath: instancePath + "/events/" + i0, parentData: data3, parentDataProperty: i0, rootData })) {
|
|
2349
|
+
vErrors = vErrors === null ? validate18.errors : vErrors.concat(validate18.errors);
|
|
2350
|
+
errors = vErrors.length;
|
|
2351
|
+
}
|
|
2352
|
+
}
|
|
2353
|
+
} else {
|
|
2354
|
+
const err10 = { instancePath: instancePath + "/events", schemaPath: "#/properties/events/type", keyword: "type", params: { type: "array" }, message: "must be array" };
|
|
2355
|
+
if (vErrors === null) {
|
|
2356
|
+
vErrors = [err10];
|
|
2357
|
+
} else {
|
|
2358
|
+
vErrors.push(err10);
|
|
2359
|
+
}
|
|
2360
|
+
errors++;
|
|
2361
|
+
}
|
|
2362
|
+
}
|
|
2363
|
+
} else {
|
|
2364
|
+
const err11 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
2365
|
+
if (vErrors === null) {
|
|
2366
|
+
vErrors = [err11];
|
|
2367
|
+
} else {
|
|
2368
|
+
vErrors.push(err11);
|
|
2369
|
+
}
|
|
2370
|
+
errors++;
|
|
2371
|
+
}
|
|
2372
|
+
validate17.errors = vErrors;
|
|
2373
|
+
return errors === 0;
|
|
2374
|
+
}
|
|
2375
|
+
function validate23(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
|
|
2376
|
+
let vErrors = null;
|
|
2377
|
+
let errors = 0;
|
|
2378
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
2379
|
+
if (data.lifelines === void 0) {
|
|
2380
|
+
const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "lifelines" }, message: "must have required property 'lifelines'" };
|
|
2381
|
+
if (vErrors === null) {
|
|
2382
|
+
vErrors = [err0];
|
|
2383
|
+
} else {
|
|
2384
|
+
vErrors.push(err0);
|
|
2385
|
+
}
|
|
2386
|
+
errors++;
|
|
2387
|
+
}
|
|
2388
|
+
for (const key0 in data) {
|
|
2389
|
+
if (!(key0 === "lifelines")) {
|
|
2390
|
+
const err1 = { instancePath, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" };
|
|
2391
|
+
if (vErrors === null) {
|
|
2392
|
+
vErrors = [err1];
|
|
2393
|
+
} else {
|
|
2394
|
+
vErrors.push(err1);
|
|
2395
|
+
}
|
|
2396
|
+
errors++;
|
|
2397
|
+
}
|
|
2398
|
+
}
|
|
2399
|
+
if (data.lifelines !== void 0) {
|
|
2400
|
+
let data0 = data.lifelines;
|
|
2401
|
+
if (Array.isArray(data0)) {
|
|
2402
|
+
if (data0.length < 1) {
|
|
2403
|
+
const err2 = { instancePath: instancePath + "/lifelines", schemaPath: "#/properties/lifelines/minItems", keyword: "minItems", params: { limit: 1 }, message: "must NOT have fewer than 1 items" };
|
|
2404
|
+
if (vErrors === null) {
|
|
2405
|
+
vErrors = [err2];
|
|
2406
|
+
} else {
|
|
2407
|
+
vErrors.push(err2);
|
|
2408
|
+
}
|
|
2409
|
+
errors++;
|
|
2410
|
+
}
|
|
2411
|
+
const len0 = data0.length;
|
|
2412
|
+
for (let i0 = 0; i0 < len0; i0++) {
|
|
2413
|
+
let data1 = data0[i0];
|
|
2414
|
+
if (typeof data1 === "string") {
|
|
2415
|
+
if (!pattern0.test(data1)) {
|
|
2416
|
+
const err3 = { instancePath: instancePath + "/lifelines/" + i0, schemaPath: "#/definitions/id/pattern", keyword: "pattern", params: { pattern: "^[^\\s\\[\\]\u300C\u300D=:]+$" }, message: 'must match pattern "^[^\\s\\[\\]\u300C\u300D=:]+$"' };
|
|
2417
|
+
if (vErrors === null) {
|
|
2418
|
+
vErrors = [err3];
|
|
2419
|
+
} else {
|
|
2420
|
+
vErrors.push(err3);
|
|
2421
|
+
}
|
|
2422
|
+
errors++;
|
|
2423
|
+
}
|
|
2424
|
+
} else {
|
|
2425
|
+
const err4 = { instancePath: instancePath + "/lifelines/" + i0, schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
2426
|
+
if (vErrors === null) {
|
|
2427
|
+
vErrors = [err4];
|
|
2428
|
+
} else {
|
|
2429
|
+
vErrors.push(err4);
|
|
2430
|
+
}
|
|
2431
|
+
errors++;
|
|
2432
|
+
}
|
|
2433
|
+
}
|
|
2434
|
+
} else {
|
|
2435
|
+
const err5 = { instancePath: instancePath + "/lifelines", schemaPath: "#/properties/lifelines/type", keyword: "type", params: { type: "array" }, message: "must be array" };
|
|
2436
|
+
if (vErrors === null) {
|
|
2437
|
+
vErrors = [err5];
|
|
2438
|
+
} else {
|
|
2439
|
+
vErrors.push(err5);
|
|
2440
|
+
}
|
|
2441
|
+
errors++;
|
|
2442
|
+
}
|
|
2443
|
+
}
|
|
2444
|
+
} else {
|
|
2445
|
+
const err6 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
2446
|
+
if (vErrors === null) {
|
|
2447
|
+
vErrors = [err6];
|
|
2448
|
+
} else {
|
|
2449
|
+
vErrors.push(err6);
|
|
2450
|
+
}
|
|
2451
|
+
errors++;
|
|
2452
|
+
}
|
|
2453
|
+
validate23.errors = vErrors;
|
|
2454
|
+
return errors === 0;
|
|
2455
|
+
}
|
|
2456
|
+
function validate10(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
|
|
2457
|
+
let vErrors = null;
|
|
2458
|
+
let errors = 0;
|
|
2459
|
+
const _errs1 = errors;
|
|
2460
|
+
let valid0 = true;
|
|
2461
|
+
const _errs2 = errors;
|
|
2462
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
2463
|
+
if (data.kind === void 0 && ("kind")) {
|
|
2464
|
+
const err0 = {};
|
|
2465
|
+
if (vErrors === null) {
|
|
2466
|
+
vErrors = [err0];
|
|
2467
|
+
} else {
|
|
2468
|
+
vErrors.push(err0);
|
|
2469
|
+
}
|
|
2470
|
+
errors++;
|
|
2471
|
+
} else {
|
|
2472
|
+
if (data.kind !== void 0) {
|
|
2473
|
+
if ("sequence" !== data.kind) {
|
|
2474
|
+
const err1 = {};
|
|
2475
|
+
if (vErrors === null) {
|
|
2476
|
+
vErrors = [err1];
|
|
2477
|
+
} else {
|
|
2478
|
+
vErrors.push(err1);
|
|
2479
|
+
}
|
|
2480
|
+
errors++;
|
|
2481
|
+
}
|
|
2482
|
+
}
|
|
2483
|
+
}
|
|
2484
|
+
}
|
|
2485
|
+
var _valid0 = _errs2 === errors;
|
|
2486
|
+
errors = _errs1;
|
|
2487
|
+
if (vErrors !== null) {
|
|
2488
|
+
if (_errs1) {
|
|
2489
|
+
vErrors.length = _errs1;
|
|
2490
|
+
} else {
|
|
2491
|
+
vErrors = null;
|
|
2492
|
+
}
|
|
2493
|
+
}
|
|
2494
|
+
let ifClause0;
|
|
2495
|
+
if (_valid0) {
|
|
2496
|
+
const _errs4 = errors;
|
|
2497
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
2498
|
+
if (data.sequence === void 0) {
|
|
2499
|
+
const err2 = { instancePath, schemaPath: "#/then/required", keyword: "required", params: { missingProperty: "sequence" }, message: "must have required property 'sequence'" };
|
|
2500
|
+
if (vErrors === null) {
|
|
2501
|
+
vErrors = [err2];
|
|
2502
|
+
} else {
|
|
2503
|
+
vErrors.push(err2);
|
|
2504
|
+
}
|
|
2505
|
+
errors++;
|
|
2506
|
+
}
|
|
2507
|
+
}
|
|
2508
|
+
var _valid0 = _errs4 === errors;
|
|
2509
|
+
valid0 = _valid0;
|
|
2510
|
+
ifClause0 = "then";
|
|
2511
|
+
} else {
|
|
2512
|
+
const _errs5 = errors;
|
|
2513
|
+
const _errs6 = errors;
|
|
2514
|
+
const _errs7 = errors;
|
|
2515
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
2516
|
+
if (data.sequence === void 0 && ("sequence")) {
|
|
2517
|
+
const err3 = {};
|
|
2518
|
+
if (vErrors === null) {
|
|
2519
|
+
vErrors = [err3];
|
|
2520
|
+
} else {
|
|
2521
|
+
vErrors.push(err3);
|
|
2522
|
+
}
|
|
2523
|
+
errors++;
|
|
2524
|
+
}
|
|
2525
|
+
}
|
|
2526
|
+
var valid2 = _errs7 === errors;
|
|
2527
|
+
if (valid2) {
|
|
2528
|
+
const err4 = { instancePath, schemaPath: "#/else/not", keyword: "not", params: {}, message: "must NOT be valid" };
|
|
2529
|
+
if (vErrors === null) {
|
|
2530
|
+
vErrors = [err4];
|
|
2531
|
+
} else {
|
|
2532
|
+
vErrors.push(err4);
|
|
2533
|
+
}
|
|
2534
|
+
errors++;
|
|
2535
|
+
} else {
|
|
2536
|
+
errors = _errs6;
|
|
2537
|
+
if (vErrors !== null) {
|
|
2538
|
+
if (_errs6) {
|
|
2539
|
+
vErrors.length = _errs6;
|
|
2540
|
+
} else {
|
|
2541
|
+
vErrors = null;
|
|
2542
|
+
}
|
|
2543
|
+
}
|
|
2544
|
+
}
|
|
2545
|
+
var _valid0 = _errs5 === errors;
|
|
2546
|
+
valid0 = _valid0;
|
|
2547
|
+
ifClause0 = "else";
|
|
2548
|
+
}
|
|
2549
|
+
if (!valid0) {
|
|
2550
|
+
const err5 = { instancePath, schemaPath: "#/if", keyword: "if", params: { failingKeyword: ifClause0 }, message: 'must match "' + ifClause0 + '" schema' };
|
|
2551
|
+
if (vErrors === null) {
|
|
2552
|
+
vErrors = [err5];
|
|
2553
|
+
} else {
|
|
2554
|
+
vErrors.push(err5);
|
|
2555
|
+
}
|
|
2556
|
+
errors++;
|
|
2557
|
+
}
|
|
2558
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
2559
|
+
if (data.version === void 0) {
|
|
2560
|
+
const err6 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "version" }, message: "must have required property 'version'" };
|
|
2561
|
+
if (vErrors === null) {
|
|
2562
|
+
vErrors = [err6];
|
|
2563
|
+
} else {
|
|
2564
|
+
vErrors.push(err6);
|
|
2565
|
+
}
|
|
2566
|
+
errors++;
|
|
2567
|
+
}
|
|
2568
|
+
if (data.kind === void 0) {
|
|
2569
|
+
const err7 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "kind" }, message: "must have required property 'kind'" };
|
|
2570
|
+
if (vErrors === null) {
|
|
2571
|
+
vErrors = [err7];
|
|
2572
|
+
} else {
|
|
2573
|
+
vErrors.push(err7);
|
|
2574
|
+
}
|
|
2575
|
+
errors++;
|
|
2576
|
+
}
|
|
2577
|
+
if (data.title === void 0) {
|
|
2578
|
+
const err8 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "title" }, message: "must have required property 'title'" };
|
|
2579
|
+
if (vErrors === null) {
|
|
2580
|
+
vErrors = [err8];
|
|
2581
|
+
} else {
|
|
2582
|
+
vErrors.push(err8);
|
|
2583
|
+
}
|
|
2584
|
+
errors++;
|
|
2585
|
+
}
|
|
2586
|
+
if (data.boxes === void 0) {
|
|
2587
|
+
const err9 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "boxes" }, message: "must have required property 'boxes'" };
|
|
2588
|
+
if (vErrors === null) {
|
|
2589
|
+
vErrors = [err9];
|
|
2590
|
+
} else {
|
|
2591
|
+
vErrors.push(err9);
|
|
2592
|
+
}
|
|
2593
|
+
errors++;
|
|
2594
|
+
}
|
|
2595
|
+
if (data.steps === void 0) {
|
|
2596
|
+
const err10 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "steps" }, message: "must have required property 'steps'" };
|
|
2597
|
+
if (vErrors === null) {
|
|
2598
|
+
vErrors = [err10];
|
|
2599
|
+
} else {
|
|
2600
|
+
vErrors.push(err10);
|
|
2601
|
+
}
|
|
2602
|
+
errors++;
|
|
2603
|
+
}
|
|
2604
|
+
for (const key0 in data) {
|
|
2605
|
+
if (!func2.call(schema11.properties, key0)) {
|
|
2606
|
+
const err11 = { instancePath, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" };
|
|
2607
|
+
if (vErrors === null) {
|
|
2608
|
+
vErrors = [err11];
|
|
2609
|
+
} else {
|
|
2610
|
+
vErrors.push(err11);
|
|
2611
|
+
}
|
|
2612
|
+
errors++;
|
|
2613
|
+
}
|
|
2614
|
+
}
|
|
2615
|
+
if (data.version !== void 0) {
|
|
2616
|
+
let data1 = data.version;
|
|
2617
|
+
if (!(typeof data1 == "number" && (!(data1 % 1) && !isNaN(data1)) && isFinite(data1))) {
|
|
2618
|
+
const err12 = { instancePath: instancePath + "/version", schemaPath: "#/properties/version/type", keyword: "type", params: { type: "integer" }, message: "must be integer" };
|
|
2619
|
+
if (vErrors === null) {
|
|
2620
|
+
vErrors = [err12];
|
|
2621
|
+
} else {
|
|
2622
|
+
vErrors.push(err12);
|
|
2623
|
+
}
|
|
2624
|
+
errors++;
|
|
2625
|
+
}
|
|
2626
|
+
if (typeof data1 == "number" && isFinite(data1)) {
|
|
2627
|
+
if (data1 < 1 || isNaN(data1)) {
|
|
2628
|
+
const err13 = { instancePath: instancePath + "/version", schemaPath: "#/properties/version/minimum", keyword: "minimum", params: { comparison: ">=", limit: 1 }, message: "must be >= 1" };
|
|
2629
|
+
if (vErrors === null) {
|
|
2630
|
+
vErrors = [err13];
|
|
2631
|
+
} else {
|
|
2632
|
+
vErrors.push(err13);
|
|
2633
|
+
}
|
|
2634
|
+
errors++;
|
|
2635
|
+
}
|
|
2636
|
+
}
|
|
2637
|
+
}
|
|
2638
|
+
if (data.kind !== void 0) {
|
|
2639
|
+
let data2 = data.kind;
|
|
2640
|
+
if (!(data2 === "sequence" || data2 === "architecture")) {
|
|
2641
|
+
const err14 = { 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" };
|
|
2642
|
+
if (vErrors === null) {
|
|
2643
|
+
vErrors = [err14];
|
|
2644
|
+
} else {
|
|
2645
|
+
vErrors.push(err14);
|
|
2646
|
+
}
|
|
2647
|
+
errors++;
|
|
2648
|
+
}
|
|
2649
|
+
}
|
|
2650
|
+
if (data.title !== void 0) {
|
|
2651
|
+
let data3 = data.title;
|
|
2652
|
+
if (typeof data3 === "string") {
|
|
2653
|
+
if (func3(data3) < 1) {
|
|
2654
|
+
const err15 = { instancePath: instancePath + "/title", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
|
|
2655
|
+
if (vErrors === null) {
|
|
2656
|
+
vErrors = [err15];
|
|
2657
|
+
} else {
|
|
2658
|
+
vErrors.push(err15);
|
|
2659
|
+
}
|
|
2660
|
+
errors++;
|
|
2661
|
+
}
|
|
2662
|
+
} else {
|
|
2663
|
+
const err16 = { instancePath: instancePath + "/title", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
2664
|
+
if (vErrors === null) {
|
|
2665
|
+
vErrors = [err16];
|
|
2666
|
+
} else {
|
|
2667
|
+
vErrors.push(err16);
|
|
2668
|
+
}
|
|
2669
|
+
errors++;
|
|
2670
|
+
}
|
|
2671
|
+
}
|
|
2672
|
+
if (data.view !== void 0) {
|
|
2673
|
+
let data4 = data.view;
|
|
2674
|
+
if (!(data4 === "fixed" || data4 === "follow")) {
|
|
2675
|
+
const err17 = { 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" };
|
|
2676
|
+
if (vErrors === null) {
|
|
2677
|
+
vErrors = [err17];
|
|
2678
|
+
} else {
|
|
2679
|
+
vErrors.push(err17);
|
|
2680
|
+
}
|
|
2681
|
+
errors++;
|
|
2682
|
+
}
|
|
2683
|
+
}
|
|
2684
|
+
if (data.regions !== void 0) {
|
|
2685
|
+
let data5 = data.regions;
|
|
2686
|
+
if (Array.isArray(data5)) {
|
|
2687
|
+
const len0 = data5.length;
|
|
2688
|
+
for (let i0 = 0; i0 < len0; i0++) {
|
|
2689
|
+
if (!validate11(data5[i0], { instancePath: instancePath + "/regions/" + i0, parentData: data5, parentDataProperty: i0, rootData })) {
|
|
2690
|
+
vErrors = vErrors === null ? validate11.errors : vErrors.concat(validate11.errors);
|
|
2691
|
+
errors = vErrors.length;
|
|
2692
|
+
}
|
|
2693
|
+
}
|
|
2694
|
+
} else {
|
|
2695
|
+
const err18 = { instancePath: instancePath + "/regions", schemaPath: "#/properties/regions/type", keyword: "type", params: { type: "array" }, message: "must be array" };
|
|
2696
|
+
if (vErrors === null) {
|
|
2697
|
+
vErrors = [err18];
|
|
2698
|
+
} else {
|
|
2699
|
+
vErrors.push(err18);
|
|
2700
|
+
}
|
|
2701
|
+
errors++;
|
|
2702
|
+
}
|
|
2703
|
+
}
|
|
2704
|
+
if (data.boxes !== void 0) {
|
|
2705
|
+
let data7 = data.boxes;
|
|
2706
|
+
if (Array.isArray(data7)) {
|
|
2707
|
+
if (data7.length < 1) {
|
|
2708
|
+
const err19 = { instancePath: instancePath + "/boxes", schemaPath: "#/properties/boxes/minItems", keyword: "minItems", params: { limit: 1 }, message: "must NOT have fewer than 1 items" };
|
|
2709
|
+
if (vErrors === null) {
|
|
2710
|
+
vErrors = [err19];
|
|
2711
|
+
} else {
|
|
2712
|
+
vErrors.push(err19);
|
|
2713
|
+
}
|
|
2714
|
+
errors++;
|
|
2715
|
+
}
|
|
2716
|
+
const len1 = data7.length;
|
|
2717
|
+
for (let i1 = 0; i1 < len1; i1++) {
|
|
2718
|
+
if (!validate13(data7[i1], { instancePath: instancePath + "/boxes/" + i1, parentData: data7, parentDataProperty: i1, rootData })) {
|
|
2719
|
+
vErrors = vErrors === null ? validate13.errors : vErrors.concat(validate13.errors);
|
|
2720
|
+
errors = vErrors.length;
|
|
2721
|
+
}
|
|
2722
|
+
}
|
|
2723
|
+
} else {
|
|
2724
|
+
const err20 = { instancePath: instancePath + "/boxes", schemaPath: "#/properties/boxes/type", keyword: "type", params: { type: "array" }, message: "must be array" };
|
|
2725
|
+
if (vErrors === null) {
|
|
2726
|
+
vErrors = [err20];
|
|
2727
|
+
} else {
|
|
2728
|
+
vErrors.push(err20);
|
|
2729
|
+
}
|
|
2730
|
+
errors++;
|
|
2731
|
+
}
|
|
2732
|
+
}
|
|
2733
|
+
if (data.strip !== void 0) {
|
|
2734
|
+
if (!validate15(data.strip, { instancePath: instancePath + "/strip", parentData: data, parentDataProperty: "strip", rootData })) {
|
|
2735
|
+
vErrors = vErrors === null ? validate15.errors : vErrors.concat(validate15.errors);
|
|
2736
|
+
errors = vErrors.length;
|
|
2737
|
+
}
|
|
2738
|
+
}
|
|
2739
|
+
if (data.steps !== void 0) {
|
|
2740
|
+
let data10 = data.steps;
|
|
2741
|
+
if (Array.isArray(data10)) {
|
|
2742
|
+
if (data10.length < 1) {
|
|
2743
|
+
const err21 = { instancePath: instancePath + "/steps", schemaPath: "#/properties/steps/minItems", keyword: "minItems", params: { limit: 1 }, message: "must NOT have fewer than 1 items" };
|
|
2744
|
+
if (vErrors === null) {
|
|
2745
|
+
vErrors = [err21];
|
|
2746
|
+
} else {
|
|
2747
|
+
vErrors.push(err21);
|
|
2748
|
+
}
|
|
2749
|
+
errors++;
|
|
2750
|
+
}
|
|
2751
|
+
const len2 = data10.length;
|
|
2752
|
+
for (let i2 = 0; i2 < len2; i2++) {
|
|
2753
|
+
if (!validate17(data10[i2], { instancePath: instancePath + "/steps/" + i2, parentData: data10, parentDataProperty: i2, rootData })) {
|
|
2754
|
+
vErrors = vErrors === null ? validate17.errors : vErrors.concat(validate17.errors);
|
|
2755
|
+
errors = vErrors.length;
|
|
2756
|
+
}
|
|
2757
|
+
}
|
|
2758
|
+
} else {
|
|
2759
|
+
const err22 = { instancePath: instancePath + "/steps", schemaPath: "#/properties/steps/type", keyword: "type", params: { type: "array" }, message: "must be array" };
|
|
2760
|
+
if (vErrors === null) {
|
|
2761
|
+
vErrors = [err22];
|
|
2762
|
+
} else {
|
|
2763
|
+
vErrors.push(err22);
|
|
2764
|
+
}
|
|
2765
|
+
errors++;
|
|
2766
|
+
}
|
|
2767
|
+
}
|
|
2768
|
+
if (data.sequence !== void 0) {
|
|
2769
|
+
if (!validate23(data.sequence, { instancePath: instancePath + "/sequence", parentData: data, parentDataProperty: "sequence", rootData })) {
|
|
2770
|
+
vErrors = vErrors === null ? validate23.errors : vErrors.concat(validate23.errors);
|
|
2771
|
+
errors = vErrors.length;
|
|
2772
|
+
}
|
|
2773
|
+
}
|
|
2774
|
+
} else {
|
|
2775
|
+
const err23 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
2776
|
+
if (vErrors === null) {
|
|
2777
|
+
vErrors = [err23];
|
|
2778
|
+
} else {
|
|
2779
|
+
vErrors.push(err23);
|
|
2780
|
+
}
|
|
2781
|
+
errors++;
|
|
2782
|
+
}
|
|
2783
|
+
validate10.errors = vErrors;
|
|
2784
|
+
return errors === 0;
|
|
2785
|
+
}
|
|
2786
|
+
|
|
2787
|
+
// src/schema.ts
|
|
2788
|
+
var EVENT_TYPES = ["edge", "action", "swap", "strip"];
|
|
2789
|
+
var NOT_ALLOWED = {
|
|
2790
|
+
"": { field: "sequence", kind: "sequence" },
|
|
2791
|
+
carry: { field: "text", kind: "tag" }
|
|
2792
|
+
};
|
|
2793
|
+
var escape = (key) => key.replaceAll("~", "~0").replaceAll("/", "~1");
|
|
2794
|
+
function forbiddenOf(pattern) {
|
|
2795
|
+
const inside = /^\^\[\^(.+)\]\+\$$/u.exec(pattern)?.[1];
|
|
2796
|
+
if (inside === void 0) return void 0;
|
|
2797
|
+
const chars = inside.match(/\\.|[^\\]/gu) ?? [];
|
|
2798
|
+
return { space: chars.includes("\\s"), chars: chars.filter((char) => char !== "\\s").map((char) => char.replace(/^\\/u, "")) };
|
|
2799
|
+
}
|
|
2800
|
+
var branchesOf = (anyOf, errors) => errors.filter(
|
|
2801
|
+
(error) => error !== anyOf && error.schemaPath.startsWith(`${anyOf.schemaPath}/`) && (error.instancePath === anyOf.instancePath || error.instancePath.startsWith(`${anyOf.instancePath}/`))
|
|
2802
|
+
);
|
|
2803
|
+
function toFieldError(error, errors, m) {
|
|
2804
|
+
const params = error.params;
|
|
2805
|
+
const at2 = error.instancePath;
|
|
2806
|
+
switch (error.keyword) {
|
|
2807
|
+
case "additionalProperties": {
|
|
2808
|
+
const key = String(params.additionalProperty);
|
|
2809
|
+
return { pointer: `${at2}/${escape(key)}`, message: m.additionalProperties(key) };
|
|
2810
|
+
}
|
|
2811
|
+
case "required": {
|
|
2812
|
+
const key = String(params.missingProperty);
|
|
2813
|
+
return { pointer: `${at2}/${escape(key)}`, message: m.required(key) };
|
|
2814
|
+
}
|
|
2815
|
+
case "not": {
|
|
2816
|
+
const allowed = NOT_ALLOWED[at2.slice(at2.lastIndexOf("/") + 1)];
|
|
2817
|
+
return { pointer: allowed ? `${at2}/${allowed.field}` : at2, message: m.not(allowed) };
|
|
2818
|
+
}
|
|
2819
|
+
case "anyOf": {
|
|
2820
|
+
const branches = branchesOf(error, errors);
|
|
2821
|
+
const missing = branches.every((branch) => branch.keyword === "required") ? branches.map((branch) => String(branch.params.missingProperty)) : [];
|
|
2822
|
+
return { pointer: at2, message: m.anyOf(missing) };
|
|
2823
|
+
}
|
|
2824
|
+
case "discriminator": {
|
|
2825
|
+
const tag = String(params.tag);
|
|
2826
|
+
return { pointer: `${at2}/${escape(tag)}`, message: m.discriminator(tag, EVENT_TYPES) };
|
|
2827
|
+
}
|
|
2828
|
+
case "enum":
|
|
2829
|
+
return { pointer: at2, message: m.enum(params.allowedValues.map(String)) };
|
|
2830
|
+
case "type":
|
|
2831
|
+
return { pointer: at2, message: m.type(String(params.type)) };
|
|
2832
|
+
case "minLength":
|
|
2833
|
+
return { pointer: at2, message: m.minLength(Number(params.limit)) };
|
|
2834
|
+
case "pattern":
|
|
2835
|
+
return { pointer: at2, message: m.pattern(forbiddenOf(String(params.pattern))) };
|
|
2836
|
+
case "minItems":
|
|
2837
|
+
return { pointer: at2, message: m.minItems(Number(params.limit)) };
|
|
2838
|
+
case "minimum":
|
|
2839
|
+
return { pointer: at2, message: m.minimum(Number(params.limit)) };
|
|
2840
|
+
case "const":
|
|
2841
|
+
return { pointer: at2, message: m.const(String(params.allowedValue)) };
|
|
2842
|
+
case "oneOf":
|
|
2843
|
+
return { pointer: at2, message: m.oneOf };
|
|
2844
|
+
default:
|
|
2845
|
+
return { pointer: at2, message: error.message ?? error.keyword };
|
|
2846
|
+
}
|
|
2847
|
+
}
|
|
2848
|
+
function validateDiagram(input, options = {}) {
|
|
2849
|
+
if (validate_diagram_default(input)) return { ok: true };
|
|
2850
|
+
const all = validate_diagram_default.errors ?? [];
|
|
2851
|
+
const inBranch = new Set(all.filter((error) => error.keyword === "anyOf").flatMap((anyOf) => branchesOf(anyOf, all)));
|
|
2852
|
+
const m = FIELD_MESSAGES[options.lang ?? "ja"];
|
|
2853
|
+
const errors = all.filter((error) => error.keyword !== "if" && !inBranch.has(error)).map((error) => toFieldError(error, all, m));
|
|
2854
|
+
return { ok: false, errors };
|
|
2855
|
+
}
|
|
2856
|
+
|
|
2857
|
+
// src/version.ts
|
|
2858
|
+
var FORMAT_VERSION = 1;
|
|
2859
|
+
function newerThanTool(input) {
|
|
2860
|
+
if (typeof input !== "object" || input === null) return void 0;
|
|
2861
|
+
const version = input.version;
|
|
2862
|
+
return typeof version === "number" && version > FORMAT_VERSION ? version : void 0;
|
|
2863
|
+
}
|
|
2864
|
+
var newerError = (version, lang) => ({
|
|
2865
|
+
pointer: "/version",
|
|
2866
|
+
message: FIELD_MESSAGES[lang].newer(version, FORMAT_VERSION)
|
|
2867
|
+
});
|
|
2868
|
+
function readDiagram(input, options = {}) {
|
|
2869
|
+
const newer = newerThanTool(input);
|
|
2870
|
+
if (newer !== void 0) return { ok: false, errors: [newerError(newer, options.lang ?? "ja")] };
|
|
2871
|
+
const checked = validateDiagram(input, options);
|
|
2872
|
+
if (!checked.ok) return checked;
|
|
2873
|
+
return { ok: true, diagram: input, warnings: [] };
|
|
2874
|
+
}
|
|
2875
|
+
|
|
2876
|
+
// src/timeline.ts
|
|
2877
|
+
function plan(step) {
|
|
2878
|
+
const out = { edges: [], events: [], busy: 0 };
|
|
2879
|
+
let cursor = MOTION.edgeAt;
|
|
2880
|
+
let arrived;
|
|
2881
|
+
let changes = 0;
|
|
2882
|
+
step.events.forEach((event, e) => {
|
|
2883
|
+
if (event.type === "edge") {
|
|
2884
|
+
const carries = event.carry.kind !== "none";
|
|
2885
|
+
const a = cursor;
|
|
2886
|
+
const b = a + (carries ? MOTION.drawCarry : MOTION.draw);
|
|
2887
|
+
out.edges.push({ event: e, a, b, carries, coin: event.carry.kind === "coin", named: event.label !== void 0 });
|
|
2888
|
+
cursor = a + MOTION.stagger;
|
|
2889
|
+
arrived = b;
|
|
2890
|
+
changes = 0;
|
|
2891
|
+
out.busy = Math.max(out.busy, b);
|
|
2892
|
+
} else if (event.type === "action") {
|
|
2893
|
+
out.events.push({ event: e, at: cursor });
|
|
2894
|
+
out.busy = Math.max(out.busy, cursor + MOTION.action);
|
|
2895
|
+
cursor += MOTION.action;
|
|
2896
|
+
changes = 0;
|
|
2897
|
+
} else {
|
|
2898
|
+
const at2 = (arrived ?? cursor) + MOTION.change * changes++;
|
|
2899
|
+
out.events.push({ event: e, at: at2 });
|
|
2900
|
+
out.busy = Math.max(out.busy, at2);
|
|
2901
|
+
}
|
|
2902
|
+
});
|
|
2903
|
+
return out;
|
|
2904
|
+
}
|
|
2905
|
+
function buildTimeline(diagram) {
|
|
2906
|
+
const plans = diagram.steps.map(plan);
|
|
2907
|
+
const steps = [];
|
|
2908
|
+
let t = MOTION.intro;
|
|
2909
|
+
diagram.steps.forEach((step, s) => {
|
|
2910
|
+
const read = Math.min(MOTION.stepMax, Math.max(MOTION.stepMin, MOTION.stepBase + [...step.body].length * MOTION.perChar));
|
|
2911
|
+
const length = Math.max(read, (plans[s]?.busy ?? 0) + MOTION.dwell);
|
|
2912
|
+
steps.push({ start: t, end: t + length });
|
|
2913
|
+
t += length;
|
|
2914
|
+
});
|
|
2915
|
+
const end = t;
|
|
2916
|
+
const total = Math.ceil(end + MOTION.outro);
|
|
2917
|
+
const last = total - MOTION.tail;
|
|
2918
|
+
const edges = [];
|
|
2919
|
+
const labels = [];
|
|
2920
|
+
const events = [];
|
|
2921
|
+
const departures = [];
|
|
2922
|
+
plans.forEach((p, s) => {
|
|
2923
|
+
const span = steps[s];
|
|
2924
|
+
const named = [];
|
|
2925
|
+
for (const edge2 of p.edges) {
|
|
2926
|
+
const a = span.start + edge2.a;
|
|
2927
|
+
edges.push({ step: s, event: edge2.event, start: a, drawn: span.start + edge2.b, end: span.end });
|
|
2928
|
+
if (edge2.carries) departures.push({ step: s, event: edge2.event, who: edge2.coin ? "coin" : "main", a, b: span.start + edge2.b });
|
|
2929
|
+
if (edge2.named) named.push({ step: s, event: edge2.event, start: a + MOTION.labelDelay, end: span.end });
|
|
2930
|
+
}
|
|
2931
|
+
named.forEach((label2, k) => {
|
|
2932
|
+
const later = named[k + 2];
|
|
2933
|
+
if (later) label2.end = Math.min(label2.end, later.start);
|
|
2934
|
+
});
|
|
2935
|
+
labels.push(...named);
|
|
2936
|
+
for (const event of p.events) events.push({ step: s, event: event.event, at: span.start + event.at });
|
|
2937
|
+
});
|
|
2938
|
+
const first = steps[0]?.start ?? 0;
|
|
2939
|
+
const hasMain = departures.some((d) => d.who === "main");
|
|
2940
|
+
const carriers = [];
|
|
2941
|
+
for (const who of ["main", "coin"]) {
|
|
2942
|
+
const list = departures.filter((d) => d.who === who);
|
|
2943
|
+
list.forEach((d, k) => {
|
|
2944
|
+
const next = list[k + 1];
|
|
2945
|
+
const waits = k === 0 && (who === "main" || !hasMain);
|
|
2946
|
+
carriers.push({
|
|
2947
|
+
step: d.step,
|
|
2948
|
+
event: d.event,
|
|
2949
|
+
who,
|
|
2950
|
+
depart: d.a,
|
|
2951
|
+
arrive: d.b,
|
|
2952
|
+
start: waits ? Math.min(first, d.a) : d.a,
|
|
2953
|
+
end: next ? Math.max(next.a, d.b) : last
|
|
2954
|
+
});
|
|
2955
|
+
});
|
|
2956
|
+
}
|
|
2957
|
+
carriers.sort((x, y) => x.depart - y.depart);
|
|
2958
|
+
return {
|
|
2959
|
+
total,
|
|
2960
|
+
last,
|
|
2961
|
+
steps,
|
|
2962
|
+
edges,
|
|
2963
|
+
carriers,
|
|
2964
|
+
labels,
|
|
2965
|
+
badges: steps.map((span, s) => ({ step: s, appears: span.start })),
|
|
2966
|
+
events,
|
|
2967
|
+
stills: steps.map((span) => span.end - MOTION.still)
|
|
2968
|
+
};
|
|
2969
|
+
}
|
|
2970
|
+
|
|
2971
|
+
// src/render/icons.ts
|
|
2972
|
+
var ICONS = {
|
|
2973
|
+
app: "M -9 -7 h18 a2 2 0 0 1 2 2 v10 a2 2 0 0 1 -2 2 h-18 a2 2 0 0 1 -2 -2 v-10 a2 2 0 0 1 2 -2 z M -11 -2 h22",
|
|
2974
|
+
router: "M -9 -4 h16 M 3 -8 l4 4 l-4 4 M 9 5 h-16 M -3 1 l-4 4 l4 4",
|
|
2975
|
+
on: "M -7 7 L 7 -7 M -1 -7 h8 v8",
|
|
2976
|
+
off: "M -7 -7 L 7 7 M 7 -1 v8 h-8",
|
|
2977
|
+
pool: "M -9 -5 a9 3.5 0 1 0 18 0 a9 3.5 0 1 0 -18 0 M -9 -5 v10 a9 3.5 0 0 0 18 0 v-10 M -9 0 a9 3.5 0 0 0 18 0",
|
|
2978
|
+
db: "M -9 -5 a9 3.5 0 1 0 18 0 a9 3.5 0 1 0 -18 0 M -9 -5 v10 a9 3.5 0 0 0 18 0 v-10 M -9 0 a9 3.5 0 0 0 18 0",
|
|
2979
|
+
exe: "M -5 -8 L 7 0 L -5 8 Z",
|
|
2980
|
+
idx: "M -9 -7 h18 M -9 -2 h18 M -9 3 h18 M -9 8 h11",
|
|
2981
|
+
sign: "M -9 4 c 3 -9 5 -9 6 0 s 3 7 6 -2 s 3 -6 6 0",
|
|
2982
|
+
env: "M -8 -5.5 h16 v11 h-16 z M -8 -5.5 l8 6 l8 -6",
|
|
2983
|
+
lock: "M -5.5 -1 h11 v8 h-11 z M -3.5 -1 v-3 a3.5 3.5 0 0 1 7 0 v3",
|
|
2984
|
+
check: "M -5 0 l3.5 3.5 l6.5 -7",
|
|
2985
|
+
x: "M -5 -5 l10 10 M 5 -5 l-10 10",
|
|
2986
|
+
chain: "M -1.5 4.5 l-2 2 a3.5 3.5 0 0 1 -5 -5 l3 -3 a3.5 3.5 0 0 1 5 0 M 1.5 -4.5 l2 -2 a3.5 3.5 0 0 1 5 5 l-3 3 a3.5 3.5 0 0 1 -5 0 M -2.5 2.5 l5 -5",
|
|
2987
|
+
net: "M -1.3 -4.6 L -5.8 3 M 1.3 -4.6 L 5.8 3 M -4.3 5.5 H 4.3 M -2.2 -7 a 2.2 2.2 0 1 0 4.4 0 a 2.2 2.2 0 1 0 -4.4 0 M -9.2 5.5 a 2.2 2.2 0 1 0 4.4 0 a 2.2 2.2 0 1 0 -4.4 0 M 4.8 5.5 a 2.2 2.2 0 1 0 4.4 0 a 2.2 2.2 0 1 0 -4.4 0",
|
|
2988
|
+
user: "M -4 -4.5 a4 4 0 1 0 8 0 a4 4 0 1 0 -8 0 M -8 9 c0 -5 3.6 -7.5 8 -7.5 s8 2.5 8 7.5",
|
|
2989
|
+
server: "M -9 -8 h18 v7 h-18 z M -9 1 h18 v7 h-18 z M -5 -4.5 h0.01 M -5 4.5 h0.01",
|
|
2990
|
+
key: "M -9 0 a3.5 3.5 0 1 0 7 0 a3.5 3.5 0 1 0 -7 0 M -2 0 h10 M 5 0 v3.5 M 8 0 v2.5",
|
|
2991
|
+
shield: "M 0 -9 l8 3 v5 c0 5 -3.5 8 -8 10 c-4.5 -2 -8 -5 -8 -10 v-5 z",
|
|
2992
|
+
globe: "M -9 0 a9 9 0 1 0 18 0 a9 9 0 1 0 -18 0 M -9 0 h18 M 0 -9 c-4.5 4 -4.5 14 0 18 M 0 -9 c4.5 4 4.5 14 0 18",
|
|
2993
|
+
bolt: "M 2 -9 L -5 1 h5 l-2 8 l7 -10 h-5 z",
|
|
2994
|
+
doc: "M -6 -9 h8 l5 5 v13 h-13 z M 2 -9 v5 h5 M -3 1 h7 M -3 5 h5",
|
|
2995
|
+
box: "M -9 -4.5 l9 -4.5 l9 4.5 v9 l-9 4.5 l-9 -4.5 z M -9 -4.5 l9 4.5 l9 -4.5 M 0 0 v9",
|
|
2996
|
+
truck: "M -10 -6 h11 v10 h-11 z M 1 -2 h5 l3.5 3.5 v2.5 h-8.5 M -7.5 6.5 a1.8 1.8 0 1 0 3.6 0 a1.8 1.8 0 1 0 -3.6 0 M 3 6.5 a1.8 1.8 0 1 0 3.6 0 a1.8 1.8 0 1 0 -3.6 0",
|
|
2997
|
+
card: "M -9 -6.5 h18 a2 2 0 0 1 2 2 v9 a2 2 0 0 1 -2 2 h-18 a2 2 0 0 1 -2 -2 v-9 a2 2 0 0 1 2 -2 z M -11 -2 h22 M -7 3 h5",
|
|
2998
|
+
cart: "M -10 -8 h3 l3 11 h11 l2.5 -8 h-15.5 M -4.5 7.5 a1.5 1.5 0 1 0 3 0 a1.5 1.5 0 1 0 -3 0 M 5 7.5 a1.5 1.5 0 1 0 3 0 a1.5 1.5 0 1 0 -3 0",
|
|
2999
|
+
clock: "M -9 0 a9 9 0 1 0 18 0 a9 9 0 1 0 -18 0 M 0 -5 v5 l3.5 2.5",
|
|
3000
|
+
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",
|
|
3001
|
+
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",
|
|
3002
|
+
refresh: "M 7 -3 a7.5 7.5 0 1 0 0.5 5 M 7.5 -8 v5 h-5",
|
|
3003
|
+
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",
|
|
3004
|
+
code: "M -4 -6 l-5 6 l5 6 M 4 -6 l5 6 l-5 6",
|
|
3005
|
+
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",
|
|
3006
|
+
block: "M -9 -7 h18 a2 2 0 0 1 2 2 v10 a2 2 0 0 1 -2 2 h-18 a2 2 0 0 1 -2 -2 v-10 a2 2 0 0 1 2 -2 z M -11 -2.5 h22 M -6 2.5 h8"
|
|
3007
|
+
};
|
|
3008
|
+
|
|
3009
|
+
// src/render/parts.ts
|
|
3010
|
+
var esc = (s) => s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
3011
|
+
var r1 = (v) => Math.round(v * 100) / 100;
|
|
3012
|
+
var cs = (k) => k === "coin" ? "--c:var(--coin);--ct:var(--coint)" : `--c:var(--c-${k});--ct:var(--t-${k})`;
|
|
3013
|
+
function glyph(name, x, y, scale, cls = "dg-gl") {
|
|
3014
|
+
const d = name === void 0 ? void 0 : ICONS[name];
|
|
3015
|
+
return d ? `<path class="${cls}" transform="translate(${r1(x)} ${r1(y)}) scale(${scale})" d="${d}"/>` : "";
|
|
3016
|
+
}
|
|
3017
|
+
var pathOf = (points) => points.map(([x, y], i) => `${i === 0 ? "M" : "L"} ${r1(x)} ${r1(y)}`).join(" ");
|
|
3018
|
+
function arrowHead(points) {
|
|
3019
|
+
const [ex, ey] = points[points.length - 1];
|
|
3020
|
+
const [px, py] = points[points.length - 2];
|
|
3021
|
+
const len = Math.hypot(ex - px, ey - py) || 1;
|
|
3022
|
+
const dx = (ex - px) / len;
|
|
3023
|
+
const dy = (ey - py) / len;
|
|
3024
|
+
const { arrow: a, arrowHalf: h } = LOOK.edge;
|
|
3025
|
+
return `M ${r1(ex - dx * a - dy * h)} ${r1(ey - dy * a + dx * h)} L ${r1(ex)} ${r1(ey)} L ${r1(ex - dx * a + dy * h)} ${r1(ey - dy * a - dx * h)}`;
|
|
3026
|
+
}
|
|
3027
|
+
function rangeKf(m, ranges2) {
|
|
3028
|
+
const pts = [[0, { opacity: 0 }]];
|
|
3029
|
+
for (const [a, b] of ranges2) pts.push([a, { opacity: 0 }, EASE.out], [a + MOTION.fade, { opacity: 1 }], [b - 0.1, { opacity: 1 }, EASE.inOut], [b + 0.25, { opacity: 0 }]);
|
|
3030
|
+
pts.push([m.total, { opacity: 0 }]);
|
|
3031
|
+
return m.kf(pts);
|
|
3032
|
+
}
|
|
3033
|
+
function activeKf(ctx, on) {
|
|
3034
|
+
const ranges2 = [];
|
|
3035
|
+
for (let k = 0; k < on.length; ) {
|
|
3036
|
+
let e = k;
|
|
3037
|
+
while (e + 1 < on.length && on[e + 1] === on[e] + 1) e++;
|
|
3038
|
+
ranges2.push([ctx.t.steps[on[k]].start, ctx.t.steps[on[e]].end]);
|
|
3039
|
+
k = e + 1;
|
|
3040
|
+
}
|
|
3041
|
+
return rangeKf(ctx.m, ranges2);
|
|
3042
|
+
}
|
|
3043
|
+
function band(region) {
|
|
3044
|
+
const { radius, icon, iconRadius, iconScale, nameY, line } = LOOK.region;
|
|
3045
|
+
const { x, y } = region.header;
|
|
3046
|
+
const lines = region.lines.map((t, k) => `<text class="dg-bz" x="${r1(x)}" y="${r1(region.y + nameY + k * line)}">${esc(t)}</text>`).join("");
|
|
3047
|
+
const note = region.note ? `<text class="dg-bx" x="${r1(x)}" y="${r1(region.y + nameY + region.lines.length * line + 1)}">${esc(region.note)}</text>` : "";
|
|
3048
|
+
const mark = region.icon && ICONS[region.icon] ? `<rect class="dg-bi" x="${r1(x)}" y="${r1(y)}" width="${icon}" height="${icon}" rx="${iconRadius}"/>${glyph(region.icon, x + icon / 2, y + icon / 2, iconScale)}` : "";
|
|
3049
|
+
return `<g style="${cs(region.color)}"><rect class="dg-band" x="${r1(region.x + 0.5)}" y="${r1(region.y + 0.5)}" width="${r1(region.w - 1)}" height="${r1(region.h - 1)}" rx="${radius}"/>${mark}${lines}${note}</g>`;
|
|
3050
|
+
}
|
|
3051
|
+
function card(box, ctx, on, changes) {
|
|
3052
|
+
const { m, sh } = ctx;
|
|
3053
|
+
const { radius, icon, iconRadius, iconScale, iconY, nameY, subY } = LOOK.box;
|
|
3054
|
+
const seq = [[0, box.sub ?? "", "dg-ss"], ...changes];
|
|
3055
|
+
const subs = seq.map(([t, text2, cls], k) => {
|
|
3056
|
+
const next = seq[k + 1]?.[0];
|
|
3057
|
+
const anim = k === 0 ? next === void 0 ? "" : m.until(next - MOTION.untilFade) : next === void 0 ? m.rise(t) : m.rise(t, next - MOTION.untilFade);
|
|
3058
|
+
if (text2 === "") return "";
|
|
3059
|
+
return `<g${anim ? ` class="dg-a" style="${anim}"` : ""}><text class="${cls}" x="${r1(box.cx)}" y="${r1(box.cy + subY)}" text-anchor="middle">${esc(text2)}</text></g>`;
|
|
3060
|
+
}).join("");
|
|
3061
|
+
const act = on.length > 0 ? activeKf(ctx, on) : void 0;
|
|
3062
|
+
const rect = (cls, extra = "") => `<rect class="${cls}" x="${r1(box.x)}" y="${r1(box.y)}" width="${r1(box.w)}" height="${box.h}" rx="${radius}"${extra}/>`;
|
|
3063
|
+
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)}` : "";
|
|
3064
|
+
return `<g style="${cs(box.color)}">${act ? `<g class="dg-a" style="${act}">${rect("dg-halo")}</g>` : ""}${rect("dg-st", ` ${sh}`)}${act ? `<g class="dg-a" style="${act}">${rect("dg-on")}</g>` : ""}${mark}<text class="dg-sn" x="${r1(box.cx)}" y="${r1(box.cy + nameY)}" text-anchor="middle">${esc(box.name)}</text>${subs}</g>`;
|
|
3065
|
+
}
|
|
3066
|
+
function lifeline(x, y1, y2) {
|
|
3067
|
+
return `<line class="dg-ll" x1="${r1(x)}" y1="${r1(y1)}" x2="${r1(x)}" y2="${r1(y2)}"/>`;
|
|
3068
|
+
}
|
|
3069
|
+
function edge(e, time, ctx) {
|
|
3070
|
+
const { m } = ctx;
|
|
3071
|
+
const d = pathOf(e.points);
|
|
3072
|
+
const head = arrowHead(e.points);
|
|
3073
|
+
const { start: a, drawn: b, end } = time;
|
|
3074
|
+
const tail = [
|
|
3075
|
+
[end, { opacity: 1 }, EASE.inOut],
|
|
3076
|
+
[end + 0.4, { opacity: 0.45 }],
|
|
3077
|
+
[ctx.end + 0.3, { opacity: 0.45 }, EASE.inOut],
|
|
3078
|
+
[ctx.end + 1, { opacity: 0.95 }],
|
|
3079
|
+
[m.last, { opacity: 0.95 }, EASE.inOut],
|
|
3080
|
+
[m.total, { opacity: 0 }]
|
|
3081
|
+
];
|
|
3082
|
+
const line = m.kf([
|
|
3083
|
+
[0, { opacity: 0, "stroke-dashoffset": 1 }],
|
|
3084
|
+
[a, { opacity: 0, "stroke-dashoffset": 1 }, EASE.inOut],
|
|
3085
|
+
[a + 0.05, { opacity: 1 }],
|
|
3086
|
+
[b, { "stroke-dashoffset": 0 }],
|
|
3087
|
+
[m.last, { "stroke-dashoffset": 0 }],
|
|
3088
|
+
[m.total, { "stroke-dashoffset": 1 }],
|
|
3089
|
+
...tail
|
|
3090
|
+
]);
|
|
3091
|
+
const hk = m.kf([[0, { opacity: 0 }], [b - 0.05, { opacity: 0 }], [b, { opacity: 1 }], ...tail]);
|
|
3092
|
+
const run = -(end - b) * 26;
|
|
3093
|
+
const flow = m.kf([
|
|
3094
|
+
[0, { opacity: 0, "stroke-dashoffset": 0 }],
|
|
3095
|
+
[b, { opacity: 0, "stroke-dashoffset": 0 }],
|
|
3096
|
+
[b + 0.25, { opacity: 0.9 }],
|
|
3097
|
+
[end - 0.1, { opacity: 0.9 }, EASE.inOut],
|
|
3098
|
+
[end + 0.2, { opacity: 0, "stroke-dashoffset": run }],
|
|
3099
|
+
[m.total, { opacity: 0, "stroke-dashoffset": run }]
|
|
3100
|
+
]);
|
|
3101
|
+
return {
|
|
3102
|
+
base: `<path class="dg-e" d="${d}"/><path class="dg-eh" d="${head}"/>`,
|
|
3103
|
+
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>`
|
|
3104
|
+
};
|
|
3105
|
+
}
|
|
3106
|
+
function label(l, time, ctx) {
|
|
3107
|
+
const ja2 = l.family === "sans" ? " dg-capj" : "";
|
|
3108
|
+
const { radius } = LOOK.label;
|
|
3109
|
+
return `<g class="dg-cap${ja2} 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="${r1(l.x + l.w / 2)}" y="${r1(l.y + l.h / 2 + LOOK.baseline.label)}" text-anchor="middle">${esc(l.text)}</text></g>`;
|
|
3110
|
+
}
|
|
3111
|
+
function action(a, at2, until, ctx) {
|
|
3112
|
+
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>`;
|
|
3113
|
+
}
|
|
3114
|
+
function carrierShape(e, sh) {
|
|
3115
|
+
const C = LOOK.carrier;
|
|
3116
|
+
if (e.carry.kind === "coin") return `<circle class="dg-coin" r="${C.coinR}"/><circle class="dg-coin-in" r="${C.coinIn}"/>`;
|
|
3117
|
+
if (e.carry.kind === "tag") {
|
|
3118
|
+
const text2 = e.carry.text;
|
|
3119
|
+
const ja2 = hasWide(text2);
|
|
3120
|
+
const w = textWidth(text2, ja2 ? TYPE.carrierJa : TYPE.carrier) + C.tagPadX * 2;
|
|
3121
|
+
return `<rect class="dg-car" x="${r1(-w / 2)}" y="${ -18 / 2}" width="${r1(w)}" height="${C.tagH}" rx="${C.tagH / 2}" ${sh}/><text class="dg-car-t${ja2 ? " dg-car-tj" : ""}" y="${LOOK.baseline.carrier}" text-anchor="middle">${esc(text2)}</text>`;
|
|
3122
|
+
}
|
|
3123
|
+
return `<rect class="dg-env" x="${ -24 / 2}" y="${ -17 / 2}" width="${C.envW}" height="${C.envH}" rx="3" ${sh}/><path class="dg-env-in" d="M -8 -4.5 L 0 1.5 L 8 -4.5"/>`;
|
|
3124
|
+
}
|
|
3125
|
+
var easeInOut = (t) => t < 0.5 ? 4 * t * t * t : 1 - (-2 * t + 2) ** 3 / 2;
|
|
3126
|
+
function carrier(e, time, ctx) {
|
|
3127
|
+
const { m } = ctx;
|
|
3128
|
+
const n = LOOK.carrier.samples;
|
|
3129
|
+
const length = pathLength(e.points);
|
|
3130
|
+
const { depart: a, arrive: b, start: from, end: gone } = time;
|
|
3131
|
+
const path = [];
|
|
3132
|
+
for (let k = 0; k <= n; k++) {
|
|
3133
|
+
const [x, y] = along(e.points, easeInOut(k / n) * length);
|
|
3134
|
+
path.push([a + (b - a) * k / n, x, y]);
|
|
3135
|
+
}
|
|
3136
|
+
const first = path[0];
|
|
3137
|
+
const lastPoint = path[path.length - 1];
|
|
3138
|
+
const rest = e.settle ?? [lastPoint[1], lastPoint[2]];
|
|
3139
|
+
const pts = [[0, first[1], first[2]], ...path];
|
|
3140
|
+
if (e.settle) pts.push([Math.min(b + 0.3, Math.max(gone, b + 0.01)), rest[0], rest[1]]);
|
|
3141
|
+
pts.push([gone, rest[0], rest[1]], [m.total, rest[0], rest[1]]);
|
|
3142
|
+
const fade = gone < m.last ? 0.05 : 0.18;
|
|
3143
|
+
return `<g class="dg-a" style="${m.move(pts, m.blink(from + 0.02, gone, fade))}">${carrierShape(e, ctx.sh)}</g>`;
|
|
3144
|
+
}
|
|
3145
|
+
function badge(b, ctx) {
|
|
3146
|
+
const { m } = ctx;
|
|
3147
|
+
const span = ctx.t.steps[b.step];
|
|
3148
|
+
const a = span.start;
|
|
3149
|
+
const e = span.end;
|
|
3150
|
+
const { r, ring: rr } = LOOK.badge;
|
|
3151
|
+
const fill = m.kf([
|
|
3152
|
+
[0, { opacity: 0, transform: "scale(.5)" }],
|
|
3153
|
+
[a, { opacity: 0, transform: "scale(.5)" }, EASE.pop],
|
|
3154
|
+
[a + 0.35, { opacity: 1, transform: "scale(1)" }],
|
|
3155
|
+
[e, { opacity: 1, transform: "scale(1)" }, EASE.inOut],
|
|
3156
|
+
[e + 0.4, { opacity: 0, transform: "scale(1)" }],
|
|
3157
|
+
[m.total, { opacity: 0, transform: "scale(.5)" }]
|
|
3158
|
+
]);
|
|
3159
|
+
const past = m.kf([[0, { opacity: 0 }], [e, { opacity: 0 }, EASE.inOut], [e + 0.4, { opacity: 1 }], [m.last, { opacity: 1 }, EASE.inOut], [m.total, { opacity: 0 }]]);
|
|
3160
|
+
const ring = m.kf([
|
|
3161
|
+
[0, { opacity: 0, transform: "scale(1)" }],
|
|
3162
|
+
[a + 0.05, { opacity: 0, transform: "scale(1)" }],
|
|
3163
|
+
[a + 0.1, { opacity: 0.7, transform: "scale(1)" }, EASE.out],
|
|
3164
|
+
[a + 0.9, { opacity: 0, transform: "scale(2.3)" }],
|
|
3165
|
+
[m.total, { opacity: 0, transform: "scale(1)" }]
|
|
3166
|
+
]);
|
|
3167
|
+
const x = r1(b.x);
|
|
3168
|
+
const y = r1(b.y);
|
|
3169
|
+
const ty = r1(b.y + LOOK.baseline.badge);
|
|
3170
|
+
const no = b.step + 1;
|
|
3171
|
+
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>`;
|
|
3172
|
+
}
|
|
3173
|
+
function strip(s, changes, ctx) {
|
|
3174
|
+
const { m, sh } = ctx;
|
|
3175
|
+
const S2 = LOOK.strip;
|
|
3176
|
+
const my = s.y + S2.h / 2;
|
|
3177
|
+
const parts = [
|
|
3178
|
+
`<rect class="dg-strip" 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}" ${sh}/>`,
|
|
3179
|
+
`<g style="${cs("slate")}"><rect class="dg-bi" x="${r1(s.x + S2.pad)}" y="${r1(my - S2.icon / 2)}" width="${S2.icon}" height="${S2.icon}" rx="${LOOK.box.iconRadius}"/>${glyph("env", s.x + S2.pad + S2.icon / 2, my, 0.78)}</g>`,
|
|
3180
|
+
`<text class="dg-sh" x="${r1(s.x + S2.titleX)}" y="${r1(my + LOOK.baseline.stripTitle)}">${esc(s.title)}</text>`
|
|
3181
|
+
];
|
|
3182
|
+
s.fields.forEach((field, i) => {
|
|
3183
|
+
const prev = s.fields[i - 1];
|
|
3184
|
+
if (prev && prev.y === field.y) {
|
|
3185
|
+
const sx = field.x - S2.fieldGap / 2;
|
|
3186
|
+
parts.push(`<line class="dg-sep" x1="${r1(sx)}" y1="${r1(field.y + S2.sepInset)}" x2="${r1(sx)}" y2="${r1(field.y + S2.h - S2.sepInset)}"/>`);
|
|
3187
|
+
}
|
|
3188
|
+
parts.push(`<text class="dg-fl" x="${r1(field.x)}" y="${r1(field.y + S2.nameY)}">${esc(field.name)}</text>`);
|
|
3189
|
+
const list = changes.get(field.name) ?? [];
|
|
3190
|
+
const values = list.filter((c) => c.value !== void 0);
|
|
3191
|
+
const tags = list.filter((c) => c.tag !== void 0);
|
|
3192
|
+
values.forEach((c, k) => {
|
|
3193
|
+
const next = values[k + 1]?.at;
|
|
3194
|
+
const value = c.value;
|
|
3195
|
+
const anim = next === void 0 ? m.rise(c.at) : m.rise(c.at, next - MOTION.untilFade);
|
|
3196
|
+
parts.push(`<g class="dg-a" style="${anim}"><text class="${hasWide(value) ? "dg-fvj" : "dg-fv"}" x="${r1(field.x)}" y="${r1(field.y + S2.valueY)}">${esc(value)}</text></g>`);
|
|
3197
|
+
});
|
|
3198
|
+
tags.forEach((c, k) => {
|
|
3199
|
+
const next = tags[k + 1]?.at;
|
|
3200
|
+
const tag = c.tag;
|
|
3201
|
+
const shown = [...values].reverse().find((v) => v.at <= c.at + 1e-9)?.value;
|
|
3202
|
+
const x = field.x + (shown ? textWidth(shown, hasWide(shown) ? TYPE.fieldValueJa : TYPE.fieldValue) + S2.tagGap : 0);
|
|
3203
|
+
const w = textWidth(tag, TYPE.tag) + S2.tagPadX * 2;
|
|
3204
|
+
const y = field.y + S2.valueY - S2.tagH / 2 - LOOK.baseline.tag;
|
|
3205
|
+
parts.push(
|
|
3206
|
+
`<g class="dg-tg dg-popc dg-a" style="${cs(c.color)};${next === void 0 ? m.pop(c.at) : m.pop(c.at, next - MOTION.untilFade)}"><rect x="${r1(x)}" y="${r1(y)}" width="${r1(w)}" height="${S2.tagH}" rx="${S2.tagH / 2}"/><text x="${r1(x + w / 2)}" y="${r1(y + S2.tagH / 2 + LOOK.baseline.tag)}" text-anchor="middle">${esc(tag)}</text></g>`
|
|
3207
|
+
);
|
|
3208
|
+
});
|
|
3209
|
+
});
|
|
3210
|
+
return parts.join("");
|
|
3211
|
+
}
|
|
3212
|
+
|
|
3213
|
+
// src/render/motion.ts
|
|
3214
|
+
var r2 = (v) => Math.round(v * 100) / 100;
|
|
3215
|
+
var Motion = class {
|
|
3216
|
+
constructor(prefix, total, last) {
|
|
3217
|
+
this.prefix = prefix;
|
|
3218
|
+
this.total = total;
|
|
3219
|
+
this.last = last;
|
|
3220
|
+
}
|
|
3221
|
+
prefix;
|
|
3222
|
+
total;
|
|
3223
|
+
last;
|
|
3224
|
+
frames = [];
|
|
3225
|
+
count = 0;
|
|
3226
|
+
pct(t) {
|
|
3227
|
+
return +(Math.min(Math.max(t, 0), this.total) / this.total * 100).toFixed(3);
|
|
3228
|
+
}
|
|
3229
|
+
/** keyframes を 1 つ足し、その名前を付ける style の字を返す。 */
|
|
3230
|
+
kf(points) {
|
|
3231
|
+
const name = `${this.prefix}-${this.count++}`;
|
|
3232
|
+
const at2 = /* @__PURE__ */ new Map();
|
|
3233
|
+
for (const [t, props, ease] of [...points].sort((a, b) => a[0] - b[0])) {
|
|
3234
|
+
const p = this.pct(t);
|
|
3235
|
+
const cur = at2.get(p) ?? { props: {} };
|
|
3236
|
+
Object.assign(cur.props, props);
|
|
3237
|
+
if (ease) cur.ease = ease;
|
|
3238
|
+
at2.set(p, cur);
|
|
3239
|
+
}
|
|
3240
|
+
const body = [...at2].map(([p, { props, ease }]) => {
|
|
3241
|
+
const d = Object.entries(props).map(([k, v]) => `${k}:${v}`);
|
|
3242
|
+
if (ease) d.push(`animation-timing-function:${ease}`);
|
|
3243
|
+
return `${p}%{${d.join(";")}}`;
|
|
3244
|
+
}).join("");
|
|
3245
|
+
this.frames.push(`@keyframes ${name}{${body}}`);
|
|
3246
|
+
return `animation-name:${name}`;
|
|
3247
|
+
}
|
|
3248
|
+
/** `a` で出て `b` から消える。`within` を立てると `b` までに消え終わる。 */
|
|
3249
|
+
vis(a, b = this.last, o = {}) {
|
|
3250
|
+
const f = o.f ?? MOTION.fade;
|
|
3251
|
+
const on = o.on ?? {};
|
|
3252
|
+
const off = o.off ?? {};
|
|
3253
|
+
const out = o.within ? Math.max(a + f, b - f) : b;
|
|
3254
|
+
return this.kf([
|
|
3255
|
+
[0, { opacity: 0, ...off }],
|
|
3256
|
+
[a, { opacity: 0, ...off }, o.ein ?? EASE.out],
|
|
3257
|
+
[a + f, { opacity: 1, ...on }],
|
|
3258
|
+
[out, { opacity: 1, ...on }, EASE.inOut],
|
|
3259
|
+
[Math.min(out + f, this.total), { opacity: 0, ...off }],
|
|
3260
|
+
[this.total, { opacity: 0, ...off }]
|
|
3261
|
+
]);
|
|
3262
|
+
}
|
|
3263
|
+
/** 少し下から浮いて出る。 */
|
|
3264
|
+
rise(a, b = this.last, within = false) {
|
|
3265
|
+
return this.vis(a, b, { on: { transform: "translateY(0)" }, off: { transform: `translateY(${LOOK.rise}px)` }, within });
|
|
3266
|
+
}
|
|
3267
|
+
/** 小さな所から弾んで出る。 */
|
|
3268
|
+
pop(a, b = this.last) {
|
|
3269
|
+
return this.vis(a, b, { f: MOTION.popFade, ein: EASE.pop, on: { transform: "scale(1)" }, off: { transform: `scale(${LOOK.popFrom})` } });
|
|
3270
|
+
}
|
|
3271
|
+
/** 初めから出ていて `b` で消える。 */
|
|
3272
|
+
until(b) {
|
|
3273
|
+
const f = MOTION.untilFade;
|
|
3274
|
+
return this.kf([
|
|
3275
|
+
[0, { opacity: 1 }],
|
|
3276
|
+
[b, { opacity: 1 }, EASE.inOut],
|
|
3277
|
+
[b + f, { opacity: 0 }],
|
|
3278
|
+
[this.last, { opacity: 0 }],
|
|
3279
|
+
[this.total, { opacity: 1 }]
|
|
3280
|
+
]);
|
|
3281
|
+
}
|
|
3282
|
+
/** 点を辿って動く。`[時刻, x, y, 大きさ, 次の点までの緩急]` の並び。 */
|
|
3283
|
+
move(points, extra = []) {
|
|
3284
|
+
return this.kf(
|
|
3285
|
+
points.map(([t, x, y, s = 1, ease]) => [t, { transform: `translate(${r2(x)}px,${r2(y)}px) scale(${s})` }, ease]).concat(extra)
|
|
3286
|
+
);
|
|
3287
|
+
}
|
|
3288
|
+
/** `a` から `b` まで見え、`fade` 秒で消える。 */
|
|
3289
|
+
blink(a, b, fade) {
|
|
3290
|
+
return [
|
|
3291
|
+
[0, { opacity: 0 }],
|
|
3292
|
+
[a - 0.01, { opacity: 0 }],
|
|
3293
|
+
[a, { opacity: 1 }],
|
|
3294
|
+
[b, { opacity: 1 }],
|
|
3295
|
+
[b + fade, { opacity: 0 }],
|
|
3296
|
+
[this.total, { opacity: 0 }]
|
|
3297
|
+
];
|
|
3298
|
+
}
|
|
3299
|
+
};
|
|
3300
|
+
|
|
3301
|
+
// src/render/svg.ts
|
|
3302
|
+
var font = (t) => `font:${t.weight} ${t.size}px var(--${t.family})`;
|
|
3303
|
+
var mix = (pct, base = "var(--surf)") => `color-mix(in srgb,var(--c) ${pct}%,${base})`;
|
|
3304
|
+
var S = LOOK.stroke;
|
|
3305
|
+
var X = LOOK.mix;
|
|
3306
|
+
var PART_CSS = [
|
|
3307
|
+
".dg{display:block;width:100%;height:auto;overflow:visible}",
|
|
3308
|
+
".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)}",
|
|
3309
|
+
".dg .dg-popc{transform-box:fill-box;transform-origin:center}",
|
|
3310
|
+
".dg-bg{fill:var(--bg)}",
|
|
3311
|
+
".dg-band{fill:color-mix(in srgb,var(--c) var(--tint),var(--bg));stroke:color-mix(in srgb,var(--c) var(--edge),transparent)}",
|
|
3312
|
+
`.dg-bi{fill:${mix(X.regionIcon)};stroke:${mix(X.regionIconEdge, "transparent")}}`,
|
|
3313
|
+
`.dg-bz{${font(TYPE.regionName)};fill:var(--ct)}`,
|
|
3314
|
+
`.dg-bx{${font(TYPE.regionNote)};fill:var(--mute)}`,
|
|
3315
|
+
".dg-st{fill:var(--surf);stroke:var(--hair)}",
|
|
3316
|
+
`.dg-halo{fill:none;stroke:var(--c);stroke-width:${S.halo};stroke-opacity:.16}`,
|
|
3317
|
+
`.dg-on{fill:none;stroke:var(--c);stroke-width:${S.on}}`,
|
|
3318
|
+
`.dg-ic{fill:${mix(X.icon)}}`,
|
|
3319
|
+
`.dg-gl{fill:none;stroke:var(--c);stroke-width:${S.glyph};stroke-linecap:round;stroke-linejoin:round}`,
|
|
3320
|
+
`.dg-sn{${font(TYPE.boxName)};fill:var(--ink)}`,
|
|
3321
|
+
`.dg-ss{${font(TYPE.boxSub)};fill:var(--mute)}`,
|
|
3322
|
+
`.dg-ss-ok{${font(TYPE.boxSubStrong)};fill:var(--ct)}`,
|
|
3323
|
+
`.dg-ss-act{${font(TYPE.boxSubStrong)};fill:var(--ink)}`,
|
|
3324
|
+
`.dg-ll{stroke:var(--line);stroke-width:${S.lifeline};stroke-dasharray:3 4}`,
|
|
3325
|
+
`.dg-e{fill:none;stroke:var(--line);stroke-width:${S.edge};stroke-linecap:round;stroke-dasharray:0 ${LOOK.edge.ghostDash}}`,
|
|
3326
|
+
`.dg-eh{fill:none;stroke:var(--line);stroke-width:${S.arrow};stroke-linecap:round;stroke-linejoin:round}`,
|
|
3327
|
+
`.dg-e-on{fill:none;stroke:var(--c);stroke-width:${S.edgeOn};stroke-linecap:round;stroke-dasharray:1 2}`,
|
|
3328
|
+
`.dg-eh-on{fill:none;stroke:var(--c);stroke-width:${S.edgeOn};stroke-linecap:round;stroke-linejoin:round}`,
|
|
3329
|
+
`.dg-flow{fill:none;stroke:var(--surf);stroke-width:${S.flow};stroke-linecap:round;stroke-dasharray:1.5 ${LOOK.edge.flowDash}}`,
|
|
3330
|
+
".dg-bd{cursor:pointer}",
|
|
3331
|
+
".dg-bdf{fill:var(--c)}",
|
|
3332
|
+
`.dg-bdft{${font(TYPE.badge)};fill:var(--on-c)}`,
|
|
3333
|
+
`.dg-bdr{fill:none;stroke:var(--c);stroke-width:${S.badgeRing}}`,
|
|
3334
|
+
`.dg-bdp{fill:${mix(X.badgePast)};stroke:${mix(X.badgePastEdge, "transparent")};stroke-width:${S.hair}}`,
|
|
3335
|
+
`.dg-bdpt{${font(TYPE.badge)};fill:var(--ct)}`,
|
|
3336
|
+
`.dg-cap rect,.dg-act rect{fill:${mix(X.cap)};stroke:${mix(X.capEdge, "transparent")}}`,
|
|
3337
|
+
`.dg-cap text{${font(TYPE.label)};fill:var(--ct)}`,
|
|
3338
|
+
`.dg-capj text{${font(TYPE.labelJa)}}`,
|
|
3339
|
+
`.dg-act text{${font(TYPE.action)};fill:var(--ct)}`,
|
|
3340
|
+
".dg-car{fill:var(--carry,var(--ink))}",
|
|
3341
|
+
`.dg-car-t{${font(TYPE.carrier)};fill:var(--bg)}`,
|
|
3342
|
+
`.dg-car-tj{${font(TYPE.carrierJa)}}`,
|
|
3343
|
+
`.dg-env{fill:var(--carry,var(--ink));stroke:var(--surf);stroke-width:${S.envelope}}`,
|
|
3344
|
+
`.dg-env-in{fill:none;stroke:var(--surf);stroke-width:${S.flow};stroke-linejoin:round;stroke-linecap:round}`,
|
|
3345
|
+
".dg-coin{fill:var(--coin);stroke:var(--surf);stroke-width:1.2}",
|
|
3346
|
+
".dg-coin-in{fill:none;stroke:var(--coinin);stroke-width:1.1}",
|
|
3347
|
+
".dg-strip{fill:var(--surf);stroke:var(--hair)}",
|
|
3348
|
+
`.dg-sep{stroke:var(--hair);stroke-width:${S.hair}}`,
|
|
3349
|
+
`.dg-sh{${font(TYPE.stripTitle)};fill:var(--ink)}`,
|
|
3350
|
+
`.dg-fl{${font(TYPE.fieldName)};fill:var(--mute)}`,
|
|
3351
|
+
`.dg-fv{${font(TYPE.fieldValue)};fill:var(--ink)}`,
|
|
3352
|
+
`.dg-fvj{${font(TYPE.fieldValueJa)};fill:var(--ink)}`,
|
|
3353
|
+
".dg-tg rect{fill:var(--c)}",
|
|
3354
|
+
`.dg-tg text{${font(TYPE.tag)};fill:var(--on-c)}`,
|
|
3355
|
+
".dg-vp-bg{fill:var(--bg)}",
|
|
3356
|
+
".dg-vp-frame{fill:none;stroke:var(--hair)}",
|
|
3357
|
+
".dg-mm-bg{fill:var(--surf);stroke:var(--hair)}",
|
|
3358
|
+
`.dg-mm-t{${font(TYPE.miniTitle)};fill:var(--mute)}`,
|
|
3359
|
+
".dg-mm-world{fill:var(--sunk);stroke:var(--hair)}",
|
|
3360
|
+
`.dg-mm-band{fill:${mix(X.miniBand)};stroke:${mix(X.miniBandEdge, "transparent")};stroke-width:.6}`,
|
|
3361
|
+
`.dg-mm-card{fill:${mix(X.mini)}}`,
|
|
3362
|
+
`.dg-mm-vp{fill:color-mix(in srgb,var(--ink) ${X.view}%,transparent);stroke:var(--ink);stroke-width:${S.badgeRing};vector-effect:non-scaling-stroke}`
|
|
3363
|
+
].join("");
|
|
3364
|
+
function nameOf(text2) {
|
|
3365
|
+
let h = 2166136261;
|
|
3366
|
+
for (let i = 0; i < text2.length; i++) {
|
|
3367
|
+
h ^= text2.charCodeAt(i);
|
|
3368
|
+
h = Math.imul(h, 16777619);
|
|
3369
|
+
}
|
|
3370
|
+
return (h >>> 0).toString(36);
|
|
3371
|
+
}
|
|
3372
|
+
function involved(diagram) {
|
|
3373
|
+
const on = /* @__PURE__ */ new Map();
|
|
3374
|
+
const add = (id, s) => {
|
|
3375
|
+
on.set(id, (on.get(id) ?? /* @__PURE__ */ new Set()).add(s));
|
|
3376
|
+
};
|
|
3377
|
+
diagram.steps.forEach((step, s) => {
|
|
3378
|
+
for (const event of step.events) {
|
|
3379
|
+
if (event.type === "edge") {
|
|
3380
|
+
add(event.from, s);
|
|
3381
|
+
add(event.to, s);
|
|
3382
|
+
} else if (event.type === "action" || event.type === "swap") add(event.box, s);
|
|
3383
|
+
}
|
|
3384
|
+
});
|
|
3385
|
+
return new Map([...on].map(([id, steps]) => [id, [...steps].sort((a, b) => a - b)]));
|
|
3386
|
+
}
|
|
3387
|
+
function subChanges(diagram, timeline, actionsInBox) {
|
|
3388
|
+
const raw = [];
|
|
3389
|
+
let order = 0;
|
|
3390
|
+
for (const time of timeline.events) {
|
|
3391
|
+
const event = diagram.steps[time.step]?.events[time.event];
|
|
3392
|
+
if (event?.type === "swap") raw.push({ t: time.at, order: order++, box: event.box, set: event.text });
|
|
3393
|
+
if (actionsInBox && event?.type === "action") {
|
|
3394
|
+
raw.push({ t: time.at, order: order++, box: event.box, act: event.label });
|
|
3395
|
+
raw.push({ t: timeline.steps[time.step].end, order: order++, box: event.box, act: null });
|
|
3396
|
+
}
|
|
3397
|
+
}
|
|
3398
|
+
raw.sort((a, b) => a.t - b.t || a.order - b.order);
|
|
3399
|
+
const out = /* @__PURE__ */ new Map();
|
|
3400
|
+
for (const box of diagram.boxes) {
|
|
3401
|
+
let base = [box.sub ?? "", "dg-ss"];
|
|
3402
|
+
let acting;
|
|
3403
|
+
let shown = base.join("|");
|
|
3404
|
+
const list = [];
|
|
3405
|
+
for (const change of raw.filter((r) => r.box === box.id)) {
|
|
3406
|
+
if (change.set !== void 0) {
|
|
3407
|
+
base = [change.set, "dg-ss-ok"];
|
|
3408
|
+
acting = void 0;
|
|
3409
|
+
}
|
|
3410
|
+
if (change.act !== void 0) acting = change.act ?? void 0;
|
|
3411
|
+
const now = acting !== void 0 ? [acting, "dg-ss-act"] : base;
|
|
3412
|
+
if (now.join("|") === shown) continue;
|
|
3413
|
+
shown = now.join("|");
|
|
3414
|
+
list.push([change.t, now[0], now[1]]);
|
|
3415
|
+
}
|
|
3416
|
+
const kept = list.filter((change, k) => {
|
|
3417
|
+
const next = list[k + 1];
|
|
3418
|
+
return next === void 0 || next[0] - change[0] >= MOTION.minShow;
|
|
3419
|
+
});
|
|
3420
|
+
out.set(box.id, kept);
|
|
3421
|
+
}
|
|
3422
|
+
return out;
|
|
3423
|
+
}
|
|
3424
|
+
function fieldChanges(diagram, timeline, layout) {
|
|
3425
|
+
const out = /* @__PURE__ */ new Map();
|
|
3426
|
+
for (const time of timeline.events) {
|
|
3427
|
+
const event = diagram.steps[time.step]?.events[time.event];
|
|
3428
|
+
if (event?.type !== "strip") continue;
|
|
3429
|
+
const color = layout.badges[time.step]?.color ?? "slate";
|
|
3430
|
+
const list = out.get(event.field) ?? [];
|
|
3431
|
+
list.push({ at: time.at, color, ...event.value !== void 0 ? { value: event.value } : {}, ...event.tag !== void 0 ? { tag: event.tag } : {} });
|
|
3432
|
+
out.set(event.field, list);
|
|
3433
|
+
}
|
|
3434
|
+
return out;
|
|
3435
|
+
}
|
|
3436
|
+
function drawSvg(diagram, layout, timeline, palette, theme, follow) {
|
|
3437
|
+
const id = nameOf(`${JSON.stringify(diagram)}|${palette.id}|${theme}|${follow ? `${follow.width}|${follow.lang}` : ""}`);
|
|
3438
|
+
const m = new Motion(`dg${id}`, timeline.total, timeline.last);
|
|
3439
|
+
const ctx = { m, t: timeline, sh: `filter="url(#dg-sh-${id})"`, end: timeline.steps[timeline.steps.length - 1].end };
|
|
3440
|
+
const on = involved(diagram);
|
|
3441
|
+
const subs = subChanges(diagram, timeline, layout.kind === "architecture");
|
|
3442
|
+
const L = { band: [], base: [], lit: [], node: [], badge: [], top: [] };
|
|
3443
|
+
for (const region of layout.regions) L.band.push(band(region));
|
|
3444
|
+
if (layout.strip) L.band.push(strip(layout.strip, fieldChanges(diagram, timeline, layout), ctx));
|
|
3445
|
+
for (const line of layout.lifelines) L.base.push(lifeline(line.x, line.y1, line.y2));
|
|
3446
|
+
for (const e of layout.edges) {
|
|
3447
|
+
const time = timeline.edges.find((t) => t.step === e.step && t.event === e.event);
|
|
3448
|
+
if (!time) continue;
|
|
3449
|
+
const drawn = edge(e, time, ctx);
|
|
3450
|
+
L.base.push(drawn.base);
|
|
3451
|
+
L.lit.push(drawn.lit);
|
|
3452
|
+
}
|
|
3453
|
+
for (const box of layout.boxes) L.node.push(card(box, ctx, on.get(box.id) ?? [], subs.get(box.id) ?? []));
|
|
3454
|
+
for (const b of layout.badges) L.badge.push(badge(b, ctx));
|
|
3455
|
+
for (const l of layout.labels) {
|
|
3456
|
+
const time = timeline.labels.find((t) => t.step === l.step && t.event === l.event);
|
|
3457
|
+
if (time) L.top.push(label(l, time, ctx));
|
|
3458
|
+
}
|
|
3459
|
+
for (const a of layout.actions) {
|
|
3460
|
+
const time = timeline.events.find((t) => t.step === a.step && t.event === a.event);
|
|
3461
|
+
if (time) L.top.push(action(a, time.at, timeline.steps[a.step].end, ctx));
|
|
3462
|
+
}
|
|
3463
|
+
for (const time of timeline.carriers) {
|
|
3464
|
+
const e = layout.edges.find((x) => x.step === time.step && x.event === time.event);
|
|
3465
|
+
if (e) L.top.push(carrier(e, time, ctx));
|
|
3466
|
+
}
|
|
3467
|
+
const content = Object.values(L).map((parts) => parts.join("")).join("");
|
|
3468
|
+
const { near, far, nearY, farY } = LOOK.shadow;
|
|
3469
|
+
const shadow = `<filter id="dg-sh-${id}" x="-20%" y="-30%" width="140%" height="180%"><feDropShadow dx="0" dy="${nearY}" stdDeviation="${near}" style="flood-color:var(--sh);flood-opacity:var(--shA)"/><feDropShadow dx="0" dy="${farY}" stdDeviation="${far}" style="flood-color:var(--sh);flood-opacity:var(--shB)"/></filter>`;
|
|
3470
|
+
const view = follow ? followView(layout, timeline, diagram, m, id, content, follow) : { body: `<rect class="dg-bg" width="${layout.width}" height="${layout.height}" rx="${LOOK.region.radius}"/>${content}`, w: layout.width, h: layout.height };
|
|
3471
|
+
const css = `.dg-${id}{${FONT_VARS};--T:${timeline.total}s;${paletteVars(palette, theme)}}${PART_CSS}${m.frames.join("")}`;
|
|
3472
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" class="dg dg-${id}" viewBox="0 0 ${Math.ceil(view.w)} ${Math.ceil(view.h)}" width="${Math.ceil(view.w)}" height="${Math.ceil(view.h)}" role="img" aria-label="${esc(diagram.title)}" data-dragon="figure" data-view="${follow ? "follow" : "fixed"}"><style>${css}</style><defs>${shadow}</defs>${view.body}</svg>`;
|
|
3473
|
+
}
|
|
3474
|
+
function focusOf(layout, diagram, step) {
|
|
3475
|
+
const rects = [];
|
|
3476
|
+
for (const e of layout.edges.filter((x2) => x2.step === step)) {
|
|
3477
|
+
const xs = e.points.map((p) => p[0]);
|
|
3478
|
+
const ys = e.points.map((p) => p[1]);
|
|
3479
|
+
rects.push({ x: Math.min(...xs), y: Math.min(...ys), w: Math.max(...xs) - Math.min(...xs), h: Math.max(...ys) - Math.min(...ys) });
|
|
3480
|
+
}
|
|
3481
|
+
rects.push(...layout.labels.filter((l) => l.step === step), ...layout.actions.filter((a) => a.step === step));
|
|
3482
|
+
for (const event of diagram.steps[step]?.events ?? []) {
|
|
3483
|
+
const ids = event.type === "edge" ? [event.from, event.to] : event.type === "action" || event.type === "swap" ? [event.box] : [];
|
|
3484
|
+
for (const id of ids) {
|
|
3485
|
+
const box = layout.boxes.find((b) => b.id === id);
|
|
3486
|
+
if (box && (layout.kind === "architecture" || event.type === "swap")) rects.push(box);
|
|
3487
|
+
}
|
|
3488
|
+
}
|
|
3489
|
+
if (rects.length === 0) return void 0;
|
|
3490
|
+
const x = Math.min(...rects.map((r) => r.x));
|
|
3491
|
+
const y = Math.min(...rects.map((r) => r.y));
|
|
3492
|
+
return { x, y, w: Math.max(...rects.map((r) => r.x + r.w)) - x, h: Math.max(...rects.map((r) => r.y + r.h)) - y };
|
|
3493
|
+
}
|
|
3494
|
+
function followView(layout, timeline, diagram, m, id, content, follow) {
|
|
3495
|
+
const F = LOOK.follow;
|
|
3496
|
+
const M = LOOK.mini;
|
|
3497
|
+
const vw = Math.min(layout.width, Math.max(1, follow.width));
|
|
3498
|
+
const vh = Math.min(layout.height, Math.max(F.minH, vw * F.aspect));
|
|
3499
|
+
const clampX = (x) => Math.min(layout.width - vw / 2, Math.max(vw / 2, x));
|
|
3500
|
+
const clampY = (y) => Math.min(layout.height - vh / 2, Math.max(vh / 2, y));
|
|
3501
|
+
let prev = [layout.width / 2, layout.height / 2];
|
|
3502
|
+
const centers = timeline.steps.map((_, s) => {
|
|
3503
|
+
const f = focusOf(layout, diagram, s);
|
|
3504
|
+
prev = f ? [f.x + f.w / 2, f.y + f.h / 2] : prev;
|
|
3505
|
+
return [clampX(prev[0]), clampY(prev[1])];
|
|
3506
|
+
});
|
|
3507
|
+
const c0 = centers[0];
|
|
3508
|
+
const cam = [
|
|
3509
|
+
[0, c0[0], c0[1]],
|
|
3510
|
+
[timeline.steps[0].start, c0[0], c0[1]]
|
|
3511
|
+
];
|
|
3512
|
+
centers.forEach((c, s) => {
|
|
3513
|
+
if (s === 0) return;
|
|
3514
|
+
const before = centers[s - 1];
|
|
3515
|
+
const start = timeline.steps[s].start;
|
|
3516
|
+
cam.push([start, before[0], before[1], 1, EASE.inOut], [start + F.ease, c[0], c[1]]);
|
|
3517
|
+
});
|
|
3518
|
+
const cl = centers[centers.length - 1];
|
|
3519
|
+
cam.push([timeline.last, cl[0], cl[1], 1, EASE.inOut], [timeline.total, c0[0], c0[1]]);
|
|
3520
|
+
const camKf = m.move(cam.map(([t, cx, cy, s, e]) => [t, vw / 2 - cx, vh / 2 - cy, s, e]));
|
|
3521
|
+
const mw = Math.min(M.w, vw * 0.4, vh * 0.4 / layout.height * layout.width);
|
|
3522
|
+
const k = mw / layout.width;
|
|
3523
|
+
const mh = layout.height * k;
|
|
3524
|
+
const title = FIGURE_TEXT[follow.lang].overview;
|
|
3525
|
+
const bw = Math.max(mw, Math.ceil(textWidth(title, TYPE.miniTitle)));
|
|
3526
|
+
const bx = vw - bw - M.inset - M.pad;
|
|
3527
|
+
const mx = bx + (bw - mw) / 2;
|
|
3528
|
+
const my = M.inset + M.pad + M.title;
|
|
3529
|
+
const shapes = [
|
|
3530
|
+
...layout.regions.map((r) => `<rect class="dg-mm-band" style="${cs(r.color)}" x="${mx + r.x * k}" y="${my + r.y * k}" width="${r.w * k}" height="${r.h * k}" rx="3"/>`),
|
|
3531
|
+
...layout.boxes.map((b) => `<rect class="dg-mm-card" style="${cs(b.color)}" x="${mx + b.x * k}" y="${my + b.y * k}" width="${b.w * k}" height="${b.h * k}" rx="1.5"/>`)
|
|
3532
|
+
].join("");
|
|
3533
|
+
const vp = m.move(cam.map(([t, cx, cy, , e]) => [t, mx + (cx - vw / 2) * k, my + (cy - vh / 2) * k, 1, e]));
|
|
3534
|
+
const mini = `<rect class="dg-mm-bg" x="${bx - M.pad}" y="${my - M.pad - M.title}" width="${bw + M.pad * 2}" height="${mh + M.pad * 2 + M.title}" rx="${M.radius}"/><text class="dg-mm-t" x="${bx}" y="${my - M.pad + 2}">${title}</text><g clip-path="url(#dg-mm-${id})"><rect class="dg-mm-world" x="${mx}" y="${my}" width="${mw}" height="${mh}"/>${shapes}<rect class="dg-mm-vp dg-a" width="${vw * k}" height="${vh * k}" rx="2" style="${vp}"/></g>`;
|
|
3535
|
+
const body = `<defs><clipPath id="dg-vp-${id}"><rect width="${vw}" height="${vh}" rx="${LOOK.region.radius}"/></clipPath><clipPath id="dg-mm-${id}"><rect x="${mx}" y="${my}" width="${mw}" height="${mh}" rx="4"/></clipPath></defs><g clip-path="url(#dg-vp-${id})"><rect class="dg-vp-bg" width="${vw}" height="${vh}"/><g class="dg-a" style="${camKf}">${content}</g></g><rect class="dg-vp-frame" x="0.5" y="0.5" width="${vw - 1}" height="${vh - 1}" rx="${LOOK.region.radius}"/>${mini}`;
|
|
3536
|
+
return { body, w: vw, h: vh };
|
|
3537
|
+
}
|
|
3538
|
+
function renderDiagram(input, options = {}) {
|
|
3539
|
+
const lang = options.lang ?? "ja";
|
|
3540
|
+
const read = readDiagram(input, { lang });
|
|
3541
|
+
if (!read.ok) throw new Error(FIGURE_TEXT[lang].cannotDraw(read.errors.map((e) => `${e.pointer} ${e.message}`).join(" / ")));
|
|
3542
|
+
const diagram = read.diagram;
|
|
3543
|
+
const palette = resolvePalette(options.palette);
|
|
3544
|
+
const theme = options.theme === "dark" ? "dark" : "light";
|
|
3545
|
+
const layout = diagram.kind === "sequence" ? layoutSequence(diagram) : layoutArchitecture(diagram);
|
|
3546
|
+
const timeline = buildTimeline(diagram);
|
|
3547
|
+
return {
|
|
3548
|
+
svg: drawSvg(diagram, layout, timeline, palette, theme),
|
|
3549
|
+
palette: palette.id,
|
|
3550
|
+
theme,
|
|
3551
|
+
...diagram.view ? { view: diagram.view } : {},
|
|
3552
|
+
fonts: { ...FONTS },
|
|
3553
|
+
layout,
|
|
3554
|
+
timeline,
|
|
3555
|
+
diagram
|
|
3556
|
+
};
|
|
3557
|
+
}
|
|
3558
|
+
|
|
3559
|
+
// src/view.ts
|
|
3560
|
+
function chooseView(rendered, frameWidth) {
|
|
3561
|
+
const textPx = Math.max(0, frameWidth) / rendered.layout.width * TYPE.boxName.size;
|
|
3562
|
+
if (rendered.view) return { mode: rendered.view, textPx };
|
|
3563
|
+
return { mode: textPx >= READABLE_PX ? "fixed" : "follow", textPx };
|
|
3564
|
+
}
|
|
3565
|
+
|
|
3566
|
+
// src/player.ts
|
|
3567
|
+
var BUTTON_TEXT = { prev: "\u2039", pause: "\u275A\u275A", play: "\u25B6", next: "\u203A" };
|
|
3568
|
+
var pad = (n) => String(n).padStart(2, "0");
|
|
3569
|
+
var stepNo = (step, count) => `${pad(step + 1)}/${pad(count)}`;
|
|
3570
|
+
var require_ = createRequire(import.meta.url);
|
|
3571
|
+
var SCRIPTS = {
|
|
3572
|
+
"/mediabunny.js": join(dirname(require_.resolve("mediabunny")), "mediabunny.min.mjs"),
|
|
3573
|
+
"/gifenc.js": require_.resolve("gifenc/dist/gifenc.esm.js")
|
|
3574
|
+
};
|
|
3575
|
+
var SCALE = 2;
|
|
3576
|
+
var INSTALL_ADD = "`pnpm add -D playwright-core`";
|
|
3577
|
+
var INSTALL_CHROMIUM = "`pnpm exec playwright-core install chromium`";
|
|
3578
|
+
var LAUNCH_TEXT = {
|
|
3579
|
+
ja: {
|
|
3580
|
+
missing: "\u66F8\u304D\u51FA\u3057\u306B\u306F playwright-core \u304C\u8981\u308B\u3002",
|
|
3581
|
+
cannotLaunch: "Chromium \u3092\u8D77\u52D5\u3067\u304D\u306A\u3044\u3002",
|
|
3582
|
+
install: `${INSTALL_ADD} \u3067\u5165\u308C\u3001${INSTALL_CHROMIUM} \u3067 Chromium \u3092\u5165\u308C\u308B`
|
|
3583
|
+
},
|
|
3584
|
+
en: {
|
|
3585
|
+
missing: "Exporting needs playwright-core. ",
|
|
3586
|
+
cannotLaunch: "Cannot launch Chromium. ",
|
|
3587
|
+
install: `Install playwright-core with ${INSTALL_ADD} and Chromium with ${INSTALL_CHROMIUM}`
|
|
3588
|
+
}
|
|
3589
|
+
};
|
|
3590
|
+
async function launch(lang) {
|
|
3591
|
+
const text2 = LAUNCH_TEXT[lang];
|
|
3592
|
+
let chromium;
|
|
3593
|
+
try {
|
|
3594
|
+
({ chromium } = await import('playwright-core'));
|
|
3595
|
+
} catch {
|
|
3596
|
+
throw new Error(`${text2.missing}${text2.install}`);
|
|
3597
|
+
}
|
|
3598
|
+
try {
|
|
3599
|
+
return await chromium.launch();
|
|
3600
|
+
} catch (error) {
|
|
3601
|
+
throw new Error(`${text2.cannotLaunch}${text2.install} (${String(error).split("\n")[0]})`);
|
|
3602
|
+
}
|
|
3603
|
+
}
|
|
3604
|
+
function sizeOf(svg) {
|
|
3605
|
+
const [, width = "0", height = "0"] = /^<svg\b[^>]*?\swidth="(\d+)"\s+height="(\d+)"/.exec(svg) ?? [];
|
|
3606
|
+
return { width: Number(width), height: Number(height) };
|
|
3607
|
+
}
|
|
3608
|
+
async function stage(browser, svg, fontCss, body) {
|
|
3609
|
+
const { width, height } = sizeOf(svg);
|
|
3610
|
+
const page = await browser.newPage({ viewport: { width, height }, deviceScaleFactor: SCALE });
|
|
3611
|
+
const paused = svg.replace(/^<svg\b/, '<svg style="--play:paused;--at:0"');
|
|
3612
|
+
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>`;
|
|
3613
|
+
await page.route("http://localhost/**", async (route) => {
|
|
3614
|
+
const path = new URL(route.request().url()).pathname;
|
|
3615
|
+
if (path === "/") return route.fulfill({ contentType: "text/html; charset=utf-8", body: html });
|
|
3616
|
+
const script = SCRIPTS[path];
|
|
3617
|
+
return script ? route.fulfill({ contentType: "text/javascript", body: readFileSync(script) }) : route.fulfill({ status: 404 });
|
|
3618
|
+
});
|
|
3619
|
+
await page.goto("http://localhost/");
|
|
3620
|
+
await page.waitForFunction(() => "__tools" in window);
|
|
3621
|
+
await page.evaluate(async () => {
|
|
3622
|
+
const loads = [];
|
|
3623
|
+
document.fonts.forEach((face) => loads.push(face.load()));
|
|
3624
|
+
await Promise.all(loads);
|
|
3625
|
+
await document.fonts.ready;
|
|
3626
|
+
});
|
|
3627
|
+
return { page, width, height };
|
|
3628
|
+
}
|
|
3629
|
+
async function at(page, t) {
|
|
3630
|
+
await page.evaluate(
|
|
3631
|
+
(t2) => new Promise((done) => {
|
|
3632
|
+
document.querySelector("svg")?.style.setProperty("--at", String(t2));
|
|
3633
|
+
requestAnimationFrame(() => requestAnimationFrame(() => done()));
|
|
3634
|
+
}),
|
|
3635
|
+
t
|
|
3636
|
+
);
|
|
3637
|
+
}
|
|
3638
|
+
async function still(stage2, t) {
|
|
3639
|
+
await at(stage2.page, t);
|
|
3640
|
+
return stage2.page.screenshot({ type: "png", omitBackground: true });
|
|
3641
|
+
}
|
|
3642
|
+
async function film(stage2, plan2) {
|
|
3643
|
+
const { page, width, height } = stage2;
|
|
3644
|
+
await page.evaluate(
|
|
3645
|
+
async ({ width: width2, height: height2, scale, fps, mp4, gifEvery }) => {
|
|
3646
|
+
const { mb, gif } = window.__tools;
|
|
3647
|
+
let add = () => Promise.resolve();
|
|
3648
|
+
let close = () => Promise.resolve(void 0);
|
|
3649
|
+
if (mp4) {
|
|
3650
|
+
const canvas = new OffscreenCanvas(width2 * scale, height2 * scale);
|
|
3651
|
+
const context = canvas.getContext("2d");
|
|
3652
|
+
const target = new mb.BufferTarget();
|
|
3653
|
+
const output = new mb.Output({ format: new mb.Mp4OutputFormat({ fastStart: "in-memory" }), target });
|
|
3654
|
+
const source = new mb.CanvasSource(canvas, { codec: "avc", bitrate: mb.QUALITY_MEDIUM, keyFrameInterval: 2 });
|
|
3655
|
+
output.addVideoTrack(source, { frameRate: fps });
|
|
3656
|
+
await output.start();
|
|
3657
|
+
add = async (bitmap, i) => {
|
|
3658
|
+
context.drawImage(bitmap, 0, 0);
|
|
3659
|
+
await source.add(i / fps, 1 / fps);
|
|
3660
|
+
};
|
|
3661
|
+
close = async () => {
|
|
3662
|
+
await output.finalize();
|
|
3663
|
+
return new Uint8Array(target.buffer);
|
|
3664
|
+
};
|
|
3665
|
+
}
|
|
3666
|
+
const small = new OffscreenCanvas(width2, height2);
|
|
3667
|
+
const smallContext = small.getContext("2d", { willReadFrequently: true });
|
|
3668
|
+
const decode = (png) => createImageBitmap(new Blob([Uint8Array.from(atob(png), (c) => c.charCodeAt(0))], { type: "image/png" }));
|
|
3669
|
+
const read = (bitmap) => {
|
|
3670
|
+
smallContext.drawImage(bitmap, 0, 0, width2, height2);
|
|
3671
|
+
return smallContext.getImageData(0, 0, width2, height2).data;
|
|
3672
|
+
};
|
|
3673
|
+
const encoder = gifEvery ? gif.GIFEncoder() : void 0;
|
|
3674
|
+
const delay = gifEvery / fps * 1e3;
|
|
3675
|
+
const sampled = [];
|
|
3676
|
+
let colors = [];
|
|
3677
|
+
const nearest = /* @__PURE__ */ new Map();
|
|
3678
|
+
const toIndex = (data) => {
|
|
3679
|
+
const index = new Uint8Array(data.length / 4);
|
|
3680
|
+
for (let p = 0; p < index.length; p++) {
|
|
3681
|
+
const i = p * 4;
|
|
3682
|
+
const key = data[i] << 16 | data[i + 1] << 8 | data[i + 2];
|
|
3683
|
+
let k = nearest.get(key);
|
|
3684
|
+
if (k === void 0) {
|
|
3685
|
+
k = gif.nearestColorIndex(colors, [data[i], data[i + 1], data[i + 2]]);
|
|
3686
|
+
nearest.set(key, k);
|
|
3687
|
+
}
|
|
3688
|
+
index[p] = k;
|
|
3689
|
+
}
|
|
3690
|
+
return index;
|
|
3691
|
+
};
|
|
3692
|
+
let previous;
|
|
3693
|
+
const writeGif = (data) => {
|
|
3694
|
+
const clear = colors.length;
|
|
3695
|
+
const index = toIndex(data);
|
|
3696
|
+
const before = previous;
|
|
3697
|
+
previous = data;
|
|
3698
|
+
if (!before) {
|
|
3699
|
+
encoder.writeFrame(index, width2, height2, { palette: [...colors, [0, 0, 0]], delay, dispose: 1 });
|
|
3700
|
+
return;
|
|
3701
|
+
}
|
|
3702
|
+
let changed = 0;
|
|
3703
|
+
for (let p = 0; p < index.length; p++) {
|
|
3704
|
+
const i = p * 4;
|
|
3705
|
+
if (data[i] === before[i] && data[i + 1] === before[i + 1] && data[i + 2] === before[i + 2]) index[p] = clear;
|
|
3706
|
+
else changed++;
|
|
3707
|
+
}
|
|
3708
|
+
if (!changed) encoder.writeFrame(new Uint8Array([clear]), 1, 1, { transparent: true, transparentIndex: clear, delay, dispose: 1 });
|
|
3709
|
+
else encoder.writeFrame(index, width2, height2, { transparent: true, transparentIndex: clear, delay, dispose: 1 });
|
|
3710
|
+
};
|
|
3711
|
+
const base64 = (bytes) => {
|
|
3712
|
+
let text2 = "";
|
|
3713
|
+
for (let i = 0; i < bytes.length; i += 32768) text2 += String.fromCharCode(...bytes.subarray(i, i + 32768));
|
|
3714
|
+
return btoa(text2);
|
|
3715
|
+
};
|
|
3716
|
+
const box = {
|
|
3717
|
+
async sample(png) {
|
|
3718
|
+
const bitmap = await decode(png);
|
|
3719
|
+
sampled.push(read(bitmap));
|
|
3720
|
+
bitmap.close();
|
|
3721
|
+
},
|
|
3722
|
+
seal() {
|
|
3723
|
+
const all = new Uint8ClampedArray(sampled.reduce((n, data) => n + data.length, 0));
|
|
3724
|
+
let offset = 0;
|
|
3725
|
+
for (const data of sampled) {
|
|
3726
|
+
all.set(data, offset);
|
|
3727
|
+
offset += data.length;
|
|
3728
|
+
}
|
|
3729
|
+
colors = gif.quantize(all, 255);
|
|
3730
|
+
},
|
|
3731
|
+
async push(png, i) {
|
|
3732
|
+
const bitmap = await decode(png);
|
|
3733
|
+
await add(bitmap, i);
|
|
3734
|
+
if (gifEvery && i % gifEvery === 0) writeGif(read(bitmap));
|
|
3735
|
+
bitmap.close();
|
|
3736
|
+
},
|
|
3737
|
+
async finish() {
|
|
3738
|
+
const video = await close();
|
|
3739
|
+
if (encoder) encoder.finish();
|
|
3740
|
+
return { ...video ? { mp4: base64(video) } : {}, ...encoder ? { gif: base64(encoder.bytes()) } : {} };
|
|
3741
|
+
}
|
|
3742
|
+
};
|
|
3743
|
+
window.__film = box;
|
|
3744
|
+
},
|
|
3745
|
+
{ width, height, scale: SCALE, fps: plan2.fps, mp4: plan2.mp4, gifEvery: plan2.gifEvery }
|
|
3746
|
+
);
|
|
3747
|
+
const cdp = await page.context().newCDPSession(page);
|
|
3748
|
+
const clip = { x: 0, y: 0, width, height, scale: SCALE };
|
|
3749
|
+
const shoot = async (t) => {
|
|
3750
|
+
await at(page, t);
|
|
3751
|
+
return (await cdp.send("Page.captureScreenshot", { format: "png", optimizeForSpeed: true, clip })).data;
|
|
3752
|
+
};
|
|
3753
|
+
if (plan2.gifEvery) {
|
|
3754
|
+
for (const t of plan2.samples) {
|
|
3755
|
+
const png = await shoot(t);
|
|
3756
|
+
await page.evaluate((png2) => window.__film.sample(png2), png);
|
|
3757
|
+
}
|
|
3758
|
+
await page.evaluate(() => window.__film.seal());
|
|
3759
|
+
}
|
|
3760
|
+
const frames = Math.round(plan2.total * plan2.fps);
|
|
3761
|
+
for (let i = 0; i < frames; i++) {
|
|
3762
|
+
const png = await shoot(i / plan2.fps);
|
|
3763
|
+
await page.evaluate(([png2, i2]) => window.__film.push(png2, i2), [png, i]);
|
|
3764
|
+
}
|
|
3765
|
+
const out = await page.evaluate(() => window.__film.finish());
|
|
3766
|
+
return {
|
|
3767
|
+
frames,
|
|
3768
|
+
...out.mp4 ? { mp4: Buffer.from(out.mp4, "base64") } : {},
|
|
3769
|
+
...out.gif ? { gif: Buffer.from(out.gif, "base64") } : {}
|
|
3770
|
+
};
|
|
3771
|
+
}
|
|
3772
|
+
var require_2 = createRequire(import.meta.url);
|
|
3773
|
+
var subsetFont = require_2("subset-font");
|
|
3774
|
+
var PACKAGES = [
|
|
3775
|
+
{ family: FONTS.sans, name: "noto-sans-jp" },
|
|
3776
|
+
{ family: FONTS.mono, name: "jetbrains-mono" }
|
|
3777
|
+
];
|
|
3778
|
+
var weights = Object.values(TYPE).map((style) => style.weight);
|
|
3779
|
+
var WEIGHT = { min: Math.min(...weights), max: Math.max(...weights) };
|
|
3780
|
+
function ranges(list) {
|
|
3781
|
+
return list.split(",").map((part) => {
|
|
3782
|
+
const [from = "", to = from] = part.trim().replace(/^U\+/i, "").split("-");
|
|
3783
|
+
return [parseInt(from, 16), parseInt(to, 16)];
|
|
3784
|
+
});
|
|
3785
|
+
}
|
|
3786
|
+
var hex = (code) => `U+${code.toString(16).toUpperCase()}`;
|
|
3787
|
+
function charsOf(texts) {
|
|
3788
|
+
return [.../* @__PURE__ */ new Set([...texts.join("")])].filter((char) => char !== "\n" && char !== "\r" && char !== " ").sort();
|
|
3789
|
+
}
|
|
3790
|
+
async function fontFaces(chars) {
|
|
3791
|
+
const faces = await Promise.all(
|
|
3792
|
+
PACKAGES.flatMap(({ family, name }) => {
|
|
3793
|
+
const base = dirname(require_2.resolve(`@fontsource-variable/${name}/unicode.json`));
|
|
3794
|
+
const table = JSON.parse(readFileSync(join(base, "unicode.json"), "utf8"));
|
|
3795
|
+
return Object.entries(table).map(async ([key, list]) => {
|
|
3796
|
+
const span = ranges(list);
|
|
3797
|
+
const own = chars.filter((char) => {
|
|
3798
|
+
const code = char.codePointAt(0) ?? -1;
|
|
3799
|
+
return span.some(([from, to]) => code >= from && code <= to);
|
|
3800
|
+
});
|
|
3801
|
+
if (!own.length) return "";
|
|
3802
|
+
const file = join(base, "files", `${name}-${key.replace(/[[\]]/g, "")}-wght-normal.woff2`);
|
|
3803
|
+
const woff2 = await subsetFont(await readFile(file), own.join(""), { targetFormat: "woff2", variationAxes: { wght: WEIGHT } });
|
|
3804
|
+
const unicode = own.map((char) => hex(char.codePointAt(0) ?? 0)).join(",");
|
|
3805
|
+
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}}`;
|
|
3806
|
+
});
|
|
3807
|
+
})
|
|
3808
|
+
);
|
|
3809
|
+
return faces.join("");
|
|
3810
|
+
}
|
|
3811
|
+
var PLAYER = new URL("./player.global.js", import.meta.url);
|
|
3812
|
+
function pageHtml(diagram, look, fontCss) {
|
|
3813
|
+
const json = JSON.stringify(diagram).replace(/</g, "\\u003c");
|
|
3814
|
+
const options = JSON.stringify({ palette: look.palette, theme: look.theme, lang: look.lang });
|
|
3815
|
+
return [
|
|
3816
|
+
"<!doctype html>",
|
|
3817
|
+
`<html lang="${look.lang}"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">`,
|
|
3818
|
+
`<title>${esc(diagram.title)}</title>`,
|
|
3819
|
+
`<style>${fontCss}:root{${look.vars}}html,body{margin:0}body{background:var(--bg)}</style>`,
|
|
3820
|
+
'</head><body><div id="dragon"></div>',
|
|
3821
|
+
`<script type="application/json" id="dragon-diagram">${json}</script>`,
|
|
3822
|
+
`<script>${readFileSync(PLAYER, "utf8").replace(/<\/script/gi, "<\\/script")}</script>`,
|
|
3823
|
+
`<script>DragonPlayer.mountDiagram(document.getElementById("dragon"),JSON.parse(document.getElementById("dragon-diagram").textContent),${options});</script>`,
|
|
3824
|
+
"</body></html>"
|
|
3825
|
+
].join("\n");
|
|
3826
|
+
}
|
|
3827
|
+
|
|
3828
|
+
// src/export/index.ts
|
|
3829
|
+
var FORMATS = ["mp4", "gif", "html", "png"];
|
|
3830
|
+
var DEFAULTS = { fps: 30, gifFps: 10, followWidth: 728 };
|
|
3831
|
+
var unescape = (s) => s.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/&/g, "&");
|
|
3832
|
+
var svgTexts = (svg) => [...svg.matchAll(/<text\b[^>]*>([\s\S]*?)<\/text>/g)].map((m) => unescape((m[1] ?? "").replace(/<[^>]+>/g, "")));
|
|
3833
|
+
function drawnTexts(rendered, followSvg) {
|
|
3834
|
+
const { diagram } = rendered;
|
|
3835
|
+
const svgs = followSvg === void 0 ? [rendered.svg] : [rendered.svg, followSvg];
|
|
3836
|
+
const count = diagram.steps.length;
|
|
3837
|
+
return [...svgs.flatMap(svgTexts), ...diagram.steps.flatMap((step, s) => [step.title, step.body, stepNo(s, count)]), ...Object.values(BUTTON_TEXT)];
|
|
3838
|
+
}
|
|
3839
|
+
async function exportDiagram(input, options) {
|
|
3840
|
+
const formats = options.formats ?? FORMATS;
|
|
3841
|
+
const lang = options.lang ?? "ja";
|
|
3842
|
+
const rendered = renderDiagram(input, {
|
|
3843
|
+
...options.palette ? { palette: options.palette } : {},
|
|
3844
|
+
...options.theme ? { theme: options.theme } : {},
|
|
3845
|
+
lang
|
|
3846
|
+
});
|
|
3847
|
+
const { diagram, layout, timeline, theme } = rendered;
|
|
3848
|
+
const palette = resolvePalette(rendered.palette);
|
|
3849
|
+
const vars = paletteVars(palette, theme);
|
|
3850
|
+
const width = options.width ?? (rendered.view === "follow" ? DEFAULTS.followWidth : layout.width);
|
|
3851
|
+
const view = chooseView(rendered, width).mode;
|
|
3852
|
+
const followSvg = rendered.view === "fixed" ? void 0 : drawSvg(diagram, layout, timeline, palette, theme, { width, lang });
|
|
3853
|
+
const videoSvg = view === "follow" && followSvg ? followSvg : rendered.svg;
|
|
3854
|
+
const fontCss = await fontFaces(charsOf(drawnTexts(rendered, followSvg)));
|
|
3855
|
+
const outputs = [];
|
|
3856
|
+
if (formats.includes("html")) outputs.push(["html", pageHtml(diagram, { palette: palette.id, theme, vars, lang }, fontCss)]);
|
|
3857
|
+
let frames = 0;
|
|
3858
|
+
const mp4 = formats.includes("mp4");
|
|
3859
|
+
const gif = formats.includes("gif");
|
|
3860
|
+
if (mp4 || gif || formats.includes("png")) {
|
|
3861
|
+
const browser = await launch(lang);
|
|
3862
|
+
try {
|
|
3863
|
+
if (formats.includes("png")) {
|
|
3864
|
+
const fixed = await stage(browser, rendered.svg, fontCss, "");
|
|
3865
|
+
outputs.push(["png", await still(fixed, timeline.stills[timeline.stills.length - 1] ?? 0)]);
|
|
3866
|
+
}
|
|
3867
|
+
if (mp4 || gif) {
|
|
3868
|
+
const fps = mp4 ? options.fps ?? DEFAULTS.fps : options.gifFps ?? DEFAULTS.gifFps;
|
|
3869
|
+
const gifEvery = gif ? Math.max(1, Math.round(fps / (options.gifFps ?? DEFAULTS.gifFps))) : 0;
|
|
3870
|
+
const shot = await film(await stage(browser, videoSvg, fontCss, `${vars};background:var(--bg)`), {
|
|
3871
|
+
total: timeline.total,
|
|
3872
|
+
fps,
|
|
3873
|
+
mp4,
|
|
3874
|
+
gifEvery,
|
|
3875
|
+
// GIF の色の表は、最初の絵と段ごとの止め絵から作る
|
|
3876
|
+
samples: [0, ...timeline.stills]
|
|
3877
|
+
});
|
|
3878
|
+
frames = shot.frames;
|
|
3879
|
+
if (shot.mp4) outputs.push(["mp4", shot.mp4]);
|
|
3880
|
+
if (shot.gif) outputs.push(["gif", shot.gif]);
|
|
3881
|
+
}
|
|
3882
|
+
} finally {
|
|
3883
|
+
await browser.close();
|
|
3884
|
+
}
|
|
3885
|
+
}
|
|
3886
|
+
const files = writeOutputs(options.outDir, options.name ?? "diagram", outputs);
|
|
3887
|
+
return { files, view, frames, ...sizeOf(videoSvg) };
|
|
3888
|
+
}
|
|
3889
|
+
function writeOutputs(outDir, name, outputs) {
|
|
3890
|
+
const created = mkdirSync(outDir, { recursive: true });
|
|
3891
|
+
const files = {};
|
|
3892
|
+
try {
|
|
3893
|
+
for (const [format, data] of outputs) {
|
|
3894
|
+
const path = join(outDir, `${name}.${format}`);
|
|
3895
|
+
writeFileSync(path, data);
|
|
3896
|
+
files[format] = path;
|
|
3897
|
+
}
|
|
3898
|
+
} catch (error) {
|
|
3899
|
+
if (created !== void 0) rmSync(created, { recursive: true, force: true });
|
|
3900
|
+
throw error;
|
|
3901
|
+
}
|
|
3902
|
+
return files;
|
|
3903
|
+
}
|
|
3904
|
+
|
|
3905
|
+
export { FORMATS, exportDiagram };
|
|
3906
|
+
//# sourceMappingURL=export.js.map
|
|
3907
|
+
//# sourceMappingURL=export.js.map
|