fumadocs-core 16.4.1 → 16.4.2

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 (278) hide show
  1. package/dist/advanced-BRT5Ij43.js +80 -0
  2. package/dist/advanced-BRT5Ij43.js.map +1 -0
  3. package/dist/algolia-CBBN8R6-.d.ts +68 -0
  4. package/dist/algolia-CBBN8R6-.d.ts.map +1 -0
  5. package/dist/algolia-CQPXCnjV.js +49 -0
  6. package/dist/algolia-CQPXCnjV.js.map +1 -0
  7. package/dist/breadcrumb.d.ts +29 -27
  8. package/dist/breadcrumb.d.ts.map +1 -0
  9. package/dist/breadcrumb.js +55 -72
  10. package/dist/breadcrumb.js.map +1 -0
  11. package/dist/chunk-B-ezknvj.js +42 -0
  12. package/dist/codeblock-utils-lld8UiQo.d.ts +37 -0
  13. package/dist/codeblock-utils-lld8UiQo.d.ts.map +1 -0
  14. package/dist/content/github.d.ts +43 -32
  15. package/dist/content/github.d.ts.map +1 -0
  16. package/dist/content/github.js +29 -43
  17. package/dist/content/github.js.map +1 -0
  18. package/dist/content/index.d.ts +20 -13
  19. package/dist/content/index.d.ts.map +1 -0
  20. package/dist/content/index.js +17 -23
  21. package/dist/content/index.js.map +1 -0
  22. package/dist/content/mdx/preset-bundler.d.ts +22 -24
  23. package/dist/content/mdx/preset-bundler.d.ts.map +1 -0
  24. package/dist/content/mdx/preset-bundler.js +38 -69
  25. package/dist/content/mdx/preset-bundler.js.map +1 -0
  26. package/dist/content/mdx/preset-runtime.d.ts +22 -24
  27. package/dist/content/mdx/preset-runtime.d.ts.map +1 -0
  28. package/dist/content/mdx/preset-runtime.js +36 -68
  29. package/dist/content/mdx/preset-runtime.js.map +1 -0
  30. package/dist/content/toc.d.ts +7 -6
  31. package/dist/content/toc.d.ts.map +1 -0
  32. package/dist/content/toc.js +15 -19
  33. package/dist/content/toc.js.map +1 -0
  34. package/dist/definitions-DuxDer_c.d.ts +62 -0
  35. package/dist/definitions-DuxDer_c.d.ts.map +1 -0
  36. package/dist/dynamic-link.d.ts +7 -5
  37. package/dist/dynamic-link.d.ts.map +1 -0
  38. package/dist/dynamic-link.js +29 -27
  39. package/dist/dynamic-link.js.map +1 -0
  40. package/dist/fetch-B5e9CFfN.js +20 -0
  41. package/dist/fetch-B5e9CFfN.js.map +1 -0
  42. package/dist/framework/index.d.ts +38 -29
  43. package/dist/framework/index.d.ts.map +1 -0
  44. package/dist/framework/index.js +68 -17
  45. package/dist/framework/index.js.map +1 -0
  46. package/dist/framework/next.d.ts +15 -10
  47. package/dist/framework/next.d.ts.map +1 -0
  48. package/dist/framework/next.js +18 -26
  49. package/dist/framework/next.js.map +1 -0
  50. package/dist/framework/react-router.d.ts +15 -10
  51. package/dist/framework/react-router.d.ts.map +1 -0
  52. package/dist/framework/react-router.js +42 -55
  53. package/dist/framework/react-router.js.map +1 -0
  54. package/dist/framework/tanstack.d.ts +15 -10
  55. package/dist/framework/tanstack.d.ts.map +1 -0
  56. package/dist/framework/tanstack.js +54 -69
  57. package/dist/framework/tanstack.js.map +1 -0
  58. package/dist/framework/waku.d.ts +15 -10
  59. package/dist/framework/waku.d.ts.map +1 -0
  60. package/dist/framework/waku.js +47 -58
  61. package/dist/framework/waku.js.map +1 -0
  62. package/dist/highlight/client.d.ts +6 -7
  63. package/dist/highlight/client.d.ts.map +1 -0
  64. package/dist/highlight/client.js +22 -14
  65. package/dist/highlight/client.js.map +1 -0
  66. package/dist/highlight/index.d.ts +2 -30
  67. package/dist/highlight/index.js +3 -13
  68. package/dist/i18n/index.d.ts +2 -39
  69. package/dist/i18n/index.js +6 -7
  70. package/dist/i18n/index.js.map +1 -0
  71. package/dist/i18n/middleware.d.ts +36 -28
  72. package/dist/i18n/middleware.d.ts.map +1 -0
  73. package/dist/i18n/middleware.js +55 -73
  74. package/dist/i18n/middleware.js.map +1 -0
  75. package/dist/icon-Dt7IObrc.js +19 -0
  76. package/dist/icon-Dt7IObrc.js.map +1 -0
  77. package/dist/index-2U6Tl4--.d.ts +379 -0
  78. package/dist/index-2U6Tl4--.d.ts.map +1 -0
  79. package/dist/index-Bw-DCOra.d.ts +41 -0
  80. package/dist/index-Bw-DCOra.d.ts.map +1 -0
  81. package/dist/link.d.ts +17 -15
  82. package/dist/link.d.ts.map +1 -0
  83. package/dist/link.js +29 -9
  84. package/dist/link.js.map +1 -0
  85. package/dist/mdast-utils-mc9-X-PK.js +40 -0
  86. package/dist/mdast-utils-mc9-X-PK.js.map +1 -0
  87. package/dist/mdx-plugins/codeblock-utils.d.ts +2 -29
  88. package/dist/mdx-plugins/codeblock-utils.js +71 -9
  89. package/dist/mdx-plugins/codeblock-utils.js.map +1 -0
  90. package/dist/mdx-plugins/index.d.ts +15 -20
  91. package/dist/mdx-plugins/index.js +18 -73
  92. package/dist/mdx-plugins/rehype-code.d.ts +2 -55
  93. package/dist/mdx-plugins/rehype-code.js +5 -15
  94. package/dist/mdx-plugins/rehype-toc.d.ts +2 -14
  95. package/dist/mdx-plugins/rehype-toc.js +3 -7
  96. package/dist/mdx-plugins/remark-admonition.d.ts +2 -20
  97. package/dist/mdx-plugins/remark-admonition.js +74 -8
  98. package/dist/mdx-plugins/remark-admonition.js.map +1 -0
  99. package/dist/mdx-plugins/remark-code-tab.d.ts +2 -30
  100. package/dist/mdx-plugins/remark-code-tab.js +183 -7
  101. package/dist/mdx-plugins/remark-code-tab.js.map +1 -0
  102. package/dist/mdx-plugins/remark-directive-admonition.d.ts +2 -27
  103. package/dist/mdx-plugins/remark-directive-admonition.js +60 -7
  104. package/dist/mdx-plugins/remark-directive-admonition.js.map +1 -0
  105. package/dist/mdx-plugins/remark-gfm.d.ts +2 -1
  106. package/dist/mdx-plugins/remark-gfm.js +3 -7
  107. package/dist/mdx-plugins/remark-heading.d.ts +2 -31
  108. package/dist/mdx-plugins/remark-heading.js +45 -8
  109. package/dist/mdx-plugins/remark-heading.js.map +1 -0
  110. package/dist/mdx-plugins/remark-image.d.ts +2 -57
  111. package/dist/mdx-plugins/remark-image.js +192 -7
  112. package/dist/mdx-plugins/remark-image.js.map +1 -0
  113. package/dist/mdx-plugins/remark-mdx-files.d.ts +2 -40
  114. package/dist/mdx-plugins/remark-mdx-files.js +187 -7
  115. package/dist/mdx-plugins/remark-mdx-files.js.map +1 -0
  116. package/dist/mdx-plugins/remark-mdx-mermaid.d.ts +2 -15
  117. package/dist/mdx-plugins/remark-mdx-mermaid.js +31 -7
  118. package/dist/mdx-plugins/remark-mdx-mermaid.js.map +1 -0
  119. package/dist/mdx-plugins/remark-npm.d.ts +2 -31
  120. package/dist/mdx-plugins/remark-npm.js +68 -8
  121. package/dist/mdx-plugins/remark-npm.js.map +1 -0
  122. package/dist/mdx-plugins/remark-steps.d.ts +2 -23
  123. package/dist/mdx-plugins/remark-steps.js +77 -7
  124. package/dist/mdx-plugins/remark-steps.js.map +1 -0
  125. package/dist/mdx-plugins/remark-structure.d.ts +2 -71
  126. package/dist/mdx-plugins/remark-structure.js +105 -11
  127. package/dist/mdx-plugins/remark-structure.js.map +1 -0
  128. package/dist/mixedbread-DlByNYSd.js +88 -0
  129. package/dist/mixedbread-DlByNYSd.js.map +1 -0
  130. package/dist/negotiation/index.d.ts +6 -4
  131. package/dist/negotiation/index.d.ts.map +1 -0
  132. package/dist/negotiation/index.js +41 -11
  133. package/dist/negotiation/index.js.map +1 -0
  134. package/dist/normalize-url-DP9-1I-S.js +16 -0
  135. package/dist/normalize-url-DP9-1I-S.js.map +1 -0
  136. package/dist/orama-cloud-DH3g37zc.js +84 -0
  137. package/dist/orama-cloud-DH3g37zc.js.map +1 -0
  138. package/dist/page-tree/index.d.ts +23 -11
  139. package/dist/page-tree/index.d.ts.map +1 -0
  140. package/dist/page-tree/index.js +3 -17
  141. package/dist/path-DHIjrDBP.js +60 -0
  142. package/dist/path-DHIjrDBP.js.map +1 -0
  143. package/dist/rehype-code-CdiZ1Y6P.js +241 -0
  144. package/dist/rehype-code-CdiZ1Y6P.js.map +1 -0
  145. package/dist/rehype-code-vVWG4-ej.d.ts +58 -0
  146. package/dist/rehype-code-vVWG4-ej.d.ts.map +1 -0
  147. package/dist/rehype-toc-DJvSyE0o.d.ts +18 -0
  148. package/dist/rehype-toc-DJvSyE0o.d.ts.map +1 -0
  149. package/dist/rehype-toc-DVwJcwvA.js +143 -0
  150. package/dist/rehype-toc-DVwJcwvA.js.map +1 -0
  151. package/dist/remark-admonition-DOwBWzsH.d.ts +22 -0
  152. package/dist/remark-admonition-DOwBWzsH.d.ts.map +1 -0
  153. package/dist/remark-code-tab-CXsYlims.d.ts +32 -0
  154. package/dist/remark-code-tab-CXsYlims.d.ts.map +1 -0
  155. package/dist/remark-directive-admonition-BCm_yiU9.d.ts +36 -0
  156. package/dist/remark-directive-admonition-BCm_yiU9.d.ts.map +1 -0
  157. package/dist/remark-gfm-CeWpMwyk.d.ts +2 -0
  158. package/dist/remark-heading-CXvCY0go.d.ts +37 -0
  159. package/dist/remark-heading-CXvCY0go.d.ts.map +1 -0
  160. package/dist/remark-image-CvUis4R1.d.ts +65 -0
  161. package/dist/remark-image-CvUis4R1.d.ts.map +1 -0
  162. package/dist/remark-mdx-files-B31xFFG4.d.ts +56 -0
  163. package/dist/remark-mdx-files-B31xFFG4.d.ts.map +1 -0
  164. package/dist/remark-mdx-mermaid-BdSUUiCG.d.ts +17 -0
  165. package/dist/remark-mdx-mermaid-BdSUUiCG.d.ts.map +1 -0
  166. package/dist/remark-npm-BIvIEKT2.d.ts +36 -0
  167. package/dist/remark-npm-BIvIEKT2.d.ts.map +1 -0
  168. package/dist/remark-steps-CHJN-rtm.d.ts +28 -0
  169. package/dist/remark-steps-CHJN-rtm.d.ts.map +1 -0
  170. package/dist/remark-structure-RZD2gGKp.d.ts +77 -0
  171. package/dist/remark-structure-RZD2gGKp.d.ts.map +1 -0
  172. package/dist/remove-undefined-Cfs4o_mM.js +19 -0
  173. package/dist/remove-undefined-Cfs4o_mM.js.map +1 -0
  174. package/dist/search/algolia.d.ts +3 -69
  175. package/dist/search/algolia.js +69 -63
  176. package/dist/search/algolia.js.map +1 -0
  177. package/dist/search/client.d.ts +120 -114
  178. package/dist/search/client.d.ts.map +1 -0
  179. package/dist/search/client.js +92 -91
  180. package/dist/search/client.js.map +1 -0
  181. package/dist/search/index.d.ts +20 -18
  182. package/dist/search/index.d.ts.map +1 -0
  183. package/dist/search/index.js +3 -7
  184. package/dist/search/orama-cloud.d.ts +70 -68
  185. package/dist/search/orama-cloud.d.ts.map +1 -0
  186. package/dist/search/orama-cloud.js +46 -54
  187. package/dist/search/orama-cloud.js.map +1 -0
  188. package/dist/search/server.d.ts +6 -136
  189. package/dist/search/server.js +292 -369
  190. package/dist/search/server.js.map +1 -0
  191. package/dist/search-D6ChCLhY.js +44 -0
  192. package/dist/search-D6ChCLhY.js.map +1 -0
  193. package/dist/server-CPR_fgkH.d.ts +133 -0
  194. package/dist/server-CPR_fgkH.d.ts.map +1 -0
  195. package/dist/shiki-4oMYwHED.js +80 -0
  196. package/dist/shiki-4oMYwHED.js.map +1 -0
  197. package/dist/shiki-CIBQys54.d.ts +33 -0
  198. package/dist/shiki-CIBQys54.d.ts.map +1 -0
  199. package/dist/source/client/index.d.ts +7 -5
  200. package/dist/source/client/index.d.ts.map +1 -0
  201. package/dist/source/client/index.js +24 -35
  202. package/dist/source/client/index.js.map +1 -0
  203. package/dist/source/index.d.ts +3 -42
  204. package/dist/source/index.js +599 -752
  205. package/dist/source/index.js.map +1 -0
  206. package/dist/source/plugins/lucide-icons.d.ts +7 -7
  207. package/dist/source/plugins/lucide-icons.d.ts.map +1 -0
  208. package/dist/source/plugins/lucide-icons.js +21 -20
  209. package/dist/source/plugins/lucide-icons.js.map +1 -0
  210. package/dist/source/plugins/slugs.d.ts +3 -0
  211. package/dist/source/plugins/slugs.js +65 -0
  212. package/dist/source/plugins/slugs.js.map +1 -0
  213. package/dist/source/schema.d.ts +17 -14
  214. package/dist/source/schema.d.ts.map +1 -0
  215. package/dist/source/schema.js +26 -22
  216. package/dist/source/schema.js.map +1 -0
  217. package/dist/static-Dq8pA8Ay.js +51 -0
  218. package/dist/static-Dq8pA8Ay.js.map +1 -0
  219. package/dist/toc.d.ts +38 -25
  220. package/dist/toc.d.ts.map +1 -0
  221. package/dist/toc.js +123 -136
  222. package/dist/toc.js.map +1 -0
  223. package/dist/util-CK2ykiif.d.ts +8 -0
  224. package/dist/util-CK2ykiif.d.ts.map +1 -0
  225. package/dist/util-s9piKHsk.js +10 -0
  226. package/dist/util-s9piKHsk.js.map +1 -0
  227. package/dist/utils/use-effect-event.d.ts +3 -1
  228. package/dist/utils/use-effect-event.d.ts.map +1 -0
  229. package/dist/utils/use-effect-event.js +16 -13
  230. package/dist/utils/use-effect-event.js.map +1 -0
  231. package/dist/utils/use-media-query.d.ts +3 -1
  232. package/dist/utils/use-media-query.d.ts.map +1 -0
  233. package/dist/utils/use-media-query.js +20 -20
  234. package/dist/utils/use-media-query.js.map +1 -0
  235. package/dist/utils/use-on-change.d.ts +3 -1
  236. package/dist/utils/use-on-change.d.ts.map +1 -0
  237. package/dist/utils/use-on-change.js +23 -7
  238. package/dist/utils/use-on-change.js.map +1 -0
  239. package/dist/utils-DUvi2WkD.js +134 -0
  240. package/dist/utils-DUvi2WkD.js.map +1 -0
  241. package/package.json +60 -58
  242. package/dist/algolia-IZEDLPHE.js +0 -58
  243. package/dist/chunk-5PMI7QDD.js +0 -220
  244. package/dist/chunk-ADBHPKXG.js +0 -78
  245. package/dist/chunk-APKPSBSB.js +0 -74
  246. package/dist/chunk-CH7YHH7V.js +0 -222
  247. package/dist/chunk-EFVXL2PP.js +0 -144
  248. package/dist/chunk-EMWGTXSW.js +0 -19
  249. package/dist/chunk-FAEPKD7U.js +0 -20
  250. package/dist/chunk-FUUVPEA5.js +0 -29
  251. package/dist/chunk-GINBKBVQ.js +0 -12
  252. package/dist/chunk-GLRQBLGN.js +0 -59
  253. package/dist/chunk-JUF4WZ6G.js +0 -117
  254. package/dist/chunk-K4WNLOVQ.js +0 -75
  255. package/dist/chunk-L4JKQWCM.js +0 -131
  256. package/dist/chunk-MA6O2UUE.js +0 -50
  257. package/dist/chunk-ONG4RVCR.js +0 -8
  258. package/dist/chunk-OTD7MV33.js +0 -53
  259. package/dist/chunk-PFNP6PEB.js +0 -11
  260. package/dist/chunk-SH7BNTG7.js +0 -38
  261. package/dist/chunk-TWIDBWFG.js +0 -84
  262. package/dist/chunk-U67V476Y.js +0 -35
  263. package/dist/chunk-VLSDGCJE.js +0 -47
  264. package/dist/chunk-W6WTLKRA.js +0 -73
  265. package/dist/chunk-X2HFD5QJ.js +0 -275
  266. package/dist/chunk-XJ6ZQNEX.js +0 -91
  267. package/dist/chunk-XN2LKXFZ.js +0 -101
  268. package/dist/chunk-XOFXGHS4.js +0 -93
  269. package/dist/chunk-XZSI7AHE.js +0 -67
  270. package/dist/chunk-YVVDKJ2H.js +0 -34
  271. package/dist/chunk-ZMWYLUDP.js +0 -21
  272. package/dist/definitions-pJ7PybYY.d.ts +0 -60
  273. package/dist/fetch-IBTWQCJR.js +0 -22
  274. package/dist/loader-_E2HOdV0.d.ts +0 -333
  275. package/dist/mixedbread-A3WLENES.js +0 -117
  276. package/dist/orama-cloud-UZAPMPFV.js +0 -93
  277. package/dist/static-A2YJ5TXV.js +0 -62
  278. package/dist/util-bZU2QeJ2.d.ts +0 -6
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils-DUvi2WkD.js","names":["out: PageTree.Item[]","result: PageTree.Root | PageTree.Folder | undefined","separator: PageTree.Separator | undefined","nodes","items: PageTree.Node[]"],"sources":["../src/page-tree/utils.ts"],"sourcesContent":["import type * as PageTree from '@/page-tree/definitions';\n\n/**\n * Flatten tree to an array of page nodes\n */\nexport function flattenTree(nodes: PageTree.Node[]): PageTree.Item[] {\n const out: PageTree.Item[] = [];\n\n for (const node of nodes) {\n if (node.type === 'folder') {\n if (node.index) out.push(node.index);\n out.push(...flattenTree(node.children));\n } else if (node.type === 'page') {\n out.push(node);\n }\n }\n\n return out;\n}\n\n/**\n * Get neighbours of a page, useful for implementing \"previous & next\" buttons\n */\nexport function findNeighbour(\n tree: PageTree.Root,\n url: string,\n options?: {\n separateRoot?: boolean;\n },\n): {\n previous?: PageTree.Item;\n next?: PageTree.Item;\n} {\n const { separateRoot = true } = options ?? {};\n const roots = separateRoot ? getPageTreeRoots(tree) : [tree];\n if (tree.fallback) roots.push(tree.fallback);\n\n for (const root of roots) {\n const list = flattenTree(root.children);\n const idx = list.findIndex((item) => item.url === url);\n if (idx === -1) continue;\n\n return {\n previous: list[idx - 1],\n next: list[idx + 1],\n };\n }\n\n return {};\n}\n\nexport function getPageTreeRoots(\n pageTree: PageTree.Root | PageTree.Folder,\n): (PageTree.Root | PageTree.Folder)[] {\n const result = pageTree.children.flatMap((child) => {\n if (child.type !== 'folder') return [];\n const roots = getPageTreeRoots(child);\n\n if (child.root) roots.push(child);\n return roots;\n });\n\n if (!('type' in pageTree)) result.push(pageTree);\n return result;\n}\n\n/**\n * Get other item nodes that lives under the same parent.\n */\nexport function getPageTreePeers(\n treeOrTrees: PageTree.Root | Record<string, PageTree.Root>,\n url: string,\n): PageTree.Item[] {\n return findSiblings(treeOrTrees, url).filter((item) => item.type === 'page');\n}\n\n/**\n * Get other tree nodes that lives under the same parent.\n */\nexport function findSiblings(\n treeOrTrees: PageTree.Root | Record<string, PageTree.Root>,\n url: string,\n): PageTree.Node[] {\n // Check if it's a single tree or multiple trees (i18n)\n if ('children' in treeOrTrees) {\n // Single tree case\n const tree = treeOrTrees as PageTree.Root;\n const parent = findParent(tree, url);\n if (!parent) return [];\n\n return parent.children.filter((item) => item.type !== 'page' || item.url !== url);\n }\n\n // Multiple trees case\n for (const lang in treeOrTrees) {\n const result = getPageTreePeers(treeOrTrees[lang], url);\n if (result) return result;\n }\n\n return [];\n}\n\nexport function findParent(\n from: PageTree.Root | PageTree.Folder,\n url: string,\n): PageTree.Root | PageTree.Folder | undefined {\n let result: PageTree.Root | PageTree.Folder | undefined;\n\n visit(from, (node, parent) => {\n if ('type' in node && node.type === 'page' && node.url === url) {\n result = parent;\n return 'break';\n }\n });\n\n return result;\n}\n\n/**\n * Search the path of a node in the tree matched by the matcher.\n *\n * @returns The path to the target node (from starting root), or null if the page doesn't exist\n */\nexport function findPath(\n nodes: PageTree.Node[],\n matcher: (node: PageTree.Node) => boolean,\n options: {\n includeSeparator?: boolean;\n } = {},\n): PageTree.Node[] | null {\n const { includeSeparator = true } = options;\n\n function run(nodes: PageTree.Node[]): PageTree.Node[] | undefined {\n let separator: PageTree.Separator | undefined;\n\n for (const node of nodes) {\n if (matcher(node)) {\n const items: PageTree.Node[] = [];\n if (separator) items.push(separator);\n items.push(node);\n\n return items;\n }\n\n if (node.type === 'separator' && includeSeparator) {\n separator = node;\n continue;\n }\n\n if (node.type === 'folder') {\n const items = node.index && matcher(node.index) ? [node.index] : run(node.children);\n\n if (items) {\n items.unshift(node);\n if (separator) items.unshift(separator);\n\n return items;\n }\n }\n }\n }\n\n return run(nodes) ?? null;\n}\n\nconst VisitBreak = Symbol('VisitBreak');\n\n/**\n * Perform a depth-first search on page tree visiting every node.\n *\n * @param root - the root of page tree to visit.\n * @param visitor - function to receive nodes, return `skip` to skip the children of current node, `break` to stop the search entirely.\n */\nexport function visit<Root extends PageTree.Node | PageTree.Root>(\n root: Root,\n visitor: <T extends PageTree.Node | PageTree.Root>(\n node: T,\n parent?: PageTree.Root | PageTree.Folder,\n ) => 'skip' | 'break' | T | void,\n): Root {\n function onNode<T extends PageTree.Node | PageTree.Root>(\n node: T,\n parent?: PageTree.Root | PageTree.Folder,\n ): T {\n const result = visitor(node, parent);\n switch (result) {\n case 'skip':\n return node;\n case 'break':\n throw VisitBreak;\n default:\n if (result) node = result;\n }\n\n if ('index' in node && node.index) {\n node.index = onNode(node.index, node);\n }\n\n if ('fallback' in node && node.fallback) {\n node.fallback = onNode(node.fallback, node);\n }\n\n if ('children' in node) {\n for (let i = 0; i < node.children.length; i++) {\n node.children[i] = onNode(node.children[i], node);\n }\n }\n\n return node;\n }\n\n try {\n return onNode(root);\n } catch (e) {\n if (e === VisitBreak) return root;\n throw e;\n }\n}\n"],"mappings":"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"}
package/package.json CHANGED
@@ -1,113 +1,116 @@
1
1
  {
2
2
  "name": "fumadocs-core",
3
- "version": "16.4.1",
3
+ "version": "16.4.2",
4
4
  "description": "The React.js library for building a documentation website",
5
5
  "keywords": [
6
- "Fumadocs",
7
- "Docs"
6
+ "Docs",
7
+ "Fumadocs"
8
8
  ],
9
9
  "homepage": "https://fumadocs.dev",
10
- "repository": "github:fuma-nama/fumadocs",
11
10
  "license": "MIT",
12
11
  "author": "Fuma Nama",
12
+ "repository": "github:fuma-nama/fumadocs",
13
+ "files": [
14
+ "dist/*"
15
+ ],
13
16
  "type": "module",
14
17
  "exports": {
15
18
  "./breadcrumb": {
16
- "import": "./dist/breadcrumb.js",
17
- "types": "./dist/breadcrumb.d.ts"
19
+ "types": "./dist/breadcrumb.d.ts",
20
+ "import": "./dist/breadcrumb.js"
18
21
  },
19
22
  "./toc": {
20
- "import": "./dist/toc.js",
21
- "types": "./dist/toc.d.ts"
23
+ "types": "./dist/toc.d.ts",
24
+ "import": "./dist/toc.js"
22
25
  },
23
26
  "./content": {
24
- "import": "./dist/content/index.js",
25
- "types": "./dist/content/index.d.ts"
27
+ "types": "./dist/content/index.d.ts",
28
+ "import": "./dist/content/index.js"
26
29
  },
27
30
  "./content/*": {
28
- "import": "./dist/content/*.js",
29
- "types": "./dist/content/*.d.ts"
31
+ "types": "./dist/content/*.d.ts",
32
+ "import": "./dist/content/*.js"
30
33
  },
31
34
  "./negotiation": {
32
- "import": "./dist/negotiation/index.js",
33
- "types": "./dist/negotiation/index.d.ts"
35
+ "types": "./dist/negotiation/index.d.ts",
36
+ "import": "./dist/negotiation/index.js"
34
37
  },
35
38
  "./page-tree": {
36
- "import": "./dist/page-tree/index.js",
37
- "types": "./dist/page-tree/index.d.ts"
39
+ "types": "./dist/page-tree/index.d.ts",
40
+ "import": "./dist/page-tree/index.js"
38
41
  },
39
42
  "./search": {
40
- "import": "./dist/search/index.js",
41
- "types": "./dist/search/index.d.ts"
43
+ "types": "./dist/search/index.d.ts",
44
+ "import": "./dist/search/index.js"
42
45
  },
43
46
  "./search/*": {
44
- "import": "./dist/search/*.js",
45
- "types": "./dist/search/*.d.ts"
47
+ "types": "./dist/search/*.d.ts",
48
+ "import": "./dist/search/*.js"
46
49
  },
47
50
  "./source": {
48
- "import": "./dist/source/index.js",
49
- "types": "./dist/source/index.d.ts"
51
+ "types": "./dist/source/index.d.ts",
52
+ "import": "./dist/source/index.js"
50
53
  },
51
54
  "./source/client": {
52
- "import": "./dist/source/client/index.js",
53
- "types": "./dist/source/client/index.d.ts"
55
+ "types": "./dist/source/client/index.d.ts",
56
+ "import": "./dist/source/client/index.js"
54
57
  },
55
58
  "./source/schema": {
56
- "import": "./dist/source/schema.js",
57
- "types": "./dist/source/schema.d.ts"
59
+ "types": "./dist/source/schema.d.ts",
60
+ "import": "./dist/source/schema.js"
58
61
  },
59
62
  "./source/*": {
60
- "import": "./dist/source/plugins/*.js",
61
- "types": "./dist/source/plugins/*.d.ts"
63
+ "types": "./dist/source/plugins/*.d.ts",
64
+ "import": "./dist/source/plugins/*.js"
62
65
  },
63
66
  "./utils/*": {
64
- "import": "./dist/utils/*.js",
65
- "types": "./dist/utils/*.d.ts"
67
+ "types": "./dist/utils/*.d.ts",
68
+ "import": "./dist/utils/*.js"
66
69
  },
67
70
  "./link": {
68
- "import": "./dist/link.js",
69
- "types": "./dist/link.d.ts"
71
+ "types": "./dist/link.d.ts",
72
+ "import": "./dist/link.js"
70
73
  },
71
74
  "./dynamic-link": {
72
- "import": "./dist/dynamic-link.js",
73
- "types": "./dist/dynamic-link.d.ts"
75
+ "types": "./dist/dynamic-link.d.ts",
76
+ "import": "./dist/dynamic-link.js"
74
77
  },
75
78
  "./mdx-plugins": {
76
- "import": "./dist/mdx-plugins/index.js",
77
- "types": "./dist/mdx-plugins/index.d.ts"
79
+ "types": "./dist/mdx-plugins/index.d.ts",
80
+ "import": "./dist/mdx-plugins/index.js"
78
81
  },
79
82
  "./mdx-plugins/*": {
80
- "import": "./dist/mdx-plugins/*.js",
81
- "types": "./dist/mdx-plugins/*.d.ts"
83
+ "types": "./dist/mdx-plugins/*.d.ts",
84
+ "import": "./dist/mdx-plugins/*.js"
82
85
  },
83
86
  "./i18n": {
84
- "import": "./dist/i18n/index.js",
85
- "types": "./dist/i18n/index.d.ts"
87
+ "types": "./dist/i18n/index.d.ts",
88
+ "import": "./dist/i18n/index.js"
86
89
  },
87
90
  "./i18n/middleware": {
88
- "import": "./dist/i18n/middleware.js",
89
- "types": "./dist/i18n/middleware.d.ts"
91
+ "types": "./dist/i18n/middleware.d.ts",
92
+ "import": "./dist/i18n/middleware.js"
90
93
  },
91
94
  "./highlight": {
92
- "import": "./dist/highlight/index.js",
93
- "types": "./dist/highlight/index.d.ts"
95
+ "types": "./dist/highlight/index.d.ts",
96
+ "import": "./dist/highlight/index.js"
94
97
  },
95
98
  "./highlight/client": {
96
- "import": "./dist/highlight/client.js",
97
- "types": "./dist/highlight/client.d.ts"
99
+ "types": "./dist/highlight/client.d.ts",
100
+ "import": "./dist/highlight/client.js"
98
101
  },
99
102
  "./framework": {
100
- "import": "./dist/framework/index.js",
101
- "types": "./dist/framework/index.d.ts"
103
+ "types": "./dist/framework/index.d.ts",
104
+ "import": "./dist/framework/index.js"
102
105
  },
103
106
  "./framework/*": {
104
- "import": "./dist/framework/*.js",
105
- "types": "./dist/framework/*.d.ts"
107
+ "types": "./dist/framework/*.d.ts",
108
+ "import": "./dist/framework/*.js"
106
109
  }
107
110
  },
108
- "files": [
109
- "dist/*"
110
- ],
111
+ "publishConfig": {
112
+ "access": "public"
113
+ },
111
114
  "dependencies": {
112
115
  "@formatjs/intl-localematcher": "^0.7.2",
113
116
  "@orama/orama": "^3.1.18",
@@ -126,6 +129,7 @@
126
129
  "remark-rehype": "^11.1.2",
127
130
  "scroll-into-view-if-needed": "^3.1.0",
128
131
  "shiki": "^3.20.0",
132
+ "tinyglobby": "^0.2.15",
129
133
  "unist-util-visit": "^5.0.0"
130
134
  },
131
135
  "devDependencies": {
@@ -149,6 +153,7 @@
149
153
  "remark-directive": "^4.0.0",
150
154
  "remark-mdx": "^3.1.1",
151
155
  "remove-markdown": "^0.6.2",
156
+ "tsdown": "^0.18.3",
152
157
  "typescript": "^5.9.3",
153
158
  "unified": "^11.0.5",
154
159
  "vfile": "^6.0.3",
@@ -209,13 +214,10 @@
209
214
  "optional": true
210
215
  }
211
216
  },
212
- "publishConfig": {
213
- "access": "public"
214
- },
215
217
  "scripts": {
216
- "build": "tsup",
218
+ "build": "tsdown",
217
219
  "clean": "rimraf dist",
218
- "dev": "tsup --watch",
220
+ "dev": "tsdown --watch",
219
221
  "lint": "eslint .",
220
222
  "types:check": "tsc --noEmit"
221
223
  }
@@ -1,58 +0,0 @@
1
- import {
2
- createContentHighlighter
3
- } from "./chunk-OTD7MV33.js";
4
- import "./chunk-U67V476Y.js";
5
-
6
- // src/search/client/algolia.ts
7
- function groupResults(hits) {
8
- const grouped = [];
9
- const scannedUrls = /* @__PURE__ */ new Set();
10
- for (const hit of hits) {
11
- if (!scannedUrls.has(hit.url)) {
12
- scannedUrls.add(hit.url);
13
- grouped.push({
14
- id: hit.url,
15
- type: "page",
16
- breadcrumbs: hit.breadcrumbs,
17
- url: hit.url,
18
- content: hit.title
19
- });
20
- }
21
- grouped.push({
22
- id: hit.objectID,
23
- type: hit.content === hit.section ? "heading" : "text",
24
- url: hit.section_id ? `${hit.url}#${hit.section_id}` : hit.url,
25
- content: hit.content
26
- });
27
- }
28
- return grouped;
29
- }
30
- async function searchDocs(query, { indexName, onSearch, client, locale, tag }) {
31
- if (query.trim().length === 0) return [];
32
- const result = onSearch ? await onSearch(query, tag, locale) : await client.searchForHits({
33
- requests: [
34
- {
35
- type: "default",
36
- indexName,
37
- query,
38
- distinct: 5,
39
- hitsPerPage: 10,
40
- filters: tag ? `tag:${tag}` : void 0
41
- }
42
- ]
43
- });
44
- const highlighter = createContentHighlighter(query);
45
- return groupResults(result.results[0].hits).flatMap((hit) => {
46
- if (hit.type === "page") {
47
- return {
48
- ...hit,
49
- contentWithHighlights: hit.contentWithHighlights ?? highlighter.highlight(hit.content)
50
- };
51
- }
52
- return [];
53
- });
54
- }
55
- export {
56
- groupResults,
57
- searchDocs
58
- };
@@ -1,220 +0,0 @@
1
- // src/mdx-plugins/remark-image.ts
2
- import * as path from "path";
3
- import { visit } from "unist-util-visit";
4
- import { fileURLToPath } from "url";
5
- var VALID_BLUR_EXT = [".jpeg", ".png", ".webp", ".avif", ".jpg"];
6
- var EXTERNAL_URL_REGEX = /^https?:\/\//;
7
- function remarkImage({
8
- placeholder = "blur",
9
- external = true,
10
- useImport = true,
11
- onError = "error",
12
- publicDir = path.join(process.cwd(), "public")
13
- } = {}) {
14
- return async (tree, file) => {
15
- const importsToInject = [];
16
- const promises = [];
17
- async function onImage(src, node) {
18
- const attributes = [
19
- {
20
- type: "mdxJsxAttribute",
21
- name: "alt",
22
- value: node.alt ?? "image"
23
- }
24
- ];
25
- if (node.title) {
26
- attributes.push({
27
- type: "mdxJsxAttribute",
28
- name: "title",
29
- value: node.title
30
- });
31
- }
32
- if (src.type === "file" && useImport) {
33
- const variableName = `__img${importsToInject.length}`;
34
- const hasBlur = placeholder === "blur" && VALID_BLUR_EXT.some((ext) => src.file.endsWith(ext));
35
- if (!file.dirname) {
36
- throw new Error(
37
- "When `useImport` is enabled, you must specify `dirname` in the VFile passed to compiler."
38
- );
39
- }
40
- importsToInject.push({
41
- variableName,
42
- importPath: getImportPath(src.file, file.dirname)
43
- });
44
- attributes.push({
45
- type: "mdxJsxAttribute",
46
- name: "src",
47
- value: {
48
- type: "mdxJsxAttributeValueExpression",
49
- value: variableName,
50
- data: {
51
- estree: {
52
- body: [
53
- {
54
- type: "ExpressionStatement",
55
- expression: { type: "Identifier", name: variableName }
56
- }
57
- ],
58
- type: "Program",
59
- sourceType: "script"
60
- }
61
- }
62
- }
63
- });
64
- const out = {
65
- children: [],
66
- type: "mdxJsxFlowElement",
67
- name: "img",
68
- attributes
69
- };
70
- if (hasBlur) {
71
- out.attributes.push({
72
- type: "mdxJsxAttribute",
73
- name: "placeholder",
74
- value: "blur"
75
- });
76
- }
77
- return out;
78
- }
79
- const size = await getImageSize(src, external).catch((e) => {
80
- throw new Error(
81
- `[Remark Image] Failed obtain image size for ${node.url} (public directory configured as ${publicDir})`,
82
- {
83
- cause: e
84
- }
85
- );
86
- });
87
- if (!size) return;
88
- attributes.push(
89
- {
90
- type: "mdxJsxAttribute",
91
- name: "src",
92
- // `src` doesn't support file paths, we can use `node.url` for files and let the underlying framework handle it
93
- value: src.type === "url" ? src.url.toString() : node.url
94
- },
95
- {
96
- type: "mdxJsxAttribute",
97
- name: "width",
98
- value: size.width.toString()
99
- },
100
- {
101
- type: "mdxJsxAttribute",
102
- name: "height",
103
- value: size.height.toString()
104
- }
105
- );
106
- return {
107
- type: "mdxJsxFlowElement",
108
- name: "img",
109
- attributes,
110
- children: []
111
- };
112
- }
113
- visit(tree, "image", (node) => {
114
- const src = parseSrc(decodeURI(node.url), publicDir, file.dirname);
115
- if (!src) return;
116
- const task = onImage(src, node).catch((e) => {
117
- if (onError === "ignore" || node.url.endsWith(".svg")) {
118
- return;
119
- }
120
- if (onError === "hide") {
121
- return {
122
- type: "mdxJsxFlowElement",
123
- name: null,
124
- attributes: [],
125
- children: []
126
- };
127
- }
128
- if (onError === "error") throw e;
129
- onError(e);
130
- }).then((res) => {
131
- if (res) Object.assign(node, res);
132
- });
133
- promises.push(task);
134
- });
135
- await Promise.all(promises);
136
- if (importsToInject.length === 0) return;
137
- const imports = importsToInject.map(
138
- ({ variableName, importPath }) => ({
139
- type: "mdxjsEsm",
140
- data: {
141
- estree: {
142
- body: [
143
- {
144
- type: "ImportDeclaration",
145
- source: { type: "Literal", value: importPath },
146
- specifiers: [
147
- {
148
- type: "ImportDefaultSpecifier",
149
- local: { type: "Identifier", name: variableName }
150
- }
151
- ]
152
- }
153
- ]
154
- }
155
- }
156
- })
157
- );
158
- tree.children.unshift(...imports);
159
- };
160
- }
161
- function getImportPath(file, dir) {
162
- const relative2 = path.relative(dir, file).replaceAll(path.sep, "/");
163
- return relative2.startsWith("../") ? relative2 : `./${relative2}`;
164
- }
165
- function parseSrc(src, publicDir, dir) {
166
- if (src.startsWith("file:///"))
167
- return { type: "file", file: fileURLToPath(src) };
168
- if (EXTERNAL_URL_REGEX.test(src)) {
169
- return {
170
- type: "url",
171
- url: new URL(src)
172
- };
173
- }
174
- if (src.startsWith("/")) {
175
- if (EXTERNAL_URL_REGEX.test(publicDir)) {
176
- const url = new URL(publicDir);
177
- const segs = [...url.pathname.split("/"), ...src.split("/")].filter(
178
- (v) => v.length > 0
179
- );
180
- url.pathname = `/${segs.join("/")}`;
181
- return { type: "url", url };
182
- }
183
- return {
184
- type: "file",
185
- file: path.join(publicDir, src)
186
- };
187
- }
188
- if (!dir) {
189
- console.warn(
190
- `[Remark Image] found relative path ${src} but missing 'dirname' in VFile, this image will be skipped for now.`
191
- );
192
- return;
193
- }
194
- return {
195
- type: "file",
196
- file: path.join(dir, src)
197
- };
198
- }
199
- async function getImageSize(src, onExternal) {
200
- if (src.type === "file") {
201
- const { imageSizeFromFile } = await import("image-size/fromFile");
202
- return imageSizeFromFile(src.file);
203
- }
204
- if (onExternal === false) return;
205
- const { timeout } = typeof onExternal === "object" ? onExternal : {};
206
- const res = await fetch(src.url, {
207
- signal: typeof timeout === "number" ? AbortSignal.timeout(timeout) : void 0
208
- });
209
- if (!res.ok) {
210
- throw new Error(
211
- `[Remark Image] Failed to fetch ${src.url} (${res.status}): ${await res.text()}`
212
- );
213
- }
214
- const { imageSize } = await import("image-size");
215
- return imageSize(new Uint8Array(await res.arrayBuffer()));
216
- }
217
-
218
- export {
219
- remarkImage
220
- };
@@ -1,78 +0,0 @@
1
- // src/mdx-plugins/remark-mdx-files.ts
2
- import { visit } from "unist-util-visit";
3
- function parseFileTree(code) {
4
- const lines = code.split(/\r?\n/);
5
- const stack = /* @__PURE__ */ new Map();
6
- for (const line of lines) {
7
- let depth = 0;
8
- let name = line;
9
- let match;
10
- while (match = /(?:├──|│|└──)\s*/.exec(name)) {
11
- name = name.slice(match[0].length);
12
- depth++;
13
- }
14
- if (!name) continue;
15
- const node = name.endsWith("/") ? { type: "folder", name, children: [], depth } : { type: "file", name, depth };
16
- let parent;
17
- for (let i = depth - 1; i >= 0 && !parent; i--) {
18
- parent = stack.get(i);
19
- }
20
- stack.set(depth, node);
21
- if (!parent) continue;
22
- if (parent.type === "file") {
23
- Object.assign(parent, {
24
- type: "folder",
25
- children: []
26
- });
27
- }
28
- parent.children.push(node);
29
- }
30
- return stack.get(0);
31
- }
32
- function defaultToMDX(node, depth = 0) {
33
- if (depth === 0) {
34
- return {
35
- type: "mdxJsxFlowElement",
36
- name: "Files",
37
- attributes: [],
38
- children: [defaultToMDX(node, depth + 1)]
39
- };
40
- }
41
- const attributes = [
42
- { type: "mdxJsxAttribute", name: "name", value: node.name }
43
- ];
44
- if (node.type === "file") {
45
- return {
46
- type: "mdxJsxFlowElement",
47
- attributes,
48
- children: [],
49
- name: "File"
50
- };
51
- }
52
- attributes.push({
53
- type: "mdxJsxAttribute",
54
- name: "defaultOpen",
55
- value: null
56
- });
57
- return {
58
- type: "mdxJsxFlowElement",
59
- attributes,
60
- name: "Folder",
61
- children: node.children.map((item) => defaultToMDX(item, depth + 1))
62
- };
63
- }
64
- function remarkMdxFiles(options = {}) {
65
- const { lang = "files", toMdx = defaultToMDX } = options;
66
- return (tree) => {
67
- visit(tree, "code", (node) => {
68
- if (node.lang !== lang || !node.value) return;
69
- const fileTree = parseFileTree(node.value);
70
- if (!fileTree) return;
71
- Object.assign(node, toMdx(fileTree));
72
- });
73
- };
74
- }
75
-
76
- export {
77
- remarkMdxFiles
78
- };
@@ -1,74 +0,0 @@
1
- // src/mdx-plugins/remark-directive-admonition.ts
2
- import { visit } from "unist-util-visit";
3
- function remarkDirectiveAdmonition({
4
- tags: {
5
- CalloutContainer = "CalloutContainer",
6
- CalloutTitle = "CalloutTitle",
7
- CalloutDescription = "CalloutDescription"
8
- } = {},
9
- types = {
10
- note: "info",
11
- tip: "info",
12
- info: "info",
13
- warn: "warning",
14
- warning: "warning",
15
- danger: "error",
16
- success: "success"
17
- }
18
- } = {}) {
19
- return (tree) => {
20
- visit(tree, "containerDirective", (node) => {
21
- if (!(node.name in types)) return;
22
- const attributes = [
23
- {
24
- type: "mdxJsxAttribute",
25
- name: "type",
26
- value: types[node.name]
27
- }
28
- ];
29
- for (const [k, v] of Object.entries(node.attributes ?? {})) {
30
- attributes.push({
31
- type: "mdxJsxAttribute",
32
- name: k,
33
- value: v
34
- });
35
- }
36
- const titleNodes = [];
37
- const descriptionNodes = [];
38
- for (const item of node.children) {
39
- if (item.type === "paragraph" && item.data?.directiveLabel) {
40
- titleNodes.push(...item.children);
41
- } else {
42
- descriptionNodes.push(item);
43
- }
44
- }
45
- const children = [];
46
- if (titleNodes.length > 0) {
47
- children.push({
48
- type: "mdxJsxFlowElement",
49
- name: CalloutTitle,
50
- attributes: [],
51
- children: titleNodes
52
- });
53
- }
54
- if (descriptionNodes.length > 0) {
55
- children.push({
56
- type: "mdxJsxFlowElement",
57
- name: CalloutDescription,
58
- attributes: [],
59
- children: descriptionNodes
60
- });
61
- }
62
- Object.assign(node, {
63
- type: "mdxJsxFlowElement",
64
- attributes,
65
- name: CalloutContainer,
66
- children
67
- });
68
- });
69
- };
70
- }
71
-
72
- export {
73
- remarkDirectiveAdmonition
74
- };