fumadocs-core 16.7.13 → 16.7.15

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 (137) hide show
  1. package/dist/{advanced-Bv_qi9IC.js → advanced-BCAHgGV0.js} +1 -1
  2. package/dist/{algolia-DphIPKrc.d.ts → algolia-ZyQLVdey.d.ts} +1 -1
  3. package/dist/breadcrumb.d.ts +1 -1
  4. package/dist/{build-doc-DKBeOVIN.js → build-doc-DBVRblOC.js} +1 -1
  5. package/dist/{client-D3PZ2z2N.d.ts → client-BRJhJ58c.d.ts} +3 -3
  6. package/dist/content/mdx/preset-bundler.d.ts +7 -7
  7. package/dist/content/mdx/preset-bundler.js +1 -1
  8. package/dist/content/mdx/preset-runtime.d.ts +7 -7
  9. package/dist/content/mdx/preset-runtime.js +1 -1
  10. package/dist/content/toc.d.ts +1 -1
  11. package/dist/highlight/client.js +1 -1
  12. package/dist/highlight/index.js +1 -1
  13. package/dist/highlight/shiki/full.d.ts +1 -1
  14. package/dist/highlight/shiki/index.d.ts +1 -1
  15. package/dist/highlight/shiki/index.js +1 -1
  16. package/dist/highlight/shiki/react.d.ts +2 -2
  17. package/dist/i18n/index.d.ts +1 -1
  18. package/dist/i18n/middleware.d.ts +1 -1
  19. package/dist/i18n/middleware.js +1 -1
  20. package/dist/{index-CDOu1Gxx2.d.ts → index-B-4lKkNh2.d.ts} +1 -1
  21. package/dist/{index-C4kyQCbj.d.ts → index-B518t-3i.d.ts} +1 -1
  22. package/dist/{index-Bm0msojm.d.ts → index-DxyTmDjY.d.ts} +1 -1
  23. package/dist/{index-9M3g3SDy.d.ts → index-gTnj-v3t.d.ts} +3 -3
  24. package/dist/is-equal-DiHmw70P.js +8 -0
  25. package/dist/mdx-plugins/codeblock-utils.d.ts +1 -1
  26. package/dist/mdx-plugins/index.d.ts +17 -17
  27. package/dist/mdx-plugins/index.js +2 -2
  28. package/dist/mdx-plugins/rehype-code.core.d.ts +1 -1
  29. package/dist/mdx-plugins/rehype-code.core.js +1 -1
  30. package/dist/mdx-plugins/rehype-code.d.ts +2 -2
  31. package/dist/mdx-plugins/rehype-code.js +1 -1
  32. package/dist/mdx-plugins/rehype-toc.d.ts +1 -1
  33. package/dist/mdx-plugins/rehype-toc.js +1 -1
  34. package/dist/mdx-plugins/remark-admonition.d.ts +1 -1
  35. package/dist/mdx-plugins/remark-admonition.js +1 -1
  36. package/dist/mdx-plugins/remark-code-tab.d.ts +1 -1
  37. package/dist/mdx-plugins/remark-code-tab.js +19 -25
  38. package/dist/mdx-plugins/remark-directive-admonition.d.ts +1 -1
  39. package/dist/mdx-plugins/remark-feedback-block.d.ts +1 -1
  40. package/dist/mdx-plugins/remark-feedback-block.js +1 -1
  41. package/dist/mdx-plugins/remark-gfm.d.ts +1 -1
  42. package/dist/mdx-plugins/remark-heading.d.ts +1 -1
  43. package/dist/mdx-plugins/remark-heading.js +1 -1
  44. package/dist/mdx-plugins/remark-image.d.ts +1 -1
  45. package/dist/mdx-plugins/remark-image.js +44 -61
  46. package/dist/mdx-plugins/remark-llms.d.ts +1 -1
  47. package/dist/mdx-plugins/remark-llms.js +4 -3
  48. package/dist/mdx-plugins/remark-llms.runtime.d.ts +1 -1
  49. package/dist/mdx-plugins/remark-mdx-files.d.ts +1 -1
  50. package/dist/mdx-plugins/remark-mdx-mermaid.d.ts +1 -1
  51. package/dist/mdx-plugins/remark-mdx-mermaid.js +3 -3
  52. package/dist/mdx-plugins/remark-npm.d.ts +1 -1
  53. package/dist/mdx-plugins/remark-npm.js +1 -1
  54. package/dist/mdx-plugins/remark-steps.d.ts +1 -1
  55. package/dist/mdx-plugins/remark-steps.js +1 -1
  56. package/dist/mdx-plugins/remark-structure.d.ts +1 -1
  57. package/dist/mdx-plugins/remark-structure.js +1 -1
  58. package/dist/mdx-plugins/stringifier.d.ts +1 -1
  59. package/dist/negotiation/index.js +1 -1
  60. package/dist/page-tree/index.d.ts +2 -2
  61. package/dist/{rehype-code-BceXtwzN.d.ts → rehype-code-DJKXLHtp.d.ts} +1 -1
  62. package/dist/rehype-code.core-Cg1anr4H.d.ts +124 -0
  63. package/dist/{rehype-code.core-B9asBGBz.js → rehype-code.core-Ckq2nRUU.js} +106 -14
  64. package/dist/remark-code-tab-BC5W5GqG.d.ts +31 -0
  65. package/dist/{remark-heading-C3ZesmHL.d.ts → remark-heading-DJvYcq64.d.ts} +1 -1
  66. package/dist/{remark-llms-4bK9f_wN.d.ts → remark-llms-Dwjerpo2.d.ts} +1 -1
  67. package/dist/{remark-npm-DIGXA7E3.js → remark-npm-BWvHn4O3.js} +21 -10
  68. package/dist/{remark-structure-DLKk-p9t.d.ts → remark-structure-BxbC5Buc.d.ts} +1 -1
  69. package/dist/search/algolia.d.ts +1 -1
  70. package/dist/search/client/algolia.d.ts +1 -1
  71. package/dist/search/client/fetch.d.ts +1 -1
  72. package/dist/search/client/flexsearch-static.d.ts +1 -1
  73. package/dist/search/client/flexsearch-static.js +1 -1
  74. package/dist/search/client/mixedbread.d.ts +1 -1
  75. package/dist/search/client/mixedbread.js +1 -1
  76. package/dist/search/client/orama-cloud-legacy.d.ts +1 -1
  77. package/dist/search/client/orama-cloud-legacy.js +1 -1
  78. package/dist/search/client/orama-cloud.d.ts +1 -1
  79. package/dist/search/client/orama-cloud.js +1 -1
  80. package/dist/search/client/orama-static.d.ts +1 -1
  81. package/dist/search/client/orama-static.js +1 -1
  82. package/dist/search/client.d.ts +1 -1
  83. package/dist/search/flexsearch.d.ts +4 -4
  84. package/dist/search/flexsearch.js +3 -3
  85. package/dist/search/index.d.ts +1 -1
  86. package/dist/search/mixedbread.d.ts +2 -2
  87. package/dist/search/mixedbread.js +2 -2
  88. package/dist/search/orama-cloud-legacy.d.ts +1 -1
  89. package/dist/search/orama-cloud.d.ts +1 -1
  90. package/dist/search/server.d.ts +1 -1
  91. package/dist/search/server.js +3 -3
  92. package/dist/{server-D74cMtck.d.ts → server-DSoALz54.d.ts} +5 -5
  93. package/dist/source/client/index.d.ts +1 -1
  94. package/dist/source/index.d.ts +1 -1
  95. package/dist/source/index.js +2 -2
  96. package/dist/source/plugins/lucide-icons.d.ts +1 -1
  97. package/dist/source/plugins/lucide-icons.js +1 -1
  98. package/dist/source/plugins/slugs.d.ts +1 -1
  99. package/dist/source/plugins/slugs.js +1 -1
  100. package/dist/source/plugins/status-badges.d.ts +2 -2
  101. package/dist/{toc-DXlLlbv_.d.ts → toc-CZK90oS5.d.ts} +10 -1
  102. package/dist/toc.d.ts +2 -2
  103. package/dist/toc.js +117 -73
  104. package/dist/types-RCtxugu0.d.ts +4 -0
  105. package/dist/utils/use-on-change.js +2 -5
  106. package/dist/{utils-C73VXFR0.js → utils-pSG8hSr9.js} +6 -2
  107. package/dist/{utils-CLsGsTYQ.js → utils-tAukrbtB.js} +4 -4
  108. package/package.json +2 -3
  109. package/dist/rehype-code.core-DfJelVqH.d.ts +0 -52
  110. package/dist/remark-code-tab-Cl4XxpJ9.d.ts +0 -31
  111. package/dist/types-D8S_yMgI.d.ts +0 -5
  112. /package/dist/{codeblock-utils-BMoNeXUb.d.ts → codeblock-utils-D1ODmcHy.d.ts} +0 -0
  113. /package/dist/{definitions-DH0vdUJV.d.ts → definitions-57FFofI9.d.ts} +0 -0
  114. /package/dist/{dist-BvsXWCqT.js → dist-BvM8AIGy.js} +0 -0
  115. /package/dist/{endpoint-BWgZs3LL.js → endpoint-CAUHRXte.js} +0 -0
  116. /package/dist/{fromFile-rjAsJGw3.js → fromFile-Fn_3e7Ng.js} +0 -0
  117. /package/dist/{icon-DXrdIp2K.js → icon-CboA1P8m.js} +0 -0
  118. /package/dist/{index-B_5tvyCk.d.ts → index-CRLkAaM0.d.ts} +0 -0
  119. /package/dist/{index-WhA-NTMB.d.ts → index-GHkAEvmO.d.ts} +0 -0
  120. /package/dist/{negotiation-CMIpYwJJ.js → negotiation-BdxTpPs1.js} +0 -0
  121. /package/dist/{path-ClKaiDuq.js → path-v4s3P8pA.js} +0 -0
  122. /package/dist/{rehype-toc-Dk5ozAin.d.ts → rehype-toc-wIDEJODt.d.ts} +0 -0
  123. /package/dist/{remark-admonition-D6mMI676.d.ts → remark-admonition-CfMnMJY5.d.ts} +0 -0
  124. /package/dist/{remark-directive-admonition-BJwUZuIt.d.ts → remark-directive-admonition-CUXTwdDg.d.ts} +0 -0
  125. /package/dist/{remark-feedback-block-PeBl_Fvl.d.ts → remark-feedback-block-Bd_7j2CA.d.ts} +0 -0
  126. /package/dist/{remark-gfm-IilhXQUz.d.ts → remark-gfm-D9aa2ppr.d.ts} +0 -0
  127. /package/dist/{remark-image-Co-rKW87.d.ts → remark-image-CSTFtaeg.d.ts} +0 -0
  128. /package/dist/{remark-mdx-files-Ba1Yf3sk.d.ts → remark-mdx-files-Cv1mLv9_.d.ts} +0 -0
  129. /package/dist/{remark-mdx-mermaid-DPDDbIZJ.d.ts → remark-mdx-mermaid-DKj2NHxp.d.ts} +0 -0
  130. /package/dist/{remark-npm-B7OPb7Ze.d.ts → remark-npm-BQkE8_Hf.d.ts} +0 -0
  131. /package/dist/{remark-steps-PxfBg8ws.d.ts → remark-steps-BmZAJIGA.d.ts} +0 -0
  132. /package/dist/{remove-markdown-CQ--9YPQ.js → remove-markdown-D2ifi9PZ.js} +0 -0
  133. /package/dist/{remove-undefined-DLE4y6II.js → remove-undefined-CTqT55E9.js} +0 -0
  134. /package/dist/{stringifier-D6T4zhkn.d.ts → stringifier-B2PmymrT.d.ts} +0 -0
  135. /package/dist/{util-CZD_oO6N.d.ts → util-BvKVaD5t.d.ts} +0 -0
  136. /package/dist/{util-D3lJGMcv.js → util-DEs3M9dw.js} +0 -0
  137. /package/dist/{utils-CEyx3kFf.js → utils-CkDkYuX8.js} +0 -0
@@ -17,17 +17,7 @@ function remarkImage({ placeholder = "none", external = true, useImport = true,
17
17
  return async (tree, file) => {
18
18
  const importsToInject = [];
19
19
  const promises = [];
20
- async function onImage(src, node) {
21
- const attributes = [{
22
- type: "mdxJsxAttribute",
23
- name: "alt",
24
- value: node.alt ?? "image"
25
- }];
26
- if (node.title) attributes.push({
27
- type: "mdxJsxAttribute",
28
- name: "title",
29
- value: node.title
30
- });
20
+ async function updateImage(src, node) {
31
21
  if (src.type === "file" && useImport) {
32
22
  const variableName = `__img${importsToInject.length}`;
33
23
  const hasBlur = placeholder === "blur" && VALID_BLUR_EXT.some((ext) => src.file.endsWith(ext));
@@ -36,31 +26,39 @@ function remarkImage({ placeholder = "none", external = true, useImport = true,
36
26
  variableName,
37
27
  importPath: getImportPath(src.file, file.dirname)
38
28
  });
39
- attributes.push({
40
- type: "mdxJsxAttribute",
41
- name: "src",
42
- value: {
43
- type: "mdxJsxAttributeValueExpression",
44
- value: variableName,
45
- data: { estree: {
46
- body: [{
47
- type: "ExpressionStatement",
48
- expression: {
49
- type: "Identifier",
50
- name: variableName
51
- }
52
- }],
53
- type: "Program",
54
- sourceType: "script"
55
- } }
56
- }
57
- });
58
29
  const out = {
59
30
  children: [],
60
31
  type: "mdxJsxFlowElement",
61
32
  name: "img",
62
- attributes
33
+ attributes: [{
34
+ type: "mdxJsxAttribute",
35
+ name: "alt",
36
+ value: node.alt ?? "image"
37
+ }, {
38
+ type: "mdxJsxAttribute",
39
+ name: "src",
40
+ value: {
41
+ type: "mdxJsxAttributeValueExpression",
42
+ value: variableName,
43
+ data: { estree: {
44
+ body: [{
45
+ type: "ExpressionStatement",
46
+ expression: {
47
+ type: "Identifier",
48
+ name: variableName
49
+ }
50
+ }],
51
+ type: "Program",
52
+ sourceType: "script"
53
+ } }
54
+ }
55
+ }]
63
56
  };
57
+ if (node.title) out.attributes.push({
58
+ type: "mdxJsxAttribute",
59
+ name: "title",
60
+ value: node.title
61
+ });
64
62
  if (hasBlur) out.attributes.push({
65
63
  type: "mdxJsxAttribute",
66
64
  name: "placeholder",
@@ -72,41 +70,26 @@ function remarkImage({ placeholder = "none", external = true, useImport = true,
72
70
  throw new Error(`[Remark Image] Failed obtain image size for ${node.url} (public directory configured as ${publicDir})`, { cause: e });
73
71
  });
74
72
  if (!size) return;
75
- attributes.push({
76
- type: "mdxJsxAttribute",
77
- name: "src",
78
- value: src.type === "url" ? src.url.toString() : node.url
79
- }, {
80
- type: "mdxJsxAttribute",
81
- name: "width",
82
- value: size.width.toString()
83
- }, {
84
- type: "mdxJsxAttribute",
85
- name: "height",
86
- value: size.height.toString()
87
- });
88
- return {
89
- type: "mdxJsxFlowElement",
90
- name: "img",
91
- attributes,
92
- children: []
93
- };
73
+ node.data ??= {};
74
+ node.data.hProperties ??= {};
75
+ node.data.hProperties.src = src.type === "url" ? src.url.href : node.url;
76
+ node.data.hProperties.width = size.width.toString();
77
+ node.data.hProperties.height = size.height.toString();
94
78
  }
95
- visit(tree, "image", (node) => {
79
+ visit(tree, "image", (node, idx, parent) => {
80
+ if (typeof idx !== "number" || !parent) return;
96
81
  const src = parseSrc(decodeURI(node.url), publicDir, file.dirname);
97
82
  if (!src) return;
98
- const task = onImage(src, node).catch((e) => {
83
+ const task = updateImage(src, node).catch((e) => {
99
84
  if (onError === "ignore" || node.url.endsWith(".svg")) return;
100
- if (onError === "hide") return {
101
- type: "mdxJsxFlowElement",
102
- name: null,
103
- attributes: [],
104
- children: []
105
- };
85
+ if (onError === "hide") {
86
+ parent.children.splice(idx, 1);
87
+ return;
88
+ }
106
89
  if (onError === "error") throw e;
107
90
  onError(e);
108
91
  }).then((res) => {
109
- if (res) Object.assign(node, res);
92
+ if (res) parent.children[idx] = res;
110
93
  });
111
94
  promises.push(task);
112
95
  });
@@ -175,14 +158,14 @@ function parseSrc(src, publicDir, dir) {
175
158
  }
176
159
  async function getImageSize(src, onExternal) {
177
160
  if (src.type === "file") {
178
- const { imageSizeFromFile } = await import("../fromFile-rjAsJGw3.js");
161
+ const { imageSizeFromFile } = await import("../fromFile-Fn_3e7Ng.js");
179
162
  return imageSizeFromFile(src.file);
180
163
  }
181
164
  if (onExternal === false) return;
182
165
  const { timeout } = typeof onExternal === "object" ? onExternal : {};
183
166
  const res = await fetch(src.url, { signal: typeof timeout === "number" ? AbortSignal.timeout(timeout) : void 0 });
184
167
  if (!res.ok) throw new Error(`[Remark Image] Failed to fetch ${src.url} (${res.status}): ${await res.text()}`);
185
- const { imageSize } = await import("../dist-BvsXWCqT.js");
168
+ const { imageSize } = await import("../dist-BvM8AIGy.js");
186
169
  return imageSize(new Uint8Array(await res.arrayBuffer()));
187
170
  }
188
171
  //#endregion
@@ -1,2 +1,2 @@
1
- import { n as placeholder, r as remarkLLMs, t as LLMsOptions } from "../remark-llms-4bK9f_wN.js";
1
+ import { n as placeholder, r as remarkLLMs, t as LLMsOptions } from "../remark-llms-Dwjerpo2.js";
2
2
  export { LLMsOptions, placeholder, remarkLLMs };
@@ -1,5 +1,6 @@
1
- import { r as toMdxExport } from "../utils-C73VXFR0.js";
1
+ import { i as toMdxExport } from "../utils-pSG8hSr9.js";
2
2
  import { defaultStringifier } from "./stringifier.js";
3
+ import { defaultHandlers } from "mdast-util-to-markdown";
3
4
  //#region src/mdx-plugins/remark-llms.ts
4
5
  /**
5
6
  * generate `llms.txt` for markdown.
@@ -23,8 +24,8 @@ function remarkLLMs({ as = "_markdown", headingIds = true, _data = false, mdxAsP
23
24
  handlers: {
24
25
  heading(node, _p, state, info) {
25
26
  const id = node.data?.hProperties?.id;
26
- const content = state.containerPhrasing(node, info);
27
- return headingIds && id ? `${content} [#${id}]` : content;
27
+ const defaultValue = defaultHandlers.heading(node, _p, state, info);
28
+ return headingIds && id ? `${defaultValue} [#${id}]` : defaultValue;
28
29
  },
29
30
  ...rest.handlers
30
31
  }
@@ -1,4 +1,4 @@
1
- import { t as Awaitable } from "../types-D8S_yMgI.js";
1
+ import { t as Awaitable } from "../types-RCtxugu0.js";
2
2
 
3
3
  //#region src/mdx-plugins/remark-llms.runtime.d.ts
4
4
  interface PlaceholderData {
@@ -1,2 +1,2 @@
1
- import { a as remarkMdxFiles, i as ToMdxOptions, n as FolderNode, r as RemarkMdxFilesOptions, t as FileNode } from "../remark-mdx-files-Ba1Yf3sk.js";
1
+ import { a as remarkMdxFiles, i as ToMdxOptions, n as FolderNode, r as RemarkMdxFilesOptions, t as FileNode } from "../remark-mdx-files-Cv1mLv9_.js";
2
2
  export { FileNode, FolderNode, RemarkMdxFilesOptions, ToMdxOptions, remarkMdxFiles };
@@ -1,2 +1,2 @@
1
- import { n as remarkMdxMermaid, t as RemarkMdxMermaidOptions } from "../remark-mdx-mermaid-DPDDbIZJ.js";
1
+ import { n as remarkMdxMermaid, t as RemarkMdxMermaidOptions } from "../remark-mdx-mermaid-DKj2NHxp.js";
2
2
  export { RemarkMdxMermaidOptions, remarkMdxMermaid };
@@ -18,9 +18,9 @@ function toMDX(code) {
18
18
  function remarkMdxMermaid(options = {}) {
19
19
  const { lang = "mermaid" } = options;
20
20
  return (tree) => {
21
- visit(tree, "code", (node) => {
22
- if (node.lang !== lang || !node.value) return;
23
- Object.assign(node, toMDX(node.value));
21
+ visit(tree, "code", (node, idx, parent) => {
22
+ if (node.lang !== lang || !node.value || typeof idx !== "number" || !parent) return;
23
+ parent.children[idx] = toMDX(node.value);
24
24
  });
25
25
  };
26
26
  }
@@ -1,2 +1,2 @@
1
- import { n as remarkNpm, t as RemarkNpmOptions } from "../remark-npm-B7OPb7Ze.js";
1
+ import { n as remarkNpm, t as RemarkNpmOptions } from "../remark-npm-BQkE8_Hf.js";
2
2
  export { RemarkNpmOptions, remarkNpm };
@@ -1,2 +1,2 @@
1
- import { t as remarkNpm } from "../remark-npm-DIGXA7E3.js";
1
+ import { t as remarkNpm } from "../remark-npm-BWvHn4O3.js";
2
2
  export { remarkNpm };
@@ -1,2 +1,2 @@
1
- import { n as remarkSteps, t as RemarkStepsOptions } from "../remark-steps-PxfBg8ws.js";
1
+ import { n as remarkSteps, t as RemarkStepsOptions } from "../remark-steps-BmZAJIGA.js";
2
2
  export { RemarkStepsOptions, remarkSteps };
@@ -1,4 +1,4 @@
1
- import { n as handleTag } from "../utils-C73VXFR0.js";
1
+ import { r as handleTag } from "../utils-pSG8hSr9.js";
2
2
  import { visit } from "unist-util-visit";
3
3
  //#region src/mdx-plugins/remark-steps.ts
4
4
  const StepRegex = /^(\d+)\.\s(.+)$/;
@@ -1,2 +1,2 @@
1
- import { a as defaultStringifier, c as structure, i as StructuredData, n as StringifyOptions, o as remarkStructure, r as StructureOptions, s as remarkStructureDefaultOptions, t as Stringifier } from "../remark-structure-DLKk-p9t.js";
1
+ import { a as defaultStringifier, c as structure, i as StructuredData, n as StringifyOptions, o as remarkStructure, r as StructureOptions, s as remarkStructureDefaultOptions, t as Stringifier } from "../remark-structure-BxbC5Buc.js";
2
2
  export { Stringifier, StringifyOptions, StructureOptions, StructuredData, defaultStringifier, remarkStructure, remarkStructureDefaultOptions, structure };
@@ -1,4 +1,4 @@
1
- import { r as toMdxExport } from "../utils-C73VXFR0.js";
1
+ import { i as toMdxExport } from "../utils-pSG8hSr9.js";
2
2
  import { remarkHeading } from "./remark-heading.js";
3
3
  import { defaultStringifier as defaultStringifier$1 } from "./stringifier.js";
4
4
  import { remark } from "remark";
@@ -1,2 +1,2 @@
1
- import { n as StringifyOptions, r as defaultStringifier, t as Stringifier } from "../stringifier-D6T4zhkn.js";
1
+ import { n as StringifyOptions, r as defaultStringifier, t as Stringifier } from "../stringifier-B2PmymrT.js";
2
2
  export { Stringifier, StringifyOptions, defaultStringifier };
@@ -1,2 +1,2 @@
1
- import { n as isMarkdownPreferred, r as rewritePath, t as getNegotiator } from "../negotiation-CMIpYwJJ.js";
1
+ import { n as isMarkdownPreferred, r as rewritePath, t as getNegotiator } from "../negotiation-BdxTpPs1.js";
2
2
  export { getNegotiator, isMarkdownPreferred, rewritePath };
@@ -1,3 +1,3 @@
1
- import { a as Separator, i as Root, n as Item, r as Node, t as Folder } from "../definitions-DH0vdUJV.js";
2
- import { a as flattenTree, c as visit, i as findSiblings, n as findParent, o as getPageTreePeers, r as findPath, s as getPageTreeRoots, t as findNeighbour } from "../index-C4kyQCbj.js";
1
+ import { a as Separator, i as Root, n as Item, r as Node, t as Folder } from "../definitions-57FFofI9.js";
2
+ import { a as flattenTree, c as visit, i as findSiblings, n as findParent, o as getPageTreePeers, r as findPath, s as getPageTreeRoots, t as findNeighbour } from "../index-B518t-3i.js";
3
3
  export { Folder, Item, Node, Root, Separator, findNeighbour, findParent, findPath, findSiblings, flattenTree, getPageTreePeers, getPageTreeRoots, visit };
@@ -1,4 +1,4 @@
1
- import { t as RehypeCodeOptionsCommon } from "./rehype-code.core-DfJelVqH.js";
1
+ import { t as RehypeCodeOptionsCommon } from "./rehype-code.core-Cg1anr4H.js";
2
2
  import * as _$unified from "unified";
3
3
  import * as _$hast from "hast";
4
4
 
@@ -0,0 +1,124 @@
1
+ import { t as Awaitable } from "./types-RCtxugu0.js";
2
+ import { n as ShikiFactory } from "./index-DxyTmDjY.js";
3
+ import { Processor, Transformer } from "unified";
4
+ import { Element, Root } from "hast";
5
+ import { BuiltinLanguage, BuiltinTheme, CodeOptionsMeta, CodeOptionsThemes, CodeToHastOptionsCommon, HighlighterCore, LanguageInput, ShikiTransformer, TransformerOptions } from "shiki";
6
+
7
+ //#region src/mdx-plugins/rehype-code/parsers.d.ts
8
+ type InlineCodeParser = 'tailing-curly-colon';
9
+ //#endregion
10
+ //#region src/mdx-plugins/rehype-code/shiki.d.ts
11
+ interface MapLike<K = unknown, V = unknown> {
12
+ get: (key: K) => V | undefined;
13
+ set: (key: K, value: V) => this;
14
+ }
15
+ interface RehypeShikiExtraOptions {
16
+ /**
17
+ * Add `language-*` class to code element
18
+ *
19
+ * @default false
20
+ */
21
+ addLanguageClass?: boolean;
22
+ /**
23
+ * The default language to use when is not specified
24
+ */
25
+ defaultLanguage?: string;
26
+ /**
27
+ * The fallback language to use when specified language is not loaded, or not included in the bundle
28
+ */
29
+ fallbackLanguage?: string;
30
+ /**
31
+ * Load languages and themes on-demand.
32
+ *
33
+ * @default true
34
+ */
35
+ lazy?: boolean;
36
+ /**
37
+ * `mdast-util-to-hast` adds a newline to the end of code blocks
38
+ *
39
+ * This option strips that newline from the code block
40
+ *
41
+ * @default true
42
+ * @see https://github.com/syntax-tree/mdast-util-to-hast/blob/f511a93817b131fb73419bf7d24d73a5b8b0f0c2/lib/handlers/code.js#L22
43
+ */
44
+ stripEndNewline?: boolean;
45
+ /**
46
+ * Custom meta string parser
47
+ * Return an object to merge with `meta`
48
+ */
49
+ parseMetaString?: (metaString: string, node: Element, tree: Root) => Record<string, unknown> | undefined | null;
50
+ /**
51
+ * Filter meta string before processing
52
+ */
53
+ filterMetaString?: (metaString: string) => string;
54
+ /**
55
+ * Highlight inline code blocks
56
+ *
57
+ * - `false`: disable inline code block highlighting
58
+ * - `tailing-curly-colon`: highlight with `\`code{:lang}\``
59
+ *
60
+ * @see https://shiki.style/packages/rehype#inline-code
61
+ * @default false
62
+ */
63
+ inline?: InlineCodeParser | false;
64
+ /**
65
+ * Custom map to cache transformed codeToHast result
66
+ *
67
+ * @default undefined
68
+ */
69
+ cache?: MapLike<string, Root>;
70
+ /**
71
+ * Chance to handle the error
72
+ * If not provided, the error will be thrown
73
+ */
74
+ onError?: (error: unknown) => void;
75
+ }
76
+ type RehypeShikiCoreOptions = CodeOptionsThemes<BuiltinTheme> & TransformerOptions & CodeOptionsMeta & RehypeShikiExtraOptions & Omit<CodeToHastOptionsCommon, 'lang'>;
77
+ //#endregion
78
+ //#region src/mdx-plugins/transformer-icon.d.ts
79
+ type CodeBlockIcon = {
80
+ viewBox: string;
81
+ fill: string;
82
+ d: string;
83
+ } | string;
84
+ interface IconOptions {
85
+ shortcuts?: Record<string, string>;
86
+ extend?: Record<string, CodeBlockIcon>;
87
+ }
88
+ /**
89
+ * Inject icons to `icon` property (as HTML)
90
+ */
91
+ declare function transformerIcon(options?: IconOptions): ShikiTransformer;
92
+ //#endregion
93
+ //#region src/mdx-plugins/rehype-code.core.d.ts
94
+ declare function rehypeCodeDefaultOptions(): RehypeCodeOptionsCommon;
95
+ type RehypeCodeOptionsCommon = RehypeShikiCoreOptions & {
96
+ /**
97
+ * Language names to include.
98
+ *
99
+ * @default Object.keys(bundledLanguages)
100
+ */
101
+ langs?: Array<LanguageInput | BuiltinLanguage>;
102
+ /**
103
+ * Alias of languages
104
+ * @example { 'my-lang': 'javascript' }
105
+ */
106
+ langAlias?: Record<string, string>;
107
+ /**
108
+ * Add icon to code blocks
109
+ */
110
+ icon?: IconOptions | false;
111
+ /**
112
+ * Wrap code blocks in `<Tab>` component when "tab" meta string presents
113
+ *
114
+ * @defaultValue true
115
+ */
116
+ tab?: boolean;
117
+ };
118
+ declare function createRehypeCode<Options extends Partial<RehypeCodeOptionsCommon> = Partial<RehypeCodeOptionsCommon>>(highlighterFactory: ShikiFactory | ((options?: Options) => Awaitable<{
119
+ highlighter: HighlighterCore;
120
+ options: RehypeCodeOptionsCommon;
121
+ }>)): (this: Processor, _options?: Options) => Transformer<Root, Root>;
122
+ declare function transformerTab(): ShikiTransformer;
123
+ //#endregion
124
+ export { CodeBlockIcon as a, transformerTab as i, createRehypeCode as n, transformerIcon as o, rehypeCodeDefaultOptions as r, RehypeCodeOptionsCommon as t };
@@ -1,7 +1,110 @@
1
- import { n as defaultThemes, r as getRequiredThemes } from "./utils-CLsGsTYQ.js";
1
+ import { n as flattenNodeHast } from "./utils-pSG8hSr9.js";
2
+ import { n as defaultThemes, r as getRequiredThemes } from "./utils-tAukrbtB.js";
2
3
  import { parseCodeBlockAttributes } from "./mdx-plugins/codeblock-utils.js";
3
- import rehypeShikiFromHighlighter from "@shikijs/rehype/core";
4
+ import { visit } from "unist-util-visit";
5
+ import { isSpecialLang } from "shiki/core";
4
6
  import { transformerNotationDiff, transformerNotationFocus, transformerNotationHighlight, transformerNotationWordHighlight } from "@shikijs/transformers";
7
+ //#region src/mdx-plugins/rehype-code/parsers.ts
8
+ const RE_TAILING_CURLY_COLON = /(.+)\{:([\w-]+)\}$/;
9
+ const InlineCodeParsers = { "tailing-curly-colon": (_tree, node) => {
10
+ const raw = flattenNodeHast(node);
11
+ const match = raw.match(RE_TAILING_CURLY_COLON);
12
+ if (!match) return;
13
+ return {
14
+ type: "inline",
15
+ code: match[1] ?? raw,
16
+ lang: match.at(2)
17
+ };
18
+ } };
19
+ const languagePrefix = "language-";
20
+ const PreParser = (_tree, node) => {
21
+ const head = node.children[0];
22
+ if (!head || head.type !== "element" || head.tagName !== "code" || !head.properties) return;
23
+ const classes = head.properties.className;
24
+ const languageClass = Array.isArray(classes) ? classes.find((d) => typeof d === "string" && d.startsWith(languagePrefix)) : void 0;
25
+ return {
26
+ type: "pre",
27
+ lang: typeof languageClass === "string" ? languageClass.slice(9) : void 0,
28
+ code: flattenNodeHast(head),
29
+ meta: head.data?.meta ?? head.properties.metastring?.toString() ?? ""
30
+ };
31
+ };
32
+ //#endregion
33
+ //#region src/mdx-plugins/rehype-code/shiki.ts
34
+ function rehypeShikiFromHighlighter(highlighter, options) {
35
+ const { addLanguageClass = false, parseMetaString, filterMetaString, cache, defaultLanguage, fallbackLanguage, onError, stripEndNewline = true, inline = false, lazy = false, ...rest } = options;
36
+ function highlight(lang, code, metaString = "", tree, node) {
37
+ if (filterMetaString) metaString = filterMetaString(metaString);
38
+ const cacheKey = `${lang}:${metaString}:${code}`;
39
+ const cachedValue = cache?.get(cacheKey);
40
+ if (cachedValue) return cachedValue;
41
+ const codeOptions = {
42
+ ...rest,
43
+ lang,
44
+ meta: {
45
+ ...rest.meta,
46
+ __raw: metaString,
47
+ ...parseMetaString?.(metaString, node, tree)
48
+ }
49
+ };
50
+ if (addLanguageClass) codeOptions.transformers = [...codeOptions.transformers ?? [], {
51
+ name: "rehype-shiki:code-language-class",
52
+ code(node) {
53
+ this.addClassToHast(node, `language-${lang}`);
54
+ return node;
55
+ }
56
+ }];
57
+ if (stripEndNewline && code.endsWith("\n")) code = code.slice(0, -1);
58
+ try {
59
+ const fragment = highlighter.codeToHast(code, codeOptions);
60
+ cache?.set(cacheKey, fragment);
61
+ return fragment;
62
+ } catch (error) {
63
+ if (onError) onError(error);
64
+ else throw error;
65
+ }
66
+ }
67
+ function isLanguageLoaded(lang) {
68
+ return isSpecialLang(lang) || highlighter.getLoadedLanguages().includes(lang);
69
+ }
70
+ async function onNode(tree, node, parsed) {
71
+ let lang = parsed.lang ?? defaultLanguage;
72
+ if (!lang) return;
73
+ if (!isLanguageLoaded(lang)) {
74
+ if (lazy && lang in highlighter.getBundledLanguages()) await highlighter.loadLanguage(lang);
75
+ else if (fallbackLanguage) {
76
+ lang = fallbackLanguage;
77
+ if (!isLanguageLoaded(fallbackLanguage)) await highlighter.loadLanguage(fallbackLanguage);
78
+ }
79
+ }
80
+ const fragment = highlight(lang, parsed.code, parsed.meta, tree, node);
81
+ if (!fragment) return;
82
+ if (parsed.type === "inline") {
83
+ const head = fragment.children[0];
84
+ if (head.type === "element" && head.tagName === "pre") head.tagName = "span";
85
+ }
86
+ return fragment;
87
+ }
88
+ return async (tree) => {
89
+ const queue = [];
90
+ visit(tree, "element", (node, index, parent) => {
91
+ let parsed;
92
+ if (!parent || index == null) return;
93
+ if (node.tagName === "pre") parsed = PreParser(tree, node);
94
+ else if (node.tagName === "code" && inline) parsed = InlineCodeParsers[inline](tree, node);
95
+ if (!parsed) return "skip";
96
+ queue.push(onNode(tree, node, parsed).then((fragment) => {
97
+ if (fragment) parent.children[index] = fragment;
98
+ }).catch((error) => {
99
+ if (onError) onError(error);
100
+ else throw error;
101
+ }));
102
+ return "skip";
103
+ });
104
+ if (queue.length > 0) await Promise.all(queue);
105
+ };
106
+ }
107
+ //#endregion
5
108
  //#region src/mdx-plugins/transformer-icon.ts
6
109
  const defaultShortcuts = {
7
110
  js: "javascript",
@@ -162,7 +265,7 @@ function rehypeCodeDefaultOptions() {
162
265
  const parsed = parseCodeBlockAttributes(meta, ["title", "tab"]);
163
266
  const data = parsed.attributes;
164
267
  parsed.rest = parseLineNumber(parsed.rest, data);
165
- data.__parsed_raw = parsed.rest;
268
+ data.__raw = parsed.rest;
166
269
  return data;
167
270
  }
168
271
  };
@@ -187,17 +290,6 @@ function createRehypeCode(highlighterFactory) {
187
290
  options = _options ?? {};
188
291
  }
189
292
  const transformers = options.transformers ? [...options.transformers] : [];
190
- transformers.unshift({
191
- name: "rehype-code:pre-process",
192
- preprocess(code, { meta }) {
193
- if (meta && "__parsed_raw" in meta) {
194
- meta.__raw = meta.__parsed_raw;
195
- delete meta.__parsed_raw;
196
- }
197
- if (meta && options.filterMetaString) meta.__raw = options.filterMetaString(meta.__raw ?? "");
198
- return code.replace(/\n$/, "");
199
- }
200
- });
201
293
  if (options.icon !== false) transformers.push(transformerIcon(options.icon));
202
294
  if (options.tab !== false) transformers.push(transformerTab());
203
295
  const langs = options.langs ?? (options.lazy ? [
@@ -0,0 +1,31 @@
1
+ import { Processor, Transformer } from "unified";
2
+ import { Root } from "mdast";
3
+
4
+ //#region src/mdx-plugins/remark-code-tab.d.ts
5
+ type TabType = 'CodeBlockTabs' | 'Tabs';
6
+ interface RemarkCodeTabOptions {
7
+ Tabs?: TabType;
8
+ /**
9
+ * Parse MDX in tab values
10
+ *
11
+ * @defaultValue false
12
+ */
13
+ parseMdx?: boolean;
14
+ }
15
+ declare module 'mdast' {
16
+ interface CodeData {
17
+ /**
18
+ * [Fumadocs: remark-code-tab] the associated tab value
19
+ */
20
+ tab?: string;
21
+ }
22
+ interface Data {
23
+ /**
24
+ * [Fumadocs: remark-code-tab] internal
25
+ */
26
+ _code_tab_visited?: true;
27
+ }
28
+ }
29
+ declare function remarkCodeTab(this: Processor, options?: RemarkCodeTabOptions): Transformer<Root, Root>;
30
+ //#endregion
31
+ export { remarkCodeTab as n, RemarkCodeTabOptions as t };
@@ -1,4 +1,4 @@
1
- import { c as TOCItemType } from "./toc-DXlLlbv_.js";
1
+ import { c as TOCItemType } from "./toc-CZK90oS5.js";
2
2
  import { Transformer } from "unified";
3
3
  import { Heading, Root } from "mdast";
4
4
 
@@ -1,4 +1,4 @@
1
- import { n as StringifyOptions } from "./stringifier-D6T4zhkn.js";
1
+ import { n as StringifyOptions } from "./stringifier-B2PmymrT.js";
2
2
  import { MdxJsxFlowElement, MdxJsxTextElement } from "mdast-util-mdx";
3
3
  import { Info, State } from "mdast-util-to-markdown";
4
4
  import { Processor, Transformer } from "unified";
@@ -530,33 +530,44 @@ function convert(str, to) {
530
530
  }
531
531
  //#endregion
532
532
  //#region src/mdx-plugins/remark-npm.ts
533
- const aliases = ["npm", "package-install"];
533
+ function convertLines(cmd, to) {
534
+ return cmd.split("\n").map((l) => convert(l, to)).join("\n");
535
+ }
534
536
  /**
535
537
  * It generates multiple tabs of codeblocks for different package managers from a npm command codeblock.
536
538
  */
537
539
  function remarkNpm({ persist = false, packageManagers = [
538
540
  {
539
- command: (cmd) => convert(cmd, "npm"),
541
+ command: (cmd) => cmd,
540
542
  name: "npm"
541
543
  },
542
544
  {
543
- command: (cmd) => convert(cmd, "pnpm"),
545
+ command: (cmd) => convertLines(cmd, "pnpm"),
544
546
  name: "pnpm"
545
547
  },
546
548
  {
547
- command: (cmd) => convert(cmd, "yarn"),
549
+ command: (cmd) => convertLines(cmd, "yarn"),
548
550
  name: "yarn"
549
551
  },
550
552
  {
551
- command: (cmd) => convert(cmd, "bun"),
553
+ command: (cmd) => convertLines(cmd, "bun"),
552
554
  name: "bun"
553
555
  }
554
556
  ] } = {}) {
555
557
  return (tree) => {
556
- visit(tree, "code", (node) => {
557
- if (!node.lang || !aliases.includes(node.lang)) return;
558
- let code = node.value;
559
- if (node.lang === "package-install" && !code.startsWith("npm") && !code.startsWith("npx")) code = `npm install ${code}`;
558
+ visit(tree, "code", (node, idx, parent) => {
559
+ if (typeof idx !== "number" || !parent) return;
560
+ let code;
561
+ switch (node.lang) {
562
+ case "package-install":
563
+ code = node.value;
564
+ if (!code.startsWith("npm") && !code.startsWith("npx")) code = `npm install ${code}`;
565
+ break;
566
+ case "npm":
567
+ code = node.value;
568
+ break;
569
+ default: return;
570
+ }
560
571
  const options = {
561
572
  persist,
562
573
  tabs: [],
@@ -584,7 +595,7 @@ function remarkNpm({ persist = false, packageManagers = [
584
595
  }]
585
596
  });
586
597
  }
587
- Object.assign(node, generateCodeBlockTabs(options));
598
+ parent.children[idx] = generateCodeBlockTabs(options);
588
599
  return "skip";
589
600
  });
590
601
  };
@@ -1,4 +1,4 @@
1
- import { n as StringifyOptions$1, t as Stringifier$1 } from "./stringifier-D6T4zhkn.js";
1
+ import { n as StringifyOptions$1, t as Stringifier$1 } from "./stringifier-B2PmymrT.js";
2
2
  import { MdxJsxAttribute, MdxJsxExpressionAttribute, MdxJsxFlowElement, MdxJsxTextElement } from "mdast-util-mdx";
3
3
  import { PluggableList, Processor, Transformer } from "unified";
4
4
  import { Nodes, Root } from "mdast";
@@ -1,2 +1,2 @@
1
- import { a as sync, i as setIndexSettings, n as DocumentRecord, o as updateDocuments, r as SyncOptions, t as BaseIndex } from "../algolia-DphIPKrc.js";
1
+ import { a as sync, i as setIndexSettings, n as DocumentRecord, o as updateDocuments, r as SyncOptions, t as BaseIndex } from "../algolia-ZyQLVdey.js";
2
2
  export { BaseIndex, DocumentRecord, SyncOptions, setIndexSettings, sync, updateDocuments };
@@ -1,2 +1,2 @@
1
- import { m as algoliaClient, p as AlgoliaOptions } from "../../client-D3PZ2z2N.js";
1
+ import { m as algoliaClient, p as AlgoliaOptions } from "../../client-BRJhJ58c.js";
2
2
  export { AlgoliaOptions, algoliaClient };