@diagrammo/dgmo 0.15.1 → 0.17.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 (122) hide show
  1. package/README.md +9 -9
  2. package/dist/advanced.cjs +612 -734
  3. package/dist/advanced.d.cts +42 -36
  4. package/dist/advanced.d.ts +42 -36
  5. package/dist/advanced.js +612 -733
  6. package/dist/auto.cjs +508 -620
  7. package/dist/auto.js +105 -105
  8. package/dist/auto.mjs +508 -620
  9. package/dist/cli.cjs +144 -144
  10. package/dist/editor.cjs +8 -9
  11. package/dist/editor.js +8 -9
  12. package/dist/highlight.cjs +8 -9
  13. package/dist/highlight.js +8 -9
  14. package/dist/index.cjs +497 -608
  15. package/dist/index.js +497 -608
  16. package/dist/internal.cjs +612 -734
  17. package/dist/internal.d.cts +42 -36
  18. package/dist/internal.d.ts +42 -36
  19. package/dist/internal.js +612 -733
  20. package/dist/pert.d.cts +2 -2
  21. package/dist/pert.d.ts +2 -2
  22. package/docs/language-reference.md +97 -84
  23. package/docs/migration-sequence-color-to-tags.md +1 -1
  24. package/gallery/fixtures/area.dgmo +3 -3
  25. package/gallery/fixtures/bar-stacked.dgmo +5 -5
  26. package/gallery/fixtures/boxes-and-lines.dgmo +2 -2
  27. package/gallery/fixtures/c4-full.dgmo +8 -8
  28. package/gallery/fixtures/class-full.dgmo +2 -2
  29. package/gallery/fixtures/doughnut.dgmo +6 -6
  30. package/gallery/fixtures/flowchart-colors.dgmo +3 -3
  31. package/gallery/fixtures/function.dgmo +3 -3
  32. package/gallery/fixtures/gantt-full.dgmo +9 -9
  33. package/gallery/fixtures/gantt.dgmo +7 -7
  34. package/gallery/fixtures/infra-full.dgmo +6 -6
  35. package/gallery/fixtures/infra.dgmo +2 -2
  36. package/gallery/fixtures/kanban.dgmo +9 -9
  37. package/gallery/fixtures/line.dgmo +2 -2
  38. package/gallery/fixtures/multi-line.dgmo +3 -3
  39. package/gallery/fixtures/org-full.dgmo +6 -6
  40. package/gallery/fixtures/quadrant.dgmo +2 -2
  41. package/gallery/fixtures/sankey.dgmo +9 -9
  42. package/gallery/fixtures/scatter.dgmo +3 -3
  43. package/gallery/fixtures/sequence-tags-protocols.dgmo +11 -11
  44. package/gallery/fixtures/sequence-tags.dgmo +10 -10
  45. package/gallery/fixtures/sequence.dgmo +4 -4
  46. package/gallery/fixtures/sitemap-full.dgmo +7 -7
  47. package/gallery/fixtures/slope.dgmo +5 -5
  48. package/gallery/fixtures/spr-eras.dgmo +9 -9
  49. package/gallery/fixtures/timeline.dgmo +3 -3
  50. package/gallery/fixtures/venn.dgmo +3 -3
  51. package/package.json +7 -3
  52. package/src/advanced.ts +0 -1
  53. package/src/auto/index.ts +2 -2
  54. package/src/boxes-and-lines/layout.ts +1 -2
  55. package/src/boxes-and-lines/renderer.ts +5 -1
  56. package/src/c4/parser.ts +2 -2
  57. package/src/c4/renderer.ts +15 -8
  58. package/src/chart.ts +18 -9
  59. package/src/class/parser.ts +8 -7
  60. package/src/class/renderer.ts +17 -6
  61. package/src/cli.ts +8 -8
  62. package/src/completion.ts +14 -17
  63. package/src/cycle/parser.ts +15 -1
  64. package/src/cycle/renderer.ts +6 -3
  65. package/src/d3.ts +88 -49
  66. package/src/diagnostics.ts +20 -0
  67. package/src/echarts.ts +28 -11
  68. package/src/editor/dgmo.grammar +1 -3
  69. package/src/editor/dgmo.grammar.d.ts +1 -1
  70. package/src/editor/dgmo.grammar.js +8 -8
  71. package/src/editor/dgmo.grammar.terms.js +11 -12
  72. package/src/editor/highlight-api.ts +0 -1
  73. package/src/editor/highlight.ts +0 -1
  74. package/src/er/parser.ts +19 -12
  75. package/src/er/renderer.ts +19 -7
  76. package/src/gantt/parser.ts +1 -1
  77. package/src/gantt/renderer.ts +7 -4
  78. package/src/graph/flowchart-parser.ts +18 -84
  79. package/src/graph/flowchart-renderer.ts +6 -8
  80. package/src/graph/layout.ts +0 -2
  81. package/src/graph/state-parser.ts +17 -62
  82. package/src/graph/state-renderer.ts +3 -8
  83. package/src/infra/parser.ts +21 -11
  84. package/src/infra/renderer.ts +8 -6
  85. package/src/journey-map/parser.ts +11 -4
  86. package/src/journey-map/renderer.ts +3 -1
  87. package/src/kanban/parser.ts +11 -7
  88. package/src/kanban/renderer.ts +3 -1
  89. package/src/mindmap/parser.ts +4 -5
  90. package/src/mindmap/renderer.ts +2 -1
  91. package/src/org/parser.ts +3 -3
  92. package/src/org/renderer.ts +4 -3
  93. package/src/pert/analyzer.ts +10 -10
  94. package/src/pert/layout.ts +1 -1
  95. package/src/pert/parser.ts +8 -8
  96. package/src/pert/renderer.ts +7 -2
  97. package/src/pert/types.ts +1 -1
  98. package/src/pyramid/parser.ts +13 -1
  99. package/src/raci/parser.ts +42 -12
  100. package/src/raci/renderer.ts +2 -1
  101. package/src/raci/types.ts +4 -3
  102. package/src/ring/parser.ts +13 -1
  103. package/src/sequence/parser.ts +81 -23
  104. package/src/sequence/participant-inference.ts +18 -181
  105. package/src/sequence/renderer.ts +48 -137
  106. package/src/sitemap/layout.ts +0 -2
  107. package/src/sitemap/parser.ts +12 -38
  108. package/src/sitemap/renderer.ts +13 -13
  109. package/src/sitemap/types.ts +0 -1
  110. package/src/tech-radar/parser.ts +2 -2
  111. package/src/tech-radar/renderer.ts +5 -3
  112. package/src/tech-radar/types.ts +2 -0
  113. package/src/utils/arrows.ts +3 -28
  114. package/src/utils/extract-alias.ts +1 -1
  115. package/src/utils/inline-markdown.ts +1 -1
  116. package/src/utils/legend-d3.ts +12 -6
  117. package/src/utils/legend-layout.ts +1 -1
  118. package/src/utils/legend-types.ts +1 -1
  119. package/src/utils/parsing.ts +64 -35
  120. package/src/utils/tag-groups.ts +98 -18
  121. package/src/utils/time-ticks.ts +1 -1
  122. package/src/wireframe/parser.ts +3 -3
@@ -5,20 +5,20 @@ critical-path
5
5
  dependencies
6
6
 
7
7
  tag Team as t
8
- Engineering(blue)
9
- Design(purple)
10
- QA(orange)
11
- Marketing(green)
8
+ Engineering blue
9
+ Design purple
10
+ QA orange
11
+ Marketing green
12
12
 
13
13
  tag Phase as p
14
- Foundation(green)
15
- Growth(orange)
16
- Launch(red)
14
+ Foundation green
15
+ Growth orange
16
+ Launch red
17
17
 
18
18
  era 2024-01-15 -> 2024-02-15 Investor Review
19
- era 2024-03-10 -> 2024-03-14 GDC 2024 (purple)
19
+ era 2024-03-10 -> 2024-03-14 GDC 2024 purple
20
20
  marker 2024-02-26 Board Meeting
21
- marker 2024-04-08 Trade Show Demo (orange)
21
+ marker 2024-04-08 Trade Show Demo orange
22
22
 
23
23
  // Independent task with offset — starts 8bd after project start
24
24
  10bd Brand Guidelines | t: Design, p: Foundation, offset: 8bd
@@ -5,18 +5,18 @@ critical-path
5
5
  dependencies
6
6
 
7
7
  tag Team as t
8
- Engineering(blue)
9
- Design(purple)
10
- QA(orange)
8
+ Engineering blue
9
+ Design purple
10
+ QA orange
11
11
 
12
12
  tag Phase as p
13
- Foundation(green)
14
- Growth(orange)
13
+ Foundation green
14
+ Growth orange
15
15
 
16
16
  era 2024-01-15 -> 2024-02-15 Investor Review
17
- era 2024-03-10 -> 2024-03-14 GDC 2024 (purple)
17
+ era 2024-03-10 -> 2024-03-14 GDC 2024 purple
18
18
  marker 2024-02-26 Board Meeting
19
- marker 2024-04-08 Trade Show Demo (orange)
19
+ marker 2024-04-08 Trade Show Demo orange
20
20
 
21
21
  // Independent task with offset — starts 8bd after project start
22
22
  10bd Brand Guidelines | t: Design, p: Foundation, offset: 8bd
@@ -1,14 +1,14 @@
1
1
  infra E-Commerce Platform — Full Infrastructure
2
2
 
3
3
  tag Team as t
4
- Backend(blue)
5
- Platform(teal)
6
- Data(purple)
4
+ Backend blue
5
+ Platform teal
6
+ Data purple
7
7
 
8
8
  tag Tier as r
9
- Edge(green)
10
- Core(blue)
11
- Storage(orange)
9
+ Edge green
10
+ Core blue
11
+ Storage orange
12
12
 
13
13
  edge
14
14
  rps: 15000
@@ -1,8 +1,8 @@
1
1
  infra Production Traffic Flow
2
2
 
3
3
  tag Team as t
4
- Backend(blue)
5
- Platform(teal)
4
+ Backend blue
5
+ Platform teal
6
6
 
7
7
  edge
8
8
  rps: 10000
@@ -1,27 +1,27 @@
1
1
  kanban Plunder Sprint 7
2
2
 
3
3
  tag Priority
4
- Low(green)
5
- Urgent(red)
6
- High(orange)
4
+ Low green
5
+ Urgent red
6
+ High orange
7
7
 
8
8
  tag Crew as c
9
- Blackbeard(red)
10
- Anne Bonny(purple)
11
- Calico Jack(teal)
9
+ Blackbeard red
10
+ Anne Bonny purple
11
+ Calico Jack teal
12
12
 
13
- [Awaiting Orders](red)
13
+ [Awaiting Orders] red
14
14
  Recruit gunners at Tortuga | priority: High, c: Calico Jack
15
15
  Chart new trade route | priority: Urgent, c: Anne Bonny
16
16
  Scout the Windward Passage
17
17
  Avoid Royal Navy patrols
18
18
  Resupply rum and powder | priority: Low, c: Calico Jack
19
19
 
20
- [Underway](orange) | wip: 2
20
+ [Underway] orange | wip: 2
21
21
  Forge letters of marque | priority: High, c: Anne Bonny
22
22
  Raid merchant convoy | priority: Urgent, c: Blackbeard
23
23
  Three ships spotted off Nassau
24
24
 
25
- [Done](green)
25
+ [Done] green
26
26
  Bribe the harbour master | priority: High, c: Anne Bonny
27
27
  Repair hull damage | priority: Low, c: Blackbeard
@@ -2,8 +2,8 @@ line Daily Active Users (Q1 2025)
2
2
  x-label Week
3
3
  y-label Users (thousands)
4
4
 
5
- era Week 1 -> Week 6 Phase 1 (blue)
6
- era Week 6 -> Week 12 Phase 2 (green)
5
+ era Week 1 -> Week 6 Phase 1 blue
6
+ era Week 6 -> Week 12 Phase 2 green
7
7
 
8
8
  Week 1 12.4
9
9
  Week 2 13.1
@@ -3,9 +3,9 @@ x-label Quarter
3
3
  y-label Amount ($M)
4
4
 
5
5
  series
6
- Revenue (blue)
7
- Operating Cost (red)
8
- Net Profit (green)
6
+ Revenue blue
7
+ Operating Cost red
8
+ Net Profit green
9
9
 
10
10
  Q1 2023 4.2 3.1 1.1
11
11
  Q2 2023 4.8 3.3 1.5
@@ -1,14 +1,14 @@
1
1
  org Acme Corp
2
2
 
3
3
  tag Location
4
- NY(blue)
5
- LA(yellow)
6
- CO(green)
7
- Remote(purple)
4
+ NY blue
5
+ LA yellow
6
+ CO green
7
+ Remote purple
8
8
 
9
9
  tag Status
10
- FTE(green)
11
- Contractor(orange)
10
+ FTE green
11
+ Contractor orange
12
12
 
13
13
  Jane Smith
14
14
  role: CEO
@@ -8,8 +8,8 @@ top-right Major Projects
8
8
  bottom-left Fill-ins
9
9
  bottom-right Avoid
10
10
 
11
- Dark Mode (blue) 0.25 0.85
12
- API v2 (red) 0.8 0.9
11
+ Dark Mode blue 0.25 0.85
12
+ API v2 red 0.8 0.9
13
13
  Fix Typos 0.1 0.15
14
14
  SSO Integration 0.75 0.7
15
15
  Export CSV 0.3 0.6
@@ -1,22 +1,22 @@
1
1
  sankey Website Traffic Flow
2
2
 
3
3
  // Source channels — colored by type
4
- Organic Search (green)
4
+ Organic Search green
5
5
  Landing Page 450
6
- Paid Ads (orange)
6
+ Paid Ads orange
7
7
  Landing Page 280
8
- Social Media (blue)
8
+ Social Media blue
9
9
  Landing Page 180
10
- Email (purple)
10
+ Email purple
11
11
  Landing Page 120
12
- Direct (teal)
12
+ Direct teal
13
13
  Landing Page 90
14
14
 
15
15
  // Engagement & Conversion
16
16
  Landing Page
17
17
  Sign Up 340
18
18
  Browse Products 520
19
- Bounce 260 (red)
19
+ Bounce 260 red
20
20
 
21
21
  Sign Up
22
22
  Free Trial 240
@@ -24,8 +24,8 @@ Sign Up
24
24
 
25
25
  Browse Products
26
26
  Add to Cart 310
27
- Exit 210 (red)
27
+ Exit 210 red
28
28
 
29
29
  Add to Cart
30
- Purchase (green) 220
31
- Abandon 90 (red)
30
+ Purchase green 220
31
+ Abandon 90 red
@@ -2,20 +2,20 @@ scatter Startup Funding vs Revenue
2
2
  x-label Funding ($M)
3
3
  y-label Annual Revenue ($M)
4
4
 
5
- [SaaS](blue)
5
+ [SaaS] blue
6
6
  Acme Cloud 12 8.5
7
7
  DataSync 5.2 3.1
8
8
  CloudOps 25 18.4
9
9
  PlatformX 8 5.7
10
10
  NexGen 3.5 1.2
11
11
 
12
- [Fintech](green)
12
+ [Fintech] green
13
13
  PayFlow 45 32
14
14
  LendTech 18 12.5
15
15
  CoinBase+ 60 41
16
16
  QuickPay 9 6.8
17
17
 
18
- [HealthTech](red)
18
+ [HealthTech] red
19
19
  MediScan 15 7.2
20
20
  HealthAI 22 14.1
21
21
  CareLink 7 3.8
@@ -2,21 +2,21 @@ sequence Order Fulfillment — Protocols & Ownership
2
2
  active-tag Protocol
3
3
 
4
4
  tag Protocol as p
5
- REST(blue)
6
- gRPC(green)
7
- Async(orange)
8
- SQL(purple)
5
+ REST blue
6
+ gRPC green
7
+ Async orange
8
+ SQL purple
9
9
 
10
10
  tag Owner as o
11
- Checkout(teal)
12
- Fulfillment(orange)
13
- Payments(red)
14
- Data(blue)
11
+ Checkout teal
12
+ Fulfillment orange
13
+ Payments red
14
+ Data blue
15
15
 
16
16
  Buyer is an actor
17
- CheckoutSvc is a service | o: Checkout
18
- InventorySvc is a service | o: Fulfillment
19
- PaymentSvc is a service | o: Payments
17
+ CheckoutSvc | o: Checkout
18
+ InventorySvc | o: Fulfillment
19
+ PaymentSvc | o: Payments
20
20
  OrderDB is a database | o: Data
21
21
  EventBus is a queue
22
22
 
@@ -2,23 +2,23 @@ sequence API Gateway — Infrastructure Concerns
2
2
  active-tag Concern
3
3
 
4
4
  tag Concern as c
5
- Caching(blue)
6
- Auth(green)
7
- RateLimiting(orange)
8
- BusinessLogic(purple) default
5
+ Caching blue
6
+ Auth green
7
+ RateLimiting orange
8
+ BusinessLogic purple default
9
9
 
10
10
  tag Team as t
11
- Platform(teal)
12
- Product(orange)
13
- Security(red)
11
+ Platform teal
12
+ Product orange
13
+ Security red
14
14
 
15
15
  Mobile is an actor
16
- Gateway is a gateway | t: Platform
16
+ Gateway | t: Platform
17
17
  Redis is a cache | c: Caching, t: Platform
18
18
 
19
19
  [Backend] | t: Product
20
- UserAPI is a service
21
- OrderAPI is a service
20
+ UserAPI
21
+ OrderAPI
22
22
  DB is a database
23
23
 
24
24
  == Authentication ==
@@ -1,10 +1,10 @@
1
1
  sequence E-Commerce Checkout
2
2
 
3
3
  User is an actor
4
- App is a frontend
5
- API is a gateway
6
- Orders is a service
7
- Payments is an external
4
+ App
5
+ API
6
+ Orders
7
+ Payments
8
8
  DB is a database
9
9
 
10
10
  [Place Order]
@@ -2,15 +2,15 @@ sitemap Grand Slam Tickets
2
2
  direction-tb
3
3
 
4
4
  tag Auth
5
- Public(green)
6
- Required(blue)
7
- Admin(red)
5
+ Public green
6
+ Required blue
7
+ Admin red
8
8
 
9
9
  tag Type
10
- Landing(purple)
11
- Form(orange)
12
- Content(cyan)
13
- Transactional(yellow)
10
+ Landing purple
11
+ Form orange
12
+ Content cyan
13
+ Transactional yellow
14
14
 
15
15
  Home
16
16
  Auth: Public
@@ -2,8 +2,8 @@ slope Programming Language Popularity
2
2
 
3
3
  period 2020 2022 2025
4
4
 
5
- Python (blue) 3 1 1
6
- JavaScript (yellow) 1 2 2
7
- TypeScript (cyan) 7 4 3
8
- Rust (orange) 18 12 5
9
- Go (green) 10 8 7
5
+ Python blue 3 1 1
6
+ JavaScript yellow 1 2 2
7
+ TypeScript cyan 7 4 3
8
+ Rust orange 18 12 5
9
+ Go green 10 8 7
@@ -1,15 +1,15 @@
1
1
  line U.S. Strategic Petroleum Reserve
2
2
  y-label Million Barrels
3
3
 
4
- era '77 -> '81 Carter (blue)
5
- era '81 -> '89 Reagan (red)
6
- era '89 -> '93 Bush (red)
7
- era '93 -> '01 Clinton (blue)
8
- era '01 -> '09 Bush (red)
9
- era '09 -> '17 Obama (blue)
10
- era '17 -> '21 Trump (red)
11
- era '21 -> '25 Biden (blue)
12
- era '25 -> '25 Trump (red)
4
+ era '77 -> '81 Carter blue
5
+ era '81 -> '89 Reagan red
6
+ era '89 -> '93 Bush red
7
+ era '93 -> '01 Clinton blue
8
+ era '01 -> '09 Bush red
9
+ era '09 -> '17 Obama blue
10
+ era '17 -> '21 Trump red
11
+ era '21 -> '25 Biden blue
12
+ era '25 -> '25 Trump red
13
13
 
14
14
  '77 7
15
15
  '78 67
@@ -2,9 +2,9 @@ timeline Product Roadmap 2024-2025
2
2
  sort tag:Team
3
3
 
4
4
  tag Team as t
5
- Engineering(blue)
6
- Design(purple)
7
- Product(green)
5
+ Engineering blue
6
+ Design purple
7
+ Product green
8
8
 
9
9
  era 2024-01 -> 2024-06 Phase 1 - Foundation
10
10
  era 2024-07 -> 2024-12 Phase 2 - Growth
@@ -1,8 +1,8 @@
1
1
  venn Full-Stack Developer Skills
2
2
 
3
- Frontend(blue) as fe
4
- Backend(green) as be
5
- DevOps(orange) as de
3
+ Frontend blue as fe
4
+ Backend green as be
5
+ DevOps orange as de
6
6
 
7
7
  fe + be Web Systems
8
8
  be + de Platform Ops
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diagrammo/dgmo",
3
- "version": "0.15.1",
3
+ "version": "0.17.0",
4
4
  "description": "DGMO diagram markup language — parser, renderer, and color system",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -117,6 +117,7 @@
117
117
  "prebuild": "rm -rf dist && pnpm codegen",
118
118
  "build": "tsup",
119
119
  "typecheck": "tsc --noEmit",
120
+ "typecheck:strict": "tsc --noEmit -p tsconfig.strict.json",
120
121
  "dev": "tsup --watch",
121
122
  "pretest": "pnpm codegen",
122
123
  "test": "vitest run --coverage",
@@ -130,12 +131,14 @@
130
131
  "lint:fix": "eslint . --fix",
131
132
  "format": "prettier --write src/",
132
133
  "format:check": "prettier --check src/",
134
+ "check:api": "pnpm build && bash scripts/check-api.sh check",
135
+ "check:api:update": "pnpm build && bash scripts/check-api.sh update",
133
136
  "check:duplication": "jscpd ./src",
134
137
  "check:deadcode": "knip",
135
138
  "check:spelling": "cspell \"src/**/*.ts\" \"tests/**/*.ts\"",
136
- "check:all": "pnpm check:deadcode && pnpm check:spelling && pnpm check:duplication && pnpm check:circular && pnpm check:deps && pnpm check:security && pnpm build && pnpm check:publish && pnpm check:types",
139
+ "check:all": "pnpm check:deadcode && pnpm check:spelling && pnpm check:duplication && pnpm check:circular && pnpm check:deps && pnpm check:security && pnpm build && bash scripts/check-api.sh check && pnpm check:publish && pnpm check:types",
137
140
  "check:circular": "madge --circular --extensions ts src/ --json | node -e \"const c=JSON.parse(require('fs').readFileSync('/dev/stdin','utf8')); const n=c.length; if(n>4){console.error('New circular deps found ('+n+' > 4 known type-only cycles)');process.exit(1)}else if(n>0){console.log(n+' known type-only/dynamic cycles (safe)')}else{console.log('No circular dependencies')}\"",
138
- "check:deps": "depcheck --ignores='@codemirror/language,@lezer/*,husky,lint-staged,tsup,axe-core'",
141
+ "check:deps": "depcheck --ignores='@codemirror/language,@lezer/*,husky,lint-staged,tsup,axe-core,type-coverage'",
139
142
  "check:security": "pnpm audit --prod",
140
143
  "check:publish": "publint",
141
144
  "check:size": "pnpm build && du -sh dist/ && echo '---' && ls -lh dist/*.js dist/*.cjs",
@@ -185,6 +188,7 @@
185
188
  "prettier": "^3.8.2",
186
189
  "publint": "^0.3.18",
187
190
  "tsup": "^8.5.1",
191
+ "type-coverage": "^2.29.7",
188
192
  "typescript": "^6.0.2",
189
193
  "typescript-eslint": "^8.58.1",
190
194
  "vitest": "^4.1.4"
package/src/advanced.ts CHANGED
@@ -28,7 +28,6 @@ export type { DgmoError, DgmoSeverity } from './diagnostics';
28
28
  export {
29
29
  parseInArrowLabel,
30
30
  validateLabelCharacters,
31
- matchColorParens,
32
31
  ARROW_DIAGNOSTIC_CODES,
33
32
  } from './utils/arrows';
34
33
  export type { ParseInArrowLabelResult } from './utils/arrows';
package/src/auto/index.ts CHANGED
@@ -279,7 +279,7 @@ export function resolveTheme(
279
279
  function ensureStyles(): void {
280
280
  if (typeof document === 'undefined') return;
281
281
  const html = document.documentElement;
282
- if (html && html.dataset && html.dataset[STYLE_FLAG] === '1') return;
282
+ if (html?.dataset?.[STYLE_FLAG] === '1') return;
283
283
 
284
284
  // If a <link rel="stylesheet"> for our css is already linked, skip inline.
285
285
  const linked = document.querySelector(
@@ -509,7 +509,7 @@ function determineReplaceTarget(matched: Element): Element {
509
509
  // If matched is a <code> whose only child of <pre> is itself, replace <pre>.
510
510
  if (matched.tagName === 'CODE') {
511
511
  const parent = matched.parentElement;
512
- if (parent && parent.tagName === 'PRE') {
512
+ if (parent?.tagName === 'PRE') {
513
513
  const meaningfulChildren = Array.from(parent.childNodes).filter(
514
514
  (n) =>
515
515
  n.nodeType === 1 ||
@@ -636,8 +636,7 @@ export async function layoutBoxesAndLines(
636
636
  const edge = parsed.edges[i];
637
637
  if (edgeParallelCounts[i] === 0) continue;
638
638
  const elkEdge = edgeById.get(`e${i}`);
639
- if (!elkEdge || !elkEdge.sections || elkEdge.sections.length === 0)
640
- continue;
639
+ if (!elkEdge?.sections || elkEdge.sections.length === 0) continue;
641
640
  const container = elkEdge.container ?? 'root';
642
641
  const off = containerAbs.get(container) ?? { x: 0, y: 0 };
643
642
  const s = elkEdge.sections[0];
@@ -309,6 +309,7 @@ interface BLRenderOptions {
309
309
  controlsExpanded?: boolean;
310
310
  onToggleDescriptions?: (active: boolean) => void;
311
311
  onToggleControlsExpand?: () => void;
312
+ exportMode?: boolean;
312
313
  }
313
314
 
314
315
  export function renderBoxesAndLines(
@@ -328,6 +329,7 @@ export function renderBoxesAndLines(
328
329
  controlsExpanded,
329
330
  onToggleDescriptions,
330
331
  onToggleControlsExpand,
332
+ exportMode = false,
331
333
  } = options ?? {};
332
334
  d3Selection.select(container).selectAll(':not([data-d3-tooltip])').remove();
333
335
 
@@ -974,7 +976,7 @@ export function renderBoxesAndLines(
974
976
  const legendConfig: LegendConfig = {
975
977
  groups: parsed.tagGroups,
976
978
  position: { placement: 'top-center', titleRelation: 'below-title' },
977
- mode: 'fixed',
979
+ mode: exportMode ? 'export' : 'preview',
978
980
  controlsGroup,
979
981
  };
980
982
  const legendState: LegendState = {
@@ -1017,11 +1019,13 @@ export function renderBoxesAndLinesForExport(
1017
1019
  exportDims?: { width: number; height: number };
1018
1020
  activeTagGroup?: string | null;
1019
1021
  hiddenTagValues?: Map<string, Set<string>>;
1022
+ exportMode?: boolean;
1020
1023
  }
1021
1024
  ): void {
1022
1025
  renderBoxesAndLines(container, parsed, layout, palette, isDark, {
1023
1026
  exportDims: options?.exportDims,
1024
1027
  activeTagGroup: options?.activeTagGroup,
1025
1028
  hiddenTagValues: options?.hiddenTagValues,
1029
+ exportMode: options?.exportMode,
1026
1030
  });
1027
1031
  }
package/src/c4/parser.ts CHANGED
@@ -232,7 +232,7 @@ export function parseC4(content: string, palette?: PaletteColors): ParsedC4 {
232
232
  return result;
233
233
  };
234
234
 
235
- if (!content || !content.trim()) {
235
+ if (!content?.trim()) {
236
236
  return fail(0, 'No content provided');
237
237
  }
238
238
 
@@ -350,7 +350,7 @@ export function parseC4(content: string, palette?: PaletteColors): ParsedC4 {
350
350
  if (!color) {
351
351
  pushError(
352
352
  lineNumber,
353
- `Expected 'Value(color)' in tag group '${currentTagGroup.name}'`
353
+ `Expected 'Value color' in tag group '${currentTagGroup.name}'`
354
354
  );
355
355
  continue;
356
356
  }
@@ -232,7 +232,8 @@ export function renderC4Context(
232
232
  isDark: boolean,
233
233
  onClickItem?: (lineNumber: number) => void,
234
234
  exportDims?: { width?: number; height?: number },
235
- activeTagGroup?: string | null
235
+ activeTagGroup?: string | null,
236
+ exportMode?: boolean
236
237
  ): void {
237
238
  d3Selection.select(container).selectAll(':not([data-d3-tooltip])').remove();
238
239
 
@@ -636,7 +637,8 @@ export function renderC4Context(
636
637
  palette,
637
638
  isDark,
638
639
  activeTagGroup,
639
- fixedLegend ? width : null
640
+ fixedLegend ? width : null,
641
+ exportMode
640
642
  );
641
643
  }
642
644
  }
@@ -1259,7 +1261,8 @@ function renderLegend(
1259
1261
  palette: PaletteColors,
1260
1262
  isDark: boolean,
1261
1263
  activeTagGroup?: string | null,
1262
- fixedWidth?: number | null
1264
+ fixedWidth?: number | null,
1265
+ exportMode?: boolean
1263
1266
  ): void {
1264
1267
  const groups = layout.legend.map((g) => ({
1265
1268
  name: g.name,
@@ -1268,7 +1271,7 @@ function renderLegend(
1268
1271
  const legendConfig: LegendConfig = {
1269
1272
  groups,
1270
1273
  position: { placement: 'top-center', titleRelation: 'below-title' },
1271
- mode: 'fixed',
1274
+ mode: exportMode ? 'export' : 'preview',
1272
1275
  };
1273
1276
  const legendState: LegendState = { activeGroup: activeTagGroup ?? null };
1274
1277
  const containerWidth = fixedWidth ?? layout.width;
@@ -1300,7 +1303,8 @@ export function renderC4Containers(
1300
1303
  isDark: boolean,
1301
1304
  onClickItem?: (lineNumber: number) => void,
1302
1305
  exportDims?: { width?: number; height?: number },
1303
- activeTagGroup?: string | null
1306
+ activeTagGroup?: string | null,
1307
+ exportMode?: boolean
1304
1308
  ): void {
1305
1309
  d3Selection.select(container).selectAll(':not([data-d3-tooltip])').remove();
1306
1310
 
@@ -1805,7 +1809,8 @@ export function renderC4Containers(
1805
1809
  palette,
1806
1810
  isDark,
1807
1811
  activeTagGroup,
1808
- fixedLegend ? width : null
1812
+ fixedLegend ? width : null,
1813
+ exportMode
1809
1814
  );
1810
1815
  }
1811
1816
  }
@@ -1933,7 +1938,8 @@ export function renderC4Deployment(
1933
1938
  isDark: boolean,
1934
1939
  onClickItem?: (lineNumber: number) => void,
1935
1940
  exportDims?: { width?: number; height?: number },
1936
- activeTagGroup?: string | null
1941
+ activeTagGroup?: string | null,
1942
+ exportMode?: boolean
1937
1943
  ): void {
1938
1944
  renderC4Containers(
1939
1945
  container,
@@ -1943,7 +1949,8 @@ export function renderC4Deployment(
1943
1949
  isDark,
1944
1950
  onClickItem,
1945
1951
  exportDims,
1946
- activeTagGroup
1952
+ activeTagGroup,
1953
+ exportMode
1947
1954
  );
1948
1955
  }
1949
1956