fumadocs-core 16.19.3 → 16.19.4

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 (29) hide show
  1. package/dist/{code-output-CTZ8RNSo.js → code-output-BZYBFRsN.js} +20 -25
  2. package/dist/{heading-id-DV5jeAL8.js → heading-id-C-jg9hhz.js} +12 -4
  3. package/dist/mdx-plugins/index.js +3 -3
  4. package/dist/mdx-plugins/rehype-code.core.js +1 -1
  5. package/dist/mdx-plugins/rehype-code.js +1 -1
  6. package/dist/mdx-plugins/rehype-toc.js +3 -3
  7. package/dist/mdx-plugins/remark-admonition.js +1 -1
  8. package/dist/mdx-plugins/remark-block-id.js +1 -1
  9. package/dist/mdx-plugins/remark-code-tab.js +1 -1
  10. package/dist/mdx-plugins/remark-directive-admonition.js +1 -1
  11. package/dist/mdx-plugins/remark-feedback-block.js +1 -1
  12. package/dist/mdx-plugins/remark-heading.js +5 -4
  13. package/dist/mdx-plugins/remark-image.js +1 -1
  14. package/dist/mdx-plugins/remark-include.js +2 -2
  15. package/dist/mdx-plugins/remark-llms.js +3 -3
  16. package/dist/mdx-plugins/remark-mdx-files.js +1 -1
  17. package/dist/mdx-plugins/remark-mdx-mermaid.js +1 -1
  18. package/dist/mdx-plugins/remark-npm.js +1 -1
  19. package/dist/mdx-plugins/remark-show.js +2 -2
  20. package/dist/mdx-plugins/remark-steps.js +2 -2
  21. package/dist/mdx-plugins/remark-structure.js +1 -1
  22. package/dist/{rehype-code.core-aegwEr3K.js → rehype-code.core-DNLXo8St.js} +1 -1
  23. package/dist/{remark-code-tab-CS8aN0DX.js → remark-code-tab-DOOMCbAN.js} +2 -2
  24. package/dist/{remark-structure-DG_c2J4O.js → remark-structure-DUU7_xF1.js} +3 -3
  25. package/dist/search/index.js +1 -1
  26. package/dist/server.js +20 -9
  27. package/dist/{steps-D4-CDiVv.js → steps-CGouhZm4.js} +1 -1
  28. package/dist/{utils-DfA1qEJN.js → utils-C7sTEOQI.js} +12 -15
  29. package/package.json +1 -1
@@ -126,11 +126,6 @@ const staticTagRegex = /^(File|TypeTable|Callout|Card)$/;
126
126
  */
127
127
  function createCodeOutput({ target, isStatic, keep, stringifier, parse, literal = JSON.stringify }) {
128
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
129
  const mark = (part) => `\0${parts.push(part) - 1}\0`;
135
130
  const wrap = (part, content) => {
136
131
  const i = parts.push(part) - 1;
@@ -176,23 +171,20 @@ function createCodeOutput({ target, isStatic, keep, stringifier, parse, literal
176
171
  pushText(text.length);
177
172
  return root;
178
173
  }
179
- /** see {@link componentsCode}, of the components of the code */
180
- const declare = (scope, from) => componentsCode(components, scope, from);
174
+ /**
175
+ * See {@link componentsCode}, of the components that the parts refer to: kept elements, and the JSX in authored
176
+ * code. The parts are parsed as the JSX they are in the output, where an expression of comments is valid.
177
+ */
178
+ const declare = (scope, from) => componentsCode(jsxComponents(parts.length > 0 && parse(`<>${chunksToJsx(parts, literal)}</>`)), scope, from);
181
179
  /** the JSX element of a component, with the code of its attributes */
182
180
  function component(node) {
183
181
  const { name } = node;
184
182
  if (typeof name !== "string" || !componentNameRegex.test(name)) return;
185
- components.add(name);
186
183
  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}`;
184
+ for (const attr of node.attributes) if (attr.type === "mdxJsxExpressionAttribute") open += ` {${attr.value}}`;
185
+ else if (attr.value == null) open += ` ${attr.name}`;
191
186
  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
- }
187
+ else open += ` ${attr.name}={${attr.value.value}}`;
196
188
  return {
197
189
  open,
198
190
  name,
@@ -226,14 +218,12 @@ function createCodeOutput({ target, isStatic, keep, stringifier, parse, literal
226
218
  else if (type === "mdxJsxFlowElement" || type === "mdxJsxTextElement") element(node);
227
219
  else if (type === "mdxTextExpression" || type === "mdxFlowExpression") {
228
220
  if (isStatic) return;
229
- const code = node.value;
230
221
  const position = s.range(node);
231
222
  s.replace(node, mark({
232
- code,
223
+ code: node.value,
233
224
  fallback: position ? s.source.slice(position.start, position.end) : "",
234
225
  inline: type === "mdxTextExpression"
235
226
  }));
236
- readJsx(`(${code}\n)`);
237
227
  } else if (target === "search") {
238
228
  if (type === "link" || type === "linkReference") s.replace(node, (s) => s.inner(node));
239
229
  else if (type === "image" || type === "imageReference") s.replace(node, "");
@@ -307,15 +297,20 @@ function componentsCode(components, scope, from, fallback) {
307
297
  }
308
298
  return names && `const { ${names}} = ${from};`;
309
299
  }
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;
300
+ /**
301
+ * The components that parsed code refers to in JSX, like MDX: the name of a tag that isn't an HTML element, or the
302
+ * object of a member tag like `<a.B>`.
303
+ */
304
+ function jsxComponents(node, out = /* @__PURE__ */ new Set()) {
305
+ if (typeof node !== "object" || node === null) return out;
313
306
  let { type, name } = node;
314
307
  if (type === "JSXOpeningElement") {
308
+ const member = name?.object !== void 0;
315
309
  while (name?.object) name = name.object;
316
- if (name?.type === "JSXIdentifier" && !/^[a-z]/.test(name.name)) out.add(name.name);
310
+ if (name?.type === "JSXIdentifier" && (member || !/^[a-z]/.test(name.name))) out.add(name.name);
317
311
  }
318
312
  for (const key in node) jsxComponents(node[key], out);
313
+ return out;
319
314
  }
320
315
  /** the names declared by the ESM statements of a module: imports and top-level declarations */
321
316
  function moduleScope(statements, scope = /* @__PURE__ */ new Set()) {
@@ -360,10 +355,10 @@ function chunksToJsx(chunks, literal) {
360
355
  let out = "";
361
356
  for (const chunk of chunks) if (typeof chunk === "string") out += `{${literal(chunk)}}`;
362
357
  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}`;
358
+ else if ("when" in chunk) out += `{(${chunk.when}) ? <>${chunksToJsx(chunk.children ?? [], literal)}</> : null}`;
364
359
  else {
365
360
  const { open, name, inline, children } = chunk;
366
- const element = children.length > 0 ? `${open}>${chunksToJsx(children, literal)}</${name}>` : `${open} />`;
361
+ const element = children?.length ? `${open}>${chunksToJsx(children, literal)}</${name}>` : `${open} />`;
367
362
  out += inline ? `<span>${element}</span>` : element;
368
363
  }
369
364
  return out;
@@ -1,4 +1,4 @@
1
- import { d as showCondition, t as and } from "./code-output-CTZ8RNSo.js";
1
+ import { d as showCondition, i as jsxComponents, n as componentsCode, t as and } from "./code-output-BZYBFRsN.js";
2
2
  // ../shared/heading-id.ts
3
3
  /** a custom ID at the end of heading text, like `[#id]` */
4
4
  const headingIdRegex = /\s*\[#(?<slug>[^]+?)]\s*$/;
@@ -50,9 +50,17 @@ function headingIdCode(runtime = headingRuntime) {
50
50
  entries.push(test ? `${test} ? ${id} : ""` : id);
51
51
  if (dynamic) return `_headingIds(props)[${entries.length - 1}]`;
52
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(", ")}]);`;
53
+ /**
54
+ * The ESM code that the IDs from code read. It declares the components of authored code, see
55
+ * {@link componentsCode}: only strings and numbers are text, so the components don't have to be there.
56
+ *
57
+ * @param parse - parse a JSX expression
58
+ */
59
+ esm(parse, scope) {
60
+ if (!dynamic) return;
61
+ const list = `[${entries.join(", ")}]`;
62
+ const declaration = componentsCode(jsxComponents(parse(list)), scope, "props.components ?? {}");
63
+ return `import { createHeadingIds as _createHeadingIds } from ${JSON.stringify(runtime)};\nexport const _headingIds = _createHeadingIds((props, _slug) => {\n${declaration}\nreturn ${list};\n});`;
56
64
  }
57
65
  };
58
66
  }
@@ -1,15 +1,15 @@
1
1
  import { remarkGfm } from "./remark-gfm.js";
2
2
  import { rehypeCode, rehypeCodeDefaultOptions } from "./rehype-code.js";
3
3
  import { remarkImage } from "./remark-image.js";
4
- import { i as transformerTab } from "../rehype-code.core-aegwEr3K.js";
4
+ import { i as transformerTab } from "../rehype-code.core-DNLXo8St.js";
5
5
  import { transformerIcon } from "./transformer-icon.js";
6
6
  import { extractCodeRegion, remarkInclude } from "./remark-include.js";
7
- import { n as remarkStructureDefaultOptions, r as structure, t as remarkStructure } from "../remark-structure-DG_c2J4O.js";
7
+ import { n as remarkStructureDefaultOptions, r as structure, t as remarkStructure } from "../remark-structure-DUU7_xF1.js";
8
8
  import { rehypeHeading, remarkHeading } from "./remark-heading.js";
9
9
  import { remarkAdmonition } from "./remark-admonition.js";
10
10
  import { remarkDirectiveAdmonition } from "./remark-directive-admonition.js";
11
11
  import { rehypeToc } from "./rehype-toc.js";
12
- import { t as remarkCodeTab } from "../remark-code-tab-CS8aN0DX.js";
12
+ import { t as remarkCodeTab } from "../remark-code-tab-DOOMCbAN.js";
13
13
  import { remarkSteps } from "./remark-steps.js";
14
14
  import { remarkNpm } from "./remark-npm.js";
15
15
  import { generateCodeBlockTabs, parseCodeBlockAttributes } from "./codeblock-utils.js";
@@ -1,3 +1,3 @@
1
- import { i as transformerTab, n as rehypeCodeDefaultOptions, r as rehypeCodeFromHighlighter, t as createRehypeCode } from "../rehype-code.core-aegwEr3K.js";
1
+ import { i as transformerTab, n as rehypeCodeDefaultOptions, r as rehypeCodeFromHighlighter, t as createRehypeCode } from "../rehype-code.core-DNLXo8St.js";
2
2
  import { transformerIcon } from "./transformer-icon.js";
3
3
  export { createRehypeCode, rehypeCodeDefaultOptions, rehypeCodeFromHighlighter, transformerIcon, transformerTab };
@@ -1,5 +1,5 @@
1
1
  import { defaultShikiFactory, wasmShikiFactory } from "../highlight/shiki/full.js";
2
- import { i as transformerTab, n as rehypeCodeDefaultOptions$1, t as createRehypeCode } from "../rehype-code.core-aegwEr3K.js";
2
+ import { i as transformerTab, n as rehypeCodeDefaultOptions$1, t as createRehypeCode } from "../rehype-code.core-DNLXo8St.js";
3
3
  import { transformerIcon } from "./transformer-icon.js";
4
4
  // src/mdx-plugins/rehype-code.ts
5
5
  const rehypeCodeDefaultOptions = {
@@ -1,6 +1,6 @@
1
- import { a as handleTag, c as toEsm, n as esmScope } from "../utils-DfA1qEJN.js";
2
- import { a as listCode, i as jsxComponents, m as walkBranches, n as componentsCode, u as isStaticOutput } from "../code-output-CTZ8RNSo.js";
3
- import { n as stepNumberCode } from "../steps-D4-CDiVv.js";
1
+ import { a as handleTag, l as toEsm, n as esmScope } from "../utils-C7sTEOQI.js";
2
+ import { a as listCode, i as jsxComponents, m as walkBranches, n as componentsCode, u as isStaticOutput } from "../code-output-BZYBFRsN.js";
3
+ import { n as stepNumberCode } from "../steps-CGouhZm4.js";
4
4
  import { toEstree } from "hast-util-to-estree";
5
5
  // src/mdx-plugins/rehype-toc.ts
6
6
  const TocOnlyTag = "[toc]";
@@ -1,4 +1,4 @@
1
- import { r as flattenNode, u as walk } from "../utils-DfA1qEJN.js";
1
+ import { d as walk, r as flattenNode } from "../utils-C7sTEOQI.js";
2
2
  // src/mdx-plugins/remark-admonition.ts
3
3
  /**
4
4
  * Remark Plugin to support Admonition syntax
@@ -1,4 +1,4 @@
1
- import { r as flattenNode, u as walk } from "../utils-DfA1qEJN.js";
1
+ import { d as walk, r as flattenNode } from "../utils-C7sTEOQI.js";
2
2
  import Slugger from "github-slugger";
3
3
  import { createHash } from "node:crypto";
4
4
  // src/mdx-plugins/remark-block-id.ts
@@ -1 +1 @@
1
- export { t as remarkCodeTab } from "../remark-code-tab-CS8aN0DX.js";
1
+ export { t as remarkCodeTab } from "../remark-code-tab-DOOMCbAN.js";
@@ -1,4 +1,4 @@
1
- import { u as walk } from "../utils-DfA1qEJN.js";
1
+ import { d as walk } from "../utils-C7sTEOQI.js";
2
2
  // src/mdx-plugins/remark-directive-admonition.ts
3
3
  /**
4
4
  * Remark Plugin to support Admonition syntax in Docusaurus, useful for migrating from Docusaurus.
@@ -1,4 +1,4 @@
1
- import { r as flattenNode, u as walk } from "../utils-DfA1qEJN.js";
1
+ import { d as walk, r as flattenNode } from "../utils-C7sTEOQI.js";
2
2
  import { createHash } from "node:crypto";
3
3
  // src/mdx-plugins/remark-feedback-block.ts
4
4
  /**
@@ -1,6 +1,6 @@
1
- import { c as toEsm, r as flattenNode, u as walk } from "../utils-DfA1qEJN.js";
2
- import { m as walkBranches } from "../code-output-CTZ8RNSo.js";
3
- import { n as headingIdRegex, t as headingIdCode } from "../heading-id-DV5jeAL8.js";
1
+ import { d as walk, l as toEsm, n as esmScope, r as flattenNode, s as parse } from "../utils-C7sTEOQI.js";
2
+ import { m as walkBranches } from "../code-output-BZYBFRsN.js";
3
+ import { n as headingIdRegex, t as headingIdCode } from "../heading-id-C-jg9hhz.js";
4
4
  import Slugger from "github-slugger";
5
5
  import { toEstree } from "hast-util-to-estree";
6
6
  // src/mdx-plugins/remark-heading.ts
@@ -53,7 +53,8 @@ function remarkHeading({ slug, slugImportSource, customId = true, generateToc =
53
53
  });
54
54
  return "skip";
55
55
  });
56
- if (ids.esm) root.children.unshift(toEsm(ids.esm));
56
+ const esm = ids.esm(parse, esmScope(root));
57
+ if (esm) root.children.unshift(toEsm(esm));
57
58
  if (generateToc) file.data.toc = toc;
58
59
  };
59
60
  }
@@ -1,5 +1,5 @@
1
1
  import { replaceSource } from "./stringifier.js";
2
- import { u as walk } from "../utils-DfA1qEJN.js";
2
+ import { d as walk } from "../utils-C7sTEOQI.js";
3
3
  import * as path from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
  // src/mdx-plugins/remark-image.ts
@@ -1,7 +1,7 @@
1
1
  import { frontmatter } from "../content/md/frontmatter.js";
2
- import { n as headingIdRegex } from "../heading-id-DV5jeAL8.js";
2
+ import { n as headingIdRegex } from "../heading-id-C-jg9hhz.js";
3
3
  import { embedSource, replaceSource } from "./stringifier.js";
4
- import { r as flattenNode, u as walk } from "../utils-DfA1qEJN.js";
4
+ import { d as walk, r as flattenNode } from "../utils-C7sTEOQI.js";
5
5
  import Slugger from "github-slugger";
6
6
  import * as path from "node:path";
7
7
  import * as fs from "node:fs/promises";
@@ -1,6 +1,6 @@
1
- import { u as isStaticOutput } from "../code-output-CTZ8RNSo.js";
2
- import { n as esmScope, o as isJsxElement, t as createCodeOutput } from "../utils-DfA1qEJN.js";
3
- import { r as stringifyHeadingId } from "../heading-id-DV5jeAL8.js";
1
+ import { u as isStaticOutput } from "../code-output-BZYBFRsN.js";
2
+ import { n as esmScope, o as isJsxElement, t as createCodeOutput } from "../utils-C7sTEOQI.js";
3
+ import { r as stringifyHeadingId } from "../heading-id-C-jg9hhz.js";
4
4
  // src/mdx-plugins/remark-llms.ts
5
5
  /**
6
6
  * Generate Markdown for LLMs from the authored source, other plugins can edit it with
@@ -1,5 +1,5 @@
1
1
  import { replaceSource } from "./stringifier.js";
2
- import { u as walk } from "../utils-DfA1qEJN.js";
2
+ import { d as walk } from "../utils-C7sTEOQI.js";
3
3
  import path from "node:path";
4
4
  // src/mdx-plugins/remark-mdx-files.ts
5
5
  function parseFileTree(code) {
@@ -1,5 +1,5 @@
1
1
  import { replaceSource } from "./stringifier.js";
2
- import { u as walk } from "../utils-DfA1qEJN.js";
2
+ import { d as walk } from "../utils-C7sTEOQI.js";
3
3
  // src/mdx-plugins/remark-mdx-mermaid.ts
4
4
  function toMDX(code) {
5
5
  return {
@@ -1,6 +1,6 @@
1
1
  import { generateCodeBlockTabs } from "./codeblock-utils.js";
2
2
  import { replaceSource } from "./stringifier.js";
3
- import { u as walk } from "../utils-DfA1qEJN.js";
3
+ import { d as walk } from "../utils-C7sTEOQI.js";
4
4
  import convert from "npm-to-yarn";
5
5
  // src/mdx-plugins/remark-npm.ts
6
6
  function convertLines(cmd, to) {
@@ -1,5 +1,5 @@
1
- import { d as showCondition, f as showDeclaration, p as showElement } from "../code-output-CTZ8RNSo.js";
2
- import { c as toEsm, o as isJsxElement, u as walk } from "../utils-DfA1qEJN.js";
1
+ import { d as showCondition, f as showDeclaration, p as showElement } from "../code-output-BZYBFRsN.js";
2
+ import { d as walk, l as toEsm, o as isJsxElement } from "../utils-C7sTEOQI.js";
3
3
  // src/mdx-plugins/remark-show.ts
4
4
  /**
5
5
  * `<show when={...}>` renders its content when the condition holds, like `props.framework === 'next'` with the params of
@@ -1,5 +1,5 @@
1
- import { u as walk } from "../utils-DfA1qEJN.js";
2
- import { t as groupSteps } from "../steps-D4-CDiVv.js";
1
+ import { d as walk } from "../utils-C7sTEOQI.js";
2
+ import { t as groupSteps } from "../steps-CGouhZm4.js";
3
3
  import { replaceSource } from "./stringifier.js";
4
4
  // src/mdx-plugins/remark-steps.ts
5
5
  /**
@@ -1,2 +1,2 @@
1
1
  import "./remark-heading.js";
2
- export { t as remarkStructure, n as remarkStructureDefaultOptions, r as structure } from "../remark-structure-DG_c2J4O.js";
2
+ export { t as remarkStructure, n as remarkStructureDefaultOptions, r as structure } from "../remark-structure-DUU7_xF1.js";
@@ -1,4 +1,4 @@
1
- import { i as flattenNodeHast, u as walk } from "./utils-DfA1qEJN.js";
1
+ import { d as walk, i as flattenNodeHast } from "./utils-C7sTEOQI.js";
2
2
  import { transformerIcon } from "./mdx-plugins/transformer-icon.js";
3
3
  import { parseCodeBlockAttributes } from "./mdx-plugins/codeblock-utils.js";
4
4
  import { a as defaultThemes, n as createShikiHighlighter } from "./shiki-DL5DIaX-.js";
@@ -1,6 +1,6 @@
1
1
  import { parseCodeBlockAttributes } from "./mdx-plugins/codeblock-utils.js";
2
- import { s as toAttributeValue, u as walk } from "./utils-DfA1qEJN.js";
3
- import { a as listCode, l as groupLists, p as showElement, t as and } from "./code-output-CTZ8RNSo.js";
2
+ import { c as toAttributeValue, d as walk } from "./utils-C7sTEOQI.js";
3
+ import { a as listCode, l as groupLists, p as showElement, t as and } from "./code-output-BZYBFRsN.js";
4
4
  // ../shared/code-tab.ts
5
5
  const elements = {
6
6
  CodeBlockTabs: {
@@ -1,6 +1,6 @@
1
- import { l as toMdxExport, n as esmScope, t as createCodeOutput } from "./utils-DfA1qEJN.js";
2
- import { a as listCode, m as walkBranches, s as staticTagRegex, u as isStaticOutput } from "./code-output-CTZ8RNSo.js";
3
- import { n as headingIdRegex } from "./heading-id-DV5jeAL8.js";
1
+ import { n as esmScope, t as createCodeOutput, u as toMdxExport } from "./utils-C7sTEOQI.js";
2
+ import { a as listCode, m as walkBranches, s as staticTagRegex, u as isStaticOutput } from "./code-output-BZYBFRsN.js";
3
+ import { n as headingIdRegex } from "./heading-id-C-jg9hhz.js";
4
4
  import { remarkHeading } from "./mdx-plugins/remark-heading.js";
5
5
  import { tableRowToStructuredData } from "./search/index.js";
6
6
  import { remark } from "remark";
@@ -1,4 +1,4 @@
1
- import { u as walk } from "../utils-DfA1qEJN.js";
1
+ import { d as walk } from "../utils-C7sTEOQI.js";
2
2
  import { markdownTable } from "../mdx-plugins/stringifier.js";
3
3
  import { t as buildRegexFromQuery } from "../highlight-D_pTHg81.js";
4
4
  import { remark } from "remark";
package/dist/server.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { markdownTable } from "./mdx-plugins/stringifier.js";
2
- import { c as toHtmlTag } from "./code-output-CTZ8RNSo.js";
2
+ import { c as toHtmlTag } from "./code-output-BZYBFRsN.js";
3
3
  import { isValidElement } from "react";
4
4
  import { AsyncLocalStorage } from "node:async_hooks";
5
5
  // src/server.ts
@@ -47,24 +47,35 @@ async function renderRoute(element) {
47
47
  * named after its tag, as function names are minified in production builds and a component can have several tags.
48
48
  */
49
49
  const tagged = /* @__PURE__ */ new WeakMap();
50
+ /** a missing component. Declared for its prototype: React reads it, and a proxy below would answer as a member tag */
51
+ function Missing() {
52
+ return null;
53
+ }
50
54
  /**
51
- * Resolve the MDX components of a generated Markdown component (`remarkLLMs` with `output: 'function'`):
52
- * a missing component is serialized as JSX syntax by `renderToMarkdown`.
55
+ * The element types of the tags under `prefix`, read from `target`: the type of a tag has the ones of its member tags,
56
+ * like `<Tabs.Tab>`.
53
57
  */
54
- function jsxComponents(components) {
55
- return new Proxy({}, { get(_, key) {
56
- if (typeof key !== "string") return;
57
- const type = components?.[key] ?? (() => null);
58
+ function tagTypes(target, components, prefix = "") {
59
+ return new Proxy(target, { get(target, key, receiver) {
60
+ if (typeof key !== "string" || key in target) return Reflect.get(target, key, receiver);
61
+ const type = components?.[key] ?? Missing;
58
62
  if (typeof type === "string") return type;
59
- const element = () => null;
63
+ const element = tagTypes(Missing, type, `${prefix}${key}.`);
60
64
  tagged.set(element, {
61
- tag: key,
65
+ tag: prefix + key,
62
66
  type
63
67
  });
64
68
  return element;
65
69
  } });
66
70
  }
67
71
  /**
72
+ * Resolve the MDX components of a generated Markdown component (`remarkLLMs` with `output: 'function'`):
73
+ * a missing component is serialized as JSX syntax by `renderToMarkdown`.
74
+ */
75
+ function jsxComponents(components) {
76
+ return tagTypes({}, components);
77
+ }
78
+ /**
68
79
  * Tagged template for Markdown, interpolated values can be strings, React nodes, promises, or arrays of them.
69
80
  *
70
81
  * Use `md\`${children}\`` inside a component to stringify its children before manipulating them, the result is not
@@ -1,4 +1,4 @@
1
- import { d as showCondition, l as groupLists } from "./code-output-CTZ8RNSo.js";
1
+ import { d as showCondition, l as groupLists } from "./code-output-BZYBFRsN.js";
2
2
  // ../shared/steps.ts
3
3
  /** the properties of the element of a node */
4
4
  function properties(node) {
@@ -1,5 +1,5 @@
1
1
  import { createStringifier } from "./mdx-plugins/stringifier.js";
2
- import { o as moduleScope, r as createCodeOutput$1 } from "./code-output-CTZ8RNSo.js";
2
+ import { o as moduleScope, r as createCodeOutput$1 } from "./code-output-BZYBFRsN.js";
3
3
  import { valueToEstree } from "estree-util-value-to-estree";
4
4
  import { Parser } from "acorn";
5
5
  import acornJsx from "acorn-jsx";
@@ -34,17 +34,20 @@ function handleTag(value, tag) {
34
34
  }
35
35
  const parser = Parser.extend(acornJsx());
36
36
  const placeholderRegex = /^_fumadocs(\d+)$/;
37
- /** the code of an ESM block, the identifiers `_fumadocs<index>` are the expressions */
38
- function toEsm(code, expressions = []) {
39
- const program = parser.parse(code, {
37
+ function parse(code) {
38
+ return parser.parse(code, {
40
39
  ecmaVersion: "latest",
41
40
  sourceType: "module"
42
41
  });
43
- if (expressions.length > 0) fill(program, expressions);
42
+ }
43
+ /** the code of an ESM block, the identifiers `_fumadocs<index>` are the expressions */
44
+ function toEsm(code, expressions = []) {
45
+ const estree = parse(code);
46
+ if (expressions.length > 0) fill(estree, expressions);
44
47
  return {
45
48
  type: "mdxjsEsm",
46
49
  value: "",
47
- data: { estree: program }
50
+ data: { estree }
48
51
  };
49
52
  }
50
53
  function fill(node, expressions) {
@@ -62,10 +65,7 @@ function toAttributeValue(code) {
62
65
  return {
63
66
  type: "mdxJsxAttributeValueExpression",
64
67
  value: code,
65
- data: { estree: parser.parse(code, {
66
- ecmaVersion: "latest",
67
- sourceType: "module"
68
- }) }
68
+ data: { estree: parse(code) }
69
69
  };
70
70
  }
71
71
  /** the shared code output, on the stringifier of mdast: estree expressions of replacements go in by placeholders */
@@ -74,10 +74,7 @@ function createCodeOutput(file, options) {
74
74
  const out = createCodeOutput$1({
75
75
  ...options,
76
76
  stringifier: (expression) => createStringifier(file, options.target, (value, fallback) => expression(`_fumadocs${expressions.push(value) - 1}`, fallback)),
77
- parse: (code) => parser.parse(code, {
78
- ecmaVersion: "latest",
79
- sourceType: "module"
80
- }),
77
+ parse,
81
78
  literal: (value) => `_fumadocs${expressions.push({
82
79
  type: "Literal",
83
80
  value
@@ -95,4 +92,4 @@ function esmScope(tree) {
95
92
  return scope;
96
93
  };
97
94
  }
98
- export { handleTag as a, toEsm as c, flattenNodeHast as i, toMdxExport as l, esmScope as n, isJsxElement as o, flattenNode as r, toAttributeValue as s, createCodeOutput as t, walk as u };
95
+ export { handleTag as a, toAttributeValue as c, walk as d, flattenNodeHast as i, toEsm as l, esmScope as n, isJsxElement as o, flattenNode as r, parse as s, createCodeOutput as t, toMdxExport as u };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-core",
3
- "version": "16.19.3",
3
+ "version": "16.19.4",
4
4
  "description": "The React.js library for building a documentation website",
5
5
  "keywords": [
6
6
  "Docs",