@zyro-sec/merman 1.0.2 → 1.0.3

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 (91) hide show
  1. package/package.json +2 -2
  2. package/script/layout-audit.ts +98 -98
  3. package/src/core/canvas.ts +228 -228
  4. package/src/core/color/style.ts +56 -56
  5. package/src/core/drawing.ts +301 -301
  6. package/src/core/geometry.ts +347 -347
  7. package/src/core/mermaid.ts +38 -38
  8. package/src/core/render-grid.ts +51 -51
  9. package/src/core/spatial.ts +243 -243
  10. package/src/core/text-lines.ts +32 -32
  11. package/src/core/text.ts +44 -44
  12. package/src/detect.ts +17 -17
  13. package/src/diagnostics.ts +16 -16
  14. package/src/flowchart/drawing.ts +340 -340
  15. package/src/flowchart/labels.ts +144 -144
  16. package/src/flowchart/layout.ts +1427 -1427
  17. package/src/flowchart/options.ts +12 -12
  18. package/src/flowchart/parser.ts +467 -467
  19. package/src/flowchart/render.ts +10 -10
  20. package/src/flowchart/routing.ts +1542 -1542
  21. package/src/flowchart/style.ts +79 -79
  22. package/src/flowchart/types.ts +65 -65
  23. package/src/gantt/diagram.ts +8 -8
  24. package/src/gantt/drawing.ts +191 -191
  25. package/src/gantt/parser.ts +161 -161
  26. package/src/gantt/render-grid.ts +17 -17
  27. package/src/gantt/style.ts +36 -36
  28. package/src/gantt/types.ts +44 -44
  29. package/src/gitgraph/diagram.ts +8 -8
  30. package/src/gitgraph/drawing.ts +234 -234
  31. package/src/gitgraph/parser.ts +219 -219
  32. package/src/gitgraph/render-grid.ts +17 -17
  33. package/src/gitgraph/style.ts +37 -37
  34. package/src/gitgraph/types.ts +36 -36
  35. package/src/markdown.ts +336 -336
  36. package/src/palette.ts +75 -75
  37. package/src/plugin.ts +15 -15
  38. package/src/sequence/diagram.ts +8 -8
  39. package/src/sequence/drawing.ts +287 -287
  40. package/src/sequence/options.ts +8 -8
  41. package/src/sequence/parser.ts +282 -282
  42. package/src/sequence/placement.ts +684 -684
  43. package/src/sequence/render-grid.ts +22 -22
  44. package/src/sequence/style.ts +81 -81
  45. package/src/sequence/types.ts +74 -74
  46. package/src/state/diagram.ts +8 -8
  47. package/src/state/drawing.ts +360 -360
  48. package/src/state/endpoint.ts +15 -15
  49. package/src/state/layout.ts +1134 -1134
  50. package/src/state/note.ts +59 -59
  51. package/src/state/options.ts +11 -11
  52. package/src/state/parser.ts +224 -224
  53. package/src/state/render-grid.ts +22 -22
  54. package/src/state/routing.ts +1522 -1522
  55. package/src/state/search.ts +103 -103
  56. package/src/state/style.ts +52 -52
  57. package/src/state/types.ts +63 -63
  58. package/src/state/visible-model.ts +77 -77
  59. package/src/test/diagram.ts +32 -32
  60. package/src/test/layout-audit/fixtures.ts +538 -538
  61. package/src/test/layout-audit/harness.ts +522 -522
  62. package/src/timeline/diagram.ts +8 -8
  63. package/src/timeline/drawing.ts +109 -109
  64. package/src/timeline/parser.ts +119 -119
  65. package/src/timeline/render-grid.ts +17 -17
  66. package/src/timeline/style.ts +36 -36
  67. package/src/timeline/types.ts +31 -31
  68. package/tsconfig.json +10 -10
  69. package/src/core/canvas.test.ts +0 -203
  70. package/src/core/color/style.test.ts +0 -24
  71. package/src/core/drawing.test.ts +0 -116
  72. package/src/core/geometry.test.ts +0 -112
  73. package/src/core/spatial.test.ts +0 -87
  74. package/src/core/text.test.ts +0 -33
  75. package/src/flowchart/flowchart.test.ts +0 -2800
  76. package/src/flowchart/labels.test.ts +0 -127
  77. package/src/flowchart/routing.test.ts +0 -368
  78. package/src/gantt/diagram.test.ts +0 -124
  79. package/src/gitgraph/diagram.test.ts +0 -183
  80. package/src/layout-audit.test.ts +0 -92
  81. package/src/palette.test.ts +0 -103
  82. package/src/sequence/diagram.test.ts +0 -757
  83. package/src/sequence/placement.test.ts +0 -219
  84. package/src/state/diagram.test.ts +0 -1386
  85. package/src/state/layout.test.ts +0 -314
  86. package/src/state/routing.test.ts +0 -693
  87. package/src/state/style.test.ts +0 -113
  88. package/src/state/visible-model.test.ts +0 -84
  89. package/src/test/diagnostics.test.ts +0 -129
  90. package/src/test/markdown.test.ts +0 -474
  91. package/src/timeline/diagram.test.ts +0 -188
@@ -1,22 +1,22 @@
1
- import type { StyledText } from "@opentui/core"
2
- import type { DiagramCanvas } from "../core/canvas.js"
3
- import { renderDiagramGridStyledText } from "../core/render-grid.js"
4
- import { sequenceStyleBackgroundColor, sequenceStyleColor, type SequenceStyleColors } from "./style.js"
5
- import type { SequenceCellStyle } from "./types.js"
6
-
7
- export type SequenceGrid = DiagramCanvas<SequenceCellStyle>
8
-
9
- export function renderSequenceGridText(grid: SequenceGrid): string {
10
- return grid.toString()
11
- }
12
-
13
- export function renderSequenceGridStyledText(
14
- grid: SequenceGrid,
15
- colors: Parameters<typeof sequenceStyleColor>[1],
16
- ): StyledText {
17
- return renderDiagramGridStyledText(
18
- grid,
19
- (run) => sequenceStyleColor(run.style, colors),
20
- (run) => sequenceStyleBackgroundColor(run.style, colors as Required<SequenceStyleColors>),
21
- )
22
- }
1
+ import type { StyledText } from "@opentui/core"
2
+ import type { DiagramCanvas } from "../core/canvas.js"
3
+ import { renderDiagramGridStyledText } from "../core/render-grid.js"
4
+ import { sequenceStyleBackgroundColor, sequenceStyleColor, type SequenceStyleColors } from "./style.js"
5
+ import type { SequenceCellStyle } from "./types.js"
6
+
7
+ export type SequenceGrid = DiagramCanvas<SequenceCellStyle>
8
+
9
+ export function renderSequenceGridText(grid: SequenceGrid): string {
10
+ return grid.toString()
11
+ }
12
+
13
+ export function renderSequenceGridStyledText(
14
+ grid: SequenceGrid,
15
+ colors: Parameters<typeof sequenceStyleColor>[1],
16
+ ): StyledText {
17
+ return renderDiagramGridStyledText(
18
+ grid,
19
+ (run) => sequenceStyleColor(run.style, colors),
20
+ (run) => sequenceStyleBackgroundColor(run.style, colors as Required<SequenceStyleColors>),
21
+ )
22
+ }
@@ -1,81 +1,81 @@
1
- import { RGBA } from "@opentui/core"
2
- import {
3
- createColorRampTheme,
4
- DIAGRAM_FADE_STEPS,
5
- numberedStyleKeys,
6
- rgba,
7
- type DiagramRgb,
8
- } from "../core/color/style.js"
9
- import type { FadeStyle, LifelineRampStyle, SequenceCellStyle } from "./types.js"
10
-
11
- export interface SequenceStyleColors {
12
- participant?: RGBA
13
- lifeline?: RGBA
14
- group?: RGBA
15
- request?: RGBA
16
- response?: RGBA
17
- fragment?: RGBA
18
- fragmentLabelBg?: RGBA
19
- note?: RGBA
20
- noteBg?: RGBA
21
- }
22
-
23
- export const SEQUENCE_FADE_STEPS = DIAGRAM_FADE_STEPS
24
- const LIFELINE_RAMP_STYLES = [
25
- "lifelineRamp1",
26
- "lifelineRamp2",
27
- "lifelineRamp3",
28
- ] as const satisfies readonly LifelineRampStyle[]
29
-
30
- const DEFAULT_THEME_RGB = {
31
- participant: [228, 239, 232],
32
- lifeline: [111, 138, 126],
33
- group: [76, 99, 89],
34
- request: [134, 225, 200],
35
- response: [230, 177, 126],
36
- fragment: [154, 184, 169],
37
- fragmentLabelBg: [28, 43, 36],
38
- noteFg: [215, 229, 221],
39
- noteBg: [36, 56, 47],
40
- } as const satisfies Record<string, DiagramRgb>
41
-
42
- export function resolveSequenceStyleColors(
43
- colors: SequenceStyleColors = {},
44
- ): Required<SequenceStyleColors> & Record<FadeStyle | LifelineRampStyle, RGBA> {
45
- const participant = colors.participant ?? rgba(DEFAULT_THEME_RGB.participant)
46
- const lifeline = colors.lifeline ?? rgba(DEFAULT_THEME_RGB.lifeline)
47
- const request = colors.request ?? rgba(DEFAULT_THEME_RGB.request)
48
- const response = colors.response ?? rgba(DEFAULT_THEME_RGB.response)
49
- return {
50
- participant,
51
- lifeline,
52
- group: colors.group ?? rgba(DEFAULT_THEME_RGB.group),
53
- request,
54
- response,
55
- fragment: colors.fragment ?? rgba(DEFAULT_THEME_RGB.fragment),
56
- fragmentLabelBg: colors.fragmentLabelBg ?? rgba(DEFAULT_THEME_RGB.fragmentLabelBg),
57
- note: colors.note ?? rgba(DEFAULT_THEME_RGB.noteFg),
58
- noteBg: colors.noteBg ?? rgba(DEFAULT_THEME_RGB.noteBg),
59
- ...createColorRampTheme(numberedStyleKeys("requestFade", SEQUENCE_FADE_STEPS), lifeline, request),
60
- ...createColorRampTheme(numberedStyleKeys("responseFade", SEQUENCE_FADE_STEPS), lifeline, response),
61
- ...createColorRampTheme(LIFELINE_RAMP_STYLES, participant, lifeline),
62
- }
63
- }
64
-
65
- export function sequenceStyleColor(
66
- style: SequenceCellStyle | undefined,
67
- colors: Required<SequenceStyleColors> & Record<FadeStyle | LifelineRampStyle, RGBA>,
68
- ): RGBA | undefined {
69
- if (style === "noteBadge") return colors.note
70
- if (style === "fragmentLabel") return colors.fragment
71
- return style ? colors[style] : undefined
72
- }
73
-
74
- export function sequenceStyleBackgroundColor(
75
- style: SequenceCellStyle | undefined,
76
- colors: Required<SequenceStyleColors>,
77
- ): RGBA | undefined {
78
- if (style === "note" || style === "noteBadge") return colors.noteBg
79
- if (style === "fragmentLabel") return colors.fragmentLabelBg
80
- return undefined
81
- }
1
+ import { RGBA } from "@opentui/core"
2
+ import {
3
+ createColorRampTheme,
4
+ DIAGRAM_FADE_STEPS,
5
+ numberedStyleKeys,
6
+ rgba,
7
+ type DiagramRgb,
8
+ } from "../core/color/style.js"
9
+ import type { FadeStyle, LifelineRampStyle, SequenceCellStyle } from "./types.js"
10
+
11
+ export interface SequenceStyleColors {
12
+ participant?: RGBA
13
+ lifeline?: RGBA
14
+ group?: RGBA
15
+ request?: RGBA
16
+ response?: RGBA
17
+ fragment?: RGBA
18
+ fragmentLabelBg?: RGBA
19
+ note?: RGBA
20
+ noteBg?: RGBA
21
+ }
22
+
23
+ export const SEQUENCE_FADE_STEPS = DIAGRAM_FADE_STEPS
24
+ const LIFELINE_RAMP_STYLES = [
25
+ "lifelineRamp1",
26
+ "lifelineRamp2",
27
+ "lifelineRamp3",
28
+ ] as const satisfies readonly LifelineRampStyle[]
29
+
30
+ const DEFAULT_THEME_RGB = {
31
+ participant: [228, 239, 232],
32
+ lifeline: [111, 138, 126],
33
+ group: [76, 99, 89],
34
+ request: [134, 225, 200],
35
+ response: [230, 177, 126],
36
+ fragment: [154, 184, 169],
37
+ fragmentLabelBg: [28, 43, 36],
38
+ noteFg: [215, 229, 221],
39
+ noteBg: [36, 56, 47],
40
+ } as const satisfies Record<string, DiagramRgb>
41
+
42
+ export function resolveSequenceStyleColors(
43
+ colors: SequenceStyleColors = {},
44
+ ): Required<SequenceStyleColors> & Record<FadeStyle | LifelineRampStyle, RGBA> {
45
+ const participant = colors.participant ?? rgba(DEFAULT_THEME_RGB.participant)
46
+ const lifeline = colors.lifeline ?? rgba(DEFAULT_THEME_RGB.lifeline)
47
+ const request = colors.request ?? rgba(DEFAULT_THEME_RGB.request)
48
+ const response = colors.response ?? rgba(DEFAULT_THEME_RGB.response)
49
+ return {
50
+ participant,
51
+ lifeline,
52
+ group: colors.group ?? rgba(DEFAULT_THEME_RGB.group),
53
+ request,
54
+ response,
55
+ fragment: colors.fragment ?? rgba(DEFAULT_THEME_RGB.fragment),
56
+ fragmentLabelBg: colors.fragmentLabelBg ?? rgba(DEFAULT_THEME_RGB.fragmentLabelBg),
57
+ note: colors.note ?? rgba(DEFAULT_THEME_RGB.noteFg),
58
+ noteBg: colors.noteBg ?? rgba(DEFAULT_THEME_RGB.noteBg),
59
+ ...createColorRampTheme(numberedStyleKeys("requestFade", SEQUENCE_FADE_STEPS), lifeline, request),
60
+ ...createColorRampTheme(numberedStyleKeys("responseFade", SEQUENCE_FADE_STEPS), lifeline, response),
61
+ ...createColorRampTheme(LIFELINE_RAMP_STYLES, participant, lifeline),
62
+ }
63
+ }
64
+
65
+ export function sequenceStyleColor(
66
+ style: SequenceCellStyle | undefined,
67
+ colors: Required<SequenceStyleColors> & Record<FadeStyle | LifelineRampStyle, RGBA>,
68
+ ): RGBA | undefined {
69
+ if (style === "noteBadge") return colors.note
70
+ if (style === "fragmentLabel") return colors.fragment
71
+ return style ? colors[style] : undefined
72
+ }
73
+
74
+ export function sequenceStyleBackgroundColor(
75
+ style: SequenceCellStyle | undefined,
76
+ colors: Required<SequenceStyleColors>,
77
+ ): RGBA | undefined {
78
+ if (style === "note" || style === "noteBadge") return colors.noteBg
79
+ if (style === "fragmentLabel") return colors.fragmentLabelBg
80
+ return undefined
81
+ }
@@ -1,74 +1,74 @@
1
- import type { BorderStyle } from "@opentui/core"
2
-
3
- export interface SequenceParticipant {
4
- id: string
5
- label: string
6
- }
7
-
8
- export interface SequenceParticipantGroup {
9
- label: string
10
- participantIds: string[]
11
- }
12
-
13
- export interface SequenceMessage {
14
- from: string
15
- to: string
16
- label: string
17
- style: "solid" | "dashed"
18
- head?: SequenceArrowHead
19
- number?: number
20
- activate?: string
21
- deactivate?: string
22
- }
23
-
24
- export type SequenceArrowHead = "open" | "cross" | "async"
25
-
26
- export interface SequenceNote {
27
- over: string[]
28
- label: string
29
- position?: "over" | "left" | "right"
30
- }
31
-
32
- export interface SequenceActivation {
33
- participant: string
34
- active: boolean
35
- }
36
-
37
- export interface SequenceFragment {
38
- kind: "alt" | "else" | "loop" | "end"
39
- label: string
40
- }
41
-
42
- export type SequenceStep =
43
- | { type: "message"; message: SequenceMessage }
44
- | { type: "note"; note: SequenceNote }
45
- | { type: "activation"; activation: SequenceActivation }
46
- | { type: "fragment"; fragment: SequenceFragment }
47
-
48
- export interface SequenceDiagram {
49
- participants: SequenceParticipant[]
50
- messages: SequenceMessage[]
51
- steps: SequenceStep[]
52
- groups: SequenceParticipantGroup[]
53
- }
54
-
55
- export interface SequenceDiagramRenderOptions {
56
- compact?: boolean
57
- minParticipantGap?: number
58
- fragmentBorderStyle?: BorderStyle
59
- }
60
-
61
- export type MessageStyle = "request" | "response"
62
- export type FadeStyle = `${MessageStyle}Fade${1 | 2 | 3 | 4 | 5}`
63
- export type LifelineRampStyle = `lifelineRamp${1 | 2 | 3}`
64
- export type SequenceCellStyle =
65
- | "participant"
66
- | "lifeline"
67
- | "group"
68
- | MessageStyle
69
- | FadeStyle
70
- | LifelineRampStyle
71
- | "fragment"
72
- | "fragmentLabel"
73
- | "note"
74
- | "noteBadge"
1
+ import type { BorderStyle } from "@opentui/core"
2
+
3
+ export interface SequenceParticipant {
4
+ id: string
5
+ label: string
6
+ }
7
+
8
+ export interface SequenceParticipantGroup {
9
+ label: string
10
+ participantIds: string[]
11
+ }
12
+
13
+ export interface SequenceMessage {
14
+ from: string
15
+ to: string
16
+ label: string
17
+ style: "solid" | "dashed"
18
+ head?: SequenceArrowHead
19
+ number?: number
20
+ activate?: string
21
+ deactivate?: string
22
+ }
23
+
24
+ export type SequenceArrowHead = "open" | "cross" | "async"
25
+
26
+ export interface SequenceNote {
27
+ over: string[]
28
+ label: string
29
+ position?: "over" | "left" | "right"
30
+ }
31
+
32
+ export interface SequenceActivation {
33
+ participant: string
34
+ active: boolean
35
+ }
36
+
37
+ export interface SequenceFragment {
38
+ kind: "alt" | "else" | "loop" | "end"
39
+ label: string
40
+ }
41
+
42
+ export type SequenceStep =
43
+ | { type: "message"; message: SequenceMessage }
44
+ | { type: "note"; note: SequenceNote }
45
+ | { type: "activation"; activation: SequenceActivation }
46
+ | { type: "fragment"; fragment: SequenceFragment }
47
+
48
+ export interface SequenceDiagram {
49
+ participants: SequenceParticipant[]
50
+ messages: SequenceMessage[]
51
+ steps: SequenceStep[]
52
+ groups: SequenceParticipantGroup[]
53
+ }
54
+
55
+ export interface SequenceDiagramRenderOptions {
56
+ compact?: boolean
57
+ minParticipantGap?: number
58
+ fragmentBorderStyle?: BorderStyle
59
+ }
60
+
61
+ export type MessageStyle = "request" | "response"
62
+ export type FadeStyle = `${MessageStyle}Fade${1 | 2 | 3 | 4 | 5}`
63
+ export type LifelineRampStyle = `lifelineRamp${1 | 2 | 3}`
64
+ export type SequenceCellStyle =
65
+ | "participant"
66
+ | "lifeline"
67
+ | "group"
68
+ | MessageStyle
69
+ | FadeStyle
70
+ | LifelineRampStyle
71
+ | "fragment"
72
+ | "fragmentLabel"
73
+ | "note"
74
+ | "noteBadge"
@@ -1,8 +1,8 @@
1
- import { drawStateDiagramGrid } from "./drawing.js"
2
- import { parseMermaidStateDiagram } from "./parser.js"
3
- import { renderStateGridText } from "./render-grid.js"
4
- import type { StateDiagramRenderOptions } from "./types.js"
5
-
6
- export function renderStateDiagram(content: string, options: StateDiagramRenderOptions = {}): string {
7
- return renderStateGridText(drawStateDiagramGrid(parseMermaidStateDiagram(content), options))
8
- }
1
+ import { drawStateDiagramGrid } from "./drawing.js"
2
+ import { parseMermaidStateDiagram } from "./parser.js"
3
+ import { renderStateGridText } from "./render-grid.js"
4
+ import type { StateDiagramRenderOptions } from "./types.js"
5
+
6
+ export function renderStateDiagram(content: string, options: StateDiagramRenderOptions = {}): string {
7
+ return renderStateGridText(drawStateDiagramGrid(parseMermaidStateDiagram(content), options))
8
+ }