@depup/nextra 4.6.1-depup.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 (293) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +56 -0
  3. package/changes.json +110 -0
  4. package/dist/client/components/banner/close-banner-button.d.ts +8 -0
  5. package/dist/client/components/banner/close-banner-button.js +45 -0
  6. package/dist/client/components/banner/index.client.d.ts +5 -0
  7. package/dist/client/components/banner/index.client.js +46 -0
  8. package/dist/client/components/banner/index.d.ts +51 -0
  9. package/dist/client/components/banner/index.js +93 -0
  10. package/dist/client/components/bleed.d.ts +63 -0
  11. package/dist/client/components/bleed.js +54 -0
  12. package/dist/client/components/button.d.ts +9 -0
  13. package/dist/client/components/button.js +55 -0
  14. package/dist/client/components/callout.d.ts +136 -0
  15. package/dist/client/components/callout.js +99 -0
  16. package/dist/client/components/cards.d.ts +104 -0
  17. package/dist/client/components/cards.js +132 -0
  18. package/dist/client/components/collapse.d.ts +12 -0
  19. package/dist/client/components/collapse.js +143 -0
  20. package/dist/client/components/file-tree/file.d.ts +9 -0
  21. package/dist/client/components/file-tree/file.js +43 -0
  22. package/dist/client/components/file-tree/folder.d.ts +12 -0
  23. package/dist/client/components/file-tree/folder.js +94 -0
  24. package/dist/client/components/file-tree/index.d.ts +57 -0
  25. package/dist/client/components/file-tree/index.js +12 -0
  26. package/dist/client/components/file-tree/tree.d.ts +5 -0
  27. package/dist/client/components/file-tree/tree.js +41 -0
  28. package/dist/client/components/head.d.ts +139 -0
  29. package/dist/client/components/head.js +202 -0
  30. package/dist/client/components/image-zoom.d.ts +6 -0
  31. package/dist/client/components/image-zoom.js +79 -0
  32. package/dist/client/components/index.d.ts +56 -0
  33. package/dist/client/components/index.js +42 -0
  34. package/dist/client/components/playground.d.ts +90 -0
  35. package/dist/client/components/playground.js +103 -0
  36. package/dist/client/components/popup/index.client.d.ts +7 -0
  37. package/dist/client/components/popup/index.client.js +83 -0
  38. package/dist/client/components/popup/index.d.ts +12 -0
  39. package/dist/client/components/popup/index.js +11 -0
  40. package/dist/client/components/search.d.ts +88 -0
  41. package/dist/client/components/search.js +426 -0
  42. package/dist/client/components/select.d.ts +19 -0
  43. package/dist/client/components/select.js +109 -0
  44. package/dist/client/components/skip-nav/index.client.d.ts +5 -0
  45. package/dist/client/components/skip-nav/index.client.js +45 -0
  46. package/dist/client/components/skip-nav/index.d.ts +6 -0
  47. package/dist/client/components/skip-nav/index.js +24 -0
  48. package/dist/client/components/steps.d.ts +64 -0
  49. package/dist/client/components/steps.js +74 -0
  50. package/dist/client/components/tabs/index.client.d.ts +21 -0
  51. package/dist/client/components/tabs/index.client.js +243 -0
  52. package/dist/client/components/tabs/index.d.ts +53 -0
  53. package/dist/client/components/tabs/index.js +9 -0
  54. package/dist/client/evaluate.d.ts +30 -0
  55. package/dist/client/evaluate.js +17 -0
  56. package/dist/client/hocs/index.d.ts +4 -0
  57. package/dist/client/hocs/index.js +6 -0
  58. package/dist/client/hocs/with-github-alert.d.ts +11 -0
  59. package/dist/client/hocs/with-github-alert.js +30 -0
  60. package/dist/client/hocs/with-icons.d.ts +6 -0
  61. package/dist/client/hocs/with-icons.js +76 -0
  62. package/dist/client/hooks/index.d.ts +4 -0
  63. package/dist/client/hooks/index.js +10 -0
  64. package/dist/client/hooks/use-copy.d.ts +9 -0
  65. package/dist/client/hooks/use-copy.js +77 -0
  66. package/dist/client/hooks/use-fs-route.d.ts +3 -0
  67. package/dist/client/hooks/use-fs-route.js +20 -0
  68. package/dist/client/hooks/use-hash.d.ts +3 -0
  69. package/dist/client/hooks/use-hash.js +20 -0
  70. package/dist/client/hooks/use-mounted.d.ts +3 -0
  71. package/dist/client/hooks/use-mounted.js +13 -0
  72. package/dist/client/icons/arrow-right.d.ts +5 -0
  73. package/dist/client/icons/arrow-right.js +24 -0
  74. package/dist/client/icons/chatgpt.d.ts +2 -0
  75. package/dist/client/icons/chatgpt.js +24 -0
  76. package/dist/client/icons/check.d.ts +2 -0
  77. package/dist/client/icons/check.js +24 -0
  78. package/dist/client/icons/claude.d.ts +2 -0
  79. package/dist/client/icons/claude.js +81 -0
  80. package/dist/client/icons/copy.d.ts +2 -0
  81. package/dist/client/icons/copy.js +31 -0
  82. package/dist/client/icons/cpp.d.ts +2 -0
  83. package/dist/client/icons/cpp.js +24 -0
  84. package/dist/client/icons/cross-circled.d.ts +2 -0
  85. package/dist/client/icons/cross-circled.js +24 -0
  86. package/dist/client/icons/csharp.d.ts +2 -0
  87. package/dist/client/icons/csharp.js +24 -0
  88. package/dist/client/icons/css.d.ts +2 -0
  89. package/dist/client/icons/css.js +24 -0
  90. package/dist/client/icons/discord.d.ts +2 -0
  91. package/dist/client/icons/discord.js +24 -0
  92. package/dist/client/icons/expand.d.ts +2 -0
  93. package/dist/client/icons/expand.js +31 -0
  94. package/dist/client/icons/file.d.ts +2 -0
  95. package/dist/client/icons/file.js +24 -0
  96. package/dist/client/icons/folder-open.d.ts +2 -0
  97. package/dist/client/icons/folder-open.js +24 -0
  98. package/dist/client/icons/folder.d.ts +2 -0
  99. package/dist/client/icons/folder.js +24 -0
  100. package/dist/client/icons/github-caution.d.ts +2 -0
  101. package/dist/client/icons/github-caution.js +24 -0
  102. package/dist/client/icons/github-important.d.ts +2 -0
  103. package/dist/client/icons/github-important.js +24 -0
  104. package/dist/client/icons/github-note.d.ts +2 -0
  105. package/dist/client/icons/github-note.js +24 -0
  106. package/dist/client/icons/github-tip.d.ts +2 -0
  107. package/dist/client/icons/github-tip.js +24 -0
  108. package/dist/client/icons/github-warning.d.ts +2 -0
  109. package/dist/client/icons/github-warning.js +24 -0
  110. package/dist/client/icons/github.d.ts +2 -0
  111. package/dist/client/icons/github.js +24 -0
  112. package/dist/client/icons/globe.d.ts +2 -0
  113. package/dist/client/icons/globe.js +24 -0
  114. package/dist/client/icons/go.d.ts +2 -0
  115. package/dist/client/icons/go.js +46 -0
  116. package/dist/client/icons/graphql.d.ts +2 -0
  117. package/dist/client/icons/graphql.js +56 -0
  118. package/dist/client/icons/index.d.ts +2 -0
  119. package/dist/client/icons/index.js +92 -0
  120. package/dist/client/icons/javascript.d.ts +2 -0
  121. package/dist/client/icons/javascript.js +24 -0
  122. package/dist/client/icons/json.d.ts +2 -0
  123. package/dist/client/icons/json.js +41 -0
  124. package/dist/client/icons/link-arrow.d.ts +2 -0
  125. package/dist/client/icons/link-arrow.js +31 -0
  126. package/dist/client/icons/link.d.ts +2 -0
  127. package/dist/client/icons/link.js +24 -0
  128. package/dist/client/icons/markdown.d.ts +2 -0
  129. package/dist/client/icons/markdown.js +24 -0
  130. package/dist/client/icons/mdx.d.ts +2 -0
  131. package/dist/client/icons/mdx.js +24 -0
  132. package/dist/client/icons/menu.d.ts +2 -0
  133. package/dist/client/icons/menu.js +36 -0
  134. package/dist/client/icons/moon.d.ts +2 -0
  135. package/dist/client/icons/moon.js +24 -0
  136. package/dist/client/icons/move.d.ts +2 -0
  137. package/dist/client/icons/move.js +24 -0
  138. package/dist/client/icons/python.d.ts +2 -0
  139. package/dist/client/icons/python.js +31 -0
  140. package/dist/client/icons/react.d.ts +2 -0
  141. package/dist/client/icons/react.js +38 -0
  142. package/dist/client/icons/rust.d.ts +2 -0
  143. package/dist/client/icons/rust.js +31 -0
  144. package/dist/client/icons/spinner.d.ts +2 -0
  145. package/dist/client/icons/spinner.js +31 -0
  146. package/dist/client/icons/sun.d.ts +2 -0
  147. package/dist/client/icons/sun.js +24 -0
  148. package/dist/client/icons/svelte.d.ts +2 -0
  149. package/dist/client/icons/svelte.js +31 -0
  150. package/dist/client/icons/terminal.d.ts +2 -0
  151. package/dist/client/icons/terminal.js +24 -0
  152. package/dist/client/icons/terraform.d.ts +2 -0
  153. package/dist/client/icons/terraform.js +24 -0
  154. package/dist/client/icons/typescript.d.ts +2 -0
  155. package/dist/client/icons/typescript.js +24 -0
  156. package/dist/client/icons/word-wrap.d.ts +2 -0
  157. package/dist/client/icons/word-wrap.js +24 -0
  158. package/dist/client/icons/x.d.ts +2 -0
  159. package/dist/client/icons/x.js +24 -0
  160. package/dist/client/mdx-components/anchor.d.ts +10 -0
  161. package/dist/client/mdx-components/anchor.js +109 -0
  162. package/dist/client/mdx-components/code.d.ts +7 -0
  163. package/dist/client/mdx-components/code.js +52 -0
  164. package/dist/client/mdx-components/details.d.ts +5 -0
  165. package/dist/client/mdx-components/details.js +166 -0
  166. package/dist/client/mdx-components/image.d.ts +28 -0
  167. package/dist/client/mdx-components/image.js +39 -0
  168. package/dist/client/mdx-components/index.d.ts +11 -0
  169. package/dist/client/mdx-components/index.js +16 -0
  170. package/dist/client/mdx-components/pre/copy-to-clipboard.d.ts +5 -0
  171. package/dist/client/mdx-components/pre/copy-to-clipboard.js +49 -0
  172. package/dist/client/mdx-components/pre/index.d.ts +16 -0
  173. package/dist/client/mdx-components/pre/index.js +156 -0
  174. package/dist/client/mdx-components/pre/toggle-word-wrap-button.d.ts +7 -0
  175. package/dist/client/mdx-components/pre/toggle-word-wrap-button.js +31 -0
  176. package/dist/client/mdx-components/summary.d.ts +5 -0
  177. package/dist/client/mdx-components/summary.js +80 -0
  178. package/dist/client/mdx-components/table.d.ts +57 -0
  179. package/dist/client/mdx-components/table.js +95 -0
  180. package/dist/client/mdx-components.d.ts +89 -0
  181. package/dist/client/mdx-components.js +15 -0
  182. package/dist/client/mdx-remote.d.ts +62 -0
  183. package/dist/client/mdx-remote.js +36 -0
  184. package/dist/client/normalize-pages.d.ts +84 -0
  185. package/dist/client/normalize-pages.js +232 -0
  186. package/dist/client/package.json +1 -0
  187. package/dist/client/pages.d.ts +131 -0
  188. package/dist/client/pages.js +39 -0
  189. package/dist/client/remove-links.d.ts +6 -0
  190. package/dist/client/remove-links.js +35 -0
  191. package/dist/client/setup-page.d.ts +18 -0
  192. package/dist/client/setup-page.js +14 -0
  193. package/dist/server/compile-metadata.d.ts +12 -0
  194. package/dist/server/compile-metadata.js +39 -0
  195. package/dist/server/compile.d.ts +39 -0
  196. package/dist/server/compile.js +158 -0
  197. package/dist/server/constants.d.ts +15 -0
  198. package/dist/server/constants.js +22 -0
  199. package/dist/server/fetch-filepaths-from-github.d.ts +10 -0
  200. package/dist/server/fetch-filepaths-from-github.js +36 -0
  201. package/dist/server/index.d.ts +39 -0
  202. package/dist/server/index.js +203 -0
  203. package/dist/server/loader.d.ts +18 -0
  204. package/dist/server/loader.js +155 -0
  205. package/dist/server/locales.d.ts +22 -0
  206. package/dist/server/locales.js +38 -0
  207. package/dist/server/page-map/find-meta-and-page-file-paths.d.ts +8 -0
  208. package/dist/server/page-map/find-meta-and-page-file-paths.js +32 -0
  209. package/dist/server/page-map/get.d.ts +50 -0
  210. package/dist/server/page-map/get.js +28 -0
  211. package/dist/server/page-map/index-page.d.ts +21 -0
  212. package/dist/server/page-map/index-page.js +57 -0
  213. package/dist/server/page-map/index.d.ts +26 -0
  214. package/dist/server/page-map/index.js +24 -0
  215. package/dist/server/page-map/merge-meta-with-page-map.d.ts +17 -0
  216. package/dist/server/page-map/merge-meta-with-page-map.js +74 -0
  217. package/dist/server/page-map/normalize.d.ts +17 -0
  218. package/dist/server/page-map/normalize.js +122 -0
  219. package/dist/server/page-map/placeholder.d.ts +2 -0
  220. package/dist/server/page-map/placeholder.js +0 -0
  221. package/dist/server/page-map/to-ast.d.ts +18 -0
  222. package/dist/server/page-map/to-ast.js +47 -0
  223. package/dist/server/page-map/to-js.d.ts +21 -0
  224. package/dist/server/page-map/to-js.js +72 -0
  225. package/dist/server/page-map/to-page-map.d.ts +26 -0
  226. package/dist/server/page-map/to-page-map.js +101 -0
  227. package/dist/server/recma-plugins/index.d.ts +3 -0
  228. package/dist/server/recma-plugins/index.js +4 -0
  229. package/dist/server/recma-plugins/recma-rewrite.d.ts +11 -0
  230. package/dist/server/recma-plugins/recma-rewrite.js +98 -0
  231. package/dist/server/rehype-plugins/index.d.ts +18 -0
  232. package/dist/server/rehype-plugins/index.js +16 -0
  233. package/dist/server/rehype-plugins/rehype-better-react-mathjax.d.ts +24 -0
  234. package/dist/server/rehype-plugins/rehype-better-react-mathjax.js +96 -0
  235. package/dist/server/rehype-plugins/rehype-extract-toc-content.d.ts +6 -0
  236. package/dist/server/rehype-plugins/rehype-extract-toc-content.js +119 -0
  237. package/dist/server/rehype-plugins/rehype-twoslash-popup.d.ts +6 -0
  238. package/dist/server/rehype-plugins/rehype-twoslash-popup.js +50 -0
  239. package/dist/server/rehype-plugins/rehype.d.ts +21 -0
  240. package/dist/server/rehype-plugins/rehype.js +84 -0
  241. package/dist/server/remark-plugins/index.d.ts +15 -0
  242. package/dist/server/remark-plugins/index.js +26 -0
  243. package/dist/server/remark-plugins/remark-assign-frontmatter.d.ts +10 -0
  244. package/dist/server/remark-plugins/remark-assign-frontmatter.js +24 -0
  245. package/dist/server/remark-plugins/remark-custom-heading-id.d.ts +9 -0
  246. package/dist/server/remark-plugins/remark-custom-heading-id.js +18 -0
  247. package/dist/server/remark-plugins/remark-export-only-metadata.d.ts +6 -0
  248. package/dist/server/remark-plugins/remark-export-only-metadata.js +18 -0
  249. package/dist/server/remark-plugins/remark-export-source-code.d.ts +6 -0
  250. package/dist/server/remark-plugins/remark-export-source-code.js +35 -0
  251. package/dist/server/remark-plugins/remark-headings.d.ts +12 -0
  252. package/dist/server/remark-plugins/remark-headings.js +133 -0
  253. package/dist/server/remark-plugins/remark-link-rewrite.d.ts +11 -0
  254. package/dist/server/remark-plugins/remark-link-rewrite.js +12 -0
  255. package/dist/server/remark-plugins/remark-mdx-disable-explicit-jsx.d.ts +10 -0
  256. package/dist/server/remark-plugins/remark-mdx-disable-explicit-jsx.js +10 -0
  257. package/dist/server/remark-plugins/remark-mdx-frontmatter.d.ts +6 -0
  258. package/dist/server/remark-plugins/remark-mdx-frontmatter.js +37 -0
  259. package/dist/server/remark-plugins/remark-mdx-title.d.ts +10 -0
  260. package/dist/server/remark-plugins/remark-mdx-title.js +53 -0
  261. package/dist/server/remark-plugins/remark-remove-imports.d.ts +6 -0
  262. package/dist/server/remark-plugins/remark-remove-imports.js +12 -0
  263. package/dist/server/remark-plugins/remark-static-image.d.ts +6 -0
  264. package/dist/server/remark-plugins/remark-static-image.js +107 -0
  265. package/dist/server/schemas.d.ts +352 -0
  266. package/dist/server/schemas.js +240 -0
  267. package/dist/server/tsdoc/base.d.ts +38 -0
  268. package/dist/server/tsdoc/base.js +284 -0
  269. package/dist/server/tsdoc/index.d.ts +6 -0
  270. package/dist/server/tsdoc/index.js +10 -0
  271. package/dist/server/tsdoc/tsdoc.d.ts +102 -0
  272. package/dist/server/tsdoc/tsdoc.js +262 -0
  273. package/dist/server/tsdoc/types.d.ts +64 -0
  274. package/dist/server/tsdoc/types.js +0 -0
  275. package/dist/server/tsdoc/zod-to-ts.d.ts +5 -0
  276. package/dist/server/tsdoc/zod-to-ts.js +107 -0
  277. package/dist/server/twoslash.d.ts +6 -0
  278. package/dist/server/twoslash.js +60 -0
  279. package/dist/server/utils.d.ts +12 -0
  280. package/dist/server/utils.js +45 -0
  281. package/dist/types.d.ts +128 -0
  282. package/dist/types.generated.d.ts +203 -0
  283. package/dist/types.generated.js +0 -0
  284. package/dist/types.js +0 -0
  285. package/loader.cjs +24 -0
  286. package/package.json +265 -0
  287. package/styles/cards.css +24 -0
  288. package/styles/code-block.css +266 -0
  289. package/styles/default.css +55 -0
  290. package/styles/react-medium-image-zoom.css +101 -0
  291. package/styles/scrollbar.css +14 -0
  292. package/styles/steps.css +22 -0
  293. package/styles/subheading-anchor.css +25 -0
@@ -0,0 +1,18 @@
1
+ export { DEFAULT_REHYPE_PRETTY_CODE_OPTIONS, rehypeAttachCodeMeta, rehypeParseCodeMeta } from './rehype.js';
2
+ export { rehypeBetterReactMathjax } from './rehype-better-react-mathjax.js';
3
+ export { rehypeExtractTocContent } from './rehype-extract-toc-content.js';
4
+ export { rehypeTwoslashPopup } from './rehype-twoslash-popup.js';
5
+ import 'hast';
6
+ import 'rehype-pretty-code';
7
+ import './lib/index.js';
8
+ import '../../types.generated.js';
9
+ import '@mdx-js/mdx';
10
+ import 'rehype-katex';
11
+ import 'better-react-mathjax';
12
+ import '../../types.js';
13
+ import 'mdast';
14
+ import 'next';
15
+ import 'react';
16
+ import 'zod';
17
+ import '../schemas.js';
18
+ import 'rehype-katex/lib/index.js';
@@ -0,0 +1,16 @@
1
+ import {
2
+ rehypeParseCodeMeta,
3
+ rehypeAttachCodeMeta,
4
+ DEFAULT_REHYPE_PRETTY_CODE_OPTIONS
5
+ } from "./rehype.js";
6
+ import { rehypeBetterReactMathjax } from "./rehype-better-react-mathjax.js";
7
+ import { rehypeExtractTocContent } from "./rehype-extract-toc-content.js";
8
+ import { rehypeTwoslashPopup } from "./rehype-twoslash-popup.js";
9
+ export {
10
+ DEFAULT_REHYPE_PRETTY_CODE_OPTIONS,
11
+ rehypeAttachCodeMeta,
12
+ rehypeBetterReactMathjax,
13
+ rehypeExtractTocContent,
14
+ rehypeParseCodeMeta,
15
+ rehypeTwoslashPopup
16
+ };
@@ -0,0 +1,24 @@
1
+ import { Root } from 'hast';
2
+ import { Plugin } from './lib/index.js';
3
+ import { MathJaxOptions } from '../../types.js';
4
+ import 'mdast';
5
+ import 'next';
6
+ import 'react';
7
+ import 'zod';
8
+ import '../schemas.js';
9
+ import 'rehype-katex/lib/index.js';
10
+ import 'better-react-mathjax';
11
+ import 'rehype-pretty-code';
12
+ import '../../types.generated.js';
13
+ import '@mdx-js/mdx';
14
+ import 'rehype-katex';
15
+
16
+ /**
17
+ * Wraps math in a `<MathJax>` component so that it can be rendered by `better-react-mathjax`.
18
+ */
19
+ declare const rehypeBetterReactMathjax: Plugin<[
20
+ Opts: MathJaxOptions,
21
+ isRemoteContent: boolean
22
+ ], Root>;
23
+
24
+ export { rehypeBetterReactMathjax };
@@ -0,0 +1,96 @@
1
+ import { valueToEstree } from "estree-util-value-to-estree";
2
+ import { visit } from "unist-util-visit";
3
+ const MATHJAX_IMPORTS = {
4
+ type: "mdxjsEsm",
5
+ data: {
6
+ estree: {
7
+ body: [
8
+ {
9
+ type: "ImportDeclaration",
10
+ source: { type: "Literal", value: "nextra/components" },
11
+ specifiers: ["MathJax", "MathJaxContext"].map((name) => ({
12
+ type: "ImportSpecifier",
13
+ imported: { type: "Identifier", name },
14
+ local: { type: "Identifier", name }
15
+ }))
16
+ }
17
+ ]
18
+ }
19
+ }
20
+ };
21
+ function wrapInMathJaxContext(children, { config, src }) {
22
+ const attributes = [];
23
+ if (src) {
24
+ attributes.push({ type: "mdxJsxAttribute", name: "src", value: src });
25
+ }
26
+ if (config && Object.keys(config).length) {
27
+ attributes.push({
28
+ type: "mdxJsxAttribute",
29
+ name: "config",
30
+ value: {
31
+ type: "mdxJsxAttributeValueExpression",
32
+ value: "",
33
+ data: {
34
+ estree: {
35
+ type: "Program",
36
+ sourceType: "module",
37
+ body: [
38
+ { type: "ExpressionStatement", expression: valueToEstree(config) }
39
+ ]
40
+ }
41
+ }
42
+ }
43
+ });
44
+ }
45
+ return {
46
+ type: "mdxJsxFlowElement",
47
+ name: "MathJaxContext",
48
+ attributes,
49
+ children
50
+ };
51
+ }
52
+ function wrapInBraces(source, mathInline, options) {
53
+ const { inlineMath, displayMath } = options.config?.tex || {};
54
+ const inlineBraces = inlineMath?.[0] || [String.raw`\(`, String.raw`\)`];
55
+ const displayBraces = displayMath?.[0] || [String.raw`\[`, String.raw`\]`];
56
+ const [before, after] = mathInline ? inlineBraces : displayBraces;
57
+ return `${before}${source}${after}`;
58
+ }
59
+ const rehypeBetterReactMathjax = (options = {}, isRemoteContent) => (ast) => {
60
+ let hasMathJax = false;
61
+ visit(ast, { tagName: "code" }, (node, _index, parent) => {
62
+ const classes = Array.isArray(node.properties.className) ? node.properties.className : [];
63
+ const hasMathLanguage = classes.includes("language-math");
64
+ if (!hasMathLanguage) return;
65
+ const isInlineMath = classes.includes("math-inline");
66
+ const [{ value }] = node.children;
67
+ const bracketedValue = wrapInBraces(value, isInlineMath, options);
68
+ const mathJaxNode = {
69
+ type: "element",
70
+ tagName: "MathJax",
71
+ children: [{ type: "text", value: bracketedValue }],
72
+ properties: isInlineMath ? { inline: true } : {}
73
+ };
74
+ Object.assign(isInlineMath ? node : parent, mathJaxNode);
75
+ hasMathJax = true;
76
+ });
77
+ if (!hasMathJax) return;
78
+ const mdxjsEsmNodes = [];
79
+ const rest = [];
80
+ for (const child of ast.children) {
81
+ if (child.type === "mdxjsEsm") {
82
+ mdxjsEsmNodes.push(child);
83
+ } else {
84
+ rest.push(child);
85
+ }
86
+ }
87
+ ast.children = [
88
+ ...mdxjsEsmNodes,
89
+ ...isRemoteContent ? [] : [MATHJAX_IMPORTS],
90
+ // Wrap everything in a `<MathJaxContext>` component.
91
+ wrapInMathJaxContext(rest, options)
92
+ ];
93
+ };
94
+ export {
95
+ rehypeBetterReactMathjax
96
+ };
@@ -0,0 +1,6 @@
1
+ import { Root } from 'hast';
2
+ import { Plugin } from './lib/index.js';
3
+
4
+ declare const rehypeExtractTocContent: Plugin<[], Root>;
5
+
6
+ export { rehypeExtractTocContent };
@@ -0,0 +1,119 @@
1
+ import { toEstree } from "hast-util-to-estree";
2
+ import { SKIP, visit } from "unist-util-visit";
3
+ import { createAstExportConst, createAstObject } from "../utils.js";
4
+ const TOC_HEADING_RE = /^h[2-6]$/;
5
+ const transformer = (ast, file) => {
6
+ const TocMap = {};
7
+ visit(ast, "element", (node, _index, parent) => {
8
+ if (!TOC_HEADING_RE.test(node.tagName)) return;
9
+ if (parent && "properties" in parent && parent.properties.dataFootnotes) {
10
+ return SKIP;
11
+ }
12
+ const { id } = node.properties;
13
+ TocMap[id] = node;
14
+ });
15
+ const hasPartialMDX = file.data.toc.some(
16
+ (name) => typeof name === "string"
17
+ );
18
+ const elements = file.data.toc.map((name, index) => {
19
+ if (typeof name === "string") {
20
+ return {
21
+ type: "SpreadElement",
22
+ argument: { type: "Identifier", name }
23
+ };
24
+ }
25
+ const node = TocMap[name.id];
26
+ const isTextOnly = node.children.every((child) => child.type === "text");
27
+ const result = isTextOnly ? node.children.map((n) => n.value).join("") : (
28
+ // @ts-expect-error -- fixme
29
+ Object.assign(toEstree(node).body[0].expression, {
30
+ type: "JSXFragment",
31
+ openingFragment: { type: "JSXOpeningFragment" },
32
+ closingFragment: { type: "JSXClosingFragment" }
33
+ })
34
+ );
35
+ if (!hasPartialMDX) {
36
+ Object.assign(node, {
37
+ type: "mdxJsxFlowElement",
38
+ name: node.tagName,
39
+ attributes: [
40
+ {
41
+ type: "mdxJsxAttribute",
42
+ name: "id",
43
+ value: createComputedKey(
44
+ "mdxJsxAttributeValueExpression",
45
+ index,
46
+ "id"
47
+ )
48
+ }
49
+ ],
50
+ children: [createComputedKey("mdxFlowExpression", index, "value")]
51
+ });
52
+ }
53
+ return createAstObject({
54
+ value: result,
55
+ id: node.properties.id,
56
+ depth: Number(node.tagName[1])
57
+ });
58
+ });
59
+ ast.children.push({
60
+ type: "mdxjsEsm",
61
+ data: {
62
+ estree: {
63
+ body: [
64
+ {
65
+ // TOC links must be inside a function, in our case inside useTOC, so
66
+ // mdx components will be injected for `<a>` or `<code>` tags inside headings
67
+ type: "FunctionDeclaration",
68
+ id: { type: "Identifier", name: "useTOC" },
69
+ params: [{ type: "Identifier", name: "props" }],
70
+ body: {
71
+ type: "BlockStatement",
72
+ body: [
73
+ {
74
+ type: "ReturnStatement",
75
+ argument: { type: "ArrayExpression", elements }
76
+ }
77
+ ]
78
+ }
79
+ },
80
+ createAstExportConst("toc", {
81
+ type: "CallExpression",
82
+ callee: { type: "Identifier", name: "useTOC" },
83
+ // https://github.com/shuding/nextra/issues/3979
84
+ arguments: [{ type: "ObjectExpression", properties: [] }],
85
+ optional: false
86
+ })
87
+ ]
88
+ }
89
+ }
90
+ });
91
+ };
92
+ function createComputedKey(type, index, key) {
93
+ return {
94
+ type,
95
+ data: {
96
+ estree: {
97
+ body: [
98
+ {
99
+ type: "ExpressionStatement",
100
+ expression: {
101
+ type: "MemberExpression",
102
+ property: { type: "Identifier", name: key },
103
+ object: {
104
+ type: "MemberExpression",
105
+ object: { type: "Identifier", name: "toc" },
106
+ property: { type: "Literal", value: index },
107
+ computed: true
108
+ }
109
+ }
110
+ }
111
+ ]
112
+ }
113
+ }
114
+ };
115
+ }
116
+ const rehypeExtractTocContent = () => transformer;
117
+ export {
118
+ rehypeExtractTocContent
119
+ };
@@ -0,0 +1,6 @@
1
+ import { Root } from 'hast';
2
+ import { Plugin } from './lib/index.js';
3
+
4
+ declare const rehypeTwoslashPopup: Plugin<[], Root>;
5
+
6
+ export { rehypeTwoslashPopup };
@@ -0,0 +1,50 @@
1
+ import { EXIT, visit } from "unist-util-visit";
2
+ const TWOSLASH_POPUP_IMPORT_AST = {
3
+ type: "mdxjsEsm",
4
+ data: {
5
+ estree: {
6
+ body: [
7
+ {
8
+ type: "ImportDeclaration",
9
+ source: { type: "Literal", value: "nextra/components" },
10
+ specifiers: [
11
+ {
12
+ type: "ImportSpecifier",
13
+ imported: { type: "Identifier", name: "Popup" },
14
+ local: { type: "Identifier", name: "Popup" }
15
+ }
16
+ ]
17
+ }
18
+ ]
19
+ }
20
+ }
21
+ };
22
+ const transformer = (ast) => {
23
+ visit(
24
+ ast,
25
+ [
26
+ { tagName: "popup" },
27
+ { tagName: "popupbutton" },
28
+ { tagName: "popuppanel" }
29
+ ],
30
+ (node) => {
31
+ const n = node;
32
+ const tagName = {
33
+ popup: "Popup",
34
+ popupbutton: "Popup.Button",
35
+ popuppanel: "Popup.Panel"
36
+ }[n.tagName];
37
+ n.tagName = tagName;
38
+ }
39
+ );
40
+ visit(ast, { tagName: "code" }, (node) => {
41
+ if (node.data?.meta === "twoslash") {
42
+ ast.children.unshift(TWOSLASH_POPUP_IMPORT_AST);
43
+ return EXIT;
44
+ }
45
+ });
46
+ };
47
+ const rehypeTwoslashPopup = () => transformer;
48
+ export {
49
+ rehypeTwoslashPopup
50
+ };
@@ -0,0 +1,21 @@
1
+ import { Root } from 'hast';
2
+ import { Options } from 'rehype-pretty-code';
3
+ import { Plugin } from './lib/index.js';
4
+ import { NextraConfig } from '../../types.generated.js';
5
+ import '@mdx-js/mdx';
6
+ import 'rehype-katex';
7
+ import 'better-react-mathjax';
8
+
9
+ declare const DEFAULT_REHYPE_PRETTY_CODE_OPTIONS: Options;
10
+ declare const rehypeParseCodeMeta: Plugin<[
11
+ {
12
+ defaultShowCopyCode?: boolean;
13
+ }
14
+ ], Root>;
15
+ declare const rehypeAttachCodeMeta: Plugin<[
16
+ {
17
+ search: NextraConfig['search'];
18
+ }
19
+ ], Root>;
20
+
21
+ export { DEFAULT_REHYPE_PRETTY_CODE_OPTIONS, rehypeAttachCodeMeta, rehypeParseCodeMeta };
@@ -0,0 +1,84 @@
1
+ import { bundledLanguages, createHighlighter } from "shiki";
2
+ import { SKIP, visit } from "unist-util-visit";
3
+ const CODE_BLOCK_FILENAME_RE = /filename="([^"]+)"/;
4
+ const DEFAULT_REHYPE_PRETTY_CODE_OPTIONS = {
5
+ keepBackground: false,
6
+ grid: false,
7
+ onVisitLine(node) {
8
+ if (node.children.length === 0) {
9
+ node.children.push({ type: "text", value: " " });
10
+ }
11
+ delete node.properties["data-line"];
12
+ },
13
+ theme: {
14
+ light: "github-light",
15
+ dark: "github-dark"
16
+ },
17
+ defaultLang: {
18
+ block: "plaintext"
19
+ },
20
+ filterMetaString: (meta) => meta.replace(CODE_BLOCK_FILENAME_RE, ""),
21
+ getHighlighter(opts) {
22
+ const langs = Object.keys(bundledLanguages).filter((l) => l !== "mermaid");
23
+ return createHighlighter({
24
+ ...opts,
25
+ // Without `getHighlighter` option ```mdx lang isn't highlighted
26
+ langs
27
+ });
28
+ }
29
+ };
30
+ const rehypeParseCodeMeta = ({ defaultShowCopyCode }) => (ast) => {
31
+ visit(ast, { tagName: "pre" }, (node) => {
32
+ const [codeEl] = node.children;
33
+ const { meta = "" } = codeEl.data || {};
34
+ node.__filename = meta.match(CODE_BLOCK_FILENAME_RE)?.[1];
35
+ node.properties["data-filename"] = node.__filename;
36
+ node.__hasWordWrap = !meta.includes("word-wrap=false");
37
+ if (node.__hasWordWrap) {
38
+ node.properties["data-word-wrap"] = "";
39
+ }
40
+ node.__hasCopyCode = meta ? defaultShowCopyCode && !/( |^)copy=false($| )/.test(meta) || /( |^)copy($| )/.test(meta) : defaultShowCopyCode;
41
+ if (node.__hasCopyCode) {
42
+ node.properties["data-copy"] = "";
43
+ }
44
+ });
45
+ };
46
+ const rehypeAttachCodeMeta = ({ search }) => {
47
+ const parseCodeblocks = typeof search === "object" ? search.codeblocks : search;
48
+ return (ast) => {
49
+ visit(
50
+ ast,
51
+ [{ tagName: "figure" }, { tagName: "span" }],
52
+ (node) => {
53
+ const isRehypePrettyCode = "data-rehype-pretty-code-figure" in node.properties;
54
+ if (!isRehypePrettyCode) return;
55
+ const preEl = Object.assign(node, node.children[0]);
56
+ delete preEl.properties["data-theme"];
57
+ if (preEl.tagName === "pre") {
58
+ const codeEl = preEl.children[0];
59
+ delete codeEl.properties["data-theme"];
60
+ delete codeEl.properties["data-language"];
61
+ if (preEl.__hasWordWrap) {
62
+ preEl.properties["data-word-wrap"] = "";
63
+ }
64
+ if (preEl.__filename) {
65
+ preEl.properties["data-filename"] = preEl.__filename;
66
+ }
67
+ if (preEl.__hasCopyCode) {
68
+ preEl.properties["data-copy"] = "";
69
+ }
70
+ if (!parseCodeblocks) {
71
+ preEl.properties["data-pagefind-ignore"] = "all";
72
+ }
73
+ return SKIP;
74
+ }
75
+ delete node.children[0].properties.className;
76
+ }
77
+ );
78
+ };
79
+ };
80
+ export {
81
+ DEFAULT_REHYPE_PRETTY_CODE_OPTIONS,
82
+ rehypeAttachCodeMeta,
83
+ rehypeParseCodeMeta
84
+ };
@@ -0,0 +1,15 @@
1
+ export { remarkCustomHeadingId } from './remark-custom-heading-id.js';
2
+ export { remarkExportOnlyMetadata } from './remark-export-only-metadata.js';
3
+ export { remarkExportSourceCode } from './remark-export-source-code.js';
4
+ export { remarkMdxFrontMatter } from './remark-mdx-frontmatter.js';
5
+ export { remarkMdxTitle } from './remark-mdx-title.js';
6
+ export { remarkHeadings } from './remark-headings.js';
7
+ export { remarkRemoveImports } from './remark-remove-imports.js';
8
+ export { RemarkLinkRewriteOptions, remarkLinkRewrite } from './remark-link-rewrite.js';
9
+ export { remarkMdxDisableExplicitJsx } from './remark-mdx-disable-explicit-jsx.js';
10
+ export { remarkStaticImage } from './remark-static-image.js';
11
+ export { remarkAssignFrontMatter } from './remark-assign-frontmatter.js';
12
+ import 'mdast';
13
+ import './lib/index.js';
14
+ import 'estree';
15
+ import 'mdast-util-mdxjs-esm';
@@ -0,0 +1,26 @@
1
+ import { remarkCustomHeadingId } from "./remark-custom-heading-id.js";
2
+ import { remarkExportOnlyMetadata } from "./remark-export-only-metadata.js";
3
+ import { remarkExportSourceCode } from "./remark-export-source-code.js";
4
+ import { remarkMdxFrontMatter } from "./remark-mdx-frontmatter.js";
5
+ import { remarkMdxTitle } from "./remark-mdx-title.js";
6
+ import { remarkHeadings } from "./remark-headings.js";
7
+ import { remarkRemoveImports } from "./remark-remove-imports.js";
8
+ import {
9
+ remarkLinkRewrite
10
+ } from "./remark-link-rewrite.js";
11
+ import { remarkMdxDisableExplicitJsx } from "./remark-mdx-disable-explicit-jsx.js";
12
+ import { remarkStaticImage } from "./remark-static-image.js";
13
+ import { remarkAssignFrontMatter } from "./remark-assign-frontmatter.js";
14
+ export {
15
+ remarkAssignFrontMatter,
16
+ remarkCustomHeadingId,
17
+ remarkExportOnlyMetadata,
18
+ remarkExportSourceCode,
19
+ remarkHeadings,
20
+ remarkLinkRewrite,
21
+ remarkMdxDisableExplicitJsx,
22
+ remarkMdxFrontMatter,
23
+ remarkMdxTitle,
24
+ remarkRemoveImports,
25
+ remarkStaticImage
26
+ };
@@ -0,0 +1,10 @@
1
+ import { Root } from 'mdast';
2
+ import { Plugin } from './lib/index.js';
3
+
4
+ declare const remarkAssignFrontMatter: Plugin<[
5
+ {
6
+ lastCommitTime?: number;
7
+ }
8
+ ], Root>;
9
+
10
+ export { remarkAssignFrontMatter };
@@ -0,0 +1,24 @@
1
+ import path from "path";
2
+ import { valueToEstree } from "estree-util-value-to-estree";
3
+ import slash from "slash";
4
+ import { CWD } from "../constants.js";
5
+ import { getFrontMatterASTObject, isExportNode } from "./remark-mdx-title.js";
6
+ const remarkAssignFrontMatter = ({ lastCommitTime }) => (ast, file) => {
7
+ const frontMatterNode = ast.children.find(
8
+ (node) => isExportNode(node, "metadata")
9
+ );
10
+ const frontMatter = getFrontMatterASTObject(frontMatterNode);
11
+ const [filePath] = file.history;
12
+ const { readingTime, title } = file.data;
13
+ const { properties } = valueToEstree({
14
+ ...title && { title },
15
+ // File path can be undefined (e.g. dynamic mdx without filePath provided to processor)
16
+ ...filePath && { filePath: slash(path.relative(CWD, filePath)) },
17
+ ...readingTime && { readingTime },
18
+ ...lastCommitTime && { timestamp: lastCommitTime }
19
+ });
20
+ frontMatter.push(...properties);
21
+ };
22
+ export {
23
+ remarkAssignFrontMatter
24
+ };
@@ -0,0 +1,9 @@
1
+ import { Root } from 'mdast';
2
+ import { Plugin } from './lib/index.js';
3
+
4
+ type HProperties = {
5
+ id?: string;
6
+ };
7
+ declare const remarkCustomHeadingId: Plugin<[], Root>;
8
+
9
+ export { type HProperties, remarkCustomHeadingId };
@@ -0,0 +1,18 @@
1
+ import { visit } from "unist-util-visit";
2
+ const transformer = (ast) => {
3
+ visit(ast, "heading", (node) => {
4
+ const lastChild = node.children.at(-1);
5
+ if (lastChild?.type !== "text") return;
6
+ const heading = lastChild.value;
7
+ const matched = heading.match(/\s*\[#([^]+?)]\s*$/);
8
+ if (!matched) return;
9
+ node.data ||= {};
10
+ const headingProps = node.data.hProperties ||= {};
11
+ headingProps.id = matched[1];
12
+ lastChild.value = heading.slice(0, matched.index);
13
+ });
14
+ };
15
+ const remarkCustomHeadingId = () => transformer;
16
+ export {
17
+ remarkCustomHeadingId
18
+ };
@@ -0,0 +1,6 @@
1
+ import { Root } from 'mdast';
2
+ import { Plugin } from './lib/index.js';
3
+
4
+ declare const remarkExportOnlyMetadata: Plugin<[], Root>;
5
+
6
+ export { remarkExportOnlyMetadata };
@@ -0,0 +1,18 @@
1
+ import { remove } from "unist-util-remove";
2
+ const transformer = (ast) => {
3
+ remove(ast, (node) => {
4
+ const isMdxJs = node.type === "mdxjsEsm";
5
+ if (!isMdxJs) return true;
6
+ const [body] = node.data.estree.body;
7
+ const isExportNamed = body.type === "ExportNamedDeclaration";
8
+ if (!isExportNamed) return true;
9
+ const isVariableDeclaration = body.declaration?.type === "VariableDeclaration";
10
+ if (!isVariableDeclaration) return true;
11
+ const isMetadata = body.declaration.declarations[0].id.name === "metadata";
12
+ return !isMetadata;
13
+ });
14
+ };
15
+ const remarkExportOnlyMetadata = () => transformer;
16
+ export {
17
+ remarkExportOnlyMetadata
18
+ };
@@ -0,0 +1,6 @@
1
+ import { Root } from 'mdast';
2
+ import { Plugin } from './lib/index.js';
3
+
4
+ declare const remarkExportSourceCode: Plugin<[], Root>;
5
+
6
+ export { remarkExportSourceCode };
@@ -0,0 +1,35 @@
1
+ const remarkExportSourceCode = () => (ast, file) => {
2
+ ast.children.push({
3
+ type: "mdxjsEsm",
4
+ value: "",
5
+ data: {
6
+ estree: {
7
+ type: "Program",
8
+ sourceType: "module",
9
+ body: [
10
+ {
11
+ type: "ExportNamedDeclaration",
12
+ specifiers: [],
13
+ declaration: {
14
+ type: "VariableDeclaration",
15
+ kind: "const",
16
+ declarations: [
17
+ {
18
+ type: "VariableDeclarator",
19
+ id: { type: "Identifier", name: "sourceCode" },
20
+ init: {
21
+ type: "Literal",
22
+ value: String(file.value).trim()
23
+ }
24
+ }
25
+ ]
26
+ }
27
+ }
28
+ ]
29
+ }
30
+ }
31
+ });
32
+ };
33
+ export {
34
+ remarkExportSourceCode
35
+ };
@@ -0,0 +1,12 @@
1
+ import { Root, Parent } from 'mdast';
2
+ import { Plugin } from './lib/index.js';
3
+
4
+ declare const getFlattenedValue: (node: Parent) => string;
5
+ declare const remarkHeadings: Plugin<[
6
+ {
7
+ exportName?: string;
8
+ isRemoteContent?: boolean;
9
+ }
10
+ ], Root>;
11
+
12
+ export { getFlattenedValue, remarkHeadings };