@p10node/plantuml 0.13.0 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +207 -203
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -127,17 +127,17 @@ function e(e, t, n, r) {
|
|
|
127
127
|
}
|
|
128
128
|
for (let e = 0; e < L; e++) (w[e] === 2 || w[e] === 3) && R[E[e]].push(e);
|
|
129
129
|
}
|
|
130
|
-
let z = new Float64Array(L),
|
|
131
|
-
|
|
132
|
-
let
|
|
130
|
+
let z = new Float64Array(L), ae = () => R.forEach((e) => e.forEach((e, t) => z[e] = t));
|
|
131
|
+
ae();
|
|
132
|
+
let B = new Float64Array(L), V = new Float64Array(a), H = () => {
|
|
133
133
|
for (let e = 0; e < a; e++) {
|
|
134
134
|
if (P[e] > F[e]) continue;
|
|
135
135
|
let t = 0;
|
|
136
136
|
for (let n = P[e]; n <= F[e]; n++) t += z[I[e][n]] / Math.max(1, R[n].length);
|
|
137
|
-
|
|
137
|
+
V[e] = t / (F[e] - P[e] + 1);
|
|
138
138
|
}
|
|
139
|
-
},
|
|
140
|
-
if (!a) return [...e].sort((e, t) =>
|
|
139
|
+
}, oe = (e, t) => {
|
|
140
|
+
if (!a) return [...e].sort((e, t) => B[e] - B[t] || z[e] - z[t]);
|
|
141
141
|
let r = {
|
|
142
142
|
node: -1,
|
|
143
143
|
cluster: -1,
|
|
@@ -158,7 +158,7 @@ function e(e, t, n, r) {
|
|
|
158
158
|
for (let t of e) w[t] === 2 ? o(O[t]) : w[t] !== 3 && o(T[t]).items.push({
|
|
159
159
|
node: t,
|
|
160
160
|
cluster: -1,
|
|
161
|
-
key:
|
|
161
|
+
key: B[t],
|
|
162
162
|
idx: z[t],
|
|
163
163
|
items: []
|
|
164
164
|
});
|
|
@@ -169,8 +169,8 @@ function e(e, t, n, r) {
|
|
|
169
169
|
let [e, i] = s(t);
|
|
170
170
|
n += e, r += i;
|
|
171
171
|
}
|
|
172
|
-
e.cluster >= 0 && (e.key = r ? n / r :
|
|
173
|
-
let i = e.items.map((e, t) => e.cluster >= 0 ? t : -1).filter((e) => e >= 0), a = i.map((t) => e.items[t]).sort((e, t) =>
|
|
172
|
+
e.cluster >= 0 && (e.key = r ? n / r : B[I[e.cluster][t]]), e.items.sort((e, t) => e.key - t.key || e.idx - t.idx);
|
|
173
|
+
let i = e.items.map((e, t) => e.cluster >= 0 ? t : -1).filter((e) => e >= 0), a = i.map((t) => e.items[t]).sort((e, t) => V[e.cluster] - V[t.cluster]);
|
|
174
174
|
return i.forEach((t, n) => e.items[t] = a[n]), [n, r];
|
|
175
175
|
};
|
|
176
176
|
s(r);
|
|
@@ -178,7 +178,7 @@ function e(e, t, n, r) {
|
|
|
178
178
|
for (let n of e.items) n.node >= 0 ? c.push(n.node) : (c.push(I[n.cluster][t]), l(n), c.push(re[n.cluster][t]));
|
|
179
179
|
};
|
|
180
180
|
return l(r), c;
|
|
181
|
-
},
|
|
181
|
+
}, U = (e) => {
|
|
182
182
|
let t = 0;
|
|
183
183
|
for (let n = 0; n + 1 < e.length; n++) {
|
|
184
184
|
let r = [];
|
|
@@ -198,35 +198,35 @@ function e(e, t, n, r) {
|
|
|
198
198
|
for (let [i, a] of t[e]) n += z[i] * a, r += a;
|
|
199
199
|
return r ? n / r : z[e];
|
|
200
200
|
};
|
|
201
|
-
for (let e of R) for (let t of e)
|
|
202
|
-
|
|
203
|
-
let ce = R.map((e) => [...e]), le =
|
|
201
|
+
for (let e of R) for (let t of e) B[t] = z[t];
|
|
202
|
+
H(), R = R.map((e, t) => oe(e, t)), ae();
|
|
203
|
+
let ce = R.map((e) => [...e]), le = U(R);
|
|
204
204
|
for (let e = 0; e < 24 && le > 0; e++) {
|
|
205
|
-
|
|
205
|
+
H();
|
|
206
206
|
let t = e % 2 == 0;
|
|
207
207
|
for (let e = 1; e <= y; e++) {
|
|
208
208
|
let n = t ? e : y - e, r = t ? A : j;
|
|
209
|
-
for (let e of R[n])
|
|
210
|
-
R[n] =
|
|
209
|
+
for (let e of R[n]) B[e] = se(e, r);
|
|
210
|
+
R[n] = oe(R[n], n), R[n].forEach((e, t) => z[e] = t);
|
|
211
211
|
}
|
|
212
|
-
let n =
|
|
212
|
+
let n = U(R);
|
|
213
213
|
n < le && (le = n, ce = R.map((e) => [...e]));
|
|
214
214
|
}
|
|
215
|
-
R = ce,
|
|
216
|
-
let
|
|
217
|
-
n.forEach((e, t) => e.parent >= 0 &&
|
|
218
|
-
let
|
|
219
|
-
for (let e = 0; e < a; e++) P[e] > F[e] || (
|
|
220
|
-
let
|
|
221
|
-
for (let e = 0; e <= y; e++)
|
|
222
|
-
let
|
|
215
|
+
R = ce, ae();
|
|
216
|
+
let ue = R.map((e) => e.reduce((e, t) => Math.max(e, C[t]), 0)), W = Array.from({ length: a }, () => []);
|
|
217
|
+
n.forEach((e, t) => e.parent >= 0 && W[e.parent].push(t));
|
|
218
|
+
let G = (e) => n[e].pad[2] + Math.max(0, ...W[e].filter((t) => P[t] === P[e]).map(G)), de = (e) => n[e].pad[3] + Math.max(0, ...W[e].filter((t) => F[t] === F[e]).map(de)), fe = Array(y + 1).fill(0), K = Array(y + 1).fill(0);
|
|
219
|
+
for (let e = 0; e < a; e++) P[e] > F[e] || (fe[P[e]] = Math.max(fe[P[e]], G(e)), K[F[e]] = Math.max(K[F[e]], de(e)));
|
|
220
|
+
let q = [];
|
|
221
|
+
for (let e = 0; e <= y; e++) q[e] = e === 0 ? ue[0] / 2 + fe[0] : q[e - 1] + ue[e - 1] / 2 + K[e - 1] + r.ranksep + fe[e] + ue[e] / 2;
|
|
222
|
+
let pe = q[y] + ue[y] / 2 + K[y], me = (e) => w[e] === 2 || w[e] === 3 ? 0 : S[e] / 2, he = (e, t) => {
|
|
223
223
|
let i = D[e], a = w[e], o = w[t];
|
|
224
|
-
return a === 2 && (i += n[O[e]].pad[0]), a === 3 && (i += r.nodesep / 2), o === 3 && (i += n[O[t]].pad[1]), o === 2 && (i += r.nodesep / 2), a < 2 && o < 2 && (i += a === 1 && o === 1 ? r.edgesep : a === 1 || o === 1 ? (r.nodesep + r.edgesep) / 2 : r.nodesep),
|
|
225
|
-
},
|
|
226
|
-
for (let e of R) for (let t = 1; t < e.length; t++)
|
|
227
|
-
let
|
|
224
|
+
return a === 2 && (i += n[O[e]].pad[0]), a === 3 && (i += r.nodesep / 2), o === 3 && (i += n[O[t]].pad[1]), o === 2 && (i += r.nodesep / 2), a < 2 && o < 2 && (i += a === 1 && o === 1 ? r.edgesep : a === 1 || o === 1 ? (r.nodesep + r.edgesep) / 2 : r.nodesep), me(e) + me(t) + i;
|
|
225
|
+
}, J = new Float64Array(L);
|
|
226
|
+
for (let e of R) for (let t = 1; t < e.length; t++) J[e[t]] = J[e[t - 1]] + he(e[t - 1], e[t]);
|
|
227
|
+
let ge = (e, t, n) => {
|
|
228
228
|
let r = e.length, i = [0];
|
|
229
|
-
for (let t = 1; t < r; t++) i[t] = i[t - 1] +
|
|
229
|
+
for (let t = 1; t < r; t++) i[t] = i[t - 1] + he(e[t - 1], e[t]);
|
|
230
230
|
let a = [];
|
|
231
231
|
for (let e = 0; e < r; e++) for (a.push({
|
|
232
232
|
s: e,
|
|
@@ -238,7 +238,7 @@ function e(e, t, n, r) {
|
|
|
238
238
|
if (e.wt / e.w < t.wt / t.w) break;
|
|
239
239
|
e.e = t.e, e.w += t.w, e.wt += t.wt, a.pop();
|
|
240
240
|
}
|
|
241
|
-
for (let t of a) for (let n = t.s; n <= t.e; n++)
|
|
241
|
+
for (let t of a) for (let n = t.s; n <= t.e; n++) J[e[n]] = t.wt / t.w + i[n];
|
|
242
242
|
};
|
|
243
243
|
for (let e = 0; e < 10; e++) {
|
|
244
244
|
let t = e >= 8, n = e % 2 == 0;
|
|
@@ -248,24 +248,24 @@ function e(e, t, n, r) {
|
|
|
248
248
|
let a = [], o = [];
|
|
249
249
|
for (let e of i) {
|
|
250
250
|
let r = 0, i = 0, s = (e) => {
|
|
251
|
-
for (let [t, n] of e) r +=
|
|
251
|
+
for (let [t, n] of e) r += J[t] * n, i += n;
|
|
252
252
|
};
|
|
253
|
-
(t || n) && s(A[e]), (t || !n) && s(j[e]), s(ie[e]), a.push(i ? r / i :
|
|
253
|
+
(t || n) && s(A[e]), (t || !n) && s(j[e]), s(ie[e]), a.push(i ? r / i : J[e]), o.push(i || .01);
|
|
254
254
|
}
|
|
255
|
-
|
|
255
|
+
ge(i, a, o);
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
|
-
let
|
|
258
|
+
let _e = L, Y = (e) => w[e] === 2 ? _e + 2 * O[e] : w[e] === 3 ? _e + 2 * O[e] + 1 : e;
|
|
259
259
|
if (a) {
|
|
260
260
|
let e = L + 2 * a, t = new Float64Array(e);
|
|
261
|
-
for (let e = 0; e < L; e++) t[e] =
|
|
262
|
-
for (let e = 0; e < a; e++) t[
|
|
263
|
-
for (let e = 0; e < L; e++) w[e] === 2 && (t[
|
|
261
|
+
for (let e = 0; e < L; e++) t[e] = J[e];
|
|
262
|
+
for (let e = 0; e < a; e++) t[_e + 2 * e] = Infinity, t[_e + 2 * e + 1] = -Infinity;
|
|
263
|
+
for (let e = 0; e < L; e++) w[e] === 2 && (t[Y(e)] = Math.min(t[Y(e)], J[e])), w[e] === 3 && (t[Y(e)] = Math.max(t[Y(e)], J[e]));
|
|
264
264
|
let r = Array.from({ length: e }, () => []), i = new Int32Array(e), o = (e, t, n) => {
|
|
265
265
|
r[e].push([t, n]), i[t]++;
|
|
266
266
|
};
|
|
267
|
-
for (let e of R) for (let t = 1; t < e.length; t++) o(
|
|
268
|
-
for (let e = 0; e < a; e++) P[e] <= F[e] && o(
|
|
267
|
+
for (let e of R) for (let t = 1; t < e.length; t++) o(Y(e[t - 1]), Y(e[t]), he(e[t - 1], e[t]));
|
|
268
|
+
for (let e = 0; e < a; e++) P[e] <= F[e] && o(_e + 2 * e, _e + 2 * e + 1, Math.max(n[e].minW, n[e].pad[0] + n[e].pad[1]));
|
|
269
269
|
let s = [];
|
|
270
270
|
for (let t = 0; t < e; t++) i[t] || s.push(t);
|
|
271
271
|
let c = 0, l = new Float64Array(t);
|
|
@@ -274,16 +274,16 @@ function e(e, t, n, r) {
|
|
|
274
274
|
c++;
|
|
275
275
|
for (let [t, n] of r[e]) Number.isFinite(l[e]) && (l[t] = Math.max(l[t], l[e] + n)), --i[t] || s.push(t);
|
|
276
276
|
}
|
|
277
|
-
if (c === e) for (let e = 0; e < L; e++)
|
|
277
|
+
if (c === e) for (let e = 0; e < L; e++) J[e] = l[Y(e)];
|
|
278
278
|
}
|
|
279
|
-
let
|
|
280
|
-
for (let e = 0; e < L; e++)
|
|
281
|
-
Number.isFinite(
|
|
282
|
-
for (let e = 0; e < L; e++)
|
|
283
|
-
let
|
|
284
|
-
x:
|
|
285
|
-
y:
|
|
286
|
-
}),
|
|
279
|
+
let ve = Infinity, ye = -Infinity;
|
|
280
|
+
for (let e = 0; e < L; e++) ve = Math.min(ve, J[e] - me(e)), ye = Math.max(ye, J[e] + me(e) + D[e]);
|
|
281
|
+
Number.isFinite(ve) || (ve = ye = 0);
|
|
282
|
+
for (let e = 0; e < L; e++) J[e] -= ve;
|
|
283
|
+
let X = (e) => ({
|
|
284
|
+
x: J[e],
|
|
285
|
+
y: q[E[e]]
|
|
286
|
+
}), be = /* @__PURE__ */ new Map();
|
|
287
287
|
{
|
|
288
288
|
let t = /* @__PURE__ */ new Map(), n = (e, n, r) => {
|
|
289
289
|
let i = t.get(e);
|
|
@@ -294,20 +294,20 @@ function e(e, t, n, r) {
|
|
|
294
294
|
};
|
|
295
295
|
f.forEach((t, r) => {
|
|
296
296
|
let i = M[r];
|
|
297
|
-
i && !ne[r] && (e[i[0]]?.spread && n(`${i[0]}:b`, r,
|
|
297
|
+
i && !ne[r] && (e[i[0]]?.spread && n(`${i[0]}:b`, r, J[i[1]]), e[i[i.length - 1]]?.spread && n(`${i[i.length - 1]}:t`, r, J[i[i.length - 2]]));
|
|
298
298
|
});
|
|
299
299
|
for (let [e, n] of t) {
|
|
300
300
|
if (n.length < 2) continue;
|
|
301
301
|
let t = Number(e.split(":")[0]);
|
|
302
302
|
n.sort((e, t) => e.nx - t.nx || e.i - t.i);
|
|
303
303
|
let r = Math.min(36, S[t] * .7 / (n.length - 1));
|
|
304
|
-
n.forEach((i, a) =>
|
|
304
|
+
n.forEach((i, a) => be.set(`${e}:${i.i}`, J[t] + (a - (n.length - 1) / 2) * r));
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
|
-
let
|
|
307
|
+
let Z = f.map((e, n) => {
|
|
308
308
|
if (e.v === e.w) return null;
|
|
309
309
|
if (ne[n]) {
|
|
310
|
-
let r =
|
|
310
|
+
let r = X(e.v), i = X(e.w), a = Math.sign(i.x - r.x) || 1, o = {
|
|
311
311
|
x: r.x + a * S[e.v] / 2,
|
|
312
312
|
y: r.y
|
|
313
313
|
}, s = {
|
|
@@ -328,13 +328,13 @@ function e(e, t, n, r) {
|
|
|
328
328
|
}
|
|
329
329
|
let r = M[n];
|
|
330
330
|
if (!r) return null;
|
|
331
|
-
let i = [], a = [], o =
|
|
331
|
+
let i = [], a = [], o = X(r[0]);
|
|
332
332
|
i.push({
|
|
333
|
-
x:
|
|
333
|
+
x: be.get(`${r[0]}:b:${n}`) ?? o.x,
|
|
334
334
|
y: o.y + C[r[0]] / 2
|
|
335
335
|
});
|
|
336
336
|
for (let e = 1; e + 1 < r.length; e++) {
|
|
337
|
-
let t =
|
|
337
|
+
let t = X(r[e]), n = ue[E[r[e]]] / 2;
|
|
338
338
|
n > .5 ? (i.push({
|
|
339
339
|
x: t.x,
|
|
340
340
|
y: t.y - n
|
|
@@ -343,9 +343,9 @@ function e(e, t, n, r) {
|
|
|
343
343
|
y: t.y + n
|
|
344
344
|
}), a.push(!1, !0)) : (i.push(t), a.push(!1));
|
|
345
345
|
}
|
|
346
|
-
let s =
|
|
346
|
+
let s = X(r[r.length - 1]);
|
|
347
347
|
i.push({
|
|
348
|
-
x:
|
|
348
|
+
x: be.get(`${r[r.length - 1]}:t:${n}`) ?? s.x,
|
|
349
349
|
y: s.y - C[r[r.length - 1]] / 2
|
|
350
350
|
}), a.push(!1);
|
|
351
351
|
let l = i.length, u = Array(l).fill(0), d = (e) => (i[e + 1].x - i[e].x) / Math.max(.5, i[e + 1].y - i[e].y);
|
|
@@ -377,7 +377,7 @@ function e(e, t, n, r) {
|
|
|
377
377
|
]
|
|
378
378
|
});
|
|
379
379
|
}
|
|
380
|
-
let p = N[n] >= 0 ?
|
|
380
|
+
let p = N[n] >= 0 ? X(N[n]) : void 0;
|
|
381
381
|
if (!c[n]) return {
|
|
382
382
|
start: i[0],
|
|
383
383
|
segs: f,
|
|
@@ -403,11 +403,11 @@ function e(e, t, n, r) {
|
|
|
403
403
|
segs: m,
|
|
404
404
|
label: p
|
|
405
405
|
};
|
|
406
|
-
}),
|
|
406
|
+
}), Q = n.map((e, t) => {
|
|
407
407
|
if (P[t] > F[t]) return null;
|
|
408
408
|
let n = Infinity, r = -Infinity;
|
|
409
|
-
for (let e = P[t]; e <= F[t]; e++) n = Math.min(n,
|
|
410
|
-
let i =
|
|
409
|
+
for (let e = P[t]; e <= F[t]; e++) n = Math.min(n, J[I[t][e]]), r = Math.max(r, J[re[t][e]]);
|
|
410
|
+
let i = q[P[t]] - ue[P[t]] / 2 - G(t), a = q[F[t]] + ue[F[t]] / 2 + de(t);
|
|
411
411
|
return {
|
|
412
412
|
x: n,
|
|
413
413
|
y: i,
|
|
@@ -416,11 +416,11 @@ function e(e, t, n, r) {
|
|
|
416
416
|
};
|
|
417
417
|
});
|
|
418
418
|
return {
|
|
419
|
-
nodes: Array.from({ length: i }, (e, t) =>
|
|
420
|
-
edges:
|
|
421
|
-
clusters:
|
|
422
|
-
w:
|
|
423
|
-
h:
|
|
419
|
+
nodes: Array.from({ length: i }, (e, t) => X(t)),
|
|
420
|
+
edges: Z,
|
|
421
|
+
clusters: Q,
|
|
422
|
+
w: ye - ve,
|
|
423
|
+
h: pe
|
|
424
424
|
};
|
|
425
425
|
}
|
|
426
426
|
// src/core/diagram/svg.ts
|
|
@@ -1289,33 +1289,33 @@ function F(t) {
|
|
|
1289
1289
|
ranksep: (o ? 50 : 60) / (b ? 2 : 1),
|
|
1290
1290
|
edgesep: 14,
|
|
1291
1291
|
sameRank: k
|
|
1292
|
-
}), R = t.title ? 32 : 0, z = F.w,
|
|
1292
|
+
}), R = t.title ? 32 : 0, z = F.w, ae = F.h, B = (e) => {
|
|
1293
1293
|
let t = n === "TB" ? e : n === "BT" ? {
|
|
1294
1294
|
x: e.x,
|
|
1295
|
-
y:
|
|
1295
|
+
y: ae - e.y
|
|
1296
1296
|
} : n === "LR" ? {
|
|
1297
1297
|
x: e.y,
|
|
1298
1298
|
y: e.x
|
|
1299
1299
|
} : {
|
|
1300
|
-
x:
|
|
1300
|
+
x: ae - e.y,
|
|
1301
1301
|
y: e.x
|
|
1302
1302
|
};
|
|
1303
1303
|
return {
|
|
1304
1304
|
x: t.x + N,
|
|
1305
1305
|
y: t.y + N + R
|
|
1306
1306
|
};
|
|
1307
|
-
},
|
|
1307
|
+
}, V = (o ? z : ae) + 32, H = (o ? ae : z) + 32 + R, oe = (e) => {
|
|
1308
1308
|
let t = 0;
|
|
1309
1309
|
for (let n = d(e); n >= 0; n = d(n)) t++;
|
|
1310
1310
|
return t;
|
|
1311
|
-
},
|
|
1312
|
-
for (let e of
|
|
1311
|
+
}, U = t.clusters.map((e, t) => t).sort((e, t) => oe(e) - oe(t)), se = t.clusters.map(() => null), ce = [];
|
|
1312
|
+
for (let e of U) {
|
|
1313
1313
|
let r = F.clusters[e];
|
|
1314
1314
|
if (!r) continue;
|
|
1315
|
-
let a = t.clusters[e], o =
|
|
1315
|
+
let a = t.clusters[e], o = B({
|
|
1316
1316
|
x: r.x,
|
|
1317
1317
|
y: r.y
|
|
1318
|
-
}), c =
|
|
1318
|
+
}), c = B({
|
|
1319
1319
|
x: r.x + r.w,
|
|
1320
1320
|
y: r.y + r.h
|
|
1321
1321
|
}), l = Math.min(o.x, c.x), d = Math.min(o.y, c.y), f = Math.abs(c.x - o.x), p = Math.abs(c.y - o.y), m = a.style ?? {};
|
|
@@ -1350,7 +1350,7 @@ function F(t) {
|
|
|
1350
1350
|
}, c = F.edges[n];
|
|
1351
1351
|
if (!c) {
|
|
1352
1352
|
if (v[n].v !== v[n].w) return;
|
|
1353
|
-
let c =
|
|
1353
|
+
let c = B(F.nodes[t]), l = _[t], u, d, f, p, h;
|
|
1354
1354
|
o ? (u = {
|
|
1355
1355
|
x: c.x + l.w / 2,
|
|
1356
1356
|
y: c.y - l.h / 4
|
|
@@ -1412,12 +1412,12 @@ function F(t) {
|
|
|
1412
1412
|
return;
|
|
1413
1413
|
}
|
|
1414
1414
|
let l = {
|
|
1415
|
-
start:
|
|
1415
|
+
start: B(c.start),
|
|
1416
1416
|
segs: c.segs.map((e) => ({
|
|
1417
1417
|
c: e.c,
|
|
1418
|
-
p: e.p.map(
|
|
1418
|
+
p: e.p.map(B)
|
|
1419
1419
|
})),
|
|
1420
|
-
label: c.label &&
|
|
1420
|
+
label: c.label && B(c.label)
|
|
1421
1421
|
}, { cv: u, cw: d } = v[n];
|
|
1422
1422
|
if (u >= 0 && !f(v[n].w, u) || d >= 0 && !f(v[n].v, d)) {
|
|
1423
1423
|
let e = ie(l.start, l.segs);
|
|
@@ -1481,7 +1481,7 @@ function F(t) {
|
|
|
1481
1481
|
}
|
|
1482
1482
|
t.nodes.forEach((e, t) => {
|
|
1483
1483
|
if (e.style?.hidden) return;
|
|
1484
|
-
let n =
|
|
1484
|
+
let n = B(F.nodes[t]);
|
|
1485
1485
|
O(s, e, _[t], n.x, n.y);
|
|
1486
1486
|
});
|
|
1487
1487
|
for (let e of le) {
|
|
@@ -1495,14 +1495,14 @@ function F(t) {
|
|
|
1495
1495
|
color: e.color ?? u.ink
|
|
1496
1496
|
});
|
|
1497
1497
|
}
|
|
1498
|
-
return t.title && (
|
|
1498
|
+
return t.title && (V = Math.max(V, r(t.title, 16, !0) + 32), s.text(V / 2, 27, t.title, {
|
|
1499
1499
|
anchor: "middle",
|
|
1500
1500
|
size: 16,
|
|
1501
1501
|
bold: !0
|
|
1502
1502
|
})), {
|
|
1503
|
-
svg: s.toString(
|
|
1504
|
-
w: Math.ceil(
|
|
1505
|
-
h: Math.ceil(
|
|
1503
|
+
svg: s.toString(V, H),
|
|
1504
|
+
w: Math.ceil(V),
|
|
1505
|
+
h: Math.ceil(H)
|
|
1506
1506
|
};
|
|
1507
1507
|
}
|
|
1508
1508
|
var I = (e, t) => ({
|
|
@@ -1549,8 +1549,12 @@ function L(e, t, n) {
|
|
|
1549
1549
|
}, ...i.slice(a)];
|
|
1550
1550
|
return n ? d : d.reverse();
|
|
1551
1551
|
}
|
|
1552
|
-
// src/core/
|
|
1552
|
+
// src/core/dict.ts
|
|
1553
1553
|
function R(e) {
|
|
1554
|
+
return Object.assign(Object.create(null), e);
|
|
1555
|
+
}
|
|
1556
|
+
// src/core/diagram/dot.ts
|
|
1557
|
+
function z(e) {
|
|
1554
1558
|
let t = [], n = e.length, r = 0, i = !0;
|
|
1555
1559
|
for (; r < n;) {
|
|
1556
1560
|
let a = e[r];
|
|
@@ -1614,7 +1618,7 @@ function R(e) {
|
|
|
1614
1618
|
}
|
|
1615
1619
|
return t;
|
|
1616
1620
|
}
|
|
1617
|
-
var
|
|
1621
|
+
var ae = R({
|
|
1618
1622
|
box: "rect",
|
|
1619
1623
|
rect: "rect",
|
|
1620
1624
|
rectangle: "rect",
|
|
@@ -1658,7 +1662,7 @@ var z = {
|
|
|
1658
1662
|
record: "rect",
|
|
1659
1663
|
mrecord: "round",
|
|
1660
1664
|
underlinebox: "rect"
|
|
1661
|
-
}, B = {
|
|
1665
|
+
}), B = R({
|
|
1662
1666
|
normal: "arrow",
|
|
1663
1667
|
inv: "arrow",
|
|
1664
1668
|
empty: "triangle",
|
|
@@ -1682,7 +1686,7 @@ var z = {
|
|
|
1682
1686
|
tee: "one",
|
|
1683
1687
|
curve: "open",
|
|
1684
1688
|
icurve: "open"
|
|
1685
|
-
};
|
|
1689
|
+
});
|
|
1686
1690
|
function V(e, t) {
|
|
1687
1691
|
if (!e) return t;
|
|
1688
1692
|
let n = e.toLowerCase().replace(/^[lr](?=[a-z])/, "");
|
|
@@ -1713,17 +1717,17 @@ function H(e) {
|
|
|
1713
1717
|
}
|
|
1714
1718
|
return l(/^[a-z]+\d+$/.test(r) ? r.replace(/\d+$/, "") : r);
|
|
1715
1719
|
}
|
|
1716
|
-
function
|
|
1720
|
+
function oe(e) {
|
|
1717
1721
|
return h(e.replace(/<br\s*\/?>/gi, "\n").replace(/<\/tr>/gi, "\n").replace(/<\/td>\s*<td/gi, " <td").replace(/<[^>]+>/g, "").replace(/\n\s*\n/g, "\n")).split("\n").map((e) => e.trim()).filter(Boolean).join("\n");
|
|
1718
1722
|
}
|
|
1719
1723
|
function U(e, t, n = "") {
|
|
1720
1724
|
return e.replace(/\\[nlr]/g, "\n").replace(/\\N/g, t).replace(/\\G/g, n).replace(/\\(.)/g, "$1").replace(/\n$/, "");
|
|
1721
1725
|
}
|
|
1722
|
-
function
|
|
1726
|
+
function se(e, t) {
|
|
1723
1727
|
return U(e, t).replace(/<[^>]*>/g, "").split(/[|{}]/).map((e) => e.trim()).filter(Boolean);
|
|
1724
1728
|
}
|
|
1725
|
-
function
|
|
1726
|
-
let t =
|
|
1729
|
+
function ce(e) {
|
|
1730
|
+
let t = z(e), n = 0, r = (e = 0) => t[n + e], i = (e, t = 0) => r(t)?.t === "p" && r(t).v === e, a = (e) => i(e) ? (n++, !0) : !1, o = (e) => r()?.t === "id" && r().v.toLowerCase() === e, s = [];
|
|
1727
1731
|
for (; n < t.length;) {
|
|
1728
1732
|
if (o("strict") && n++, !o("graph") && !o("digraph")) {
|
|
1729
1733
|
n++;
|
|
@@ -1832,28 +1836,28 @@ function se(e) {
|
|
|
1832
1836
|
BT: "BT",
|
|
1833
1837
|
TB: "TB"
|
|
1834
1838
|
}[(m.rankdir ?? "TB").toUpperCase()] ?? "TB";
|
|
1835
|
-
l.g.dir = C, m.label && (l.g.title = m.label.startsWith("<") ?
|
|
1836
|
-
for (let e of l.g.nodes)
|
|
1839
|
+
l.g.dir = C, m.label && (l.g.title = m.label.startsWith("<") ? oe(m.label.slice(1, -1)) : U(m.label, "", c));
|
|
1840
|
+
for (let e of l.g.nodes) le(e, u.get(e.id) ?? {});
|
|
1837
1841
|
for (let e of l.g.clusters) {
|
|
1838
1842
|
let t = h.get(e.id) ?? {};
|
|
1839
|
-
e.label = t.label ? t.label.startsWith("<") ?
|
|
1843
|
+
e.label = t.label ? t.label.startsWith("<") ? oe(t.label.slice(1, -1)) : U(t.label, "", e.id) : "";
|
|
1840
1844
|
let n = {}, r = (t.style ?? "").toLowerCase();
|
|
1841
1845
|
r.includes("filled") ? n.fill = H(t.fillcolor ?? t.color ?? t.bgcolor) ?? "#d3d3d3" : t.bgcolor && (n.fill = H(t.bgcolor)), (t.color || t.pencolor) && (n.stroke = H(t.pencolor ?? t.color)), r.includes("dashed") && (n.dash = "6 4"), r.includes("dotted") && (n.dash = "2 3"), t.fontcolor && (n.color = H(t.fontcolor)), r.includes("invis") && (n.stroke = n.fill = "none"), e.style = n;
|
|
1842
1846
|
}
|
|
1843
|
-
for (let { e: t, attrs: n } of d) l.g.edges.push(
|
|
1847
|
+
for (let { e: t, attrs: n } of d) l.g.edges.push(ue(t, n, e));
|
|
1844
1848
|
l.g.sameRank = f, s.push(l.g);
|
|
1845
1849
|
}
|
|
1846
1850
|
if (!s.length) throw new g("No “graph” or “digraph” found");
|
|
1847
1851
|
return s;
|
|
1848
1852
|
}
|
|
1849
|
-
function
|
|
1853
|
+
function le(e, t) {
|
|
1850
1854
|
let n = (t.shape ?? "ellipse").toLowerCase();
|
|
1851
|
-
e.shape =
|
|
1855
|
+
e.shape = ae[n] ?? "ellipse";
|
|
1852
1856
|
let r = t.label;
|
|
1853
1857
|
if (r !== void 0) {
|
|
1854
|
-
if (r.startsWith("<") && r.endsWith(">")) e.label =
|
|
1858
|
+
if (r.startsWith("<") && r.endsWith(">")) e.label = oe(r.slice(1, -1));
|
|
1855
1859
|
else if (n === "record" || n === "mrecord") {
|
|
1856
|
-
let t =
|
|
1860
|
+
let t = se(r, e.id);
|
|
1857
1861
|
e.label = t.join("\n"), t.length > 1 && (e.sections = t.map((e) => ({
|
|
1858
1862
|
rows: [[e]],
|
|
1859
1863
|
center: !0
|
|
@@ -1864,15 +1868,15 @@ function ce(e, t) {
|
|
|
1864
1868
|
let i = {}, a = (t.style ?? "").toLowerCase();
|
|
1865
1869
|
a.includes("filled") || t.fillcolor ? i.fill = H(t.fillcolor ?? t.color) ?? "#d3d3d3" : e.shape !== "point" && (i.fill = "#ffffff"), i.stroke = t.color ? H(t.color) : "#000000", t.fontcolor && (i.color = H(t.fontcolor)), a.includes("dashed") && (i.dash = "6 4"), a.includes("dotted") && (i.dash = "2 3"), a.includes("bold") && (i.sw = 2.4), t.penwidth && (i.sw = Math.min(8, Number(t.penwidth) || 1)), a.includes("invis") && (i.hidden = !0), a.includes("rounded") && e.shape === "rect" && (e.shape = "round"), e.shape === "none" && (i.fill = void 0), e.style = i;
|
|
1866
1870
|
}
|
|
1867
|
-
function
|
|
1871
|
+
function ue(e, t, n) {
|
|
1868
1872
|
let r = (t.style ?? "").toLowerCase(), i = (t.dir ?? (n ? "forward" : "none")).toLowerCase(), a = V(t.arrowhead, "arrow"), o = V(t.arrowtail, "arrow");
|
|
1869
1873
|
e.head = i === "forward" || i === "both" ? a : "none", e.tail = i === "back" || i === "both" ? o : "none";
|
|
1870
1874
|
let s = t.label ?? t.xlabel;
|
|
1871
|
-
return s && (e.label = s.startsWith("<") && s.endsWith(">") ?
|
|
1875
|
+
return s && (e.label = s.startsWith("<") && s.endsWith(">") ? oe(s.slice(1, -1)) : U(s, "")), t.headlabel && (e.headLabel = U(t.headlabel, "")), t.taillabel && (e.tailLabel = U(t.taillabel, "")), e.line = r.includes("invis") ? "hidden" : r.includes("dashed") ? "dashed" : r.includes("dotted") ? "dotted" : r.includes("bold") ? "thick" : "solid", e.color = H(t.color) ?? "#000000", t.penwidth && (e.sw = Math.min(8, Number(t.penwidth) || 1)), t.minlen && (e.minlen = Math.max(1, Math.min(6, Math.round(Number(t.minlen)) || 1))), e;
|
|
1872
1876
|
}
|
|
1873
1877
|
// src/core/diagram/charts.ts
|
|
1874
1878
|
var W = 16, G = (e) => Math.round(e * 100) / 100;
|
|
1875
|
-
function
|
|
1879
|
+
function de(e) {
|
|
1876
1880
|
let t = e.slices.filter((e) => e.value > 0 && Number.isFinite(e.value));
|
|
1877
1881
|
if (!t.length) throw Error("The pie chart has no values");
|
|
1878
1882
|
let n = t.reduce((e, t) => e + t.value, 0), i = new p(), a = W + (e.title ? 36 : 0) + 130, o = (e) => u.series[e % u.series.length], s = -Math.PI / 2, c = (e, t) => ({
|
|
@@ -1907,7 +1911,7 @@ function ue(e) {
|
|
|
1907
1911
|
});
|
|
1908
1912
|
let l = a - t.length * 24 / 2 + 12, d = 0;
|
|
1909
1913
|
t.forEach((t, n) => {
|
|
1910
|
-
let a = e.showData ? `${t.label} [${
|
|
1914
|
+
let a = e.showData ? `${t.label} [${fe(t.value)}]` : t.label;
|
|
1911
1915
|
i.rect(306, l + n * 24 - 8, 16, 16, { fill: o(n) }, 3), i.text(330, l + n * 24, a), d = Math.max(d, r(a, 14));
|
|
1912
1916
|
});
|
|
1913
1917
|
let f = 330 + d + W, m = Math.max(a + 130, l + t.length * 24) + W;
|
|
@@ -1921,8 +1925,8 @@ function ue(e) {
|
|
|
1921
1925
|
h: Math.ceil(m)
|
|
1922
1926
|
};
|
|
1923
1927
|
}
|
|
1924
|
-
var
|
|
1925
|
-
function
|
|
1928
|
+
var fe = (e) => String(Number.isInteger(e) ? e : Math.round(e * 100) / 100), K = 36e5, q = 24 * K, pe = (e) => String(e).padStart(2, "0");
|
|
1929
|
+
function me(e) {
|
|
1926
1930
|
let t = e.sections.flatMap((e) => e.tasks);
|
|
1927
1931
|
if (!t.length) throw Error("The Gantt chart has no tasks");
|
|
1928
1932
|
let n = Math.min(...t.map((e) => e.start)), i = Math.max(...t.map((e) => Math.max(e.end, e.start))), a = Math.max(i - n, K), s = Math.min(180, Math.max(0, ...e.sections.map((e) => r(e.name, 13, !0))) + 24), c = Math.max(560, Math.min(1100, t.length * 60)), l = c / a, d = e.title ? 36 : 0, f = W + s, m = W + d, h = (e) => f + (e - n) * l, g = new p(), _ = m + t.length * 28 + 24 + W + 6, v = [
|
|
@@ -1939,7 +1943,7 @@ function fe(e) {
|
|
|
1939
1943
|
365 * q
|
|
1940
1944
|
].find((e) => a / e <= 12) ?? 365 * q, y = Math.ceil(n / v) * v, b = (e) => {
|
|
1941
1945
|
let t = new Date(e);
|
|
1942
|
-
return v < q ? `${
|
|
1946
|
+
return v < q ? `${pe(t.getUTCHours())}:${pe(t.getUTCMinutes())}` : v >= 365 * q ? String(t.getUTCFullYear()) : v >= 30 * q ? `${t.getUTCFullYear()}-${pe(t.getUTCMonth() + 1)}` : `${t.getUTCFullYear()}-${pe(t.getUTCMonth() + 1)}-${pe(t.getUTCDate())}`;
|
|
1943
1947
|
}, x = m + t.length * 28 + 4;
|
|
1944
1948
|
for (let e = y; e <= i; e += v) {
|
|
1945
1949
|
let t = h(e);
|
|
@@ -2001,8 +2005,8 @@ function fe(e) {
|
|
|
2001
2005
|
h: Math.ceil(_)
|
|
2002
2006
|
};
|
|
2003
2007
|
}
|
|
2004
|
-
var
|
|
2005
|
-
function
|
|
2008
|
+
var he = 44, J = 12;
|
|
2009
|
+
function ge(e, t) {
|
|
2006
2010
|
let n = new p(), i = (e, t) => {
|
|
2007
2011
|
let n = t === 0 ? 16 : t === 1 ? 14 : 13, r = o(e.label.split("\n"), 220, n, t === 0), i = a(r, n, t === 0), s = e.shape === "circle", c = Math.max(i.w, i.h) + 20;
|
|
2008
2012
|
return {
|
|
@@ -2012,7 +2016,7 @@ function Y(e, t) {
|
|
|
2012
2016
|
fs: n
|
|
2013
2017
|
};
|
|
2014
2018
|
}, s = (e, t, n) => {
|
|
2015
|
-
let r = i(e, t), a = e.children.map((e, r) => s(e, t + 1, t === 0 ? u.series[r % u.series.length] : n)), o = Math.max(r.h, a.reduce((e, t) => e + t.span, 0) + Math.max(0, a.length - 1) *
|
|
2019
|
+
let r = i(e, t), a = e.children.map((e, r) => s(e, t + 1, t === 0 ? u.series[r % u.series.length] : n)), o = Math.max(r.h, a.reduce((e, t) => e + t.span, 0) + Math.max(0, a.length - 1) * J);
|
|
2016
2020
|
return {
|
|
2017
2021
|
n: e,
|
|
2018
2022
|
w: r.w,
|
|
@@ -2033,13 +2037,13 @@ function Y(e, t) {
|
|
|
2033
2037
|
} else l = c.kids;
|
|
2034
2038
|
let f = (e, t, n, r) => {
|
|
2035
2039
|
e.x = t;
|
|
2036
|
-
let i = n + (e.span - (e.kids.reduce((e, t) => e + t.span, 0) + Math.max(0, e.kids.length - 1) *
|
|
2037
|
-
for (let n of e.kids) f(n, t + r * (e.w / 2 +
|
|
2040
|
+
let i = n + (e.span - (e.kids.reduce((e, t) => e + t.span, 0) + Math.max(0, e.kids.length - 1) * J)) / 2;
|
|
2041
|
+
for (let n of e.kids) f(n, t + r * (e.w / 2 + he + n.w / 2), i, r), i += n.span + J;
|
|
2038
2042
|
e.y = e.kids.length ? (e.kids[0].y + e.kids[e.kids.length - 1].y) / 2 : n + e.span / 2;
|
|
2039
|
-
}, h = (e) => e.reduce((e, t) => e + t.span, 0) + Math.max(0, e.length - 1) *
|
|
2040
|
-
for (let e of l) f(e, c.w / 2 +
|
|
2043
|
+
}, h = (e) => e.reduce((e, t) => e + t.span, 0) + Math.max(0, e.length - 1) * J, g = h(l), _ = h(d), v = Math.max(c.h, g, _), y = (v - g) / 2;
|
|
2044
|
+
for (let e of l) f(e, c.w / 2 + he + e.w / 2, y, 1), y += e.span + J;
|
|
2041
2045
|
y = (v - _) / 2;
|
|
2042
|
-
for (let e of d) f(e, -(c.w / 2 +
|
|
2046
|
+
for (let e of d) f(e, -(c.w / 2 + he + e.w / 2), y, -1), y += e.span + J;
|
|
2043
2047
|
c.x = 0, c.y = v / 2;
|
|
2044
2048
|
let b = Infinity, x = -Infinity, S = Infinity, C = -Infinity, w = [], T = (e) => {
|
|
2045
2049
|
w.push(e), b = Math.min(b, e.x - e.w / 2), x = Math.max(x, e.x + e.w / 2), S = Math.min(S, e.y - e.h / 2), C = Math.max(C, e.y + e.h / 2), e.kids.forEach(T);
|
|
@@ -2079,7 +2083,7 @@ function Y(e, t) {
|
|
|
2079
2083
|
});
|
|
2080
2084
|
}
|
|
2081
2085
|
for (let e of w) {
|
|
2082
|
-
let t = k(e), r = e.depth === 0 ? 16 : e.depth === 1 ? 14 : 13, i = t.x - e.w / 2, a = t.y - e.h / 2, o = e.n.shape ?? (e.depth, "round"), s = e.depth === 0 ? u.dark : e.depth === 1 ? e.color :
|
|
2086
|
+
let t = k(e), r = e.depth === 0 ? 16 : e.depth === 1 ? 14 : 13, i = t.x - e.w / 2, a = t.y - e.h / 2, o = e.n.shape ?? (e.depth, "round"), s = e.depth === 0 ? u.dark : e.depth === 1 ? e.color : _e(e.color), c = e.depth <= 1 ? "#ffffff" : u.ink;
|
|
2083
2087
|
if (o === "none") n.line(i, a + e.h, i + e.w, a + e.h, {
|
|
2084
2088
|
stroke: e.color,
|
|
2085
2089
|
sw: 1.5
|
|
@@ -2131,7 +2135,7 @@ function Y(e, t) {
|
|
|
2131
2135
|
h: Math.ceil(j)
|
|
2132
2136
|
};
|
|
2133
2137
|
}
|
|
2134
|
-
function
|
|
2138
|
+
function _e(e) {
|
|
2135
2139
|
let t = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);
|
|
2136
2140
|
return t ? "#" + [
|
|
2137
2141
|
t[1],
|
|
@@ -2140,7 +2144,7 @@ function he(e) {
|
|
|
2140
2144
|
].map((e) => Math.round(parseInt(e, 16) * .22 + 198.9).toString(16).padStart(2, "0")).join("") : "#f1f3f7";
|
|
2141
2145
|
}
|
|
2142
2146
|
// src/core/diagram/sequence.ts
|
|
2143
|
-
var
|
|
2147
|
+
var Y = (e) => Math.round(e * 100) / 100, ve = class {
|
|
2144
2148
|
s = {
|
|
2145
2149
|
participants: [],
|
|
2146
2150
|
events: []
|
|
@@ -2162,9 +2166,9 @@ var X = (e) => Math.round(e * 100) / 100, ge = class {
|
|
|
2162
2166
|
push(e) {
|
|
2163
2167
|
e.t === "msg" ? (this.participant(e.from), this.participant(e.to)) : e.t === "note" ? e.who.forEach((e) => this.participant(e)) : (e.t === "act" || e.t === "destroy") && this.participant(e.who), this.s.events.push(e);
|
|
2164
2168
|
}
|
|
2165
|
-
},
|
|
2166
|
-
function
|
|
2167
|
-
let t =
|
|
2169
|
+
}, ye = 14, X = 13, be = i(X), Z = 16, Q = (e) => e ? e.split("\n") : [];
|
|
2170
|
+
function xe(e) {
|
|
2171
|
+
let t = Q(e.label), n = a(t, ye);
|
|
2168
2172
|
switch (e.kind) {
|
|
2169
2173
|
case "actor": return {
|
|
2170
2174
|
w: Math.max(44, n.w + 8),
|
|
@@ -2190,7 +2194,7 @@ function be(e) {
|
|
|
2190
2194
|
};
|
|
2191
2195
|
}
|
|
2192
2196
|
}
|
|
2193
|
-
function
|
|
2197
|
+
function Se(e, t, n, r, a) {
|
|
2194
2198
|
let o = t.fill ?? u.fill, s = {
|
|
2195
2199
|
fill: o,
|
|
2196
2200
|
stroke: u.stroke,
|
|
@@ -2199,7 +2203,7 @@ function xe(e, t, n, r, a) {
|
|
|
2199
2203
|
fill: "none",
|
|
2200
2204
|
stroke: u.dark,
|
|
2201
2205
|
sw: 1.5
|
|
2202
|
-
}, l = (t) => e.text(r, t + n.text.length * i(
|
|
2206
|
+
}, l = (t) => e.text(r, t + n.text.length * i(ye) / 2, n.text, { anchor: "middle" }), d = r - n.w / 2;
|
|
2203
2207
|
switch (t.kind) {
|
|
2204
2208
|
case "actor":
|
|
2205
2209
|
e.circle(r, a + 8, 7, {
|
|
@@ -2222,7 +2226,7 @@ function xe(e, t, n, r, a) {
|
|
|
2222
2226
|
return;
|
|
2223
2227
|
case "database": {
|
|
2224
2228
|
let t = n.w, i = n.h;
|
|
2225
|
-
e.path(`M${
|
|
2229
|
+
e.path(`M${Y(d)} ${Y(a + 6)} A${Y(t / 2)} 6 0 0 1 ${Y(d + t)} ${Y(a + 6)} L${Y(d + t)} ${Y(a + i - 6)} A${Y(t / 2)} 6 0 0 1 ${Y(d)} ${Y(a + i - 6)} Z`, s), e.path(`M${Y(d)} ${Y(a + 6)} A${Y(t / 2)} 6 0 0 0 ${Y(d + t)} ${Y(a + 6)}`, {
|
|
2226
2230
|
...s,
|
|
2227
2231
|
fill: "none"
|
|
2228
2232
|
}), e.text(r, a + i / 2 + 3, n.text, { anchor: "middle" });
|
|
@@ -2238,7 +2242,7 @@ function xe(e, t, n, r, a) {
|
|
|
2238
2242
|
}
|
|
2239
2243
|
e.text(r, a + n.h / 2, n.text, { anchor: "middle" });
|
|
2240
2244
|
}
|
|
2241
|
-
function
|
|
2245
|
+
function Ce(e, t, n, r, i) {
|
|
2242
2246
|
let a = u.line;
|
|
2243
2247
|
switch (t) {
|
|
2244
2248
|
case "filled":
|
|
@@ -2277,11 +2281,11 @@ function Se(e, t, n, r, i) {
|
|
|
2277
2281
|
});
|
|
2278
2282
|
}
|
|
2279
2283
|
}
|
|
2280
|
-
function
|
|
2284
|
+
function we(e) {
|
|
2281
2285
|
let t = e.participants;
|
|
2282
2286
|
if (!t.length) throw new g("The sequence diagram has no participants");
|
|
2283
2287
|
if (t.length > 300 || e.events.length > 8e3) throw new g("The sequence diagram is too large to draw");
|
|
2284
|
-
let n = new Map(t.map((e, t) => [e.id, t])), i = t.map(
|
|
2288
|
+
let n = new Map(t.map((e, t) => [e.id, t])), i = t.map(xe), o = t.length, s = Array(o).fill(0);
|
|
2285
2289
|
for (let e = 1; e < o; e++) s[e] = (i[e - 1].w + i[e].w) / 2 + 28;
|
|
2286
2290
|
let c = 0, l = 0, d = (e, t, n) => {
|
|
2287
2291
|
if (e > t && ([e, t] = [t, e]), e === t) return;
|
|
@@ -2293,10 +2297,10 @@ function Ce(e) {
|
|
|
2293
2297
|
}, f = (t) => e.autonumber ? r(String(t), 10) + 14 : 0, m = 0;
|
|
2294
2298
|
for (let t of e.events) if (t.t === "msg") {
|
|
2295
2299
|
m++;
|
|
2296
|
-
let e = n.get(t.from), a = n.get(t.to), s = Math.max(0, ...
|
|
2300
|
+
let e = n.get(t.from), a = n.get(t.to), s = Math.max(0, ...Q(t.text).map((e) => r(e, X))) + f(m);
|
|
2297
2301
|
e === a ? e + 1 < o ? d(e, e + 1, i[e + 1].w / 2 + s + 44) : l = Math.max(l, s + 44 - i[e].w / 2) : d(e, a, s + 30);
|
|
2298
2302
|
} else if (t.t === "note") {
|
|
2299
|
-
let e = a(
|
|
2303
|
+
let e = a(Q(t.text), X).w + 20, r = t.who.map((e) => n.get(e)), s = Math.min(...r), u = Math.max(...r);
|
|
2300
2304
|
t.pos === "over" ? s !== u && d(s, u, e - 50) : t.pos === "left" ? s > 0 ? d(s - 1, s, e + 16 + i[s - 1].w / 2) : c = Math.max(c, e + 16 - i[0].w / 2) : u + 1 < o ? d(u, u + 1, e + 16 + i[u + 1].w / 2) : l = Math.max(l, e + 16 - i[u].w / 2);
|
|
2301
2305
|
}
|
|
2302
2306
|
let h = [], _ = (() => {
|
|
@@ -2304,9 +2308,9 @@ function Ce(e) {
|
|
|
2304
2308
|
for (let r of e.events) r.t === "block" ? n = Math.max(n, ++t) : r.t === "end" && (t = Math.max(0, t - 1));
|
|
2305
2309
|
return n;
|
|
2306
2310
|
})(), v = _ ? 12 + _ * 8 : 0;
|
|
2307
|
-
h[0] =
|
|
2311
|
+
h[0] = Z + Math.max(i[0].w / 2, c + i[0].w / 2, v + 10);
|
|
2308
2312
|
for (let e = 1; e < o; e++) h[e] = h[e - 1] + s[e];
|
|
2309
|
-
let y = h[o - 1] + Math.max(i[o - 1].w / 2, l + i[o - 1].w / 2, v + 10) +
|
|
2313
|
+
let y = h[o - 1] + Math.max(i[o - 1].w / 2, l + i[o - 1].w / 2, v + 10) + Z, b = Z + (e.title ? 34 : 0), x = Math.max(...i.map((e) => e.h)), S = b + x + 18, C = new p(), w = new p(), T = new p(), E = t.map(() => []), D = [], O = [], k = [], A = /* @__PURE__ */ new Map(), j = (e, t) => {
|
|
2310
2314
|
for (let n of k) n.lo = Math.min(n.lo, e), n.hi = Math.max(n.hi, t);
|
|
2311
2315
|
}, ee = (e, t) => {
|
|
2312
2316
|
let n = E[e].length;
|
|
@@ -2324,7 +2328,7 @@ function Ce(e) {
|
|
|
2324
2328
|
for (let t of e.events) switch (t.t) {
|
|
2325
2329
|
case "msg": {
|
|
2326
2330
|
m++;
|
|
2327
|
-
let i = n.get(t.from), a = n.get(t.to), o =
|
|
2331
|
+
let i = n.get(t.from), a = n.get(t.to), o = Q(t.text), s = o.length * be, c = {
|
|
2328
2332
|
stroke: u.line,
|
|
2329
2333
|
sw: 1.4,
|
|
2330
2334
|
dash: t.dashed ? "6 4" : void 0
|
|
@@ -2337,17 +2341,17 @@ function Ce(e) {
|
|
|
2337
2341
|
[n + 34, S],
|
|
2338
2342
|
[n + 34, S + 20],
|
|
2339
2343
|
[n + 2, S + 20]
|
|
2340
|
-
], c, !1),
|
|
2344
|
+
], c, !1), Ce(w, t.head, n, S + 20, -1), T.text(n + 6 + l, S - 4 - s / 2, o, { size: X }), e.autonumber && Te(T, n, S, m), j(h[i] - 10, n + 34 + 6 + l + Math.max(...o.map((e) => r(e, X)))), S += 20, t.activate && te(a, S), t.deactivate && M(i, S), S += 14;
|
|
2341
2345
|
break;
|
|
2342
2346
|
}
|
|
2343
2347
|
S += s + 6;
|
|
2344
2348
|
let d = a > i ? 1 : -1;
|
|
2345
2349
|
t.activate && te(a, S);
|
|
2346
2350
|
let p = ee(i, d), g = ee(a, -d);
|
|
2347
|
-
w.line(p, S, g, S, c),
|
|
2351
|
+
w.line(p, S, g, S, c), Ce(w, t.head, g, S, d), t.both && Ce(w, t.head, p, S, -d), T.text((p + g) / 2 + d * l / 2, S - 5 - s / 2, o, {
|
|
2348
2352
|
anchor: "middle",
|
|
2349
|
-
size:
|
|
2350
|
-
}), e.autonumber &&
|
|
2353
|
+
size: X
|
|
2354
|
+
}), e.autonumber && Te(T, p, S, m), t.deactivate && M(i, S), j(Math.min(h[i], h[a]), Math.max(h[i], h[a])), S += 14;
|
|
2351
2355
|
break;
|
|
2352
2356
|
}
|
|
2353
2357
|
case "act": {
|
|
@@ -2356,7 +2360,7 @@ function Ce(e) {
|
|
|
2356
2360
|
break;
|
|
2357
2361
|
}
|
|
2358
2362
|
case "note": {
|
|
2359
|
-
let e = t.who.map((e) => n.get(e)), r = Math.min(...e), i = Math.max(...e), o =
|
|
2363
|
+
let e = t.who.map((e) => n.get(e)), r = Math.min(...e), i = Math.max(...e), o = Q(t.text), s = a(o, X), c = Math.max(s.w + 20, t.pos === "over" && r !== i ? h[i] - h[r] + 50 : 0, 60), l = s.h + 12;
|
|
2360
2364
|
S += 6;
|
|
2361
2365
|
let d = t.pos === "left" ? h[r] - 12 - c : t.pos === "right" ? h[i] + 12 : (h[r] + h[i]) / 2 - c / 2;
|
|
2362
2366
|
T.poly([
|
|
@@ -2369,7 +2373,7 @@ function Ce(e) {
|
|
|
2369
2373
|
fill: u.note,
|
|
2370
2374
|
stroke: u.noteStroke,
|
|
2371
2375
|
sw: 1
|
|
2372
|
-
}), T.text(d + 10, S + l / 2, o, { size:
|
|
2376
|
+
}), T.text(d + 10, S + l / 2, o, { size: X }), j(d, d + c), S += l + 8;
|
|
2373
2377
|
break;
|
|
2374
2378
|
}
|
|
2375
2379
|
case "block": {
|
|
@@ -2405,28 +2409,28 @@ function Ce(e) {
|
|
|
2405
2409
|
}
|
|
2406
2410
|
case "divider": {
|
|
2407
2411
|
S += 16;
|
|
2408
|
-
let e = a(
|
|
2409
|
-
T.line(
|
|
2412
|
+
let e = a(Q(t.text), X);
|
|
2413
|
+
T.line(Z / 2, S - 2, y - Z / 2, S - 2, {
|
|
2410
2414
|
stroke: u.muted,
|
|
2411
2415
|
sw: 1
|
|
2412
|
-
}).line(
|
|
2416
|
+
}).line(Z / 2, S + 2, y - Z / 2, S + 2, {
|
|
2413
2417
|
stroke: u.muted,
|
|
2414
2418
|
sw: 1
|
|
2415
2419
|
}), t.text && (T.rect(y / 2 - e.w / 2 - 10, S - e.h / 2 - 4, e.w + 20, e.h + 8, {
|
|
2416
2420
|
fill: "#ffffff",
|
|
2417
2421
|
stroke: u.muted,
|
|
2418
2422
|
sw: 1
|
|
2419
|
-
}, 3), T.text(y / 2, S,
|
|
2423
|
+
}, 3), T.text(y / 2, S, Q(t.text), {
|
|
2420
2424
|
anchor: "middle",
|
|
2421
|
-
size:
|
|
2425
|
+
size: X,
|
|
2422
2426
|
bold: !0
|
|
2423
2427
|
})), S += 22;
|
|
2424
2428
|
break;
|
|
2425
2429
|
}
|
|
2426
2430
|
case "delay":
|
|
2427
|
-
S += 14, t.text && T.text(y / 2, S,
|
|
2431
|
+
S += 14, t.text && T.text(y / 2, S, Q(t.text), {
|
|
2428
2432
|
anchor: "middle",
|
|
2429
|
-
size:
|
|
2433
|
+
size: X,
|
|
2430
2434
|
italic: !0,
|
|
2431
2435
|
color: u.muted
|
|
2432
2436
|
}), S += 18;
|
|
@@ -2449,7 +2453,7 @@ function Ce(e) {
|
|
|
2449
2453
|
for (let e = 0; e < o; e++) for (; E[e].length;) M(e, S);
|
|
2450
2454
|
for (let e of k.splice(0)) e.y1 = S;
|
|
2451
2455
|
S += 14;
|
|
2452
|
-
let N = e.footer !== !1, ne = S + (N ? x : 0) +
|
|
2456
|
+
let N = e.footer !== !1, ne = S + (N ? x : 0) + Z;
|
|
2453
2457
|
for (let e of O) {
|
|
2454
2458
|
let t = 12 + (_ - e.depth) * 8;
|
|
2455
2459
|
e.lo > e.hi && (e.lo = h[0], e.hi = h[o - 1]);
|
|
@@ -2506,7 +2510,7 @@ function Ce(e) {
|
|
|
2506
2510
|
});
|
|
2507
2511
|
}
|
|
2508
2512
|
return P.raw(w.body()), P.raw(T.body()), t.forEach((e, t) => {
|
|
2509
|
-
|
|
2513
|
+
Se(P, e, i[t], h[t], b + x - i[t].h), N && !A.has(t) && Se(P, e, i[t], h[t], S);
|
|
2510
2514
|
}), e.title && (y = Math.max(y, r(e.title, 16, !0) + 32), P.text(y / 2, 28, e.title, {
|
|
2511
2515
|
anchor: "middle",
|
|
2512
2516
|
size: 16,
|
|
@@ -2517,7 +2521,7 @@ function Ce(e) {
|
|
|
2517
2521
|
h: Math.ceil(ne)
|
|
2518
2522
|
};
|
|
2519
2523
|
}
|
|
2520
|
-
function
|
|
2524
|
+
function Te(e, t, n, i) {
|
|
2521
2525
|
let a = Math.max(8, r(String(i), 10) / 2 + 4);
|
|
2522
2526
|
e.circle(t, n, a, { fill: u.dark }), e.text(t, n, String(i), {
|
|
2523
2527
|
anchor: "middle",
|
|
@@ -2527,17 +2531,17 @@ function we(e, t, n, i) {
|
|
|
2527
2531
|
});
|
|
2528
2532
|
}
|
|
2529
2533
|
// src/core/diagram/model.ts
|
|
2530
|
-
function
|
|
2534
|
+
function Ee(e) {
|
|
2531
2535
|
switch (e.t) {
|
|
2532
2536
|
case "graph": return F(e.graph);
|
|
2533
|
-
case "sequence": return
|
|
2534
|
-
case "pie": return
|
|
2535
|
-
case "gantt": return
|
|
2536
|
-
case "tree": return
|
|
2537
|
+
case "sequence": return we(e.seq);
|
|
2538
|
+
case "pie": return de(e.pie);
|
|
2539
|
+
case "gantt": return me(e.gantt);
|
|
2540
|
+
case "tree": return ge(e.root, e.title);
|
|
2537
2541
|
}
|
|
2538
2542
|
}
|
|
2539
2543
|
// src/core/diagram/plantuml.ts
|
|
2540
|
-
function
|
|
2544
|
+
function De(e) {
|
|
2541
2545
|
let t = e.replace(/^/, "").replace(/\r\n?/g, "\n"), n = [], r = /^[ \t]*@start(\w+)[^\n]*\n([\s\S]*?)^[ \t]*@end\1\b/gm, i;
|
|
2542
2546
|
for (; i = r.exec(t);) n.push({
|
|
2543
2547
|
kind: i[1].toLowerCase(),
|
|
@@ -2548,52 +2552,52 @@ function Ee(e) {
|
|
|
2548
2552
|
lines: t.split("\n")
|
|
2549
2553
|
}), n;
|
|
2550
2554
|
}
|
|
2551
|
-
function
|
|
2552
|
-
return
|
|
2555
|
+
function Oe(e) {
|
|
2556
|
+
return De(e).map(({ kind: e, lines: t }) => Ae(e, t));
|
|
2553
2557
|
}
|
|
2554
|
-
var
|
|
2555
|
-
function
|
|
2558
|
+
var ke = (e) => Oe(e).map(Ee);
|
|
2559
|
+
function Ae(e, t) {
|
|
2556
2560
|
if (e === "dot") return {
|
|
2557
2561
|
t: "graph",
|
|
2558
|
-
graph:
|
|
2562
|
+
graph: ce(t.join("\n"))[0]
|
|
2559
2563
|
};
|
|
2560
|
-
let { lines: n, title: r, dir: i } =
|
|
2564
|
+
let { lines: n, title: r, dir: i } = je(t);
|
|
2561
2565
|
switch (e) {
|
|
2562
2566
|
case "uml": break;
|
|
2563
2567
|
case "mindmap":
|
|
2564
2568
|
case "wbs": return {
|
|
2565
2569
|
t: "tree",
|
|
2566
|
-
root:
|
|
2570
|
+
root: Ge(n, e === "wbs"),
|
|
2567
2571
|
title: r
|
|
2568
2572
|
};
|
|
2569
2573
|
default: throw new g(`PlantUML @start${e} diagrams are not supported yet`);
|
|
2570
2574
|
}
|
|
2571
|
-
switch (
|
|
2575
|
+
switch (Me(n)) {
|
|
2572
2576
|
case "activity": return {
|
|
2573
2577
|
t: "graph",
|
|
2574
2578
|
graph: {
|
|
2575
|
-
...
|
|
2579
|
+
...We(n),
|
|
2576
2580
|
title: r
|
|
2577
2581
|
}
|
|
2578
2582
|
};
|
|
2579
2583
|
case "sequence": return {
|
|
2580
2584
|
t: "sequence",
|
|
2581
2585
|
seq: {
|
|
2582
|
-
...
|
|
2586
|
+
...Pe(n),
|
|
2583
2587
|
title: r
|
|
2584
2588
|
}
|
|
2585
2589
|
};
|
|
2586
2590
|
case "state": return {
|
|
2587
2591
|
t: "graph",
|
|
2588
2592
|
graph: {
|
|
2589
|
-
...
|
|
2593
|
+
...Ue(n, i),
|
|
2590
2594
|
title: r
|
|
2591
2595
|
}
|
|
2592
2596
|
};
|
|
2593
2597
|
default: return {
|
|
2594
2598
|
t: "graph",
|
|
2595
2599
|
graph: {
|
|
2596
|
-
...
|
|
2600
|
+
...He(n, i),
|
|
2597
2601
|
title: r
|
|
2598
2602
|
}
|
|
2599
2603
|
};
|
|
@@ -2602,7 +2606,7 @@ function ke(e, t) {
|
|
|
2602
2606
|
function $(e) {
|
|
2603
2607
|
return h(e.trim().replace(/^"(.*)"$/s, "$1").replace(/\*\*(.+?)\*\*|\/\/(.+?)\/\/|""(.+?)""|__(.+?)__|~~(.+?)~~|--(.+?)--/g, (...e) => e.slice(1, 7).find((e) => e !== void 0) ?? "").replace(/<\/?(?:b|i|u|s|font|color|size|back|code|plain|strike|w|sub|sup)\b[^>]*>/gi, "").replace(/<&[\w-]+>/g, "").replace(/\\t/g, " "));
|
|
2604
2608
|
}
|
|
2605
|
-
function
|
|
2609
|
+
function je(e) {
|
|
2606
2610
|
let t = [], n, r, i = null, a = null, o = !1;
|
|
2607
2611
|
for (let s of e) {
|
|
2608
2612
|
if (o) {
|
|
@@ -2632,11 +2636,11 @@ function Ae(e) {
|
|
|
2632
2636
|
dir: r
|
|
2633
2637
|
};
|
|
2634
2638
|
}
|
|
2635
|
-
function
|
|
2639
|
+
function Me(e) {
|
|
2636
2640
|
let t = (t) => e.some((e) => t.test(e));
|
|
2637
2641
|
return t(/^(start|stop)$/) || t(/^:[\s\S]*[;|<>/\]}]$/) || t(/^:/) || t(/^(if\s*\(.*\)\s*then|while\s*\(|repeat\b|fork$|endif$)/) ? "activity" : t(/\[\*\]/) || t(/^state\s/) ? "state" : t(/^(participant|boundary|control|collections|queue|autonumber|activate|deactivate|alt|loop|return|ref\s+over)\b/) || t(/^(==.*==|\.\.\.|\|\|\d*\|\|)$/) ? "sequence" : t(/^(abstract|class|interface|enum|annotation|struct|protocol|object|map|json|usecase|component|node|cloud|package|namespace|folder|frame|rectangle|artifact|storage|card|file|agent|person|hexagon|together)\b/) || t(/\([^)]*\)|\[[^\]*]+\]|<\|--|--\|>|\*--|o--|\.\.>/) ? "description" : t(/^(actor|database|entity)\b/) || t(/^\S+\s*<?-{1,2}>?>?\s*\S+\s*:/) ? "sequence" : "description";
|
|
2638
2642
|
}
|
|
2639
|
-
var
|
|
2643
|
+
var Ne = R({
|
|
2640
2644
|
participant: "participant",
|
|
2641
2645
|
actor: "actor",
|
|
2642
2646
|
boundary: "boundary",
|
|
@@ -2645,9 +2649,9 @@ var Me = {
|
|
|
2645
2649
|
database: "database",
|
|
2646
2650
|
collections: "collections",
|
|
2647
2651
|
queue: "queue"
|
|
2648
|
-
};
|
|
2649
|
-
function
|
|
2650
|
-
let t = new
|
|
2652
|
+
});
|
|
2653
|
+
function Pe(e) {
|
|
2654
|
+
let t = new ve(), n = [], r = null, i = null, a = null, o = (e) => e.trim().replace(/^"(.*)"$/, "$1");
|
|
2651
2655
|
for (let s of e) {
|
|
2652
2656
|
if (r) {
|
|
2653
2657
|
/^end\s*(note|ref|rnote|hnote)$/i.test(s) ? (i && i.who.length && t.push({
|
|
@@ -2664,7 +2668,7 @@ function Ne(e) {
|
|
|
2664
2668
|
r && (n = n.slice(0, r.index).trim()), n = n.replace(/<<[^>]*>>/g, "").trim();
|
|
2665
2669
|
let i = n, a = n, s = /^"([^"]+)"\s+as\s+(\S+)$/.exec(n), c = /^(\S+)\s+as\s+"?([^"]+)"?$/.exec(n);
|
|
2666
2670
|
s ? [i, a] = [s[2], s[1]] : c ? [i, a] = [c[1], c[2]] : i = a = o(n), t.participant(i, {
|
|
2667
|
-
kind:
|
|
2671
|
+
kind: Ne[e[1].toLowerCase()],
|
|
2668
2672
|
label: $(a),
|
|
2669
2673
|
fill: r ? l(r[1].slice(1)) ?? l(r[1]) : void 0
|
|
2670
2674
|
});
|
|
@@ -2771,7 +2775,7 @@ function Ne(e) {
|
|
|
2771
2775
|
});
|
|
2772
2776
|
continue;
|
|
2773
2777
|
}
|
|
2774
|
-
let c =
|
|
2778
|
+
let c = Ie(s);
|
|
2775
2779
|
if (c) {
|
|
2776
2780
|
let { from: e, to: r, dashed: i, head: o, both: s, act: l, text: u } = c;
|
|
2777
2781
|
t.push({
|
|
@@ -2798,9 +2802,9 @@ function Ne(e) {
|
|
|
2798
2802
|
}
|
|
2799
2803
|
return t.s;
|
|
2800
2804
|
}
|
|
2801
|
-
var
|
|
2802
|
-
function
|
|
2803
|
-
let t =
|
|
2805
|
+
var Fe = /^(\[|\]|[\w.$À-]+|"[^"]+")?\s*(<<?|[\\/]{1,2})?(-{1,2}|\.{1,2})(?:\[[^\]]*\])?(-?)(>>?|[\\/]{1,2})?\s*([ox])?\s*(\[|\]|[\w.$À-]+|"[^"]+")?\s*(\+\+|--|\*\*|!!)?\s*(?::\s*(.*))?$/u;
|
|
2806
|
+
function Ie(e) {
|
|
2807
|
+
let t = Fe.exec(e.replace(/^(\S+)\s*([ox])(?=<|-)/, "$1 "));
|
|
2804
2808
|
if (!t) return null;
|
|
2805
2809
|
let [, n, r, i, , a, , o, s, c] = t;
|
|
2806
2810
|
if (!r && !a || !n || !o) return null;
|
|
@@ -2817,7 +2821,7 @@ function Fe(e) {
|
|
|
2817
2821
|
text: $(c ?? "")
|
|
2818
2822
|
};
|
|
2819
2823
|
}
|
|
2820
|
-
var
|
|
2824
|
+
var Le = R({
|
|
2821
2825
|
actor: "actor",
|
|
2822
2826
|
person: "actor",
|
|
2823
2827
|
usecase: "ellipse",
|
|
@@ -2855,7 +2859,7 @@ var Ie = {
|
|
|
2855
2859
|
json: "rect",
|
|
2856
2860
|
diamond: "diamond",
|
|
2857
2861
|
state: "round"
|
|
2858
|
-
},
|
|
2862
|
+
}), Re = /* @__PURE__ */ new Set([
|
|
2859
2863
|
"class",
|
|
2860
2864
|
"abstract",
|
|
2861
2865
|
"abstract class",
|
|
@@ -2871,7 +2875,7 @@ var Ie = {
|
|
|
2871
2875
|
"object",
|
|
2872
2876
|
"map",
|
|
2873
2877
|
"json"
|
|
2874
|
-
]),
|
|
2878
|
+
]), ze = R({
|
|
2875
2879
|
">": "arrow",
|
|
2876
2880
|
"<": "arrow",
|
|
2877
2881
|
"|>": "triangle",
|
|
@@ -2893,8 +2897,8 @@ var Ie = {
|
|
|
2893
2897
|
"o{": "zero-many",
|
|
2894
2898
|
"}|": "one-many",
|
|
2895
2899
|
"|{": "one-many"
|
|
2896
|
-
},
|
|
2897
|
-
function
|
|
2900
|
+
}), Be = String.raw`\[\*\]|\[[^\]]+\]|\([^)]*\)|:[^:]+:|"[^"]+"|\(\)\s*"[^"]+"|\(\)\s*[\w.]+|[\w.$À--]+`, Ve = new RegExp(String.raw`^(${Be})\s*(?:"([^"]*)"\s*)?((?:<\||<<|\}o|\}\||\|o|\|\||[<*o#x+^}])?)([-.=~]+)(?:\[([^\]]*)\])?((?:up|down|left|right|u|d|l|r|le|ri|do)?)([-.=~]*)(?:\[([^\]]*)\])?((?:\|>|>>|o\{|\|\{|o\||\|\||[>*#+^{]|[ox](?=\s|\[|\(|"|:|$))?)\s*(?:"([^"]*)"\s*)?(${Be})\s*(?::\s*(.*))?$`, "u");
|
|
2901
|
+
function He(e, t) {
|
|
2898
2902
|
let n = new _(t ?? "TB", "rect"), r = /* @__PURE__ */ new Map(), i = [], a = [], o = null, s = null, c, u = "", d = 0, f = 0, p = () => i[i.length - 1], m = (e) => {
|
|
2899
2903
|
let t = e.trim(), r;
|
|
2900
2904
|
return t === "(*)" ? "start" : (r = /^\[(.+)\]$/.exec(t)) ? h(r[1], "component") : (r = /^\((.*)\)$/.exec(t)) ? h(r[1], "ellipse") : (r = /^:(.+):$/.exec(t)) ? h(r[1], "actor") : (r = /^\(\)\s*"?([^"]+)"?$/.exec(t)) ? h(r[1], "circle") : (t = t.replace(/^"(.*)"$/, "$1"), !n.has(t) && !n.isCluster(t) && n.node(t, { label: $(t) }, p()), t);
|
|
@@ -2962,7 +2966,7 @@ function Ve(e, t) {
|
|
|
2962
2966
|
fill: "none",
|
|
2963
2967
|
stroke: "none"
|
|
2964
2968
|
}), i.push(o), a.push(t);
|
|
2965
|
-
} else if ((e = /^(abstract\s+class|abstract|class|interface|enum|annotation|struct|protocol|entity|exception|metaclass|stereotype|object|map|json)\s+(?:"([^"]+)"\s+as\s+(\S+)|(\S+)\s+as\s+"([^"]+)"|([^\s{<#]+))(?:\s*<([^>]+)>)?\s*(<<.+?>>)?\s*(#\S+)?\s*(\{)?\s*(\})?$/.exec(t)) &&
|
|
2969
|
+
} else if ((e = /^(abstract\s+class|abstract|class|interface|enum|annotation|struct|protocol|entity|exception|metaclass|stereotype|object|map|json)\s+(?:"([^"]+)"\s+as\s+(\S+)|(\S+)\s+as\s+"([^"]+)"|([^\s{<#]+))(?:\s*<([^>]+)>)?\s*(<<.+?>>)?\s*(#\S+)?\s*(\{)?\s*(\})?$/.exec(t)) && Re.has(e[1].toLowerCase().replace(/\s+/, " "))) {
|
|
2966
2970
|
let t = e[1].toLowerCase().replace(/\s+/, " "), i = e[3] ?? e[4] ?? e[6], a = e[2] ?? e[5] ?? i, s = e[7] ? `<${e[7]}>` : "";
|
|
2967
2971
|
n.node(i, {
|
|
2968
2972
|
label: $(a) + s,
|
|
@@ -2989,7 +2993,7 @@ function Ve(e, t) {
|
|
|
2989
2993
|
/^["([:]/.test(e) ? [s, o] = [e, t] : [o, s] = [e, t];
|
|
2990
2994
|
}
|
|
2991
2995
|
s = s.replace(/^\((.*)\)$|^\[(.*)\]$|^:(.*):$/, "$1$2$3"), o = o.replace(/^\((.*)\)$|^\[(.*)\]$|^:(.*):$/, "$1$2$3").replace(/^"(.*)"$/, "$1");
|
|
2992
|
-
let u = t === "usecase" ? "ellipse" : t === "actor" ? "actor" :
|
|
2996
|
+
let u = t === "usecase" ? "ellipse" : t === "actor" ? "actor" : Le[t] ?? "rect", d = n.node(o, {
|
|
2993
2997
|
label: $(s) + (a ? `\n«${a[1]}»` : ""),
|
|
2994
2998
|
shape: u
|
|
2995
2999
|
}, p()), f = i ? l(i[1].slice(1)) ?? l(i[1]) : void 0;
|
|
@@ -3006,8 +3010,8 @@ function Ve(e, t) {
|
|
|
3006
3010
|
shape: r.shape
|
|
3007
3011
|
}, p()), n.g.nodes.splice(n.g.nodes.indexOf(r), 1);
|
|
3008
3012
|
}
|
|
3009
|
-
} else if (e =
|
|
3010
|
-
let [, t, r, i, a, , o, s, , c, l, u, d] = e, f = m(t), p = m(u), h = a + s, g = i ?
|
|
3013
|
+
} else if (e = Ve.exec(t)) {
|
|
3014
|
+
let [, t, r, i, a, , o, s, , c, l, u, d] = e, f = m(t), p = m(u), h = a + s, g = i ? ze[i] ?? "none" : "none", _ = c ? ze[c] ?? "none" : "none", v = r, y = l;
|
|
3011
3015
|
/^(up|u|left|l|le)$/i.test(o) && ([f, p] = [p, f], [g, _] = [_, g], [v, y] = [y, v]);
|
|
3012
3016
|
let b = {
|
|
3013
3017
|
from: f,
|
|
@@ -3055,7 +3059,7 @@ function Ve(e, t) {
|
|
|
3055
3059
|
}
|
|
3056
3060
|
return n.g;
|
|
3057
3061
|
}
|
|
3058
|
-
function
|
|
3062
|
+
function Ue(e, t) {
|
|
3059
3063
|
let n = new _(t ?? "TB", "round"), r = [], i = /* @__PURE__ */ new Map(), a = 0, o = null, s, c = () => r[r.length - 1], u = (e, t) => {
|
|
3060
3064
|
let r = e.trim().replace(/^"(.*)"$/, "$1");
|
|
3061
3065
|
if (r === "[*]") {
|
|
@@ -3142,7 +3146,7 @@ function He(e, t) {
|
|
|
3142
3146
|
}
|
|
3143
3147
|
return n.g;
|
|
3144
3148
|
}
|
|
3145
|
-
function
|
|
3149
|
+
function We(e) {
|
|
3146
3150
|
let t = new _("TB", "round"), n = [];
|
|
3147
3151
|
for (let t = 0; t < e.length; t++) {
|
|
3148
3152
|
let r = e[t];
|
|
@@ -3282,7 +3286,7 @@ function Ue(e) {
|
|
|
3282
3286
|
};
|
|
3283
3287
|
return u([], /^\u0000$/), t.g;
|
|
3284
3288
|
}
|
|
3285
|
-
function
|
|
3289
|
+
function Ge(e, t) {
|
|
3286
3290
|
let n = [], r;
|
|
3287
3291
|
for (let i = 0; i < e.length; i++) {
|
|
3288
3292
|
let a = e[i], o = /^([*+\-#]+)(_)?\s*(?:\[#[\w]+\])?\s*(.*)$/.exec(a);
|
|
@@ -3315,7 +3319,7 @@ function We(e, t) {
|
|
|
3315
3319
|
return i(r, !0), r;
|
|
3316
3320
|
}
|
|
3317
3321
|
// packages/diagram/src/dom.ts
|
|
3318
|
-
async function
|
|
3322
|
+
async function Ke(e, t = 2) {
|
|
3319
3323
|
let n = (t) => Number(RegExp(`<svg[^>]*\\s${t}="([\\d.]+)"`).exec(e)?.[1] ?? 0), r = n("width"), i = n("height");
|
|
3320
3324
|
if (!r || !i) throw Error("Not a picture with a size");
|
|
3321
3325
|
let a = new Image();
|
|
@@ -3326,36 +3330,36 @@ async function Ge(e, t = 2) {
|
|
|
3326
3330
|
if (!s) throw Error("No 2D canvas");
|
|
3327
3331
|
return s.scale(t, t), s.drawImage(a, 0, 0, r, i), new Promise((e, t) => o.toBlob((n) => n ? e(n) : t(/* @__PURE__ */ Error("PNG export failed")), "image/png"));
|
|
3328
3332
|
}
|
|
3329
|
-
function
|
|
3333
|
+
function qe(e, t) {
|
|
3330
3334
|
e.innerHTML = t.join("");
|
|
3331
3335
|
}
|
|
3332
3336
|
// packages/plantuml/src/index.ts
|
|
3333
|
-
var
|
|
3337
|
+
var Je = class extends Error {
|
|
3334
3338
|
constructor(e) {
|
|
3335
3339
|
super(e), this.name = "DiagramError";
|
|
3336
3340
|
}
|
|
3337
3341
|
};
|
|
3338
|
-
function
|
|
3342
|
+
function Ye(e) {
|
|
3339
3343
|
try {
|
|
3340
|
-
return
|
|
3344
|
+
return ke(e).map((e) => ({
|
|
3341
3345
|
svg: e.svg,
|
|
3342
3346
|
width: e.w,
|
|
3343
3347
|
height: e.h
|
|
3344
3348
|
}));
|
|
3345
3349
|
} catch (e) {
|
|
3346
|
-
throw new
|
|
3350
|
+
throw new Je(e.message);
|
|
3347
3351
|
}
|
|
3348
3352
|
}
|
|
3349
|
-
function
|
|
3350
|
-
return
|
|
3353
|
+
function Xe(e) {
|
|
3354
|
+
return Ye(e)[0];
|
|
3351
3355
|
}
|
|
3352
|
-
function
|
|
3353
|
-
let n =
|
|
3354
|
-
return
|
|
3356
|
+
function Ze(e, t) {
|
|
3357
|
+
let n = Ye(t);
|
|
3358
|
+
return qe(e, n.map((e) => e.svg)), n;
|
|
3355
3359
|
}
|
|
3356
|
-
function
|
|
3357
|
-
return
|
|
3360
|
+
function Qe(e, t = 2) {
|
|
3361
|
+
return Ke(e, t);
|
|
3358
3362
|
}
|
|
3359
|
-
export {
|
|
3363
|
+
export { Je as DiagramError, Xe as render, Ye as renderEach, Ze as renderTo, Qe as toPng };
|
|
3360
3364
|
|
|
3361
3365
|
//# sourceMappingURL=index.js.map
|