state-machine-cat 12.0.17 → 12.0.18

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.
@@ -1,77 +0,0 @@
1
- import he from "he";
2
- import { getOptionValue } from "../../options.mjs";
3
- export function escapeString(pString) {
4
- return pString
5
- .replace(/\\/g, "\\\\")
6
- .replace(/\n\s*/g, "\\l")
7
- .replace(/"/g, '\\"')
8
- .concat("\\l");
9
- }
10
- export function escapeLabelString(pString) {
11
- return pString
12
- .replace(/\\/g, "\\\\")
13
- .replace(/\n\s*/g, " \\l")
14
- .replace(/"/g, '\\"')
15
- .concat(" \\l");
16
- }
17
- export function isVertical(pDirection) {
18
- const lDirection = pDirection || "top-down";
19
- return lDirection === "top-down" || lDirection === "bottom-top";
20
- }
21
- export function isCompositeSelf(pStateMachineModel, pTransition) {
22
- return (
23
- pTransition.from === pTransition.to &&
24
- pStateMachineModel.findStateByName(pTransition.from).statemachine &&
25
- pTransition.type !== "internal"
26
- );
27
- }
28
- export function noteToLabel(pNote) {
29
- return pNote.map(escapeString).join("");
30
- }
31
- export function stateNote(pState, pIndent) {
32
- if (pState.note) {
33
- const lNoteName = `note_${pState.name}`;
34
- let lReturnValue = `\n${pIndent} "${lNoteName}" [color=black fontcolor=black label="${noteToLabel(pState.note)}" shape=note fontsize=10 fillcolor="#ffffcc" penwidth=1.0]`;
35
- lReturnValue += `\n${pIndent} "${pState.name}" -> "${lNoteName}" [style=dashed arrowtail=none arrowhead=none]`;
36
- return lReturnValue;
37
- }
38
- return "";
39
- }
40
- export function normalizeState(pState, pIndent) {
41
- const lReturnValue = structuredClone(pState);
42
- lReturnValue.color = pState.color ?? "black";
43
- lReturnValue.class = pState.class
44
- ? `state ${pState.type} ${pState.class}`
45
- : `state ${pState.type}`;
46
- lReturnValue.label = he.escape(pState.label ?? pState.name);
47
- lReturnValue.noteText = stateNote(pState, pIndent);
48
- if (
49
- !pState.isParallelArea &&
50
- pState.type === "parallel" &&
51
- (pState.statemachine?.states ?? []).length > 0
52
- ) {
53
- lReturnValue.statemachine.states = pState.statemachine.states.map(
54
- (pChildState) => ({
55
- ...pChildState,
56
- isParallelArea: pChildState.type === "regular",
57
- }),
58
- );
59
- }
60
- return lReturnValue;
61
- }
62
- export function formatActionType(pString) {
63
- return pString === "activity" ? "" : `${pString}/ `;
64
- }
65
- export function getTransitionPorts(pOptions, pModel, pTransition) {
66
- let lTailPorts = 'tailport="n" headport="n" ';
67
- let lHeadPorts = 'tailport="n" ';
68
- const lDirection = getOptionValue(pOptions, "direction");
69
- if (isVertical(lDirection)) {
70
- lTailPorts = 'tailport="e" headport="e" ';
71
- lHeadPorts = 'tailport="w" ';
72
- } else if (pModel.findStateByName(pTransition.from).hasParent) {
73
- lTailPorts = 'tailport="n" headport="n" ';
74
- lHeadPorts = 'tailport="s" ';
75
- }
76
- return { lTailPorts, lHeadPorts };
77
- }