@p10node/markdown 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 +335 -321
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -129,14 +129,14 @@ function e(e, t, n, r) {
|
|
|
129
129
|
}
|
|
130
130
|
let L = new Float64Array(F), se = () => I.forEach((e) => e.forEach((e, t) => L[e] = t));
|
|
131
131
|
se();
|
|
132
|
-
let R = new Float64Array(F), z = new Float64Array(a),
|
|
132
|
+
let R = new Float64Array(F), z = new Float64Array(a), ce = () => {
|
|
133
133
|
for (let e = 0; e < a; e++) {
|
|
134
134
|
if (M[e] > N[e]) continue;
|
|
135
135
|
let t = 0;
|
|
136
136
|
for (let n = M[e]; n <= N[e]; n++) t += L[P[e][n]] / Math.max(1, I[n].length);
|
|
137
137
|
z[e] = t / (N[e] - M[e] + 1);
|
|
138
138
|
}
|
|
139
|
-
},
|
|
139
|
+
}, B = (e, t) => {
|
|
140
140
|
if (!a) return [...e].sort((e, t) => R[e] - R[t] || L[e] - L[t]);
|
|
141
141
|
let r = {
|
|
142
142
|
node: -1,
|
|
@@ -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(P[n.cluster][t]), l(n), c.push(ae[n.cluster][t]));
|
|
179
179
|
};
|
|
180
180
|
return l(r), c;
|
|
181
|
-
},
|
|
181
|
+
}, le = (e) => {
|
|
182
182
|
let t = 0;
|
|
183
183
|
for (let n = 0; n + 1 < e.length; n++) {
|
|
184
184
|
let r = [];
|
|
@@ -193,40 +193,40 @@ function e(e, t, n, r) {
|
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
return t;
|
|
196
|
-
},
|
|
196
|
+
}, V = (e, t) => {
|
|
197
197
|
let n = 0, r = 0;
|
|
198
198
|
for (let [i, a] of t[e]) n += L[i] * a, r += a;
|
|
199
199
|
return r ? n / r : L[e];
|
|
200
200
|
};
|
|
201
201
|
for (let e of I) for (let t of e) R[t] = L[t];
|
|
202
|
-
|
|
203
|
-
let ue = I.map((e) => [...e]),
|
|
204
|
-
for (let e = 0; e < 24 &&
|
|
205
|
-
|
|
202
|
+
ce(), I = I.map((e, t) => B(e, t)), se();
|
|
203
|
+
let ue = I.map((e) => [...e]), H = le(I);
|
|
204
|
+
for (let e = 0; e < 24 && H > 0; e++) {
|
|
205
|
+
ce();
|
|
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 ? k : A;
|
|
209
|
-
for (let e of I[n]) R[e] =
|
|
210
|
-
I[n] =
|
|
209
|
+
for (let e of I[n]) R[e] = V(e, r);
|
|
210
|
+
I[n] = B(I[n], n), I[n].forEach((e, t) => L[e] = t);
|
|
211
211
|
}
|
|
212
|
-
let n =
|
|
213
|
-
n <
|
|
212
|
+
let n = le(I);
|
|
213
|
+
n < H && (H = n, ue = I.map((e) => [...e]));
|
|
214
214
|
}
|
|
215
215
|
I = ue, se();
|
|
216
|
-
let
|
|
217
|
-
n.forEach((e, t) => e.parent >= 0 &&
|
|
218
|
-
let
|
|
219
|
-
for (let e = 0; e < a; e++) M[e] > N[e] || (
|
|
220
|
-
let
|
|
221
|
-
for (let e = 0; e <= y; e++)
|
|
222
|
-
let
|
|
216
|
+
let de = I.map((e) => e.reduce((e, t) => Math.max(e, C[t]), 0)), fe = Array.from({ length: a }, () => []);
|
|
217
|
+
n.forEach((e, t) => e.parent >= 0 && fe[e.parent].push(t));
|
|
218
|
+
let pe = (e) => n[e].pad[2] + Math.max(0, ...fe[e].filter((t) => M[t] === M[e]).map(pe)), U = (e) => n[e].pad[3] + Math.max(0, ...fe[e].filter((t) => N[t] === N[e]).map(U)), W = Array(y + 1).fill(0), me = Array(y + 1).fill(0);
|
|
219
|
+
for (let e = 0; e < a; e++) M[e] > N[e] || (W[M[e]] = Math.max(W[M[e]], pe(e)), me[N[e]] = Math.max(me[N[e]], U(e)));
|
|
220
|
+
let he = [];
|
|
221
|
+
for (let e = 0; e <= y; e++) he[e] = e === 0 ? de[0] / 2 + W[0] : he[e - 1] + de[e - 1] / 2 + me[e - 1] + r.ranksep + W[e] + de[e] / 2;
|
|
222
|
+
let ge = he[y] + de[y] / 2 + me[y], G = (e) => w[e] === 2 || w[e] === 3 ? 0 : S[e] / 2, _e = (e, t) => {
|
|
223
223
|
let i = ee[e], a = w[e], o = w[t];
|
|
224
|
-
return a === 2 && (i += n[D[e]].pad[0]), a === 3 && (i += r.nodesep / 2), o === 3 && (i += n[D[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 I) for (let t = 1; t < e.length; t++)
|
|
227
|
-
let
|
|
224
|
+
return a === 2 && (i += n[D[e]].pad[0]), a === 3 && (i += r.nodesep / 2), o === 3 && (i += n[D[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), G(e) + G(t) + i;
|
|
225
|
+
}, K = new Float64Array(F);
|
|
226
|
+
for (let e of I) for (let t = 1; t < e.length; t++) K[e[t]] = K[e[t - 1]] + _e(e[t - 1], e[t]);
|
|
227
|
+
let ve = (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] + _e(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++) K[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 += K[t] * n, i += n;
|
|
252
252
|
};
|
|
253
|
-
(t || n) && s(k[e]), (t || !n) && s(A[e]), s(oe[e]), a.push(i ? r / i :
|
|
253
|
+
(t || n) && s(k[e]), (t || !n) && s(A[e]), s(oe[e]), a.push(i ? r / i : K[e]), o.push(i || .01);
|
|
254
254
|
}
|
|
255
|
-
|
|
255
|
+
ve(i, a, o);
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
|
-
let
|
|
258
|
+
let q = F, ye = (e) => w[e] === 2 ? q + 2 * D[e] : w[e] === 3 ? q + 2 * D[e] + 1 : e;
|
|
259
259
|
if (a) {
|
|
260
260
|
let e = F + 2 * a, t = new Float64Array(e);
|
|
261
|
-
for (let e = 0; e < F; e++) t[e] =
|
|
262
|
-
for (let e = 0; e < a; e++) t[
|
|
263
|
-
for (let e = 0; e < F; e++) w[e] === 2 && (t[ye(e)] = Math.min(t[ye(e)],
|
|
261
|
+
for (let e = 0; e < F; e++) t[e] = K[e];
|
|
262
|
+
for (let e = 0; e < a; e++) t[q + 2 * e] = Infinity, t[q + 2 * e + 1] = -Infinity;
|
|
263
|
+
for (let e = 0; e < F; e++) w[e] === 2 && (t[ye(e)] = Math.min(t[ye(e)], K[e])), w[e] === 3 && (t[ye(e)] = Math.max(t[ye(e)], K[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 I) for (let t = 1; t < e.length; t++) o(ye(e[t - 1]), ye(e[t]),
|
|
268
|
-
for (let e = 0; e < a; e++) M[e] <= N[e] && o(
|
|
267
|
+
for (let e of I) for (let t = 1; t < e.length; t++) o(ye(e[t - 1]), ye(e[t]), _e(e[t - 1], e[t]));
|
|
268
|
+
for (let e = 0; e < a; e++) M[e] <= N[e] && o(q + 2 * e, q + 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 < F; e++)
|
|
277
|
+
if (c === e) for (let e = 0; e < F; e++) K[e] = l[ye(e)];
|
|
278
278
|
}
|
|
279
|
-
let
|
|
280
|
-
for (let e = 0; e < F; e++)
|
|
281
|
-
Number.isFinite(
|
|
282
|
-
for (let e = 0; e < F; e++)
|
|
279
|
+
let be = Infinity, J = -Infinity;
|
|
280
|
+
for (let e = 0; e < F; e++) be = Math.min(be, K[e] - G(e)), J = Math.max(J, K[e] + G(e) + ee[e]);
|
|
281
|
+
Number.isFinite(be) || (be = J = 0);
|
|
282
|
+
for (let e = 0; e < F; e++) K[e] -= be;
|
|
283
283
|
let Y = (e) => ({
|
|
284
|
-
x:
|
|
285
|
-
y:
|
|
286
|
-
}),
|
|
284
|
+
x: K[e],
|
|
285
|
+
y: he[E[e]]
|
|
286
|
+
}), xe = /* @__PURE__ */ new Map();
|
|
287
287
|
{
|
|
288
288
|
let t = /* @__PURE__ */ new Map(), n = (e, n, r) => {
|
|
289
289
|
let i = t.get(e);
|
|
@@ -294,17 +294,17 @@ function e(e, t, n, r) {
|
|
|
294
294
|
};
|
|
295
295
|
f.forEach((t, r) => {
|
|
296
296
|
let i = j[r];
|
|
297
|
-
i && !ie[r] && (e[i[0]]?.spread && n(`${i[0]}:b`, r,
|
|
297
|
+
i && !ie[r] && (e[i[0]]?.spread && n(`${i[0]}:b`, r, K[i[1]]), e[i[i.length - 1]]?.spread && n(`${i[i.length - 1]}:t`, r, K[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) => xe.set(`${e}:${i.i}`, K[t] + (a - (n.length - 1) / 2) * r));
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
|
-
let
|
|
307
|
+
let X = f.map((e, n) => {
|
|
308
308
|
if (e.v === e.w) return null;
|
|
309
309
|
if (ie[n]) {
|
|
310
310
|
let r = Y(e.v), i = Y(e.w), a = Math.sign(i.x - r.x) || 1, o = {
|
|
@@ -330,11 +330,11 @@ function e(e, t, n, r) {
|
|
|
330
330
|
if (!r) return null;
|
|
331
331
|
let i = [], a = [], o = Y(r[0]);
|
|
332
332
|
i.push({
|
|
333
|
-
x:
|
|
333
|
+
x: xe.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 = Y(r[e]), n =
|
|
337
|
+
let t = Y(r[e]), n = de[E[r[e]]] / 2;
|
|
338
338
|
n > .5 ? (i.push({
|
|
339
339
|
x: t.x,
|
|
340
340
|
y: t.y - n
|
|
@@ -345,7 +345,7 @@ function e(e, t, n, r) {
|
|
|
345
345
|
}
|
|
346
346
|
let s = Y(r[r.length - 1]);
|
|
347
347
|
i.push({
|
|
348
|
-
x:
|
|
348
|
+
x: xe.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);
|
|
@@ -406,8 +406,8 @@ function e(e, t, n, r) {
|
|
|
406
406
|
}), Se = n.map((e, t) => {
|
|
407
407
|
if (M[t] > N[t]) return null;
|
|
408
408
|
let n = Infinity, r = -Infinity;
|
|
409
|
-
for (let e = M[t]; e <= N[t]; e++) n = Math.min(n,
|
|
410
|
-
let i =
|
|
409
|
+
for (let e = M[t]; e <= N[t]; e++) n = Math.min(n, K[P[t][e]]), r = Math.max(r, K[ae[t][e]]);
|
|
410
|
+
let i = he[M[t]] - de[M[t]] / 2 - pe(t), a = he[N[t]] + de[N[t]] / 2 + U(t);
|
|
411
411
|
return {
|
|
412
412
|
x: n,
|
|
413
413
|
y: i,
|
|
@@ -417,10 +417,10 @@ function e(e, t, n, r) {
|
|
|
417
417
|
});
|
|
418
418
|
return {
|
|
419
419
|
nodes: Array.from({ length: i }, (e, t) => Y(t)),
|
|
420
|
-
edges:
|
|
420
|
+
edges: X,
|
|
421
421
|
clusters: Se,
|
|
422
|
-
w:
|
|
423
|
-
h:
|
|
422
|
+
w: J - be,
|
|
423
|
+
h: ge
|
|
424
424
|
};
|
|
425
425
|
}
|
|
426
426
|
// src/core/diagram/svg.ts
|
|
@@ -1304,12 +1304,12 @@ function P(t) {
|
|
|
1304
1304
|
x: t.x + ie,
|
|
1305
1305
|
y: t.y + ie + P
|
|
1306
1306
|
};
|
|
1307
|
-
}, z = (o ? L : se) + 32,
|
|
1307
|
+
}, z = (o ? L : se) + 32, ce = (o ? se : L) + 32 + P, B = (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
|
+
}, le = t.clusters.map((e, t) => t).sort((e, t) => B(e) - B(t)), V = t.clusters.map(() => null), ue = [];
|
|
1312
|
+
for (let e of le) {
|
|
1313
1313
|
let r = k.clusters[e];
|
|
1314
1314
|
if (!r) continue;
|
|
1315
1315
|
let a = t.clusters[e], o = R({
|
|
@@ -1319,7 +1319,7 @@ function P(t) {
|
|
|
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 ?? {};
|
|
1322
|
-
if (
|
|
1322
|
+
if (V[e] = {
|
|
1323
1323
|
x: l,
|
|
1324
1324
|
y: d,
|
|
1325
1325
|
w: f,
|
|
@@ -1340,7 +1340,7 @@ function P(t) {
|
|
|
1340
1340
|
});
|
|
1341
1341
|
}
|
|
1342
1342
|
}
|
|
1343
|
-
let
|
|
1343
|
+
let H = [];
|
|
1344
1344
|
v.forEach(({ e, v: t }, n) => {
|
|
1345
1345
|
if (e.line === "hidden") return;
|
|
1346
1346
|
let r = re(e), i = {
|
|
@@ -1398,7 +1398,7 @@ function P(t) {
|
|
|
1398
1398
|
p: e.p
|
|
1399
1399
|
}))]), i), ne(s, y, p, x, r), e.label) {
|
|
1400
1400
|
let t = a(w(e.label), b);
|
|
1401
|
-
|
|
1401
|
+
H.push({
|
|
1402
1402
|
p: o ? {
|
|
1403
1403
|
x: h.x + t.w / 2 + 4,
|
|
1404
1404
|
y: h.y
|
|
@@ -1421,7 +1421,7 @@ function P(t) {
|
|
|
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 = F(l.start, l.segs);
|
|
1424
|
-
u >= 0 &&
|
|
1424
|
+
u >= 0 && V[u] && (e = I(e, V[u], !0)), d >= 0 && V[d] && (e = I(e, V[d], !1)), e.length > 1 && (l = {
|
|
1425
1425
|
start: e[0],
|
|
1426
1426
|
segs: e.slice(1).map((e) => ({
|
|
1427
1427
|
c: "L",
|
|
@@ -1452,14 +1452,14 @@ function P(t) {
|
|
|
1452
1452
|
p: e.p
|
|
1453
1453
|
}))]), i), p !== "none" && ne(s, p, _, y, r), h !== "none" && ne(s, h, C, S, r), e.label) {
|
|
1454
1454
|
let t = l.label ?? ae(l.start, _);
|
|
1455
|
-
|
|
1455
|
+
H.push({
|
|
1456
1456
|
p: t,
|
|
1457
1457
|
text: w(e.label)
|
|
1458
1458
|
});
|
|
1459
1459
|
}
|
|
1460
1460
|
let ee = (e, t, n) => {
|
|
1461
1461
|
let r = a(w(n), b), i = -t.y, o = t.x, s = Math.abs(i) * (r.w / 2 + 5) + Math.abs(o) * (r.h / 2 + 3);
|
|
1462
|
-
|
|
1462
|
+
H.push({
|
|
1463
1463
|
p: {
|
|
1464
1464
|
x: e.x - t.x * (16 + r.h / 2) + i * s,
|
|
1465
1465
|
y: e.y - t.y * (14 + r.h / 2) + o * s
|
|
@@ -1484,7 +1484,7 @@ function P(t) {
|
|
|
1484
1484
|
let n = R(k.nodes[t]);
|
|
1485
1485
|
O(s, e, g[t], n.x, n.y);
|
|
1486
1486
|
});
|
|
1487
|
-
for (let e of
|
|
1487
|
+
for (let e of H) {
|
|
1488
1488
|
let t = a(e.text, b);
|
|
1489
1489
|
e.plain || s.rect(e.p.x - t.w / 2 - 3, e.p.y - t.h / 2 - 1, t.w + 6, t.h + 2, {
|
|
1490
1490
|
fill: u.label,
|
|
@@ -1500,9 +1500,9 @@ function P(t) {
|
|
|
1500
1500
|
size: 16,
|
|
1501
1501
|
bold: !0
|
|
1502
1502
|
})), {
|
|
1503
|
-
svg: s.toString(z,
|
|
1503
|
+
svg: s.toString(z, ce),
|
|
1504
1504
|
w: Math.ceil(z),
|
|
1505
|
-
h: Math.ceil(
|
|
1505
|
+
h: Math.ceil(ce)
|
|
1506
1506
|
};
|
|
1507
1507
|
}
|
|
1508
1508
|
var ae = (e, t) => ({
|
|
@@ -1549,8 +1549,12 @@ function I(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 L(e) {
|
|
1554
|
+
return Object.assign(Object.create(null), e);
|
|
1555
|
+
}
|
|
1556
|
+
// src/core/diagram/dot.ts
|
|
1557
|
+
function se(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 L(e) {
|
|
|
1614
1618
|
}
|
|
1615
1619
|
return t;
|
|
1616
1620
|
}
|
|
1617
|
-
var
|
|
1621
|
+
var R = L({
|
|
1618
1622
|
box: "rect",
|
|
1619
1623
|
rect: "rect",
|
|
1620
1624
|
rectangle: "rect",
|
|
@@ -1658,7 +1662,7 @@ var se = {
|
|
|
1658
1662
|
record: "rect",
|
|
1659
1663
|
mrecord: "round",
|
|
1660
1664
|
underlinebox: "rect"
|
|
1661
|
-
},
|
|
1665
|
+
}), z = L({
|
|
1662
1666
|
normal: "arrow",
|
|
1663
1667
|
inv: "arrow",
|
|
1664
1668
|
empty: "triangle",
|
|
@@ -1682,11 +1686,11 @@ var se = {
|
|
|
1682
1686
|
tee: "one",
|
|
1683
1687
|
curve: "open",
|
|
1684
1688
|
icurve: "open"
|
|
1685
|
-
};
|
|
1686
|
-
function
|
|
1689
|
+
});
|
|
1690
|
+
function ce(e, t) {
|
|
1687
1691
|
if (!e) return t;
|
|
1688
1692
|
let n = e.toLowerCase().replace(/^[lr](?=[a-z])/, "");
|
|
1689
|
-
return
|
|
1693
|
+
return z[n] ?? z[n.replace(/^o/, "")] ?? t;
|
|
1690
1694
|
}
|
|
1691
1695
|
function B(e) {
|
|
1692
1696
|
if (!e) return;
|
|
@@ -1713,17 +1717,17 @@ function B(e) {
|
|
|
1713
1717
|
}
|
|
1714
1718
|
return l(/^[a-z]+\d+$/.test(r) ? r.replace(/\d+$/, "") : r);
|
|
1715
1719
|
}
|
|
1716
|
-
function
|
|
1720
|
+
function le(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 V(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 ue(e, t) {
|
|
1723
1727
|
return V(e, t).replace(/<[^>]*>/g, "").split(/[|{}]/).map((e) => e.trim()).filter(Boolean);
|
|
1724
1728
|
}
|
|
1725
|
-
function
|
|
1726
|
-
let t =
|
|
1729
|
+
function H(e) {
|
|
1730
|
+
let t = se(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,11 +1836,11 @@ function ue(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("<") ?
|
|
1839
|
+
l.g.dir = C, m.label && (l.g.title = m.label.startsWith("<") ? le(m.label.slice(1, -1)) : V(m.label, "", c));
|
|
1836
1840
|
for (let e of l.g.nodes) de(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("<") ? le(t.label.slice(1, -1)) : V(t.label, "", e.id) : "";
|
|
1840
1844
|
let n = {}, r = (t.style ?? "").toLowerCase();
|
|
1841
1845
|
r.includes("filled") ? n.fill = B(t.fillcolor ?? t.color ?? t.bgcolor) ?? "#d3d3d3" : t.bgcolor && (n.fill = B(t.bgcolor)), (t.color || t.pencolor) && (n.stroke = B(t.pencolor ?? t.color)), r.includes("dashed") && (n.dash = "6 4"), r.includes("dotted") && (n.dash = "2 3"), t.fontcolor && (n.color = B(t.fontcolor)), r.includes("invis") && (n.stroke = n.fill = "none"), e.style = n;
|
|
1842
1846
|
}
|
|
@@ -1848,12 +1852,12 @@ function ue(e) {
|
|
|
1848
1852
|
}
|
|
1849
1853
|
function de(e, t) {
|
|
1850
1854
|
let n = (t.shape ?? "ellipse").toLowerCase();
|
|
1851
|
-
e.shape =
|
|
1855
|
+
e.shape = R[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 = le(r.slice(1, -1));
|
|
1855
1859
|
else if (n === "record" || n === "mrecord") {
|
|
1856
|
-
let t =
|
|
1860
|
+
let t = ue(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
|
|
@@ -1865,20 +1869,20 @@ function de(e, t) {
|
|
|
1865
1869
|
a.includes("filled") || t.fillcolor ? i.fill = B(t.fillcolor ?? t.color) ?? "#d3d3d3" : e.shape !== "point" && (i.fill = "#ffffff"), i.stroke = t.color ? B(t.color) : "#000000", t.fontcolor && (i.color = B(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
1871
|
function fe(e, t, n) {
|
|
1868
|
-
let r = (t.style ?? "").toLowerCase(), i = (t.dir ?? (n ? "forward" : "none")).toLowerCase(), a =
|
|
1872
|
+
let r = (t.style ?? "").toLowerCase(), i = (t.dir ?? (n ? "forward" : "none")).toLowerCase(), a = ce(t.arrowhead, "arrow"), o = ce(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(">") ? le(s.slice(1, -1)) : V(s, "")), t.headlabel && (e.headLabel = V(t.headlabel, "")), t.taillabel && (e.tailLabel = V(t.taillabel, "")), e.line = r.includes("invis") ? "hidden" : r.includes("dashed") ? "dashed" : r.includes("dotted") ? "dotted" : r.includes("bold") ? "thick" : "solid", e.color = B(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
|
function pe(e) {
|
|
1874
|
-
return
|
|
1878
|
+
return H(e).map(P);
|
|
1875
1879
|
}
|
|
1876
1880
|
// src/core/diagram/charts.ts
|
|
1877
|
-
var
|
|
1881
|
+
var U = 16, W = (e) => Math.round(e * 100) / 100;
|
|
1878
1882
|
function me(e) {
|
|
1879
1883
|
let t = e.slices.filter((e) => e.value > 0 && Number.isFinite(e.value));
|
|
1880
1884
|
if (!t.length) throw Error("The pie chart has no values");
|
|
1881
|
-
let n = t.reduce((e, t) => e + t.value, 0), i = new p(), a =
|
|
1885
|
+
let n = t.reduce((e, t) => e + t.value, 0), i = new p(), a = U + (e.title ? 36 : 0) + 130, o = (e) => u.series[e % u.series.length], s = -Math.PI / 2, c = (e, t) => ({
|
|
1882
1886
|
x: 146 + Math.cos(e) * t,
|
|
1883
1887
|
y: a + Math.sin(e) * t
|
|
1884
1888
|
});
|
|
@@ -1891,7 +1895,7 @@ function me(e) {
|
|
|
1891
1895
|
});
|
|
1892
1896
|
else {
|
|
1893
1897
|
let e = c(s, 130), n = c(l, 130);
|
|
1894
|
-
i.path(`M${
|
|
1898
|
+
i.path(`M${W(146)} ${W(a)} L${W(e.x)} ${W(e.y)} A130 130 0 ${+(r > .5)} 1 ${W(n.x)} ${W(n.y)} Z`, {
|
|
1895
1899
|
fill: o(t),
|
|
1896
1900
|
stroke: "#ffffff",
|
|
1897
1901
|
sw: 2
|
|
@@ -1913,7 +1917,7 @@ function me(e) {
|
|
|
1913
1917
|
let a = e.showData ? `${t.label} [${he(t.value)}]` : t.label;
|
|
1914
1918
|
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));
|
|
1915
1919
|
});
|
|
1916
|
-
let f = 330 + d +
|
|
1920
|
+
let f = 330 + d + U, m = Math.max(a + 130, l + t.length * 24) + U;
|
|
1917
1921
|
return e.title && (f = Math.max(f, r(e.title, 16, !0) + 32), i.text(f / 2, 28, e.title, {
|
|
1918
1922
|
anchor: "middle",
|
|
1919
1923
|
size: 16,
|
|
@@ -1924,15 +1928,15 @@ function me(e) {
|
|
|
1924
1928
|
h: Math.ceil(m)
|
|
1925
1929
|
};
|
|
1926
1930
|
}
|
|
1927
|
-
var he = (e) => String(Number.isInteger(e) ? e : Math.round(e * 100) / 100),
|
|
1928
|
-
function
|
|
1931
|
+
var he = (e) => String(Number.isInteger(e) ? e : Math.round(e * 100) / 100), ge = 36e5, G = 24 * ge, _e = (e) => String(e).padStart(2, "0");
|
|
1932
|
+
function K(e) {
|
|
1929
1933
|
let t = e.sections.flatMap((e) => e.tasks);
|
|
1930
1934
|
if (!t.length) throw Error("The Gantt chart has no tasks");
|
|
1931
|
-
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,
|
|
1932
|
-
|
|
1933
|
-
3 *
|
|
1934
|
-
6 *
|
|
1935
|
-
12 *
|
|
1935
|
+
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, ge), 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 = U + s, m = U + d, h = (e) => f + (e - n) * l, g = new p(), _ = m + t.length * 28 + 24 + U + 6, v = [
|
|
1936
|
+
ge,
|
|
1937
|
+
3 * ge,
|
|
1938
|
+
6 * ge,
|
|
1939
|
+
12 * ge,
|
|
1936
1940
|
G,
|
|
1937
1941
|
2 * G,
|
|
1938
1942
|
7 * G,
|
|
@@ -1942,7 +1946,7 @@ function ge(e) {
|
|
|
1942
1946
|
365 * G
|
|
1943
1947
|
].find((e) => a / e <= 12) ?? 365 * G, y = Math.ceil(n / v) * v, b = (e) => {
|
|
1944
1948
|
let t = new Date(e);
|
|
1945
|
-
return v < G ? `${
|
|
1949
|
+
return v < G ? `${_e(t.getUTCHours())}:${_e(t.getUTCMinutes())}` : v >= 365 * G ? String(t.getUTCFullYear()) : v >= 30 * G ? `${t.getUTCFullYear()}-${_e(t.getUTCMonth() + 1)}` : `${t.getUTCFullYear()}-${_e(t.getUTCMonth() + 1)}-${_e(t.getUTCDate())}`;
|
|
1946
1950
|
}, x = m + t.length * 28 + 4;
|
|
1947
1951
|
for (let e = y; e <= i; e += v) {
|
|
1948
1952
|
let t = h(e);
|
|
@@ -1958,7 +1962,7 @@ function ge(e) {
|
|
|
1958
1962
|
let S = 0;
|
|
1959
1963
|
e.sections.forEach((e, t) => {
|
|
1960
1964
|
let n = u.series[t % u.series.length], i = m + S * 28;
|
|
1961
|
-
t % 2 == 0 && g.rect(
|
|
1965
|
+
t % 2 == 0 && g.rect(U, i, s + c, e.tasks.length * 28, { fill: "#f6f7fa" }), e.name && g.text(22, i + e.tasks.length * 28 / 2, o([e.name], s - 12, 13, !0), {
|
|
1962
1966
|
size: 13,
|
|
1963
1967
|
bold: !0
|
|
1964
1968
|
});
|
|
@@ -1992,8 +1996,8 @@ function ge(e) {
|
|
|
1992
1996
|
S++;
|
|
1993
1997
|
}
|
|
1994
1998
|
});
|
|
1995
|
-
let C = f + c +
|
|
1996
|
-
for (let e of t) C = Math.max(C, h(e.end) + 12 + r(e.name, 12) +
|
|
1999
|
+
let C = f + c + U;
|
|
2000
|
+
for (let e of t) C = Math.max(C, h(e.end) + 12 + r(e.name, 12) + U);
|
|
1997
2001
|
return e.title && (C = Math.max(C, r(e.title, 16, !0) + 32), g.text(C / 2, 28, e.title, {
|
|
1998
2002
|
anchor: "middle",
|
|
1999
2003
|
size: 16,
|
|
@@ -2004,8 +2008,8 @@ function ge(e) {
|
|
|
2004
2008
|
h: Math.ceil(_)
|
|
2005
2009
|
};
|
|
2006
2010
|
}
|
|
2007
|
-
var
|
|
2008
|
-
function
|
|
2011
|
+
var ve = 44, q = 12;
|
|
2012
|
+
function ye(e, t) {
|
|
2009
2013
|
let n = new p(), i = (e, t) => {
|
|
2010
2014
|
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;
|
|
2011
2015
|
return {
|
|
@@ -2015,7 +2019,7 @@ function ve(e, t) {
|
|
|
2015
2019
|
fs: n
|
|
2016
2020
|
};
|
|
2017
2021
|
}, s = (e, t, n) => {
|
|
2018
|
-
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) *
|
|
2022
|
+
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) * q);
|
|
2019
2023
|
return {
|
|
2020
2024
|
n: e,
|
|
2021
2025
|
w: r.w,
|
|
@@ -2036,19 +2040,19 @@ function ve(e, t) {
|
|
|
2036
2040
|
} else l = c.kids;
|
|
2037
2041
|
let f = (e, t, n, r) => {
|
|
2038
2042
|
e.x = t;
|
|
2039
|
-
let i = n + (e.span - (e.kids.reduce((e, t) => e + t.span, 0) + Math.max(0, e.kids.length - 1) *
|
|
2040
|
-
for (let n of e.kids) f(n, t + r * (e.w / 2 +
|
|
2043
|
+
let i = n + (e.span - (e.kids.reduce((e, t) => e + t.span, 0) + Math.max(0, e.kids.length - 1) * q)) / 2;
|
|
2044
|
+
for (let n of e.kids) f(n, t + r * (e.w / 2 + ve + n.w / 2), i, r), i += n.span + q;
|
|
2041
2045
|
e.y = e.kids.length ? (e.kids[0].y + e.kids[e.kids.length - 1].y) / 2 : n + e.span / 2;
|
|
2042
|
-
}, h = (e) => e.reduce((e, t) => e + t.span, 0) + Math.max(0, e.length - 1) *
|
|
2043
|
-
for (let e of l) f(e, c.w / 2 +
|
|
2046
|
+
}, h = (e) => e.reduce((e, t) => e + t.span, 0) + Math.max(0, e.length - 1) * q, g = h(l), _ = h(d), v = Math.max(c.h, g, _), y = (v - g) / 2;
|
|
2047
|
+
for (let e of l) f(e, c.w / 2 + ve + e.w / 2, y, 1), y += e.span + q;
|
|
2044
2048
|
y = (v - _) / 2;
|
|
2045
|
-
for (let e of d) f(e, -(c.w / 2 +
|
|
2049
|
+
for (let e of d) f(e, -(c.w / 2 + ve + e.w / 2), y, -1), y += e.span + q;
|
|
2046
2050
|
c.x = 0, c.y = v / 2;
|
|
2047
2051
|
let b = Infinity, x = -Infinity, S = Infinity, C = -Infinity, w = [], T = (e) => {
|
|
2048
2052
|
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);
|
|
2049
2053
|
};
|
|
2050
2054
|
T(c);
|
|
2051
|
-
let E = t ? 36 : 0, ee =
|
|
2055
|
+
let E = t ? 36 : 0, ee = U - b, D = U + E - S, O = (e) => ({
|
|
2052
2056
|
x: e.x + ee,
|
|
2053
2057
|
y: e.y + D
|
|
2054
2058
|
});
|
|
@@ -2082,7 +2086,7 @@ function ve(e, t) {
|
|
|
2082
2086
|
});
|
|
2083
2087
|
}
|
|
2084
2088
|
for (let e of w) {
|
|
2085
|
-
let t = O(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 :
|
|
2089
|
+
let t = O(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 : be(e.color), c = e.depth <= 1 ? "#ffffff" : u.ink;
|
|
2086
2090
|
if (o === "none") n.line(i, a + e.h, i + e.w, a + e.h, {
|
|
2087
2091
|
stroke: e.color,
|
|
2088
2092
|
sw: 1.5
|
|
@@ -2134,7 +2138,7 @@ function ve(e, t) {
|
|
|
2134
2138
|
h: Math.ceil(A)
|
|
2135
2139
|
};
|
|
2136
2140
|
}
|
|
2137
|
-
function
|
|
2141
|
+
function be(e) {
|
|
2138
2142
|
let t = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);
|
|
2139
2143
|
return t ? "#" + [
|
|
2140
2144
|
t[1],
|
|
@@ -2143,7 +2147,7 @@ function ye(e) {
|
|
|
2143
2147
|
].map((e) => Math.round(parseInt(e, 16) * .22 + 198.9).toString(16).padStart(2, "0")).join("") : "#f1f3f7";
|
|
2144
2148
|
}
|
|
2145
2149
|
// src/core/diagram/sequence.ts
|
|
2146
|
-
var J = (e) => Math.round(e * 100) / 100,
|
|
2150
|
+
var J = (e) => Math.round(e * 100) / 100, Y = class {
|
|
2147
2151
|
s = {
|
|
2148
2152
|
participants: [],
|
|
2149
2153
|
events: []
|
|
@@ -2165,9 +2169,9 @@ var J = (e) => Math.round(e * 100) / 100, be = class {
|
|
|
2165
2169
|
push(e) {
|
|
2166
2170
|
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);
|
|
2167
2171
|
}
|
|
2168
|
-
},
|
|
2169
|
-
function
|
|
2170
|
-
let t =
|
|
2172
|
+
}, xe = 14, X = 13, Se = i(X), Ce = 16, we = (e) => e ? e.split("\n") : [];
|
|
2173
|
+
function Te(e) {
|
|
2174
|
+
let t = we(e.label), n = a(t, xe);
|
|
2171
2175
|
switch (e.kind) {
|
|
2172
2176
|
case "actor": return {
|
|
2173
2177
|
w: Math.max(44, n.w + 8),
|
|
@@ -2193,7 +2197,7 @@ function we(e) {
|
|
|
2193
2197
|
};
|
|
2194
2198
|
}
|
|
2195
2199
|
}
|
|
2196
|
-
function
|
|
2200
|
+
function Ee(e, t, n, r, a) {
|
|
2197
2201
|
let o = t.fill ?? u.fill, s = {
|
|
2198
2202
|
fill: o,
|
|
2199
2203
|
stroke: u.stroke,
|
|
@@ -2202,7 +2206,7 @@ function Te(e, t, n, r, a) {
|
|
|
2202
2206
|
fill: "none",
|
|
2203
2207
|
stroke: u.dark,
|
|
2204
2208
|
sw: 1.5
|
|
2205
|
-
}, l = (t) => e.text(r, t + n.text.length * i(
|
|
2209
|
+
}, l = (t) => e.text(r, t + n.text.length * i(xe) / 2, n.text, { anchor: "middle" }), d = r - n.w / 2;
|
|
2206
2210
|
switch (t.kind) {
|
|
2207
2211
|
case "actor":
|
|
2208
2212
|
e.circle(r, a + 8, 7, {
|
|
@@ -2241,7 +2245,7 @@ function Te(e, t, n, r, a) {
|
|
|
2241
2245
|
}
|
|
2242
2246
|
e.text(r, a + n.h / 2, n.text, { anchor: "middle" });
|
|
2243
2247
|
}
|
|
2244
|
-
function
|
|
2248
|
+
function De(e, t, n, r, i) {
|
|
2245
2249
|
let a = u.line;
|
|
2246
2250
|
switch (t) {
|
|
2247
2251
|
case "filled":
|
|
@@ -2280,11 +2284,11 @@ function Ee(e, t, n, r, i) {
|
|
|
2280
2284
|
});
|
|
2281
2285
|
}
|
|
2282
2286
|
}
|
|
2283
|
-
function
|
|
2287
|
+
function Oe(e) {
|
|
2284
2288
|
let t = e.participants;
|
|
2285
2289
|
if (!t.length) throw new _("The sequence diagram has no participants");
|
|
2286
2290
|
if (t.length > 300 || e.events.length > 8e3) throw new _("The sequence diagram is too large to draw");
|
|
2287
|
-
let n = new Map(t.map((e, t) => [e.id, t])), i = t.map(
|
|
2291
|
+
let n = new Map(t.map((e, t) => [e.id, t])), i = t.map(Te), o = t.length, s = Array(o).fill(0);
|
|
2288
2292
|
for (let e = 1; e < o; e++) s[e] = (i[e - 1].w + i[e].w) / 2 + 28;
|
|
2289
2293
|
let c = 0, l = 0, d = (e, t, n) => {
|
|
2290
2294
|
if (e > t && ([e, t] = [t, e]), e === t) return;
|
|
@@ -2296,10 +2300,10 @@ function De(e) {
|
|
|
2296
2300
|
}, f = (t) => e.autonumber ? r(String(t), 10) + 14 : 0, m = 0;
|
|
2297
2301
|
for (let t of e.events) if (t.t === "msg") {
|
|
2298
2302
|
m++;
|
|
2299
|
-
let e = n.get(t.from), a = n.get(t.to), s = Math.max(0, ...
|
|
2303
|
+
let e = n.get(t.from), a = n.get(t.to), s = Math.max(0, ...we(t.text).map((e) => r(e, X))) + f(m);
|
|
2300
2304
|
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);
|
|
2301
2305
|
} else if (t.t === "note") {
|
|
2302
|
-
let e = a(
|
|
2306
|
+
let e = a(we(t.text), X).w + 20, r = t.who.map((e) => n.get(e)), s = Math.min(...r), u = Math.max(...r);
|
|
2303
2307
|
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);
|
|
2304
2308
|
}
|
|
2305
2309
|
let h = [], g = (() => {
|
|
@@ -2307,9 +2311,9 @@ function De(e) {
|
|
|
2307
2311
|
for (let r of e.events) r.t === "block" ? n = Math.max(n, ++t) : r.t === "end" && (t = Math.max(0, t - 1));
|
|
2308
2312
|
return n;
|
|
2309
2313
|
})(), v = g ? 12 + g * 8 : 0;
|
|
2310
|
-
h[0] =
|
|
2314
|
+
h[0] = Ce + Math.max(i[0].w / 2, c + i[0].w / 2, v + 10);
|
|
2311
2315
|
for (let e = 1; e < o; e++) h[e] = h[e - 1] + s[e];
|
|
2312
|
-
let y = h[o - 1] + Math.max(i[o - 1].w / 2, l + i[o - 1].w / 2, v + 10) +
|
|
2316
|
+
let y = h[o - 1] + Math.max(i[o - 1].w / 2, l + i[o - 1].w / 2, v + 10) + Ce, b = Ce + (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(() => []), ee = [], D = [], O = [], k = /* @__PURE__ */ new Map(), A = (e, t) => {
|
|
2313
2317
|
for (let n of O) n.lo = Math.min(n.lo, e), n.hi = Math.max(n.hi, t);
|
|
2314
2318
|
}, te = (e, t) => {
|
|
2315
2319
|
let n = E[e].length;
|
|
@@ -2327,7 +2331,7 @@ function De(e) {
|
|
|
2327
2331
|
for (let t of e.events) switch (t.t) {
|
|
2328
2332
|
case "msg": {
|
|
2329
2333
|
m++;
|
|
2330
|
-
let i = n.get(t.from), a = n.get(t.to), o =
|
|
2334
|
+
let i = n.get(t.from), a = n.get(t.to), o = we(t.text), s = o.length * Se, c = {
|
|
2331
2335
|
stroke: u.line,
|
|
2332
2336
|
sw: 1.4,
|
|
2333
2337
|
dash: t.dashed ? "6 4" : void 0
|
|
@@ -2340,17 +2344,17 @@ function De(e) {
|
|
|
2340
2344
|
[n + 34, S],
|
|
2341
2345
|
[n + 34, S + 20],
|
|
2342
2346
|
[n + 2, S + 20]
|
|
2343
|
-
], c, !1),
|
|
2347
|
+
], c, !1), De(w, t.head, n, S + 20, -1), T.text(n + 6 + l, S - 4 - s / 2, o, { size: X }), e.autonumber && ke(T, n, S, m), A(h[i] - 10, n + 34 + 6 + l + Math.max(...o.map((e) => r(e, X)))), S += 20, t.activate && ne(a, S), t.deactivate && j(i, S), S += 14;
|
|
2344
2348
|
break;
|
|
2345
2349
|
}
|
|
2346
2350
|
S += s + 6;
|
|
2347
2351
|
let d = a > i ? 1 : -1;
|
|
2348
2352
|
t.activate && ne(a, S);
|
|
2349
2353
|
let p = te(i, d), g = te(a, -d);
|
|
2350
|
-
w.line(p, S, g, S, c),
|
|
2354
|
+
w.line(p, S, g, S, c), De(w, t.head, g, S, d), t.both && De(w, t.head, p, S, -d), T.text((p + g) / 2 + d * l / 2, S - 5 - s / 2, o, {
|
|
2351
2355
|
anchor: "middle",
|
|
2352
2356
|
size: X
|
|
2353
|
-
}), e.autonumber &&
|
|
2357
|
+
}), e.autonumber && ke(T, p, S, m), t.deactivate && j(i, S), A(Math.min(h[i], h[a]), Math.max(h[i], h[a])), S += 14;
|
|
2354
2358
|
break;
|
|
2355
2359
|
}
|
|
2356
2360
|
case "act": {
|
|
@@ -2359,7 +2363,7 @@ function De(e) {
|
|
|
2359
2363
|
break;
|
|
2360
2364
|
}
|
|
2361
2365
|
case "note": {
|
|
2362
|
-
let e = t.who.map((e) => n.get(e)), r = Math.min(...e), i = Math.max(...e), o =
|
|
2366
|
+
let e = t.who.map((e) => n.get(e)), r = Math.min(...e), i = Math.max(...e), o = we(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;
|
|
2363
2367
|
S += 6;
|
|
2364
2368
|
let d = t.pos === "left" ? h[r] - 12 - c : t.pos === "right" ? h[i] + 12 : (h[r] + h[i]) / 2 - c / 2;
|
|
2365
2369
|
T.poly([
|
|
@@ -2408,18 +2412,18 @@ function De(e) {
|
|
|
2408
2412
|
}
|
|
2409
2413
|
case "divider": {
|
|
2410
2414
|
S += 16;
|
|
2411
|
-
let e = a(
|
|
2412
|
-
T.line(
|
|
2415
|
+
let e = a(we(t.text), X);
|
|
2416
|
+
T.line(Ce / 2, S - 2, y - Ce / 2, S - 2, {
|
|
2413
2417
|
stroke: u.muted,
|
|
2414
2418
|
sw: 1
|
|
2415
|
-
}).line(
|
|
2419
|
+
}).line(Ce / 2, S + 2, y - Ce / 2, S + 2, {
|
|
2416
2420
|
stroke: u.muted,
|
|
2417
2421
|
sw: 1
|
|
2418
2422
|
}), t.text && (T.rect(y / 2 - e.w / 2 - 10, S - e.h / 2 - 4, e.w + 20, e.h + 8, {
|
|
2419
2423
|
fill: "#ffffff",
|
|
2420
2424
|
stroke: u.muted,
|
|
2421
2425
|
sw: 1
|
|
2422
|
-
}, 3), T.text(y / 2, S,
|
|
2426
|
+
}, 3), T.text(y / 2, S, we(t.text), {
|
|
2423
2427
|
anchor: "middle",
|
|
2424
2428
|
size: X,
|
|
2425
2429
|
bold: !0
|
|
@@ -2427,7 +2431,7 @@ function De(e) {
|
|
|
2427
2431
|
break;
|
|
2428
2432
|
}
|
|
2429
2433
|
case "delay":
|
|
2430
|
-
S += 14, t.text && T.text(y / 2, S,
|
|
2434
|
+
S += 14, t.text && T.text(y / 2, S, we(t.text), {
|
|
2431
2435
|
anchor: "middle",
|
|
2432
2436
|
size: X,
|
|
2433
2437
|
italic: !0,
|
|
@@ -2452,7 +2456,7 @@ function De(e) {
|
|
|
2452
2456
|
for (let e = 0; e < o; e++) for (; E[e].length;) j(e, S);
|
|
2453
2457
|
for (let e of O.splice(0)) e.y1 = S;
|
|
2454
2458
|
S += 14;
|
|
2455
|
-
let re = e.footer !== !1, ie = S + (re ? x : 0) +
|
|
2459
|
+
let re = e.footer !== !1, ie = S + (re ? x : 0) + Ce;
|
|
2456
2460
|
for (let e of D) {
|
|
2457
2461
|
let t = 12 + (g - e.depth) * 8;
|
|
2458
2462
|
e.lo > e.hi && (e.lo = h[0], e.hi = h[o - 1]);
|
|
@@ -2509,7 +2513,7 @@ function De(e) {
|
|
|
2509
2513
|
});
|
|
2510
2514
|
}
|
|
2511
2515
|
return M.raw(w.body()), M.raw(T.body()), t.forEach((e, t) => {
|
|
2512
|
-
|
|
2516
|
+
Ee(M, e, i[t], h[t], b + x - i[t].h), re && !k.has(t) && Ee(M, e, i[t], h[t], S);
|
|
2513
2517
|
}), e.title && (y = Math.max(y, r(e.title, 16, !0) + 32), M.text(y / 2, 28, e.title, {
|
|
2514
2518
|
anchor: "middle",
|
|
2515
2519
|
size: 16,
|
|
@@ -2520,7 +2524,7 @@ function De(e) {
|
|
|
2520
2524
|
h: Math.ceil(ie)
|
|
2521
2525
|
};
|
|
2522
2526
|
}
|
|
2523
|
-
function
|
|
2527
|
+
function ke(e, t, n, i) {
|
|
2524
2528
|
let a = Math.max(8, r(String(i), 10) / 2 + 4);
|
|
2525
2529
|
e.circle(t, n, a, { fill: u.dark }), e.text(t, n, String(i), {
|
|
2526
2530
|
anchor: "middle",
|
|
@@ -2530,25 +2534,25 @@ function Oe(e, t, n, i) {
|
|
|
2530
2534
|
});
|
|
2531
2535
|
}
|
|
2532
2536
|
// src/core/diagram/model.ts
|
|
2533
|
-
function
|
|
2537
|
+
function Ae(e) {
|
|
2534
2538
|
switch (e.t) {
|
|
2535
2539
|
case "graph": return P(e.graph);
|
|
2536
|
-
case "sequence": return
|
|
2540
|
+
case "sequence": return Oe(e.seq);
|
|
2537
2541
|
case "pie": return me(e.pie);
|
|
2538
|
-
case "gantt": return
|
|
2539
|
-
case "tree": return
|
|
2542
|
+
case "gantt": return K(e.gantt);
|
|
2543
|
+
case "tree": return ye(e.root, e.title);
|
|
2540
2544
|
}
|
|
2541
2545
|
}
|
|
2542
2546
|
// src/core/diagram/mermaid.ts
|
|
2543
|
-
function
|
|
2547
|
+
function je(e) {
|
|
2544
2548
|
let t = e.replace(/^/, "").replace(/\r\n?/g, "\n"), n, r = /^\s*---\n([\s\S]*?)\n---[ \t]*(\n|$)/.exec(t);
|
|
2545
2549
|
return r && (n = /^title:\s*(.+)$/m.exec(r[1])?.[1].trim().replace(/^(["'])(.*)\1$/, "$2"), t = t.slice(r[0].length)), t = t.replace(/%%\{[\s\S]*?\}%%/g, ""), {
|
|
2546
2550
|
lines: t.split("\n").filter((e) => !/^\s*%%/.test(e)),
|
|
2547
2551
|
title: n
|
|
2548
2552
|
};
|
|
2549
2553
|
}
|
|
2550
|
-
function
|
|
2551
|
-
let { lines: t, title: n } =
|
|
2554
|
+
function Me(e) {
|
|
2555
|
+
let { lines: t, title: n } = je(e), r = t.findIndex((e) => e.trim());
|
|
2552
2556
|
if (r < 0) throw new _("The diagram is empty");
|
|
2553
2557
|
let i = t[r].trim(), a = /^[\w-]+/.exec(i)?.[0] ?? i, o = t.slice(r + 1);
|
|
2554
2558
|
switch (a) {
|
|
@@ -2556,54 +2560,54 @@ function je(e) {
|
|
|
2556
2560
|
case "flowchart":
|
|
2557
2561
|
case "flowchart-elk": return {
|
|
2558
2562
|
t: "graph",
|
|
2559
|
-
graph:
|
|
2563
|
+
graph: We(i, o, n)
|
|
2560
2564
|
};
|
|
2561
2565
|
case "sequenceDiagram": return {
|
|
2562
2566
|
t: "sequence",
|
|
2563
|
-
seq:
|
|
2567
|
+
seq: qe(o, n)
|
|
2564
2568
|
};
|
|
2565
2569
|
case "classDiagram":
|
|
2566
2570
|
case "classDiagram-v2": return {
|
|
2567
2571
|
t: "graph",
|
|
2568
|
-
graph:
|
|
2572
|
+
graph: Xe(o, n)
|
|
2569
2573
|
};
|
|
2570
2574
|
case "stateDiagram":
|
|
2571
2575
|
case "stateDiagram-v2": return {
|
|
2572
2576
|
t: "graph",
|
|
2573
|
-
graph:
|
|
2577
|
+
graph: Ze(o, n)
|
|
2574
2578
|
};
|
|
2575
2579
|
case "erDiagram": return {
|
|
2576
2580
|
t: "graph",
|
|
2577
|
-
graph:
|
|
2581
|
+
graph: et(o, n)
|
|
2578
2582
|
};
|
|
2579
2583
|
case "pie": return {
|
|
2580
2584
|
t: "pie",
|
|
2581
|
-
pie:
|
|
2585
|
+
pie: tt(i, o, n)
|
|
2582
2586
|
};
|
|
2583
2587
|
case "gantt": return {
|
|
2584
2588
|
t: "gantt",
|
|
2585
|
-
gantt:
|
|
2589
|
+
gantt: it(o, n)
|
|
2586
2590
|
};
|
|
2587
2591
|
case "mindmap": return {
|
|
2588
2592
|
t: "tree",
|
|
2589
|
-
root:
|
|
2593
|
+
root: ot(o),
|
|
2590
2594
|
title: n
|
|
2591
2595
|
};
|
|
2592
2596
|
default: throw new _(`Mermaid “${a}” diagrams are not supported yet`);
|
|
2593
2597
|
}
|
|
2594
2598
|
}
|
|
2595
|
-
var
|
|
2599
|
+
var Ne = (e) => Ae(Me(e)), Pe = L({
|
|
2596
2600
|
TB: "TB",
|
|
2597
2601
|
TD: "TB",
|
|
2598
2602
|
BT: "BT",
|
|
2599
2603
|
LR: "LR",
|
|
2600
2604
|
RL: "RL"
|
|
2601
|
-
};
|
|
2605
|
+
});
|
|
2602
2606
|
function Z(e) {
|
|
2603
2607
|
let t = e.trim();
|
|
2604
2608
|
return /^".*"$/s.test(t) && (t = t.slice(1, -1)), /^`.*`$/s.test(t) && (t = g(t.slice(1, -1))), t = t.replace(/\bfa[bkrs]?:fa-[\w-]+\s*/g, ""), h(t).trim();
|
|
2605
2609
|
}
|
|
2606
|
-
function
|
|
2610
|
+
function Fe(e) {
|
|
2607
2611
|
let t = {};
|
|
2608
2612
|
for (let n of e.split(/,(?![^(]*\))/)) {
|
|
2609
2613
|
let e = n.indexOf(":");
|
|
@@ -2613,12 +2617,12 @@ function Pe(e) {
|
|
|
2613
2617
|
}
|
|
2614
2618
|
return t;
|
|
2615
2619
|
}
|
|
2616
|
-
var
|
|
2620
|
+
var Ie = (e, t) => {
|
|
2617
2621
|
let n = { ...e };
|
|
2618
2622
|
for (let [e, r] of Object.entries(t)) r !== void 0 && (n[e] = r);
|
|
2619
2623
|
return n;
|
|
2620
2624
|
};
|
|
2621
|
-
function
|
|
2625
|
+
function Le(e, t) {
|
|
2622
2626
|
let n = [], r = 0, i = "", a = "";
|
|
2623
2627
|
for (let o of e) {
|
|
2624
2628
|
if (i) o === i && (i = "");
|
|
@@ -2633,7 +2637,7 @@ function Ie(e, t) {
|
|
|
2633
2637
|
}
|
|
2634
2638
|
return n.push(a), n;
|
|
2635
2639
|
}
|
|
2636
|
-
var
|
|
2640
|
+
var Re = [
|
|
2637
2641
|
[
|
|
2638
2642
|
"(((",
|
|
2639
2643
|
[")))"],
|
|
@@ -2694,7 +2698,7 @@ var Le = [
|
|
|
2694
2698
|
["]"],
|
|
2695
2699
|
["flag"]
|
|
2696
2700
|
]
|
|
2697
|
-
],
|
|
2701
|
+
], ze = L({
|
|
2698
2702
|
rect: "rect",
|
|
2699
2703
|
rectangle: "rect",
|
|
2700
2704
|
proc: "rect",
|
|
@@ -2752,10 +2756,10 @@ var Le = [
|
|
|
2752
2756
|
card: "note",
|
|
2753
2757
|
"f-circ": "point",
|
|
2754
2758
|
junction: "point"
|
|
2755
|
-
},
|
|
2756
|
-
function
|
|
2759
|
+
}), Be = /^[\p{L}\p{N}_$]+(?:-[\p{L}\p{N}_$]+)*/u;
|
|
2760
|
+
function Ve(e, t, n) {
|
|
2757
2761
|
for (; e[t] === " " || e[t] === " ";) t++;
|
|
2758
|
-
let r =
|
|
2762
|
+
let r = Be.exec(e.slice(t));
|
|
2759
2763
|
if (!r) return null;
|
|
2760
2764
|
let i = r[0];
|
|
2761
2765
|
t += i.length;
|
|
@@ -2764,9 +2768,9 @@ function Be(e, t, n) {
|
|
|
2764
2768
|
let n = e.indexOf("}", t);
|
|
2765
2769
|
if (n > 0) {
|
|
2766
2770
|
let r = e.slice(t + 2, n), i = /shape\s*:\s*["']?([\w-]+)/.exec(r)?.[1], o = /label\s*:\s*("([^"]*)"|'([^']*)'|[^,]+)/.exec(r);
|
|
2767
|
-
i &&
|
|
2771
|
+
i && ze[i] && (a.shape = ze[i]), o && (a.label = Z(o[2] ?? o[3] ?? o[1])), t = n + 1;
|
|
2768
2772
|
}
|
|
2769
|
-
} else for (let [n, r, i] of
|
|
2773
|
+
} else for (let [n, r, i] of Re) {
|
|
2770
2774
|
if (!e.startsWith(n, t)) continue;
|
|
2771
2775
|
let o = t + n.length, s = "";
|
|
2772
2776
|
for (; e[o] === " ";) o++;
|
|
@@ -2793,12 +2797,12 @@ function Be(e, t, n) {
|
|
|
2793
2797
|
}
|
|
2794
2798
|
return [i, t];
|
|
2795
2799
|
}
|
|
2796
|
-
var
|
|
2800
|
+
var He = L({
|
|
2797
2801
|
">": "arrow",
|
|
2798
2802
|
o: "circle",
|
|
2799
2803
|
x: "cross"
|
|
2800
|
-
};
|
|
2801
|
-
function
|
|
2804
|
+
});
|
|
2805
|
+
function Ue(e, t) {
|
|
2802
2806
|
let n = e.slice(t), r = /^\s*([<ox]?)(--|==|-\.)\s+(.+?)\s*(-{2,}|={2,}|\.+-)([>ox]?)(?=[\s\p{L}\p{N}_$"]|$)/u.exec(n), i, a = "", o = "", s = "", c = !1;
|
|
2803
2807
|
if (r) [, a, , i, o, s] = r, c = r[2] === "-.";
|
|
2804
2808
|
else {
|
|
@@ -2814,19 +2818,19 @@ function He(e, t) {
|
|
|
2814
2818
|
let d = o.includes("="), f = c ? (o.match(/\./g)?.length ?? 1) - 1 : o.length - (s ? 2 : 3);
|
|
2815
2819
|
return [{
|
|
2816
2820
|
label: i !== void 0 && i.trim() ? Z(i) : void 0,
|
|
2817
|
-
head:
|
|
2821
|
+
head: He[s] ?? "none",
|
|
2818
2822
|
tail: a === "<" ? "arrow" : a === "o" ? "circle" : a === "x" ? "cross" : "none",
|
|
2819
2823
|
line: d ? "thick" : c ? "dashed" : "solid",
|
|
2820
2824
|
minlen: 1 + Math.max(0, Math.min(f, 6))
|
|
2821
2825
|
}, t + l];
|
|
2822
2826
|
}
|
|
2823
|
-
function
|
|
2824
|
-
let r = /^\w+\s+(\w+)/.exec(e)?.[1]?.toUpperCase(), i = new v(
|
|
2827
|
+
function We(e, t, n) {
|
|
2828
|
+
let r = /^\w+\s+(\w+)/.exec(e)?.[1]?.toUpperCase(), i = new v(Pe[r ?? "TB"] ?? "TB", "rect"), a = {
|
|
2825
2829
|
b: i,
|
|
2826
2830
|
clusters: [],
|
|
2827
2831
|
classes: /* @__PURE__ */ new Map(),
|
|
2828
2832
|
defs: /* @__PURE__ */ new Map()
|
|
2829
|
-
}, o = [], s = t.flatMap((e) =>
|
|
2833
|
+
}, o = [], s = t.flatMap((e) => Le(e, ";")).map((e) => e.trim()).filter(Boolean), c = Le(e, ";").slice(1).map((e) => e.trim()).filter(Boolean);
|
|
2830
2834
|
for (let e of [...c, ...s]) {
|
|
2831
2835
|
let t;
|
|
2832
2836
|
if (t = /^subgraph\s+(.*)$/.exec(e)) {
|
|
@@ -2842,7 +2846,7 @@ function Ue(e, t, n) {
|
|
|
2842
2846
|
}
|
|
2843
2847
|
if (/^direction\s+\w+$/.test(e)) continue;
|
|
2844
2848
|
if (t = /^classDef\s+([\w,-]+)\s+(.+)$/.exec(e)) {
|
|
2845
|
-
for (let e of t[1].split(",")) a.defs.set(e.trim(),
|
|
2849
|
+
for (let e of t[1].split(",")) a.defs.set(e.trim(), Ie(a.defs.get(e.trim()), Fe(t[2])));
|
|
2846
2850
|
continue;
|
|
2847
2851
|
}
|
|
2848
2852
|
if (t = /^class\s+([^\s]+)\s+([\w-]+)$/.exec(e)) {
|
|
@@ -2850,15 +2854,15 @@ function Ue(e, t, n) {
|
|
|
2850
2854
|
continue;
|
|
2851
2855
|
}
|
|
2852
2856
|
if (t = /^style\s+([^\s]+)\s+(.+)$/.exec(e)) {
|
|
2853
|
-
let e =
|
|
2857
|
+
let e = Fe(t[2]);
|
|
2854
2858
|
for (let n of t[1].split(",")) if (i.isCluster(n)) {
|
|
2855
2859
|
let t = i.g.clusters.find((e) => e.id === n);
|
|
2856
|
-
t.style =
|
|
2857
|
-
} else i.node(n).style =
|
|
2860
|
+
t.style = Ie(t.style, e);
|
|
2861
|
+
} else i.node(n).style = Ie(i.get(n)?.style, e);
|
|
2858
2862
|
continue;
|
|
2859
2863
|
}
|
|
2860
2864
|
if (t = /^linkStyle\s+([\d,\s]+|default)\s+(.+)$/.exec(e)) {
|
|
2861
|
-
o.push([t[1].trim(),
|
|
2865
|
+
o.push([t[1].trim(), Fe(t[2])]);
|
|
2862
2866
|
continue;
|
|
2863
2867
|
}
|
|
2864
2868
|
if (/^(click|accTitle|accDescr|callback)\b/.test(e)) continue;
|
|
@@ -2866,7 +2870,7 @@ function Ue(e, t, n) {
|
|
|
2866
2870
|
for (;;) {
|
|
2867
2871
|
let t = [];
|
|
2868
2872
|
for (;;) {
|
|
2869
|
-
let r =
|
|
2873
|
+
let r = Ve(e, n, a);
|
|
2870
2874
|
if (!r) break;
|
|
2871
2875
|
t.push(r[0]), n = r[1];
|
|
2872
2876
|
let i = /^\s*&\s*/.exec(e.slice(n));
|
|
@@ -2880,19 +2884,19 @@ function Ue(e, t, n) {
|
|
|
2880
2884
|
to: n
|
|
2881
2885
|
});
|
|
2882
2886
|
r = t;
|
|
2883
|
-
let o =
|
|
2887
|
+
let o = Ue(e, n);
|
|
2884
2888
|
if (!o) break;
|
|
2885
2889
|
s = o[0], n = o[1];
|
|
2886
2890
|
}
|
|
2887
2891
|
}
|
|
2888
2892
|
let l = a.defs.get("default");
|
|
2889
2893
|
for (let e of i.g.nodes) {
|
|
2890
|
-
let t = l ?
|
|
2891
|
-
l && e.style && (t =
|
|
2892
|
-
for (let n of a.classes.get(e.id) ?? []) t =
|
|
2894
|
+
let t = l ? Ie(void 0, l) : e.style;
|
|
2895
|
+
l && e.style && (t = Ie(t, e.style));
|
|
2896
|
+
for (let n of a.classes.get(e.id) ?? []) t = Ie(t, a.defs.get(n) ?? {});
|
|
2893
2897
|
t && (e.style = t);
|
|
2894
2898
|
}
|
|
2895
|
-
for (let e of i.g.clusters) for (let t of a.classes.get(e.id) ?? []) e.style =
|
|
2899
|
+
for (let e of i.g.clusters) for (let t of a.classes.get(e.id) ?? []) e.style = Ie(e.style, a.defs.get(t) ?? {});
|
|
2896
2900
|
for (let [e, t] of o) {
|
|
2897
2901
|
let n = e === "default" ? i.g.edges.map((e, t) => t) : e.split(",").map((e) => Number(e.trim()));
|
|
2898
2902
|
for (let e of n) {
|
|
@@ -2902,7 +2906,7 @@ function Ue(e, t, n) {
|
|
|
2902
2906
|
}
|
|
2903
2907
|
return i.g.title = n, i.g;
|
|
2904
2908
|
}
|
|
2905
|
-
var
|
|
2909
|
+
var Ge = [
|
|
2906
2910
|
[
|
|
2907
2911
|
"<<-->>",
|
|
2908
2912
|
!0,
|
|
@@ -2963,7 +2967,7 @@ var We = [
|
|
|
2963
2967
|
"none",
|
|
2964
2968
|
!1
|
|
2965
2969
|
]
|
|
2966
|
-
],
|
|
2970
|
+
], Ke = L({
|
|
2967
2971
|
participant: "participant",
|
|
2968
2972
|
actor: "actor",
|
|
2969
2973
|
boundary: "boundary",
|
|
@@ -2972,11 +2976,11 @@ var We = [
|
|
|
2972
2976
|
database: "database",
|
|
2973
2977
|
collections: "collections",
|
|
2974
2978
|
queue: "queue"
|
|
2975
|
-
};
|
|
2976
|
-
function
|
|
2977
|
-
let n = new
|
|
2979
|
+
});
|
|
2980
|
+
function qe(e, t) {
|
|
2981
|
+
let n = new Y();
|
|
2978
2982
|
n.s.title = t;
|
|
2979
|
-
let r = [], i = RegExp(`^(.+?)\\s*(${
|
|
2983
|
+
let r = [], i = RegExp(`^(.+?)\\s*(${Ge.map(([e]) => e.replace(/[()|]/g, "\\$&")).join("|")})\\s*([+-]?)\\s*([^:]+?)\\s*(?::(.*))?$`);
|
|
2980
2984
|
for (let t of e) {
|
|
2981
2985
|
let e = t.trim();
|
|
2982
2986
|
if (!e) continue;
|
|
@@ -2984,7 +2988,7 @@ function Ke(e, t) {
|
|
|
2984
2988
|
if (a = /^(?:create\s+)?(participant|actor)\s+(.+?)(?:@\{(.*)\})?(?:\s+as\s+(.+))?$/.exec(e)) {
|
|
2985
2989
|
let e = a[2].trim(), t = a[3] ? /"type"\s*:\s*"(\w+)"/.exec(a[3])?.[1] : void 0;
|
|
2986
2990
|
n.participant(e, {
|
|
2987
|
-
kind:
|
|
2991
|
+
kind: Ke[t ?? a[1]] ?? "participant",
|
|
2988
2992
|
label: a[4] ? Z(a[4]) : e
|
|
2989
2993
|
});
|
|
2990
2994
|
} else if (a = /^destroy\s+(.+)$/.exec(e)) n.push({
|
|
@@ -3022,7 +3026,7 @@ function Ke(e, t) {
|
|
|
3022
3026
|
});
|
|
3023
3027
|
else if (e === "end") r.pop() === "frag" && n.push({ t: "end" });
|
|
3024
3028
|
else if (a = i.exec(e)) {
|
|
3025
|
-
let e =
|
|
3029
|
+
let e = Ge.find(([e]) => e === a[2]);
|
|
3026
3030
|
n.push({
|
|
3027
3031
|
t: "msg",
|
|
3028
3032
|
from: a[1].trim(),
|
|
@@ -3038,7 +3042,7 @@ function Ke(e, t) {
|
|
|
3038
3042
|
}
|
|
3039
3043
|
return n.s;
|
|
3040
3044
|
}
|
|
3041
|
-
var
|
|
3045
|
+
var Je = (e) => e.replace(/~([^~]*)~/g, "<$1>"), Ye = L({
|
|
3042
3046
|
"<|": "triangle",
|
|
3043
3047
|
"|>": "triangle",
|
|
3044
3048
|
"*": "diamond",
|
|
@@ -3046,17 +3050,17 @@ var qe = (e) => e.replace(/~([^~]*)~/g, "<$1>"), Je = {
|
|
|
3046
3050
|
"<": "open",
|
|
3047
3051
|
">": "open",
|
|
3048
3052
|
"()": "ocircle"
|
|
3049
|
-
};
|
|
3050
|
-
function
|
|
3053
|
+
});
|
|
3054
|
+
function Xe(e, t) {
|
|
3051
3055
|
let n = new v("TB", "rect"), r = /* @__PURE__ */ new Map(), i = [], a = (e) => {
|
|
3052
3056
|
let t = e.replace(/~.*~$/, "");
|
|
3053
3057
|
return r.has(t) || r.set(t, {
|
|
3054
3058
|
attrs: [],
|
|
3055
3059
|
methods: [],
|
|
3056
|
-
label: e === t ? void 0 :
|
|
3060
|
+
label: e === t ? void 0 : Je(e)
|
|
3057
3061
|
}), n.node(t, {}, i[i.length - 1]), r.get(t);
|
|
3058
3062
|
}, o = (e, t) => {
|
|
3059
|
-
let n =
|
|
3063
|
+
let n = Je(t.trim());
|
|
3060
3064
|
if (!n) return;
|
|
3061
3065
|
let r = /^<<(.+)>>$/.exec(n);
|
|
3062
3066
|
r ? e.stereo = r[1] : n.includes("(") ? e.methods.push(n.replace(/[$*]$/, "")) : e.attrs.push(n.replace(/[$*]$/, ""));
|
|
@@ -3069,7 +3073,7 @@ function Ye(e, t) {
|
|
|
3069
3073
|
continue;
|
|
3070
3074
|
}
|
|
3071
3075
|
let r;
|
|
3072
|
-
if (r = /^direction\s+(\w+)$/.exec(e)) n.g.dir =
|
|
3076
|
+
if (r = /^direction\s+(\w+)$/.exec(e)) n.g.dir = Pe[r[1].toUpperCase()] ?? "TB";
|
|
3073
3077
|
else if (r = /^namespace\s+([\w.]+)\s*\{$/.exec(e)) n.cluster(r[1], r[1], i[i.length - 1]), i.push(r[1]);
|
|
3074
3078
|
else if (e === "}" && i.length) i.pop();
|
|
3075
3079
|
else if (r = /^class\s+([\w$~,<>.-]+?)(?:\["([^"]*)"\])?(?::::[\w-]+)?\s*(\{)?\s*(\})?$/.exec(e)) {
|
|
@@ -3097,8 +3101,8 @@ function Ye(e, t) {
|
|
|
3097
3101
|
a(e), a(l), n.edge({
|
|
3098
3102
|
from: e.replace(/~.*~$/, ""),
|
|
3099
3103
|
to: l.replace(/~.*~$/, ""),
|
|
3100
|
-
tail: i ?
|
|
3101
|
-
head: s ?
|
|
3104
|
+
tail: i ? Ye[i] : "none",
|
|
3105
|
+
head: s ? Ye[s] : "none",
|
|
3102
3106
|
line: o === ".." ? "dashed" : "solid",
|
|
3103
3107
|
label: u ? Z(u) : void 0,
|
|
3104
3108
|
tailLabel: t || void 0,
|
|
@@ -3121,7 +3125,7 @@ function Ye(e, t) {
|
|
|
3121
3125
|
}
|
|
3122
3126
|
return n.g.title = t, n.g;
|
|
3123
3127
|
}
|
|
3124
|
-
function
|
|
3128
|
+
function Ze(e, t) {
|
|
3125
3129
|
let n = new v("TB", "round"), r = [], i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), s = 0, c = null, l = null, u = () => r[r.length - 1], d = (e, t) => {
|
|
3126
3130
|
let r = e.trim(), i = /:::([\w-]+)$/.exec(r);
|
|
3127
3131
|
if (i && (r = r.slice(0, i.index), o.set(r, [...o.get(r) ?? [], i[1]])), r === "[*]") {
|
|
@@ -3156,7 +3160,7 @@ function Xe(e, t) {
|
|
|
3156
3160
|
}
|
|
3157
3161
|
if (!e || e === "--") continue;
|
|
3158
3162
|
let f;
|
|
3159
|
-
if (f = /^direction\s+(\w+)$/.exec(e)) r.length || (n.g.dir =
|
|
3163
|
+
if (f = /^direction\s+(\w+)$/.exec(e)) r.length || (n.g.dir = Pe[f[1].toUpperCase()] ?? "TB");
|
|
3160
3164
|
else if (f = /^state\s+(?:"([^"]+)"\s+as\s+)?([\w.-]+)\s*(<<(fork|join|choice)>>)?\s*(\{)?$/.exec(e)) {
|
|
3161
3165
|
let e = f[2];
|
|
3162
3166
|
if (f[5]) {
|
|
@@ -3191,7 +3195,7 @@ function Xe(e, t) {
|
|
|
3191
3195
|
head: "none"
|
|
3192
3196
|
});
|
|
3193
3197
|
} else c = [], l = { id: e };
|
|
3194
|
-
} else if (f = /^classDef\s+([\w-]+)\s+(.+)$/.exec(e)) a.set(f[1],
|
|
3198
|
+
} else if (f = /^classDef\s+([\w-]+)\s+(.+)$/.exec(e)) a.set(f[1], Fe(f[2]));
|
|
3195
3199
|
else if (f = /^class\s+([\w,\s-]+?)\s+([\w-]+)$/.exec(e)) for (let e of f[1].split(",")) o.set(e.trim(), [...o.get(e.trim()) ?? [], f[2]]);
|
|
3196
3200
|
else if (f = /^(.+?)\s*-->\s*([^:]+?)\s*(?::\s*(.*))?$/.exec(e)) {
|
|
3197
3201
|
let e = d(f[1], !1), t = d(f[2], !0);
|
|
@@ -3210,11 +3214,11 @@ function Xe(e, t) {
|
|
|
3210
3214
|
bold: !0,
|
|
3211
3215
|
center: !0
|
|
3212
3216
|
}, { rows: t.map((e) => [e]) }]);
|
|
3213
|
-
for (let t of o.get(e.id) ?? []) e.style =
|
|
3217
|
+
for (let t of o.get(e.id) ?? []) e.style = Ie(e.style, a.get(t) ?? {});
|
|
3214
3218
|
}
|
|
3215
3219
|
return n.g.title = t, n.g;
|
|
3216
3220
|
}
|
|
3217
|
-
var
|
|
3221
|
+
var Qe = L({
|
|
3218
3222
|
"|o": "zero-one",
|
|
3219
3223
|
"o|": "zero-one",
|
|
3220
3224
|
"||": "one",
|
|
@@ -3222,7 +3226,7 @@ var Ze = {
|
|
|
3222
3226
|
"o{": "zero-many",
|
|
3223
3227
|
"}|": "one-many",
|
|
3224
3228
|
"|{": "one-many"
|
|
3225
|
-
},
|
|
3229
|
+
}), $e = L({
|
|
3226
3230
|
"one or zero": "zero-one",
|
|
3227
3231
|
"zero or one": "zero-one",
|
|
3228
3232
|
"one or more": "one-many",
|
|
@@ -3235,12 +3239,12 @@ var Ze = {
|
|
|
3235
3239
|
"0+": "zero-many",
|
|
3236
3240
|
"only one": "one",
|
|
3237
3241
|
1: "one"
|
|
3238
|
-
};
|
|
3239
|
-
function
|
|
3242
|
+
});
|
|
3243
|
+
function et(e, t) {
|
|
3240
3244
|
let n = new v("TB", "rect"), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = null, o = (e) => {
|
|
3241
3245
|
let t = /^([\w-]+)(?:\[\s*"?([^"\]]*)"?\s*\])?$/.exec(e.trim().replace(/^"(.*)"$/, "$1")), a = t ? t[1] : e.trim().replace(/^"(.*)"$/, "$1");
|
|
3242
3246
|
return t?.[2] && i.set(a, t[2]), n.node(a), r.has(a) || r.set(a, []), a;
|
|
3243
|
-
}, s = Object.keys(
|
|
3247
|
+
}, s = Object.keys($e).sort((e, t) => t.length - e.length).map((e) => e.replace(/[()+]/g, "\\$&")).join("|"), c = /^(\S+)\s+(\|o|\|\||\}o|\}\|)(--|\.\.)(o\||\|\||o\{|\|\{)\s+(\S+)\s*:\s*(.*)$/, l = RegExp(`^(\\S+)\\s+(${s})\\s+(to|optionally to)\\s+(${s})\\s+(\\S+)\\s*:\\s*(.*)$`, "i");
|
|
3244
3248
|
for (let t of e) {
|
|
3245
3249
|
let e = t.trim();
|
|
3246
3250
|
if (!e) continue;
|
|
@@ -3259,15 +3263,15 @@ function $e(e, t) {
|
|
|
3259
3263
|
continue;
|
|
3260
3264
|
}
|
|
3261
3265
|
let i;
|
|
3262
|
-
if (i = /^direction\s+(\w+)$/.exec(e)) n.g.dir =
|
|
3266
|
+
if (i = /^direction\s+(\w+)$/.exec(e)) n.g.dir = Pe[i[1].toUpperCase()] ?? "TB";
|
|
3263
3267
|
else if (i = /^(.+?)\s*\{$/.exec(e)) a = o(i[1]);
|
|
3264
3268
|
else if (i = c.exec(e)) {
|
|
3265
3269
|
let e = o(i[1]), t = o(i[5]);
|
|
3266
3270
|
n.edge({
|
|
3267
3271
|
from: e,
|
|
3268
3272
|
to: t,
|
|
3269
|
-
tail:
|
|
3270
|
-
head:
|
|
3273
|
+
tail: Qe[i[2]],
|
|
3274
|
+
head: Qe[i[4]],
|
|
3271
3275
|
line: i[3] === ".." ? "dashed" : "solid",
|
|
3272
3276
|
label: Z(i[6]) || void 0
|
|
3273
3277
|
});
|
|
@@ -3276,8 +3280,8 @@ function $e(e, t) {
|
|
|
3276
3280
|
n.edge({
|
|
3277
3281
|
from: e,
|
|
3278
3282
|
to: t,
|
|
3279
|
-
tail:
|
|
3280
|
-
head:
|
|
3283
|
+
tail: $e[i[2].toLowerCase()],
|
|
3284
|
+
head: $e[i[4].toLowerCase()],
|
|
3281
3285
|
line: i[3].toLowerCase() === "to" ? "solid" : "dashed",
|
|
3282
3286
|
label: Z(i[6]) || void 0
|
|
3283
3287
|
});
|
|
@@ -3293,7 +3297,7 @@ function $e(e, t) {
|
|
|
3293
3297
|
}
|
|
3294
3298
|
return n.g.title = t, n.g;
|
|
3295
3299
|
}
|
|
3296
|
-
function
|
|
3300
|
+
function tt(e, t, n) {
|
|
3297
3301
|
let r = /\bshowData\b/.test(e), i = /\btitle\s+(.+)$/.exec(e)?.[1] ?? n, a = [];
|
|
3298
3302
|
for (let e of t) {
|
|
3299
3303
|
let t = e.trim(), n;
|
|
@@ -3308,7 +3312,7 @@ function et(e, t, n) {
|
|
|
3308
3312
|
slices: a
|
|
3309
3313
|
};
|
|
3310
3314
|
}
|
|
3311
|
-
var
|
|
3315
|
+
var nt = L({
|
|
3312
3316
|
ms: 1,
|
|
3313
3317
|
s: 1e3,
|
|
3314
3318
|
m: 6e4,
|
|
@@ -3317,8 +3321,8 @@ var tt = {
|
|
|
3317
3321
|
w: 6048e5,
|
|
3318
3322
|
M: 2592e6,
|
|
3319
3323
|
y: 31536e6
|
|
3320
|
-
};
|
|
3321
|
-
function
|
|
3324
|
+
});
|
|
3325
|
+
function rt(e, t) {
|
|
3322
3326
|
if (e = e.trim(), t === "X") return Number(e) * 1e3;
|
|
3323
3327
|
if (t === "x") return Number(e);
|
|
3324
3328
|
let n = [], r = t.replace(/YYYY|YY|MM|M|DD|D|HH|H|mm|ss|SSS|[.*+?^${}()|[\]\\]/g, (e) => /^[.*+?^${}()|[\]\\]$/.test(e) ? "\\" + e : (n.push(e), e === "YYYY" ? "(\\d{4})" : e === "SSS" ? "(\\d{3})" : e.length === 1 ? "(\\d{1,2})" : "(\\d{2})")), i = RegExp(`^${r}$`).exec(e);
|
|
@@ -3331,7 +3335,7 @@ function nt(e, t) {
|
|
|
3331
3335
|
let o = a.Y === void 0 ? 1970 : n.includes("YY") ? 2e3 + a.Y : a.Y;
|
|
3332
3336
|
return Date.UTC(o, (a.M ?? 1) - 1, a.D ?? 1, a.H ?? 0, a.m ?? 0, a.s ?? 0, a.S ?? 0);
|
|
3333
3337
|
}
|
|
3334
|
-
function
|
|
3338
|
+
function it(e, t) {
|
|
3335
3339
|
let n = "YYYY-MM-DD", r = t, i = [], a = /* @__PURE__ */ new Map(), o, s = (() => {
|
|
3336
3340
|
let e = /* @__PURE__ */ new Date();
|
|
3337
3341
|
return Date.UTC(e.getUTCFullYear(), e.getUTCMonth(), e.getUTCDate());
|
|
@@ -3360,17 +3364,17 @@ function rt(e, t) {
|
|
|
3360
3364
|
let l;
|
|
3361
3365
|
t.length >= 3 && (l = t.shift());
|
|
3362
3366
|
let u, d;
|
|
3363
|
-
t.length >= 2 ? [u, d] = t : d = t[0], t.length === 2 && !/^after\s/.test(u) &&
|
|
3367
|
+
t.length >= 2 ? [u, d] = t : d = t[0], t.length === 2 && !/^after\s/.test(u) && rt(u, n) === void 0 && !/^\d/.test(u) && (l = u, u = void 0), r.start = ((e) => {
|
|
3364
3368
|
if (!e) return o ? o.end : s;
|
|
3365
3369
|
let t = /^after\s+(.+)$/.exec(e);
|
|
3366
3370
|
if (t) {
|
|
3367
3371
|
let e = t[1].split(/\s+/).map((e) => a.get(e)?.end).filter((e) => e !== void 0);
|
|
3368
3372
|
return e.length ? Math.max(...e) : o ? o.end : s;
|
|
3369
3373
|
}
|
|
3370
|
-
return
|
|
3374
|
+
return rt(e, n) ?? (o ? o.end : s);
|
|
3371
3375
|
})(u);
|
|
3372
3376
|
let f = d && /^([\d.]+)\s*(ms|s|m|h|d|w|M|y)$/.exec(d), p = d && /^until\s+(.+)$/.exec(d);
|
|
3373
|
-
r.end = f ? r.start + Number(f[1]) *
|
|
3377
|
+
r.end = f ? r.start + Number(f[1]) * nt[f[2]] : p ? a.get(p[1].trim())?.start ?? r.start : d ? rt(d, n) ?? r.start + 864e5 : r.start + 864e5, r.milestone && (r.end = r.start), l && a.set(l, r), i.length || i.push({
|
|
3374
3378
|
name: "",
|
|
3375
3379
|
tasks: []
|
|
3376
3380
|
}), i[i.length - 1].tasks.push(r), o = r;
|
|
@@ -3381,7 +3385,7 @@ function rt(e, t) {
|
|
|
3381
3385
|
sections: i
|
|
3382
3386
|
};
|
|
3383
3387
|
}
|
|
3384
|
-
var
|
|
3388
|
+
var at = [
|
|
3385
3389
|
[/^[\w-]*\(\((.*)\)\)$/, "circle"],
|
|
3386
3390
|
[/^[\w-]*\)\)(.*)\(\($/, "cloud"],
|
|
3387
3391
|
[/^[\w-]*\)(.*)\($/, "cloud"],
|
|
@@ -3389,14 +3393,14 @@ var it = [
|
|
|
3389
3393
|
[/^[\w-]*\[(.*)\]$/, "rect"],
|
|
3390
3394
|
[/^[\w-]*\((.*)\)$/, "round"]
|
|
3391
3395
|
];
|
|
3392
|
-
function
|
|
3396
|
+
function ot(e) {
|
|
3393
3397
|
let t = [], n;
|
|
3394
3398
|
for (let r of e) {
|
|
3395
3399
|
if (!r.trim()) continue;
|
|
3396
3400
|
let e = r.trim().replace(/:::[\w\s-]+$/, "").trim();
|
|
3397
3401
|
if (/^::icon\(/.test(e) || !e) continue;
|
|
3398
3402
|
let i = r.replace(/\t/g, " ").search(/\S/), a = e, o;
|
|
3399
|
-
for (let [t, n] of
|
|
3403
|
+
for (let [t, n] of at) {
|
|
3400
3404
|
let r = t.exec(e);
|
|
3401
3405
|
if (r) {
|
|
3402
3406
|
a = r[1], o = n;
|
|
@@ -3424,7 +3428,7 @@ function at(e) {
|
|
|
3424
3428
|
return n;
|
|
3425
3429
|
}
|
|
3426
3430
|
// src/core/diagram/plantuml.ts
|
|
3427
|
-
function
|
|
3431
|
+
function st(e) {
|
|
3428
3432
|
let t = e.replace(/^/, "").replace(/\r\n?/g, "\n"), n = [], r = /^[ \t]*@start(\w+)[^\n]*\n([\s\S]*?)^[ \t]*@end\1\b/gm, i;
|
|
3429
3433
|
for (; i = r.exec(t);) n.push({
|
|
3430
3434
|
kind: i[1].toLowerCase(),
|
|
@@ -3435,52 +3439,52 @@ function ot(e) {
|
|
|
3435
3439
|
lines: t.split("\n")
|
|
3436
3440
|
}), n;
|
|
3437
3441
|
}
|
|
3438
|
-
function
|
|
3439
|
-
return
|
|
3442
|
+
function ct(e) {
|
|
3443
|
+
return st(e).map(({ kind: e, lines: t }) => ut(e, t));
|
|
3440
3444
|
}
|
|
3441
|
-
var
|
|
3442
|
-
function
|
|
3445
|
+
var lt = (e) => ct(e).map(Ae);
|
|
3446
|
+
function ut(e, t) {
|
|
3443
3447
|
if (e === "dot") return {
|
|
3444
3448
|
t: "graph",
|
|
3445
|
-
graph:
|
|
3449
|
+
graph: H(t.join("\n"))[0]
|
|
3446
3450
|
};
|
|
3447
|
-
let { lines: n, title: r, dir: i } =
|
|
3451
|
+
let { lines: n, title: r, dir: i } = dt(t);
|
|
3448
3452
|
switch (e) {
|
|
3449
3453
|
case "uml": break;
|
|
3450
3454
|
case "mindmap":
|
|
3451
3455
|
case "wbs": return {
|
|
3452
3456
|
t: "tree",
|
|
3453
|
-
root:
|
|
3457
|
+
root: Tt(n, e === "wbs"),
|
|
3454
3458
|
title: r
|
|
3455
3459
|
};
|
|
3456
3460
|
default: throw new _(`PlantUML @start${e} diagrams are not supported yet`);
|
|
3457
3461
|
}
|
|
3458
|
-
switch (
|
|
3462
|
+
switch (ft(n)) {
|
|
3459
3463
|
case "activity": return {
|
|
3460
3464
|
t: "graph",
|
|
3461
3465
|
graph: {
|
|
3462
|
-
...
|
|
3466
|
+
...wt(n),
|
|
3463
3467
|
title: r
|
|
3464
3468
|
}
|
|
3465
3469
|
};
|
|
3466
3470
|
case "sequence": return {
|
|
3467
3471
|
t: "sequence",
|
|
3468
3472
|
seq: {
|
|
3469
|
-
...
|
|
3473
|
+
...mt(n),
|
|
3470
3474
|
title: r
|
|
3471
3475
|
}
|
|
3472
3476
|
};
|
|
3473
3477
|
case "state": return {
|
|
3474
3478
|
t: "graph",
|
|
3475
3479
|
graph: {
|
|
3476
|
-
...
|
|
3480
|
+
...Ct(n, i),
|
|
3477
3481
|
title: r
|
|
3478
3482
|
}
|
|
3479
3483
|
};
|
|
3480
3484
|
default: return {
|
|
3481
3485
|
t: "graph",
|
|
3482
3486
|
graph: {
|
|
3483
|
-
...
|
|
3487
|
+
...St(n, i),
|
|
3484
3488
|
title: r
|
|
3485
3489
|
}
|
|
3486
3490
|
};
|
|
@@ -3489,7 +3493,7 @@ function lt(e, t) {
|
|
|
3489
3493
|
function Q(e) {
|
|
3490
3494
|
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, " "));
|
|
3491
3495
|
}
|
|
3492
|
-
function
|
|
3496
|
+
function dt(e) {
|
|
3493
3497
|
let t = [], n, r, i = null, a = null, o = !1;
|
|
3494
3498
|
for (let s of e) {
|
|
3495
3499
|
if (o) {
|
|
@@ -3519,11 +3523,11 @@ function ut(e) {
|
|
|
3519
3523
|
dir: r
|
|
3520
3524
|
};
|
|
3521
3525
|
}
|
|
3522
|
-
function
|
|
3526
|
+
function ft(e) {
|
|
3523
3527
|
let t = (t) => e.some((e) => t.test(e));
|
|
3524
3528
|
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";
|
|
3525
3529
|
}
|
|
3526
|
-
var
|
|
3530
|
+
var pt = L({
|
|
3527
3531
|
participant: "participant",
|
|
3528
3532
|
actor: "actor",
|
|
3529
3533
|
boundary: "boundary",
|
|
@@ -3532,9 +3536,9 @@ var ft = {
|
|
|
3532
3536
|
database: "database",
|
|
3533
3537
|
collections: "collections",
|
|
3534
3538
|
queue: "queue"
|
|
3535
|
-
};
|
|
3536
|
-
function
|
|
3537
|
-
let t = new
|
|
3539
|
+
});
|
|
3540
|
+
function mt(e) {
|
|
3541
|
+
let t = new Y(), n = [], r = null, i = null, a = null, o = (e) => e.trim().replace(/^"(.*)"$/, "$1");
|
|
3538
3542
|
for (let s of e) {
|
|
3539
3543
|
if (r) {
|
|
3540
3544
|
/^end\s*(note|ref|rnote|hnote)$/i.test(s) ? (i && i.who.length && t.push({
|
|
@@ -3551,7 +3555,7 @@ function pt(e) {
|
|
|
3551
3555
|
r && (n = n.slice(0, r.index).trim()), n = n.replace(/<<[^>]*>>/g, "").trim();
|
|
3552
3556
|
let i = n, a = n, s = /^"([^"]+)"\s+as\s+(\S+)$/.exec(n), c = /^(\S+)\s+as\s+"?([^"]+)"?$/.exec(n);
|
|
3553
3557
|
s ? [i, a] = [s[2], s[1]] : c ? [i, a] = [c[1], c[2]] : i = a = o(n), t.participant(i, {
|
|
3554
|
-
kind:
|
|
3558
|
+
kind: pt[e[1].toLowerCase()],
|
|
3555
3559
|
label: Q(a),
|
|
3556
3560
|
fill: r ? l(r[1].slice(1)) ?? l(r[1]) : void 0
|
|
3557
3561
|
});
|
|
@@ -3658,7 +3662,7 @@ function pt(e) {
|
|
|
3658
3662
|
});
|
|
3659
3663
|
continue;
|
|
3660
3664
|
}
|
|
3661
|
-
let c =
|
|
3665
|
+
let c = gt(s);
|
|
3662
3666
|
if (c) {
|
|
3663
3667
|
let { from: e, to: r, dashed: i, head: o, both: s, act: l, text: u } = c;
|
|
3664
3668
|
t.push({
|
|
@@ -3685,9 +3689,9 @@ function pt(e) {
|
|
|
3685
3689
|
}
|
|
3686
3690
|
return t.s;
|
|
3687
3691
|
}
|
|
3688
|
-
var
|
|
3689
|
-
function
|
|
3690
|
-
let t =
|
|
3692
|
+
var ht = /^(\[|\]|[\w.$À-]+|"[^"]+")?\s*(<<?|[\\/]{1,2})?(-{1,2}|\.{1,2})(?:\[[^\]]*\])?(-?)(>>?|[\\/]{1,2})?\s*([ox])?\s*(\[|\]|[\w.$À-]+|"[^"]+")?\s*(\+\+|--|\*\*|!!)?\s*(?::\s*(.*))?$/u;
|
|
3693
|
+
function gt(e) {
|
|
3694
|
+
let t = ht.exec(e.replace(/^(\S+)\s*([ox])(?=<|-)/, "$1 "));
|
|
3691
3695
|
if (!t) return null;
|
|
3692
3696
|
let [, n, r, i, , a, , o, s, c] = t;
|
|
3693
3697
|
if (!r && !a || !n || !o) return null;
|
|
@@ -3704,7 +3708,7 @@ function ht(e) {
|
|
|
3704
3708
|
text: Q(c ?? "")
|
|
3705
3709
|
};
|
|
3706
3710
|
}
|
|
3707
|
-
var
|
|
3711
|
+
var _t = L({
|
|
3708
3712
|
actor: "actor",
|
|
3709
3713
|
person: "actor",
|
|
3710
3714
|
usecase: "ellipse",
|
|
@@ -3742,7 +3746,7 @@ var gt = {
|
|
|
3742
3746
|
json: "rect",
|
|
3743
3747
|
diamond: "diamond",
|
|
3744
3748
|
state: "round"
|
|
3745
|
-
},
|
|
3749
|
+
}), vt = /* @__PURE__ */ new Set([
|
|
3746
3750
|
"class",
|
|
3747
3751
|
"abstract",
|
|
3748
3752
|
"abstract class",
|
|
@@ -3758,7 +3762,7 @@ var gt = {
|
|
|
3758
3762
|
"object",
|
|
3759
3763
|
"map",
|
|
3760
3764
|
"json"
|
|
3761
|
-
]),
|
|
3765
|
+
]), yt = L({
|
|
3762
3766
|
">": "arrow",
|
|
3763
3767
|
"<": "arrow",
|
|
3764
3768
|
"|>": "triangle",
|
|
@@ -3780,8 +3784,8 @@ var gt = {
|
|
|
3780
3784
|
"o{": "zero-many",
|
|
3781
3785
|
"}|": "one-many",
|
|
3782
3786
|
"|{": "one-many"
|
|
3783
|
-
},
|
|
3784
|
-
function
|
|
3787
|
+
}), bt = String.raw`\[\*\]|\[[^\]]+\]|\([^)]*\)|:[^:]+:|"[^"]+"|\(\)\s*"[^"]+"|\(\)\s*[\w.]+|[\w.$À--]+`, xt = new RegExp(String.raw`^(${bt})\s*(?:"([^"]*)"\s*)?((?:<\||<<|\}o|\}\||\|o|\|\||[<*o#x+^}])?)([-.=~]+)(?:\[([^\]]*)\])?((?:up|down|left|right|u|d|l|r|le|ri|do)?)([-.=~]*)(?:\[([^\]]*)\])?((?:\|>|>>|o\{|\|\{|o\||\|\||[>*#+^{]|[ox](?=\s|\[|\(|"|:|$))?)\s*(?:"([^"]*)"\s*)?(${bt})\s*(?::\s*(.*))?$`, "u");
|
|
3788
|
+
function St(e, t) {
|
|
3785
3789
|
let n = new v(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) => {
|
|
3786
3790
|
let t = e.trim(), r;
|
|
3787
3791
|
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: Q(t) }, p()), t);
|
|
@@ -3849,7 +3853,7 @@ function xt(e, t) {
|
|
|
3849
3853
|
fill: "none",
|
|
3850
3854
|
stroke: "none"
|
|
3851
3855
|
}), i.push(o), a.push(t);
|
|
3852
|
-
} 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)) &&
|
|
3856
|
+
} 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)) && vt.has(e[1].toLowerCase().replace(/\s+/, " "))) {
|
|
3853
3857
|
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]}>` : "";
|
|
3854
3858
|
n.node(i, {
|
|
3855
3859
|
label: Q(a) + s,
|
|
@@ -3876,7 +3880,7 @@ function xt(e, t) {
|
|
|
3876
3880
|
/^["([:]/.test(e) ? [s, o] = [e, t] : [o, s] = [e, t];
|
|
3877
3881
|
}
|
|
3878
3882
|
s = s.replace(/^\((.*)\)$|^\[(.*)\]$|^:(.*):$/, "$1$2$3"), o = o.replace(/^\((.*)\)$|^\[(.*)\]$|^:(.*):$/, "$1$2$3").replace(/^"(.*)"$/, "$1");
|
|
3879
|
-
let u = t === "usecase" ? "ellipse" : t === "actor" ? "actor" :
|
|
3883
|
+
let u = t === "usecase" ? "ellipse" : t === "actor" ? "actor" : _t[t] ?? "rect", d = n.node(o, {
|
|
3880
3884
|
label: Q(s) + (a ? `\n«${a[1]}»` : ""),
|
|
3881
3885
|
shape: u
|
|
3882
3886
|
}, p()), f = i ? l(i[1].slice(1)) ?? l(i[1]) : void 0;
|
|
@@ -3893,8 +3897,8 @@ function xt(e, t) {
|
|
|
3893
3897
|
shape: r.shape
|
|
3894
3898
|
}, p()), n.g.nodes.splice(n.g.nodes.indexOf(r), 1);
|
|
3895
3899
|
}
|
|
3896
|
-
} else if (e =
|
|
3897
|
-
let [, t, r, i, a, , o, s, , c, l, u, d] = e, f = m(t), p = m(u), h = a + s, g = i ?
|
|
3900
|
+
} else if (e = xt.exec(t)) {
|
|
3901
|
+
let [, t, r, i, a, , o, s, , c, l, u, d] = e, f = m(t), p = m(u), h = a + s, g = i ? yt[i] ?? "none" : "none", _ = c ? yt[c] ?? "none" : "none", v = r, y = l;
|
|
3898
3902
|
/^(up|u|left|l|le)$/i.test(o) && ([f, p] = [p, f], [g, _] = [_, g], [v, y] = [y, v]);
|
|
3899
3903
|
let b = {
|
|
3900
3904
|
from: f,
|
|
@@ -3942,7 +3946,7 @@ function xt(e, t) {
|
|
|
3942
3946
|
}
|
|
3943
3947
|
return n.g;
|
|
3944
3948
|
}
|
|
3945
|
-
function
|
|
3949
|
+
function Ct(e, t) {
|
|
3946
3950
|
let n = new v(t ?? "TB", "round"), r = [], i = /* @__PURE__ */ new Map(), a = 0, o = null, s, c = () => r[r.length - 1], u = (e, t) => {
|
|
3947
3951
|
let r = e.trim().replace(/^"(.*)"$/, "$1");
|
|
3948
3952
|
if (r === "[*]") {
|
|
@@ -4029,7 +4033,7 @@ function St(e, t) {
|
|
|
4029
4033
|
}
|
|
4030
4034
|
return n.g;
|
|
4031
4035
|
}
|
|
4032
|
-
function
|
|
4036
|
+
function wt(e) {
|
|
4033
4037
|
let t = new v("TB", "round"), n = [];
|
|
4034
4038
|
for (let t = 0; t < e.length; t++) {
|
|
4035
4039
|
let r = e[t];
|
|
@@ -4169,7 +4173,7 @@ function Ct(e) {
|
|
|
4169
4173
|
};
|
|
4170
4174
|
return u([], /^\u0000$/), t.g;
|
|
4171
4175
|
}
|
|
4172
|
-
function
|
|
4176
|
+
function Tt(e, t) {
|
|
4173
4177
|
let n = [], r;
|
|
4174
4178
|
for (let i = 0; i < e.length; i++) {
|
|
4175
4179
|
let a = e[i], o = /^([*+\-#]+)(_)?\s*(?:\[#[\w]+\])?\s*(.*)$/.exec(a);
|
|
@@ -4201,8 +4205,18 @@ function wt(e, t) {
|
|
|
4201
4205
|
let i = (e, t) => e.children.forEach((e) => (t || (e.side = void 0), i(e, !1)));
|
|
4202
4206
|
return i(r, !0), r;
|
|
4203
4207
|
}
|
|
4204
|
-
|
|
4205
|
-
|
|
4208
|
+
L({
|
|
4209
|
+
mmd: "mermaid",
|
|
4210
|
+
mermaid: "mermaid",
|
|
4211
|
+
puml: "plantuml",
|
|
4212
|
+
plantuml: "plantuml",
|
|
4213
|
+
pu: "plantuml",
|
|
4214
|
+
iuml: "plantuml",
|
|
4215
|
+
wsd: "plantuml",
|
|
4216
|
+
dot: "graphviz",
|
|
4217
|
+
gv: "graphviz"
|
|
4218
|
+
});
|
|
4219
|
+
var Et = L({
|
|
4206
4220
|
mermaid: "mermaid",
|
|
4207
4221
|
mmd: "mermaid",
|
|
4208
4222
|
plantuml: "plantuml",
|
|
@@ -4211,17 +4225,17 @@ var Tt = {
|
|
|
4211
4225
|
dot: "graphviz",
|
|
4212
4226
|
graphviz: "graphviz",
|
|
4213
4227
|
gv: "graphviz"
|
|
4214
|
-
},
|
|
4228
|
+
}), Dt = {
|
|
4215
4229
|
mermaid: "Mermaid",
|
|
4216
4230
|
plantuml: "PlantUML",
|
|
4217
4231
|
graphviz: "Graphviz"
|
|
4218
|
-
},
|
|
4219
|
-
function
|
|
4220
|
-
if (t.length >
|
|
4232
|
+
}, Ot = 2e6;
|
|
4233
|
+
function kt(e, t) {
|
|
4234
|
+
if (t.length > Ot) throw new _("The diagram is too large to draw");
|
|
4221
4235
|
try {
|
|
4222
4236
|
switch (e) {
|
|
4223
|
-
case "mermaid": return [
|
|
4224
|
-
case "plantuml": return
|
|
4237
|
+
case "mermaid": return [Ne(t)];
|
|
4238
|
+
case "plantuml": return lt(t);
|
|
4225
4239
|
case "graphviz": return pe(t);
|
|
4226
4240
|
}
|
|
4227
4241
|
} catch (e) {
|
|
@@ -4229,7 +4243,7 @@ function Ot(e, t) {
|
|
|
4229
4243
|
}
|
|
4230
4244
|
}
|
|
4231
4245
|
// src/core/url.ts
|
|
4232
|
-
var
|
|
4246
|
+
var At = /* @__PURE__ */ new Set([
|
|
4233
4247
|
"http",
|
|
4234
4248
|
"https",
|
|
4235
4249
|
"mailto",
|
|
@@ -4238,14 +4252,14 @@ var kt = /* @__PURE__ */ new Set([
|
|
|
4238
4252
|
"ftp",
|
|
4239
4253
|
"ftps"
|
|
4240
4254
|
]);
|
|
4241
|
-
function
|
|
4255
|
+
function jt(e) {
|
|
4242
4256
|
if (!e) return;
|
|
4243
4257
|
let t = e.replace(/^[\u0000- ]+|[\u0000- ]+$/g, "").replace(/[\t\n\r]/g, ""), n = /^([a-z][a-z0-9+.-]*):/i.exec(t)?.[1].toLowerCase();
|
|
4244
|
-
return !n ||
|
|
4258
|
+
return !n || At.has(n) ? e : void 0;
|
|
4245
4259
|
}
|
|
4246
4260
|
// packages/markdown/src/markdown.ts
|
|
4247
|
-
var $ = (e) => e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """),
|
|
4248
|
-
function
|
|
4261
|
+
var $ = (e) => e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """), Mt = /^( {0,3})(`{3,}|~{3,})[ \t]*([^\s`]*)[^`\n]*$/, Nt = /^ {0,3}(#{1,6})(?:[ \t]+(.*?))?(?:[ \t]+#+)?[ \t]*$/, Pt = /^ {0,3}(=+|-+)[ \t]*$/, Ft = /^ {0,3}([-*_])(?:[ \t]*\1){2,}[ \t]*$/, It = /^ {0,3}> ?(.*)$/, Lt = /^( {0,3})([-*+]|\d{1,9}[.)])(?:([ \t]{1,4})(.*)|[ \t]*)$/, Rt = /^ {0,3}\|?[ \t]*:?-+:?[ \t]*(?:\|[ \t]*:?-+:?[ \t]*)*\|?[ \t]*$/, zt = /^ {0,3}\[([^\]]+)\]:[ \t]*<?([^\s>]+)>?(?:[ \t]+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\)))?[ \t]*$/, Bt = (e) => e.trim().replace(/\s+/g, " ").toLowerCase();
|
|
4262
|
+
function Vt(e, t = {}) {
|
|
4249
4263
|
let n = e.replace(/^/, "").replace(/\r\n?/g, "\n").replace(/\t/g, " ").split("\n"), r = {
|
|
4250
4264
|
refs: /* @__PURE__ */ new Map(),
|
|
4251
4265
|
diagrams: t.diagrams !== !1,
|
|
@@ -4253,28 +4267,28 @@ function Bt(e, t = {}) {
|
|
|
4253
4267
|
slugs: /* @__PURE__ */ new Map()
|
|
4254
4268
|
}, i = [], a = null;
|
|
4255
4269
|
for (let e of n) {
|
|
4256
|
-
let t =
|
|
4270
|
+
let t = Mt.exec(e);
|
|
4257
4271
|
if (a) {
|
|
4258
4272
|
t && t[2][0] === a[0] && t[2].length >= a.length && !t[3] && (a = null), i.push(e);
|
|
4259
4273
|
continue;
|
|
4260
4274
|
}
|
|
4261
4275
|
t && (a = t[2]);
|
|
4262
|
-
let n = !a &&
|
|
4276
|
+
let n = !a && zt.exec(e);
|
|
4263
4277
|
if (n) {
|
|
4264
|
-
let e =
|
|
4278
|
+
let e = Bt(n[1]);
|
|
4265
4279
|
r.refs.has(e) || r.refs.set(e, {
|
|
4266
4280
|
href: n[2],
|
|
4267
4281
|
title: n[3] ?? n[4] ?? n[5]
|
|
4268
4282
|
});
|
|
4269
4283
|
} else i.push(e);
|
|
4270
4284
|
}
|
|
4271
|
-
return
|
|
4285
|
+
return Ut(i, r, !1);
|
|
4272
4286
|
}
|
|
4273
|
-
var
|
|
4274
|
-
function
|
|
4287
|
+
var Ht = (e) => Mt.test(e) || Nt.test(e) || Ft.test(e) || It.test(e) || Lt.test(e);
|
|
4288
|
+
function Ut(e, t, n) {
|
|
4275
4289
|
let r = [], i = [], a = () => {
|
|
4276
4290
|
if (!i.length) return;
|
|
4277
|
-
let e =
|
|
4291
|
+
let e = en(i.map((e) => e.replace(/^ +/, "")).join("\n").replace(/\s+$/, ""), t);
|
|
4278
4292
|
r.push(n ? e : `<p>${e}</p>`), i = [];
|
|
4279
4293
|
}, o = 0;
|
|
4280
4294
|
for (; o < e.length;) {
|
|
@@ -4284,49 +4298,49 @@ function Ht(e, t, n) {
|
|
|
4284
4298
|
continue;
|
|
4285
4299
|
}
|
|
4286
4300
|
let s;
|
|
4287
|
-
if (s =
|
|
4301
|
+
if (s = Mt.exec(n)) {
|
|
4288
4302
|
a();
|
|
4289
4303
|
let n = s[1].length, i = s[2], c = RegExp(`^ {0,3}${i[0] === "`" ? "`" : "~"}{${i.length},}[ \\t]*$`), l = [];
|
|
4290
4304
|
for (o++; o < e.length && !c.test(e[o]);) l.push(e[o++].replace(RegExp(`^ {0,${n}}`), ""));
|
|
4291
|
-
o++, r.push(
|
|
4305
|
+
o++, r.push(qt(l.join("\n"), s[3], t));
|
|
4292
4306
|
} else if (!i.length && /^ {4}/.test(n)) {
|
|
4293
4307
|
let t = [];
|
|
4294
4308
|
for (; o < e.length && (/^ {4}/.test(e[o]) || !e[o].trim());) t.push(e[o++].slice(4));
|
|
4295
4309
|
for (; t.length && !t[t.length - 1].trim();) t.pop();
|
|
4296
4310
|
r.push(`<pre><code>${$(t.join("\n"))}\n</code></pre>`);
|
|
4297
|
-
} else if (s =
|
|
4298
|
-
else if (i.length && (s =
|
|
4311
|
+
} else if (s = Nt.exec(n)) a(), r.push(Kt(s[1].length, s[2] ?? "", t)), o++;
|
|
4312
|
+
else if (i.length && (s = Pt.exec(n))) {
|
|
4299
4313
|
let e = i.join("\n");
|
|
4300
|
-
i = [], r.push(
|
|
4301
|
-
} else if (
|
|
4302
|
-
else if (
|
|
4314
|
+
i = [], r.push(Kt(s[1][0] === "=" ? 1 : 2, e, t)), o++;
|
|
4315
|
+
} else if (Ft.test(n)) a(), r.push("<hr>"), o++;
|
|
4316
|
+
else if (It.test(n)) {
|
|
4303
4317
|
a();
|
|
4304
4318
|
let n = [];
|
|
4305
4319
|
for (; o < e.length;) {
|
|
4306
|
-
let t =
|
|
4320
|
+
let t = It.exec(e[o]);
|
|
4307
4321
|
if (t) n.push(t[1]);
|
|
4308
|
-
else if (e[o].trim() && n.length && n[n.length - 1].trim() && !
|
|
4322
|
+
else if (e[o].trim() && n.length && n[n.length - 1].trim() && !Ht(e[o])) n.push(e[o]);
|
|
4309
4323
|
else break;
|
|
4310
4324
|
o++;
|
|
4311
4325
|
}
|
|
4312
|
-
r.push(`<blockquote>\n${
|
|
4326
|
+
r.push(`<blockquote>\n${Ut(n, t, !1)}\n</blockquote>`);
|
|
4313
4327
|
} else {
|
|
4314
|
-
if (s =
|
|
4328
|
+
if (s = Lt.exec(n)) {
|
|
4315
4329
|
let n = s[4] === void 0 || !s[4].trim();
|
|
4316
4330
|
if (!i.length || !n && (!/\d/.test(s[2]) || parseInt(s[2], 10) === 1)) {
|
|
4317
|
-
a(), o =
|
|
4331
|
+
a(), o = Wt(e, o, r, t);
|
|
4318
4332
|
continue;
|
|
4319
4333
|
}
|
|
4320
4334
|
}
|
|
4321
|
-
n.includes("|") && o + 1 < e.length &&
|
|
4335
|
+
n.includes("|") && o + 1 < e.length && Rt.test(e[o + 1]) && (e[o + 1].includes("|") || !n.trim().startsWith("|")) ? (a(), o = Gt(e, o, r, t)) : (i.push(n), o++);
|
|
4322
4336
|
}
|
|
4323
4337
|
}
|
|
4324
4338
|
return a(), r.join("\n");
|
|
4325
4339
|
}
|
|
4326
|
-
function
|
|
4327
|
-
let i =
|
|
4340
|
+
function Wt(e, t, n, r) {
|
|
4341
|
+
let i = Lt.exec(e[t]), a = /\d/.test(i[2]), o = i[2].slice(-1), s = [], c = !1, l = t;
|
|
4328
4342
|
for (; l < e.length;) {
|
|
4329
|
-
let t =
|
|
4343
|
+
let t = Lt.exec(e[l]);
|
|
4330
4344
|
if (!t || /\d/.test(t[2]) !== a || t[2].slice(-1) !== o) break;
|
|
4331
4345
|
let n = t[3] === void 0 || t[3].length > 4 ? 1 : t[3].length, r = t[1].length + t[2].length + n, i = [t[3] === void 0 ? "" : t[3].length > 4 ? t[3].slice(1) + t[4] : t[4]];
|
|
4332
4346
|
l++;
|
|
@@ -4337,15 +4351,15 @@ function Ut(e, t, n, r) {
|
|
|
4337
4351
|
else if (t.length - t.trimStart().length >= r) i.push(t.slice(r)), u = !1, l++;
|
|
4338
4352
|
else {
|
|
4339
4353
|
if (u) break;
|
|
4340
|
-
if (!
|
|
4354
|
+
if (!Ht(t) && i[i.length - 1].trim()) i.push(t), l++;
|
|
4341
4355
|
else break;
|
|
4342
4356
|
}
|
|
4343
4357
|
}
|
|
4344
4358
|
let d = !1;
|
|
4345
4359
|
for (; i.length > 1 && !i[i.length - 1].trim();) i.pop(), d = !0;
|
|
4346
|
-
for (let e = 1; e + 1 < i.length; e++) !i[e].trim() && i[e + 1].trim() && !/^\s/.test(i[e + 1]) && !
|
|
4360
|
+
for (let e = 1; e + 1 < i.length; e++) !i[e].trim() && i[e + 1].trim() && !/^\s/.test(i[e + 1]) && !Lt.test(i[e + 1]) && (c = !0);
|
|
4347
4361
|
if (s.push(i), d) {
|
|
4348
|
-
let t = l < e.length ?
|
|
4362
|
+
let t = l < e.length ? Lt.exec(e[l]) : null;
|
|
4349
4363
|
t && /\d/.test(t[2]) === a && t[2].slice(-1) === o && (c = !0);
|
|
4350
4364
|
}
|
|
4351
4365
|
}
|
|
@@ -4354,72 +4368,72 @@ function Ut(e, t, n, r) {
|
|
|
4354
4368
|
for (let e of s) {
|
|
4355
4369
|
let t = /^\[([ xX])\][ \t]+/.exec(e[0]);
|
|
4356
4370
|
t && (e[0] = e[0].slice(t[0].length));
|
|
4357
|
-
let i =
|
|
4371
|
+
let i = Ut(e, r, !c), a = t ? `<input type="checkbox" disabled${t[1] === " " ? "" : " checked"}> ` : "";
|
|
4358
4372
|
n.push(t ? `<li class="task-list-item">${a}${i}</li>` : `<li>${i}</li>`);
|
|
4359
4373
|
}
|
|
4360
4374
|
return n.push(a ? "</ol>" : "</ul>"), l;
|
|
4361
4375
|
}
|
|
4362
|
-
function
|
|
4376
|
+
function Gt(e, t, n, r) {
|
|
4363
4377
|
let i = (e) => {
|
|
4364
4378
|
let t = e.trim();
|
|
4365
4379
|
return t.startsWith("|") && (t = t.slice(1)), t.endsWith("|") && !t.endsWith("\\|") && (t = t.slice(0, -1)), t.split(/(?<!\\)\|/).map((e) => e.trim().replace(/\\\|/g, "|"));
|
|
4366
4380
|
}, a = i(e[t]), o = i(e[t + 1]).map((e) => e.startsWith(":") && e.endsWith(":") ? "center" : e.endsWith(":") ? "right" : e.startsWith(":") ? "left" : "");
|
|
4367
4381
|
t += 2;
|
|
4368
4382
|
let s = [];
|
|
4369
|
-
for (; t < e.length && e[t].trim() && !
|
|
4370
|
-
let c = (e, t, n) => `<${e}${o[n] ? ` style="text-align:${o[n]}"` : ""}>${
|
|
4383
|
+
for (; t < e.length && e[t].trim() && !Ht(e[t]);) s.push(i(e[t++]));
|
|
4384
|
+
let c = (e, t, n) => `<${e}${o[n] ? ` style="text-align:${o[n]}"` : ""}>${en(t ?? "", r)}</${e}>`, l = `<table>\n<thead>\n<tr>${a.map((e, t) => c("th", e, t)).join("")}</tr>\n</thead>`;
|
|
4371
4385
|
return s.length && (l += `\n<tbody>\n${s.map((e) => `<tr>${a.map((t, n) => c("td", e[n], n)).join("")}</tr>`).join("\n")}\n</tbody>`), n.push(l + "\n</table>"), t;
|
|
4372
4386
|
}
|
|
4373
|
-
function
|
|
4374
|
-
let r =
|
|
4387
|
+
function Kt(e, t, n) {
|
|
4388
|
+
let r = en(t.trim(), n);
|
|
4375
4389
|
if (!n.ids) return `<h${e}>${r}</h${e}>`;
|
|
4376
4390
|
let i = r.replace(/<[^>]*>/g, "").replace(/&\w+;|&#\d+;/g, "").toLowerCase().replace(/[^\p{L}\p{N}\s_-]/gu, "").trim().replace(/\s+/g, "-") || "section", a = n.slugs.get(i) ?? 0;
|
|
4377
4391
|
return n.slugs.set(i, a + 1), `<h${e} id="${$(a ? `${i}-${a}` : i)}">${r}</h${e}>`;
|
|
4378
4392
|
}
|
|
4379
|
-
function
|
|
4380
|
-
let r = t.toLowerCase().replace(/[^\w+#.-]/g, ""), i =
|
|
4393
|
+
function qt(e, t, n) {
|
|
4394
|
+
let r = t.toLowerCase().replace(/[^\w+#.-]/g, ""), i = Et[r];
|
|
4381
4395
|
if (i && n.diagrams) try {
|
|
4382
|
-
return
|
|
4396
|
+
return kt(i, e).map((e) => `<figure class="md-diagram md-${i}">${e.svg}</figure>`).join("\n");
|
|
4383
4397
|
} catch (t) {
|
|
4384
|
-
return `<div class="md-diagram-error"><p>${$(
|
|
4398
|
+
return `<div class="md-diagram-error"><p>${$(Dt[i])} diagram not drawn: ${$(t.message)}</p><pre><code class="language-${r}">${$(e)}\n</code></pre></div>`;
|
|
4385
4399
|
}
|
|
4386
4400
|
return `<pre><code${r ? ` class="language-${r}"` : ""}>${$(e)}${e ? "\n" : ""}</code></pre>`;
|
|
4387
4401
|
}
|
|
4388
|
-
function
|
|
4402
|
+
function Jt(e) {
|
|
4389
4403
|
let t = e.trim();
|
|
4390
4404
|
if (/^data:image\/(png|jpe?g|gif|webp|svg\+xml|avif|bmp);/i.test(t)) return t;
|
|
4391
4405
|
let n = /^([a-z][a-z0-9+.-]*):/i.exec(t.replace(/[\u0000- ]/g, ""))?.[1].toLowerCase();
|
|
4392
4406
|
return !n || n === "http" || n === "https" ? t : void 0;
|
|
4393
4407
|
}
|
|
4394
|
-
var
|
|
4395
|
-
function
|
|
4408
|
+
var Yt = /\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g, Xt = String.raw`\(\s*(<[^>\n]*>|[^\s()]*(?:\([^\s()]*\)[^\s()]*)*)(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\)))?\s*\)`, Zt = new RegExp(String.raw`!\[((?:[^\[\]\\]|\\.|\[[^\]]*\])*)\]` + Xt, "g"), Qt = new RegExp(String.raw`\[((?:[^\[\]\\]|\\.|\[[^\]]*\])*)\]` + Xt, "g"), $t = /(!?)\[((?:[^[\]\\]|\\.)*)\](?:\[((?:[^[\]\\]|\\.)*)\])?/g;
|
|
4409
|
+
function en(e, t) {
|
|
4396
4410
|
let n = [], r = (e) => `\u0000${n.push(e) - 1}\u0001`, i = (e) => e.replace(/^<|>$/g, ""), a = (e, t, n) => {
|
|
4397
|
-
let i =
|
|
4411
|
+
let i = jt(e.replace(Yt, "$1"));
|
|
4398
4412
|
return r(i ? `<a href="${$(i)}"${n ? ` title="${$(n)}"` : ""}>${t}</a>` : t);
|
|
4399
4413
|
}, o = (e, t, n) => {
|
|
4400
|
-
let i =
|
|
4414
|
+
let i = Jt(e.replace(Yt, "$1")), a = $(t.replace(Yt, "$1").replace(/[*_~`]/g, ""));
|
|
4401
4415
|
return r(i ? `<img src="${$(i)}" alt="${a}"${n ? ` title="${$(n)}"` : ""}>` : a);
|
|
4402
4416
|
}, s = e.replace(/[\u0000\u0001]/g, "�");
|
|
4403
4417
|
s = s.replace(/(`+)(?!`)([\s\S]*?[^`])\1(?!`)/g, (e, t, n) => {
|
|
4404
4418
|
let i = n.replace(/\n/g, " ");
|
|
4405
4419
|
return r(`<code>${$(/^ .* $/.test(i) && i.trim() ? i.slice(1, -1) : i)}</code>`);
|
|
4406
|
-
}), s = s.replace(/\\\n/g, () => r("<br>\n")), s = s.replace(
|
|
4407
|
-
let s = t.refs.get(
|
|
4408
|
-
return s ? n ? o(s.href, r, s.title) : a(s.href,
|
|
4409
|
-
}), s = s.replace(/(^|[\s(*_~])((?:https?:\/\/|www\.)[^\s<\u0000]*[^\s<\u0000.,:;"')\]!?*_~])/g, (e, t, n) => t + a(n.startsWith("www.") ? "http://" + n : n, $(n))), s =
|
|
4420
|
+
}), s = s.replace(/\\\n/g, () => r("<br>\n")), s = s.replace(Yt, (e, t) => r($(t))), s = s.replace(/<((?:https?|ftp):\/\/[^\s<>]+|mailto:[^\s<>]+)>/gi, (e, t) => a(t, $(t))), s = s.replace(/<([\w.+-]+@[\w-]+(?:\.[\w-]+)+)>/g, (e, t) => a("mailto:" + t, $(t))), s = s.replace(Zt, (e, t, n, r, a, s) => o(i(n), t, r ?? a ?? s)), s = s.replace(Qt, (e, t, n, r, o, s) => a(i(n), tn(t), r ?? o ?? s)), s = s.replace($t, (e, n, r, i) => {
|
|
4421
|
+
let s = t.refs.get(Bt(i || r));
|
|
4422
|
+
return s ? n ? o(s.href, r, s.title) : a(s.href, tn(r), s.title) : e;
|
|
4423
|
+
}), s = s.replace(/(^|[\s(*_~])((?:https?:\/\/|www\.)[^\s<\u0000]*[^\s<\u0000.,:;"')\]!?*_~])/g, (e, t, n) => t + a(n.startsWith("www.") ? "http://" + n : n, $(n))), s = tn(s);
|
|
4410
4424
|
for (let e = 0; e < 4 && s.includes("\0"); e++) s = s.replace(/\u0000(\d+)\u0001/g, (e, t) => n[Number(t)]);
|
|
4411
4425
|
return s;
|
|
4412
4426
|
}
|
|
4413
|
-
function
|
|
4427
|
+
function tn(e) {
|
|
4414
4428
|
return $(e).replace(/\*\*\*(?=\S)([\s\S]*?\S)\*\*\*/g, "<strong><em>$1</em></strong>").replace(/\*\*(?=\S)([\s\S]*?\S)\*\*/g, "<strong>$1</strong>").replace(/(?<![\p{L}\p{N}_])__(?=\S)([\s\S]*?\S)__(?![\p{L}\p{N}_])/gu, "<strong>$1</strong>").replace(/\*(?=[^\s*])([\s\S]*?[^\s*])\*/g, "<em>$1</em>").replace(/(?<![\p{L}\p{N}_])_(?=[^\s_])([\s\S]*?[^\s_])_(?![\p{L}\p{N}_])/gu, "<em>$1</em>").replace(/~~(?=\S)([\s\S]*?\S)~~/g, "<del>$1</del>").replace(/ {2,}\n/g, "<br>\n");
|
|
4415
4429
|
}
|
|
4416
4430
|
// packages/markdown/src/index.ts
|
|
4417
|
-
function
|
|
4418
|
-
return
|
|
4431
|
+
function nn(e, t = {}) {
|
|
4432
|
+
return Vt(e, t);
|
|
4419
4433
|
}
|
|
4420
|
-
function
|
|
4421
|
-
e.innerHTML =
|
|
4434
|
+
function rn(e, t, n = {}) {
|
|
4435
|
+
e.innerHTML = Vt(t, n);
|
|
4422
4436
|
}
|
|
4423
|
-
export {
|
|
4437
|
+
export { nn as render, rn as renderTo };
|
|
4424
4438
|
|
|
4425
4439
|
//# sourceMappingURL=index.js.map
|