mermaid 13.0.0-alpha.2 → 13.0.0-alpha.4

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 (497) hide show
  1. package/README.md +18 -1
  2. package/THIRD_PARTY_NOTICES +66 -0
  3. package/dist/analyser.d.ts +58 -0
  4. package/dist/analyser.js +160 -0
  5. package/dist/analysis-cache.d.ts +63 -0
  6. package/dist/analysis-cache.js +51 -0
  7. package/dist/api-types.d.ts +137 -0
  8. package/dist/api-types.js +1 -0
  9. package/dist/api.d.ts +23 -130
  10. package/dist/api.js +153 -576
  11. package/dist/ascii.d.ts +5 -4
  12. package/dist/ascii.js +20 -0
  13. package/dist/block-pass.d.ts +143 -0
  14. package/dist/block-pass.js +460 -0
  15. package/dist/chunks/chunk-2B66ILJX.mjs +2 -0
  16. package/dist/chunks/chunk-2B66ILJX.mjs.map +1 -0
  17. package/dist/chunks/chunk-2G45NV5W.mjs +2 -0
  18. package/dist/chunks/chunk-2G45NV5W.mjs.map +1 -0
  19. package/dist/chunks/chunk-2OMLVWQU.mjs +5 -0
  20. package/dist/chunks/chunk-2OMLVWQU.mjs.map +1 -0
  21. package/dist/chunks/chunk-3RMXRSW2.mjs +2 -0
  22. package/dist/chunks/chunk-3RMXRSW2.mjs.map +1 -0
  23. package/dist/chunks/chunk-4YYB3CFC.mjs +6 -0
  24. package/dist/chunks/chunk-4YYB3CFC.mjs.map +1 -0
  25. package/dist/chunks/chunk-4ZSF6MYO.mjs +2 -0
  26. package/dist/chunks/chunk-4ZSF6MYO.mjs.map +1 -0
  27. package/dist/chunks/chunk-53XKVPPJ.mjs +2 -0
  28. package/dist/chunks/chunk-53XKVPPJ.mjs.map +1 -0
  29. package/dist/chunks/chunk-55IU7BZR.mjs +2 -0
  30. package/dist/chunks/chunk-55IU7BZR.mjs.map +1 -0
  31. package/dist/chunks/chunk-5DQMX57J.mjs +2 -0
  32. package/dist/chunks/chunk-5DQMX57J.mjs.map +1 -0
  33. package/dist/chunks/chunk-63SLTT2J.mjs +2 -0
  34. package/dist/chunks/chunk-63SLTT2J.mjs.map +1 -0
  35. package/dist/chunks/chunk-6OB52IUX.mjs +2 -0
  36. package/dist/chunks/chunk-6OB52IUX.mjs.map +1 -0
  37. package/dist/chunks/chunk-6OPFHSIO.mjs +28 -0
  38. package/dist/chunks/chunk-6OPFHSIO.mjs.map +1 -0
  39. package/dist/chunks/chunk-6PP75ECG.mjs +8 -0
  40. package/dist/chunks/chunk-6PP75ECG.mjs.map +1 -0
  41. package/dist/chunks/chunk-6Q57CDGO.mjs +6 -0
  42. package/dist/chunks/chunk-6Q57CDGO.mjs.map +1 -0
  43. package/dist/chunks/chunk-6RKSYWDE.mjs +2 -0
  44. package/dist/chunks/chunk-6RKSYWDE.mjs.map +1 -0
  45. package/dist/chunks/chunk-73GQ7VZJ.mjs +5 -0
  46. package/dist/chunks/chunk-73GQ7VZJ.mjs.map +1 -0
  47. package/dist/chunks/chunk-7WN3MZ72.mjs +2 -0
  48. package/dist/chunks/chunk-7WN3MZ72.mjs.map +1 -0
  49. package/dist/chunks/chunk-A3VFHFGO.mjs +2 -0
  50. package/dist/chunks/chunk-A3VFHFGO.mjs.map +1 -0
  51. package/dist/chunks/chunk-APLS7WHQ.mjs +9 -0
  52. package/dist/chunks/chunk-APLS7WHQ.mjs.map +1 -0
  53. package/dist/chunks/chunk-ATRV5TEE.mjs +2 -0
  54. package/dist/chunks/chunk-ATRV5TEE.mjs.map +1 -0
  55. package/dist/chunks/chunk-AYJFJUGV.mjs +5 -0
  56. package/dist/chunks/chunk-AYJFJUGV.mjs.map +1 -0
  57. package/dist/chunks/chunk-B3Z6CRWV.mjs +3 -0
  58. package/dist/chunks/chunk-B3Z6CRWV.mjs.map +1 -0
  59. package/dist/chunks/chunk-BVSQMGIZ.mjs +2 -0
  60. package/dist/chunks/chunk-BVSQMGIZ.mjs.map +1 -0
  61. package/dist/chunks/chunk-CII5JVDH.mjs +7 -0
  62. package/dist/chunks/chunk-CII5JVDH.mjs.map +1 -0
  63. package/dist/chunks/chunk-CPEZEGT2.mjs +3 -0
  64. package/dist/chunks/chunk-CPEZEGT2.mjs.map +1 -0
  65. package/dist/chunks/chunk-CXYCSADA.mjs +3 -0
  66. package/dist/chunks/chunk-CXYCSADA.mjs.map +1 -0
  67. package/dist/chunks/chunk-CZCYXCKX.mjs +2 -0
  68. package/dist/chunks/chunk-CZCYXCKX.mjs.map +1 -0
  69. package/dist/chunks/chunk-D3MQDA6N.mjs +7 -0
  70. package/dist/chunks/chunk-D3MQDA6N.mjs.map +1 -0
  71. package/dist/chunks/chunk-DGH5467V.mjs +2 -0
  72. package/dist/chunks/chunk-DGH5467V.mjs.map +1 -0
  73. package/dist/chunks/chunk-DHHPFGB6.mjs +2 -0
  74. package/dist/chunks/chunk-DHHPFGB6.mjs.map +1 -0
  75. package/dist/chunks/chunk-ECCMJNBF.mjs +3 -0
  76. package/dist/chunks/chunk-ECCMJNBF.mjs.map +1 -0
  77. package/dist/chunks/chunk-ESGJI3CB.mjs +2 -0
  78. package/dist/chunks/chunk-ESGJI3CB.mjs.map +1 -0
  79. package/dist/chunks/chunk-EUNLDHVF.mjs +11 -0
  80. package/dist/chunks/chunk-EUNLDHVF.mjs.map +1 -0
  81. package/dist/chunks/chunk-EYCHBA43.mjs +2 -0
  82. package/dist/chunks/chunk-EYCHBA43.mjs.map +1 -0
  83. package/dist/chunks/chunk-F25STVVZ.mjs +3 -0
  84. package/dist/chunks/chunk-F25STVVZ.mjs.map +1 -0
  85. package/dist/chunks/chunk-F2VKDTOW.mjs +1 -0
  86. package/dist/chunks/chunk-F2VKDTOW.mjs.map +1 -0
  87. package/dist/chunks/chunk-F6KJEEFC.mjs +2 -0
  88. package/dist/chunks/chunk-F6KJEEFC.mjs.map +1 -0
  89. package/dist/chunks/chunk-FFFVN7SO.mjs +7 -0
  90. package/dist/chunks/chunk-FFFVN7SO.mjs.map +1 -0
  91. package/dist/chunks/chunk-FILBDYXK.mjs +2 -0
  92. package/dist/chunks/chunk-FILBDYXK.mjs.map +1 -0
  93. package/dist/chunks/chunk-FRLNOW6X.mjs +9 -0
  94. package/dist/chunks/chunk-FRLNOW6X.mjs.map +1 -0
  95. package/dist/chunks/chunk-FSEHSCUF.mjs +7 -0
  96. package/dist/chunks/chunk-FSEHSCUF.mjs.map +1 -0
  97. package/dist/chunks/chunk-FUAFR7TD.mjs +4 -0
  98. package/dist/chunks/chunk-FUAFR7TD.mjs.map +1 -0
  99. package/dist/chunks/chunk-HOFRH6AT.mjs +6 -0
  100. package/dist/chunks/chunk-HOFRH6AT.mjs.map +1 -0
  101. package/dist/chunks/chunk-JDA75SEZ.mjs +5 -0
  102. package/dist/chunks/chunk-JDA75SEZ.mjs.map +1 -0
  103. package/dist/chunks/chunk-JUTA6NDE.mjs +2 -0
  104. package/dist/chunks/chunk-JUTA6NDE.mjs.map +1 -0
  105. package/dist/chunks/chunk-KFAVCZ7F.mjs +2 -0
  106. package/dist/chunks/chunk-KFAVCZ7F.mjs.map +1 -0
  107. package/dist/chunks/chunk-KMRZJL6Y.mjs +2 -0
  108. package/dist/chunks/chunk-KMRZJL6Y.mjs.map +1 -0
  109. package/dist/chunks/chunk-LAYJZNXD.mjs +3 -0
  110. package/dist/chunks/chunk-LAYJZNXD.mjs.map +1 -0
  111. package/dist/chunks/chunk-LKH6V7B5.mjs +2 -0
  112. package/dist/chunks/chunk-LKH6V7B5.mjs.map +1 -0
  113. package/dist/chunks/chunk-LRCJEL5L.mjs +2 -0
  114. package/dist/chunks/chunk-LRCJEL5L.mjs.map +1 -0
  115. package/dist/chunks/chunk-MA5HEXJO.mjs +2 -0
  116. package/dist/chunks/chunk-MA5HEXJO.mjs.map +1 -0
  117. package/dist/chunks/chunk-MYKXZDGE.mjs +2 -0
  118. package/dist/chunks/chunk-MYKXZDGE.mjs.map +1 -0
  119. package/dist/chunks/chunk-NCV3UNP6.mjs +2 -0
  120. package/dist/chunks/chunk-NCV3UNP6.mjs.map +1 -0
  121. package/dist/chunks/chunk-NJHONMGN.mjs +2 -0
  122. package/dist/chunks/chunk-NJHONMGN.mjs.map +1 -0
  123. package/dist/chunks/chunk-NK3PVI6J.mjs +11 -0
  124. package/dist/chunks/chunk-NK3PVI6J.mjs.map +1 -0
  125. package/dist/chunks/chunk-NPFNW3L4.mjs +3 -0
  126. package/dist/chunks/chunk-NPFNW3L4.mjs.map +1 -0
  127. package/dist/chunks/chunk-O5X5W6VS.mjs +2 -0
  128. package/dist/chunks/chunk-O5X5W6VS.mjs.map +1 -0
  129. package/dist/chunks/chunk-OBN54HYF.mjs +3 -0
  130. package/dist/chunks/chunk-OBN54HYF.mjs.map +1 -0
  131. package/dist/chunks/chunk-OKL6T5MF.mjs +2 -0
  132. package/dist/chunks/chunk-OKL6T5MF.mjs.map +1 -0
  133. package/dist/chunks/chunk-ORCEJTLL.mjs +2 -0
  134. package/dist/chunks/chunk-ORCEJTLL.mjs.map +1 -0
  135. package/dist/chunks/chunk-P4U3LNF3.mjs +4 -0
  136. package/dist/chunks/chunk-P4U3LNF3.mjs.map +1 -0
  137. package/dist/chunks/chunk-P7LZK7ZS.mjs +2 -0
  138. package/dist/chunks/chunk-P7LZK7ZS.mjs.map +1 -0
  139. package/dist/chunks/chunk-PIRTZYQV.mjs +2 -0
  140. package/dist/chunks/chunk-PIRTZYQV.mjs.map +1 -0
  141. package/dist/chunks/chunk-PZGWFEJJ.mjs +2 -0
  142. package/dist/chunks/chunk-PZGWFEJJ.mjs.map +1 -0
  143. package/dist/chunks/chunk-Q5NJYMF6.mjs +4 -0
  144. package/dist/chunks/chunk-Q5NJYMF6.mjs.map +1 -0
  145. package/dist/chunks/chunk-QBUXMIAV.mjs +3 -0
  146. package/dist/chunks/chunk-QBUXMIAV.mjs.map +1 -0
  147. package/dist/chunks/chunk-RGQXLGJG.mjs +9 -0
  148. package/dist/chunks/chunk-RGQXLGJG.mjs.map +1 -0
  149. package/dist/chunks/chunk-RGURYBR4.mjs +5 -0
  150. package/dist/chunks/chunk-RGURYBR4.mjs.map +1 -0
  151. package/dist/chunks/chunk-SFA7OB4J.mjs +2 -0
  152. package/dist/chunks/chunk-SFA7OB4J.mjs.map +1 -0
  153. package/dist/chunks/chunk-SMSUPHPV.mjs +2 -0
  154. package/dist/chunks/chunk-SMSUPHPV.mjs.map +1 -0
  155. package/dist/chunks/chunk-T6OEMCQU.mjs +2 -0
  156. package/dist/chunks/chunk-T6OEMCQU.mjs.map +1 -0
  157. package/dist/chunks/chunk-THW3ONRS.mjs +2 -0
  158. package/dist/chunks/chunk-THW3ONRS.mjs.map +1 -0
  159. package/dist/chunks/chunk-U4DUVHGY.mjs +5 -0
  160. package/dist/chunks/chunk-U4DUVHGY.mjs.map +1 -0
  161. package/dist/chunks/chunk-VGHE46EI.mjs +2 -0
  162. package/dist/chunks/chunk-VGHE46EI.mjs.map +1 -0
  163. package/dist/chunks/chunk-VMEWKJS2.mjs +2 -0
  164. package/dist/chunks/chunk-VMEWKJS2.mjs.map +1 -0
  165. package/dist/chunks/chunk-VOS34JV6.mjs +2 -0
  166. package/dist/chunks/chunk-VOS34JV6.mjs.map +1 -0
  167. package/dist/chunks/chunk-VPARZRLQ.mjs +2 -0
  168. package/dist/chunks/chunk-VPARZRLQ.mjs.map +1 -0
  169. package/dist/chunks/chunk-VT36NW42.mjs +2 -0
  170. package/dist/chunks/chunk-VT36NW42.mjs.map +1 -0
  171. package/dist/chunks/chunk-VYBXWFSY.mjs +2 -0
  172. package/dist/chunks/chunk-VYBXWFSY.mjs.map +1 -0
  173. package/dist/chunks/chunk-WBEM5SWV.mjs +3 -0
  174. package/dist/chunks/chunk-WBEM5SWV.mjs.map +1 -0
  175. package/dist/chunks/chunk-WO7F4RJM.mjs +3 -0
  176. package/dist/chunks/chunk-WO7F4RJM.mjs.map +1 -0
  177. package/dist/chunks/chunk-WRAHFZFY.mjs +9 -0
  178. package/dist/chunks/chunk-WRAHFZFY.mjs.map +1 -0
  179. package/dist/chunks/chunk-X5P7CX7L.mjs +7 -0
  180. package/dist/chunks/chunk-X5P7CX7L.mjs.map +1 -0
  181. package/dist/chunks/chunk-YE2KRCA3.mjs +4 -0
  182. package/dist/chunks/chunk-YE2KRCA3.mjs.map +1 -0
  183. package/dist/chunks/chunk-YELLBXXX.mjs +3 -0
  184. package/dist/chunks/chunk-YELLBXXX.mjs.map +1 -0
  185. package/dist/chunks/chunk-YKQIHLV5.mjs +2 -0
  186. package/dist/chunks/chunk-YKQIHLV5.mjs.map +1 -0
  187. package/dist/chunks/chunk-YTHSONFA.mjs +2 -0
  188. package/dist/chunks/chunk-YTHSONFA.mjs.map +1 -0
  189. package/dist/chunks/chunk-YUTCY5ZO.mjs +2 -0
  190. package/dist/chunks/chunk-YUTCY5ZO.mjs.map +1 -0
  191. package/dist/chunks/chunk-YWTNPF6F.mjs +3 -0
  192. package/dist/chunks/chunk-YWTNPF6F.mjs.map +1 -0
  193. package/dist/chunks/chunk-ZIBG2WAF.mjs +2 -0
  194. package/dist/chunks/chunk-ZIBG2WAF.mjs.map +1 -0
  195. package/dist/chunks/chunk-ZOT5QLCB.mjs +3 -0
  196. package/dist/chunks/chunk-ZOT5QLCB.mjs.map +1 -0
  197. package/dist/chunks/core-layout-compass-index.mjs +2 -0
  198. package/dist/chunks/core-layout-compass-index.mjs.map +1 -0
  199. package/dist/chunks/core-layout-swimlane-index.mjs +2 -0
  200. package/dist/chunks/core-layout-swimlane-index.mjs.map +1 -0
  201. package/dist/chunks/core-layout-tree-index.mjs +1 -1
  202. package/dist/chunks/core-layout-tree-index.mjs.map +1 -1
  203. package/dist/chunks/core-text-font-tables.mjs +2 -0
  204. package/dist/chunks/core-text-font-tables.mjs.map +1 -0
  205. package/dist/chunks/core-theme-specs-base.mjs +1 -1
  206. package/dist/chunks/core-theme-specs-base.mjs.map +1 -1
  207. package/dist/chunks/core-theme-specs-dark.mjs +1 -1
  208. package/dist/chunks/core-theme-specs-dark.mjs.map +1 -1
  209. package/dist/chunks/core-theme-specs-default.mjs +1 -1
  210. package/dist/chunks/core-theme-specs-default.mjs.map +1 -1
  211. package/dist/chunks/core-theme-specs-forest.mjs +1 -1
  212. package/dist/chunks/core-theme-specs-forest.mjs.map +1 -1
  213. package/dist/chunks/core-theme-specs-neo-dark.mjs +1 -1
  214. package/dist/chunks/core-theme-specs-neo-dark.mjs.map +1 -1
  215. package/dist/chunks/core-theme-specs-neo.mjs +1 -1
  216. package/dist/chunks/core-theme-specs-neo.mjs.map +1 -1
  217. package/dist/chunks/core-theme-specs-neutral.mjs +1 -1
  218. package/dist/chunks/core-theme-specs-neutral.mjs.map +1 -1
  219. package/dist/chunks/core-theme-specs-redux-dark-color.mjs +1 -1
  220. package/dist/chunks/core-theme-specs-redux-dark-color.mjs.map +1 -1
  221. package/dist/chunks/core-theme-specs-redux-dark.mjs +1 -1
  222. package/dist/chunks/core-theme-specs-redux-dark.mjs.map +1 -1
  223. package/dist/chunks/diagram-agentflow-ascii.mjs +2 -0
  224. package/dist/chunks/diagram-agentflow-ascii.mjs.map +1 -0
  225. package/dist/chunks/diagram-agentflow-language.mjs +21 -0
  226. package/dist/chunks/diagram-agentflow-language.mjs.map +1 -0
  227. package/dist/chunks/diagram-agentflow.mjs +2 -0
  228. package/dist/chunks/diagram-agentflow.mjs.map +1 -0
  229. package/dist/chunks/diagram-architecture-language.mjs +21 -0
  230. package/dist/chunks/diagram-architecture-language.mjs.map +1 -0
  231. package/dist/chunks/diagram-architecture.mjs +2 -0
  232. package/dist/chunks/diagram-architecture.mjs.map +1 -0
  233. package/dist/chunks/diagram-block-ascii.mjs +2 -0
  234. package/dist/chunks/diagram-block-ascii.mjs.map +1 -0
  235. package/dist/chunks/diagram-block-language.mjs +14 -0
  236. package/dist/chunks/diagram-block-language.mjs.map +1 -0
  237. package/dist/chunks/diagram-block.mjs +2 -0
  238. package/dist/chunks/diagram-block.mjs.map +1 -0
  239. package/dist/chunks/diagram-c4-ascii.mjs +2 -0
  240. package/dist/chunks/diagram-c4-ascii.mjs.map +1 -0
  241. package/dist/chunks/diagram-c4-language.mjs +30 -0
  242. package/dist/chunks/diagram-c4-language.mjs.map +1 -0
  243. package/dist/chunks/diagram-c4.mjs +2 -0
  244. package/dist/chunks/diagram-c4.mjs.map +1 -0
  245. package/dist/chunks/diagram-class-language.mjs +12 -18
  246. package/dist/chunks/diagram-class-language.mjs.map +1 -1
  247. package/dist/chunks/diagram-class.mjs +1 -1
  248. package/dist/chunks/diagram-class.mjs.map +1 -1
  249. package/dist/chunks/diagram-cynefin-language.mjs +2 -4
  250. package/dist/chunks/diagram-cynefin-language.mjs.map +1 -1
  251. package/dist/chunks/diagram-cynefin.mjs +1 -1
  252. package/dist/chunks/diagram-cynefin.mjs.map +1 -1
  253. package/dist/chunks/diagram-er-ascii.mjs +1 -4
  254. package/dist/chunks/diagram-er-ascii.mjs.map +1 -1
  255. package/dist/chunks/diagram-er-language.mjs +10 -17
  256. package/dist/chunks/diagram-er-language.mjs.map +1 -1
  257. package/dist/chunks/diagram-er.mjs +1 -1
  258. package/dist/chunks/diagram-er.mjs.map +1 -1
  259. package/dist/chunks/diagram-eventmodeling-language.mjs +19 -0
  260. package/dist/chunks/diagram-eventmodeling-language.mjs.map +1 -0
  261. package/dist/chunks/diagram-eventmodeling.mjs +3 -0
  262. package/dist/chunks/diagram-eventmodeling.mjs.map +1 -0
  263. package/dist/chunks/diagram-flowchart-ascii.mjs +1 -4
  264. package/dist/chunks/diagram-flowchart-ascii.mjs.map +1 -1
  265. package/dist/chunks/diagram-flowchart-lanes.mjs +2 -0
  266. package/dist/chunks/diagram-flowchart-lanes.mjs.map +1 -0
  267. package/dist/chunks/diagram-flowchart-language.mjs +9 -20
  268. package/dist/chunks/diagram-flowchart-language.mjs.map +1 -1
  269. package/dist/chunks/diagram-flowchart.mjs +1 -1
  270. package/dist/chunks/diagram-flowchart.mjs.map +1 -1
  271. package/dist/chunks/diagram-gantt-language.mjs +6 -7
  272. package/dist/chunks/diagram-gantt-language.mjs.map +1 -1
  273. package/dist/chunks/diagram-gantt.mjs +1 -1
  274. package/dist/chunks/diagram-gantt.mjs.map +1 -1
  275. package/dist/chunks/diagram-gitgraph-language.mjs +9 -11
  276. package/dist/chunks/diagram-gitgraph-language.mjs.map +1 -1
  277. package/dist/chunks/diagram-gitgraph.mjs +2 -2
  278. package/dist/chunks/diagram-gitgraph.mjs.map +1 -1
  279. package/dist/chunks/diagram-info-ascii.mjs +1 -1
  280. package/dist/chunks/diagram-info-ascii.mjs.map +1 -1
  281. package/dist/chunks/diagram-info-language.mjs +1 -3
  282. package/dist/chunks/diagram-info-language.mjs.map +1 -1
  283. package/dist/chunks/diagram-info.mjs +1 -1
  284. package/dist/chunks/diagram-info.mjs.map +1 -1
  285. package/dist/chunks/diagram-ishikawa-ascii.mjs +4 -0
  286. package/dist/chunks/diagram-ishikawa-ascii.mjs.map +1 -0
  287. package/dist/chunks/diagram-ishikawa-language.mjs +13 -0
  288. package/dist/chunks/diagram-ishikawa-language.mjs.map +1 -0
  289. package/dist/chunks/diagram-ishikawa.mjs +2 -0
  290. package/dist/chunks/diagram-ishikawa.mjs.map +1 -0
  291. package/dist/chunks/diagram-journey-language.mjs +11 -12
  292. package/dist/chunks/diagram-journey-language.mjs.map +1 -1
  293. package/dist/chunks/diagram-journey.mjs +1 -1
  294. package/dist/chunks/diagram-journey.mjs.map +1 -1
  295. package/dist/chunks/diagram-kanban-ascii.mjs +1 -3
  296. package/dist/chunks/diagram-kanban-ascii.mjs.map +1 -1
  297. package/dist/chunks/diagram-kanban-language.mjs +10 -10
  298. package/dist/chunks/diagram-kanban-language.mjs.map +1 -1
  299. package/dist/chunks/diagram-kanban.mjs +1 -1
  300. package/dist/chunks/diagram-kanban.mjs.map +1 -1
  301. package/dist/chunks/diagram-mindmap-language.mjs +9 -9
  302. package/dist/chunks/diagram-mindmap-language.mjs.map +1 -1
  303. package/dist/chunks/diagram-mindmap.mjs +1 -1
  304. package/dist/chunks/diagram-mindmap.mjs.map +1 -1
  305. package/dist/chunks/diagram-packet-ascii.mjs +4 -4
  306. package/dist/chunks/diagram-packet-ascii.mjs.map +1 -1
  307. package/dist/chunks/diagram-packet-language.mjs +4 -6
  308. package/dist/chunks/diagram-packet-language.mjs.map +1 -1
  309. package/dist/chunks/diagram-packet.mjs +1 -1
  310. package/dist/chunks/diagram-packet.mjs.map +1 -1
  311. package/dist/chunks/diagram-pie-language.mjs +5 -7
  312. package/dist/chunks/diagram-pie-language.mjs.map +1 -1
  313. package/dist/chunks/diagram-pie.mjs +1 -1
  314. package/dist/chunks/diagram-pie.mjs.map +1 -1
  315. package/dist/chunks/diagram-quadrant-language.mjs +9 -9
  316. package/dist/chunks/diagram-quadrant-language.mjs.map +1 -1
  317. package/dist/chunks/diagram-quadrant.mjs +1 -1
  318. package/dist/chunks/diagram-quadrant.mjs.map +1 -1
  319. package/dist/chunks/diagram-radar-language.mjs +7 -10
  320. package/dist/chunks/diagram-radar-language.mjs.map +1 -1
  321. package/dist/chunks/diagram-radar.mjs +1 -1
  322. package/dist/chunks/diagram-radar.mjs.map +1 -1
  323. package/dist/chunks/diagram-railroad-ascii.mjs +2 -0
  324. package/dist/chunks/diagram-railroad-ascii.mjs.map +1 -0
  325. package/dist/chunks/diagram-railroad-language.mjs +14 -0
  326. package/dist/chunks/diagram-railroad-language.mjs.map +1 -0
  327. package/dist/chunks/diagram-railroad.mjs +2 -0
  328. package/dist/chunks/diagram-railroad.mjs.map +1 -0
  329. package/dist/chunks/diagram-requirement-ascii.mjs +2 -0
  330. package/dist/chunks/diagram-requirement-ascii.mjs.map +1 -0
  331. package/dist/chunks/diagram-requirement-language.mjs +21 -0
  332. package/dist/chunks/diagram-requirement-language.mjs.map +1 -0
  333. package/dist/chunks/diagram-requirement.mjs +2 -0
  334. package/dist/chunks/diagram-requirement.mjs.map +1 -0
  335. package/dist/chunks/diagram-sankey-language.mjs +6 -8
  336. package/dist/chunks/diagram-sankey-language.mjs.map +1 -1
  337. package/dist/chunks/diagram-sankey.mjs +1 -1
  338. package/dist/chunks/diagram-sankey.mjs.map +1 -1
  339. package/dist/chunks/diagram-sequence-ascii.mjs +3 -3
  340. package/dist/chunks/diagram-sequence-ascii.mjs.map +1 -1
  341. package/dist/chunks/diagram-sequence-language.mjs +7 -10
  342. package/dist/chunks/diagram-sequence-language.mjs.map +1 -1
  343. package/dist/chunks/diagram-sequence.mjs +1 -1
  344. package/dist/chunks/diagram-sequence.mjs.map +1 -1
  345. package/dist/chunks/diagram-state-language.mjs +9 -16
  346. package/dist/chunks/diagram-state-language.mjs.map +1 -1
  347. package/dist/chunks/diagram-state.mjs +3 -3
  348. package/dist/chunks/diagram-state.mjs.map +1 -1
  349. package/dist/chunks/diagram-timeline-language.mjs +2 -2
  350. package/dist/chunks/diagram-timeline-language.mjs.map +1 -1
  351. package/dist/chunks/diagram-timeline.mjs +1 -1
  352. package/dist/chunks/diagram-timeline.mjs.map +1 -1
  353. package/dist/chunks/diagram-treemap-language.mjs +10 -13
  354. package/dist/chunks/diagram-treemap-language.mjs.map +1 -1
  355. package/dist/chunks/diagram-treemap.mjs +1 -1
  356. package/dist/chunks/diagram-treemap.mjs.map +1 -1
  357. package/dist/chunks/diagram-treeview-ascii.mjs +4 -0
  358. package/dist/chunks/diagram-treeview-ascii.mjs.map +1 -0
  359. package/dist/chunks/diagram-treeview-language.mjs +8 -0
  360. package/dist/chunks/diagram-treeview-language.mjs.map +1 -0
  361. package/dist/chunks/diagram-treeview.mjs +2 -0
  362. package/dist/chunks/diagram-treeview.mjs.map +1 -0
  363. package/dist/chunks/diagram-usecase-ascii.mjs +2 -0
  364. package/dist/chunks/diagram-usecase-ascii.mjs.map +1 -0
  365. package/dist/chunks/diagram-usecase-language.mjs +14 -0
  366. package/dist/chunks/diagram-usecase-language.mjs.map +1 -0
  367. package/dist/chunks/diagram-usecase.mjs +3 -0
  368. package/dist/chunks/diagram-usecase.mjs.map +1 -0
  369. package/dist/chunks/diagram-venn-language.mjs +5 -5
  370. package/dist/chunks/diagram-venn-language.mjs.map +1 -1
  371. package/dist/chunks/diagram-venn.mjs +1 -1
  372. package/dist/chunks/diagram-venn.mjs.map +1 -1
  373. package/dist/chunks/diagram-wardley-language.mjs +5 -8
  374. package/dist/chunks/diagram-wardley-language.mjs.map +1 -1
  375. package/dist/chunks/diagram-wardley.mjs +1 -1
  376. package/dist/chunks/diagram-wardley.mjs.map +1 -1
  377. package/dist/chunks/diagram-xychart-language.mjs +6 -9
  378. package/dist/chunks/diagram-xychart-language.mjs.map +1 -1
  379. package/dist/chunks/diagram-xychart.mjs +1 -1
  380. package/dist/chunks/diagram-xychart.mjs.map +1 -1
  381. package/dist/chunks/mermaid-ascii.mjs +1 -1
  382. package/dist/chunks/mermaid-ascii.mjs.map +1 -1
  383. package/dist/chunks/mermaid-block-pass.mjs +5 -0
  384. package/dist/chunks/mermaid-block-pass.mjs.map +1 -0
  385. package/dist/cli-plugins.d.ts +20 -0
  386. package/dist/cli-plugins.js +165 -0
  387. package/dist/cli.js +36 -3
  388. package/dist/config-snapshot.d.ts +43 -8
  389. package/dist/config-snapshot.js +78 -20
  390. package/dist/dom.d.ts +4 -1
  391. package/dist/dom.js +20 -0
  392. package/dist/draw-context.d.ts +42 -0
  393. package/dist/draw-context.js +288 -0
  394. package/dist/draw.d.ts +28 -0
  395. package/dist/draw.js +134 -0
  396. package/dist/embeds.d.ts +48 -0
  397. package/dist/embeds.js +57 -0
  398. package/dist/errors.d.ts +7 -1
  399. package/dist/errors.js +13 -0
  400. package/dist/exports.d.ts +3 -1
  401. package/dist/exports.js +0 -1
  402. package/dist/generated/autoload-load.gen.d.ts +51 -0
  403. package/dist/generated/autoload-load.gen.js +127 -0
  404. package/dist/generated/autoload-scan.gen.d.ts +80 -0
  405. package/dist/generated/autoload-scan.gen.js +292 -0
  406. package/dist/generated/detectors.gen.d.ts +2 -0
  407. package/dist/generated/detectors.gen.js +16 -15
  408. package/dist/generated/registry.gen.js +122 -14
  409. package/dist/index.d.ts +30 -22
  410. package/dist/index.js +1 -1
  411. package/dist/measurer.d.ts +2 -0
  412. package/dist/measurer.js +3 -2
  413. package/dist/mermaid.esm.min.mjs +3 -3
  414. package/dist/mermaid.esm.min.mjs.map +1 -1
  415. package/dist/mermaid.min.js +1 -1
  416. package/dist/mermaid.min.js.map +1 -1
  417. package/dist/node-scan.d.ts +1 -58
  418. package/dist/node-scan.js +6 -206
  419. package/dist/node.d.ts +17 -2
  420. package/dist/node.js +24 -116
  421. package/dist/prepare.d.ts +17 -0
  422. package/dist/prepare.js +145 -0
  423. package/dist/registry.d.ts +36 -6
  424. package/dist/registry.js +101 -19
  425. package/dist/session.d.ts +58 -0
  426. package/dist/session.js +40 -0
  427. package/dist/slim.d.ts +19 -10
  428. package/dist/slim.js +57 -16
  429. package/dist/version.d.ts +1 -1
  430. package/dist/version.js +1 -1
  431. package/package.json +35 -24
  432. package/dist/chunks/chunk-2SBABYQO.mjs +0 -6
  433. package/dist/chunks/chunk-2SBABYQO.mjs.map +0 -1
  434. package/dist/chunks/chunk-3QHCWLG2.mjs +0 -12
  435. package/dist/chunks/chunk-3QHCWLG2.mjs.map +0 -1
  436. package/dist/chunks/chunk-3SMLKEUJ.mjs +0 -6
  437. package/dist/chunks/chunk-3SMLKEUJ.mjs.map +0 -1
  438. package/dist/chunks/chunk-B24N3EFY.mjs +0 -2
  439. package/dist/chunks/chunk-B24N3EFY.mjs.map +0 -1
  440. package/dist/chunks/chunk-BBQQRPRV.mjs +0 -3
  441. package/dist/chunks/chunk-BBQQRPRV.mjs.map +0 -1
  442. package/dist/chunks/chunk-BFIZPEAM.mjs +0 -6
  443. package/dist/chunks/chunk-BFIZPEAM.mjs.map +0 -1
  444. package/dist/chunks/chunk-DTOBFHMA.mjs +0 -10
  445. package/dist/chunks/chunk-DTOBFHMA.mjs.map +0 -1
  446. package/dist/chunks/chunk-DUKAL7EW.mjs +0 -7
  447. package/dist/chunks/chunk-DUKAL7EW.mjs.map +0 -1
  448. package/dist/chunks/chunk-FSN3B5SH.mjs +0 -4
  449. package/dist/chunks/chunk-FSN3B5SH.mjs.map +0 -1
  450. package/dist/chunks/chunk-FYF7T3FM.mjs +0 -7
  451. package/dist/chunks/chunk-FYF7T3FM.mjs.map +0 -1
  452. package/dist/chunks/chunk-G5JCFFZO.mjs +0 -10
  453. package/dist/chunks/chunk-G5JCFFZO.mjs.map +0 -1
  454. package/dist/chunks/chunk-HVRHH7BT.mjs +0 -6
  455. package/dist/chunks/chunk-HVRHH7BT.mjs.map +0 -1
  456. package/dist/chunks/chunk-ICB73T2E.mjs +0 -25
  457. package/dist/chunks/chunk-ICB73T2E.mjs.map +0 -1
  458. package/dist/chunks/chunk-IOHHGREU.mjs +0 -3
  459. package/dist/chunks/chunk-IOHHGREU.mjs.map +0 -1
  460. package/dist/chunks/chunk-IY435URU.mjs +0 -2
  461. package/dist/chunks/chunk-IY435URU.mjs.map +0 -1
  462. package/dist/chunks/chunk-J2CYG3BU.mjs +0 -2
  463. package/dist/chunks/chunk-J2CYG3BU.mjs.map +0 -1
  464. package/dist/chunks/chunk-JL46TWOM.mjs +0 -13
  465. package/dist/chunks/chunk-JL46TWOM.mjs.map +0 -1
  466. package/dist/chunks/chunk-JN7HU5Z4.mjs +0 -6
  467. package/dist/chunks/chunk-JN7HU5Z4.mjs.map +0 -1
  468. package/dist/chunks/chunk-KHWLAZE2.mjs +0 -6
  469. package/dist/chunks/chunk-KHWLAZE2.mjs.map +0 -1
  470. package/dist/chunks/chunk-MTHJHLUH.mjs +0 -2
  471. package/dist/chunks/chunk-MTHJHLUH.mjs.map +0 -1
  472. package/dist/chunks/chunk-NGL2KHQW.mjs +0 -2
  473. package/dist/chunks/chunk-NGL2KHQW.mjs.map +0 -1
  474. package/dist/chunks/chunk-NM2RNLMZ.mjs +0 -5
  475. package/dist/chunks/chunk-NM2RNLMZ.mjs.map +0 -1
  476. package/dist/chunks/chunk-RUW4Q76Y.mjs +0 -7
  477. package/dist/chunks/chunk-RUW4Q76Y.mjs.map +0 -1
  478. package/dist/chunks/chunk-SNYNP3PS.mjs +0 -5
  479. package/dist/chunks/chunk-SNYNP3PS.mjs.map +0 -1
  480. package/dist/chunks/chunk-TJOE3FON.mjs +0 -8
  481. package/dist/chunks/chunk-TJOE3FON.mjs.map +0 -1
  482. package/dist/chunks/chunk-VRD5GZ6G.mjs +0 -9
  483. package/dist/chunks/chunk-VRD5GZ6G.mjs.map +0 -1
  484. package/dist/chunks/chunk-WBKKKHXZ.mjs +0 -8
  485. package/dist/chunks/chunk-WBKKKHXZ.mjs.map +0 -1
  486. package/dist/chunks/chunk-WINJRA54.mjs +0 -7
  487. package/dist/chunks/chunk-WINJRA54.mjs.map +0 -1
  488. package/dist/chunks/chunk-WJD3LR33.mjs +0 -5
  489. package/dist/chunks/chunk-WJD3LR33.mjs.map +0 -1
  490. package/dist/chunks/chunk-X3UAU7VF.mjs +0 -8
  491. package/dist/chunks/chunk-X3UAU7VF.mjs.map +0 -1
  492. package/dist/chunks/chunk-X3VGHK3G.mjs +0 -6
  493. package/dist/chunks/chunk-X3VGHK3G.mjs.map +0 -1
  494. package/dist/chunks/chunk-ZOQOZJZV.mjs +0 -2
  495. package/dist/chunks/chunk-ZOQOZJZV.mjs.map +0 -1
  496. package/dist/chunks/chunk-ZVYEDT2M.mjs +0 -3
  497. package/dist/chunks/chunk-ZVYEDT2M.mjs.map +0 -1
package/README.md CHANGED
@@ -20,7 +20,7 @@ const { text } = await mermaid.render('id', 'flowchart LR\n A --> B', { format:
20
20
 
21
21
  Every first-party diagram type is included. Bundlers split each type into its own chunk, so a page downloads only the types it renders.
22
22
 
23
- The size budget is in [`size-budget.json`](./size-budget.json): core, everything the `mermaid` entry loads before any diagram chunk, is at most 96 KB gzip, and core plus flowchart, as loaded for one flowchart render, at most 128 KB gzip.
23
+ The size budget is in [`size-budget.json`](./size-budget.json): core, everything the `mermaid` entry loads before any diagram chunk, is at most 98 KB gzip, and core plus flowchart, as loaded for one flowchart render, at most 145 KB gzip.
24
24
 
25
25
  ## Pick your diagrams
26
26
 
@@ -40,6 +40,23 @@ const mermaid = createMermaid({ diagrams: [{ ...flowchart, ascii }] });
40
40
  const { svg } = await mermaid.render('id', 'flowchart LR\n A --> B');
41
41
  ```
42
42
 
43
+ To load each diagram on first use, pass loaders keyed by diagram id instead. A loader runs when a diagram of that type is first rendered, never at `createMermaid`, and a bundler puts each in a chunk of its own. Objects and loaders mix, and a key that is not a first-party id is an error:
44
+
45
+ ```js
46
+ import { createMermaid } from 'mermaid/slim';
47
+ import { pie } from '@mermaid-js/diagram-pie';
48
+
49
+ const mermaid = createMermaid({
50
+ diagrams: {
51
+ flowchart: () => import('@mermaid-js/diagram-flowchart'),
52
+ sequence: () => import('@mermaid-js/diagram-sequence'),
53
+ pie,
54
+ },
55
+ });
56
+ ```
57
+
58
+ A loader that fails, or that resolves to a module without that diagram's plugin, rejects the render with an error naming the id (a failed load is tried again on the next render). For text output, resolve to the module with its hook added: `() => import('@mermaid-js/diagram-flowchart').then(async (m) => ({ ...m, ascii: (await import('@mermaid-js/diagram-flowchart/ascii')).ascii }))`. Before the first load, `supportsFormat` answers from the diagram's manifest.
59
+
43
60
  Other diagram types are still detected, and reject with an `UNSUPPORTED_DIAGRAM` error. `mermaid/slim` has no default instance and does not render `.mermaid` elements on page load: call `mermaid.run()` yourself.
44
61
 
45
62
  ## Command line
@@ -32,6 +32,72 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
32
32
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33
33
  SOFTWARE.
34
34
 
35
+ Pele, in @mermaid-js/diagram-agentflow
36
+ --------------------------------------
37
+
38
+ The CDN build also bundles @mermaid-js/diagram-agentflow without its legal comments. That
39
+ package's parser/lexer.ts, parser/parser.ts and parser/model.ts are its dialect of the flow
40
+ family's lexer, parser and model builder, which it shares with @mermaid-js/diagram-flowchart
41
+ through @mermaid-js/shared (D467, D595); its layout/prepare.ts is written from flowchart's
42
+ layout builder; and its layout/shapes.ts and render/shapes.ts outline and draw the shared
43
+ shapes of @mermaid-js/shared (D446, D559) with agentflow's own variants. All are ported from,
44
+ or based on, Pele (https://github.com/obsidianmd/pele) at commit 3a2f075 (release 1.13.0). Pele
45
+ is used under the MIT License:
46
+
47
+ MIT License
48
+
49
+ Copyright (c) 2026 kepano
50
+
51
+ Permission is hereby granted, free of charge, to any person obtaining a copy
52
+ of this software and associated documentation files (the "Software"), to deal
53
+ in the Software without restriction, including without limitation the rights
54
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
55
+ copies of the Software, and to permit persons to whom the Software is
56
+ furnished to do so, subject to the following conditions:
57
+
58
+ The above copyright notice and this permission notice shall be included in all
59
+ copies or substantial portions of the Software.
60
+
61
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
62
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
63
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
64
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
65
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
66
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
67
+ SOFTWARE.
68
+
69
+ Pele, in @mermaid-js/diagram-c4
70
+ -------------------------------
71
+
72
+ The CDN build also bundles @mermaid-js/diagram-c4 without its legal comments. That package's
73
+ layout/grid.ts, layout/layout.ts, layout/metrics.ts, layout/path.ts, layout/route.ts and
74
+ layout/shapes.ts are ported from Pele's C4 grid, relation router and label placement, and its
75
+ render/shapes.ts draws C4's shapes with the shared shapes' paths from @mermaid-js/shared (D446,
76
+ D559), all ported from, or based on, Pele (https://github.com/obsidianmd/pele) at commit
77
+ 3a2f075 (release 1.13.0). Pele is used under the MIT License:
78
+
79
+ MIT License
80
+
81
+ Copyright (c) 2026 kepano
82
+
83
+ Permission is hereby granted, free of charge, to any person obtaining a copy
84
+ of this software and associated documentation files (the "Software"), to deal
85
+ in the Software without restriction, including without limitation the rights
86
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
87
+ copies of the Software, and to permit persons to whom the Software is
88
+ furnished to do so, subject to the following conditions:
89
+
90
+ The above copyright notice and this permission notice shall be included in all
91
+ copies or substantial portions of the Software.
92
+
93
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
94
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
95
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
96
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
97
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
98
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
99
+ SOFTWARE.
100
+
35
101
  d3-sankey
36
102
  ---------
37
103
 
@@ -0,0 +1,58 @@
1
+ import { type ResolvedConfig } from '@mermaid-js/core/config';
2
+ import { type PreprocessResult } from '@mermaid-js/core/preprocess';
3
+ import { AnalysisCache, type Analysis, type Detection, type Parsed } from './analysis-cache.ts';
4
+ import { type SiteConfigs, type Snapshot } from './config-snapshot.ts';
5
+ import type { BlockHost } from './embeds.ts';
6
+ import type { AnyPlugin, Detected, Registry } from './registry.ts';
7
+ /** What `detect` found, for a type with a plugin package. */
8
+ export interface Found {
9
+ readonly detected: Detected & {
10
+ readonly id: string;
11
+ };
12
+ readonly pre: PreprocessResult;
13
+ }
14
+ /** A type may read its own section on top of its plugin's (`swimlane` over `flowchart`, D534). */
15
+ export declare function sectionOf(detected: Detected, plugin?: AnyPlugin): string | string[] | undefined;
16
+ export declare class Analyser {
17
+ private readonly registry;
18
+ private readonly siteConfigs;
19
+ private readonly claims;
20
+ private readonly readsAst;
21
+ /** The analyses of recent texts, each valid only for the snapshot it was made with. */
22
+ readonly cache: AnalysisCache<Analysis>;
23
+ /** The configs of recent diagram-text configs, by value, over each site config. */
24
+ private texts;
25
+ /**
26
+ * `claims`: what the registered extensions claim of a parse, read at each parse because the
27
+ * hooks are rebuilt after a registration. `readsAst`: whether a `postParse` hook of a render
28
+ * of `plugin` with `config` reads the AST, so its parse is full (DESIGN §4.2).
29
+ */
30
+ constructor(registry: Registry, siteConfigs: SiteConfigs, claims: () => readonly string[], readsAst: (plugin: AnyPlugin, config: ResolvedConfig) => boolean);
31
+ /** Drops every parsed text: a registration changes how texts detect, resolve and parse. */
32
+ invalidate(): void;
33
+ /** The author's config layers and the config they resolve to, over the site's and a host's. */
34
+ private layers;
35
+ /**
36
+ * Detect, resolve config and parse with a loaded plugin (DESIGN §3 steps 1–4). The parse is
37
+ * lean (DESIGN §4.2) unless the call asks for it `full` or a `postParse` hook of the render
38
+ * reads the AST; a lean parse with an error is parsed again in full for its diagnostics.
39
+ */
40
+ analyse(text: string, snap: Snapshot, plugin: AnyPlugin, { detected, pre }: Detection, host?: BlockHost, full?: boolean): Parsed;
41
+ detect(text: string, s: Snapshot): Detection;
42
+ /**
43
+ * Whether `a`'s type has text output (R-ASCII-5, D80). Asked by type: a type can draw fewer
44
+ * formats than its plugin (`typeOptions` `formats`).
45
+ */
46
+ textOf(a: {
47
+ detected: Detected;
48
+ }): boolean;
49
+ /** Throws `UnsupportedFormatError` unless `detected` declares ascii (R-ASCII-5, D80). */
50
+ checkText(detected: Detected): void;
51
+ /** `detect`, for a type with a plugin package that can draw `ascii` when that is asked for. */
52
+ detectSupported(text: string, s: Snapshot, ascii: boolean): Found;
53
+ /**
54
+ * Parses with the loaded `plugin` and caches the analysis (DESIGN §3 steps 2–4): only its
55
+ * lean parse; a full parse goes to the call that asked for it.
56
+ */
57
+ analysisOf(text: string, s: Snapshot, found: Found, plugin: AnyPlugin | undefined, full?: boolean): Parsed;
58
+ }
@@ -0,0 +1,160 @@
1
+ /**
2
+ * The analyser of one API object (DESIGN §3 steps 1–4): detect, site config, parse, and the
3
+ * cache of what they made. Every registration drops the cache through `invalidate()`, the one
4
+ * place it is cleared from.
5
+ */
6
+ import { errorFromDiagnostics, UnsupportedFormatError, } from '@mermaid-js/core';
7
+ import { resolveText } from '@mermaid-js/core/config';
8
+ import { checkSource } from '@mermaid-js/core/limits';
9
+ import { preprocess } from '@mermaid-js/core/preprocess';
10
+ import { stageEnd, stageStart } from '@mermaid-js/core/timing';
11
+ import { AnalysisCache, dataAstOf, fullParse, parseStep, } from "./analysis-cache.js";
12
+ import { directiveConfig, textConfig, } from "./config-snapshot.js";
13
+ import { toWarning, unsupportedDiagram } from "./errors.js";
14
+ import { outsideBlocks } from "./embeds.js";
15
+ /** A type may read its own section on top of its plugin's (`swimlane` over `flowchart`, D534). */
16
+ export function sectionOf(detected, plugin) {
17
+ const own = plugin?.configSection ?? plugin?.id ?? detected.id;
18
+ return detected.section && detected.section !== own ? [detected.section, own] : own;
19
+ }
20
+ /** Whether `diagnostics` hold an error: only then does `errorFromDiagnostics` make one. */
21
+ function hasError(diagnostics) {
22
+ for (const d of diagnostics)
23
+ if (d.severity === 'error')
24
+ return true;
25
+ return false;
26
+ }
27
+ /** Hands the warnings among `diagnostics` to `warn`. */
28
+ function warnOf(diagnostics, warn) {
29
+ for (const d of diagnostics)
30
+ if (d.severity === 'warning')
31
+ warn(d);
32
+ }
33
+ export class Analyser {
34
+ registry;
35
+ siteConfigs;
36
+ claims;
37
+ readsAst;
38
+ /** The analyses of recent texts, each valid only for the snapshot it was made with. */
39
+ cache = new AnalysisCache();
40
+ /** The configs of recent diagram-text configs, by value, over each site config. */
41
+ texts = new WeakMap();
42
+ /**
43
+ * `claims`: what the registered extensions claim of a parse, read at each parse because the
44
+ * hooks are rebuilt after a registration. `readsAst`: whether a `postParse` hook of a render
45
+ * of `plugin` with `config` reads the AST, so its parse is full (DESIGN §4.2).
46
+ */
47
+ constructor(registry, siteConfigs, claims, readsAst) {
48
+ this.registry = registry;
49
+ this.siteConfigs = siteConfigs;
50
+ this.claims = claims;
51
+ this.readsAst = readsAst;
52
+ }
53
+ /** Drops every parsed text: a registration changes how texts detect, resolve and parse. */
54
+ invalidate() {
55
+ this.cache.clear();
56
+ this.texts = new WeakMap();
57
+ }
58
+ /** The author's config layers and the config they resolve to, over the site's and a host's. */
59
+ layers(pre, snap, plugin, detected, warn, host) {
60
+ const section = sectionOf(detected, plugin);
61
+ let front = pre.frontMatter?.config;
62
+ let directives = directiveConfig(pre, section);
63
+ const hit = this.siteConfigs.get(snap, plugin, detected, section, this.registry.fragments());
64
+ for (const w of hit.warnings)
65
+ warn(w);
66
+ // An embedded diagram (ADR-15) sets only its own options, with one warning for the rest.
67
+ if (host)
68
+ ({ front, directives } = host.layers(front, directives, hit.site, warn));
69
+ // An embedded diagram starts from its host's config, and takes its theme.
70
+ let config = host
71
+ ? resolveText(hit.site, front, directives, { warn, under: host.config })
72
+ : textConfig(this.texts, hit, front, directives, warn);
73
+ if (host)
74
+ config = host.resolve(config, [section ?? []].flat());
75
+ return { config, sources: [hit.site.site, front, ...directives] };
76
+ }
77
+ /**
78
+ * Detect, resolve config and parse with a loaded plugin (DESIGN §3 steps 1–4). The parse is
79
+ * lean (DESIGN §4.2) unless the call asks for it `full` or a `postParse` hook of the render
80
+ * reads the AST; a lean parse with an error is parsed again in full for its diagnostics.
81
+ */
82
+ analyse(text, snap, plugin, { detected, pre }, host, full = false) {
83
+ const warnings = [];
84
+ const warn = (w) => void warnings.push(toWarning(w, this.registry.fragments()));
85
+ warnOf(pre.diagnostics, warn);
86
+ const { config, sources } = this.layers(pre, snap, plugin, detected, warn, host);
87
+ const t = stageStart();
88
+ const claims = this.claims();
89
+ const ctx = claims.length > 0
90
+ ? { config, preprocessed: pre, limits: snap.limits, claims }
91
+ : { config, preprocessed: pre, limits: snap.limits };
92
+ const readsAst = this.readsAst(plugin, config);
93
+ const dataAst = dataAstOf(snap.options, plugin, readsAst);
94
+ const parsed = parseStep(plugin, text, ctx, !full && !readsAst, dataAst);
95
+ const parse = parsed.lean;
96
+ stageEnd('parse', t);
97
+ // A directive inside a block belongs to the block (ADR-15): parse again without it.
98
+ const outside = outsideBlocks(pre, parse);
99
+ if (outside !== pre)
100
+ return this.analyse(text, snap, plugin, { detected, pre: outside }, host, full);
101
+ if (hasError(pre.diagnostics) || hasError(parse.diagnostics))
102
+ throw errorFromDiagnostics(text, [...pre.diagnostics, ...parse.diagnostics]);
103
+ warnOf(parse.diagnostics, warn);
104
+ const analysis = {
105
+ detected,
106
+ plugin,
107
+ prepared: { diagramType: detected.type, config, parse, warnings },
108
+ title: pre.frontMatter?.title,
109
+ sources,
110
+ dataAst,
111
+ full: () => fullParse(plugin, text, ctx),
112
+ };
113
+ return { analysis, full: parsed.full };
114
+ }
115
+ detect(text, s) {
116
+ // DESIGN §3 step 1: the source limit, before the text is read at all.
117
+ checkSource(text, s.limits);
118
+ const pre = preprocess(text);
119
+ if (hasError(pre.diagnostics))
120
+ throw errorFromDiagnostics(text, pre.diagnostics);
121
+ return {
122
+ detected: this.registry.detect(text, pre, s.config),
123
+ pre,
124
+ };
125
+ }
126
+ /**
127
+ * Whether `a`'s type has text output (R-ASCII-5, D80). Asked by type: a type can draw fewer
128
+ * formats than its plugin (`typeOptions` `formats`).
129
+ */
130
+ textOf(a) {
131
+ return a.detected.id !== undefined && this.registry.formats(a.detected.type).includes('ascii');
132
+ }
133
+ /** Throws `UnsupportedFormatError` unless `detected` declares ascii (R-ASCII-5, D80). */
134
+ checkText(detected) {
135
+ if (!this.textOf({ detected }))
136
+ throw new UnsupportedFormatError(detected.type, 'ascii');
137
+ }
138
+ /** `detect`, for a type with a plugin package that can draw `ascii` when that is asked for. */
139
+ detectSupported(text, s, ascii) {
140
+ const found = this.detect(text, s);
141
+ const { detected } = found;
142
+ if (detected.id === undefined)
143
+ throw unsupportedDiagram(detected.type);
144
+ if (ascii)
145
+ this.checkText(detected);
146
+ // The registry's row itself, its id now known to be set: nothing writes it (readonly).
147
+ return found;
148
+ }
149
+ /**
150
+ * Parses with the loaded `plugin` and caches the analysis (DESIGN §3 steps 2–4): only its
151
+ * lean parse; a full parse goes to the call that asked for it.
152
+ */
153
+ analysisOf(text, s, found, plugin, full = false) {
154
+ if (!plugin)
155
+ throw unsupportedDiagram(found.detected.type);
156
+ const parsed = this.analyse(text, s, plugin, found, undefined, full);
157
+ this.cache.set(text, s, parsed.analysis);
158
+ return parsed;
159
+ }
160
+ }
@@ -0,0 +1,63 @@
1
+ import { type DiagramParseContext } from '@mermaid-js/core';
2
+ import type { LeanParseResult, ParseResult } from '@mermaid-js/core/parser-kit';
3
+ import type { PreprocessResult } from '@mermaid-js/core/preprocess';
4
+ import type { Prepared } from './api-types.ts';
5
+ import type { IntegratorOptions, Snapshot } from './config-snapshot.ts';
6
+ import type { AnyPlugin, Detected } from './registry.ts';
7
+ /**
8
+ * What the API object keeps of one parsed text (DESIGN §3 steps 1–4): its parse is lean
9
+ * (DESIGN §4.2), whatever the plugin returned, so a cached text holds no AST.
10
+ */
11
+ export interface Analysis {
12
+ readonly detected: Detected;
13
+ readonly plugin: AnyPlugin;
14
+ readonly prepared: Omit<Prepared, 'parse'> & {
15
+ readonly parse: LeanParseResult<unknown>;
16
+ };
17
+ /** The front-matter title, for text output (D82). */
18
+ readonly title: string | undefined;
19
+ /** The author's config layers (`initialize`, front matter, directives), for line hops (D537). */
20
+ readonly sources: readonly (Readonly<Record<string, unknown>> | undefined)[];
21
+ /** Whether its SVG draws write `data-ast` (`RenderContext.dataAst`). */
22
+ readonly dataAst: boolean;
23
+ /**
24
+ * The text parsed again in full, for a call that reads the AST (`prepare()`, text output, a
25
+ * `postParse` hook). It is the caller's: nothing keeps it.
26
+ */
27
+ readonly full: () => ParseResult<unknown>;
28
+ }
29
+ /** An analysis, with the full parse when the call that made it parsed in full. */
30
+ export interface Parsed {
31
+ readonly analysis: Analysis;
32
+ readonly full?: ParseResult<unknown>;
33
+ }
34
+ /**
35
+ * Whether an analysis's SVG draws write `data-ast` (R-PARSE-8): as the integrator says
36
+ * (`output.dataAst`); unset, for a plugin that parses lean only when an extension reads the AST
37
+ * (`postParse`), and always for one that does not (its parse always gives the ids).
38
+ */
39
+ export declare function dataAstOf(options: Readonly<IntegratorOptions>, plugin: AnyPlugin, readsAst: boolean): boolean;
40
+ /**
41
+ * The parse step of an analysis (DESIGN §3 step 3): lean when `lean` (DESIGN §4.2), with the
42
+ * model's AST ids when `astIds`. A lean parse with an error is parsed again in full, so the
43
+ * error and its diagnostics are the full parse's. Returns the lean view of the result, and the
44
+ * result itself when it is full.
45
+ */
46
+ export declare function parseStep(plugin: AnyPlugin, text: string, ctx: DiagramParseContext, lean: boolean, astIds: boolean): {
47
+ readonly lean: LeanParseResult<unknown>;
48
+ readonly full?: ParseResult<unknown>;
49
+ };
50
+ /** `plugin`'s full parse: a plugin gives a lean one only when asked for it. */
51
+ export declare function fullParse(plugin: AnyPlugin, text: string, ctx: DiagramParseContext): ParseResult<unknown>;
52
+ /** What `detect` found. */
53
+ export interface Detection {
54
+ readonly detected: Detected;
55
+ readonly pre: PreprocessResult;
56
+ }
57
+ /** The analyses of recent texts, each valid only for the snapshot it was made with. */
58
+ export declare class AnalysisCache<A> {
59
+ private readonly entries;
60
+ get(text: string, snap: Snapshot): A | undefined;
61
+ set(text: string, snap: Snapshot, analysis: A): void;
62
+ clear(): void;
63
+ }
@@ -0,0 +1,51 @@
1
+ import { MermaidError } from '@mermaid-js/core';
2
+ /**
3
+ * Whether an analysis's SVG draws write `data-ast` (R-PARSE-8): as the integrator says
4
+ * (`output.dataAst`); unset, for a plugin that parses lean only when an extension reads the AST
5
+ * (`postParse`), and always for one that does not (its parse always gives the ids).
6
+ */
7
+ export function dataAstOf(options, plugin, readsAst) {
8
+ return options.output?.dataAst ?? (!plugin.leanParse || readsAst);
9
+ }
10
+ /**
11
+ * The parse step of an analysis (DESIGN §3 step 3): lean when `lean` (DESIGN §4.2), with the
12
+ * model's AST ids when `astIds`. A lean parse with an error is parsed again in full, so the
13
+ * error and its diagnostics are the full parse's. Returns the lean view of the result, and the
14
+ * result itself when it is full.
15
+ */
16
+ export function parseStep(plugin, text, ctx, lean, astIds) {
17
+ let parse = plugin.parse(text, lean ? { ...ctx, lean, astIds } : ctx);
18
+ if (parse.lean && parse.diagnostics.some((d) => d.severity === 'error'))
19
+ parse = plugin.parse(text, ctx);
20
+ if (parse.lean)
21
+ return { lean: parse };
22
+ // The lean view: what a draw reads, nothing of the AST, symbols, statements or tokens.
23
+ const full = parse;
24
+ const { model, diagnostics, embeds, edgeCount } = full;
25
+ return { lean: { lean: true, model, diagnostics, embeds, edgeCount }, full };
26
+ }
27
+ /** `plugin`'s full parse: a plugin gives a lean one only when asked for it. */
28
+ export function fullParse(plugin, text, ctx) {
29
+ const parse = plugin.parse(text, ctx);
30
+ if (parse.lean)
31
+ throw new MermaidError('INTERNAL', `${plugin.id}: lean parse unasked`);
32
+ return parse;
33
+ }
34
+ const CACHE_SIZE = 32;
35
+ /** The analyses of recent texts, each valid only for the snapshot it was made with. */
36
+ export class AnalysisCache {
37
+ entries = new Map();
38
+ get(text, snap) {
39
+ const hit = this.entries.get(text);
40
+ return hit && hit.snap === snap ? hit.analysis : undefined;
41
+ }
42
+ set(text, snap, analysis) {
43
+ this.entries.delete(text);
44
+ this.entries.set(text, { snap, analysis });
45
+ if (this.entries.size > CACHE_SIZE)
46
+ this.entries.delete(this.entries.keys().next().value);
47
+ }
48
+ clear() {
49
+ this.entries.clear();
50
+ }
51
+ }
@@ -0,0 +1,137 @@
1
+ /**
2
+ * The public option and result types of the API object (`api.ts` re-exports them).
3
+ */
4
+ import type { ExtensionPlugin as CoreExtensionPlugin, MermaidError, PluginFormat, Warning } from '@mermaid-js/core';
5
+ import type { MermaidConfig, ResolvedConfig } from '@mermaid-js/core/config';
6
+ import type { ParseResult } from '@mermaid-js/core/parser-kit';
7
+ import type { InitializeConfig } from './config-snapshot.ts';
8
+ export interface RenderOptions {
9
+ /**
10
+ * Prefix of the ids in the output (`render(id)` passes its id). Without one, the prefix is
11
+ * `mermaid-<hash>`, a stable hash of the source text and the resolved config, so different
12
+ * diagrams on one page get distinct ids and the same input stays byte-identical (R-SVG-3,
13
+ * R-ARCH-6). Pass an `id` to render the same text twice on one page.
14
+ */
15
+ id?: string;
16
+ /** Per-call integrator config, merged over `initialize()`'s. */
17
+ config?: InitializeConfig;
18
+ /** Draw placeholders for missing resources, with a warning, instead of throwing. */
19
+ placeholders?: boolean;
20
+ /**
21
+ * Output format (R-ASCII-4, D80): `svg` (default) or `ascii`, text drawn in character cells
22
+ * for the types whose manifest lists it (`supportsFormat`).
23
+ */
24
+ format?: PluginFormat;
25
+ /**
26
+ * Width in px the drawing should fit (R-LAYOUT-5): graph layouts tighten their spacing and
27
+ * may turn LR into TB. Off by default; `mount(…, { availableWidth: true })` passes the
28
+ * element's width. SVG only: text output fits `ascii.maxWidth` columns instead (D84).
29
+ */
30
+ availableWidth?: number;
31
+ /**
32
+ * The instant the diagram treats as now (D270): gantt's `today` line and `today`-relative
33
+ * dates. Defaults to `Date.now()` at each call (D275). Not a config key: diagram text
34
+ * cannot set it.
35
+ */
36
+ now?: number | Date;
37
+ }
38
+ /** Options of an SVG render (`format` absent or `svg`). */
39
+ export interface SvgRenderOptions extends RenderOptions {
40
+ format?: 'svg';
41
+ }
42
+ /** Options of a text render (R-ASCII-4, D80). */
43
+ export interface TextRenderOptions extends RenderOptions {
44
+ format: 'ascii';
45
+ /**
46
+ * Explicit text options for this call (the CLI's `--charset` and `--width`). Each key set here
47
+ * wins over the same `ascii` key from any config, the diagram's front matter and directives
48
+ * included; unset keys fall back to the config as usual.
49
+ */
50
+ ascii?: {
51
+ charset?: 'unicode' | 'ascii';
52
+ padding?: 'compact' | 'roomy';
53
+ maxWidth?: number;
54
+ };
55
+ }
56
+ /**
57
+ * A text render (R-ASCII-4, D80): `\n` line ends, no trailing spaces, byte-deterministic.
58
+ * `columns` is the widest line in cells (a wide character takes 2), `rows` the line count.
59
+ */
60
+ export interface TextRenderResult {
61
+ format: 'ascii';
62
+ text: string;
63
+ columns: number;
64
+ rows: number;
65
+ diagramType: string;
66
+ warnings: Warning[];
67
+ }
68
+ export interface RenderResult {
69
+ svg: string;
70
+ diagramType: string;
71
+ width: number;
72
+ height: number;
73
+ warnings: Warning[];
74
+ /**
75
+ * Set only when a registered extension has an `afterMount` hook (the interactions plugin,
76
+ * DESIGN §12.3): runs those hooks on the element the svg was mounted in. The DOM adapter
77
+ * (`run`/`mount`, #16) calls it after inserting the svg.
78
+ */
79
+ bindFunctions?: (element: Element) => void;
80
+ }
81
+ /**
82
+ * An extension plugin (DESIGN §12.2): hooks for every diagram type, registered through
83
+ * `registerExternalDiagrams`. `afterMount` runs only in the DOM adapter (`bindFunctions`).
84
+ */
85
+ export type ExtensionPlugin = CoreExtensionPlugin<Element, RenderResult>;
86
+ /**
87
+ * What `prepare` found: cached so `renderSync` right after does not parse again. The object is the
88
+ * cached one, shared with later renders of the same text: read it, never change it. Only the
89
+ * config is frozen (by `resolveText`).
90
+ */
91
+ export interface Prepared {
92
+ readonly diagramType: string;
93
+ readonly config: ResolvedConfig;
94
+ /** The diagram plugin's parse result (model, AST, diagnostics, symbols). */
95
+ readonly parse: ParseResult<unknown>;
96
+ readonly warnings: readonly Warning[];
97
+ }
98
+ export interface ParseOptions {
99
+ /** Resolve to `false` instead of rejecting when the diagram is invalid. */
100
+ suppressErrors?: boolean;
101
+ }
102
+ export interface ParseResult12 {
103
+ /** The v12 diagram type, e.g. `flowchart-v2`. */
104
+ diagramType: string;
105
+ /**
106
+ * The config given in front matter and directives, without the integrator-only keys.
107
+ * `theme` keeps v12's type so v12 callers still compile (R-COMPAT-5); a diagram that asks
108
+ * for v13's `theme: 'auto'` reports it as the string `'auto'` all the same.
109
+ */
110
+ config: Omit<MermaidConfig, 'securityLevel' | 'theme'> & {
111
+ theme?: V12Theme;
112
+ };
113
+ warnings: Warning[];
114
+ }
115
+ /** The `theme` names v12 declared: every v13 name except `auto`. */
116
+ type V12Theme = Exclude<MermaidConfig['theme'], 'auto'>;
117
+ export interface PreloadRequest {
118
+ /** Diagram types or plugin ids. */
119
+ types?: readonly string[];
120
+ layouts?: readonly string[];
121
+ themes?: readonly string[];
122
+ /** `'ascii'` also loads each type's text entry, for `renderSync(…, { format: 'ascii' })`. */
123
+ formats?: readonly PluginFormat[];
124
+ /**
125
+ * Runs these packs' loaders (`registerIconPacks`), for `renderSync` with their icons (D294).
126
+ * An unregistered name is ignored; a rejecting loader does not reject (D299).
127
+ */
128
+ iconPacks?: readonly string[];
129
+ /** Loads what a registered math extension provides, for `renderSync` with `$$…$$` (D178). */
130
+ math?: boolean;
131
+ }
132
+ /**
133
+ * @deprecated v12 compatibility: receives the `MermaidError` of a failed `parse()`, `render()` or
134
+ * `run()` element.
135
+ */
136
+ export type ParseErrorHandler = (error: MermaidError) => void;
137
+ export {};
@@ -0,0 +1 @@
1
+ export {};