@zombie-mermaid/core 4.0.0 → 4.2.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 +7 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +62 -17
- package/dist/index.d.ts +62 -17
- package/dist/index.js +215 -160
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/cluster-edges.test.ts +47 -0
- package/src/__tests__/diagram-type.test.ts +15 -0
- package/src/__tests__/theme.test.ts +18 -15
- package/src/cluster-edges.ts +78 -0
- package/src/diagram-type.ts +9 -1
- package/src/index.ts +1 -0
- package/src/multiline-utils.ts +66 -2
- package/src/theme.ts +53 -37
- 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 d(e) {
|
|
52
87
|
return e === void 0 ? 1 : e.endsWith("%") ? Number(e.slice(0, -1)) / 100 : Number(e);
|
|
53
88
|
}
|
|
54
|
-
function
|
|
89
|
+
function f(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: d(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 p(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 ee(e, t, n) {
|
|
134
|
+
let r = f(e), i = f(t);
|
|
100
135
|
if (!r || !i) return e;
|
|
101
|
-
let a =
|
|
102
|
-
return a ?
|
|
136
|
+
let a = p(r, i, n, 100 - n);
|
|
137
|
+
return a ? h(a) : e;
|
|
103
138
|
}
|
|
104
|
-
var
|
|
105
|
-
function
|
|
106
|
-
let t =
|
|
139
|
+
var m = (e) => Math.min(255, Math.max(0, Math.round(e)));
|
|
140
|
+
function h(e) {
|
|
141
|
+
let t = m(e.r), n = m(e.g), r = m(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 g = /^[&#](?:#?[0-9]+|#?[xX][0-9a-fA-F]+|[a-zA-Z][a-zA-Z0-9]*);/, _ = /* @__PURE__ */ new Set(["&", "#"]);
|
|
151
|
+
function te(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 (_.has(r)) {
|
|
164
|
+
let t = g.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 (_.has(a)) {
|
|
187
|
+
let t = g.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 = te(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,52 +215,53 @@ 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",
|
|
192
227
|
"er",
|
|
193
228
|
"xychart",
|
|
194
229
|
"architecture",
|
|
195
|
-
"c4"
|
|
230
|
+
"c4",
|
|
231
|
+
"pie"
|
|
196
232
|
];
|
|
197
|
-
function
|
|
198
|
-
let t =
|
|
199
|
-
return /^xychart(?:-beta)?(?:\s|$)/.test(
|
|
233
|
+
function ie(e) {
|
|
234
|
+
let t = y(e)[0]?.text ?? "", n = t.toLowerCase();
|
|
235
|
+
return /^pie(?:\s|$)/.test(t) ? "pie" : /^xychart(?:-beta)?(?:\s|$)/.test(n) ? "xychart" : /^architecture(?:-beta)?\s*$/.test(n) ? "architecture" : /^c4(?:context|container|component|dynamic|deployment)\s*$/.test(n) ? "c4" : /^sequencediagram\s*$/.test(n) ? "sequence" : /^classdiagram\s*$/.test(n) ? "class" : /^erdiagram\s*$/.test(n) ? "er" : "flowchart";
|
|
200
236
|
}
|
|
201
237
|
//#endregion
|
|
202
238
|
//#region packages/core/src/direction.ts
|
|
203
|
-
function
|
|
239
|
+
function b(e) {
|
|
204
240
|
return e === "TD" || e === "TB" || e === "LR" || e === "BT" || e === "RL";
|
|
205
241
|
}
|
|
206
|
-
function
|
|
242
|
+
function x(e) {
|
|
207
243
|
let t = e?.toUpperCase();
|
|
208
|
-
if (t === void 0 || !
|
|
244
|
+
if (t === void 0 || !b(t)) throw Error(`Invalid direction: "${e}"`);
|
|
209
245
|
return t;
|
|
210
246
|
}
|
|
211
247
|
//#endregion
|
|
212
248
|
//#region packages/core/src/direction-override.ts
|
|
213
|
-
function
|
|
214
|
-
return t === void 0 || !
|
|
249
|
+
function S(e, t) {
|
|
250
|
+
return t === void 0 || !b(t) ? e : {
|
|
215
251
|
...e,
|
|
216
252
|
direction: t
|
|
217
253
|
};
|
|
218
254
|
}
|
|
219
255
|
//#endregion
|
|
220
256
|
//#region packages/core/src/init-directive.ts
|
|
221
|
-
var
|
|
257
|
+
var C = /* @__PURE__ */ new Set([
|
|
222
258
|
"linear",
|
|
223
259
|
"basis",
|
|
224
260
|
"natural",
|
|
225
261
|
"step",
|
|
226
262
|
"stepBefore",
|
|
227
263
|
"stepAfter"
|
|
228
|
-
]),
|
|
264
|
+
]), w = {
|
|
229
265
|
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
266
|
securitylevel: "this renderer emits static SVG and never executes diagram-supplied script, so there is no sandbox to configure",
|
|
231
267
|
defaultrenderer: "ELK is the only layout engine; dagre/elk selection has no effect",
|
|
@@ -233,11 +269,11 @@ var x = /* @__PURE__ */ new Set([
|
|
|
233
269
|
htmllabels: "labels are always rendered as SVG text; there is no HTML label mode",
|
|
234
270
|
maxtextsize: "no text-size limit is enforced",
|
|
235
271
|
startonload: "not a browser auto-render integration"
|
|
236
|
-
},
|
|
237
|
-
function
|
|
238
|
-
return
|
|
272
|
+
}, T = /^\s*%%\{\s*(?:init|initialize)\s*:\s*([\s\S]*?)\}%%/i;
|
|
273
|
+
function ae(e) {
|
|
274
|
+
return T.test(e);
|
|
239
275
|
}
|
|
240
|
-
function
|
|
276
|
+
function oe(e) {
|
|
241
277
|
let t = "", n = null;
|
|
242
278
|
for (let r = 0; r < e.length; r++) {
|
|
243
279
|
let i = e[r];
|
|
@@ -268,12 +304,12 @@ function re(e) {
|
|
|
268
304
|
}
|
|
269
305
|
return t;
|
|
270
306
|
}
|
|
271
|
-
function
|
|
272
|
-
let t = e.match(
|
|
307
|
+
function E(e) {
|
|
308
|
+
let t = e.match(T);
|
|
273
309
|
if (!t) return;
|
|
274
310
|
let n;
|
|
275
311
|
try {
|
|
276
|
-
n = JSON.parse(
|
|
312
|
+
n = JSON.parse(oe(t[1]));
|
|
277
313
|
} catch {
|
|
278
314
|
return;
|
|
279
315
|
}
|
|
@@ -289,37 +325,37 @@ function T(e) {
|
|
|
289
325
|
let e = { ...t };
|
|
290
326
|
for (let [t, n] of Object.entries(e)) {
|
|
291
327
|
if (t.toLowerCase() === "curve" && typeof n == "string") {
|
|
292
|
-
|
|
328
|
+
C.has(n) && (r.curve = n);
|
|
293
329
|
continue;
|
|
294
330
|
}
|
|
295
|
-
t.toLowerCase() in
|
|
331
|
+
t.toLowerCase() in w && r.ignored.push(t);
|
|
296
332
|
}
|
|
297
333
|
continue;
|
|
298
334
|
}
|
|
299
|
-
n in
|
|
335
|
+
n in w && r.ignored.push(e);
|
|
300
336
|
}
|
|
301
337
|
return r;
|
|
302
338
|
}
|
|
303
|
-
function
|
|
339
|
+
function se(e) {
|
|
304
340
|
let t = { ignored: [] };
|
|
305
341
|
for (let n of e) {
|
|
306
|
-
let e =
|
|
342
|
+
let e = E(n);
|
|
307
343
|
e && (e.theme !== void 0 && (t.theme = e.theme), e.curve !== void 0 && (t.curve = e.curve), t.ignored.push(...e.ignored));
|
|
308
344
|
}
|
|
309
345
|
return t;
|
|
310
346
|
}
|
|
311
|
-
function
|
|
347
|
+
function ce(e, t) {
|
|
312
348
|
return t.curve === void 0 || e.curve !== void 0 ? e : {
|
|
313
349
|
...e,
|
|
314
350
|
curve: t.curve
|
|
315
351
|
};
|
|
316
352
|
}
|
|
317
|
-
function
|
|
318
|
-
return [...new Set(e.ignored)].map((e) => `${e}: ${
|
|
353
|
+
function le(e) {
|
|
354
|
+
return [...new Set(e.ignored)].map((e) => `${e}: ${w[e.toLowerCase()] ?? "not supported"}`);
|
|
319
355
|
}
|
|
320
356
|
//#endregion
|
|
321
357
|
//#region packages/core/src/text-metrics.ts
|
|
322
|
-
var
|
|
358
|
+
var D = {
|
|
323
359
|
" ": .521,
|
|
324
360
|
"!": .533,
|
|
325
361
|
"\"": .863,
|
|
@@ -416,10 +452,10 @@ var E = {
|
|
|
416
452
|
"}": .789,
|
|
417
453
|
"~": 1.225
|
|
418
454
|
};
|
|
419
|
-
function
|
|
420
|
-
return Object.hasOwn(
|
|
455
|
+
function ue(e) {
|
|
456
|
+
return Object.hasOwn(D, e);
|
|
421
457
|
}
|
|
422
|
-
var
|
|
458
|
+
var de = /* @__PURE__ */ new Set([
|
|
423
459
|
"i",
|
|
424
460
|
"l",
|
|
425
461
|
"t",
|
|
@@ -434,14 +470,14 @@ var ce = /* @__PURE__ */ new Set([
|
|
|
434
470
|
":",
|
|
435
471
|
";",
|
|
436
472
|
"'"
|
|
437
|
-
]),
|
|
473
|
+
]), fe = /* @__PURE__ */ new Set([
|
|
438
474
|
"W",
|
|
439
475
|
"M",
|
|
440
476
|
"w",
|
|
441
477
|
"m",
|
|
442
478
|
"@",
|
|
443
479
|
"%"
|
|
444
|
-
]),
|
|
480
|
+
]), pe = /* @__PURE__ */ new Set(["W", "M"]), me = /* @__PURE__ */ new Set([
|
|
445
481
|
"(",
|
|
446
482
|
")",
|
|
447
483
|
"[",
|
|
@@ -454,68 +490,68 @@ var ce = /* @__PURE__ */ new Set([
|
|
|
454
490
|
"\"",
|
|
455
491
|
"`"
|
|
456
492
|
]);
|
|
457
|
-
function
|
|
493
|
+
function he(e) {
|
|
458
494
|
return e >= 768 && e <= 879 || e >= 6832 && e <= 6911 || e >= 7616 && e <= 7679 || e >= 8400 && e <= 8447 || e >= 65056 && e <= 65071;
|
|
459
495
|
}
|
|
460
|
-
function
|
|
496
|
+
function O(e) {
|
|
461
497
|
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
498
|
}
|
|
463
|
-
var
|
|
464
|
-
function
|
|
499
|
+
var ge = /\p{Emoji_Presentation}/u, _e = /\p{Extended_Pictographic}/u;
|
|
500
|
+
function ve(e) {
|
|
465
501
|
return e >= 9632 && e <= 9727;
|
|
466
502
|
}
|
|
467
|
-
function
|
|
503
|
+
function k(e) {
|
|
468
504
|
return e >= 8596 && e <= 8601 || e === 8617 || e === 8618;
|
|
469
505
|
}
|
|
470
|
-
function
|
|
471
|
-
if (
|
|
506
|
+
function A(e) {
|
|
507
|
+
if (ge.test(e)) return !0;
|
|
472
508
|
let t = e.codePointAt(0);
|
|
473
|
-
return t !== void 0 &&
|
|
509
|
+
return t !== void 0 && ve(t) || t !== void 0 && k(t) ? !1 : _e.test(e);
|
|
474
510
|
}
|
|
475
|
-
function
|
|
511
|
+
function j(e) {
|
|
476
512
|
let t = e.codePointAt(0);
|
|
477
|
-
return t === void 0 ? !1 :
|
|
513
|
+
return t === void 0 ? !1 : O(t) || A(e);
|
|
478
514
|
}
|
|
479
|
-
function
|
|
515
|
+
function M(e) {
|
|
480
516
|
let t = e.codePointAt(0);
|
|
481
517
|
if (t === void 0) return 0;
|
|
482
|
-
if (Object.hasOwn(
|
|
483
|
-
let t =
|
|
518
|
+
if (Object.hasOwn(D, e)) {
|
|
519
|
+
let t = D[e];
|
|
484
520
|
/* v8 ignore else */
|
|
485
521
|
if (t !== void 0) return t;
|
|
486
522
|
}
|
|
487
|
-
if (
|
|
488
|
-
if (
|
|
523
|
+
if (he(t)) return 0;
|
|
524
|
+
if (O(t) || A(e)) return 2;
|
|
489
525
|
let n = e.normalize("NFD")[0];
|
|
490
526
|
if (n !== void 0 && n !== e) {
|
|
491
|
-
let e =
|
|
527
|
+
let e = D[n];
|
|
492
528
|
if (e !== void 0) return e;
|
|
493
529
|
}
|
|
494
|
-
return e === " " ? .3 :
|
|
530
|
+
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
531
|
}
|
|
496
|
-
var
|
|
497
|
-
function
|
|
532
|
+
var N = .6, P = !1;
|
|
533
|
+
function F(e) {
|
|
498
534
|
return /mono|consol|menlo|courier|\bcode\b/i.test(e);
|
|
499
535
|
}
|
|
500
|
-
function
|
|
501
|
-
|
|
536
|
+
function ye(e) {
|
|
537
|
+
P = e;
|
|
502
538
|
}
|
|
503
|
-
function
|
|
539
|
+
function I(e, t, n) {
|
|
504
540
|
let r = t * .15;
|
|
505
|
-
if (
|
|
541
|
+
if (P) {
|
|
506
542
|
let n = 0;
|
|
507
543
|
for (let t of e) n += 1;
|
|
508
|
-
return n * t *
|
|
544
|
+
return n * t * N + r;
|
|
509
545
|
}
|
|
510
546
|
let i = n >= 600 ? .6 : n >= 500 ? .57 : .54, a = 0;
|
|
511
|
-
for (let t of e) a +=
|
|
547
|
+
for (let t of e) a += M(t);
|
|
512
548
|
return a * t * i + r;
|
|
513
549
|
}
|
|
514
|
-
var
|
|
515
|
-
function
|
|
516
|
-
let r = e.split("\n"), i = t *
|
|
550
|
+
var L = 1.3;
|
|
551
|
+
function be(e, t, n) {
|
|
552
|
+
let r = e.split("\n"), i = t * L, a = 0;
|
|
517
553
|
for (let e of r) {
|
|
518
|
-
let r =
|
|
554
|
+
let r = I(e.replace(/<\/?(?:b|strong|i|em|u|s|del)\s*>/gi, ""), t, n);
|
|
519
555
|
r > a && (a = r);
|
|
520
556
|
}
|
|
521
557
|
return {
|
|
@@ -527,24 +563,41 @@ function B(e, t, n) {
|
|
|
527
563
|
}
|
|
528
564
|
//#endregion
|
|
529
565
|
//#region packages/core/src/render-utils.ts
|
|
530
|
-
function
|
|
566
|
+
function xe(e) {
|
|
531
567
|
return Number.isFinite(e) ? Number(e.toFixed(2)) : 0;
|
|
532
568
|
}
|
|
533
|
-
function
|
|
569
|
+
function R(e, ...t) {
|
|
534
570
|
let n = e[0] ?? "";
|
|
535
571
|
for (let r = 0; r < t.length; r++) {
|
|
536
572
|
let i = t[r];
|
|
537
|
-
n += String(typeof i == "number" ?
|
|
573
|
+
n += String(typeof i == "number" ? xe(i) : i), n += e[r + 1] ?? "";
|
|
538
574
|
}
|
|
539
575
|
return n;
|
|
540
576
|
}
|
|
541
577
|
//#endregion
|
|
542
578
|
//#region packages/core/src/multiline-utils.ts
|
|
543
|
-
function
|
|
579
|
+
function Se(e) {
|
|
544
580
|
let t = e.startsWith("\"") && e.endsWith("\"") ? e.slice(1, -1) : e;
|
|
545
|
-
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>");
|
|
581
|
+
return V((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>"));
|
|
582
|
+
}
|
|
583
|
+
var Ce = 1114111, z = {
|
|
584
|
+
quot: "\"",
|
|
585
|
+
amp: "&",
|
|
586
|
+
lt: "<",
|
|
587
|
+
gt: ">",
|
|
588
|
+
apos: "'",
|
|
589
|
+
nbsp: "\xA0"
|
|
590
|
+
};
|
|
591
|
+
function B(e) {
|
|
592
|
+
return Number.isInteger(e) && e > 0 && e <= Ce && !(e >= 55296 && e <= 57343) ? String.fromCodePoint(e) : void 0;
|
|
593
|
+
}
|
|
594
|
+
function V(e) {
|
|
595
|
+
return e.replace(/#([xX][0-9a-fA-F]+|[0-9]+|[a-zA-Z]+);/g, (e, t) => /^x/i.test(t) ? B(parseInt(t.slice(1), 16)) ?? e : /^[0-9]+$/.test(t) ? B(parseInt(t, 10)) ?? e : z[t.toLowerCase()] ?? e);
|
|
546
596
|
}
|
|
547
|
-
function
|
|
597
|
+
function we(e) {
|
|
598
|
+
return e.replace(/&(#[xX][0-9a-fA-F]+|#[0-9]+|quot|amp|lt|gt|apos);/g, (e, t) => /^#x/i.test(t) ? B(parseInt(t.slice(2), 16)) ?? e : t.startsWith("#") ? B(parseInt(t.slice(1), 10)) ?? e : z[t] ?? e);
|
|
599
|
+
}
|
|
600
|
+
function Te(e) {
|
|
548
601
|
return e.replace(/<\/?(?:b|strong|i|em|u|s|del)\s*>/gi, "");
|
|
549
602
|
}
|
|
550
603
|
function H(e) {
|
|
@@ -554,7 +607,7 @@ function U(e) {
|
|
|
554
607
|
return e.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
555
608
|
}
|
|
556
609
|
var W = /<(\/)?(?:(b|strong)|(i|em)|(u)|(s|del))\s*>/gi;
|
|
557
|
-
function
|
|
610
|
+
function Ee(e) {
|
|
558
611
|
let t = [], n = !1, r = !1, i = !1, a = !1, o = 0;
|
|
559
612
|
W.lastIndex = 0;
|
|
560
613
|
let s;
|
|
@@ -577,10 +630,10 @@ function _e(e) {
|
|
|
577
630
|
strikethrough: a
|
|
578
631
|
}), t;
|
|
579
632
|
}
|
|
580
|
-
var
|
|
633
|
+
var De = /<\/?(?:b|strong|i|em|u|s|del)\s*>/i;
|
|
581
634
|
function G(e) {
|
|
582
|
-
if (!
|
|
583
|
-
let t =
|
|
635
|
+
if (!De.test(e)) return H(e);
|
|
636
|
+
let t = Ee(e);
|
|
584
637
|
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
638
|
let t = H(e.text);
|
|
586
639
|
if (!e.bold && !e.italic && !e.underline && !e.strikethrough) return t;
|
|
@@ -592,13 +645,13 @@ function G(e) {
|
|
|
592
645
|
}
|
|
593
646
|
function K(e, t, n, r, i, a = .35) {
|
|
594
647
|
let o = e.split("\n");
|
|
595
|
-
if (o.length === 1) return
|
|
596
|
-
let s = r *
|
|
597
|
-
return
|
|
648
|
+
if (o.length === 1) return R`<text x="${t}" y="${n}" ${i} dy="${r * a}">${G(e)}</text>`;
|
|
649
|
+
let s = r * L, c = -((o.length - 1) / 2) * s + r * a;
|
|
650
|
+
return R`<text x="${t}" y="${n}" ${i}>${o.map((e, n) => R`<tspan x="${t}" dy="${n === 0 ? c : s}">${G(e)}</tspan>`).join("")}</text>`;
|
|
598
651
|
}
|
|
599
|
-
function
|
|
652
|
+
function Oe(e, t, n, r, i, a, o, s, c) {
|
|
600
653
|
let l = r + o * 2, u = i + o * 2;
|
|
601
|
-
return `${
|
|
654
|
+
return `${R`<rect x="${t - l / 2}" y="${n - u / 2}" ` + R`width="${l}" height="${u}" ${c} />`}\n${K(e, t, n, a, s)}`;
|
|
602
655
|
}
|
|
603
656
|
//#endregion
|
|
604
657
|
//#region packages/core/src/style-directives.ts
|
|
@@ -613,7 +666,7 @@ function q(e) {
|
|
|
613
666
|
}
|
|
614
667
|
return n;
|
|
615
668
|
}
|
|
616
|
-
function
|
|
669
|
+
function ke(e, t) {
|
|
617
670
|
let n = e.match(/^classDef\s+([\w,-]+)\s+(.+)$/);
|
|
618
671
|
if (!n) return !1;
|
|
619
672
|
let r = q(n[2]);
|
|
@@ -623,14 +676,14 @@ function be(e, t) {
|
|
|
623
676
|
}
|
|
624
677
|
return !0;
|
|
625
678
|
}
|
|
626
|
-
function
|
|
679
|
+
function Ae(e, t) {
|
|
627
680
|
let n = e.match(/^class\s+([\w-]+(?:\s*,\s*[\w-]+)*)\s+([\w-]+)\s*;?\s*$/);
|
|
628
681
|
if (!n) return !1;
|
|
629
682
|
let r = n[2];
|
|
630
683
|
for (let e of n[1].split(",")) t.classAssignments.set(e.trim(), r);
|
|
631
684
|
return !0;
|
|
632
685
|
}
|
|
633
|
-
function
|
|
686
|
+
function je(e, t) {
|
|
634
687
|
let n = e.match(/^cssClass\s+"([^"]*)"\s+([\w-]+)\s*;?\s*$/);
|
|
635
688
|
if (!n) return !1;
|
|
636
689
|
let r = n[2];
|
|
@@ -640,7 +693,7 @@ function Se(e, t) {
|
|
|
640
693
|
}
|
|
641
694
|
return !0;
|
|
642
695
|
}
|
|
643
|
-
function
|
|
696
|
+
function Me(e, t) {
|
|
644
697
|
let n = e.match(/^style\s+([\w,-]+)\s+(.+)$/);
|
|
645
698
|
if (!n) return !1;
|
|
646
699
|
let r = q(n[2]);
|
|
@@ -650,14 +703,14 @@ function Ce(e, t) {
|
|
|
650
703
|
});
|
|
651
704
|
return !0;
|
|
652
705
|
}
|
|
653
|
-
function
|
|
706
|
+
function Ne(e) {
|
|
654
707
|
let t = e.match(/^(.+?):::([\w][\w-]*)$/);
|
|
655
708
|
return t ? {
|
|
656
709
|
id: t[1],
|
|
657
710
|
className: t[2]
|
|
658
711
|
} : { id: e };
|
|
659
712
|
}
|
|
660
|
-
function
|
|
713
|
+
function Pe(e, t) {
|
|
661
714
|
let n, r = t.classDefs.get("default");
|
|
662
715
|
r && (n = { ...r });
|
|
663
716
|
let i = t.classAssignments.get(e);
|
|
@@ -674,12 +727,12 @@ function Te(e, t) {
|
|
|
674
727
|
...a
|
|
675
728
|
} : { ...a }), n;
|
|
676
729
|
}
|
|
677
|
-
function
|
|
730
|
+
function Fe(e) {
|
|
678
731
|
if (e) return /^-?[a-zA-Z_][a-zA-Z0-9_-]*$/.test(e) ? e : void 0;
|
|
679
732
|
}
|
|
680
733
|
//#endregion
|
|
681
|
-
//#region packages/core/src/
|
|
682
|
-
var
|
|
734
|
+
//#region packages/core/src/theme.ts
|
|
735
|
+
var Ie = {
|
|
683
736
|
bg: "#FFFFFF",
|
|
684
737
|
fg: "#27272A"
|
|
685
738
|
}, J = {
|
|
@@ -694,7 +747,7 @@ var De = "JetBrains Mono NL", Oe = "@font-face {\n font-family: 'JetBrains Mono
|
|
|
694
747
|
groupHeader: 5,
|
|
695
748
|
innerStroke: 12,
|
|
696
749
|
keyBadge: 10
|
|
697
|
-
},
|
|
750
|
+
}, Le = {
|
|
698
751
|
"zinc-light": {
|
|
699
752
|
bg: "#FFFFFF",
|
|
700
753
|
fg: "#27272A"
|
|
@@ -795,7 +848,7 @@ var De = "JetBrains Mono NL", Oe = "@font-face {\n font-family: 'JetBrains Mono
|
|
|
795
848
|
muted: "#5c6370"
|
|
796
849
|
}
|
|
797
850
|
};
|
|
798
|
-
function
|
|
851
|
+
function Re(e) {
|
|
799
852
|
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
853
|
return {
|
|
801
854
|
bg: t["editor.background"] ?? (n ? "#1e1e1e" : "#ffffff"),
|
|
@@ -808,7 +861,7 @@ function je(e) {
|
|
|
808
861
|
};
|
|
809
862
|
}
|
|
810
863
|
var Y = /[<>{};]/;
|
|
811
|
-
function
|
|
864
|
+
function ze(e) {
|
|
812
865
|
let t = e.trim();
|
|
813
866
|
if (!t.startsWith("var(") || !t.endsWith(")") || Y.test(t)) return !1;
|
|
814
867
|
let n = 0;
|
|
@@ -816,7 +869,7 @@ function Me(e) {
|
|
|
816
869
|
else if (e === ")" && (n--, n < 0)) return !1;
|
|
817
870
|
return n === 0;
|
|
818
871
|
}
|
|
819
|
-
var
|
|
872
|
+
var Be = /* @__PURE__ */ new Set([
|
|
820
873
|
"sans-serif",
|
|
821
874
|
"serif",
|
|
822
875
|
"monospace",
|
|
@@ -831,15 +884,15 @@ var Ne = /* @__PURE__ */ new Set([
|
|
|
831
884
|
"emoji",
|
|
832
885
|
"fangsong"
|
|
833
886
|
]);
|
|
834
|
-
function
|
|
887
|
+
function Ve(e) {
|
|
835
888
|
let t = e.trim();
|
|
836
|
-
return t.includes(",") ? !0 :
|
|
889
|
+
return t.includes(",") ? !0 : Be.has(t.toLowerCase());
|
|
837
890
|
}
|
|
838
891
|
function X(e) {
|
|
839
892
|
return e === void 0 || e.trim() === "" ? "<style>" : `<style nonce="${U(e)}">`;
|
|
840
893
|
}
|
|
841
|
-
function
|
|
842
|
-
let r =
|
|
894
|
+
function He(e, t, n) {
|
|
895
|
+
let r = ze(e), i = r ? e.trim() : e.replace(/[<>{};'"]/g, ""), a = r || Ve(e) ? [] : [`@import url('https://fonts.googleapis.com/css2?family=${encodeURIComponent(i)}:wght@400;500;600;700&display=swap');`], o = `
|
|
843
896
|
/* Derived from --bg and --fg (overridable via --line, --accent, etc.) */
|
|
844
897
|
--_text: var(--fg);
|
|
845
898
|
--_text-sec: var(--muted, color-mix(in srgb, var(--fg) ${J.textSec}%, var(--bg)));
|
|
@@ -856,28 +909,32 @@ function Fe(e, t, n) {
|
|
|
856
909
|
return [
|
|
857
910
|
X(n),
|
|
858
911
|
...a.length > 0 ? [` ${a.join("\n ")}`] : [],
|
|
859
|
-
...t ? [` ${
|
|
912
|
+
...t ? [` ${t.faceCss}`] : [],
|
|
860
913
|
` text { font-family: ${r ? i : `'${i}'`}, system-ui, sans-serif; }`,
|
|
861
|
-
...t ? [` .mono { font-family: '${
|
|
914
|
+
...t ? [` .mono { font-family: '${t.family}', 'SF Mono', 'Fira Code', ui-monospace, monospace; }`] : [],
|
|
862
915
|
` svg {${o}`,
|
|
863
916
|
" }",
|
|
864
917
|
"</style>"
|
|
865
918
|
].join("\n");
|
|
866
919
|
}
|
|
867
|
-
function
|
|
920
|
+
function Ue(e, t, n) {
|
|
868
921
|
return (.299 * e + .587 * t + .114 * n) / 255;
|
|
869
922
|
}
|
|
870
|
-
function
|
|
923
|
+
function We(e, t) {
|
|
871
924
|
if (!e) return t;
|
|
872
|
-
let n =
|
|
873
|
-
return n ?
|
|
925
|
+
let n = c(e);
|
|
926
|
+
return n ? Ue(...n) > .5 ? "#000000" : "#FFFFFF" : t;
|
|
874
927
|
}
|
|
875
928
|
var Z = 0;
|
|
876
|
-
function
|
|
929
|
+
function Ge() {
|
|
877
930
|
return Z += 1, `zm-title-${Z}`;
|
|
878
931
|
}
|
|
879
|
-
|
|
880
|
-
|
|
932
|
+
var Q = 0;
|
|
933
|
+
function Ke() {
|
|
934
|
+
return Q += 1, `zm-desc-${Q}`;
|
|
935
|
+
}
|
|
936
|
+
function qe() {
|
|
937
|
+
Z = 0, Q = 0;
|
|
881
938
|
}
|
|
882
939
|
function $(e, t) {
|
|
883
940
|
return `${[
|
|
@@ -890,21 +947,19 @@ function $(e, t) {
|
|
|
890
947
|
e.border ? `--border:${e.border}` : ""
|
|
891
948
|
].filter(Boolean).join(";")}${t ? "" : ";background:var(--bg)"}`;
|
|
892
949
|
}
|
|
893
|
-
function
|
|
894
|
-
let
|
|
895
|
-
if (o) {
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
let e = Q();
|
|
903
|
-
l += ` aria-labelledby="${e}"`, u = `\n <title id="${e}">${H(i)}</title>`;
|
|
950
|
+
function Je(e, t, n, r, i, a, o, s = !0, c) {
|
|
951
|
+
let l = s ? ` style="${$(n, r)}"` : "", u = "", d = "", f = o || !a;
|
|
952
|
+
if (!o && a ? u = " aria-hidden=\"true\"" : o || (u = " role=\"img\""), f && i) {
|
|
953
|
+
let e = Ge();
|
|
954
|
+
u += ` aria-labelledby="${e}"`, d = `\n <title id="${e}">${H(i)}</title>`;
|
|
955
|
+
}
|
|
956
|
+
if (f && c) {
|
|
957
|
+
let e = Ke();
|
|
958
|
+
u += ` aria-describedby="${e}"`, d += `\n <desc id="${e}">${H(c)}</desc>`;
|
|
904
959
|
}
|
|
905
|
-
return
|
|
960
|
+
return R`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${e} ${t}" ` + R`width="${e}" height="${t}"${u}${l}>` + d;
|
|
906
961
|
}
|
|
907
962
|
//#endregion
|
|
908
|
-
export {
|
|
963
|
+
export { Ie as DEFAULTS, re as DIAGRAM_TYPES, L as LINE_HEIGHT_RATIO, J as MIX, Le as THEMES, qe as __resetSvgTitleIdCounterForTests, e as applyClickStatement, ce as applyInitConfig, He as buildStyleBlock, V as decodeMermaidEntities, we as decodeXmlEntitiesInLabel, le as describeIgnored, ie as detectDiagramType, U as escapeAttr, H as escapeXml, se as extractInitConfig, R as f, h as formatCssColor, Re as fromShikiTheme, M as getCharWidth, We as getReadableTextColor, ue as hasMeasuredAdvance, b as isDirection, r as isEdgeWithinOwnCluster, ae as isInitDirective, F as isMonospaceFont, j as isWideChar, be as measureMultilineText, I as measureTextWidth, ee as mixHexColors, p as mixSrgb, Se as normalizeBrTags, f as parseCssColor, c as parseHexColor, l as parseHexRgba, E as parseInitDirective, q as parseStyleProps, K as renderMultilineText, Oe as renderMultilineTextWithBackground, Pe as resolveNodeStyle, t as safeHref, Fe as sanitizeClassName, ye as setMonospaceMetrics, Ne as splitClassShorthand, y as splitStatements, v as splitStatementsByLine, Te as stripFormattingTags, X as styleOpenTag, Je as svgOpenTag, $ as themeStyleDeclarations, x as toDirection, Ae as tryApplyClassAssignment, ke as tryApplyClassDef, je as tryApplyCssClass, Me as tryApplyStyleStatement, S as withDirectionOverride, a as withoutOwnClusterEdges };
|
|
909
964
|
|
|
910
965
|
//# sourceMappingURL=index.js.map
|