fumadocs-core 16.18.4 → 16.19.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 (96) hide show
  1. package/dist/{algolia-DsNJZd4P.d.ts → algolia-CQ_t21WZ.d.ts} +2 -2
  2. package/dist/{client-Bv_2P4D3.d.ts → client-Ca0pBjkk.d.ts} +3 -3
  3. package/dist/code-output-CTZ8RNSo.js +371 -0
  4. package/dist/content/mdx/preset-bundler.d.ts +4 -4
  5. package/dist/content/mdx/preset-runtime.d.ts +4 -4
  6. package/dist/{dynamic-CENrXFis.js → dynamic-BOCEF-LU.js} +19 -3
  7. package/dist/framework/plugin.d.ts +2 -2
  8. package/dist/heading-id-DV5jeAL8.js +78 -0
  9. package/dist/{index-CE1OSGGq.d.ts → index-BlFx9iJj.d.ts} +1 -1
  10. package/dist/index-DKOSCE6a.d.ts +18 -0
  11. package/dist/{index-BOhS1UKT.d.ts → index-DqVvRMMI.d.ts} +63 -79
  12. package/dist/mcp.d.ts +2 -2
  13. package/dist/mcp.js +1 -9
  14. package/dist/mdx-plugins/index.d.ts +9 -8
  15. package/dist/mdx-plugins/index.js +5 -5
  16. package/dist/mdx-plugins/rehype-code.core.js +1 -1
  17. package/dist/mdx-plugins/rehype-code.js +1 -1
  18. package/dist/mdx-plugins/rehype-toc.d.ts +1 -1
  19. package/dist/mdx-plugins/rehype-toc.js +74 -110
  20. package/dist/mdx-plugins/remark-admonition.js +1 -1
  21. package/dist/mdx-plugins/remark-block-id.js +1 -1
  22. package/dist/mdx-plugins/remark-code-tab.d.ts +1 -1
  23. package/dist/mdx-plugins/remark-code-tab.js +1 -192
  24. package/dist/mdx-plugins/remark-directive-admonition.js +1 -1
  25. package/dist/mdx-plugins/remark-feedback-block.js +1 -1
  26. package/dist/mdx-plugins/remark-gfm.d.ts +1 -1
  27. package/dist/mdx-plugins/remark-heading.d.ts +2 -2
  28. package/dist/mdx-plugins/remark-heading.js +51 -13
  29. package/dist/mdx-plugins/remark-heading.runtime.d.ts +11 -0
  30. package/dist/mdx-plugins/remark-heading.runtime.js +30 -0
  31. package/dist/mdx-plugins/remark-image.js +8 -8
  32. package/dist/mdx-plugins/remark-include.js +6 -6
  33. package/dist/mdx-plugins/remark-llms.d.ts +1 -1
  34. package/dist/mdx-plugins/remark-llms.js +18 -297
  35. package/dist/mdx-plugins/remark-mdx-files.js +1 -1
  36. package/dist/mdx-plugins/remark-mdx-mermaid.js +1 -1
  37. package/dist/mdx-plugins/remark-npm.js +1 -1
  38. package/dist/mdx-plugins/remark-show.d.ts +2 -2
  39. package/dist/mdx-plugins/remark-show.js +14 -154
  40. package/dist/mdx-plugins/remark-steps.js +11 -84
  41. package/dist/mdx-plugins/remark-structure.d.ts +1 -1
  42. package/dist/mdx-plugins/remark-structure.js +2 -157
  43. package/dist/mdx-plugins/stringifier.d.ts +23 -4
  44. package/dist/mdx-plugins/stringifier.js +3 -2
  45. package/dist/{meilisearch-DzjbVbAn.d.ts → meilisearch-BngEnZgG.d.ts} +2 -2
  46. package/dist/{mixedbread-CMi5F-zO.d.ts → mixedbread-d8e8wgqx.d.ts} +3 -3
  47. package/dist/{rehype-code.core-Jt2VtK1A.js → rehype-code.core-aegwEr3K.js} +1 -1
  48. package/dist/{rehype-toc-BBnmTg-x.d.ts → rehype-toc-B0HyD0yu.d.ts} +1 -1
  49. package/dist/{remark-code-tab-Dj_--R3y.d.ts → remark-code-tab-Bp3EItqr.d.ts} +3 -9
  50. package/dist/remark-code-tab-CS8aN0DX.js +154 -0
  51. package/dist/remark-gfm-chhuRhmk.d.ts +2 -0
  52. package/dist/remark-heading-BfD2dpns.d.ts +49 -0
  53. package/dist/{remark-llms-eA0WMw4X.d.ts → remark-llms-BCyfmS02.d.ts} +9 -10
  54. package/dist/remark-show-uR9rtiVe.d.ts +8 -0
  55. package/dist/{remark-structure-50nmY6sX.d.ts → remark-structure-CV606E7e.d.ts} +7 -2
  56. package/dist/remark-structure-DG_c2J4O.js +212 -0
  57. package/dist/search/algolia.d.ts +1 -1
  58. package/dist/search/client/algolia.d.ts +1 -1
  59. package/dist/search/client/docs-search.d.ts +1 -1
  60. package/dist/search/client/fetch.d.ts +1 -1
  61. package/dist/search/client/flexsearch-static.d.ts +1 -1
  62. package/dist/search/client/meilisearch.d.ts +1 -1
  63. package/dist/search/client/mixedbread.d.ts +2 -2
  64. package/dist/search/client/orama-cloud-legacy.d.ts +1 -1
  65. package/dist/search/client/orama-cloud.d.ts +1 -1
  66. package/dist/search/client/orama-static.d.ts +1 -1
  67. package/dist/search/client/orama-static.js +3 -3
  68. package/dist/search/client.d.ts +1 -1
  69. package/dist/search/flexsearch.d.ts +3 -3
  70. package/dist/search/index.d.ts +1 -1
  71. package/dist/search/index.js +1 -1
  72. package/dist/search/meilisearch.d.ts +1 -1
  73. package/dist/search/mixedbread.d.ts +2 -2
  74. package/dist/search/orama-cloud-legacy.d.ts +2 -2
  75. package/dist/search/orama-cloud.d.ts +3 -2
  76. package/dist/search/server.d.ts +1 -1
  77. package/dist/{server-MsDv36PV.d.ts → server-BJlZvi0B.d.ts} +3 -3
  78. package/dist/server.d.ts +8 -4
  79. package/dist/server.js +56 -26
  80. package/dist/source/dynamic.d.ts +1 -1
  81. package/dist/source/dynamic.js +1 -1
  82. package/dist/source/index.d.ts +2 -2
  83. package/dist/source/index.js +1 -1
  84. package/dist/source/llms.d.ts +1 -1
  85. package/dist/source/llms.js +93 -13
  86. package/dist/source/plugins/lucide-icons.d.ts +1 -1
  87. package/dist/source/plugins/slugs.d.ts +1 -1
  88. package/dist/source/plugins/slugs.js +5 -5
  89. package/dist/source/plugins/status-badges.d.ts +1 -1
  90. package/dist/steps-D4-CDiVv.js +135 -0
  91. package/dist/utils-DfA1qEJN.js +98 -0
  92. package/package.json +10 -7
  93. package/dist/heading-id-BXARvmRb.js +0 -15
  94. package/dist/remark-gfm-DpVfAX1x.d.ts +0 -2
  95. package/dist/remark-heading-Dhiig5Fv.d.ts +0 -31
  96. package/dist/utils-DV8PBZiI.js +0 -58
@@ -1,5 +1,5 @@
1
- import { n as StructuredData } from "./remark-structure-50nmY6sX.js";
2
- import { j as LoaderOutput, k as LoaderConfig } from "./index-BOhS1UKT.js";
1
+ import { n as StructuredData } from "./remark-structure-CV606E7e.js";
2
+ import { D as LoaderOutput, T as LoaderConfig } from "./index-DqVvRMMI.js";
3
3
  import { t as Awaitable } from "./types-Dvkw0Kd0.js";
4
4
  import { Algoliasearch } from "algoliasearch";
5
5
  interface DocumentRecord {
@@ -1,7 +1,7 @@
1
- import { r as SortedResult } from "./index-CE1OSGGq.js";
1
+ import { r as SortedResult } from "./index-BlFx9iJj.js";
2
2
  import { t as Awaitable } from "./types-Dvkw0Kd0.js";
3
- import { t as BaseIndex } from "./algolia-DsNJZd4P.js";
4
- import "./mixedbread-CMi5F-zO.js";
3
+ import { t as BaseIndex } from "./algolia-CQ_t21WZ.js";
4
+ import "./mixedbread-d8e8wgqx.js";
5
5
  import { DependencyList } from "react";
6
6
  import { AnyZBSearch, SearchParams } from "zbsearch";
7
7
  import { Root } from "hast";
@@ -0,0 +1,371 @@
1
+ // ../shared/show.ts
2
+ /** the element of a branch of `<show>`, defined in the module by {@link showDeclaration} */
3
+ const showElement = "_Show";
4
+ /** the ESM code that defines {@link showElement} */
5
+ const showDeclaration = `export function ${showElement}(props) { return props.when ? props.children : null }`;
6
+ /** the condition of a branch of `<show>`, code checked when rendering */
7
+ function showCondition(node) {
8
+ const { name, attributes } = node;
9
+ if (name !== "_Show") return;
10
+ for (const attr of attributes) if (attr.type === "mdxJsxAttribute" && attr.name === "when" && typeof attr.value === "object") return attr.value?.value;
11
+ }
12
+ /**
13
+ * Visit a tree in document order, with the conditions of the branches around each node, outermost first. Returning
14
+ * `skip` skips the children of a node, a visitor can remove the node it visits from `parent`.
15
+ */
16
+ function walkBranches(node, visitor, when = [], parent) {
17
+ if (visitor(node, when, parent) === "skip" || !node.children) return;
18
+ const condition = showCondition(node);
19
+ if (condition) when = [...when, condition];
20
+ const { children } = node;
21
+ for (let i = 0; i < children.length; i++) {
22
+ const child = children[i];
23
+ walkBranches(child, visitor, when, node);
24
+ if (children[i] !== child) i--;
25
+ }
26
+ }
27
+ const none = [];
28
+ /**
29
+ * Group the lists among sibling nodes, like steps and the tabs of code blocks. A branch doesn't break a list: the nodes
30
+ * inside it are nodes of the list around it, unless one of them ends the list. A list has an item outside branches, a
31
+ * branch groups the lists inside it otherwise.
32
+ *
33
+ * @param test - read a node as an item of the list, `false` ends the list and the nodes without a result are its
34
+ * content. `first` is the first item of the list
35
+ * @param build - the nodes that replace the nodes of a list
36
+ * @param setChildren - set the children of a branch, trees differ in how a node is edited
37
+ * @returns the siblings, `undefined` without a list
38
+ */
39
+ function groupLists(children, test, build, setChildren) {
40
+ const out = [];
41
+ /** the nodes before it are in `out` */
42
+ let done = 0;
43
+ let changed = false;
44
+ let branches = false;
45
+ let start = -1;
46
+ let items = [];
47
+ let direct = false;
48
+ let ends = false;
49
+ const visit = (node, when) => {
50
+ if (showCondition(node)) {
51
+ branches = true;
52
+ return;
53
+ }
54
+ const result = ends ? void 0 : test(node, items[0]?.node);
55
+ if (result) items.push({
56
+ node,
57
+ data: result,
58
+ when
59
+ });
60
+ else if (result === false) ends = true;
61
+ return "skip";
62
+ };
63
+ /** the nodes outside lists stay, a branch groups the lists inside it */
64
+ const keep = (end) => {
65
+ for (; done < end; done++) {
66
+ const node = children[done];
67
+ const inner = showCondition(node) && groupLists(node.children, test, build, setChildren);
68
+ if (inner) {
69
+ setChildren(node, inner);
70
+ changed = true;
71
+ }
72
+ out.push(node);
73
+ }
74
+ };
75
+ const close = (end) => {
76
+ if (direct) {
77
+ keep(start);
78
+ for (const node of build(children.slice(start, end), items)) out.push(node);
79
+ done = end;
80
+ changed = true;
81
+ }
82
+ start = -1;
83
+ items = [];
84
+ direct = false;
85
+ };
86
+ for (let i = 0; i < children.length; i++) {
87
+ const count = items.length;
88
+ ends = false;
89
+ walkBranches(children[i], visit, none);
90
+ if (ends) {
91
+ items.length = count;
92
+ if (start !== -1) {
93
+ close(i);
94
+ i--;
95
+ }
96
+ continue;
97
+ }
98
+ if (items.length === count) continue;
99
+ if (start === -1) start = i;
100
+ direct ||= items[count].when.length === 0;
101
+ }
102
+ close(children.length);
103
+ if (!changed && !branches) return;
104
+ keep(children.length);
105
+ if (changed) return out;
106
+ }
107
+ /**
108
+ * Whether the outputs of a document are static: values analysed from the source, which can't tell the branches that
109
+ * show nor read props. A document with branches has no static outputs.
110
+ *
111
+ * @param isStatic - by default, unless the content source of the document renders its pages for props
112
+ */
113
+ function isStaticOutput(data, isStatic = !data.unstable_runtimeOutputs) {
114
+ if (isStatic && data._show) throw new Error("`<show>` is checked when rendering, but the outputs of this document are static: its content source doesn't set `unstable_runtimeOutputs` in the data of the file, or processed Markdown has `output: 'string'`.");
115
+ return isStatic;
116
+ }
117
+ // ../shared/code-output.ts
118
+ const markerRegex = /\0(\/?)(\d+)\0/g;
119
+ const componentNameRegex = /^[A-Z][\w$]*$/;
120
+ /** the elements that static search keeps as HTML tags by default */
121
+ const staticTagRegex = /^(File|TypeTable|Callout|Card)$/;
122
+ /**
123
+ * Markdown stringified from the authored source for a target, with parts that render from code. Replacements mark the
124
+ * parts, so edits apply to their content like to other content (e.g. the prefixes of list items), and the code of the
125
+ * output splits it on the markers. The code runs in a function of the props of the page, in the scope of its module.
126
+ */
127
+ function createCodeOutput({ target, isStatic, keep, stringifier, parse, literal = JSON.stringify }) {
128
+ const parts = [];
129
+ /** the components that the code refers to in JSX: kept elements, and the JSX in authored code */
130
+ const components = /* @__PURE__ */ new Set();
131
+ const readJsx = (code) => {
132
+ if (code.includes("<")) jsxComponents(parse(code), components);
133
+ };
134
+ const mark = (part) => `\0${parts.push(part) - 1}\0`;
135
+ const wrap = (part, content) => {
136
+ const i = parts.push(part) - 1;
137
+ return `\0${i}\0${content}\0/${i}\0`;
138
+ };
139
+ const expression = (code, fallback) => mark({
140
+ code,
141
+ fallback
142
+ });
143
+ const s = stringifier(expression);
144
+ function chunks(text) {
145
+ const root = [];
146
+ const stack = [root];
147
+ /** a branch that just closed, the line break after it goes with it */
148
+ let branch;
149
+ let idx = 0;
150
+ const pushText = (end) => {
151
+ let value = text.slice(idx, end);
152
+ if (branch) {
153
+ const lead = /^\s*/.exec(value)[0];
154
+ if (lead.includes("\n")) {
155
+ branch.push(lead);
156
+ value = value.slice(lead.length);
157
+ }
158
+ branch = void 0;
159
+ }
160
+ if (value) stack.at(-1).push(value);
161
+ };
162
+ for (const match of text.matchAll(markerRegex)) {
163
+ pushText(match.index);
164
+ idx = match.index + match[0].length;
165
+ const part = parts[Number(match[2])];
166
+ if (match[1]) {
167
+ const children = stack.pop();
168
+ stack.at(-1).push({
169
+ ...part,
170
+ children
171
+ });
172
+ if ("when" in part) branch = children;
173
+ } else if ("code" in part) stack.at(-1).push(part);
174
+ else stack.push([]);
175
+ }
176
+ pushText(text.length);
177
+ return root;
178
+ }
179
+ /** see {@link componentsCode}, of the components of the code */
180
+ const declare = (scope, from) => componentsCode(components, scope, from);
181
+ /** the JSX element of a component, with the code of its attributes */
182
+ function component(node) {
183
+ const { name } = node;
184
+ if (typeof name !== "string" || !componentNameRegex.test(name)) return;
185
+ components.add(name);
186
+ let open = `<${name}`;
187
+ for (const attr of node.attributes) if (attr.type === "mdxJsxExpressionAttribute") {
188
+ open += ` {${attr.value}}`;
189
+ readJsx(`({${attr.value}})`);
190
+ } else if (attr.value == null) open += ` ${attr.name}`;
191
+ else if (typeof attr.value === "string") open += ` ${attr.name}={${JSON.stringify(attr.value)}}`;
192
+ else {
193
+ open += ` ${attr.name}={${attr.value.value}}`;
194
+ readJsx(`(${attr.value.value}\n)`);
195
+ }
196
+ return {
197
+ open,
198
+ name,
199
+ inline: node.type === "mdxJsxTextElement"
200
+ };
201
+ }
202
+ function element(node) {
203
+ const when = showCondition(node);
204
+ if (when) return s.replace(node, (s) => wrap({ when }, s.inner(node)));
205
+ const kept = keep ? keep(node) : !isStatic || staticTagRegex.test(String(node.name));
206
+ const part = kept && !isStatic ? component(node) : void 0;
207
+ if (part) s.replace(node, (s) => {
208
+ const inner = s.inner(node);
209
+ return wrap(part, target === "markdown" && inner && !part.inline ? `\n${inner}\n` : inner);
210
+ });
211
+ else if (target === "search") s.replace(node, (s) => {
212
+ if (!kept || !(keep || isStatic)) return s.inner(node);
213
+ const attributes = {};
214
+ for (const attr of node.attributes) if (attr.type === "mdxJsxAttribute") attributes[attr.name] = (typeof attr.value === "object" ? attr.value?.value : attr.value) ?? true;
215
+ return toHtmlTag(node.name, attributes, s.inner(node));
216
+ });
217
+ }
218
+ return {
219
+ s,
220
+ /** mark the code of a value */
221
+ expression,
222
+ /** Edit a node for the target: authored expressions, `<show>` branches, JSX elements, links, images and ESM. */
223
+ edit(node) {
224
+ const { type } = node;
225
+ if (type === "mdxjsEsm") s.replace(node, "");
226
+ else if (type === "mdxJsxFlowElement" || type === "mdxJsxTextElement") element(node);
227
+ else if (type === "mdxTextExpression" || type === "mdxFlowExpression") {
228
+ if (isStatic) return;
229
+ const code = node.value;
230
+ const position = s.range(node);
231
+ s.replace(node, mark({
232
+ code,
233
+ fallback: position ? s.source.slice(position.start, position.end) : "",
234
+ inline: type === "mdxTextExpression"
235
+ }));
236
+ readJsx(`(${code}\n)`);
237
+ } else if (target === "search") {
238
+ if (type === "link" || type === "linkReference") s.replace(node, (s) => s.inner(node));
239
+ else if (type === "image" || type === "imageReference") s.replace(node, "");
240
+ }
241
+ },
242
+ /** the output without code: values as their fallbacks, the content of every branch and element */
243
+ toStatic(text) {
244
+ return text.replace(markerRegex, (_, close, i) => {
245
+ const part = parts[Number(i)];
246
+ return !close && "fallback" in part ? part.fallback : "";
247
+ });
248
+ },
249
+ /** the output as a string in code, its values are concatenated: for an output without branches or elements */
250
+ toConcat(text) {
251
+ let out = "";
252
+ for (const chunk of chunks(text)) out += `${out ? " + " : ""}${typeof chunk === "string" ? literal(chunk) : `(${chunk.code})`}`;
253
+ return out || "\"\"";
254
+ },
255
+ /** the output as a value in code: a string without parts, a fragment otherwise */
256
+ toCode(text) {
257
+ return chunksToCode(chunks(text), literal);
258
+ },
259
+ componentsCode: declare,
260
+ /**
261
+ * The export of processed Markdown: a component, rendered with `renderToMarkdown()` of `fumadocs-core/server`.
262
+ * Its elements resolve like in the content, a missing MDX component is kept as JSX syntax.
263
+ */
264
+ markdownCode(as, text, scope) {
265
+ const declaration = declare(scope, "_jsxComponents(props.components)");
266
+ return [
267
+ `import { asMarkdown as _asMarkdown${declaration && ", jsxComponents as _jsxComponents"} } from "fumadocs-core/server";`,
268
+ `export function ${as}(props) {`,
269
+ " if (!_asMarkdown()) return null;",
270
+ declaration,
271
+ ` return ${chunksToCode(chunks(text), literal)};`,
272
+ "}"
273
+ ].join("\n");
274
+ }
275
+ };
276
+ }
277
+ /**
278
+ * An element as an HTML tag, so search dialogs render it as an element: its attributes that are text or `true`, with
279
+ * values and content on one line, values truncated.
280
+ */
281
+ function toHtmlTag(name, attributes, inner) {
282
+ let open = `<${name}`;
283
+ for (const key in attributes) {
284
+ const value = attributes[key];
285
+ if (value === true) open += ` ${key}`;
286
+ if (key === "children" || typeof value !== "string" && typeof value !== "number") continue;
287
+ let text = String(value).replace(/\s+/g, " ");
288
+ if (text.length > 100) text = `${text.slice(0, 100)}…`;
289
+ open += ` ${key}="${text.replaceAll("&", "&amp;").replaceAll("\"", "&quot;")}"`;
290
+ }
291
+ const children = inner.replace(/\s+/g, " ");
292
+ return children ? `${open}>${children}</${name}>` : `${open} />`;
293
+ }
294
+ /**
295
+ * The declaration of the components that code refers to and the module doesn't declare. Like in the content, they
296
+ * are MDX components.
297
+ *
298
+ * @param scope - the names that the module declares, read when there are components
299
+ * @param from - the code of the MDX components
300
+ * @param fallback - the code of a component that `from` doesn't have
301
+ */
302
+ function componentsCode(components, scope, from, fallback) {
303
+ let names = "";
304
+ if (components.size > 0) {
305
+ const declared = scope();
306
+ for (const name of components) if (!declared.has(name)) names += fallback ? `${name} = ${fallback}, ` : `${name}, `;
307
+ }
308
+ return names && `const { ${names}} = ${from};`;
309
+ }
310
+ /** the components that a program refers to in JSX, like MDX: the first name of a tag that isn't an HTML element */
311
+ function jsxComponents(node, out) {
312
+ if (typeof node !== "object" || node === null) return;
313
+ let { type, name } = node;
314
+ if (type === "JSXOpeningElement") {
315
+ while (name?.object) name = name.object;
316
+ if (name?.type === "JSXIdentifier" && !/^[a-z]/.test(name.name)) out.add(name.name);
317
+ }
318
+ for (const key in node) jsxComponents(node[key], out);
319
+ }
320
+ /** the names declared by the ESM statements of a module: imports and top-level declarations */
321
+ function moduleScope(statements, scope = /* @__PURE__ */ new Set()) {
322
+ for (const item of statements) {
323
+ for (const { local } of item.specifiers ?? []) if (local.name) scope.add(local.name);
324
+ const declaration = item.type === "ExportNamedDeclaration" ? item.declaration : item;
325
+ if (declaration?.id?.name) scope.add(declaration.id.name);
326
+ for (const { id } of declaration?.declarations ?? []) if (id.type === "Identifier" && id.name) scope.add(id.name);
327
+ }
328
+ return scope;
329
+ }
330
+ /** all of the conditions */
331
+ function and(conditions) {
332
+ if (conditions.length > 0) return `(${conditions.join(") && (")})`;
333
+ }
334
+ /**
335
+ * The code of a list output: a function of the props giving the items whose conditions hold, or the list when static.
336
+ * The list is read in document order, so an entry with `run` can count the items that show.
337
+ *
338
+ * @param declaration - the code that declares the names of the items, see {@link componentsCode}
339
+ */
340
+ function listCode(items, isStatic, declaration = "") {
341
+ let list = "[";
342
+ for (const { code, when, run } of items) {
343
+ const test = and(when);
344
+ const item = run ? `...((${code}), [])` : code;
345
+ list += test ? `...(${test} ? [${item}] : []),` : `${item},`;
346
+ }
347
+ list += "]";
348
+ if (isStatic) return list;
349
+ return declaration ? `(props) => {\n${declaration}\nreturn ${list};\n}` : `(props) => ${list}`;
350
+ }
351
+ function chunksToCode(chunks, literal) {
352
+ let text = "";
353
+ for (const chunk of chunks) {
354
+ if (typeof chunk !== "string") return `<>${chunksToJsx(chunks, literal)}</>`;
355
+ text += chunk;
356
+ }
357
+ return literal(text);
358
+ }
359
+ function chunksToJsx(chunks, literal) {
360
+ let out = "";
361
+ for (const chunk of chunks) if (typeof chunk === "string") out += `{${literal(chunk)}}`;
362
+ else if ("code" in chunk) out += chunk.inline ? `<span>{${chunk.code}}</span>` : `{${chunk.code}}`;
363
+ else if ("when" in chunk) out += `{(${chunk.when}) ? <>${chunksToJsx(chunk.children, literal)}</> : null}`;
364
+ else {
365
+ const { open, name, inline, children } = chunk;
366
+ const element = children.length > 0 ? `${open}>${chunksToJsx(children, literal)}</${name}>` : `${open} />`;
367
+ out += inline ? `<span>${element}</span>` : element;
368
+ }
369
+ return out;
370
+ }
371
+ export { listCode as a, toHtmlTag as c, showCondition as d, showDeclaration as f, jsxComponents as i, groupLists as l, walkBranches as m, componentsCode as n, moduleScope as o, showElement as p, createCodeOutput as r, staticTagRegex as s, and as t, isStaticOutput as u };
@@ -1,10 +1,10 @@
1
1
  import { t as RehypeCodeOptions } from "../../rehype-code-Czh_8L5z.js";
2
2
  import { t as RemarkImageOptions } from "../../remark-image-BwyGdFld.js";
3
- import { t as StructureOptions } from "../../remark-structure-50nmY6sX.js";
4
- import { t as RemarkHeadingOptions } from "../../remark-heading-Dhiig5Fv.js";
5
- import { t as RemarkCodeTabOptions } from "../../remark-code-tab-Dj_--R3y.js";
3
+ import { t as StructureOptions } from "../../remark-structure-CV606E7e.js";
4
+ import { t as RemarkHeadingOptions } from "../../remark-heading-BfD2dpns.js";
5
+ import { t as RemarkCodeTabOptions } from "../../remark-code-tab-Bp3EItqr.js";
6
6
  import { t as RemarkNpmOptions } from "../../remark-npm-IH35Vls_.js";
7
- import "../../index-BOhS1UKT.js";
7
+ import "../../index-DKOSCE6a.js";
8
8
  import { t as ResolvePlugins } from "../../util-YfkucgkA.js";
9
9
  import { Pluggable } from "unified";
10
10
  import { ProcessorOptions } from "@mdx-js/mdx";
@@ -1,10 +1,10 @@
1
1
  import { t as RehypeCodeOptions } from "../../rehype-code-Czh_8L5z.js";
2
2
  import { t as RemarkImageOptions } from "../../remark-image-BwyGdFld.js";
3
- import { t as StructureOptions } from "../../remark-structure-50nmY6sX.js";
4
- import { t as RemarkHeadingOptions } from "../../remark-heading-Dhiig5Fv.js";
5
- import { t as RemarkCodeTabOptions } from "../../remark-code-tab-Dj_--R3y.js";
3
+ import { t as StructureOptions } from "../../remark-structure-CV606E7e.js";
4
+ import { t as RemarkHeadingOptions } from "../../remark-heading-BfD2dpns.js";
5
+ import { t as RemarkCodeTabOptions } from "../../remark-code-tab-Bp3EItqr.js";
6
6
  import { t as RemarkNpmOptions } from "../../remark-npm-IH35Vls_.js";
7
- import "../../index-BOhS1UKT.js";
7
+ import "../../index-DKOSCE6a.js";
8
8
  import { t as ResolvePlugins } from "../../util-YfkucgkA.js";
9
9
  import { ProcessorOptions } from "@mdx-js/mdx";
10
10
  export type MDXRuntimePresetOptions = Omit<NonNullable<ProcessorOptions>, 'rehypePlugins' | 'remarkPlugins'> & {
@@ -261,7 +261,8 @@ function createContentStorageBuilder(loaderConfig) {
261
261
  path,
262
262
  slugs: inputFile.slugs,
263
263
  data: inputFile.data,
264
- absolutePath: inputFile.absolutePath
264
+ absolutePath: inputFile.absolutePath,
265
+ dataAt: inputFile.dataAt
265
266
  };
266
267
  const page = file;
267
268
  files = getStaticParams(path, {
@@ -654,6 +655,7 @@ function slugsKey(slugs) {
654
655
  function createPageIndexer({ url }) {
655
656
  /** locale (empty without i18n) -> index */
656
657
  const indexes = /* @__PURE__ */ new Map();
658
+ const binders = /* @__PURE__ */ new WeakMap();
657
659
  return {
658
660
  scan(storage, lang) {
659
661
  const index = {
@@ -683,6 +685,7 @@ function createPageIndexer({ url }) {
683
685
  params: item.params,
684
686
  locale: lang
685
687
  };
688
+ if (item.dataAt) binders.set(page, item.dataAt);
686
689
  index.pathToPage.set(path, page);
687
690
  index.pages.set(slugsKey(page.slugs), page);
688
691
  index.urlToPage.set(page.url, page);
@@ -700,6 +703,17 @@ function createPageIndexer({ url }) {
700
703
  getPageBySlugs(slugs, lang = "") {
701
704
  return indexes.get(lang)?.pages.get(slugsKey(slugs));
702
705
  },
706
+ /** the page with props passed to its content, not cached */
707
+ withProps(page, props) {
708
+ const bind = binders.get(page);
709
+ return bind ? {
710
+ ...page,
711
+ data: bind(page.params ?? {}, {
712
+ props,
713
+ data: page.data
714
+ })
715
+ } : page;
716
+ },
703
717
  /** do not filter by language if `lang` is not specified */
704
718
  getPages(lang) {
705
719
  const out = [];
@@ -792,8 +806,10 @@ function loader(...args) {
792
806
  });
793
807
  return list;
794
808
  },
795
- getPage(slugs = [], language = i18n?.defaultLanguage) {
796
- return indexer.getPageBySlugs(slugs, language);
809
+ getPage(slugs = [], options) {
810
+ const { language = i18n?.defaultLanguage, props } = typeof options === "object" ? options : { language: options };
811
+ const page = indexer.getPageBySlugs(slugs, language);
812
+ return page && props ? indexer.withProps(page, props) : page;
797
813
  },
798
814
  getPageByUrl(url, language) {
799
815
  if (language !== void 0 || !i18n) return indexer.getPageByUrl(url, language);
@@ -1,6 +1,6 @@
1
1
  import { i as TranslationExtension } from "../index-DFrWGSeW.js";
2
- import { n as StructuredData } from "../remark-structure-50nmY6sX.js";
3
- import { A as LoaderOptions, N as LoaderPluginOption, j as LoaderOutput, k as LoaderConfig } from "../index-BOhS1UKT.js";
2
+ import { n as StructuredData } from "../remark-structure-CV606E7e.js";
3
+ import { D as LoaderOutput, E as LoaderOptions, T as LoaderConfig, k as LoaderPluginOption } from "../index-DqVvRMMI.js";
4
4
  import { c as TOCItemType } from "../toc-BuHOTlzj.js";
5
5
  import { ReactNode } from "react";
6
6
  type Awaitable<T> = T | Promise<T>;
@@ -0,0 +1,78 @@
1
+ import { d as showCondition, t as and } from "./code-output-CTZ8RNSo.js";
2
+ // ../shared/heading-id.ts
3
+ /** a custom ID at the end of heading text, like `[#id]` */
4
+ const headingIdRegex = /\s*\[#(?<slug>[^]+?)]\s*$/;
5
+ /** the default runtime of ID code, function bodies read it from `arguments[0]` like the JSX runtime */
6
+ const headingRuntime = "fumadocs-core/mdx-plugins/remark-heading.runtime";
7
+ /**
8
+ * The text of inline content as code, the items of an array of its parts: authored expressions are values, the
9
+ * content of a branch of `<show>` is there when it shows. Like in React, only strings and numbers are text.
10
+ *
11
+ * @param onCode - called when a part is code
12
+ */
13
+ function textParts(nodes, onCode) {
14
+ let parts = "";
15
+ for (const node of nodes) {
16
+ const branch = showCondition(node);
17
+ if (node.type === "mdxTextExpression") {
18
+ onCode();
19
+ parts += `...[${node.value}\n],`;
20
+ } else if (branch) {
21
+ onCode();
22
+ parts += `...((${branch}) ? [${textParts(node.children, onCode)}] : []),`;
23
+ } else if (node.children) parts += textParts(node.children, onCode);
24
+ else if (typeof node.value === "string") parts += `${JSON.stringify(node.value)},`;
25
+ }
26
+ return parts;
27
+ }
28
+ /**
29
+ * IDs slugged when rendering, from the first heading that has an authored expression, or is in or around a branch of
30
+ * `<show>`. The headings are slugged in document order, so only the ones that show count for duplicates.
31
+ *
32
+ * @param runtime - the module that the code imports `createHeadingIds()` from
33
+ */
34
+ function headingIdCode(runtime = headingRuntime) {
35
+ const entries = [];
36
+ let dynamic = false;
37
+ const onCode = () => {
38
+ dynamic = true;
39
+ };
40
+ return {
41
+ /**
42
+ * The code of the ID of the next heading in document order, when it renders from code.
43
+ *
44
+ * @param when - the conditions of the branches around the heading
45
+ */
46
+ next(nodes, when) {
47
+ const test = and(when);
48
+ if (test) dynamic = true;
49
+ const id = `_slug([${textParts(nodes, onCode)}])`;
50
+ entries.push(test ? `${test} ? ${id} : ""` : id);
51
+ if (dynamic) return `_headingIds(props)[${entries.length - 1}]`;
52
+ },
53
+ /** the ESM code that the IDs from code read */
54
+ get esm() {
55
+ if (dynamic) return `import { createHeadingIds as _createHeadingIds } from ${JSON.stringify(runtime)};\nexport const _headingIds = _createHeadingIds((props, _slug) => [${entries.join(", ")}]);`;
56
+ }
57
+ };
58
+ }
59
+ /**
60
+ * Write the ID of a heading in stringified Markdown, the one that `remarkHeading` gave it unless it has a custom ID.
61
+ *
62
+ * @param ids - the IDs from code, `false` removes custom IDs
63
+ */
64
+ function stringifyHeadingId({ s, expression }, node, ids) {
65
+ const start = s.range(node)?.start;
66
+ const last = node.children[node.children.length - 1];
67
+ const end = last && s.range(last)?.end;
68
+ if (start === void 0 || end === void 0) return;
69
+ const marker = headingIdRegex.exec(s.source.slice(start, end));
70
+ const id = node.data?.hProperties?.id;
71
+ if (ids === false) {
72
+ if (marker) s.edit(start + marker.index, end, "", node);
73
+ } else if (id != null && !marker) {
74
+ const code = ids?.[id];
75
+ s.edit(end, end, ` [#${code ? expression(code, id) : id}]`, node);
76
+ }
77
+ }
78
+ export { headingIdRegex as n, stringifyHeadingId as r, headingIdCode as t };
@@ -1,4 +1,4 @@
1
- import { r as StructuredDataContent } from "./remark-structure-50nmY6sX.js";
1
+ import { r as StructuredDataContent } from "./remark-structure-CV606E7e.js";
2
2
  import { ReactNode } from "react";
3
3
  interface SortedResult<Content = string> {
4
4
  id: string;
@@ -0,0 +1,18 @@
1
+ import "./remark-gfm-chhuRhmk.js";
2
+ import "./rehype-code-Czh_8L5z.js";
3
+ import "./remark-image-BwyGdFld.js";
4
+ import "./remark-include-D_FmDdtI.js";
5
+ import "./remark-structure-CV606E7e.js";
6
+ import "./remark-heading-BfD2dpns.js";
7
+ import "./remark-admonition-BxacgP6i.js";
8
+ import "./remark-directive-admonition-BT_PH6hL.js";
9
+ import "./rehype-toc-B0HyD0yu.js";
10
+ import "./remark-code-tab-Bp3EItqr.js";
11
+ import "./remark-steps-CKvq9VmR.js";
12
+ import "./remark-npm-IH35Vls_.js";
13
+ import "./codeblock-utils-D65x-Jra.js";
14
+ import "./remark-mdx-files-BJvKexDp.js";
15
+ import "./remark-mdx-mermaid-BrK4YVTJ.js";
16
+ import "./remark-feedback-block-2Ei4IDr4.js";
17
+ import "./remark-show-uR9rtiVe.js";
18
+ import "./remark-llms-BCyfmS02.js";