@grethel-labs/excaliplant 0.8.0 → 0.10.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/CHANGELOG.md +3 -0
- package/README.md +120 -4
- package/index.mjs +30 -0
- package/package.json +2 -2
- package/src/diagrams/index.mjs +38 -0
- package/src/diagrams/object/assets.mjs +22 -0
- package/src/diagrams/object/docs/coverage_examples.mjs +50 -0
- package/src/diagrams/object/docs.mjs +20 -0
- package/src/diagrams/object/layout.mjs +20 -0
- package/src/diagrams/object/module.mjs +99 -0
- package/src/diagrams/object/parser.mjs +70 -0
- package/src/diagrams/object/plugins/syntax.mjs +244 -0
- package/src/diagrams/object/render.mjs +20 -0
- package/src/diagrams/object/security.mjs +19 -0
- package/src/diagrams/object/tests/object_components.test.mjs +71 -0
- package/src/diagrams/object/tests/output/.gitignore +2 -0
- package/src/diagrams/object/tests/output.mjs +22 -0
- package/src/diagrams/object/tests.mjs +20 -0
- package/src/diagrams/use-case/assets.mjs +16 -0
- package/src/diagrams/use-case/docs.mjs +20 -0
- package/src/diagrams/use-case/layout.mjs +18 -0
- package/src/diagrams/use-case/module.mjs +61 -0
- package/src/diagrams/use-case/parser.mjs +197 -0
- package/src/diagrams/use-case/plugins/actors.mjs +108 -0
- package/src/diagrams/use-case/plugins/containers.mjs +63 -0
- package/src/diagrams/use-case/plugins/notes.mjs +71 -0
- package/src/diagrams/use-case/plugins/relationships.mjs +97 -0
- package/src/diagrams/use-case/plugins/usecases.mjs +86 -0
- package/src/diagrams/use-case/render.mjs +18 -0
- package/src/diagrams/use-case/security.mjs +16 -0
- package/src/diagrams/use-case/tests/usecase_components.test.mjs +28 -0
- package/src/diagrams/use-case/tests.mjs +20 -0
- package/src/general/layout/sizing.mjs +5 -0
- package/src/general/model/diagram.mjs +3 -0
- package/src/general/render/excalidraw.mjs +30 -0
- package/src/main/builtin.mjs +20 -0
- package/src/main/parser.mjs +14 -0
package/CHANGELOG.md
CHANGED
|
@@ -85,6 +85,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
85
85
|
primary files.
|
|
86
86
|
- Shared parser helpers now cover reusable title-line parsing and block-line
|
|
87
87
|
accumulation for note-style block plugins.
|
|
88
|
+
- Built-in object diagrams now parse object declarations, aliases,
|
|
89
|
+
body/colon field rows, maps with row anchors, diamonds, notes, and
|
|
90
|
+
class-like relationships through a dedicated `object` diagram module.
|
|
88
91
|
|
|
89
92
|
### Changed
|
|
90
93
|
|
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.10.0** · 200 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 **
|
|
134
|
+
Ships with **200 tests** across functional, edge-case,
|
|
135
135
|
security (XSS / ReDoS / prototype-pollution), and self-introspection
|
|
136
136
|
suites.
|
|
137
137
|
|
|
@@ -308,6 +308,18 @@ excaliplant
|
|
|
308
308
|
│ │ │ ├── render.mjs
|
|
309
309
|
│ │ │ ├── security.mjs
|
|
310
310
|
│ │ │ └── tests.mjs
|
|
311
|
+
│ │ ├── object
|
|
312
|
+
│ │ │ ├── docs
|
|
313
|
+
│ │ │ ├── plugins
|
|
314
|
+
│ │ │ ├── tests
|
|
315
|
+
│ │ │ ├── assets.mjs
|
|
316
|
+
│ │ │ ├── docs.mjs
|
|
317
|
+
│ │ │ ├── layout.mjs
|
|
318
|
+
│ │ │ ├── module.mjs
|
|
319
|
+
│ │ │ ├── parser.mjs
|
|
320
|
+
│ │ │ ├── render.mjs
|
|
321
|
+
│ │ │ ├── security.mjs
|
|
322
|
+
│ │ │ └── tests.mjs
|
|
311
323
|
│ │ ├── sequence
|
|
312
324
|
│ │ │ ├── docs
|
|
313
325
|
│ │ │ ├── plugins
|
|
@@ -330,6 +342,17 @@ excaliplant
|
|
|
330
342
|
│ │ │ ├── graph_context.mjs
|
|
331
343
|
│ │ │ ├── graph_parser.mjs
|
|
332
344
|
│ │ │ └── graph_runtime.mjs
|
|
345
|
+
│ │ ├── use-case
|
|
346
|
+
│ │ │ ├── plugins
|
|
347
|
+
│ │ │ ├── tests
|
|
348
|
+
│ │ │ ├── assets.mjs
|
|
349
|
+
│ │ │ ├── docs.mjs
|
|
350
|
+
│ │ │ ├── layout.mjs
|
|
351
|
+
│ │ │ ├── module.mjs
|
|
352
|
+
│ │ │ ├── parser.mjs
|
|
353
|
+
│ │ │ ├── render.mjs
|
|
354
|
+
│ │ │ ├── security.mjs
|
|
355
|
+
│ │ │ └── tests.mjs
|
|
333
356
|
│ │ └── index.mjs
|
|
334
357
|
│ ├── general
|
|
335
358
|
│ │ ├── layout
|
|
@@ -375,11 +398,13 @@ excaliplant
|
|
|
375
398
|
│ ├── functional_more.test.mjs
|
|
376
399
|
│ ├── merge_driver.test.mjs
|
|
377
400
|
│ ├── modular_architecture.test.mjs
|
|
401
|
+
│ ├── object_components.test.mjs
|
|
378
402
|
│ ├── plantuml.test.mjs
|
|
379
403
|
│ ├── security.test.mjs
|
|
380
404
|
│ ├── self_introspection.test.mjs
|
|
381
405
|
│ ├── sequence_components.test.mjs
|
|
382
|
-
│
|
|
406
|
+
│ ├── style.test.mjs
|
|
407
|
+
│ └── usecase_components.test.mjs
|
|
383
408
|
├── AGENTS.md
|
|
384
409
|
├── CHANGELOG.md
|
|
385
410
|
├── CLAUDE.md
|
|
@@ -392,7 +417,6 @@ excaliplant
|
|
|
392
417
|
├── index.mjs
|
|
393
418
|
├── lifecycle-test.svg
|
|
394
419
|
├── package.json
|
|
395
|
-
├── prompt-deployment-diagram.md
|
|
396
420
|
├── style.example.json
|
|
397
421
|
├── style.example.yaml
|
|
398
422
|
└── tsconfig.json
|
|
@@ -561,6 +585,46 @@ generated by the same command from JSDoc.
|
|
|
561
585
|
|
|
562
586
|
|
|
563
587
|
|
|
588
|
+
### diagrams/object/assets
|
|
589
|
+
|
|
590
|
+
|
|
591
|
+
|
|
592
|
+
### diagrams/object/docs
|
|
593
|
+
|
|
594
|
+
|
|
595
|
+
|
|
596
|
+
### diagrams/object/docs/coverage_examples
|
|
597
|
+
|
|
598
|
+
|
|
599
|
+
|
|
600
|
+
### diagrams/object/layout
|
|
601
|
+
|
|
602
|
+
|
|
603
|
+
|
|
604
|
+
### diagrams/object/module
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
### diagrams/object/parser
|
|
609
|
+
|
|
610
|
+
|
|
611
|
+
|
|
612
|
+
### diagrams/object/plugins/syntax
|
|
613
|
+
|
|
614
|
+
|
|
615
|
+
|
|
616
|
+
### diagrams/object/render
|
|
617
|
+
|
|
618
|
+
|
|
619
|
+
|
|
620
|
+
### diagrams/object/security
|
|
621
|
+
|
|
622
|
+
|
|
623
|
+
|
|
624
|
+
### diagrams/object/tests
|
|
625
|
+
|
|
626
|
+
|
|
627
|
+
|
|
564
628
|
### diagrams/sequence/assets
|
|
565
629
|
|
|
566
630
|
|
|
@@ -601,6 +665,58 @@ generated by the same command from JSDoc.
|
|
|
601
665
|
|
|
602
666
|
|
|
603
667
|
|
|
668
|
+
### diagrams/use-case/assets
|
|
669
|
+
|
|
670
|
+
|
|
671
|
+
|
|
672
|
+
### diagrams/use-case/docs
|
|
673
|
+
|
|
674
|
+
|
|
675
|
+
|
|
676
|
+
### diagrams/use-case/layout
|
|
677
|
+
|
|
678
|
+
|
|
679
|
+
|
|
680
|
+
### diagrams/use-case/module
|
|
681
|
+
|
|
682
|
+
|
|
683
|
+
|
|
684
|
+
### diagrams/use-case/parser
|
|
685
|
+
|
|
686
|
+
|
|
687
|
+
|
|
688
|
+
### diagrams/use-case/plugins/actors
|
|
689
|
+
|
|
690
|
+
|
|
691
|
+
|
|
692
|
+
### diagrams/use-case/plugins/containers
|
|
693
|
+
|
|
694
|
+
|
|
695
|
+
|
|
696
|
+
### diagrams/use-case/plugins/notes
|
|
697
|
+
|
|
698
|
+
|
|
699
|
+
|
|
700
|
+
### diagrams/use-case/plugins/relationships
|
|
701
|
+
|
|
702
|
+
|
|
703
|
+
|
|
704
|
+
### diagrams/use-case/plugins/usecases
|
|
705
|
+
|
|
706
|
+
|
|
707
|
+
|
|
708
|
+
### diagrams/use-case/render
|
|
709
|
+
|
|
710
|
+
|
|
711
|
+
|
|
712
|
+
### diagrams/use-case/security
|
|
713
|
+
|
|
714
|
+
|
|
715
|
+
|
|
716
|
+
### diagrams/use-case/tests
|
|
717
|
+
|
|
718
|
+
|
|
719
|
+
|
|
604
720
|
### layout
|
|
605
721
|
|
|
606
722
|
Layout chooses positions for every shape and routes every edge.
|
package/index.mjs
CHANGED
|
@@ -106,8 +106,29 @@ export {
|
|
|
106
106
|
componentDiagramModule,
|
|
107
107
|
DEFAULT_CLASS_PLUGINS,
|
|
108
108
|
DEFAULT_COMPONENT_PLUGINS,
|
|
109
|
+
DEFAULT_DEPLOYMENT_PLUGINS,
|
|
110
|
+
DEFAULT_OBJECT_PLUGINS,
|
|
109
111
|
DEFAULT_SEQUENCE_PLUGINS,
|
|
112
|
+
DEFAULT_USE_CASE_PLUGINS,
|
|
110
113
|
defaultDiagramModuleRegistry,
|
|
114
|
+
DeploymentDiagramAssets,
|
|
115
|
+
DeploymentDiagramDocs,
|
|
116
|
+
DeploymentDiagramLayout,
|
|
117
|
+
DeploymentDiagramModule,
|
|
118
|
+
DeploymentDiagramParser,
|
|
119
|
+
DeploymentDiagramRenderer,
|
|
120
|
+
DeploymentDiagramSecurity,
|
|
121
|
+
DeploymentDiagramTests,
|
|
122
|
+
deploymentDiagramModule,
|
|
123
|
+
ObjectDiagramAssets,
|
|
124
|
+
ObjectDiagramDocs,
|
|
125
|
+
ObjectDiagramLayout,
|
|
126
|
+
ObjectDiagramModule,
|
|
127
|
+
ObjectDiagramParser,
|
|
128
|
+
ObjectDiagramRenderer,
|
|
129
|
+
ObjectDiagramSecurity,
|
|
130
|
+
ObjectDiagramTests,
|
|
131
|
+
objectDiagramModule,
|
|
111
132
|
SequenceDiagramAssets,
|
|
112
133
|
SequenceDiagramDocs,
|
|
113
134
|
SequenceDiagramLayout,
|
|
@@ -117,6 +138,15 @@ export {
|
|
|
117
138
|
SequenceDiagramSecurity,
|
|
118
139
|
SequenceDiagramTests,
|
|
119
140
|
sequenceDiagramModule,
|
|
141
|
+
UseCaseDiagramAssets,
|
|
142
|
+
UseCaseDiagramDocs,
|
|
143
|
+
UseCaseDiagramLayout,
|
|
144
|
+
UseCaseDiagramModule,
|
|
145
|
+
UseCaseDiagramParser,
|
|
146
|
+
UseCaseDiagramRenderer,
|
|
147
|
+
UseCaseDiagramSecurity,
|
|
148
|
+
UseCaseDiagramTests,
|
|
149
|
+
useCaseDiagramModule,
|
|
120
150
|
} from "./src/main/builtin.mjs";
|
|
121
151
|
export {
|
|
122
152
|
resolveModuleDependencies,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grethel-labs/excaliplant",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.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/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/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",
|
package/src/diagrams/index.mjs
CHANGED
|
@@ -91,11 +91,47 @@ export {
|
|
|
91
91
|
} from "./deployment/render.mjs";
|
|
92
92
|
export { DeploymentDiagramSecurity, deploymentDiagramSecurity } from "./deployment/security.mjs";
|
|
93
93
|
export { DeploymentDiagramTests, deploymentDiagramTests } from "./deployment/tests.mjs";
|
|
94
|
+
export { UseCaseDiagramModule, useCaseDiagramModule } from "./use-case/module.mjs";
|
|
95
|
+
export { UseCaseDiagramAssets, useCaseDiagramAssets } from "./use-case/assets.mjs";
|
|
96
|
+
export { UseCaseDiagramDocs, useCaseDiagramDocs } from "./use-case/docs.mjs";
|
|
97
|
+
export { UseCaseDiagramLayout, useCaseDiagramLayout } from "./use-case/layout.mjs";
|
|
98
|
+
export {
|
|
99
|
+
UseCaseDiagramParser,
|
|
100
|
+
DEFAULT_USE_CASE_PLUGINS,
|
|
101
|
+
createUseCaseParseContext,
|
|
102
|
+
detectUseCaseDiagram,
|
|
103
|
+
prepareUseCaseLines,
|
|
104
|
+
useCaseDiagramParser,
|
|
105
|
+
} from "./use-case/parser.mjs";
|
|
106
|
+
export { UseCaseDiagramRenderer, useCaseDiagramRenderer } from "./use-case/render.mjs";
|
|
107
|
+
export { UseCaseDiagramSecurity, useCaseDiagramSecurity } from "./use-case/security.mjs";
|
|
108
|
+
export { UseCaseDiagramTests, useCaseDiagramTests } from "./use-case/tests.mjs";
|
|
109
|
+
export { ObjectDiagramModule, objectDiagramModule } from "./object/module.mjs";
|
|
110
|
+
export { ObjectDiagramAssets, objectDiagramAssets } from "./object/assets.mjs";
|
|
111
|
+
export { ObjectDiagramDocs, objectDiagramDocs } from "./object/docs.mjs";
|
|
112
|
+
export { ObjectDiagramLayout, layoutObjectDiagram, objectDiagramLayout } from "./object/layout.mjs";
|
|
113
|
+
export {
|
|
114
|
+
ObjectDiagramParser,
|
|
115
|
+
DEFAULT_OBJECT_PLUGINS,
|
|
116
|
+
createObjectParseContext,
|
|
117
|
+
detectObjectDiagram,
|
|
118
|
+
prepareObjectLines,
|
|
119
|
+
objectDiagramParser,
|
|
120
|
+
} from "./object/parser.mjs";
|
|
121
|
+
export {
|
|
122
|
+
OBJECT_RENDERERS,
|
|
123
|
+
ObjectDiagramRenderer,
|
|
124
|
+
objectDiagramRenderer,
|
|
125
|
+
} from "./object/render.mjs";
|
|
126
|
+
export { ObjectDiagramSecurity, objectDiagramSecurity } from "./object/security.mjs";
|
|
127
|
+
export { ObjectDiagramTests, objectDiagramTests } from "./object/tests.mjs";
|
|
94
128
|
|
|
95
129
|
import { sequenceDiagramModule } from "./sequence/module.mjs";
|
|
96
130
|
import { classDiagramModule } from "./class/module.mjs";
|
|
97
131
|
import { componentDiagramModule } from "./component/module.mjs";
|
|
98
132
|
import { deploymentDiagramModule } from "./deployment/module.mjs";
|
|
133
|
+
import { useCaseDiagramModule } from "./use-case/module.mjs";
|
|
134
|
+
import { objectDiagramModule } from "./object/module.mjs";
|
|
99
135
|
|
|
100
136
|
/** @public */
|
|
101
137
|
export const BUILTIN_DIAGRAM_MODULES = Object.freeze([
|
|
@@ -103,4 +139,6 @@ export const BUILTIN_DIAGRAM_MODULES = Object.freeze([
|
|
|
103
139
|
classDiagramModule,
|
|
104
140
|
componentDiagramModule,
|
|
105
141
|
deploymentDiagramModule,
|
|
142
|
+
useCaseDiagramModule,
|
|
143
|
+
objectDiagramModule,
|
|
106
144
|
]);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Object diagram asset contract.
|
|
3
|
+
* @module diagrams/object/assets
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { BaseModuleAssets } from "../base/assets.mjs";
|
|
7
|
+
|
|
8
|
+
/** @public */
|
|
9
|
+
export class ObjectDiagramAssets extends BaseModuleAssets {
|
|
10
|
+
constructor() {
|
|
11
|
+
super({
|
|
12
|
+
fonts: ["Excalifont"],
|
|
13
|
+
sprites: [],
|
|
14
|
+
icons: [],
|
|
15
|
+
fixtures: [],
|
|
16
|
+
allowsRemoteAssets: false,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** @public */
|
|
22
|
+
export const objectDiagramAssets = new ObjectDiagramAssets();
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Object-diagram coverage examples owned by the object module.
|
|
3
|
+
* @module diagrams/object/docs/coverage_examples
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @type {readonly {id:string,title:string,description:string,source:string}[]}
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export const OBJECT_COMPONENT_EXAMPLES = Object.freeze([
|
|
11
|
+
{
|
|
12
|
+
id: "objects-fields",
|
|
13
|
+
title: "Objects and fields",
|
|
14
|
+
description: "Object declarations, aliases, body fields and colon field syntax.",
|
|
15
|
+
source: `@startobject
|
|
16
|
+
object user {
|
|
17
|
+
name = "Dummy"
|
|
18
|
+
id = 123
|
|
19
|
+
}
|
|
20
|
+
object "Session Token" as session
|
|
21
|
+
session : value = "abc"
|
|
22
|
+
user --> session : owns
|
|
23
|
+
@endobject`,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
id: "maps-anchors",
|
|
27
|
+
title: "Maps and row anchors",
|
|
28
|
+
description: "Map rows, row anchors and class-like relationships between objects.",
|
|
29
|
+
source: `@startobject
|
|
30
|
+
map CapitalCity {
|
|
31
|
+
UK => London
|
|
32
|
+
USA => Washington
|
|
33
|
+
}
|
|
34
|
+
object Traveler
|
|
35
|
+
Traveler --> CapitalCity::UK : visits
|
|
36
|
+
@endobject`,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
id: "diamond-relationships",
|
|
40
|
+
title: "Diamonds and relationships",
|
|
41
|
+
description: "Object diagrams share class-style relationship operators and diamonds.",
|
|
42
|
+
source: `@startobject
|
|
43
|
+
object Order
|
|
44
|
+
object LineItem
|
|
45
|
+
diamond Aggregation
|
|
46
|
+
Order *-- LineItem : contains
|
|
47
|
+
Order --> Aggregation
|
|
48
|
+
@endobject`,
|
|
49
|
+
},
|
|
50
|
+
]);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Object diagram documentation contract.
|
|
3
|
+
* @module diagrams/object/docs
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { BaseModuleDocs } from "../base/docs.mjs";
|
|
7
|
+
|
|
8
|
+
/** @public */
|
|
9
|
+
export class ObjectDiagramDocs extends BaseModuleDocs {
|
|
10
|
+
constructor() {
|
|
11
|
+
super({
|
|
12
|
+
examples: ["objects", "maps", "diamonds", "relationships", "notes"],
|
|
13
|
+
generatedPages: [],
|
|
14
|
+
knownGaps: ["json-block-mixing", "object-title-underlining"],
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** @public */
|
|
20
|
+
export const objectDiagramDocs = new ObjectDiagramDocs();
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Object diagram layout adapter.
|
|
3
|
+
* @module diagrams/object/layout
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { BaseModuleLayout } from "../base/layout.mjs";
|
|
7
|
+
import { layoutGraphModel } from "../shared/graph_runtime.mjs";
|
|
8
|
+
|
|
9
|
+
/** @public */
|
|
10
|
+
export const layoutObjectDiagram = layoutGraphModel;
|
|
11
|
+
|
|
12
|
+
/** @public */
|
|
13
|
+
export class ObjectDiagramLayout extends BaseModuleLayout {
|
|
14
|
+
constructor() {
|
|
15
|
+
super({ layoutStrategy: "elkGraph", layout: layoutObjectDiagram });
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** @public */
|
|
20
|
+
export const objectDiagramLayout = new ObjectDiagramLayout();
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in object diagram module.
|
|
3
|
+
* @module diagrams/object/module
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { GraphModuleBase } from "../base/module.mjs";
|
|
7
|
+
import { objectDiagramAssets } from "./assets.mjs";
|
|
8
|
+
import { objectDiagramDocs } from "./docs.mjs";
|
|
9
|
+
import { objectDiagramLayout } from "./layout.mjs";
|
|
10
|
+
import { objectDiagramParser } from "./parser.mjs";
|
|
11
|
+
import { objectDiagramRenderer } from "./render.mjs";
|
|
12
|
+
import { objectDiagramSecurity } from "./security.mjs";
|
|
13
|
+
import { objectDiagramTests } from "./tests.mjs";
|
|
14
|
+
|
|
15
|
+
/** @public */
|
|
16
|
+
export class ObjectDiagramModule extends GraphModuleBase {
|
|
17
|
+
constructor() {
|
|
18
|
+
super({
|
|
19
|
+
kind: "object",
|
|
20
|
+
artifactRoot: "src/diagrams/object",
|
|
21
|
+
ownedArtifacts: {
|
|
22
|
+
parser: [
|
|
23
|
+
"src/diagrams/object/parser.mjs",
|
|
24
|
+
"src/diagrams/object/plugins/syntax.mjs",
|
|
25
|
+
"src/diagrams/shared/graph_parser.mjs",
|
|
26
|
+
"src/diagrams/shared/graph_plugins/connections.mjs",
|
|
27
|
+
"src/diagrams/shared/graph_plugins/containers.mjs",
|
|
28
|
+
"src/diagrams/shared/graph_plugins/filters.mjs",
|
|
29
|
+
"src/diagrams/shared/graph_plugins/notes.mjs",
|
|
30
|
+
"src/diagrams/shared/graph_plugins/ports.mjs",
|
|
31
|
+
"src/diagrams/shared/graph_plugins/preamble.mjs",
|
|
32
|
+
"src/diagrams/shared/graph_plugins/shapes.mjs",
|
|
33
|
+
],
|
|
34
|
+
model: ["src/diagrams/shared/graph_context.mjs", "src/general/model/diagram.mjs"],
|
|
35
|
+
style: [],
|
|
36
|
+
layout: ["src/diagrams/object/layout.mjs"],
|
|
37
|
+
render: ["src/diagrams/object/render.mjs", "src/general/render/excalidraw.mjs"],
|
|
38
|
+
security: ["src/diagrams/object/security.mjs"],
|
|
39
|
+
assets: ["src/diagrams/object/assets.mjs"],
|
|
40
|
+
docs: ["src/diagrams/object/docs.mjs", "src/diagrams/object/docs/coverage_examples.mjs"],
|
|
41
|
+
tests: [
|
|
42
|
+
"src/diagrams/object/tests.mjs",
|
|
43
|
+
"src/diagrams/object/tests/object_components.test.mjs",
|
|
44
|
+
"src/diagrams/object/tests/output.mjs",
|
|
45
|
+
"tests/object_components.test.mjs",
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
startDirectives: ["@startobject"],
|
|
49
|
+
parser: objectDiagramParser,
|
|
50
|
+
layout: objectDiagramLayout,
|
|
51
|
+
renderer: objectDiagramRenderer,
|
|
52
|
+
docs: objectDiagramDocs,
|
|
53
|
+
tests: objectDiagramTests,
|
|
54
|
+
security: objectDiagramSecurity,
|
|
55
|
+
assets: objectDiagramAssets,
|
|
56
|
+
dependencies: [
|
|
57
|
+
{
|
|
58
|
+
kind: "security-base",
|
|
59
|
+
versionRange: "^1.0.0",
|
|
60
|
+
capabilities: ["sanitize", "limits"],
|
|
61
|
+
optional: false,
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
kind: "style-base",
|
|
65
|
+
versionRange: "^1.0.0",
|
|
66
|
+
capabilities: ["style-cascade"],
|
|
67
|
+
optional: false,
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
kind: "text-base",
|
|
71
|
+
versionRange: "^1.0.0",
|
|
72
|
+
capabilities: ["inline-text"],
|
|
73
|
+
optional: false,
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
kind: "arrow-base",
|
|
77
|
+
versionRange: "^1.0.0",
|
|
78
|
+
capabilities: ["diagram-arrow"],
|
|
79
|
+
optional: false,
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
kind: "asset-base",
|
|
83
|
+
versionRange: "^1.0.0",
|
|
84
|
+
capabilities: ["packaged-assets"],
|
|
85
|
+
optional: false,
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
kind: "graph-structure",
|
|
89
|
+
versionRange: "^1.0.0",
|
|
90
|
+
capabilities: ["boxes", "containers", "connections"],
|
|
91
|
+
optional: false,
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** @public */
|
|
99
|
+
export const objectDiagramModule = new ObjectDiagramModule();
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Object diagram parser contract.
|
|
3
|
+
* @module diagrams/object/parser
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { explodeBraces, stripComment } from "../../util/plantuml_utils.mjs";
|
|
7
|
+
import { BaseModuleParser } from "../base/parser.mjs";
|
|
8
|
+
import { DEFAULT_GRAPH_PLUGINS, createGraphParseContext } from "../shared/graph_parser.mjs";
|
|
9
|
+
import { connectionPlugin } from "../shared/graph_plugins/connections.mjs";
|
|
10
|
+
import {
|
|
11
|
+
diamondDeclarationPlugin,
|
|
12
|
+
mapDeclarationPlugin,
|
|
13
|
+
objectDeclarationPlugin,
|
|
14
|
+
objectFieldPlugin,
|
|
15
|
+
} from "./plugins/syntax.mjs";
|
|
16
|
+
|
|
17
|
+
const graphPluginsBeforeConnections = DEFAULT_GRAPH_PLUGINS.filter(
|
|
18
|
+
(plugin) => plugin.name !== connectionPlugin.name,
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
/** @public */
|
|
22
|
+
export const DEFAULT_OBJECT_PLUGINS = Object.freeze([
|
|
23
|
+
...graphPluginsBeforeConnections,
|
|
24
|
+
objectDeclarationPlugin,
|
|
25
|
+
mapDeclarationPlugin,
|
|
26
|
+
diamondDeclarationPlugin,
|
|
27
|
+
objectFieldPlugin,
|
|
28
|
+
connectionPlugin,
|
|
29
|
+
]);
|
|
30
|
+
|
|
31
|
+
/** @public */
|
|
32
|
+
export const createObjectParseContext = createGraphParseContext;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @param {string[]} lines Raw PlantUML lines.
|
|
36
|
+
* @returns {string[]} Lines prepared for object-diagram parsing.
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
export function prepareObjectLines(lines) {
|
|
40
|
+
return explodeBraces(lines).filter((line) => !/^@(start|end)object\b/i.test(line.trim()));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** @public */
|
|
44
|
+
export class ObjectDiagramParser extends BaseModuleParser {
|
|
45
|
+
constructor() {
|
|
46
|
+
super({
|
|
47
|
+
plugins: DEFAULT_OBJECT_PLUGINS,
|
|
48
|
+
createParseContext: createObjectParseContext,
|
|
49
|
+
prepareLines: prepareObjectLines,
|
|
50
|
+
detect: detectObjectDiagram,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** @public */
|
|
56
|
+
export const objectDiagramParser = new ObjectDiagramParser();
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @param {string} text Raw PlantUML source.
|
|
60
|
+
* @returns {boolean}
|
|
61
|
+
*/
|
|
62
|
+
export function detectObjectDiagram(text) {
|
|
63
|
+
for (const raw of text.split(/\r?\n/)) {
|
|
64
|
+
const line = stripComment(raw).trim();
|
|
65
|
+
if (!line) continue;
|
|
66
|
+
if (/^skinparam\s+object\b/i.test(line)) return true;
|
|
67
|
+
if (/^(?:object|map|diamond)\b/i.test(line)) return true;
|
|
68
|
+
}
|
|
69
|
+
return false;
|
|
70
|
+
}
|