@vezham/docs-core 1.0.1

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 (201) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +5 -0
  3. package/dist/advanced-Ct13khZr.js +79 -0
  4. package/dist/algolia-C0E5qQhM.d.ts +66 -0
  5. package/dist/breadcrumb.d.ts +46 -0
  6. package/dist/breadcrumb.js +59 -0
  7. package/dist/build-doc-4OvfjVN2.js +85 -0
  8. package/dist/client-kQ39Ub0-.d.ts +247 -0
  9. package/dist/codeblock-utils-CyP8qsYv.d.ts +29 -0
  10. package/dist/content/github.d.ts +41 -0
  11. package/dist/content/github.js +28 -0
  12. package/dist/content/md/frontmatter.d.ts +15 -0
  13. package/dist/content/md/frontmatter.js +24 -0
  14. package/dist/content/md.d.ts +24 -0
  15. package/dist/content/md.js +43 -0
  16. package/dist/content/mdx/preset-bundler.d.ts +29 -0
  17. package/dist/content/mdx/preset-bundler.js +39 -0
  18. package/dist/content/mdx/preset-runtime.d.ts +26 -0
  19. package/dist/content/mdx/preset-runtime.js +36 -0
  20. package/dist/content/toc.d.ts +19 -0
  21. package/dist/content/toc.js +14 -0
  22. package/dist/definitions-CFOhwE1k.d.ts +72 -0
  23. package/dist/dynamic-CTsodhTH.js +905 -0
  24. package/dist/dynamic-link.d.ts +12 -0
  25. package/dist/dynamic-link.js +31 -0
  26. package/dist/endpoint-MyoBU5IC.js +28 -0
  27. package/dist/framework/astro.d.ts +21 -0
  28. package/dist/framework/astro.js +52 -0
  29. package/dist/framework/index.d.ts +40 -0
  30. package/dist/framework/index.js +66 -0
  31. package/dist/framework/next.d.ts +10 -0
  32. package/dist/framework/next.js +19 -0
  33. package/dist/framework/react-router.d.ts +10 -0
  34. package/dist/framework/react-router.js +43 -0
  35. package/dist/framework/tanstack.d.ts +13 -0
  36. package/dist/framework/tanstack.js +54 -0
  37. package/dist/framework/waku.d.ts +10 -0
  38. package/dist/framework/waku.js +46 -0
  39. package/dist/highlight/client.d.ts +11 -0
  40. package/dist/highlight/client.js +15 -0
  41. package/dist/highlight/index.d.ts +31 -0
  42. package/dist/highlight/index.js +30 -0
  43. package/dist/highlight/shiki/full.d.ts +7 -0
  44. package/dist/highlight/shiki/full.js +23 -0
  45. package/dist/highlight/shiki/index.d.ts +2 -0
  46. package/dist/highlight/shiki/index.js +27 -0
  47. package/dist/highlight/shiki/react.d.ts +23 -0
  48. package/dist/highlight/shiki/react.js +50 -0
  49. package/dist/i18n/index.d.ts +2 -0
  50. package/dist/i18n/index.js +63 -0
  51. package/dist/i18n/middleware.d.ts +34 -0
  52. package/dist/i18n/middleware.js +3855 -0
  53. package/dist/icon-BILaoXeg.js +17 -0
  54. package/dist/index-B-0R0VbS.d.ts +18 -0
  55. package/dist/index-BM36H-xw.d.ts +36 -0
  56. package/dist/index-BMEUQz-F.d.ts +21 -0
  57. package/dist/index-DAYtLGbx.d.ts +16 -0
  58. package/dist/index-DIwKCYOz.d.ts +513 -0
  59. package/dist/index-DydiXvgS.d.ts +90 -0
  60. package/dist/index-E8Qh_yQs.d.ts +49 -0
  61. package/dist/is-equal-LdLqRs0o.js +8 -0
  62. package/dist/link.d.ts +17 -0
  63. package/dist/link.js +23 -0
  64. package/dist/mdx-plugins/codeblock-utils.d.ts +2 -0
  65. package/dist/mdx-plugins/codeblock-utils.js +68 -0
  66. package/dist/mdx-plugins/index.d.ts +20 -0
  67. package/dist/mdx-plugins/index.js +18 -0
  68. package/dist/mdx-plugins/rehype-code.core.d.ts +3 -0
  69. package/dist/mdx-plugins/rehype-code.core.js +3 -0
  70. package/dist/mdx-plugins/rehype-code.d.ts +4 -0
  71. package/dist/mdx-plugins/rehype-code.js +24 -0
  72. package/dist/mdx-plugins/rehype-toc.d.ts +2 -0
  73. package/dist/mdx-plugins/rehype-toc.js +139 -0
  74. package/dist/mdx-plugins/remark-admonition.d.ts +2 -0
  75. package/dist/mdx-plugins/remark-admonition.js +71 -0
  76. package/dist/mdx-plugins/remark-block-id.d.ts +37 -0
  77. package/dist/mdx-plugins/remark-block-id.js +41 -0
  78. package/dist/mdx-plugins/remark-code-tab.d.ts +2 -0
  79. package/dist/mdx-plugins/remark-code-tab.js +190 -0
  80. package/dist/mdx-plugins/remark-directive-admonition.d.ts +2 -0
  81. package/dist/mdx-plugins/remark-directive-admonition.js +57 -0
  82. package/dist/mdx-plugins/remark-feedback-block.d.ts +2 -0
  83. package/dist/mdx-plugins/remark-feedback-block.js +54 -0
  84. package/dist/mdx-plugins/remark-gfm.d.ts +2 -0
  85. package/dist/mdx-plugins/remark-gfm.js +2 -0
  86. package/dist/mdx-plugins/remark-heading.d.ts +2 -0
  87. package/dist/mdx-plugins/remark-heading.js +46 -0
  88. package/dist/mdx-plugins/remark-image.d.ts +2 -0
  89. package/dist/mdx-plugins/remark-image.js +167 -0
  90. package/dist/mdx-plugins/remark-llms.d.ts +2 -0
  91. package/dist/mdx-plugins/remark-llms.js +338 -0
  92. package/dist/mdx-plugins/remark-llms.runtime.d.ts +10 -0
  93. package/dist/mdx-plugins/remark-llms.runtime.js +24 -0
  94. package/dist/mdx-plugins/remark-mdx-files.d.ts +2 -0
  95. package/dist/mdx-plugins/remark-mdx-files.js +182 -0
  96. package/dist/mdx-plugins/remark-mdx-mermaid.d.ts +2 -0
  97. package/dist/mdx-plugins/remark-mdx-mermaid.js +28 -0
  98. package/dist/mdx-plugins/remark-npm.d.ts +2 -0
  99. package/dist/mdx-plugins/remark-npm.js +76 -0
  100. package/dist/mdx-plugins/remark-steps.d.ts +2 -0
  101. package/dist/mdx-plugins/remark-steps.js +93 -0
  102. package/dist/mdx-plugins/remark-structure.d.ts +2 -0
  103. package/dist/mdx-plugins/remark-structure.js +118 -0
  104. package/dist/mdx-plugins/stringifier.d.ts +2 -0
  105. package/dist/mdx-plugins/stringifier.js +91 -0
  106. package/dist/mdx-plugins/transformer-icon.d.ts +2 -0
  107. package/dist/mdx-plugins/transformer-icon.js +145 -0
  108. package/dist/negotiation/index.d.ts +17 -0
  109. package/dist/negotiation/index.js +378 -0
  110. package/dist/page-tree/index.d.ts +3 -0
  111. package/dist/page-tree/index.js +2 -0
  112. package/dist/path-1H5VzYiT.js +75 -0
  113. package/dist/rehype-code-D-RFJb9W.d.ts +14 -0
  114. package/dist/rehype-code.core-BUwNuchP.js +548 -0
  115. package/dist/rehype-code.core-BjH1uHWj.d.ts +115 -0
  116. package/dist/rehype-toc-K51AGb5U.d.ts +43 -0
  117. package/dist/remark-admonition-BwTcmI_S.d.ts +20 -0
  118. package/dist/remark-code-tab-DE_4bdnu.d.ts +34 -0
  119. package/dist/remark-directive-admonition-BLiJ5l43.d.ts +27 -0
  120. package/dist/remark-feedback-block-BxtINXN-.d.ts +45 -0
  121. package/dist/remark-gfm-DpVfAX1x.d.ts +2 -0
  122. package/dist/remark-heading-DEIzTkU5.d.ts +33 -0
  123. package/dist/remark-image-BI2S9LOb.d.ts +57 -0
  124. package/dist/remark-llms-bD3WvU2V.d.ts +73 -0
  125. package/dist/remark-mdx-files-Buvxc-sa.d.ts +54 -0
  126. package/dist/remark-mdx-mermaid-C1bCHHc6.d.ts +15 -0
  127. package/dist/remark-npm-BbpvkJaT.d.ts +31 -0
  128. package/dist/remark-steps-DqVEo0iq.d.ts +23 -0
  129. package/dist/remark-structure-CnHwvNZr.d.ts +87 -0
  130. package/dist/remove-markdown-DfKNMl9w.js +40 -0
  131. package/dist/remove-undefined-CzMSKybq.js +24 -0
  132. package/dist/rolldown-runtime-DC62tzP2.js +33 -0
  133. package/dist/search/algolia.d.ts +2 -0
  134. package/dist/search/algolia.js +75 -0
  135. package/dist/search/client/algolia.d.ts +2 -0
  136. package/dist/search/client/algolia.js +53 -0
  137. package/dist/search/client/fetch.d.ts +2 -0
  138. package/dist/search/client/fetch.js +28 -0
  139. package/dist/search/client/flexsearch-static.d.ts +2 -0
  140. package/dist/search/client/flexsearch-static.js +42 -0
  141. package/dist/search/client/mixedbread.d.ts +2 -0
  142. package/dist/search/client/mixedbread.js +65 -0
  143. package/dist/search/client/orama-cloud-legacy.d.ts +2 -0
  144. package/dist/search/client/orama-cloud-legacy.js +84 -0
  145. package/dist/search/client/orama-cloud.d.ts +2 -0
  146. package/dist/search/client/orama-cloud.js +86 -0
  147. package/dist/search/client/orama-static.d.ts +2 -0
  148. package/dist/search/client/orama-static.js +75 -0
  149. package/dist/search/client.d.ts +2 -0
  150. package/dist/search/client.js +97 -0
  151. package/dist/search/flexsearch.d.ts +56 -0
  152. package/dist/search/flexsearch.js +128 -0
  153. package/dist/search/index.d.ts +2 -0
  154. package/dist/search/index.js +74 -0
  155. package/dist/search/mixedbread.d.ts +49 -0
  156. package/dist/search/mixedbread.js +77 -0
  157. package/dist/search/orama-cloud-legacy.d.ts +75 -0
  158. package/dist/search/orama-cloud-legacy.js +48 -0
  159. package/dist/search/orama-cloud.d.ts +75 -0
  160. package/dist/search/orama-cloud.js +50 -0
  161. package/dist/search/server.d.ts +2 -0
  162. package/dist/search/server.js +237 -0
  163. package/dist/server-CCqACwlF.d.ts +165 -0
  164. package/dist/server.browser.d.ts +13 -0
  165. package/dist/server.browser.js +22 -0
  166. package/dist/server.d.ts +42 -0
  167. package/dist/server.js +398 -0
  168. package/dist/source/client/index.d.ts +2 -0
  169. package/dist/source/client/index.js +37 -0
  170. package/dist/source/dynamic.d.ts +2 -0
  171. package/dist/source/dynamic.js +2 -0
  172. package/dist/source/index.d.ts +2 -0
  173. package/dist/source/index.js +5 -0
  174. package/dist/source/llms.d.ts +2 -0
  175. package/dist/source/llms.js +74 -0
  176. package/dist/source/plugins/lucide-icons.d.ts +11 -0
  177. package/dist/source/plugins/lucide-icons.js +21 -0
  178. package/dist/source/plugins/slugs.d.ts +2 -0
  179. package/dist/source/plugins/slugs.js +75 -0
  180. package/dist/source/plugins/status-badges.d.ts +50 -0
  181. package/dist/source/plugins/status-badges.js +52 -0
  182. package/dist/source/schema.d.ts +30 -0
  183. package/dist/source/schema.js +28 -0
  184. package/dist/stringifier-B_QUcUyo.d.ts +63 -0
  185. package/dist/toc-CtW5lwA1.d.ts +64 -0
  186. package/dist/toc.d.ts +2 -0
  187. package/dist/toc.js +245 -0
  188. package/dist/transformer-icon-DlrneIS3.d.ts +17 -0
  189. package/dist/types-D89QoQR-.d.ts +4 -0
  190. package/dist/url-BVHvi3_K.js +29 -0
  191. package/dist/util-BDsqOxh3.d.ts +6 -0
  192. package/dist/util-DjBr9b3w.js +8 -0
  193. package/dist/utils/use-media-query.d.ts +4 -0
  194. package/dist/utils/use-media-query.js +20 -0
  195. package/dist/utils/use-on-change.d.ts +9 -0
  196. package/dist/utils/use-on-change.js +17 -0
  197. package/dist/utils-Bvy3V-fv.js +59 -0
  198. package/dist/utils-Cgs-6U-z.js +39 -0
  199. package/dist/utils-DEVq3cEC.js +151 -0
  200. package/dist/utils-Yx0IL9eW.js +48 -0
  201. package/package.json +251 -0
package/dist/server.js ADDED
@@ -0,0 +1,398 @@
1
+ import { isValidElement } from "react";
2
+ import { AsyncLocalStorage } from "node:async_hooks";
3
+ //#region src/server.ts
4
+ const ROOT_STATE = {
5
+ pre: false,
6
+ inline: false,
7
+ heading: false
8
+ };
9
+ const CLIENT_REFERENCE = Symbol.for("react.client.reference");
10
+ const REACT_LAZY = Symbol.for("react.lazy");
11
+ const REACT_MEMO = Symbol.for("react.memo");
12
+ const REACT_FORWARD_REF = Symbol.for("react.forward_ref");
13
+ const NOT_OPTED_IN = Symbol();
14
+ const store = new AsyncLocalStorage({ name: "fumadocs:markdown" });
15
+ /**
16
+ * Whether the current component is being rendered into Markdown, calling it opts the component in.
17
+ */
18
+ function asMarkdown() {
19
+ const frame = store.getStore();
20
+ if (!frame) return false;
21
+ frame.optedIn = true;
22
+ return true;
23
+ }
24
+ /**
25
+ * Render a React tree into a Markdown document.
26
+ */
27
+ async function renderToMarkdown(node) {
28
+ return collapse(await walk(node, ROOT_STATE)).trim();
29
+ }
30
+ /**
31
+ * Render a page element into Markdown, `undefined` when its component doesn't call `asMarkdown()`.
32
+ */
33
+ async function renderRoute(element) {
34
+ if (typeof element.type !== "function") return;
35
+ const result = await optIn(element.type, element.props);
36
+ if (result !== NOT_OPTED_IN) return renderToMarkdown(result);
37
+ }
38
+ /**
39
+ * Resolve the MDX components of a generated Markdown component (`remarkLLMs` with `output: 'function'`):
40
+ * a missing component becomes a stub that `renderToMarkdown` serializes as JSX syntax.
41
+ */
42
+ function jsxComponents(components) {
43
+ return new Proxy(components ?? {}, { get(target, key) {
44
+ const value = target[key];
45
+ if (value !== void 0 || typeof key !== "string") return value;
46
+ const stub = () => null;
47
+ stub.displayName = key;
48
+ return stub;
49
+ } });
50
+ }
51
+ /**
52
+ * Tagged template for Markdown, interpolated values can be strings, React nodes, promises, or arrays of them.
53
+ *
54
+ * Use `md\`${children}\`` inside a component to stringify its children before manipulating them, the result is not
55
+ * trimmed so block-level output keeps its trailing blank line.
56
+ *
57
+ * Formatters (Prettier, oxfmt) format `md` templates as Markdown and may move the content onto its own indented lines,
58
+ * so a leading empty line, the indentation before the closing backtick and the common indentation are removed.
59
+ */
60
+ const md = Object.assign(async function md(strings, ...values) {
61
+ const parts = dedent(strings);
62
+ const resolved = await Promise.all(values.map(render));
63
+ let out = parts[0];
64
+ for (let i = 0; i < resolved.length; i++) out += resolved[i] + parts[i + 1];
65
+ return out;
66
+ }, {
67
+ linePrefix(prefix) {
68
+ return async (strings, ...values) => {
69
+ const text = (await md(strings, ...values)).trim();
70
+ return text.length === 0 ? "" : `\n${prefixLines(text, prefix)}\n\n`;
71
+ };
72
+ },
73
+ indent(size = 2) {
74
+ return md.linePrefix(" ".repeat(size));
75
+ }
76
+ });
77
+ /** stands in for interpolations while dedenting, so their lines count as content */
78
+ const PLACEHOLDER = "\0";
79
+ function dedent(strings) {
80
+ const lines = strings.join(PLACEHOLDER).split("\n");
81
+ if (lines.length === 1) return [...strings];
82
+ if (lines[0].trim().length === 0) lines.shift();
83
+ const last = lines[lines.length - 1];
84
+ if (lines.length > 1 && last.length > 0 && last.trim().length === 0) lines.pop();
85
+ let indent = Infinity;
86
+ for (const line of lines) if (line.trim().length > 0) indent = Math.min(indent, /^[ \t]*/.exec(line)[0].length);
87
+ let out = "";
88
+ for (let i = 0; i < lines.length; i++) {
89
+ if (i > 0) out += "\n";
90
+ out += indent === Infinity ? lines[i] : lines[i].slice(Math.min(indent, lines[i].length));
91
+ }
92
+ return out.split(PLACEHOLDER);
93
+ }
94
+ async function render(node) {
95
+ return collapse(await walk(node, ROOT_STATE));
96
+ }
97
+ /**
98
+ * Prefix every line, empty lines receive the trimmed prefix (e.g. `>` instead of `> `).
99
+ */
100
+ function prefixLines(text, prefix) {
101
+ const empty = prefix.trimEnd();
102
+ return text.replace(/^.*$/gm, (line) => line.length === 0 ? empty : prefix + line);
103
+ }
104
+ function collapse(text) {
105
+ return text.replace(/\n{3,}/g, "\n\n");
106
+ }
107
+ /**
108
+ * Render a component in its own frame, `NOT_OPTED_IN` when it never calls `asMarkdown()`.
109
+ *
110
+ * A component that throws before opting in (e.g. it needs a context that only exists on its own route) is treated the
111
+ * same, it has no Markdown form.
112
+ */
113
+ async function optIn(component, props) {
114
+ const frame = { optedIn: false };
115
+ try {
116
+ const result = await store.run(frame, () => component(props));
117
+ return frame.optedIn ? result : NOT_OPTED_IN;
118
+ } catch (e) {
119
+ if (frame.optedIn) throw e;
120
+ return NOT_OPTED_IN;
121
+ }
122
+ }
123
+ async function walk(node, state) {
124
+ if (node === null || node === void 0 || typeof node === "boolean") return "";
125
+ if (typeof node === "string") return node;
126
+ if (typeof node === "number" || typeof node === "bigint") return String(node);
127
+ if (isThenable(node)) return walk(await node, state);
128
+ if (isValidElement(node)) return element(node.type, node.props, state);
129
+ if (typeof node === "object" && Symbol.iterator in node) return (await Promise.all(Array.from(node, (child) => walk(child, state)))).join("");
130
+ return "";
131
+ }
132
+ async function element(type, props, state) {
133
+ if (typeof type === "string") return host(type, props, state);
134
+ if (isClientReference(type)) return jsx(clientReferenceName(type.$$id), props, state);
135
+ if (typeof type === "function") return component(type, props, state);
136
+ if (typeof type === "symbol") return walk(props.children, state);
137
+ if (typeof type === "object" && type !== null) {
138
+ const special = type;
139
+ switch (special.$$typeof) {
140
+ case REACT_LAZY: return element(await resolveLazy(special), props, state);
141
+ case REACT_MEMO: return element(special.type, props, state);
142
+ case REACT_FORWARD_REF: return component(special.render, props, state);
143
+ }
144
+ }
145
+ return "";
146
+ }
147
+ async function component(fn, props, state) {
148
+ const result = await optIn(fn, props);
149
+ if (result === NOT_OPTED_IN) return jsx(componentName(fn), props, state);
150
+ return walk(result, state);
151
+ }
152
+ function componentName(fn) {
153
+ const { displayName, name } = fn;
154
+ return typeof displayName === "string" && displayName ? displayName : name || "Component";
155
+ }
156
+ async function resolveLazy(type) {
157
+ for (;;) try {
158
+ return type._init(type._payload);
159
+ } catch (e) {
160
+ if (!isThenable(e)) throw e;
161
+ await e;
162
+ }
163
+ }
164
+ /**
165
+ * The export name of a client reference, or a PascalCase name from its file for default exports.
166
+ */
167
+ function clientReferenceName(id) {
168
+ if (typeof id !== "string") return "Component";
169
+ try {
170
+ id = decodeURIComponent(id);
171
+ } catch {}
172
+ const hash = id.lastIndexOf("#");
173
+ const exportName = hash === -1 ? "" : id.slice(hash + 1);
174
+ if (exportName && exportName !== "default") return exportName;
175
+ const file = (hash === -1 ? id : id.slice(0, hash)).split(/[\\/]/).pop();
176
+ let name = "";
177
+ for (const part of file.replace(/\.[^.]+$/, "").split(/[^\w$]+/)) if (part) name += part[0].toUpperCase() + part.slice(1);
178
+ return name || "Component";
179
+ }
180
+ const MAX_ATTRIBUTE_LENGTH = 1024;
181
+ const PRESENTATIONAL_PROPS = /* @__PURE__ */ new Set([
182
+ "children",
183
+ "className",
184
+ "style",
185
+ "tabIndex"
186
+ ]);
187
+ /**
188
+ * Serialize a component as JSX syntax, for components without a Markdown form.
189
+ */
190
+ async function jsx(name, props, state) {
191
+ let open = `<${name}`;
192
+ for (const key in props) {
193
+ if (PRESENTATIONAL_PROPS.has(key)) continue;
194
+ const attr = attribute(key, props[key]);
195
+ if (attr !== void 0) open += ` ${attr}`;
196
+ }
197
+ const children = await walk(props.children, state);
198
+ if (state.inline) return children.trim().length === 0 ? `${open} />` : `${open}>${children}</${name}>`;
199
+ const body = children.trim();
200
+ if (body.length === 0) return `\n${open} />\n\n`;
201
+ return `\n${open}>\n${body}\n</${name}>\n\n`;
202
+ }
203
+ function attribute(key, value) {
204
+ if (value === true) return key;
205
+ if (value === false || value === null || value === void 0) return;
206
+ if (typeof value === "string") return value.length > MAX_ATTRIBUTE_LENGTH ? void 0 : `${key}=${JSON.stringify(value)}`;
207
+ if (typeof value === "number" || typeof value === "bigint") return `${key}={${value}}`;
208
+ if (typeof value === "function" || typeof value === "symbol" || isValidElement(value)) return;
209
+ try {
210
+ const json = JSON.stringify(value, (_, v) => isValidElement(v) ? void 0 : v);
211
+ if (json === void 0 || json.length > MAX_ATTRIBUTE_LENGTH) return;
212
+ return `${key}={${json}}`;
213
+ } catch {
214
+ return;
215
+ }
216
+ }
217
+ const INLINE_TAGS = /* @__PURE__ */ new Set([
218
+ "a",
219
+ "abbr",
220
+ "b",
221
+ "cite",
222
+ "code",
223
+ "del",
224
+ "em",
225
+ "i",
226
+ "kbd",
227
+ "label",
228
+ "mark",
229
+ "q",
230
+ "s",
231
+ "small",
232
+ "span",
233
+ "strong",
234
+ "sub",
235
+ "sup",
236
+ "time",
237
+ "u"
238
+ ]);
239
+ const DROP_TAGS = /* @__PURE__ */ new Set([
240
+ "head",
241
+ "link",
242
+ "meta",
243
+ "noscript",
244
+ "script",
245
+ "style",
246
+ "svg",
247
+ "template",
248
+ "title"
249
+ ]);
250
+ async function host(tag, props, state) {
251
+ if (DROP_TAGS.has(tag)) return "";
252
+ if (state.pre) {
253
+ if (tag === "br") return "\n";
254
+ return walk(props.children, state);
255
+ }
256
+ const children = (override) => walk(props.children, {
257
+ ...state,
258
+ ...override
259
+ });
260
+ switch (tag) {
261
+ case "p": {
262
+ const c = (await children({ inline: true })).trim();
263
+ return state.inline ? `${c} ` : `\n${c}\n\n`;
264
+ }
265
+ case "h1":
266
+ case "h2":
267
+ case "h3":
268
+ case "h4":
269
+ case "h5":
270
+ case "h6": {
271
+ const c = (await children({
272
+ inline: true,
273
+ heading: true
274
+ })).trim().replace(/\s*\n\s*/g, " ");
275
+ return `\n${"#".repeat(Number(tag[1]))} ${c}\n\n`;
276
+ }
277
+ case "a": {
278
+ const href = typeof props.href === "string" ? props.href : void 0;
279
+ const c = await children({ inline: true });
280
+ if (!href || state.heading && href.startsWith("#")) return c;
281
+ const text = c.trim();
282
+ return text.length === 0 ? `<${href}>` : `[${text}](${href})`;
283
+ }
284
+ case "strong":
285
+ case "b": return wrap(await children({ inline: true }), "**");
286
+ case "em":
287
+ case "i": return wrap(await children({ inline: true }), "*");
288
+ case "del":
289
+ case "s": return wrap(await children({ inline: true }), "~~");
290
+ case "code":
291
+ case "kbd": {
292
+ const c = await children({ inline: true });
293
+ if (c.includes("\n") && !state.inline) return codeFence(detectLang(props), c);
294
+ return inlineCode(c);
295
+ }
296
+ case "pre": return codeFence(detectLang(props), await children({ pre: true }));
297
+ case "blockquote": return `\n${prefixLines(collapse(await children({ inline: false })).trim(), "> ")}\n\n`;
298
+ case "ul":
299
+ case "ol": {
300
+ const ordered = tag === "ol";
301
+ let index = typeof props.start === "number" ? props.start : 1;
302
+ return `\n${(await Promise.all(flatten(props.children).map((child) => {
303
+ if (!isValidElement(child)) return typeof child === "string" ? child.trim() : "";
304
+ return walk(child, {
305
+ ...state,
306
+ inline: false,
307
+ list: {
308
+ ordered,
309
+ index: index++
310
+ }
311
+ });
312
+ }))).join("")}\n`;
313
+ }
314
+ case "li": {
315
+ const marker = state.list?.ordered ? `${state.list.index}. ` : "- ";
316
+ return `${marker}${prefixLines((await children({ inline: false })).trim().replace(/\n{2,}(?=(?:[-*+] |\d+\. ))/g, "\n"), " ".repeat(marker.length)).slice(marker.length)}\n`;
317
+ }
318
+ case "img": {
319
+ if (typeof props.src !== "string") return "";
320
+ const alt = typeof props.alt === "string" ? props.alt : "";
321
+ return state.inline ? `![${alt}](${props.src})` : `\n![${alt}](${props.src})\n\n`;
322
+ }
323
+ case "hr": return "\n---\n\n";
324
+ case "br": return "\n";
325
+ case "table": {
326
+ const rows = (await children({ inline: false })).replace(/\n\s*\n/g, "\n").trim();
327
+ if (rows.length === 0) return "";
328
+ const end = rows.indexOf("\n");
329
+ const first = end === -1 ? rows : rows.slice(0, end);
330
+ return `\n${first}\n${separatorRow(first)}${end === -1 ? "" : rows.slice(end)}\n\n`;
331
+ }
332
+ case "tr": return `|${await children({ inline: false })}\n`;
333
+ case "th":
334
+ case "td": return ` ${(await children({ inline: true })).trim().replace(/\s*\n\s*/g, " ").replaceAll("|", "\\|")} |`;
335
+ }
336
+ if (INLINE_TAGS.has(tag)) return children({ inline: true });
337
+ const c = (await children({ inline: false })).trim();
338
+ return c.length === 0 ? "" : `\n${c}\n\n`;
339
+ }
340
+ function separatorRow(row) {
341
+ const cells = Math.max(1, (row.match(/(?<!\\)\|/g)?.length ?? 2) - 1);
342
+ return `|${" --- |".repeat(cells)}`;
343
+ }
344
+ function wrap(text, marker) {
345
+ const [, lead, core, trail] = /^(\s*)([\s\S]*?)(\s*)$/.exec(text);
346
+ return core ? `${lead}${marker}${core}${marker}${trail}` : text;
347
+ }
348
+ function codeFence(lang, code) {
349
+ const text = code.replace(/\n$/, "");
350
+ const fence = "`".repeat(Math.max(3, longestRun(text, "`") + 1));
351
+ return `\n${fence}${lang}\n${text}\n${fence}\n\n`;
352
+ }
353
+ function inlineCode(text) {
354
+ const fence = "`".repeat(longestRun(text, "`") + 1);
355
+ const pad = text.startsWith("`") || text.endsWith("`") ? " " : "";
356
+ return `${fence}${pad}${text}${pad}${fence}`;
357
+ }
358
+ function longestRun(text, char) {
359
+ let max = 0;
360
+ let current = 0;
361
+ for (const c of text) {
362
+ current = c === char ? current + 1 : 0;
363
+ if (current > max) max = current;
364
+ }
365
+ return max;
366
+ }
367
+ /** from `data-lang` or a `language-*` class name, of the element or its `<code>` child */
368
+ function detectLang(props) {
369
+ const lang = props["data-lang"] ?? props.lang;
370
+ if (typeof lang === "string" && lang.length > 0) return lang;
371
+ const fromClass = (className) => typeof className === "string" ? /(?:^|\s)(?:language|lang)-([\w+#.-]+)/.exec(className)?.[1] : void 0;
372
+ let out = fromClass(props.className);
373
+ for (const child of flatten(props.children)) {
374
+ if (out) break;
375
+ if (isValidElement(child) && child.type === "code") out = fromClass(child.props.className);
376
+ }
377
+ return out ?? "";
378
+ }
379
+ /**
380
+ * Direct children, flattened through arrays and fragments.
381
+ */
382
+ function flatten(node, out = []) {
383
+ if (node === null || node === void 0 || typeof node === "boolean") return out;
384
+ if (isValidElement(node)) {
385
+ if (typeof node.type === "symbol") flatten(node.props.children, out);
386
+ else out.push(node);
387
+ } else if (typeof node === "object" && Symbol.iterator in node) for (const child of node) flatten(child, out);
388
+ else out.push(node);
389
+ return out;
390
+ }
391
+ function isClientReference(type) {
392
+ return (typeof type === "function" || typeof type === "object" && type !== null) && type.$$typeof === CLIENT_REFERENCE;
393
+ }
394
+ function isThenable(value) {
395
+ return typeof value === "object" && value !== null && typeof value.then === "function";
396
+ }
397
+ //#endregion
398
+ export { asMarkdown, jsxComponents, md, renderRoute, renderToMarkdown };
@@ -0,0 +1,2 @@
1
+ import { i as useFumadocsLoader, n as SerializedPageTree, r as deserializePageTree, t as Serialized } from "../../index-B-0R0VbS.js";
2
+ export { Serialized, SerializedPageTree, deserializePageTree, useFumadocsLoader };
@@ -0,0 +1,37 @@
1
+ import { l as visit } from "../../utils-DEVq3cEC.js";
2
+ import { useMemo } from "react";
3
+ import { jsx } from "react/jsx-runtime";
4
+ //#region src/source/client/index.tsx
5
+ function deserializePageTree(serialized) {
6
+ const root = serialized.data;
7
+ visit(root, (item) => {
8
+ if ("icon" in item && typeof item.icon === "string") item.icon = /* @__PURE__ */ jsx("span", { dangerouslySetInnerHTML: { __html: item.icon } });
9
+ if (typeof item.name === "string") item.name = /* @__PURE__ */ jsx("span", {
10
+ className: "fd-page-tree-item-name",
11
+ dangerouslySetInnerHTML: { __html: item.name }
12
+ });
13
+ });
14
+ return root;
15
+ }
16
+ /**
17
+ * Deserialize loader data that is serialized by the server-side Fumadocs `loader()`, supported:
18
+ * - Page Tree
19
+ *
20
+ * other unrelated properties are kept in the output.
21
+ */
22
+ function useFumadocsLoader(serialized) {
23
+ return useMemo(() => {
24
+ const out = {};
25
+ for (const k in serialized) {
26
+ const v = serialized[k];
27
+ if (isSerializedPageTree(v)) out[k] = deserializePageTree(v);
28
+ else out[k] = v;
29
+ }
30
+ return out;
31
+ }, [serialized]);
32
+ }
33
+ function isSerializedPageTree(v) {
34
+ return typeof v === "object" && v !== null && "$fumadocs_loader" in v && v.$fumadocs_loader === "page-tree";
35
+ }
36
+ //#endregion
37
+ export { deserializePageTree, useFumadocsLoader };
@@ -0,0 +1,2 @@
1
+ import { h as dynamicLoader, m as DynamicLoaderConfig, p as DynamicLoader } from "../index-DIwKCYOz.js";
2
+ export { DynamicLoader, DynamicLoaderConfig, dynamicLoader };
@@ -0,0 +1,2 @@
1
+ import { t as dynamicLoader } from "../dynamic-CTsodhTH.js";
2
+ export { dynamicLoader };
@@ -0,0 +1,2 @@
1
+ import { B as ContentStoragePageFile, C as Meta, D as loader, E as createGetUrl, F as PageTreeBuilderContext, I as PageTreeOptions, L as PageTreeTransformer, O as types_d_exports, P as PageTreeBuilder, R as ContentStorage, S as LoaderPluginOption, T as ResolvedLoaderConfig, V as FileSystem, _ as InferPageType, a as MetaData, b as LoaderOutput, c as SourceUnion, d as multiple, f as update, g as InferMetaType, h as dynamicLoader, i as DynamicSource, j as getSlugs, l as StaticSource, m as DynamicLoaderConfig, n as llms, o as PageData, p as DynamicLoader, r as path_d_exports, s as Source, t as LLMsConfig, u as VirtualFile, v as LoaderConfig, w as Page, x as LoaderPlugin, y as LoaderOptions, z as ContentStorageMetaFile } from "../index-DIwKCYOz.js";
2
+ export { type ContentStorage, type ContentStorageMetaFile, type ContentStoragePageFile, type DynamicLoader, type DynamicLoaderConfig, type DynamicSource, FileSystem, InferMetaType, InferPageType, LLMsConfig, LoaderConfig, LoaderOptions, LoaderOutput, LoaderPlugin, LoaderPluginOption, Meta, type MetaData, Page, type PageData, type PageTreeBuilder, type PageTreeBuilderContext, type PageTreeOptions, type PageTreeTransformer, path_d_exports as PathUtils, ResolvedLoaderConfig, type Source, type SourceUnion, type StaticSource, type VirtualFile, type types_d_exports as _Internal, createGetUrl, dynamicLoader, getSlugs, llms, loader, multiple, update };
@@ -0,0 +1,5 @@
1
+ import { o as path_exports } from "../path-1H5VzYiT.js";
2
+ import { a as update, i as multiple, n as createGetUrl, o as FileSystem, r as loader, t as dynamicLoader } from "../dynamic-CTsodhTH.js";
3
+ import { getSlugs } from "./plugins/slugs.js";
4
+ import { llms } from "./llms.js";
5
+ export { FileSystem, path_exports as PathUtils, createGetUrl, dynamicLoader, getSlugs, llms, loader, multiple, update };
@@ -0,0 +1,2 @@
1
+ import { n as llms, t as LLMsConfig } from "../index-DIwKCYOz.js";
2
+ export { LLMsConfig, llms };
@@ -0,0 +1,74 @@
1
+ //#region src/source/llms.ts
2
+ function llms(loader, config = {}) {
3
+ const { TAB = " ", renderName = (node, ctx) => {
4
+ if (node.type === "page") {
5
+ const page = loader.getNodePage(node, ctx.lang);
6
+ if (page?.data.title) return page.data.title;
7
+ } else if (node.type !== "separator") {
8
+ const meta = loader.getNodeMeta(node, ctx.lang);
9
+ if (meta?.data.title) return meta.data.title;
10
+ }
11
+ return typeof node.name === "string" ? node.name : "";
12
+ }, renderDescription = (node, ctx) => {
13
+ if (node.type === "page") {
14
+ const page = loader.getNodePage(node, ctx.lang);
15
+ if (page?.data.description) return page.data.description;
16
+ } else {
17
+ const meta = loader.getNodeMeta(node, ctx.lang);
18
+ if (meta?.data.description) return meta.data.description;
19
+ }
20
+ return typeof node.description === "string" ? node.description : "";
21
+ } } = config;
22
+ function formatListItem(name, description, indent) {
23
+ const prefix = TAB.repeat(indent);
24
+ description = description.trim();
25
+ if (description.length > 0) return `${prefix}- ${name}: ${description}`;
26
+ return `${prefix}- ${name}`;
27
+ }
28
+ function formatNode(node, indent, ctx) {
29
+ switch (node.type) {
30
+ case "page": return formatListItem(formatMarkdownLink(renderName(node, ctx), node.url), renderDescription(node, ctx), indent);
31
+ case "folder": {
32
+ const out = [];
33
+ out.push(formatListItem(renderName(node, ctx), renderDescription(node, ctx), indent));
34
+ if (node.index) out.push(formatNode(node.index, indent + 1, ctx));
35
+ for (const child of node.children) out.push(formatNode(child, indent + 1, ctx));
36
+ return out.join("\n");
37
+ }
38
+ case "separator": return "\n" + formatListItem(`**${renderName(node, ctx) || "Separator"}**`, "", indent);
39
+ }
40
+ }
41
+ function index(lang) {
42
+ if (loader._i18n && lang === void 0) {
43
+ const { languages } = loader._i18n;
44
+ return languages.map(index).join("\n\n");
45
+ }
46
+ const pageTree = loader.getPageTree(lang);
47
+ const out = [];
48
+ const ctx = { lang };
49
+ out.push(`# ${renderName(pageTree, ctx)}`, "");
50
+ const description = renderDescription(pageTree, ctx);
51
+ if (description) out.push(`> ${description}`, "");
52
+ for (const child of pageTree.children) out.push(formatNode(child, 0, ctx));
53
+ return out.join("\n");
54
+ }
55
+ return {
56
+ /**
57
+ * generate `llms.txt` content in Markdown format.
58
+ *
59
+ * use `indexNode(node)` instead for more control (e.g. add extra sections to output).
60
+ */
61
+ index,
62
+ /**
63
+ * generate `llms.txt` content for a single page tree node.
64
+ */
65
+ indexNode(node, lang) {
66
+ return formatNode(node, 0, { lang });
67
+ }
68
+ };
69
+ }
70
+ function formatMarkdownLink(title, url) {
71
+ return `[${title.replace(/([[\]])/g, "\\$1")}](${url.replace(/([()])/g, "\\$1")})`;
72
+ }
73
+ //#endregion
74
+ export { llms };
@@ -0,0 +1,11 @@
1
+ import { x as LoaderPlugin } from "../../index-DIwKCYOz.js";
2
+ import { icons } from "lucide-react";
3
+ //#region src/source/plugins/lucide-icons.d.ts
4
+ /**
5
+ * Convert icon names into Lucide Icons, requires `lucide-react` to be installed.
6
+ */
7
+ declare function lucideIconsPlugin(options?: {
8
+ defaultIcon?: keyof typeof icons;
9
+ }): LoaderPlugin;
10
+ //#endregion
11
+ export { lucideIconsPlugin };
@@ -0,0 +1,21 @@
1
+ import { t as iconPlugin } from "../../icon-BILaoXeg.js";
2
+ import { createElement } from "react";
3
+ import { icons } from "lucide-react";
4
+ //#region src/source/plugins/lucide-icons.ts
5
+ /**
6
+ * Convert icon names into Lucide Icons, requires `lucide-react` to be installed.
7
+ */
8
+ function lucideIconsPlugin(options = {}) {
9
+ const { defaultIcon } = options;
10
+ return iconPlugin((icon = defaultIcon) => {
11
+ if (icon === void 0) return;
12
+ const Icon = icons[icon];
13
+ if (!Icon) {
14
+ console.warn(`[lucide-icons-plugin] Unknown icon detected: ${icon}.`);
15
+ return;
16
+ }
17
+ return createElement(Icon);
18
+ });
19
+ }
20
+ //#endregion
21
+ export { lucideIconsPlugin };
@@ -0,0 +1,2 @@
1
+ import { A as SlugsPluginOptions, M as slugsFromData, N as slugsPlugin, j as getSlugs, k as SlugFn } from "../../index-DIwKCYOz.js";
2
+ export { SlugFn, SlugsPluginOptions, getSlugs, slugsFromData, slugsPlugin };
@@ -0,0 +1,75 @@
1
+ import { n as dirname, r as extname, t as basename } from "../../path-1H5VzYiT.js";
2
+ //#region src/source/plugins/slugs.ts
3
+ /**
4
+ * Generate slugs for pages if missing.
5
+ */
6
+ function slugsPlugin(optsOrFn = {}) {
7
+ const prepended = /* @__PURE__ */ new WeakSet();
8
+ const { baseSlugs = [], slugs: slugFn } = typeof optsOrFn === "function" ? { slugs: optsOrFn } : optsOrFn;
9
+ function generateSlugs(path, file) {
10
+ const out = slugFn?.(file, () => getSlugs(path)) ?? getSlugs(path);
11
+ prepended.add(file);
12
+ return baseSlugs.length > 0 ? [...baseSlugs, ...out] : out;
13
+ }
14
+ return {
15
+ name: "fumadocs:slugs",
16
+ transformStorage({ storage }) {
17
+ const indexFiles = [];
18
+ const taken = /* @__PURE__ */ new Set();
19
+ for (const path of storage.getFiles()) {
20
+ const file = storage.read(path);
21
+ if (!file || file.format !== "page") continue;
22
+ if (file.slugs) {
23
+ if (baseSlugs.length > 0 && !prepended.has(file)) {
24
+ file.slugs = [...baseSlugs, ...file.slugs];
25
+ prepended.add(file);
26
+ }
27
+ continue;
28
+ }
29
+ if (basename(path, extname(path)) === "index") {
30
+ indexFiles.push(path);
31
+ continue;
32
+ }
33
+ file.slugs = generateSlugs(path, file);
34
+ const key = file.slugs.join("/");
35
+ if (taken.has(key)) throw new Error(`Duplicated slugs: ${key}`);
36
+ taken.add(key);
37
+ }
38
+ for (const path of indexFiles) {
39
+ const file = storage.read(path);
40
+ if (file?.format !== "page") continue;
41
+ file.slugs = generateSlugs(path, file);
42
+ if (taken.has(file.slugs.join("/"))) file.slugs = [...file.slugs, "index"];
43
+ const key = file.slugs.join("/");
44
+ if (taken.has(key)) throw new Error(`Duplicated slugs: ${key}`);
45
+ taken.add(key);
46
+ }
47
+ }
48
+ };
49
+ }
50
+ /**
51
+ * Generate slugs from file data (e.g. frontmatter).
52
+ *
53
+ * @param key - the property name in file data to generate slugs, default to `slug`.
54
+ */
55
+ function slugsFromData(key = "slug") {
56
+ return (file) => {
57
+ const k = key;
58
+ if (k in file.data && typeof file.data[k] === "string") return file.data[k].split("/").filter((v) => v.length > 0);
59
+ };
60
+ }
61
+ const GroupRegex = /^\(.+\)$/;
62
+ /**
63
+ * Convert file path into slugs, also encode non-ASCII characters, so they can work in pathname
64
+ */
65
+ function getSlugs(file) {
66
+ const dir = dirname(file);
67
+ const name = basename(file, extname(file));
68
+ const slugs = [];
69
+ for (const seg of dir.split("/")) if (seg.length > 0 && !GroupRegex.test(seg)) slugs.push(encodeURI(seg));
70
+ if (GroupRegex.test(name)) throw new Error(`Cannot use folder group in file names: ${file}`);
71
+ if (name !== "index") slugs.push(encodeURI(name));
72
+ return slugs;
73
+ }
74
+ //#endregion
75
+ export { getSlugs, slugsFromData, slugsPlugin };