@diagrammo/dgmo 0.8.10 → 0.8.12

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 (43) hide show
  1. package/dist/cli.cjs +245 -672
  2. package/dist/editor.cjs.map +1 -1
  3. package/dist/editor.d.cts +2 -3
  4. package/dist/editor.d.ts +2 -3
  5. package/dist/editor.js.map +1 -1
  6. package/dist/index.cjs +491 -125
  7. package/dist/index.cjs.map +1 -1
  8. package/dist/index.d.cts +9 -1
  9. package/dist/index.d.ts +9 -1
  10. package/dist/index.js +489 -125
  11. package/dist/index.js.map +1 -1
  12. package/gallery/fixtures/er.dgmo +36 -0
  13. package/gallery/fixtures/kanban.dgmo +27 -0
  14. package/package.json +14 -17
  15. package/src/boxes-and-lines/parser.ts +2 -0
  16. package/src/boxes-and-lines/renderer.ts +13 -5
  17. package/src/c4/layout.ts +31 -10
  18. package/src/c4/parser.ts +5 -1
  19. package/src/completion.ts +17 -2
  20. package/src/d3.ts +220 -102
  21. package/src/echarts.ts +57 -58
  22. package/src/editor/index.ts +1 -2
  23. package/src/er/parser.ts +5 -1
  24. package/src/gantt/parser.ts +8 -0
  25. package/src/gantt/renderer.ts +6 -7
  26. package/src/gantt/resolver.ts +19 -14
  27. package/src/gantt/types.ts +1 -0
  28. package/src/index.ts +2 -0
  29. package/src/infra/parser.ts +4 -0
  30. package/src/kanban/parser.ts +4 -1
  31. package/src/kanban/renderer.ts +11 -8
  32. package/src/label-layout.ts +286 -0
  33. package/src/org/parser.ts +3 -0
  34. package/src/sequence/parser.ts +6 -0
  35. package/src/sequence/renderer.ts +24 -9
  36. package/src/sharing.ts +15 -5
  37. package/src/sitemap/parser.ts +2 -0
  38. package/src/utils/arrows.ts +1 -1
  39. package/src/utils/legend-layout.ts +8 -8
  40. package/src/utils/legend-svg.ts +2 -2
  41. package/src/utils/legend-types.ts +0 -3
  42. package/src/utils/parsing.ts +1 -1
  43. package/src/utils/tag-groups.ts +65 -1
@@ -22,7 +22,7 @@ export interface TagGroup {
22
22
  }
23
23
 
24
24
  /** Result of matching a tag block heading */
25
- export interface TagBlockMatch {
25
+ interface TagBlockMatch {
26
26
  name: string;
27
27
  alias: string | undefined;
28
28
  colorHint: string | undefined;
@@ -304,6 +304,27 @@ export function validateTagValues(
304
304
  }
305
305
  }
306
306
 
307
+ // ── Tag Group Name Validation ────────────────────────────
308
+
309
+ /**
310
+ * Warn when a tag group uses the reserved name "none" (case-insensitive).
311
+ * Should be called alongside `validateTagValues()` in each parser's
312
+ * post-parse validation.
313
+ */
314
+ export function validateTagGroupNames(
315
+ tagGroups: ReadonlyArray<{ name: string; lineNumber: number }>,
316
+ pushWarning: (lineNumber: number, message: string) => void
317
+ ): void {
318
+ for (const group of tagGroups) {
319
+ if (group.name.toLowerCase() === 'none') {
320
+ pushWarning(
321
+ group.lineNumber,
322
+ `'none' is a reserved keyword and cannot be used as a tag group name`
323
+ );
324
+ }
325
+ }
326
+ }
327
+
307
328
  // ── Default Metadata Injection ────────────────────────────
308
329
 
309
330
  /**
@@ -340,6 +361,49 @@ export function injectDefaultTagMetadata(
340
361
  }
341
362
  }
342
363
 
364
+ // ── Active Tag Group Resolution ──────────────────────────────
365
+
366
+ /**
367
+ * Determine which tag group should be active, using a priority chain:
368
+ *
369
+ * 1. Programmatic override (from render API / CLI flag) — highest priority
370
+ * 2. Diagram-level `active-tag` option (from parsed source)
371
+ * 3. Auto-activate first declared tag group
372
+ * 4. No coloring (null)
373
+ *
374
+ * The sentinel value `"none"` (case-insensitive) at any level means
375
+ * "suppress tag coloring."
376
+ *
377
+ * @param tagGroups Declared tag groups (only `.name` is used)
378
+ * @param explicitActiveTag Value of `active-tag` option from parsed diagram, if any
379
+ * @param programmaticOverride Value from render API / CLI; `undefined` = not set,
380
+ * `null` or `''` = explicitly no coloring
381
+ */
382
+ export function resolveActiveTagGroup(
383
+ tagGroups: ReadonlyArray<{ name: string }>,
384
+ explicitActiveTag: string | undefined,
385
+ programmaticOverride?: string | null
386
+ ): string | null {
387
+ // 1. Programmatic override (highest priority)
388
+ if (programmaticOverride !== undefined) {
389
+ if (!programmaticOverride) return null; // null or ''
390
+ if (programmaticOverride.toLowerCase() === 'none') return null;
391
+ return programmaticOverride;
392
+ }
393
+
394
+ // 2. Diagram-level active-tag option
395
+ if (explicitActiveTag) {
396
+ if (explicitActiveTag.toLowerCase() === 'none') return null;
397
+ return explicitActiveTag;
398
+ }
399
+
400
+ // 3. Auto-activate first declared group
401
+ if (tagGroups.length > 0) return tagGroups[0].name;
402
+
403
+ // 4. No tag groups → no coloring
404
+ return null;
405
+ }
406
+
343
407
  // ── Matchers ────────────────────────────────────────────────
344
408
 
345
409
  export function matchTagBlockHeading(trimmed: string): TagBlockMatch | null {