@grethel-labs/excaliplant 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -1
- package/package.json +1 -1
- package/src/diagrams/activity/assets.mjs +16 -0
- package/src/diagrams/activity/docs.mjs +20 -0
- package/src/diagrams/activity/layout.mjs +31 -0
- package/src/diagrams/activity/module.mjs +80 -0
- package/src/diagrams/activity/parser.mjs +74 -0
- package/src/diagrams/activity/plugins/syntax.mjs +550 -0
- package/src/diagrams/activity/render.mjs +36 -0
- package/src/diagrams/activity/security.mjs +19 -0
- package/src/diagrams/activity/tests/activity_components.test.mjs +206 -0
- package/src/diagrams/activity/tests.mjs +20 -0
- package/src/diagrams/index.mjs +14 -0
- package/src/main/builtin.mjs +11 -1
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://nodejs.org)
|
|
8
8
|
[](./LICENSE)
|
|
9
9
|
|
|
10
|
-
> PlantUML → ELK layout → Excalidraw renderer with a plugin-based parser. · **v0.
|
|
10
|
+
> PlantUML → ELK layout → Excalidraw renderer with a plugin-based parser. · **v0.12.0** · 210 tests · MIT
|
|
11
11
|
|
|
12
12
|
`@grethel-labs/excaliplant` takes PlantUML source, runs it through a plugin-based
|
|
13
13
|
parser, lays it out with [ELK](https://github.com/kieler/elkjs), and
|
|
@@ -262,6 +262,17 @@ excaliplant
|
|
|
262
262
|
│ └── smoke.mjs
|
|
263
263
|
├── src
|
|
264
264
|
│ ├── diagrams
|
|
265
|
+
│ │ ├── activity
|
|
266
|
+
│ │ │ ├── plugins
|
|
267
|
+
│ │ │ ├── tests
|
|
268
|
+
│ │ │ ├── assets.mjs
|
|
269
|
+
│ │ │ ├── docs.mjs
|
|
270
|
+
│ │ │ ├── layout.mjs
|
|
271
|
+
│ │ │ ├── module.mjs
|
|
272
|
+
│ │ │ ├── parser.mjs
|
|
273
|
+
│ │ │ ├── render.mjs
|
|
274
|
+
│ │ │ ├── security.mjs
|
|
275
|
+
│ │ │ └── tests.mjs
|
|
265
276
|
│ │ ├── base
|
|
266
277
|
│ │ │ ├── artifacts.mjs
|
|
267
278
|
│ │ │ ├── assets.mjs
|
|
@@ -403,6 +414,7 @@ excaliplant
|
|
|
403
414
|
├── tests
|
|
404
415
|
│ ├── helpers
|
|
405
416
|
│ │ └── output.mjs
|
|
417
|
+
│ ├── activity_components.test.mjs
|
|
406
418
|
│ ├── class_components.test.mjs
|
|
407
419
|
│ ├── component_components.test.mjs
|
|
408
420
|
│ ├── deployment_components.test.mjs
|
|
@@ -446,6 +458,46 @@ generated by the same command from JSDoc.
|
|
|
446
458
|
|
|
447
459
|
|
|
448
460
|
|
|
461
|
+
### diagrams/activity/assets
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
### diagrams/activity/docs
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
|
|
469
|
+
### diagrams/activity/layout
|
|
470
|
+
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
### diagrams/activity/module
|
|
474
|
+
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
### diagrams/activity/parser
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
### diagrams/activity/plugins/syntax
|
|
482
|
+
|
|
483
|
+
|
|
484
|
+
|
|
485
|
+
### diagrams/activity/render
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
|
|
489
|
+
### diagrams/activity/security
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
|
|
493
|
+
### diagrams/activity/tests
|
|
494
|
+
|
|
495
|
+
|
|
496
|
+
|
|
497
|
+
### diagrams/activity/tests/activity_components
|
|
498
|
+
|
|
499
|
+
|
|
500
|
+
|
|
449
501
|
### diagrams/base
|
|
450
502
|
|
|
451
503
|
|
package/package.json
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Activity diagram asset manifest.
|
|
3
|
+
* @module diagrams/activity/assets
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { BaseModuleAssets } from "../base/assets.mjs";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Activity diagram asset manifest.
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export class ActivityDiagramAssets extends BaseModuleAssets {
|
|
13
|
+
constructor() {
|
|
14
|
+
super({});
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Activity diagram documentation manifest.
|
|
3
|
+
* @module diagrams/activity/docs
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { BaseModuleDocs } from "../base/docs.mjs";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Activity diagram documentation manifest.
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export class ActivityDiagramDocs extends BaseModuleDocs {
|
|
13
|
+
constructor() {
|
|
14
|
+
super({
|
|
15
|
+
examples: ["basic", "conditions", "loops", "parallel", "swimlanes", "legacy"],
|
|
16
|
+
generatedPages: [],
|
|
17
|
+
knownGaps: [],
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Activity diagram layout engine.
|
|
3
|
+
* @module diagrams/activity/layout
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { BaseModuleLayout } from "../base/layout.mjs";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Activity diagram layout contract.
|
|
10
|
+
* Uses a custom flow layout algorithm for activity diagrams.
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export class ActivityDiagramLayout extends BaseModuleLayout {
|
|
14
|
+
constructor() {
|
|
15
|
+
super({
|
|
16
|
+
layoutStrategy: "flow",
|
|
17
|
+
layout: (diagram, options = {}) => {
|
|
18
|
+
// TODO: Implement flow layout for activity diagrams
|
|
19
|
+
// This includes:
|
|
20
|
+
// - Positioning actions in flow order
|
|
21
|
+
// - Layout for branches (if/switch)
|
|
22
|
+
// - Layout for loops (while/repeat)
|
|
23
|
+
// - Layout for fork/split (parallel flows)
|
|
24
|
+
// - Swimlane positioning
|
|
25
|
+
|
|
26
|
+
// For now, return diagram with minimal layout
|
|
27
|
+
return diagram;
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in activity diagram module.
|
|
3
|
+
* @module diagrams/activity/module
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { BaseDiagramModule } from "../base/module.mjs";
|
|
7
|
+
import { ActivityDiagramAssets } from "./assets.mjs";
|
|
8
|
+
import { ActivityDiagramDocs } from "./docs.mjs";
|
|
9
|
+
import { ActivityDiagramLayout } from "./layout.mjs";
|
|
10
|
+
import { ActivityDiagramParser } from "./parser.mjs";
|
|
11
|
+
import { ActivityDiagramRenderer } from "./render.mjs";
|
|
12
|
+
import { ActivityDiagramSecurity } from "./security.mjs";
|
|
13
|
+
import { ActivityDiagramTests } from "./tests.mjs";
|
|
14
|
+
|
|
15
|
+
/** @public */
|
|
16
|
+
export class ActivityDiagramModule extends BaseDiagramModule {
|
|
17
|
+
constructor() {
|
|
18
|
+
super({
|
|
19
|
+
kind: "activity",
|
|
20
|
+
artifactRoot: "src/diagrams/activity",
|
|
21
|
+
ownedArtifacts: {
|
|
22
|
+
parser: ["src/diagrams/activity/parser.mjs", "src/diagrams/activity/plugins/syntax.mjs"],
|
|
23
|
+
model: ["src/general/model/diagram.mjs"],
|
|
24
|
+
style: [],
|
|
25
|
+
layout: ["src/diagrams/activity/layout.mjs"],
|
|
26
|
+
render: ["src/diagrams/activity/render.mjs"],
|
|
27
|
+
security: ["src/diagrams/activity/security.mjs"],
|
|
28
|
+
assets: ["src/diagrams/activity/assets.mjs"],
|
|
29
|
+
docs: ["src/diagrams/activity/docs.mjs"],
|
|
30
|
+
tests: [
|
|
31
|
+
"src/diagrams/activity/tests.mjs",
|
|
32
|
+
"src/diagrams/activity/tests/activity_components.test.mjs",
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
startDirectives: ["@startuml", "@startactivity"],
|
|
36
|
+
parser: new ActivityDiagramParser(),
|
|
37
|
+
layout: new ActivityDiagramLayout(),
|
|
38
|
+
renderer: new ActivityDiagramRenderer(),
|
|
39
|
+
docs: new ActivityDiagramDocs(),
|
|
40
|
+
tests: new ActivityDiagramTests(),
|
|
41
|
+
security: new ActivityDiagramSecurity(),
|
|
42
|
+
assets: new ActivityDiagramAssets(),
|
|
43
|
+
dependencies: [
|
|
44
|
+
{
|
|
45
|
+
kind: "security-base",
|
|
46
|
+
versionRange: "^1.0.0",
|
|
47
|
+
capabilities: ["sanitize", "limits"],
|
|
48
|
+
optional: false,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
kind: "style-base",
|
|
52
|
+
versionRange: "^1.0.0",
|
|
53
|
+
capabilities: ["style-cascade"],
|
|
54
|
+
optional: false,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
kind: "text-base",
|
|
58
|
+
versionRange: "^1.0.0",
|
|
59
|
+
capabilities: ["inline-text"],
|
|
60
|
+
optional: false,
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
kind: "arrow-base",
|
|
64
|
+
versionRange: "^1.0.0",
|
|
65
|
+
capabilities: ["diagram-arrow"],
|
|
66
|
+
optional: false,
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
kind: "asset-base",
|
|
70
|
+
versionRange: "^1.0.0",
|
|
71
|
+
capabilities: ["packaged-assets"],
|
|
72
|
+
optional: false,
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** @public */
|
|
80
|
+
export const activityDiagramModule = new ActivityDiagramModule();
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Activity diagram parser contract and detection.
|
|
3
|
+
* @module diagrams/activity/parser
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { BaseModuleParser } from "../base/parser.mjs";
|
|
7
|
+
import { activitySyntaxPlugin } from "./plugins/syntax.mjs";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Default plugins for activity diagram parsing.
|
|
11
|
+
* @type {Array<object>}
|
|
12
|
+
*/
|
|
13
|
+
export const DEFAULT_ACTIVITY_PLUGINS = [activitySyntaxPlugin];
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Detect if content is an activity diagram.
|
|
17
|
+
* @param {string[]} lines - PlantUML source lines
|
|
18
|
+
* @returns {boolean}
|
|
19
|
+
*/
|
|
20
|
+
function detectActivity(lines) {
|
|
21
|
+
// Ensure lines is an array
|
|
22
|
+
if (!Array.isArray(lines)) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Check for activity-specific directives or syntax patterns
|
|
27
|
+
const firstNonEmpty = lines.find((l) => l.trim().length > 0);
|
|
28
|
+
if (!firstNonEmpty) return false;
|
|
29
|
+
|
|
30
|
+
const trimmed = firstNonEmpty.trim().toLowerCase();
|
|
31
|
+
if (trimmed.startsWith("@startactivity")) return true;
|
|
32
|
+
|
|
33
|
+
// Check for activity-specific keywords in first 20 lines
|
|
34
|
+
const activityKeywords = [
|
|
35
|
+
/^start\s*$/i,
|
|
36
|
+
/^stop\s*$/i,
|
|
37
|
+
/^end\s*$/i,
|
|
38
|
+
/^:.*;\s*$/i,
|
|
39
|
+
/^if\s+\(/i,
|
|
40
|
+
/^while\s+\(/i,
|
|
41
|
+
/^repeat\s*$/i,
|
|
42
|
+
/^fork\s*$/i,
|
|
43
|
+
/^split\s*$/i,
|
|
44
|
+
/^\|[^|]+\|\s*$/i, // Swimlane syntax
|
|
45
|
+
];
|
|
46
|
+
|
|
47
|
+
const sample = lines.slice(0, 20).join("\n");
|
|
48
|
+
return activityKeywords.some((pattern) => pattern.test(sample));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Activity diagram parser contract.
|
|
53
|
+
* @public
|
|
54
|
+
*/
|
|
55
|
+
export class ActivityDiagramParser extends BaseModuleParser {
|
|
56
|
+
constructor() {
|
|
57
|
+
super({
|
|
58
|
+
plugins: DEFAULT_ACTIVITY_PLUGINS,
|
|
59
|
+
detect: (/** @type {string} */ text) => {
|
|
60
|
+
const lines = text.split("\n");
|
|
61
|
+
return detectActivity(lines);
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Detect if content is an activity diagram.
|
|
69
|
+
* @param {string[]} lines - PlantUML source lines
|
|
70
|
+
* @returns {boolean}
|
|
71
|
+
*/
|
|
72
|
+
export function detectActivityDiagram(lines) {
|
|
73
|
+
return detectActivity(lines);
|
|
74
|
+
}
|
|
@@ -0,0 +1,550 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Activity diagram syntax parser plugins.
|
|
3
|
+
* @module diagrams/activity/plugins/syntax
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { stripComment } from "../../../util/plantuml_utils.mjs";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Activity node types.
|
|
10
|
+
* @enum {string}
|
|
11
|
+
*/
|
|
12
|
+
export const ActivityNodeType = {
|
|
13
|
+
START: "start",
|
|
14
|
+
STOP: "stop",
|
|
15
|
+
END: "end",
|
|
16
|
+
ACTION: "action",
|
|
17
|
+
DECISION: "decision",
|
|
18
|
+
SWITCH: "switch",
|
|
19
|
+
WHILE: "while",
|
|
20
|
+
REPEAT: "repeat",
|
|
21
|
+
FORK: "fork",
|
|
22
|
+
SPLIT: "split",
|
|
23
|
+
CONNECTOR: "connector",
|
|
24
|
+
SWIMLANE: "swimlane",
|
|
25
|
+
PARTITION: "partition",
|
|
26
|
+
NOTE: "note",
|
|
27
|
+
KILL: "kill",
|
|
28
|
+
DETACH: "detach",
|
|
29
|
+
LABEL: "label",
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Parse action text with optional styling.
|
|
34
|
+
* @param {string} text - Raw action text
|
|
35
|
+
* @returns {{text: string, style?: object}}
|
|
36
|
+
*/
|
|
37
|
+
function parseActionText(text) {
|
|
38
|
+
// Handle color prefix like #HotPink:action text
|
|
39
|
+
const colorMatch = text.match(/^#(\w+):(.*)$/);
|
|
40
|
+
if (colorMatch) {
|
|
41
|
+
return {
|
|
42
|
+
text: colorMatch[2].trim(),
|
|
43
|
+
style: { backgroundColor: colorMatch[1] },
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
return { text: text.trim() };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Plugin for activity start/stop/end keywords.
|
|
51
|
+
* @type {object}
|
|
52
|
+
*/
|
|
53
|
+
export const activityControlPlugin = {
|
|
54
|
+
name: "activity.control",
|
|
55
|
+
/** @type {(line: string, ctx: any) => boolean} */
|
|
56
|
+
tryLine: (line, ctx) => {
|
|
57
|
+
const clean = stripComment(line).trim();
|
|
58
|
+
if (!clean) return false;
|
|
59
|
+
|
|
60
|
+
const lower = clean.toLowerCase();
|
|
61
|
+
|
|
62
|
+
if (lower === "start") {
|
|
63
|
+
ctx.addNode({ type: ActivityNodeType.START, id: "start" });
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (lower === "stop" || lower === "end") {
|
|
68
|
+
ctx.addNode({ type: ActivityNodeType.STOP, id: lower });
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (lower === "kill") {
|
|
73
|
+
ctx.addNode({ type: ActivityNodeType.KILL, id: `kill_${ctx.nodeCount}` });
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (lower === "detach") {
|
|
78
|
+
ctx.addNode({ type: ActivityNodeType.DETACH, id: `detach_${ctx.nodeCount}` });
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return false;
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Plugin for activity actions (:action; syntax).
|
|
88
|
+
* @type {object}
|
|
89
|
+
*/
|
|
90
|
+
export const activityActionPlugin = {
|
|
91
|
+
name: "activity.action",
|
|
92
|
+
/** @type {(line: string, ctx: any) => boolean} */
|
|
93
|
+
tryLine: (line, ctx) => {
|
|
94
|
+
const clean = stripComment(line).trim();
|
|
95
|
+
if (!clean) return false;
|
|
96
|
+
|
|
97
|
+
// Match :action; syntax (including multiline)
|
|
98
|
+
const match = clean.match(/^:(.+);$/s);
|
|
99
|
+
if (!match) return false;
|
|
100
|
+
|
|
101
|
+
const parsed = parseActionText(match[1]);
|
|
102
|
+
/** @type {any} */
|
|
103
|
+
const node = {
|
|
104
|
+
type: ActivityNodeType.ACTION,
|
|
105
|
+
id: `action_${ctx.nodeCount}`,
|
|
106
|
+
text: parsed.text,
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
if (parsed.style) {
|
|
110
|
+
node.style = parsed.style;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Check for stereotypes like <<object>>
|
|
114
|
+
const stereoMatch = parsed.text.match(/(.+?)\s*<<(\w+)>>\s*$/);
|
|
115
|
+
if (stereoMatch) {
|
|
116
|
+
node.text = stereoMatch[1].trim();
|
|
117
|
+
node.stereotype = stereoMatch[2];
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
ctx.addNode(node);
|
|
121
|
+
return true;
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Plugin for simple list actions (- Action or * Action).
|
|
127
|
+
* @type {object}
|
|
128
|
+
*/
|
|
129
|
+
export const activityListActionPlugin = {
|
|
130
|
+
name: "activity.list_action",
|
|
131
|
+
/** @type {(line: string, ctx: any) => boolean} */
|
|
132
|
+
tryLine: (line, ctx) => {
|
|
133
|
+
const clean = stripComment(line).trim();
|
|
134
|
+
if (!clean) return false;
|
|
135
|
+
|
|
136
|
+
// Match - Action or * Action with optional nesting
|
|
137
|
+
const match = clean.match(/^([-*]+)\s+(.+)$/);
|
|
138
|
+
if (!match) return false;
|
|
139
|
+
|
|
140
|
+
const level = match[1].length;
|
|
141
|
+
const text = match[2];
|
|
142
|
+
|
|
143
|
+
ctx.addNode({
|
|
144
|
+
type: ActivityNodeType.ACTION,
|
|
145
|
+
id: `action_${ctx.nodeCount}`,
|
|
146
|
+
text,
|
|
147
|
+
level,
|
|
148
|
+
});
|
|
149
|
+
return true;
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Plugin for if/then/else/elseif/endif conditions.
|
|
155
|
+
* @type {object}
|
|
156
|
+
*/
|
|
157
|
+
export const activityIfPlugin = {
|
|
158
|
+
name: "activity.if",
|
|
159
|
+
/** @type {(line: string, ctx: any) => object|null} */
|
|
160
|
+
tryStart: (line, ctx) => {
|
|
161
|
+
const clean = stripComment(line).trim();
|
|
162
|
+
if (!clean) return null;
|
|
163
|
+
|
|
164
|
+
// Match if (condition) then (label)
|
|
165
|
+
const ifMatch = clean.match(/^if\s*\((.+?)\)\s*then\s*(?:\((.+?)\))?/i);
|
|
166
|
+
if (ifMatch) {
|
|
167
|
+
const condition = ifMatch[1].trim();
|
|
168
|
+
const thenLabel = ifMatch[2] || "yes";
|
|
169
|
+
|
|
170
|
+
return {
|
|
171
|
+
type: "if",
|
|
172
|
+
condition,
|
|
173
|
+
thenLabel,
|
|
174
|
+
elseLabel: "no",
|
|
175
|
+
elseifs: [],
|
|
176
|
+
onLine: () => false,
|
|
177
|
+
tryEnd: (/** @type {string} */ l) => {
|
|
178
|
+
const c = stripComment(l).trim().toLowerCase();
|
|
179
|
+
return c === "endif" ? { end: true } : null;
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return null;
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Plugin for switch/case/endswitch.
|
|
190
|
+
* @type {object}
|
|
191
|
+
*/
|
|
192
|
+
export const activitySwitchPlugin = {
|
|
193
|
+
name: "activity.switch",
|
|
194
|
+
/** @type {(line: string, ctx: any) => object|null} */
|
|
195
|
+
tryStart: (line, ctx) => {
|
|
196
|
+
const clean = stripComment(line).trim();
|
|
197
|
+
if (!clean) return null;
|
|
198
|
+
|
|
199
|
+
const switchMatch = clean.match(/^switch\s*\((.+?)\)/i);
|
|
200
|
+
if (switchMatch) {
|
|
201
|
+
return {
|
|
202
|
+
type: "switch",
|
|
203
|
+
expression: switchMatch[1].trim(),
|
|
204
|
+
cases: [],
|
|
205
|
+
onLine: () => false,
|
|
206
|
+
tryEnd: (/** @type {string} */ l) => {
|
|
207
|
+
const c = stripComment(l).trim().toLowerCase();
|
|
208
|
+
return c === "endswitch" ? { end: true } : null;
|
|
209
|
+
},
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
return null;
|
|
214
|
+
},
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Plugin for while loops.
|
|
219
|
+
* @type {object}
|
|
220
|
+
*/
|
|
221
|
+
export const activityWhilePlugin = {
|
|
222
|
+
name: "activity.while",
|
|
223
|
+
/** @type {(line: string, ctx: any) => object|null} */
|
|
224
|
+
tryStart: (line, ctx) => {
|
|
225
|
+
const clean = stripComment(line).trim();
|
|
226
|
+
if (!clean) return null;
|
|
227
|
+
|
|
228
|
+
const whileMatch = clean.match(/^while\s*\((.+?)\)/i);
|
|
229
|
+
if (whileMatch) {
|
|
230
|
+
return {
|
|
231
|
+
type: "while",
|
|
232
|
+
condition: whileMatch[1].trim(),
|
|
233
|
+
onLine: () => false,
|
|
234
|
+
tryEnd: (/** @type {string} */ l) => {
|
|
235
|
+
const c = stripComment(l).trim().toLowerCase();
|
|
236
|
+
return c === "endwhile" ? { end: true } : null;
|
|
237
|
+
},
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return null;
|
|
242
|
+
},
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Plugin for repeat loops.
|
|
247
|
+
* @type {object}
|
|
248
|
+
*/
|
|
249
|
+
export const activityRepeatPlugin = {
|
|
250
|
+
name: "activity.repeat",
|
|
251
|
+
/** @type {(line: string, ctx: any) => object|null} */
|
|
252
|
+
tryStart: (line, ctx) => {
|
|
253
|
+
const clean = stripComment(line).trim();
|
|
254
|
+
if (!clean) return null;
|
|
255
|
+
|
|
256
|
+
const lower = clean.toLowerCase();
|
|
257
|
+
|
|
258
|
+
if (lower === "repeat") {
|
|
259
|
+
return {
|
|
260
|
+
type: "repeat",
|
|
261
|
+
onLine: () => false,
|
|
262
|
+
tryEnd: (/** @type {string} */ l) => {
|
|
263
|
+
const c = stripComment(l).trim();
|
|
264
|
+
const m = c.match(/^repeat\s+while\s*\((.+?)\)/i);
|
|
265
|
+
if (m) {
|
|
266
|
+
return { end: true, condition: m[1].trim() };
|
|
267
|
+
}
|
|
268
|
+
return null;
|
|
269
|
+
},
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
return null;
|
|
274
|
+
},
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Plugin for fork/end fork.
|
|
279
|
+
* @type {object}
|
|
280
|
+
*/
|
|
281
|
+
export const activityForkPlugin = {
|
|
282
|
+
name: "activity.fork",
|
|
283
|
+
/** @type {(line: string, ctx: any) => object|null} */
|
|
284
|
+
tryStart: (line, ctx) => {
|
|
285
|
+
const clean = stripComment(line).trim();
|
|
286
|
+
if (!clean) return null;
|
|
287
|
+
|
|
288
|
+
const lower = clean.toLowerCase();
|
|
289
|
+
|
|
290
|
+
if (lower === "fork") {
|
|
291
|
+
return {
|
|
292
|
+
type: "fork",
|
|
293
|
+
branches: [[]],
|
|
294
|
+
onLine: () => false,
|
|
295
|
+
tryEnd: (/** @type {string} */ l) => {
|
|
296
|
+
const c = stripComment(l).trim().toLowerCase();
|
|
297
|
+
return c === "end fork" ? { end: true } : null;
|
|
298
|
+
},
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
return null;
|
|
303
|
+
},
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Plugin for split/end split.
|
|
308
|
+
* @type {object}
|
|
309
|
+
*/
|
|
310
|
+
export const activitySplitPlugin = {
|
|
311
|
+
name: "activity.split",
|
|
312
|
+
/** @type {(line: string, ctx: any) => object|null} */
|
|
313
|
+
tryStart: (line, ctx) => {
|
|
314
|
+
const clean = stripComment(line).trim();
|
|
315
|
+
if (!clean) return null;
|
|
316
|
+
|
|
317
|
+
const lower = clean.toLowerCase();
|
|
318
|
+
|
|
319
|
+
if (lower === "split") {
|
|
320
|
+
return {
|
|
321
|
+
type: "split",
|
|
322
|
+
branches: [[]],
|
|
323
|
+
onLine: () => false,
|
|
324
|
+
tryEnd: (/** @type {string} */ l) => {
|
|
325
|
+
const c = stripComment(l).trim().toLowerCase();
|
|
326
|
+
return c === "end split" ? { end: true } : null;
|
|
327
|
+
},
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
return null;
|
|
332
|
+
},
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Plugin for swimlanes.
|
|
337
|
+
* @type {object}
|
|
338
|
+
*/
|
|
339
|
+
export const activitySwimlanePlugin = {
|
|
340
|
+
name: "activity.swimlane",
|
|
341
|
+
/** @type {(line: string, ctx: any) => boolean} */
|
|
342
|
+
tryLine: (line, ctx) => {
|
|
343
|
+
const clean = stripComment(line).trim();
|
|
344
|
+
if (!clean) return false;
|
|
345
|
+
|
|
346
|
+
// Match |SwimlaneName| or |#Color|SwimlaneName|
|
|
347
|
+
const swimlaneMatch = clean.match(/^\|(?:#(\w+))?\|?([^|]*)\|\s*$/);
|
|
348
|
+
if (swimlaneMatch) {
|
|
349
|
+
const color = swimlaneMatch[1];
|
|
350
|
+
const name = swimlaneMatch[2].trim();
|
|
351
|
+
|
|
352
|
+
ctx.addNode({
|
|
353
|
+
type: ActivityNodeType.SWIMLANE,
|
|
354
|
+
id: `swimlane_${ctx.nodeCount}`,
|
|
355
|
+
name,
|
|
356
|
+
color,
|
|
357
|
+
});
|
|
358
|
+
return true;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
return false;
|
|
362
|
+
},
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Plugin for partitions.
|
|
367
|
+
* @type {object}
|
|
368
|
+
*/
|
|
369
|
+
export const activityPartitionPlugin = {
|
|
370
|
+
name: "activity.partition",
|
|
371
|
+
/** @type {(line: string, ctx: any) => object|null} */
|
|
372
|
+
tryStart: (line, ctx) => {
|
|
373
|
+
const clean = stripComment(line).trim();
|
|
374
|
+
if (!clean) return null;
|
|
375
|
+
|
|
376
|
+
const partitionMatch = clean.match(/^partition\s+"([^"]+)"\s*\{/i);
|
|
377
|
+
if (partitionMatch) {
|
|
378
|
+
return {
|
|
379
|
+
type: "partition",
|
|
380
|
+
name: partitionMatch[1],
|
|
381
|
+
onLine: () => false,
|
|
382
|
+
tryEnd: (/** @type {string} */ l) => {
|
|
383
|
+
const c = stripComment(l).trim();
|
|
384
|
+
return c === "}" ? { end: true } : null;
|
|
385
|
+
},
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
return null;
|
|
390
|
+
},
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Plugin for connectors (labels in parentheses).
|
|
395
|
+
* @type {object}
|
|
396
|
+
*/
|
|
397
|
+
export const activityConnectorPlugin = {
|
|
398
|
+
name: "activity.connector",
|
|
399
|
+
/** @type {(line: string, ctx: any) => boolean} */
|
|
400
|
+
tryLine: (line, ctx) => {
|
|
401
|
+
const clean = stripComment(line).trim();
|
|
402
|
+
if (!clean) return false;
|
|
403
|
+
|
|
404
|
+
// Match (ConnectorName)
|
|
405
|
+
const connectorMatch = clean.match(/^\((\w+)\)$/);
|
|
406
|
+
if (connectorMatch) {
|
|
407
|
+
ctx.addNode({
|
|
408
|
+
type: ActivityNodeType.CONNECTOR,
|
|
409
|
+
id: connectorMatch[1],
|
|
410
|
+
name: connectorMatch[1],
|
|
411
|
+
});
|
|
412
|
+
return true;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
return false;
|
|
416
|
+
},
|
|
417
|
+
};
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Plugin for goto/label.
|
|
421
|
+
* @type {object}
|
|
422
|
+
*/
|
|
423
|
+
export const activityGotoPlugin = {
|
|
424
|
+
name: "activity.goto",
|
|
425
|
+
/** @type {(line: string, ctx: any) => boolean} */
|
|
426
|
+
tryLine: (line, ctx) => {
|
|
427
|
+
const clean = stripComment(line).trim();
|
|
428
|
+
if (!clean) return false;
|
|
429
|
+
|
|
430
|
+
const lower = clean.toLowerCase();
|
|
431
|
+
|
|
432
|
+
// Match label Name
|
|
433
|
+
const labelMatch = clean.match(/^label\s+(\w+)/i);
|
|
434
|
+
if (labelMatch) {
|
|
435
|
+
ctx.addNode({
|
|
436
|
+
type: ActivityNodeType.LABEL,
|
|
437
|
+
id: labelMatch[1],
|
|
438
|
+
name: labelMatch[1],
|
|
439
|
+
});
|
|
440
|
+
return true;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
// Match goto Name
|
|
444
|
+
const gotoMatch = clean.match(/^goto\s+(\w+)/i);
|
|
445
|
+
if (gotoMatch) {
|
|
446
|
+
ctx.addNode({
|
|
447
|
+
type: ActivityNodeType.ACTION,
|
|
448
|
+
id: `goto_${ctx.nodeCount}`,
|
|
449
|
+
text: `goto ${gotoMatch[1]}`,
|
|
450
|
+
gotoTarget: gotoMatch[1],
|
|
451
|
+
});
|
|
452
|
+
return true;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
return false;
|
|
456
|
+
},
|
|
457
|
+
};
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* Plugin for break statement.
|
|
461
|
+
* @type {object}
|
|
462
|
+
*/
|
|
463
|
+
export const activityBreakPlugin = {
|
|
464
|
+
name: "activity.break",
|
|
465
|
+
/** @type {(line: string, ctx: any) => boolean} */
|
|
466
|
+
tryLine: (line, ctx) => {
|
|
467
|
+
const clean = stripComment(line).trim().toLowerCase();
|
|
468
|
+
if (clean === "break") {
|
|
469
|
+
ctx.addNode({
|
|
470
|
+
type: ActivityNodeType.ACTION,
|
|
471
|
+
id: `break_${ctx.nodeCount}`,
|
|
472
|
+
text: "break",
|
|
473
|
+
isBreak: true,
|
|
474
|
+
});
|
|
475
|
+
return true;
|
|
476
|
+
}
|
|
477
|
+
return false;
|
|
478
|
+
},
|
|
479
|
+
};
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* Plugin for notes.
|
|
483
|
+
* @type {object}
|
|
484
|
+
*/
|
|
485
|
+
export const activityNotePlugin = {
|
|
486
|
+
name: "activity.note",
|
|
487
|
+
/** @type {(line: string, ctx: any) => object|null} */
|
|
488
|
+
tryStart: (line, ctx) => {
|
|
489
|
+
const clean = stripComment(line).trim();
|
|
490
|
+
if (!clean) return null;
|
|
491
|
+
|
|
492
|
+
// Floating note: note left/right/top/bottom: text
|
|
493
|
+
const floatingMatch = clean.match(/^note\s+(left|right|top|bottom)\s*:(.+)/i);
|
|
494
|
+
if (floatingMatch) {
|
|
495
|
+
return {
|
|
496
|
+
type: "note",
|
|
497
|
+
position: floatingMatch[1],
|
|
498
|
+
text: floatingMatch[2].trim(),
|
|
499
|
+
floating: true,
|
|
500
|
+
onLine: () => false,
|
|
501
|
+
tryEnd: () => null, // Single line note
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
// Multiline note: note left/right/top/bottom
|
|
506
|
+
const multilineMatch = clean.match(/^note\s+(left|right|top|bottom)$/i);
|
|
507
|
+
if (multilineMatch) {
|
|
508
|
+
return {
|
|
509
|
+
type: "note",
|
|
510
|
+
position: multilineMatch[1],
|
|
511
|
+
lines: [],
|
|
512
|
+
floating: true,
|
|
513
|
+
onLine: () => false,
|
|
514
|
+
tryEnd: (/** @type {string} */ l) => {
|
|
515
|
+
const c = stripComment(l).trim().toLowerCase();
|
|
516
|
+
return c === "end note" ? { end: true } : null;
|
|
517
|
+
},
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
return null;
|
|
522
|
+
},
|
|
523
|
+
};
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* Main activity syntax plugin combining all sub-plugins.
|
|
527
|
+
* @type {object}
|
|
528
|
+
*/
|
|
529
|
+
export const activitySyntaxPlugin = {
|
|
530
|
+
name: "activity.syntax",
|
|
531
|
+
plugins: [
|
|
532
|
+
activityControlPlugin,
|
|
533
|
+
activityActionPlugin,
|
|
534
|
+
activityListActionPlugin,
|
|
535
|
+
activityIfPlugin,
|
|
536
|
+
activitySwitchPlugin,
|
|
537
|
+
activityWhilePlugin,
|
|
538
|
+
activityRepeatPlugin,
|
|
539
|
+
activityForkPlugin,
|
|
540
|
+
activitySplitPlugin,
|
|
541
|
+
activitySwimlanePlugin,
|
|
542
|
+
activityPartitionPlugin,
|
|
543
|
+
activityConnectorPlugin,
|
|
544
|
+
activityGotoPlugin,
|
|
545
|
+
activityBreakPlugin,
|
|
546
|
+
activityNotePlugin,
|
|
547
|
+
],
|
|
548
|
+
};
|
|
549
|
+
|
|
550
|
+
export default activitySyntaxPlugin;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Activity diagram renderer.
|
|
3
|
+
* @module diagrams/activity/render
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { BaseModuleRenderer } from "../base/renderer.mjs";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Activity diagram renderer contract.
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export class ActivityDiagramRenderer extends BaseModuleRenderer {
|
|
13
|
+
constructor() {
|
|
14
|
+
super({
|
|
15
|
+
renderers: {
|
|
16
|
+
excalidraw: (diagram, options = {}) => {
|
|
17
|
+
// TODO: Implement activity diagram rendering
|
|
18
|
+
// This includes:
|
|
19
|
+
// - Action shapes (rounded rectangles)
|
|
20
|
+
// - Decision diamonds
|
|
21
|
+
// - Start/Stop symbols
|
|
22
|
+
// - Fork/Split bars
|
|
23
|
+
// - Swimlanes
|
|
24
|
+
// - Arrows with labels
|
|
25
|
+
|
|
26
|
+
// For now, return empty elements array
|
|
27
|
+
return {
|
|
28
|
+
elements: [],
|
|
29
|
+
appState: {},
|
|
30
|
+
files: {},
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Activity diagram security profile.
|
|
3
|
+
* @module diagrams/activity/security
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { BaseModuleSecurity } from "../base/security.mjs";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Activity diagram security profile.
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export class ActivityDiagramSecurity extends BaseModuleSecurity {
|
|
13
|
+
constructor() {
|
|
14
|
+
super({
|
|
15
|
+
maxNodes: 500,
|
|
16
|
+
maxEdges: 1000,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Activity diagram component tests.
|
|
3
|
+
* @module diagrams/activity/tests/activity_components
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { describe, it } from "node:test";
|
|
7
|
+
import assert from "node:assert";
|
|
8
|
+
import { parsePlantUml } from "../../../main/parser.mjs";
|
|
9
|
+
import { layoutDiagram } from "../../../general/layout/elk_layout.mjs";
|
|
10
|
+
import { exportDiagram } from "../../../general/render/excalidraw.mjs";
|
|
11
|
+
|
|
12
|
+
describe("Activity Diagram Parser", () => {
|
|
13
|
+
describe("Basic Actions", () => {
|
|
14
|
+
it("should parse start and stop", () => {
|
|
15
|
+
const puml = `@startuml
|
|
16
|
+
start
|
|
17
|
+
:Hello world;
|
|
18
|
+
stop
|
|
19
|
+
@enduml`;
|
|
20
|
+
|
|
21
|
+
const result = parsePlantUml(puml);
|
|
22
|
+
assert.ok(result.diagram, "Should produce a diagram");
|
|
23
|
+
assert.strictEqual(result.diagram.kind, "activity");
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("should parse action with text", () => {
|
|
27
|
+
const puml = `@startuml
|
|
28
|
+
start
|
|
29
|
+
:This is an action;
|
|
30
|
+
stop
|
|
31
|
+
@enduml`;
|
|
32
|
+
|
|
33
|
+
const result = parsePlantUml(puml);
|
|
34
|
+
assert.ok(result.diagram);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("should parse multiline action", () => {
|
|
38
|
+
const puml = `@startuml
|
|
39
|
+
start
|
|
40
|
+
:This is on
|
|
41
|
+
several lines;
|
|
42
|
+
stop
|
|
43
|
+
@enduml`;
|
|
44
|
+
|
|
45
|
+
const result = parsePlantUml(puml);
|
|
46
|
+
assert.ok(result.diagram);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
describe("Conditions", () => {
|
|
51
|
+
it("should parse if/then/else", () => {
|
|
52
|
+
const puml = `@startuml
|
|
53
|
+
start
|
|
54
|
+
if (Graphviz installed?) then (yes)
|
|
55
|
+
:process all diagrams;
|
|
56
|
+
else (no)
|
|
57
|
+
:skip;
|
|
58
|
+
endif
|
|
59
|
+
stop
|
|
60
|
+
@enduml`;
|
|
61
|
+
|
|
62
|
+
const result = parsePlantUml(puml);
|
|
63
|
+
assert.ok(result.diagram);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("should parse switch/case", () => {
|
|
67
|
+
const puml = `@startuml
|
|
68
|
+
start
|
|
69
|
+
switch (mode?)
|
|
70
|
+
case (A)
|
|
71
|
+
:A;
|
|
72
|
+
case (B)
|
|
73
|
+
:B;
|
|
74
|
+
endswitch
|
|
75
|
+
stop
|
|
76
|
+
@enduml`;
|
|
77
|
+
|
|
78
|
+
const result = parsePlantUml(puml);
|
|
79
|
+
assert.ok(result.diagram);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
describe("Loops", () => {
|
|
84
|
+
it("should parse while loop", () => {
|
|
85
|
+
const puml = `@startuml
|
|
86
|
+
start
|
|
87
|
+
while (queue?)
|
|
88
|
+
:consume;
|
|
89
|
+
endwhile
|
|
90
|
+
stop
|
|
91
|
+
@enduml`;
|
|
92
|
+
|
|
93
|
+
const result = parsePlantUml(puml);
|
|
94
|
+
assert.ok(result.diagram);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it("should parse repeat loop", () => {
|
|
98
|
+
const puml = `@startuml
|
|
99
|
+
start
|
|
100
|
+
repeat
|
|
101
|
+
:read data;
|
|
102
|
+
:generate diagrams;
|
|
103
|
+
repeat while (more data?)
|
|
104
|
+
stop
|
|
105
|
+
@enduml`;
|
|
106
|
+
|
|
107
|
+
const result = parsePlantUml(puml);
|
|
108
|
+
assert.ok(result.diagram);
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
describe("Parallel Flows", () => {
|
|
113
|
+
it("should parse fork", () => {
|
|
114
|
+
const puml = `@startuml
|
|
115
|
+
start
|
|
116
|
+
fork
|
|
117
|
+
:Treatment 1;
|
|
118
|
+
fork again
|
|
119
|
+
:Treatment 2;
|
|
120
|
+
end fork
|
|
121
|
+
stop
|
|
122
|
+
@enduml`;
|
|
123
|
+
|
|
124
|
+
const result = parsePlantUml(puml);
|
|
125
|
+
assert.ok(result.diagram);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it("should parse split", () => {
|
|
129
|
+
const puml = `@startuml
|
|
130
|
+
start
|
|
131
|
+
split
|
|
132
|
+
:A;
|
|
133
|
+
split again
|
|
134
|
+
:B;
|
|
135
|
+
end split
|
|
136
|
+
stop
|
|
137
|
+
@enduml`;
|
|
138
|
+
|
|
139
|
+
const result = parsePlantUml(puml);
|
|
140
|
+
assert.ok(result.diagram);
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
describe("Swimlanes", () => {
|
|
145
|
+
it("should parse swimlane", () => {
|
|
146
|
+
const puml = `@startuml
|
|
147
|
+
|Swimlane1|
|
|
148
|
+
start
|
|
149
|
+
:Action 1;
|
|
150
|
+
|Swimlane2|
|
|
151
|
+
:Action 2;
|
|
152
|
+
stop
|
|
153
|
+
@enduml`;
|
|
154
|
+
|
|
155
|
+
const result = parsePlantUml(puml);
|
|
156
|
+
assert.ok(result.diagram);
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
describe("Notes", () => {
|
|
161
|
+
it("should parse floating note", () => {
|
|
162
|
+
const puml = `@startuml
|
|
163
|
+
start
|
|
164
|
+
:Action;
|
|
165
|
+
floating note left: This is a note
|
|
166
|
+
stop
|
|
167
|
+
@enduml`;
|
|
168
|
+
|
|
169
|
+
const result = parsePlantUml(puml);
|
|
170
|
+
assert.ok(result.diagram);
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
describe("Activity Diagram Layout", () => {
|
|
176
|
+
it("should layout basic activity diagram", () => {
|
|
177
|
+
const puml = `@startuml
|
|
178
|
+
start
|
|
179
|
+
:Hello world;
|
|
180
|
+
stop
|
|
181
|
+
@enduml`;
|
|
182
|
+
|
|
183
|
+
const parseResult = parsePlantUml(puml);
|
|
184
|
+
assert.ok(parseResult.diagram);
|
|
185
|
+
|
|
186
|
+
const layoutResult = layoutDiagram(parseResult.diagram);
|
|
187
|
+
assert.ok(layoutResult);
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
describe("Activity Diagram Renderer", () => {
|
|
192
|
+
it("should render basic activity diagram to Excalidraw", () => {
|
|
193
|
+
const puml = `@startuml
|
|
194
|
+
start
|
|
195
|
+
:Hello world;
|
|
196
|
+
stop
|
|
197
|
+
@enduml`;
|
|
198
|
+
|
|
199
|
+
const parseResult = parsePlantUml(puml);
|
|
200
|
+
const layoutResult = layoutDiagram(parseResult.diagram);
|
|
201
|
+
const exportResult = exportDiagram(layoutResult, { format: "excalidraw" });
|
|
202
|
+
|
|
203
|
+
assert.ok(exportResult.elements);
|
|
204
|
+
assert.ok(Array.isArray(exportResult.elements));
|
|
205
|
+
});
|
|
206
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Activity diagram test manifest.
|
|
3
|
+
* @module diagrams/activity/tests
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { BaseModuleTests } from "../base/tests.mjs";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Activity diagram test manifest.
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export class ActivityDiagramTests extends BaseModuleTests {
|
|
13
|
+
constructor() {
|
|
14
|
+
super({
|
|
15
|
+
unit: ["activity_components"],
|
|
16
|
+
integration: [],
|
|
17
|
+
security: [],
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
package/src/diagrams/index.mjs
CHANGED
|
@@ -140,6 +140,18 @@ export {
|
|
|
140
140
|
export { STATE_RENDERERS, StateDiagramRenderer, stateDiagramRenderer } from "./state/render.mjs";
|
|
141
141
|
export { StateDiagramSecurity, stateDiagramSecurity } from "./state/security.mjs";
|
|
142
142
|
export { StateDiagramTests, stateDiagramTests } from "./state/tests.mjs";
|
|
143
|
+
export { ActivityDiagramModule, activityDiagramModule } from "./activity/module.mjs";
|
|
144
|
+
export { ActivityDiagramAssets } from "./activity/assets.mjs";
|
|
145
|
+
export { ActivityDiagramDocs } from "./activity/docs.mjs";
|
|
146
|
+
export { ActivityDiagramLayout } from "./activity/layout.mjs";
|
|
147
|
+
export {
|
|
148
|
+
ActivityDiagramParser,
|
|
149
|
+
DEFAULT_ACTIVITY_PLUGINS,
|
|
150
|
+
detectActivityDiagram,
|
|
151
|
+
} from "./activity/parser.mjs";
|
|
152
|
+
export { ActivityDiagramRenderer } from "./activity/render.mjs";
|
|
153
|
+
export { ActivityDiagramSecurity } from "./activity/security.mjs";
|
|
154
|
+
export { ActivityDiagramTests } from "./activity/tests.mjs";
|
|
143
155
|
|
|
144
156
|
import { sequenceDiagramModule } from "./sequence/module.mjs";
|
|
145
157
|
import { classDiagramModule } from "./class/module.mjs";
|
|
@@ -148,6 +160,7 @@ import { deploymentDiagramModule } from "./deployment/module.mjs";
|
|
|
148
160
|
import { useCaseDiagramModule } from "./use-case/module.mjs";
|
|
149
161
|
import { objectDiagramModule } from "./object/module.mjs";
|
|
150
162
|
import { stateDiagramModule } from "./state/module.mjs";
|
|
163
|
+
import { activityDiagramModule } from "./activity/module.mjs";
|
|
151
164
|
|
|
152
165
|
/** @public */
|
|
153
166
|
export const BUILTIN_DIAGRAM_MODULES = Object.freeze([
|
|
@@ -158,4 +171,5 @@ export const BUILTIN_DIAGRAM_MODULES = Object.freeze([
|
|
|
158
171
|
useCaseDiagramModule,
|
|
159
172
|
objectDiagramModule,
|
|
160
173
|
stateDiagramModule,
|
|
174
|
+
activityDiagramModule,
|
|
161
175
|
]);
|
package/src/main/builtin.mjs
CHANGED
|
@@ -11,6 +11,15 @@ import { BUILTIN_DIAGRAM_MODULES } from "../diagrams/index.mjs";
|
|
|
11
11
|
|
|
12
12
|
export {
|
|
13
13
|
BUILTIN_DIAGRAM_MODULES,
|
|
14
|
+
ActivityDiagramAssets,
|
|
15
|
+
ActivityDiagramDocs,
|
|
16
|
+
ActivityDiagramLayout,
|
|
17
|
+
ActivityDiagramModule,
|
|
18
|
+
ActivityDiagramParser,
|
|
19
|
+
ActivityDiagramRenderer,
|
|
20
|
+
ActivityDiagramSecurity,
|
|
21
|
+
ActivityDiagramTests,
|
|
22
|
+
activityDiagramModule,
|
|
14
23
|
ClassDiagramAssets,
|
|
15
24
|
ClassDiagramDocs,
|
|
16
25
|
ClassDiagramLayout,
|
|
@@ -19,6 +28,7 @@ export {
|
|
|
19
28
|
ClassDiagramRenderer,
|
|
20
29
|
ClassDiagramSecurity,
|
|
21
30
|
ClassDiagramTests,
|
|
31
|
+
classDiagramModule,
|
|
22
32
|
ComponentDiagramAssets,
|
|
23
33
|
ComponentDiagramDocs,
|
|
24
34
|
ComponentDiagramLayout,
|
|
@@ -27,8 +37,8 @@ export {
|
|
|
27
37
|
ComponentDiagramRenderer,
|
|
28
38
|
ComponentDiagramSecurity,
|
|
29
39
|
ComponentDiagramTests,
|
|
30
|
-
classDiagramModule,
|
|
31
40
|
componentDiagramModule,
|
|
41
|
+
DEFAULT_ACTIVITY_PLUGINS,
|
|
32
42
|
DEFAULT_CLASS_PLUGINS,
|
|
33
43
|
DEFAULT_COMPONENT_PLUGINS,
|
|
34
44
|
DEFAULT_DEPLOYMENT_PLUGINS,
|