@mintlify/common 1.0.409 → 1.0.410

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.
@@ -6,6 +6,7 @@ import type { PluggableList } from 'unified';
6
6
  import { MdxExtracts } from '../types/mdx/MdxExtracts.js';
7
7
  type MDXOptionsData = {
8
8
  snippetTreeMap: Record<string, Root>;
9
+ allowedComponents: string[];
9
10
  pageMetadata: PageMetaTags;
10
11
  config?: DocsConfig | MintConfig;
11
12
  subdomain?: string;
@@ -1,4 +1,5 @@
1
1
  import { rehypeCodeBlocks, rehypeDynamicTailwindCss, rehypeMdxExtractEndpoint, rehypeMdxExtractExamples, rehypeParamFieldIds, rehypeRawComponents, rehypeUnicodeIds, rehypeZoomImages, remarkExtractChangelogFilters, remarkExtractTableOfContents, remarkFrames, remarkHeadingIds, remarkMdxInjectSnippets, remarkMdxRemoveUnusedVariables, remarkRemoveImports, remarkMdxExtractPanel, } from './plugins/index.js';
2
+ import { remarkMdxRemoveUnknownJsx } from './plugins/remark/remarkMdxRemoveUnknownJsx/index.js';
2
3
  import { remarkMermaid } from './plugins/remark/remarkMermaid.js';
3
4
  // avoid running extractors unnecessarily
4
5
  const rehypeExtractors = (mdxExtracts, data) => {
@@ -22,6 +23,7 @@ export const getMDXOptions = ({ data, remarkPlugins = [], rehypePlugins = [], md
22
23
  remarkMermaid,
23
24
  remarkHeadingIds,
24
25
  ...remarkPlugins,
26
+ [remarkMdxRemoveUnknownJsx, data.allowedComponents],
25
27
  ],
26
28
  rehypePlugins: [
27
29
  rehypeCodeBlocks,
@@ -3,6 +3,7 @@ export * from './remarkFrames.js';
3
3
  export * from './remarkRemoveImports.js';
4
4
  export * from './remarkExtractTableOfContents.js';
5
5
  export * from './remarkMdxRemoveUnusedVariables.js';
6
+ export * from './remarkMdxRemoveUnknownJsx/index.js';
6
7
  export * from './remarkReplaceAllImages.js';
7
8
  export * from './remarkMermaid.js';
8
9
  export * from './remarkMdxRemoveJs.js';
@@ -3,6 +3,7 @@ export * from './remarkFrames.js';
3
3
  export * from './remarkRemoveImports.js';
4
4
  export * from './remarkExtractTableOfContents.js';
5
5
  export * from './remarkMdxRemoveUnusedVariables.js';
6
+ export * from './remarkMdxRemoveUnknownJsx/index.js';
6
7
  export * from './remarkReplaceAllImages.js';
7
8
  export * from './remarkMermaid.js';
8
9
  export * from './remarkMdxRemoveJs.js';
@@ -0,0 +1,2 @@
1
+ import { MdxFlowExpression } from 'mdast-util-mdx';
2
+ export declare const createCommentNode: (componentName: string) => MdxFlowExpression;
@@ -0,0 +1,20 @@
1
+ export const createCommentNode = (componentName) => {
2
+ const comment = ` Component ${componentName} does not exist. `;
3
+ return {
4
+ type: 'mdxFlowExpression',
5
+ value: `/* ${comment} */`,
6
+ data: {
7
+ estree: {
8
+ type: 'Program',
9
+ body: [],
10
+ comments: [
11
+ {
12
+ type: 'Block',
13
+ value: comment,
14
+ },
15
+ ],
16
+ sourceType: 'module',
17
+ },
18
+ },
19
+ };
20
+ };
@@ -0,0 +1,2 @@
1
+ import type { Root } from 'mdast';
2
+ export declare const remarkMdxRemoveUnknownJsx: (allowedComponents?: string[]) => (tree: Root) => Root | import("mdast-util-mdxjs-esm").MdxjsEsm | import("mdast-util-mdx-expression").MdxFlowExpression | import("mdast-util-mdx-expression").MdxTextExpression | import("mdast").Link | import("mdast").Delete | import("mdast").Yaml | import("mdast").Emphasis | import("mdast").Strong | import("mdast-util-mdx").MdxJsxFlowElement | import("mdast").Blockquote | import("mdast").Break | import("mdast").Code | import("mdast").Definition | import("mdast").FootnoteDefinition | import("mdast").FootnoteReference | import("mdast").Heading | import("mdast").Html | import("mdast").Image | import("mdast").ImageReference | import("mdast").InlineCode | import("mdast").LinkReference | import("mdast").List | import("mdast").ListItem | import("mdast").Paragraph | import("mdast").Table | import("mdast").TableCell | import("mdast").TableRow | import("mdast").Text | import("mdast").ThematicBreak | import("mdast-util-math").InlineMath | import("mdast-util-math").Math | import("mdast-util-mdx").MdxJsxTextElement;
@@ -0,0 +1,16 @@
1
+ import { map } from 'unist-util-map';
2
+ import { findExportedNodes, isMdxJsxFlowElementHast } from '../../../lib/index.js';
3
+ import { createCommentNode } from './createCommentNode.js';
4
+ export const remarkMdxRemoveUnknownJsx = (allowedComponents) => (tree) => {
5
+ const exportedComponentNames = findExportedNodes(tree, 'ArrowFunctionExpression');
6
+ return map(tree, (node) => {
7
+ if (isMdxJsxFlowElementHast(node)) {
8
+ if (node.name &&
9
+ !(allowedComponents === null || allowedComponents === void 0 ? void 0 : allowedComponents.includes(node.name)) &&
10
+ !exportedComponentNames.includes(node.name)) {
11
+ return createCommentNode(node.name);
12
+ }
13
+ }
14
+ return node;
15
+ });
16
+ };