@cristianormazabal/triton-core 0.1.17 → 0.1.19
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/diagrams/mermaid/architecture/gridPlacer.d.ts +36 -0
- package/dist/diagrams/mermaid/architecture/gridPlacer.d.ts.map +1 -0
- package/dist/diagrams/mermaid/architecture/gridPlacer.js +153 -0
- package/dist/diagrams/mermaid/architecture/gridPlacer.js.map +1 -0
- package/dist/diagrams/{triton → mermaid}/architecture/index.d.ts +1 -1
- package/dist/diagrams/mermaid/architecture/index.d.ts.map +1 -0
- package/dist/diagrams/{triton → mermaid}/architecture/index.js +2 -2
- package/dist/diagrams/mermaid/architecture/index.js.map +1 -0
- package/dist/diagrams/mermaid/architecture/ir.d.ts +55 -0
- package/dist/diagrams/mermaid/architecture/ir.d.ts.map +1 -0
- package/dist/diagrams/mermaid/architecture/ir.js.map +1 -0
- package/dist/diagrams/mermaid/architecture/layout.d.ts +27 -0
- package/dist/diagrams/mermaid/architecture/layout.d.ts.map +1 -0
- package/dist/diagrams/mermaid/architecture/layout.js +352 -0
- package/dist/diagrams/mermaid/architecture/layout.js.map +1 -0
- package/dist/diagrams/triton/ds/hashmap/hashmap.d.ts +9 -9
- package/dist/diagrams/triton/ds/hashmap/hashmap.d.ts.map +1 -1
- package/dist/diagrams/triton/ds/hashmap/hashmap.js +126 -28
- package/dist/diagrams/triton/ds/hashmap/hashmap.js.map +1 -1
- package/dist/frontend/index.js +1 -1
- package/dist/frontend/index.js.map +1 -1
- package/dist/index.js +933 -170
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
- package/dist/diagrams/triton/architecture/index.d.ts.map +0 -1
- package/dist/diagrams/triton/architecture/index.js.map +0 -1
- package/dist/diagrams/triton/architecture/ir.d.ts +0 -29
- package/dist/diagrams/triton/architecture/ir.d.ts.map +0 -1
- package/dist/diagrams/triton/architecture/ir.js.map +0 -1
- package/dist/diagrams/triton/architecture/layout.d.ts +0 -11
- package/dist/diagrams/triton/architecture/layout.d.ts.map +0 -1
- package/dist/diagrams/triton/architecture/layout.js +0 -124
- package/dist/diagrams/triton/architecture/layout.js.map +0 -1
- /package/dist/diagrams/{triton → mermaid}/architecture/ir.js +0 -0
package/dist/index.js
CHANGED
|
@@ -38320,8 +38320,99 @@ var c4 = {
|
|
|
38320
38320
|
}
|
|
38321
38321
|
};
|
|
38322
38322
|
|
|
38323
|
-
// src/diagrams/
|
|
38324
|
-
var
|
|
38323
|
+
// src/diagrams/mermaid/architecture/gridPlacer.ts
|
|
38324
|
+
var DELTA = {
|
|
38325
|
+
LR: [-1, 0],
|
|
38326
|
+
RL: [1, 0],
|
|
38327
|
+
TB: [0, -1],
|
|
38328
|
+
BT: [0, 1],
|
|
38329
|
+
LT: [-1, -1],
|
|
38330
|
+
LB: [-1, 1],
|
|
38331
|
+
RT: [1, -1],
|
|
38332
|
+
RB: [1, 1],
|
|
38333
|
+
TL: [-1, -1],
|
|
38334
|
+
TR: [1, -1],
|
|
38335
|
+
BL: [-1, 1],
|
|
38336
|
+
BR: [1, 1]
|
|
38337
|
+
};
|
|
38338
|
+
function directionalGridPlacer(nodes, edges2) {
|
|
38339
|
+
if (nodes.length === 0) return /* @__PURE__ */ new Map();
|
|
38340
|
+
const adjList = /* @__PURE__ */ new Map();
|
|
38341
|
+
for (const n of nodes) adjList.set(n.id, /* @__PURE__ */ new Map());
|
|
38342
|
+
for (const e of edges2) {
|
|
38343
|
+
const fs = e.fromSide.toUpperCase();
|
|
38344
|
+
const ts = e.toSide.toUpperCase();
|
|
38345
|
+
const fwd = fs + ts;
|
|
38346
|
+
const rev = ts + fs;
|
|
38347
|
+
const fromAdj = adjList.get(e.from);
|
|
38348
|
+
const toAdj = adjList.get(e.to);
|
|
38349
|
+
if (!fromAdj || !toAdj) continue;
|
|
38350
|
+
if (fromAdj.has(fwd) && fromAdj.get(fwd) !== e.to) {
|
|
38351
|
+
console.warn(`[gridPlacer] Contradictory constraint on "${e.from}" direction ${fwd} \u2014 first-wins`);
|
|
38352
|
+
} else {
|
|
38353
|
+
fromAdj.set(fwd, e.to);
|
|
38354
|
+
}
|
|
38355
|
+
if (toAdj.has(rev) && toAdj.get(rev) !== e.from) {
|
|
38356
|
+
console.warn(`[gridPlacer] Contradictory constraint on "${e.to}" direction ${rev} \u2014 first-wins`);
|
|
38357
|
+
} else {
|
|
38358
|
+
toAdj.set(rev, e.from);
|
|
38359
|
+
}
|
|
38360
|
+
}
|
|
38361
|
+
const position = /* @__PURE__ */ new Map();
|
|
38362
|
+
const occupied = /* @__PURE__ */ new Map();
|
|
38363
|
+
function bfs(seed2, seedCol, seedRow) {
|
|
38364
|
+
position.set(seed2, { col: seedCol, row: seedRow });
|
|
38365
|
+
occupied.set(`${seedCol},${seedRow}`, seed2);
|
|
38366
|
+
const queue2 = [seed2];
|
|
38367
|
+
while (queue2.length > 0) {
|
|
38368
|
+
const curr = queue2.shift();
|
|
38369
|
+
const currPos = position.get(curr);
|
|
38370
|
+
const adj = adjList.get(curr);
|
|
38371
|
+
if (!adj) continue;
|
|
38372
|
+
for (const [pair, neighbor] of adj) {
|
|
38373
|
+
if (position.has(neighbor)) continue;
|
|
38374
|
+
const d = DELTA[pair];
|
|
38375
|
+
if (!d) continue;
|
|
38376
|
+
let col = currPos.col + d[0];
|
|
38377
|
+
let row = currPos.row + d[1];
|
|
38378
|
+
const key = `${col},${row}`;
|
|
38379
|
+
if (occupied.has(key) && occupied.get(key) !== neighbor) {
|
|
38380
|
+
console.warn(`[gridPlacer] Cell collision at (${col},${row}), bumping "${neighbor}"`);
|
|
38381
|
+
let bump = row + 1;
|
|
38382
|
+
while (occupied.has(`${col},${bump}`)) bump++;
|
|
38383
|
+
row = bump;
|
|
38384
|
+
}
|
|
38385
|
+
position.set(neighbor, { col, row });
|
|
38386
|
+
occupied.set(`${col},${row}`, neighbor);
|
|
38387
|
+
queue2.push(neighbor);
|
|
38388
|
+
}
|
|
38389
|
+
}
|
|
38390
|
+
}
|
|
38391
|
+
const connected = /* @__PURE__ */ new Set([...edges2.map((e) => e.from), ...edges2.map((e) => e.to)]);
|
|
38392
|
+
const seed = nodes.find((n) => connected.has(n.id)) ?? nodes[0];
|
|
38393
|
+
bfs(seed.id, 0, 0);
|
|
38394
|
+
for (const n of nodes) {
|
|
38395
|
+
if (!position.has(n.id)) {
|
|
38396
|
+
const maxCol = position.size > 0 ? Math.max(...[...position.values()].map((p) => p.col)) + 2 : 0;
|
|
38397
|
+
bfs(n.id, maxCol, 0);
|
|
38398
|
+
}
|
|
38399
|
+
}
|
|
38400
|
+
if (position.size === 0) {
|
|
38401
|
+
nodes.forEach((n, i) => position.set(n.id, { col: i, row: 0 }));
|
|
38402
|
+
}
|
|
38403
|
+
const vals = [...position.values()];
|
|
38404
|
+
const minCol = Math.min(...vals.map((p) => p.col));
|
|
38405
|
+
const minRow = Math.min(...vals.map((p) => p.row));
|
|
38406
|
+
const result = /* @__PURE__ */ new Map();
|
|
38407
|
+
for (const [id, pos] of position) {
|
|
38408
|
+
result.set(id, { col: pos.col - minCol, row: pos.row - minRow });
|
|
38409
|
+
}
|
|
38410
|
+
return result;
|
|
38411
|
+
}
|
|
38412
|
+
|
|
38413
|
+
// src/diagrams/mermaid/architecture/layout.ts
|
|
38414
|
+
var ARROW_END_ID = "arch-arrow-end";
|
|
38415
|
+
var ARROW_START_ID = "arch-arrow-start";
|
|
38325
38416
|
function port(r, side) {
|
|
38326
38417
|
switch (side.toUpperCase()) {
|
|
38327
38418
|
case "L":
|
|
@@ -38334,42 +38425,162 @@ function port(r, side) {
|
|
|
38334
38425
|
return { x: r.x + r.width / 2, y: r.y + r.height };
|
|
38335
38426
|
}
|
|
38336
38427
|
}
|
|
38337
|
-
function
|
|
38428
|
+
function sideToDir(side) {
|
|
38429
|
+
switch (side.toUpperCase()) {
|
|
38430
|
+
case "L":
|
|
38431
|
+
return "W";
|
|
38432
|
+
case "R":
|
|
38433
|
+
return "E";
|
|
38434
|
+
case "T":
|
|
38435
|
+
return "N";
|
|
38436
|
+
default:
|
|
38437
|
+
return "S";
|
|
38438
|
+
}
|
|
38439
|
+
}
|
|
38440
|
+
function groupsByDepth(groups) {
|
|
38441
|
+
const result = [];
|
|
38442
|
+
const added = /* @__PURE__ */ new Set();
|
|
38443
|
+
function add(g) {
|
|
38444
|
+
if (added.has(g.id)) return;
|
|
38445
|
+
if (g.parent) {
|
|
38446
|
+
const par = groups.find((pg) => pg.id === g.parent);
|
|
38447
|
+
if (par) add(par);
|
|
38448
|
+
}
|
|
38449
|
+
result.push(g);
|
|
38450
|
+
added.add(g.id);
|
|
38451
|
+
}
|
|
38452
|
+
for (const g of groups) add(g);
|
|
38453
|
+
return result;
|
|
38454
|
+
}
|
|
38455
|
+
function layoutArchitecture(ir, theme, options) {
|
|
38338
38456
|
const { palette, typography, spacing } = theme;
|
|
38339
38457
|
const p = pen(theme);
|
|
38340
38458
|
const margin = spacing.diagramMargin;
|
|
38341
38459
|
const font = typography.baseFontSize;
|
|
38460
|
+
const iconPacks = options?.icons;
|
|
38342
38461
|
const svcW = 130, svcH = 56;
|
|
38343
|
-
const
|
|
38344
|
-
const
|
|
38345
|
-
const
|
|
38462
|
+
const jctW = 16, jctH = 16;
|
|
38463
|
+
const nodeSizes = /* @__PURE__ */ new Map();
|
|
38464
|
+
for (const s of ir.services) nodeSizes.set(s.id, { width: svcW, height: svcH });
|
|
38465
|
+
for (const j of ir.junctions) nodeSizes.set(j.id, { width: jctW, height: jctH });
|
|
38466
|
+
const colGap = 90, rowGap = 44;
|
|
38467
|
+
const gridCells = directionalGridPlacer(
|
|
38468
|
+
[...ir.services, ...ir.junctions],
|
|
38469
|
+
ir.edges
|
|
38470
|
+
);
|
|
38471
|
+
const positions = /* @__PURE__ */ new Map();
|
|
38472
|
+
for (const [id, cell] of gridCells) {
|
|
38473
|
+
positions.set(id, {
|
|
38474
|
+
x: cell.col * (svcW + colGap) + margin,
|
|
38475
|
+
y: cell.row * (svcH + rowGap) + margin
|
|
38476
|
+
});
|
|
38477
|
+
}
|
|
38478
|
+
for (const align of ir.aligns) {
|
|
38479
|
+
const coords = align.members.map((id) => positions.get(id)).filter((pos) => !!pos);
|
|
38480
|
+
if (coords.length < 2) continue;
|
|
38481
|
+
if (align.axis === "row") {
|
|
38482
|
+
const ys = coords.map((c) => c.y).sort((a, b) => a - b);
|
|
38483
|
+
const medY = ys[Math.floor(ys.length / 2)];
|
|
38484
|
+
for (const id of align.members) {
|
|
38485
|
+
const pos = positions.get(id);
|
|
38486
|
+
if (pos) pos.y = medY;
|
|
38487
|
+
}
|
|
38488
|
+
} else {
|
|
38489
|
+
const xs = coords.map((c) => c.x).sort((a, b) => a - b);
|
|
38490
|
+
const medX = xs[Math.floor(xs.length / 2)];
|
|
38491
|
+
for (const id of align.members) {
|
|
38492
|
+
const pos = positions.get(id);
|
|
38493
|
+
if (pos) pos.x = medX;
|
|
38494
|
+
}
|
|
38495
|
+
}
|
|
38496
|
+
}
|
|
38346
38497
|
const titleH = ir.metadata.title ? typography.titleFontSize + 14 : 0;
|
|
38347
38498
|
const yOff = titleH;
|
|
38348
38499
|
const rectOf = (id) => {
|
|
38349
|
-
const
|
|
38350
|
-
|
|
38500
|
+
const pos = positions.get(id);
|
|
38501
|
+
const sz = nodeSizes.get(id);
|
|
38502
|
+
if (!pos || !sz) return void 0;
|
|
38503
|
+
return { x: pos.x, y: pos.y + yOff, width: sz.width, height: sz.height };
|
|
38504
|
+
};
|
|
38505
|
+
const groupRectCache = /* @__PURE__ */ new Map();
|
|
38506
|
+
const computeGroupRect = (gId) => {
|
|
38507
|
+
if (groupRectCache.has(gId)) return groupRectCache.get(gId);
|
|
38508
|
+
const pad = 20;
|
|
38509
|
+
const memberRects = [
|
|
38510
|
+
...ir.services.filter((s) => s.group === gId).map((s) => rectOf(s.id)).filter((r) => !!r),
|
|
38511
|
+
...ir.junctions.filter((j) => j.group === gId).map((j) => rectOf(j.id)).filter((r) => !!r),
|
|
38512
|
+
...ir.groups.filter((g) => g.parent === gId).map((g) => computeGroupRect(g.id)).filter((r) => !!r)
|
|
38513
|
+
];
|
|
38514
|
+
if (memberRects.length === 0) return void 0;
|
|
38515
|
+
const minX = Math.min(...memberRects.map((r) => r.x)) - pad;
|
|
38516
|
+
const minY = Math.min(...memberRects.map((r) => r.y)) - pad - 14;
|
|
38517
|
+
const maxX = Math.max(...memberRects.map((r) => r.x + r.width)) + pad;
|
|
38518
|
+
const maxY = Math.max(...memberRects.map((r) => r.y + r.height)) + pad;
|
|
38519
|
+
const rect = { x: minX, y: minY, width: maxX - minX, height: maxY - minY };
|
|
38520
|
+
groupRectCache.set(gId, rect);
|
|
38521
|
+
return rect;
|
|
38351
38522
|
};
|
|
38523
|
+
for (const g of ir.groups) computeGroupRect(g.id);
|
|
38352
38524
|
const elements = [];
|
|
38353
|
-
if (ir.metadata.title)
|
|
38354
|
-
|
|
38355
|
-
|
|
38356
|
-
|
|
38357
|
-
|
|
38358
|
-
|
|
38359
|
-
|
|
38360
|
-
|
|
38361
|
-
|
|
38525
|
+
if (ir.metadata.title) {
|
|
38526
|
+
elements.push(p.text(
|
|
38527
|
+
String(ir.metadata.title),
|
|
38528
|
+
margin,
|
|
38529
|
+
margin + typography.titleFontSize,
|
|
38530
|
+
typography.titleFontSize,
|
|
38531
|
+
palette.text,
|
|
38532
|
+
{ weight: "bold" }
|
|
38533
|
+
));
|
|
38534
|
+
}
|
|
38535
|
+
const orderedGroups = groupsByDepth(ir.groups);
|
|
38536
|
+
orderedGroups.forEach((g, gi) => {
|
|
38537
|
+
const r = computeGroupRect(g.id);
|
|
38538
|
+
if (!r) return;
|
|
38362
38539
|
const hue = categoricalHue(gi);
|
|
38363
|
-
elements.push(p.rect(
|
|
38364
|
-
|
|
38540
|
+
elements.push(p.rect(
|
|
38541
|
+
{ x: rhu(r.x), y: rhu(r.y), width: rhu(r.width), height: rhu(r.height) },
|
|
38542
|
+
hue + "14",
|
|
38543
|
+
hue,
|
|
38544
|
+
1.4,
|
|
38545
|
+
{ rx: 10 }
|
|
38546
|
+
));
|
|
38547
|
+
elements.push(p.text(
|
|
38548
|
+
g.label,
|
|
38549
|
+
rhu(r.x + 12),
|
|
38550
|
+
rhu(r.y + 16),
|
|
38551
|
+
typography.smallFontSize,
|
|
38552
|
+
hue,
|
|
38553
|
+
{ weight: "bold" }
|
|
38554
|
+
));
|
|
38365
38555
|
});
|
|
38366
|
-
const allBoxes = [
|
|
38556
|
+
const allBoxes = [];
|
|
38557
|
+
for (const [id, pos] of positions) {
|
|
38558
|
+
const sz = nodeSizes.get(id);
|
|
38559
|
+
if (sz) allBoxes.push({ id, x: pos.x, y: pos.y, width: sz.width, height: sz.height });
|
|
38560
|
+
}
|
|
38367
38561
|
for (const e of ir.edges) {
|
|
38368
|
-
|
|
38369
|
-
if (!
|
|
38370
|
-
|
|
38371
|
-
|
|
38372
|
-
|
|
38562
|
+
let fromRect = rectOf(e.from);
|
|
38563
|
+
if (!fromRect) continue;
|
|
38564
|
+
if (e.fromGroup) {
|
|
38565
|
+
const svc = ir.services.find((s) => s.id === e.from);
|
|
38566
|
+
if (svc?.group) {
|
|
38567
|
+
const gr = computeGroupRect(svc.group);
|
|
38568
|
+
if (gr) fromRect = gr;
|
|
38569
|
+
}
|
|
38570
|
+
}
|
|
38571
|
+
let toRect2 = rectOf(e.to);
|
|
38572
|
+
if (!toRect2) continue;
|
|
38573
|
+
if (e.toGroup) {
|
|
38574
|
+
const svc = ir.services.find((s) => s.id === e.to);
|
|
38575
|
+
if (svc?.group) {
|
|
38576
|
+
const gr = computeGroupRect(svc.group);
|
|
38577
|
+
if (gr) toRect2 = gr;
|
|
38578
|
+
}
|
|
38579
|
+
}
|
|
38580
|
+
const pa = port(fromRect, e.fromSide);
|
|
38581
|
+
const pb = port(toRect2, e.toSide);
|
|
38582
|
+
const fromDir = sideToDir(e.fromSide);
|
|
38583
|
+
const toDir = sideToDir(e.toSide);
|
|
38373
38584
|
const obstacles = allBoxes.filter((bx) => bx.id !== e.from && bx.id !== e.to).map((bx) => ({ x: bx.x, y: bx.y + yOff, width: bx.width, height: bx.height }));
|
|
38374
38585
|
const route = orthogonalRouter.route({
|
|
38375
38586
|
from: pa,
|
|
@@ -38380,28 +38591,106 @@ function layoutArchitecture(ir, theme) {
|
|
|
38380
38591
|
fromDir,
|
|
38381
38592
|
toDir
|
|
38382
38593
|
});
|
|
38383
|
-
|
|
38594
|
+
const pathOpts = {};
|
|
38595
|
+
if (e.arrowRight) pathOpts.markerEnd = ARROW_END_ID;
|
|
38596
|
+
if (e.arrowLeft) pathOpts.markerStart = ARROW_START_ID;
|
|
38597
|
+
elements.push(p.path(route.path, palette.primary, 1.6, pathOpts));
|
|
38384
38598
|
}
|
|
38599
|
+
const warnedIcons = /* @__PURE__ */ new Set();
|
|
38385
38600
|
ir.services.forEach((s, i) => {
|
|
38386
38601
|
const r = rectOf(s.id);
|
|
38602
|
+
if (!r) return;
|
|
38387
38603
|
const hue = categoricalHue(i);
|
|
38388
|
-
elements.push(p.rect(
|
|
38389
|
-
|
|
38390
|
-
|
|
38391
|
-
|
|
38604
|
+
elements.push(p.rect(
|
|
38605
|
+
{ x: rhu(r.x), y: rhu(r.y), width: rhu(r.width), height: rhu(r.height) },
|
|
38606
|
+
palette.surface,
|
|
38607
|
+
palette.border,
|
|
38608
|
+
1.4,
|
|
38609
|
+
{ rx: 8 }
|
|
38610
|
+
));
|
|
38611
|
+
elements.push(p.rect(
|
|
38612
|
+
{ x: rhu(r.x), y: rhu(r.y), width: rhu(r.width), height: 8 },
|
|
38613
|
+
hue,
|
|
38614
|
+
hue,
|
|
38615
|
+
0,
|
|
38616
|
+
{ rx: 4 }
|
|
38617
|
+
));
|
|
38618
|
+
const iconElems = resolveIconElems(p, s.icon, r.x + r.width / 2, r.y + 24, hue, palette, iconPacks, warnedIcons);
|
|
38619
|
+
elements.push(...iconElems);
|
|
38620
|
+
elements.push(p.text(
|
|
38621
|
+
s.label,
|
|
38622
|
+
rhuInt(r.x + r.width / 2),
|
|
38623
|
+
rhu(r.y + r.height - 9),
|
|
38624
|
+
font,
|
|
38625
|
+
palette.text,
|
|
38626
|
+
{ weight: "bold", anchor: "middle" }
|
|
38627
|
+
));
|
|
38392
38628
|
});
|
|
38393
|
-
|
|
38394
|
-
|
|
38395
|
-
|
|
38396
|
-
|
|
38629
|
+
ir.junctions.forEach((j) => {
|
|
38630
|
+
const r = rectOf(j.id);
|
|
38631
|
+
if (!r) return;
|
|
38632
|
+
const cx = rhu(r.x + r.width / 2);
|
|
38633
|
+
const cy = rhu(r.y + r.height / 2);
|
|
38634
|
+
const R = 4;
|
|
38635
|
+
elements.push(p.circle({ x: cx, y: cy }, R, palette.primary, palette.primary, 0));
|
|
38636
|
+
elements.push(p.path(
|
|
38637
|
+
`M ${rhu(cx - R)} ${cy} L ${rhu(cx + R)} ${cy} M ${cx} ${rhu(cy - R)} L ${cx} ${rhu(cy + R)}`,
|
|
38638
|
+
palette.primary,
|
|
38639
|
+
1.6
|
|
38640
|
+
));
|
|
38641
|
+
});
|
|
38642
|
+
const allNodeRects = [
|
|
38643
|
+
...ir.services.map((s) => rectOf(s.id)).filter((r) => !!r),
|
|
38644
|
+
...ir.junctions.map((j) => rectOf(j.id)).filter((r) => !!r)
|
|
38645
|
+
];
|
|
38646
|
+
const allGroupRects = [...groupRectCache.values()];
|
|
38647
|
+
const allRects = [...allNodeRects, ...allGroupRects];
|
|
38648
|
+
if (allRects.length === 0) {
|
|
38649
|
+
const scene2 = applyOverlays(
|
|
38650
|
+
{ viewBox: { x: 0, y: 0, width: 200, height: 100 }, background: palette.background, elements, defs: [] },
|
|
38651
|
+
ir.overlays,
|
|
38652
|
+
theme
|
|
38653
|
+
);
|
|
38654
|
+
return { scene: scene2, anchors: {} };
|
|
38655
|
+
}
|
|
38656
|
+
const totalW = rhuInt(Math.max(...allRects.map((r) => r.x + r.width)) + margin + 26);
|
|
38657
|
+
const totalH = rhuInt(Math.max(...allRects.map((r) => r.y + r.height)) + margin + 26);
|
|
38658
|
+
const vbX = rhuInt(Math.min(0, ...allRects.map((r) => r.x)) - margin);
|
|
38659
|
+
const vbY = rhuInt(Math.min(0, ...allRects.map((r) => r.y)) - margin);
|
|
38660
|
+
const defs = [
|
|
38661
|
+
`<marker id="${ARROW_END_ID}" markerWidth="10" markerHeight="8" refX="9" refY="4" orient="auto"><polygon points="0 0, 10 4, 0 8" fill="${palette.primary}" /></marker>`,
|
|
38662
|
+
`<marker id="${ARROW_START_ID}" markerWidth="10" markerHeight="8" refX="1" refY="4" orient="auto-start-reverse"><polygon points="0 0, 10 4, 0 8" fill="${palette.primary}" /></marker>`
|
|
38663
|
+
];
|
|
38397
38664
|
const scene = applyOverlays({
|
|
38398
|
-
viewBox: { x:
|
|
38665
|
+
viewBox: { x: vbX, y: vbY, width: totalW - vbX, height: totalH - vbY },
|
|
38399
38666
|
background: palette.background,
|
|
38400
38667
|
elements,
|
|
38401
38668
|
defs
|
|
38402
38669
|
}, ir.overlays, theme);
|
|
38403
38670
|
return { scene, anchors: {} };
|
|
38404
38671
|
}
|
|
38672
|
+
function resolveIconElems(p, icon, cx, cy, hue, palette, iconPacks, warnedIcons) {
|
|
38673
|
+
if (icon.includes(":") && iconPacks) {
|
|
38674
|
+
const ref = parseIconRef(icon);
|
|
38675
|
+
if (ref.ok) {
|
|
38676
|
+
const resolved = resolveIcon(ref.value, iconPacks);
|
|
38677
|
+
if (resolved.ok) {
|
|
38678
|
+
const size = 24;
|
|
38679
|
+
return [p.icon(resolved.value, rhu(cx - size / 2), rhu(cy - size / 2), size, { color: hue })];
|
|
38680
|
+
}
|
|
38681
|
+
}
|
|
38682
|
+
if (!warnedIcons.has(icon)) {
|
|
38683
|
+
warnedIcons.add(icon);
|
|
38684
|
+
console.warn(`[architecture] icon "${icon}" could not be resolved \u2014 falling back to glyph.`);
|
|
38685
|
+
}
|
|
38686
|
+
} else if (icon.includes(":") && !iconPacks) {
|
|
38687
|
+
if (!warnedIcons.has(icon)) {
|
|
38688
|
+
warnedIcons.add(icon);
|
|
38689
|
+
console.warn(`[architecture] icon "${icon}" is an iconify token but no icon packs were loaded.`);
|
|
38690
|
+
}
|
|
38691
|
+
}
|
|
38692
|
+
return iconGlyph(p, icon, cx, cy, hue, palette);
|
|
38693
|
+
}
|
|
38405
38694
|
function iconGlyph(p, icon, cx, cy, hue, palette) {
|
|
38406
38695
|
const name = icon.toLowerCase();
|
|
38407
38696
|
const out = [];
|
|
@@ -38426,7 +38715,7 @@ function iconGlyph(p, icon, cx, cy, hue, palette) {
|
|
|
38426
38715
|
return out;
|
|
38427
38716
|
}
|
|
38428
38717
|
|
|
38429
|
-
// src/diagrams/
|
|
38718
|
+
// src/diagrams/mermaid/architecture/parser.js
|
|
38430
38719
|
function peg$subclass21(child, parent) {
|
|
38431
38720
|
function C() {
|
|
38432
38721
|
this.constructor = child;
|
|
@@ -38562,14 +38851,20 @@ function peg$parse21(input, options) {
|
|
|
38562
38851
|
var peg$c3 = ")";
|
|
38563
38852
|
var peg$c4 = "[";
|
|
38564
38853
|
var peg$c5 = "]";
|
|
38565
|
-
var peg$c6 = "
|
|
38566
|
-
var peg$c7 = "
|
|
38567
|
-
var peg$c8 = "
|
|
38568
|
-
var peg$c9 = "
|
|
38569
|
-
var peg$c10 = "
|
|
38854
|
+
var peg$c6 = "in";
|
|
38855
|
+
var peg$c7 = "service";
|
|
38856
|
+
var peg$c8 = "junction";
|
|
38857
|
+
var peg$c9 = ":";
|
|
38858
|
+
var peg$c10 = "{group}";
|
|
38570
38859
|
var peg$c11 = "<-->";
|
|
38571
|
-
var peg$c12 = "
|
|
38572
|
-
var peg$c13 = "
|
|
38860
|
+
var peg$c12 = "-->";
|
|
38861
|
+
var peg$c13 = "<--";
|
|
38862
|
+
var peg$c14 = "--";
|
|
38863
|
+
var peg$c15 = "align";
|
|
38864
|
+
var peg$c16 = "row";
|
|
38865
|
+
var peg$c17 = "column";
|
|
38866
|
+
var peg$c18 = "\r";
|
|
38867
|
+
var peg$c19 = "\n";
|
|
38573
38868
|
var peg$r0 = /^[ \t]/;
|
|
38574
38869
|
var peg$r1 = /^[^)\n]/;
|
|
38575
38870
|
var peg$r2 = /^[^\]\n]/;
|
|
@@ -38585,48 +38880,96 @@ function peg$parse21(input, options) {
|
|
|
38585
38880
|
var peg$e6 = peg$literalExpectation("[", false);
|
|
38586
38881
|
var peg$e7 = peg$classExpectation(["]", "\n"], true, false);
|
|
38587
38882
|
var peg$e8 = peg$literalExpectation("]", false);
|
|
38588
|
-
var peg$e9 = peg$literalExpectation("
|
|
38589
|
-
var peg$e10 = peg$literalExpectation("
|
|
38590
|
-
var peg$e11 = peg$literalExpectation("
|
|
38591
|
-
var peg$e12 = peg$literalExpectation("
|
|
38592
|
-
var peg$e13 = peg$literalExpectation("
|
|
38883
|
+
var peg$e9 = peg$literalExpectation("in", true);
|
|
38884
|
+
var peg$e10 = peg$literalExpectation("service", true);
|
|
38885
|
+
var peg$e11 = peg$literalExpectation("junction", true);
|
|
38886
|
+
var peg$e12 = peg$literalExpectation(":", false);
|
|
38887
|
+
var peg$e13 = peg$literalExpectation("{group}", false);
|
|
38593
38888
|
var peg$e14 = peg$literalExpectation("<-->", false);
|
|
38594
|
-
var peg$e15 = peg$
|
|
38595
|
-
var peg$e16 = peg$
|
|
38596
|
-
var peg$e17 = peg$
|
|
38597
|
-
var peg$e18 = peg$literalExpectation("
|
|
38598
|
-
var peg$e19 = peg$literalExpectation("
|
|
38599
|
-
var peg$e20 = peg$
|
|
38889
|
+
var peg$e15 = peg$literalExpectation("-->", false);
|
|
38890
|
+
var peg$e16 = peg$literalExpectation("<--", false);
|
|
38891
|
+
var peg$e17 = peg$literalExpectation("--", false);
|
|
38892
|
+
var peg$e18 = peg$literalExpectation("align", true);
|
|
38893
|
+
var peg$e19 = peg$literalExpectation("row", true);
|
|
38894
|
+
var peg$e20 = peg$literalExpectation("column", true);
|
|
38895
|
+
var peg$e21 = peg$classExpectation(["L", "R", "T", "B", "l", "r", "t", "b"], false, false);
|
|
38896
|
+
var peg$e22 = peg$classExpectation(["\n"], true, false);
|
|
38897
|
+
var peg$e23 = peg$classExpectation([["A", "Z"], ["a", "z"], ["0", "9"], "_"], false, false);
|
|
38898
|
+
var peg$e24 = peg$literalExpectation("\r", false);
|
|
38899
|
+
var peg$e25 = peg$literalExpectation("\n", false);
|
|
38900
|
+
var peg$e26 = peg$anyExpectation();
|
|
38600
38901
|
var peg$f0 = function(lines2) {
|
|
38601
38902
|
const groups = [];
|
|
38602
38903
|
const services = [];
|
|
38904
|
+
const junctions = [];
|
|
38603
38905
|
const edges2 = [];
|
|
38906
|
+
const aligns = [];
|
|
38604
38907
|
let curGroup, curIndent = -1;
|
|
38605
38908
|
for (const l of lines2.filter(Boolean)) {
|
|
38606
38909
|
if (l.t === "group") {
|
|
38607
|
-
groups.push({ id: l.id, label: l.label, icon: l.icon });
|
|
38910
|
+
groups.push({ id: l.id, label: l.label, icon: l.icon, ...l.inGroup ? { parent: l.inGroup } : {} });
|
|
38608
38911
|
curGroup = l.id;
|
|
38609
38912
|
curIndent = l.indent;
|
|
38610
38913
|
} else if (l.t === "service") {
|
|
38611
38914
|
const group = l.inGroup || (l.indent > curIndent && curGroup ? curGroup : void 0);
|
|
38612
38915
|
services.push({ id: l.id, label: l.label, icon: l.icon, ...group ? { group } : {} });
|
|
38613
|
-
} else if (l.t === "
|
|
38916
|
+
} else if (l.t === "junction") {
|
|
38917
|
+
const group = l.inGroup || (l.indent > curIndent && curGroup ? curGroup : void 0);
|
|
38918
|
+
junctions.push({ id: l.id, ...group ? { group } : {} });
|
|
38919
|
+
} else if (l.t === "edge") {
|
|
38920
|
+
edges2.push({ from: l.from, fromSide: l.fromSide, fromGroup: l.fromGroup, to: l.to, toSide: l.toSide, toGroup: l.toGroup, arrowLeft: l.arrowLeft, arrowRight: l.arrowRight });
|
|
38921
|
+
} else if (l.t === "align") {
|
|
38922
|
+
aligns.push({ axis: l.axis, members: l.members });
|
|
38923
|
+
}
|
|
38614
38924
|
}
|
|
38615
|
-
return { version: "1.0", metadata: {}, groups, services, edges: edges2 };
|
|
38925
|
+
return { version: "1.0", metadata: {}, groups, services, junctions, edges: edges2, aligns };
|
|
38926
|
+
};
|
|
38927
|
+
var peg$f1 = function(ind, id, icon, label, g) {
|
|
38928
|
+
return g;
|
|
38616
38929
|
};
|
|
38617
|
-
var peg$
|
|
38618
|
-
return { t: "group", indent: ind.length, id, icon: icon.trim(), label: label.trim() };
|
|
38930
|
+
var peg$f2 = function(ind, id, icon, label, inG) {
|
|
38931
|
+
return { t: "group", indent: ind.length, id, icon: icon.trim(), label: label.trim(), inGroup: inG || void 0 };
|
|
38619
38932
|
};
|
|
38620
|
-
var peg$
|
|
38933
|
+
var peg$f3 = function(ind, id, icon, label, g) {
|
|
38621
38934
|
return g;
|
|
38622
38935
|
};
|
|
38623
|
-
var peg$
|
|
38936
|
+
var peg$f4 = function(ind, id, icon, label, inG) {
|
|
38624
38937
|
return { t: "service", indent: ind.length, id, icon: icon.trim(), label: label.trim(), inGroup: inG || void 0 };
|
|
38625
38938
|
};
|
|
38626
|
-
var peg$
|
|
38627
|
-
return
|
|
38939
|
+
var peg$f5 = function(ind, id, g) {
|
|
38940
|
+
return g;
|
|
38628
38941
|
};
|
|
38629
|
-
var peg$
|
|
38942
|
+
var peg$f6 = function(ind, id, inG) {
|
|
38943
|
+
return { t: "junction", indent: ind.length, id, inGroup: inG || void 0 };
|
|
38944
|
+
};
|
|
38945
|
+
var peg$f7 = function(fromEp, fromSide, arrow, toSide, toEp) {
|
|
38946
|
+
return { t: "edge", from: fromEp.id, fromSide, fromGroup: fromEp.grp, to: toEp.id, toSide, toGroup: toEp.grp, arrowLeft: arrow.left, arrowRight: arrow.right };
|
|
38947
|
+
};
|
|
38948
|
+
var peg$f8 = function(id) {
|
|
38949
|
+
return true;
|
|
38950
|
+
};
|
|
38951
|
+
var peg$f9 = function(id, grp) {
|
|
38952
|
+
return { id, grp: grp === true };
|
|
38953
|
+
};
|
|
38954
|
+
var peg$f10 = function() {
|
|
38955
|
+
return { left: true, right: true };
|
|
38956
|
+
};
|
|
38957
|
+
var peg$f11 = function() {
|
|
38958
|
+
return { left: false, right: true };
|
|
38959
|
+
};
|
|
38960
|
+
var peg$f12 = function() {
|
|
38961
|
+
return { left: true, right: false };
|
|
38962
|
+
};
|
|
38963
|
+
var peg$f13 = function() {
|
|
38964
|
+
return { left: false, right: false };
|
|
38965
|
+
};
|
|
38966
|
+
var peg$f14 = function(axis, head, id) {
|
|
38967
|
+
return id;
|
|
38968
|
+
};
|
|
38969
|
+
var peg$f15 = function(axis, head, tail) {
|
|
38970
|
+
return { t: "align", axis: axis.toLowerCase(), members: [head, ...tail] };
|
|
38971
|
+
};
|
|
38972
|
+
var peg$f16 = function() {
|
|
38630
38973
|
return null;
|
|
38631
38974
|
};
|
|
38632
38975
|
var peg$currPos = options.peg$currPos | 0;
|
|
@@ -38800,16 +39143,22 @@ function peg$parse21(input, options) {
|
|
|
38800
39143
|
if (s0 === peg$FAILED) {
|
|
38801
39144
|
s0 = peg$parseServiceLine();
|
|
38802
39145
|
if (s0 === peg$FAILED) {
|
|
38803
|
-
s0 = peg$
|
|
39146
|
+
s0 = peg$parseJunctionLine();
|
|
38804
39147
|
if (s0 === peg$FAILED) {
|
|
38805
|
-
s0 = peg$
|
|
39148
|
+
s0 = peg$parseAlignLine();
|
|
39149
|
+
if (s0 === peg$FAILED) {
|
|
39150
|
+
s0 = peg$parseEdgeLine();
|
|
39151
|
+
if (s0 === peg$FAILED) {
|
|
39152
|
+
s0 = peg$parseBlankLine();
|
|
39153
|
+
}
|
|
39154
|
+
}
|
|
38806
39155
|
}
|
|
38807
39156
|
}
|
|
38808
39157
|
}
|
|
38809
39158
|
return s0;
|
|
38810
39159
|
}
|
|
38811
39160
|
function peg$parseGroupLine() {
|
|
38812
|
-
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12;
|
|
39161
|
+
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15;
|
|
38813
39162
|
s0 = peg$currPos;
|
|
38814
39163
|
s1 = peg$currPos;
|
|
38815
39164
|
s2 = [];
|
|
@@ -38937,11 +39286,49 @@ function peg$parse21(input, options) {
|
|
|
38937
39286
|
}
|
|
38938
39287
|
}
|
|
38939
39288
|
if (s10 !== peg$FAILED) {
|
|
38940
|
-
s11 = peg$
|
|
38941
|
-
s12 = peg$
|
|
39289
|
+
s11 = peg$currPos;
|
|
39290
|
+
s12 = peg$parse__();
|
|
38942
39291
|
if (s12 !== peg$FAILED) {
|
|
39292
|
+
s13 = input.substr(peg$currPos, 2);
|
|
39293
|
+
if (s13.toLowerCase() === peg$c6) {
|
|
39294
|
+
peg$currPos += 2;
|
|
39295
|
+
} else {
|
|
39296
|
+
s13 = peg$FAILED;
|
|
39297
|
+
if (peg$silentFails === 0) {
|
|
39298
|
+
peg$fail(peg$e9);
|
|
39299
|
+
}
|
|
39300
|
+
}
|
|
39301
|
+
if (s13 !== peg$FAILED) {
|
|
39302
|
+
s14 = peg$parse__();
|
|
39303
|
+
if (s14 !== peg$FAILED) {
|
|
39304
|
+
s15 = peg$parseIdent();
|
|
39305
|
+
if (s15 !== peg$FAILED) {
|
|
39306
|
+
peg$savedPos = s11;
|
|
39307
|
+
s11 = peg$f1(s1, s4, s6, s9, s15);
|
|
39308
|
+
} else {
|
|
39309
|
+
peg$currPos = s11;
|
|
39310
|
+
s11 = peg$FAILED;
|
|
39311
|
+
}
|
|
39312
|
+
} else {
|
|
39313
|
+
peg$currPos = s11;
|
|
39314
|
+
s11 = peg$FAILED;
|
|
39315
|
+
}
|
|
39316
|
+
} else {
|
|
39317
|
+
peg$currPos = s11;
|
|
39318
|
+
s11 = peg$FAILED;
|
|
39319
|
+
}
|
|
39320
|
+
} else {
|
|
39321
|
+
peg$currPos = s11;
|
|
39322
|
+
s11 = peg$FAILED;
|
|
39323
|
+
}
|
|
39324
|
+
if (s11 === peg$FAILED) {
|
|
39325
|
+
s11 = null;
|
|
39326
|
+
}
|
|
39327
|
+
s12 = peg$parseRestIgnore();
|
|
39328
|
+
s13 = peg$parseLineEnd();
|
|
39329
|
+
if (s13 !== peg$FAILED) {
|
|
38943
39330
|
peg$savedPos = s0;
|
|
38944
|
-
s0 = peg$
|
|
39331
|
+
s0 = peg$f2(s1, s4, s6, s9, s11);
|
|
38945
39332
|
} else {
|
|
38946
39333
|
peg$currPos = s0;
|
|
38947
39334
|
s0 = peg$FAILED;
|
|
@@ -39004,12 +39391,12 @@ function peg$parse21(input, options) {
|
|
|
39004
39391
|
}
|
|
39005
39392
|
s1 = input.substring(s1, peg$currPos);
|
|
39006
39393
|
s2 = input.substr(peg$currPos, 7);
|
|
39007
|
-
if (s2.toLowerCase() === peg$
|
|
39394
|
+
if (s2.toLowerCase() === peg$c7) {
|
|
39008
39395
|
peg$currPos += 7;
|
|
39009
39396
|
} else {
|
|
39010
39397
|
s2 = peg$FAILED;
|
|
39011
39398
|
if (peg$silentFails === 0) {
|
|
39012
|
-
peg$fail(peg$
|
|
39399
|
+
peg$fail(peg$e10);
|
|
39013
39400
|
}
|
|
39014
39401
|
}
|
|
39015
39402
|
if (s2 !== peg$FAILED) {
|
|
@@ -39109,12 +39496,12 @@ function peg$parse21(input, options) {
|
|
|
39109
39496
|
s12 = peg$parse__();
|
|
39110
39497
|
if (s12 !== peg$FAILED) {
|
|
39111
39498
|
s13 = input.substr(peg$currPos, 2);
|
|
39112
|
-
if (s13.toLowerCase() === peg$
|
|
39499
|
+
if (s13.toLowerCase() === peg$c6) {
|
|
39113
39500
|
peg$currPos += 2;
|
|
39114
39501
|
} else {
|
|
39115
39502
|
s13 = peg$FAILED;
|
|
39116
39503
|
if (peg$silentFails === 0) {
|
|
39117
|
-
peg$fail(peg$
|
|
39504
|
+
peg$fail(peg$e9);
|
|
39118
39505
|
}
|
|
39119
39506
|
}
|
|
39120
39507
|
if (s13 !== peg$FAILED) {
|
|
@@ -39123,7 +39510,7 @@ function peg$parse21(input, options) {
|
|
|
39123
39510
|
s15 = peg$parseIdent();
|
|
39124
39511
|
if (s15 !== peg$FAILED) {
|
|
39125
39512
|
peg$savedPos = s11;
|
|
39126
|
-
s11 = peg$
|
|
39513
|
+
s11 = peg$f3(s1, s4, s6, s9, s15);
|
|
39127
39514
|
} else {
|
|
39128
39515
|
peg$currPos = s11;
|
|
39129
39516
|
s11 = peg$FAILED;
|
|
@@ -39147,7 +39534,184 @@ function peg$parse21(input, options) {
|
|
|
39147
39534
|
s13 = peg$parseLineEnd();
|
|
39148
39535
|
if (s13 !== peg$FAILED) {
|
|
39149
39536
|
peg$savedPos = s0;
|
|
39150
|
-
s0 = peg$
|
|
39537
|
+
s0 = peg$f4(s1, s4, s6, s9, s11);
|
|
39538
|
+
} else {
|
|
39539
|
+
peg$currPos = s0;
|
|
39540
|
+
s0 = peg$FAILED;
|
|
39541
|
+
}
|
|
39542
|
+
} else {
|
|
39543
|
+
peg$currPos = s0;
|
|
39544
|
+
s0 = peg$FAILED;
|
|
39545
|
+
}
|
|
39546
|
+
} else {
|
|
39547
|
+
peg$currPos = s0;
|
|
39548
|
+
s0 = peg$FAILED;
|
|
39549
|
+
}
|
|
39550
|
+
} else {
|
|
39551
|
+
peg$currPos = s0;
|
|
39552
|
+
s0 = peg$FAILED;
|
|
39553
|
+
}
|
|
39554
|
+
} else {
|
|
39555
|
+
peg$currPos = s0;
|
|
39556
|
+
s0 = peg$FAILED;
|
|
39557
|
+
}
|
|
39558
|
+
} else {
|
|
39559
|
+
peg$currPos = s0;
|
|
39560
|
+
s0 = peg$FAILED;
|
|
39561
|
+
}
|
|
39562
|
+
} else {
|
|
39563
|
+
peg$currPos = s0;
|
|
39564
|
+
s0 = peg$FAILED;
|
|
39565
|
+
}
|
|
39566
|
+
} else {
|
|
39567
|
+
peg$currPos = s0;
|
|
39568
|
+
s0 = peg$FAILED;
|
|
39569
|
+
}
|
|
39570
|
+
return s0;
|
|
39571
|
+
}
|
|
39572
|
+
function peg$parseJunctionLine() {
|
|
39573
|
+
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9;
|
|
39574
|
+
s0 = peg$currPos;
|
|
39575
|
+
s1 = peg$currPos;
|
|
39576
|
+
s2 = [];
|
|
39577
|
+
s3 = input.charAt(peg$currPos);
|
|
39578
|
+
if (peg$r0.test(s3)) {
|
|
39579
|
+
peg$currPos++;
|
|
39580
|
+
} else {
|
|
39581
|
+
s3 = peg$FAILED;
|
|
39582
|
+
if (peg$silentFails === 0) {
|
|
39583
|
+
peg$fail(peg$e1);
|
|
39584
|
+
}
|
|
39585
|
+
}
|
|
39586
|
+
while (s3 !== peg$FAILED) {
|
|
39587
|
+
s2.push(s3);
|
|
39588
|
+
s3 = input.charAt(peg$currPos);
|
|
39589
|
+
if (peg$r0.test(s3)) {
|
|
39590
|
+
peg$currPos++;
|
|
39591
|
+
} else {
|
|
39592
|
+
s3 = peg$FAILED;
|
|
39593
|
+
if (peg$silentFails === 0) {
|
|
39594
|
+
peg$fail(peg$e1);
|
|
39595
|
+
}
|
|
39596
|
+
}
|
|
39597
|
+
}
|
|
39598
|
+
s1 = input.substring(s1, peg$currPos);
|
|
39599
|
+
s2 = input.substr(peg$currPos, 8);
|
|
39600
|
+
if (s2.toLowerCase() === peg$c8) {
|
|
39601
|
+
peg$currPos += 8;
|
|
39602
|
+
} else {
|
|
39603
|
+
s2 = peg$FAILED;
|
|
39604
|
+
if (peg$silentFails === 0) {
|
|
39605
|
+
peg$fail(peg$e11);
|
|
39606
|
+
}
|
|
39607
|
+
}
|
|
39608
|
+
if (s2 !== peg$FAILED) {
|
|
39609
|
+
s3 = peg$parse__();
|
|
39610
|
+
if (s3 !== peg$FAILED) {
|
|
39611
|
+
s4 = peg$parseIdent();
|
|
39612
|
+
if (s4 !== peg$FAILED) {
|
|
39613
|
+
s5 = peg$currPos;
|
|
39614
|
+
s6 = peg$parse__();
|
|
39615
|
+
if (s6 !== peg$FAILED) {
|
|
39616
|
+
s7 = input.substr(peg$currPos, 2);
|
|
39617
|
+
if (s7.toLowerCase() === peg$c6) {
|
|
39618
|
+
peg$currPos += 2;
|
|
39619
|
+
} else {
|
|
39620
|
+
s7 = peg$FAILED;
|
|
39621
|
+
if (peg$silentFails === 0) {
|
|
39622
|
+
peg$fail(peg$e9);
|
|
39623
|
+
}
|
|
39624
|
+
}
|
|
39625
|
+
if (s7 !== peg$FAILED) {
|
|
39626
|
+
s8 = peg$parse__();
|
|
39627
|
+
if (s8 !== peg$FAILED) {
|
|
39628
|
+
s9 = peg$parseIdent();
|
|
39629
|
+
if (s9 !== peg$FAILED) {
|
|
39630
|
+
peg$savedPos = s5;
|
|
39631
|
+
s5 = peg$f5(s1, s4, s9);
|
|
39632
|
+
} else {
|
|
39633
|
+
peg$currPos = s5;
|
|
39634
|
+
s5 = peg$FAILED;
|
|
39635
|
+
}
|
|
39636
|
+
} else {
|
|
39637
|
+
peg$currPos = s5;
|
|
39638
|
+
s5 = peg$FAILED;
|
|
39639
|
+
}
|
|
39640
|
+
} else {
|
|
39641
|
+
peg$currPos = s5;
|
|
39642
|
+
s5 = peg$FAILED;
|
|
39643
|
+
}
|
|
39644
|
+
} else {
|
|
39645
|
+
peg$currPos = s5;
|
|
39646
|
+
s5 = peg$FAILED;
|
|
39647
|
+
}
|
|
39648
|
+
if (s5 === peg$FAILED) {
|
|
39649
|
+
s5 = null;
|
|
39650
|
+
}
|
|
39651
|
+
s6 = peg$parseRestIgnore();
|
|
39652
|
+
s7 = peg$parseLineEnd();
|
|
39653
|
+
if (s7 !== peg$FAILED) {
|
|
39654
|
+
peg$savedPos = s0;
|
|
39655
|
+
s0 = peg$f6(s1, s4, s5);
|
|
39656
|
+
} else {
|
|
39657
|
+
peg$currPos = s0;
|
|
39658
|
+
s0 = peg$FAILED;
|
|
39659
|
+
}
|
|
39660
|
+
} else {
|
|
39661
|
+
peg$currPos = s0;
|
|
39662
|
+
s0 = peg$FAILED;
|
|
39663
|
+
}
|
|
39664
|
+
} else {
|
|
39665
|
+
peg$currPos = s0;
|
|
39666
|
+
s0 = peg$FAILED;
|
|
39667
|
+
}
|
|
39668
|
+
} else {
|
|
39669
|
+
peg$currPos = s0;
|
|
39670
|
+
s0 = peg$FAILED;
|
|
39671
|
+
}
|
|
39672
|
+
return s0;
|
|
39673
|
+
}
|
|
39674
|
+
function peg$parseEdgeLine() {
|
|
39675
|
+
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12;
|
|
39676
|
+
s0 = peg$currPos;
|
|
39677
|
+
s1 = peg$parse_();
|
|
39678
|
+
s2 = peg$parseEdgeEndpoint();
|
|
39679
|
+
if (s2 !== peg$FAILED) {
|
|
39680
|
+
if (input.charCodeAt(peg$currPos) === 58) {
|
|
39681
|
+
s3 = peg$c9;
|
|
39682
|
+
peg$currPos++;
|
|
39683
|
+
} else {
|
|
39684
|
+
s3 = peg$FAILED;
|
|
39685
|
+
if (peg$silentFails === 0) {
|
|
39686
|
+
peg$fail(peg$e12);
|
|
39687
|
+
}
|
|
39688
|
+
}
|
|
39689
|
+
if (s3 !== peg$FAILED) {
|
|
39690
|
+
s4 = peg$parseSide();
|
|
39691
|
+
if (s4 !== peg$FAILED) {
|
|
39692
|
+
s5 = peg$parse_();
|
|
39693
|
+
s6 = peg$parseArrow();
|
|
39694
|
+
if (s6 !== peg$FAILED) {
|
|
39695
|
+
s7 = peg$parse_();
|
|
39696
|
+
s8 = peg$parseSide();
|
|
39697
|
+
if (s8 !== peg$FAILED) {
|
|
39698
|
+
if (input.charCodeAt(peg$currPos) === 58) {
|
|
39699
|
+
s9 = peg$c9;
|
|
39700
|
+
peg$currPos++;
|
|
39701
|
+
} else {
|
|
39702
|
+
s9 = peg$FAILED;
|
|
39703
|
+
if (peg$silentFails === 0) {
|
|
39704
|
+
peg$fail(peg$e12);
|
|
39705
|
+
}
|
|
39706
|
+
}
|
|
39707
|
+
if (s9 !== peg$FAILED) {
|
|
39708
|
+
s10 = peg$parseEdgeEndpoint();
|
|
39709
|
+
if (s10 !== peg$FAILED) {
|
|
39710
|
+
s11 = peg$parseRestIgnore();
|
|
39711
|
+
s12 = peg$parseLineEnd();
|
|
39712
|
+
if (s12 !== peg$FAILED) {
|
|
39713
|
+
peg$savedPos = s0;
|
|
39714
|
+
s0 = peg$f7(s2, s4, s6, s8, s10);
|
|
39151
39715
|
} else {
|
|
39152
39716
|
peg$currPos = s0;
|
|
39153
39717
|
s0 = peg$FAILED;
|
|
@@ -39182,81 +39746,192 @@ function peg$parse21(input, options) {
|
|
|
39182
39746
|
}
|
|
39183
39747
|
return s0;
|
|
39184
39748
|
}
|
|
39185
|
-
function peg$
|
|
39186
|
-
var s0, s1, s2, s3
|
|
39749
|
+
function peg$parseEdgeEndpoint() {
|
|
39750
|
+
var s0, s1, s2, s3;
|
|
39187
39751
|
s0 = peg$currPos;
|
|
39188
|
-
s1 = peg$
|
|
39189
|
-
|
|
39190
|
-
|
|
39191
|
-
if (input.
|
|
39192
|
-
s3 = peg$
|
|
39193
|
-
peg$currPos
|
|
39752
|
+
s1 = peg$parseIdent();
|
|
39753
|
+
if (s1 !== peg$FAILED) {
|
|
39754
|
+
s2 = peg$currPos;
|
|
39755
|
+
if (input.substr(peg$currPos, 7) === peg$c10) {
|
|
39756
|
+
s3 = peg$c10;
|
|
39757
|
+
peg$currPos += 7;
|
|
39194
39758
|
} else {
|
|
39195
39759
|
s3 = peg$FAILED;
|
|
39196
39760
|
if (peg$silentFails === 0) {
|
|
39197
|
-
peg$fail(peg$
|
|
39761
|
+
peg$fail(peg$e13);
|
|
39198
39762
|
}
|
|
39199
39763
|
}
|
|
39200
39764
|
if (s3 !== peg$FAILED) {
|
|
39201
|
-
|
|
39202
|
-
|
|
39203
|
-
|
|
39204
|
-
|
|
39205
|
-
|
|
39206
|
-
|
|
39765
|
+
peg$savedPos = s2;
|
|
39766
|
+
s3 = peg$f8(s1);
|
|
39767
|
+
}
|
|
39768
|
+
s2 = s3;
|
|
39769
|
+
if (s2 === peg$FAILED) {
|
|
39770
|
+
s2 = null;
|
|
39771
|
+
}
|
|
39772
|
+
peg$savedPos = s0;
|
|
39773
|
+
s0 = peg$f9(s1, s2);
|
|
39774
|
+
} else {
|
|
39775
|
+
peg$currPos = s0;
|
|
39776
|
+
s0 = peg$FAILED;
|
|
39777
|
+
}
|
|
39778
|
+
return s0;
|
|
39779
|
+
}
|
|
39780
|
+
function peg$parseArrow() {
|
|
39781
|
+
var s0, s1;
|
|
39782
|
+
s0 = peg$currPos;
|
|
39783
|
+
if (input.substr(peg$currPos, 4) === peg$c11) {
|
|
39784
|
+
s1 = peg$c11;
|
|
39785
|
+
peg$currPos += 4;
|
|
39786
|
+
} else {
|
|
39787
|
+
s1 = peg$FAILED;
|
|
39788
|
+
if (peg$silentFails === 0) {
|
|
39789
|
+
peg$fail(peg$e14);
|
|
39790
|
+
}
|
|
39791
|
+
}
|
|
39792
|
+
if (s1 !== peg$FAILED) {
|
|
39793
|
+
peg$savedPos = s0;
|
|
39794
|
+
s1 = peg$f10();
|
|
39795
|
+
}
|
|
39796
|
+
s0 = s1;
|
|
39797
|
+
if (s0 === peg$FAILED) {
|
|
39798
|
+
s0 = peg$currPos;
|
|
39799
|
+
if (input.substr(peg$currPos, 3) === peg$c12) {
|
|
39800
|
+
s1 = peg$c12;
|
|
39801
|
+
peg$currPos += 3;
|
|
39802
|
+
} else {
|
|
39803
|
+
s1 = peg$FAILED;
|
|
39804
|
+
if (peg$silentFails === 0) {
|
|
39805
|
+
peg$fail(peg$e15);
|
|
39806
|
+
}
|
|
39807
|
+
}
|
|
39808
|
+
if (s1 !== peg$FAILED) {
|
|
39809
|
+
peg$savedPos = s0;
|
|
39810
|
+
s1 = peg$f11();
|
|
39811
|
+
}
|
|
39812
|
+
s0 = s1;
|
|
39813
|
+
if (s0 === peg$FAILED) {
|
|
39814
|
+
s0 = peg$currPos;
|
|
39815
|
+
if (input.substr(peg$currPos, 3) === peg$c13) {
|
|
39816
|
+
s1 = peg$c13;
|
|
39817
|
+
peg$currPos += 3;
|
|
39818
|
+
} else {
|
|
39819
|
+
s1 = peg$FAILED;
|
|
39820
|
+
if (peg$silentFails === 0) {
|
|
39821
|
+
peg$fail(peg$e16);
|
|
39822
|
+
}
|
|
39823
|
+
}
|
|
39824
|
+
if (s1 !== peg$FAILED) {
|
|
39825
|
+
peg$savedPos = s0;
|
|
39826
|
+
s1 = peg$f12();
|
|
39827
|
+
}
|
|
39828
|
+
s0 = s1;
|
|
39829
|
+
if (s0 === peg$FAILED) {
|
|
39830
|
+
s0 = peg$currPos;
|
|
39831
|
+
if (input.substr(peg$currPos, 2) === peg$c14) {
|
|
39832
|
+
s1 = peg$c14;
|
|
39833
|
+
peg$currPos += 2;
|
|
39207
39834
|
} else {
|
|
39208
|
-
|
|
39835
|
+
s1 = peg$FAILED;
|
|
39209
39836
|
if (peg$silentFails === 0) {
|
|
39210
|
-
peg$fail(peg$
|
|
39837
|
+
peg$fail(peg$e17);
|
|
39211
39838
|
}
|
|
39212
39839
|
}
|
|
39213
|
-
if (
|
|
39214
|
-
|
|
39215
|
-
|
|
39216
|
-
|
|
39217
|
-
|
|
39218
|
-
|
|
39219
|
-
|
|
39220
|
-
|
|
39221
|
-
|
|
39222
|
-
|
|
39223
|
-
|
|
39224
|
-
|
|
39225
|
-
|
|
39226
|
-
|
|
39227
|
-
|
|
39228
|
-
|
|
39229
|
-
|
|
39230
|
-
|
|
39231
|
-
|
|
39232
|
-
|
|
39840
|
+
if (s1 !== peg$FAILED) {
|
|
39841
|
+
peg$savedPos = s0;
|
|
39842
|
+
s1 = peg$f13();
|
|
39843
|
+
}
|
|
39844
|
+
s0 = s1;
|
|
39845
|
+
}
|
|
39846
|
+
}
|
|
39847
|
+
}
|
|
39848
|
+
return s0;
|
|
39849
|
+
}
|
|
39850
|
+
function peg$parseAlignLine() {
|
|
39851
|
+
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10;
|
|
39852
|
+
s0 = peg$currPos;
|
|
39853
|
+
s1 = peg$parse_();
|
|
39854
|
+
s2 = input.substr(peg$currPos, 5);
|
|
39855
|
+
if (s2.toLowerCase() === peg$c15) {
|
|
39856
|
+
peg$currPos += 5;
|
|
39857
|
+
} else {
|
|
39858
|
+
s2 = peg$FAILED;
|
|
39859
|
+
if (peg$silentFails === 0) {
|
|
39860
|
+
peg$fail(peg$e18);
|
|
39861
|
+
}
|
|
39862
|
+
}
|
|
39863
|
+
if (s2 !== peg$FAILED) {
|
|
39864
|
+
s3 = peg$parse__();
|
|
39865
|
+
if (s3 !== peg$FAILED) {
|
|
39866
|
+
s4 = input.substr(peg$currPos, 3);
|
|
39867
|
+
if (s4.toLowerCase() === peg$c16) {
|
|
39868
|
+
peg$currPos += 3;
|
|
39869
|
+
} else {
|
|
39870
|
+
s4 = peg$FAILED;
|
|
39871
|
+
if (peg$silentFails === 0) {
|
|
39872
|
+
peg$fail(peg$e19);
|
|
39873
|
+
}
|
|
39874
|
+
}
|
|
39875
|
+
if (s4 === peg$FAILED) {
|
|
39876
|
+
s4 = input.substr(peg$currPos, 6);
|
|
39877
|
+
if (s4.toLowerCase() === peg$c17) {
|
|
39878
|
+
peg$currPos += 6;
|
|
39879
|
+
} else {
|
|
39880
|
+
s4 = peg$FAILED;
|
|
39881
|
+
if (peg$silentFails === 0) {
|
|
39882
|
+
peg$fail(peg$e20);
|
|
39233
39883
|
}
|
|
39234
39884
|
}
|
|
39235
|
-
|
|
39236
|
-
|
|
39237
|
-
|
|
39238
|
-
|
|
39239
|
-
|
|
39240
|
-
|
|
39241
|
-
|
|
39242
|
-
|
|
39243
|
-
|
|
39244
|
-
if (peg$silentFails === 0) {
|
|
39245
|
-
peg$fail(peg$e11);
|
|
39246
|
-
}
|
|
39247
|
-
}
|
|
39885
|
+
}
|
|
39886
|
+
if (s4 !== peg$FAILED) {
|
|
39887
|
+
s5 = peg$parse__();
|
|
39888
|
+
if (s5 !== peg$FAILED) {
|
|
39889
|
+
s6 = peg$parseIdent();
|
|
39890
|
+
if (s6 !== peg$FAILED) {
|
|
39891
|
+
s7 = [];
|
|
39892
|
+
s8 = peg$currPos;
|
|
39893
|
+
s9 = peg$parse__();
|
|
39248
39894
|
if (s9 !== peg$FAILED) {
|
|
39249
39895
|
s10 = peg$parseIdent();
|
|
39250
39896
|
if (s10 !== peg$FAILED) {
|
|
39251
|
-
|
|
39252
|
-
|
|
39253
|
-
|
|
39254
|
-
|
|
39255
|
-
|
|
39897
|
+
peg$savedPos = s8;
|
|
39898
|
+
s8 = peg$f14(s4, s6, s10);
|
|
39899
|
+
} else {
|
|
39900
|
+
peg$currPos = s8;
|
|
39901
|
+
s8 = peg$FAILED;
|
|
39902
|
+
}
|
|
39903
|
+
} else {
|
|
39904
|
+
peg$currPos = s8;
|
|
39905
|
+
s8 = peg$FAILED;
|
|
39906
|
+
}
|
|
39907
|
+
if (s8 !== peg$FAILED) {
|
|
39908
|
+
while (s8 !== peg$FAILED) {
|
|
39909
|
+
s7.push(s8);
|
|
39910
|
+
s8 = peg$currPos;
|
|
39911
|
+
s9 = peg$parse__();
|
|
39912
|
+
if (s9 !== peg$FAILED) {
|
|
39913
|
+
s10 = peg$parseIdent();
|
|
39914
|
+
if (s10 !== peg$FAILED) {
|
|
39915
|
+
peg$savedPos = s8;
|
|
39916
|
+
s8 = peg$f14(s4, s6, s10);
|
|
39917
|
+
} else {
|
|
39918
|
+
peg$currPos = s8;
|
|
39919
|
+
s8 = peg$FAILED;
|
|
39920
|
+
}
|
|
39256
39921
|
} else {
|
|
39257
|
-
peg$currPos =
|
|
39258
|
-
|
|
39922
|
+
peg$currPos = s8;
|
|
39923
|
+
s8 = peg$FAILED;
|
|
39259
39924
|
}
|
|
39925
|
+
}
|
|
39926
|
+
} else {
|
|
39927
|
+
s7 = peg$FAILED;
|
|
39928
|
+
}
|
|
39929
|
+
if (s7 !== peg$FAILED) {
|
|
39930
|
+
s8 = peg$parseRestIgnore();
|
|
39931
|
+
s9 = peg$parseLineEnd();
|
|
39932
|
+
if (s9 !== peg$FAILED) {
|
|
39933
|
+
peg$savedPos = s0;
|
|
39934
|
+
s0 = peg$f15(s4, s6, s7);
|
|
39260
39935
|
} else {
|
|
39261
39936
|
peg$currPos = s0;
|
|
39262
39937
|
s0 = peg$FAILED;
|
|
@@ -39295,7 +39970,7 @@ function peg$parse21(input, options) {
|
|
|
39295
39970
|
} else {
|
|
39296
39971
|
s0 = peg$FAILED;
|
|
39297
39972
|
if (peg$silentFails === 0) {
|
|
39298
|
-
peg$fail(peg$
|
|
39973
|
+
peg$fail(peg$e21);
|
|
39299
39974
|
}
|
|
39300
39975
|
}
|
|
39301
39976
|
return s0;
|
|
@@ -39310,7 +39985,7 @@ function peg$parse21(input, options) {
|
|
|
39310
39985
|
} else {
|
|
39311
39986
|
s2 = peg$FAILED;
|
|
39312
39987
|
if (peg$silentFails === 0) {
|
|
39313
|
-
peg$fail(peg$
|
|
39988
|
+
peg$fail(peg$e22);
|
|
39314
39989
|
}
|
|
39315
39990
|
}
|
|
39316
39991
|
while (s2 !== peg$FAILED) {
|
|
@@ -39321,7 +39996,7 @@ function peg$parse21(input, options) {
|
|
|
39321
39996
|
} else {
|
|
39322
39997
|
s2 = peg$FAILED;
|
|
39323
39998
|
if (peg$silentFails === 0) {
|
|
39324
|
-
peg$fail(peg$
|
|
39999
|
+
peg$fail(peg$e22);
|
|
39325
40000
|
}
|
|
39326
40001
|
}
|
|
39327
40002
|
}
|
|
@@ -39338,7 +40013,7 @@ function peg$parse21(input, options) {
|
|
|
39338
40013
|
} else {
|
|
39339
40014
|
s2 = peg$FAILED;
|
|
39340
40015
|
if (peg$silentFails === 0) {
|
|
39341
|
-
peg$fail(peg$
|
|
40016
|
+
peg$fail(peg$e23);
|
|
39342
40017
|
}
|
|
39343
40018
|
}
|
|
39344
40019
|
if (s2 !== peg$FAILED) {
|
|
@@ -39350,7 +40025,7 @@ function peg$parse21(input, options) {
|
|
|
39350
40025
|
} else {
|
|
39351
40026
|
s2 = peg$FAILED;
|
|
39352
40027
|
if (peg$silentFails === 0) {
|
|
39353
|
-
peg$fail(peg$
|
|
40028
|
+
peg$fail(peg$e23);
|
|
39354
40029
|
}
|
|
39355
40030
|
}
|
|
39356
40031
|
}
|
|
@@ -39369,29 +40044,29 @@ function peg$parse21(input, options) {
|
|
|
39369
40044
|
s0 = peg$currPos;
|
|
39370
40045
|
s1 = peg$parse_();
|
|
39371
40046
|
if (input.charCodeAt(peg$currPos) === 13) {
|
|
39372
|
-
s2 = peg$
|
|
40047
|
+
s2 = peg$c18;
|
|
39373
40048
|
peg$currPos++;
|
|
39374
40049
|
} else {
|
|
39375
40050
|
s2 = peg$FAILED;
|
|
39376
40051
|
if (peg$silentFails === 0) {
|
|
39377
|
-
peg$fail(peg$
|
|
40052
|
+
peg$fail(peg$e24);
|
|
39378
40053
|
}
|
|
39379
40054
|
}
|
|
39380
40055
|
if (s2 === peg$FAILED) {
|
|
39381
40056
|
s2 = null;
|
|
39382
40057
|
}
|
|
39383
40058
|
if (input.charCodeAt(peg$currPos) === 10) {
|
|
39384
|
-
s3 = peg$
|
|
40059
|
+
s3 = peg$c19;
|
|
39385
40060
|
peg$currPos++;
|
|
39386
40061
|
} else {
|
|
39387
40062
|
s3 = peg$FAILED;
|
|
39388
40063
|
if (peg$silentFails === 0) {
|
|
39389
|
-
peg$fail(peg$
|
|
40064
|
+
peg$fail(peg$e25);
|
|
39390
40065
|
}
|
|
39391
40066
|
}
|
|
39392
40067
|
if (s3 !== peg$FAILED) {
|
|
39393
40068
|
peg$savedPos = s0;
|
|
39394
|
-
s0 = peg$
|
|
40069
|
+
s0 = peg$f16();
|
|
39395
40070
|
} else {
|
|
39396
40071
|
peg$currPos = s0;
|
|
39397
40072
|
s0 = peg$FAILED;
|
|
@@ -39402,24 +40077,24 @@ function peg$parse21(input, options) {
|
|
|
39402
40077
|
var s0, s1, s2;
|
|
39403
40078
|
s0 = peg$currPos;
|
|
39404
40079
|
if (input.charCodeAt(peg$currPos) === 13) {
|
|
39405
|
-
s1 = peg$
|
|
40080
|
+
s1 = peg$c18;
|
|
39406
40081
|
peg$currPos++;
|
|
39407
40082
|
} else {
|
|
39408
40083
|
s1 = peg$FAILED;
|
|
39409
40084
|
if (peg$silentFails === 0) {
|
|
39410
|
-
peg$fail(peg$
|
|
40085
|
+
peg$fail(peg$e24);
|
|
39411
40086
|
}
|
|
39412
40087
|
}
|
|
39413
40088
|
if (s1 === peg$FAILED) {
|
|
39414
40089
|
s1 = null;
|
|
39415
40090
|
}
|
|
39416
40091
|
if (input.charCodeAt(peg$currPos) === 10) {
|
|
39417
|
-
s2 = peg$
|
|
40092
|
+
s2 = peg$c19;
|
|
39418
40093
|
peg$currPos++;
|
|
39419
40094
|
} else {
|
|
39420
40095
|
s2 = peg$FAILED;
|
|
39421
40096
|
if (peg$silentFails === 0) {
|
|
39422
|
-
peg$fail(peg$
|
|
40097
|
+
peg$fail(peg$e25);
|
|
39423
40098
|
}
|
|
39424
40099
|
}
|
|
39425
40100
|
if (s2 !== peg$FAILED) {
|
|
@@ -39438,7 +40113,7 @@ function peg$parse21(input, options) {
|
|
|
39438
40113
|
} else {
|
|
39439
40114
|
s1 = peg$FAILED;
|
|
39440
40115
|
if (peg$silentFails === 0) {
|
|
39441
|
-
peg$fail(peg$
|
|
40116
|
+
peg$fail(peg$e26);
|
|
39442
40117
|
}
|
|
39443
40118
|
}
|
|
39444
40119
|
peg$silentFails--;
|
|
@@ -39534,7 +40209,7 @@ function peg$parse21(input, options) {
|
|
|
39534
40209
|
}
|
|
39535
40210
|
}
|
|
39536
40211
|
|
|
39537
|
-
// src/diagrams/
|
|
40212
|
+
// src/diagrams/mermaid/architecture/index.ts
|
|
39538
40213
|
var architecture = {
|
|
39539
40214
|
parseMermaid(input) {
|
|
39540
40215
|
return peg$parse21(input);
|
|
@@ -39542,8 +40217,8 @@ var architecture = {
|
|
|
39542
40217
|
parseYaml(input) {
|
|
39543
40218
|
return JSON.parse(input);
|
|
39544
40219
|
},
|
|
39545
|
-
layout(ir, theme) {
|
|
39546
|
-
return layoutArchitecture(ir, theme);
|
|
40220
|
+
layout(ir, theme, options) {
|
|
40221
|
+
return layoutArchitecture(ir, theme, options);
|
|
39547
40222
|
}
|
|
39548
40223
|
};
|
|
39549
40224
|
|
|
@@ -43768,9 +44443,89 @@ function parseEntries(spec) {
|
|
|
43768
44443
|
return { key: pair, value: "" };
|
|
43769
44444
|
});
|
|
43770
44445
|
}
|
|
44446
|
+
function parseBucketLabels(spec) {
|
|
44447
|
+
const labels = [];
|
|
44448
|
+
let current = "";
|
|
44449
|
+
let inQuotes = false;
|
|
44450
|
+
let escaping = false;
|
|
44451
|
+
for (const ch of spec) {
|
|
44452
|
+
if (escaping) {
|
|
44453
|
+
current += ch;
|
|
44454
|
+
escaping = false;
|
|
44455
|
+
continue;
|
|
44456
|
+
}
|
|
44457
|
+
if (inQuotes && ch === "\\") {
|
|
44458
|
+
escaping = true;
|
|
44459
|
+
continue;
|
|
44460
|
+
}
|
|
44461
|
+
if (ch === '"') {
|
|
44462
|
+
inQuotes = !inQuotes;
|
|
44463
|
+
continue;
|
|
44464
|
+
}
|
|
44465
|
+
if (!inQuotes && ch === ",") {
|
|
44466
|
+
const label = current.trim();
|
|
44467
|
+
if (label) labels.push(label);
|
|
44468
|
+
current = "";
|
|
44469
|
+
continue;
|
|
44470
|
+
}
|
|
44471
|
+
current += ch;
|
|
44472
|
+
}
|
|
44473
|
+
if (inQuotes) throw new Error(`Unterminated bucket label: ${spec}`);
|
|
44474
|
+
const tail = current.trim();
|
|
44475
|
+
if (tail) labels.push(tail);
|
|
44476
|
+
return labels;
|
|
44477
|
+
}
|
|
44478
|
+
function splitBucketDirective(spec) {
|
|
44479
|
+
let inQuotes = false;
|
|
44480
|
+
let escaping = false;
|
|
44481
|
+
for (let i = 0; i < spec.length; i++) {
|
|
44482
|
+
const ch = spec[i];
|
|
44483
|
+
if (escaping) {
|
|
44484
|
+
escaping = false;
|
|
44485
|
+
continue;
|
|
44486
|
+
}
|
|
44487
|
+
if (inQuotes && ch === "\\") {
|
|
44488
|
+
escaping = true;
|
|
44489
|
+
continue;
|
|
44490
|
+
}
|
|
44491
|
+
if (ch === '"') {
|
|
44492
|
+
inQuotes = !inQuotes;
|
|
44493
|
+
continue;
|
|
44494
|
+
}
|
|
44495
|
+
if (!inQuotes && ch === ":") {
|
|
44496
|
+
return { id: spec.slice(0, i).trim(), entries: spec.slice(i + 1).trim() };
|
|
44497
|
+
}
|
|
44498
|
+
}
|
|
44499
|
+
return null;
|
|
44500
|
+
}
|
|
44501
|
+
function parseBucketId(spec) {
|
|
44502
|
+
const [label = ""] = parseBucketLabels(spec);
|
|
44503
|
+
return /^\d+$/.test(label) ? Number(label) : label;
|
|
44504
|
+
}
|
|
44505
|
+
function normalizeDoc(doc) {
|
|
44506
|
+
const chains = doc.chains ?? [];
|
|
44507
|
+
const bucketLabels = [...doc.bucketLabels ?? []];
|
|
44508
|
+
for (const chain of chains) {
|
|
44509
|
+
if (typeof chain.index === "string" && !bucketLabels.includes(chain.index)) bucketLabels.push(chain.index);
|
|
44510
|
+
}
|
|
44511
|
+
const maxIdx = chains.reduce((mx, c) => typeof c.index === "number" ? Math.max(mx, c.index) : mx, -1);
|
|
44512
|
+
const numericBucketCount = Math.max(doc.buckets ?? 0, maxIdx + 1, 1);
|
|
44513
|
+
if (bucketLabels.length === 0) {
|
|
44514
|
+
for (let i = 0; i < numericBucketCount; i++) bucketLabels.push(String(i));
|
|
44515
|
+
} else {
|
|
44516
|
+
while (bucketLabels.length < numericBucketCount) bucketLabels.push(String(bucketLabels.length));
|
|
44517
|
+
}
|
|
44518
|
+
return {
|
|
44519
|
+
...doc.title !== void 0 ? { title: doc.title } : {},
|
|
44520
|
+
buckets: bucketLabels.length,
|
|
44521
|
+
bucketLabels,
|
|
44522
|
+
chains
|
|
44523
|
+
};
|
|
44524
|
+
}
|
|
43771
44525
|
function parse10(input) {
|
|
43772
44526
|
let title;
|
|
43773
44527
|
let bucketCount;
|
|
44528
|
+
let explicitBucketLabels;
|
|
43774
44529
|
const chains = [];
|
|
43775
44530
|
for (const line of lines(input)) {
|
|
43776
44531
|
const t = line.split(/\s+/);
|
|
@@ -43782,18 +44537,25 @@ function parse10(input) {
|
|
|
43782
44537
|
continue;
|
|
43783
44538
|
}
|
|
43784
44539
|
if (t[0] === "buckets") {
|
|
43785
|
-
const
|
|
43786
|
-
if (
|
|
44540
|
+
const spec = line.slice(7).trim();
|
|
44541
|
+
if (!spec) continue;
|
|
44542
|
+
if (/^\d+$/.test(spec)) {
|
|
44543
|
+
bucketCount = Number(spec);
|
|
44544
|
+
explicitBucketLabels = void 0;
|
|
44545
|
+
} else {
|
|
44546
|
+
explicitBucketLabels = parseBucketLabels(spec);
|
|
44547
|
+
}
|
|
43787
44548
|
continue;
|
|
43788
44549
|
}
|
|
43789
44550
|
if (t[0] === "bucket") {
|
|
43790
|
-
const
|
|
43791
|
-
if (
|
|
44551
|
+
const parsed = splitBucketDirective(line.slice(6).trim());
|
|
44552
|
+
if (parsed) chains.push({ index: parseBucketId(parsed.id), entries: parseEntries(parsed.entries) });
|
|
43792
44553
|
}
|
|
43793
44554
|
}
|
|
43794
|
-
|
|
43795
|
-
|
|
43796
|
-
|
|
44555
|
+
return normalizeDoc({ title, buckets: bucketCount, bucketLabels: explicitBucketLabels, chains });
|
|
44556
|
+
}
|
|
44557
|
+
function bucketKey(id) {
|
|
44558
|
+
return typeof id === "number" ? `n:${id}` : `s:${id}`;
|
|
43797
44559
|
}
|
|
43798
44560
|
function layoutHashmap(doc, theme) {
|
|
43799
44561
|
const { palette, typography, spacing } = theme;
|
|
@@ -43801,7 +44563,7 @@ function layoutHashmap(doc, theme) {
|
|
|
43801
44563
|
const margin = spacing.diagramMargin;
|
|
43802
44564
|
const font = typography.baseFontSize;
|
|
43803
44565
|
const cellH = 38;
|
|
43804
|
-
const idxW = 46;
|
|
44566
|
+
const idxW = Math.max(46, ...doc.bucketLabels.map((label) => measureText(label, font).width + 24));
|
|
43805
44567
|
const entryH = 30;
|
|
43806
44568
|
const entryGap = 30;
|
|
43807
44569
|
const chainGap = 36;
|
|
@@ -43811,22 +44573,23 @@ function layoutHashmap(doc, theme) {
|
|
|
43811
44573
|
if (doc.title) {
|
|
43812
44574
|
elements.push(p.text(doc.title, margin, margin + typography.titleFontSize, typography.titleFontSize, palette.text, { weight: "bold" }));
|
|
43813
44575
|
}
|
|
43814
|
-
const
|
|
44576
|
+
const slotById = /* @__PURE__ */ new Map();
|
|
44577
|
+
const anchors = {};
|
|
43815
44578
|
for (let i = 0; i < doc.buckets; i++) {
|
|
43816
44579
|
const slot = { x: origin.x, y: origin.y + i * cellH, width: idxW, height: cellH };
|
|
43817
|
-
|
|
44580
|
+
const label = doc.bucketLabels[i] ?? String(i);
|
|
44581
|
+
slotById.set(bucketKey(i), { row: i, bounds: slot });
|
|
44582
|
+
if (!slotById.has(bucketKey(label))) slotById.set(bucketKey(label), { row: i, bounds: slot });
|
|
44583
|
+
anchors[`b${i}`] = { bounds: slot };
|
|
43818
44584
|
elements.push(p.rect(slot, palette.surface, palette.border, 1.5, { rx: 3 }));
|
|
43819
|
-
elements.push(p.text(
|
|
44585
|
+
elements.push(p.text(label, slot.x + slot.width / 2, slot.y + slot.height / 2 + font * 0.35, font, palette.textMuted, { anchor: "middle", weight: "bold" }));
|
|
43820
44586
|
}
|
|
43821
|
-
const anchors = {};
|
|
43822
|
-
slots.forEach((slot, i) => {
|
|
43823
|
-
anchors[`b${i}`] = { bounds: slot };
|
|
43824
|
-
});
|
|
43825
44587
|
const chainStartX = origin.x + idxW + chainGap;
|
|
43826
44588
|
let maxRight = chainStartX;
|
|
43827
44589
|
for (const chain of doc.chains) {
|
|
43828
|
-
const
|
|
43829
|
-
if (!
|
|
44590
|
+
const slotRef = slotById.get(bucketKey(chain.index));
|
|
44591
|
+
if (!slotRef || chain.entries.length === 0) continue;
|
|
44592
|
+
const { bounds: slot, row } = slotRef;
|
|
43830
44593
|
const cy = slot.y + slot.height / 2;
|
|
43831
44594
|
let x = chainStartX;
|
|
43832
44595
|
let fromX = slot.x + slot.width;
|
|
@@ -43837,7 +44600,7 @@ function layoutHashmap(doc, theme) {
|
|
|
43837
44600
|
elements.push(p.path(`M ${rhu(fromX)} ${rhu(cy)} L ${rhu(x - 3)} ${rhu(cy)}`, palette.primary, 1.5, { markerEnd: ARROW_ID2 }));
|
|
43838
44601
|
elements.push(p.rect(box, palette.surface, palette.border, 1.5, { rx: 4 }));
|
|
43839
44602
|
elements.push(p.text(label, x + w / 2, cy + font * 0.35, font, palette.text, { anchor: "middle", weight: "bold" }));
|
|
43840
|
-
anchors[`b${
|
|
44603
|
+
anchors[`b${row}e${j}`] = { bounds: box };
|
|
43841
44604
|
fromX = x + w;
|
|
43842
44605
|
x = fromX + entryGap;
|
|
43843
44606
|
maxRight = Math.max(maxRight, fromX);
|
|
@@ -43858,7 +44621,7 @@ var hashmap = {
|
|
|
43858
44621
|
return { version: "1.0", metadata: {}, ...parse10(input) };
|
|
43859
44622
|
},
|
|
43860
44623
|
parseYaml(input) {
|
|
43861
|
-
return JSON.parse(input);
|
|
44624
|
+
return { version: "1.0", metadata: {}, ...normalizeDoc(JSON.parse(input)) };
|
|
43862
44625
|
},
|
|
43863
44626
|
layout(ir, theme) {
|
|
43864
44627
|
return layoutHashmap(ir, theme);
|