@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,64 @@
1
+ type GeneratedType = {
2
+ /** Type fields. */
3
+ entries: TypeField[];
4
+ };
5
+ type Tags = Record<string, string>;
6
+ type ReturnField = {
7
+ /** Function return type. */
8
+ type: string;
9
+ };
10
+ type GeneratedDefinition = {
11
+ /**
12
+ * Where type definition is located on disk.
13
+ */
14
+ filePath?: string;
15
+ /**
16
+ * Definition name.
17
+ */
18
+ name: string;
19
+ /**
20
+ * Definition description.
21
+ */
22
+ description?: string;
23
+ /**
24
+ * [TSDoc tags](https://tsdoc.org/pages/spec/tag_kinds).
25
+ */
26
+ tags?: Tags;
27
+ };
28
+ type GeneratedFunction = {
29
+ signatures: {
30
+ /** Function parameters. */
31
+ params: TypeField[];
32
+ /** Function return. */
33
+ returns: TypeField[] | ReturnField;
34
+ }[];
35
+ };
36
+ type TypeField = {
37
+ /** Field name. */
38
+ name: string;
39
+ /** Field type. */
40
+ type: string;
41
+ /** Field description. */
42
+ description?: string;
43
+ /** Is field optional. */
44
+ optional?: boolean;
45
+ /** Field tags. */
46
+ tags?: Tags;
47
+ };
48
+ type BaseArgs = {
49
+ /** TypeScript source code to be processed. */
50
+ code: string;
51
+ /**
52
+ * The name of the exported declaration.
53
+ * @default "default"
54
+ */
55
+ exportName?: string;
56
+ /**
57
+ * Whether to flatten nested objects.
58
+ * E.g. `{ foo: { bar: string } }` will be represented as: `{ foo.bar: string }`
59
+ * @default false
60
+ */
61
+ flattened?: boolean;
62
+ };
63
+
64
+ export type { BaseArgs, GeneratedDefinition, GeneratedFunction, GeneratedType, ReturnField, Tags, TypeField };
File without changes
@@ -0,0 +1,5 @@
1
+ import { z } from 'zod';
2
+
3
+ declare function generateTsFromZod(schema: z.ZodType, indent?: number): string;
4
+
5
+ export { generateTsFromZod };
@@ -0,0 +1,107 @@
1
+ import { z } from "zod";
2
+ function generateTsFromZod(schema, indent = 2) {
3
+ const isZodObject = schema instanceof z.ZodObject;
4
+ if (!isZodObject) {
5
+ return generateTsFromZodType(schema, indent);
6
+ }
7
+ const objectFields = Object.entries(schema.shape).map(([key, _value]) => {
8
+ const value = _value;
9
+ const tsType = generateTsFromZodType(value, indent + 2);
10
+ const docComment = getDocComment(value, indent);
11
+ const isOptional = value instanceof z.ZodOptional || getDefaultValue(value) !== void 0;
12
+ return [
13
+ docComment,
14
+ " ".repeat(indent),
15
+ key,
16
+ isOptional ? "?" : "",
17
+ `: ${tsType}
18
+ `
19
+ ].join("");
20
+ }).join("\n");
21
+ return ["{\n", objectFields, " ".repeat(indent - 2), "}"].join("");
22
+ }
23
+ function generateTsFromZodType(schema, indent) {
24
+ const { name } = schema.constructor;
25
+ const typeName = schema.meta()?.type;
26
+ if (typeName) return typeName;
27
+ if (schema instanceof z.ZodCustom) {
28
+ const fnName = schema.def.fn.name;
29
+ return fnName.startsWith("check") ? "React." + fnName.slice(5) : '"@TODO TO IMPLEMENT"';
30
+ }
31
+ switch (name) {
32
+ case "ZodString":
33
+ return "string";
34
+ case "ZodNumber":
35
+ return "number";
36
+ case "ZodBoolean":
37
+ return "boolean";
38
+ }
39
+ if (schema instanceof z.ZodPipe) {
40
+ return generateTsFromZodType(schema.in, indent);
41
+ }
42
+ if (schema instanceof z.ZodLiteral) {
43
+ return `"${[...schema.values]}"`;
44
+ }
45
+ if (schema instanceof z.ZodOptional || schema instanceof z.ZodDefault) {
46
+ return generateTsFromZodType(schema.def.innerType, indent);
47
+ }
48
+ if (schema instanceof z.ZodNullable) {
49
+ return `${generateTsFromZodType(schema.def.innerType, indent)} | null`;
50
+ }
51
+ if (schema instanceof z.ZodArray) {
52
+ return `${generateTsFromZodType(schema.def.element, indent)}[]`;
53
+ }
54
+ if (schema instanceof z.ZodUnion) {
55
+ return schema.def.options.map((opt) => {
56
+ const r = generateTsFromZodType(opt, indent);
57
+ return opt instanceof z.ZodArray ? `(${r.replace("[", ")[")}` : r;
58
+ }).join(" | ");
59
+ }
60
+ if (schema instanceof z.ZodObject) {
61
+ return generateTsFromZod(schema, indent);
62
+ }
63
+ if (schema instanceof z.ZodEnum) {
64
+ return schema.options.map((v) => `"${v}"`).join(" | ");
65
+ }
66
+ throw new Error(`Unknown schema type '${name}'`);
67
+ }
68
+ function getDefaultValue(schema) {
69
+ if (schema instanceof z.ZodDefault) {
70
+ return schema.def.defaultValue;
71
+ }
72
+ if (schema instanceof z.ZodPipe) {
73
+ return schema.in.def.defaultValue;
74
+ }
75
+ return;
76
+ }
77
+ function getDocComment(schema, indent) {
78
+ const meta = schema.meta() ?? {};
79
+ const description = (
80
+ // @ts-expect-error -- fixme
81
+ meta.description || schema.def.innerType?.description
82
+ );
83
+ const defaultValue = getDefaultValue(schema);
84
+ const def = meta.default ?? (defaultValue === void 0 ? void 0 : JSON.stringify(defaultValue, null, 2));
85
+ const comments = [];
86
+ if (description) {
87
+ comments.push(description);
88
+ }
89
+ if (def !== void 0) {
90
+ comments.push(`@default ${def}`);
91
+ }
92
+ if (!comments.length) {
93
+ return "";
94
+ }
95
+ const comment = [
96
+ //
97
+ "/**",
98
+ ...comments.flatMap(
99
+ (comment2) => comment2.split("\n").map((line) => ` * ${line}`)
100
+ ),
101
+ " */"
102
+ ].map((line) => `${" ".repeat(indent)}${line}`).join("\n");
103
+ return comment + "\n";
104
+ }
105
+ export {
106
+ generateTsFromZod
107
+ };
@@ -0,0 +1,6 @@
1
+ import * as _shikijs_twoslash from '@shikijs/twoslash';
2
+ import { RendererRichOptions } from '@shikijs/twoslash';
3
+
4
+ declare function twoslashRenderer(options?: RendererRichOptions): _shikijs_twoslash.TwoslashRenderer;
5
+
6
+ export { twoslashRenderer };
@@ -0,0 +1,60 @@
1
+ import { rendererRich } from "@shikijs/twoslash";
2
+ import { fromMarkdown } from "mdast-util-from-markdown";
3
+ import { gfmFromMarkdown } from "mdast-util-gfm";
4
+ import { defaultHandlers, toHast } from "mdast-util-to-hast";
5
+ function renderMarkdown(md) {
6
+ const mdast = fromMarkdown(
7
+ md.replaceAll(/{@link (?<link>[^}]*)}/g, "$1"),
8
+ // replace jsdoc links
9
+ { mdastExtensions: [gfmFromMarkdown()] }
10
+ );
11
+ return toHast(mdast, {
12
+ handlers: {
13
+ code: (state, node) => {
14
+ if (node.lang) {
15
+ return this.codeToHast(node.value, {
16
+ ...this.options,
17
+ transformers: [],
18
+ meta: {
19
+ __raw: node.meta ?? void 0
20
+ },
21
+ lang: node.lang
22
+ }).children[0];
23
+ }
24
+ return defaultHandlers.code(state, node);
25
+ }
26
+ }
27
+ }).children;
28
+ }
29
+ function renderMarkdownInline(md, context) {
30
+ const text = context === "tag:param" ? md.replace(/^(?<link>[\w$-]+)/, "`$1` ") : md;
31
+ const children = renderMarkdown.call(this, text);
32
+ const [firstChild] = children;
33
+ if (children.length === 1 && firstChild?.type === "element" && firstChild.tagName === "p")
34
+ return firstChild.children;
35
+ return children;
36
+ }
37
+ function twoslashRenderer(options) {
38
+ return rendererRich({
39
+ ...options,
40
+ renderMarkdown,
41
+ renderMarkdownInline,
42
+ hast: {
43
+ hoverToken: { tagName: "Popup" },
44
+ hoverPopup: { tagName: "PopupPanel" },
45
+ hoverCompose: ({ popup, token }) => [
46
+ popup,
47
+ {
48
+ type: "element",
49
+ tagName: "PopupButton",
50
+ properties: {},
51
+ children: [token]
52
+ }
53
+ ],
54
+ ...options?.hast
55
+ }
56
+ });
57
+ }
58
+ export {
59
+ twoslashRenderer
60
+ };
@@ -0,0 +1,12 @@
1
+ import { ArrayExpression, ObjectExpression, Expression, ExportNamedDeclaration } from 'estree';
2
+
3
+ declare const logger: {
4
+ info: (...args: any[]) => void;
5
+ warn: (...args: any[]) => void;
6
+ error: (...args: any[]) => void;
7
+ };
8
+ declare function pageTitleFromFilename(fileName: string): string;
9
+ declare function createAstExportConst(name: string, value: ArrayExpression | ObjectExpression | Expression): ExportNamedDeclaration;
10
+ declare function createAstObject(obj: Record<string, string | number | boolean | null | Expression>): ObjectExpression;
11
+
12
+ export { createAstExportConst, createAstObject, logger, pageTitleFromFilename };
@@ -0,0 +1,45 @@
1
+ import title from "title";
2
+ import { DEFAULT_PROPERTY_PROPS } from "./constants.js";
3
+ const logger = {
4
+ info: console.log.bind(null, "-", "\x1B[36minfo\x1B[0m", "[nextra]"),
5
+ warn: console.log.bind(null, "-", "\x1B[33mwarn\x1B[0m", "[nextra]"),
6
+ error: console.log.bind(null, "-", "\x1B[31merror\x1B[0m", "[nextra]")
7
+ };
8
+ function pageTitleFromFilename(fileName) {
9
+ return title(fileName.replaceAll(/[-_]/g, " "), {
10
+ special: ["SSR", "CORS", "ESLint"]
11
+ });
12
+ }
13
+ function createAstExportConst(name, value) {
14
+ return {
15
+ type: "ExportNamedDeclaration",
16
+ specifiers: [],
17
+ declaration: {
18
+ type: "VariableDeclaration",
19
+ kind: "const",
20
+ declarations: [
21
+ {
22
+ type: "VariableDeclarator",
23
+ id: { type: "Identifier", name },
24
+ init: value
25
+ }
26
+ ]
27
+ }
28
+ };
29
+ }
30
+ function createAstObject(obj) {
31
+ return {
32
+ type: "ObjectExpression",
33
+ properties: Object.entries(obj).map(([key, value]) => ({
34
+ ...DEFAULT_PROPERTY_PROPS,
35
+ key: { type: "Identifier", name: key },
36
+ value: value && typeof value === "object" ? value : { type: "Literal", value }
37
+ }))
38
+ };
39
+ }
40
+ export {
41
+ createAstExportConst,
42
+ createAstObject,
43
+ logger,
44
+ pageTitleFromFilename
45
+ };
@@ -0,0 +1,128 @@
1
+ import { Heading as Heading$1 } from 'mdast';
2
+ import { Metadata } from 'next';
3
+ import { ReactElement, FC, ReactNode } from 'react';
4
+ import { z } from 'zod';
5
+ import { NextraConfigSchema, MathJaxOptionsSchema, metaSchema, separatorItemSchema, menuSchema } from './server/schemas.js';
6
+ export { NextraConfig } from './types.generated.js';
7
+ import './lib/index.js';
8
+ import 'rehype-katex/lib/index.js';
9
+ import 'better-react-mathjax';
10
+ import 'rehype-pretty-code';
11
+ import '@mdx-js/mdx';
12
+ import 'rehype-katex';
13
+
14
+ type NextraConfigFromZod = z.infer<typeof NextraConfigSchema>;
15
+ interface LoaderOptions extends NextraConfigFromZod {
16
+ isPageImport?: boolean;
17
+ locales: string[];
18
+ contentDir?: string;
19
+ shouldAddLocaleToLinks?: boolean;
20
+ }
21
+ type TPageItem = {
22
+ name: string;
23
+ route: string;
24
+ __pagePath: string;
25
+ };
26
+ type TMetaItem = {
27
+ __metaPath: string;
28
+ };
29
+ interface TFolder<T = TItem> {
30
+ name: string;
31
+ route: string;
32
+ children: T[];
33
+ }
34
+ type TItem = TPageItem | TMetaItem | TFolder;
35
+ interface Folder<FileType = PageMapItem> {
36
+ name: string;
37
+ route: string;
38
+ children: FileType[];
39
+ }
40
+ type Import = {
41
+ importName: string;
42
+ filePath: string;
43
+ };
44
+ type MetaJsonFile = {
45
+ data: {
46
+ [fileName: string]: Meta;
47
+ };
48
+ };
49
+ type DynamicFolder = {
50
+ items: DynamicMeta;
51
+ title?: string;
52
+ };
53
+ type DynamicMetaItem = Meta | DynamicFolder;
54
+ type DynamicMeta = Record<string, DynamicMetaItem>;
55
+ type FrontMatter = Record<string, any>;
56
+ type Meta = string | Record<string, any>;
57
+ type MdxFile<FrontMatterType = FrontMatter> = {
58
+ name: string;
59
+ route: string;
60
+ frontMatter?: FrontMatterType;
61
+ };
62
+ type PageMapItem = Folder | MdxFile | MetaJsonFile;
63
+ type Page = (MdxFile | Folder<Page>) & {
64
+ meta?: Exclude<Meta, string>;
65
+ };
66
+ type Heading = {
67
+ depth: Exclude<Heading$1['depth'], 1>;
68
+ value: string | ReactElement;
69
+ id: string;
70
+ };
71
+ type $NextraMetadata = Omit<Metadata, 'title'> & {
72
+ title: string;
73
+ filePath: string;
74
+ timestamp?: number;
75
+ readingTime?: ReadingTime;
76
+ };
77
+ type ReadingTime = {
78
+ text: string;
79
+ minutes: number;
80
+ time: number;
81
+ words: number;
82
+ };
83
+ type MathJaxOptions = z.infer<typeof MathJaxOptionsSchema>;
84
+ type MDXWrapper = FC<{
85
+ children: ReactNode;
86
+ bottomContent?: ReactNode;
87
+ } & Omit<EvaluateResult, 'default'>>;
88
+ type MetaRecord = Record<string, z.infer<typeof metaSchema>>;
89
+ type SeparatorItem = z.infer<typeof separatorItemSchema>;
90
+ type MenuItem = z.infer<typeof menuSchema>;
91
+ /**
92
+ * Options that can be passed to `pagefind.search()`.
93
+ * @remarks Copied from https://github.com/CloudCannon/pagefind/blob/2a0aa90cfb78bb8551645ac9127a1cd49cf54add/pagefind_web_js/types/index.d.ts#L72-L82
94
+ */
95
+ type PagefindSearchOptions = {
96
+ /**
97
+ * If set, this call will load all assets but return before searching. Prefer using `pagefind.preload()` instead.
98
+ */
99
+ preload?: boolean;
100
+ /**
101
+ * Add more verbose console logging for this search query.
102
+ */
103
+ verbose?: boolean;
104
+ /**
105
+ * The set of filters to execute with this search. Input type is extremely flexible, see the filtering docs for details.
106
+ */
107
+ filters?: object;
108
+ /**
109
+ * The set of sorts to use for this search, instead of relevancy.
110
+ */
111
+ sort?: object;
112
+ };
113
+ type NextraMetadata = Metadata & {
114
+ asIndexPage?: boolean;
115
+ sidebarTitle?: string;
116
+ };
117
+ type EvaluateResult = {
118
+ /** The MDX component to render. */
119
+ default: FC<any>;
120
+ /** Table of contents list. */
121
+ toc: Heading[];
122
+ /** Page's front matter or `metadata` object including `title`, `description`, etc. */
123
+ metadata: $NextraMetadata;
124
+ /** Raw MDX source code */
125
+ sourceCode: string;
126
+ };
127
+
128
+ export type { $NextraMetadata, DynamicFolder, DynamicMeta, DynamicMetaItem, EvaluateResult, Folder, FrontMatter, Heading, Import, LoaderOptions, MDXWrapper, MathJaxOptions, MdxFile, MenuItem, Meta, MetaJsonFile, MetaRecord, NextraMetadata, Page, PageMapItem, PagefindSearchOptions, ReadingTime, SeparatorItem, TItem };
@@ -0,0 +1,203 @@
1
+ import * as rehype_pretty_code from 'rehype-pretty-code';
2
+ import * as _mdx_js_mdx from '@mdx-js/mdx';
3
+ import * as rehype_katex from 'rehype-katex';
4
+ import * as better_react_mathjax from 'better-react-mathjax';
5
+
6
+ interface NextraConfig {
7
+ /**
8
+ * Enable the copy button for all code blocks by default, without needing to set `copy=true` attribute in the code block metadata.
9
+ * > [!TIP]
10
+ * >
11
+ * > You could still disable the button for specific blocks using `copy=false` attribute.
12
+ */
13
+ defaultShowCopyCode?: boolean;
14
+ /**
15
+ * Option to enable search functionality. When enabled, it sets the `data-pagefind-body` attribute on the `<main>` element.
16
+ * > [!TIP]
17
+ * >
18
+ * > When set to `codeblocks: false`, it adds the `data-pagefind-ignore="all"` attribute to all code blocks (`<pre>` elements).
19
+ * @default {
20
+ * "codeblocks": false
21
+ * }
22
+ */
23
+ search?: boolean | {
24
+ /**
25
+ * Whether to index code blocks.
26
+ */
27
+ codeblocks: boolean;
28
+ };
29
+ /**
30
+ * Option to automatically optimizing your static image imports with the Markdown syntax.
31
+ * > [!TIP]
32
+ * >
33
+ * > Example: `![Hello](/demo.png)`.
34
+ * @default true
35
+ */
36
+ staticImage?: boolean;
37
+ /**
38
+ * Adds estimated reading time of `.md` and `.mdx` files using [readingTime](https://npmjs.com/package/reading-time) package.
39
+ * > [!TIP]
40
+ * >
41
+ * > The reading time is added to the front matter under the `readingTime` key.
42
+ */
43
+ readingTime?: boolean;
44
+ /**
45
+ * Enable LaTeX either with [KaTeX](https://katex.org) to pre-render LaTeX expressions directly in MDX or [MathJax](https://mathjax.org) to dynamically render math in the browser.
46
+ */
47
+ latex?: boolean | {
48
+ renderer: "mathjax";
49
+ options?: {
50
+ /**
51
+ * URL for MathJax.
52
+ * @default "https://cdnjs.cloudflare.com"
53
+ */
54
+ src?: string;
55
+ /**
56
+ * MathJax config. See [configuring MathJax](https://docs.mathjax.org/en/latest/options/index.html).
57
+ */
58
+ config?: better_react_mathjax.MathJax3Config;
59
+ };
60
+ } | {
61
+ renderer: "katex";
62
+ /**
63
+ * KaTeX options. See https://katex.org/docs/options.html.
64
+ */
65
+ options: rehype_katex.Options;
66
+ };
67
+ /**
68
+ * Enable or disable syntax highlighting.
69
+ * @default true
70
+ */
71
+ codeHighlight?: boolean;
72
+ /**
73
+ * Options specific to MDX compiling.
74
+ * @remarks `MdxOptions`
75
+ * @default {
76
+ * "format": "detect",
77
+ * "rehypePrettyCodeOptions": {}
78
+ * }
79
+ */
80
+ mdxOptions?: {
81
+ /**
82
+ * List of rehype plugins.
83
+ */
84
+ rehypePlugins?: _mdx_js_mdx.ProcessorOptions["rehypePlugins"];
85
+ /**
86
+ * List of remark plugins.
87
+ */
88
+ remarkPlugins?: _mdx_js_mdx.ProcessorOptions["remarkPlugins"];
89
+ /**
90
+ * List of recma plugins. This is a new ecosystem, currently in beta, to transform esast trees (JavaScript).
91
+ */
92
+ recmaPlugins?: _mdx_js_mdx.ProcessorOptions["recmaPlugins"];
93
+ /**
94
+ * Format of the file.
95
+ * - `'md'` means treat as markdown
96
+ * - `'mdx'` means treat as MDX
97
+ * - `'detect'` means try to detect the format based on file path.
98
+ * @default "detect"
99
+ */
100
+ format?: "detect" | "mdx" | "md";
101
+ /**
102
+ * Configuration options for [Rehype Pretty Code](https://github.com/rehype-pretty/rehype-pretty-code).
103
+ * @remarks `RehypePrettyCodeOptions`
104
+ * @default {}
105
+ */
106
+ rehypePrettyCodeOptions?: rehype_pretty_code.Options;
107
+ };
108
+ /**
109
+ * Allows you to whitelist HTML elements to be replaced with components defined in the `mdx-components.js` file.
110
+ * > [!TIP]
111
+ * >
112
+ * > By default, Nextra only replaces `<details>` and `<summary>` elements.
113
+ */
114
+ whiteListTagsStyling?: string[];
115
+ /**
116
+ * Option to serve your `.md` and `.mdx` files from the `content` directory at a custom path instead of the root (`/`).
117
+ * @default "/"
118
+ */
119
+ contentDirBasePath?: string;
120
+ /**
121
+ * Prefixes locale to all links in the page map information. Useful for i18n when you don't want to use Nextra's `middleware` function.
122
+ * @default false
123
+ */
124
+ unstable_shouldAddLocaleToLinks?: boolean;
125
+ }
126
+ interface HeadProps {
127
+ /**
128
+ * @default {
129
+ * "hue": {
130
+ * "dark": 204,
131
+ * "light": 212
132
+ * },
133
+ * "saturation": {
134
+ * "dark": 100,
135
+ * "light": 100
136
+ * },
137
+ * "lightness": {
138
+ * "dark": 55,
139
+ * "light": 45
140
+ * }
141
+ * }
142
+ */
143
+ color?: {
144
+ /**
145
+ * The hue of the primary theme color.<br/>Range: `0 - 360`
146
+ * @default {
147
+ * "dark": 204,
148
+ * "light": 212
149
+ * }
150
+ */
151
+ hue?: number | {
152
+ dark: number;
153
+ light: number;
154
+ };
155
+ /**
156
+ * The saturation of the primary theme color.<br/>Range: `0 - 100`
157
+ * @default 100
158
+ */
159
+ saturation?: number | {
160
+ dark: number;
161
+ light: number;
162
+ };
163
+ /**
164
+ * The lightness of the primary theme color.<br/>Range: `0 - 100`
165
+ * @default {
166
+ * "dark": 55,
167
+ * "light": 45
168
+ * }
169
+ */
170
+ lightness?: number | {
171
+ dark: number;
172
+ light: number;
173
+ };
174
+ };
175
+ /**
176
+ * The glyph to use as the favicon.
177
+ */
178
+ faviconGlyph?: string;
179
+ /**
180
+ * @default {
181
+ * "dark": "17,17,17",
182
+ * "light": "250,250,250"
183
+ * }
184
+ */
185
+ backgroundColor?: {
186
+ /**
187
+ * Background color for dark theme.<br/>Format: `"rgb(RRR,GGG,BBB)" | "#RRGGBB"`
188
+ * @default "rgb(17,17,17)"
189
+ */
190
+ dark?: string;
191
+ /**
192
+ * Background color for light theme.<br/>Format: `"rgb(RRR,GGG,BBB)" | "#RRGGBB"`
193
+ * @default "rgb(250,250,250)"
194
+ */
195
+ light?: string;
196
+ };
197
+ /**
198
+ * Content of `<head>`.
199
+ */
200
+ children?: React.ReactNode;
201
+ }
202
+
203
+ export type { HeadProps, NextraConfig };
File without changes
package/dist/types.js ADDED
File without changes
package/loader.cjs ADDED
@@ -0,0 +1,24 @@
1
+ /* eslint-env node */
2
+ // https://github.com/mdx-js/mdx/blob/061cdbf440bd8193867fcef3f5a131c08e4fe469/packages/loader/index.cjs
3
+
4
+ /**
5
+ * Webpack loader
6
+ *
7
+ * @todo once webpack supports ESM loaders, remove this wrapper.
8
+ *
9
+ * @this {import('webpack').LoaderContext}
10
+ * @param {string} code
11
+ * @return {Promise<void>}
12
+ */
13
+ module.exports = async function loader(code) {
14
+ const callback = this.async()
15
+
16
+ try {
17
+ // Note that `import()` caches, so this should be fast enough.
18
+ const { loader } = await import('./dist/server/loader.js')
19
+ const result = await loader.call(this, code)
20
+ callback(null, result)
21
+ } catch (error) {
22
+ callback(error)
23
+ }
24
+ }