@temelj/mdx 0.14.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (373) hide show
  1. package/README.md +468 -82
  2. package/dist/character-entities.d.mts +4 -0
  3. package/dist/character-entities.d.mts.map +1 -0
  4. package/dist/character-entities.mjs +2132 -0
  5. package/dist/character-entities.mjs.map +1 -0
  6. package/dist/character-reference.d.mts +6 -0
  7. package/dist/character-reference.d.mts.map +1 -0
  8. package/dist/character-reference.mjs +18 -0
  9. package/dist/character-reference.mjs.map +1 -0
  10. package/dist/compile-analysis.d.mts +28 -0
  11. package/dist/compile-analysis.d.mts.map +1 -0
  12. package/dist/compile-analysis.mjs +74 -0
  13. package/dist/compile-analysis.mjs.map +1 -0
  14. package/dist/compile-emit.d.mts +9 -0
  15. package/dist/compile-emit.d.mts.map +1 -0
  16. package/dist/compile-emit.mjs +187 -0
  17. package/dist/compile-emit.mjs.map +1 -0
  18. package/dist/compile-esm.d.mts +34 -0
  19. package/dist/compile-esm.d.mts.map +1 -0
  20. package/dist/compile-esm.mjs +187 -0
  21. package/dist/compile-esm.mjs.map +1 -0
  22. package/dist/compile-names.d.mts +13 -0
  23. package/dist/compile-names.d.mts.map +1 -0
  24. package/dist/compile-names.mjs +32 -0
  25. package/dist/compile-names.mjs.map +1 -0
  26. package/dist/compiler.d.mts +69 -85
  27. package/dist/compiler.d.mts.map +1 -1
  28. package/dist/compiler.mjs +185 -418
  29. package/dist/compiler.mjs.map +1 -1
  30. package/dist/diagnostics.d.mts +37 -0
  31. package/dist/diagnostics.d.mts.map +1 -0
  32. package/dist/diagnostics.mjs +57 -0
  33. package/dist/diagnostics.mjs.map +1 -0
  34. package/dist/errors.d.mts +157 -0
  35. package/dist/errors.d.mts.map +1 -0
  36. package/dist/errors.mjs +263 -0
  37. package/dist/errors.mjs.map +1 -0
  38. package/dist/footnote-numbering.d.mts +27 -0
  39. package/dist/footnote-numbering.d.mts.map +1 -0
  40. package/dist/footnote-numbering.mjs +49 -0
  41. package/dist/footnote-numbering.mjs.map +1 -0
  42. package/dist/format-context.d.mts +46 -0
  43. package/dist/format-context.d.mts.map +1 -0
  44. package/dist/format-context.mjs +26 -0
  45. package/dist/format-context.mjs.map +1 -0
  46. package/dist/format-directive.d.mts +9 -0
  47. package/dist/format-directive.d.mts.map +1 -0
  48. package/dist/format-directive.mjs +99 -0
  49. package/dist/format-directive.mjs.map +1 -0
  50. package/dist/format-jsx.d.mts +8 -0
  51. package/dist/format-jsx.d.mts.map +1 -0
  52. package/dist/format-jsx.mjs +47 -0
  53. package/dist/format-jsx.mjs.map +1 -0
  54. package/dist/format-math.d.mts +9 -0
  55. package/dist/format-math.d.mts.map +1 -0
  56. package/dist/format-math.mjs +79 -0
  57. package/dist/format-math.mjs.map +1 -0
  58. package/dist/format-safe.d.mts +25 -0
  59. package/dist/format-safe.d.mts.map +1 -0
  60. package/dist/format-safe.mjs +366 -0
  61. package/dist/format-safe.mjs.map +1 -0
  62. package/dist/format-table.d.mts +8 -0
  63. package/dist/format-table.d.mts.map +1 -0
  64. package/dist/format-table.mjs +55 -0
  65. package/dist/format-table.mjs.map +1 -0
  66. package/dist/format-track.d.mts +18 -0
  67. package/dist/format-track.d.mts.map +1 -0
  68. package/dist/format-track.mjs +34 -0
  69. package/dist/format-track.mjs.map +1 -0
  70. package/dist/format.d.mts +7 -0
  71. package/dist/format.d.mts.map +1 -0
  72. package/dist/format.mjs +549 -0
  73. package/dist/format.mjs.map +1 -0
  74. package/dist/frontmatter.d.mts +15 -0
  75. package/dist/frontmatter.d.mts.map +1 -0
  76. package/dist/frontmatter.mjs +187 -0
  77. package/dist/frontmatter.mjs.map +1 -0
  78. package/dist/heading.d.mts +6 -0
  79. package/dist/heading.d.mts.map +1 -0
  80. package/dist/heading.mjs +19 -0
  81. package/dist/heading.mjs.map +1 -0
  82. package/dist/html-format.d.mts +32 -0
  83. package/dist/html-format.d.mts.map +1 -0
  84. package/dist/html-format.mjs +127 -0
  85. package/dist/html-format.mjs.map +1 -0
  86. package/dist/html-lower.d.mts +78 -0
  87. package/dist/html-lower.d.mts.map +1 -0
  88. package/dist/html-lower.mjs +583 -0
  89. package/dist/html-lower.mjs.map +1 -0
  90. package/dist/html-stream.d.mts +13 -0
  91. package/dist/html-stream.d.mts.map +1 -0
  92. package/dist/html-stream.mjs +32 -0
  93. package/dist/html-stream.mjs.map +1 -0
  94. package/dist/html.d.mts +120 -0
  95. package/dist/html.d.mts.map +1 -0
  96. package/dist/html.mjs +77 -0
  97. package/dist/html.mjs.map +1 -0
  98. package/dist/identifier.d.mts +4 -0
  99. package/dist/identifier.d.mts.map +1 -0
  100. package/dist/identifier.mjs +8 -0
  101. package/dist/identifier.mjs.map +1 -0
  102. package/dist/javascript-ast.d.mts +16 -0
  103. package/dist/javascript-ast.d.mts.map +1 -0
  104. package/dist/javascript-ast.mjs +39 -0
  105. package/dist/javascript-ast.mjs.map +1 -0
  106. package/dist/javascript-jsx.d.mts +24 -0
  107. package/dist/javascript-jsx.d.mts.map +1 -0
  108. package/dist/javascript-jsx.mjs +189 -0
  109. package/dist/javascript-jsx.mjs.map +1 -0
  110. package/dist/javascript.d.mts +9 -0
  111. package/dist/javascript.d.mts.map +1 -0
  112. package/dist/javascript.mjs +31 -0
  113. package/dist/javascript.mjs.map +1 -0
  114. package/dist/jsx-reference.d.mts +15 -0
  115. package/dist/jsx-reference.d.mts.map +1 -0
  116. package/dist/jsx-reference.mjs +31 -0
  117. package/dist/jsx-reference.mjs.map +1 -0
  118. package/dist/mod.d.mts +25 -9
  119. package/dist/mod.mjs +19 -8
  120. package/dist/model.d.mts +196 -0
  121. package/dist/model.d.mts.map +1 -0
  122. package/dist/model.mjs +113 -0
  123. package/dist/model.mjs.map +1 -0
  124. package/dist/parser/block-container-recognizers.d.mts +40 -0
  125. package/dist/parser/block-container-recognizers.d.mts.map +1 -0
  126. package/dist/parser/block-container-recognizers.mjs +90 -0
  127. package/dist/parser/block-container-recognizers.mjs.map +1 -0
  128. package/dist/parser/block-directive-recognizers.d.mts +22 -0
  129. package/dist/parser/block-directive-recognizers.d.mts.map +1 -0
  130. package/dist/parser/block-directive-recognizers.mjs +77 -0
  131. package/dist/parser/block-directive-recognizers.mjs.map +1 -0
  132. package/dist/parser/block-leaf-recognizers.d.mts +53 -0
  133. package/dist/parser/block-leaf-recognizers.d.mts.map +1 -0
  134. package/dist/parser/block-leaf-recognizers.mjs +386 -0
  135. package/dist/parser/block-leaf-recognizers.mjs.map +1 -0
  136. package/dist/parser/block-parser.d.mts +38 -0
  137. package/dist/parser/block-parser.d.mts.map +1 -0
  138. package/dist/parser/block-parser.mjs +895 -0
  139. package/dist/parser/block-parser.mjs.map +1 -0
  140. package/dist/parser/block-syntax.d.mts +240 -0
  141. package/dist/parser/block-syntax.d.mts.map +1 -0
  142. package/dist/parser/characters.d.mts +19 -0
  143. package/dist/parser/characters.d.mts.map +1 -0
  144. package/dist/parser/characters.mjs +52 -0
  145. package/dist/parser/characters.mjs.map +1 -0
  146. package/dist/parser/config.d.mts +16 -0
  147. package/dist/parser/config.d.mts.map +1 -0
  148. package/dist/parser/config.mjs +25 -0
  149. package/dist/parser/config.mjs.map +1 -0
  150. package/dist/parser/directive-attributes.d.mts +9 -0
  151. package/dist/parser/directive-attributes.d.mts.map +1 -0
  152. package/dist/parser/directive-attributes.mjs +24 -0
  153. package/dist/parser/directive-attributes.mjs.map +1 -0
  154. package/dist/parser/embedded-scanner.d.mts +18 -0
  155. package/dist/parser/embedded-scanner.d.mts.map +1 -0
  156. package/dist/parser/embedded-scanner.mjs +199 -0
  157. package/dist/parser/embedded-scanner.mjs.map +1 -0
  158. package/dist/parser/inline-autolink.d.mts +7 -0
  159. package/dist/parser/inline-autolink.d.mts.map +1 -0
  160. package/dist/parser/inline-autolink.mjs +42 -0
  161. package/dist/parser/inline-autolink.mjs.map +1 -0
  162. package/dist/parser/inline-character-reference.d.mts +7 -0
  163. package/dist/parser/inline-character-reference.d.mts.map +1 -0
  164. package/dist/parser/inline-character-reference.mjs +22 -0
  165. package/dist/parser/inline-character-reference.mjs.map +1 -0
  166. package/dist/parser/inline-code.d.mts +7 -0
  167. package/dist/parser/inline-code.d.mts.map +1 -0
  168. package/dist/parser/inline-code.mjs +29 -0
  169. package/dist/parser/inline-code.mjs.map +1 -0
  170. package/dist/parser/inline-directive.d.mts +9 -0
  171. package/dist/parser/inline-directive.d.mts.map +1 -0
  172. package/dist/parser/inline-directive.mjs +45 -0
  173. package/dist/parser/inline-directive.mjs.map +1 -0
  174. package/dist/parser/inline-embedded.d.mts +19 -0
  175. package/dist/parser/inline-embedded.d.mts.map +1 -0
  176. package/dist/parser/inline-embedded.mjs +92 -0
  177. package/dist/parser/inline-embedded.mjs.map +1 -0
  178. package/dist/parser/inline-emphasis.d.mts +11 -0
  179. package/dist/parser/inline-emphasis.d.mts.map +1 -0
  180. package/dist/parser/inline-emphasis.mjs +79 -0
  181. package/dist/parser/inline-emphasis.mjs.map +1 -0
  182. package/dist/parser/inline-input.d.mts +46 -0
  183. package/dist/parser/inline-input.d.mts.map +1 -0
  184. package/dist/parser/inline-input.mjs +137 -0
  185. package/dist/parser/inline-input.mjs.map +1 -0
  186. package/dist/parser/inline-link.d.mts +12 -0
  187. package/dist/parser/inline-link.d.mts.map +1 -0
  188. package/dist/parser/inline-link.mjs +187 -0
  189. package/dist/parser/inline-link.mjs.map +1 -0
  190. package/dist/parser/inline-math.d.mts +10 -0
  191. package/dist/parser/inline-math.d.mts.map +1 -0
  192. package/dist/parser/inline-math.mjs +46 -0
  193. package/dist/parser/inline-math.mjs.map +1 -0
  194. package/dist/parser/inline-output.d.mts +34 -0
  195. package/dist/parser/inline-output.d.mts.map +1 -0
  196. package/dist/parser/inline-output.mjs +62 -0
  197. package/dist/parser/inline-output.mjs.map +1 -0
  198. package/dist/parser/inline-parser.d.mts +14 -0
  199. package/dist/parser/inline-parser.d.mts.map +1 -0
  200. package/dist/parser/inline-parser.mjs +328 -0
  201. package/dist/parser/inline-parser.mjs.map +1 -0
  202. package/dist/parser/inline-pending.d.mts +23 -0
  203. package/dist/parser/inline-pending.d.mts.map +1 -0
  204. package/dist/parser/inline-pending.mjs +100 -0
  205. package/dist/parser/inline-pending.mjs.map +1 -0
  206. package/dist/parser/inline-syntax.d.mts +118 -0
  207. package/dist/parser/inline-syntax.d.mts.map +1 -0
  208. package/dist/parser/inline-syntax.mjs +1 -0
  209. package/dist/parser/javascript-boundary.d.mts +16 -0
  210. package/dist/parser/javascript-boundary.d.mts.map +1 -0
  211. package/dist/parser/javascript-boundary.mjs +42 -0
  212. package/dist/parser/javascript-boundary.mjs.map +1 -0
  213. package/dist/parser/javascript-scanner.d.mts +22 -0
  214. package/dist/parser/javascript-scanner.d.mts.map +1 -0
  215. package/dist/parser/javascript-scanner.mjs +122 -0
  216. package/dist/parser/javascript-scanner.mjs.map +1 -0
  217. package/dist/parser/materialize-cache.d.mts +34 -0
  218. package/dist/parser/materialize-cache.d.mts.map +1 -0
  219. package/dist/parser/materialize-cache.mjs +12 -0
  220. package/dist/parser/materialize-cache.mjs.map +1 -0
  221. package/dist/parser/materialize-jsx.d.mts +14 -0
  222. package/dist/parser/materialize-jsx.d.mts.map +1 -0
  223. package/dist/parser/materialize-jsx.mjs +76 -0
  224. package/dist/parser/materialize-jsx.mjs.map +1 -0
  225. package/dist/parser/materialize.d.mts +61 -0
  226. package/dist/parser/materialize.d.mts.map +1 -0
  227. package/dist/parser/materialize.mjs +736 -0
  228. package/dist/parser/materialize.mjs.map +1 -0
  229. package/dist/parser/recognizer.d.mts +20 -0
  230. package/dist/parser/recognizer.d.mts.map +1 -0
  231. package/dist/parser/recognizer.mjs +24 -0
  232. package/dist/parser/recognizer.mjs.map +1 -0
  233. package/dist/parser/session.d.mts +42 -0
  234. package/dist/parser/session.d.mts.map +1 -0
  235. package/dist/parser/session.mjs +89 -0
  236. package/dist/parser/session.mjs.map +1 -0
  237. package/dist/parser.d.mts +25 -0
  238. package/dist/parser.d.mts.map +1 -0
  239. package/dist/parser.mjs +37 -0
  240. package/dist/parser.mjs.map +1 -0
  241. package/dist/plugin-internal.d.mts +25 -0
  242. package/dist/plugin-internal.d.mts.map +1 -0
  243. package/dist/plugin-internal.mjs +99 -0
  244. package/dist/plugin-internal.mjs.map +1 -0
  245. package/dist/plugin.d.mts +37 -0
  246. package/dist/plugin.d.mts.map +1 -0
  247. package/dist/plugin.mjs +1 -0
  248. package/dist/plugins/code-block-metadata.d.mts +42 -0
  249. package/dist/plugins/code-block-metadata.d.mts.map +1 -0
  250. package/dist/plugins/code-block-metadata.mjs +133 -0
  251. package/dist/plugins/code-block-metadata.mjs.map +1 -0
  252. package/dist/plugins/heading-id.d.mts +15 -0
  253. package/dist/plugins/heading-id.d.mts.map +1 -0
  254. package/dist/plugins/heading-id.mjs +45 -0
  255. package/dist/plugins/heading-id.mjs.map +1 -0
  256. package/dist/plugins/lower-heading.d.mts +16 -0
  257. package/dist/plugins/lower-heading.d.mts.map +1 -0
  258. package/dist/plugins/lower-heading.mjs +28 -0
  259. package/dist/plugins/lower-heading.mjs.map +1 -0
  260. package/dist/plugins/math-render.d.mts +26 -0
  261. package/dist/plugins/math-render.d.mts.map +1 -0
  262. package/dist/plugins/math-render.mjs +51 -0
  263. package/dist/plugins/math-render.mjs.map +1 -0
  264. package/dist/plugins/mod.d.mts +9 -6
  265. package/dist/plugins/mod.mjs +8 -6
  266. package/dist/plugins/remove-esm.d.mts +10 -0
  267. package/dist/plugins/remove-esm.d.mts.map +1 -0
  268. package/dist/plugins/remove-esm.mjs +12 -0
  269. package/dist/plugins/remove-esm.mjs.map +1 -0
  270. package/dist/plugins/shiki.d.mts +21 -0
  271. package/dist/plugins/shiki.d.mts.map +1 -0
  272. package/dist/plugins/shiki.mjs +144 -0
  273. package/dist/plugins/shiki.mjs.map +1 -0
  274. package/dist/plugins/syntax-highlight.d.mts +38 -0
  275. package/dist/plugins/syntax-highlight.d.mts.map +1 -0
  276. package/dist/plugins/syntax-highlight.mjs +106 -0
  277. package/dist/plugins/syntax-highlight.mjs.map +1 -0
  278. package/dist/processor.d.mts +60 -0
  279. package/dist/processor.d.mts.map +1 -0
  280. package/dist/processor.mjs +106 -0
  281. package/dist/processor.mjs.map +1 -0
  282. package/dist/ranges.d.mts +10 -0
  283. package/dist/ranges.d.mts.map +1 -0
  284. package/dist/ranges.mjs +22 -0
  285. package/dist/ranges.mjs.map +1 -0
  286. package/dist/source-map.d.mts +28 -0
  287. package/dist/source-map.d.mts.map +1 -0
  288. package/dist/source-map.mjs +90 -0
  289. package/dist/source-map.mjs.map +1 -0
  290. package/dist/source-text.d.mts +35 -0
  291. package/dist/source-text.d.mts.map +1 -0
  292. package/dist/source-text.mjs +132 -0
  293. package/dist/source-text.mjs.map +1 -0
  294. package/dist/source.d.mts +86 -0
  295. package/dist/source.d.mts.map +1 -0
  296. package/dist/source.mjs +264 -0
  297. package/dist/source.mjs.map +1 -0
  298. package/dist/stream-events.d.mts +59 -0
  299. package/dist/stream-events.d.mts.map +1 -0
  300. package/dist/stream-events.mjs +115 -0
  301. package/dist/stream-events.mjs.map +1 -0
  302. package/dist/stream-session.d.mts +79 -0
  303. package/dist/stream-session.d.mts.map +1 -0
  304. package/dist/stream-session.mjs +904 -0
  305. package/dist/stream-session.mjs.map +1 -0
  306. package/dist/stream-tail.d.mts +84 -0
  307. package/dist/stream-tail.d.mts.map +1 -0
  308. package/dist/stream-tail.mjs +359 -0
  309. package/dist/stream-tail.mjs.map +1 -0
  310. package/dist/stream-types.d.mts +89 -0
  311. package/dist/stream-types.d.mts.map +1 -0
  312. package/dist/stream-types.mjs +1 -0
  313. package/dist/stream.d.mts +28 -0
  314. package/dist/stream.d.mts.map +1 -0
  315. package/dist/stream.mjs +68 -0
  316. package/dist/stream.mjs.map +1 -0
  317. package/dist/syntax-options.d.mts +21 -0
  318. package/dist/syntax-options.d.mts.map +1 -0
  319. package/dist/syntax-options.mjs +26 -0
  320. package/dist/syntax-options.mjs.map +1 -0
  321. package/dist/traversal.d.mts +25 -0
  322. package/dist/traversal.d.mts.map +1 -0
  323. package/dist/traversal.mjs +136 -0
  324. package/dist/traversal.mjs.map +1 -0
  325. package/dist/tree.d.mts +18 -0
  326. package/dist/tree.d.mts.map +1 -0
  327. package/dist/tree.mjs +43 -0
  328. package/dist/tree.mjs.map +1 -0
  329. package/dist/unified/adapter.d.mts +24 -0
  330. package/dist/unified/adapter.d.mts.map +1 -0
  331. package/dist/unified/adapter.mjs +44 -0
  332. package/dist/unified/adapter.mjs.map +1 -0
  333. package/dist/unified/mod.d.mts +2 -0
  334. package/dist/unified/mod.mjs +1 -0
  335. package/dist/unified/runtime.d.mts +10 -0
  336. package/dist/unified/runtime.d.mts.map +1 -0
  337. package/dist/unified/runtime.mjs +115 -0
  338. package/dist/unified/runtime.mjs.map +1 -0
  339. package/dist/unified/tree-bridge.d.mts +63 -0
  340. package/dist/unified/tree-bridge.d.mts.map +1 -0
  341. package/dist/unified/tree-bridge.mjs +876 -0
  342. package/dist/unified/tree-bridge.mjs.map +1 -0
  343. package/dist/uri.d.mts +5 -0
  344. package/dist/uri.d.mts.map +1 -0
  345. package/dist/uri.mjs +32 -0
  346. package/dist/uri.mjs.map +1 -0
  347. package/package.json +56 -30
  348. package/dist/plugins/heading-id/plugin.d.mts +0 -17
  349. package/dist/plugins/heading-id/plugin.d.mts.map +0 -1
  350. package/dist/plugins/heading-id/plugin.mjs +0 -23
  351. package/dist/plugins/heading-id/plugin.mjs.map +0 -1
  352. package/dist/plugins/katex/plugin.d.mts +0 -39
  353. package/dist/plugins/katex/plugin.d.mts.map +0 -1
  354. package/dist/plugins/katex/plugin.mjs +0 -107
  355. package/dist/plugins/katex/plugin.mjs.map +0 -1
  356. package/dist/plugins/remove-imports-exports.d.mts +0 -10
  357. package/dist/plugins/remove-imports-exports.d.mts.map +0 -1
  358. package/dist/plugins/remove-imports-exports.mjs +0 -15
  359. package/dist/plugins/remove-imports-exports.mjs.map +0 -1
  360. package/dist/plugins/syntax-highlight/code-meta.d.mts +0 -22
  361. package/dist/plugins/syntax-highlight/code-meta.d.mts.map +0 -1
  362. package/dist/plugins/syntax-highlight/code-meta.mjs +0 -38
  363. package/dist/plugins/syntax-highlight/code-meta.mjs.map +0 -1
  364. package/dist/plugins/syntax-highlight/plugin.d.mts +0 -57
  365. package/dist/plugins/syntax-highlight/plugin.d.mts.map +0 -1
  366. package/dist/plugins/syntax-highlight/plugin.mjs +0 -93
  367. package/dist/plugins/syntax-highlight/plugin.mjs.map +0 -1
  368. package/dist/plugins/tree-processor/plugin.d.mts +0 -19
  369. package/dist/plugins/tree-processor/plugin.d.mts.map +0 -1
  370. package/dist/plugins/tree-processor/plugin.mjs +0 -21
  371. package/dist/plugins/tree-processor/plugin.mjs.map +0 -1
  372. package/dist/types.d.mts +0 -2
  373. /package/dist/{types.mjs → parser/block-syntax.mjs} +0 -0
@@ -0,0 +1,263 @@
1
+ import { createDiagnostic } from "./diagnostics.mjs";
2
+ //#region src/errors.ts
3
+ var MdxError = class extends Error {
4
+ constructor(name, message, options = {}, context) {
5
+ super(message, options);
6
+ this.name = name;
7
+ if (Error.captureStackTrace !== void 0) Error.captureStackTrace(this, context ?? this.constructor);
8
+ }
9
+ };
10
+ var InputError = class InputError extends MdxError {
11
+ issue;
12
+ constructor(message, issue, context) {
13
+ super("InputError", message, {}, context);
14
+ this.issue = Object.freeze(issue);
15
+ }
16
+ static mathDelimiterCollision(nodeKind, delimiter) {
17
+ return new InputError(`Cannot format ${nodeKind} as TeX because its value contains ${JSON.stringify(delimiter)}`, {
18
+ kind: "mathDelimiterCollision",
19
+ format: "tex",
20
+ nodeKind,
21
+ delimiter
22
+ }, InputError.mathDelimiterCollision);
23
+ }
24
+ static mathMetadataUnsupported() {
25
+ return new InputError("TeX display math does not support fence metadata", {
26
+ kind: "mathMetadata",
27
+ format: "tex"
28
+ }, InputError.mathMetadataUnsupported);
29
+ }
30
+ static invalidHtmlTagName(name) {
31
+ return new InputError(`Invalid HTML tag name: ${name}`, {
32
+ kind: "htmlTagName",
33
+ name
34
+ }, InputError.invalidHtmlTagName);
35
+ }
36
+ static replacementRangeOutsideSource(start, end, sourceLength) {
37
+ return new InputError(`Replacement range ${start}..${end} is outside source of length ${sourceLength}`, {
38
+ kind: "replacementRange",
39
+ start,
40
+ end,
41
+ sourceLength
42
+ }, InputError.replacementRangeOutsideSource);
43
+ }
44
+ static sourceOffsetOutsideFile(offset, sourceLength) {
45
+ return new InputError(`Source offset ${offset} is outside file of length ${sourceLength}`, {
46
+ kind: "sourceOffset",
47
+ offset,
48
+ sourceLength
49
+ }, InputError.sourceOffsetOutsideFile);
50
+ }
51
+ static streamCompleted() {
52
+ return new InputError("A successfully completed MdxStream cannot be changed", { kind: "streamCompleted" }, InputError.streamCompleted);
53
+ }
54
+ };
55
+ var ConfigurationError = class ConfigurationError extends MdxError {
56
+ issue;
57
+ constructor(message, issue, context) {
58
+ super("ConfigurationError", message, {}, context);
59
+ this.issue = Object.freeze(issue);
60
+ }
61
+ static asynchronousPluginInSynchronousProcessor() {
62
+ return new ConfigurationError("processSync() cannot run an asynchronous plugin; use process() instead", { kind: "asynchronousPluginInSynchronousProcessor" }, ConfigurationError.asynchronousPluginInSynchronousProcessor);
63
+ }
64
+ static unsupportedUnifiedPlugin() {
65
+ return new ConfigurationError("Unified parser and compiler plugins are not supported by the transform adapter", { kind: "unifiedPlugin" }, ConfigurationError.unsupportedUnifiedPlugin);
66
+ }
67
+ static invalidCacheCapacity(pluginName, capacity) {
68
+ return new ConfigurationError(`Invalid ${pluginName} cache capacity: ${capacity}; expected a non-negative safe integer`, {
69
+ kind: "cacheCapacity",
70
+ pluginName,
71
+ capacity
72
+ }, ConfigurationError.invalidCacheCapacity);
73
+ }
74
+ static invalidCompilerLimit(option, value) {
75
+ return new ConfigurationError(`Invalid compiler ${option}: ${value}; expected a non-negative safe integer`, {
76
+ kind: "compilerLimit",
77
+ option,
78
+ value
79
+ }, ConfigurationError.invalidCompilerLimit);
80
+ }
81
+ static invalidStreamLimit(option, value, minimum) {
82
+ return new ConfigurationError(`Invalid stream ${option}: ${value}; expected a safe integer of at least ${minimum}`, {
83
+ kind: "streamLimit",
84
+ option,
85
+ value,
86
+ minimum
87
+ }, ConfigurationError.invalidStreamLimit);
88
+ }
89
+ static invalidParserLimit(option, value, minimum) {
90
+ return new ConfigurationError(`Invalid parser ${option}: ${value}; expected a safe integer of at least ${minimum}`, {
91
+ kind: "parserLimit",
92
+ option,
93
+ value,
94
+ minimum
95
+ }, ConfigurationError.invalidParserLimit);
96
+ }
97
+ static invalidPluginIntegerOption(pluginName, option, value, minimum) {
98
+ return new ConfigurationError(`Invalid ${pluginName} ${option}: ${value}; expected a safe integer of at least ${minimum}`, {
99
+ kind: "pluginIntegerOption",
100
+ pluginName,
101
+ option,
102
+ value,
103
+ minimum
104
+ }, ConfigurationError.invalidPluginIntegerOption);
105
+ }
106
+ };
107
+ var TransformError = class TransformError extends MdxError {
108
+ issue;
109
+ file;
110
+ diagnostics;
111
+ constructor(issue, file, diagnostics, options, context) {
112
+ super("TransformError", `Plugin "${issue.pluginName}" failed while transforming ${issue.target}`, options, context);
113
+ this.issue = Object.freeze(issue);
114
+ this.file = file;
115
+ this.diagnostics = Object.freeze([...diagnostics]);
116
+ }
117
+ static pluginTransformFailed(target, pluginName, file, diagnostics, cause) {
118
+ return new TransformError({
119
+ kind: "threw",
120
+ target,
121
+ pluginName
122
+ }, file, diagnostics, { cause }, TransformError.pluginTransformFailed);
123
+ }
124
+ static pluginReportedErrors(target, pluginName, file, diagnostics) {
125
+ return new TransformError({
126
+ kind: "reported",
127
+ target,
128
+ pluginName
129
+ }, file, diagnostics, {}, TransformError.pluginReportedErrors);
130
+ }
131
+ };
132
+ var CompileError = class CompileError extends MdxError {
133
+ issue;
134
+ constructor(message, issue, options, context) {
135
+ super("CompileError", message, options, context);
136
+ this.issue = Object.freeze(issue);
137
+ }
138
+ static generationFailed(cause) {
139
+ return new CompileError("MDX compilation failed", { kind: "generation" }, { cause }, CompileError.generationFailed);
140
+ }
141
+ static multipleDefaultExports() {
142
+ return CompileError.invalidDocument("multipleDefaultExports", "MDX has more than one default export", void 0, CompileError.multipleDefaultExports);
143
+ }
144
+ static defaultExportBindingMissing() {
145
+ return CompileError.invalidDocument("defaultExportBindingMissing", "Default MDX export has no local binding", void 0, CompileError.defaultExportBindingMissing);
146
+ }
147
+ static jsxElementOpeningMissing() {
148
+ return CompileError.invalidDocument("jsxElementOpeningMissing", "JSX element has no opening element", void 0, CompileError.jsxElementOpeningMissing);
149
+ }
150
+ static jsxElementNameMissing() {
151
+ return CompileError.invalidDocument("jsxElementNameMissing", "JSX element has no name", void 0, CompileError.jsxElementNameMissing);
152
+ }
153
+ static jsxSpreadArgumentMissing() {
154
+ return CompileError.invalidDocument("jsxSpreadArgumentMissing", "JSX spread has no argument", void 0, CompileError.jsxSpreadArgumentMissing);
155
+ }
156
+ static jsxAttributeNameMissing() {
157
+ return CompileError.invalidDocument("jsxAttributeNameMissing", "JSX attribute has no name", void 0, CompileError.jsxAttributeNameMissing);
158
+ }
159
+ static jsxAttributeExpressionEmpty() {
160
+ return CompileError.invalidDocument("jsxAttributeExpressionEmpty", "JSX attribute expression is empty", void 0, CompileError.jsxAttributeExpressionEmpty);
161
+ }
162
+ static jsxIdentifierNameMissing() {
163
+ return CompileError.invalidDocument("jsxIdentifierNameMissing", "JSX identifier has no name", void 0, CompileError.jsxIdentifierNameMissing);
164
+ }
165
+ static jsxMemberExpressionIncomplete() {
166
+ return CompileError.invalidDocument("jsxMemberExpressionIncomplete", "JSX member expression is incomplete", void 0, CompileError.jsxMemberExpressionIncomplete);
167
+ }
168
+ static jsxNamespaceIncomplete() {
169
+ return CompileError.invalidDocument("jsxNamespaceIncomplete", "JSX namespace is incomplete", void 0, CompileError.jsxNamespaceIncomplete);
170
+ }
171
+ static unsupportedJsxName(nodeType) {
172
+ return CompileError.invalidDocument("unsupportedJsxName", `Unsupported JSX name node: ${nodeType}`, nodeType, CompileError.unsupportedJsxName);
173
+ }
174
+ static generatedProgramInvalid(cause) {
175
+ return new CompileError("The generated MDX module is not valid JavaScript", { kind: "generatedProgram" }, { cause }, CompileError.generatedProgramInvalid);
176
+ }
177
+ static invalidDocument(invariant, message, detail, context) {
178
+ return new CompileError(message, {
179
+ kind: "invalidDocument",
180
+ invariant,
181
+ detail
182
+ }, {}, context);
183
+ }
184
+ };
185
+ var ParseError = class ParseError extends MdxError {
186
+ file;
187
+ diagnostics;
188
+ constructor(file, diagnostics) {
189
+ super("ParseError", diagnostics[0].message, {}, ParseError.invalidSyntax);
190
+ this.file = file;
191
+ this.diagnostics = Object.freeze([...diagnostics]);
192
+ }
193
+ static invalidSyntax(file, diagnostics) {
194
+ return new ParseError(file, diagnostics);
195
+ }
196
+ };
197
+ var LimitError = class LimitError extends MdxError {
198
+ file;
199
+ diagnostics;
200
+ limit;
201
+ maximum;
202
+ actual;
203
+ constructor(file, limit, maximum, range, actual) {
204
+ const message = `MDX limit ${limit} exceeded: maximum ${maximum}${actual === void 0 ? "" : `, actual ${actual}`}`;
205
+ super("LimitError", message, {}, LimitError.exceeded);
206
+ this.file = file;
207
+ this.limit = limit;
208
+ this.maximum = maximum;
209
+ this.actual = actual;
210
+ this.diagnostics = Object.freeze([createDiagnostic({
211
+ severity: "error",
212
+ code: `mdx.limit.${limit}`,
213
+ message,
214
+ span: {
215
+ file,
216
+ ...range
217
+ }
218
+ })]);
219
+ }
220
+ static exceeded(file, limit, maximum, range = {
221
+ start: 0,
222
+ end: file.length
223
+ }, actual) {
224
+ return new LimitError(file, limit, maximum, range, actual);
225
+ }
226
+ };
227
+ var FrontmatterError = class FrontmatterError extends MdxError {
228
+ file;
229
+ diagnostics;
230
+ issue;
231
+ constructor(file, diagnostics, issue, context) {
232
+ super("FrontmatterError", diagnostics[0]?.message ?? "Frontmatter schema validation failed", {}, context);
233
+ this.file = file;
234
+ this.diagnostics = Object.freeze([...diagnostics]);
235
+ this.issue = Object.freeze(issue);
236
+ }
237
+ static schemaValidationFailed(file, diagnostics, issues) {
238
+ return new FrontmatterError(file, diagnostics, {
239
+ kind: "schema",
240
+ issues: Object.freeze([...issues])
241
+ }, FrontmatterError.schemaValidationFailed);
242
+ }
243
+ static nonTransportableValue(file, origin, reason) {
244
+ const diagnostic = createDiagnostic({
245
+ severity: "error",
246
+ code: "mdx.frontmatter.transport",
247
+ message: "Validated frontmatter must contain transportable values",
248
+ notes: [reason],
249
+ span: origin === void 0 ? void 0 : {
250
+ file,
251
+ ...origin
252
+ }
253
+ });
254
+ return new FrontmatterError(file, [diagnostic], {
255
+ kind: "transport",
256
+ reason
257
+ }, FrontmatterError.nonTransportableValue);
258
+ }
259
+ };
260
+ //#endregion
261
+ export { CompileError, ConfigurationError, FrontmatterError, InputError, LimitError, MdxError, ParseError, TransformError };
262
+
263
+ //# sourceMappingURL=errors.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.mjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["import type { SchemaIssue } from \"@temelj/standard-schema\";\n\nimport type { Diagnostic } from \"./diagnostics.ts\";\nimport type { ParserLimit } from \"./parser/config.ts\";\nimport type { SourceRange } from \"./ranges.ts\";\nimport type { SourceFile } from \"./source.ts\";\n\nimport { createDiagnostic } from \"./diagnostics.ts\";\n\nexport abstract class MdxError extends Error {\n protected constructor(\n name: string,\n message: string,\n options: ErrorOptions = {},\n context?: Function,\n ) {\n super(message, options);\n this.name = name;\n\n if (Error.captureStackTrace !== undefined) {\n Error.captureStackTrace(this, context ?? this.constructor);\n }\n }\n}\n\nexport type InputIssue =\n | Readonly<{ kind: \"htmlTagName\"; name: string }>\n | Readonly<{\n kind: \"mathDelimiterCollision\";\n format: \"tex\";\n nodeKind: \"inlineMath\" | \"displayMath\";\n delimiter: \"\\\\)\" | \"\\\\]\";\n }>\n | Readonly<{ kind: \"mathMetadata\"; format: \"tex\" }>\n | Readonly<{ kind: \"replacementRange\"; start: number; end: number; sourceLength: number }>\n | Readonly<{ kind: \"sourceOffset\"; offset: number; sourceLength: number }>\n | Readonly<{ kind: \"streamCompleted\" }>;\n\nexport class InputError extends MdxError {\n public readonly issue: InputIssue;\n\n private constructor(message: string, issue: InputIssue, context: Function) {\n super(\"InputError\", message, {}, context);\n this.issue = Object.freeze(issue);\n }\n\n public static mathDelimiterCollision(\n this: void,\n nodeKind: \"inlineMath\" | \"displayMath\",\n delimiter: \"\\\\)\" | \"\\\\]\",\n ): InputError {\n return new InputError(\n `Cannot format ${nodeKind} as TeX because its value contains ${JSON.stringify(delimiter)}`,\n { kind: \"mathDelimiterCollision\", format: \"tex\", nodeKind, delimiter },\n InputError.mathDelimiterCollision,\n );\n }\n\n public static mathMetadataUnsupported(this: void): InputError {\n return new InputError(\n \"TeX display math does not support fence metadata\",\n { kind: \"mathMetadata\", format: \"tex\" },\n InputError.mathMetadataUnsupported,\n );\n }\n\n public static invalidHtmlTagName(this: void, name: string): InputError {\n return new InputError(\n `Invalid HTML tag name: ${name}`,\n { kind: \"htmlTagName\", name },\n InputError.invalidHtmlTagName,\n );\n }\n\n public static replacementRangeOutsideSource(\n this: void,\n start: number,\n end: number,\n sourceLength: number,\n ): InputError {\n return new InputError(\n `Replacement range ${start}..${end} is outside source of length ${sourceLength}`,\n { kind: \"replacementRange\", start, end, sourceLength },\n InputError.replacementRangeOutsideSource,\n );\n }\n\n public static sourceOffsetOutsideFile(\n this: void,\n offset: number,\n sourceLength: number,\n ): InputError {\n return new InputError(\n `Source offset ${offset} is outside file of length ${sourceLength}`,\n { kind: \"sourceOffset\", offset, sourceLength },\n InputError.sourceOffsetOutsideFile,\n );\n }\n\n public static streamCompleted(this: void): InputError {\n return new InputError(\n \"A successfully completed MdxStream cannot be changed\",\n { kind: \"streamCompleted\" },\n InputError.streamCompleted,\n );\n }\n}\n\nexport type ConfigurationIssue =\n | Readonly<{ kind: \"asynchronousPluginInSynchronousProcessor\" }>\n | Readonly<{ kind: \"cacheCapacity\"; pluginName: string; capacity: number }>\n | Readonly<{ kind: \"compilerLimit\"; option: string; value: number }>\n | Readonly<{ kind: \"parserLimit\"; option: string; value: number; minimum: number }>\n | Readonly<{\n kind: \"pluginIntegerOption\";\n pluginName: string;\n option: string;\n value: number;\n minimum: number;\n }>\n | Readonly<{ kind: \"streamLimit\"; option: string; value: number; minimum: number }>\n | Readonly<{ kind: \"unifiedPlugin\" }>;\n\nexport class ConfigurationError extends MdxError {\n public readonly issue: ConfigurationIssue;\n\n private constructor(message: string, issue: ConfigurationIssue, context: Function) {\n super(\"ConfigurationError\", message, {}, context);\n this.issue = Object.freeze(issue);\n }\n\n public static asynchronousPluginInSynchronousProcessor(this: void): ConfigurationError {\n return new ConfigurationError(\n \"processSync() cannot run an asynchronous plugin; use process() instead\",\n { kind: \"asynchronousPluginInSynchronousProcessor\" },\n ConfigurationError.asynchronousPluginInSynchronousProcessor,\n );\n }\n\n public static unsupportedUnifiedPlugin(this: void): ConfigurationError {\n return new ConfigurationError(\n \"Unified parser and compiler plugins are not supported by the transform adapter\",\n { kind: \"unifiedPlugin\" },\n ConfigurationError.unsupportedUnifiedPlugin,\n );\n }\n\n public static invalidCacheCapacity(\n this: void,\n pluginName: string,\n capacity: number,\n ): ConfigurationError {\n return new ConfigurationError(\n `Invalid ${pluginName} cache capacity: ${capacity}; expected a non-negative safe integer`,\n { kind: \"cacheCapacity\", pluginName, capacity },\n ConfigurationError.invalidCacheCapacity,\n );\n }\n\n public static invalidCompilerLimit(\n this: void,\n option: string,\n value: number,\n ): ConfigurationError {\n return new ConfigurationError(\n `Invalid compiler ${option}: ${value}; expected a non-negative safe integer`,\n { kind: \"compilerLimit\", option, value },\n ConfigurationError.invalidCompilerLimit,\n );\n }\n\n public static invalidStreamLimit(\n this: void,\n option: string,\n value: number,\n minimum: number,\n ): ConfigurationError {\n return new ConfigurationError(\n `Invalid stream ${option}: ${value}; expected a safe integer of at least ${minimum}`,\n { kind: \"streamLimit\", option, value, minimum },\n ConfigurationError.invalidStreamLimit,\n );\n }\n\n public static invalidParserLimit(\n this: void,\n option: string,\n value: number,\n minimum: number,\n ): ConfigurationError {\n return new ConfigurationError(\n `Invalid parser ${option}: ${value}; expected a safe integer of at least ${minimum}`,\n { kind: \"parserLimit\", option, value, minimum },\n ConfigurationError.invalidParserLimit,\n );\n }\n\n public static invalidPluginIntegerOption(\n this: void,\n pluginName: string,\n option: string,\n value: number,\n minimum: number,\n ): ConfigurationError {\n return new ConfigurationError(\n `Invalid ${pluginName} ${option}: ${value}; expected a safe integer of at least ${minimum}`,\n { kind: \"pluginIntegerOption\", pluginName, option, value, minimum },\n ConfigurationError.invalidPluginIntegerOption,\n );\n }\n}\n\nexport type TransformTarget = \"document\" | \"html\";\n\nexport interface TransformIssue {\n readonly kind: \"threw\" | \"reported\";\n readonly target: TransformTarget;\n readonly pluginName: string;\n}\n\nexport class TransformError extends MdxError {\n public readonly issue: TransformIssue;\n public readonly file: SourceFile;\n public readonly diagnostics: readonly Diagnostic[];\n\n private constructor(\n issue: TransformIssue,\n file: SourceFile,\n diagnostics: readonly Diagnostic[],\n options: ErrorOptions,\n context: Function,\n ) {\n super(\n \"TransformError\",\n `Plugin \"${issue.pluginName}\" failed while transforming ${issue.target}`,\n options,\n context,\n );\n this.issue = Object.freeze(issue);\n this.file = file;\n this.diagnostics = Object.freeze([...diagnostics]);\n }\n\n public static pluginTransformFailed(\n this: void,\n target: TransformTarget,\n pluginName: string,\n file: SourceFile,\n diagnostics: readonly Diagnostic[],\n cause: unknown,\n ): TransformError {\n return new TransformError(\n { kind: \"threw\", target, pluginName },\n file,\n diagnostics,\n { cause },\n TransformError.pluginTransformFailed,\n );\n }\n\n public static pluginReportedErrors(\n this: void,\n target: TransformTarget,\n pluginName: string,\n file: SourceFile,\n diagnostics: readonly Diagnostic[],\n ): TransformError {\n return new TransformError(\n { kind: \"reported\", target, pluginName },\n file,\n diagnostics,\n {},\n TransformError.pluginReportedErrors,\n );\n }\n}\n\nexport type CompilationInvariant =\n | \"defaultExportBindingMissing\"\n | \"jsxAttributeExpressionEmpty\"\n | \"jsxAttributeNameMissing\"\n | \"jsxElementNameMissing\"\n | \"jsxElementOpeningMissing\"\n | \"jsxIdentifierNameMissing\"\n | \"jsxMemberExpressionIncomplete\"\n | \"jsxNamespaceIncomplete\"\n | \"jsxSpreadArgumentMissing\"\n | \"multipleDefaultExports\"\n | \"unsupportedJsxName\";\n\nexport type CompilationIssue =\n | Readonly<{ kind: \"generation\" }>\n | Readonly<{ kind: \"generatedProgram\" }>\n | Readonly<{ kind: \"invalidDocument\"; invariant: CompilationInvariant; detail?: string }>;\n\nexport class CompileError extends MdxError {\n public readonly issue: CompilationIssue;\n\n private constructor(\n message: string,\n issue: CompilationIssue,\n options: ErrorOptions,\n context: Function,\n ) {\n super(\"CompileError\", message, options, context);\n this.issue = Object.freeze(issue);\n }\n\n public static generationFailed(this: void, cause: unknown): CompileError {\n return new CompileError(\n \"MDX compilation failed\",\n { kind: \"generation\" },\n { cause },\n CompileError.generationFailed,\n );\n }\n\n public static multipleDefaultExports(this: void): CompileError {\n return CompileError.invalidDocument(\n \"multipleDefaultExports\",\n \"MDX has more than one default export\",\n undefined,\n CompileError.multipleDefaultExports,\n );\n }\n\n public static defaultExportBindingMissing(this: void): CompileError {\n return CompileError.invalidDocument(\n \"defaultExportBindingMissing\",\n \"Default MDX export has no local binding\",\n undefined,\n CompileError.defaultExportBindingMissing,\n );\n }\n\n public static jsxElementOpeningMissing(this: void): CompileError {\n return CompileError.invalidDocument(\n \"jsxElementOpeningMissing\",\n \"JSX element has no opening element\",\n undefined,\n CompileError.jsxElementOpeningMissing,\n );\n }\n\n public static jsxElementNameMissing(this: void): CompileError {\n return CompileError.invalidDocument(\n \"jsxElementNameMissing\",\n \"JSX element has no name\",\n undefined,\n CompileError.jsxElementNameMissing,\n );\n }\n\n public static jsxSpreadArgumentMissing(this: void): CompileError {\n return CompileError.invalidDocument(\n \"jsxSpreadArgumentMissing\",\n \"JSX spread has no argument\",\n undefined,\n CompileError.jsxSpreadArgumentMissing,\n );\n }\n\n public static jsxAttributeNameMissing(this: void): CompileError {\n return CompileError.invalidDocument(\n \"jsxAttributeNameMissing\",\n \"JSX attribute has no name\",\n undefined,\n CompileError.jsxAttributeNameMissing,\n );\n }\n\n public static jsxAttributeExpressionEmpty(this: void): CompileError {\n return CompileError.invalidDocument(\n \"jsxAttributeExpressionEmpty\",\n \"JSX attribute expression is empty\",\n undefined,\n CompileError.jsxAttributeExpressionEmpty,\n );\n }\n\n public static jsxIdentifierNameMissing(this: void): CompileError {\n return CompileError.invalidDocument(\n \"jsxIdentifierNameMissing\",\n \"JSX identifier has no name\",\n undefined,\n CompileError.jsxIdentifierNameMissing,\n );\n }\n\n public static jsxMemberExpressionIncomplete(this: void): CompileError {\n return CompileError.invalidDocument(\n \"jsxMemberExpressionIncomplete\",\n \"JSX member expression is incomplete\",\n undefined,\n CompileError.jsxMemberExpressionIncomplete,\n );\n }\n\n public static jsxNamespaceIncomplete(this: void): CompileError {\n return CompileError.invalidDocument(\n \"jsxNamespaceIncomplete\",\n \"JSX namespace is incomplete\",\n undefined,\n CompileError.jsxNamespaceIncomplete,\n );\n }\n\n public static unsupportedJsxName(this: void, nodeType: string): CompileError {\n return CompileError.invalidDocument(\n \"unsupportedJsxName\",\n `Unsupported JSX name node: ${nodeType}`,\n nodeType,\n CompileError.unsupportedJsxName,\n );\n }\n\n public static generatedProgramInvalid(this: void, cause: unknown): CompileError {\n return new CompileError(\n \"The generated MDX module is not valid JavaScript\",\n { kind: \"generatedProgram\" },\n { cause },\n CompileError.generatedProgramInvalid,\n );\n }\n\n private static invalidDocument(\n invariant: CompilationInvariant,\n message: string,\n detail: string | undefined,\n context: Function,\n ): CompileError {\n return new CompileError(\n message,\n {\n kind: \"invalidDocument\",\n invariant,\n detail,\n },\n {},\n context,\n );\n }\n}\n\nexport class ParseError extends MdxError {\n public readonly file: SourceFile;\n public readonly diagnostics: readonly [Diagnostic, ...Diagnostic[]];\n\n private constructor(file: SourceFile, diagnostics: readonly [Diagnostic, ...Diagnostic[]]) {\n super(\"ParseError\", diagnostics[0].message, {}, ParseError.invalidSyntax);\n this.file = file;\n this.diagnostics = Object.freeze([...diagnostics]);\n }\n\n public static invalidSyntax(\n this: void,\n file: SourceFile,\n diagnostics: readonly [Diagnostic, ...Diagnostic[]],\n ): ParseError {\n return new ParseError(file, diagnostics);\n }\n}\n\nexport type CompileLimit = \"maximumGeneratedCodeBytes\" | \"maximumSourceMapBytes\";\n\nexport class LimitError extends MdxError {\n public readonly file: SourceFile;\n public readonly diagnostics: readonly [Diagnostic];\n public readonly limit: ParserLimit | CompileLimit;\n public readonly maximum: number;\n public readonly actual: number | undefined;\n\n private constructor(\n file: SourceFile,\n limit: ParserLimit | CompileLimit,\n maximum: number,\n range: SourceRange,\n actual?: number,\n ) {\n const message = `MDX limit ${limit} exceeded: maximum ${maximum}${actual === undefined ? \"\" : `, actual ${actual}`}`;\n super(\"LimitError\", message, {}, LimitError.exceeded);\n this.file = file;\n this.limit = limit;\n this.maximum = maximum;\n this.actual = actual;\n this.diagnostics = Object.freeze([\n createDiagnostic({\n severity: \"error\",\n code: `mdx.limit.${limit}`,\n message,\n span: { file, ...range },\n }),\n ]);\n }\n\n public static exceeded(\n this: void,\n file: SourceFile,\n limit: ParserLimit | CompileLimit,\n maximum: number,\n range: SourceRange = { start: 0, end: file.length },\n actual?: number,\n ): LimitError {\n return new LimitError(file, limit, maximum, range, actual);\n }\n}\n\nexport type FrontmatterIssue =\n | Readonly<{ kind: \"schema\"; issues: readonly SchemaIssue[] }>\n | Readonly<{ kind: \"transport\"; reason: string }>;\n\nexport class FrontmatterError extends MdxError {\n public readonly file: SourceFile;\n public readonly diagnostics: readonly Diagnostic[];\n public readonly issue: FrontmatterIssue;\n\n private constructor(\n file: SourceFile,\n diagnostics: readonly Diagnostic[],\n issue: FrontmatterIssue,\n context: Function,\n ) {\n super(\n \"FrontmatterError\",\n diagnostics[0]?.message ?? \"Frontmatter schema validation failed\",\n {},\n context,\n );\n this.file = file;\n this.diagnostics = Object.freeze([...diagnostics]);\n this.issue = Object.freeze(issue);\n }\n\n public static schemaValidationFailed(\n this: void,\n file: SourceFile,\n diagnostics: readonly Diagnostic[],\n issues: readonly SchemaIssue[],\n ): FrontmatterError {\n return new FrontmatterError(\n file,\n diagnostics,\n { kind: \"schema\", issues: Object.freeze([...issues]) },\n FrontmatterError.schemaValidationFailed,\n );\n }\n\n public static nonTransportableValue(\n this: void,\n file: SourceFile,\n origin: SourceRange | undefined,\n reason: string,\n ): FrontmatterError {\n const diagnostic = createDiagnostic({\n severity: \"error\",\n code: \"mdx.frontmatter.transport\",\n message: \"Validated frontmatter must contain transportable values\",\n notes: [reason],\n span: origin === undefined ? undefined : { file, ...origin },\n });\n\n return new FrontmatterError(\n file,\n [diagnostic],\n { kind: \"transport\", reason },\n FrontmatterError.nonTransportableValue,\n );\n }\n}\n"],"mappings":";;AASA,IAAsB,WAAtB,cAAuC,MAAM;CAC3C,YACE,MACA,SACA,UAAwB,CAAC,GACzB,SACA;EACA,MAAM,SAAS,OAAO;EACtB,KAAK,OAAO;EAEZ,IAAI,MAAM,sBAAsB,KAAA,GAC9B,MAAM,kBAAkB,MAAM,WAAW,KAAK,WAAW;CAE7D;AACF;AAeA,IAAa,aAAb,MAAa,mBAAmB,SAAS;CACvC;CAEA,YAAoB,SAAiB,OAAmB,SAAmB;EACzE,MAAM,cAAc,SAAS,CAAC,GAAG,OAAO;EACxC,KAAK,QAAQ,OAAO,OAAO,KAAK;CAClC;CAEA,OAAc,uBAEZ,UACA,WACY;EACZ,OAAO,IAAI,WACT,iBAAiB,SAAS,qCAAqC,KAAK,UAAU,SAAS,KACvF;GAAE,MAAM;GAA0B,QAAQ;GAAO;GAAU;EAAU,GACrE,WAAW,sBACb;CACF;CAEA,OAAc,0BAAgD;EAC5D,OAAO,IAAI,WACT,oDACA;GAAE,MAAM;GAAgB,QAAQ;EAAM,GACtC,WAAW,uBACb;CACF;CAEA,OAAc,mBAA+B,MAA0B;EACrE,OAAO,IAAI,WACT,0BAA0B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O,OAAO,CAAC,GAAG,MAAM,CAAC;EAAE,GACrD,iBAAiB,sBACnB;CACF;CAEA,OAAc,sBAEZ,MACA,QACA,QACkB;EAClB,MAAM,aAAa,iBAAiB;GAClC,UAAU;GACV,MAAM;GACN,SAAS;GACT,OAAO,CAAC,MAAM;GACd,MAAM,WAAW,KAAA,IAAY,KAAA,IAAY;IAAE;IAAM,GAAG;GAAO;EAC7D,CAAC;EAED,OAAO,IAAI,iBACT,MACA,CAAC,UAAU,GACX;GAAE,MAAM;GAAa;EAAO,GAC5B,iBAAiB,qBACnB;CACF;AACF"}
@@ -0,0 +1,27 @@
1
+ //#region src/footnote-numbering.d.ts
2
+ /** A footnote reference's place in the document-wide footnote layout. */
3
+ export interface FootnoteOccurrence {
4
+ /** The 1-based footnote number, assigned by first reference. */
5
+ readonly ordinal: number;
6
+ /** The 1-based count of references to the same footnote so far. */
7
+ readonly occurrence: number;
8
+ }
9
+ /**
10
+ * Numbers defined footnotes by first reference, in document order. Batch
11
+ * lowering numbers one document; a stream numbers its settled prefix once and
12
+ * forks the result for each open tail.
13
+ */
14
+ export declare class FootnoteNumbering {
15
+ #private;
16
+ /** Identifiers by first reference. */
17
+ get order(): readonly string[];
18
+ /** Records the next reference to a defined footnote. */
19
+ reference(identifier: string): FootnoteOccurrence;
20
+ count(identifier: string): number;
21
+ /** A copy that later references do not share. */
22
+ fork(): FootnoteNumbering;
23
+ /** Two numberings produce the same footnote section when order and counts match. */
24
+ equals(other: FootnoteNumbering): boolean;
25
+ }
26
+ //#endregion
27
+ //# sourceMappingURL=footnote-numbering.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"footnote-numbering.d.mts","names":[],"sources":["../src/footnote-numbering.ts"],"mappings":";;iBACiB;;WAEN;;WAEA;;;;;;;qBAQE;;;MAMA;;EAKJ,UAAU,qBAAqB;EAe/B,MAAM;;EAKN,QAAQ;;EAgBR,OAAO,OAAO"}
@@ -0,0 +1,49 @@
1
+ //#region src/footnote-numbering.ts
2
+ /**
3
+ * Numbers defined footnotes by first reference, in document order. Batch
4
+ * lowering numbers one document; a stream numbers its settled prefix once and
5
+ * forks the result for each open tail.
6
+ */
7
+ var FootnoteNumbering = class FootnoteNumbering {
8
+ #order = [];
9
+ #ordinals = /* @__PURE__ */ new Map();
10
+ #counts = /* @__PURE__ */ new Map();
11
+ /** Identifiers by first reference. */
12
+ get order() {
13
+ return this.#order;
14
+ }
15
+ /** Records the next reference to a defined footnote. */
16
+ reference(identifier) {
17
+ let ordinal = this.#ordinals.get(identifier);
18
+ if (ordinal === void 0) {
19
+ this.#order.push(identifier);
20
+ ordinal = this.#order.length;
21
+ this.#ordinals.set(identifier, ordinal);
22
+ }
23
+ const occurrence = (this.#counts.get(identifier) ?? 0) + 1;
24
+ this.#counts.set(identifier, occurrence);
25
+ return {
26
+ ordinal,
27
+ occurrence
28
+ };
29
+ }
30
+ count(identifier) {
31
+ return this.#counts.get(identifier) ?? 0;
32
+ }
33
+ /** A copy that later references do not share. */
34
+ fork() {
35
+ const copy = new FootnoteNumbering();
36
+ copy.#order.push(...this.#order);
37
+ for (const [identifier, ordinal] of this.#ordinals) copy.#ordinals.set(identifier, ordinal);
38
+ for (const [identifier, count] of this.#counts) copy.#counts.set(identifier, count);
39
+ return copy;
40
+ }
41
+ /** Two numberings produce the same footnote section when order and counts match. */
42
+ equals(other) {
43
+ return this.#order.length === other.#order.length && this.#order.every((identifier, index) => other.#order[index] === identifier && other.count(identifier) === this.count(identifier));
44
+ }
45
+ };
46
+ //#endregion
47
+ export { FootnoteNumbering };
48
+
49
+ //# sourceMappingURL=footnote-numbering.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"footnote-numbering.mjs","names":[],"sources":["../src/footnote-numbering.ts"],"sourcesContent":["/** A footnote reference's place in the document-wide footnote layout. */\nexport interface FootnoteOccurrence {\n /** The 1-based footnote number, assigned by first reference. */\n readonly ordinal: number;\n /** The 1-based count of references to the same footnote so far. */\n readonly occurrence: number;\n}\n\n/**\n * Numbers defined footnotes by first reference, in document order. Batch\n * lowering numbers one document; a stream numbers its settled prefix once and\n * forks the result for each open tail.\n */\nexport class FootnoteNumbering {\n readonly #order: string[] = [];\n readonly #ordinals = new Map<string, number>();\n readonly #counts = new Map<string, number>();\n\n /** Identifiers by first reference. */\n public get order(): readonly string[] {\n return this.#order;\n }\n\n /** Records the next reference to a defined footnote. */\n public reference(identifier: string): FootnoteOccurrence {\n let ordinal = this.#ordinals.get(identifier);\n\n if (ordinal === undefined) {\n this.#order.push(identifier);\n ordinal = this.#order.length;\n this.#ordinals.set(identifier, ordinal);\n }\n\n const occurrence = (this.#counts.get(identifier) ?? 0) + 1;\n this.#counts.set(identifier, occurrence);\n\n return { ordinal, occurrence };\n }\n\n public count(identifier: string): number {\n return this.#counts.get(identifier) ?? 0;\n }\n\n /** A copy that later references do not share. */\n public fork(): FootnoteNumbering {\n const copy = new FootnoteNumbering();\n copy.#order.push(...this.#order);\n\n for (const [identifier, ordinal] of this.#ordinals) {\n copy.#ordinals.set(identifier, ordinal);\n }\n\n for (const [identifier, count] of this.#counts) {\n copy.#counts.set(identifier, count);\n }\n\n return copy;\n }\n\n /** Two numberings produce the same footnote section when order and counts match. */\n public equals(other: FootnoteNumbering): boolean {\n return (\n this.#order.length === other.#order.length &&\n this.#order.every(\n (identifier, index) =>\n other.#order[index] === identifier && other.count(identifier) === this.count(identifier),\n )\n );\n }\n}\n"],"mappings":";;;;;;AAaA,IAAa,oBAAb,MAAa,kBAAkB;CAC7B,SAA4B,CAAC;CAC7B,4BAAqB,IAAI,IAAoB;CAC7C,0BAAmB,IAAI,IAAoB;;CAG3C,IAAW,QAA2B;EACpC,OAAO,KAAK;CACd;;CAGA,UAAiB,YAAwC;EACvD,IAAI,UAAU,KAAK,UAAU,IAAI,UAAU;EAE3C,IAAI,YAAY,KAAA,GAAW;GACzB,KAAK,OAAO,KAAK,UAAU;GAC3B,UAAU,KAAK,OAAO;GACtB,KAAK,UAAU,IAAI,YAAY,OAAO;EACxC;EAEA,MAAM,cAAc,KAAK,QAAQ,IAAI,UAAU,KAAK,KAAK;EACzD,KAAK,QAAQ,IAAI,YAAY,UAAU;EAEvC,OAAO;GAAE;GAAS;EAAW;CAC/B;CAEA,MAAa,YAA4B;EACvC,OAAO,KAAK,QAAQ,IAAI,UAAU,KAAK;CACzC;;CAGA,OAAiC;EAC/B,MAAM,OAAO,IAAI,kBAAkB;EACnC,KAAK,OAAO,KAAK,GAAG,KAAK,MAAM;EAE/B,KAAK,MAAM,CAAC,YAAY,YAAY,KAAK,WACvC,KAAK,UAAU,IAAI,YAAY,OAAO;EAGxC,KAAK,MAAM,CAAC,YAAY,UAAU,KAAK,SACrC,KAAK,QAAQ,IAAI,YAAY,KAAK;EAGpC,OAAO;CACT;;CAGA,OAAc,OAAmC;EAC/C,OACE,KAAK,OAAO,WAAW,MAAM,OAAO,UACpC,KAAK,OAAO,OACT,YAAY,UACX,MAAM,OAAO,WAAW,cAAc,MAAM,MAAM,UAAU,MAAM,KAAK,MAAM,UAAU,CAC3F;CAEJ;AACF"}
@@ -0,0 +1,46 @@
1
+ import { ResolvedSyntaxOptions, SyntaxOptions } from "./syntax-options.mjs";
2
+ import { MdxNode } from "./model.mjs";
3
+ import { FormatConstruct, FormatSafeInfo, FormatUnsafePattern } from "./format-safe.mjs";
4
+ import { FormatTrackInfo } from "./format-track.mjs";
5
+ //#region src/format-context.d.ts
6
+ export interface FormatInfo extends FormatTrackInfo {
7
+ readonly after: string;
8
+ readonly before: string;
9
+ }
10
+ export declare const rootInfo: FormatInfo;
11
+ export interface FormatOptions {
12
+ readonly bullet?: "*" | "+" | "-";
13
+ readonly bulletOrdered?: "." | ")";
14
+ readonly closeAtx?: boolean;
15
+ readonly emphasis?: "*" | "_";
16
+ readonly fence?: "`" | "~";
17
+ readonly footnoteFirstLineBlank?: boolean;
18
+ readonly incrementListMarker?: boolean;
19
+ readonly listItemIndent?: "mixed" | "one" | "tab";
20
+ readonly quote?: '"' | "'";
21
+ readonly rule?: "*" | "-" | "_";
22
+ readonly ruleRepetition?: number;
23
+ readonly ruleSpaces?: boolean;
24
+ readonly strong?: "*" | "_";
25
+ readonly syntax?: SyntaxOptions;
26
+ readonly tightDefinitions?: boolean;
27
+ readonly tableCellPadding?: boolean;
28
+ readonly tablePipeAlign?: boolean;
29
+ readonly tableStringLength?: (value: string) => number;
30
+ }
31
+ /** What construct formatters share: options, the construct stack, and nested formatting. */
32
+ export interface FormatContext {
33
+ readonly options: FormatOptions;
34
+ readonly syntax: ResolvedSyntaxOptions;
35
+ readonly stack: readonly FormatConstruct[];
36
+ readonly unsafe: readonly FormatUnsafePattern[];
37
+ compilePattern(pattern: FormatUnsafePattern): RegExp;
38
+ flow(nodes: readonly MdxNode[], info: FormatInfo, spread?: boolean): string;
39
+ phrasing(nodes: readonly MdxNode[], info: FormatInfo): string;
40
+ enter(construct: FormatConstruct): () => void;
41
+ safe(value: string, info: FormatSafeInfo): string;
42
+ }
43
+ export declare function indentLines(value: string, map: (line: string, blank: boolean, index: number) => string): string;
44
+ export declare function longestRun(value: string, marker: string): number;
45
+ //#endregion
46
+ //# sourceMappingURL=format-context.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-context.d.mts","names":[],"sources":["../src/format-context.ts"],"mappings":";;;;;iBAKiB,mBAAmB;WACzB;WACA;;qBAGE,UAAU;iBAON;WACN;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA,SAAS;WACT;WACA;WACA;WACA,qBAAqB;;;iBAIf;WACN,SAAS;WACT,QAAQ;WACR,gBAAgB;WAChB,iBAAiB;EAC1B,eAAe,SAAS,sBAAsB;EAC9C,KAAK,gBAAgB,WAAW,MAAM,YAAY;EAClD,SAAS,gBAAgB,WAAW,MAAM;EAC1C,MAAM,WAAW;EACjB,KAAK,eAAe,MAAM;;wBAGZ,YACd,eACA,MAAM,cAAc,gBAAgB;wBAQtB,WAAW,eAAe"}
@@ -0,0 +1,26 @@
1
+ //#region src/format-context.ts
2
+ const rootInfo = {
3
+ after: "\n",
4
+ before: "\n",
5
+ lineShift: 0,
6
+ now: {
7
+ line: 1,
8
+ column: 1
9
+ }
10
+ };
11
+ function indentLines(value, map) {
12
+ return value.split(/\r\n?|\n/gu).map((line, index) => map(line, line.length === 0, index)).join("\n");
13
+ }
14
+ function longestRun(value, marker) {
15
+ let longest = 0;
16
+ let current = 0;
17
+ for (const character of value) {
18
+ current = character === marker ? current + 1 : 0;
19
+ longest = Math.max(longest, current);
20
+ }
21
+ return longest;
22
+ }
23
+ //#endregion
24
+ export { indentLines, longestRun, rootInfo };
25
+
26
+ //# sourceMappingURL=format-context.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-context.mjs","names":[],"sources":["../src/format-context.ts"],"sourcesContent":["import type { FormatConstruct, FormatSafeInfo, FormatUnsafePattern } from \"./format-safe.ts\";\nimport type { FormatTrackInfo } from \"./format-track.ts\";\nimport type { MdxNode } from \"./model.ts\";\nimport type { ResolvedSyntaxOptions, SyntaxOptions } from \"./syntax-options.ts\";\n\nexport interface FormatInfo extends FormatTrackInfo {\n readonly after: string;\n readonly before: string;\n}\n\nexport const rootInfo: FormatInfo = {\n after: \"\\n\",\n before: \"\\n\",\n lineShift: 0,\n now: { line: 1, column: 1 },\n};\n\nexport interface FormatOptions {\n readonly bullet?: \"*\" | \"+\" | \"-\";\n readonly bulletOrdered?: \".\" | \")\";\n readonly closeAtx?: boolean;\n readonly emphasis?: \"*\" | \"_\";\n readonly fence?: \"`\" | \"~\";\n readonly footnoteFirstLineBlank?: boolean;\n readonly incrementListMarker?: boolean;\n readonly listItemIndent?: \"mixed\" | \"one\" | \"tab\";\n readonly quote?: '\"' | \"'\";\n readonly rule?: \"*\" | \"-\" | \"_\";\n readonly ruleRepetition?: number;\n readonly ruleSpaces?: boolean;\n readonly strong?: \"*\" | \"_\";\n readonly syntax?: SyntaxOptions;\n readonly tightDefinitions?: boolean;\n readonly tableCellPadding?: boolean;\n readonly tablePipeAlign?: boolean;\n readonly tableStringLength?: (value: string) => number;\n}\n\n/** What construct formatters share: options, the construct stack, and nested formatting. */\nexport interface FormatContext {\n readonly options: FormatOptions;\n readonly syntax: ResolvedSyntaxOptions;\n readonly stack: readonly FormatConstruct[];\n readonly unsafe: readonly FormatUnsafePattern[];\n compilePattern(pattern: FormatUnsafePattern): RegExp;\n flow(nodes: readonly MdxNode[], info: FormatInfo, spread?: boolean): string;\n phrasing(nodes: readonly MdxNode[], info: FormatInfo): string;\n enter(construct: FormatConstruct): () => void;\n safe(value: string, info: FormatSafeInfo): string;\n}\n\nexport function indentLines(\n value: string,\n map: (line: string, blank: boolean, index: number) => string,\n): string {\n return value\n .split(/\\r\\n?|\\n/gu)\n .map((line, index) => map(line, line.length === 0, index))\n .join(\"\\n\");\n}\n\nexport function longestRun(value: string, marker: string): number {\n let longest = 0;\n let current = 0;\n\n for (const character of value) {\n current = character === marker ? current + 1 : 0;\n longest = Math.max(longest, current);\n }\n\n return longest;\n}\n"],"mappings":";AAUA,MAAa,WAAuB;CAClC,OAAO;CACP,QAAQ;CACR,WAAW;CACX,KAAK;EAAE,MAAM;EAAG,QAAQ;CAAE;AAC5B;AAoCA,SAAgB,YACd,OACA,KACQ;CACR,OAAO,MACJ,MAAM,YAAY,CAAC,CACnB,KAAK,MAAM,UAAU,IAAI,MAAM,KAAK,WAAW,GAAG,KAAK,CAAC,CAAC,CACzD,KAAK,IAAI;AACd;AAEA,SAAgB,WAAW,OAAe,QAAwB;CAChE,IAAI,UAAU;CACd,IAAI,UAAU;CAEd,KAAK,MAAM,aAAa,OAAO;EAC7B,UAAU,cAAc,SAAS,UAAU,IAAI;EAC/C,UAAU,KAAK,IAAI,SAAS,OAAO;CACrC;CAEA,OAAO;AACT"}
@@ -0,0 +1,9 @@
1
+ import { ContainerDirectiveNode, DirectiveLabelNode, LeafDirectiveNode, MdxNode, TextDirectiveNode } from "./model.mjs";
2
+ import { FormatContext, FormatInfo } from "./format-context.mjs";
3
+ //#region src/format-directive.d.ts
4
+ export declare function formatDirective(context: FormatContext, node: TextDirectiveNode | LeafDirectiveNode, info: FormatInfo, sequence: ":" | "::"): string;
5
+ export declare function formatContainerDirective(context: FormatContext, node: ContainerDirectiveNode, info: FormatInfo): string;
6
+ export declare function formatDirectiveLabel(context: FormatContext, node: DirectiveLabelNode, info: FormatInfo): string;
7
+ export declare function containsDirective(node: MdxNode): boolean;
8
+ //#endregion
9
+ //# sourceMappingURL=format-directive.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-directive.d.mts","names":[],"sources":["../src/format-directive.ts"],"mappings":";;;wBAegB,gBACd,SAAS,eACT,MAAM,oBAAoB,mBAC1B,MAAM,YACN;wBAsBc,yBACd,SAAS,eACT,MAAM,wBACN,MAAM;wBAoCQ,qBACd,SAAS,eACT,MAAM,oBACN,MAAM;wBAqBQ,kBAAkB,MAAM"}
@@ -0,0 +1,99 @@
1
+ import { FormatTracker } from "./format-track.mjs";
2
+ import { mdxChildren } from "./model.mjs";
3
+ //#region src/format-directive.ts
4
+ function formatDirective(context, node, info, sequence) {
5
+ const exit = context.enter(node.kind);
6
+ const tracker = new FormatTracker(info);
7
+ let value = tracker.move(`${sequence}${node.name}`);
8
+ if (node.label !== void 0) value += tracker.move(formatDirectiveLabel(context, node.label, {
9
+ after: "{",
10
+ before: value,
11
+ ...tracker.current()
12
+ }));
13
+ value += tracker.move(formatDirectiveAttributes(node.attributes, context.options));
14
+ exit();
15
+ return value;
16
+ }
17
+ function formatContainerDirective(context, node, info) {
18
+ const exit = context.enter("containerDirective");
19
+ const tracker = new FormatTracker(info);
20
+ const sequence = ":".repeat(containerDirectiveFenceSize(node));
21
+ let value = tracker.move(`${sequence}${node.name}`);
22
+ if (node.label !== void 0) value += tracker.move(formatDirectiveLabel(context, node.label, {
23
+ after: "{",
24
+ before: value,
25
+ ...tracker.current()
26
+ }));
27
+ value += tracker.move(formatDirectiveAttributes(node.attributes, context.options));
28
+ if (node.children.length > 0) {
29
+ value += tracker.move("\n");
30
+ value += tracker.move(context.flow(node.children, {
31
+ after: "\n",
32
+ before: "\n",
33
+ ...tracker.current()
34
+ }));
35
+ }
36
+ value += tracker.move(`\n${sequence}`);
37
+ exit();
38
+ return value;
39
+ }
40
+ function formatDirectiveLabel(context, node, info) {
41
+ const exit = context.enter("directiveLabel");
42
+ const exitLabel = context.enter("label");
43
+ const tracker = new FormatTracker(info);
44
+ const opening = tracker.move("[");
45
+ const content = tracker.move(context.phrasing(node.children, {
46
+ after: "]",
47
+ before: opening,
48
+ ...tracker.current()
49
+ }));
50
+ exitLabel();
51
+ exit();
52
+ return `${opening}${content}]`;
53
+ }
54
+ function containsDirective(node) {
55
+ return node.kind === "textDirective" || node.kind === "leafDirective" || node.kind === "containerDirective" || mdxChildren(node).some(containsDirective);
56
+ }
57
+ function containerDirectiveFenceSize(node) {
58
+ let nested = 0;
59
+ const visit = (child) => {
60
+ if (child.kind === "containerDirective") nested = Math.max(nested, containerDirectiveFenceSize(child) - 2);
61
+ else mdxChildren(child).forEach(visit);
62
+ };
63
+ node.children.forEach(visit);
64
+ return 3 + nested;
65
+ }
66
+ function formatDirectiveAttributes(entries, options) {
67
+ if (entries.length === 0) return "";
68
+ const shortcut = /^[^\t\n\r "#'.<=>`}]+$/u;
69
+ const values = [];
70
+ let id;
71
+ const classes = [];
72
+ const fullClasses = [];
73
+ for (const entry of entries) if (entry.name === "id" && shortcut.test(entry.value)) id = `#${entry.value}`;
74
+ else if (entry.name === "class") for (const className of entry.value.split(/[\t\n\r ]+/u)) {
75
+ if (className.length === 0) continue;
76
+ if (shortcut.test(className)) classes.push(className);
77
+ else fullClasses.push(className);
78
+ }
79
+ else values.push(formatDirectiveAttribute(entry.name, entry.value, options));
80
+ if (fullClasses.length > 0) values.unshift(formatDirectiveAttribute("class", fullClasses.join(" "), options));
81
+ if (classes.length > 0) values.unshift(`.${classes.join(".")}`);
82
+ if (id !== void 0) values.unshift(id);
83
+ return `{${values.join(" ")}}`;
84
+ }
85
+ function formatDirectiveAttribute(name, value, options) {
86
+ if (value.length === 0) return name;
87
+ const quote = options.quote ?? "\"";
88
+ return `${name}=${quote}${value.replace(/[&\r\n"']/gu, (character) => {
89
+ if (character === "&") return "&amp;";
90
+ if (character === "\r") return "&#xD;";
91
+ if (character === "\n") return "&#xA;";
92
+ if (character === quote) return quote === "\"" ? "&quot;" : "&#x27;";
93
+ return character;
94
+ })}${quote}`;
95
+ }
96
+ //#endregion
97
+ export { containsDirective, formatContainerDirective, formatDirective, formatDirectiveLabel };
98
+
99
+ //# sourceMappingURL=format-directive.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-directive.mjs","names":[],"sources":["../src/format-directive.ts"],"sourcesContent":["import type { FormatContext, FormatInfo, FormatOptions } from \"./format-context.ts\";\nimport type {\n ContainerDirectiveNode,\n DirectiveAttribute,\n DirectiveLabelNode,\n LeafDirectiveNode,\n MdxNode,\n TextDirectiveNode,\n} from \"./model.ts\";\n\nimport { FormatTracker } from \"./format-track.ts\";\nimport { mdxChildren } from \"./model.ts\";\n\n// Directives, their labels, and their attributes.\n\nexport function formatDirective(\n context: FormatContext,\n node: TextDirectiveNode | LeafDirectiveNode,\n info: FormatInfo,\n sequence: \":\" | \"::\",\n): string {\n const exit = context.enter(node.kind);\n const tracker = new FormatTracker(info);\n let value = tracker.move(`${sequence}${node.name}`);\n\n if (node.label !== undefined) {\n value += tracker.move(\n formatDirectiveLabel(context, node.label, {\n after: \"{\",\n before: value,\n ...tracker.current(),\n }),\n );\n }\n\n value += tracker.move(formatDirectiveAttributes(node.attributes, context.options));\n exit();\n\n return value;\n}\n\nexport function formatContainerDirective(\n context: FormatContext,\n node: ContainerDirectiveNode,\n info: FormatInfo,\n): string {\n const exit = context.enter(\"containerDirective\");\n const tracker = new FormatTracker(info);\n const sequence = \":\".repeat(containerDirectiveFenceSize(node));\n let value = tracker.move(`${sequence}${node.name}`);\n\n if (node.label !== undefined) {\n value += tracker.move(\n formatDirectiveLabel(context, node.label, {\n after: \"{\",\n before: value,\n ...tracker.current(),\n }),\n );\n }\n\n value += tracker.move(formatDirectiveAttributes(node.attributes, context.options));\n\n if (node.children.length > 0) {\n value += tracker.move(\"\\n\");\n value += tracker.move(\n context.flow(node.children, {\n after: \"\\n\",\n before: \"\\n\",\n ...tracker.current(),\n }),\n );\n }\n\n value += tracker.move(`\\n${sequence}`);\n exit();\n\n return value;\n}\n\nexport function formatDirectiveLabel(\n context: FormatContext,\n node: DirectiveLabelNode,\n info: FormatInfo,\n): string {\n const exit = context.enter(\"directiveLabel\");\n const exitLabel = context.enter(\"label\");\n const tracker = new FormatTracker(info);\n const opening = tracker.move(\"[\");\n\n const content = tracker.move(\n context.phrasing(node.children, {\n after: \"]\",\n before: opening,\n ...tracker.current(),\n }),\n );\n\n exitLabel();\n exit();\n\n return `${opening}${content}]`;\n}\n\nexport function containsDirective(node: MdxNode): boolean {\n return (\n node.kind === \"textDirective\" ||\n node.kind === \"leafDirective\" ||\n node.kind === \"containerDirective\" ||\n mdxChildren(node).some(containsDirective)\n );\n}\n\nfunction containerDirectiveFenceSize(node: ContainerDirectiveNode): number {\n let nested = 0;\n\n const visit = (child: MdxNode): void => {\n if (child.kind === \"containerDirective\") {\n nested = Math.max(nested, containerDirectiveFenceSize(child) - 2);\n } else {\n mdxChildren(child).forEach(visit);\n }\n };\n\n node.children.forEach(visit);\n\n return 3 + nested;\n}\n\nfunction formatDirectiveAttributes(\n entries: readonly DirectiveAttribute[],\n options: FormatOptions,\n): string {\n if (entries.length === 0) {\n return \"\";\n }\n\n const shortcut = /^[^\\t\\n\\r \"#'.<=>`}]+$/u;\n const values: string[] = [];\n let id: string | undefined;\n const classes: string[] = [];\n const fullClasses: string[] = [];\n\n for (const entry of entries) {\n if (entry.name === \"id\" && shortcut.test(entry.value)) {\n id = `#${entry.value}`;\n } else if (entry.name === \"class\") {\n for (const className of entry.value.split(/[\\t\\n\\r ]+/u)) {\n if (className.length === 0) {\n continue;\n }\n\n if (shortcut.test(className)) {\n classes.push(className);\n } else {\n fullClasses.push(className);\n }\n }\n } else {\n values.push(formatDirectiveAttribute(entry.name, entry.value, options));\n }\n }\n\n if (fullClasses.length > 0) {\n values.unshift(formatDirectiveAttribute(\"class\", fullClasses.join(\" \"), options));\n }\n\n if (classes.length > 0) {\n values.unshift(`.${classes.join(\".\")}`);\n }\n\n if (id !== undefined) {\n values.unshift(id);\n }\n\n return `{${values.join(\" \")}}`;\n}\n\nfunction formatDirectiveAttribute(name: string, value: string, options: FormatOptions): string {\n if (value.length === 0) {\n return name;\n }\n\n const quote = options.quote ?? '\"';\n\n const encoded = value.replace(/[&\\r\\n\"']/gu, (character) => {\n if (character === \"&\") {\n return \"&amp;\";\n }\n\n if (character === \"\\r\") {\n return \"&#xD;\";\n }\n\n if (character === \"\\n\") {\n return \"&#xA;\";\n }\n\n if (character === quote) {\n return quote === '\"' ? \"&quot;\" : \"&#x27;\";\n }\n\n return character;\n });\n\n return `${name}=${quote}${encoded}${quote}`;\n}\n"],"mappings":";;;AAeA,SAAgB,gBACd,SACA,MACA,MACA,UACQ;CACR,MAAM,OAAO,QAAQ,MAAM,KAAK,IAAI;CACpC,MAAM,UAAU,IAAI,cAAc,IAAI;CACtC,IAAI,QAAQ,QAAQ,KAAK,GAAG,WAAW,KAAK,MAAM;CAElD,IAAI,KAAK,UAAU,KAAA,GACjB,SAAS,QAAQ,KACf,qBAAqB,SAAS,KAAK,OAAO;EACxC,OAAO;EACP,QAAQ;EACR,GAAG,QAAQ,QAAQ;CACrB,CAAC,CACH;CAGF,SAAS,QAAQ,KAAK,0BAA0B,KAAK,YAAY,QAAQ,OAAO,CAAC;CACjF,KAAK;CAEL,OAAO;AACT;AAEA,SAAgB,yBACd,SACA,MACA,MACQ;CACR,MAAM,OAAO,QAAQ,MAAM,oBAAoB;CAC/C,MAAM,UAAU,IAAI,cAAc,IAAI;CACtC,MAAM,WAAW,IAAI,OAAO,4BAA4B,IAAI,CAAC;CAC7D,IAAI,QAAQ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1
+ import { JsxFlowElementNode, JsxTextElementNode } from "./model.mjs";
2
+ import { FormatContext, FormatInfo } from "./format-context.mjs";
3
+ //#region src/format-jsx.d.ts
4
+ export declare function formatJsxTextElement(context: FormatContext, node: JsxTextElementNode, info: FormatInfo): string;
5
+ export declare function formatJsxFlowElement(context: FormatContext, node: JsxFlowElementNode, info: FormatInfo): string;
6
+ export declare function indentExpression(value: string): string;
7
+ //#endregion
8
+ //# sourceMappingURL=format-jsx.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-jsx.d.mts","names":[],"sources":["../src/format-jsx.ts"],"mappings":";;;wBA4BgB,qBACd,SAAS,eACT,MAAM,oBACN,MAAM;wBAeQ,qBACd,SAAS,eACT,MAAM,oBACN,MAAM;wBAyCQ,iBAAiB"}