@uigraph/sdk 1.2.6 → 1.2.8
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/README.md +1 -1
- package/dist/{__index.BVDt3Nmx.d.cts → __index.B1JSpBNJ.d.cts} +4 -0
- package/dist/{__index.BQQp_uAt.d.mts → __index.BjLNt7Hi.d.mts} +4 -0
- package/dist/browser.d.cts +1 -1
- package/dist/browser.d.mts +1 -1
- package/dist/index.cjs +1241 -998
- package/dist/index.d.cts +21 -15
- package/dist/index.d.mts +21 -15
- package/dist/index.mjs +1238 -999
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -2564,6 +2564,7 @@ function convertC4ToReactFlow(data) {
|
|
|
2564
2564
|
},
|
|
2565
2565
|
data: {
|
|
2566
2566
|
source: "mermaid",
|
|
2567
|
+
c4DiagramType: data.type,
|
|
2567
2568
|
c4BoundaryKind: boundary.kind,
|
|
2568
2569
|
boundaryType: boundary.type,
|
|
2569
2570
|
description: boundary.description,
|
|
@@ -2603,6 +2604,7 @@ function convertC4ToReactFlow(data) {
|
|
|
2603
2604
|
source: "mermaid",
|
|
2604
2605
|
diagramId: element.subDiagramId,
|
|
2605
2606
|
diagramName: element.label,
|
|
2607
|
+
c4DiagramType: data.type,
|
|
2606
2608
|
c4Kind: element.kind,
|
|
2607
2609
|
c4Shape: element.shape,
|
|
2608
2610
|
isExternal: element.isExternal,
|
|
@@ -2666,6 +2668,9 @@ function convertC4ToReactFlow(data) {
|
|
|
2666
2668
|
},
|
|
2667
2669
|
data: {
|
|
2668
2670
|
source: "mermaid",
|
|
2671
|
+
c4RelDirection: rel.direction,
|
|
2672
|
+
c4RelTechnology: rel.technology,
|
|
2673
|
+
c4RelDescription: rel.description,
|
|
2669
2674
|
labelColor: style === null || style === void 0 ? void 0 : style.textColor,
|
|
2670
2675
|
labelOffsetX: style === null || style === void 0 ? void 0 : style.offsetX,
|
|
2671
2676
|
labelOffsetY: style === null || style === void 0 ? void 0 : style.offsetY
|
|
@@ -5199,1048 +5204,1282 @@ function _convertMermaidToReactFlow() {
|
|
|
5199
5204
|
});
|
|
5200
5205
|
return _convertMermaidToReactFlow.apply(this, arguments);
|
|
5201
5206
|
}
|
|
5202
|
-
|
|
5203
|
-
|
|
5204
|
-
|
|
5205
|
-
|
|
5206
|
-
|
|
5207
|
-
|
|
5208
|
-
|
|
5209
|
-
|
|
5210
|
-
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
|
|
5214
|
-
|
|
5215
|
-
|
|
5216
|
-
|
|
5217
|
-
|
|
5218
|
-
|
|
5219
|
-
|
|
5220
|
-
|
|
5221
|
-
|
|
5222
|
-
|
|
5223
|
-
|
|
5224
|
-
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
5207
|
+
const CONTEXT_SHAPES = new Set([
|
|
5208
|
+
"rectangle",
|
|
5209
|
+
"rounded-rect",
|
|
5210
|
+
"ellipse",
|
|
5211
|
+
"diamond",
|
|
5212
|
+
"triangle",
|
|
5213
|
+
"parallelogram",
|
|
5214
|
+
"trapezoid",
|
|
5215
|
+
"hexagon",
|
|
5216
|
+
"document",
|
|
5217
|
+
"cylinder",
|
|
5218
|
+
"delay",
|
|
5219
|
+
"off-page-connector",
|
|
5220
|
+
"display",
|
|
5221
|
+
"collate",
|
|
5222
|
+
"sort",
|
|
5223
|
+
"terminator",
|
|
5224
|
+
"or",
|
|
5225
|
+
"database",
|
|
5226
|
+
"multiple-documents",
|
|
5227
|
+
"subroutine",
|
|
5228
|
+
"manual-input",
|
|
5229
|
+
"summing-junction",
|
|
5230
|
+
"internal-storage"
|
|
5231
|
+
]);
|
|
5232
|
+
const COMPONENT_INPUT_TYPES = new Set(Object.values(require_component_type.ComponentInputType));
|
|
5233
|
+
const INLINE_MERMAID_LABEL_MAX_LENGTH = 32;
|
|
5234
|
+
const KNOWN_NODE_DATA_KEYS = new Set([
|
|
5235
|
+
"componentFields",
|
|
5236
|
+
"shape",
|
|
5237
|
+
"fill",
|
|
5238
|
+
"stroke",
|
|
5239
|
+
"strokeWidth",
|
|
5240
|
+
"strokeStyle",
|
|
5241
|
+
"borderRadius",
|
|
5242
|
+
"borderAnimationEnabled",
|
|
5243
|
+
"strokeAnimation",
|
|
5244
|
+
"src",
|
|
5245
|
+
"animatedIcon",
|
|
5246
|
+
"iconSrc",
|
|
5247
|
+
"componentId",
|
|
5248
|
+
"serviceTable",
|
|
5249
|
+
"title",
|
|
5250
|
+
"columns",
|
|
5251
|
+
"rows",
|
|
5252
|
+
"name",
|
|
5253
|
+
"label",
|
|
5254
|
+
"value",
|
|
5255
|
+
"cloud",
|
|
5256
|
+
"service",
|
|
5257
|
+
"childNodes"
|
|
5258
|
+
]);
|
|
5259
|
+
function isComponentInputType(value) {
|
|
5260
|
+
return COMPONENT_INPUT_TYPES.has(value);
|
|
5229
5261
|
}
|
|
5230
|
-
function
|
|
5231
|
-
|
|
5232
|
-
const fields = (_node$data = node.data) === null || _node$data === void 0 ? void 0 : _node$data.componentFields;
|
|
5233
|
-
if (!Array.isArray(fields)) return void 0;
|
|
5234
|
-
const field = fields.find((candidate) => (candidate === null || candidate === void 0 ? void 0 : candidate.componentFieldId) === componentFieldId);
|
|
5235
|
-
const value = field === null || field === void 0 || (_field$data = field.data) === null || _field$data === void 0 || (_field$data = _field$data[0]) === null || _field$data === void 0 ? void 0 : _field$data.value;
|
|
5236
|
-
if (typeof value !== "string") return void 0;
|
|
5237
|
-
if (!value.trim()) return void 0;
|
|
5262
|
+
function toRecord(value) {
|
|
5263
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return;
|
|
5238
5264
|
return value;
|
|
5239
5265
|
}
|
|
5240
|
-
function
|
|
5241
|
-
|
|
5242
|
-
const
|
|
5243
|
-
if (
|
|
5244
|
-
|
|
5245
|
-
if (typeof label === "string") return label;
|
|
5246
|
-
return "";
|
|
5266
|
+
function pickString(value) {
|
|
5267
|
+
if (typeof value !== "string") return;
|
|
5268
|
+
const trimmed = value.trim();
|
|
5269
|
+
if (!trimmed) return;
|
|
5270
|
+
return trimmed;
|
|
5247
5271
|
}
|
|
5248
|
-
function
|
|
5249
|
-
|
|
5272
|
+
function pickPosition(value) {
|
|
5273
|
+
const position = toRecord(value);
|
|
5274
|
+
if (!position) return;
|
|
5275
|
+
if (typeof position.x !== "number" || !Number.isFinite(position.x)) return;
|
|
5276
|
+
if (typeof position.y !== "number" || !Number.isFinite(position.y)) return;
|
|
5277
|
+
return {
|
|
5278
|
+
x: position.x,
|
|
5279
|
+
y: position.y
|
|
5280
|
+
};
|
|
5250
5281
|
}
|
|
5251
|
-
function
|
|
5252
|
-
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
|
|
5256
|
-
|
|
5257
|
-
suffix++;
|
|
5258
|
-
}
|
|
5259
|
-
used.add(candidate);
|
|
5260
|
-
return candidate;
|
|
5282
|
+
function getFieldValue(fieldData) {
|
|
5283
|
+
if (!Array.isArray(fieldData) || fieldData.length !== 1) return fieldData;
|
|
5284
|
+
const first = toRecord(fieldData[0]);
|
|
5285
|
+
if (!first) return fieldData;
|
|
5286
|
+
if (!("value" in first)) return first;
|
|
5287
|
+
return first.value;
|
|
5261
5288
|
}
|
|
5262
|
-
function
|
|
5263
|
-
|
|
5264
|
-
|
|
5265
|
-
|
|
5266
|
-
const name = nodeLabel(node) || `Participant ${index + 1}`;
|
|
5267
|
-
const rawType = (_node$data3 = node.data) === null || _node$data3 === void 0 ? void 0 : _node$data3.participantType;
|
|
5268
|
-
const activations = (_node$data4 = node.data) === null || _node$data4 === void 0 ? void 0 : _node$data4.activations;
|
|
5269
|
-
const links = (_node$data5 = node.data) === null || _node$data5 === void 0 ? void 0 : _node$data5.links;
|
|
5270
|
-
const createdRow = (_node$data6 = node.data) === null || _node$data6 === void 0 ? void 0 : _node$data6.lifelineStartRow;
|
|
5271
|
-
const destroyedRow = (_node$data7 = node.data) === null || _node$data7 === void 0 ? void 0 : _node$data7.lifelineEndRow;
|
|
5272
|
-
return _objectSpread2(_objectSpread2(_objectSpread2({
|
|
5273
|
-
nodeId: node.id,
|
|
5274
|
-
mermaidId: toMermaidId(name, index, used),
|
|
5275
|
-
name,
|
|
5276
|
-
type: typeof rawType === "string" ? rawType : "participant",
|
|
5277
|
-
links: Array.isArray(links) ? links : [],
|
|
5278
|
-
activations: Array.isArray(activations) ? activations : []
|
|
5279
|
-
}, typeof createdRow === "number" ? { createdRow } : {}), typeof destroyedRow === "number" ? { destroyedRow } : {}), {}, { x: node.position.x });
|
|
5289
|
+
function getFieldByLabel(fields, label) {
|
|
5290
|
+
return fields.find((field) => {
|
|
5291
|
+
var _pickString;
|
|
5292
|
+
return ((_pickString = pickString(field.label)) === null || _pickString === void 0 ? void 0 : _pickString.toLowerCase()) === label.toLowerCase() && pickString(field.type);
|
|
5280
5293
|
});
|
|
5281
5294
|
}
|
|
5282
|
-
function
|
|
5283
|
-
const
|
|
5284
|
-
|
|
5285
|
-
|
|
5286
|
-
if (participantNodeIds.has(edge.target)) links.set(edge.source, _objectSpread2(_objectSpread2({}, links.get(edge.source)), {}, { to: edge.target }));
|
|
5287
|
-
}
|
|
5288
|
-
return links;
|
|
5295
|
+
function getFieldString(fields, label) {
|
|
5296
|
+
const field = getFieldByLabel(fields, label);
|
|
5297
|
+
if (!field) return;
|
|
5298
|
+
return pickString(getFieldValue(field.data));
|
|
5289
5299
|
}
|
|
5290
|
-
function
|
|
5291
|
-
|
|
5292
|
-
|
|
5293
|
-
const half = (_edgeTo$data$half = edgeTo === null || edgeTo === void 0 || (_edgeTo$data2 = edgeTo.data) === null || _edgeTo$data2 === void 0 ? void 0 : _edgeTo$data2.half) !== null && _edgeTo$data$half !== void 0 ? _edgeTo$data$half : edgeFrom === null || edgeFrom === void 0 || (_edgeFrom$data2 = edgeFrom.data) === null || _edgeFrom$data2 === void 0 ? void 0 : _edgeFrom$data2.half;
|
|
5294
|
-
const reversed = (edgeFrom === null || edgeFrom === void 0 || (_edgeFrom$data3 = edgeFrom.data) === null || _edgeFrom$data3 === void 0 ? void 0 : _edgeFrom$data3.reversed) === true;
|
|
5295
|
-
return findArrowTokenFor(_objectSpread2(_objectSpread2({
|
|
5296
|
-
lineStyle: (edgeTo === null || edgeTo === void 0 || (_ref = edgeTo.style) === null || _ref === void 0 ? void 0 : _ref.strokeDasharray) !== void 0 || (edgeFrom === null || edgeFrom === void 0 || (_ref2 = edgeFrom.style) === null || _ref2 === void 0 ? void 0 : _ref2.strokeDasharray) !== void 0 ? "dashed" : "solid",
|
|
5297
|
-
arrowType: arrowType !== null && arrowType !== void 0 ? arrowType : "filled"
|
|
5298
|
-
}, half ? { half } : {}), {}, { reversed }));
|
|
5300
|
+
function isEmptyFieldValue(value) {
|
|
5301
|
+
if (typeof value === "string") return value.trim().length === 0;
|
|
5302
|
+
return value === void 0 || value === null;
|
|
5299
5303
|
}
|
|
5300
|
-
function
|
|
5301
|
-
|
|
5302
|
-
|
|
5303
|
-
if (
|
|
5304
|
-
|
|
5305
|
-
return
|
|
5304
|
+
function parseStrokeStyle(dashArray) {
|
|
5305
|
+
if (typeof dashArray !== "string" || !dashArray.trim()) return;
|
|
5306
|
+
const normalized = dashArray.replaceAll(",", " ").replace(/\s+/g, " ").trim();
|
|
5307
|
+
if (normalized === "1 2") return "dotted";
|
|
5308
|
+
if (normalized === "4 2" || normalized === "4 4" || normalized === "8 4") return "dashed";
|
|
5309
|
+
return "solid";
|
|
5306
5310
|
}
|
|
5307
|
-
function
|
|
5308
|
-
|
|
5309
|
-
const
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
|
|
5314
|
-
|
|
5315
|
-
|
|
5316
|
-
|
|
5317
|
-
|
|
5318
|
-
|
|
5319
|
-
kind: "note",
|
|
5320
|
-
nodeId: node.id,
|
|
5321
|
-
text: nodeLabel(node),
|
|
5322
|
-
placement: (_note$placement = note.placement) !== null && _note$placement !== void 0 ? _note$placement : "over",
|
|
5323
|
-
participantNodeIds: noteParticipantNodeIds(note, participants, node)
|
|
5324
|
-
},
|
|
5325
|
-
y: node.position.y
|
|
5326
|
-
});
|
|
5327
|
-
continue;
|
|
5328
|
-
}
|
|
5329
|
-
const link = links.get(node.id);
|
|
5330
|
-
if (!(link === null || link === void 0 ? void 0 : link.from) || !link.to) continue;
|
|
5331
|
-
const edgeFrom = edges.find((edge) => edge.target === node.id && edge.source === link.from);
|
|
5332
|
-
const edgeTo = edges.find((edge) => edge.source === node.id && edge.target === link.to);
|
|
5333
|
-
const sequenceNumber = (_node$data9 = node.data) === null || _node$data9 === void 0 ? void 0 : _node$data9.sequenceNumber;
|
|
5334
|
-
items.push({
|
|
5335
|
-
item: _objectSpread2({
|
|
5336
|
-
kind: "message",
|
|
5337
|
-
nodeId: node.id,
|
|
5338
|
-
fromNodeId: link.from,
|
|
5339
|
-
toNodeId: link.to,
|
|
5340
|
-
label: nodeLabel(node),
|
|
5341
|
-
token: arrowTokenOf(edgeFrom, edgeTo),
|
|
5342
|
-
centralSource: (edgeFrom === null || edgeFrom === void 0 || (_edgeFrom$data4 = edgeFrom.data) === null || _edgeFrom$data4 === void 0 ? void 0 : _edgeFrom$data4.centralSource) === true,
|
|
5343
|
-
centralTarget: (edgeTo === null || edgeTo === void 0 || (_edgeTo$data3 = edgeTo.data) === null || _edgeTo$data3 === void 0 ? void 0 : _edgeTo$data3.centralTarget) === true
|
|
5344
|
-
}, typeof sequenceNumber === "number" ? { sequenceNumber } : {}),
|
|
5345
|
-
y: node.position.y
|
|
5346
|
-
});
|
|
5347
|
-
}
|
|
5348
|
-
return items.sort((a, b) => a.y - b.y).map((entry) => entry.item);
|
|
5311
|
+
function normalizeMarker(marker) {
|
|
5312
|
+
if (typeof marker === "string") return { type: marker };
|
|
5313
|
+
const markerRecord = toRecord(marker);
|
|
5314
|
+
if (!markerRecord) return;
|
|
5315
|
+
const type = pickString(markerRecord.type);
|
|
5316
|
+
if (!type) return;
|
|
5317
|
+
const color = pickString(markerRecord.color);
|
|
5318
|
+
if (color) return {
|
|
5319
|
+
type,
|
|
5320
|
+
color
|
|
5321
|
+
};
|
|
5322
|
+
return { type };
|
|
5349
5323
|
}
|
|
5350
|
-
function
|
|
5351
|
-
|
|
5352
|
-
for (const node of nodes) {
|
|
5353
|
-
var _node$data10, _block$type, _block$label, _block$depth, _block$sections;
|
|
5354
|
-
const block = (_node$data10 = node.data) === null || _node$data10 === void 0 ? void 0 : _node$data10.sequenceBlock;
|
|
5355
|
-
if (!block) continue;
|
|
5356
|
-
if (typeof block.startRow !== "number") continue;
|
|
5357
|
-
if (typeof block.endRow !== "number") continue;
|
|
5358
|
-
blocks.push(_objectSpread2(_objectSpread2({
|
|
5359
|
-
type: (_block$type = block.type) !== null && _block$type !== void 0 ? _block$type : "rect",
|
|
5360
|
-
label: (_block$label = block.label) !== null && _block$label !== void 0 ? _block$label : ""
|
|
5361
|
-
}, block.color ? { color: block.color } : {}), {}, {
|
|
5362
|
-
depth: (_block$depth = block.depth) !== null && _block$depth !== void 0 ? _block$depth : 0,
|
|
5363
|
-
startRow: block.startRow,
|
|
5364
|
-
endRow: block.endRow,
|
|
5365
|
-
sections: ((_block$sections = block.sections) !== null && _block$sections !== void 0 ? _block$sections : []).filter((section) => typeof section.startRow === "number" && typeof section.endRow === "number").map((section) => {
|
|
5366
|
-
var _section$label;
|
|
5367
|
-
return {
|
|
5368
|
-
label: (_section$label = section.label) !== null && _section$label !== void 0 ? _section$label : "",
|
|
5369
|
-
startRow: section.startRow,
|
|
5370
|
-
endRow: section.endRow
|
|
5371
|
-
};
|
|
5372
|
-
})
|
|
5373
|
-
}));
|
|
5374
|
-
}
|
|
5375
|
-
return blocks;
|
|
5324
|
+
function escapeMermaidText(value) {
|
|
5325
|
+
return value.replaceAll("\"", "\\\"");
|
|
5376
5326
|
}
|
|
5377
|
-
function
|
|
5378
|
-
|
|
5379
|
-
|
|
5380
|
-
|
|
5381
|
-
const box = (_node$data11 = node.data) === null || _node$data11 === void 0 ? void 0 : _node$data11.sequenceBox;
|
|
5382
|
-
if (!box) continue;
|
|
5383
|
-
const byImportedId = (Array.isArray(box.participants) ? box.participants.filter((value) => typeof value === "string") : []).map((id) => participants.find((participant) => participant.nodeId === `participant-${id}`)).filter((participant) => Boolean(participant));
|
|
5384
|
-
const left = node.position.x;
|
|
5385
|
-
const right = node.position.x + (Number(node.width) || 0);
|
|
5386
|
-
const contained = byImportedId.length > 0 ? byImportedId : participants.filter((participant) => participant.x >= left && participant.x <= right);
|
|
5387
|
-
if (contained.length === 0) continue;
|
|
5388
|
-
const backgroundColor = (_node$data12 = node.data) === null || _node$data12 === void 0 ? void 0 : _node$data12.backgroundColor;
|
|
5389
|
-
boxes.push(_objectSpread2(_objectSpread2({ label: (_box$label = box.label) !== null && _box$label !== void 0 ? _box$label : "" }, typeof backgroundColor === "string" ? { color: backgroundColor } : {}), {}, { participantNodeIds: contained.map((participant) => participant.nodeId) }));
|
|
5390
|
-
}
|
|
5391
|
-
return boxes;
|
|
5327
|
+
function canInlineMermaidLabel(value) {
|
|
5328
|
+
if (value.length > INLINE_MERMAID_LABEL_MAX_LENGTH) return false;
|
|
5329
|
+
if (value.includes("\n") || value.includes("\r")) return false;
|
|
5330
|
+
return true;
|
|
5392
5331
|
}
|
|
5393
|
-
function
|
|
5394
|
-
|
|
5395
|
-
const alias = participant.mermaidId === participant.name ? "" : ` as ${encodeLabel(participant.name)}`;
|
|
5396
|
-
return `${keyword} ${participant.mermaidId}${stereotype}${alias}`;
|
|
5332
|
+
function normalizeDetailedMermaidLabel(value) {
|
|
5333
|
+
return value.split(/\r?\n/).map((line) => line.replace(/\s+/g, " ").trim()).filter((line) => line.length > 0).join("\n");
|
|
5397
5334
|
}
|
|
5398
|
-
function
|
|
5399
|
-
|
|
5400
|
-
|
|
5401
|
-
|
|
5402
|
-
|
|
5403
|
-
const
|
|
5404
|
-
const
|
|
5405
|
-
const
|
|
5406
|
-
|
|
5407
|
-
|
|
5408
|
-
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
|
|
5412
|
-
|
|
5413
|
-
|
|
5414
|
-
|
|
5415
|
-
|
|
5416
|
-
|
|
5417
|
-
|
|
5418
|
-
const
|
|
5419
|
-
if (
|
|
5335
|
+
function toComponentFields(value) {
|
|
5336
|
+
if (!Array.isArray(value)) return [];
|
|
5337
|
+
return value.map((field) => toRecord(field)).filter((field) => field !== void 0);
|
|
5338
|
+
}
|
|
5339
|
+
function buildContextEdges(edges, nodeIdMap) {
|
|
5340
|
+
const contextEdges = {};
|
|
5341
|
+
const ordinals = /* @__PURE__ */ new Map();
|
|
5342
|
+
for (const edge of edges) {
|
|
5343
|
+
var _ordinals$get, _toRecord, _toRecord2;
|
|
5344
|
+
const source = nodeIdMap.get(edge.source);
|
|
5345
|
+
const target = nodeIdMap.get(edge.target);
|
|
5346
|
+
if (!source || !target) continue;
|
|
5347
|
+
const pair = `${source}-${target}`;
|
|
5348
|
+
const ordinal = (_ordinals$get = ordinals.get(pair)) !== null && _ordinals$get !== void 0 ? _ordinals$get : 0;
|
|
5349
|
+
ordinals.set(pair, ordinal + 1);
|
|
5350
|
+
const edgeContext = {};
|
|
5351
|
+
const edgeType = pickString(edge.type);
|
|
5352
|
+
if (edgeType) edgeContext.type = edgeType;
|
|
5353
|
+
const sourceHandle = pickString(edge.sourceHandle);
|
|
5354
|
+
if (sourceHandle) edgeContext.sourceHandle = sourceHandle;
|
|
5355
|
+
const targetHandle = pickString(edge.targetHandle);
|
|
5356
|
+
if (targetHandle) edgeContext.targetHandle = targetHandle;
|
|
5357
|
+
const edgeLabel = pickString(edge.label);
|
|
5358
|
+
if (edgeLabel) edgeContext.label = edgeLabel;
|
|
5359
|
+
const edgeStyleRecord = (_toRecord = toRecord(edge.style)) !== null && _toRecord !== void 0 ? _toRecord : {};
|
|
5360
|
+
const edgeStyle = {};
|
|
5361
|
+
const stroke = pickString(edgeStyleRecord.stroke);
|
|
5362
|
+
if (stroke) edgeStyle.stroke = stroke;
|
|
5363
|
+
if (typeof edgeStyleRecord.strokeWidth === "number") edgeStyle.strokeWidth = edgeStyleRecord.strokeWidth;
|
|
5364
|
+
const strokeStyle = parseStrokeStyle(edgeStyleRecord.strokeDasharray);
|
|
5365
|
+
if (strokeStyle) edgeStyle.strokeStyle = strokeStyle;
|
|
5366
|
+
if (typeof edge.animated === "boolean") edgeStyle.borderAnimationEnabled = edge.animated;
|
|
5367
|
+
if (Object.keys(edgeStyle).length > 0) edgeContext.style = edgeStyle;
|
|
5368
|
+
const markerStart = normalizeMarker(edge.markerStart);
|
|
5369
|
+
if (markerStart) edgeContext.markerStart = markerStart;
|
|
5370
|
+
const markerEnd = normalizeMarker(edge.markerEnd);
|
|
5371
|
+
if (markerEnd) edgeContext.markerEnd = markerEnd;
|
|
5372
|
+
const edgeData$1 = (_toRecord2 = toRecord(edge.data)) !== null && _toRecord2 !== void 0 ? _toRecord2 : {};
|
|
5373
|
+
if (Object.keys(edgeData$1).length > 0) edgeContext.___internal = edgeData$1;
|
|
5374
|
+
if (Object.keys(edgeContext).length > 0) if (ordinal === 0) contextEdges[pair] = edgeContext;
|
|
5375
|
+
else contextEdges[`${pair}#${ordinal}`] = edgeContext;
|
|
5420
5376
|
}
|
|
5421
|
-
|
|
5422
|
-
|
|
5423
|
-
|
|
5424
|
-
|
|
5425
|
-
|
|
5426
|
-
|
|
5427
|
-
|
|
5428
|
-
|
|
5377
|
+
return contextEdges;
|
|
5378
|
+
}
|
|
5379
|
+
function buildContextGroups(groupNodes, nodeIdMap) {
|
|
5380
|
+
const contextGroups = {};
|
|
5381
|
+
for (const groupNode of groupNodes) {
|
|
5382
|
+
var _toRecord;
|
|
5383
|
+
const groupData = (_toRecord = toRecord(groupNode.data)) !== null && _toRecord !== void 0 ? _toRecord : {};
|
|
5384
|
+
const childNodes = Array.isArray(groupData.childNodes) ? groupData.childNodes.map((childId) => typeof childId === "string" ? nodeIdMap.get(childId) : void 0).filter((childId) => childId !== void 0) : [];
|
|
5385
|
+
const name = getFieldString(Array.isArray(groupData.componentFields) ? groupData.componentFields.map((field) => toRecord(field)).filter((field) => field !== void 0) : [], "Name");
|
|
5386
|
+
if (!name && childNodes.length === 0) continue;
|
|
5387
|
+
contextGroups[groupNode.id] = {
|
|
5388
|
+
name: name !== null && name !== void 0 ? name : void 0,
|
|
5389
|
+
nodes: childNodes
|
|
5390
|
+
};
|
|
5429
5391
|
}
|
|
5430
|
-
|
|
5431
|
-
|
|
5432
|
-
|
|
5433
|
-
|
|
5434
|
-
|
|
5435
|
-
|
|
5392
|
+
return contextGroups;
|
|
5393
|
+
}
|
|
5394
|
+
function buildContextNodes(graphNodes, nodeIdMap) {
|
|
5395
|
+
const contextNodes = {};
|
|
5396
|
+
for (const node of graphNodes) {
|
|
5397
|
+
var _toRecord, _toRecord2, _pickString, _pickString2;
|
|
5398
|
+
const mappedNodeId = nodeIdMap.get(node.id);
|
|
5399
|
+
if (!mappedNodeId) continue;
|
|
5400
|
+
const nodeData$1 = (_toRecord = toRecord(node.data)) !== null && _toRecord !== void 0 ? _toRecord : {};
|
|
5401
|
+
const nodeStyle = (_toRecord2 = toRecord(node.style)) !== null && _toRecord2 !== void 0 ? _toRecord2 : {};
|
|
5402
|
+
const componentFields = Array.isArray(nodeData$1.componentFields) ? nodeData$1.componentFields.map((field) => toRecord(field)).filter((field) => field !== void 0) : [];
|
|
5403
|
+
const nodeContext = {};
|
|
5404
|
+
const nodeType = pickString(node.type);
|
|
5405
|
+
if (nodeType) nodeContext.type = nodeType;
|
|
5406
|
+
const nameField = getFieldByLabel(componentFields, "Name");
|
|
5407
|
+
const nameRawValue = nameField ? getFieldValue(nameField.data) : void 0;
|
|
5408
|
+
const name = pickString(nameRawValue);
|
|
5409
|
+
if (name) nodeContext.name = name;
|
|
5410
|
+
const textField = nodeType === "text" ? getFieldByLabel(componentFields, "Text") : void 0;
|
|
5411
|
+
const textRawValue = textField ? getFieldValue(textField.data) : void 0;
|
|
5412
|
+
const textValue = pickString(textRawValue);
|
|
5413
|
+
if (nodeType === "text") {
|
|
5414
|
+
if (textValue) nodeContext.value = textValue;
|
|
5436
5415
|
}
|
|
5437
|
-
|
|
5438
|
-
|
|
5439
|
-
|
|
5416
|
+
const codeField = nodeType === "code" ? getFieldByLabel(componentFields, "Code") : void 0;
|
|
5417
|
+
const codeRawValue = codeField ? getFieldValue(codeField.data) : void 0;
|
|
5418
|
+
const codeValue = pickString(codeRawValue);
|
|
5419
|
+
if (nodeType === "code") {
|
|
5420
|
+
if (codeValue) nodeContext.value = codeValue;
|
|
5440
5421
|
}
|
|
5441
|
-
const
|
|
5442
|
-
|
|
5443
|
-
|
|
5444
|
-
|
|
5445
|
-
|
|
5446
|
-
|
|
5447
|
-
const
|
|
5448
|
-
|
|
5449
|
-
|
|
5450
|
-
|
|
5451
|
-
|
|
5452
|
-
|
|
5453
|
-
|
|
5454
|
-
|
|
5455
|
-
|
|
5456
|
-
const
|
|
5457
|
-
|
|
5458
|
-
|
|
5459
|
-
|
|
5460
|
-
|
|
5461
|
-
|
|
5422
|
+
const src = pickString(nodeData$1.src);
|
|
5423
|
+
if (src) nodeContext.src = src;
|
|
5424
|
+
const animatedIcon = pickString(nodeData$1.animatedIcon);
|
|
5425
|
+
if (animatedIcon) nodeContext.animatedIcon = animatedIcon;
|
|
5426
|
+
const cloud = pickString(nodeData$1.cloud);
|
|
5427
|
+
if (cloud) nodeContext.cloud = cloud;
|
|
5428
|
+
const service = pickString(nodeData$1.service);
|
|
5429
|
+
if (service) nodeContext.service = service;
|
|
5430
|
+
const componentId = pickString(nodeData$1.componentId);
|
|
5431
|
+
if (componentId) nodeContext.componentId = componentId;
|
|
5432
|
+
const shape = pickString(nodeData$1.shape);
|
|
5433
|
+
if (shape && CONTEXT_SHAPES.has(shape)) nodeContext.shape = shape;
|
|
5434
|
+
const style = {};
|
|
5435
|
+
const width = typeof node.width === "number" ? node.width : typeof nodeStyle.width === "number" ? nodeStyle.width : void 0;
|
|
5436
|
+
if (typeof width === "number") style.width = width;
|
|
5437
|
+
const height = typeof node.height === "number" ? node.height : typeof nodeStyle.height === "number" ? nodeStyle.height : void 0;
|
|
5438
|
+
if (typeof height === "number") style.height = height;
|
|
5439
|
+
const fill = (_pickString = pickString(nodeData$1.fill)) !== null && _pickString !== void 0 ? _pickString : pickString(nodeStyle.fill);
|
|
5440
|
+
if (fill) style.fill = fill;
|
|
5441
|
+
const stroke = (_pickString2 = pickString(nodeData$1.stroke)) !== null && _pickString2 !== void 0 ? _pickString2 : pickString(nodeStyle.stroke);
|
|
5442
|
+
if (stroke) style.stroke = stroke;
|
|
5443
|
+
const strokeWidth = typeof nodeData$1.strokeWidth === "number" ? nodeData$1.strokeWidth : typeof nodeStyle.strokeWidth === "number" ? nodeStyle.strokeWidth : void 0;
|
|
5444
|
+
if (typeof strokeWidth === "number") style.strokeWidth = strokeWidth;
|
|
5445
|
+
const borderRadius = typeof nodeData$1.borderRadius === "number" ? nodeData$1.borderRadius : typeof nodeStyle.borderRadius === "number" ? nodeStyle.borderRadius : void 0;
|
|
5446
|
+
if (typeof borderRadius === "number") style.borderRadius = borderRadius;
|
|
5447
|
+
const strokeStyleFromData = pickString(nodeData$1.strokeStyle);
|
|
5448
|
+
if (strokeStyleFromData === "solid" || strokeStyleFromData === "dashed" || strokeStyleFromData === "dotted") style.strokeStyle = strokeStyleFromData;
|
|
5449
|
+
else {
|
|
5450
|
+
const strokeStyleFromDash = parseStrokeStyle(nodeStyle.strokeDasharray);
|
|
5451
|
+
if (strokeStyleFromDash) style.strokeStyle = strokeStyleFromDash;
|
|
5462
5452
|
}
|
|
5463
|
-
|
|
5464
|
-
|
|
5465
|
-
|
|
5466
|
-
|
|
5453
|
+
const borderAnimationEnabled = typeof nodeData$1.borderAnimationEnabled === "boolean" ? nodeData$1.borderAnimationEnabled : nodeData$1.strokeAnimation === "dash" ? true : void 0;
|
|
5454
|
+
if (typeof borderAnimationEnabled === "boolean") style.borderAnimationEnabled = borderAnimationEnabled;
|
|
5455
|
+
if (Object.keys(style).length > 0) nodeContext.style = style;
|
|
5456
|
+
const tableColumns = Array.isArray(nodeData$1.columns) ? nodeData$1.columns.filter((value) => typeof value === "string") : void 0;
|
|
5457
|
+
const tableRows = Array.isArray(nodeData$1.rows) ? nodeData$1.rows.map((row) => Array.isArray(row) ? row.filter((value) => typeof value === "string") : void 0).filter((row) => row !== void 0) : void 0;
|
|
5458
|
+
if (tableColumns || tableRows) nodeContext.table = {
|
|
5459
|
+
columns: tableColumns !== null && tableColumns !== void 0 ? tableColumns : [],
|
|
5460
|
+
rows: tableRows !== null && tableRows !== void 0 ? tableRows : []
|
|
5461
|
+
};
|
|
5462
|
+
const serviceTable = toRecord(nodeData$1.serviceTable);
|
|
5463
|
+
const serviceName = pickString(serviceTable === null || serviceTable === void 0 ? void 0 : serviceTable.serviceName);
|
|
5464
|
+
const databaseName = pickString(serviceTable === null || serviceTable === void 0 ? void 0 : serviceTable.databaseName);
|
|
5465
|
+
const tableName = pickString(serviceTable === null || serviceTable === void 0 ? void 0 : serviceTable.tableName);
|
|
5466
|
+
if (serviceName && databaseName && tableName) nodeContext.dbConfig = {
|
|
5467
|
+
serviceName,
|
|
5468
|
+
databaseName,
|
|
5469
|
+
tableName
|
|
5470
|
+
};
|
|
5471
|
+
const dynamicData = {};
|
|
5472
|
+
for (const field of componentFields) {
|
|
5473
|
+
const label$1 = pickString(field.label);
|
|
5474
|
+
const type = pickString(field.type);
|
|
5475
|
+
if (!label$1 || !type || !isComponentInputType(type)) continue;
|
|
5476
|
+
const componentType = type;
|
|
5477
|
+
const normalizedLabel = label$1.toLowerCase();
|
|
5478
|
+
if (normalizedLabel === "name") continue;
|
|
5479
|
+
if (nodeType === "text" && normalizedLabel === "text") continue;
|
|
5480
|
+
if (nodeType === "code" && normalizedLabel === "code") continue;
|
|
5481
|
+
const options = Array.isArray(field.options) ? field.options.filter((option) => typeof option === "string") : void 0;
|
|
5482
|
+
dynamicData[label$1] = {
|
|
5483
|
+
type: componentType,
|
|
5484
|
+
value: getFieldValue(field.data),
|
|
5485
|
+
options: options && options.length > 0 ? options : void 0
|
|
5486
|
+
};
|
|
5467
5487
|
}
|
|
5468
|
-
|
|
5469
|
-
|
|
5470
|
-
|
|
5471
|
-
|
|
5472
|
-
|
|
5473
|
-
|
|
5474
|
-
|
|
5475
|
-
|
|
5476
|
-
|
|
5477
|
-
lines.push(`${indent()}destroy ${participant.mermaidId}`);
|
|
5488
|
+
if (nameField && !name && isEmptyFieldValue(nameRawValue)) {
|
|
5489
|
+
const nameType = pickString(nameField.type);
|
|
5490
|
+
if (nameType && isComponentInputType(nameType)) {
|
|
5491
|
+
const nameOptions = Array.isArray(nameField.options) ? nameField.options.filter((option) => typeof option === "string") : void 0;
|
|
5492
|
+
dynamicData.Name = {
|
|
5493
|
+
type: nameType,
|
|
5494
|
+
value: "",
|
|
5495
|
+
options: nameOptions && nameOptions.length > 0 ? nameOptions : void 0
|
|
5496
|
+
};
|
|
5478
5497
|
}
|
|
5479
|
-
|
|
5480
|
-
|
|
5481
|
-
|
|
5498
|
+
}
|
|
5499
|
+
if (textField && !textValue && isEmptyFieldValue(textRawValue)) {
|
|
5500
|
+
const textType = pickString(textField.type);
|
|
5501
|
+
if (textType && isComponentInputType(textType)) {
|
|
5502
|
+
const textOptions = Array.isArray(textField.options) ? textField.options.filter((option) => typeof option === "string") : void 0;
|
|
5503
|
+
dynamicData.Text = {
|
|
5504
|
+
type: textType,
|
|
5505
|
+
value: "",
|
|
5506
|
+
options: textOptions && textOptions.length > 0 ? textOptions : void 0
|
|
5507
|
+
};
|
|
5482
5508
|
}
|
|
5483
|
-
if (item.kind === "message") {
|
|
5484
|
-
const from = participantByNodeId.get(item.fromNodeId);
|
|
5485
|
-
const to = participantByNodeId.get(item.toNodeId);
|
|
5486
|
-
if (from && to) {
|
|
5487
|
-
const source = item.centralSource ? `${from.mermaidId}()` : from.mermaidId;
|
|
5488
|
-
const target = item.centralTarget ? `()${to.mermaidId}` : to.mermaidId;
|
|
5489
|
-
lines.push(`${indent()}${source}${item.token}${target}: ${encodeLabel(item.label)}`);
|
|
5490
|
-
}
|
|
5491
|
-
}
|
|
5492
|
-
if (item.kind === "note") {
|
|
5493
|
-
const names = item.participantNodeIds.map((nodeId) => {
|
|
5494
|
-
var _participantByNodeId$;
|
|
5495
|
-
return (_participantByNodeId$ = participantByNodeId.get(nodeId)) === null || _participantByNodeId$ === void 0 ? void 0 : _participantByNodeId$.mermaidId;
|
|
5496
|
-
}).filter((id) => id !== void 0);
|
|
5497
|
-
if (names.length > 0) lines.push(`${indent()}Note ${item.placement} ${names.join(",")}: ${encodeLabel(item.text)}`);
|
|
5498
|
-
}
|
|
5499
|
-
}
|
|
5500
|
-
const rowEnd = item ? lastRowByItemId.get(item.nodeId) : currentRow;
|
|
5501
|
-
for (const participant of participants) for (const activation of participant.activations) {
|
|
5502
|
-
if (activation.endRow !== rowEnd) continue;
|
|
5503
|
-
lines.push(`${indent()}deactivate ${participant.mermaidId}`);
|
|
5504
5509
|
}
|
|
5505
|
-
|
|
5506
|
-
|
|
5507
|
-
|
|
5510
|
+
if (codeField && !codeValue && isEmptyFieldValue(codeRawValue)) {
|
|
5511
|
+
const codeType = pickString(codeField.type);
|
|
5512
|
+
if (codeType && isComponentInputType(codeType)) {
|
|
5513
|
+
const codeOptions = Array.isArray(codeField.options) ? codeField.options.filter((option) => typeof option === "string") : void 0;
|
|
5514
|
+
dynamicData.Code = {
|
|
5515
|
+
type: codeType,
|
|
5516
|
+
value: "",
|
|
5517
|
+
options: codeOptions && codeOptions.length > 0 ? codeOptions : void 0
|
|
5518
|
+
};
|
|
5519
|
+
}
|
|
5508
5520
|
}
|
|
5521
|
+
if (Object.keys(dynamicData).length > 0) nodeContext.data = dynamicData;
|
|
5522
|
+
const position = pickPosition(node.position);
|
|
5523
|
+
if (position) nodeContext.___position = position;
|
|
5524
|
+
const internalData = Object.entries(nodeData$1).reduce((acc, [key, value]) => {
|
|
5525
|
+
if (KNOWN_NODE_DATA_KEYS.has(key)) return acc;
|
|
5526
|
+
acc[key] = value;
|
|
5527
|
+
return acc;
|
|
5528
|
+
}, {});
|
|
5529
|
+
if (nodeType === "builder" && Array.isArray(nodeData$1.componentFields)) internalData.componentFields = nodeData$1.componentFields;
|
|
5530
|
+
const iconSrc = pickString(nodeData$1.iconSrc);
|
|
5531
|
+
if (iconSrc) internalData.iconSrc = iconSrc;
|
|
5532
|
+
const label = pickString(nodeData$1.label);
|
|
5533
|
+
if (label) internalData.label = label;
|
|
5534
|
+
const internalCloud = pickString(nodeData$1.cloud);
|
|
5535
|
+
if (internalCloud) internalData.cloud = internalCloud;
|
|
5536
|
+
if (Object.keys(internalData).length > 0) nodeContext.___internal = internalData;
|
|
5537
|
+
if (Object.keys(nodeContext).length > 0) contextNodes[mappedNodeId] = nodeContext;
|
|
5509
5538
|
}
|
|
5510
|
-
|
|
5511
|
-
|
|
5512
|
-
|
|
5539
|
+
return contextNodes;
|
|
5540
|
+
}
|
|
5541
|
+
function buildValidatedContext(graphNodes, edges, groupNodes, nodeIdMap) {
|
|
5542
|
+
const contextNodes = buildContextNodes(graphNodes, nodeIdMap);
|
|
5543
|
+
const contextEdges = buildContextEdges(edges, nodeIdMap);
|
|
5544
|
+
const contextGroups = buildContextGroups(groupNodes, nodeIdMap);
|
|
5545
|
+
const context = {};
|
|
5546
|
+
if (Object.keys(contextNodes).length > 0) context.nodes = contextNodes;
|
|
5547
|
+
if (Object.keys(contextEdges).length > 0) context.edges = contextEdges;
|
|
5548
|
+
if (Object.keys(contextGroups).length > 0) context.groups = contextGroups;
|
|
5549
|
+
return require_headless.contextSchema.parse(context);
|
|
5550
|
+
}
|
|
5551
|
+
function nodeData(node) {
|
|
5552
|
+
var _node$data;
|
|
5553
|
+
return (_node$data = node.data) !== null && _node$data !== void 0 ? _node$data : {};
|
|
5554
|
+
}
|
|
5555
|
+
function edgeData(edge) {
|
|
5556
|
+
var _edge$data;
|
|
5557
|
+
return (_edge$data = edge.data) !== null && _edge$data !== void 0 ? _edge$data : {};
|
|
5558
|
+
}
|
|
5559
|
+
function isC4ReactFlowDiagram(nodes) {
|
|
5560
|
+
return nodes.some((node) => node.type === "c4" || node.type === "c4Boundary");
|
|
5561
|
+
}
|
|
5562
|
+
function isC4Element(node) {
|
|
5563
|
+
if (node.type !== "c4" && node.type !== "subDiagram") return false;
|
|
5564
|
+
const kind = nodeData(node).c4Kind;
|
|
5565
|
+
return kind === "person" || kind === "system" || kind === "container" || kind === "component";
|
|
5566
|
+
}
|
|
5567
|
+
function isC4Boundary(node) {
|
|
5568
|
+
return node.type === "c4Boundary";
|
|
5569
|
+
}
|
|
5570
|
+
function quoteC4Value(value) {
|
|
5571
|
+
return `"${value.replace(/"/g, "\\\"").replace(/\r\n?/g, "\n").replace(/\n/g, "<br/>").trim()}"`;
|
|
5572
|
+
}
|
|
5573
|
+
function nodeName(node) {
|
|
5574
|
+
var _node$data2;
|
|
5575
|
+
const fields = (_node$data2 = node.data) === null || _node$data2 === void 0 ? void 0 : _node$data2.componentFields;
|
|
5576
|
+
if (Array.isArray(fields)) {
|
|
5577
|
+
var _field$data;
|
|
5578
|
+
const field = fields.find((candidate) => (candidate === null || candidate === void 0 ? void 0 : candidate.componentFieldId) === "name");
|
|
5579
|
+
const value = field === null || field === void 0 || (_field$data = field.data) === null || _field$data === void 0 || (_field$data = _field$data[0]) === null || _field$data === void 0 ? void 0 : _field$data.value;
|
|
5580
|
+
if (typeof value === "string" && value.trim()) return value;
|
|
5581
|
+
}
|
|
5582
|
+
const diagramName = nodeData(node).diagramName;
|
|
5583
|
+
if (typeof diagramName === "string" && diagramName) return diagramName;
|
|
5584
|
+
return node.id;
|
|
5585
|
+
}
|
|
5586
|
+
function c4ElementKeyword(kind, shape, isExternal) {
|
|
5587
|
+
let keyword;
|
|
5588
|
+
if (kind === "person") keyword = "Person";
|
|
5589
|
+
else if (kind === "system") keyword = "System";
|
|
5590
|
+
else if (kind === "container") keyword = "Container";
|
|
5591
|
+
else if (kind === "component") keyword = "Component";
|
|
5592
|
+
else throw new Error(`Unsupported C4 element kind: ${String(kind)}`);
|
|
5593
|
+
if (shape === "db") keyword += "Db";
|
|
5594
|
+
if (shape === "queue") keyword += "Queue";
|
|
5595
|
+
if (isExternal) keyword += "_Ext";
|
|
5596
|
+
return keyword;
|
|
5597
|
+
}
|
|
5598
|
+
function c4BoundaryKeyword(kind, nodeType) {
|
|
5599
|
+
if (kind === "enterprise") return "Enterprise_Boundary";
|
|
5600
|
+
if (kind === "system") return "System_Boundary";
|
|
5601
|
+
if (kind === "container") return "Container_Boundary";
|
|
5602
|
+
if (kind === "node") {
|
|
5603
|
+
if (nodeType === "nodeL") return "Node_L";
|
|
5604
|
+
if (nodeType === "nodeR") return "Node_R";
|
|
5605
|
+
return "Deployment_Node";
|
|
5606
|
+
}
|
|
5607
|
+
return "Boundary";
|
|
5608
|
+
}
|
|
5609
|
+
function c4RelationshipKeyword(direction) {
|
|
5610
|
+
if (direction === "default") return "Rel";
|
|
5611
|
+
if (direction === "bi") return "BiRel";
|
|
5612
|
+
if (direction === "back") return "Rel_Back";
|
|
5613
|
+
if (direction === "up") return "Rel_U";
|
|
5614
|
+
if (direction === "down") return "Rel_D";
|
|
5615
|
+
if (direction === "left") return "Rel_L";
|
|
5616
|
+
if (direction === "right") return "Rel_R";
|
|
5617
|
+
throw new Error(`Unsupported C4 relationship direction: ${String(direction)}`);
|
|
5618
|
+
}
|
|
5619
|
+
function resolveRelDirection(edge) {
|
|
5620
|
+
const stored = edgeData(edge).c4RelDirection;
|
|
5621
|
+
if (stored) return stored;
|
|
5622
|
+
if (edge.markerStart) return "bi";
|
|
5623
|
+
if (edge.sourceHandle === "source-top") return "up";
|
|
5624
|
+
if (edge.sourceHandle === "source-bottom") return "down";
|
|
5625
|
+
if (edge.sourceHandle === "source-left") return "left";
|
|
5626
|
+
if (edge.sourceHandle === "source-right") return "right";
|
|
5627
|
+
return "default";
|
|
5628
|
+
}
|
|
5629
|
+
function relationshipLabel(edge, technology) {
|
|
5630
|
+
const label = typeof edge.label === "string" ? edge.label : "";
|
|
5631
|
+
if (!technology) return label;
|
|
5632
|
+
const suffix = ` [${technology}]`;
|
|
5633
|
+
if (label.endsWith(suffix)) return label.slice(0, -suffix.length);
|
|
5634
|
+
return label;
|
|
5635
|
+
}
|
|
5636
|
+
function resolveDiagramType(c4Nodes) {
|
|
5637
|
+
for (const node of c4Nodes) {
|
|
5638
|
+
const stored = nodeData(node).c4DiagramType;
|
|
5639
|
+
if (stored) return stored;
|
|
5640
|
+
}
|
|
5641
|
+
if (c4Nodes.some((node) => nodeData(node).c4Kind === "component")) return "C4Component";
|
|
5642
|
+
if (c4Nodes.some((node) => nodeData(node).c4Kind === "container")) return "C4Container";
|
|
5643
|
+
return "C4Context";
|
|
5644
|
+
}
|
|
5645
|
+
function trimTrailingSlots(values, keep) {
|
|
5646
|
+
const trimmed = [...values];
|
|
5647
|
+
while (trimmed.length > keep && trimmed[trimmed.length - 1] === "") trimmed.pop();
|
|
5648
|
+
return trimmed;
|
|
5649
|
+
}
|
|
5650
|
+
function emitC4Mermaid(nodes, edges) {
|
|
5651
|
+
const c4Nodes = nodes.filter((node) => isC4Element(node) || isC4Boundary(node));
|
|
5652
|
+
const c4NodeIds = new Set(c4Nodes.map((node) => node.id));
|
|
5653
|
+
const boundaryIds = new Set(c4Nodes.filter((node) => isC4Boundary(node)).map((node) => node.id));
|
|
5654
|
+
function parentOf(node) {
|
|
5655
|
+
if (node.parentId && boundaryIds.has(node.parentId)) return node.parentId;
|
|
5656
|
+
}
|
|
5657
|
+
function renderNode(node, indentation) {
|
|
5658
|
+
const data = nodeData(node);
|
|
5659
|
+
const name = quoteC4Value(nodeName(node));
|
|
5660
|
+
if (isC4Element(node)) {
|
|
5661
|
+
const values$1 = [node.id, name];
|
|
5662
|
+
if (data.c4Kind === "container" || data.c4Kind === "component") values$1.push(data.technology ? quoteC4Value(data.technology) : "");
|
|
5663
|
+
values$1.push(data.description ? quoteC4Value(data.description) : "");
|
|
5664
|
+
const trimmed$1 = trimTrailingSlots(values$1, 2);
|
|
5665
|
+
const link = data.diagramId ? `uig:${data.diagramId}` : data.link;
|
|
5666
|
+
if (link) trimmed$1.push(`$link=${quoteC4Value(link)}`);
|
|
5667
|
+
return `${indentation}${c4ElementKeyword(data.c4Kind, data.c4Shape, data.isExternal === true)}(${trimmed$1.join(", ")})`;
|
|
5668
|
+
}
|
|
5669
|
+
const keyword = c4BoundaryKeyword(data.c4BoundaryKind, data.c4NodeType);
|
|
5670
|
+
const values = [node.id, name];
|
|
5671
|
+
if (keyword === "Boundary" && data.boundaryType) values.push(quoteC4Value(data.boundaryType));
|
|
5672
|
+
if (data.c4BoundaryKind === "node") {
|
|
5673
|
+
values.push(data.boundaryType ? quoteC4Value(data.boundaryType) : "\"node\"");
|
|
5674
|
+
values.push(data.description ? quoteC4Value(data.description) : "");
|
|
5675
|
+
}
|
|
5676
|
+
const trimmed = trimTrailingSlots(values, 2);
|
|
5677
|
+
if (data.link) trimmed.push(`$link=${quoteC4Value(data.link)}`);
|
|
5678
|
+
return `${indentation}${keyword}(${trimmed.join(", ")}) {`;
|
|
5679
|
+
}
|
|
5680
|
+
function renderChildren(parentId, indentation) {
|
|
5681
|
+
const lines = [];
|
|
5682
|
+
for (const node of c4Nodes) {
|
|
5683
|
+
if (parentOf(node) !== parentId) continue;
|
|
5684
|
+
lines.push(renderNode(node, indentation));
|
|
5685
|
+
if (isC4Boundary(node)) {
|
|
5686
|
+
lines.push(...renderChildren(node.id, `${indentation} `));
|
|
5687
|
+
lines.push(`${indentation}}`);
|
|
5688
|
+
}
|
|
5689
|
+
}
|
|
5690
|
+
return lines;
|
|
5513
5691
|
}
|
|
5514
|
-
|
|
5692
|
+
const relationships = edges.flatMap((edge) => {
|
|
5693
|
+
if (!c4NodeIds.has(edge.source) || !c4NodeIds.has(edge.target)) return [];
|
|
5694
|
+
const data = edgeData(edge);
|
|
5695
|
+
const direction = resolveRelDirection(edge);
|
|
5696
|
+
const isBack = direction === "back";
|
|
5697
|
+
const values = [
|
|
5698
|
+
isBack ? edge.target : edge.source,
|
|
5699
|
+
isBack ? edge.source : edge.target,
|
|
5700
|
+
quoteC4Value(relationshipLabel(edge, data.c4RelTechnology)),
|
|
5701
|
+
data.c4RelTechnology ? quoteC4Value(data.c4RelTechnology) : "",
|
|
5702
|
+
data.c4RelDescription ? quoteC4Value(data.c4RelDescription) : ""
|
|
5703
|
+
];
|
|
5704
|
+
return `${c4RelationshipKeyword(direction)}(${trimTrailingSlots(values, 3).join(", ")})`;
|
|
5705
|
+
});
|
|
5706
|
+
return {
|
|
5707
|
+
mermaid: [
|
|
5708
|
+
resolveDiagramType(c4Nodes),
|
|
5709
|
+
...renderChildren(void 0, ""),
|
|
5710
|
+
...relationships
|
|
5711
|
+
].join("\n"),
|
|
5712
|
+
nodeIdMap: new Map(c4Nodes.map((node) => [node.id, node.id]))
|
|
5713
|
+
};
|
|
5515
5714
|
}
|
|
5516
|
-
|
|
5517
|
-
|
|
5518
|
-
|
|
5715
|
+
function convertReactFlowToC4Mermaid(nodes, edges) {
|
|
5716
|
+
return emitC4Mermaid(nodes, edges).mermaid;
|
|
5717
|
+
}
|
|
5718
|
+
function convertReactFlowToC4UiGraph(nodes, edges) {
|
|
5719
|
+
const { mermaid: mermaid$2, nodeIdMap } = emitC4Mermaid(nodes, edges);
|
|
5519
5720
|
return {
|
|
5520
|
-
|
|
5521
|
-
|
|
5522
|
-
position: {
|
|
5523
|
-
x: options.bounds.x,
|
|
5524
|
-
y: options.bounds.y
|
|
5525
|
-
},
|
|
5526
|
-
data: {
|
|
5527
|
-
childNodes: options.nodes,
|
|
5528
|
-
autoLayout: true,
|
|
5529
|
-
componentFields: [generateComponentFieldNameInput((_options$name = options.name) !== null && _options$name !== void 0 ? _options$name : "Group")]
|
|
5530
|
-
},
|
|
5531
|
-
style: {
|
|
5532
|
-
width: options.bounds.width + 20,
|
|
5533
|
-
height: options.bounds.height + 50
|
|
5534
|
-
}
|
|
5721
|
+
mermaid: mermaid$2,
|
|
5722
|
+
context: buildValidatedContext(nodes, edges, [], nodeIdMap)
|
|
5535
5723
|
};
|
|
5536
5724
|
}
|
|
5537
|
-
function
|
|
5538
|
-
|
|
5539
|
-
|
|
5540
|
-
return
|
|
5541
|
-
|
|
5542
|
-
|
|
5543
|
-
|
|
5544
|
-
|
|
5545
|
-
|
|
5546
|
-
|
|
5547
|
-
|
|
5548
|
-
const minY = Math.min(...bounds.map((b) => b.top));
|
|
5549
|
-
const maxX = Math.max(...bounds.map((b) => b.right));
|
|
5550
|
-
const maxY = Math.max(...bounds.map((b) => b.bottom));
|
|
5551
|
-
return createGroupNode({
|
|
5552
|
-
id,
|
|
5553
|
-
name,
|
|
5554
|
-
nodes: nodes.map((node) => node.id),
|
|
5555
|
-
bounds: {
|
|
5556
|
-
x: minX - BOUND_PADDING,
|
|
5557
|
-
y: minY - BOUND_PADDING,
|
|
5558
|
-
width: maxX - minX + BOUND_PADDING * 2,
|
|
5559
|
-
height: maxY - minY + BOUND_PADDING * 2
|
|
5560
|
-
}
|
|
5725
|
+
function sanitizeMermaidLabels(src) {
|
|
5726
|
+
if (!src) return src;
|
|
5727
|
+
const subgraphFixed = src.replace(/([A-Za-z0-9_]+)\[((?:(?![\"']).)*?)\]/g, (m, id, label) => {
|
|
5728
|
+
if (/^[\"']/.test(label)) return m;
|
|
5729
|
+
if (/[()\"\[\],:;]/.test(label)) return `${id}[\"${String(label).replace(/\\/g, "\\\\").replace(/\"/g, "\\\"")}\"]`;
|
|
5730
|
+
return m;
|
|
5731
|
+
}).replace(/^([ \t]*subgraph\s+)([^\n\r]+)(\|[^\n\r]*)?$/gim, (m, pre, title, rest) => {
|
|
5732
|
+
const t = String(title).trim();
|
|
5733
|
+
if (/^[\"']/.test(t)) return m;
|
|
5734
|
+
if (/[()\"\[\],:;]/.test(t)) return `${pre}\"${t.replace(/\\/g, "\\\\").replace(/\"/g, "\\\"")}\"${rest || ""}`;
|
|
5735
|
+
return m;
|
|
5561
5736
|
});
|
|
5737
|
+
const diagRegex = /\b(graph|flowchart|sequenceDiagram|stateDiagram|classDiagram|gantt|journey|erDiagram|gitGraph|pie|timeline|infoDiagram)\b/i;
|
|
5738
|
+
const allStarts = [];
|
|
5739
|
+
let mm;
|
|
5740
|
+
const globalRegex = new RegExp(diagRegex.source, "gim");
|
|
5741
|
+
while ((mm = globalRegex.exec(subgraphFixed)) !== null) {
|
|
5742
|
+
allStarts.push(mm.index);
|
|
5743
|
+
if (globalRegex.lastIndex === mm.index) globalRegex.lastIndex++;
|
|
5744
|
+
}
|
|
5745
|
+
if (allStarts.length <= 1) return subgraphFixed;
|
|
5746
|
+
const first = allStarts[0];
|
|
5747
|
+
const second = allStarts[1];
|
|
5748
|
+
return subgraphFixed.slice(first, second).trim();
|
|
5562
5749
|
}
|
|
5563
|
-
function
|
|
5564
|
-
return
|
|
5750
|
+
function isSequenceDiagram(nodes) {
|
|
5751
|
+
return nodes.some((node) => node.type === "sequenceParticipant");
|
|
5565
5752
|
}
|
|
5566
|
-
function
|
|
5567
|
-
|
|
5568
|
-
|
|
5569
|
-
|
|
5570
|
-
|
|
5571
|
-
|
|
5572
|
-
|
|
5573
|
-
|
|
5753
|
+
function fieldValue(node, componentFieldId) {
|
|
5754
|
+
var _node$data, _field$data;
|
|
5755
|
+
const fields = (_node$data = node.data) === null || _node$data === void 0 ? void 0 : _node$data.componentFields;
|
|
5756
|
+
if (!Array.isArray(fields)) return void 0;
|
|
5757
|
+
const field = fields.find((candidate) => (candidate === null || candidate === void 0 ? void 0 : candidate.componentFieldId) === componentFieldId);
|
|
5758
|
+
const value = field === null || field === void 0 || (_field$data = field.data) === null || _field$data === void 0 || (_field$data = _field$data[0]) === null || _field$data === void 0 ? void 0 : _field$data.value;
|
|
5759
|
+
if (typeof value !== "string") return void 0;
|
|
5760
|
+
if (!value.trim()) return void 0;
|
|
5761
|
+
return value;
|
|
5574
5762
|
}
|
|
5575
|
-
function
|
|
5576
|
-
|
|
5763
|
+
function nodeLabel(node) {
|
|
5764
|
+
var _node$data2;
|
|
5765
|
+
const fromField = fieldValue(node, "name");
|
|
5766
|
+
if (fromField !== void 0) return fromField;
|
|
5767
|
+
const label = (_node$data2 = node.data) === null || _node$data2 === void 0 ? void 0 : _node$data2.label;
|
|
5768
|
+
if (typeof label === "string") return label;
|
|
5769
|
+
return "";
|
|
5577
5770
|
}
|
|
5578
|
-
function
|
|
5579
|
-
|
|
5580
|
-
|
|
5581
|
-
|
|
5582
|
-
|
|
5771
|
+
function encodeLabel(text) {
|
|
5772
|
+
return text.replace(/#/g, "#").replace(/\r\n?/g, "\n").replace(/\n/g, "<br/>").trim();
|
|
5773
|
+
}
|
|
5774
|
+
function toMermaidId(name, index, used) {
|
|
5775
|
+
const base = name.replace(/[^A-Za-z0-9_]/g, "") || `P${index}`;
|
|
5776
|
+
let candidate = base;
|
|
5777
|
+
let suffix = 2;
|
|
5778
|
+
while (used.has(candidate)) {
|
|
5779
|
+
candidate = `${base}_${suffix}`;
|
|
5780
|
+
suffix++;
|
|
5781
|
+
}
|
|
5782
|
+
used.add(candidate);
|
|
5783
|
+
return candidate;
|
|
5784
|
+
}
|
|
5785
|
+
function collectParticipants(nodes) {
|
|
5786
|
+
const used = /* @__PURE__ */ new Set();
|
|
5787
|
+
return nodes.filter((node) => node.type === "sequenceParticipant").sort((a, b) => a.position.x - b.position.x).map((node, index) => {
|
|
5788
|
+
var _node$data3, _node$data4, _node$data5, _node$data6, _node$data7;
|
|
5789
|
+
const name = nodeLabel(node) || `Participant ${index + 1}`;
|
|
5790
|
+
const rawType = (_node$data3 = node.data) === null || _node$data3 === void 0 ? void 0 : _node$data3.participantType;
|
|
5791
|
+
const activations = (_node$data4 = node.data) === null || _node$data4 === void 0 ? void 0 : _node$data4.activations;
|
|
5792
|
+
const links = (_node$data5 = node.data) === null || _node$data5 === void 0 ? void 0 : _node$data5.links;
|
|
5793
|
+
const createdRow = (_node$data6 = node.data) === null || _node$data6 === void 0 ? void 0 : _node$data6.lifelineStartRow;
|
|
5794
|
+
const destroyedRow = (_node$data7 = node.data) === null || _node$data7 === void 0 ? void 0 : _node$data7.lifelineEndRow;
|
|
5795
|
+
return _objectSpread2(_objectSpread2(_objectSpread2({
|
|
5796
|
+
nodeId: node.id,
|
|
5797
|
+
mermaidId: toMermaidId(name, index, used),
|
|
5798
|
+
name,
|
|
5799
|
+
type: typeof rawType === "string" ? rawType : "participant",
|
|
5800
|
+
links: Array.isArray(links) ? links : [],
|
|
5801
|
+
activations: Array.isArray(activations) ? activations : []
|
|
5802
|
+
}, typeof createdRow === "number" ? { createdRow } : {}), typeof destroyedRow === "number" ? { destroyedRow } : {}), {}, { x: node.position.x });
|
|
5583
5803
|
});
|
|
5584
|
-
return _resolveAnimatedNode.apply(this, arguments);
|
|
5585
5804
|
}
|
|
5586
|
-
|
|
5587
|
-
|
|
5588
|
-
|
|
5589
|
-
|
|
5590
|
-
|
|
5591
|
-
table: {
|
|
5592
|
-
width: 600,
|
|
5593
|
-
height: 400
|
|
5594
|
-
},
|
|
5595
|
-
code: {
|
|
5596
|
-
width: 300,
|
|
5597
|
-
height: 400
|
|
5805
|
+
function buildMessageLinks(edges, participantNodeIds) {
|
|
5806
|
+
const links = /* @__PURE__ */ new Map();
|
|
5807
|
+
for (const edge of edges) {
|
|
5808
|
+
if (participantNodeIds.has(edge.source)) links.set(edge.target, _objectSpread2(_objectSpread2({}, links.get(edge.target)), {}, { from: edge.source }));
|
|
5809
|
+
if (participantNodeIds.has(edge.target)) links.set(edge.source, _objectSpread2(_objectSpread2({}, links.get(edge.source)), {}, { to: edge.target }));
|
|
5598
5810
|
}
|
|
5599
|
-
|
|
5600
|
-
const GROUP_BOUND_PADDING = 20;
|
|
5601
|
-
const GROUP_WIDTH_PADDING = 20;
|
|
5602
|
-
const GROUP_HEIGHT_PADDING = 50;
|
|
5603
|
-
const MIN_HORIZONTAL_GAP = 140;
|
|
5604
|
-
const ROW_ALIGNMENT_TOLERANCE = 80;
|
|
5605
|
-
function resolveDimension(value) {
|
|
5606
|
-
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
5811
|
+
return links;
|
|
5607
5812
|
}
|
|
5608
|
-
function
|
|
5609
|
-
var
|
|
5610
|
-
const
|
|
5611
|
-
|
|
5612
|
-
|
|
5613
|
-
|
|
5614
|
-
|
|
5813
|
+
function arrowTokenOf(edgeFrom, edgeTo) {
|
|
5814
|
+
var _edgeTo$data$arrowTyp, _edgeTo$data, _edgeFrom$data, _edgeTo$data$half, _edgeTo$data2, _edgeFrom$data2, _edgeFrom$data3, _ref, _ref2;
|
|
5815
|
+
const arrowType = (_edgeTo$data$arrowTyp = edgeTo === null || edgeTo === void 0 || (_edgeTo$data = edgeTo.data) === null || _edgeTo$data === void 0 ? void 0 : _edgeTo$data.arrowType) !== null && _edgeTo$data$arrowTyp !== void 0 ? _edgeTo$data$arrowTyp : edgeFrom === null || edgeFrom === void 0 || (_edgeFrom$data = edgeFrom.data) === null || _edgeFrom$data === void 0 ? void 0 : _edgeFrom$data.arrowType;
|
|
5816
|
+
const half = (_edgeTo$data$half = edgeTo === null || edgeTo === void 0 || (_edgeTo$data2 = edgeTo.data) === null || _edgeTo$data2 === void 0 ? void 0 : _edgeTo$data2.half) !== null && _edgeTo$data$half !== void 0 ? _edgeTo$data$half : edgeFrom === null || edgeFrom === void 0 || (_edgeFrom$data2 = edgeFrom.data) === null || _edgeFrom$data2 === void 0 ? void 0 : _edgeFrom$data2.half;
|
|
5817
|
+
const reversed = (edgeFrom === null || edgeFrom === void 0 || (_edgeFrom$data3 = edgeFrom.data) === null || _edgeFrom$data3 === void 0 ? void 0 : _edgeFrom$data3.reversed) === true;
|
|
5818
|
+
return findArrowTokenFor(_objectSpread2(_objectSpread2({
|
|
5819
|
+
lineStyle: (edgeTo === null || edgeTo === void 0 || (_ref = edgeTo.style) === null || _ref === void 0 ? void 0 : _ref.strokeDasharray) !== void 0 || (edgeFrom === null || edgeFrom === void 0 || (_ref2 = edgeFrom.style) === null || _ref2 === void 0 ? void 0 : _ref2.strokeDasharray) !== void 0 ? "dashed" : "solid",
|
|
5820
|
+
arrowType: arrowType !== null && arrowType !== void 0 ? arrowType : "filled"
|
|
5821
|
+
}, half ? { half } : {}), {}, { reversed }));
|
|
5615
5822
|
}
|
|
5616
|
-
function
|
|
5617
|
-
const
|
|
5618
|
-
|
|
5619
|
-
|
|
5620
|
-
|
|
5621
|
-
|
|
5622
|
-
|
|
5623
|
-
|
|
5624
|
-
|
|
5625
|
-
|
|
5626
|
-
|
|
5627
|
-
|
|
5628
|
-
|
|
5629
|
-
|
|
5630
|
-
|
|
5631
|
-
|
|
5632
|
-
|
|
5633
|
-
|
|
5634
|
-
|
|
5635
|
-
|
|
5636
|
-
|
|
5637
|
-
|
|
5638
|
-
|
|
5639
|
-
|
|
5640
|
-
|
|
5641
|
-
|
|
5642
|
-
|
|
5643
|
-
x: node.position.x + offsetX,
|
|
5644
|
-
y: node.position.y + offsetY
|
|
5645
|
-
} });
|
|
5646
|
-
});
|
|
5647
|
-
const resizedNodesById = new Map(resizedNodes.map((node) => [node.id, node]));
|
|
5648
|
-
const rowNodes = resizedNodes.filter((node) => {
|
|
5649
|
-
var _node$data2;
|
|
5650
|
-
return !Array.isArray((_node$data2 = node.data) === null || _node$data2 === void 0 ? void 0 : _node$data2.childNodes);
|
|
5651
|
-
}).sort((a, b) => a.position.y === b.position.y ? a.position.x - b.position.x : a.position.y - b.position.y);
|
|
5652
|
-
const rows = [];
|
|
5653
|
-
for (const node of rowNodes) {
|
|
5654
|
-
const row = rows.find((currentRow) => Math.abs(currentRow[0].position.y - node.position.y) <= ROW_ALIGNMENT_TOLERANCE);
|
|
5655
|
-
if (row) {
|
|
5656
|
-
row.push(node);
|
|
5823
|
+
function noteParticipantNodeIds(note, participants, noteNode$1) {
|
|
5824
|
+
const byImportedId = (Array.isArray(note.participants) ? note.participants.filter((value) => typeof value === "string") : []).map((id) => participants.find((participant) => participant.nodeId === `participant-${id}`)).filter((participant) => Boolean(participant));
|
|
5825
|
+
if (byImportedId.length > 0) return byImportedId.map((participant) => participant.nodeId);
|
|
5826
|
+
if (participants.length === 0) return [];
|
|
5827
|
+
const noteCenter = noteNode$1.position.x + (Number(noteNode$1.width) || 0) / 2;
|
|
5828
|
+
return [[...participants].sort((a, b) => Math.abs(a.x - noteCenter) - Math.abs(b.x - noteCenter))[0].nodeId];
|
|
5829
|
+
}
|
|
5830
|
+
function collectRowItems(nodes, edges, participants) {
|
|
5831
|
+
const participantNodeIds = new Set(participants.map((p) => p.nodeId));
|
|
5832
|
+
const links = buildMessageLinks(edges, participantNodeIds);
|
|
5833
|
+
const items = [];
|
|
5834
|
+
for (const node of nodes) {
|
|
5835
|
+
var _node$data8, _node$data9, _edgeFrom$data4, _edgeTo$data3;
|
|
5836
|
+
if (participantNodeIds.has(node.id)) continue;
|
|
5837
|
+
const note = (_node$data8 = node.data) === null || _node$data8 === void 0 ? void 0 : _node$data8.sequenceNote;
|
|
5838
|
+
if (note) {
|
|
5839
|
+
var _note$placement;
|
|
5840
|
+
items.push({
|
|
5841
|
+
item: {
|
|
5842
|
+
kind: "note",
|
|
5843
|
+
nodeId: node.id,
|
|
5844
|
+
text: nodeLabel(node),
|
|
5845
|
+
placement: (_note$placement = note.placement) !== null && _note$placement !== void 0 ? _note$placement : "over",
|
|
5846
|
+
participantNodeIds: noteParticipantNodeIds(note, participants, node)
|
|
5847
|
+
},
|
|
5848
|
+
y: node.position.y
|
|
5849
|
+
});
|
|
5657
5850
|
continue;
|
|
5658
5851
|
}
|
|
5659
|
-
|
|
5660
|
-
|
|
5661
|
-
|
|
5662
|
-
|
|
5663
|
-
|
|
5664
|
-
|
|
5665
|
-
|
|
5666
|
-
|
|
5667
|
-
|
|
5668
|
-
|
|
5669
|
-
|
|
5670
|
-
|
|
5671
|
-
|
|
5672
|
-
|
|
5673
|
-
|
|
5674
|
-
|
|
5675
|
-
|
|
5676
|
-
}
|
|
5677
|
-
return resizedNodes.map((node) => {
|
|
5678
|
-
var _resizedNodesById$get, _node$data3;
|
|
5679
|
-
const shiftedNode = (_resizedNodesById$get = resizedNodesById.get(node.id)) !== null && _resizedNodesById$get !== void 0 ? _resizedNodesById$get : node;
|
|
5680
|
-
const childNodeIds = (_node$data3 = node.data) === null || _node$data3 === void 0 ? void 0 : _node$data3.childNodes;
|
|
5681
|
-
if (!Array.isArray(childNodeIds)) return shiftedNode;
|
|
5682
|
-
const childNodes = childNodeIds.map((childNodeId) => typeof childNodeId === "string" ? resizedNodesById.get(childNodeId) : void 0).filter((childNode) => Boolean(childNode));
|
|
5683
|
-
if (childNodes.length === 0) return shiftedNode;
|
|
5684
|
-
const bounds = childNodes.map((childNode) => {
|
|
5685
|
-
const size = getNodeSize(childNode);
|
|
5686
|
-
return {
|
|
5687
|
-
left: childNode.position.x,
|
|
5688
|
-
top: childNode.position.y,
|
|
5689
|
-
right: childNode.position.x + size.width,
|
|
5690
|
-
bottom: childNode.position.y + size.height
|
|
5691
|
-
};
|
|
5692
|
-
});
|
|
5693
|
-
const minX = Math.min(...bounds.map((bound) => bound.left));
|
|
5694
|
-
const minY = Math.min(...bounds.map((bound) => bound.top));
|
|
5695
|
-
const maxX = Math.max(...bounds.map((bound) => bound.right));
|
|
5696
|
-
const maxY = Math.max(...bounds.map((bound) => bound.bottom));
|
|
5697
|
-
return _objectSpread2(_objectSpread2({}, shiftedNode), {}, {
|
|
5698
|
-
position: {
|
|
5699
|
-
x: minX - GROUP_BOUND_PADDING,
|
|
5700
|
-
y: minY - GROUP_BOUND_PADDING
|
|
5701
|
-
},
|
|
5702
|
-
style: _objectSpread2(_objectSpread2({}, shiftedNode.style), {}, {
|
|
5703
|
-
width: maxX - minX + GROUP_BOUND_PADDING * 2 + GROUP_WIDTH_PADDING,
|
|
5704
|
-
height: maxY - minY + GROUP_BOUND_PADDING * 2 + GROUP_HEIGHT_PADDING
|
|
5705
|
-
})
|
|
5852
|
+
const link = links.get(node.id);
|
|
5853
|
+
if (!(link === null || link === void 0 ? void 0 : link.from) || !link.to) continue;
|
|
5854
|
+
const edgeFrom = edges.find((edge) => edge.target === node.id && edge.source === link.from);
|
|
5855
|
+
const edgeTo = edges.find((edge) => edge.source === node.id && edge.target === link.to);
|
|
5856
|
+
const sequenceNumber = (_node$data9 = node.data) === null || _node$data9 === void 0 ? void 0 : _node$data9.sequenceNumber;
|
|
5857
|
+
items.push({
|
|
5858
|
+
item: _objectSpread2({
|
|
5859
|
+
kind: "message",
|
|
5860
|
+
nodeId: node.id,
|
|
5861
|
+
fromNodeId: link.from,
|
|
5862
|
+
toNodeId: link.to,
|
|
5863
|
+
label: nodeLabel(node),
|
|
5864
|
+
token: arrowTokenOf(edgeFrom, edgeTo),
|
|
5865
|
+
centralSource: (edgeFrom === null || edgeFrom === void 0 || (_edgeFrom$data4 = edgeFrom.data) === null || _edgeFrom$data4 === void 0 ? void 0 : _edgeFrom$data4.centralSource) === true,
|
|
5866
|
+
centralTarget: (edgeTo === null || edgeTo === void 0 || (_edgeTo$data3 = edgeTo.data) === null || _edgeTo$data3 === void 0 ? void 0 : _edgeTo$data3.centralTarget) === true
|
|
5867
|
+
}, typeof sequenceNumber === "number" ? { sequenceNumber } : {}),
|
|
5868
|
+
y: node.position.y
|
|
5706
5869
|
});
|
|
5707
|
-
}
|
|
5870
|
+
}
|
|
5871
|
+
return items.sort((a, b) => a.y - b.y).map((entry) => entry.item);
|
|
5708
5872
|
}
|
|
5709
|
-
function
|
|
5710
|
-
|
|
5711
|
-
|
|
5873
|
+
function collectBlocks(nodes) {
|
|
5874
|
+
const blocks = [];
|
|
5875
|
+
for (const node of nodes) {
|
|
5876
|
+
var _node$data10, _block$type, _block$label, _block$depth, _block$sections;
|
|
5877
|
+
const block = (_node$data10 = node.data) === null || _node$data10 === void 0 ? void 0 : _node$data10.sequenceBlock;
|
|
5878
|
+
if (!block) continue;
|
|
5879
|
+
if (typeof block.startRow !== "number") continue;
|
|
5880
|
+
if (typeof block.endRow !== "number") continue;
|
|
5881
|
+
blocks.push(_objectSpread2(_objectSpread2({
|
|
5882
|
+
nodeId: node.id,
|
|
5883
|
+
type: (_block$type = block.type) !== null && _block$type !== void 0 ? _block$type : "rect",
|
|
5884
|
+
label: (_block$label = block.label) !== null && _block$label !== void 0 ? _block$label : ""
|
|
5885
|
+
}, block.color ? { color: block.color } : {}), {}, {
|
|
5886
|
+
depth: (_block$depth = block.depth) !== null && _block$depth !== void 0 ? _block$depth : 0,
|
|
5887
|
+
startRow: block.startRow,
|
|
5888
|
+
endRow: block.endRow,
|
|
5889
|
+
sections: ((_block$sections = block.sections) !== null && _block$sections !== void 0 ? _block$sections : []).filter((section) => typeof section.startRow === "number" && typeof section.endRow === "number").map((section) => {
|
|
5890
|
+
var _section$label;
|
|
5891
|
+
return {
|
|
5892
|
+
label: (_section$label = section.label) !== null && _section$label !== void 0 ? _section$label : "",
|
|
5893
|
+
startRow: section.startRow,
|
|
5894
|
+
endRow: section.endRow
|
|
5895
|
+
};
|
|
5896
|
+
})
|
|
5897
|
+
}));
|
|
5898
|
+
}
|
|
5899
|
+
return blocks;
|
|
5712
5900
|
}
|
|
5713
|
-
function
|
|
5714
|
-
|
|
5715
|
-
const
|
|
5716
|
-
|
|
5717
|
-
|
|
5718
|
-
|
|
5719
|
-
|
|
5720
|
-
|
|
5721
|
-
|
|
5722
|
-
|
|
5723
|
-
|
|
5724
|
-
|
|
5901
|
+
function collectBoxes(nodes, participants) {
|
|
5902
|
+
const boxes = [];
|
|
5903
|
+
for (const node of nodes) {
|
|
5904
|
+
var _node$data11, _node$data12, _box$label;
|
|
5905
|
+
const box = (_node$data11 = node.data) === null || _node$data11 === void 0 ? void 0 : _node$data11.sequenceBox;
|
|
5906
|
+
if (!box) continue;
|
|
5907
|
+
const byImportedId = (Array.isArray(box.participants) ? box.participants.filter((value) => typeof value === "string") : []).map((id) => participants.find((participant) => participant.nodeId === `participant-${id}`)).filter((participant) => Boolean(participant));
|
|
5908
|
+
const left = node.position.x;
|
|
5909
|
+
const right = node.position.x + (Number(node.width) || 0);
|
|
5910
|
+
const contained = byImportedId.length > 0 ? byImportedId : participants.filter((participant) => participant.x >= left && participant.x <= right);
|
|
5911
|
+
if (contained.length === 0) continue;
|
|
5912
|
+
const backgroundColor = (_node$data12 = node.data) === null || _node$data12 === void 0 ? void 0 : _node$data12.backgroundColor;
|
|
5913
|
+
boxes.push(_objectSpread2(_objectSpread2({
|
|
5914
|
+
nodeId: node.id,
|
|
5915
|
+
label: (_box$label = box.label) !== null && _box$label !== void 0 ? _box$label : ""
|
|
5916
|
+
}, typeof backgroundColor === "string" ? { color: backgroundColor } : {}), {}, { participantNodeIds: contained.map((participant) => participant.nodeId) }));
|
|
5917
|
+
}
|
|
5918
|
+
return boxes;
|
|
5725
5919
|
}
|
|
5726
|
-
function
|
|
5727
|
-
|
|
5920
|
+
function participantDeclaration(participant, keyword) {
|
|
5921
|
+
const stereotype = participant.type === "participant" || participant.type === "actor" ? "" : `@{ "type": "${participant.type}" }`;
|
|
5922
|
+
const alias = participant.mermaidId === participant.name ? "" : ` as ${encodeLabel(participant.name)}`;
|
|
5923
|
+
return `${keyword} ${participant.mermaidId}${stereotype}${alias}`;
|
|
5728
5924
|
}
|
|
5729
|
-
function
|
|
5730
|
-
|
|
5731
|
-
|
|
5732
|
-
|
|
5733
|
-
|
|
5734
|
-
|
|
5735
|
-
|
|
5736
|
-
|
|
5737
|
-
|
|
5738
|
-
|
|
5739
|
-
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
|
-
|
|
5745
|
-
|
|
5746
|
-
|
|
5747
|
-
|
|
5748
|
-
|
|
5749
|
-
|
|
5750
|
-
|
|
5751
|
-
|
|
5752
|
-
|
|
5753
|
-
|
|
5754
|
-
|
|
5755
|
-
|
|
5756
|
-
|
|
5757
|
-
|
|
5758
|
-
|
|
5759
|
-
|
|
5760
|
-
|
|
5761
|
-
|
|
5762
|
-
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
|
|
5769
|
-
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
|
|
5773
|
-
|
|
5774
|
-
|
|
5775
|
-
|
|
5776
|
-
|
|
5777
|
-
|
|
5778
|
-
|
|
5779
|
-
|
|
5780
|
-
|
|
5781
|
-
|
|
5782
|
-
|
|
5783
|
-
|
|
5784
|
-
|
|
5785
|
-
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
|
|
5789
|
-
|
|
5790
|
-
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
|
|
5794
|
-
|
|
5795
|
-
|
|
5796
|
-
|
|
5797
|
-
|
|
5798
|
-
|
|
5799
|
-
|
|
5800
|
-
|
|
5801
|
-
|
|
5802
|
-
|
|
5803
|
-
|
|
5804
|
-
|
|
5805
|
-
|
|
5806
|
-
|
|
5807
|
-
|
|
5808
|
-
|
|
5925
|
+
function emitSequenceMermaid(nodes, edges) {
|
|
5926
|
+
const nodeIdMap = /* @__PURE__ */ new Map();
|
|
5927
|
+
const participants = collectParticipants(nodes);
|
|
5928
|
+
const items = collectRowItems(nodes, edges, participants);
|
|
5929
|
+
const blocks = collectBlocks(nodes);
|
|
5930
|
+
const boxes = collectBoxes(nodes, participants);
|
|
5931
|
+
const participantByNodeId = new Map(participants.map((participant) => [participant.nodeId, participant]));
|
|
5932
|
+
for (const participant of participants) nodeIdMap.set(participant.nodeId, `participant-${participant.mermaidId}`);
|
|
5933
|
+
const rowByItemId = /* @__PURE__ */ new Map();
|
|
5934
|
+
const lastRowByItemId = /* @__PURE__ */ new Map();
|
|
5935
|
+
let row = 0;
|
|
5936
|
+
for (const item of items) {
|
|
5937
|
+
rowByItemId.set(item.nodeId, row);
|
|
5938
|
+
const isSelf = item.kind === "message" && item.fromNodeId === item.toNodeId;
|
|
5939
|
+
lastRowByItemId.set(item.nodeId, isSelf ? row + 1 : row);
|
|
5940
|
+
row += isSelf ? 2 : 1;
|
|
5941
|
+
}
|
|
5942
|
+
const rowCount = row;
|
|
5943
|
+
const lines = ["sequenceDiagram"];
|
|
5944
|
+
const titleNode = nodes.find((node) => node.id === "sequence-title");
|
|
5945
|
+
if (titleNode) {
|
|
5946
|
+
var _fieldValue;
|
|
5947
|
+
const text = (_fieldValue = fieldValue(titleNode, "text")) !== null && _fieldValue !== void 0 ? _fieldValue : nodeLabel(titleNode);
|
|
5948
|
+
if (text) {
|
|
5949
|
+
lines.push(` title ${encodeLabel(text)}`);
|
|
5950
|
+
nodeIdMap.set(titleNode.id, "sequence-title");
|
|
5951
|
+
}
|
|
5952
|
+
}
|
|
5953
|
+
const boxByFirstParticipant = /* @__PURE__ */ new Map();
|
|
5954
|
+
const boxEndByParticipant = /* @__PURE__ */ new Map();
|
|
5955
|
+
for (const box of boxes) {
|
|
5956
|
+
var _boxEndByParticipant$;
|
|
5957
|
+
const ordered = participants.filter((participant) => box.participantNodeIds.includes(participant.nodeId));
|
|
5958
|
+
if (ordered.length === 0) continue;
|
|
5959
|
+
boxByFirstParticipant.set(ordered[0].nodeId, box);
|
|
5960
|
+
boxEndByParticipant.set(ordered[ordered.length - 1].nodeId, ((_boxEndByParticipant$ = boxEndByParticipant.get(ordered[ordered.length - 1].nodeId)) !== null && _boxEndByParticipant$ !== void 0 ? _boxEndByParticipant$ : 0) + 1);
|
|
5961
|
+
}
|
|
5962
|
+
let boxIndex = 0;
|
|
5963
|
+
for (const participant of participants) {
|
|
5964
|
+
var _boxEndByParticipant$2;
|
|
5965
|
+
const box = boxByFirstParticipant.get(participant.nodeId);
|
|
5966
|
+
if (box) {
|
|
5967
|
+
const color = box.color ? `${box.color} ` : "";
|
|
5968
|
+
lines.push(` box ${color}${encodeLabel(box.label)}`.trimEnd());
|
|
5969
|
+
nodeIdMap.set(box.nodeId, `sequence-box-box-${boxIndex}`);
|
|
5970
|
+
boxIndex++;
|
|
5971
|
+
}
|
|
5972
|
+
if (participant.createdRow === void 0) {
|
|
5973
|
+
const keyword = participant.type === "actor" ? "actor" : "participant";
|
|
5974
|
+
lines.push(` ${participantDeclaration(participant, keyword)}`);
|
|
5975
|
+
}
|
|
5976
|
+
const boxEnds = (_boxEndByParticipant$2 = boxEndByParticipant.get(participant.nodeId)) !== null && _boxEndByParticipant$2 !== void 0 ? _boxEndByParticipant$2 : 0;
|
|
5977
|
+
for (let index = 0; index < boxEnds; index++) lines.push(" end");
|
|
5978
|
+
}
|
|
5979
|
+
for (const participant of participants) for (const link of participant.links) lines.push(` link ${participant.mermaidId}: ${link.label} @ ${link.url}`);
|
|
5980
|
+
const numbered = items.filter((item) => item.kind === "message" && item.sequenceNumber !== void 0);
|
|
5981
|
+
if (numbered.length > 0) {
|
|
5982
|
+
const start = numbered[0].sequenceNumber;
|
|
5983
|
+
const step = numbered.length > 1 ? numbered[1].sequenceNumber - numbered[0].sequenceNumber : 1;
|
|
5984
|
+
lines.push(` autonumber ${start} ${step}`);
|
|
5985
|
+
}
|
|
5986
|
+
const openBlocks = [];
|
|
5987
|
+
let blockIndex = 0;
|
|
5988
|
+
let parserRow = 0;
|
|
5989
|
+
function indent() {
|
|
5990
|
+
return " ".repeat(openBlocks.length + 1);
|
|
5991
|
+
}
|
|
5992
|
+
for (let currentRow = 0; currentRow < rowCount; currentRow++) {
|
|
5993
|
+
const opening = blocks.filter((block) => block.startRow === currentRow).sort((a, b) => a.depth - b.depth);
|
|
5994
|
+
for (const block of opening) {
|
|
5995
|
+
const label = encodeLabel(block.label);
|
|
5996
|
+
const color = block.type === "rect" && block.color ? `${block.color} ` : "";
|
|
5997
|
+
lines.push(`${indent()}${block.type} ${color}${label}`.trimEnd());
|
|
5998
|
+
nodeIdMap.set(block.nodeId, `sequence-block-block-${blockIndex}`);
|
|
5999
|
+
blockIndex++;
|
|
6000
|
+
openBlocks.push(block);
|
|
6001
|
+
}
|
|
6002
|
+
for (const [depth, block] of openBlocks.entries()) for (const section of block.sections.slice(1)) {
|
|
6003
|
+
if (section.startRow !== currentRow) continue;
|
|
6004
|
+
const keyword = block.type === "par" ? "and" : block.type === "critical" ? "option" : "else";
|
|
6005
|
+
lines.push(`${" ".repeat(depth + 1)}${keyword} ${encodeLabel(section.label)}`.trimEnd());
|
|
6006
|
+
}
|
|
6007
|
+
const item = items.find((entry) => rowByItemId.get(entry.nodeId) === currentRow);
|
|
6008
|
+
if (item) {
|
|
6009
|
+
for (const participant of participants) {
|
|
6010
|
+
if (participant.createdRow !== currentRow) continue;
|
|
6011
|
+
const keyword = participant.type === "actor" ? "actor" : "participant";
|
|
6012
|
+
lines.push(`${indent()}create ${participantDeclaration(participant, keyword)}`);
|
|
6013
|
+
}
|
|
6014
|
+
for (const participant of participants) {
|
|
6015
|
+
if (participant.destroyedRow !== currentRow) continue;
|
|
6016
|
+
lines.push(`${indent()}destroy ${participant.mermaidId}`);
|
|
6017
|
+
}
|
|
6018
|
+
for (const participant of participants) for (const activation of participant.activations) {
|
|
6019
|
+
if (activation.startRow !== currentRow) continue;
|
|
6020
|
+
lines.push(`${indent()}activate ${participant.mermaidId}`);
|
|
6021
|
+
}
|
|
6022
|
+
if (item.kind === "message") {
|
|
6023
|
+
const from = participantByNodeId.get(item.fromNodeId);
|
|
6024
|
+
const to = participantByNodeId.get(item.toNodeId);
|
|
6025
|
+
if (from && to) {
|
|
6026
|
+
const source = item.centralSource ? `${from.mermaidId}()` : from.mermaidId;
|
|
6027
|
+
const target = item.centralTarget ? `()${to.mermaidId}` : to.mermaidId;
|
|
6028
|
+
lines.push(`${indent()}${source}${item.token}${target}: ${encodeLabel(item.label)}`);
|
|
6029
|
+
nodeIdMap.set(item.nodeId, `message-${parserRow}`);
|
|
6030
|
+
parserRow++;
|
|
5809
6031
|
}
|
|
5810
|
-
|
|
5811
|
-
|
|
5812
|
-
|
|
5813
|
-
|
|
5814
|
-
|
|
5815
|
-
|
|
5816
|
-
|
|
5817
|
-
|
|
5818
|
-
|
|
5819
|
-
|
|
5820
|
-
type: metaInput.type,
|
|
5821
|
-
data: metaInput.value,
|
|
5822
|
-
options: metaInput.options
|
|
5823
|
-
});
|
|
5824
|
-
if (!componentField) componentFields.push(newComponentField);
|
|
5825
|
-
else {
|
|
5826
|
-
componentField.type = newComponentField.type;
|
|
5827
|
-
componentField.data = newComponentField.data;
|
|
5828
|
-
}
|
|
6032
|
+
}
|
|
6033
|
+
if (item.kind === "note") {
|
|
6034
|
+
const names = item.participantNodeIds.map((nodeId) => {
|
|
6035
|
+
var _participantByNodeId$;
|
|
6036
|
+
return (_participantByNodeId$ = participantByNodeId.get(nodeId)) === null || _participantByNodeId$ === void 0 ? void 0 : _participantByNodeId$.mermaidId;
|
|
6037
|
+
}).filter((id) => id !== void 0);
|
|
6038
|
+
if (names.length > 0) {
|
|
6039
|
+
lines.push(`${indent()}Note ${item.placement} ${names.join(",")}: ${encodeLabel(item.text)}`);
|
|
6040
|
+
nodeIdMap.set(item.nodeId, `note-${parserRow}`);
|
|
6041
|
+
parserRow++;
|
|
5829
6042
|
}
|
|
5830
|
-
|
|
5831
|
-
|
|
5832
|
-
|
|
5833
|
-
|
|
5834
|
-
|
|
5835
|
-
|
|
5836
|
-
|
|
5837
|
-
|
|
5838
|
-
|
|
5839
|
-
|
|
5840
|
-
|
|
5841
|
-
|
|
5842
|
-
|
|
5843
|
-
|
|
5844
|
-
|
|
5845
|
-
|
|
5846
|
-
|
|
5847
|
-
|
|
5848
|
-
|
|
5849
|
-
|
|
5850
|
-
|
|
5851
|
-
|
|
5852
|
-
|
|
5853
|
-
|
|
5854
|
-
|
|
5855
|
-
|
|
5856
|
-
|
|
5857
|
-
|
|
5858
|
-
|
|
5859
|
-
|
|
5860
|
-
|
|
5861
|
-
|
|
5862
|
-
|
|
5863
|
-
|
|
5864
|
-
|
|
5865
|
-
|
|
5866
|
-
|
|
5867
|
-
|
|
5868
|
-
|
|
5869
|
-
|
|
5870
|
-
|
|
5871
|
-
|
|
5872
|
-
|
|
5873
|
-
|
|
5874
|
-
|
|
5875
|
-
|
|
5876
|
-
|
|
5877
|
-
|
|
5878
|
-
|
|
5879
|
-
|
|
5880
|
-
|
|
5881
|
-
|
|
5882
|
-
|
|
5883
|
-
|
|
5884
|
-
|
|
5885
|
-
}());
|
|
5886
|
-
const resolvedEdges = yield Promise.all(rfEdgesPromises);
|
|
5887
|
-
const combinedNodes = [...groupNodes, ...resolvedNodes.map((node) => {
|
|
5888
|
-
const nodeParent = groupNodes.find((groupNode) => {
|
|
5889
|
-
var _groupNode$data$child;
|
|
5890
|
-
return (_groupNode$data$child = groupNode.data.childNodes) === null || _groupNode$data$child === void 0 ? void 0 : _groupNode$data$child.includes(node.id);
|
|
5891
|
-
});
|
|
5892
|
-
if (nodeParent) return _objectSpread2(_objectSpread2({}, node), {}, { parentId: nodeParent.id });
|
|
5893
|
-
return node;
|
|
5894
|
-
})];
|
|
5895
|
-
if (isSequenceDiagram(combinedNodes)) return {
|
|
5896
|
-
edges: resolvedEdges,
|
|
5897
|
-
nodes: combinedNodes
|
|
5898
|
-
};
|
|
6043
|
+
}
|
|
6044
|
+
}
|
|
6045
|
+
const rowEnd = item ? lastRowByItemId.get(item.nodeId) : currentRow;
|
|
6046
|
+
for (const participant of participants) for (const activation of participant.activations) {
|
|
6047
|
+
if (activation.endRow !== rowEnd) continue;
|
|
6048
|
+
lines.push(`${indent()}deactivate ${participant.mermaidId}`);
|
|
6049
|
+
}
|
|
6050
|
+
while (openBlocks.length > 0 && openBlocks[openBlocks.length - 1].endRow <= rowEnd) {
|
|
6051
|
+
openBlocks.pop();
|
|
6052
|
+
lines.push(`${indent()}end`);
|
|
6053
|
+
}
|
|
6054
|
+
}
|
|
6055
|
+
while (openBlocks.length > 0) {
|
|
6056
|
+
openBlocks.pop();
|
|
6057
|
+
lines.push(`${indent()}end`);
|
|
6058
|
+
}
|
|
6059
|
+
return {
|
|
6060
|
+
mermaid: lines.join("\n"),
|
|
6061
|
+
nodeIdMap
|
|
6062
|
+
};
|
|
6063
|
+
}
|
|
6064
|
+
function convertReactFlowToSequenceMermaid(nodes, edges) {
|
|
6065
|
+
return emitSequenceMermaid(nodes, edges).mermaid;
|
|
6066
|
+
}
|
|
6067
|
+
function convertReactFlowToSequenceUiGraph(nodes, edges) {
|
|
6068
|
+
const { mermaid: mermaid$2, nodeIdMap } = emitSequenceMermaid(nodes, edges);
|
|
6069
|
+
return {
|
|
6070
|
+
mermaid: mermaid$2,
|
|
6071
|
+
context: buildValidatedContext(nodes, edges, [], nodeIdMap)
|
|
6072
|
+
};
|
|
6073
|
+
}
|
|
6074
|
+
const BOUND_PADDING = 20;
|
|
6075
|
+
function createGroupNode(options) {
|
|
6076
|
+
var _options$id, _options$name;
|
|
6077
|
+
return {
|
|
6078
|
+
id: (_options$id = options.id) !== null && _options$id !== void 0 ? _options$id : (0, daily_code.generateUUID)(),
|
|
6079
|
+
type: "group",
|
|
6080
|
+
position: {
|
|
6081
|
+
x: options.bounds.x,
|
|
6082
|
+
y: options.bounds.y
|
|
6083
|
+
},
|
|
6084
|
+
data: {
|
|
6085
|
+
childNodes: options.nodes,
|
|
6086
|
+
autoLayout: true,
|
|
6087
|
+
componentFields: [generateComponentFieldNameInput((_options$name = options.name) !== null && _options$name !== void 0 ? _options$name : "Group")]
|
|
6088
|
+
},
|
|
6089
|
+
style: {
|
|
6090
|
+
width: options.bounds.width + 20,
|
|
6091
|
+
height: options.bounds.height + 50
|
|
6092
|
+
}
|
|
6093
|
+
};
|
|
6094
|
+
}
|
|
6095
|
+
function generateGroupNodeFromNodes(id, name, nodes) {
|
|
6096
|
+
const bounds = nodes.map((node) => {
|
|
6097
|
+
var _ref, _ref2, _node$height, _node$style, _node$measured, _ref3, _ref4, _node$width, _node$style2, _node$measured2;
|
|
5899
6098
|
return {
|
|
5900
|
-
|
|
5901
|
-
|
|
6099
|
+
top: node.position.y,
|
|
6100
|
+
left: node.position.x,
|
|
6101
|
+
bottom: node.position.y + ((_ref = (_ref2 = (_node$height = node.height) !== null && _node$height !== void 0 ? _node$height : (_node$style = node.style) === null || _node$style === void 0 ? void 0 : _node$style.height) !== null && _ref2 !== void 0 ? _ref2 : (_node$measured = node.measured) === null || _node$measured === void 0 ? void 0 : _node$measured.height) !== null && _ref !== void 0 ? _ref : 0),
|
|
6102
|
+
right: node.position.x + ((_ref3 = (_ref4 = (_node$width = node.width) !== null && _node$width !== void 0 ? _node$width : (_node$style2 = node.style) === null || _node$style2 === void 0 ? void 0 : _node$style2.width) !== null && _ref4 !== void 0 ? _ref4 : (_node$measured2 = node.measured) === null || _node$measured2 === void 0 ? void 0 : _node$measured2.width) !== null && _ref3 !== void 0 ? _ref3 : 0)
|
|
5902
6103
|
};
|
|
5903
6104
|
});
|
|
5904
|
-
|
|
5905
|
-
|
|
5906
|
-
const
|
|
5907
|
-
|
|
5908
|
-
|
|
5909
|
-
|
|
5910
|
-
|
|
5911
|
-
|
|
5912
|
-
|
|
5913
|
-
|
|
5914
|
-
|
|
5915
|
-
|
|
5916
|
-
|
|
5917
|
-
|
|
5918
|
-
|
|
5919
|
-
"display",
|
|
5920
|
-
"collate",
|
|
5921
|
-
"sort",
|
|
5922
|
-
"terminator",
|
|
5923
|
-
"or",
|
|
5924
|
-
"database",
|
|
5925
|
-
"multiple-documents",
|
|
5926
|
-
"subroutine",
|
|
5927
|
-
"manual-input",
|
|
5928
|
-
"summing-junction",
|
|
5929
|
-
"internal-storage"
|
|
5930
|
-
]);
|
|
5931
|
-
const COMPONENT_INPUT_TYPES = new Set(Object.values(require_component_type.ComponentInputType));
|
|
5932
|
-
const INLINE_MERMAID_LABEL_MAX_LENGTH = 32;
|
|
5933
|
-
const KNOWN_NODE_DATA_KEYS = new Set([
|
|
5934
|
-
"componentFields",
|
|
5935
|
-
"shape",
|
|
5936
|
-
"fill",
|
|
5937
|
-
"stroke",
|
|
5938
|
-
"strokeWidth",
|
|
5939
|
-
"strokeStyle",
|
|
5940
|
-
"borderRadius",
|
|
5941
|
-
"borderAnimationEnabled",
|
|
5942
|
-
"strokeAnimation",
|
|
5943
|
-
"src",
|
|
5944
|
-
"animatedIcon",
|
|
5945
|
-
"iconSrc",
|
|
5946
|
-
"componentId",
|
|
5947
|
-
"serviceTable",
|
|
5948
|
-
"title",
|
|
5949
|
-
"columns",
|
|
5950
|
-
"rows",
|
|
5951
|
-
"name",
|
|
5952
|
-
"label",
|
|
5953
|
-
"value",
|
|
5954
|
-
"cloud",
|
|
5955
|
-
"service",
|
|
5956
|
-
"childNodes"
|
|
5957
|
-
]);
|
|
5958
|
-
function isComponentInputType(value) {
|
|
5959
|
-
return COMPONENT_INPUT_TYPES.has(value);
|
|
5960
|
-
}
|
|
5961
|
-
function toRecord(value) {
|
|
5962
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return;
|
|
5963
|
-
return value;
|
|
5964
|
-
}
|
|
5965
|
-
function pickString(value) {
|
|
5966
|
-
if (typeof value !== "string") return;
|
|
5967
|
-
const trimmed = value.trim();
|
|
5968
|
-
if (!trimmed) return;
|
|
5969
|
-
return trimmed;
|
|
5970
|
-
}
|
|
5971
|
-
function pickPosition(value) {
|
|
5972
|
-
const position = toRecord(value);
|
|
5973
|
-
if (!position) return;
|
|
5974
|
-
if (typeof position.x !== "number" || !Number.isFinite(position.x)) return;
|
|
5975
|
-
if (typeof position.y !== "number" || !Number.isFinite(position.y)) return;
|
|
5976
|
-
return {
|
|
5977
|
-
x: position.x,
|
|
5978
|
-
y: position.y
|
|
5979
|
-
};
|
|
6105
|
+
const minX = Math.min(...bounds.map((b) => b.left));
|
|
6106
|
+
const minY = Math.min(...bounds.map((b) => b.top));
|
|
6107
|
+
const maxX = Math.max(...bounds.map((b) => b.right));
|
|
6108
|
+
const maxY = Math.max(...bounds.map((b) => b.bottom));
|
|
6109
|
+
return createGroupNode({
|
|
6110
|
+
id,
|
|
6111
|
+
name,
|
|
6112
|
+
nodes: nodes.map((node) => node.id),
|
|
6113
|
+
bounds: {
|
|
6114
|
+
x: minX - BOUND_PADDING,
|
|
6115
|
+
y: minY - BOUND_PADDING,
|
|
6116
|
+
width: maxX - minX + BOUND_PADDING * 2,
|
|
6117
|
+
height: maxY - minY + BOUND_PADDING * 2
|
|
6118
|
+
}
|
|
6119
|
+
});
|
|
5980
6120
|
}
|
|
5981
|
-
function
|
|
5982
|
-
|
|
5983
|
-
const first = toRecord(fieldData[0]);
|
|
5984
|
-
if (!first) return fieldData;
|
|
5985
|
-
if (!("value" in first)) return first;
|
|
5986
|
-
return first.value;
|
|
6121
|
+
function resolveCloudIcon(_x, _x2) {
|
|
6122
|
+
return _resolveCloudIcon.apply(this, arguments);
|
|
5987
6123
|
}
|
|
5988
|
-
function
|
|
5989
|
-
|
|
5990
|
-
|
|
5991
|
-
|
|
6124
|
+
function _resolveCloudIcon() {
|
|
6125
|
+
_resolveCloudIcon = _asyncToGenerator(function* (cloud, serviceName) {
|
|
6126
|
+
const cloudName = cloud === null || cloud === void 0 ? void 0 : cloud.toLowerCase();
|
|
6127
|
+
const icon = (cloudName === "azure" ? [...(yield Promise.resolve().then(() => require("./__azure-icons.DJJasII-.cjs"))).default] : cloudName === "aws" ? [...(yield Promise.resolve().then(() => require("./__aws-icons.BEeU8uCn.cjs"))).default] : [...(yield Promise.resolve().then(() => require("./__aws-icons.BEeU8uCn.cjs"))).default, ...(yield Promise.resolve().then(() => require("./__azure-icons.DJJasII-.cjs"))).default]).find((icon$1) => icon$1.name.toLowerCase() === serviceName.toLowerCase());
|
|
6128
|
+
if (!icon) return null;
|
|
6129
|
+
return `/${icon.cloud.toLowerCase()}-icons/${icon.relativePath}`;
|
|
5992
6130
|
});
|
|
6131
|
+
return _resolveCloudIcon.apply(this, arguments);
|
|
5993
6132
|
}
|
|
5994
|
-
function
|
|
5995
|
-
|
|
5996
|
-
if (!field) return;
|
|
5997
|
-
return pickString(getFieldValue(field.data));
|
|
6133
|
+
function resolveAnimatedNode(_x3) {
|
|
6134
|
+
return _resolveAnimatedNode.apply(this, arguments);
|
|
5998
6135
|
}
|
|
5999
|
-
function
|
|
6000
|
-
|
|
6001
|
-
|
|
6136
|
+
function _resolveAnimatedNode() {
|
|
6137
|
+
_resolveAnimatedNode = _asyncToGenerator(function* (animatedIcon) {
|
|
6138
|
+
const node = (yield Promise.resolve().then(() => require("./__animated-nodes.CUxruu-b.cjs"))).default.find((node$1) => node$1.name.toLowerCase() === animatedIcon.toLowerCase());
|
|
6139
|
+
if (!node) return null;
|
|
6140
|
+
return `/animated-nodes/${node.fileName}`;
|
|
6141
|
+
});
|
|
6142
|
+
return _resolveAnimatedNode.apply(this, arguments);
|
|
6002
6143
|
}
|
|
6003
|
-
|
|
6004
|
-
|
|
6005
|
-
|
|
6006
|
-
|
|
6007
|
-
|
|
6008
|
-
|
|
6144
|
+
const EXPECTED_NODE_SIZE = {
|
|
6145
|
+
databaseTableSQL: {
|
|
6146
|
+
width: 500,
|
|
6147
|
+
height: 400
|
|
6148
|
+
},
|
|
6149
|
+
table: {
|
|
6150
|
+
width: 600,
|
|
6151
|
+
height: 400
|
|
6152
|
+
},
|
|
6153
|
+
code: {
|
|
6154
|
+
width: 300,
|
|
6155
|
+
height: 400
|
|
6156
|
+
}
|
|
6157
|
+
};
|
|
6158
|
+
const GROUP_BOUND_PADDING = 20;
|
|
6159
|
+
const GROUP_WIDTH_PADDING = 20;
|
|
6160
|
+
const GROUP_HEIGHT_PADDING = 50;
|
|
6161
|
+
const MIN_HORIZONTAL_GAP = 140;
|
|
6162
|
+
const ROW_ALIGNMENT_TOLERANCE = 80;
|
|
6163
|
+
function resolveDimension(value) {
|
|
6164
|
+
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
6009
6165
|
}
|
|
6010
|
-
function
|
|
6011
|
-
|
|
6012
|
-
const
|
|
6013
|
-
|
|
6014
|
-
|
|
6015
|
-
|
|
6016
|
-
const color = pickString(markerRecord.color);
|
|
6017
|
-
if (color) return {
|
|
6018
|
-
type,
|
|
6019
|
-
color
|
|
6166
|
+
function getNodeSize(node) {
|
|
6167
|
+
var _ref, _ref2, _ref3, _resolveDimension, _node$style, _node$measured, _ref4, _ref5, _ref6, _resolveDimension2, _node$style2, _node$measured2;
|
|
6168
|
+
const expectedSize = node.type ? EXPECTED_NODE_SIZE[node.type] : void 0;
|
|
6169
|
+
return {
|
|
6170
|
+
width: (_ref = (_ref2 = (_ref3 = (_resolveDimension = resolveDimension(node.width)) !== null && _resolveDimension !== void 0 ? _resolveDimension : resolveDimension((_node$style = node.style) === null || _node$style === void 0 ? void 0 : _node$style.width)) !== null && _ref3 !== void 0 ? _ref3 : resolveDimension((_node$measured = node.measured) === null || _node$measured === void 0 ? void 0 : _node$measured.width)) !== null && _ref2 !== void 0 ? _ref2 : expectedSize === null || expectedSize === void 0 ? void 0 : expectedSize.width) !== null && _ref !== void 0 ? _ref : 0,
|
|
6171
|
+
height: (_ref4 = (_ref5 = (_ref6 = (_resolveDimension2 = resolveDimension(node.height)) !== null && _resolveDimension2 !== void 0 ? _resolveDimension2 : resolveDimension((_node$style2 = node.style) === null || _node$style2 === void 0 ? void 0 : _node$style2.height)) !== null && _ref6 !== void 0 ? _ref6 : resolveDimension((_node$measured2 = node.measured) === null || _node$measured2 === void 0 ? void 0 : _node$measured2.height)) !== null && _ref5 !== void 0 ? _ref5 : expectedSize === null || expectedSize === void 0 ? void 0 : expectedSize.height) !== null && _ref4 !== void 0 ? _ref4 : 0
|
|
6020
6172
|
};
|
|
6021
|
-
return { type };
|
|
6022
|
-
}
|
|
6023
|
-
function escapeMermaidText(value) {
|
|
6024
|
-
return value.replaceAll("\"", "\\\"");
|
|
6025
|
-
}
|
|
6026
|
-
function canInlineMermaidLabel(value) {
|
|
6027
|
-
if (value.length > INLINE_MERMAID_LABEL_MAX_LENGTH) return false;
|
|
6028
|
-
if (value.includes("\n") || value.includes("\r")) return false;
|
|
6029
|
-
return true;
|
|
6030
|
-
}
|
|
6031
|
-
function normalizeDetailedMermaidLabel(value) {
|
|
6032
|
-
return value.split(/\r?\n/).map((line) => line.replace(/\s+/g, " ").trim()).filter((line) => line.length > 0).join("\n");
|
|
6033
|
-
}
|
|
6034
|
-
function toComponentFields(value) {
|
|
6035
|
-
if (!Array.isArray(value)) return [];
|
|
6036
|
-
return value.map((field) => toRecord(field)).filter((field) => field !== void 0);
|
|
6037
|
-
}
|
|
6038
|
-
function buildContextEdges(edges, nodeIdMap) {
|
|
6039
|
-
const contextEdges = {};
|
|
6040
|
-
for (const edge of edges) {
|
|
6041
|
-
var _toRecord, _toRecord2;
|
|
6042
|
-
const source = nodeIdMap.get(edge.source);
|
|
6043
|
-
const target = nodeIdMap.get(edge.target);
|
|
6044
|
-
if (!source || !target) continue;
|
|
6045
|
-
const edgeContext = {};
|
|
6046
|
-
const edgeType = pickString(edge.type);
|
|
6047
|
-
if (edgeType) edgeContext.type = edgeType;
|
|
6048
|
-
const sourceHandle = pickString(edge.sourceHandle);
|
|
6049
|
-
if (sourceHandle) edgeContext.sourceHandle = sourceHandle;
|
|
6050
|
-
const targetHandle = pickString(edge.targetHandle);
|
|
6051
|
-
if (targetHandle) edgeContext.targetHandle = targetHandle;
|
|
6052
|
-
const edgeLabel = pickString(edge.label);
|
|
6053
|
-
if (edgeLabel) edgeContext.label = edgeLabel;
|
|
6054
|
-
const edgeStyleRecord = (_toRecord = toRecord(edge.style)) !== null && _toRecord !== void 0 ? _toRecord : {};
|
|
6055
|
-
const edgeStyle = {};
|
|
6056
|
-
const stroke = pickString(edgeStyleRecord.stroke);
|
|
6057
|
-
if (stroke) edgeStyle.stroke = stroke;
|
|
6058
|
-
if (typeof edgeStyleRecord.strokeWidth === "number") edgeStyle.strokeWidth = edgeStyleRecord.strokeWidth;
|
|
6059
|
-
const strokeStyle = parseStrokeStyle(edgeStyleRecord.strokeDasharray);
|
|
6060
|
-
if (strokeStyle) edgeStyle.strokeStyle = strokeStyle;
|
|
6061
|
-
if (typeof edge.animated === "boolean") edgeStyle.borderAnimationEnabled = edge.animated;
|
|
6062
|
-
if (Object.keys(edgeStyle).length > 0) edgeContext.style = edgeStyle;
|
|
6063
|
-
const markerStart = normalizeMarker(edge.markerStart);
|
|
6064
|
-
if (markerStart) edgeContext.markerStart = markerStart;
|
|
6065
|
-
const markerEnd = normalizeMarker(edge.markerEnd);
|
|
6066
|
-
if (markerEnd) edgeContext.markerEnd = markerEnd;
|
|
6067
|
-
const edgeData = (_toRecord2 = toRecord(edge.data)) !== null && _toRecord2 !== void 0 ? _toRecord2 : {};
|
|
6068
|
-
if (Object.keys(edgeData).length > 0) edgeContext.___internal = edgeData;
|
|
6069
|
-
if (Object.keys(edgeContext).length > 0) contextEdges[`${source}-${target}`] = edgeContext;
|
|
6070
|
-
}
|
|
6071
|
-
return contextEdges;
|
|
6072
6173
|
}
|
|
6073
|
-
function
|
|
6074
|
-
const
|
|
6075
|
-
|
|
6076
|
-
|
|
6077
|
-
|
|
6078
|
-
const
|
|
6079
|
-
|
|
6080
|
-
|
|
6081
|
-
|
|
6082
|
-
|
|
6083
|
-
|
|
6174
|
+
function resizeNodesLayouts(nodes) {
|
|
6175
|
+
const resizeRules = nodes.map((node) => {
|
|
6176
|
+
if (!node.type) return;
|
|
6177
|
+
const expectedSize = EXPECTED_NODE_SIZE[node.type];
|
|
6178
|
+
if (!expectedSize) return;
|
|
6179
|
+
const size = getNodeSize(node);
|
|
6180
|
+
return {
|
|
6181
|
+
startX: node.position.x + expectedSize.width,
|
|
6182
|
+
startY: node.position.y + expectedSize.height,
|
|
6183
|
+
deltaX: Math.max(0, size.width - expectedSize.width),
|
|
6184
|
+
deltaY: Math.max(0, size.height - expectedSize.height)
|
|
6084
6185
|
};
|
|
6085
|
-
}
|
|
6086
|
-
|
|
6087
|
-
|
|
6088
|
-
|
|
6089
|
-
|
|
6090
|
-
|
|
6091
|
-
|
|
6092
|
-
|
|
6093
|
-
|
|
6094
|
-
const
|
|
6095
|
-
|
|
6096
|
-
|
|
6097
|
-
|
|
6098
|
-
|
|
6099
|
-
|
|
6100
|
-
|
|
6101
|
-
|
|
6102
|
-
|
|
6103
|
-
|
|
6104
|
-
|
|
6105
|
-
|
|
6106
|
-
|
|
6107
|
-
|
|
6108
|
-
|
|
6109
|
-
|
|
6110
|
-
|
|
6111
|
-
const
|
|
6112
|
-
|
|
6113
|
-
|
|
6114
|
-
|
|
6186
|
+
}).filter((rule) => Boolean(rule));
|
|
6187
|
+
const resizedNodes = nodes.map((node) => {
|
|
6188
|
+
var _node$data;
|
|
6189
|
+
const childNodeIds = (_node$data = node.data) === null || _node$data === void 0 ? void 0 : _node$data.childNodes;
|
|
6190
|
+
if (Array.isArray(childNodeIds)) return _objectSpread2({}, node);
|
|
6191
|
+
const offsetX = resizeRules.reduce((total, rule) => {
|
|
6192
|
+
if (!rule || rule.deltaX === 0 || node.position.x < rule.startX) return total;
|
|
6193
|
+
return total + rule.deltaX;
|
|
6194
|
+
}, 0);
|
|
6195
|
+
const offsetY = resizeRules.reduce((total, rule) => {
|
|
6196
|
+
if (!rule || rule.deltaY === 0 || node.position.y < rule.startY) return total;
|
|
6197
|
+
return total + rule.deltaY;
|
|
6198
|
+
}, 0);
|
|
6199
|
+
if (offsetX === 0 && offsetY === 0) return node;
|
|
6200
|
+
return _objectSpread2(_objectSpread2({}, node), {}, { position: {
|
|
6201
|
+
x: node.position.x + offsetX,
|
|
6202
|
+
y: node.position.y + offsetY
|
|
6203
|
+
} });
|
|
6204
|
+
});
|
|
6205
|
+
const resizedNodesById = new Map(resizedNodes.map((node) => [node.id, node]));
|
|
6206
|
+
const rowNodes = resizedNodes.filter((node) => {
|
|
6207
|
+
var _node$data2;
|
|
6208
|
+
return !Array.isArray((_node$data2 = node.data) === null || _node$data2 === void 0 ? void 0 : _node$data2.childNodes);
|
|
6209
|
+
}).sort((a, b) => a.position.y === b.position.y ? a.position.x - b.position.x : a.position.y - b.position.y);
|
|
6210
|
+
const rows = [];
|
|
6211
|
+
for (const node of rowNodes) {
|
|
6212
|
+
const row = rows.find((currentRow) => Math.abs(currentRow[0].position.y - node.position.y) <= ROW_ALIGNMENT_TOLERANCE);
|
|
6213
|
+
if (row) {
|
|
6214
|
+
row.push(node);
|
|
6215
|
+
continue;
|
|
6115
6216
|
}
|
|
6116
|
-
|
|
6117
|
-
|
|
6118
|
-
|
|
6119
|
-
|
|
6120
|
-
|
|
6121
|
-
|
|
6122
|
-
|
|
6123
|
-
|
|
6124
|
-
|
|
6125
|
-
|
|
6126
|
-
|
|
6127
|
-
|
|
6128
|
-
|
|
6129
|
-
|
|
6130
|
-
|
|
6131
|
-
|
|
6132
|
-
if (typeof height === "number") style.height = height;
|
|
6133
|
-
const fill = (_pickString = pickString(nodeData.fill)) !== null && _pickString !== void 0 ? _pickString : pickString(nodeStyle.fill);
|
|
6134
|
-
if (fill) style.fill = fill;
|
|
6135
|
-
const stroke = (_pickString2 = pickString(nodeData.stroke)) !== null && _pickString2 !== void 0 ? _pickString2 : pickString(nodeStyle.stroke);
|
|
6136
|
-
if (stroke) style.stroke = stroke;
|
|
6137
|
-
const strokeWidth = typeof nodeData.strokeWidth === "number" ? nodeData.strokeWidth : typeof nodeStyle.strokeWidth === "number" ? nodeStyle.strokeWidth : void 0;
|
|
6138
|
-
if (typeof strokeWidth === "number") style.strokeWidth = strokeWidth;
|
|
6139
|
-
const borderRadius = typeof nodeData.borderRadius === "number" ? nodeData.borderRadius : typeof nodeStyle.borderRadius === "number" ? nodeStyle.borderRadius : void 0;
|
|
6140
|
-
if (typeof borderRadius === "number") style.borderRadius = borderRadius;
|
|
6141
|
-
const strokeStyleFromData = pickString(nodeData.strokeStyle);
|
|
6142
|
-
if (strokeStyleFromData === "solid" || strokeStyleFromData === "dashed" || strokeStyleFromData === "dotted") style.strokeStyle = strokeStyleFromData;
|
|
6143
|
-
else {
|
|
6144
|
-
const strokeStyleFromDash = parseStrokeStyle(nodeStyle.strokeDasharray);
|
|
6145
|
-
if (strokeStyleFromDash) style.strokeStyle = strokeStyleFromDash;
|
|
6217
|
+
rows.push([node]);
|
|
6218
|
+
}
|
|
6219
|
+
for (const row of rows) {
|
|
6220
|
+
row.sort((a, b) => a.position.x - b.position.x);
|
|
6221
|
+
for (let index = 1; index < row.length; index += 1) {
|
|
6222
|
+
const previousNode = row[index - 1];
|
|
6223
|
+
const currentNode = row[index];
|
|
6224
|
+
const previousNodeSize = getNodeSize(previousNode);
|
|
6225
|
+
const minimumX = previousNode.position.x + previousNodeSize.width + MIN_HORIZONTAL_GAP;
|
|
6226
|
+
if (currentNode.position.x >= minimumX) continue;
|
|
6227
|
+
const shiftedNode = _objectSpread2(_objectSpread2({}, currentNode), {}, { position: {
|
|
6228
|
+
x: minimumX,
|
|
6229
|
+
y: currentNode.position.y
|
|
6230
|
+
} });
|
|
6231
|
+
row[index] = shiftedNode;
|
|
6232
|
+
resizedNodesById.set(shiftedNode.id, shiftedNode);
|
|
6146
6233
|
}
|
|
6147
|
-
|
|
6148
|
-
|
|
6149
|
-
|
|
6150
|
-
const
|
|
6151
|
-
const
|
|
6152
|
-
if (
|
|
6153
|
-
|
|
6154
|
-
|
|
6155
|
-
|
|
6156
|
-
|
|
6157
|
-
|
|
6158
|
-
|
|
6159
|
-
|
|
6160
|
-
|
|
6161
|
-
|
|
6162
|
-
databaseName,
|
|
6163
|
-
tableName
|
|
6164
|
-
};
|
|
6165
|
-
const dynamicData = {};
|
|
6166
|
-
for (const field of componentFields) {
|
|
6167
|
-
const label$1 = pickString(field.label);
|
|
6168
|
-
const type = pickString(field.type);
|
|
6169
|
-
if (!label$1 || !type || !isComponentInputType(type)) continue;
|
|
6170
|
-
const componentType = type;
|
|
6171
|
-
const normalizedLabel = label$1.toLowerCase();
|
|
6172
|
-
if (normalizedLabel === "name") continue;
|
|
6173
|
-
if (nodeType === "text" && normalizedLabel === "text") continue;
|
|
6174
|
-
if (nodeType === "code" && normalizedLabel === "code") continue;
|
|
6175
|
-
const options = Array.isArray(field.options) ? field.options.filter((option) => typeof option === "string") : void 0;
|
|
6176
|
-
dynamicData[label$1] = {
|
|
6177
|
-
type: componentType,
|
|
6178
|
-
value: getFieldValue(field.data),
|
|
6179
|
-
options: options && options.length > 0 ? options : void 0
|
|
6234
|
+
}
|
|
6235
|
+
return resizedNodes.map((node) => {
|
|
6236
|
+
var _resizedNodesById$get, _node$data3;
|
|
6237
|
+
const shiftedNode = (_resizedNodesById$get = resizedNodesById.get(node.id)) !== null && _resizedNodesById$get !== void 0 ? _resizedNodesById$get : node;
|
|
6238
|
+
const childNodeIds = (_node$data3 = node.data) === null || _node$data3 === void 0 ? void 0 : _node$data3.childNodes;
|
|
6239
|
+
if (!Array.isArray(childNodeIds)) return shiftedNode;
|
|
6240
|
+
const childNodes = childNodeIds.map((childNodeId) => typeof childNodeId === "string" ? resizedNodesById.get(childNodeId) : void 0).filter((childNode) => Boolean(childNode));
|
|
6241
|
+
if (childNodes.length === 0) return shiftedNode;
|
|
6242
|
+
const bounds = childNodes.map((childNode) => {
|
|
6243
|
+
const size = getNodeSize(childNode);
|
|
6244
|
+
return {
|
|
6245
|
+
left: childNode.position.x,
|
|
6246
|
+
top: childNode.position.y,
|
|
6247
|
+
right: childNode.position.x + size.width,
|
|
6248
|
+
bottom: childNode.position.y + size.height
|
|
6180
6249
|
};
|
|
6181
|
-
}
|
|
6182
|
-
|
|
6183
|
-
|
|
6184
|
-
|
|
6185
|
-
|
|
6186
|
-
|
|
6187
|
-
|
|
6188
|
-
|
|
6189
|
-
|
|
6250
|
+
});
|
|
6251
|
+
const minX = Math.min(...bounds.map((bound) => bound.left));
|
|
6252
|
+
const minY = Math.min(...bounds.map((bound) => bound.top));
|
|
6253
|
+
const maxX = Math.max(...bounds.map((bound) => bound.right));
|
|
6254
|
+
const maxY = Math.max(...bounds.map((bound) => bound.bottom));
|
|
6255
|
+
return _objectSpread2(_objectSpread2({}, shiftedNode), {}, {
|
|
6256
|
+
position: {
|
|
6257
|
+
x: minX - GROUP_BOUND_PADDING,
|
|
6258
|
+
y: minY - GROUP_BOUND_PADDING
|
|
6259
|
+
},
|
|
6260
|
+
style: _objectSpread2(_objectSpread2({}, shiftedNode.style), {}, {
|
|
6261
|
+
width: maxX - minX + GROUP_BOUND_PADDING * 2 + GROUP_WIDTH_PADDING,
|
|
6262
|
+
height: maxY - minY + GROUP_BOUND_PADDING * 2 + GROUP_HEIGHT_PADDING
|
|
6263
|
+
})
|
|
6264
|
+
});
|
|
6265
|
+
});
|
|
6266
|
+
}
|
|
6267
|
+
function hasValidPosition(position) {
|
|
6268
|
+
if (!position) return false;
|
|
6269
|
+
return Number.isFinite(position.x) && Number.isFinite(position.y);
|
|
6270
|
+
}
|
|
6271
|
+
function normalizeContextMarker(marker) {
|
|
6272
|
+
if (!marker) return;
|
|
6273
|
+
const markerType = marker.type.trim().toLowerCase();
|
|
6274
|
+
let type;
|
|
6275
|
+
if (markerType === "arrow") type = __xyflow_react.MarkerType.Arrow;
|
|
6276
|
+
else if (markerType === "arrowclosed" || markerType === "arrow-closed" || markerType === "arrow_closed") type = __xyflow_react.MarkerType.ArrowClosed;
|
|
6277
|
+
if (!type) return;
|
|
6278
|
+
if (marker.color) return {
|
|
6279
|
+
type,
|
|
6280
|
+
color: marker.color
|
|
6281
|
+
};
|
|
6282
|
+
return { type };
|
|
6283
|
+
}
|
|
6284
|
+
function convertMermaidToReactFlowWithContext(_x4, _x5, _x6) {
|
|
6285
|
+
return _convertMermaidToReactFlowWithContext.apply(this, arguments);
|
|
6286
|
+
}
|
|
6287
|
+
function _convertMermaidToReactFlowWithContext() {
|
|
6288
|
+
_convertMermaidToReactFlowWithContext = _asyncToGenerator(function* (mermaidCode, context, options) {
|
|
6289
|
+
var _context$groups;
|
|
6290
|
+
const validatedContext = require_headless.contextSchema.parse(context);
|
|
6291
|
+
const reactFlowData = yield convertMermaidToReactFlow(mermaidCode);
|
|
6292
|
+
const rfNodesPromises = reactFlowData.nodes.map(function() {
|
|
6293
|
+
var _ref = _asyncToGenerator(function* (node) {
|
|
6294
|
+
var _validatedContext$nod, _clonedNode$data$comp, _ctx$data, _clonedNode$data, _ctx$style, _ctx$style2, _ctx$style3, _ctx$style4;
|
|
6295
|
+
const ctx = (_validatedContext$nod = validatedContext.nodes) === null || _validatedContext$nod === void 0 ? void 0 : _validatedContext$nod[node.id];
|
|
6296
|
+
if (!ctx) return node;
|
|
6297
|
+
const clonedNode = JSON.parse(JSON.stringify(node));
|
|
6298
|
+
const componentFields = (_clonedNode$data$comp = clonedNode.data.componentFields) !== null && _clonedNode$data$comp !== void 0 ? _clonedNode$data$comp : [];
|
|
6299
|
+
(_ctx$data = ctx.data) !== null && _ctx$data !== void 0 || (ctx.data = {});
|
|
6300
|
+
(_clonedNode$data = clonedNode.data) !== null && _clonedNode$data !== void 0 || (clonedNode.data = {});
|
|
6301
|
+
if (hasValidPosition(ctx.___position)) clonedNode.position = {
|
|
6302
|
+
x: ctx.___position.x,
|
|
6303
|
+
y: ctx.___position.y
|
|
6190
6304
|
};
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
|
|
6195
|
-
|
|
6196
|
-
|
|
6197
|
-
|
|
6198
|
-
|
|
6199
|
-
|
|
6200
|
-
|
|
6305
|
+
if (ctx.type) {
|
|
6306
|
+
clonedNode.type = ctx.type;
|
|
6307
|
+
delete clonedNode.style;
|
|
6308
|
+
if (ctx.type === "cloud") {
|
|
6309
|
+
clonedNode.height = 150;
|
|
6310
|
+
clonedNode.width = 150;
|
|
6311
|
+
if (ctx.service) {
|
|
6312
|
+
const cloudIcon = (options === null || options === void 0 ? void 0 : options.resolveCloudIcon) ? yield options.resolveCloudIcon(ctx.cloud, ctx.service) : yield resolveCloudIcon(ctx.cloud, ctx.service);
|
|
6313
|
+
if (cloudIcon) clonedNode.data.iconSrc = cloudIcon;
|
|
6314
|
+
}
|
|
6315
|
+
}
|
|
6316
|
+
if (ctx.type === "image" && ctx.src) clonedNode.data = _objectSpread2(_objectSpread2({}, clonedNode.data), {}, { src: ctx.src });
|
|
6317
|
+
if (ctx.type === "gif") {
|
|
6318
|
+
if (ctx.animatedIcon) {
|
|
6319
|
+
const animatedNodeSrc = yield resolveAnimatedNode(ctx.animatedIcon);
|
|
6320
|
+
if (animatedNodeSrc) clonedNode.data = _objectSpread2(_objectSpread2({}, clonedNode.data), {}, { src: animatedNodeSrc });
|
|
6321
|
+
} else if (ctx.src) clonedNode.data = _objectSpread2(_objectSpread2({}, clonedNode.data), {}, { src: ctx.src });
|
|
6322
|
+
}
|
|
6323
|
+
if (ctx.type === "text" && (ctx.value || ctx.name)) {
|
|
6324
|
+
const textComponentField = generateComponentFieldInput({
|
|
6325
|
+
type: require_component_type.ComponentInputType.TextInput,
|
|
6326
|
+
componentFieldId: "text",
|
|
6327
|
+
label: "Text",
|
|
6328
|
+
data: ctx.value || ctx.name,
|
|
6329
|
+
isReadonly: true
|
|
6330
|
+
});
|
|
6331
|
+
componentFields.unshift(textComponentField);
|
|
6332
|
+
}
|
|
6333
|
+
if (ctx.type === "code" && ctx.value) {
|
|
6334
|
+
const textComponentField = generateComponentFieldInput({
|
|
6335
|
+
type: require_component_type.ComponentInputType.CodeEditor,
|
|
6336
|
+
componentFieldId: "code",
|
|
6337
|
+
label: "Code",
|
|
6338
|
+
data: ctx.value,
|
|
6339
|
+
isReadonly: true
|
|
6340
|
+
});
|
|
6341
|
+
componentFields.unshift(textComponentField);
|
|
6342
|
+
}
|
|
6343
|
+
if (ctx.type === "table" && ctx.table) {
|
|
6344
|
+
var _ctx$table$rows, _ctx$table$columns;
|
|
6345
|
+
clonedNode.data.title = ctx.name;
|
|
6346
|
+
clonedNode.data.rows = (_ctx$table$rows = ctx.table.rows) !== null && _ctx$table$rows !== void 0 ? _ctx$table$rows : [];
|
|
6347
|
+
clonedNode.data.columns = (_ctx$table$columns = ctx.table.columns) !== null && _ctx$table$columns !== void 0 ? _ctx$table$columns : [];
|
|
6348
|
+
}
|
|
6349
|
+
if (ctx.type === "data-source" || ctx.type === "db-table") {
|
|
6350
|
+
ctx.type = "databaseTableSQL";
|
|
6351
|
+
clonedNode.type = "databaseTableSQL";
|
|
6352
|
+
}
|
|
6353
|
+
if (ctx.type === "component") {
|
|
6354
|
+
ctx.type = "builder";
|
|
6355
|
+
clonedNode.type = "builder";
|
|
6356
|
+
clonedNode.data.componentId = ctx.componentId;
|
|
6357
|
+
}
|
|
6358
|
+
if (ctx.type === "shape" && ctx.shape) {
|
|
6359
|
+
clonedNode.data.shape = ctx.shape;
|
|
6360
|
+
if (ctx.shape === "or" || ctx.shape === "summing-junction") {
|
|
6361
|
+
var _clonedNode$width, _clonedNode$height;
|
|
6362
|
+
const maxSize = Math.max((_clonedNode$width = clonedNode.width) !== null && _clonedNode$width !== void 0 ? _clonedNode$width : 0, (_clonedNode$height = clonedNode.height) !== null && _clonedNode$height !== void 0 ? _clonedNode$height : 0, 200);
|
|
6363
|
+
clonedNode.width = maxSize;
|
|
6364
|
+
clonedNode.height = maxSize;
|
|
6365
|
+
}
|
|
6366
|
+
}
|
|
6367
|
+
}
|
|
6368
|
+
if (ctx.name) ctx.data["Name"] = {
|
|
6369
|
+
type: require_component_type.ComponentInputType.TextInput,
|
|
6370
|
+
value: ctx.name
|
|
6201
6371
|
};
|
|
6202
|
-
|
|
6203
|
-
|
|
6204
|
-
|
|
6205
|
-
|
|
6206
|
-
|
|
6207
|
-
|
|
6208
|
-
|
|
6209
|
-
|
|
6210
|
-
|
|
6211
|
-
|
|
6372
|
+
for (const key in ctx.data) {
|
|
6373
|
+
const metaInput = ctx.data[key];
|
|
6374
|
+
if (metaInput === void 0) continue;
|
|
6375
|
+
const componentField = getComponentFieldByLabel(componentFields, key);
|
|
6376
|
+
const newComponentField = generateComponentFieldInput({
|
|
6377
|
+
label: key,
|
|
6378
|
+
type: metaInput.type,
|
|
6379
|
+
data: metaInput.value,
|
|
6380
|
+
options: metaInput.options
|
|
6381
|
+
});
|
|
6382
|
+
if (!componentField) componentFields.push(newComponentField);
|
|
6383
|
+
else {
|
|
6384
|
+
componentField.type = newComponentField.type;
|
|
6385
|
+
componentField.data = newComponentField.data;
|
|
6386
|
+
}
|
|
6387
|
+
}
|
|
6388
|
+
if (ctx.dbConfig) clonedNode.data.serviceTable = {
|
|
6389
|
+
serviceName: ctx.dbConfig.serviceName,
|
|
6390
|
+
databaseName: ctx.dbConfig.databaseName,
|
|
6391
|
+
tableName: ctx.dbConfig.tableName
|
|
6212
6392
|
};
|
|
6213
|
-
|
|
6214
|
-
|
|
6215
|
-
|
|
6216
|
-
|
|
6217
|
-
|
|
6218
|
-
|
|
6219
|
-
|
|
6220
|
-
|
|
6221
|
-
|
|
6222
|
-
|
|
6223
|
-
|
|
6224
|
-
|
|
6225
|
-
|
|
6226
|
-
|
|
6227
|
-
|
|
6228
|
-
|
|
6229
|
-
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
}
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
|
|
6238
|
-
|
|
6239
|
-
|
|
6240
|
-
|
|
6241
|
-
|
|
6242
|
-
|
|
6243
|
-
|
|
6393
|
+
if ((_ctx$style = ctx.style) === null || _ctx$style === void 0 ? void 0 : _ctx$style.height) clonedNode.height = ctx.style.height;
|
|
6394
|
+
if ((_ctx$style2 = ctx.style) === null || _ctx$style2 === void 0 ? void 0 : _ctx$style2.width) clonedNode.width = ctx.style.width;
|
|
6395
|
+
clonedNode.data = _objectSpread2(_objectSpread2(_objectSpread2({}, clonedNode.data), (0, daily_code.objectPick)((_ctx$style3 = ctx.style) !== null && _ctx$style3 !== void 0 ? _ctx$style3 : {}, [
|
|
6396
|
+
"color",
|
|
6397
|
+
"fill",
|
|
6398
|
+
"stroke",
|
|
6399
|
+
"strokeWidth",
|
|
6400
|
+
"strokeStyle",
|
|
6401
|
+
"borderRadius",
|
|
6402
|
+
"borderAnimationEnabled"
|
|
6403
|
+
])), {}, {
|
|
6404
|
+
componentFields,
|
|
6405
|
+
strokeAnimation: ((_ctx$style4 = ctx.style) === null || _ctx$style4 === void 0 ? void 0 : _ctx$style4.borderAnimationEnabled) ? "dash" : void 0
|
|
6406
|
+
}, ctx === null || ctx === void 0 ? void 0 : ctx.___internal);
|
|
6407
|
+
return clonedNode;
|
|
6408
|
+
});
|
|
6409
|
+
return function(_x) {
|
|
6410
|
+
return _ref.apply(this, arguments);
|
|
6411
|
+
};
|
|
6412
|
+
}());
|
|
6413
|
+
const resolvedNodes = yield Promise.all(rfNodesPromises);
|
|
6414
|
+
const groupNodes = Object.entries((_context$groups = context.groups) !== null && _context$groups !== void 0 ? _context$groups : {}).map(([nodeId, groupCtx]) => {
|
|
6415
|
+
var _groupCtx$nodes, _groupCtx$name;
|
|
6416
|
+
const childNodes = (0, daily_code.arrayNonNullable)(((_groupCtx$nodes = groupCtx.nodes) !== null && _groupCtx$nodes !== void 0 ? _groupCtx$nodes : []).map((nodeId$1) => resolvedNodes.find((n) => n.id === nodeId$1)));
|
|
6417
|
+
return generateGroupNodeFromNodes(nodeId, (_groupCtx$name = groupCtx.name) !== null && _groupCtx$name !== void 0 ? _groupCtx$name : "Group", childNodes);
|
|
6418
|
+
});
|
|
6419
|
+
const edgeOrdinals = /* @__PURE__ */ new Map();
|
|
6420
|
+
const edgeContextKeys = reactFlowData.edges.map((edge) => {
|
|
6421
|
+
var _edgeOrdinals$get;
|
|
6422
|
+
const pair = `${edge.source}-${edge.target}`;
|
|
6423
|
+
const ordinal = (_edgeOrdinals$get = edgeOrdinals.get(pair)) !== null && _edgeOrdinals$get !== void 0 ? _edgeOrdinals$get : 0;
|
|
6424
|
+
edgeOrdinals.set(pair, ordinal + 1);
|
|
6425
|
+
if (ordinal === 0) return {
|
|
6426
|
+
pair,
|
|
6427
|
+
key: pair
|
|
6428
|
+
};
|
|
6429
|
+
return {
|
|
6430
|
+
pair,
|
|
6431
|
+
key: `${pair}#${ordinal}`
|
|
6432
|
+
};
|
|
6433
|
+
});
|
|
6434
|
+
const rfEdgesPromises = reactFlowData.edges.map(function() {
|
|
6435
|
+
var _ref3 = _asyncToGenerator(function* (edge, index) {
|
|
6436
|
+
var _ref2, _validatedContext$edg, _validatedContext$edg2, _validatedContext$edg3, _ctx$type, _ctx$sourceHandle, _ctx$targetHandle, _normalizeContextMark, _normalizeContextMark2, _ctx$label, _ctx$style$borderAnim, _ctx$style5, _ctx$style$stroke, _ctx$style6, _edge$style, _ctx$style$strokeWidt, _ctx$style7, _edge$style2, _ctx$style8, _ctx$style9, _ctx$style10, _edge$style3;
|
|
6437
|
+
const { pair, key } = edgeContextKeys[index];
|
|
6438
|
+
const ctx = (_ref2 = (_validatedContext$edg = (_validatedContext$edg2 = validatedContext.edges) === null || _validatedContext$edg2 === void 0 ? void 0 : _validatedContext$edg2[key]) !== null && _validatedContext$edg !== void 0 ? _validatedContext$edg : (_validatedContext$edg3 = validatedContext.edges) === null || _validatedContext$edg3 === void 0 ? void 0 : _validatedContext$edg3[pair]) !== null && _ref2 !== void 0 ? _ref2 : null;
|
|
6439
|
+
if (!ctx) return edge;
|
|
6440
|
+
return _objectSpread2(_objectSpread2({}, edge), {}, {
|
|
6441
|
+
type: (_ctx$type = ctx.type) !== null && _ctx$type !== void 0 ? _ctx$type : edge.type,
|
|
6442
|
+
sourceHandle: (_ctx$sourceHandle = ctx.sourceHandle) !== null && _ctx$sourceHandle !== void 0 ? _ctx$sourceHandle : edge.sourceHandle,
|
|
6443
|
+
targetHandle: (_ctx$targetHandle = ctx.targetHandle) !== null && _ctx$targetHandle !== void 0 ? _ctx$targetHandle : edge.targetHandle,
|
|
6444
|
+
markerStart: (_normalizeContextMark = normalizeContextMarker(ctx.markerStart)) !== null && _normalizeContextMark !== void 0 ? _normalizeContextMark : edge.markerStart,
|
|
6445
|
+
markerEnd: (_normalizeContextMark2 = normalizeContextMarker(ctx.markerEnd)) !== null && _normalizeContextMark2 !== void 0 ? _normalizeContextMark2 : edge.markerEnd,
|
|
6446
|
+
data: _objectSpread2(_objectSpread2({}, edge.data), ctx === null || ctx === void 0 ? void 0 : ctx.___internal),
|
|
6447
|
+
label: (_ctx$label = ctx.label) !== null && _ctx$label !== void 0 ? _ctx$label : edge.label,
|
|
6448
|
+
animated: (_ctx$style$borderAnim = (_ctx$style5 = ctx.style) === null || _ctx$style5 === void 0 ? void 0 : _ctx$style5.borderAnimationEnabled) !== null && _ctx$style$borderAnim !== void 0 ? _ctx$style$borderAnim : edge.animated,
|
|
6449
|
+
style: _objectSpread2(_objectSpread2({}, edge.style), {}, {
|
|
6450
|
+
stroke: (_ctx$style$stroke = (_ctx$style6 = ctx.style) === null || _ctx$style6 === void 0 ? void 0 : _ctx$style6.stroke) !== null && _ctx$style$stroke !== void 0 ? _ctx$style$stroke : (_edge$style = edge.style) === null || _edge$style === void 0 ? void 0 : _edge$style.stroke,
|
|
6451
|
+
strokeWidth: (_ctx$style$strokeWidt = (_ctx$style7 = ctx.style) === null || _ctx$style7 === void 0 ? void 0 : _ctx$style7.strokeWidth) !== null && _ctx$style$strokeWidt !== void 0 ? _ctx$style$strokeWidt : (_edge$style2 = edge.style) === null || _edge$style2 === void 0 ? void 0 : _edge$style2.strokeWidth,
|
|
6452
|
+
strokeDasharray: ((_ctx$style8 = ctx.style) === null || _ctx$style8 === void 0 ? void 0 : _ctx$style8.strokeStyle) === "dashed" ? "4 2" : ((_ctx$style9 = ctx.style) === null || _ctx$style9 === void 0 ? void 0 : _ctx$style9.strokeStyle) === "dotted" ? "1 2" : ((_ctx$style10 = ctx.style) === null || _ctx$style10 === void 0 ? void 0 : _ctx$style10.strokeStyle) === "solid" ? void 0 : (_edge$style3 = edge.style) === null || _edge$style3 === void 0 ? void 0 : _edge$style3.strokeDasharray
|
|
6453
|
+
})
|
|
6454
|
+
});
|
|
6455
|
+
});
|
|
6456
|
+
return function(_x2, _x3) {
|
|
6457
|
+
return _ref3.apply(this, arguments);
|
|
6458
|
+
};
|
|
6459
|
+
}());
|
|
6460
|
+
const resolvedEdges = yield Promise.all(rfEdgesPromises);
|
|
6461
|
+
const combinedNodes = [...groupNodes, ...resolvedNodes.map((node) => {
|
|
6462
|
+
const nodeParent = groupNodes.find((groupNode) => {
|
|
6463
|
+
var _groupNode$data$child;
|
|
6464
|
+
return (_groupNode$data$child = groupNode.data.childNodes) === null || _groupNode$data$child === void 0 ? void 0 : _groupNode$data$child.includes(node.id);
|
|
6465
|
+
});
|
|
6466
|
+
if (nodeParent) return _objectSpread2(_objectSpread2({}, node), {}, { parentId: nodeParent.id });
|
|
6467
|
+
return node;
|
|
6468
|
+
})];
|
|
6469
|
+
if (isSequenceDiagram(combinedNodes)) return {
|
|
6470
|
+
edges: resolvedEdges,
|
|
6471
|
+
nodes: combinedNodes
|
|
6472
|
+
};
|
|
6473
|
+
if (isC4ReactFlowDiagram(combinedNodes)) return {
|
|
6474
|
+
edges: resolvedEdges,
|
|
6475
|
+
nodes: combinedNodes
|
|
6476
|
+
};
|
|
6477
|
+
return {
|
|
6478
|
+
edges: resolvedEdges,
|
|
6479
|
+
nodes: (options === null || options === void 0 ? void 0 : options.repositionNodes) ? resizeNodesLayouts(combinedNodes) : combinedNodes
|
|
6480
|
+
};
|
|
6481
|
+
});
|
|
6482
|
+
return _convertMermaidToReactFlowWithContext.apply(this, arguments);
|
|
6244
6483
|
}
|
|
6245
6484
|
function inferDirection(nodes, edges) {
|
|
6246
6485
|
const nodeMap = new Map(nodes.map((node) => [node.id, node]));
|
|
@@ -6295,8 +6534,8 @@ function buildNodeIdMap(graphNodes) {
|
|
|
6295
6534
|
}
|
|
6296
6535
|
function resolveMermaidNodeLabel(node) {
|
|
6297
6536
|
const nodeType = node.type;
|
|
6298
|
-
const nodeData = toRecord(node.data);
|
|
6299
|
-
const componentFields = Array.isArray(nodeData === null || nodeData === void 0 ? void 0 : nodeData.componentFields) ? nodeData.componentFields.map((field) => toRecord(field)).filter((field) => field !== void 0) : [];
|
|
6537
|
+
const nodeData$1 = toRecord(node.data);
|
|
6538
|
+
const componentFields = Array.isArray(nodeData$1 === null || nodeData$1 === void 0 ? void 0 : nodeData$1.componentFields) ? nodeData$1.componentFields.map((field) => toRecord(field)).filter((field) => field !== void 0) : [];
|
|
6300
6539
|
const name = getFieldString(componentFields, "Name");
|
|
6301
6540
|
if (nodeType === "text") return getFieldString(componentFields, "Text");
|
|
6302
6541
|
if (nodeType === "code") return getFieldString(componentFields, "Code");
|
|
@@ -6392,9 +6631,9 @@ function formatDetailValue(value) {
|
|
|
6392
6631
|
return entries.join(",");
|
|
6393
6632
|
}
|
|
6394
6633
|
}
|
|
6395
|
-
function getNodeName(nodeData, componentFields) {
|
|
6634
|
+
function getNodeName(nodeData$1, componentFields) {
|
|
6396
6635
|
var _getFieldString;
|
|
6397
|
-
return (_getFieldString = getFieldString(componentFields, "Name")) !== null && _getFieldString !== void 0 ? _getFieldString : pickString(nodeData === null || nodeData === void 0 ? void 0 : nodeData.name);
|
|
6636
|
+
return (_getFieldString = getFieldString(componentFields, "Name")) !== null && _getFieldString !== void 0 ? _getFieldString : pickString(nodeData$1 === null || nodeData$1 === void 0 ? void 0 : nodeData$1.name);
|
|
6398
6637
|
}
|
|
6399
6638
|
function buildFieldLines(componentFields, excludedLabels) {
|
|
6400
6639
|
const lines = [];
|
|
@@ -6426,25 +6665,25 @@ function buildDetailedLabel(lines) {
|
|
|
6426
6665
|
}
|
|
6427
6666
|
function resolveMermaidDetailedNodeLabel(node) {
|
|
6428
6667
|
const nodeType = pickString(node.type);
|
|
6429
|
-
const nodeData = toRecord(node.data);
|
|
6430
|
-
const componentFields = toComponentFields(nodeData === null || nodeData === void 0 ? void 0 : nodeData.componentFields);
|
|
6431
|
-
const name = getNodeName(nodeData, componentFields);
|
|
6668
|
+
const nodeData$1 = toRecord(node.data);
|
|
6669
|
+
const componentFields = toComponentFields(nodeData$1 === null || nodeData$1 === void 0 ? void 0 : nodeData$1.componentFields);
|
|
6670
|
+
const name = getNodeName(nodeData$1, componentFields);
|
|
6432
6671
|
if (nodeType === "text") {
|
|
6433
6672
|
var _getFieldString2;
|
|
6434
|
-
const text = (_getFieldString2 = getFieldString(componentFields, "Text")) !== null && _getFieldString2 !== void 0 ? _getFieldString2 : pickString(nodeData === null || nodeData === void 0 ? void 0 : nodeData.value);
|
|
6673
|
+
const text = (_getFieldString2 = getFieldString(componentFields, "Text")) !== null && _getFieldString2 !== void 0 ? _getFieldString2 : pickString(nodeData$1 === null || nodeData$1 === void 0 ? void 0 : nodeData$1.value);
|
|
6435
6674
|
return buildDetailedLabel([text ? `Text: ${text}` : "Text", ...buildFieldLines(componentFields, new Set(["name", "text"]))]);
|
|
6436
6675
|
}
|
|
6437
6676
|
if (nodeType === "code") {
|
|
6438
6677
|
var _getFieldString3, _code$split$;
|
|
6439
|
-
const code = (_getFieldString3 = getFieldString(componentFields, "Code")) !== null && _getFieldString3 !== void 0 ? _getFieldString3 : pickString(nodeData === null || nodeData === void 0 ? void 0 : nodeData.value);
|
|
6678
|
+
const code = (_getFieldString3 = getFieldString(componentFields, "Code")) !== null && _getFieldString3 !== void 0 ? _getFieldString3 : pickString(nodeData$1 === null || nodeData$1 === void 0 ? void 0 : nodeData$1.value);
|
|
6440
6679
|
const firstLine = code === null || code === void 0 || (_code$split$ = code.split(/\r?\n/)[0]) === null || _code$split$ === void 0 ? void 0 : _code$split$.trim();
|
|
6441
6680
|
return buildDetailedLabel([firstLine ? `Code: ${firstLine}` : "Code", ...buildFieldLines(componentFields, new Set(["name", "code"]))]);
|
|
6442
6681
|
}
|
|
6443
6682
|
if (nodeType === "data-source" || nodeType === "databaseTableSQL") {
|
|
6444
6683
|
var _pickString, _pickString2, _pickString3;
|
|
6445
6684
|
const lines = [];
|
|
6446
|
-
const serviceTable = toRecord(nodeData === null || nodeData === void 0 ? void 0 : nodeData.serviceTable);
|
|
6447
|
-
const dbConfig = toRecord(nodeData === null || nodeData === void 0 ? void 0 : nodeData.dbConfig);
|
|
6685
|
+
const serviceTable = toRecord(nodeData$1 === null || nodeData$1 === void 0 ? void 0 : nodeData$1.serviceTable);
|
|
6686
|
+
const dbConfig = toRecord(nodeData$1 === null || nodeData$1 === void 0 ? void 0 : nodeData$1.dbConfig);
|
|
6448
6687
|
const database = (_pickString = pickString(serviceTable === null || serviceTable === void 0 ? void 0 : serviceTable.databaseName)) !== null && _pickString !== void 0 ? _pickString : pickString(dbConfig === null || dbConfig === void 0 ? void 0 : dbConfig.databaseName);
|
|
6449
6688
|
const tableName = (_pickString2 = pickString(serviceTable === null || serviceTable === void 0 ? void 0 : serviceTable.tableName)) !== null && _pickString2 !== void 0 ? _pickString2 : pickString(dbConfig === null || dbConfig === void 0 ? void 0 : dbConfig.tableName);
|
|
6450
6689
|
const dbService = (_pickString3 = pickString(serviceTable === null || serviceTable === void 0 ? void 0 : serviceTable.serviceName)) !== null && _pickString3 !== void 0 ? _pickString3 : pickString(dbConfig === null || dbConfig === void 0 ? void 0 : dbConfig.serviceName);
|
|
@@ -6458,9 +6697,9 @@ function resolveMermaidDetailedNodeLabel(node) {
|
|
|
6458
6697
|
if (nodeType === "cloud") {
|
|
6459
6698
|
const lines = [];
|
|
6460
6699
|
lines.push(name ? `Cloud: ${name}` : "Cloud");
|
|
6461
|
-
const cloud = pickString(nodeData === null || nodeData === void 0 ? void 0 : nodeData.cloud);
|
|
6700
|
+
const cloud = pickString(nodeData$1 === null || nodeData$1 === void 0 ? void 0 : nodeData$1.cloud);
|
|
6462
6701
|
if (cloud) lines.push(`provider: ${cloud}`);
|
|
6463
|
-
const service = pickString(nodeData === null || nodeData === void 0 ? void 0 : nodeData.service);
|
|
6702
|
+
const service = pickString(nodeData$1 === null || nodeData$1 === void 0 ? void 0 : nodeData$1.service);
|
|
6464
6703
|
if (service) lines.push(`service: ${service}`);
|
|
6465
6704
|
lines.push(...buildFieldLines(componentFields, new Set(["name"])));
|
|
6466
6705
|
return buildDetailedLabel(lines);
|
|
@@ -6468,11 +6707,11 @@ function resolveMermaidDetailedNodeLabel(node) {
|
|
|
6468
6707
|
if (nodeType === "table" || nodeType === "dataTableInterface") {
|
|
6469
6708
|
var _pickString4;
|
|
6470
6709
|
const lines = [];
|
|
6471
|
-
const table = toRecord(nodeData === null || nodeData === void 0 ? void 0 : nodeData.table);
|
|
6710
|
+
const table = toRecord(nodeData$1 === null || nodeData$1 === void 0 ? void 0 : nodeData$1.table);
|
|
6472
6711
|
const tableName = (_pickString4 = pickString(table === null || table === void 0 ? void 0 : table.name)) !== null && _pickString4 !== void 0 ? _pickString4 : name;
|
|
6473
6712
|
lines.push(tableName ? `Table: ${tableName}` : "Table");
|
|
6474
|
-
const columns = Array.isArray(nodeData === null || nodeData === void 0 ? void 0 : nodeData.columns) ? nodeData.columns.filter((value) => typeof value === "string").length : Array.isArray(table === null || table === void 0 ? void 0 : table.columns) ? table.columns.length : 0;
|
|
6475
|
-
const rows = Array.isArray(nodeData === null || nodeData === void 0 ? void 0 : nodeData.rows) ? nodeData.rows.filter((value) => Array.isArray(value)).length : Array.isArray(table === null || table === void 0 ? void 0 : table.rows) ? table.rows.length : 0;
|
|
6713
|
+
const columns = Array.isArray(nodeData$1 === null || nodeData$1 === void 0 ? void 0 : nodeData$1.columns) ? nodeData$1.columns.filter((value) => typeof value === "string").length : Array.isArray(table === null || table === void 0 ? void 0 : table.columns) ? table.columns.length : 0;
|
|
6714
|
+
const rows = Array.isArray(nodeData$1 === null || nodeData$1 === void 0 ? void 0 : nodeData$1.rows) ? nodeData$1.rows.filter((value) => Array.isArray(value)).length : Array.isArray(table === null || table === void 0 ? void 0 : table.rows) ? table.rows.length : 0;
|
|
6476
6715
|
lines.push(`columns: ${columns}`);
|
|
6477
6716
|
lines.push(`rows: ${rows}`);
|
|
6478
6717
|
lines.push(...buildFieldLines(componentFields, new Set(["name"])));
|
|
@@ -6485,7 +6724,7 @@ function resolveMermaidDetailedNodeLabel(node) {
|
|
|
6485
6724
|
return;
|
|
6486
6725
|
}
|
|
6487
6726
|
if (nodeType === "gif") {
|
|
6488
|
-
const src = pickString(nodeData === null || nodeData === void 0 ? void 0 : nodeData.src);
|
|
6727
|
+
const src = pickString(nodeData$1 === null || nodeData$1 === void 0 ? void 0 : nodeData$1.src);
|
|
6489
6728
|
return buildDetailedLabel([
|
|
6490
6729
|
name ? `Gif: ${name}` : src ? `Gif: ${src}` : "Gif",
|
|
6491
6730
|
...src ? [`src: ${src}`] : [],
|
|
@@ -6493,7 +6732,7 @@ function resolveMermaidDetailedNodeLabel(node) {
|
|
|
6493
6732
|
]);
|
|
6494
6733
|
}
|
|
6495
6734
|
if (nodeType === "image") {
|
|
6496
|
-
const src = pickString(nodeData === null || nodeData === void 0 ? void 0 : nodeData.src);
|
|
6735
|
+
const src = pickString(nodeData$1 === null || nodeData$1 === void 0 ? void 0 : nodeData$1.src);
|
|
6497
6736
|
return buildDetailedLabel([
|
|
6498
6737
|
name ? `Image: ${name}` : src ? `Image: ${src}` : "Image",
|
|
6499
6738
|
...src ? [`src: ${src}`] : [],
|
|
@@ -6501,7 +6740,7 @@ function resolveMermaidDetailedNodeLabel(node) {
|
|
|
6501
6740
|
]);
|
|
6502
6741
|
}
|
|
6503
6742
|
if (nodeType === "group") {
|
|
6504
|
-
const childCount = Array.isArray(nodeData === null || nodeData === void 0 ? void 0 : nodeData.childNodes) ? nodeData.childNodes.length : 0;
|
|
6743
|
+
const childCount = Array.isArray(nodeData$1 === null || nodeData$1 === void 0 ? void 0 : nodeData$1.childNodes) ? nodeData$1.childNodes.length : 0;
|
|
6505
6744
|
return buildDetailedLabel([
|
|
6506
6745
|
name ? `Group: ${name}` : "Group",
|
|
6507
6746
|
`children: ${childCount}`,
|
|
@@ -6510,10 +6749,10 @@ function resolveMermaidDetailedNodeLabel(node) {
|
|
|
6510
6749
|
}
|
|
6511
6750
|
if (nodeType === "sequenceParticipant") {
|
|
6512
6751
|
var _getFieldString4;
|
|
6513
|
-
const label = (_getFieldString4 = getFieldString(componentFields, "Label")) !== null && _getFieldString4 !== void 0 ? _getFieldString4 : pickString(nodeData === null || nodeData === void 0 ? void 0 : nodeData.label);
|
|
6752
|
+
const label = (_getFieldString4 = getFieldString(componentFields, "Label")) !== null && _getFieldString4 !== void 0 ? _getFieldString4 : pickString(nodeData$1 === null || nodeData$1 === void 0 ? void 0 : nodeData$1.label);
|
|
6514
6753
|
const participantName = name !== null && name !== void 0 ? name : label;
|
|
6515
|
-
const rowCount = typeof (nodeData === null || nodeData === void 0 ? void 0 : nodeData.rowCount) === "number" ? nodeData.rowCount : void 0;
|
|
6516
|
-
const color = pickString(nodeData === null || nodeData === void 0 ? void 0 : nodeData.color);
|
|
6754
|
+
const rowCount = typeof (nodeData$1 === null || nodeData$1 === void 0 ? void 0 : nodeData$1.rowCount) === "number" ? nodeData$1.rowCount : void 0;
|
|
6755
|
+
const color = pickString(nodeData$1 === null || nodeData$1 === void 0 ? void 0 : nodeData$1.color);
|
|
6517
6756
|
return buildDetailedLabel([
|
|
6518
6757
|
participantName ? `SequenceParticipant: ${participantName}` : "SequenceParticipant",
|
|
6519
6758
|
...typeof rowCount === "number" ? [`rows: ${rowCount}`] : [],
|
|
@@ -6521,9 +6760,9 @@ function resolveMermaidDetailedNodeLabel(node) {
|
|
|
6521
6760
|
...buildFieldLines(componentFields, new Set(["name", "label"]))
|
|
6522
6761
|
]);
|
|
6523
6762
|
}
|
|
6524
|
-
if (nodeType === "comment") return buildDetailedLabel([`Comment: ${(typeof (nodeData === null || nodeData === void 0 ? void 0 : nodeData.isResolved) === "boolean" ? nodeData.isResolved : void 0) ? "Resolved" : "Open"}`, ...buildFieldLines(componentFields, new Set(["name"]))]);
|
|
6763
|
+
if (nodeType === "comment") return buildDetailedLabel([`Comment: ${(typeof (nodeData$1 === null || nodeData$1 === void 0 ? void 0 : nodeData$1.isResolved) === "boolean" ? nodeData$1.isResolved : void 0) ? "Resolved" : "Open"}`, ...buildFieldLines(componentFields, new Set(["name"]))]);
|
|
6525
6764
|
if (nodeType === "builder") {
|
|
6526
|
-
const componentId = pickString(nodeData === null || nodeData === void 0 ? void 0 : nodeData.componentId);
|
|
6765
|
+
const componentId = pickString(nodeData$1 === null || nodeData$1 === void 0 ? void 0 : nodeData$1.componentId);
|
|
6527
6766
|
return buildDetailedLabel([
|
|
6528
6767
|
name ? `Builder: ${name}` : "Builder",
|
|
6529
6768
|
...componentId ? [`componentId: ${componentId}`] : [],
|
|
@@ -6540,7 +6779,7 @@ function resolveMermaidDetailedNodeLabel(node) {
|
|
|
6540
6779
|
])));
|
|
6541
6780
|
return buildDetailedLabel(lines);
|
|
6542
6781
|
}
|
|
6543
|
-
const fallbackLabel = pickString(nodeData === null || nodeData === void 0 ? void 0 : nodeData.label);
|
|
6782
|
+
const fallbackLabel = pickString(nodeData$1 === null || nodeData$1 === void 0 ? void 0 : nodeData$1.label);
|
|
6544
6783
|
if (fallbackLabel) return `${nodeType ? nodeType.charAt(0).toUpperCase() + nodeType.slice(1) : "Node"}: ${fallbackLabel}`;
|
|
6545
6784
|
}
|
|
6546
6785
|
function escapeMermaidEdgeLabelText(value) {
|
|
@@ -6631,7 +6870,10 @@ exports.convertMermaidToReactFlow = convertMermaidToReactFlow;
|
|
|
6631
6870
|
exports.convertMermaidToReactFlowWithContext = convertMermaidToReactFlowWithContext;
|
|
6632
6871
|
exports.convertMongoSchemaToAst = convertMongoSchemaToAst;
|
|
6633
6872
|
exports.convertNoSQLToAst = convertNoSQLToAst;
|
|
6873
|
+
exports.convertReactFlowToC4Mermaid = convertReactFlowToC4Mermaid;
|
|
6874
|
+
exports.convertReactFlowToC4UiGraph = convertReactFlowToC4UiGraph;
|
|
6634
6875
|
exports.convertReactFlowToSequenceMermaid = convertReactFlowToSequenceMermaid;
|
|
6876
|
+
exports.convertReactFlowToSequenceUiGraph = convertReactFlowToSequenceUiGraph;
|
|
6635
6877
|
exports.convertUiGraphToMermaid = convertUiGraphToMermaid;
|
|
6636
6878
|
exports.estimateSequenceMessageBoxSize = estimateSequenceMessageBoxSize;
|
|
6637
6879
|
exports.flattenMetaData = flattenMetaData;
|
|
@@ -6639,6 +6881,7 @@ exports.generateTableNodeId = generateTableNodeId;
|
|
|
6639
6881
|
exports.generateUUID = generateUUID;
|
|
6640
6882
|
exports.getC4ElementColors = getC4ElementColors;
|
|
6641
6883
|
exports.isC4Diagram = isC4Diagram;
|
|
6884
|
+
exports.isC4ReactFlowDiagram = isC4ReactFlowDiagram;
|
|
6642
6885
|
exports.isSequenceDiagram = isSequenceDiagram;
|
|
6643
6886
|
exports.parseC4Diagram = parseC4Diagram;
|
|
6644
6887
|
exports.sanitizeMermaidLabels = sanitizeMermaidLabels;
|