@temelj/mdx 0.13.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 (369) 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 -8
  119. package/dist/mod.mjs +19 -7
  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 -5
  265. package/dist/plugins/mod.mjs +8 -5
  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 -27
  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/remove-imports-exports.d.mts +0 -10
  353. package/dist/plugins/remove-imports-exports.d.mts.map +0 -1
  354. package/dist/plugins/remove-imports-exports.mjs +0 -15
  355. package/dist/plugins/remove-imports-exports.mjs.map +0 -1
  356. package/dist/plugins/syntax-highlight/code-meta.d.mts +0 -22
  357. package/dist/plugins/syntax-highlight/code-meta.d.mts.map +0 -1
  358. package/dist/plugins/syntax-highlight/code-meta.mjs +0 -38
  359. package/dist/plugins/syntax-highlight/code-meta.mjs.map +0 -1
  360. package/dist/plugins/syntax-highlight/plugin.d.mts +0 -57
  361. package/dist/plugins/syntax-highlight/plugin.d.mts.map +0 -1
  362. package/dist/plugins/syntax-highlight/plugin.mjs +0 -93
  363. package/dist/plugins/syntax-highlight/plugin.mjs.map +0 -1
  364. package/dist/plugins/tree-processor/plugin.d.mts +0 -19
  365. package/dist/plugins/tree-processor/plugin.d.mts.map +0 -1
  366. package/dist/plugins/tree-processor/plugin.mjs +0 -21
  367. package/dist/plugins/tree-processor/plugin.mjs.map +0 -1
  368. package/dist/types.d.mts +0 -2
  369. /package/dist/{types.mjs → parser/block-syntax.mjs} +0 -0
@@ -0,0 +1,34 @@
1
+ import { SourceRange } from "./ranges.mjs";
2
+ import { SourceFile } from "./source.mjs";
3
+ import { CompileOutputFormat } from "./compiler.mjs";
4
+ import { JavaScriptNode } from "./javascript-ast.mjs";
5
+ import { JavaScriptJsxContext } from "./javascript-jsx.mjs";
6
+ //#region src/compile-esm.d.ts
7
+ /** One authored ESM block, parsed once for bindings, JSX, and exports. */
8
+ export interface ParsedEsm {
9
+ readonly code: string;
10
+ readonly origin?: SourceRange;
11
+ readonly program: JavaScriptNode;
12
+ }
13
+ export interface CompiledEsm {
14
+ readonly code: string;
15
+ readonly origin?: SourceRange;
16
+ }
17
+ /**
18
+ * Authored ESM as emitted code. A function body resolves imports through
19
+ * `__resolveMdxImport` and returns its exports, so it records both.
20
+ */
21
+ export interface EmittedEsm {
22
+ readonly blocks: readonly CompiledEsm[];
23
+ /** A default export is the document layout. */
24
+ readonly hasLayout: boolean;
25
+ readonly imports: readonly string[];
26
+ /** Entries of the object a function body returns, such as `"name":local` or `...spread`. */
27
+ readonly exports: readonly string[];
28
+ }
29
+ export declare function parseEsm(code: string, origin: SourceRange | undefined): ParsedEsm;
30
+ /** Names that ESM declares or imports at the top level. */
31
+ export declare function collectEsmBindings(program: JavaScriptNode, names: Set<string>): void;
32
+ export declare function emitEsm(entries: readonly ParsedEsm[], format: CompileOutputFormat, context: JavaScriptJsxContext, file: SourceFile | undefined): EmittedEsm;
33
+ //#endregion
34
+ //# sourceMappingURL=compile-esm.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compile-esm.d.mts","names":[],"sources":["../src/compile-esm.ts"],"mappings":";;;;;;;iBAoBiB;WACN;WACA,SAAS;WACT,SAAS;;iBAGH;WACN;WACA,SAAS;;;;;;iBAOH;WACN,iBAAiB;;WAEjB;WACA;;WAEA;;wBAGK,SAAS,cAAc,QAAQ,0BAA0B;;wBAKzD,mBAAmB,SAAS,gBAAgB,OAAO;wBAcnD,QACd,kBAAkB,aAClB,QAAQ,qBACR,SAAS,sBACT,MAAM,yBACL"}
@@ -0,0 +1,187 @@
1
+ import { CompileError } from "./errors.mjs";
2
+ import { childNode, collectPatternNames, nodeArray, nodeValue } from "./javascript-ast.mjs";
3
+ import { parseJavaScriptProgram } from "./javascript.mjs";
4
+ import { programTransformer } from "./javascript-jsx.mjs";
5
+ import { isString } from "@temelj/value";
6
+ //#region src/compile-esm.ts
7
+ function parseEsm(code, origin) {
8
+ return {
9
+ code,
10
+ origin,
11
+ program: parseJavaScriptProgram(code)
12
+ };
13
+ }
14
+ /** Names that ESM declares or imports at the top level. */
15
+ function collectEsmBindings(program, names) {
16
+ for (const statement of nodeArray(program, "body")) if (statement.type === "ImportDeclaration") for (const specifier of nodeArray(statement, "specifiers")) collectPatternNames(childNode(nodeValue(specifier, "local")), names);
17
+ else if (statement.type === "ExportNamedDeclaration") collectDeclarationNames(childNode(nodeValue(statement, "declaration")), names);
18
+ else collectDeclarationNames(statement, names);
19
+ }
20
+ function emitEsm(entries, format, context, file) {
21
+ const emitter = new EsmEmitter(format, context.names);
22
+ return {
23
+ blocks: entries.map((entry) => ({
24
+ code: emitter.block(entry, programTransformer(entry.code, entry.program, context, entry.origin === void 0 || file === void 0 ? void 0 : {
25
+ file,
26
+ offset: entry.origin.start
27
+ })),
28
+ origin: entry.origin
29
+ })),
30
+ hasLayout: emitter.hasLayout,
31
+ imports: emitter.imports,
32
+ exports: [...emitter.stars, ...emitter.exports]
33
+ };
34
+ }
35
+ /** Rewrites ESM statements for one output format. */
36
+ var EsmEmitter = class {
37
+ #format;
38
+ #names;
39
+ imports = [];
40
+ exports = [];
41
+ /** Star re-exports spread first, so explicit exports win. */
42
+ stars = [];
43
+ hasLayout = false;
44
+ #modules = 0;
45
+ constructor(format, names) {
46
+ this.#format = format;
47
+ this.#names = names;
48
+ }
49
+ block(entry, transform) {
50
+ const { code } = entry;
51
+ const chunks = [];
52
+ let cursor = 0;
53
+ for (const statement of nodeArray(entry.program, "body")) {
54
+ chunks.push(code.slice(cursor, statement.start));
55
+ chunks.push(preserveLineCount(this.statement(statement, code, transform), code.slice(statement.start, statement.end)));
56
+ cursor = statement.end;
57
+ }
58
+ chunks.push(code.slice(cursor));
59
+ return chunks.join("");
60
+ }
61
+ statement(statement, code, transform) {
62
+ switch (statement.type) {
63
+ case "ExportDefaultDeclaration": return this.layout(`(${transform(requiredChild(statement, "declaration"))})`);
64
+ case "ExportNamedDeclaration": return this.namedExport(statement, code, transform);
65
+ case "ImportDeclaration": return this.#format === "program" ? transform(statement) : this.resolve(moduleSpecifier(statement), (module) => importBindings(statement, module));
66
+ case "ExportAllDeclaration": return this.#format === "program" ? transform(statement) : this.starExport(statement);
67
+ default: return transform(statement);
68
+ }
69
+ }
70
+ /** The default export becomes the layout that wraps the content. */
71
+ layout(value) {
72
+ if (this.hasLayout) throw CompileError.multipleDefaultExports();
73
+ this.hasLayout = true;
74
+ return `const ${this.#names.get("Layout")} = ${value};`;
75
+ }
76
+ namedExport(statement, code, transform) {
77
+ const declaration = childNode(nodeValue(statement, "declaration"));
78
+ if (declaration !== void 0) {
79
+ if (this.#format === "program") return transform(statement);
80
+ for (const name of declarationNames(declaration)) this.exports.push(`${JSON.stringify(name)}:${name}`);
81
+ return transform(declaration);
82
+ }
83
+ const from = childNode(nodeValue(statement, "source"));
84
+ const specifiers = nodeArray(statement, "specifiers");
85
+ const layout = specifiers.find((specifier) => identifierValue(childNode(nodeValue(specifier, "exported"))) === "default");
86
+ const remaining = specifiers.filter((specifier) => specifier !== layout);
87
+ if (this.#format === "program") return this.programNamedExport(statement, code, from, layout, remaining);
88
+ const bind = (module) => {
89
+ const local = (specifier) => {
90
+ const name = requiredIdentifier(specifier, "local");
91
+ return module === void 0 ? name : `${module}[${JSON.stringify(name)}]`;
92
+ };
93
+ for (const specifier of remaining) this.exports.push(`${JSON.stringify(requiredIdentifier(specifier, "exported"))}:${local(specifier)}`);
94
+ return layout === void 0 ? "" : this.layout(local(layout));
95
+ };
96
+ return from === void 0 ? bind() : this.resolve(literalString(from), bind);
97
+ }
98
+ programNamedExport(statement, code, from, layout, remaining) {
99
+ if (layout === void 0) return code.slice(statement.start, statement.end);
100
+ const localName = identifierValue(childNode(nodeValue(layout, "local")));
101
+ if (localName === void 0) throw CompileError.defaultExportBindingMissing();
102
+ if (this.hasLayout) throw CompileError.multipleDefaultExports();
103
+ this.hasLayout = true;
104
+ const layoutName = this.#names.get("Layout");
105
+ const layoutDeclaration = from === void 0 ? `const ${layoutName} = ${localName};` : `import {${localName} as ${layoutName}} from ${code.slice(from.start, from.end)};`;
106
+ if (remaining.length === 0) return layoutDeclaration;
107
+ const suffix = from === void 0 ? ";" : ` from ${code.slice(from.start, statement.end).replace(/;?$/u, ";")}`;
108
+ return `${layoutDeclaration}\nexport {${remaining.map((specifier) => code.slice(specifier.start, specifier.end)).join(", ")}}${suffix}`;
109
+ }
110
+ starExport(statement) {
111
+ const exported = childNode(nodeValue(statement, "exported"));
112
+ return this.resolve(moduleSpecifier(statement), (module) => {
113
+ if (exported === void 0) {
114
+ const star = this.#names.get(`__mdxStar${this.#modules}`);
115
+ const ignored = this.#names.get(`__mdxIgnored${this.#modules}`);
116
+ this.stars.push(`...${star}`);
117
+ return `const {default: ${ignored}, ...${star}} = ${module};`;
118
+ }
119
+ this.exports.push(`${JSON.stringify(requiredIdentifierNode(exported))}:${module}`);
120
+ return "";
121
+ });
122
+ }
123
+ /** Resolves a module through the evaluator, then binds names from it. */
124
+ resolve(specifier, bind) {
125
+ const module = this.#names.get(`__mdxModule${this.#modules++}`);
126
+ if (!this.imports.includes(specifier)) this.imports.push(specifier);
127
+ return `const ${module} = await ${this.#names.get("_resolveMdxImport")}(${JSON.stringify(specifier)});${bind(module)}`;
128
+ }
129
+ };
130
+ function importBindings(statement, module) {
131
+ return nodeArray(statement, "specifiers").map((specifier) => {
132
+ const local = requiredIdentifier(specifier, "local");
133
+ if (specifier.type === "ImportNamespaceSpecifier") return `const ${local} = ${module};`;
134
+ if (specifier.type === "ImportDefaultSpecifier") return `const ${local} = ${module}.default;`;
135
+ return `const ${local} = ${module}[${JSON.stringify(requiredIdentifier(specifier, "imported"))}];`;
136
+ }).join("");
137
+ }
138
+ function preserveLineCount(replacement, original) {
139
+ const missingLines = countLineFeeds(original) - countLineFeeds(replacement);
140
+ return missingLines <= 0 ? replacement : `${replacement}${"\n".repeat(missingLines)}`;
141
+ }
142
+ function countLineFeeds(value) {
143
+ let count = 0;
144
+ for (const character of value) if (character === "\n") count++;
145
+ return count;
146
+ }
147
+ function moduleSpecifier(statement) {
148
+ return literalString(requiredChild(statement, "source"));
149
+ }
150
+ function literalString(node) {
151
+ const value = nodeValue(node, "value");
152
+ if (!isString(value)) throw new TypeError("Expected a JavaScript string literal");
153
+ return value;
154
+ }
155
+ function requiredChild(node, key) {
156
+ const child = childNode(nodeValue(node, key));
157
+ if (child === void 0) throw new TypeError(`Expected ${node.type}.${key} to be a JavaScript node`);
158
+ return child;
159
+ }
160
+ function requiredIdentifier(node, key) {
161
+ return requiredIdentifierNode(requiredChild(node, key));
162
+ }
163
+ function requiredIdentifierNode(node) {
164
+ const value = identifierValue(node);
165
+ if (value === void 0) throw new TypeError(`Expected ${node.type} to contain an identifier`);
166
+ return value;
167
+ }
168
+ function identifierValue(node) {
169
+ if (node === void 0) return;
170
+ const name = nodeValue(node, "name");
171
+ const value = nodeValue(node, "value");
172
+ return isString(name) ? name : isString(value) ? value : void 0;
173
+ }
174
+ function declarationNames(declaration) {
175
+ const names = /* @__PURE__ */ new Set();
176
+ collectDeclarationNames(declaration, names);
177
+ return [...names];
178
+ }
179
+ function collectDeclarationNames(node, names) {
180
+ if (node === void 0) return;
181
+ if (node.type === "VariableDeclaration") for (const declaration of nodeArray(node, "declarations")) collectPatternNames(childNode(nodeValue(declaration, "id")), names);
182
+ else if (node.type === "FunctionDeclaration" || node.type === "ClassDeclaration") collectPatternNames(childNode(nodeValue(node, "id")), names);
183
+ }
184
+ //#endregion
185
+ export { collectEsmBindings, emitEsm, parseEsm };
186
+
187
+ //# sourceMappingURL=compile-esm.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compile-esm.mjs","names":[],"sources":["../src/compile-esm.ts"],"sourcesContent":["import { isString } from \"@temelj/value\";\n\nimport type { CompileNames } from \"./compile-names.ts\";\nimport type { CompileOutputFormat } from \"./compiler.ts\";\nimport type { JavaScriptJsxContext } from \"./javascript-jsx.ts\";\nimport type { SourceRange } from \"./ranges.ts\";\nimport type { SourceFile } from \"./source.ts\";\n\nimport { CompileError } from \"./errors.ts\";\nimport {\n childNode,\n collectPatternNames,\n nodeArray,\n nodeValue,\n type JavaScriptNode,\n} from \"./javascript-ast.ts\";\nimport { programTransformer } from \"./javascript-jsx.ts\";\nimport { parseJavaScriptProgram } from \"./javascript.ts\";\n\n/** One authored ESM block, parsed once for bindings, JSX, and exports. */\nexport interface ParsedEsm {\n readonly code: string;\n readonly origin?: SourceRange;\n readonly program: JavaScriptNode;\n}\n\nexport interface CompiledEsm {\n readonly code: string;\n readonly origin?: SourceRange;\n}\n\n/**\n * Authored ESM as emitted code. A function body resolves imports through\n * `__resolveMdxImport` and returns its exports, so it records both.\n */\nexport interface EmittedEsm {\n readonly blocks: readonly CompiledEsm[];\n /** A default export is the document layout. */\n readonly hasLayout: boolean;\n readonly imports: readonly string[];\n /** Entries of the object a function body returns, such as `\"name\":local` or `...spread`. */\n readonly exports: readonly string[];\n}\n\nexport function parseEsm(code: string, origin: SourceRange | undefined): ParsedEsm {\n return { code, origin, program: parseJavaScriptProgram(code) };\n}\n\n/** Names that ESM declares or imports at the top level. */\nexport function collectEsmBindings(program: JavaScriptNode, names: Set<string>): void {\n for (const statement of nodeArray(program, \"body\")) {\n if (statement.type === \"ImportDeclaration\") {\n for (const specifier of nodeArray(statement, \"specifiers\")) {\n collectPatternNames(childNode(nodeValue(specifier, \"local\")), names);\n }\n } else if (statement.type === \"ExportNamedDeclaration\") {\n collectDeclarationNames(childNode(nodeValue(statement, \"declaration\")), names);\n } else {\n collectDeclarationNames(statement, names);\n }\n }\n}\n\nexport function emitEsm(\n entries: readonly ParsedEsm[],\n format: CompileOutputFormat,\n context: JavaScriptJsxContext,\n file: SourceFile | undefined,\n): EmittedEsm {\n const emitter = new EsmEmitter(format, context.names);\n\n const blocks = entries.map((entry): CompiledEsm => ({\n code: emitter.block(\n entry,\n programTransformer(\n entry.code,\n entry.program,\n context,\n entry.origin === undefined || file === undefined\n ? undefined\n : { file, offset: entry.origin.start },\n ),\n ),\n origin: entry.origin,\n }));\n\n return {\n blocks,\n hasLayout: emitter.hasLayout,\n imports: emitter.imports,\n exports: [...emitter.stars, ...emitter.exports],\n };\n}\n\ntype Transform = (node: JavaScriptNode) => string;\n\n/** Rewrites ESM statements for one output format. */\nclass EsmEmitter {\n readonly #format: CompileOutputFormat;\n readonly #names: CompileNames;\n readonly imports: string[] = [];\n readonly exports: string[] = [];\n /** Star re-exports spread first, so explicit exports win. */\n readonly stars: string[] = [];\n hasLayout = false;\n #modules = 0;\n\n public constructor(format: CompileOutputFormat, names: CompileNames) {\n this.#format = format;\n this.#names = names;\n }\n\n public block(entry: ParsedEsm, transform: Transform): string {\n const { code } = entry;\n const chunks: string[] = [];\n let cursor = 0;\n\n for (const statement of nodeArray(entry.program, \"body\")) {\n chunks.push(code.slice(cursor, statement.start));\n // Rewritten statements keep their line count, so source map lines stay aligned.\n chunks.push(\n preserveLineCount(\n this.statement(statement, code, transform),\n code.slice(statement.start, statement.end),\n ),\n );\n cursor = statement.end;\n }\n\n chunks.push(code.slice(cursor));\n\n return chunks.join(\"\");\n }\n\n private statement(statement: JavaScriptNode, code: string, transform: Transform): string {\n switch (statement.type) {\n case \"ExportDefaultDeclaration\":\n return this.layout(`(${transform(requiredChild(statement, \"declaration\"))})`);\n case \"ExportNamedDeclaration\":\n return this.namedExport(statement, code, transform);\n case \"ImportDeclaration\":\n return this.#format === \"program\"\n ? transform(statement)\n : this.resolve(moduleSpecifier(statement), (module) => importBindings(statement, module));\n case \"ExportAllDeclaration\":\n return this.#format === \"program\" ? transform(statement) : this.starExport(statement);\n default:\n return transform(statement);\n }\n }\n\n /** The default export becomes the layout that wraps the content. */\n private layout(value: string): string {\n if (this.hasLayout) {\n throw CompileError.multipleDefaultExports();\n }\n\n this.hasLayout = true;\n\n return `const ${this.#names.get(\"Layout\")} = ${value};`;\n }\n\n private namedExport(statement: JavaScriptNode, code: string, transform: Transform): string {\n const declaration = childNode(nodeValue(statement, \"declaration\"));\n\n if (declaration !== undefined) {\n if (this.#format === \"program\") {\n return transform(statement);\n }\n\n for (const name of declarationNames(declaration)) {\n this.exports.push(`${JSON.stringify(name)}:${name}`);\n }\n\n return transform(declaration);\n }\n\n const from = childNode(nodeValue(statement, \"source\"));\n const specifiers = nodeArray(statement, \"specifiers\");\n\n const layout = specifiers.find(\n (specifier) => identifierValue(childNode(nodeValue(specifier, \"exported\"))) === \"default\",\n );\n\n const remaining = specifiers.filter((specifier) => specifier !== layout);\n\n if (this.#format === \"program\") {\n return this.programNamedExport(statement, code, from, layout, remaining);\n }\n\n const bind = (module?: string): string => {\n const local = (specifier: JavaScriptNode): string => {\n const name = requiredIdentifier(specifier, \"local\");\n\n return module === undefined ? name : `${module}[${JSON.stringify(name)}]`;\n };\n\n for (const specifier of remaining) {\n this.exports.push(\n `${JSON.stringify(requiredIdentifier(specifier, \"exported\"))}:${local(specifier)}`,\n );\n }\n\n return layout === undefined ? \"\" : this.layout(local(layout));\n };\n\n return from === undefined ? bind() : this.resolve(literalString(from), bind);\n }\n\n private programNamedExport(\n statement: JavaScriptNode,\n code: string,\n from: JavaScriptNode | undefined,\n layout: JavaScriptNode | undefined,\n remaining: readonly JavaScriptNode[],\n ): string {\n if (layout === undefined) {\n return code.slice(statement.start, statement.end);\n }\n\n const localName = identifierValue(childNode(nodeValue(layout, \"local\")));\n\n if (localName === undefined) {\n throw CompileError.defaultExportBindingMissing();\n }\n\n if (this.hasLayout) {\n throw CompileError.multipleDefaultExports();\n }\n\n this.hasLayout = true;\n const layoutName = this.#names.get(\"Layout\");\n\n const layoutDeclaration =\n from === undefined\n ? `const ${layoutName} = ${localName};`\n : `import {${localName} as ${layoutName}} from ${code.slice(from.start, from.end)};`;\n\n if (remaining.length === 0) {\n return layoutDeclaration;\n }\n\n const suffix =\n from === undefined\n ? \";\"\n : ` from ${code.slice(from.start, statement.end).replace(/;?$/u, \";\")}`;\n\n return `${layoutDeclaration}\\nexport {${remaining\n .map((specifier) => code.slice(specifier.start, specifier.end))\n .join(\", \")}}${suffix}`;\n }\n\n private starExport(statement: JavaScriptNode): string {\n const exported = childNode(nodeValue(statement, \"exported\"));\n\n return this.resolve(moduleSpecifier(statement), (module) => {\n if (exported === undefined) {\n const star = this.#names.get(`__mdxStar${this.#modules}`);\n const ignored = this.#names.get(`__mdxIgnored${this.#modules}`);\n this.stars.push(`...${star}`);\n\n return `const {default: ${ignored}, ...${star}} = ${module};`;\n }\n\n this.exports.push(`${JSON.stringify(requiredIdentifierNode(exported))}:${module}`);\n\n return \"\";\n });\n }\n\n /** Resolves a module through the evaluator, then binds names from it. */\n private resolve(specifier: string, bind: (module: string) => string): string {\n const module = this.#names.get(`__mdxModule${this.#modules++}`);\n\n if (!this.imports.includes(specifier)) {\n this.imports.push(specifier);\n }\n\n return `const ${module} = await ${this.#names.get(\"_resolveMdxImport\")}(${JSON.stringify(specifier)});${bind(module)}`;\n }\n}\n\nfunction importBindings(statement: JavaScriptNode, module: string): string {\n return nodeArray(statement, \"specifiers\")\n .map((specifier) => {\n const local = requiredIdentifier(specifier, \"local\");\n\n if (specifier.type === \"ImportNamespaceSpecifier\") {\n return `const ${local} = ${module};`;\n }\n\n if (specifier.type === \"ImportDefaultSpecifier\") {\n return `const ${local} = ${module}.default;`;\n }\n\n return `const ${local} = ${module}[${JSON.stringify(requiredIdentifier(specifier, \"imported\"))}];`;\n })\n .join(\"\");\n}\n\nfunction preserveLineCount(replacement: string, original: string): string {\n const missingLines = countLineFeeds(original) - countLineFeeds(replacement);\n\n return missingLines <= 0 ? replacement : `${replacement}${\"\\n\".repeat(missingLines)}`;\n}\n\nfunction countLineFeeds(value: string): number {\n let count = 0;\n\n for (const character of value) {\n if (character === \"\\n\") {\n count++;\n }\n }\n\n return count;\n}\n\nfunction moduleSpecifier(statement: JavaScriptNode): string {\n return literalString(requiredChild(statement, \"source\"));\n}\n\nfunction literalString(node: JavaScriptNode): string {\n const value = nodeValue(node, \"value\");\n\n if (!isString(value)) {\n throw new TypeError(\"Expected a JavaScript string literal\");\n }\n\n return value;\n}\n\nfunction requiredChild(node: JavaScriptNode, key: string): JavaScriptNode {\n const child = childNode(nodeValue(node, key));\n\n if (child === undefined) {\n throw new TypeError(`Expected ${node.type}.${key} to be a JavaScript node`);\n }\n\n return child;\n}\n\nfunction requiredIdentifier(node: JavaScriptNode, key: string): string {\n return requiredIdentifierNode(requiredChild(node, key));\n}\n\nfunction requiredIdentifierNode(node: JavaScriptNode): string {\n const value = identifierValue(node);\n\n if (value === undefined) {\n throw new TypeError(`Expected ${node.type} to contain an identifier`);\n }\n\n return value;\n}\n\nfunction identifierValue(node: JavaScriptNode | undefined): string | undefined {\n if (node === undefined) {\n return undefined;\n }\n\n const name = nodeValue(node, \"name\");\n const value = nodeValue(node, \"value\");\n\n return isString(name) ? name : isString(value) ? value : undefined;\n}\n\nfunction declarationNames(declaration: JavaScriptNode): string[] {\n const names = new Set<string>();\n collectDeclarationNames(declaration, names);\n\n return [...names];\n}\n\nfunction collectDeclarationNames(node: JavaScriptNode | undefined, names: Set<string>): void {\n if (node === undefined) {\n return;\n }\n\n if (node.type === \"VariableDeclaration\") {\n for (const declaration of nodeArray(node, \"declarations\")) {\n collectPatternNames(childNode(nodeValue(declaration, \"id\")), names);\n }\n } else if (node.type === \"FunctionDeclaration\" || node.type === \"ClassDeclaration\") {\n collectPatternNames(childNode(nodeValue(node, \"id\")), names);\n }\n}\n"],"mappings":";;;;;;AA4CA,SAAgB,SAAS,MAAc,QAA4C;CACjF,OAAO;EAAE;EAAM;EAAQ,SAAS,uBAAuB,IAAI;CAAE;AAC/D;;AAGA,SAAgB,mBAAmB,SAAyB,OAA0B;CACpF,KAAK,MAAM,aAAa,UAAU,SAAS,MAAM,GAC/C,IAAI,UAAU,SAAS,qBACrB,KAAK,MAAM,aAAa,UAAU,WAAW,YAAY,GACvD,oBAAoB,UAAU,UAAU,WAAW,OAAO,CAAC,GAAG,KAAK;MAEhE,IAAI,UAAU,SAAS,0BAC5B,wBAAwB,UAAU,UAAU,WAAW,aAAa,CAAC,GAAG,KAAK;MAE7E,wBAAwB,WAAW,KAAK;AAG9C;AAEA,SAAgB,QACd,SACA,QACA,SACA,MACY;CACZ,MAAM,UAAU,IAAI,WAAW,QAAQ,QAAQ,KAAK;CAiBpD,OAAO;EACL,QAhBa,QAAQ,KAAK,WAAwB;GAClD,MAAM,QAAQ,MACZ,OACA,mBACE,MAAM,MACN,MAAM,SACN,SACA,MAAM,WAAW,KAAA,KAAa,SAAS,KAAA,IACnC,KAAA,IACA;IAAE;IAAM,QAAQ,MAAM,OAAO;GAAM,CACzC,CACF;GACA,QAAQ,MAAM;EAChB,EAGO;EACL,WAAW,QAAQ;EACnB,SAAS,QAAQ;EACjB,SAAS,CAAC,GAAG,QAAQ,OAAO,GAAG,QAAQ,OAAO;CAChD;AACF;;AAKA,IAAM,aAAN,MAAiB;CACf;CACA;CACA,UAA6B,CAAC;CAC9B,UAA6B,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AElC,IAAI,UAAU,KAAA,GACZ,MAAM,IAAI,UAAU,YAAY,KAAK,KAAK,0BAA0B;CAGtE,OAAO;AACT;AAEA,SAAS,gBAAgB,MAAsD;CAC7E,IAAI,SAAS,KAAA,GACX;CAGF,MAAM,OAAO,UAAU,MAAM,MAAM;CACnC,MAAM,QAAQ,UAAU,MAAM,OAAO;CAErC,OAAO,SAAS,IAAI,IAAI,OAAO,SAAS,KAAK,IAAI,QAAQ,KAAA;AAC3D;AAEA,SAAS,iBAAiB,aAAuC;CAC/D,MAAM,wBAAQ,IAAI,IAAY;CAC9B,wBAAwB,aAAa,KAAK;CAE1C,OAAO,CAAC,GAAG,KAAK;AAClB;AAEA,SAAS,wBAAwB,MAAkC,OAA0B;CAC3F,IAAI,SAAS,KAAA,GACX;CAGF,IAAI,KAAK,SAAS,uBAChB,KAAK,MAAM,eAAe,UAAU,MAAM,cAAc,GACtD,oBAAoB,UAAU,UAAU,aAAa,IAAI,CAAC,GAAG,KAAK;MAE/D,IAAI,KAAK,SAAS,yBAAyB,KAAK,SAAS,oBAC9D,oBAAoB,UAAU,UAAU,MAAM,IAAI,CAAC,GAAG,KAAK;AAE/D"}
@@ -0,0 +1,13 @@
1
+ import { JavaScriptNode } from "./javascript-ast.mjs";
2
+ //#region src/compile-names.d.ts
3
+ type CompileName = "Content" | "Layout" | "ReferenceError" | "_props" | "_components" | "_createContent" | "_Fragment" | "_jsx" | "_jsxs" | "_jsxDEV" | "_missingReference" | "_provideComponents" | "_resolveMdxImport" | `__mdxModule${number}` | `__mdxStar${number}` | `__mdxIgnored${number}`;
4
+ /** Reserves authored identifiers before assigning stable names to generated bindings. */
5
+ export declare class CompileNames {
6
+ #private;
7
+ reserve(name: string): void;
8
+ reserveJavaScript(node: JavaScriptNode): void;
9
+ get(preferred: CompileName): string;
10
+ }
11
+ //#endregion
12
+ export {};
13
+ //# sourceMappingURL=compile-names.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compile-names.d.mts","names":[],"sources":["../src/compile-names.ts"],"mappings":";;KAIK;;qBAmBQ;;EAIJ,QAAQ;EAIR,kBAAkB,MAAM;EAcxB,IAAI,WAAW"}
@@ -0,0 +1,32 @@
1
+ import { javascriptChildren, nodeValue } from "./javascript-ast.mjs";
2
+ import { isString } from "@temelj/value";
3
+ //#region src/compile-names.ts
4
+ /** Reserves authored identifiers before assigning stable names to generated bindings. */
5
+ var CompileNames = class {
6
+ #used = /* @__PURE__ */ new Set();
7
+ #generated = /* @__PURE__ */ new Map();
8
+ reserve(name) {
9
+ this.#used.add(name);
10
+ }
11
+ reserveJavaScript(node) {
12
+ if (node.type === "Identifier" || node.type === "JSXIdentifier") {
13
+ const name = nodeValue(node, "name");
14
+ if (isString(name)) this.reserve(name);
15
+ }
16
+ for (const child of javascriptChildren(node)) this.reserveJavaScript(child);
17
+ }
18
+ get(preferred) {
19
+ const existing = this.#generated.get(preferred);
20
+ if (existing !== void 0) return existing;
21
+ let name = preferred;
22
+ let suffix = 0;
23
+ while (this.#used.has(name)) name = `${preferred}${++suffix}`;
24
+ this.#used.add(name);
25
+ this.#generated.set(preferred, name);
26
+ return name;
27
+ }
28
+ };
29
+ //#endregion
30
+ export { CompileNames };
31
+
32
+ //# sourceMappingURL=compile-names.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compile-names.mjs","names":[],"sources":["../src/compile-names.ts"],"sourcesContent":["import { isString } from \"@temelj/value\";\n\nimport { javascriptChildren, nodeValue, type JavaScriptNode } from \"./javascript-ast.ts\";\n\ntype CompileName =\n | \"Content\"\n | \"Layout\"\n | \"ReferenceError\"\n | \"_props\"\n | \"_components\"\n | \"_createContent\"\n | \"_Fragment\"\n | \"_jsx\"\n | \"_jsxs\"\n | \"_jsxDEV\"\n | \"_missingReference\"\n | \"_provideComponents\"\n | \"_resolveMdxImport\"\n | `__mdxModule${number}`\n | `__mdxStar${number}`\n | `__mdxIgnored${number}`;\n\n/** Reserves authored identifiers before assigning stable names to generated bindings. */\nexport class CompileNames {\n readonly #used = new Set<string>();\n readonly #generated = new Map<CompileName, string>();\n\n public reserve(name: string): void {\n this.#used.add(name);\n }\n\n public reserveJavaScript(node: JavaScriptNode): void {\n if (node.type === \"Identifier\" || node.type === \"JSXIdentifier\") {\n const name = nodeValue(node, \"name\");\n\n if (isString(name)) {\n this.reserve(name);\n }\n }\n\n for (const child of javascriptChildren(node)) {\n this.reserveJavaScript(child);\n }\n }\n\n public get(preferred: CompileName): string {\n const existing = this.#generated.get(preferred);\n\n if (existing !== undefined) {\n return existing;\n }\n\n let name: string = preferred;\n let suffix = 0;\n\n while (this.#used.has(name)) {\n name = `${preferred}${++suffix}`;\n }\n\n this.#used.add(name);\n this.#generated.set(preferred, name);\n\n return name;\n }\n}\n"],"mappings":";;;;AAuBA,IAAa,eAAb,MAA0B;CACxB,wBAAiB,IAAI,IAAY;CACjC,6BAAsB,IAAI,IAAyB;CAEnD,QAAe,MAAoB;EACjC,KAAK,MAAM,IAAI,IAAI;CACrB;CAEA,kBAAyB,MAA4B;EACnD,IAAI,KAAK,SAAS,gBAAgB,KAAK,SAAS,iBAAiB;GAC/D,MAAM,OAAO,UAAU,MAAM,MAAM;GAEnC,IAAI,SAAS,IAAI,GACf,KAAK,QAAQ,IAAI;EAErB;EAEA,KAAK,MAAM,SAAS,mBAAmB,IAAI,GACzC,KAAK,kBAAkB,KAAK;CAEhC;CAEA,IAAW,WAAgC;EACzC,MAAM,WAAW,KAAK,WAAW,IAAI,SAAS;EAE9C,IAAI,aAAa,KAAA,GACf,OAAO;EAGT,IAAI,OAAe;EACnB,IAAI,SAAS;EAEb,OAAO,KAAK,MAAM,IAAI,IAAI,GACxB,OAAO,GAAG,YAAY,EAAE;EAG1B,KAAK,MAAM,IAAI,IAAI;EACnB,KAAK,WAAW,IAAI,WAAW,IAAI;EAEnC,OAAO;CACT;AACF"}
@@ -1,98 +1,82 @@
1
- import { HastNode as Node } from "./types.mjs";
2
- import { CompileOptions } from "@mdx-js/mdx";
3
- import remarkFrontmatterPlugin from "remark-frontmatter";
4
- import remarkGfmPlugin from "remark-gfm";
5
- import { StandardSchemaV1 } from "@standard-schema/spec";
6
- import { Plugin } from "unified";
1
+ import { FrontmatterObject } from "./model.mjs";
2
+ import { HtmlRenderOptions } from "./html-lower.mjs";
3
+ import { ParseResult } from "./parser.mjs";
4
+ import { SourceMap } from "./source-map.mjs";
5
+ import { Schema, SchemaOutput } from "@temelj/standard-schema";
7
6
  //#region src/compiler.d.ts
7
+ /** Compiled content renders the same elements as `lowerHtml` with these options. */
8
+ export interface CompileOptions extends HtmlRenderOptions {
9
+ /** Emit `jsxDEV` calls with authored source locations. */
10
+ readonly development?: boolean;
11
+ /** Package providing `jsx-runtime`. */
12
+ readonly jsxImportSource?: string;
13
+ /** Maximum UTF-8 size of generated JavaScript. */
14
+ readonly maximumGeneratedCodeBytes?: number;
15
+ /** Maximum UTF-8 size of the serialized source map. */
16
+ readonly maximumSourceMapBytes?: number;
17
+ /** Optional generated filename written into the source map. */
18
+ readonly outputName?: string;
19
+ /** Optional package providing a `useMDXComponents` export. */
20
+ readonly providerImportSource?: string;
21
+ /** Original MDX filename written into the source map. */
22
+ readonly sourceName?: string;
23
+ /** JavaScript shape emitted by the compiler. */
24
+ readonly outputFormat?: CompileOutputFormat;
25
+ }
26
+ export type CompileOutputFormat = "functionBody" | "program";
8
27
  /**
9
- * Represents the source content for an MDX document.
10
- */
11
- type MdxSource = string | Uint8Array;
12
- /**
13
- * Options for compiling an MDX document.
28
+ * The components compiled content reads from `props.components`: element
29
+ * overrides by tag name, authored JSX components by name, and three reserved
30
+ * entries whose names cannot collide with either.
14
31
  */
15
- interface MdxCompileOptions {
16
- frontmatterOnly?: boolean | undefined;
17
- mdxOptions?: CompileOptions;
32
+ export interface CompiledComponents<TComponent = unknown> {
33
+ readonly [name: string]: TComponent | undefined;
34
+ /** Receives `code`, `language`, `meta`, `node`, and `status`. Defaults to `<pre><code>`. */
35
+ readonly codeBlock?: TComponent;
36
+ /** Receives `source`, `style`, and `meta`. Defaults to a readable code fallback. */
37
+ readonly mathFormula?: TComponent;
38
+ /** Wraps the whole document and receives its props plus `children`. */
39
+ readonly wrapper?: TComponent;
18
40
  }
19
- interface MdxMessagePoint {
20
- line?: number | undefined;
21
- column?: number | undefined;
22
- offset?: number | undefined;
41
+ export type MdxTransportValue = null | boolean | number | bigint | string | readonly MdxTransportValue[] | Readonly<{
42
+ [key: string]: MdxTransportValue;
43
+ }>;
44
+ interface CompileArtifactBase {
45
+ readonly code: string;
46
+ readonly frontmatter: MdxTransportValue;
47
+ readonly map: SourceMap;
23
48
  }
24
- interface MdxMessagePlace {
25
- start?: MdxMessagePoint | undefined;
26
- end?: MdxMessagePoint | undefined;
49
+ export interface ProgramCompileArtifact extends CompileArtifactBase {
50
+ readonly format: "program";
27
51
  }
28
- interface MdxMessage {
29
- message: string;
30
- reason: string;
31
- source?: string | undefined;
32
- ruleId?: string | undefined;
33
- fatal?: boolean | undefined;
34
- line?: number | undefined;
35
- column?: number | undefined;
36
- place?: MdxMessagePlace | undefined;
37
- sourceLine?: string | undefined;
38
- snippet?: string | undefined;
39
- sourcePointer?: string | undefined;
40
- hint?: string | undefined;
41
- cause?: {
42
- name?: string | undefined;
43
- message: string;
44
- };
52
+ export interface FunctionBodyCompileArtifact extends CompileArtifactBase {
53
+ readonly format: "functionBody";
54
+ readonly imports: readonly string[];
45
55
  }
46
- /**
47
- * The result of compiling an MDX document.
48
- * Compiled content is optional, because sometimes we only need the frontmatter.
49
- */
50
- interface MdxArtifact<TFrontmatter = Record<string, unknown>> {
51
- compiled?: string | undefined;
52
- frontmatter: TFrontmatter;
53
- messages: MdxMessage[];
56
+ export type CompileArtifact = ProgramCompileArtifact | FunctionBodyCompileArtifact;
57
+ export interface CompileSchemaOptions<TSchema extends Schema> extends CompileOptions {
58
+ /** Standard Schema validation for decoded frontmatter. */
59
+ readonly frontmatterSchema: TSchema;
54
60
  }
55
- declare class MdxCompileError extends Error {
56
- readonly reason: string;
57
- readonly source?: string | undefined;
58
- readonly ruleId?: string | undefined;
59
- readonly line?: number | undefined;
60
- readonly column?: number | undefined;
61
- readonly place?: MdxMessagePlace | undefined;
62
- readonly sourceLine?: string | undefined;
63
- readonly snippet?: string | undefined;
64
- readonly sourcePointer?: string | undefined;
65
- readonly hint?: string | undefined;
66
- readonly diagnostics: MdxMessage[];
67
- constructor(reason: string, options?: {
68
- source?: string | undefined;
69
- ruleId?: string | undefined;
70
- line?: number | undefined;
71
- column?: number | undefined;
72
- place?: MdxMessagePlace | undefined;
73
- sourceLine?: string | undefined;
74
- snippet?: string | undefined;
75
- sourcePointer?: string | undefined;
76
- hint?: string | undefined;
77
- causeMessage?: string | undefined;
78
- diagnostics?: MdxMessage[] | undefined;
79
- cause?: unknown;
80
- }, context?: Function);
81
- static create(this: void, reason: string, options?: ConstructorParameters<typeof MdxCompileError>[1]): MdxCompileError;
61
+ export interface CompileResult<TFrontmatter = FrontmatterObject, TFormat extends CompileOutputFormat = CompileOutputFormat> extends ParseResult {
62
+ readonly artifact: Extract<CompileArtifact, {
63
+ readonly format: TFormat;
64
+ }>;
65
+ readonly frontmatter: TFrontmatter;
82
66
  }
83
67
  /**
84
- * A reusable compiler for compiling MDX.
68
+ * Validates frontmatter and compiles a parsed or transformed document without executing it.
69
+ * @throws {FrontmatterError} Invalid schema output or unsupported transport data.
70
+ * @throws {LimitError} Generated code or its source map exceeds a configured limit.
71
+ * @throws {CompileError} JavaScript generation fails.
72
+ * @throws {ConfigurationError} Invalid compiler options.
85
73
  */
86
- declare class MdxCompiler {
87
- private readonly mdxOptions;
88
- private readonly remarkPlugins;
89
- private readonly rehypePlugins;
90
- constructor(mdxOptions?: CompileOptions);
91
- withRemarkPlugin<TOptions>(plugin: Plugin<[TOptions?], Node, Node>, options?: TOptions): MdxCompiler;
92
- withRehypePlugin<TOptions>(plugin: Plugin<[TOptions?], Node, Node>, options?: TOptions): MdxCompiler;
93
- compile(source: MdxSource, options?: MdxCompileOptions): Promise<MdxArtifact<Record<string, unknown>>>;
94
- compile<TFrontmatterSchema extends StandardSchemaV1>(source: MdxSource, options: MdxCompileOptions | undefined, frontmatterSchema: TFrontmatterSchema): Promise<MdxArtifact<StandardSchemaV1.InferOutput<TFrontmatterSchema>>>;
95
- }
74
+ export declare function compile<TSchema extends Schema, TFormat extends CompileOutputFormat = "functionBody">(input: ParseResult, options: Readonly<CompileSchemaOptions<TSchema> & {
75
+ readonly outputFormat?: TFormat;
76
+ }>): Promise<CompileResult<SchemaOutput<TSchema>, TFormat>>;
77
+ export declare function compile<TFormat extends CompileOutputFormat = "functionBody">(input: ParseResult, options?: Readonly<CompileOptions & {
78
+ readonly outputFormat?: TFormat;
79
+ }>): Promise<CompileResult<FrontmatterObject, TFormat>>;
96
80
  //#endregion
97
- export { MdxArtifact, MdxCompileError, MdxCompileOptions, MdxCompiler, MdxMessage, MdxMessagePlace, MdxMessagePoint, MdxSource, remarkFrontmatterPlugin, remarkGfmPlugin };
81
+ export {};
98
82
  //# sourceMappingURL=compiler.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"compiler.d.mts","names":[],"sources":["../src/compiler.ts"],"mappings":";;;;;;;;;;KAiBY,qBAAqB;;;;UAKhB;EACf;EACA,aAAa;;UAGE;EACf;EACA;EACA;;UAGe;EACf,QAAQ;EACR,MAAM;;UAGS;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA,QAAQ;EACR;EACA;EACA;EACA;EACA;IACE;IACA;;;;;;;UAea,YAAY,eAAe;EAC1C;EACA,aAAa;EACb,UAAU;;cAGC,wBAAwB;WACnB;WACA;WACA;WACA;WACA;WACA,QAAQ;WACR;WACA;WACA;WACA;WACA,aAAa;EAE7B,YACE,gBACA;IACE;IACA;IACA;IACA;IACA,QAAQ;IACR;IACA;IACA;IACA;IACA;IACA,cAAc;IACd;KAEF,UAAU;SAmCL,OACL,YACA,gBACA,UAAS,6BAA6B,sBACrC;;;;;cAQQ;mBACM;mBACA;mBACA;EAEjB,YAAmB,aAAY;E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