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