mermaid 13.0.0-alpha.3 → 13.0.0-beta.5

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 (587) hide show
  1. package/README.md +28 -11
  2. package/THIRD_PARTY_NOTICES +0 -126
  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 +54 -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 +161 -602
  11. package/dist/ascii.d.ts +5 -4
  12. package/dist/ascii.js +20 -0
  13. package/dist/block-pass.d.ts +144 -0
  14. package/dist/block-pass.js +460 -0
  15. package/dist/chunks/chunk-34CNSMZO.mjs +2 -0
  16. package/dist/chunks/chunk-34CNSMZO.mjs.map +1 -0
  17. package/dist/chunks/chunk-35VDXA3F.mjs +3 -0
  18. package/dist/chunks/chunk-35VDXA3F.mjs.map +1 -0
  19. package/dist/chunks/chunk-3BVCMOYJ.mjs +3 -0
  20. package/dist/chunks/chunk-3BVCMOYJ.mjs.map +1 -0
  21. package/dist/chunks/chunk-3MYLJHPW.mjs +2 -0
  22. package/dist/chunks/chunk-3MYLJHPW.mjs.map +1 -0
  23. package/dist/chunks/chunk-4Y6EKTOM.mjs +2 -0
  24. package/dist/chunks/chunk-4Y6EKTOM.mjs.map +1 -0
  25. package/dist/chunks/chunk-54X7EXAD.mjs +2 -0
  26. package/dist/chunks/chunk-54X7EXAD.mjs.map +1 -0
  27. package/dist/chunks/chunk-57JERKFE.mjs +2 -0
  28. package/dist/chunks/chunk-57JERKFE.mjs.map +1 -0
  29. package/dist/chunks/chunk-5P3W53PJ.mjs +2 -0
  30. package/dist/chunks/chunk-5P3W53PJ.mjs.map +1 -0
  31. package/dist/chunks/chunk-5SJDMHSY.mjs +2 -0
  32. package/dist/chunks/chunk-5SJDMHSY.mjs.map +1 -0
  33. package/dist/chunks/chunk-63EMOOT5.mjs +3 -0
  34. package/dist/chunks/chunk-63EMOOT5.mjs.map +1 -0
  35. package/dist/chunks/chunk-65NV4M6T.mjs +2 -0
  36. package/dist/chunks/chunk-65NV4M6T.mjs.map +1 -0
  37. package/dist/chunks/chunk-6MLWUK4R.mjs +11 -0
  38. package/dist/chunks/chunk-6MLWUK4R.mjs.map +1 -0
  39. package/dist/chunks/chunk-7445R5LN.mjs +3 -0
  40. package/dist/chunks/chunk-7445R5LN.mjs.map +1 -0
  41. package/dist/chunks/chunk-7GDL2TWK.mjs +5 -0
  42. package/dist/chunks/chunk-7GDL2TWK.mjs.map +1 -0
  43. package/dist/chunks/chunk-7UX6Z54Y.mjs +2 -0
  44. package/dist/chunks/chunk-7UX6Z54Y.mjs.map +1 -0
  45. package/dist/chunks/chunk-A5PG4H2A.mjs +2 -0
  46. package/dist/chunks/chunk-A5PG4H2A.mjs.map +1 -0
  47. package/dist/chunks/chunk-AA5A5TTE.mjs +2 -0
  48. package/dist/chunks/chunk-AA5A5TTE.mjs.map +1 -0
  49. package/dist/chunks/chunk-ATRV5TEE.mjs +2 -0
  50. package/dist/chunks/chunk-ATRV5TEE.mjs.map +1 -0
  51. package/dist/chunks/chunk-B4PZC3M4.mjs +3 -0
  52. package/dist/chunks/chunk-B4PZC3M4.mjs.map +1 -0
  53. package/dist/chunks/chunk-BIV33NIH.mjs +3 -0
  54. package/dist/chunks/chunk-BIV33NIH.mjs.map +1 -0
  55. package/dist/chunks/chunk-BNFS7F7S.mjs +5 -0
  56. package/dist/chunks/chunk-BNFS7F7S.mjs.map +1 -0
  57. package/dist/chunks/chunk-BT2K77IK.mjs +3 -0
  58. package/dist/chunks/chunk-BT2K77IK.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-C4SDPANP.mjs +5 -0
  62. package/dist/chunks/chunk-C4SDPANP.mjs.map +1 -0
  63. package/dist/chunks/chunk-C6TDUBRR.mjs +7 -0
  64. package/dist/chunks/chunk-C6TDUBRR.mjs.map +1 -0
  65. package/dist/chunks/chunk-CCM24AVG.mjs +2 -0
  66. package/dist/chunks/chunk-CCM24AVG.mjs.map +1 -0
  67. package/dist/chunks/chunk-CHEOV6RV.mjs +3 -0
  68. package/dist/chunks/chunk-CHEOV6RV.mjs.map +1 -0
  69. package/dist/chunks/chunk-CIRJ4NYK.mjs +2 -0
  70. package/dist/chunks/chunk-CIRJ4NYK.mjs.map +1 -0
  71. package/dist/chunks/chunk-CMVAKZHL.mjs +7 -0
  72. package/dist/chunks/chunk-CMVAKZHL.mjs.map +1 -0
  73. package/dist/chunks/chunk-CPJV4WUF.mjs +2 -0
  74. package/dist/chunks/{chunk-YKQIHLV5.mjs.map → chunk-CPJV4WUF.mjs.map} +1 -1
  75. package/dist/chunks/chunk-DLU4BZ6H.mjs +2 -0
  76. package/dist/chunks/chunk-DLU4BZ6H.mjs.map +1 -0
  77. package/dist/chunks/chunk-DPSPHODO.mjs +2 -0
  78. package/dist/chunks/chunk-DPSPHODO.mjs.map +1 -0
  79. package/dist/chunks/chunk-EAGNTERD.mjs +2 -0
  80. package/dist/chunks/chunk-EAGNTERD.mjs.map +1 -0
  81. package/dist/chunks/chunk-EK4S7EXT.mjs +2 -0
  82. package/dist/chunks/chunk-EK4S7EXT.mjs.map +1 -0
  83. package/dist/chunks/chunk-ESGJI3CB.mjs +2 -0
  84. package/dist/chunks/chunk-ESGJI3CB.mjs.map +1 -0
  85. package/dist/chunks/chunk-EVRF73VT.mjs +3 -0
  86. package/dist/chunks/chunk-EVRF73VT.mjs.map +1 -0
  87. package/dist/chunks/chunk-EVZ53CQP.mjs +2 -0
  88. package/dist/chunks/chunk-EVZ53CQP.mjs.map +1 -0
  89. package/dist/chunks/chunk-F2VKDTOW.mjs +1 -0
  90. package/dist/chunks/chunk-F6KJEEFC.mjs +2 -0
  91. package/dist/chunks/chunk-F6KJEEFC.mjs.map +1 -0
  92. package/dist/chunks/chunk-FC5BAB6Y.mjs +4 -0
  93. package/dist/chunks/chunk-FC5BAB6Y.mjs.map +1 -0
  94. package/dist/chunks/chunk-FGPTI5LN.mjs +2 -0
  95. package/dist/chunks/chunk-FGPTI5LN.mjs.map +1 -0
  96. package/dist/chunks/chunk-FVBLN5SX.mjs +2 -0
  97. package/dist/chunks/chunk-FVBLN5SX.mjs.map +1 -0
  98. package/dist/chunks/chunk-FYP52GV4.mjs +3 -0
  99. package/dist/chunks/chunk-FYP52GV4.mjs.map +1 -0
  100. package/dist/chunks/chunk-G7JG3T44.mjs +8 -0
  101. package/dist/chunks/chunk-G7JG3T44.mjs.map +1 -0
  102. package/dist/chunks/chunk-GYTZZAWH.mjs +6 -0
  103. package/dist/chunks/chunk-GYTZZAWH.mjs.map +1 -0
  104. package/dist/chunks/chunk-GZ4G72AU.mjs +2 -0
  105. package/dist/chunks/chunk-GZ4G72AU.mjs.map +1 -0
  106. package/dist/chunks/chunk-HDD66BKK.mjs +2 -0
  107. package/dist/chunks/chunk-HDD66BKK.mjs.map +1 -0
  108. package/dist/chunks/chunk-HHLXJJ7H.mjs +2 -0
  109. package/dist/chunks/chunk-HHLXJJ7H.mjs.map +1 -0
  110. package/dist/chunks/chunk-HZQAGUYT.mjs +11 -0
  111. package/dist/chunks/chunk-HZQAGUYT.mjs.map +1 -0
  112. package/dist/chunks/chunk-IY436MEC.mjs +2 -0
  113. package/dist/chunks/chunk-IY436MEC.mjs.map +1 -0
  114. package/dist/chunks/chunk-J4P53XG6.mjs +2 -0
  115. package/dist/chunks/chunk-J4P53XG6.mjs.map +1 -0
  116. package/dist/chunks/chunk-JUCDZ7CP.mjs +3 -0
  117. package/dist/chunks/chunk-JUCDZ7CP.mjs.map +1 -0
  118. package/dist/chunks/chunk-JVLFSOHI.mjs +3 -0
  119. package/dist/chunks/chunk-JVLFSOHI.mjs.map +1 -0
  120. package/dist/chunks/chunk-JXHIG6FZ.mjs +2 -0
  121. package/dist/chunks/chunk-JXHIG6FZ.mjs.map +1 -0
  122. package/dist/chunks/{chunk-53XKVPPJ.mjs → chunk-K6GRKAXG.mjs} +1 -1
  123. package/dist/chunks/chunk-K6GRKAXG.mjs.map +1 -0
  124. package/dist/chunks/chunk-LEQ57ZOM.mjs +6 -0
  125. package/dist/chunks/chunk-LEQ57ZOM.mjs.map +1 -0
  126. package/dist/chunks/chunk-M3NSD6ZW.mjs +3 -0
  127. package/dist/chunks/chunk-M3NSD6ZW.mjs.map +1 -0
  128. package/dist/chunks/chunk-M7Z3J4NO.mjs +2 -0
  129. package/dist/chunks/chunk-M7Z3J4NO.mjs.map +1 -0
  130. package/dist/chunks/chunk-MNLDZQNB.mjs +3 -0
  131. package/dist/chunks/chunk-MNLDZQNB.mjs.map +1 -0
  132. package/dist/chunks/chunk-MOVLMRFC.mjs +2 -0
  133. package/dist/chunks/chunk-MOVLMRFC.mjs.map +1 -0
  134. package/dist/chunks/chunk-MPMWZO6R.mjs +6 -0
  135. package/dist/chunks/chunk-MPMWZO6R.mjs.map +1 -0
  136. package/dist/chunks/chunk-NGJUUS6G.mjs +7 -0
  137. package/dist/chunks/chunk-NGJUUS6G.mjs.map +1 -0
  138. package/dist/chunks/chunk-NKB7NH64.mjs +2 -0
  139. package/dist/chunks/chunk-NKB7NH64.mjs.map +1 -0
  140. package/dist/chunks/chunk-NNXXXZOH.mjs +2 -0
  141. package/dist/chunks/chunk-NNXXXZOH.mjs.map +1 -0
  142. package/dist/chunks/chunk-OIW2ACTI.mjs +2 -0
  143. package/dist/chunks/chunk-OIW2ACTI.mjs.map +1 -0
  144. package/dist/chunks/chunk-OKL6T5MF.mjs +2 -0
  145. package/dist/chunks/chunk-OKL6T5MF.mjs.map +1 -0
  146. package/dist/chunks/chunk-ON3DSIC6.mjs +2 -0
  147. package/dist/chunks/chunk-ON3DSIC6.mjs.map +1 -0
  148. package/dist/chunks/chunk-OTDD3VKD.mjs +2 -0
  149. package/dist/chunks/chunk-OTDD3VKD.mjs.map +1 -0
  150. package/dist/chunks/chunk-P4TOP4AF.mjs +4 -0
  151. package/dist/chunks/chunk-P4TOP4AF.mjs.map +1 -0
  152. package/dist/chunks/chunk-P7ASZ2DF.mjs +2 -0
  153. package/dist/chunks/chunk-P7ASZ2DF.mjs.map +1 -0
  154. package/dist/chunks/chunk-PFAC3TV3.mjs +2 -0
  155. package/dist/chunks/chunk-PFAC3TV3.mjs.map +1 -0
  156. package/dist/chunks/chunk-PGLDPGVR.mjs +9 -0
  157. package/dist/chunks/chunk-PGLDPGVR.mjs.map +1 -0
  158. package/dist/chunks/chunk-PY4MJHBX.mjs +7 -0
  159. package/dist/chunks/chunk-PY4MJHBX.mjs.map +1 -0
  160. package/dist/chunks/chunk-PZNE6TK6.mjs +2 -0
  161. package/dist/chunks/chunk-PZNE6TK6.mjs.map +1 -0
  162. package/dist/chunks/chunk-Q2TSECSK.mjs +2 -0
  163. package/dist/chunks/chunk-Q2TSECSK.mjs.map +1 -0
  164. package/dist/chunks/chunk-QGV44AQG.mjs +2 -0
  165. package/dist/chunks/chunk-QGV44AQG.mjs.map +1 -0
  166. package/dist/chunks/chunk-QNCYRYSM.mjs +2 -0
  167. package/dist/chunks/chunk-QNCYRYSM.mjs.map +1 -0
  168. package/dist/chunks/chunk-QSOECHY3.mjs +2 -0
  169. package/dist/chunks/chunk-QSOECHY3.mjs.map +1 -0
  170. package/dist/chunks/chunk-R3FKHKB6.mjs +3 -0
  171. package/dist/chunks/chunk-R3FKHKB6.mjs.map +1 -0
  172. package/dist/chunks/chunk-RGYOWKGP.mjs +3 -0
  173. package/dist/chunks/chunk-RGYOWKGP.mjs.map +1 -0
  174. package/dist/chunks/chunk-RSPJTOPF.mjs +2 -0
  175. package/dist/chunks/chunk-RSPJTOPF.mjs.map +1 -0
  176. package/dist/chunks/chunk-S4VYITV3.mjs +2 -0
  177. package/dist/chunks/chunk-S4VYITV3.mjs.map +1 -0
  178. package/dist/chunks/chunk-SASGMFFB.mjs +2 -0
  179. package/dist/chunks/chunk-SASGMFFB.mjs.map +1 -0
  180. package/dist/chunks/chunk-SKTDVG3X.mjs +6 -0
  181. package/dist/chunks/chunk-SKTDVG3X.mjs.map +1 -0
  182. package/dist/chunks/chunk-SRYATSMJ.mjs +3 -0
  183. package/dist/chunks/chunk-SRYATSMJ.mjs.map +1 -0
  184. package/dist/chunks/chunk-SUH3QCTV.mjs +2 -0
  185. package/dist/chunks/chunk-SUH3QCTV.mjs.map +1 -0
  186. package/dist/chunks/chunk-TEKRHUSC.mjs +9 -0
  187. package/dist/chunks/chunk-TEKRHUSC.mjs.map +1 -0
  188. package/dist/chunks/chunk-TI27NBVQ.mjs +2 -0
  189. package/dist/chunks/chunk-TI27NBVQ.mjs.map +1 -0
  190. package/dist/chunks/chunk-TNQLTQZT.mjs +2 -0
  191. package/dist/chunks/chunk-TNQLTQZT.mjs.map +1 -0
  192. package/dist/chunks/chunk-TOA72OFK.mjs +5 -0
  193. package/dist/chunks/chunk-TOA72OFK.mjs.map +1 -0
  194. package/dist/chunks/chunk-TRXZHDEJ.mjs +2 -0
  195. package/dist/chunks/chunk-TRXZHDEJ.mjs.map +1 -0
  196. package/dist/chunks/chunk-VYBXWFSY.mjs +2 -0
  197. package/dist/chunks/chunk-VYBXWFSY.mjs.map +1 -0
  198. package/dist/chunks/chunk-W3OIJRHI.mjs +2 -0
  199. package/dist/chunks/chunk-W3OIJRHI.mjs.map +1 -0
  200. package/dist/chunks/chunk-W6UVS5YO.mjs +2 -0
  201. package/dist/chunks/chunk-W6UVS5YO.mjs.map +1 -0
  202. package/dist/chunks/chunk-WEAEHFAN.mjs +4 -0
  203. package/dist/chunks/chunk-WEAEHFAN.mjs.map +1 -0
  204. package/dist/chunks/chunk-WGSYFIUA.mjs +3 -0
  205. package/dist/chunks/chunk-WGSYFIUA.mjs.map +1 -0
  206. package/dist/chunks/chunk-WHZNT2D3.mjs +2 -0
  207. package/dist/chunks/chunk-WHZNT2D3.mjs.map +1 -0
  208. package/dist/chunks/chunk-WIESXAR7.mjs +2 -0
  209. package/dist/chunks/chunk-WIESXAR7.mjs.map +1 -0
  210. package/dist/chunks/chunk-WJKVYSQH.mjs +9 -0
  211. package/dist/chunks/chunk-WJKVYSQH.mjs.map +1 -0
  212. package/dist/chunks/chunk-WMW43FL7.mjs +2 -0
  213. package/dist/chunks/chunk-WMW43FL7.mjs.map +1 -0
  214. package/dist/chunks/chunk-X4QTHGQU.mjs +28 -0
  215. package/dist/chunks/chunk-X4QTHGQU.mjs.map +1 -0
  216. package/dist/chunks/chunk-X7RNGEDH.mjs +2 -0
  217. package/dist/chunks/chunk-X7RNGEDH.mjs.map +1 -0
  218. package/dist/chunks/chunk-XWDBF7XH.mjs +2 -0
  219. package/dist/chunks/chunk-XWDBF7XH.mjs.map +1 -0
  220. package/dist/chunks/chunk-YO3WCZ5G.mjs +2 -0
  221. package/dist/chunks/chunk-YO3WCZ5G.mjs.map +1 -0
  222. package/dist/chunks/chunk-YTHSONFA.mjs +2 -0
  223. package/dist/chunks/chunk-YTHSONFA.mjs.map +1 -0
  224. package/dist/chunks/{chunk-2G45NV5W.mjs → chunk-YUOTUL2V.mjs} +1 -1
  225. package/dist/chunks/chunk-YUOTUL2V.mjs.map +1 -0
  226. package/dist/chunks/chunk-Z5PRIQDH.mjs +3 -0
  227. package/dist/chunks/chunk-Z5PRIQDH.mjs.map +1 -0
  228. package/dist/chunks/chunk-ZGESO7SP.mjs +9 -0
  229. package/dist/chunks/chunk-ZGESO7SP.mjs.map +1 -0
  230. package/dist/chunks/chunk-ZYHWXZDV.mjs +8 -0
  231. package/dist/chunks/chunk-ZYHWXZDV.mjs.map +1 -0
  232. package/dist/chunks/core-layout-compass-index.mjs +1 -1
  233. package/dist/chunks/core-layout-compass-index.mjs.map +1 -1
  234. package/dist/chunks/core-layout-grid-index.mjs +2 -0
  235. package/dist/chunks/core-layout-grid-index.mjs.map +1 -0
  236. package/dist/chunks/core-layout-swimlane-index.mjs +1 -1
  237. package/dist/chunks/core-layout-swimlane-index.mjs.map +1 -1
  238. package/dist/chunks/core-layout-tree-index.mjs +1 -1
  239. package/dist/chunks/core-layout-tree-index.mjs.map +1 -1
  240. package/dist/chunks/core-text-font-tables.mjs +2 -0
  241. package/dist/chunks/core-text-font-tables.mjs.map +1 -0
  242. package/dist/chunks/core-theme-specs-base.mjs +1 -1
  243. package/dist/chunks/core-theme-specs-base.mjs.map +1 -1
  244. package/dist/chunks/core-theme-specs-dark.mjs +1 -1
  245. package/dist/chunks/core-theme-specs-dark.mjs.map +1 -1
  246. package/dist/chunks/core-theme-specs-default.mjs +1 -1
  247. package/dist/chunks/core-theme-specs-default.mjs.map +1 -1
  248. package/dist/chunks/core-theme-specs-forest.mjs +1 -1
  249. package/dist/chunks/core-theme-specs-forest.mjs.map +1 -1
  250. package/dist/chunks/core-theme-specs-neo-dark.mjs +1 -1
  251. package/dist/chunks/core-theme-specs-neo-dark.mjs.map +1 -1
  252. package/dist/chunks/core-theme-specs-neo.mjs +1 -1
  253. package/dist/chunks/core-theme-specs-neo.mjs.map +1 -1
  254. package/dist/chunks/core-theme-specs-neutral.mjs +1 -1
  255. package/dist/chunks/core-theme-specs-neutral.mjs.map +1 -1
  256. package/dist/chunks/core-theme-specs-redux-dark-color.mjs +1 -1
  257. package/dist/chunks/core-theme-specs-redux-dark-color.mjs.map +1 -1
  258. package/dist/chunks/core-theme-specs-redux-dark.mjs +1 -1
  259. package/dist/chunks/core-theme-specs-redux-dark.mjs.map +1 -1
  260. package/dist/chunks/diagram-agentflow-ascii.mjs +1 -4
  261. package/dist/chunks/diagram-agentflow-ascii.mjs.map +1 -1
  262. package/dist/chunks/diagram-agentflow-language.mjs +11 -22
  263. package/dist/chunks/diagram-agentflow-language.mjs.map +1 -1
  264. package/dist/chunks/diagram-agentflow.mjs +1 -1
  265. package/dist/chunks/diagram-agentflow.mjs.map +1 -1
  266. package/dist/chunks/diagram-architecture-language.mjs +6 -8
  267. package/dist/chunks/diagram-architecture-language.mjs.map +1 -1
  268. package/dist/chunks/diagram-architecture.mjs +1 -1
  269. package/dist/chunks/diagram-architecture.mjs.map +1 -1
  270. package/dist/chunks/diagram-block-ascii.mjs +1 -3
  271. package/dist/chunks/diagram-block-ascii.mjs.map +1 -1
  272. package/dist/chunks/diagram-block-language.mjs +7 -7
  273. package/dist/chunks/diagram-block-language.mjs.map +1 -1
  274. package/dist/chunks/diagram-block.mjs +1 -1
  275. package/dist/chunks/diagram-block.mjs.map +1 -1
  276. package/dist/chunks/diagram-c4-ascii.mjs +1 -3
  277. package/dist/chunks/diagram-c4-ascii.mjs.map +1 -1
  278. package/dist/chunks/diagram-c4-language.mjs +21 -11
  279. package/dist/chunks/diagram-c4-language.mjs.map +1 -1
  280. package/dist/chunks/diagram-c4.mjs +1 -1
  281. package/dist/chunks/diagram-c4.mjs.map +1 -1
  282. package/dist/chunks/diagram-class-language.mjs +12 -18
  283. package/dist/chunks/diagram-class-language.mjs.map +1 -1
  284. package/dist/chunks/diagram-class.mjs +1 -1
  285. package/dist/chunks/diagram-class.mjs.map +1 -1
  286. package/dist/chunks/diagram-cynefin-language.mjs +2 -4
  287. package/dist/chunks/diagram-cynefin-language.mjs.map +1 -1
  288. package/dist/chunks/diagram-cynefin.mjs +1 -1
  289. package/dist/chunks/diagram-cynefin.mjs.map +1 -1
  290. package/dist/chunks/diagram-er-ascii.mjs +1 -4
  291. package/dist/chunks/diagram-er-ascii.mjs.map +1 -1
  292. package/dist/chunks/diagram-er-language.mjs +10 -17
  293. package/dist/chunks/diagram-er-language.mjs.map +1 -1
  294. package/dist/chunks/diagram-er.mjs +1 -1
  295. package/dist/chunks/diagram-er.mjs.map +1 -1
  296. package/dist/chunks/diagram-eventmodeling-language.mjs +7 -9
  297. package/dist/chunks/diagram-eventmodeling-language.mjs.map +1 -1
  298. package/dist/chunks/diagram-eventmodeling.mjs +2 -2
  299. package/dist/chunks/diagram-eventmodeling.mjs.map +1 -1
  300. package/dist/chunks/diagram-flowchart-ascii.mjs +1 -4
  301. package/dist/chunks/diagram-flowchart-ascii.mjs.map +1 -1
  302. package/dist/chunks/diagram-flowchart-lanes.mjs +1 -1
  303. package/dist/chunks/diagram-flowchart-lanes.mjs.map +1 -1
  304. package/dist/chunks/diagram-flowchart-language.mjs +9 -20
  305. package/dist/chunks/diagram-flowchart-language.mjs.map +1 -1
  306. package/dist/chunks/diagram-flowchart.mjs +1 -1
  307. package/dist/chunks/diagram-flowchart.mjs.map +1 -1
  308. package/dist/chunks/diagram-gantt-language.mjs +6 -7
  309. package/dist/chunks/diagram-gantt-language.mjs.map +1 -1
  310. package/dist/chunks/diagram-gantt.mjs +1 -1
  311. package/dist/chunks/diagram-gantt.mjs.map +1 -1
  312. package/dist/chunks/diagram-gitgraph-language.mjs +9 -11
  313. package/dist/chunks/diagram-gitgraph-language.mjs.map +1 -1
  314. package/dist/chunks/diagram-gitgraph.mjs +2 -2
  315. package/dist/chunks/diagram-gitgraph.mjs.map +1 -1
  316. package/dist/chunks/diagram-info-ascii.mjs +1 -1
  317. package/dist/chunks/diagram-info-ascii.mjs.map +1 -1
  318. package/dist/chunks/diagram-info-language.mjs +1 -3
  319. package/dist/chunks/diagram-info-language.mjs.map +1 -1
  320. package/dist/chunks/diagram-info.mjs +1 -1
  321. package/dist/chunks/diagram-info.mjs.map +1 -1
  322. package/dist/chunks/diagram-ishikawa-ascii.mjs +3 -3
  323. package/dist/chunks/diagram-ishikawa-ascii.mjs.map +1 -1
  324. package/dist/chunks/diagram-ishikawa-language.mjs +7 -7
  325. package/dist/chunks/diagram-ishikawa-language.mjs.map +1 -1
  326. package/dist/chunks/diagram-ishikawa.mjs +1 -1
  327. package/dist/chunks/diagram-ishikawa.mjs.map +1 -1
  328. package/dist/chunks/diagram-journey-language.mjs +11 -12
  329. package/dist/chunks/diagram-journey-language.mjs.map +1 -1
  330. package/dist/chunks/diagram-journey.mjs +1 -1
  331. package/dist/chunks/diagram-journey.mjs.map +1 -1
  332. package/dist/chunks/diagram-json-ascii.mjs +2 -0
  333. package/dist/chunks/diagram-json-ascii.mjs.map +1 -0
  334. package/dist/chunks/diagram-json-language.mjs +5 -0
  335. package/dist/chunks/diagram-json-language.mjs.map +1 -0
  336. package/dist/chunks/diagram-json.mjs +2 -0
  337. package/dist/chunks/diagram-json.mjs.map +1 -0
  338. package/dist/chunks/diagram-kanban-ascii.mjs +1 -3
  339. package/dist/chunks/diagram-kanban-ascii.mjs.map +1 -1
  340. package/dist/chunks/diagram-kanban-language.mjs +10 -10
  341. package/dist/chunks/diagram-kanban-language.mjs.map +1 -1
  342. package/dist/chunks/diagram-kanban.mjs +1 -1
  343. package/dist/chunks/diagram-kanban.mjs.map +1 -1
  344. package/dist/chunks/diagram-mindmap-language.mjs +9 -9
  345. package/dist/chunks/diagram-mindmap-language.mjs.map +1 -1
  346. package/dist/chunks/diagram-mindmap.mjs +1 -1
  347. package/dist/chunks/diagram-mindmap.mjs.map +1 -1
  348. package/dist/chunks/diagram-packet-ascii.mjs +4 -5
  349. package/dist/chunks/diagram-packet-ascii.mjs.map +1 -1
  350. package/dist/chunks/diagram-packet-language.mjs +4 -6
  351. package/dist/chunks/diagram-packet-language.mjs.map +1 -1
  352. package/dist/chunks/diagram-packet.mjs +2 -1
  353. package/dist/chunks/diagram-packet.mjs.map +1 -1
  354. package/dist/chunks/diagram-pie-language.mjs +5 -7
  355. package/dist/chunks/diagram-pie-language.mjs.map +1 -1
  356. package/dist/chunks/diagram-pie.mjs +1 -1
  357. package/dist/chunks/diagram-pie.mjs.map +1 -1
  358. package/dist/chunks/diagram-quadrant-language.mjs +9 -9
  359. package/dist/chunks/diagram-quadrant-language.mjs.map +1 -1
  360. package/dist/chunks/diagram-quadrant.mjs +1 -1
  361. package/dist/chunks/diagram-quadrant.mjs.map +1 -1
  362. package/dist/chunks/diagram-radar-language.mjs +7 -10
  363. package/dist/chunks/diagram-radar-language.mjs.map +1 -1
  364. package/dist/chunks/diagram-radar.mjs +1 -1
  365. package/dist/chunks/diagram-radar.mjs.map +1 -1
  366. package/dist/chunks/diagram-railroad-ascii.mjs +1 -1
  367. package/dist/chunks/diagram-railroad-ascii.mjs.map +1 -1
  368. package/dist/chunks/diagram-railroad-language.mjs +7 -11
  369. package/dist/chunks/diagram-railroad-language.mjs.map +1 -1
  370. package/dist/chunks/diagram-railroad.mjs +1 -1
  371. package/dist/chunks/diagram-railroad.mjs.map +1 -1
  372. package/dist/chunks/diagram-requirement-ascii.mjs +1 -4
  373. package/dist/chunks/diagram-requirement-ascii.mjs.map +1 -1
  374. package/dist/chunks/diagram-requirement-language.mjs +7 -11
  375. package/dist/chunks/diagram-requirement-language.mjs.map +1 -1
  376. package/dist/chunks/diagram-requirement.mjs +1 -1
  377. package/dist/chunks/diagram-requirement.mjs.map +1 -1
  378. package/dist/chunks/diagram-sankey-language.mjs +6 -8
  379. package/dist/chunks/diagram-sankey-language.mjs.map +1 -1
  380. package/dist/chunks/diagram-sankey.mjs +1 -1
  381. package/dist/chunks/diagram-sankey.mjs.map +1 -1
  382. package/dist/chunks/diagram-sequence-ascii.mjs +3 -3
  383. package/dist/chunks/diagram-sequence-ascii.mjs.map +1 -1
  384. package/dist/chunks/diagram-sequence-language.mjs +7 -10
  385. package/dist/chunks/diagram-sequence-language.mjs.map +1 -1
  386. package/dist/chunks/diagram-sequence.mjs +1 -1
  387. package/dist/chunks/diagram-sequence.mjs.map +1 -1
  388. package/dist/chunks/diagram-state-language.mjs +9 -16
  389. package/dist/chunks/diagram-state-language.mjs.map +1 -1
  390. package/dist/chunks/diagram-state.mjs +3 -3
  391. package/dist/chunks/diagram-state.mjs.map +1 -1
  392. package/dist/chunks/diagram-timeline-language.mjs +2 -2
  393. package/dist/chunks/diagram-timeline-language.mjs.map +1 -1
  394. package/dist/chunks/diagram-timeline.mjs +1 -1
  395. package/dist/chunks/diagram-timeline.mjs.map +1 -1
  396. package/dist/chunks/diagram-treemap-language.mjs +9 -12
  397. package/dist/chunks/diagram-treemap-language.mjs.map +1 -1
  398. package/dist/chunks/diagram-treemap.mjs +2 -1
  399. package/dist/chunks/diagram-treemap.mjs.map +1 -1
  400. package/dist/chunks/diagram-treeview-ascii.mjs +3 -3
  401. package/dist/chunks/diagram-treeview-ascii.mjs.map +1 -1
  402. package/dist/chunks/diagram-treeview-language.mjs +4 -6
  403. package/dist/chunks/diagram-treeview-language.mjs.map +1 -1
  404. package/dist/chunks/diagram-treeview.mjs +2 -1
  405. package/dist/chunks/diagram-treeview.mjs.map +1 -1
  406. package/dist/chunks/diagram-usecase-ascii.mjs +1 -4
  407. package/dist/chunks/diagram-usecase-ascii.mjs.map +1 -1
  408. package/dist/chunks/diagram-usecase-language.mjs +7 -10
  409. package/dist/chunks/diagram-usecase-language.mjs.map +1 -1
  410. package/dist/chunks/diagram-usecase.mjs +2 -2
  411. package/dist/chunks/diagram-usecase.mjs.map +1 -1
  412. package/dist/chunks/diagram-venn-language.mjs +5 -5
  413. package/dist/chunks/diagram-venn-language.mjs.map +1 -1
  414. package/dist/chunks/diagram-venn.mjs +1 -1
  415. package/dist/chunks/diagram-venn.mjs.map +1 -1
  416. package/dist/chunks/diagram-wardley-language.mjs +5 -8
  417. package/dist/chunks/diagram-wardley-language.mjs.map +1 -1
  418. package/dist/chunks/diagram-wardley.mjs +2 -1
  419. package/dist/chunks/diagram-wardley.mjs.map +1 -1
  420. package/dist/chunks/diagram-xychart-language.mjs +6 -9
  421. package/dist/chunks/diagram-xychart-language.mjs.map +1 -1
  422. package/dist/chunks/diagram-xychart.mjs +1 -1
  423. package/dist/chunks/diagram-xychart.mjs.map +1 -1
  424. package/dist/chunks/mermaid-ascii.mjs +1 -1
  425. package/dist/chunks/mermaid-ascii.mjs.map +1 -1
  426. package/dist/chunks/mermaid-block-pass.mjs +5 -0
  427. package/dist/chunks/mermaid-block-pass.mjs.map +1 -0
  428. package/dist/cli-plugins.d.ts +20 -0
  429. package/dist/cli-plugins.js +165 -0
  430. package/dist/cli.js +36 -3
  431. package/dist/config-snapshot.d.ts +33 -5
  432. package/dist/config-snapshot.js +70 -18
  433. package/dist/discovery.d.ts +12 -21
  434. package/dist/discovery.js +8 -17
  435. package/dist/dom.d.ts +4 -1
  436. package/dist/dom.js +40 -7
  437. package/dist/draw-context.d.ts +42 -0
  438. package/dist/draw-context.js +324 -0
  439. package/dist/draw.d.ts +28 -0
  440. package/dist/draw.js +130 -0
  441. package/dist/embeds.d.ts +48 -0
  442. package/dist/embeds.js +57 -0
  443. package/dist/errors.d.ts +15 -4
  444. package/dist/errors.js +33 -9
  445. package/dist/exports.d.ts +3 -1
  446. package/dist/exports.js +0 -1
  447. package/dist/generated/detectors.gen.d.ts +2 -0
  448. package/dist/generated/detectors.gen.js +4 -1
  449. package/dist/generated/registry.gen.d.ts +1 -1
  450. package/dist/generated/registry.gen.js +27 -68
  451. package/dist/index.d.ts +30 -24
  452. package/dist/index.js +2 -9
  453. package/dist/measurer.d.ts +2 -0
  454. package/dist/measurer.js +3 -4
  455. package/dist/mermaid.esm.min.mjs +4 -3
  456. package/dist/mermaid.esm.min.mjs.map +1 -1
  457. package/dist/mermaid.min.js +1 -1
  458. package/dist/mermaid.min.js.map +1 -1
  459. package/dist/plugin-queue.js +3 -11
  460. package/dist/prepare.d.ts +17 -0
  461. package/dist/prepare.js +145 -0
  462. package/dist/registry.d.ts +40 -29
  463. package/dist/registry.js +106 -98
  464. package/dist/seam.d.ts +12 -21
  465. package/dist/seam.js +31 -49
  466. package/dist/session.d.ts +58 -0
  467. package/dist/session.js +40 -0
  468. package/dist/slim.d.ts +19 -10
  469. package/dist/slim.js +57 -16
  470. package/dist/version.d.ts +1 -1
  471. package/dist/version.js +1 -1
  472. package/package.json +37 -46
  473. package/dist/bundled.d.ts +0 -2
  474. package/dist/bundled.js +0 -8
  475. package/dist/chunks/chunk-2G45NV5W.mjs.map +0 -1
  476. package/dist/chunks/chunk-2MDKOWUQ.mjs +0 -11
  477. package/dist/chunks/chunk-2MDKOWUQ.mjs.map +0 -1
  478. package/dist/chunks/chunk-33QZBPQK.mjs +0 -2
  479. package/dist/chunks/chunk-33QZBPQK.mjs.map +0 -1
  480. package/dist/chunks/chunk-4DR73ZXX.mjs +0 -6
  481. package/dist/chunks/chunk-4DR73ZXX.mjs.map +0 -1
  482. package/dist/chunks/chunk-4XJZCOJ5.mjs +0 -6
  483. package/dist/chunks/chunk-4XJZCOJ5.mjs.map +0 -1
  484. package/dist/chunks/chunk-53XKVPPJ.mjs.map +0 -1
  485. package/dist/chunks/chunk-66W4K2AQ.mjs +0 -6
  486. package/dist/chunks/chunk-66W4K2AQ.mjs.map +0 -1
  487. package/dist/chunks/chunk-7M5U2MEN.mjs +0 -6
  488. package/dist/chunks/chunk-7M5U2MEN.mjs.map +0 -1
  489. package/dist/chunks/chunk-7ZMEJOJJ.mjs +0 -7
  490. package/dist/chunks/chunk-7ZMEJOJJ.mjs.map +0 -1
  491. package/dist/chunks/chunk-AVHUPARR.mjs +0 -3
  492. package/dist/chunks/chunk-AVHUPARR.mjs.map +0 -1
  493. package/dist/chunks/chunk-AWBQHRRG.mjs +0 -2
  494. package/dist/chunks/chunk-AWBQHRRG.mjs.map +0 -1
  495. package/dist/chunks/chunk-B24N3EFY.mjs +0 -2
  496. package/dist/chunks/chunk-B24N3EFY.mjs.map +0 -1
  497. package/dist/chunks/chunk-B3YRDLFF.mjs +0 -2
  498. package/dist/chunks/chunk-B3YRDLFF.mjs.map +0 -1
  499. package/dist/chunks/chunk-BNYOSPTM.mjs +0 -7
  500. package/dist/chunks/chunk-BNYOSPTM.mjs.map +0 -1
  501. package/dist/chunks/chunk-CR7BS4ZT.mjs +0 -2
  502. package/dist/chunks/chunk-CR7BS4ZT.mjs.map +0 -1
  503. package/dist/chunks/chunk-D57VZ7SP.mjs +0 -8
  504. package/dist/chunks/chunk-D57VZ7SP.mjs.map +0 -1
  505. package/dist/chunks/chunk-DAWKCFB3.mjs +0 -3
  506. package/dist/chunks/chunk-DAWKCFB3.mjs.map +0 -1
  507. package/dist/chunks/chunk-DXRKQGX5.mjs +0 -13
  508. package/dist/chunks/chunk-DXRKQGX5.mjs.map +0 -1
  509. package/dist/chunks/chunk-E6QAXEJ5.mjs +0 -8
  510. package/dist/chunks/chunk-E6QAXEJ5.mjs.map +0 -1
  511. package/dist/chunks/chunk-ECJELNAF.mjs +0 -12
  512. package/dist/chunks/chunk-ECJELNAF.mjs.map +0 -1
  513. package/dist/chunks/chunk-F4JMGHZK.mjs +0 -2
  514. package/dist/chunks/chunk-F4JMGHZK.mjs.map +0 -1
  515. package/dist/chunks/chunk-FSPKR3UC.mjs +0 -6
  516. package/dist/chunks/chunk-FSPKR3UC.mjs.map +0 -1
  517. package/dist/chunks/chunk-GAH5QBYB.mjs +0 -6
  518. package/dist/chunks/chunk-GAH5QBYB.mjs.map +0 -1
  519. package/dist/chunks/chunk-GBVNGTXG.mjs +0 -3
  520. package/dist/chunks/chunk-GBVNGTXG.mjs.map +0 -1
  521. package/dist/chunks/chunk-HVBYWS5S.mjs +0 -10
  522. package/dist/chunks/chunk-HVBYWS5S.mjs.map +0 -1
  523. package/dist/chunks/chunk-I22UEOUC.mjs +0 -9
  524. package/dist/chunks/chunk-I22UEOUC.mjs.map +0 -1
  525. package/dist/chunks/chunk-IJ5P4GFV.mjs +0 -2
  526. package/dist/chunks/chunk-IJ5P4GFV.mjs.map +0 -1
  527. package/dist/chunks/chunk-IPLCT667.mjs +0 -2
  528. package/dist/chunks/chunk-IPLCT667.mjs.map +0 -1
  529. package/dist/chunks/chunk-IXOM253I.mjs +0 -7
  530. package/dist/chunks/chunk-IXOM253I.mjs.map +0 -1
  531. package/dist/chunks/chunk-J6NFIU3A.mjs +0 -5
  532. package/dist/chunks/chunk-J6NFIU3A.mjs.map +0 -1
  533. package/dist/chunks/chunk-JDIMSSA6.mjs +0 -6
  534. package/dist/chunks/chunk-JDIMSSA6.mjs.map +0 -1
  535. package/dist/chunks/chunk-JDOD4XCT.mjs +0 -2
  536. package/dist/chunks/chunk-JDOD4XCT.mjs.map +0 -1
  537. package/dist/chunks/chunk-JYMLZQ2B.mjs +0 -8
  538. package/dist/chunks/chunk-JYMLZQ2B.mjs.map +0 -1
  539. package/dist/chunks/chunk-KJT4SRSJ.mjs +0 -25
  540. package/dist/chunks/chunk-KJT4SRSJ.mjs.map +0 -1
  541. package/dist/chunks/chunk-KX2OAC2D.mjs +0 -5
  542. package/dist/chunks/chunk-KX2OAC2D.mjs.map +0 -1
  543. package/dist/chunks/chunk-LQYFD6JY.mjs +0 -10
  544. package/dist/chunks/chunk-LQYFD6JY.mjs.map +0 -1
  545. package/dist/chunks/chunk-LXCHQLNA.mjs +0 -2
  546. package/dist/chunks/chunk-LXCHQLNA.mjs.map +0 -1
  547. package/dist/chunks/chunk-MBJJBXJZ.mjs +0 -16
  548. package/dist/chunks/chunk-MBJJBXJZ.mjs.map +0 -1
  549. package/dist/chunks/chunk-ODVGAOCZ.mjs +0 -4
  550. package/dist/chunks/chunk-ODVGAOCZ.mjs.map +0 -1
  551. package/dist/chunks/chunk-OKDL7PKZ.mjs +0 -7
  552. package/dist/chunks/chunk-OKDL7PKZ.mjs.map +0 -1
  553. package/dist/chunks/chunk-PVRCMZP4.mjs +0 -6
  554. package/dist/chunks/chunk-PVRCMZP4.mjs.map +0 -1
  555. package/dist/chunks/chunk-Q7W6MMRR.mjs +0 -5
  556. package/dist/chunks/chunk-Q7W6MMRR.mjs.map +0 -1
  557. package/dist/chunks/chunk-QYJEIDIR.mjs +0 -6
  558. package/dist/chunks/chunk-QYJEIDIR.mjs.map +0 -1
  559. package/dist/chunks/chunk-SE5N425R.mjs +0 -10
  560. package/dist/chunks/chunk-SE5N425R.mjs.map +0 -1
  561. package/dist/chunks/chunk-SYA7GVFH.mjs +0 -7
  562. package/dist/chunks/chunk-SYA7GVFH.mjs.map +0 -1
  563. package/dist/chunks/chunk-UN4MBN2V.mjs +0 -5
  564. package/dist/chunks/chunk-UN4MBN2V.mjs.map +0 -1
  565. package/dist/chunks/chunk-UWZJI5W3.mjs +0 -7
  566. package/dist/chunks/chunk-UWZJI5W3.mjs.map +0 -1
  567. package/dist/chunks/chunk-V4K3YOUF.mjs +0 -11
  568. package/dist/chunks/chunk-V4K3YOUF.mjs.map +0 -1
  569. package/dist/chunks/chunk-VXHJOKOD.mjs +0 -2
  570. package/dist/chunks/chunk-VXHJOKOD.mjs.map +0 -1
  571. package/dist/chunks/chunk-X5LC6Z6E.mjs +0 -6
  572. package/dist/chunks/chunk-X5LC6Z6E.mjs.map +0 -1
  573. package/dist/chunks/chunk-YKQIHLV5.mjs +0 -2
  574. package/dist/chunks/chunk-YQGIJV4G.mjs +0 -2
  575. package/dist/chunks/chunk-YQGIJV4G.mjs.map +0 -1
  576. package/dist/chunks/chunk-ZOQOZJZV.mjs +0 -2
  577. package/dist/chunks/chunk-ZOQOZJZV.mjs.map +0 -1
  578. package/dist/chunks/chunk-ZPEZXPWQ.mjs +0 -6
  579. package/dist/chunks/chunk-ZPEZXPWQ.mjs.map +0 -1
  580. package/dist/chunks/core-layout-hops-index.mjs +0 -2
  581. package/dist/discovered.d.ts +0 -11
  582. package/dist/discovered.js +0 -3
  583. package/dist/node-scan.d.ts +0 -63
  584. package/dist/node-scan.js +0 -215
  585. package/dist/node.d.ts +0 -24
  586. package/dist/node.js +0 -166
  587. /package/dist/chunks/{core-layout-hops-index.mjs.map → chunk-F2VKDTOW.mjs.map} +0 -0
package/README.md CHANGED
@@ -1,14 +1,14 @@
1
- # mermaid (v13 alpha)
1
+ # mermaid
2
2
 
3
- > [!WARNING]
4
- > This is an **alpha** of Mermaid v13. Don't use it in production. APIs, output and defaults can change between alpha builds, so pin an exact version. `mermaid@latest` is still v12.
3
+ > [!NOTE]
4
+ > `mermaid@latest` is v12. Mermaid v13 is published under the npm tag `v13-beta`, which the commands below use.
5
5
 
6
- Mermaid v13 renders without a browser DOM: in Node, Deno, web workers and browsers. Its output is deterministic, and it has no third-party runtime dependencies. Flowchart is the only diagram type with a v13 renderer so far.
6
+ Mermaid v13 renders without a browser DOM: in Node, Deno, web workers and browsers. Its output is deterministic, and it has no third-party runtime dependencies.
7
7
 
8
8
  ## Everything
9
9
 
10
10
  ```bash
11
- npm install mermaid@v13-alpha --save-exact
11
+ npm install mermaid@v13-beta --save-exact
12
12
  ```
13
13
 
14
14
  ```js
@@ -20,14 +20,14 @@ 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). It has two limits, both gzipped: one for core, which is everything the `mermaid` entry loads before any diagram chunk, and one for core plus flowchart, as loaded for one flowchart render.
24
24
 
25
25
  ## Pick your diagrams
26
26
 
27
- `mermaid/slim` is the same API without the first-party diagrams. Only the diagrams you pass in are bundled. Each package has its own version. The newest `mermaid@v13-alpha` depends on the newest `@v13-alpha` of each diagram package, so install them together:
27
+ `mermaid/slim` is the same API without the first-party diagrams. Only the diagrams you pass in are bundled. Each package has its own version. The newest `mermaid@v13-beta` depends on the newest `@v13-beta` of each diagram package, so install them together:
28
28
 
29
29
  ```bash
30
- npm install mermaid@v13-alpha @mermaid-js/diagram-flowchart@v13-alpha --save-exact
30
+ npm install mermaid@v13-beta @mermaid-js/diagram-flowchart@v13-beta --save-exact
31
31
  ```
32
32
 
33
33
  ```js
@@ -40,14 +40,31 @@ const mermaid = createMermaid({ diagrams: [{ ...flowchart, ascii }] });
40
40
  const { svg } = await mermaid.render('id', 'flowchart LR\n A --> B');
41
41
  ```
42
42
 
43
- 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.
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
+
60
+ A diagram type that you did not pass in is still detected, and rendering it rejects 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
46
63
 
47
64
  ```bash
48
- npx mermaid@v13-alpha render diagram.mmd --format ascii
65
+ npx mermaid@v13-beta render diagram.mmd --format ascii
49
66
  ```
50
67
 
51
68
  ## Feedback
52
69
 
53
- [Open an issue](https://github.com/mermaid-js/mermaid/issues/new/choose) with **v13** in the title, the exact alpha build (`npm ls mermaid`) and the diagram source.
70
+ [Open an issue](https://github.com/mermaid-js/mermaid/issues/new/choose) with **v13** in the title, the exact version (`npm ls mermaid`) and the diagram source.
@@ -1,132 +1,6 @@
1
1
  Third-party notices for mermaid
2
2
  ===============================
3
3
 
4
- Pele
5
- ----
6
-
7
- The files below are ported from, or based on, Pele (https://github.com/obsidianmd/pele) at
8
- commit 3a2f075 (release 1.13.0). Each file's header says what it took and what changed. Pele is
9
- used under the MIT License:
10
-
11
- src/measurer.ts
12
-
13
- MIT License
14
-
15
- Copyright (c) 2026 kepano
16
-
17
- Permission is hereby granted, free of charge, to any person obtaining a copy
18
- of this software and associated documentation files (the "Software"), to deal
19
- in the Software without restriction, including without limitation the rights
20
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
21
- copies of the Software, and to permit persons to whom the Software is
22
- furnished to do so, subject to the following conditions:
23
-
24
- The above copyright notice and this permission notice shall be included in all
25
- copies or substantial portions of the Software.
26
-
27
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
28
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
29
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
30
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
31
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
32
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33
- SOFTWARE.
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, parser/base.ts, parser/statements.ts,
40
- parser/model.ts, layout/prepare.ts, layout/shapes.ts, render/shapes.ts and render/edges.ts are
41
- local copies of @mermaid-js/diagram-flowchart's lexer, parser, builder, shapes and edges (D446,
42
- D467), which are ported from, or based on, Pele (https://github.com/obsidianmd/pele) at commit
43
- 3a2f075 (release 1.13.0). Pele is used under the MIT License:
44
-
45
- MIT License
46
-
47
- Copyright (c) 2026 kepano
48
-
49
- Permission is hereby granted, free of charge, to any person obtaining a copy
50
- of this software and associated documentation files (the "Software"), to deal
51
- in the Software without restriction, including without limitation the rights
52
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
53
- copies of the Software, and to permit persons to whom the Software is
54
- furnished to do so, subject to the following conditions:
55
-
56
- The above copyright notice and this permission notice shall be included in all
57
- copies or substantial portions of the Software.
58
-
59
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
60
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
61
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
62
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
63
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
64
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
65
- SOFTWARE.
66
-
67
- Pele, in @mermaid-js/diagram-block
68
- ----------------------------------
69
-
70
- The CDN build also bundles @mermaid-js/diagram-block without its legal comments. That
71
- package's shapes/leaf.ts, shapes/draw.ts and render/arrowheads.ts are local copies of
72
- @mermaid-js/diagram-flowchart's shapes and arrowheads (D446), which are ported from, or based
73
- on, Pele (https://github.com/obsidianmd/pele) at commit 3a2f075 (release 1.13.0). Pele is used
74
- under the MIT License:
75
-
76
- MIT License
77
-
78
- Copyright (c) 2026 kepano
79
-
80
- Permission is hereby granted, free of charge, to any person obtaining a copy
81
- of this software and associated documentation files (the "Software"), to deal
82
- in the Software without restriction, including without limitation the rights
83
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
84
- copies of the Software, and to permit persons to whom the Software is
85
- furnished to do so, subject to the following conditions:
86
-
87
- The above copyright notice and this permission notice shall be included in all
88
- copies or substantial portions of the Software.
89
-
90
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
91
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
92
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
93
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
94
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
95
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
96
- SOFTWARE.
97
-
98
- Pele, in @mermaid-js/diagram-c4
99
- -------------------------------
100
-
101
- The CDN build also bundles @mermaid-js/diagram-c4 without its legal comments. That package's
102
- layout/grid.ts, layout/layout.ts, layout/metrics.ts, layout/path.ts, layout/route.ts and
103
- layout/shapes.ts are ported from Pele's C4 grid, relation router and label placement, and its
104
- render/shapes.ts is a local copy of @mermaid-js/diagram-flowchart's shapes (D446), all ported
105
- from, or based on, Pele (https://github.com/obsidianmd/pele) at commit 3a2f075 (release
106
- 1.13.0). Pele is used under the MIT License:
107
-
108
- MIT License
109
-
110
- Copyright (c) 2026 kepano
111
-
112
- Permission is hereby granted, free of charge, to any person obtaining a copy
113
- of this software and associated documentation files (the "Software"), to deal
114
- in the Software without restriction, including without limitation the rights
115
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
116
- copies of the Software, and to permit persons to whom the Software is
117
- furnished to do so, subject to the following conditions:
118
-
119
- The above copyright notice and this permission notice shall be included in all
120
- copies or substantial portions of the Software.
121
-
122
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
123
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
124
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
125
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
126
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
127
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
128
- SOFTWARE.
129
-
130
4
  d3-sankey
131
5
  ---------
132
6
 
@@ -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 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,54 @@
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
+ // A new map, not `Map#clear()`: V8 leaves a cleared map's old table pointing at its new one,
50
+ // so once the GC has promoted one table, every later table and the analyses in it survive
51
+ // each scavenge until a full GC. Only these methods read `entries`, so none holds the old map.
52
+ this.entries = new Map();
53
+ }
54
+ }