@uigraph/sdk 1.2.6 → 1.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +987 -951
- package/dist/index.d.cts +15 -14
- package/dist/index.d.mts +15 -14
- package/dist/index.mjs +987 -952
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -5217,1023 +5217,1058 @@ function sanitizeMermaidLabels(src) {
|
|
|
5217
5217
|
const second = allStarts[1];
|
|
5218
5218
|
return subgraphFixed.slice(first, second).trim();
|
|
5219
5219
|
}
|
|
5220
|
-
|
|
5221
|
-
|
|
5220
|
+
const CONTEXT_SHAPES = new Set([
|
|
5221
|
+
"rectangle",
|
|
5222
|
+
"rounded-rect",
|
|
5223
|
+
"ellipse",
|
|
5224
|
+
"diamond",
|
|
5225
|
+
"triangle",
|
|
5226
|
+
"parallelogram",
|
|
5227
|
+
"trapezoid",
|
|
5228
|
+
"hexagon",
|
|
5229
|
+
"document",
|
|
5230
|
+
"cylinder",
|
|
5231
|
+
"delay",
|
|
5232
|
+
"off-page-connector",
|
|
5233
|
+
"display",
|
|
5234
|
+
"collate",
|
|
5235
|
+
"sort",
|
|
5236
|
+
"terminator",
|
|
5237
|
+
"or",
|
|
5238
|
+
"database",
|
|
5239
|
+
"multiple-documents",
|
|
5240
|
+
"subroutine",
|
|
5241
|
+
"manual-input",
|
|
5242
|
+
"summing-junction",
|
|
5243
|
+
"internal-storage"
|
|
5244
|
+
]);
|
|
5245
|
+
const COMPONENT_INPUT_TYPES = new Set(Object.values(ComponentInputType));
|
|
5246
|
+
const INLINE_MERMAID_LABEL_MAX_LENGTH = 32;
|
|
5247
|
+
const KNOWN_NODE_DATA_KEYS = new Set([
|
|
5248
|
+
"componentFields",
|
|
5249
|
+
"shape",
|
|
5250
|
+
"fill",
|
|
5251
|
+
"stroke",
|
|
5252
|
+
"strokeWidth",
|
|
5253
|
+
"strokeStyle",
|
|
5254
|
+
"borderRadius",
|
|
5255
|
+
"borderAnimationEnabled",
|
|
5256
|
+
"strokeAnimation",
|
|
5257
|
+
"src",
|
|
5258
|
+
"animatedIcon",
|
|
5259
|
+
"iconSrc",
|
|
5260
|
+
"componentId",
|
|
5261
|
+
"serviceTable",
|
|
5262
|
+
"title",
|
|
5263
|
+
"columns",
|
|
5264
|
+
"rows",
|
|
5265
|
+
"name",
|
|
5266
|
+
"label",
|
|
5267
|
+
"value",
|
|
5268
|
+
"cloud",
|
|
5269
|
+
"service",
|
|
5270
|
+
"childNodes"
|
|
5271
|
+
]);
|
|
5272
|
+
function isComponentInputType(value) {
|
|
5273
|
+
return COMPONENT_INPUT_TYPES.has(value);
|
|
5222
5274
|
}
|
|
5223
|
-
function
|
|
5224
|
-
|
|
5225
|
-
const fields = (_node$data = node.data) === null || _node$data === void 0 ? void 0 : _node$data.componentFields;
|
|
5226
|
-
if (!Array.isArray(fields)) return void 0;
|
|
5227
|
-
const field = fields.find((candidate) => (candidate === null || candidate === void 0 ? void 0 : candidate.componentFieldId) === componentFieldId);
|
|
5228
|
-
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;
|
|
5229
|
-
if (typeof value !== "string") return void 0;
|
|
5230
|
-
if (!value.trim()) return void 0;
|
|
5275
|
+
function toRecord(value) {
|
|
5276
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return;
|
|
5231
5277
|
return value;
|
|
5232
5278
|
}
|
|
5233
|
-
function
|
|
5234
|
-
|
|
5235
|
-
const
|
|
5236
|
-
if (
|
|
5237
|
-
|
|
5238
|
-
if (typeof label === "string") return label;
|
|
5239
|
-
return "";
|
|
5279
|
+
function pickString(value) {
|
|
5280
|
+
if (typeof value !== "string") return;
|
|
5281
|
+
const trimmed = value.trim();
|
|
5282
|
+
if (!trimmed) return;
|
|
5283
|
+
return trimmed;
|
|
5240
5284
|
}
|
|
5241
|
-
function
|
|
5242
|
-
|
|
5285
|
+
function pickPosition(value) {
|
|
5286
|
+
const position = toRecord(value);
|
|
5287
|
+
if (!position) return;
|
|
5288
|
+
if (typeof position.x !== "number" || !Number.isFinite(position.x)) return;
|
|
5289
|
+
if (typeof position.y !== "number" || !Number.isFinite(position.y)) return;
|
|
5290
|
+
return {
|
|
5291
|
+
x: position.x,
|
|
5292
|
+
y: position.y
|
|
5293
|
+
};
|
|
5243
5294
|
}
|
|
5244
|
-
function
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
suffix++;
|
|
5251
|
-
}
|
|
5252
|
-
used.add(candidate);
|
|
5253
|
-
return candidate;
|
|
5295
|
+
function getFieldValue(fieldData) {
|
|
5296
|
+
if (!Array.isArray(fieldData) || fieldData.length !== 1) return fieldData;
|
|
5297
|
+
const first = toRecord(fieldData[0]);
|
|
5298
|
+
if (!first) return fieldData;
|
|
5299
|
+
if (!("value" in first)) return first;
|
|
5300
|
+
return first.value;
|
|
5254
5301
|
}
|
|
5255
|
-
function
|
|
5256
|
-
|
|
5257
|
-
|
|
5258
|
-
|
|
5259
|
-
const name = nodeLabel(node) || `Participant ${index + 1}`;
|
|
5260
|
-
const rawType = (_node$data3 = node.data) === null || _node$data3 === void 0 ? void 0 : _node$data3.participantType;
|
|
5261
|
-
const activations = (_node$data4 = node.data) === null || _node$data4 === void 0 ? void 0 : _node$data4.activations;
|
|
5262
|
-
const links = (_node$data5 = node.data) === null || _node$data5 === void 0 ? void 0 : _node$data5.links;
|
|
5263
|
-
const createdRow = (_node$data6 = node.data) === null || _node$data6 === void 0 ? void 0 : _node$data6.lifelineStartRow;
|
|
5264
|
-
const destroyedRow = (_node$data7 = node.data) === null || _node$data7 === void 0 ? void 0 : _node$data7.lifelineEndRow;
|
|
5265
|
-
return _objectSpread2(_objectSpread2(_objectSpread2({
|
|
5266
|
-
nodeId: node.id,
|
|
5267
|
-
mermaidId: toMermaidId(name, index, used),
|
|
5268
|
-
name,
|
|
5269
|
-
type: typeof rawType === "string" ? rawType : "participant",
|
|
5270
|
-
links: Array.isArray(links) ? links : [],
|
|
5271
|
-
activations: Array.isArray(activations) ? activations : []
|
|
5272
|
-
}, typeof createdRow === "number" ? { createdRow } : {}), typeof destroyedRow === "number" ? { destroyedRow } : {}), {}, { x: node.position.x });
|
|
5302
|
+
function getFieldByLabel(fields, label) {
|
|
5303
|
+
return fields.find((field) => {
|
|
5304
|
+
var _pickString;
|
|
5305
|
+
return ((_pickString = pickString(field.label)) === null || _pickString === void 0 ? void 0 : _pickString.toLowerCase()) === label.toLowerCase() && pickString(field.type);
|
|
5273
5306
|
});
|
|
5274
5307
|
}
|
|
5275
|
-
function
|
|
5276
|
-
const
|
|
5277
|
-
|
|
5278
|
-
|
|
5279
|
-
if (participantNodeIds.has(edge.target)) links.set(edge.source, _objectSpread2(_objectSpread2({}, links.get(edge.source)), {}, { to: edge.target }));
|
|
5280
|
-
}
|
|
5281
|
-
return links;
|
|
5308
|
+
function getFieldString(fields, label) {
|
|
5309
|
+
const field = getFieldByLabel(fields, label);
|
|
5310
|
+
if (!field) return;
|
|
5311
|
+
return pickString(getFieldValue(field.data));
|
|
5282
5312
|
}
|
|
5283
|
-
function
|
|
5284
|
-
|
|
5285
|
-
|
|
5286
|
-
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;
|
|
5287
|
-
const reversed = (edgeFrom === null || edgeFrom === void 0 || (_edgeFrom$data3 = edgeFrom.data) === null || _edgeFrom$data3 === void 0 ? void 0 : _edgeFrom$data3.reversed) === true;
|
|
5288
|
-
return findArrowTokenFor(_objectSpread2(_objectSpread2({
|
|
5289
|
-
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",
|
|
5290
|
-
arrowType: arrowType !== null && arrowType !== void 0 ? arrowType : "filled"
|
|
5291
|
-
}, half ? { half } : {}), {}, { reversed }));
|
|
5313
|
+
function isEmptyFieldValue(value) {
|
|
5314
|
+
if (typeof value === "string") return value.trim().length === 0;
|
|
5315
|
+
return value === void 0 || value === null;
|
|
5292
5316
|
}
|
|
5293
|
-
function
|
|
5294
|
-
|
|
5295
|
-
|
|
5296
|
-
if (
|
|
5297
|
-
|
|
5298
|
-
return
|
|
5317
|
+
function parseStrokeStyle(dashArray) {
|
|
5318
|
+
if (typeof dashArray !== "string" || !dashArray.trim()) return;
|
|
5319
|
+
const normalized = dashArray.replaceAll(",", " ").replace(/\s+/g, " ").trim();
|
|
5320
|
+
if (normalized === "1 2") return "dotted";
|
|
5321
|
+
if (normalized === "4 2" || normalized === "4 4" || normalized === "8 4") return "dashed";
|
|
5322
|
+
return "solid";
|
|
5299
5323
|
}
|
|
5300
|
-
function
|
|
5301
|
-
|
|
5302
|
-
const
|
|
5303
|
-
|
|
5304
|
-
|
|
5305
|
-
|
|
5306
|
-
|
|
5307
|
-
|
|
5308
|
-
|
|
5309
|
-
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
kind: "note",
|
|
5313
|
-
nodeId: node.id,
|
|
5314
|
-
text: nodeLabel(node),
|
|
5315
|
-
placement: (_note$placement = note.placement) !== null && _note$placement !== void 0 ? _note$placement : "over",
|
|
5316
|
-
participantNodeIds: noteParticipantNodeIds(note, participants, node)
|
|
5317
|
-
},
|
|
5318
|
-
y: node.position.y
|
|
5319
|
-
});
|
|
5320
|
-
continue;
|
|
5321
|
-
}
|
|
5322
|
-
const link = links.get(node.id);
|
|
5323
|
-
if (!(link === null || link === void 0 ? void 0 : link.from) || !link.to) continue;
|
|
5324
|
-
const edgeFrom = edges.find((edge) => edge.target === node.id && edge.source === link.from);
|
|
5325
|
-
const edgeTo = edges.find((edge) => edge.source === node.id && edge.target === link.to);
|
|
5326
|
-
const sequenceNumber = (_node$data9 = node.data) === null || _node$data9 === void 0 ? void 0 : _node$data9.sequenceNumber;
|
|
5327
|
-
items.push({
|
|
5328
|
-
item: _objectSpread2({
|
|
5329
|
-
kind: "message",
|
|
5330
|
-
nodeId: node.id,
|
|
5331
|
-
fromNodeId: link.from,
|
|
5332
|
-
toNodeId: link.to,
|
|
5333
|
-
label: nodeLabel(node),
|
|
5334
|
-
token: arrowTokenOf(edgeFrom, edgeTo),
|
|
5335
|
-
centralSource: (edgeFrom === null || edgeFrom === void 0 || (_edgeFrom$data4 = edgeFrom.data) === null || _edgeFrom$data4 === void 0 ? void 0 : _edgeFrom$data4.centralSource) === true,
|
|
5336
|
-
centralTarget: (edgeTo === null || edgeTo === void 0 || (_edgeTo$data3 = edgeTo.data) === null || _edgeTo$data3 === void 0 ? void 0 : _edgeTo$data3.centralTarget) === true
|
|
5337
|
-
}, typeof sequenceNumber === "number" ? { sequenceNumber } : {}),
|
|
5338
|
-
y: node.position.y
|
|
5339
|
-
});
|
|
5340
|
-
}
|
|
5341
|
-
return items.sort((a, b) => a.y - b.y).map((entry) => entry.item);
|
|
5324
|
+
function normalizeMarker(marker) {
|
|
5325
|
+
if (typeof marker === "string") return { type: marker };
|
|
5326
|
+
const markerRecord = toRecord(marker);
|
|
5327
|
+
if (!markerRecord) return;
|
|
5328
|
+
const type = pickString(markerRecord.type);
|
|
5329
|
+
if (!type) return;
|
|
5330
|
+
const color = pickString(markerRecord.color);
|
|
5331
|
+
if (color) return {
|
|
5332
|
+
type,
|
|
5333
|
+
color
|
|
5334
|
+
};
|
|
5335
|
+
return { type };
|
|
5342
5336
|
}
|
|
5343
|
-
function
|
|
5344
|
-
|
|
5345
|
-
for (const node of nodes) {
|
|
5346
|
-
var _node$data10, _block$type, _block$label, _block$depth, _block$sections;
|
|
5347
|
-
const block = (_node$data10 = node.data) === null || _node$data10 === void 0 ? void 0 : _node$data10.sequenceBlock;
|
|
5348
|
-
if (!block) continue;
|
|
5349
|
-
if (typeof block.startRow !== "number") continue;
|
|
5350
|
-
if (typeof block.endRow !== "number") continue;
|
|
5351
|
-
blocks.push(_objectSpread2(_objectSpread2({
|
|
5352
|
-
type: (_block$type = block.type) !== null && _block$type !== void 0 ? _block$type : "rect",
|
|
5353
|
-
label: (_block$label = block.label) !== null && _block$label !== void 0 ? _block$label : ""
|
|
5354
|
-
}, block.color ? { color: block.color } : {}), {}, {
|
|
5355
|
-
depth: (_block$depth = block.depth) !== null && _block$depth !== void 0 ? _block$depth : 0,
|
|
5356
|
-
startRow: block.startRow,
|
|
5357
|
-
endRow: block.endRow,
|
|
5358
|
-
sections: ((_block$sections = block.sections) !== null && _block$sections !== void 0 ? _block$sections : []).filter((section) => typeof section.startRow === "number" && typeof section.endRow === "number").map((section) => {
|
|
5359
|
-
var _section$label;
|
|
5360
|
-
return {
|
|
5361
|
-
label: (_section$label = section.label) !== null && _section$label !== void 0 ? _section$label : "",
|
|
5362
|
-
startRow: section.startRow,
|
|
5363
|
-
endRow: section.endRow
|
|
5364
|
-
};
|
|
5365
|
-
})
|
|
5366
|
-
}));
|
|
5367
|
-
}
|
|
5368
|
-
return blocks;
|
|
5337
|
+
function escapeMermaidText(value) {
|
|
5338
|
+
return value.replaceAll("\"", "\\\"");
|
|
5369
5339
|
}
|
|
5370
|
-
function
|
|
5371
|
-
|
|
5372
|
-
|
|
5373
|
-
|
|
5374
|
-
const box = (_node$data11 = node.data) === null || _node$data11 === void 0 ? void 0 : _node$data11.sequenceBox;
|
|
5375
|
-
if (!box) continue;
|
|
5376
|
-
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));
|
|
5377
|
-
const left = node.position.x;
|
|
5378
|
-
const right = node.position.x + (Number(node.width) || 0);
|
|
5379
|
-
const contained = byImportedId.length > 0 ? byImportedId : participants.filter((participant) => participant.x >= left && participant.x <= right);
|
|
5380
|
-
if (contained.length === 0) continue;
|
|
5381
|
-
const backgroundColor = (_node$data12 = node.data) === null || _node$data12 === void 0 ? void 0 : _node$data12.backgroundColor;
|
|
5382
|
-
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) }));
|
|
5383
|
-
}
|
|
5384
|
-
return boxes;
|
|
5340
|
+
function canInlineMermaidLabel(value) {
|
|
5341
|
+
if (value.length > INLINE_MERMAID_LABEL_MAX_LENGTH) return false;
|
|
5342
|
+
if (value.includes("\n") || value.includes("\r")) return false;
|
|
5343
|
+
return true;
|
|
5385
5344
|
}
|
|
5386
|
-
function
|
|
5387
|
-
|
|
5388
|
-
const alias = participant.mermaidId === participant.name ? "" : ` as ${encodeLabel(participant.name)}`;
|
|
5389
|
-
return `${keyword} ${participant.mermaidId}${stereotype}${alias}`;
|
|
5345
|
+
function normalizeDetailedMermaidLabel(value) {
|
|
5346
|
+
return value.split(/\r?\n/).map((line) => line.replace(/\s+/g, " ").trim()).filter((line) => line.length > 0).join("\n");
|
|
5390
5347
|
}
|
|
5391
|
-
function
|
|
5392
|
-
|
|
5393
|
-
|
|
5394
|
-
|
|
5395
|
-
|
|
5396
|
-
const
|
|
5397
|
-
const
|
|
5398
|
-
|
|
5399
|
-
|
|
5400
|
-
|
|
5401
|
-
|
|
5402
|
-
const
|
|
5403
|
-
|
|
5404
|
-
|
|
5405
|
-
|
|
5406
|
-
|
|
5407
|
-
|
|
5408
|
-
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
const
|
|
5412
|
-
|
|
5348
|
+
function toComponentFields(value) {
|
|
5349
|
+
if (!Array.isArray(value)) return [];
|
|
5350
|
+
return value.map((field) => toRecord(field)).filter((field) => field !== void 0);
|
|
5351
|
+
}
|
|
5352
|
+
function buildContextEdges(edges, nodeIdMap) {
|
|
5353
|
+
const contextEdges = {};
|
|
5354
|
+
for (const edge of edges) {
|
|
5355
|
+
var _toRecord, _toRecord2;
|
|
5356
|
+
const source = nodeIdMap.get(edge.source);
|
|
5357
|
+
const target = nodeIdMap.get(edge.target);
|
|
5358
|
+
if (!source || !target) continue;
|
|
5359
|
+
const edgeContext = {};
|
|
5360
|
+
const edgeType = pickString(edge.type);
|
|
5361
|
+
if (edgeType) edgeContext.type = edgeType;
|
|
5362
|
+
const sourceHandle = pickString(edge.sourceHandle);
|
|
5363
|
+
if (sourceHandle) edgeContext.sourceHandle = sourceHandle;
|
|
5364
|
+
const targetHandle = pickString(edge.targetHandle);
|
|
5365
|
+
if (targetHandle) edgeContext.targetHandle = targetHandle;
|
|
5366
|
+
const edgeLabel = pickString(edge.label);
|
|
5367
|
+
if (edgeLabel) edgeContext.label = edgeLabel;
|
|
5368
|
+
const edgeStyleRecord = (_toRecord = toRecord(edge.style)) !== null && _toRecord !== void 0 ? _toRecord : {};
|
|
5369
|
+
const edgeStyle = {};
|
|
5370
|
+
const stroke = pickString(edgeStyleRecord.stroke);
|
|
5371
|
+
if (stroke) edgeStyle.stroke = stroke;
|
|
5372
|
+
if (typeof edgeStyleRecord.strokeWidth === "number") edgeStyle.strokeWidth = edgeStyleRecord.strokeWidth;
|
|
5373
|
+
const strokeStyle = parseStrokeStyle(edgeStyleRecord.strokeDasharray);
|
|
5374
|
+
if (strokeStyle) edgeStyle.strokeStyle = strokeStyle;
|
|
5375
|
+
if (typeof edge.animated === "boolean") edgeStyle.borderAnimationEnabled = edge.animated;
|
|
5376
|
+
if (Object.keys(edgeStyle).length > 0) edgeContext.style = edgeStyle;
|
|
5377
|
+
const markerStart = normalizeMarker(edge.markerStart);
|
|
5378
|
+
if (markerStart) edgeContext.markerStart = markerStart;
|
|
5379
|
+
const markerEnd = normalizeMarker(edge.markerEnd);
|
|
5380
|
+
if (markerEnd) edgeContext.markerEnd = markerEnd;
|
|
5381
|
+
const edgeData = (_toRecord2 = toRecord(edge.data)) !== null && _toRecord2 !== void 0 ? _toRecord2 : {};
|
|
5382
|
+
if (Object.keys(edgeData).length > 0) edgeContext.___internal = edgeData;
|
|
5383
|
+
if (Object.keys(edgeContext).length > 0) contextEdges[`${source}-${target}`] = edgeContext;
|
|
5413
5384
|
}
|
|
5414
|
-
|
|
5415
|
-
|
|
5416
|
-
|
|
5417
|
-
|
|
5418
|
-
|
|
5419
|
-
|
|
5420
|
-
|
|
5421
|
-
|
|
5385
|
+
return contextEdges;
|
|
5386
|
+
}
|
|
5387
|
+
function buildContextGroups(groupNodes, nodeIdMap) {
|
|
5388
|
+
const contextGroups = {};
|
|
5389
|
+
for (const groupNode of groupNodes) {
|
|
5390
|
+
var _toRecord;
|
|
5391
|
+
const groupData = (_toRecord = toRecord(groupNode.data)) !== null && _toRecord !== void 0 ? _toRecord : {};
|
|
5392
|
+
const childNodes = Array.isArray(groupData.childNodes) ? groupData.childNodes.map((childId) => typeof childId === "string" ? nodeIdMap.get(childId) : void 0).filter((childId) => childId !== void 0) : [];
|
|
5393
|
+
const name = getFieldString(Array.isArray(groupData.componentFields) ? groupData.componentFields.map((field) => toRecord(field)).filter((field) => field !== void 0) : [], "Name");
|
|
5394
|
+
if (!name && childNodes.length === 0) continue;
|
|
5395
|
+
contextGroups[groupNode.id] = {
|
|
5396
|
+
name: name !== null && name !== void 0 ? name : void 0,
|
|
5397
|
+
nodes: childNodes
|
|
5398
|
+
};
|
|
5422
5399
|
}
|
|
5423
|
-
|
|
5424
|
-
|
|
5425
|
-
|
|
5426
|
-
|
|
5427
|
-
|
|
5428
|
-
|
|
5400
|
+
return contextGroups;
|
|
5401
|
+
}
|
|
5402
|
+
function buildContextNodes(graphNodes, nodeIdMap) {
|
|
5403
|
+
const contextNodes = {};
|
|
5404
|
+
for (const node of graphNodes) {
|
|
5405
|
+
var _toRecord, _toRecord2, _pickString, _pickString2;
|
|
5406
|
+
const mappedNodeId = nodeIdMap.get(node.id);
|
|
5407
|
+
if (!mappedNodeId) continue;
|
|
5408
|
+
const nodeData = (_toRecord = toRecord(node.data)) !== null && _toRecord !== void 0 ? _toRecord : {};
|
|
5409
|
+
const nodeStyle = (_toRecord2 = toRecord(node.style)) !== null && _toRecord2 !== void 0 ? _toRecord2 : {};
|
|
5410
|
+
const componentFields = Array.isArray(nodeData.componentFields) ? nodeData.componentFields.map((field) => toRecord(field)).filter((field) => field !== void 0) : [];
|
|
5411
|
+
const nodeContext = {};
|
|
5412
|
+
const nodeType = pickString(node.type);
|
|
5413
|
+
if (nodeType) nodeContext.type = nodeType;
|
|
5414
|
+
const nameField = getFieldByLabel(componentFields, "Name");
|
|
5415
|
+
const nameRawValue = nameField ? getFieldValue(nameField.data) : void 0;
|
|
5416
|
+
const name = pickString(nameRawValue);
|
|
5417
|
+
if (name) nodeContext.name = name;
|
|
5418
|
+
const textField = nodeType === "text" ? getFieldByLabel(componentFields, "Text") : void 0;
|
|
5419
|
+
const textRawValue = textField ? getFieldValue(textField.data) : void 0;
|
|
5420
|
+
const textValue = pickString(textRawValue);
|
|
5421
|
+
if (nodeType === "text") {
|
|
5422
|
+
if (textValue) nodeContext.value = textValue;
|
|
5429
5423
|
}
|
|
5430
|
-
|
|
5431
|
-
|
|
5432
|
-
|
|
5424
|
+
const codeField = nodeType === "code" ? getFieldByLabel(componentFields, "Code") : void 0;
|
|
5425
|
+
const codeRawValue = codeField ? getFieldValue(codeField.data) : void 0;
|
|
5426
|
+
const codeValue = pickString(codeRawValue);
|
|
5427
|
+
if (nodeType === "code") {
|
|
5428
|
+
if (codeValue) nodeContext.value = codeValue;
|
|
5433
5429
|
}
|
|
5434
|
-
const
|
|
5435
|
-
|
|
5436
|
-
|
|
5437
|
-
|
|
5438
|
-
|
|
5439
|
-
|
|
5440
|
-
const
|
|
5441
|
-
|
|
5442
|
-
|
|
5443
|
-
|
|
5444
|
-
|
|
5445
|
-
|
|
5446
|
-
|
|
5447
|
-
|
|
5448
|
-
|
|
5449
|
-
const
|
|
5450
|
-
|
|
5451
|
-
|
|
5452
|
-
|
|
5453
|
-
|
|
5454
|
-
|
|
5430
|
+
const src = pickString(nodeData.src);
|
|
5431
|
+
if (src) nodeContext.src = src;
|
|
5432
|
+
const animatedIcon = pickString(nodeData.animatedIcon);
|
|
5433
|
+
if (animatedIcon) nodeContext.animatedIcon = animatedIcon;
|
|
5434
|
+
const cloud = pickString(nodeData.cloud);
|
|
5435
|
+
if (cloud) nodeContext.cloud = cloud;
|
|
5436
|
+
const service = pickString(nodeData.service);
|
|
5437
|
+
if (service) nodeContext.service = service;
|
|
5438
|
+
const componentId = pickString(nodeData.componentId);
|
|
5439
|
+
if (componentId) nodeContext.componentId = componentId;
|
|
5440
|
+
const shape = pickString(nodeData.shape);
|
|
5441
|
+
if (shape && CONTEXT_SHAPES.has(shape)) nodeContext.shape = shape;
|
|
5442
|
+
const style = {};
|
|
5443
|
+
const width = typeof node.width === "number" ? node.width : typeof nodeStyle.width === "number" ? nodeStyle.width : void 0;
|
|
5444
|
+
if (typeof width === "number") style.width = width;
|
|
5445
|
+
const height = typeof node.height === "number" ? node.height : typeof nodeStyle.height === "number" ? nodeStyle.height : void 0;
|
|
5446
|
+
if (typeof height === "number") style.height = height;
|
|
5447
|
+
const fill = (_pickString = pickString(nodeData.fill)) !== null && _pickString !== void 0 ? _pickString : pickString(nodeStyle.fill);
|
|
5448
|
+
if (fill) style.fill = fill;
|
|
5449
|
+
const stroke = (_pickString2 = pickString(nodeData.stroke)) !== null && _pickString2 !== void 0 ? _pickString2 : pickString(nodeStyle.stroke);
|
|
5450
|
+
if (stroke) style.stroke = stroke;
|
|
5451
|
+
const strokeWidth = typeof nodeData.strokeWidth === "number" ? nodeData.strokeWidth : typeof nodeStyle.strokeWidth === "number" ? nodeStyle.strokeWidth : void 0;
|
|
5452
|
+
if (typeof strokeWidth === "number") style.strokeWidth = strokeWidth;
|
|
5453
|
+
const borderRadius = typeof nodeData.borderRadius === "number" ? nodeData.borderRadius : typeof nodeStyle.borderRadius === "number" ? nodeStyle.borderRadius : void 0;
|
|
5454
|
+
if (typeof borderRadius === "number") style.borderRadius = borderRadius;
|
|
5455
|
+
const strokeStyleFromData = pickString(nodeData.strokeStyle);
|
|
5456
|
+
if (strokeStyleFromData === "solid" || strokeStyleFromData === "dashed" || strokeStyleFromData === "dotted") style.strokeStyle = strokeStyleFromData;
|
|
5457
|
+
else {
|
|
5458
|
+
const strokeStyleFromDash = parseStrokeStyle(nodeStyle.strokeDasharray);
|
|
5459
|
+
if (strokeStyleFromDash) style.strokeStyle = strokeStyleFromDash;
|
|
5455
5460
|
}
|
|
5456
|
-
|
|
5457
|
-
|
|
5458
|
-
|
|
5459
|
-
|
|
5461
|
+
const borderAnimationEnabled = typeof nodeData.borderAnimationEnabled === "boolean" ? nodeData.borderAnimationEnabled : nodeData.strokeAnimation === "dash" ? true : void 0;
|
|
5462
|
+
if (typeof borderAnimationEnabled === "boolean") style.borderAnimationEnabled = borderAnimationEnabled;
|
|
5463
|
+
if (Object.keys(style).length > 0) nodeContext.style = style;
|
|
5464
|
+
const tableColumns = Array.isArray(nodeData.columns) ? nodeData.columns.filter((value) => typeof value === "string") : void 0;
|
|
5465
|
+
const tableRows = Array.isArray(nodeData.rows) ? nodeData.rows.map((row) => Array.isArray(row) ? row.filter((value) => typeof value === "string") : void 0).filter((row) => row !== void 0) : void 0;
|
|
5466
|
+
if (tableColumns || tableRows) nodeContext.table = {
|
|
5467
|
+
columns: tableColumns !== null && tableColumns !== void 0 ? tableColumns : [],
|
|
5468
|
+
rows: tableRows !== null && tableRows !== void 0 ? tableRows : []
|
|
5469
|
+
};
|
|
5470
|
+
const serviceTable = toRecord(nodeData.serviceTable);
|
|
5471
|
+
const serviceName = pickString(serviceTable === null || serviceTable === void 0 ? void 0 : serviceTable.serviceName);
|
|
5472
|
+
const databaseName = pickString(serviceTable === null || serviceTable === void 0 ? void 0 : serviceTable.databaseName);
|
|
5473
|
+
const tableName = pickString(serviceTable === null || serviceTable === void 0 ? void 0 : serviceTable.tableName);
|
|
5474
|
+
if (serviceName && databaseName && tableName) nodeContext.dbConfig = {
|
|
5475
|
+
serviceName,
|
|
5476
|
+
databaseName,
|
|
5477
|
+
tableName
|
|
5478
|
+
};
|
|
5479
|
+
const dynamicData = {};
|
|
5480
|
+
for (const field of componentFields) {
|
|
5481
|
+
const label$1 = pickString(field.label);
|
|
5482
|
+
const type = pickString(field.type);
|
|
5483
|
+
if (!label$1 || !type || !isComponentInputType(type)) continue;
|
|
5484
|
+
const componentType = type;
|
|
5485
|
+
const normalizedLabel = label$1.toLowerCase();
|
|
5486
|
+
if (normalizedLabel === "name") continue;
|
|
5487
|
+
if (nodeType === "text" && normalizedLabel === "text") continue;
|
|
5488
|
+
if (nodeType === "code" && normalizedLabel === "code") continue;
|
|
5489
|
+
const options = Array.isArray(field.options) ? field.options.filter((option) => typeof option === "string") : void 0;
|
|
5490
|
+
dynamicData[label$1] = {
|
|
5491
|
+
type: componentType,
|
|
5492
|
+
value: getFieldValue(field.data),
|
|
5493
|
+
options: options && options.length > 0 ? options : void 0
|
|
5494
|
+
};
|
|
5460
5495
|
}
|
|
5461
|
-
|
|
5462
|
-
|
|
5463
|
-
|
|
5464
|
-
|
|
5465
|
-
|
|
5466
|
-
|
|
5467
|
-
|
|
5468
|
-
|
|
5469
|
-
|
|
5470
|
-
lines.push(`${indent()}destroy ${participant.mermaidId}`);
|
|
5471
|
-
}
|
|
5472
|
-
for (const participant of participants) for (const activation of participant.activations) {
|
|
5473
|
-
if (activation.startRow !== currentRow) continue;
|
|
5474
|
-
lines.push(`${indent()}activate ${participant.mermaidId}`);
|
|
5475
|
-
}
|
|
5476
|
-
if (item.kind === "message") {
|
|
5477
|
-
const from = participantByNodeId.get(item.fromNodeId);
|
|
5478
|
-
const to = participantByNodeId.get(item.toNodeId);
|
|
5479
|
-
if (from && to) {
|
|
5480
|
-
const source = item.centralSource ? `${from.mermaidId}()` : from.mermaidId;
|
|
5481
|
-
const target = item.centralTarget ? `()${to.mermaidId}` : to.mermaidId;
|
|
5482
|
-
lines.push(`${indent()}${source}${item.token}${target}: ${encodeLabel(item.label)}`);
|
|
5483
|
-
}
|
|
5484
|
-
}
|
|
5485
|
-
if (item.kind === "note") {
|
|
5486
|
-
const names = item.participantNodeIds.map((nodeId) => {
|
|
5487
|
-
var _participantByNodeId$;
|
|
5488
|
-
return (_participantByNodeId$ = participantByNodeId.get(nodeId)) === null || _participantByNodeId$ === void 0 ? void 0 : _participantByNodeId$.mermaidId;
|
|
5489
|
-
}).filter((id) => id !== void 0);
|
|
5490
|
-
if (names.length > 0) lines.push(`${indent()}Note ${item.placement} ${names.join(",")}: ${encodeLabel(item.text)}`);
|
|
5496
|
+
if (nameField && !name && isEmptyFieldValue(nameRawValue)) {
|
|
5497
|
+
const nameType = pickString(nameField.type);
|
|
5498
|
+
if (nameType && isComponentInputType(nameType)) {
|
|
5499
|
+
const nameOptions = Array.isArray(nameField.options) ? nameField.options.filter((option) => typeof option === "string") : void 0;
|
|
5500
|
+
dynamicData.Name = {
|
|
5501
|
+
type: nameType,
|
|
5502
|
+
value: "",
|
|
5503
|
+
options: nameOptions && nameOptions.length > 0 ? nameOptions : void 0
|
|
5504
|
+
};
|
|
5491
5505
|
}
|
|
5492
5506
|
}
|
|
5493
|
-
|
|
5494
|
-
|
|
5495
|
-
if (
|
|
5496
|
-
|
|
5507
|
+
if (textField && !textValue && isEmptyFieldValue(textRawValue)) {
|
|
5508
|
+
const textType = pickString(textField.type);
|
|
5509
|
+
if (textType && isComponentInputType(textType)) {
|
|
5510
|
+
const textOptions = Array.isArray(textField.options) ? textField.options.filter((option) => typeof option === "string") : void 0;
|
|
5511
|
+
dynamicData.Text = {
|
|
5512
|
+
type: textType,
|
|
5513
|
+
value: "",
|
|
5514
|
+
options: textOptions && textOptions.length > 0 ? textOptions : void 0
|
|
5515
|
+
};
|
|
5516
|
+
}
|
|
5497
5517
|
}
|
|
5498
|
-
|
|
5499
|
-
|
|
5500
|
-
|
|
5518
|
+
if (codeField && !codeValue && isEmptyFieldValue(codeRawValue)) {
|
|
5519
|
+
const codeType = pickString(codeField.type);
|
|
5520
|
+
if (codeType && isComponentInputType(codeType)) {
|
|
5521
|
+
const codeOptions = Array.isArray(codeField.options) ? codeField.options.filter((option) => typeof option === "string") : void 0;
|
|
5522
|
+
dynamicData.Code = {
|
|
5523
|
+
type: codeType,
|
|
5524
|
+
value: "",
|
|
5525
|
+
options: codeOptions && codeOptions.length > 0 ? codeOptions : void 0
|
|
5526
|
+
};
|
|
5527
|
+
}
|
|
5501
5528
|
}
|
|
5529
|
+
if (Object.keys(dynamicData).length > 0) nodeContext.data = dynamicData;
|
|
5530
|
+
const position = pickPosition(node.position);
|
|
5531
|
+
if (position) nodeContext.___position = position;
|
|
5532
|
+
const internalData = Object.entries(nodeData).reduce((acc, [key, value]) => {
|
|
5533
|
+
if (KNOWN_NODE_DATA_KEYS.has(key)) return acc;
|
|
5534
|
+
acc[key] = value;
|
|
5535
|
+
return acc;
|
|
5536
|
+
}, {});
|
|
5537
|
+
if (nodeType === "builder" && Array.isArray(nodeData.componentFields)) internalData.componentFields = nodeData.componentFields;
|
|
5538
|
+
const iconSrc = pickString(nodeData.iconSrc);
|
|
5539
|
+
if (iconSrc) internalData.iconSrc = iconSrc;
|
|
5540
|
+
const label = pickString(nodeData.label);
|
|
5541
|
+
if (label) internalData.label = label;
|
|
5542
|
+
const internalCloud = pickString(nodeData.cloud);
|
|
5543
|
+
if (internalCloud) internalData.cloud = internalCloud;
|
|
5544
|
+
if (Object.keys(internalData).length > 0) nodeContext.___internal = internalData;
|
|
5545
|
+
if (Object.keys(nodeContext).length > 0) contextNodes[mappedNodeId] = nodeContext;
|
|
5502
5546
|
}
|
|
5503
|
-
|
|
5504
|
-
openBlocks.pop();
|
|
5505
|
-
lines.push(`${indent()}end`);
|
|
5506
|
-
}
|
|
5507
|
-
return lines.join("\n");
|
|
5547
|
+
return contextNodes;
|
|
5508
5548
|
}
|
|
5509
|
-
|
|
5510
|
-
|
|
5511
|
-
|
|
5512
|
-
|
|
5513
|
-
|
|
5514
|
-
|
|
5515
|
-
|
|
5516
|
-
|
|
5517
|
-
|
|
5518
|
-
},
|
|
5519
|
-
data: {
|
|
5520
|
-
childNodes: options.nodes,
|
|
5521
|
-
autoLayout: true,
|
|
5522
|
-
componentFields: [generateComponentFieldNameInput((_options$name = options.name) !== null && _options$name !== void 0 ? _options$name : "Group")]
|
|
5523
|
-
},
|
|
5524
|
-
style: {
|
|
5525
|
-
width: options.bounds.width + 20,
|
|
5526
|
-
height: options.bounds.height + 50
|
|
5527
|
-
}
|
|
5528
|
-
};
|
|
5549
|
+
function buildValidatedContext(graphNodes, edges, groupNodes, nodeIdMap) {
|
|
5550
|
+
const contextNodes = buildContextNodes(graphNodes, nodeIdMap);
|
|
5551
|
+
const contextEdges = buildContextEdges(edges, nodeIdMap);
|
|
5552
|
+
const contextGroups = buildContextGroups(groupNodes, nodeIdMap);
|
|
5553
|
+
const context = {};
|
|
5554
|
+
if (Object.keys(contextNodes).length > 0) context.nodes = contextNodes;
|
|
5555
|
+
if (Object.keys(contextEdges).length > 0) context.edges = contextEdges;
|
|
5556
|
+
if (Object.keys(contextGroups).length > 0) context.groups = contextGroups;
|
|
5557
|
+
return contextSchema.parse(context);
|
|
5529
5558
|
}
|
|
5530
|
-
function
|
|
5531
|
-
|
|
5532
|
-
var _ref, _ref2, _node$height, _node$style, _node$measured, _ref3, _ref4, _node$width, _node$style2, _node$measured2;
|
|
5533
|
-
return {
|
|
5534
|
-
top: node.position.y,
|
|
5535
|
-
left: node.position.x,
|
|
5536
|
-
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),
|
|
5537
|
-
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)
|
|
5538
|
-
};
|
|
5539
|
-
});
|
|
5540
|
-
const minX = Math.min(...bounds.map((b) => b.left));
|
|
5541
|
-
const minY = Math.min(...bounds.map((b) => b.top));
|
|
5542
|
-
const maxX = Math.max(...bounds.map((b) => b.right));
|
|
5543
|
-
const maxY = Math.max(...bounds.map((b) => b.bottom));
|
|
5544
|
-
return createGroupNode({
|
|
5545
|
-
id,
|
|
5546
|
-
name,
|
|
5547
|
-
nodes: nodes.map((node) => node.id),
|
|
5548
|
-
bounds: {
|
|
5549
|
-
x: minX - BOUND_PADDING,
|
|
5550
|
-
y: minY - BOUND_PADDING,
|
|
5551
|
-
width: maxX - minX + BOUND_PADDING * 2,
|
|
5552
|
-
height: maxY - minY + BOUND_PADDING * 2
|
|
5553
|
-
}
|
|
5554
|
-
});
|
|
5559
|
+
function isSequenceDiagram(nodes) {
|
|
5560
|
+
return nodes.some((node) => node.type === "sequenceParticipant");
|
|
5555
5561
|
}
|
|
5556
|
-
function
|
|
5557
|
-
|
|
5562
|
+
function fieldValue(node, componentFieldId) {
|
|
5563
|
+
var _node$data, _field$data;
|
|
5564
|
+
const fields = (_node$data = node.data) === null || _node$data === void 0 ? void 0 : _node$data.componentFields;
|
|
5565
|
+
if (!Array.isArray(fields)) return void 0;
|
|
5566
|
+
const field = fields.find((candidate) => (candidate === null || candidate === void 0 ? void 0 : candidate.componentFieldId) === componentFieldId);
|
|
5567
|
+
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;
|
|
5568
|
+
if (typeof value !== "string") return void 0;
|
|
5569
|
+
if (!value.trim()) return void 0;
|
|
5570
|
+
return value;
|
|
5558
5571
|
}
|
|
5559
|
-
function
|
|
5560
|
-
|
|
5561
|
-
|
|
5562
|
-
|
|
5563
|
-
|
|
5564
|
-
|
|
5565
|
-
|
|
5566
|
-
return _resolveCloudIcon.apply(this, arguments);
|
|
5572
|
+
function nodeLabel(node) {
|
|
5573
|
+
var _node$data2;
|
|
5574
|
+
const fromField = fieldValue(node, "name");
|
|
5575
|
+
if (fromField !== void 0) return fromField;
|
|
5576
|
+
const label = (_node$data2 = node.data) === null || _node$data2 === void 0 ? void 0 : _node$data2.label;
|
|
5577
|
+
if (typeof label === "string") return label;
|
|
5578
|
+
return "";
|
|
5567
5579
|
}
|
|
5568
|
-
function
|
|
5569
|
-
return
|
|
5580
|
+
function encodeLabel(text) {
|
|
5581
|
+
return text.replace(/#/g, "#").replace(/\r\n?/g, "\n").replace(/\n/g, "<br/>").trim();
|
|
5570
5582
|
}
|
|
5571
|
-
function
|
|
5572
|
-
|
|
5573
|
-
|
|
5574
|
-
|
|
5575
|
-
|
|
5583
|
+
function toMermaidId(name, index, used) {
|
|
5584
|
+
const base = name.replace(/[^A-Za-z0-9_]/g, "") || `P${index}`;
|
|
5585
|
+
let candidate = base;
|
|
5586
|
+
let suffix = 2;
|
|
5587
|
+
while (used.has(candidate)) {
|
|
5588
|
+
candidate = `${base}_${suffix}`;
|
|
5589
|
+
suffix++;
|
|
5590
|
+
}
|
|
5591
|
+
used.add(candidate);
|
|
5592
|
+
return candidate;
|
|
5593
|
+
}
|
|
5594
|
+
function collectParticipants(nodes) {
|
|
5595
|
+
const used = /* @__PURE__ */ new Set();
|
|
5596
|
+
return nodes.filter((node) => node.type === "sequenceParticipant").sort((a, b) => a.position.x - b.position.x).map((node, index) => {
|
|
5597
|
+
var _node$data3, _node$data4, _node$data5, _node$data6, _node$data7;
|
|
5598
|
+
const name = nodeLabel(node) || `Participant ${index + 1}`;
|
|
5599
|
+
const rawType = (_node$data3 = node.data) === null || _node$data3 === void 0 ? void 0 : _node$data3.participantType;
|
|
5600
|
+
const activations = (_node$data4 = node.data) === null || _node$data4 === void 0 ? void 0 : _node$data4.activations;
|
|
5601
|
+
const links = (_node$data5 = node.data) === null || _node$data5 === void 0 ? void 0 : _node$data5.links;
|
|
5602
|
+
const createdRow = (_node$data6 = node.data) === null || _node$data6 === void 0 ? void 0 : _node$data6.lifelineStartRow;
|
|
5603
|
+
const destroyedRow = (_node$data7 = node.data) === null || _node$data7 === void 0 ? void 0 : _node$data7.lifelineEndRow;
|
|
5604
|
+
return _objectSpread2(_objectSpread2(_objectSpread2({
|
|
5605
|
+
nodeId: node.id,
|
|
5606
|
+
mermaidId: toMermaidId(name, index, used),
|
|
5607
|
+
name,
|
|
5608
|
+
type: typeof rawType === "string" ? rawType : "participant",
|
|
5609
|
+
links: Array.isArray(links) ? links : [],
|
|
5610
|
+
activations: Array.isArray(activations) ? activations : []
|
|
5611
|
+
}, typeof createdRow === "number" ? { createdRow } : {}), typeof destroyedRow === "number" ? { destroyedRow } : {}), {}, { x: node.position.x });
|
|
5576
5612
|
});
|
|
5577
|
-
return _resolveAnimatedNode.apply(this, arguments);
|
|
5578
5613
|
}
|
|
5579
|
-
|
|
5580
|
-
|
|
5581
|
-
|
|
5582
|
-
|
|
5583
|
-
|
|
5584
|
-
table: {
|
|
5585
|
-
width: 600,
|
|
5586
|
-
height: 400
|
|
5587
|
-
},
|
|
5588
|
-
code: {
|
|
5589
|
-
width: 300,
|
|
5590
|
-
height: 400
|
|
5614
|
+
function buildMessageLinks(edges, participantNodeIds) {
|
|
5615
|
+
const links = /* @__PURE__ */ new Map();
|
|
5616
|
+
for (const edge of edges) {
|
|
5617
|
+
if (participantNodeIds.has(edge.source)) links.set(edge.target, _objectSpread2(_objectSpread2({}, links.get(edge.target)), {}, { from: edge.source }));
|
|
5618
|
+
if (participantNodeIds.has(edge.target)) links.set(edge.source, _objectSpread2(_objectSpread2({}, links.get(edge.source)), {}, { to: edge.target }));
|
|
5591
5619
|
}
|
|
5592
|
-
|
|
5593
|
-
const GROUP_BOUND_PADDING = 20;
|
|
5594
|
-
const GROUP_WIDTH_PADDING = 20;
|
|
5595
|
-
const GROUP_HEIGHT_PADDING = 50;
|
|
5596
|
-
const MIN_HORIZONTAL_GAP = 140;
|
|
5597
|
-
const ROW_ALIGNMENT_TOLERANCE = 80;
|
|
5598
|
-
function resolveDimension(value) {
|
|
5599
|
-
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
5620
|
+
return links;
|
|
5600
5621
|
}
|
|
5601
|
-
function
|
|
5602
|
-
var
|
|
5603
|
-
const
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
5622
|
+
function arrowTokenOf(edgeFrom, edgeTo) {
|
|
5623
|
+
var _edgeTo$data$arrowTyp, _edgeTo$data, _edgeFrom$data, _edgeTo$data$half, _edgeTo$data2, _edgeFrom$data2, _edgeFrom$data3, _ref, _ref2;
|
|
5624
|
+
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;
|
|
5625
|
+
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;
|
|
5626
|
+
const reversed = (edgeFrom === null || edgeFrom === void 0 || (_edgeFrom$data3 = edgeFrom.data) === null || _edgeFrom$data3 === void 0 ? void 0 : _edgeFrom$data3.reversed) === true;
|
|
5627
|
+
return findArrowTokenFor(_objectSpread2(_objectSpread2({
|
|
5628
|
+
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",
|
|
5629
|
+
arrowType: arrowType !== null && arrowType !== void 0 ? arrowType : "filled"
|
|
5630
|
+
}, half ? { half } : {}), {}, { reversed }));
|
|
5608
5631
|
}
|
|
5609
|
-
function
|
|
5610
|
-
const
|
|
5611
|
-
|
|
5612
|
-
|
|
5613
|
-
|
|
5614
|
-
|
|
5615
|
-
|
|
5616
|
-
|
|
5617
|
-
|
|
5618
|
-
|
|
5619
|
-
|
|
5620
|
-
|
|
5621
|
-
|
|
5622
|
-
|
|
5623
|
-
|
|
5624
|
-
|
|
5625
|
-
|
|
5626
|
-
|
|
5627
|
-
|
|
5628
|
-
|
|
5629
|
-
|
|
5630
|
-
|
|
5631
|
-
|
|
5632
|
-
|
|
5633
|
-
|
|
5634
|
-
|
|
5635
|
-
|
|
5636
|
-
|
|
5637
|
-
y: node.position.y + offsetY
|
|
5638
|
-
} });
|
|
5639
|
-
});
|
|
5640
|
-
const resizedNodesById = new Map(resizedNodes.map((node) => [node.id, node]));
|
|
5641
|
-
const rowNodes = resizedNodes.filter((node) => {
|
|
5642
|
-
var _node$data2;
|
|
5643
|
-
return !Array.isArray((_node$data2 = node.data) === null || _node$data2 === void 0 ? void 0 : _node$data2.childNodes);
|
|
5644
|
-
}).sort((a, b) => a.position.y === b.position.y ? a.position.x - b.position.x : a.position.y - b.position.y);
|
|
5645
|
-
const rows = [];
|
|
5646
|
-
for (const node of rowNodes) {
|
|
5647
|
-
const row = rows.find((currentRow) => Math.abs(currentRow[0].position.y - node.position.y) <= ROW_ALIGNMENT_TOLERANCE);
|
|
5648
|
-
if (row) {
|
|
5649
|
-
row.push(node);
|
|
5650
|
-
continue;
|
|
5651
|
-
}
|
|
5652
|
-
rows.push([node]);
|
|
5653
|
-
}
|
|
5654
|
-
for (const row of rows) {
|
|
5655
|
-
row.sort((a, b) => a.position.x - b.position.x);
|
|
5656
|
-
for (let index = 1; index < row.length; index += 1) {
|
|
5657
|
-
const previousNode = row[index - 1];
|
|
5658
|
-
const currentNode = row[index];
|
|
5659
|
-
const previousNodeSize = getNodeSize(previousNode);
|
|
5660
|
-
const minimumX = previousNode.position.x + previousNodeSize.width + MIN_HORIZONTAL_GAP;
|
|
5661
|
-
if (currentNode.position.x >= minimumX) continue;
|
|
5662
|
-
const shiftedNode = _objectSpread2(_objectSpread2({}, currentNode), {}, { position: {
|
|
5663
|
-
x: minimumX,
|
|
5664
|
-
y: currentNode.position.y
|
|
5665
|
-
} });
|
|
5666
|
-
row[index] = shiftedNode;
|
|
5667
|
-
resizedNodesById.set(shiftedNode.id, shiftedNode);
|
|
5632
|
+
function noteParticipantNodeIds(note, participants, noteNode$1) {
|
|
5633
|
+
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));
|
|
5634
|
+
if (byImportedId.length > 0) return byImportedId.map((participant) => participant.nodeId);
|
|
5635
|
+
if (participants.length === 0) return [];
|
|
5636
|
+
const noteCenter = noteNode$1.position.x + (Number(noteNode$1.width) || 0) / 2;
|
|
5637
|
+
return [[...participants].sort((a, b) => Math.abs(a.x - noteCenter) - Math.abs(b.x - noteCenter))[0].nodeId];
|
|
5638
|
+
}
|
|
5639
|
+
function collectRowItems(nodes, edges, participants) {
|
|
5640
|
+
const participantNodeIds = new Set(participants.map((p) => p.nodeId));
|
|
5641
|
+
const links = buildMessageLinks(edges, participantNodeIds);
|
|
5642
|
+
const items = [];
|
|
5643
|
+
for (const node of nodes) {
|
|
5644
|
+
var _node$data8, _node$data9, _edgeFrom$data4, _edgeTo$data3;
|
|
5645
|
+
if (participantNodeIds.has(node.id)) continue;
|
|
5646
|
+
const note = (_node$data8 = node.data) === null || _node$data8 === void 0 ? void 0 : _node$data8.sequenceNote;
|
|
5647
|
+
if (note) {
|
|
5648
|
+
var _note$placement;
|
|
5649
|
+
items.push({
|
|
5650
|
+
item: {
|
|
5651
|
+
kind: "note",
|
|
5652
|
+
nodeId: node.id,
|
|
5653
|
+
text: nodeLabel(node),
|
|
5654
|
+
placement: (_note$placement = note.placement) !== null && _note$placement !== void 0 ? _note$placement : "over",
|
|
5655
|
+
participantNodeIds: noteParticipantNodeIds(note, participants, node)
|
|
5656
|
+
},
|
|
5657
|
+
y: node.position.y
|
|
5658
|
+
});
|
|
5659
|
+
continue;
|
|
5668
5660
|
}
|
|
5669
|
-
|
|
5670
|
-
|
|
5671
|
-
|
|
5672
|
-
const
|
|
5673
|
-
const
|
|
5674
|
-
|
|
5675
|
-
|
|
5676
|
-
|
|
5677
|
-
|
|
5678
|
-
|
|
5679
|
-
|
|
5680
|
-
|
|
5681
|
-
|
|
5682
|
-
|
|
5683
|
-
|
|
5684
|
-
}
|
|
5685
|
-
|
|
5686
|
-
const minX = Math.min(...bounds.map((bound) => bound.left));
|
|
5687
|
-
const minY = Math.min(...bounds.map((bound) => bound.top));
|
|
5688
|
-
const maxX = Math.max(...bounds.map((bound) => bound.right));
|
|
5689
|
-
const maxY = Math.max(...bounds.map((bound) => bound.bottom));
|
|
5690
|
-
return _objectSpread2(_objectSpread2({}, shiftedNode), {}, {
|
|
5691
|
-
position: {
|
|
5692
|
-
x: minX - GROUP_BOUND_PADDING,
|
|
5693
|
-
y: minY - GROUP_BOUND_PADDING
|
|
5694
|
-
},
|
|
5695
|
-
style: _objectSpread2(_objectSpread2({}, shiftedNode.style), {}, {
|
|
5696
|
-
width: maxX - minX + GROUP_BOUND_PADDING * 2 + GROUP_WIDTH_PADDING,
|
|
5697
|
-
height: maxY - minY + GROUP_BOUND_PADDING * 2 + GROUP_HEIGHT_PADDING
|
|
5698
|
-
})
|
|
5661
|
+
const link = links.get(node.id);
|
|
5662
|
+
if (!(link === null || link === void 0 ? void 0 : link.from) || !link.to) continue;
|
|
5663
|
+
const edgeFrom = edges.find((edge) => edge.target === node.id && edge.source === link.from);
|
|
5664
|
+
const edgeTo = edges.find((edge) => edge.source === node.id && edge.target === link.to);
|
|
5665
|
+
const sequenceNumber = (_node$data9 = node.data) === null || _node$data9 === void 0 ? void 0 : _node$data9.sequenceNumber;
|
|
5666
|
+
items.push({
|
|
5667
|
+
item: _objectSpread2({
|
|
5668
|
+
kind: "message",
|
|
5669
|
+
nodeId: node.id,
|
|
5670
|
+
fromNodeId: link.from,
|
|
5671
|
+
toNodeId: link.to,
|
|
5672
|
+
label: nodeLabel(node),
|
|
5673
|
+
token: arrowTokenOf(edgeFrom, edgeTo),
|
|
5674
|
+
centralSource: (edgeFrom === null || edgeFrom === void 0 || (_edgeFrom$data4 = edgeFrom.data) === null || _edgeFrom$data4 === void 0 ? void 0 : _edgeFrom$data4.centralSource) === true,
|
|
5675
|
+
centralTarget: (edgeTo === null || edgeTo === void 0 || (_edgeTo$data3 = edgeTo.data) === null || _edgeTo$data3 === void 0 ? void 0 : _edgeTo$data3.centralTarget) === true
|
|
5676
|
+
}, typeof sequenceNumber === "number" ? { sequenceNumber } : {}),
|
|
5677
|
+
y: node.position.y
|
|
5699
5678
|
});
|
|
5700
|
-
}
|
|
5679
|
+
}
|
|
5680
|
+
return items.sort((a, b) => a.y - b.y).map((entry) => entry.item);
|
|
5701
5681
|
}
|
|
5702
|
-
function
|
|
5703
|
-
|
|
5704
|
-
|
|
5682
|
+
function collectBlocks(nodes) {
|
|
5683
|
+
const blocks = [];
|
|
5684
|
+
for (const node of nodes) {
|
|
5685
|
+
var _node$data10, _block$type, _block$label, _block$depth, _block$sections;
|
|
5686
|
+
const block = (_node$data10 = node.data) === null || _node$data10 === void 0 ? void 0 : _node$data10.sequenceBlock;
|
|
5687
|
+
if (!block) continue;
|
|
5688
|
+
if (typeof block.startRow !== "number") continue;
|
|
5689
|
+
if (typeof block.endRow !== "number") continue;
|
|
5690
|
+
blocks.push(_objectSpread2(_objectSpread2({
|
|
5691
|
+
nodeId: node.id,
|
|
5692
|
+
type: (_block$type = block.type) !== null && _block$type !== void 0 ? _block$type : "rect",
|
|
5693
|
+
label: (_block$label = block.label) !== null && _block$label !== void 0 ? _block$label : ""
|
|
5694
|
+
}, block.color ? { color: block.color } : {}), {}, {
|
|
5695
|
+
depth: (_block$depth = block.depth) !== null && _block$depth !== void 0 ? _block$depth : 0,
|
|
5696
|
+
startRow: block.startRow,
|
|
5697
|
+
endRow: block.endRow,
|
|
5698
|
+
sections: ((_block$sections = block.sections) !== null && _block$sections !== void 0 ? _block$sections : []).filter((section) => typeof section.startRow === "number" && typeof section.endRow === "number").map((section) => {
|
|
5699
|
+
var _section$label;
|
|
5700
|
+
return {
|
|
5701
|
+
label: (_section$label = section.label) !== null && _section$label !== void 0 ? _section$label : "",
|
|
5702
|
+
startRow: section.startRow,
|
|
5703
|
+
endRow: section.endRow
|
|
5704
|
+
};
|
|
5705
|
+
})
|
|
5706
|
+
}));
|
|
5707
|
+
}
|
|
5708
|
+
return blocks;
|
|
5705
5709
|
}
|
|
5706
|
-
function
|
|
5707
|
-
|
|
5708
|
-
const
|
|
5709
|
-
|
|
5710
|
-
|
|
5711
|
-
|
|
5712
|
-
|
|
5713
|
-
|
|
5714
|
-
|
|
5715
|
-
|
|
5716
|
-
|
|
5717
|
-
|
|
5710
|
+
function collectBoxes(nodes, participants) {
|
|
5711
|
+
const boxes = [];
|
|
5712
|
+
for (const node of nodes) {
|
|
5713
|
+
var _node$data11, _node$data12, _box$label;
|
|
5714
|
+
const box = (_node$data11 = node.data) === null || _node$data11 === void 0 ? void 0 : _node$data11.sequenceBox;
|
|
5715
|
+
if (!box) continue;
|
|
5716
|
+
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));
|
|
5717
|
+
const left = node.position.x;
|
|
5718
|
+
const right = node.position.x + (Number(node.width) || 0);
|
|
5719
|
+
const contained = byImportedId.length > 0 ? byImportedId : participants.filter((participant) => participant.x >= left && participant.x <= right);
|
|
5720
|
+
if (contained.length === 0) continue;
|
|
5721
|
+
const backgroundColor = (_node$data12 = node.data) === null || _node$data12 === void 0 ? void 0 : _node$data12.backgroundColor;
|
|
5722
|
+
boxes.push(_objectSpread2(_objectSpread2({
|
|
5723
|
+
nodeId: node.id,
|
|
5724
|
+
label: (_box$label = box.label) !== null && _box$label !== void 0 ? _box$label : ""
|
|
5725
|
+
}, typeof backgroundColor === "string" ? { color: backgroundColor } : {}), {}, { participantNodeIds: contained.map((participant) => participant.nodeId) }));
|
|
5726
|
+
}
|
|
5727
|
+
return boxes;
|
|
5718
5728
|
}
|
|
5719
|
-
function
|
|
5720
|
-
|
|
5729
|
+
function participantDeclaration(participant, keyword) {
|
|
5730
|
+
const stereotype = participant.type === "participant" || participant.type === "actor" ? "" : `@{ "type": "${participant.type}" }`;
|
|
5731
|
+
const alias = participant.mermaidId === participant.name ? "" : ` as ${encodeLabel(participant.name)}`;
|
|
5732
|
+
return `${keyword} ${participant.mermaidId}${stereotype}${alias}`;
|
|
5721
5733
|
}
|
|
5722
|
-
function
|
|
5723
|
-
|
|
5724
|
-
|
|
5725
|
-
|
|
5726
|
-
|
|
5727
|
-
|
|
5728
|
-
|
|
5729
|
-
|
|
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
|
-
|
|
5809
|
-
|
|
5810
|
-
|
|
5811
|
-
|
|
5812
|
-
|
|
5813
|
-
|
|
5814
|
-
|
|
5815
|
-
|
|
5816
|
-
|
|
5817
|
-
|
|
5818
|
-
|
|
5819
|
-
|
|
5820
|
-
|
|
5821
|
-
|
|
5734
|
+
function emitSequenceMermaid(nodes, edges) {
|
|
5735
|
+
const nodeIdMap = /* @__PURE__ */ new Map();
|
|
5736
|
+
const participants = collectParticipants(nodes);
|
|
5737
|
+
const items = collectRowItems(nodes, edges, participants);
|
|
5738
|
+
const blocks = collectBlocks(nodes);
|
|
5739
|
+
const boxes = collectBoxes(nodes, participants);
|
|
5740
|
+
const participantByNodeId = new Map(participants.map((participant) => [participant.nodeId, participant]));
|
|
5741
|
+
for (const participant of participants) nodeIdMap.set(participant.nodeId, `participant-${participant.mermaidId}`);
|
|
5742
|
+
const rowByItemId = /* @__PURE__ */ new Map();
|
|
5743
|
+
const lastRowByItemId = /* @__PURE__ */ new Map();
|
|
5744
|
+
let row = 0;
|
|
5745
|
+
for (const item of items) {
|
|
5746
|
+
rowByItemId.set(item.nodeId, row);
|
|
5747
|
+
const isSelf = item.kind === "message" && item.fromNodeId === item.toNodeId;
|
|
5748
|
+
lastRowByItemId.set(item.nodeId, isSelf ? row + 1 : row);
|
|
5749
|
+
row += isSelf ? 2 : 1;
|
|
5750
|
+
}
|
|
5751
|
+
const rowCount = row;
|
|
5752
|
+
const lines = ["sequenceDiagram"];
|
|
5753
|
+
const titleNode = nodes.find((node) => node.id === "sequence-title");
|
|
5754
|
+
if (titleNode) {
|
|
5755
|
+
var _fieldValue;
|
|
5756
|
+
const text = (_fieldValue = fieldValue(titleNode, "text")) !== null && _fieldValue !== void 0 ? _fieldValue : nodeLabel(titleNode);
|
|
5757
|
+
if (text) {
|
|
5758
|
+
lines.push(` title ${encodeLabel(text)}`);
|
|
5759
|
+
nodeIdMap.set(titleNode.id, "sequence-title");
|
|
5760
|
+
}
|
|
5761
|
+
}
|
|
5762
|
+
const boxByFirstParticipant = /* @__PURE__ */ new Map();
|
|
5763
|
+
const boxEndByParticipant = /* @__PURE__ */ new Map();
|
|
5764
|
+
for (const box of boxes) {
|
|
5765
|
+
var _boxEndByParticipant$;
|
|
5766
|
+
const ordered = participants.filter((participant) => box.participantNodeIds.includes(participant.nodeId));
|
|
5767
|
+
if (ordered.length === 0) continue;
|
|
5768
|
+
boxByFirstParticipant.set(ordered[0].nodeId, box);
|
|
5769
|
+
boxEndByParticipant.set(ordered[ordered.length - 1].nodeId, ((_boxEndByParticipant$ = boxEndByParticipant.get(ordered[ordered.length - 1].nodeId)) !== null && _boxEndByParticipant$ !== void 0 ? _boxEndByParticipant$ : 0) + 1);
|
|
5770
|
+
}
|
|
5771
|
+
let boxIndex = 0;
|
|
5772
|
+
for (const participant of participants) {
|
|
5773
|
+
var _boxEndByParticipant$2;
|
|
5774
|
+
const box = boxByFirstParticipant.get(participant.nodeId);
|
|
5775
|
+
if (box) {
|
|
5776
|
+
const color = box.color ? `${box.color} ` : "";
|
|
5777
|
+
lines.push(` box ${color}${encodeLabel(box.label)}`.trimEnd());
|
|
5778
|
+
nodeIdMap.set(box.nodeId, `sequence-box-box-${boxIndex}`);
|
|
5779
|
+
boxIndex++;
|
|
5780
|
+
}
|
|
5781
|
+
if (participant.createdRow === void 0) {
|
|
5782
|
+
const keyword = participant.type === "actor" ? "actor" : "participant";
|
|
5783
|
+
lines.push(` ${participantDeclaration(participant, keyword)}`);
|
|
5784
|
+
}
|
|
5785
|
+
const boxEnds = (_boxEndByParticipant$2 = boxEndByParticipant.get(participant.nodeId)) !== null && _boxEndByParticipant$2 !== void 0 ? _boxEndByParticipant$2 : 0;
|
|
5786
|
+
for (let index = 0; index < boxEnds; index++) lines.push(" end");
|
|
5787
|
+
}
|
|
5788
|
+
for (const participant of participants) for (const link of participant.links) lines.push(` link ${participant.mermaidId}: ${link.label} @ ${link.url}`);
|
|
5789
|
+
const numbered = items.filter((item) => item.kind === "message" && item.sequenceNumber !== void 0);
|
|
5790
|
+
if (numbered.length > 0) {
|
|
5791
|
+
const start = numbered[0].sequenceNumber;
|
|
5792
|
+
const step = numbered.length > 1 ? numbered[1].sequenceNumber - numbered[0].sequenceNumber : 1;
|
|
5793
|
+
lines.push(` autonumber ${start} ${step}`);
|
|
5794
|
+
}
|
|
5795
|
+
const openBlocks = [];
|
|
5796
|
+
let blockIndex = 0;
|
|
5797
|
+
let parserRow = 0;
|
|
5798
|
+
function indent() {
|
|
5799
|
+
return " ".repeat(openBlocks.length + 1);
|
|
5800
|
+
}
|
|
5801
|
+
for (let currentRow = 0; currentRow < rowCount; currentRow++) {
|
|
5802
|
+
const opening = blocks.filter((block) => block.startRow === currentRow).sort((a, b) => a.depth - b.depth);
|
|
5803
|
+
for (const block of opening) {
|
|
5804
|
+
const label = encodeLabel(block.label);
|
|
5805
|
+
const color = block.type === "rect" && block.color ? `${block.color} ` : "";
|
|
5806
|
+
lines.push(`${indent()}${block.type} ${color}${label}`.trimEnd());
|
|
5807
|
+
nodeIdMap.set(block.nodeId, `sequence-block-block-${blockIndex}`);
|
|
5808
|
+
blockIndex++;
|
|
5809
|
+
openBlocks.push(block);
|
|
5810
|
+
}
|
|
5811
|
+
for (const [depth, block] of openBlocks.entries()) for (const section of block.sections.slice(1)) {
|
|
5812
|
+
if (section.startRow !== currentRow) continue;
|
|
5813
|
+
const keyword = block.type === "par" ? "and" : block.type === "critical" ? "option" : "else";
|
|
5814
|
+
lines.push(`${" ".repeat(depth + 1)}${keyword} ${encodeLabel(section.label)}`.trimEnd());
|
|
5815
|
+
}
|
|
5816
|
+
const item = items.find((entry) => rowByItemId.get(entry.nodeId) === currentRow);
|
|
5817
|
+
if (item) {
|
|
5818
|
+
for (const participant of participants) {
|
|
5819
|
+
if (participant.createdRow !== currentRow) continue;
|
|
5820
|
+
const keyword = participant.type === "actor" ? "actor" : "participant";
|
|
5821
|
+
lines.push(`${indent()}create ${participantDeclaration(participant, keyword)}`);
|
|
5822
|
+
}
|
|
5823
|
+
for (const participant of participants) {
|
|
5824
|
+
if (participant.destroyedRow !== currentRow) continue;
|
|
5825
|
+
lines.push(`${indent()}destroy ${participant.mermaidId}`);
|
|
5826
|
+
}
|
|
5827
|
+
for (const participant of participants) for (const activation of participant.activations) {
|
|
5828
|
+
if (activation.startRow !== currentRow) continue;
|
|
5829
|
+
lines.push(`${indent()}activate ${participant.mermaidId}`);
|
|
5830
|
+
}
|
|
5831
|
+
if (item.kind === "message") {
|
|
5832
|
+
const from = participantByNodeId.get(item.fromNodeId);
|
|
5833
|
+
const to = participantByNodeId.get(item.toNodeId);
|
|
5834
|
+
if (from && to) {
|
|
5835
|
+
const source = item.centralSource ? `${from.mermaidId}()` : from.mermaidId;
|
|
5836
|
+
const target = item.centralTarget ? `()${to.mermaidId}` : to.mermaidId;
|
|
5837
|
+
lines.push(`${indent()}${source}${item.token}${target}: ${encodeLabel(item.label)}`);
|
|
5838
|
+
nodeIdMap.set(item.nodeId, `message-${parserRow}`);
|
|
5839
|
+
parserRow++;
|
|
5822
5840
|
}
|
|
5823
|
-
|
|
5824
|
-
|
|
5825
|
-
|
|
5826
|
-
|
|
5827
|
-
|
|
5828
|
-
|
|
5829
|
-
if (
|
|
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
|
-
|
|
5887
|
-
|
|
5888
|
-
|
|
5889
|
-
edges: resolvedEdges,
|
|
5890
|
-
nodes: combinedNodes
|
|
5891
|
-
};
|
|
5841
|
+
}
|
|
5842
|
+
if (item.kind === "note") {
|
|
5843
|
+
const names = item.participantNodeIds.map((nodeId) => {
|
|
5844
|
+
var _participantByNodeId$;
|
|
5845
|
+
return (_participantByNodeId$ = participantByNodeId.get(nodeId)) === null || _participantByNodeId$ === void 0 ? void 0 : _participantByNodeId$.mermaidId;
|
|
5846
|
+
}).filter((id) => id !== void 0);
|
|
5847
|
+
if (names.length > 0) {
|
|
5848
|
+
lines.push(`${indent()}Note ${item.placement} ${names.join(",")}: ${encodeLabel(item.text)}`);
|
|
5849
|
+
nodeIdMap.set(item.nodeId, `note-${parserRow}`);
|
|
5850
|
+
parserRow++;
|
|
5851
|
+
}
|
|
5852
|
+
}
|
|
5853
|
+
}
|
|
5854
|
+
const rowEnd = item ? lastRowByItemId.get(item.nodeId) : currentRow;
|
|
5855
|
+
for (const participant of participants) for (const activation of participant.activations) {
|
|
5856
|
+
if (activation.endRow !== rowEnd) continue;
|
|
5857
|
+
lines.push(`${indent()}deactivate ${participant.mermaidId}`);
|
|
5858
|
+
}
|
|
5859
|
+
while (openBlocks.length > 0 && openBlocks[openBlocks.length - 1].endRow <= rowEnd) {
|
|
5860
|
+
openBlocks.pop();
|
|
5861
|
+
lines.push(`${indent()}end`);
|
|
5862
|
+
}
|
|
5863
|
+
}
|
|
5864
|
+
while (openBlocks.length > 0) {
|
|
5865
|
+
openBlocks.pop();
|
|
5866
|
+
lines.push(`${indent()}end`);
|
|
5867
|
+
}
|
|
5868
|
+
return {
|
|
5869
|
+
mermaid: lines.join("\n"),
|
|
5870
|
+
nodeIdMap
|
|
5871
|
+
};
|
|
5872
|
+
}
|
|
5873
|
+
function convertReactFlowToSequenceMermaid(nodes, edges) {
|
|
5874
|
+
return emitSequenceMermaid(nodes, edges).mermaid;
|
|
5875
|
+
}
|
|
5876
|
+
function convertReactFlowToSequenceUiGraph(nodes, edges) {
|
|
5877
|
+
const { mermaid: mermaid$1, nodeIdMap } = emitSequenceMermaid(nodes, edges);
|
|
5878
|
+
return {
|
|
5879
|
+
mermaid: mermaid$1,
|
|
5880
|
+
context: buildValidatedContext(nodes, edges, [], nodeIdMap)
|
|
5881
|
+
};
|
|
5882
|
+
}
|
|
5883
|
+
const BOUND_PADDING = 20;
|
|
5884
|
+
function createGroupNode(options) {
|
|
5885
|
+
var _options$id, _options$name;
|
|
5886
|
+
return {
|
|
5887
|
+
id: (_options$id = options.id) !== null && _options$id !== void 0 ? _options$id : generateUUID$1(),
|
|
5888
|
+
type: "group",
|
|
5889
|
+
position: {
|
|
5890
|
+
x: options.bounds.x,
|
|
5891
|
+
y: options.bounds.y
|
|
5892
|
+
},
|
|
5893
|
+
data: {
|
|
5894
|
+
childNodes: options.nodes,
|
|
5895
|
+
autoLayout: true,
|
|
5896
|
+
componentFields: [generateComponentFieldNameInput((_options$name = options.name) !== null && _options$name !== void 0 ? _options$name : "Group")]
|
|
5897
|
+
},
|
|
5898
|
+
style: {
|
|
5899
|
+
width: options.bounds.width + 20,
|
|
5900
|
+
height: options.bounds.height + 50
|
|
5901
|
+
}
|
|
5902
|
+
};
|
|
5903
|
+
}
|
|
5904
|
+
function generateGroupNodeFromNodes(id, name, nodes) {
|
|
5905
|
+
const bounds = nodes.map((node) => {
|
|
5906
|
+
var _ref, _ref2, _node$height, _node$style, _node$measured, _ref3, _ref4, _node$width, _node$style2, _node$measured2;
|
|
5892
5907
|
return {
|
|
5893
|
-
|
|
5894
|
-
|
|
5908
|
+
top: node.position.y,
|
|
5909
|
+
left: node.position.x,
|
|
5910
|
+
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),
|
|
5911
|
+
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)
|
|
5895
5912
|
};
|
|
5896
5913
|
});
|
|
5897
|
-
|
|
5914
|
+
const minX = Math.min(...bounds.map((b) => b.left));
|
|
5915
|
+
const minY = Math.min(...bounds.map((b) => b.top));
|
|
5916
|
+
const maxX = Math.max(...bounds.map((b) => b.right));
|
|
5917
|
+
const maxY = Math.max(...bounds.map((b) => b.bottom));
|
|
5918
|
+
return createGroupNode({
|
|
5919
|
+
id,
|
|
5920
|
+
name,
|
|
5921
|
+
nodes: nodes.map((node) => node.id),
|
|
5922
|
+
bounds: {
|
|
5923
|
+
x: minX - BOUND_PADDING,
|
|
5924
|
+
y: minY - BOUND_PADDING,
|
|
5925
|
+
width: maxX - minX + BOUND_PADDING * 2,
|
|
5926
|
+
height: maxY - minY + BOUND_PADDING * 2
|
|
5927
|
+
}
|
|
5928
|
+
});
|
|
5898
5929
|
}
|
|
5899
|
-
|
|
5900
|
-
|
|
5901
|
-
"rounded-rect",
|
|
5902
|
-
"ellipse",
|
|
5903
|
-
"diamond",
|
|
5904
|
-
"triangle",
|
|
5905
|
-
"parallelogram",
|
|
5906
|
-
"trapezoid",
|
|
5907
|
-
"hexagon",
|
|
5908
|
-
"document",
|
|
5909
|
-
"cylinder",
|
|
5910
|
-
"delay",
|
|
5911
|
-
"off-page-connector",
|
|
5912
|
-
"display",
|
|
5913
|
-
"collate",
|
|
5914
|
-
"sort",
|
|
5915
|
-
"terminator",
|
|
5916
|
-
"or",
|
|
5917
|
-
"database",
|
|
5918
|
-
"multiple-documents",
|
|
5919
|
-
"subroutine",
|
|
5920
|
-
"manual-input",
|
|
5921
|
-
"summing-junction",
|
|
5922
|
-
"internal-storage"
|
|
5923
|
-
]);
|
|
5924
|
-
const COMPONENT_INPUT_TYPES = new Set(Object.values(ComponentInputType));
|
|
5925
|
-
const INLINE_MERMAID_LABEL_MAX_LENGTH = 32;
|
|
5926
|
-
const KNOWN_NODE_DATA_KEYS = new Set([
|
|
5927
|
-
"componentFields",
|
|
5928
|
-
"shape",
|
|
5929
|
-
"fill",
|
|
5930
|
-
"stroke",
|
|
5931
|
-
"strokeWidth",
|
|
5932
|
-
"strokeStyle",
|
|
5933
|
-
"borderRadius",
|
|
5934
|
-
"borderAnimationEnabled",
|
|
5935
|
-
"strokeAnimation",
|
|
5936
|
-
"src",
|
|
5937
|
-
"animatedIcon",
|
|
5938
|
-
"iconSrc",
|
|
5939
|
-
"componentId",
|
|
5940
|
-
"serviceTable",
|
|
5941
|
-
"title",
|
|
5942
|
-
"columns",
|
|
5943
|
-
"rows",
|
|
5944
|
-
"name",
|
|
5945
|
-
"label",
|
|
5946
|
-
"value",
|
|
5947
|
-
"cloud",
|
|
5948
|
-
"service",
|
|
5949
|
-
"childNodes"
|
|
5950
|
-
]);
|
|
5951
|
-
function isComponentInputType(value) {
|
|
5952
|
-
return COMPONENT_INPUT_TYPES.has(value);
|
|
5930
|
+
function resolveCloudIcon(_x, _x2) {
|
|
5931
|
+
return _resolveCloudIcon.apply(this, arguments);
|
|
5953
5932
|
}
|
|
5954
|
-
function
|
|
5955
|
-
|
|
5956
|
-
|
|
5933
|
+
function _resolveCloudIcon() {
|
|
5934
|
+
_resolveCloudIcon = _asyncToGenerator(function* (cloud, serviceName) {
|
|
5935
|
+
const cloudName = cloud === null || cloud === void 0 ? void 0 : cloud.toLowerCase();
|
|
5936
|
+
const icon = (cloudName === "azure" ? [...(yield import("./__azure-icons.DgR1F6C6.mjs")).default] : cloudName === "aws" ? [...(yield import("./__aws-icons.agWBtDk7.mjs")).default] : [...(yield import("./__aws-icons.agWBtDk7.mjs")).default, ...(yield import("./__azure-icons.DgR1F6C6.mjs")).default]).find((icon$1) => icon$1.name.toLowerCase() === serviceName.toLowerCase());
|
|
5937
|
+
if (!icon) return null;
|
|
5938
|
+
return `/${icon.cloud.toLowerCase()}-icons/${icon.relativePath}`;
|
|
5939
|
+
});
|
|
5940
|
+
return _resolveCloudIcon.apply(this, arguments);
|
|
5957
5941
|
}
|
|
5958
|
-
function
|
|
5959
|
-
|
|
5960
|
-
const trimmed = value.trim();
|
|
5961
|
-
if (!trimmed) return;
|
|
5962
|
-
return trimmed;
|
|
5942
|
+
function resolveAnimatedNode(_x3) {
|
|
5943
|
+
return _resolveAnimatedNode.apply(this, arguments);
|
|
5963
5944
|
}
|
|
5964
|
-
function
|
|
5965
|
-
|
|
5966
|
-
|
|
5967
|
-
|
|
5968
|
-
|
|
5945
|
+
function _resolveAnimatedNode() {
|
|
5946
|
+
_resolveAnimatedNode = _asyncToGenerator(function* (animatedIcon) {
|
|
5947
|
+
const node = (yield import("./__animated-nodes.DI0XYTuw.mjs")).default.find((node$1) => node$1.name.toLowerCase() === animatedIcon.toLowerCase());
|
|
5948
|
+
if (!node) return null;
|
|
5949
|
+
return `/animated-nodes/${node.fileName}`;
|
|
5950
|
+
});
|
|
5951
|
+
return _resolveAnimatedNode.apply(this, arguments);
|
|
5952
|
+
}
|
|
5953
|
+
const EXPECTED_NODE_SIZE = {
|
|
5954
|
+
databaseTableSQL: {
|
|
5955
|
+
width: 500,
|
|
5956
|
+
height: 400
|
|
5957
|
+
},
|
|
5958
|
+
table: {
|
|
5959
|
+
width: 600,
|
|
5960
|
+
height: 400
|
|
5961
|
+
},
|
|
5962
|
+
code: {
|
|
5963
|
+
width: 300,
|
|
5964
|
+
height: 400
|
|
5965
|
+
}
|
|
5966
|
+
};
|
|
5967
|
+
const GROUP_BOUND_PADDING = 20;
|
|
5968
|
+
const GROUP_WIDTH_PADDING = 20;
|
|
5969
|
+
const GROUP_HEIGHT_PADDING = 50;
|
|
5970
|
+
const MIN_HORIZONTAL_GAP = 140;
|
|
5971
|
+
const ROW_ALIGNMENT_TOLERANCE = 80;
|
|
5972
|
+
function resolveDimension(value) {
|
|
5973
|
+
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
5974
|
+
}
|
|
5975
|
+
function getNodeSize(node) {
|
|
5976
|
+
var _ref, _ref2, _ref3, _resolveDimension, _node$style, _node$measured, _ref4, _ref5, _ref6, _resolveDimension2, _node$style2, _node$measured2;
|
|
5977
|
+
const expectedSize = node.type ? EXPECTED_NODE_SIZE[node.type] : void 0;
|
|
5969
5978
|
return {
|
|
5970
|
-
|
|
5971
|
-
|
|
5979
|
+
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,
|
|
5980
|
+
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
|
|
5972
5981
|
};
|
|
5973
5982
|
}
|
|
5974
|
-
function
|
|
5975
|
-
|
|
5976
|
-
|
|
5977
|
-
|
|
5978
|
-
|
|
5979
|
-
|
|
5980
|
-
|
|
5981
|
-
|
|
5982
|
-
|
|
5983
|
-
|
|
5984
|
-
|
|
5983
|
+
function resizeNodesLayouts(nodes) {
|
|
5984
|
+
const resizeRules = nodes.map((node) => {
|
|
5985
|
+
if (!node.type) return;
|
|
5986
|
+
const expectedSize = EXPECTED_NODE_SIZE[node.type];
|
|
5987
|
+
if (!expectedSize) return;
|
|
5988
|
+
const size = getNodeSize(node);
|
|
5989
|
+
return {
|
|
5990
|
+
startX: node.position.x + expectedSize.width,
|
|
5991
|
+
startY: node.position.y + expectedSize.height,
|
|
5992
|
+
deltaX: Math.max(0, size.width - expectedSize.width),
|
|
5993
|
+
deltaY: Math.max(0, size.height - expectedSize.height)
|
|
5994
|
+
};
|
|
5995
|
+
}).filter((rule) => Boolean(rule));
|
|
5996
|
+
const resizedNodes = nodes.map((node) => {
|
|
5997
|
+
var _node$data;
|
|
5998
|
+
const childNodeIds = (_node$data = node.data) === null || _node$data === void 0 ? void 0 : _node$data.childNodes;
|
|
5999
|
+
if (Array.isArray(childNodeIds)) return _objectSpread2({}, node);
|
|
6000
|
+
const offsetX = resizeRules.reduce((total, rule) => {
|
|
6001
|
+
if (!rule || rule.deltaX === 0 || node.position.x < rule.startX) return total;
|
|
6002
|
+
return total + rule.deltaX;
|
|
6003
|
+
}, 0);
|
|
6004
|
+
const offsetY = resizeRules.reduce((total, rule) => {
|
|
6005
|
+
if (!rule || rule.deltaY === 0 || node.position.y < rule.startY) return total;
|
|
6006
|
+
return total + rule.deltaY;
|
|
6007
|
+
}, 0);
|
|
6008
|
+
if (offsetX === 0 && offsetY === 0) return node;
|
|
6009
|
+
return _objectSpread2(_objectSpread2({}, node), {}, { position: {
|
|
6010
|
+
x: node.position.x + offsetX,
|
|
6011
|
+
y: node.position.y + offsetY
|
|
6012
|
+
} });
|
|
6013
|
+
});
|
|
6014
|
+
const resizedNodesById = new Map(resizedNodes.map((node) => [node.id, node]));
|
|
6015
|
+
const rowNodes = resizedNodes.filter((node) => {
|
|
6016
|
+
var _node$data2;
|
|
6017
|
+
return !Array.isArray((_node$data2 = node.data) === null || _node$data2 === void 0 ? void 0 : _node$data2.childNodes);
|
|
6018
|
+
}).sort((a, b) => a.position.y === b.position.y ? a.position.x - b.position.x : a.position.y - b.position.y);
|
|
6019
|
+
const rows = [];
|
|
6020
|
+
for (const node of rowNodes) {
|
|
6021
|
+
const row = rows.find((currentRow) => Math.abs(currentRow[0].position.y - node.position.y) <= ROW_ALIGNMENT_TOLERANCE);
|
|
6022
|
+
if (row) {
|
|
6023
|
+
row.push(node);
|
|
6024
|
+
continue;
|
|
6025
|
+
}
|
|
6026
|
+
rows.push([node]);
|
|
6027
|
+
}
|
|
6028
|
+
for (const row of rows) {
|
|
6029
|
+
row.sort((a, b) => a.position.x - b.position.x);
|
|
6030
|
+
for (let index = 1; index < row.length; index += 1) {
|
|
6031
|
+
const previousNode = row[index - 1];
|
|
6032
|
+
const currentNode = row[index];
|
|
6033
|
+
const previousNodeSize = getNodeSize(previousNode);
|
|
6034
|
+
const minimumX = previousNode.position.x + previousNodeSize.width + MIN_HORIZONTAL_GAP;
|
|
6035
|
+
if (currentNode.position.x >= minimumX) continue;
|
|
6036
|
+
const shiftedNode = _objectSpread2(_objectSpread2({}, currentNode), {}, { position: {
|
|
6037
|
+
x: minimumX,
|
|
6038
|
+
y: currentNode.position.y
|
|
6039
|
+
} });
|
|
6040
|
+
row[index] = shiftedNode;
|
|
6041
|
+
resizedNodesById.set(shiftedNode.id, shiftedNode);
|
|
6042
|
+
}
|
|
6043
|
+
}
|
|
6044
|
+
return resizedNodes.map((node) => {
|
|
6045
|
+
var _resizedNodesById$get, _node$data3;
|
|
6046
|
+
const shiftedNode = (_resizedNodesById$get = resizedNodesById.get(node.id)) !== null && _resizedNodesById$get !== void 0 ? _resizedNodesById$get : node;
|
|
6047
|
+
const childNodeIds = (_node$data3 = node.data) === null || _node$data3 === void 0 ? void 0 : _node$data3.childNodes;
|
|
6048
|
+
if (!Array.isArray(childNodeIds)) return shiftedNode;
|
|
6049
|
+
const childNodes = childNodeIds.map((childNodeId) => typeof childNodeId === "string" ? resizedNodesById.get(childNodeId) : void 0).filter((childNode) => Boolean(childNode));
|
|
6050
|
+
if (childNodes.length === 0) return shiftedNode;
|
|
6051
|
+
const bounds = childNodes.map((childNode) => {
|
|
6052
|
+
const size = getNodeSize(childNode);
|
|
6053
|
+
return {
|
|
6054
|
+
left: childNode.position.x,
|
|
6055
|
+
top: childNode.position.y,
|
|
6056
|
+
right: childNode.position.x + size.width,
|
|
6057
|
+
bottom: childNode.position.y + size.height
|
|
6058
|
+
};
|
|
6059
|
+
});
|
|
6060
|
+
const minX = Math.min(...bounds.map((bound) => bound.left));
|
|
6061
|
+
const minY = Math.min(...bounds.map((bound) => bound.top));
|
|
6062
|
+
const maxX = Math.max(...bounds.map((bound) => bound.right));
|
|
6063
|
+
const maxY = Math.max(...bounds.map((bound) => bound.bottom));
|
|
6064
|
+
return _objectSpread2(_objectSpread2({}, shiftedNode), {}, {
|
|
6065
|
+
position: {
|
|
6066
|
+
x: minX - GROUP_BOUND_PADDING,
|
|
6067
|
+
y: minY - GROUP_BOUND_PADDING
|
|
6068
|
+
},
|
|
6069
|
+
style: _objectSpread2(_objectSpread2({}, shiftedNode.style), {}, {
|
|
6070
|
+
width: maxX - minX + GROUP_BOUND_PADDING * 2 + GROUP_WIDTH_PADDING,
|
|
6071
|
+
height: maxY - minY + GROUP_BOUND_PADDING * 2 + GROUP_HEIGHT_PADDING
|
|
6072
|
+
})
|
|
6073
|
+
});
|
|
5985
6074
|
});
|
|
5986
6075
|
}
|
|
5987
|
-
function
|
|
5988
|
-
|
|
5989
|
-
|
|
5990
|
-
return pickString(getFieldValue(field.data));
|
|
5991
|
-
}
|
|
5992
|
-
function isEmptyFieldValue(value) {
|
|
5993
|
-
if (typeof value === "string") return value.trim().length === 0;
|
|
5994
|
-
return value === void 0 || value === null;
|
|
5995
|
-
}
|
|
5996
|
-
function parseStrokeStyle(dashArray) {
|
|
5997
|
-
if (typeof dashArray !== "string" || !dashArray.trim()) return;
|
|
5998
|
-
const normalized = dashArray.replaceAll(",", " ").replace(/\s+/g, " ").trim();
|
|
5999
|
-
if (normalized === "1 2") return "dotted";
|
|
6000
|
-
if (normalized === "4 2" || normalized === "4 4" || normalized === "8 4") return "dashed";
|
|
6001
|
-
return "solid";
|
|
6076
|
+
function hasValidPosition(position) {
|
|
6077
|
+
if (!position) return false;
|
|
6078
|
+
return Number.isFinite(position.x) && Number.isFinite(position.y);
|
|
6002
6079
|
}
|
|
6003
|
-
function
|
|
6004
|
-
if (
|
|
6005
|
-
const
|
|
6006
|
-
|
|
6007
|
-
|
|
6080
|
+
function normalizeContextMarker(marker) {
|
|
6081
|
+
if (!marker) return;
|
|
6082
|
+
const markerType = marker.type.trim().toLowerCase();
|
|
6083
|
+
let type;
|
|
6084
|
+
if (markerType === "arrow") type = MarkerType.Arrow;
|
|
6085
|
+
else if (markerType === "arrowclosed" || markerType === "arrow-closed" || markerType === "arrow_closed") type = MarkerType.ArrowClosed;
|
|
6008
6086
|
if (!type) return;
|
|
6009
|
-
|
|
6010
|
-
if (color) return {
|
|
6087
|
+
if (marker.color) return {
|
|
6011
6088
|
type,
|
|
6012
|
-
color
|
|
6089
|
+
color: marker.color
|
|
6013
6090
|
};
|
|
6014
6091
|
return { type };
|
|
6015
6092
|
}
|
|
6016
|
-
function
|
|
6017
|
-
return
|
|
6018
|
-
}
|
|
6019
|
-
function canInlineMermaidLabel(value) {
|
|
6020
|
-
if (value.length > INLINE_MERMAID_LABEL_MAX_LENGTH) return false;
|
|
6021
|
-
if (value.includes("\n") || value.includes("\r")) return false;
|
|
6022
|
-
return true;
|
|
6023
|
-
}
|
|
6024
|
-
function normalizeDetailedMermaidLabel(value) {
|
|
6025
|
-
return value.split(/\r?\n/).map((line) => line.replace(/\s+/g, " ").trim()).filter((line) => line.length > 0).join("\n");
|
|
6026
|
-
}
|
|
6027
|
-
function toComponentFields(value) {
|
|
6028
|
-
if (!Array.isArray(value)) return [];
|
|
6029
|
-
return value.map((field) => toRecord(field)).filter((field) => field !== void 0);
|
|
6093
|
+
function convertMermaidToReactFlowWithContext(_x3, _x4, _x5) {
|
|
6094
|
+
return _convertMermaidToReactFlowWithContext.apply(this, arguments);
|
|
6030
6095
|
}
|
|
6031
|
-
function
|
|
6032
|
-
|
|
6033
|
-
|
|
6034
|
-
|
|
6035
|
-
const
|
|
6036
|
-
const
|
|
6037
|
-
|
|
6038
|
-
|
|
6039
|
-
|
|
6040
|
-
|
|
6041
|
-
|
|
6042
|
-
|
|
6043
|
-
|
|
6044
|
-
|
|
6045
|
-
|
|
6046
|
-
|
|
6047
|
-
|
|
6048
|
-
const edgeStyle = {};
|
|
6049
|
-
const stroke = pickString(edgeStyleRecord.stroke);
|
|
6050
|
-
if (stroke) edgeStyle.stroke = stroke;
|
|
6051
|
-
if (typeof edgeStyleRecord.strokeWidth === "number") edgeStyle.strokeWidth = edgeStyleRecord.strokeWidth;
|
|
6052
|
-
const strokeStyle = parseStrokeStyle(edgeStyleRecord.strokeDasharray);
|
|
6053
|
-
if (strokeStyle) edgeStyle.strokeStyle = strokeStyle;
|
|
6054
|
-
if (typeof edge.animated === "boolean") edgeStyle.borderAnimationEnabled = edge.animated;
|
|
6055
|
-
if (Object.keys(edgeStyle).length > 0) edgeContext.style = edgeStyle;
|
|
6056
|
-
const markerStart = normalizeMarker(edge.markerStart);
|
|
6057
|
-
if (markerStart) edgeContext.markerStart = markerStart;
|
|
6058
|
-
const markerEnd = normalizeMarker(edge.markerEnd);
|
|
6059
|
-
if (markerEnd) edgeContext.markerEnd = markerEnd;
|
|
6060
|
-
const edgeData = (_toRecord2 = toRecord(edge.data)) !== null && _toRecord2 !== void 0 ? _toRecord2 : {};
|
|
6061
|
-
if (Object.keys(edgeData).length > 0) edgeContext.___internal = edgeData;
|
|
6062
|
-
if (Object.keys(edgeContext).length > 0) contextEdges[`${source}-${target}`] = edgeContext;
|
|
6063
|
-
}
|
|
6064
|
-
return contextEdges;
|
|
6065
|
-
}
|
|
6066
|
-
function buildContextGroups(groupNodes, nodeIdMap) {
|
|
6067
|
-
const contextGroups = {};
|
|
6068
|
-
for (const groupNode of groupNodes) {
|
|
6069
|
-
var _toRecord;
|
|
6070
|
-
const groupData = (_toRecord = toRecord(groupNode.data)) !== null && _toRecord !== void 0 ? _toRecord : {};
|
|
6071
|
-
const childNodes = Array.isArray(groupData.childNodes) ? groupData.childNodes.map((childId) => typeof childId === "string" ? nodeIdMap.get(childId) : void 0).filter((childId) => childId !== void 0) : [];
|
|
6072
|
-
const name = getFieldString(Array.isArray(groupData.componentFields) ? groupData.componentFields.map((field) => toRecord(field)).filter((field) => field !== void 0) : [], "Name");
|
|
6073
|
-
if (!name && childNodes.length === 0) continue;
|
|
6074
|
-
contextGroups[groupNode.id] = {
|
|
6075
|
-
name: name !== null && name !== void 0 ? name : void 0,
|
|
6076
|
-
nodes: childNodes
|
|
6077
|
-
};
|
|
6078
|
-
}
|
|
6079
|
-
return contextGroups;
|
|
6080
|
-
}
|
|
6081
|
-
function buildContextNodes(graphNodes, nodeIdMap) {
|
|
6082
|
-
const contextNodes = {};
|
|
6083
|
-
for (const node of graphNodes) {
|
|
6084
|
-
var _toRecord, _toRecord2, _pickString, _pickString2;
|
|
6085
|
-
const mappedNodeId = nodeIdMap.get(node.id);
|
|
6086
|
-
if (!mappedNodeId) continue;
|
|
6087
|
-
const nodeData = (_toRecord = toRecord(node.data)) !== null && _toRecord !== void 0 ? _toRecord : {};
|
|
6088
|
-
const nodeStyle = (_toRecord2 = toRecord(node.style)) !== null && _toRecord2 !== void 0 ? _toRecord2 : {};
|
|
6089
|
-
const componentFields = Array.isArray(nodeData.componentFields) ? nodeData.componentFields.map((field) => toRecord(field)).filter((field) => field !== void 0) : [];
|
|
6090
|
-
const nodeContext = {};
|
|
6091
|
-
const nodeType = pickString(node.type);
|
|
6092
|
-
if (nodeType) nodeContext.type = nodeType;
|
|
6093
|
-
const nameField = getFieldByLabel(componentFields, "Name");
|
|
6094
|
-
const nameRawValue = nameField ? getFieldValue(nameField.data) : void 0;
|
|
6095
|
-
const name = pickString(nameRawValue);
|
|
6096
|
-
if (name) nodeContext.name = name;
|
|
6097
|
-
const textField = nodeType === "text" ? getFieldByLabel(componentFields, "Text") : void 0;
|
|
6098
|
-
const textRawValue = textField ? getFieldValue(textField.data) : void 0;
|
|
6099
|
-
const textValue = pickString(textRawValue);
|
|
6100
|
-
if (nodeType === "text") {
|
|
6101
|
-
if (textValue) nodeContext.value = textValue;
|
|
6102
|
-
}
|
|
6103
|
-
const codeField = nodeType === "code" ? getFieldByLabel(componentFields, "Code") : void 0;
|
|
6104
|
-
const codeRawValue = codeField ? getFieldValue(codeField.data) : void 0;
|
|
6105
|
-
const codeValue = pickString(codeRawValue);
|
|
6106
|
-
if (nodeType === "code") {
|
|
6107
|
-
if (codeValue) nodeContext.value = codeValue;
|
|
6108
|
-
}
|
|
6109
|
-
const src = pickString(nodeData.src);
|
|
6110
|
-
if (src) nodeContext.src = src;
|
|
6111
|
-
const animatedIcon = pickString(nodeData.animatedIcon);
|
|
6112
|
-
if (animatedIcon) nodeContext.animatedIcon = animatedIcon;
|
|
6113
|
-
const cloud = pickString(nodeData.cloud);
|
|
6114
|
-
if (cloud) nodeContext.cloud = cloud;
|
|
6115
|
-
const service = pickString(nodeData.service);
|
|
6116
|
-
if (service) nodeContext.service = service;
|
|
6117
|
-
const componentId = pickString(nodeData.componentId);
|
|
6118
|
-
if (componentId) nodeContext.componentId = componentId;
|
|
6119
|
-
const shape = pickString(nodeData.shape);
|
|
6120
|
-
if (shape && CONTEXT_SHAPES.has(shape)) nodeContext.shape = shape;
|
|
6121
|
-
const style = {};
|
|
6122
|
-
const width = typeof node.width === "number" ? node.width : typeof nodeStyle.width === "number" ? nodeStyle.width : void 0;
|
|
6123
|
-
if (typeof width === "number") style.width = width;
|
|
6124
|
-
const height = typeof node.height === "number" ? node.height : typeof nodeStyle.height === "number" ? nodeStyle.height : void 0;
|
|
6125
|
-
if (typeof height === "number") style.height = height;
|
|
6126
|
-
const fill = (_pickString = pickString(nodeData.fill)) !== null && _pickString !== void 0 ? _pickString : pickString(nodeStyle.fill);
|
|
6127
|
-
if (fill) style.fill = fill;
|
|
6128
|
-
const stroke = (_pickString2 = pickString(nodeData.stroke)) !== null && _pickString2 !== void 0 ? _pickString2 : pickString(nodeStyle.stroke);
|
|
6129
|
-
if (stroke) style.stroke = stroke;
|
|
6130
|
-
const strokeWidth = typeof nodeData.strokeWidth === "number" ? nodeData.strokeWidth : typeof nodeStyle.strokeWidth === "number" ? nodeStyle.strokeWidth : void 0;
|
|
6131
|
-
if (typeof strokeWidth === "number") style.strokeWidth = strokeWidth;
|
|
6132
|
-
const borderRadius = typeof nodeData.borderRadius === "number" ? nodeData.borderRadius : typeof nodeStyle.borderRadius === "number" ? nodeStyle.borderRadius : void 0;
|
|
6133
|
-
if (typeof borderRadius === "number") style.borderRadius = borderRadius;
|
|
6134
|
-
const strokeStyleFromData = pickString(nodeData.strokeStyle);
|
|
6135
|
-
if (strokeStyleFromData === "solid" || strokeStyleFromData === "dashed" || strokeStyleFromData === "dotted") style.strokeStyle = strokeStyleFromData;
|
|
6136
|
-
else {
|
|
6137
|
-
const strokeStyleFromDash = parseStrokeStyle(nodeStyle.strokeDasharray);
|
|
6138
|
-
if (strokeStyleFromDash) style.strokeStyle = strokeStyleFromDash;
|
|
6139
|
-
}
|
|
6140
|
-
const borderAnimationEnabled = typeof nodeData.borderAnimationEnabled === "boolean" ? nodeData.borderAnimationEnabled : nodeData.strokeAnimation === "dash" ? true : void 0;
|
|
6141
|
-
if (typeof borderAnimationEnabled === "boolean") style.borderAnimationEnabled = borderAnimationEnabled;
|
|
6142
|
-
if (Object.keys(style).length > 0) nodeContext.style = style;
|
|
6143
|
-
const tableColumns = Array.isArray(nodeData.columns) ? nodeData.columns.filter((value) => typeof value === "string") : void 0;
|
|
6144
|
-
const tableRows = Array.isArray(nodeData.rows) ? nodeData.rows.map((row) => Array.isArray(row) ? row.filter((value) => typeof value === "string") : void 0).filter((row) => row !== void 0) : void 0;
|
|
6145
|
-
if (tableColumns || tableRows) nodeContext.table = {
|
|
6146
|
-
columns: tableColumns !== null && tableColumns !== void 0 ? tableColumns : [],
|
|
6147
|
-
rows: tableRows !== null && tableRows !== void 0 ? tableRows : []
|
|
6148
|
-
};
|
|
6149
|
-
const serviceTable = toRecord(nodeData.serviceTable);
|
|
6150
|
-
const serviceName = pickString(serviceTable === null || serviceTable === void 0 ? void 0 : serviceTable.serviceName);
|
|
6151
|
-
const databaseName = pickString(serviceTable === null || serviceTable === void 0 ? void 0 : serviceTable.databaseName);
|
|
6152
|
-
const tableName = pickString(serviceTable === null || serviceTable === void 0 ? void 0 : serviceTable.tableName);
|
|
6153
|
-
if (serviceName && databaseName && tableName) nodeContext.dbConfig = {
|
|
6154
|
-
serviceName,
|
|
6155
|
-
databaseName,
|
|
6156
|
-
tableName
|
|
6157
|
-
};
|
|
6158
|
-
const dynamicData = {};
|
|
6159
|
-
for (const field of componentFields) {
|
|
6160
|
-
const label$1 = pickString(field.label);
|
|
6161
|
-
const type = pickString(field.type);
|
|
6162
|
-
if (!label$1 || !type || !isComponentInputType(type)) continue;
|
|
6163
|
-
const componentType = type;
|
|
6164
|
-
const normalizedLabel = label$1.toLowerCase();
|
|
6165
|
-
if (normalizedLabel === "name") continue;
|
|
6166
|
-
if (nodeType === "text" && normalizedLabel === "text") continue;
|
|
6167
|
-
if (nodeType === "code" && normalizedLabel === "code") continue;
|
|
6168
|
-
const options = Array.isArray(field.options) ? field.options.filter((option) => typeof option === "string") : void 0;
|
|
6169
|
-
dynamicData[label$1] = {
|
|
6170
|
-
type: componentType,
|
|
6171
|
-
value: getFieldValue(field.data),
|
|
6172
|
-
options: options && options.length > 0 ? options : void 0
|
|
6173
|
-
};
|
|
6174
|
-
}
|
|
6175
|
-
if (nameField && !name && isEmptyFieldValue(nameRawValue)) {
|
|
6176
|
-
const nameType = pickString(nameField.type);
|
|
6177
|
-
if (nameType && isComponentInputType(nameType)) {
|
|
6178
|
-
const nameOptions = Array.isArray(nameField.options) ? nameField.options.filter((option) => typeof option === "string") : void 0;
|
|
6179
|
-
dynamicData.Name = {
|
|
6180
|
-
type: nameType,
|
|
6181
|
-
value: "",
|
|
6182
|
-
options: nameOptions && nameOptions.length > 0 ? nameOptions : void 0
|
|
6096
|
+
function _convertMermaidToReactFlowWithContext() {
|
|
6097
|
+
_convertMermaidToReactFlowWithContext = _asyncToGenerator(function* (mermaidCode, context, options) {
|
|
6098
|
+
var _context$groups;
|
|
6099
|
+
const validatedContext = contextSchema.parse(context);
|
|
6100
|
+
const reactFlowData = yield convertMermaidToReactFlow(mermaidCode);
|
|
6101
|
+
const rfNodesPromises = reactFlowData.nodes.map(function() {
|
|
6102
|
+
var _ref = _asyncToGenerator(function* (node) {
|
|
6103
|
+
var _validatedContext$nod, _clonedNode$data$comp, _ctx$data, _clonedNode$data, _ctx$style, _ctx$style2, _ctx$style3, _ctx$style4;
|
|
6104
|
+
const ctx = (_validatedContext$nod = validatedContext.nodes) === null || _validatedContext$nod === void 0 ? void 0 : _validatedContext$nod[node.id];
|
|
6105
|
+
if (!ctx) return node;
|
|
6106
|
+
const clonedNode = JSON.parse(JSON.stringify(node));
|
|
6107
|
+
const componentFields = (_clonedNode$data$comp = clonedNode.data.componentFields) !== null && _clonedNode$data$comp !== void 0 ? _clonedNode$data$comp : [];
|
|
6108
|
+
(_ctx$data = ctx.data) !== null && _ctx$data !== void 0 || (ctx.data = {});
|
|
6109
|
+
(_clonedNode$data = clonedNode.data) !== null && _clonedNode$data !== void 0 || (clonedNode.data = {});
|
|
6110
|
+
if (hasValidPosition(ctx.___position)) clonedNode.position = {
|
|
6111
|
+
x: ctx.___position.x,
|
|
6112
|
+
y: ctx.___position.y
|
|
6183
6113
|
};
|
|
6184
|
-
|
|
6185
|
-
|
|
6186
|
-
|
|
6187
|
-
|
|
6188
|
-
|
|
6189
|
-
|
|
6190
|
-
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6114
|
+
if (ctx.type) {
|
|
6115
|
+
clonedNode.type = ctx.type;
|
|
6116
|
+
delete clonedNode.style;
|
|
6117
|
+
if (ctx.type === "cloud") {
|
|
6118
|
+
clonedNode.height = 150;
|
|
6119
|
+
clonedNode.width = 150;
|
|
6120
|
+
if (ctx.service) {
|
|
6121
|
+
const cloudIcon = (options === null || options === void 0 ? void 0 : options.resolveCloudIcon) ? yield options.resolveCloudIcon(ctx.cloud, ctx.service) : yield resolveCloudIcon(ctx.cloud, ctx.service);
|
|
6122
|
+
if (cloudIcon) clonedNode.data.iconSrc = cloudIcon;
|
|
6123
|
+
}
|
|
6124
|
+
}
|
|
6125
|
+
if (ctx.type === "image" && ctx.src) clonedNode.data = _objectSpread2(_objectSpread2({}, clonedNode.data), {}, { src: ctx.src });
|
|
6126
|
+
if (ctx.type === "gif") {
|
|
6127
|
+
if (ctx.animatedIcon) {
|
|
6128
|
+
const animatedNodeSrc = yield resolveAnimatedNode(ctx.animatedIcon);
|
|
6129
|
+
if (animatedNodeSrc) clonedNode.data = _objectSpread2(_objectSpread2({}, clonedNode.data), {}, { src: animatedNodeSrc });
|
|
6130
|
+
} else if (ctx.src) clonedNode.data = _objectSpread2(_objectSpread2({}, clonedNode.data), {}, { src: ctx.src });
|
|
6131
|
+
}
|
|
6132
|
+
if (ctx.type === "text" && (ctx.value || ctx.name)) {
|
|
6133
|
+
const textComponentField = generateComponentFieldInput({
|
|
6134
|
+
type: ComponentInputType.TextInput,
|
|
6135
|
+
componentFieldId: "text",
|
|
6136
|
+
label: "Text",
|
|
6137
|
+
data: ctx.value || ctx.name,
|
|
6138
|
+
isReadonly: true
|
|
6139
|
+
});
|
|
6140
|
+
componentFields.unshift(textComponentField);
|
|
6141
|
+
}
|
|
6142
|
+
if (ctx.type === "code" && ctx.value) {
|
|
6143
|
+
const textComponentField = generateComponentFieldInput({
|
|
6144
|
+
type: ComponentInputType.CodeEditor,
|
|
6145
|
+
componentFieldId: "code",
|
|
6146
|
+
label: "Code",
|
|
6147
|
+
data: ctx.value,
|
|
6148
|
+
isReadonly: true
|
|
6149
|
+
});
|
|
6150
|
+
componentFields.unshift(textComponentField);
|
|
6151
|
+
}
|
|
6152
|
+
if (ctx.type === "table" && ctx.table) {
|
|
6153
|
+
var _ctx$table$rows, _ctx$table$columns;
|
|
6154
|
+
clonedNode.data.title = ctx.name;
|
|
6155
|
+
clonedNode.data.rows = (_ctx$table$rows = ctx.table.rows) !== null && _ctx$table$rows !== void 0 ? _ctx$table$rows : [];
|
|
6156
|
+
clonedNode.data.columns = (_ctx$table$columns = ctx.table.columns) !== null && _ctx$table$columns !== void 0 ? _ctx$table$columns : [];
|
|
6157
|
+
}
|
|
6158
|
+
if (ctx.type === "data-source" || ctx.type === "db-table") {
|
|
6159
|
+
ctx.type = "databaseTableSQL";
|
|
6160
|
+
clonedNode.type = "databaseTableSQL";
|
|
6161
|
+
}
|
|
6162
|
+
if (ctx.type === "component") {
|
|
6163
|
+
ctx.type = "builder";
|
|
6164
|
+
clonedNode.type = "builder";
|
|
6165
|
+
clonedNode.data.componentId = ctx.componentId;
|
|
6166
|
+
}
|
|
6167
|
+
if (ctx.type === "shape" && ctx.shape) {
|
|
6168
|
+
clonedNode.data.shape = ctx.shape;
|
|
6169
|
+
if (ctx.shape === "or" || ctx.shape === "summing-junction") {
|
|
6170
|
+
var _clonedNode$width, _clonedNode$height;
|
|
6171
|
+
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);
|
|
6172
|
+
clonedNode.width = maxSize;
|
|
6173
|
+
clonedNode.height = maxSize;
|
|
6174
|
+
}
|
|
6175
|
+
}
|
|
6176
|
+
}
|
|
6177
|
+
if (ctx.name) ctx.data["Name"] = {
|
|
6178
|
+
type: ComponentInputType.TextInput,
|
|
6179
|
+
value: ctx.name
|
|
6194
6180
|
};
|
|
6195
|
-
|
|
6196
|
-
|
|
6197
|
-
|
|
6198
|
-
|
|
6199
|
-
|
|
6200
|
-
|
|
6201
|
-
|
|
6202
|
-
|
|
6203
|
-
|
|
6204
|
-
|
|
6181
|
+
for (const key in ctx.data) {
|
|
6182
|
+
const metaInput = ctx.data[key];
|
|
6183
|
+
if (metaInput === void 0) continue;
|
|
6184
|
+
const componentField = getComponentFieldByLabel(componentFields, key);
|
|
6185
|
+
const newComponentField = generateComponentFieldInput({
|
|
6186
|
+
label: key,
|
|
6187
|
+
type: metaInput.type,
|
|
6188
|
+
data: metaInput.value,
|
|
6189
|
+
options: metaInput.options
|
|
6190
|
+
});
|
|
6191
|
+
if (!componentField) componentFields.push(newComponentField);
|
|
6192
|
+
else {
|
|
6193
|
+
componentField.type = newComponentField.type;
|
|
6194
|
+
componentField.data = newComponentField.data;
|
|
6195
|
+
}
|
|
6196
|
+
}
|
|
6197
|
+
if (ctx.dbConfig) clonedNode.data.serviceTable = {
|
|
6198
|
+
serviceName: ctx.dbConfig.serviceName,
|
|
6199
|
+
databaseName: ctx.dbConfig.databaseName,
|
|
6200
|
+
tableName: ctx.dbConfig.tableName
|
|
6205
6201
|
};
|
|
6206
|
-
|
|
6207
|
-
|
|
6208
|
-
|
|
6209
|
-
|
|
6210
|
-
|
|
6211
|
-
|
|
6212
|
-
|
|
6213
|
-
|
|
6214
|
-
|
|
6215
|
-
|
|
6216
|
-
|
|
6217
|
-
|
|
6218
|
-
|
|
6219
|
-
|
|
6220
|
-
|
|
6221
|
-
|
|
6222
|
-
|
|
6223
|
-
|
|
6224
|
-
|
|
6225
|
-
|
|
6226
|
-
|
|
6227
|
-
}
|
|
6228
|
-
|
|
6229
|
-
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
|
|
6235
|
-
|
|
6236
|
-
|
|
6202
|
+
if ((_ctx$style = ctx.style) === null || _ctx$style === void 0 ? void 0 : _ctx$style.height) clonedNode.height = ctx.style.height;
|
|
6203
|
+
if ((_ctx$style2 = ctx.style) === null || _ctx$style2 === void 0 ? void 0 : _ctx$style2.width) clonedNode.width = ctx.style.width;
|
|
6204
|
+
clonedNode.data = _objectSpread2(_objectSpread2(_objectSpread2({}, clonedNode.data), objectPick((_ctx$style3 = ctx.style) !== null && _ctx$style3 !== void 0 ? _ctx$style3 : {}, [
|
|
6205
|
+
"color",
|
|
6206
|
+
"fill",
|
|
6207
|
+
"stroke",
|
|
6208
|
+
"strokeWidth",
|
|
6209
|
+
"strokeStyle",
|
|
6210
|
+
"borderRadius",
|
|
6211
|
+
"borderAnimationEnabled"
|
|
6212
|
+
])), {}, {
|
|
6213
|
+
componentFields,
|
|
6214
|
+
strokeAnimation: ((_ctx$style4 = ctx.style) === null || _ctx$style4 === void 0 ? void 0 : _ctx$style4.borderAnimationEnabled) ? "dash" : void 0
|
|
6215
|
+
}, ctx === null || ctx === void 0 ? void 0 : ctx.___internal);
|
|
6216
|
+
return clonedNode;
|
|
6217
|
+
});
|
|
6218
|
+
return function(_x) {
|
|
6219
|
+
return _ref.apply(this, arguments);
|
|
6220
|
+
};
|
|
6221
|
+
}());
|
|
6222
|
+
const resolvedNodes = yield Promise.all(rfNodesPromises);
|
|
6223
|
+
const groupNodes = Object.entries((_context$groups = context.groups) !== null && _context$groups !== void 0 ? _context$groups : {}).map(([nodeId, groupCtx]) => {
|
|
6224
|
+
var _groupCtx$nodes, _groupCtx$name;
|
|
6225
|
+
const childNodes = arrayNonNullable(((_groupCtx$nodes = groupCtx.nodes) !== null && _groupCtx$nodes !== void 0 ? _groupCtx$nodes : []).map((nodeId$1) => resolvedNodes.find((n) => n.id === nodeId$1)));
|
|
6226
|
+
return generateGroupNodeFromNodes(nodeId, (_groupCtx$name = groupCtx.name) !== null && _groupCtx$name !== void 0 ? _groupCtx$name : "Group", childNodes);
|
|
6227
|
+
});
|
|
6228
|
+
const rfEdgesPromises = reactFlowData.edges.map(function() {
|
|
6229
|
+
var _ref2 = _asyncToGenerator(function* (edge) {
|
|
6230
|
+
var _validatedContext$edg, _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;
|
|
6231
|
+
const ctx = (_validatedContext$edg = validatedContext.edges) === null || _validatedContext$edg === void 0 ? void 0 : _validatedContext$edg[`${edge.source}-${edge.target}`];
|
|
6232
|
+
if (!ctx) return edge;
|
|
6233
|
+
return _objectSpread2(_objectSpread2({}, edge), {}, {
|
|
6234
|
+
type: (_ctx$type = ctx.type) !== null && _ctx$type !== void 0 ? _ctx$type : edge.type,
|
|
6235
|
+
sourceHandle: (_ctx$sourceHandle = ctx.sourceHandle) !== null && _ctx$sourceHandle !== void 0 ? _ctx$sourceHandle : edge.sourceHandle,
|
|
6236
|
+
targetHandle: (_ctx$targetHandle = ctx.targetHandle) !== null && _ctx$targetHandle !== void 0 ? _ctx$targetHandle : edge.targetHandle,
|
|
6237
|
+
markerStart: (_normalizeContextMark = normalizeContextMarker(ctx.markerStart)) !== null && _normalizeContextMark !== void 0 ? _normalizeContextMark : edge.markerStart,
|
|
6238
|
+
markerEnd: (_normalizeContextMark2 = normalizeContextMarker(ctx.markerEnd)) !== null && _normalizeContextMark2 !== void 0 ? _normalizeContextMark2 : edge.markerEnd,
|
|
6239
|
+
data: _objectSpread2(_objectSpread2({}, edge.data), ctx === null || ctx === void 0 ? void 0 : ctx.___internal),
|
|
6240
|
+
label: (_ctx$label = ctx.label) !== null && _ctx$label !== void 0 ? _ctx$label : edge.label,
|
|
6241
|
+
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,
|
|
6242
|
+
style: _objectSpread2(_objectSpread2({}, edge.style), {}, {
|
|
6243
|
+
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,
|
|
6244
|
+
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,
|
|
6245
|
+
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
|
|
6246
|
+
})
|
|
6247
|
+
});
|
|
6248
|
+
});
|
|
6249
|
+
return function(_x2) {
|
|
6250
|
+
return _ref2.apply(this, arguments);
|
|
6251
|
+
};
|
|
6252
|
+
}());
|
|
6253
|
+
const resolvedEdges = yield Promise.all(rfEdgesPromises);
|
|
6254
|
+
const combinedNodes = [...groupNodes, ...resolvedNodes.map((node) => {
|
|
6255
|
+
const nodeParent = groupNodes.find((groupNode) => {
|
|
6256
|
+
var _groupNode$data$child;
|
|
6257
|
+
return (_groupNode$data$child = groupNode.data.childNodes) === null || _groupNode$data$child === void 0 ? void 0 : _groupNode$data$child.includes(node.id);
|
|
6258
|
+
});
|
|
6259
|
+
if (nodeParent) return _objectSpread2(_objectSpread2({}, node), {}, { parentId: nodeParent.id });
|
|
6260
|
+
return node;
|
|
6261
|
+
})];
|
|
6262
|
+
if (isSequenceDiagram(combinedNodes)) return {
|
|
6263
|
+
edges: resolvedEdges,
|
|
6264
|
+
nodes: combinedNodes
|
|
6265
|
+
};
|
|
6266
|
+
return {
|
|
6267
|
+
edges: resolvedEdges,
|
|
6268
|
+
nodes: (options === null || options === void 0 ? void 0 : options.repositionNodes) ? resizeNodesLayouts(combinedNodes) : combinedNodes
|
|
6269
|
+
};
|
|
6270
|
+
});
|
|
6271
|
+
return _convertMermaidToReactFlowWithContext.apply(this, arguments);
|
|
6237
6272
|
}
|
|
6238
6273
|
function inferDirection(nodes, edges) {
|
|
6239
6274
|
const nodeMap = new Map(nodes.map((node) => [node.id, node]));
|
|
@@ -6591,4 +6626,4 @@ function convertUiGraphToMermaid(input, options) {
|
|
|
6591
6626
|
context
|
|
6592
6627
|
};
|
|
6593
6628
|
}
|
|
6594
|
-
export { AstToSqlGenerator, AstToUiConverter, BasicDetailsSchema, C4_COLORS, C4_LAYOUT, ComponentInputType, DialectIdSchema, DocumentCollectionSchema, DocumentIndexSchema, DynamoAttributeSchema, DynamoEditorSchema, DynamoGsiSchema, EditorSupportedDialectSchema, JsonEditorSchema, MongoCollectionSchema, MongoEditorSchema, MongoIndexFieldSchema, MongoIndexSchema, MongoNestedFieldSchema, NestedFieldSchema, NoSqlFieldSchema, SEQUENCE_LAYOUT, SqlToAstParser, buildMetaData, contextSchema, convertC4MermaidToReactFlow, convertC4ToReactFlow, convertDynamoSchemaToAst, convertJsonSchemaToAst, convertMermaidToReactFlow, convertMermaidToReactFlowWithContext, convertMongoSchemaToAst, convertNoSQLToAst, convertReactFlowToSequenceMermaid, convertUiGraphToMermaid, estimateSequenceMessageBoxSize, flattenMetaData, generateTableNodeId, generateUUID, getC4ElementColors, isC4Diagram, isSequenceDiagram, parseC4Diagram, sanitizeMermaidLabels, syncBaseData };
|
|
6629
|
+
export { AstToSqlGenerator, AstToUiConverter, BasicDetailsSchema, C4_COLORS, C4_LAYOUT, ComponentInputType, DialectIdSchema, DocumentCollectionSchema, DocumentIndexSchema, DynamoAttributeSchema, DynamoEditorSchema, DynamoGsiSchema, EditorSupportedDialectSchema, JsonEditorSchema, MongoCollectionSchema, MongoEditorSchema, MongoIndexFieldSchema, MongoIndexSchema, MongoNestedFieldSchema, NestedFieldSchema, NoSqlFieldSchema, SEQUENCE_LAYOUT, SqlToAstParser, buildMetaData, contextSchema, convertC4MermaidToReactFlow, convertC4ToReactFlow, convertDynamoSchemaToAst, convertJsonSchemaToAst, convertMermaidToReactFlow, convertMermaidToReactFlowWithContext, convertMongoSchemaToAst, convertNoSQLToAst, convertReactFlowToSequenceMermaid, convertReactFlowToSequenceUiGraph, convertUiGraphToMermaid, estimateSequenceMessageBoxSize, flattenMetaData, generateTableNodeId, generateUUID, getC4ElementColors, isC4Diagram, isSequenceDiagram, parseC4Diagram, sanitizeMermaidLabels, syncBaseData };
|