@grethel-labs/excaliplant 0.9.0 → 0.11.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.
Files changed (38) hide show
  1. package/CHANGELOG.md +3 -0
  2. package/README.md +117 -2
  3. package/index.mjs +40 -0
  4. package/package.json +2 -2
  5. package/src/diagrams/index.mjs +38 -0
  6. package/src/diagrams/object/assets.mjs +22 -0
  7. package/src/diagrams/object/docs/coverage_examples.mjs +50 -0
  8. package/src/diagrams/object/docs.mjs +20 -0
  9. package/src/diagrams/object/layout.mjs +20 -0
  10. package/src/diagrams/object/module.mjs +99 -0
  11. package/src/diagrams/object/parser.mjs +70 -0
  12. package/src/diagrams/object/plugins/syntax.mjs +244 -0
  13. package/src/diagrams/object/render.mjs +20 -0
  14. package/src/diagrams/object/security.mjs +19 -0
  15. package/src/diagrams/object/tests/object_components.test.mjs +71 -0
  16. package/src/diagrams/object/tests/output/.gitignore +2 -0
  17. package/src/diagrams/object/tests/output.mjs +22 -0
  18. package/src/diagrams/object/tests.mjs +20 -0
  19. package/src/diagrams/state/assets.mjs +22 -0
  20. package/src/diagrams/state/docs/coverage_examples.mjs +77 -0
  21. package/src/diagrams/state/docs.mjs +27 -0
  22. package/src/diagrams/state/layout.mjs +30 -0
  23. package/src/diagrams/state/module.mjs +99 -0
  24. package/src/diagrams/state/parser.mjs +74 -0
  25. package/src/diagrams/state/plugins/syntax.mjs +291 -0
  26. package/src/diagrams/state/render.mjs +22 -0
  27. package/src/diagrams/state/security.mjs +18 -0
  28. package/src/diagrams/state/tests/output.mjs +24 -0
  29. package/src/diagrams/state/tests/state_components.test.mjs +147 -0
  30. package/src/diagrams/state/tests.mjs +20 -0
  31. package/src/diagrams/use-case/module.mjs +5 -1
  32. package/src/diagrams/use-case/tests/usecase_components.test.mjs +28 -0
  33. package/src/diagrams/use-case/tests.mjs +2 -2
  34. package/src/general/layout/sizing.mjs +47 -0
  35. package/src/general/model/diagram.mjs +11 -0
  36. package/src/general/render/excalidraw.mjs +207 -0
  37. package/src/main/builtin.mjs +30 -0
  38. package/src/main/parser.mjs +21 -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
  [![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.9.0**  ·  194 tests  ·  MIT
10
+ > PlantUML → ELK layout → Excalidraw renderer with a plugin-based parser.  ·  **v0.11.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 **194 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
 
@@ -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,8 +342,21 @@ excaliplant
330
342
  │ │ │ ├── graph_context.mjs
331
343
  │ │ │ ├── graph_parser.mjs
332
344
  │ │ │ └── graph_runtime.mjs
345
+ │ │ ├── state
346
+ │ │ │ ├── docs
347
+ │ │ │ ├── plugins
348
+ │ │ │ ├── tests
349
+ │ │ │ ├── assets.mjs
350
+ │ │ │ ├── docs.mjs
351
+ │ │ │ ├── layout.mjs
352
+ │ │ │ ├── module.mjs
353
+ │ │ │ ├── parser.mjs
354
+ │ │ │ ├── render.mjs
355
+ │ │ │ ├── security.mjs
356
+ │ │ │ └── tests.mjs
333
357
  │ │ ├── use-case
334
358
  │ │ │ ├── plugins
359
+ │ │ │ ├── tests
335
360
  │ │ │ ├── assets.mjs
336
361
  │ │ │ ├── docs.mjs
337
362
  │ │ │ ├── layout.mjs
@@ -385,10 +410,12 @@ excaliplant
385
410
  │ ├── functional_more.test.mjs
386
411
  │ ├── merge_driver.test.mjs
387
412
  │ ├── modular_architecture.test.mjs
413
+ │ ├── object_components.test.mjs
388
414
  │ ├── plantuml.test.mjs
389
415
  │ ├── security.test.mjs
390
416
  │ ├── self_introspection.test.mjs
391
417
  │ ├── sequence_components.test.mjs
418
+ │ ├── state_components.test.mjs
392
419
  │ ├── style.test.mjs
393
420
  │ └── usecase_components.test.mjs
394
421
  ├── AGENTS.md
@@ -571,6 +598,46 @@ generated by the same command from JSDoc.
571
598
 
572
599
 
573
600
 
601
+ ### diagrams/object/assets
602
+
603
+
604
+
605
+ ### diagrams/object/docs
606
+
607
+
608
+
609
+ ### diagrams/object/docs/coverage_examples
610
+
611
+
612
+
613
+ ### diagrams/object/layout
614
+
615
+
616
+
617
+ ### diagrams/object/module
618
+
619
+
620
+
621
+ ### diagrams/object/parser
622
+
623
+
624
+
625
+ ### diagrams/object/plugins/syntax
626
+
627
+
628
+
629
+ ### diagrams/object/render
630
+
631
+
632
+
633
+ ### diagrams/object/security
634
+
635
+
636
+
637
+ ### diagrams/object/tests
638
+
639
+
640
+
574
641
  ### diagrams/sequence/assets
575
642
 
576
643
 
@@ -611,6 +678,54 @@ generated by the same command from JSDoc.
611
678
 
612
679
 
613
680
 
681
+ ### diagrams/state/assets
682
+
683
+
684
+
685
+ ### diagrams/state/docs
686
+
687
+
688
+
689
+ ### diagrams/state/docs/coverage_examples
690
+
691
+
692
+
693
+ ### diagrams/state/layout
694
+
695
+
696
+
697
+ ### diagrams/state/module
698
+
699
+
700
+
701
+ ### diagrams/state/parser
702
+
703
+
704
+
705
+ ### diagrams/state/plugins/syntax
706
+
707
+
708
+
709
+ ### diagrams/state/render
710
+
711
+
712
+
713
+ ### diagrams/state/security
714
+
715
+
716
+
717
+ ### diagrams/state/tests
718
+
719
+
720
+
721
+ ### diagrams/state/tests/output
722
+
723
+
724
+
725
+ ### diagrams/state/tests/state_components
726
+
727
+
728
+
614
729
  ### diagrams/use-case/assets
615
730
 
616
731
 
package/index.mjs CHANGED
@@ -106,8 +106,39 @@ 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_STATE_PLUGINS,
113
+ DEFAULT_USE_CASE_PLUGINS,
110
114
  defaultDiagramModuleRegistry,
115
+ DeploymentDiagramAssets,
116
+ DeploymentDiagramDocs,
117
+ DeploymentDiagramLayout,
118
+ DeploymentDiagramModule,
119
+ DeploymentDiagramParser,
120
+ DeploymentDiagramRenderer,
121
+ DeploymentDiagramSecurity,
122
+ DeploymentDiagramTests,
123
+ deploymentDiagramModule,
124
+ ObjectDiagramAssets,
125
+ ObjectDiagramDocs,
126
+ ObjectDiagramLayout,
127
+ ObjectDiagramModule,
128
+ ObjectDiagramParser,
129
+ ObjectDiagramRenderer,
130
+ ObjectDiagramSecurity,
131
+ ObjectDiagramTests,
132
+ objectDiagramModule,
133
+ StateDiagramAssets,
134
+ StateDiagramDocs,
135
+ StateDiagramLayout,
136
+ StateDiagramModule,
137
+ StateDiagramParser,
138
+ StateDiagramRenderer,
139
+ StateDiagramSecurity,
140
+ StateDiagramTests,
141
+ stateDiagramModule,
111
142
  SequenceDiagramAssets,
112
143
  SequenceDiagramDocs,
113
144
  SequenceDiagramLayout,
@@ -117,6 +148,15 @@ export {
117
148
  SequenceDiagramSecurity,
118
149
  SequenceDiagramTests,
119
150
  sequenceDiagramModule,
151
+ UseCaseDiagramAssets,
152
+ UseCaseDiagramDocs,
153
+ UseCaseDiagramLayout,
154
+ UseCaseDiagramModule,
155
+ UseCaseDiagramParser,
156
+ UseCaseDiagramRenderer,
157
+ UseCaseDiagramSecurity,
158
+ UseCaseDiagramTests,
159
+ useCaseDiagramModule,
120
160
  } from "./src/main/builtin.mjs";
121
161
  export {
122
162
  resolveModuleDependencies,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grethel-labs/excaliplant",
3
- "version": "0.9.0",
3
+ "version": "0.11.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/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",
@@ -106,12 +106,48 @@ export {
106
106
  export { UseCaseDiagramRenderer, useCaseDiagramRenderer } from "./use-case/render.mjs";
107
107
  export { UseCaseDiagramSecurity, useCaseDiagramSecurity } from "./use-case/security.mjs";
108
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";
128
+ export { StateDiagramModule, stateDiagramModule } from "./state/module.mjs";
129
+ export { StateDiagramAssets, stateDiagramAssets } from "./state/assets.mjs";
130
+ export { StateDiagramDocs, stateDiagramDocs } from "./state/docs.mjs";
131
+ export { StateDiagramLayout, layoutStateDiagram, stateDiagramLayout } from "./state/layout.mjs";
132
+ export {
133
+ StateDiagramParser,
134
+ DEFAULT_STATE_PLUGINS,
135
+ createStateParseContext,
136
+ detectStateDiagram,
137
+ prepareStateLines,
138
+ stateDiagramParser,
139
+ } from "./state/parser.mjs";
140
+ export { STATE_RENDERERS, StateDiagramRenderer, stateDiagramRenderer } from "./state/render.mjs";
141
+ export { StateDiagramSecurity, stateDiagramSecurity } from "./state/security.mjs";
142
+ export { StateDiagramTests, stateDiagramTests } from "./state/tests.mjs";
109
143
 
110
144
  import { sequenceDiagramModule } from "./sequence/module.mjs";
111
145
  import { classDiagramModule } from "./class/module.mjs";
112
146
  import { componentDiagramModule } from "./component/module.mjs";
113
147
  import { deploymentDiagramModule } from "./deployment/module.mjs";
114
148
  import { useCaseDiagramModule } from "./use-case/module.mjs";
149
+ import { objectDiagramModule } from "./object/module.mjs";
150
+ import { stateDiagramModule } from "./state/module.mjs";
115
151
 
116
152
  /** @public */
117
153
  export const BUILTIN_DIAGRAM_MODULES = Object.freeze([
@@ -120,4 +156,6 @@ export const BUILTIN_DIAGRAM_MODULES = Object.freeze([
120
156
  componentDiagramModule,
121
157
  deploymentDiagramModule,
122
158
  useCaseDiagramModule,
159
+ objectDiagramModule,
160
+ stateDiagramModule,
123
161
  ]);
@@ -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
+ }