@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,79 +1,79 @@
1
- import { RGBA, type StyledText } from "@opentui/core"
2
- import type { DiagramCanvas } from "../core/canvas.js"
3
- import { renderDiagramGridStyledTextByStyle } from "../core/render-grid.js"
4
- import {
5
- createColorRampTheme,
6
- DIAGRAM_FADE_STEPS,
7
- numberedStyleKeys,
8
- rgba,
9
- type DiagramFadeStep,
10
- type DiagramRgb,
11
- } from "../core/color/style.js"
12
-
13
- export type FlowchartBaseCellStyle =
14
- | "node"
15
- | "nodeBorder"
16
- | "database"
17
- | "databaseBorder"
18
- | "edge"
19
- | "label"
20
- | "group"
21
- | "groupLabel"
22
- export type FlowchartNodeEdgeFadeStyle = `nodeEdgeFade${DiagramFadeStep}`
23
- export type FlowchartDatabaseEdgeFadeStyle = `databaseEdgeFade${DiagramFadeStep}`
24
- export type FlowchartEdgeFadeStyle = FlowchartNodeEdgeFadeStyle | FlowchartDatabaseEdgeFadeStyle
25
- export type FlowchartCellStyle = FlowchartBaseCellStyle | FlowchartEdgeFadeStyle
26
- export interface FlowchartCellMetadata {
27
- attributes?: number
28
- }
29
- export type FlowchartGrid = DiagramCanvas<FlowchartCellStyle, FlowchartCellMetadata>
30
- export type FlowchartStyleColors = Required<Record<FlowchartCellStyle, RGBA>>
31
- export type FlowchartStyleBackgroundColors = Partial<Record<FlowchartCellStyle, RGBA>>
32
- export const DEFAULT_THEME_RGB = {
33
- node: [228, 239, 232],
34
- nodeBorder: [141, 163, 151],
35
- database: [228, 239, 232],
36
- databaseBorder: [141, 163, 151],
37
- edge: [134, 225, 200],
38
- label: [134, 225, 200],
39
- group: [76, 99, 89],
40
- groupLabel: [76, 99, 89],
41
- } as const satisfies Record<FlowchartBaseCellStyle, DiagramRgb>
42
-
43
- export const NODE_EDGE_FADE_STYLES = numberedStyleKeys("nodeEdgeFade", DIAGRAM_FADE_STEPS)
44
- export const DATABASE_EDGE_FADE_STYLES = numberedStyleKeys("databaseEdgeFade", DIAGRAM_FADE_STEPS)
45
-
46
- export function resolveFlowchartStyleColors(
47
- colors: Partial<Record<FlowchartCellStyle, RGBA | undefined>> = {},
48
- ): FlowchartStyleColors {
49
- const node = colors.node ?? rgba(DEFAULT_THEME_RGB.node)
50
- const nodeBorder = colors.nodeBorder ?? rgba(DEFAULT_THEME_RGB.nodeBorder)
51
- const database = colors.database ?? rgba(DEFAULT_THEME_RGB.database)
52
- const databaseBorder = colors.databaseBorder ?? rgba(DEFAULT_THEME_RGB.databaseBorder)
53
- const edge = colors.edge ?? rgba(DEFAULT_THEME_RGB.edge)
54
- return {
55
- node,
56
- nodeBorder,
57
- database,
58
- databaseBorder,
59
- edge,
60
- label: colors.label ?? rgba(DEFAULT_THEME_RGB.label),
61
- group: colors.group ?? rgba(DEFAULT_THEME_RGB.group),
62
- groupLabel: colors.groupLabel ?? colors.group ?? rgba(DEFAULT_THEME_RGB.groupLabel),
63
- ...createColorRampTheme(NODE_EDGE_FADE_STYLES, nodeBorder, edge),
64
- ...createColorRampTheme(DATABASE_EDGE_FADE_STYLES, databaseBorder, edge),
65
- }
66
- }
67
-
68
- export function renderGridStyledText(
69
- grid: FlowchartGrid,
70
- colors: FlowchartStyleColors,
71
- backgrounds?: FlowchartStyleBackgroundColors,
72
- ): StyledText {
73
- return renderDiagramGridStyledTextByStyle(grid, colors, backgrounds, {
74
- key: (cell) => [cell.style, cell.attributes],
75
- attributes: (run) => run.cell.attributes,
76
- trimTop: true,
77
- trimBottom: true,
78
- })
79
- }
1
+ import { RGBA, type StyledText } from "@opentui/core"
2
+ import type { DiagramCanvas } from "../core/canvas.js"
3
+ import { renderDiagramGridStyledTextByStyle } from "../core/render-grid.js"
4
+ import {
5
+ createColorRampTheme,
6
+ DIAGRAM_FADE_STEPS,
7
+ numberedStyleKeys,
8
+ rgba,
9
+ type DiagramFadeStep,
10
+ type DiagramRgb,
11
+ } from "../core/color/style.js"
12
+
13
+ export type FlowchartBaseCellStyle =
14
+ | "node"
15
+ | "nodeBorder"
16
+ | "database"
17
+ | "databaseBorder"
18
+ | "edge"
19
+ | "label"
20
+ | "group"
21
+ | "groupLabel"
22
+ export type FlowchartNodeEdgeFadeStyle = `nodeEdgeFade${DiagramFadeStep}`
23
+ export type FlowchartDatabaseEdgeFadeStyle = `databaseEdgeFade${DiagramFadeStep}`
24
+ export type FlowchartEdgeFadeStyle = FlowchartNodeEdgeFadeStyle | FlowchartDatabaseEdgeFadeStyle
25
+ export type FlowchartCellStyle = FlowchartBaseCellStyle | FlowchartEdgeFadeStyle
26
+ export interface FlowchartCellMetadata {
27
+ attributes?: number
28
+ }
29
+ export type FlowchartGrid = DiagramCanvas<FlowchartCellStyle, FlowchartCellMetadata>
30
+ export type FlowchartStyleColors = Required<Record<FlowchartCellStyle, RGBA>>
31
+ export type FlowchartStyleBackgroundColors = Partial<Record<FlowchartCellStyle, RGBA>>
32
+ export const DEFAULT_THEME_RGB = {
33
+ node: [228, 239, 232],
34
+ nodeBorder: [141, 163, 151],
35
+ database: [228, 239, 232],
36
+ databaseBorder: [141, 163, 151],
37
+ edge: [134, 225, 200],
38
+ label: [134, 225, 200],
39
+ group: [76, 99, 89],
40
+ groupLabel: [76, 99, 89],
41
+ } as const satisfies Record<FlowchartBaseCellStyle, DiagramRgb>
42
+
43
+ export const NODE_EDGE_FADE_STYLES = numberedStyleKeys("nodeEdgeFade", DIAGRAM_FADE_STEPS)
44
+ export const DATABASE_EDGE_FADE_STYLES = numberedStyleKeys("databaseEdgeFade", DIAGRAM_FADE_STEPS)
45
+
46
+ export function resolveFlowchartStyleColors(
47
+ colors: Partial<Record<FlowchartCellStyle, RGBA | undefined>> = {},
48
+ ): FlowchartStyleColors {
49
+ const node = colors.node ?? rgba(DEFAULT_THEME_RGB.node)
50
+ const nodeBorder = colors.nodeBorder ?? rgba(DEFAULT_THEME_RGB.nodeBorder)
51
+ const database = colors.database ?? rgba(DEFAULT_THEME_RGB.database)
52
+ const databaseBorder = colors.databaseBorder ?? rgba(DEFAULT_THEME_RGB.databaseBorder)
53
+ const edge = colors.edge ?? rgba(DEFAULT_THEME_RGB.edge)
54
+ return {
55
+ node,
56
+ nodeBorder,
57
+ database,
58
+ databaseBorder,
59
+ edge,
60
+ label: colors.label ?? rgba(DEFAULT_THEME_RGB.label),
61
+ group: colors.group ?? rgba(DEFAULT_THEME_RGB.group),
62
+ groupLabel: colors.groupLabel ?? colors.group ?? rgba(DEFAULT_THEME_RGB.groupLabel),
63
+ ...createColorRampTheme(NODE_EDGE_FADE_STYLES, nodeBorder, edge),
64
+ ...createColorRampTheme(DATABASE_EDGE_FADE_STYLES, databaseBorder, edge),
65
+ }
66
+ }
67
+
68
+ export function renderGridStyledText(
69
+ grid: FlowchartGrid,
70
+ colors: FlowchartStyleColors,
71
+ backgrounds?: FlowchartStyleBackgroundColors,
72
+ ): StyledText {
73
+ return renderDiagramGridStyledTextByStyle(grid, colors, backgrounds, {
74
+ key: (cell) => [cell.style, cell.attributes],
75
+ attributes: (run) => run.cell.attributes,
76
+ trimTop: true,
77
+ trimBottom: true,
78
+ })
79
+ }
@@ -1,65 +1,65 @@
1
- import type { DiagramAxis, DiagramBounds, DiagramDirection, DiagramPoint } from "../core/geometry.js"
2
-
3
- export type FlowchartDirection = "TB" | "TD" | "BT" | "LR" | "RL"
4
- export type FlowchartNodeShape = "box" | "rounded" | "database" | "decision" | "subroutine"
5
- export type FlowchartEdgeStyle = "thick" | "dashed"
6
-
7
- export interface FlowchartNode {
8
- id: string
9
- label: string
10
- shape: FlowchartNodeShape
11
- }
12
-
13
- export interface FlowchartEdge {
14
- from: string
15
- to: string
16
- label: string
17
- style?: FlowchartEdgeStyle
18
- arrowhead?: false
19
- sourceArrowhead?: true
20
- orderOnly?: boolean
21
- }
22
-
23
- export interface FlowchartSubgraph {
24
- id: string
25
- label: string
26
- nodeIds: string[]
27
- parentId?: string
28
- direction?: FlowchartDirection
29
- }
30
-
31
- export interface FlowchartDiagram {
32
- direction: FlowchartDirection
33
- nodes: FlowchartNode[]
34
- edges: FlowchartEdge[]
35
- subgraphs?: FlowchartSubgraph[]
36
- }
37
-
38
- export interface FlowchartNodeSize {
39
- width: number
40
- height: number
41
- lines: string[]
42
- }
43
-
44
- export interface FlowchartNodeBounds extends FlowchartNodeSize, DiagramBounds {
45
- id: string
46
- }
47
-
48
- export interface FlowchartSubgraphBounds extends DiagramBounds {
49
- id: string
50
- label: string
51
- labelSide: "top" | "bottom"
52
- }
53
-
54
- export type FlowchartEndpointBounds = FlowchartNodeBounds | FlowchartSubgraphBounds
55
-
56
- export type FlowchartPoint = DiagramPoint
57
-
58
- export interface FlowchartEdgeRoute {
59
- edge: FlowchartEdge
60
- points: FlowchartPoint[]
61
- labelAxis?: DiagramAxis
62
- labelPoint?: FlowchartPoint
63
- }
64
-
65
- export type FlowchartEdgeDirection = DiagramDirection
1
+ import type { DiagramAxis, DiagramBounds, DiagramDirection, DiagramPoint } from "../core/geometry.js"
2
+
3
+ export type FlowchartDirection = "TB" | "TD" | "BT" | "LR" | "RL"
4
+ export type FlowchartNodeShape = "box" | "rounded" | "database" | "decision" | "subroutine"
5
+ export type FlowchartEdgeStyle = "thick" | "dashed"
6
+
7
+ export interface FlowchartNode {
8
+ id: string
9
+ label: string
10
+ shape: FlowchartNodeShape
11
+ }
12
+
13
+ export interface FlowchartEdge {
14
+ from: string
15
+ to: string
16
+ label: string
17
+ style?: FlowchartEdgeStyle
18
+ arrowhead?: false
19
+ sourceArrowhead?: true
20
+ orderOnly?: boolean
21
+ }
22
+
23
+ export interface FlowchartSubgraph {
24
+ id: string
25
+ label: string
26
+ nodeIds: string[]
27
+ parentId?: string
28
+ direction?: FlowchartDirection
29
+ }
30
+
31
+ export interface FlowchartDiagram {
32
+ direction: FlowchartDirection
33
+ nodes: FlowchartNode[]
34
+ edges: FlowchartEdge[]
35
+ subgraphs?: FlowchartSubgraph[]
36
+ }
37
+
38
+ export interface FlowchartNodeSize {
39
+ width: number
40
+ height: number
41
+ lines: string[]
42
+ }
43
+
44
+ export interface FlowchartNodeBounds extends FlowchartNodeSize, DiagramBounds {
45
+ id: string
46
+ }
47
+
48
+ export interface FlowchartSubgraphBounds extends DiagramBounds {
49
+ id: string
50
+ label: string
51
+ labelSide: "top" | "bottom"
52
+ }
53
+
54
+ export type FlowchartEndpointBounds = FlowchartNodeBounds | FlowchartSubgraphBounds
55
+
56
+ export type FlowchartPoint = DiagramPoint
57
+
58
+ export interface FlowchartEdgeRoute {
59
+ edge: FlowchartEdge
60
+ points: FlowchartPoint[]
61
+ labelAxis?: DiagramAxis
62
+ labelPoint?: FlowchartPoint
63
+ }
64
+
65
+ export type FlowchartEdgeDirection = DiagramDirection
@@ -1,8 +1,8 @@
1
- import { drawGanttDiagramGrid } from "./drawing.js"
2
- import { parseMermaidGanttDiagram } from "./parser.js"
3
- import { renderGanttGridText } from "./render-grid.js"
4
- import type { GanttDiagramRenderOptions } from "./types.js"
5
-
6
- export function renderGanttDiagram(content: string, options: GanttDiagramRenderOptions = {}): string {
7
- return renderGanttGridText(drawGanttDiagramGrid(parseMermaidGanttDiagram(content), options))
8
- }
1
+ import { drawGanttDiagramGrid } from "./drawing.js"
2
+ import { parseMermaidGanttDiagram } from "./parser.js"
3
+ import { renderGanttGridText } from "./render-grid.js"
4
+ import type { GanttDiagramRenderOptions } from "./types.js"
5
+
6
+ export function renderGanttDiagram(content: string, options: GanttDiagramRenderOptions = {}): string {
7
+ return renderGanttGridText(drawGanttDiagramGrid(parseMermaidGanttDiagram(content), options))
8
+ }