@peter.prib/renderengine 0.0.0-stage → 0.2.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 (451) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +203 -2
  3. package/REFERENCE.md +2198 -0
  4. package/dist/renderengine-workspace.umd.js +46905 -0
  5. package/dist/renderengine.umd.js +42223 -0
  6. package/examples/archimate.html +66 -0
  7. package/examples/diagram-editor.html +51 -0
  8. package/package.json +65 -4
  9. package/src/BaseRenderer.js +57 -0
  10. package/src/CanvasRenderer.js +194 -0
  11. package/src/Mat4.js +111 -0
  12. package/src/OrbitCamera.js +57 -0
  13. package/src/RendererFactory.js +50 -0
  14. package/src/SVGRenderer.js +439 -0
  15. package/src/archimate.js +723 -0
  16. package/src/archimateArchiFormat.js +1693 -0
  17. package/src/archimateArchiTypes.js +72 -0
  18. package/src/archimateArchive.js +140 -0
  19. package/src/archimateCSV.js +127 -0
  20. package/src/archimateDrawio.js +182 -0
  21. package/src/archimateExchangeFormat.js +546 -0
  22. package/src/archimateRelationshipTable.js +93 -0
  23. package/src/archimateSpecializations.js +161 -0
  24. package/src/chartCatalog.js +589 -0
  25. package/src/charting/ArchimateDiagramEditor.js +1624 -0
  26. package/src/charting/ArchimateSpecializationSelector.js +134 -0
  27. package/src/charting/Axis.js +68 -0
  28. package/src/charting/CameraSeeder.js +30 -0
  29. package/src/charting/CatalogDialog.js +92 -0
  30. package/src/charting/Chart.js +37 -0
  31. package/src/charting/Chart3D.js +99 -0
  32. package/src/charting/ChartBox.js +80 -0
  33. package/src/charting/ChartData.js +27 -0
  34. package/src/charting/ChartRegistry.js +76 -0
  35. package/src/charting/CheckboxTreeSelector.js +304 -0
  36. package/src/charting/ColorField.js +107 -0
  37. package/src/charting/ColorPalette.js +88 -0
  38. package/src/charting/CommandHistory.js +176 -0
  39. package/src/charting/DataFilter.js +52 -0
  40. package/src/charting/Diagram.js +36 -0
  41. package/src/charting/Diagram3D.js +29 -0
  42. package/src/charting/DiagramClipboard.js +31 -0
  43. package/src/charting/DiagramEditor.js +3330 -0
  44. package/src/charting/DiagramEditorCommand.js +110 -0
  45. package/src/charting/DiagramEditorCommands.js +237 -0
  46. package/src/charting/DiagramEditorEdgeCommands.js +142 -0
  47. package/src/charting/DiagramEditorState.js +98 -0
  48. package/src/charting/DiagramRegistry.js +86 -0
  49. package/src/charting/DiagramTypeRegistry.js +326 -0
  50. package/src/charting/DiagramViewPropertiesDialog.js +46 -0
  51. package/src/charting/Edge.js +113 -0
  52. package/src/charting/ErrorBars.js +37 -0
  53. package/src/charting/FilterSystem.js +285 -0
  54. package/src/charting/FindReplaceDialog.js +139 -0
  55. package/src/charting/FormDialog.js +385 -0
  56. package/src/charting/Gauge.js +58 -0
  57. package/src/charting/Hierarchy.js +175 -0
  58. package/src/charting/HintPanel.js +86 -0
  59. package/src/charting/ImageSelector.js +148 -0
  60. package/src/charting/InteractionManager.js +725 -0
  61. package/src/charting/Legend.js +58 -0
  62. package/src/charting/MenuBar.js +62 -0
  63. package/src/charting/ModelFileFormat.js +115 -0
  64. package/src/charting/OrbitControls.js +77 -0
  65. package/src/charting/Palette.js +119 -0
  66. package/src/charting/PopupMenu.js +117 -0
  67. package/src/charting/PropertiesPanel.js +155 -0
  68. package/src/charting/PropertyListEditor.js +96 -0
  69. package/src/charting/PropertyLog.js +92 -0
  70. package/src/charting/SettingsCascade.js +93 -0
  71. package/src/charting/SettingsDialog.js +53 -0
  72. package/src/charting/SettingsManager.js +179 -0
  73. package/src/charting/SettingsViewPropertiesDialog.js +58 -0
  74. package/src/charting/ShapePaths.js +27 -0
  75. package/src/charting/Statistics.js +134 -0
  76. package/src/charting/TemplateCatalog.js +59 -0
  77. package/src/charting/TemplateLibrary.js +103 -0
  78. package/src/charting/TextStyle.js +168 -0
  79. package/src/charting/ViewFit.js +55 -0
  80. package/src/charting/ViewMenu.js +70 -0
  81. package/src/charting/ViewPropertiesDialog.js +77 -0
  82. package/src/charting/ViewTabStrip.js +81 -0
  83. package/src/charting/archimate/ArchiFileFormat.js +32 -0
  84. package/src/charting/archimate/ArchimateCanvasEditor.js +815 -0
  85. package/src/charting/archimate/ArchimateCsvFileFormat.js +35 -0
  86. package/src/charting/archimate/ArchimateEdge.js +137 -0
  87. package/src/charting/archimate/ArchimateElementTemplate.js +195 -0
  88. package/src/charting/archimate/ArchimatePalette.js +102 -0
  89. package/src/charting/archimate/CsvImportDialog.js +105 -0
  90. package/src/charting/archimate/CustomViewpoints.js +74 -0
  91. package/src/charting/archimate/DerivedEdge.js +29 -0
  92. package/src/charting/archimate/DrawioFileFormat.js +24 -0
  93. package/src/charting/archimate/ElementFilterRule.js +21 -0
  94. package/src/charting/archimate/ExchangeFileFormat.js +28 -0
  95. package/src/charting/archimate/ViewGroupTemplate.js +137 -0
  96. package/src/charting/archimate/ViewLineEdge.js +84 -0
  97. package/src/charting/archimate/ViewpointRule.js +45 -0
  98. package/src/charting/archimate/archimateFileFormats.js +12 -0
  99. package/src/charting/archimate/archimateNames.js +5 -0
  100. package/src/charting/archimate/csvMapping.js +122 -0
  101. package/src/charting/archimate/elementMenuItems.js +32 -0
  102. package/src/charting/archimate/elementProperties.js +146 -0
  103. package/src/charting/archimate/elementTypeChoices.js +7 -0
  104. package/src/charting/archimate/elementTypeGroups.js +19 -0
  105. package/src/charting/archimate/index.js +17 -0
  106. package/src/charting/archimate/specializationCatalogDialog.js +64 -0
  107. package/src/charting/archimate/typeGlyph.js +29 -0
  108. package/src/charting/arrangement/Arrangement.js +112 -0
  109. package/src/charting/arrangement/ArrangementCommand.js +29 -0
  110. package/src/charting/arrangement/BackgroundCommand.js +41 -0
  111. package/src/charting/arrangement/BackgroundGroup.js +18 -0
  112. package/src/charting/arrangement/GroupCommand.js +46 -0
  113. package/src/charting/arrangement/ItemGroup.js +62 -0
  114. package/src/charting/arrangement/LockCommand.js +32 -0
  115. package/src/charting/arrangement/UngroupCommand.js +27 -0
  116. package/src/charting/arrangement/alignment.js +88 -0
  117. package/src/charting/arrangement/arrangeMenuItems.js +25 -0
  118. package/src/charting/arrangement/index.js +11 -0
  119. package/src/charting/arrangement/layouts.js +233 -0
  120. package/src/charting/canvas/ArchiHint.js +78 -0
  121. package/src/charting/canvas/CanvasBoxKind.js +39 -0
  122. package/src/charting/canvas/CanvasPalette.js +49 -0
  123. package/src/charting/canvas/CanvasTemplateLibrary.js +61 -0
  124. package/src/charting/canvas/CanvasTemplateMenu.js +151 -0
  125. package/src/charting/canvas/EditHintCommand.js +28 -0
  126. package/src/charting/canvas/canvasBoxKinds.js +27 -0
  127. package/src/charting/canvas/canvasBoxMenuItems.js +40 -0
  128. package/src/charting/canvas/defaultCanvasTemplates.js +186 -0
  129. package/src/charting/canvas/diagramBoxKinds.js +12 -0
  130. package/src/charting/canvas/hintMenuItems.js +49 -0
  131. package/src/charting/charts/ArcGauge.js +55 -0
  132. package/src/charting/charts/AreaChart.js +71 -0
  133. package/src/charting/charts/BarChart.js +80 -0
  134. package/src/charting/charts/BarChart3D.js +56 -0
  135. package/src/charting/charts/BarChart3DOrbit.js +53 -0
  136. package/src/charting/charts/BarChartBase.js +70 -0
  137. package/src/charting/charts/BarGauge.js +42 -0
  138. package/src/charting/charts/BoxPlotChart.js +41 -0
  139. package/src/charting/charts/BubbleChart.js +99 -0
  140. package/src/charting/charts/BubbleChart3D.js +78 -0
  141. package/src/charting/charts/BulletGauge.js +87 -0
  142. package/src/charting/charts/CalendarHeatmapChart.js +204 -0
  143. package/src/charting/charts/CandlestickChart.js +54 -0
  144. package/src/charting/charts/ChordDiagram.js +130 -0
  145. package/src/charting/charts/DensityChart.js +73 -0
  146. package/src/charting/charts/DialGauge.js +65 -0
  147. package/src/charting/charts/DonutChart.js +15 -0
  148. package/src/charting/charts/FunnelChart.js +47 -0
  149. package/src/charting/charts/GanttChart.js +201 -0
  150. package/src/charting/charts/GaugeChart.js +175 -0
  151. package/src/charting/charts/GeoMapChart.js +146 -0
  152. package/src/charting/charts/GroupedBarChart.js +88 -0
  153. package/src/charting/charts/GroupedDistributionChart.js +70 -0
  154. package/src/charting/charts/HeatmapChart.js +80 -0
  155. package/src/charting/charts/HierarchyChart.js +39 -0
  156. package/src/charting/charts/HistogramChart.js +45 -0
  157. package/src/charting/charts/KpiTile.js +72 -0
  158. package/src/charting/charts/LagPlotChart.js +41 -0
  159. package/src/charting/charts/LineChart.js +124 -0
  160. package/src/charting/charts/MultiRingGauge.js +54 -0
  161. package/src/charting/charts/OutlineChart.js +95 -0
  162. package/src/charting/charts/ParallelCoordinatesChart.js +130 -0
  163. package/src/charting/charts/PieChart.js +56 -0
  164. package/src/charting/charts/PipeChart.js +88 -0
  165. package/src/charting/charts/PopulationPyramidChart.js +106 -0
  166. package/src/charting/charts/QQPlotChart.js +64 -0
  167. package/src/charting/charts/RadarChart.js +76 -0
  168. package/src/charting/charts/RadialBarChart.js +96 -0
  169. package/src/charting/charts/RingGauge.js +23 -0
  170. package/src/charting/charts/SankeyDiagram.js +174 -0
  171. package/src/charting/charts/ScatterChart.js +104 -0
  172. package/src/charting/charts/StackedAreaChart.js +15 -0
  173. package/src/charting/charts/StackedBarChart.js +33 -0
  174. package/src/charting/charts/StackedBarChart3DOrbit.js +58 -0
  175. package/src/charting/charts/StreamGraphChart.js +131 -0
  176. package/src/charting/charts/SunburstChart.js +57 -0
  177. package/src/charting/charts/ThermometerGauge.js +43 -0
  178. package/src/charting/charts/TreemapChart.js +54 -0
  179. package/src/charting/charts/ViolinChart.js +37 -0
  180. package/src/charting/charts/WaterfallChart.js +66 -0
  181. package/src/charting/charts/WordCloudChart.js +104 -0
  182. package/src/charting/diagramModel/AddViewCommand.js +33 -0
  183. package/src/charting/diagramModel/DiagramModel.js +39 -0
  184. package/src/charting/diagramModel/DiagramModelSearch.js +22 -0
  185. package/src/charting/diagramModel/DiagramView.js +50 -0
  186. package/src/charting/diagramModel/ModelHistory.js +43 -0
  187. package/src/charting/diagramModel/ModelReport.js +153 -0
  188. package/src/charting/diagramModel/ModelSearch.js +223 -0
  189. package/src/charting/diagramModel/RemoveViewCommand.js +25 -0
  190. package/src/charting/diagramModel/RenameViewCommand.js +21 -0
  191. package/src/charting/diagramModel/ReplaceTextCommand.js +25 -0
  192. package/src/charting/diagramModel/ViewSetChecker.js +34 -0
  193. package/src/charting/diagramModel/ViewSetModel.js +243 -0
  194. package/src/charting/diagramModel/index.js +6 -0
  195. package/src/charting/diagramModel/nameTransforms.js +29 -0
  196. package/src/charting/diagrams/ArchimateCommands.js +141 -0
  197. package/src/charting/diagrams/ArchimateDiagram.js +263 -0
  198. package/src/charting/diagrams/ArchimateModel.js +1155 -0
  199. package/src/charting/diagrams/ArchimateModelChecker.js +125 -0
  200. package/src/charting/diagrams/ArchimateModelReport.js +128 -0
  201. package/src/charting/diagrams/ArchimateModelSearch.js +41 -0
  202. package/src/charting/diagrams/ArchimateValidator.js +357 -0
  203. package/src/charting/diagrams/CanvasView.js +112 -0
  204. package/src/charting/diagrams/ContextMenu.js +37 -0
  205. package/src/charting/diagrams/DataModelDiagram.js +86 -0
  206. package/src/charting/diagrams/DataModelRelationshipStrategy.js +38 -0
  207. package/src/charting/diagrams/DerivedRelationships.js +102 -0
  208. package/src/charting/diagrams/EbnfDiagram.js +39 -0
  209. package/src/charting/diagrams/EdgeGeometry.js +553 -0
  210. package/src/charting/diagrams/EditViewItemCommand.js +128 -0
  211. package/src/charting/diagrams/ElementInstance.js +157 -0
  212. package/src/charting/diagrams/GraphDiagram.js +1340 -0
  213. package/src/charting/diagrams/GraphDiagram3D.js +152 -0
  214. package/src/charting/diagrams/GraphMetrics.js +81 -0
  215. package/src/charting/diagrams/GridOverlay.js +137 -0
  216. package/src/charting/diagrams/ImportRowsCommand.js +62 -0
  217. package/src/charting/diagrams/LabelHelper.js +108 -0
  218. package/src/charting/diagrams/MergeElementsCommand.js +101 -0
  219. package/src/charting/diagrams/NestInstanceCommand.js +34 -0
  220. package/src/charting/diagrams/NodeGeometry.js +158 -0
  221. package/src/charting/diagrams/PlaceItemsCommand.js +77 -0
  222. package/src/charting/diagrams/RadialLayout.js +101 -0
  223. package/src/charting/diagrams/RelationshipInstance.js +93 -0
  224. package/src/charting/diagrams/RemoveGroupFromViewCommand.js +28 -0
  225. package/src/charting/diagrams/RemoveLineCommand.js +27 -0
  226. package/src/charting/diagrams/ShowElementCommand.js +43 -0
  227. package/src/charting/diagrams/SvgCoordinate.js +17 -0
  228. package/src/charting/diagrams/SvgZoom.js +127 -0
  229. package/src/charting/diagrams/Tooltip.js +62 -0
  230. package/src/charting/diagrams/ViewConnectionInstance.js +102 -0
  231. package/src/charting/diagrams/ViewObjectInstance.js +56 -0
  232. package/src/charting/diagrams/commands/AddEdgeCommand.js +34 -0
  233. package/src/charting/diagrams/commands/AddNodeCommand.js +28 -0
  234. package/src/charting/diagrams/commands/AddWaypointCommand.js +27 -0
  235. package/src/charting/diagrams/commands/CreateFolderCommand.js +27 -0
  236. package/src/charting/diagrams/commands/DeleteEdgeCommand.js +30 -0
  237. package/src/charting/diagrams/commands/DeleteFolderCommand.js +47 -0
  238. package/src/charting/diagrams/commands/DeleteNodeCommand.js +35 -0
  239. package/src/charting/diagrams/commands/DeleteWaypointCommand.js +24 -0
  240. package/src/charting/diagrams/commands/GraphCommand.js +65 -0
  241. package/src/charting/diagrams/commands/InvertEdgeCommand.js +24 -0
  242. package/src/charting/diagrams/commands/MoveNodeCommand.js +44 -0
  243. package/src/charting/diagrams/commands/MoveWaypointCommand.js +27 -0
  244. package/src/charting/diagrams/commands/RenameEdgeCommand.js +23 -0
  245. package/src/charting/diagrams/commands/RenameFolderCommand.js +31 -0
  246. package/src/charting/diagrams/commands/RenameNodeCommand.js +27 -0
  247. package/src/charting/diagrams/commands/ResizeNodeCommand.js +46 -0
  248. package/src/charting/diagrams/commands/UpdateEdgeSideCommand.js +40 -0
  249. package/src/charting/diagrams/commands/index.js +17 -0
  250. package/src/charting/diagrams/duplicates.js +49 -0
  251. package/src/charting/diagrams/nesting.js +30 -0
  252. package/src/charting/diagrams/roadmap.js +77 -0
  253. package/src/charting/edgeMarkers/ArrowMarker.js +15 -0
  254. package/src/charting/edgeMarkers/CircleMarker.js +13 -0
  255. package/src/charting/edgeMarkers/CrowsFootMarker.js +16 -0
  256. package/src/charting/edgeMarkers/DiamondMarker.js +15 -0
  257. package/src/charting/edgeMarkers/EdgeMarker.js +34 -0
  258. package/src/charting/edgeMarkers/HalfArrowMarker.js +8 -0
  259. package/src/charting/edgeMarkers/HollowDiamondMarker.js +18 -0
  260. package/src/charting/edgeMarkers/HollowTriangleMarker.js +18 -0
  261. package/src/charting/edgeMarkers/OpenArrowMarker.js +17 -0
  262. package/src/charting/edgeMarkers/index.js +27 -0
  263. package/src/charting/edgeStyle/EdgeStyleCascade.js +22 -0
  264. package/src/charting/edgeStyle/EdgeStyleDialog.js +51 -0
  265. package/src/charting/edgeStyle/EdgeStyleSchema.js +43 -0
  266. package/src/charting/edgeStyle/SetStyleCommand.js +12 -0
  267. package/src/charting/edgeStyle/index.js +4 -0
  268. package/src/charting/emphasis/EmphasisRule.js +42 -0
  269. package/src/charting/emphasis/HighlightRule.js +24 -0
  270. package/src/charting/gauges/ArcTrack.js +51 -0
  271. package/src/charting/gauges/GaugeAnimation.js +51 -0
  272. package/src/charting/gauges/GaugeBands.js +48 -0
  273. package/src/charting/gauges/GaugeScale.js +87 -0
  274. package/src/charting/gauges/GaugeTrack.js +44 -0
  275. package/src/charting/gauges/GaugeValue.js +61 -0
  276. package/src/charting/gauges/HorizontalTrack.js +14 -0
  277. package/src/charting/gauges/LinearTrack.js +29 -0
  278. package/src/charting/gauges/Sparkline.js +42 -0
  279. package/src/charting/gauges/VerticalTrack.js +17 -0
  280. package/src/charting/glyphs/ArrowGlyph.js +21 -0
  281. package/src/charting/glyphs/BatteryGlyph.js +18 -0
  282. package/src/charting/glyphs/ChevronGlyph.js +18 -0
  283. package/src/charting/glyphs/CircleGlyph.js +15 -0
  284. package/src/charting/glyphs/CloudGlyph.js +19 -0
  285. package/src/charting/glyphs/ComponentGlyph.js +18 -0
  286. package/src/charting/glyphs/ConstraintGlyph.js +24 -0
  287. package/src/charting/glyphs/ContractBoxGlyph.js +10 -0
  288. package/src/charting/glyphs/CubeGlyph.js +19 -0
  289. package/src/charting/glyphs/CylinderGlyph.js +19 -0
  290. package/src/charting/glyphs/DashedDoubleArrowGlyph.js +11 -0
  291. package/src/charting/glyphs/DeviceGlyph.js +17 -0
  292. package/src/charting/glyphs/DiamondGlyph.js +17 -0
  293. package/src/charting/glyphs/DocumentGlyph.js +17 -0
  294. package/src/charting/glyphs/DoubleArrowGlyph.js +23 -0
  295. package/src/charting/glyphs/DoubleCircleGlyph.js +24 -0
  296. package/src/charting/glyphs/EllipseGlyph.js +18 -0
  297. package/src/charting/glyphs/FactoryGlyph.js +20 -0
  298. package/src/charting/glyphs/FlagGlyph.js +16 -0
  299. package/src/charting/glyphs/GapCircleGlyph.js +17 -0
  300. package/src/charting/glyphs/GearGlyph.js +37 -0
  301. package/src/charting/glyphs/Glyph.js +98 -0
  302. package/src/charting/glyphs/GroupingBoxGlyph.js +13 -0
  303. package/src/charting/glyphs/HalfCircleGlyph.js +22 -0
  304. package/src/charting/glyphs/HexagonGlyph.js +28 -0
  305. package/src/charting/glyphs/IconGlyph.js +22 -0
  306. package/src/charting/glyphs/ImageGlyph.js +16 -0
  307. package/src/charting/glyphs/JunctionGlyph.js +17 -0
  308. package/src/charting/glyphs/LollipopGlyph.js +22 -0
  309. package/src/charting/glyphs/MagnifierGlyph.js +17 -0
  310. package/src/charting/glyphs/NoteGlyph.js +33 -0
  311. package/src/charting/glyphs/ObjectBoxGlyph.js +21 -0
  312. package/src/charting/glyphs/OrJunctionGlyph.js +17 -0
  313. package/src/charting/glyphs/ParallelogramGlyph.js +20 -0
  314. package/src/charting/glyphs/PersonGlyph.js +23 -0
  315. package/src/charting/glyphs/PillGlyph.js +23 -0
  316. package/src/charting/glyphs/PinGlyph.js +18 -0
  317. package/src/charting/glyphs/PrincipleGlyph.js +23 -0
  318. package/src/charting/glyphs/ProductBoxGlyph.js +16 -0
  319. package/src/charting/glyphs/RectGlyph.js +15 -0
  320. package/src/charting/glyphs/RoundedBoxGlyph.js +13 -0
  321. package/src/charting/glyphs/StackGlyph.js +14 -0
  322. package/src/charting/glyphs/StepsGlyph.js +20 -0
  323. package/src/charting/glyphs/StickFigureGlyph.js +32 -0
  324. package/src/charting/glyphs/SystemSoftwareBoxGlyph.js +16 -0
  325. package/src/charting/glyphs/TabbedBoxGlyph.js +37 -0
  326. package/src/charting/glyphs/TargetGlyph.js +23 -0
  327. package/src/charting/glyphs/WavyBoxGlyph.js +17 -0
  328. package/src/charting/glyphs/WheelGlyph.js +28 -0
  329. package/src/charting/glyphs/drawGlyph.js +28 -0
  330. package/src/charting/glyphs/glyphSvg.js +55 -0
  331. package/src/charting/glyphs/index.js +109 -0
  332. package/src/charting/modelTree/AnalysisPanel.js +159 -0
  333. package/src/charting/modelTree/DiagramTabs.js +217 -0
  334. package/src/charting/modelTree/ModelTree.js +164 -0
  335. package/src/charting/modelTree/ModelTreePanel.js +914 -0
  336. package/src/charting/modelTree/TreeBuilder.js +238 -0
  337. package/src/charting/modelTree/TreeModeRegistry.js +51 -0
  338. package/src/charting/modelTree/TreeViewMode.js +110 -0
  339. package/src/charting/modelTree/buildFilterTrees.js +138 -0
  340. package/src/charting/modelTree/modes/FlatTreeMode.js +46 -0
  341. package/src/charting/modelTree/modes/LayerGroupedTreeMode.js +62 -0
  342. package/src/charting/modelTree/modes/TypeGroupedTreeMode.js +60 -0
  343. package/src/charting/modelTree/treeLayers.js +11 -0
  344. package/src/charting/report/reportHtml.js +82 -0
  345. package/src/charting/report/reportViewer.js +118 -0
  346. package/src/charting/shapes/CircleShape.js +19 -0
  347. package/src/charting/shapes/PathShape.js +17 -0
  348. package/src/charting/shapes/RectShape.js +20 -0
  349. package/src/charting/shapes/Shape.js +20 -0
  350. package/src/charting/shapes/ShapeFactory.js +23 -0
  351. package/src/charting/storage/LocalJsonStore.js +43 -0
  352. package/src/charting/templates/ActorTemplate.js +36 -0
  353. package/src/charting/templates/BoxTemplate.js +27 -0
  354. package/src/charting/templates/CircleTemplate.js +18 -0
  355. package/src/charting/templates/ClassTemplate.js +20 -0
  356. package/src/charting/templates/CloudTemplate.js +43 -0
  357. package/src/charting/templates/ComponentTemplate.js +19 -0
  358. package/src/charting/templates/CylinderTemplate.js +30 -0
  359. package/src/charting/templates/DataStoreTemplate.js +16 -0
  360. package/src/charting/templates/DiamondTemplate.js +10 -0
  361. package/src/charting/templates/DocumentTemplate.js +32 -0
  362. package/src/charting/templates/EllipseTemplate.js +15 -0
  363. package/src/charting/templates/FinalStateTemplate.js +12 -0
  364. package/src/charting/templates/GlyphTemplate.js +47 -0
  365. package/src/charting/templates/HexagonTemplate.js +17 -0
  366. package/src/charting/templates/LifelineTemplate.js +20 -0
  367. package/src/charting/templates/ManualInputTemplate.js +12 -0
  368. package/src/charting/templates/NoteTemplate.js +23 -0
  369. package/src/charting/templates/OctagonTemplate.js +7 -0
  370. package/src/charting/templates/PackageTemplate.js +25 -0
  371. package/src/charting/templates/ParallelogramTemplate.js +11 -0
  372. package/src/charting/templates/PentagonTemplate.js +5 -0
  373. package/src/charting/templates/PolygonTemplate.js +18 -0
  374. package/src/charting/templates/PredefinedProcessTemplate.js +13 -0
  375. package/src/charting/templates/RectangleTemplate.js +28 -0
  376. package/src/charting/templates/RegularPolygonTemplate.js +21 -0
  377. package/src/charting/templates/RoundedRectangleTemplate.js +5 -0
  378. package/src/charting/templates/StadiumTemplate.js +8 -0
  379. package/src/charting/templates/StarTemplate.js +17 -0
  380. package/src/charting/templates/SwimlaneTemplate.js +18 -0
  381. package/src/charting/templates/Template.js +208 -0
  382. package/src/charting/templates/TrapezoidTemplate.js +11 -0
  383. package/src/charting/templates/TriangleTemplate.js +12 -0
  384. package/src/charting/templates/index.js +31 -0
  385. package/src/charting/templates/outline.js +59 -0
  386. package/src/charting/templates/svg.js +19 -0
  387. package/src/charting/textToShapes.js +61 -0
  388. package/src/charting/toolbar/ToolbarButton.js +38 -0
  389. package/src/charting/toolbar/ToolbarCheckbox.js +31 -0
  390. package/src/charting/toolbar/ToolbarItem.js +19 -0
  391. package/src/charting/toolbar/ToolbarMenu.js +36 -0
  392. package/src/charting/toolbar/ToolbarSelect.js +38 -0
  393. package/src/charting/toolbar/ToolbarSeparator.js +7 -0
  394. package/src/charting/toolbar/ToolbarText.js +22 -0
  395. package/src/charting/toolbar/index.js +8 -0
  396. package/src/charting/toolbar/pickFile.js +14 -0
  397. package/src/charting/viewDecorations.js +85 -0
  398. package/src/charting/zOrder.js +57 -0
  399. package/src/csvTable.js +61 -0
  400. package/src/datamodel.js +122 -0
  401. package/src/datawindow/BoundedWindow.js +36 -0
  402. package/src/datawindow/FlatDataWindow.js +34 -0
  403. package/src/datawindow/GraphDataWindow.js +40 -0
  404. package/src/datawindow/GroupedSampleDataWindow.js +16 -0
  405. package/src/datawindow/SeriesDataWindow.js +42 -0
  406. package/src/datawindow/index.js +31 -0
  407. package/src/diagramCatalog.js +30 -0
  408. package/src/ebnfDiagram.js +57 -0
  409. package/src/ebnfParser.js +129 -0
  410. package/src/exportImage.js +233 -0
  411. package/src/index.js +2636 -0
  412. package/src/itIcons.js +84 -0
  413. package/src/kernelExpr.js +243 -0
  414. package/src/propertiesDialog.js +463 -0
  415. package/src/railroadDiagram.js +571 -0
  416. package/src/treeModeCatalog.js +16 -0
  417. package/src/workspace/ContextBus.js +79 -0
  418. package/src/workspace/EditorShell.js +67 -0
  419. package/src/workspace/Part.js +163 -0
  420. package/src/workspace/PartFactory.js +49 -0
  421. package/src/workspace/PartRegistry.js +86 -0
  422. package/src/workspace/Workspace.js +321 -0
  423. package/src/workspace/archimateServices.js +33 -0
  424. package/src/workspace/dom.js +120 -0
  425. package/src/workspace/index.js +75 -0
  426. package/src/workspace/layout/GridNode.js +280 -0
  427. package/src/workspace/layout/LayoutNode.js +89 -0
  428. package/src/workspace/layout/PartNode.js +77 -0
  429. package/src/workspace/layout/SplitNode.js +114 -0
  430. package/src/workspace/layout/TabsNode.js +191 -0
  431. package/src/workspace/layout/index.js +24 -0
  432. package/src/workspace/parts/AdapterPart.js +33 -0
  433. package/src/workspace/parts/ArchimateCanvasPart.js +345 -0
  434. package/src/workspace/parts/ArchimateEditorPart.js +79 -0
  435. package/src/workspace/parts/ChartPart.js +115 -0
  436. package/src/workspace/parts/ContentPart.js +34 -0
  437. package/src/workspace/parts/DetailPart.js +46 -0
  438. package/src/workspace/parts/DiagramEditorPart.js +135 -0
  439. package/src/workspace/parts/EditorPart.js +388 -0
  440. package/src/workspace/parts/HtmlPart.js +25 -0
  441. package/src/workspace/parts/ListPart.js +57 -0
  442. package/src/workspace/parts/ModelFile.js +187 -0
  443. package/src/workspace/parts/ModelsPart.js +135 -0
  444. package/src/workspace/styles.js +258 -0
  445. package/src/workspace/themes.js +96 -0
  446. package/src/workspace/workArea.js +413 -0
  447. package/src/workspace/workAreaModel.js +197 -0
  448. package/src/workspace.js +16 -0
  449. package/src/zip/ZipArchive.js +160 -0
  450. package/src/zip/crc32.js +25 -0
  451. package/src/zip/inflate.js +159 -0
@@ -0,0 +1,439 @@
1
+ import { BaseRenderer } from './BaseRenderer.js';
2
+
3
+ /**
4
+ * @class SVGRenderer
5
+ * Renders shapes by creating and appending SVG elements to an <svg> tag.
6
+ */
7
+ export class SVGRenderer extends BaseRenderer {
8
+ get type() { return 'svg'; }
9
+ get supportsSceneGraph() { return true; }
10
+
11
+ static #instances = 0;
12
+
13
+ /**
14
+ * The id of a line-end marker in this renderer's <defs>. Each renderer has
15
+ * its own prefix: ids are page-wide, and `url(#arrow)` would otherwise find
16
+ * the first SVG's marker, which may be hidden (another tab, another editor).
17
+ * @param {string} name - marker name, e.g. 'arrow', 'diamond-hollow'
18
+ */
19
+ markerId(name) { return `${this.markerPrefix}${name}`; }
20
+
21
+ /** The `marker-start`/`marker-end` value for a marker name. */
22
+ markerUrl(name) { return `url(#${this.markerId(name)})`; }
23
+
24
+ _createElement(tag,attributes = {},stroke = null) {
25
+ const el = document.createElementNS("http://www.w3.org/2000/svg", tag);
26
+ this._setAttributes(el, attributes);
27
+ if (stroke) {
28
+ this._setAttributes(el, { stroke: stroke.color || 'none', 'stroke-width': stroke.width || 1 });
29
+ // Used by the gauge arcs' rounded end-caps ({cap: 'round'}) — was
30
+ // silently dropped, so gauges always got default (butt) caps.
31
+ if (stroke.cap) this._setAttributes(el, { 'stroke-linecap': stroke.cap });
32
+ }
33
+ // Do not append here; let the caller decide.
34
+ // if (this.svg) this.svg.appendChild(el);
35
+ return el;
36
+ }
37
+ _elMap = new Map();
38
+ constructor(container, width, height) {
39
+ super(container, width, height);
40
+ this.markerPrefix = `re${SVGRenderer.#instances++}-`;
41
+ this.svg = this._createElement("svg",{ width, height, viewBox: `0 0 ${width} ${height}` });
42
+ // Inline elements (the default for <svg>) leave a few px of baseline
43
+ // whitespace below them inside a block container, making the
44
+ // container's scrollHeight exceed its clientHeight for every chart.
45
+ this.svg.style.display = 'block';
46
+
47
+ // Add a style tag for hover effects
48
+ const defs = this._createElement('defs');
49
+
50
+ // Default arrow marker
51
+ const arrowMarker = this._createElement('marker', { id: this.markerId('arrow'), viewBox: '0 0 10 10', refX: 8, refY: 5, markerWidth: 6, markerHeight: 6, orient: 'auto-start-reverse' });
52
+ arrowMarker.appendChild(this._createElement('path', { d: 'M 0 0 L 10 5 L 0 10 z', class: 'arrowhead-path' }));
53
+ defs.appendChild(arrowMarker);
54
+
55
+ // Circle marker
56
+ const circleMarker = this._createElement('marker', { id: this.markerId('circle'), viewBox: '0 0 10 10', refX: 5, refY: 5, markerWidth: 6, markerHeight: 6, orient: 'auto-start-reverse' });
57
+ circleMarker.appendChild(this._createElement('circle', { cx: 5, cy: 5, r: 4, class: 'arrowhead-path' }));
58
+ defs.appendChild(circleMarker);
59
+
60
+ // Tee marker
61
+ const teeMarker = this._createElement('marker', { id: this.markerId('tee'), viewBox: '0 0 10 10', refX: 1, refY: 5, markerWidth: 6, markerHeight: 6, orient: 'auto-start-reverse' });
62
+ teeMarker.appendChild(this._createElement('path', { d: 'M 0 0 L 0 10', 'stroke-width': 2, class: 'arrowhead-path' }));
63
+ defs.appendChild(teeMarker);
64
+
65
+ // The four markers below exist for graphDiagram's relationship-style
66
+ // notation (composition/aggregation/realization/specialization/
67
+ // serving/access/influence — see _archimateRelationshipStyle) but
68
+ // aren't ArchiMate-specific themselves: any edge can use them via
69
+ // `arrowhead`/`arrowheadStart`, same as 'arrow'/'circle'/'tee' above.
70
+ // Filled diamond (composition's "whole"-end glyph).
71
+ const diamondMarker = this._createElement('marker', { id: this.markerId('diamond'), viewBox: '0 0 10 10', refX: 9, refY: 5, markerWidth: 8, markerHeight: 8, orient: 'auto-start-reverse' });
72
+ diamondMarker.appendChild(this._createElement('path', { d: 'M0,5 L5,0 L10,5 L5,10 Z', class: 'arrowhead-path' }));
73
+ defs.appendChild(diamondMarker);
74
+
75
+ // Hollow diamond (aggregation) — filled white, not transparent, so
76
+ // the line underneath doesn't show through the shape.
77
+ const diamondHollowMarker = this._createElement('marker', { id: this.markerId('diamond-hollow'), viewBox: '0 0 10 10', refX: 9, refY: 5, markerWidth: 8, markerHeight: 8, orient: 'auto-start-reverse' });
78
+ diamondHollowMarker.appendChild(this._createElement('path', { d: 'M0,5 L5,0 L10,5 L5,10 Z', class: 'arrowhead-path-hollow' }));
79
+ defs.appendChild(diamondHollowMarker);
80
+
81
+ // Hollow triangle (realization/specialization) — same white-filled
82
+ // convention as the hollow diamond above.
83
+ const triangleHollowMarker = this._createElement('marker', { id: this.markerId('triangle-hollow'), viewBox: '0 0 10 10', refX: 9, refY: 5, markerWidth: 8, markerHeight: 8, orient: 'auto-start-reverse' });
84
+ triangleHollowMarker.appendChild(this._createElement('path', { d: 'M0,0 L10,5 L0,10 Z', class: 'arrowhead-path-hollow' }));
85
+ defs.appendChild(triangleHollowMarker);
86
+
87
+ // Open/thin arrow (serving, access, influence) — an unfilled chevron,
88
+ // distinct from 'arrow's solid filled triangle.
89
+ const openArrowMarker = this._createElement('marker', { id: this.markerId('open-arrow'), viewBox: '0 0 10 10', refX: 9, refY: 5, markerWidth: 8, markerHeight: 8, orient: 'auto-start-reverse' });
90
+ openArrowMarker.appendChild(this._createElement('path', { d: 'M0,0 L9,5 L0,10', class: 'arrowhead-path-open' }));
91
+ defs.appendChild(openArrowMarker);
92
+
93
+ // Half/single-barb open arrow — ArchiMate's DIRECTED association (the
94
+ // spec's own relationships figure shows association twice: a plain
95
+ // line, and this one-barb variant for the directed form).
96
+ const halfArrowMarker = this._createElement('marker', { id: this.markerId('open-arrow-half'), viewBox: '0 0 10 10', refX: 9, refY: 5, markerWidth: 8, markerHeight: 8, orient: 'auto-start-reverse' });
97
+ halfArrowMarker.appendChild(this._createElement('path', { d: 'M0,0 L9,5', class: 'arrowhead-path-open' }));
98
+ defs.appendChild(halfArrowMarker);
99
+
100
+ // Crow's-foot ERD cardinality glyphs (dataModelDiagram's 'crowsfoot'
101
+ // notation — see src/datamodel.js) — a representative rendition, not
102
+ // every real-notation optionality combination. All four share a
103
+ // 16-wide viewBox with refX:15 (the point that sits ON the entity's
104
+ // edge) so the drawn glyph sits BETWEEN the entity and the line,
105
+ // extending away from it toward x:0.
106
+ // "Exactly one" (mandatory, single cardinality) — one perpendicular tick.
107
+ const crowsfootOneMarker = this._createElement('marker', { id: this.markerId('crowsfoot-one'), viewBox: '0 0 16 10', refX: 15, refY: 5, markerWidth: 12, markerHeight: 8, orient: 'auto-start-reverse' });
108
+ crowsfootOneMarker.appendChild(this._createElement('path', { d: 'M10,1 L10,9', class: 'arrowhead-path-open' }));
109
+ defs.appendChild(crowsfootOneMarker);
110
+ // "Zero or one" (optional, single cardinality) — hollow circle (the
111
+ // "zero"/optional part) plus one tick (the "one" part) further out.
112
+ const crowsfootOneOptionalMarker = this._createElement('marker', { id: this.markerId('crowsfoot-one-optional'), viewBox: '0 0 16 10', refX: 15, refY: 5, markerWidth: 12, markerHeight: 8, orient: 'auto-start-reverse' });
113
+ crowsfootOneOptionalMarker.appendChild(this._createElement('circle', { cx: 12, cy: 5, r: 3, class: 'arrowhead-path-hollow' }));
114
+ crowsfootOneOptionalMarker.appendChild(this._createElement('path', { d: 'M5,1 L5,9', class: 'arrowhead-path-open' }));
115
+ defs.appendChild(crowsfootOneOptionalMarker);
116
+ // "Zero or many" (optional, many cardinality) — the crow's-foot fork
117
+ // alone, its three prongs touching the entity edge.
118
+ const crowsfootManyMarker = this._createElement('marker', { id: this.markerId('crowsfoot-many'), viewBox: '0 0 16 10', refX: 15, refY: 5, markerWidth: 12, markerHeight: 8, orient: 'auto-start-reverse' });
119
+ crowsfootManyMarker.appendChild(this._createElement('path', { d: 'M5,5 L15,0 M5,5 L15,5 M5,5 L15,10', class: 'arrowhead-path-open' }));
120
+ defs.appendChild(crowsfootManyMarker);
121
+ // "One or many" (mandatory, many cardinality) — the fork plus one
122
+ // tick further out (the "at least one" part).
123
+ const crowsfootManyMandatoryMarker = this._createElement('marker', { id: this.markerId('crowsfoot-many-mandatory'), viewBox: '0 0 16 10', refX: 15, refY: 5, markerWidth: 12, markerHeight: 8, orient: 'auto-start-reverse' });
124
+ crowsfootManyMandatoryMarker.appendChild(this._createElement('path', { d: 'M5,5 L15,0 M5,5 L15,5 M5,5 L15,10 M2,2 L2,8', class: 'arrowhead-path-open' }));
125
+ defs.appendChild(crowsfootManyMandatoryMarker);
126
+
127
+ this.svg.appendChild(defs);
128
+ const style =this._createElement("style");
129
+ style.textContent = `
130
+ .hover {
131
+ fill: orange;
132
+ stroke: #333;
133
+ stroke-width: 2px;
134
+ }
135
+ .selected {
136
+ filter: drop-shadow(0 0 3px var(--ws-accent, #91cc75));
137
+ }
138
+ .selected > path,
139
+ .selected > rect,
140
+ .selected > circle,
141
+ .selected > ellipse,
142
+ .selected > polygon {
143
+ stroke: var(--ws-accent, #91cc75);
144
+ stroke-width: 3px;
145
+ }
146
+ .selected-edge {
147
+ stroke: var(--ws-accent, #91cc75);
148
+ stroke-width: 3px;
149
+ }
150
+ .arrowhead-path {
151
+ fill: inherit;
152
+ stroke: inherit;
153
+ }
154
+ .arrowhead-path-hollow {
155
+ fill: white;
156
+ stroke: black;
157
+ stroke-width: 1px;
158
+ }
159
+ .arrowhead-path-open {
160
+ fill: none;
161
+ stroke: black;
162
+ stroke-width: 1.5px;
163
+ }
164
+ `;
165
+ this.svg.appendChild(style);
166
+ // The main SVG is now the default parent for new elements.
167
+ this.container.appendChild(this.svg);
168
+ }
169
+
170
+ clear() {
171
+ this._elMap.clear();
172
+ // Keep <defs> and <style> elements; remove everything else.
173
+ for (const child of [...this.svg.children]) {
174
+ if (child.tagName !== 'style' && child.tagName !== 'defs') child.remove();
175
+ }
176
+ }
177
+ _defineShape(shape,attributes, stroke = null) {
178
+ shape.id=`shape_${this._elMap.size}`;
179
+ const parent = shape.parent || this.svg;
180
+ const el = this._createElement(shape.type, attributes, stroke);
181
+ parent.appendChild(el);
182
+ this._elMap.set(shape.id, { el, shape });
183
+ return shape.id;
184
+ }
185
+ rect(x, y, width, height, fill, stroke, extra) {
186
+ const shape = { type: 'rect', x, y, width, height, fill, stroke, ...extra };
187
+ this._defineShape(shape, { x, y, width, height, fill: fill || 'none', ...extra }, stroke);
188
+ return this._elMap.get(shape.id).el;
189
+ }
190
+
191
+ circle(cx, cy, r, fill, stroke, extra) {
192
+ const shape = { type: 'circle', cx, cy, r, fill, stroke, ...extra};
193
+ this._defineShape(shape, { cx, cy, r, fill: fill || 'none' }, stroke);
194
+ return this._elMap.get(shape.id).el;
195
+ }
196
+
197
+ path(d, fill, stroke, extra = {}) {
198
+ // `extra` (e.g. {tooltip}) merges into the shape descriptor only, not
199
+ // into DOM attributes — hitTest()/tooltip resolution reads it straight
200
+ // off `shape` (see _addTooltipListeners), it was never rendered as a
201
+ // real SVG attribute for rect/circle either. Previously missing here
202
+ // (CanvasRenderer.path already accepted it) — pie/doughnut wedges,
203
+ // candlestick bodies, and box-plot boxes all need path-level tooltips.
204
+ const shape = { type: 'path', d, fill, stroke, ...extra, id: `shape_${this._elMap.size}` };
205
+ // _createElement already applies stroke.color/width as real SVG attributes
206
+ // (see the `stroke` param handling above) — do NOT also set them as inline
207
+ // styles here. Setting style.fill = stroke.color previously clobbered any
208
+ // closed shape's real fill (e.g. graphDiagram's diamond node, filled with
209
+ // the group color but stroked white) with the stroke color instead, since
210
+ // inline styles win over attributes. Open paths (edge lines, fill:'none')
211
+ // never showed the bug since there's no enclosed area to paint either way.
212
+ const pathEl = this._createElement("path", { d, fill: fill || 'none' }, stroke);
213
+ this.svg.appendChild(pathEl);
214
+ this._elMap.set(shape.id, { el: pathEl, shape });
215
+ return pathEl;
216
+ }
217
+
218
+ /** Text width measured with a (shared, off-page) 2D canvas context; the estimate without a document. */
219
+ measureText(text, font = {}) {
220
+ if (typeof document === 'undefined' || typeof document.createElement !== 'function') return super.measureText(text, font);
221
+ const ctx = (SVGRenderer._measureContext ??= document.createElement('canvas').getContext?.('2d'));
222
+ if (!ctx) return super.measureText(text, font);
223
+ ctx.font = BaseRenderer.cssFont(font);
224
+ return ctx.measureText(String(text)).width;
225
+ }
226
+
227
+ text(text, x, y, options = {}) {
228
+ const shape = { type: 'text', text, x, y, ...options, id: `shape_${this._elMap.size}` };
229
+ const attrs = { x, y, fill: options.fill || 'black', 'font-family': options.fontFamily || 'sans-serif', 'font-size': options.fontSize || '12px', 'text-anchor': options.textAnchor || 'start' };
230
+ // Several call sites (graph-node initials/labels, table-node rows) pass
231
+ // verticalAlign:'middle' expecting the text to be vertically centred on
232
+ // its y-coordinate — this was silently ignored (SVG's default baseline
233
+ // is alphabetic, not middle), so multi-row content sat visibly low.
234
+ if (options.verticalAlign === 'middle') attrs['dominant-baseline'] = 'middle';
235
+ if (options.fontWeight) attrs['font-weight'] = options.fontWeight;
236
+ if (options.fontStyle) attrs['font-style'] = options.fontStyle;
237
+ // Every graphDiagram call site passes 'pointer-events':'none' on node
238
+ // initials/labels expecting clicks to fall through to the shape/badge
239
+ // underneath — silently dropped since it wasn't in this whitelist, so
240
+ // filled text always intercepted the click regardless of what callers
241
+ // asked for (surfaced by the new collapse-badge glyph sitting on top
242
+ // of its own circle and eating every click meant for it).
243
+ if (options['pointer-events']) attrs['pointer-events'] = options['pointer-events'];
244
+ // `rotation` is in radians (matches Canvas's ctx.rotate() convention) —
245
+ // convert to degrees for SVG's transform=rotate(deg, cx, cy). Every
246
+ // yAxisLabel call across the chart methods relies on this to render
247
+ // vertically instead of overlapping/clipping past the chart's left edge.
248
+ if (options.rotation) attrs.transform = `rotate(${options.rotation * 180 / Math.PI} ${x} ${y})`;
249
+ const el = this._createElement('text', attrs);
250
+ el.textContent = text;
251
+ this.svg.appendChild(el);
252
+ this._elMap.set(shape.id, { el, shape });
253
+ return el;
254
+ }
255
+
256
+ /** An SVG `<image>` — used for graphDiagram's `node.iconUrl` (a custom
257
+ * icon/image file/data URI centred on a node, in place of the plain
258
+ * initials text). `href` is set as the plain SVG2 attribute; every
259
+ * renderer target this library ships against (real browsers, jsdom in
260
+ * tests) resolves that without also needing the legacy `xlink:href`. */
261
+ image(href, x, y, width, height, options = {}) {
262
+ const shape = { type: 'image', href, x, y, width, height, ...options, id: `shape_${this._elMap.size}` };
263
+ const attrs = { href, x, y, width, height, preserveAspectRatio: options.preserveAspectRatio || 'xMidYMid meet' };
264
+ if (options['pointer-events']) attrs['pointer-events'] = options['pointer-events'];
265
+ const el = this._createElement('image', attrs);
266
+ this.svg.appendChild(el);
267
+ this._elMap.set(shape.id, { el, shape });
268
+ return el;
269
+ }
270
+
271
+ group(attributes = {}) {
272
+ const shape = { type: 'g', ...attributes, id: `shape_${this._elMap.size}` };
273
+ const el = this._createElement('g', attributes);
274
+ this.svg.appendChild(el);
275
+ this._elMap.set(shape.id, { el, shape });
276
+ return el;
277
+ }
278
+
279
+ hitTest(x, y) {
280
+ // This is a bit of a hack. We find the element and then iterate our map to find the shape.
281
+ // A more robust solution might use a WeakMap from element to shape.
282
+ //
283
+ // `x`/`y` are viewport coordinates (every caller in index.js passes
284
+ // event.clientX/clientY straight through) — document.elementFromPoint
285
+ // already takes coordinates in that same space. Adding this.svg's own
286
+ // getBoundingClientRect().left/top on top double-offset the query
287
+ // point by the canvas's on-page position, so hitTest silently queried
288
+ // the wrong spot on the page for any layout where the SVG isn't flush
289
+ // against the browser's top-left corner (i.e. basically always, once
290
+ // there's a toolbar/sidebar around it) — drag-start, the context
291
+ // menu, and tooltips all read this result directly, so all three
292
+ // misfired by exactly that offset. Zoom (the SVG's internal viewBox
293
+ // scale) doesn't factor in here at all: elementFromPoint operates on
294
+ // real rendered screen pixels, which already reflect whatever zoom is
295
+ // applied, so no CTM/zoom math belongs in this function.
296
+ const hitEl = this.svg.ownerDocument.elementFromPoint(x, y);
297
+ if (!hitEl) return null;
298
+ return SVGRenderer.resolveHit(this._elMap, hitEl);
299
+ }
300
+
301
+ /**
302
+ * Given the element under the cursor and the el→{el,shape} registry, picks
303
+ * which registered shape a hit resolves to. Split out from hitTest() so
304
+ * this candidate-selection logic is unit-testable without a real DOM
305
+ * (`hitEl`/registered `el`s just need a `.contains()` method).
306
+ *
307
+ * A graph node is drawn as an outer <g draggable nodeId tooltip> wrapping
308
+ * an inner shape primitive (circle/rect/path) plus text labels — each
309
+ * registered in _elMap separately, with the inner primitive inserted
310
+ * *before* the wrapping group. Since _elMap is iterated in insertion order
311
+ * and this used to return the *first* match, a click on the node's own
312
+ * visible body resolved to the inner primitive's bare shape (no
313
+ * draggable/tooltip/nodeId) instead of the wrapping group — silently
314
+ * breaking drag-start, the context menu, and hover tooltips (all of which
315
+ * read hitTest()'s result directly, unlike click-to-select which bubbles
316
+ * via a real DOM listener). Prefer a draggable node wrapper among the
317
+ * candidates when one is present; otherwise keep the original first-match
318
+ * behavior (legend markers etc. resolve via their own direct listeners
319
+ * already, not this method).
320
+ */
321
+ static resolveHit(elMap, hitEl) {
322
+ let first = null;
323
+ for (const { el, shape } of elMap.values()) {
324
+ if (el === hitEl || el.contains(hitEl)) {
325
+ if (!first) first = shape;
326
+ if (shape.draggable && shape.nodeId != null) return shape;
327
+ }
328
+ }
329
+ return first;
330
+ }
331
+
332
+ enterState(shape, stateName) {
333
+ this._elMap.get(shape.id)?.el.classList.add(stateName);
334
+ }
335
+
336
+ leaveState(shape, stateName) {
337
+ this._elMap.get(shape.id)?.el.classList.remove(stateName);
338
+ }
339
+
340
+ renderDiagram(diagram) {
341
+ // 20,20 padding matches this file's own DiagramNode.prototype.drawOn
342
+ // (railroadDiagram.js, the Canvas rendering path) — without a real
343
+ // starting x/y, every node's format() computes its own position as
344
+ // NaN (this used to be called with zero args, so x/y were undefined
345
+ // throughout the whole tree).
346
+ diagram.format(20, 20);
347
+
348
+ const group = this._createElement('g', {
349
+ 'font-family': 'monospace',
350
+ 'font-size': '12px'
351
+ });
352
+
353
+ // Collect every leaf first, then draw in a fixed path -> rect -> text
354
+ // paint order, rather than the tree's own traversal order. Connector
355
+ // lines (Sequence's backbone, ZeroOrMore's top line, Choice's arcs)
356
+ // legitimately run behind boxes they connect through — but walk()
357
+ // visits nodes in whatever order each FORMATTERS.* function happened
358
+ // to build its .item/.items — e.g. a Sequence's own backbone Path is
359
+ // appended (via addTo()) AFTER its child items are formatted, so it
360
+ // painted on top of and struck through every terminal/nonterminal
361
+ // box's text. A fixed paint order guarantees lines stay underneath
362
+ // opaque boxes and text stays readable on top, regardless of which
363
+ // order the diagram tree happens to store its children in.
364
+ const leaves = [];
365
+ diagram.walk(item => {
366
+ // The `if (item.type === 'rect'/'path'/'text')` chain below
367
+ // already correctly picks out only real leaf shapes — every
368
+ // intermediate DiagramNode-tree node (Sequence/Choice/Terminal/
369
+ // NonTerminal/...) has a .type that never matches any of those,
370
+ // so it's harmless to reach the chain and fall through. A prior
371
+ // `if (!item.width) return;` guard here was presumably meant to
372
+ // skip those same intermediate nodes, but 'text' and 'path'
373
+ // FakeSVG leaves never carry a .width at all (only 'rect' does —
374
+ // same as real SVG <text>/<path> elements), so it silently
375
+ // discarded every label and every connector line too.
376
+ if (item.type === 'rect' || item.type === 'path' || item.type === 'text') leaves.push(item);
377
+ });
378
+ const paintOrder = { path: 0, rect: 1, text: 2 };
379
+ leaves.sort((a, b) => paintOrder[a.type] - paintOrder[b.type]);
380
+ leaves.forEach(item => {
381
+ if (item.type === 'rect') {
382
+ // NonTerminal rects have no rx/ry (sharp corners, by design —
383
+ // see railroadDiagram.js's FORMATTERS.NonTerminal) — only
384
+ // pass them through when real, rather than setting a literal
385
+ // "undefined" string attribute value.
386
+ const extra = { parent: group };
387
+ if (item.rx != null) extra.rx = item.rx;
388
+ if (item.ry != null) extra.ry = item.ry;
389
+ this.rect(item.x, item.y, item.width, item.height, 'hsl(30,20%,95%)', { color: 'black', width: 2 }, extra);
390
+ } else if (item.type === 'path') {
391
+ const pathEl = this._createElement('path', { d: item.attrs.d }, { color: 'black', width: 3 });
392
+ pathEl.setAttribute('fill', 'none');
393
+ group.appendChild(pathEl);
394
+ } else if (item.type === 'text') {
395
+ const textEl = this._createElement('text', {
396
+ x: item.x,
397
+ y: item.y,
398
+ 'text-anchor': 'middle',
399
+ fill: 'black'
400
+ });
401
+ if (item.attrs.class === 'comment') {
402
+ textEl.setAttribute('font-style', 'italic');
403
+ } else if (item.type === 'NonTerminal') {
404
+ textEl.setAttribute('font-weight', 'bold');
405
+ }
406
+ textEl.textContent = item.text;
407
+ group.appendChild(textEl);
408
+ }
409
+ });
410
+
411
+ // Every other SVGRenderer primitive (group()/rect()/circle()/...)
412
+ // appends itself to this.svg (or a specified parent) within its own
413
+ // method — this one built `group` and populated it via the walk
414
+ // callback's this.rect(...) calls (which do append into `group`,
415
+ // via the `parent: group` extra above), but never attached `group`
416
+ // to the actual <svg> itself, so nothing was ever visible.
417
+ this.svg.appendChild(group);
418
+
419
+ // A diagram's natural width is data-driven (however many rule
420
+ // elements it has) and routinely wider than a chart's fixed
421
+ // container box. Only the viewBox is updated to the content's real
422
+ // size — width/height stay at whatever they were set to at
423
+ // construction (the container's own clientWidth/clientHeight, same
424
+ // as every other chart type) — so the SVG's default
425
+ // preserveAspectRatio="xMidYMid meet" scales the whole diagram down
426
+ // to fit that fixed box, exactly like an <img>: no scrollbar, no
427
+ // clipping, just a smaller rendering for a wide diagram. (An
428
+ // earlier version of this also resized width/height to match the
429
+ // content, which fit the diagram at full native size but broke
430
+ // the page's CSS grid layout — a grid item's automatic minimum
431
+ // size is based on its content's intrinsic size unless something
432
+ // caps it — and even with that capped, still needed a scrollbar to
433
+ // reach the full content. Not resizing width/height avoids both.)
434
+ const w = diagram.width + 40, h = diagram.height + 40;
435
+ this.svg.setAttribute('viewBox', `0 0 ${w} ${h}`);
436
+
437
+ return group;
438
+ }
439
+ }