@grethel-labs/excaliplant 0.10.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 CHANGED
@@ -7,7 +7,7 @@
7
7
  [![node](https://img.shields.io/node/v/@grethel-labs/excaliplant.svg)](https://nodejs.org)
8
8
  [![license](https://img.shields.io/npm/l/@grethel-labs/excaliplant.svg)](./LICENSE)
9
9
 
10
- > PlantUML → ELK layout → Excalidraw renderer with a plugin-based parser.  ·  **v0.10.0**  ·  200 tests  ·  MIT
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
@@ -131,7 +131,7 @@ See the full [Sequence Diagram Component Coverage](./docs/sequence-components.md
131
131
  npm test
132
132
  ```
133
133
 
134
- Ships with **200 tests** across functional, edge-case,
134
+ Ships with **210 tests** across functional, edge-case,
135
135
  security (XSS / ReDoS / prototype-pollution), and self-introspection
136
136
  suites.
137
137
 
@@ -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
@@ -342,6 +353,18 @@ excaliplant
342
353
  │ │ │ ├── graph_context.mjs
343
354
  │ │ │ ├── graph_parser.mjs
344
355
  │ │ │ └── graph_runtime.mjs
356
+ │ │ ├── state
357
+ │ │ │ ├── docs
358
+ │ │ │ ├── plugins
359
+ │ │ │ ├── tests
360
+ │ │ │ ├── assets.mjs
361
+ │ │ │ ├── docs.mjs
362
+ │ │ │ ├── layout.mjs
363
+ │ │ │ ├── module.mjs
364
+ │ │ │ ├── parser.mjs
365
+ │ │ │ ├── render.mjs
366
+ │ │ │ ├── security.mjs
367
+ │ │ │ └── tests.mjs
345
368
  │ │ ├── use-case
346
369
  │ │ │ ├── plugins
347
370
  │ │ │ ├── tests
@@ -391,6 +414,7 @@ excaliplant
391
414
  ├── tests
392
415
  │ ├── helpers
393
416
  │ │ └── output.mjs
417
+ │ ├── activity_components.test.mjs
394
418
  │ ├── class_components.test.mjs
395
419
  │ ├── component_components.test.mjs
396
420
  │ ├── deployment_components.test.mjs
@@ -403,6 +427,7 @@ excaliplant
403
427
  │ ├── security.test.mjs
404
428
  │ ├── self_introspection.test.mjs
405
429
  │ ├── sequence_components.test.mjs
430
+ │ ├── state_components.test.mjs
406
431
  │ ├── style.test.mjs
407
432
  │ └── usecase_components.test.mjs
408
433
  ├── AGENTS.md
@@ -433,6 +458,46 @@ generated by the same command from JSDoc.
433
458
 
434
459
 
435
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
+
436
501
  ### diagrams/base
437
502
 
438
503
 
@@ -665,6 +730,54 @@ generated by the same command from JSDoc.
665
730
 
666
731
 
667
732
 
733
+ ### diagrams/state/assets
734
+
735
+
736
+
737
+ ### diagrams/state/docs
738
+
739
+
740
+
741
+ ### diagrams/state/docs/coverage_examples
742
+
743
+
744
+
745
+ ### diagrams/state/layout
746
+
747
+
748
+
749
+ ### diagrams/state/module
750
+
751
+
752
+
753
+ ### diagrams/state/parser
754
+
755
+
756
+
757
+ ### diagrams/state/plugins/syntax
758
+
759
+
760
+
761
+ ### diagrams/state/render
762
+
763
+
764
+
765
+ ### diagrams/state/security
766
+
767
+
768
+
769
+ ### diagrams/state/tests
770
+
771
+
772
+
773
+ ### diagrams/state/tests/output
774
+
775
+
776
+
777
+ ### diagrams/state/tests/state_components
778
+
779
+
780
+
668
781
  ### diagrams/use-case/assets
669
782
 
670
783
 
package/index.mjs CHANGED
@@ -109,6 +109,7 @@ export {
109
109
  DEFAULT_DEPLOYMENT_PLUGINS,
110
110
  DEFAULT_OBJECT_PLUGINS,
111
111
  DEFAULT_SEQUENCE_PLUGINS,
112
+ DEFAULT_STATE_PLUGINS,
112
113
  DEFAULT_USE_CASE_PLUGINS,
113
114
  defaultDiagramModuleRegistry,
114
115
  DeploymentDiagramAssets,
@@ -129,6 +130,15 @@ export {
129
130
  ObjectDiagramSecurity,
130
131
  ObjectDiagramTests,
131
132
  objectDiagramModule,
133
+ StateDiagramAssets,
134
+ StateDiagramDocs,
135
+ StateDiagramLayout,
136
+ StateDiagramModule,
137
+ StateDiagramParser,
138
+ StateDiagramRenderer,
139
+ StateDiagramSecurity,
140
+ StateDiagramTests,
141
+ stateDiagramModule,
132
142
  SequenceDiagramAssets,
133
143
  SequenceDiagramDocs,
134
144
  SequenceDiagramLayout,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grethel-labs/excaliplant",
3
- "version": "0.10.0",
3
+ "version": "0.12.0",
4
4
  "description": "PlantUML → ELK layout → Excalidraw renderer with a plugin-based parser.",
5
5
  "type": "module",
6
6
  "main": "index.mjs",
@@ -51,7 +51,7 @@
51
51
  },
52
52
  "scripts": {
53
53
  "pretest": "node scripts/clean-test-output.mjs",
54
- "test": "node --test tests/edge_cases.test.mjs tests/functional_more.test.mjs tests/merge_driver.test.mjs tests/modular_architecture.test.mjs tests/plantuml.test.mjs tests/security.test.mjs tests/self_introspection.test.mjs tests/sequence_components.test.mjs tests/class_components.test.mjs tests/component_components.test.mjs tests/deployment_components.test.mjs tests/usecase_components.test.mjs tests/object_components.test.mjs tests/style.test.mjs",
54
+ "test": "node --test tests/edge_cases.test.mjs tests/functional_more.test.mjs tests/merge_driver.test.mjs tests/modular_architecture.test.mjs tests/plantuml.test.mjs tests/security.test.mjs tests/self_introspection.test.mjs tests/sequence_components.test.mjs tests/class_components.test.mjs tests/component_components.test.mjs tests/deployment_components.test.mjs tests/usecase_components.test.mjs tests/object_components.test.mjs tests/state_components.test.mjs tests/style.test.mjs",
55
55
  "typecheck": "tsc -p tsconfig.json",
56
56
  "build:docs": "node docs/scripts/build-docs.mjs",
57
57
  "build:api": "node docs/scripts/build-docs.mjs",
@@ -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
+ }