@zombie-mermaid/core 3.2.0 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +8 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +38 -15
- package/dist/index.d.ts +38 -15
- package/dist/index.js +179 -144
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/cluster-edges.test.ts +47 -0
- package/src/__tests__/theme.test.ts +18 -15
- package/src/cluster-edges.ts +78 -0
- package/src/index.ts +1 -0
- package/src/theme.ts +22 -22
- package/src/generated/mono-font-subset.ts +0 -32
package/dist/index.js
CHANGED
|
@@ -22,36 +22,71 @@ function t(e) {
|
|
|
22
22
|
return n === void 0 || /^(https?|mailto)$/i.test(n) ? t : void 0;
|
|
23
23
|
}
|
|
24
24
|
//#endregion
|
|
25
|
+
//#region packages/core/src/cluster-edges.ts
|
|
26
|
+
function n(e, t) {
|
|
27
|
+
t.set(e.id, e);
|
|
28
|
+
for (let r of e.children) n(r, t);
|
|
29
|
+
}
|
|
30
|
+
function r(e, t) {
|
|
31
|
+
let n = (e, n) => {
|
|
32
|
+
let r = t.get(e);
|
|
33
|
+
if (!r) return !1;
|
|
34
|
+
let a = /* @__PURE__ */ new Set();
|
|
35
|
+
return i(r, a), a.has(n);
|
|
36
|
+
};
|
|
37
|
+
return n(e.target, e.source) || n(e.source, e.target);
|
|
38
|
+
}
|
|
39
|
+
function i(e, t) {
|
|
40
|
+
for (let n of e.nodeIds) t.add(n);
|
|
41
|
+
for (let n of e.children) t.add(n.id), i(n, t);
|
|
42
|
+
}
|
|
43
|
+
function a(e) {
|
|
44
|
+
if (e.subgraphs.length === 0) return e;
|
|
45
|
+
let t = /* @__PURE__ */ new Map();
|
|
46
|
+
for (let r of e.subgraphs) n(r, t);
|
|
47
|
+
let i = e.edges.filter((e) => !r(e, t));
|
|
48
|
+
if (i.length === e.edges.length) return e;
|
|
49
|
+
let a = /* @__PURE__ */ new Set();
|
|
50
|
+
for (let e of i) a.add(e.source), a.add(e.target);
|
|
51
|
+
let o = new Map(e.nodes);
|
|
52
|
+
for (let e of t.keys()) a.has(e) || o.delete(e);
|
|
53
|
+
return {
|
|
54
|
+
...e,
|
|
55
|
+
nodes: o,
|
|
56
|
+
edges: i
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
25
60
|
//#region packages/core/src/color-utils.ts
|
|
26
|
-
var
|
|
27
|
-
function
|
|
28
|
-
let t =
|
|
61
|
+
var o = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/, s = /^rgba?\(\s*([\d.]+%?)\s*[, ]\s*([\d.]+%?)\s*[, ]\s*([\d.]+%?)\s*(?:[,/]\s*([\d.]+%?)\s*)?\)$/i;
|
|
62
|
+
function c(e) {
|
|
63
|
+
let t = l(e);
|
|
29
64
|
return t ? [
|
|
30
65
|
t.r,
|
|
31
66
|
t.g,
|
|
32
67
|
t.b
|
|
33
68
|
] : null;
|
|
34
69
|
}
|
|
35
|
-
function
|
|
36
|
-
let t =
|
|
70
|
+
function l(e) {
|
|
71
|
+
let t = o.exec(e.trim());
|
|
37
72
|
if (!t) return null;
|
|
38
|
-
let
|
|
39
|
-
if (
|
|
40
|
-
let
|
|
41
|
-
return (
|
|
42
|
-
r: parseInt(
|
|
43
|
-
g: parseInt(
|
|
44
|
-
b: parseInt(
|
|
45
|
-
a:
|
|
73
|
+
let n = t[1];
|
|
74
|
+
if (n === void 0) return null;
|
|
75
|
+
let r = n;
|
|
76
|
+
return (r.length === 3 || r.length === 4) && (r = r.split("").map((e) => e + e).join("")), {
|
|
77
|
+
r: parseInt(r.slice(0, 2), 16),
|
|
78
|
+
g: parseInt(r.slice(2, 4), 16),
|
|
79
|
+
b: parseInt(r.slice(4, 6), 16),
|
|
80
|
+
a: r.length === 8 ? parseInt(r.slice(6, 8), 16) / 255 : 1
|
|
46
81
|
};
|
|
47
82
|
}
|
|
48
|
-
function
|
|
83
|
+
function u(e) {
|
|
49
84
|
return e.endsWith("%") ? Number(e.slice(0, -1)) / 100 * 255 : Number(e);
|
|
50
85
|
}
|
|
51
|
-
function
|
|
86
|
+
function ee(e) {
|
|
52
87
|
return e === void 0 ? 1 : e.endsWith("%") ? Number(e.slice(0, -1)) / 100 : Number(e);
|
|
53
88
|
}
|
|
54
|
-
function
|
|
89
|
+
function d(e) {
|
|
55
90
|
let t = e.trim();
|
|
56
91
|
if (t.toLowerCase() === "transparent") return {
|
|
57
92
|
r: 0,
|
|
@@ -59,17 +94,17 @@ function c(e) {
|
|
|
59
94
|
b: 0,
|
|
60
95
|
a: 0
|
|
61
96
|
};
|
|
62
|
-
let n =
|
|
97
|
+
let n = l(t);
|
|
63
98
|
if (n) return n;
|
|
64
|
-
let
|
|
65
|
-
if (
|
|
66
|
-
let [, e, t, n,
|
|
99
|
+
let r = s.exec(t);
|
|
100
|
+
if (r) {
|
|
101
|
+
let [, e, t, n, i] = r;
|
|
67
102
|
if (e === void 0 || t === void 0 || n === void 0) return null;
|
|
68
103
|
let a = {
|
|
69
|
-
r:
|
|
70
|
-
g:
|
|
71
|
-
b:
|
|
72
|
-
a:
|
|
104
|
+
r: u(e),
|
|
105
|
+
g: u(t),
|
|
106
|
+
b: u(n),
|
|
107
|
+
a: ee(i)
|
|
73
108
|
};
|
|
74
109
|
return [
|
|
75
110
|
a.r,
|
|
@@ -80,7 +115,7 @@ function c(e) {
|
|
|
80
115
|
}
|
|
81
116
|
return null;
|
|
82
117
|
}
|
|
83
|
-
function
|
|
118
|
+
function f(e, t, n, r) {
|
|
84
119
|
let i, a;
|
|
85
120
|
n === void 0 && r === void 0 ? (i = 50, a = 50) : n === void 0 ? (a = r ?? 50, i = 100 - a) : r === void 0 ? (i = n, a = 100 - i) : (i = n, a = r);
|
|
86
121
|
let o = i + a;
|
|
@@ -95,15 +130,15 @@ function l(e, t, n, r) {
|
|
|
95
130
|
a: c * s
|
|
96
131
|
};
|
|
97
132
|
}
|
|
98
|
-
function
|
|
99
|
-
let r =
|
|
133
|
+
function te(e, t, n) {
|
|
134
|
+
let r = d(e), i = d(t);
|
|
100
135
|
if (!r || !i) return e;
|
|
101
|
-
let a =
|
|
102
|
-
return a ?
|
|
136
|
+
let a = f(r, i, n, 100 - n);
|
|
137
|
+
return a ? m(a) : e;
|
|
103
138
|
}
|
|
104
|
-
var
|
|
105
|
-
function
|
|
106
|
-
let t =
|
|
139
|
+
var p = (e) => Math.min(255, Math.max(0, Math.round(e)));
|
|
140
|
+
function m(e) {
|
|
141
|
+
let t = p(e.r), n = p(e.g), r = p(e.b), i = Math.min(1, Math.max(0, e.a));
|
|
107
142
|
return i >= 1 ? "#" + [
|
|
108
143
|
t,
|
|
109
144
|
n,
|
|
@@ -112,8 +147,8 @@ function f(e) {
|
|
|
112
147
|
}
|
|
113
148
|
//#endregion
|
|
114
149
|
//#region packages/core/src/statements.ts
|
|
115
|
-
var
|
|
116
|
-
function
|
|
150
|
+
var h = /^[&#](?:#?[0-9]+|#?[xX][0-9a-fA-F]+|[a-zA-Z][a-zA-Z0-9]*);/, g = /* @__PURE__ */ new Set(["&", "#"]);
|
|
151
|
+
function _(e) {
|
|
117
152
|
let t = null;
|
|
118
153
|
for (let n = 0; n < e.length; n++) {
|
|
119
154
|
let r = e[n];
|
|
@@ -125,8 +160,8 @@ function ee(e) {
|
|
|
125
160
|
t = r;
|
|
126
161
|
continue;
|
|
127
162
|
}
|
|
128
|
-
if (
|
|
129
|
-
let t =
|
|
163
|
+
if (g.has(r)) {
|
|
164
|
+
let t = h.exec(e.slice(n));
|
|
130
165
|
if (t) {
|
|
131
166
|
n += t[0].length - 1;
|
|
132
167
|
continue;
|
|
@@ -136,7 +171,7 @@ function ee(e) {
|
|
|
136
171
|
}
|
|
137
172
|
return -1;
|
|
138
173
|
}
|
|
139
|
-
function
|
|
174
|
+
function ne(e) {
|
|
140
175
|
let t = [], n = "", r = null;
|
|
141
176
|
for (let i = 0; i < e.length; i++) {
|
|
142
177
|
let a = e[i];
|
|
@@ -148,8 +183,8 @@ function h(e) {
|
|
|
148
183
|
r = a, n += a;
|
|
149
184
|
continue;
|
|
150
185
|
}
|
|
151
|
-
if (
|
|
152
|
-
let t =
|
|
186
|
+
if (g.has(a)) {
|
|
187
|
+
let t = h.exec(e.slice(i));
|
|
153
188
|
if (t) {
|
|
154
189
|
n += t[0], i += t[0].length - 1;
|
|
155
190
|
continue;
|
|
@@ -163,13 +198,13 @@ function h(e) {
|
|
|
163
198
|
}
|
|
164
199
|
return t.push(n), t;
|
|
165
200
|
}
|
|
166
|
-
function
|
|
201
|
+
function v(e) {
|
|
167
202
|
let t = [], n = e.split("\n");
|
|
168
203
|
for (let e = 0; e < n.length; e++) {
|
|
169
|
-
let r = n[e].trim(), i = e + 1, a =
|
|
204
|
+
let r = n[e].trim(), i = e + 1, a = _(r);
|
|
170
205
|
if (a !== -1 && (r = r.slice(0, a).trim()), r.length === 0) continue;
|
|
171
206
|
let o = [];
|
|
172
|
-
for (let e of
|
|
207
|
+
for (let e of ne(r)) {
|
|
173
208
|
let t = e.trim();
|
|
174
209
|
t.length !== 0 && o.push({
|
|
175
210
|
text: t,
|
|
@@ -180,12 +215,12 @@ function g(e) {
|
|
|
180
215
|
}
|
|
181
216
|
return t;
|
|
182
217
|
}
|
|
183
|
-
function
|
|
184
|
-
return
|
|
218
|
+
function y(e) {
|
|
219
|
+
return v(e).flat();
|
|
185
220
|
}
|
|
186
221
|
//#endregion
|
|
187
222
|
//#region packages/core/src/diagram-type.ts
|
|
188
|
-
var
|
|
223
|
+
var re = [
|
|
189
224
|
"flowchart",
|
|
190
225
|
"sequence",
|
|
191
226
|
"class",
|
|
@@ -194,38 +229,38 @@ var v = [
|
|
|
194
229
|
"architecture",
|
|
195
230
|
"c4"
|
|
196
231
|
];
|
|
197
|
-
function
|
|
198
|
-
let t =
|
|
232
|
+
function b(e) {
|
|
233
|
+
let t = y(e)[0]?.text.toLowerCase() ?? "";
|
|
199
234
|
return /^xychart(?:-beta)?(?:\s|$)/.test(t) ? "xychart" : /^architecture(?:-beta)?\s*$/.test(t) ? "architecture" : /^c4(?:context|container|component|dynamic|deployment)\s*$/.test(t) ? "c4" : /^sequencediagram\s*$/.test(t) ? "sequence" : /^classdiagram\s*$/.test(t) ? "class" : /^erdiagram\s*$/.test(t) ? "er" : "flowchart";
|
|
200
235
|
}
|
|
201
236
|
//#endregion
|
|
202
237
|
//#region packages/core/src/direction.ts
|
|
203
|
-
function
|
|
238
|
+
function x(e) {
|
|
204
239
|
return e === "TD" || e === "TB" || e === "LR" || e === "BT" || e === "RL";
|
|
205
240
|
}
|
|
206
|
-
function
|
|
241
|
+
function S(e) {
|
|
207
242
|
let t = e?.toUpperCase();
|
|
208
|
-
if (t === void 0 || !
|
|
243
|
+
if (t === void 0 || !x(t)) throw Error(`Invalid direction: "${e}"`);
|
|
209
244
|
return t;
|
|
210
245
|
}
|
|
211
246
|
//#endregion
|
|
212
247
|
//#region packages/core/src/direction-override.ts
|
|
213
|
-
function
|
|
214
|
-
return t === void 0 || !
|
|
248
|
+
function C(e, t) {
|
|
249
|
+
return t === void 0 || !x(t) ? e : {
|
|
215
250
|
...e,
|
|
216
251
|
direction: t
|
|
217
252
|
};
|
|
218
253
|
}
|
|
219
254
|
//#endregion
|
|
220
255
|
//#region packages/core/src/init-directive.ts
|
|
221
|
-
var
|
|
256
|
+
var ie = /* @__PURE__ */ new Set([
|
|
222
257
|
"linear",
|
|
223
258
|
"basis",
|
|
224
259
|
"natural",
|
|
225
260
|
"step",
|
|
226
261
|
"stepBefore",
|
|
227
262
|
"stepAfter"
|
|
228
|
-
]),
|
|
263
|
+
]), w = {
|
|
229
264
|
theme: "colors come from the caller's bg/fg render options, which are usually CSS variables so a diagram inherits the host page's light/dark. A diagram-supplied theme would hard-code colors that fight it. Mermaid's theme names (default/dark/forest/neutral) also have no equivalent in this renderer's palettes — pass `bg`/`fg`, or a THEMES entry, instead",
|
|
230
265
|
securitylevel: "this renderer emits static SVG and never executes diagram-supplied script, so there is no sandbox to configure",
|
|
231
266
|
defaultrenderer: "ELK is the only layout engine; dagre/elk selection has no effect",
|
|
@@ -233,11 +268,11 @@ var x = /* @__PURE__ */ new Set([
|
|
|
233
268
|
htmllabels: "labels are always rendered as SVG text; there is no HTML label mode",
|
|
234
269
|
maxtextsize: "no text-size limit is enforced",
|
|
235
270
|
startonload: "not a browser auto-render integration"
|
|
236
|
-
},
|
|
237
|
-
function
|
|
238
|
-
return
|
|
271
|
+
}, T = /^\s*%%\{\s*(?:init|initialize)\s*:\s*([\s\S]*?)\}%%/i;
|
|
272
|
+
function ae(e) {
|
|
273
|
+
return T.test(e);
|
|
239
274
|
}
|
|
240
|
-
function
|
|
275
|
+
function oe(e) {
|
|
241
276
|
let t = "", n = null;
|
|
242
277
|
for (let r = 0; r < e.length; r++) {
|
|
243
278
|
let i = e[r];
|
|
@@ -268,12 +303,12 @@ function re(e) {
|
|
|
268
303
|
}
|
|
269
304
|
return t;
|
|
270
305
|
}
|
|
271
|
-
function
|
|
272
|
-
let t = e.match(
|
|
306
|
+
function E(e) {
|
|
307
|
+
let t = e.match(T);
|
|
273
308
|
if (!t) return;
|
|
274
309
|
let n;
|
|
275
310
|
try {
|
|
276
|
-
n = JSON.parse(
|
|
311
|
+
n = JSON.parse(oe(t[1]));
|
|
277
312
|
} catch {
|
|
278
313
|
return;
|
|
279
314
|
}
|
|
@@ -289,37 +324,37 @@ function T(e) {
|
|
|
289
324
|
let e = { ...t };
|
|
290
325
|
for (let [t, n] of Object.entries(e)) {
|
|
291
326
|
if (t.toLowerCase() === "curve" && typeof n == "string") {
|
|
292
|
-
|
|
327
|
+
ie.has(n) && (r.curve = n);
|
|
293
328
|
continue;
|
|
294
329
|
}
|
|
295
|
-
t.toLowerCase() in
|
|
330
|
+
t.toLowerCase() in w && r.ignored.push(t);
|
|
296
331
|
}
|
|
297
332
|
continue;
|
|
298
333
|
}
|
|
299
|
-
n in
|
|
334
|
+
n in w && r.ignored.push(e);
|
|
300
335
|
}
|
|
301
336
|
return r;
|
|
302
337
|
}
|
|
303
|
-
function
|
|
338
|
+
function se(e) {
|
|
304
339
|
let t = { ignored: [] };
|
|
305
340
|
for (let n of e) {
|
|
306
|
-
let e =
|
|
341
|
+
let e = E(n);
|
|
307
342
|
e && (e.theme !== void 0 && (t.theme = e.theme), e.curve !== void 0 && (t.curve = e.curve), t.ignored.push(...e.ignored));
|
|
308
343
|
}
|
|
309
344
|
return t;
|
|
310
345
|
}
|
|
311
|
-
function
|
|
346
|
+
function ce(e, t) {
|
|
312
347
|
return t.curve === void 0 || e.curve !== void 0 ? e : {
|
|
313
348
|
...e,
|
|
314
349
|
curve: t.curve
|
|
315
350
|
};
|
|
316
351
|
}
|
|
317
|
-
function
|
|
318
|
-
return [...new Set(e.ignored)].map((e) => `${e}: ${
|
|
352
|
+
function le(e) {
|
|
353
|
+
return [...new Set(e.ignored)].map((e) => `${e}: ${w[e.toLowerCase()] ?? "not supported"}`);
|
|
319
354
|
}
|
|
320
355
|
//#endregion
|
|
321
356
|
//#region packages/core/src/text-metrics.ts
|
|
322
|
-
var
|
|
357
|
+
var D = {
|
|
323
358
|
" ": .521,
|
|
324
359
|
"!": .533,
|
|
325
360
|
"\"": .863,
|
|
@@ -416,10 +451,10 @@ var E = {
|
|
|
416
451
|
"}": .789,
|
|
417
452
|
"~": 1.225
|
|
418
453
|
};
|
|
419
|
-
function
|
|
420
|
-
return Object.hasOwn(
|
|
454
|
+
function ue(e) {
|
|
455
|
+
return Object.hasOwn(D, e);
|
|
421
456
|
}
|
|
422
|
-
var
|
|
457
|
+
var de = /* @__PURE__ */ new Set([
|
|
423
458
|
"i",
|
|
424
459
|
"l",
|
|
425
460
|
"t",
|
|
@@ -434,14 +469,14 @@ var ce = /* @__PURE__ */ new Set([
|
|
|
434
469
|
":",
|
|
435
470
|
";",
|
|
436
471
|
"'"
|
|
437
|
-
]),
|
|
472
|
+
]), fe = /* @__PURE__ */ new Set([
|
|
438
473
|
"W",
|
|
439
474
|
"M",
|
|
440
475
|
"w",
|
|
441
476
|
"m",
|
|
442
477
|
"@",
|
|
443
478
|
"%"
|
|
444
|
-
]),
|
|
479
|
+
]), pe = /* @__PURE__ */ new Set(["W", "M"]), me = /* @__PURE__ */ new Set([
|
|
445
480
|
"(",
|
|
446
481
|
")",
|
|
447
482
|
"[",
|
|
@@ -454,68 +489,68 @@ var ce = /* @__PURE__ */ new Set([
|
|
|
454
489
|
"\"",
|
|
455
490
|
"`"
|
|
456
491
|
]);
|
|
457
|
-
function
|
|
492
|
+
function he(e) {
|
|
458
493
|
return e >= 768 && e <= 879 || e >= 6832 && e <= 6911 || e >= 7616 && e <= 7679 || e >= 8400 && e <= 8447 || e >= 65056 && e <= 65071;
|
|
459
494
|
}
|
|
460
|
-
function
|
|
495
|
+
function O(e) {
|
|
461
496
|
return e >= 4352 && e <= 4447 || e >= 11904 && e <= 12031 || e >= 12032 && e <= 12255 || e >= 12288 && e <= 12351 || e >= 12352 && e <= 12447 || e >= 12448 && e <= 12543 || e >= 12544 && e <= 12591 || e >= 12592 && e <= 12687 || e >= 12688 && e <= 12799 || e >= 12800 && e <= 13311 || e >= 13312 && e <= 19903 || e >= 19968 && e <= 40959 || e >= 44032 && e <= 55215 || e >= 63744 && e <= 64255 || e >= 65280 && e <= 65376 || e >= 65504 && e <= 65510 || e >= 131072;
|
|
462
497
|
}
|
|
463
|
-
var
|
|
464
|
-
function
|
|
498
|
+
var k = /\p{Emoji_Presentation}/u, A = /\p{Extended_Pictographic}/u;
|
|
499
|
+
function j(e) {
|
|
465
500
|
return e >= 9632 && e <= 9727;
|
|
466
501
|
}
|
|
467
|
-
function
|
|
502
|
+
function M(e) {
|
|
468
503
|
return e >= 8596 && e <= 8601 || e === 8617 || e === 8618;
|
|
469
504
|
}
|
|
470
|
-
function
|
|
471
|
-
if (
|
|
505
|
+
function N(e) {
|
|
506
|
+
if (k.test(e)) return !0;
|
|
472
507
|
let t = e.codePointAt(0);
|
|
473
|
-
return t !== void 0 &&
|
|
508
|
+
return t !== void 0 && j(t) || t !== void 0 && M(t) ? !1 : A.test(e);
|
|
474
509
|
}
|
|
475
|
-
function
|
|
510
|
+
function P(e) {
|
|
476
511
|
let t = e.codePointAt(0);
|
|
477
|
-
return t === void 0 ? !1 :
|
|
512
|
+
return t === void 0 ? !1 : O(t) || N(e);
|
|
478
513
|
}
|
|
479
|
-
function
|
|
514
|
+
function F(e) {
|
|
480
515
|
let t = e.codePointAt(0);
|
|
481
516
|
if (t === void 0) return 0;
|
|
482
|
-
if (Object.hasOwn(
|
|
483
|
-
let t =
|
|
517
|
+
if (Object.hasOwn(D, e)) {
|
|
518
|
+
let t = D[e];
|
|
484
519
|
/* v8 ignore else */
|
|
485
520
|
if (t !== void 0) return t;
|
|
486
521
|
}
|
|
487
|
-
if (
|
|
488
|
-
if (
|
|
522
|
+
if (he(t)) return 0;
|
|
523
|
+
if (O(t) || N(e)) return 2;
|
|
489
524
|
let n = e.normalize("NFD")[0];
|
|
490
525
|
if (n !== void 0 && n !== e) {
|
|
491
|
-
let e =
|
|
526
|
+
let e = D[n];
|
|
492
527
|
if (e !== void 0) return e;
|
|
493
528
|
}
|
|
494
|
-
return e === " " ? .3 :
|
|
529
|
+
return e === " " ? .3 : pe.has(e) ? 1.5 : fe.has(e) ? 1.2 : de.has(e) ? .4 : me.has(e) ? .5 : e === "r" ? .8 : t >= 65 && t <= 90 ? 1.2 : 1;
|
|
495
530
|
}
|
|
496
|
-
var
|
|
497
|
-
function
|
|
531
|
+
var I = .6, L = !1;
|
|
532
|
+
function R(e) {
|
|
498
533
|
return /mono|consol|menlo|courier|\bcode\b/i.test(e);
|
|
499
534
|
}
|
|
500
|
-
function
|
|
501
|
-
|
|
535
|
+
function ge(e) {
|
|
536
|
+
L = e;
|
|
502
537
|
}
|
|
503
|
-
function
|
|
538
|
+
function z(e, t, n) {
|
|
504
539
|
let r = t * .15;
|
|
505
|
-
if (
|
|
540
|
+
if (L) {
|
|
506
541
|
let n = 0;
|
|
507
542
|
for (let t of e) n += 1;
|
|
508
|
-
return n * t *
|
|
543
|
+
return n * t * I + r;
|
|
509
544
|
}
|
|
510
545
|
let i = n >= 600 ? .6 : n >= 500 ? .57 : .54, a = 0;
|
|
511
|
-
for (let t of e) a +=
|
|
546
|
+
for (let t of e) a += F(t);
|
|
512
547
|
return a * t * i + r;
|
|
513
548
|
}
|
|
514
|
-
var
|
|
515
|
-
function
|
|
516
|
-
let r = e.split("\n"), i = t *
|
|
549
|
+
var B = 1.3;
|
|
550
|
+
function _e(e, t, n) {
|
|
551
|
+
let r = e.split("\n"), i = t * B, a = 0;
|
|
517
552
|
for (let e of r) {
|
|
518
|
-
let r =
|
|
553
|
+
let r = z(e.replace(/<\/?(?:b|strong|i|em|u|s|del)\s*>/gi, ""), t, n);
|
|
519
554
|
r > a && (a = r);
|
|
520
555
|
}
|
|
521
556
|
return {
|
|
@@ -527,24 +562,24 @@ function B(e, t, n) {
|
|
|
527
562
|
}
|
|
528
563
|
//#endregion
|
|
529
564
|
//#region packages/core/src/render-utils.ts
|
|
530
|
-
function
|
|
565
|
+
function ve(e) {
|
|
531
566
|
return Number.isFinite(e) ? Number(e.toFixed(2)) : 0;
|
|
532
567
|
}
|
|
533
568
|
function V(e, ...t) {
|
|
534
569
|
let n = e[0] ?? "";
|
|
535
570
|
for (let r = 0; r < t.length; r++) {
|
|
536
571
|
let i = t[r];
|
|
537
|
-
n += String(typeof i == "number" ?
|
|
572
|
+
n += String(typeof i == "number" ? ve(i) : i), n += e[r + 1] ?? "";
|
|
538
573
|
}
|
|
539
574
|
return n;
|
|
540
575
|
}
|
|
541
576
|
//#endregion
|
|
542
577
|
//#region packages/core/src/multiline-utils.ts
|
|
543
|
-
function
|
|
578
|
+
function ye(e) {
|
|
544
579
|
let t = e.startsWith("\"") && e.endsWith("\"") ? e.slice(1, -1) : e;
|
|
545
580
|
return (t.length >= 2 && t.startsWith("`") && t.endsWith("`") ? t.slice(1, -1) : t).replace(/<br\s*\/?>/gi, "\n").replace(/\\n/g, "\n").replace(/<\/?(?:sub|sup|small|mark)\s*>/gi, "").replace(/\*\*(.+?)\*\*/g, "<b>$1</b>").replace(/(?<!\*)\*([^\s*](?:[^*]*[^\s*])?)\*(?!\*)/g, "<i>$1</i>").replace(/~~(.+?)~~/g, "<s>$1</s>");
|
|
546
581
|
}
|
|
547
|
-
function
|
|
582
|
+
function be(e) {
|
|
548
583
|
return e.replace(/<\/?(?:b|strong|i|em|u|s|del)\s*>/gi, "");
|
|
549
584
|
}
|
|
550
585
|
function H(e) {
|
|
@@ -554,7 +589,7 @@ function U(e) {
|
|
|
554
589
|
return e.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
555
590
|
}
|
|
556
591
|
var W = /<(\/)?(?:(b|strong)|(i|em)|(u)|(s|del))\s*>/gi;
|
|
557
|
-
function
|
|
592
|
+
function xe(e) {
|
|
558
593
|
let t = [], n = !1, r = !1, i = !1, a = !1, o = 0;
|
|
559
594
|
W.lastIndex = 0;
|
|
560
595
|
let s;
|
|
@@ -577,10 +612,10 @@ function _e(e) {
|
|
|
577
612
|
strikethrough: a
|
|
578
613
|
}), t;
|
|
579
614
|
}
|
|
580
|
-
var
|
|
615
|
+
var Se = /<\/?(?:b|strong|i|em|u|s|del)\s*>/i;
|
|
581
616
|
function G(e) {
|
|
582
|
-
if (!
|
|
583
|
-
let t =
|
|
617
|
+
if (!Se.test(e)) return H(e);
|
|
618
|
+
let t = xe(e);
|
|
584
619
|
return t.length === 0 ? "" : t.every((e) => !e.bold && !e.italic && !e.underline && !e.strikethrough) ? t.map((e) => H(e.text)).join("") : t.map((e) => {
|
|
585
620
|
let t = H(e.text);
|
|
586
621
|
if (!e.bold && !e.italic && !e.underline && !e.strikethrough) return t;
|
|
@@ -593,10 +628,10 @@ function G(e) {
|
|
|
593
628
|
function K(e, t, n, r, i, a = .35) {
|
|
594
629
|
let o = e.split("\n");
|
|
595
630
|
if (o.length === 1) return V`<text x="${t}" y="${n}" ${i} dy="${r * a}">${G(e)}</text>`;
|
|
596
|
-
let s = r *
|
|
631
|
+
let s = r * B, c = -((o.length - 1) / 2) * s + r * a;
|
|
597
632
|
return V`<text x="${t}" y="${n}" ${i}>${o.map((e, n) => V`<tspan x="${t}" dy="${n === 0 ? c : s}">${G(e)}</tspan>`).join("")}</text>`;
|
|
598
633
|
}
|
|
599
|
-
function
|
|
634
|
+
function Ce(e, t, n, r, i, a, o, s, c) {
|
|
600
635
|
let l = r + o * 2, u = i + o * 2;
|
|
601
636
|
return `${V`<rect x="${t - l / 2}" y="${n - u / 2}" ` + V`width="${l}" height="${u}" ${c} />`}\n${K(e, t, n, a, s)}`;
|
|
602
637
|
}
|
|
@@ -613,7 +648,7 @@ function q(e) {
|
|
|
613
648
|
}
|
|
614
649
|
return n;
|
|
615
650
|
}
|
|
616
|
-
function
|
|
651
|
+
function we(e, t) {
|
|
617
652
|
let n = e.match(/^classDef\s+([\w,-]+)\s+(.+)$/);
|
|
618
653
|
if (!n) return !1;
|
|
619
654
|
let r = q(n[2]);
|
|
@@ -623,14 +658,14 @@ function be(e, t) {
|
|
|
623
658
|
}
|
|
624
659
|
return !0;
|
|
625
660
|
}
|
|
626
|
-
function
|
|
661
|
+
function Te(e, t) {
|
|
627
662
|
let n = e.match(/^class\s+([\w-]+(?:\s*,\s*[\w-]+)*)\s+([\w-]+)\s*;?\s*$/);
|
|
628
663
|
if (!n) return !1;
|
|
629
664
|
let r = n[2];
|
|
630
665
|
for (let e of n[1].split(",")) t.classAssignments.set(e.trim(), r);
|
|
631
666
|
return !0;
|
|
632
667
|
}
|
|
633
|
-
function
|
|
668
|
+
function Ee(e, t) {
|
|
634
669
|
let n = e.match(/^cssClass\s+"([^"]*)"\s+([\w-]+)\s*;?\s*$/);
|
|
635
670
|
if (!n) return !1;
|
|
636
671
|
let r = n[2];
|
|
@@ -640,7 +675,7 @@ function Se(e, t) {
|
|
|
640
675
|
}
|
|
641
676
|
return !0;
|
|
642
677
|
}
|
|
643
|
-
function
|
|
678
|
+
function De(e, t) {
|
|
644
679
|
let n = e.match(/^style\s+([\w,-]+)\s+(.+)$/);
|
|
645
680
|
if (!n) return !1;
|
|
646
681
|
let r = q(n[2]);
|
|
@@ -650,14 +685,14 @@ function Ce(e, t) {
|
|
|
650
685
|
});
|
|
651
686
|
return !0;
|
|
652
687
|
}
|
|
653
|
-
function
|
|
688
|
+
function Oe(e) {
|
|
654
689
|
let t = e.match(/^(.+?):::([\w][\w-]*)$/);
|
|
655
690
|
return t ? {
|
|
656
691
|
id: t[1],
|
|
657
692
|
className: t[2]
|
|
658
693
|
} : { id: e };
|
|
659
694
|
}
|
|
660
|
-
function
|
|
695
|
+
function ke(e, t) {
|
|
661
696
|
let n, r = t.classDefs.get("default");
|
|
662
697
|
r && (n = { ...r });
|
|
663
698
|
let i = t.classAssignments.get(e);
|
|
@@ -674,12 +709,12 @@ function Te(e, t) {
|
|
|
674
709
|
...a
|
|
675
710
|
} : { ...a }), n;
|
|
676
711
|
}
|
|
677
|
-
function
|
|
712
|
+
function Ae(e) {
|
|
678
713
|
if (e) return /^-?[a-zA-Z_][a-zA-Z0-9_-]*$/.test(e) ? e : void 0;
|
|
679
714
|
}
|
|
680
715
|
//#endregion
|
|
681
|
-
//#region packages/core/src/
|
|
682
|
-
var
|
|
716
|
+
//#region packages/core/src/theme.ts
|
|
717
|
+
var je = {
|
|
683
718
|
bg: "#FFFFFF",
|
|
684
719
|
fg: "#27272A"
|
|
685
720
|
}, J = {
|
|
@@ -694,7 +729,7 @@ var De = "JetBrains Mono NL", Oe = "@font-face {\n font-family: 'JetBrains Mono
|
|
|
694
729
|
groupHeader: 5,
|
|
695
730
|
innerStroke: 12,
|
|
696
731
|
keyBadge: 10
|
|
697
|
-
},
|
|
732
|
+
}, Me = {
|
|
698
733
|
"zinc-light": {
|
|
699
734
|
bg: "#FFFFFF",
|
|
700
735
|
fg: "#27272A"
|
|
@@ -795,7 +830,7 @@ var De = "JetBrains Mono NL", Oe = "@font-face {\n font-family: 'JetBrains Mono
|
|
|
795
830
|
muted: "#5c6370"
|
|
796
831
|
}
|
|
797
832
|
};
|
|
798
|
-
function
|
|
833
|
+
function Ne(e) {
|
|
799
834
|
let t = e.colors ?? {}, n = e.type === "dark", r = (t) => e.tokenColors?.find((e) => Array.isArray(e.scope) ? e.scope.includes(t) : e.scope === t)?.settings?.foreground;
|
|
800
835
|
return {
|
|
801
836
|
bg: t["editor.background"] ?? (n ? "#1e1e1e" : "#ffffff"),
|
|
@@ -807,16 +842,16 @@ function je(e) {
|
|
|
807
842
|
border: t["editorWidget.border"] ?? void 0
|
|
808
843
|
};
|
|
809
844
|
}
|
|
810
|
-
var
|
|
811
|
-
function
|
|
845
|
+
var Pe = /[<>{};]/;
|
|
846
|
+
function Fe(e) {
|
|
812
847
|
let t = e.trim();
|
|
813
|
-
if (!t.startsWith("var(") || !t.endsWith(")") ||
|
|
848
|
+
if (!t.startsWith("var(") || !t.endsWith(")") || Pe.test(t)) return !1;
|
|
814
849
|
let n = 0;
|
|
815
850
|
for (let e of t) if (e === "(") n++;
|
|
816
851
|
else if (e === ")" && (n--, n < 0)) return !1;
|
|
817
852
|
return n === 0;
|
|
818
853
|
}
|
|
819
|
-
var
|
|
854
|
+
var Ie = /* @__PURE__ */ new Set([
|
|
820
855
|
"sans-serif",
|
|
821
856
|
"serif",
|
|
822
857
|
"monospace",
|
|
@@ -831,15 +866,15 @@ var Ne = /* @__PURE__ */ new Set([
|
|
|
831
866
|
"emoji",
|
|
832
867
|
"fangsong"
|
|
833
868
|
]);
|
|
834
|
-
function
|
|
869
|
+
function Le(e) {
|
|
835
870
|
let t = e.trim();
|
|
836
|
-
return t.includes(",") ? !0 :
|
|
871
|
+
return t.includes(",") ? !0 : Ie.has(t.toLowerCase());
|
|
837
872
|
}
|
|
838
|
-
function
|
|
873
|
+
function Y(e) {
|
|
839
874
|
return e === void 0 || e.trim() === "" ? "<style>" : `<style nonce="${U(e)}">`;
|
|
840
875
|
}
|
|
841
|
-
function
|
|
842
|
-
let r =
|
|
876
|
+
function X(e, t, n) {
|
|
877
|
+
let r = Fe(e), i = r ? e.trim() : e.replace(/[<>{};'"]/g, ""), a = r || Le(e) ? [] : [`@import url('https://fonts.googleapis.com/css2?family=${encodeURIComponent(i)}:wght@400;500;600;700&display=swap');`], o = `
|
|
843
878
|
/* Derived from --bg and --fg (overridable via --line, --accent, etc.) */
|
|
844
879
|
--_text: var(--fg);
|
|
845
880
|
--_text-sec: var(--muted, color-mix(in srgb, var(--fg) ${J.textSec}%, var(--bg)));
|
|
@@ -854,29 +889,29 @@ function Fe(e, t, n) {
|
|
|
854
889
|
--_inner-stroke: color-mix(in srgb, var(--fg) ${J.innerStroke}%, var(--bg));
|
|
855
890
|
--_key-badge: color-mix(in srgb, var(--fg) ${J.keyBadge}%, var(--bg));`;
|
|
856
891
|
return [
|
|
857
|
-
|
|
892
|
+
Y(n),
|
|
858
893
|
...a.length > 0 ? [` ${a.join("\n ")}`] : [],
|
|
859
|
-
...t ? [` ${
|
|
894
|
+
...t ? [` ${t.faceCss}`] : [],
|
|
860
895
|
` text { font-family: ${r ? i : `'${i}'`}, system-ui, sans-serif; }`,
|
|
861
|
-
...t ? [` .mono { font-family: '${
|
|
896
|
+
...t ? [` .mono { font-family: '${t.family}', 'SF Mono', 'Fira Code', ui-monospace, monospace; }`] : [],
|
|
862
897
|
` svg {${o}`,
|
|
863
898
|
" }",
|
|
864
899
|
"</style>"
|
|
865
900
|
].join("\n");
|
|
866
901
|
}
|
|
867
|
-
function
|
|
902
|
+
function Re(e, t, n) {
|
|
868
903
|
return (.299 * e + .587 * t + .114 * n) / 255;
|
|
869
904
|
}
|
|
870
|
-
function
|
|
905
|
+
function ze(e, t) {
|
|
871
906
|
if (!e) return t;
|
|
872
|
-
let n =
|
|
873
|
-
return n ?
|
|
907
|
+
let n = c(e);
|
|
908
|
+
return n ? Re(...n) > .5 ? "#000000" : "#FFFFFF" : t;
|
|
874
909
|
}
|
|
875
910
|
var Z = 0;
|
|
876
911
|
function Q() {
|
|
877
912
|
return Z += 1, `zm-title-${Z}`;
|
|
878
913
|
}
|
|
879
|
-
function
|
|
914
|
+
function Be() {
|
|
880
915
|
Z = 0;
|
|
881
916
|
}
|
|
882
917
|
function $(e, t) {
|
|
@@ -890,7 +925,7 @@ function $(e, t) {
|
|
|
890
925
|
e.border ? `--border:${e.border}` : ""
|
|
891
926
|
].filter(Boolean).join(";")}${t ? "" : ";background:var(--bg)"}`;
|
|
892
927
|
}
|
|
893
|
-
function
|
|
928
|
+
function Ve(e, t, n, r, i, a, o, s = !0) {
|
|
894
929
|
let c = s ? ` style="${$(n, r)}"` : "", l = "", u = "";
|
|
895
930
|
if (o) {
|
|
896
931
|
if (i) {
|
|
@@ -905,6 +940,6 @@ function ze(e, t, n, r, i, a, o, s = !0) {
|
|
|
905
940
|
return V`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${e} ${t}" ` + V`width="${e}" height="${t}"${l}${c}>` + u;
|
|
906
941
|
}
|
|
907
942
|
//#endregion
|
|
908
|
-
export {
|
|
943
|
+
export { je as DEFAULTS, re as DIAGRAM_TYPES, B as LINE_HEIGHT_RATIO, J as MIX, Me as THEMES, Be as __resetSvgTitleIdCounterForTests, e as applyClickStatement, ce as applyInitConfig, X as buildStyleBlock, le as describeIgnored, b as detectDiagramType, U as escapeAttr, H as escapeXml, se as extractInitConfig, V as f, m as formatCssColor, Ne as fromShikiTheme, F as getCharWidth, ze as getReadableTextColor, ue as hasMeasuredAdvance, x as isDirection, r as isEdgeWithinOwnCluster, ae as isInitDirective, R as isMonospaceFont, P as isWideChar, _e as measureMultilineText, z as measureTextWidth, te as mixHexColors, f as mixSrgb, ye as normalizeBrTags, d as parseCssColor, c as parseHexColor, l as parseHexRgba, E as parseInitDirective, q as parseStyleProps, K as renderMultilineText, Ce as renderMultilineTextWithBackground, ke as resolveNodeStyle, t as safeHref, Ae as sanitizeClassName, ge as setMonospaceMetrics, Oe as splitClassShorthand, y as splitStatements, v as splitStatementsByLine, be as stripFormattingTags, Y as styleOpenTag, Ve as svgOpenTag, $ as themeStyleDeclarations, S as toDirection, Te as tryApplyClassAssignment, we as tryApplyClassDef, Ee as tryApplyCssClass, De as tryApplyStyleStatement, C as withDirectionOverride, a as withoutOwnClusterEdges };
|
|
909
944
|
|
|
910
945
|
//# sourceMappingURL=index.js.map
|