@mintlify/common 1.0.197 → 1.0.199

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 (57) hide show
  1. package/dist/mdx/getMDXOptions.d.ts +4 -4
  2. package/dist/mdx/getMDXOptions.js +2 -3
  3. package/dist/mdx/lib/findExportedNode.d.ts +2 -2
  4. package/dist/mdx/lib/findExportedNode.js +3 -1
  5. package/dist/mdx/lib/remark-utils.d.ts +1 -1
  6. package/dist/mdx/plugins/rehype/index.d.ts +0 -1
  7. package/dist/mdx/plugins/rehype/index.js +0 -1
  8. package/dist/mdx/plugins/rehype/rehypeMdxExtractEndpoint/index.d.ts +2 -2
  9. package/dist/mdx/plugins/rehype/rehypeMdxExtractExamples.d.ts +2 -2
  10. package/dist/mdx/plugins/rehype/rehypeMdxExtractExamples.js +5 -5
  11. package/dist/mdx/plugins/rehype/rehypeParamFieldIds.d.ts +2 -2
  12. package/dist/mdx/plugins/rehype/rehypeParamFieldIds.js +1 -2
  13. package/dist/mdx/plugins/rehype/rehypeZoomImages.d.ts +2 -2
  14. package/dist/mdx/plugins/rehype/rehypeZoomImages.js +3 -3
  15. package/dist/mdx/plugins/remark/index.d.ts +1 -0
  16. package/dist/mdx/plugins/remark/index.js +1 -0
  17. package/dist/mdx/plugins/remark/remarkMdxInjectSnippets.d.ts +2 -1
  18. package/dist/mdx/plugins/remark/remarkMdxInjectSnippets.js +19 -20
  19. package/dist/mdx/plugins/remark/remarkMdxRemoveJs.d.ts +2 -2
  20. package/dist/mdx/plugins/remark/remarkMdxRemoveJs.js +0 -1
  21. package/dist/mdx/plugins/remark/remarkMdxRemoveUnknownJsx/createCommentNode.d.ts +2 -0
  22. package/dist/mdx/plugins/remark/remarkMdxRemoveUnknownJsx/index.d.ts +2 -0
  23. package/dist/mdx/plugins/{rehype/rehypeMdxRemoveUnknownJsx → remark/remarkMdxRemoveUnknownJsx}/index.js +1 -2
  24. package/dist/mdx/plugins/remark/remarkMdxRemoveUnusedVariables.d.ts +2 -2
  25. package/dist/mdx/plugins/remark/remarkMermaid.d.ts +2 -2
  26. package/dist/mdx/plugins/remark/remarkMermaid.js +3 -4
  27. package/dist/mdx/plugins/remark/remarkRemoveImports.d.ts +2 -2
  28. package/dist/mdx/plugins/remark/remarkRemoveImports.js +2 -6
  29. package/dist/mdx/plugins/remark/remarkReplaceAllImages.d.ts +2 -11
  30. package/dist/mdx/plugins/remark/remarkReplaceAllImages.js +16 -17
  31. package/dist/mdx/remark.d.ts +3 -3
  32. package/dist/mdx/snippets/findAndRemoveImports.js +1 -3
  33. package/dist/mdx/snippets/getExportMap.d.ts +1 -1
  34. package/dist/mdx/snippets/index.d.ts +0 -1
  35. package/dist/mdx/snippets/index.js +0 -1
  36. package/dist/mdx/snippets/nodeIncludesExport.d.ts +8 -3
  37. package/dist/mdx/snippets/nodeIncludesExport.js +4 -11
  38. package/dist/mdx/utils.d.ts +9 -6
  39. package/dist/mdx/utils.js +4 -7
  40. package/dist/tsconfig.build.tsbuildinfo +1 -1
  41. package/dist/types/mdx/index.d.ts +1 -12
  42. package/package.json +29 -29
  43. package/dist/mdx/plugins/rehype/rehypeMdxRemoveUnknownJsx/createCommentNode.d.ts +0 -15
  44. package/dist/mdx/plugins/rehype/rehypeMdxRemoveUnknownJsx/index.d.ts +0 -3
  45. package/dist/mdx/snippets/mdxMdToHtml/code.d.ts +0 -10
  46. package/dist/mdx/snippets/mdxMdToHtml/code.js +0 -38
  47. package/dist/mdx/snippets/mdxMdToHtml/image.d.ts +0 -10
  48. package/dist/mdx/snippets/mdxMdToHtml/image.js +0 -31
  49. package/dist/mdx/snippets/mdxMdToHtml/index.d.ts +0 -11
  50. package/dist/mdx/snippets/mdxMdToHtml/index.js +0 -83
  51. package/dist/mdx/snippets/mdxMdToHtml/list.d.ts +0 -11
  52. package/dist/mdx/snippets/mdxMdToHtml/list.js +0 -18
  53. package/dist/mdx/snippets/mdxMdToHtml/table.d.ts +0 -16
  54. package/dist/mdx/snippets/mdxMdToHtml/table.js +0 -37
  55. package/dist/mdx/snippets/mdxMdToHtml/utils.d.ts +0 -10
  56. package/dist/mdx/snippets/mdxMdToHtml/utils.js +0 -22
  57. /package/dist/mdx/plugins/{rehype/rehypeMdxRemoveUnknownJsx → remark/remarkMdxRemoveUnknownJsx}/createCommentNode.js +0 -0
@@ -1,17 +1,6 @@
1
- import type { Program, Directive, Statement, ModuleDeclaration } from 'estree-jsx';
2
- import type { Content } from 'mdast';
3
- import type { MdxJsxTextElement as BaseMdxJsxTextElement } from 'mdast-util-mdx-jsx';
1
+ import type { Directive, Statement, ModuleDeclaration } from 'estree-jsx';
4
2
  export type MdxNodeBodyChildType = Directive | Statement | ModuleDeclaration;
5
3
  export type MdxNodeBodyType = Array<MdxNodeBodyChildType>;
6
- export type NodeWithEstree = Content & {
7
- value?: string;
8
- data: {
9
- estree: Program;
10
- };
11
- };
12
- export type MdxJsxTextElement = BaseMdxJsxTextElement & {
13
- value: string;
14
- };
15
4
  export type FileType = {
16
5
  filename: string;
17
6
  content: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mintlify/common",
3
- "version": "1.0.197",
3
+ "version": "1.0.199",
4
4
  "description": "Commonly shared code within Mintlify",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -28,56 +28,56 @@
28
28
  "author": "Mintlify, Inc.",
29
29
  "license": "ISC",
30
30
  "dependencies": {
31
- "@mintlify/models": "0.0.152",
31
+ "@mintlify/mdx": "^1.0.1",
32
+ "@mintlify/models": "0.0.153",
32
33
  "@mintlify/openapi-parser": "^0.0.7",
33
- "@mintlify/validation": "0.1.226",
34
+ "@mintlify/validation": "0.1.227",
34
35
  "@sindresorhus/slugify": "^2.1.1",
35
36
  "acorn": "^8.11.2",
36
37
  "estree-util-to-js": "^2.0.0",
37
38
  "estree-walker": "^3.0.3",
38
39
  "gray-matter": "^4.0.3",
39
- "hast-util-from-html": "^1.0.0",
40
- "hast-util-to-html": "^8.0.3",
41
- "hast-util-to-text": "^4.0.0",
40
+ "hast-util-from-html": "^2.0.3",
41
+ "hast-util-to-html": "^9.0.4",
42
+ "hast-util-to-text": "^4.0.2",
42
43
  "is-absolute-url": "^4.0.1",
43
44
  "js-yaml": "^4.1.0",
44
45
  "lodash": "^4.17.21",
45
- "mdast": "^3.0.0",
46
- "mdast-util-from-markdown": "^1.2.0",
47
- "mdast-util-mdx": "^2.0.0",
48
- "mdast-util-mdx-jsx": "^2.1.2",
49
- "micromark-extension-mdx-jsx": "^1.0.3",
46
+ "mdast-util-from-markdown": "^2.0.2",
47
+ "mdast-util-mdx": "^3.0.0",
48
+ "mdast-util-mdx-jsx": "^3.1.3",
49
+ "micromark-extension-mdx-jsx": "^3.0.1",
50
50
  "openapi-types": "^12.0.0",
51
- "remark": "^14.0.2",
52
- "remark-frontmatter": "^4.0.1",
53
- "remark-gfm": "^3.0.1",
54
- "remark-math": "^5.1.1",
55
- "remark-mdx": "^2.0.0",
56
- "unist-builder": "^3.0.1",
57
- "unist-util-map": "^3.1.2",
58
- "unist-util-remove": "^3.1.0",
59
- "unist-util-remove-position": "^4.0.0",
60
- "unist-util-visit": "^4.1.1",
61
- "unist-util-visit-parents": "^5.0.0",
62
- "vfile": "^5.3.6"
51
+ "remark": "^15.0.1",
52
+ "remark-frontmatter": "^5.0.0",
53
+ "remark-gfm": "^4.0.0",
54
+ "remark-math": "^6.0.0",
55
+ "remark-mdx": "^3.1.0",
56
+ "unified": "^11.0.5",
57
+ "unist-builder": "^4.0.0",
58
+ "unist-util-map": "^4.0.0",
59
+ "unist-util-remove": "^4.0.0",
60
+ "unist-util-remove-position": "^5.0.0",
61
+ "unist-util-visit": "^5.0.0",
62
+ "unist-util-visit-parents": "^6.0.1",
63
+ "vfile": "^6.0.3"
63
64
  },
64
65
  "devDependencies": {
65
66
  "@mintlify/eslint-config-typescript": "1.0.13",
66
- "@mintlify/mdx": "0.0.54",
67
67
  "@mintlify/openapi-types": "^0.0.0",
68
68
  "@mintlify/ts-config": "^2.0.2",
69
69
  "@tsconfig/recommended": "1.x",
70
- "@types/estree-jsx": "^1.0.0",
71
- "@types/hast": "^3.0.0",
72
- "@types/mdast": "^3.0.10",
70
+ "@types/estree-jsx": "^1.0.5",
71
+ "@types/hast": "^3.0.4",
72
+ "@types/js-yaml": "^4.0.9",
73
+ "@types/mdast": "^4.0.4",
73
74
  "@typescript-eslint/parser": "6.x",
74
75
  "eslint": "8.x",
75
76
  "openapi-types": "^12.0.0",
76
77
  "prettier": "^3.1.1",
77
78
  "rimraf": "^5.0.1",
78
79
  "typescript": "^5.5.3",
79
- "unified": "^10.0.0",
80
80
  "vitest": "^2.0.4"
81
81
  },
82
- "gitHead": "35ffbb39c233d402af1be4886250a01eb14c0c06"
82
+ "gitHead": "328ec45e7b77e0a09006647a1d7bffbd010e990a"
83
83
  }
@@ -1,15 +0,0 @@
1
- export declare const createCommentNode: (componentName: string) => {
2
- type: string;
3
- value: string;
4
- data: {
5
- estree: {
6
- type: string;
7
- body: never[];
8
- comments: {
9
- type: string;
10
- value: string;
11
- }[];
12
- sourceType: string;
13
- };
14
- };
15
- };
@@ -1,3 +0,0 @@
1
- import type { Node } from 'unist';
2
- declare const rehypeMdxRemoveUnknownJsx: (allowedComponents?: string[]) => (tree: Node) => Node<import("unist").Data>;
3
- export default rehypeMdxRemoveUnknownJsx;
@@ -1,10 +0,0 @@
1
- import type { Code as BaseCode } from 'mdast';
2
- import type { MdxJsxFlowElement } from 'mdast-util-mdx-jsx';
3
- import type { Node } from 'unist';
4
- type Code = MdxJsxFlowElement & Omit<BaseCode, 'type'>;
5
- export declare const isCode: (node: Node) => node is Code;
6
- /**
7
- * Converts "`code`" to "<pre><code>code</code></pre>"
8
- */
9
- export declare const convertCode: (node: Code) => void;
10
- export {};
@@ -1,38 +0,0 @@
1
- export const isCode = (node) => node.type === 'code';
2
- /**
3
- * Converts "`code`" to "<pre><code>code</code></pre>"
4
- */
5
- export const convertCode = (node) => {
6
- node.type = 'mdxJsxFlowElement';
7
- node.name = 'pre';
8
- const attributes = [
9
- {
10
- type: 'mdxJsxAttribute',
11
- name: 'tabindex',
12
- value: '0',
13
- },
14
- ];
15
- const className = node.lang
16
- ? {
17
- type: 'mdxJsxAttribute',
18
- name: 'class',
19
- value: `language-${node.lang}`,
20
- }
21
- : undefined;
22
- if (className) {
23
- attributes.push(className);
24
- }
25
- node.attributes = attributes;
26
- const codeChild = {
27
- type: 'mdxJsxFlowElement',
28
- name: 'code',
29
- children: [
30
- {
31
- type: 'text',
32
- value: node.value,
33
- },
34
- ],
35
- attributes: className ? [className] : [],
36
- }; // the children type is malformed
37
- node.children = [codeChild];
38
- };
@@ -1,10 +0,0 @@
1
- import type { Image as BaseImage } from 'mdast';
2
- import type { MdxJsxFlowElement } from 'mdast-util-mdx-jsx';
3
- import type { Node } from 'unist';
4
- type Image = MdxJsxFlowElement & Partial<Omit<BaseImage, 'type'>>;
5
- export declare const isImage: (node: Node) => node is Image;
6
- /**
7
- * Converts "![alt](url)" to "<img src="url" alt="alt">"
8
- */
9
- export declare const convertImage: (node: Image) => void;
10
- export {};
@@ -1,31 +0,0 @@
1
- export const isImage = (node) => node.type === 'image';
2
- /**
3
- * Converts "![alt](url)" to "<img src="url" alt="alt">"
4
- */
5
- export const convertImage = (node) => {
6
- node.type = 'mdxJsxFlowElement';
7
- node.name = 'img';
8
- const attributes = [];
9
- if (node.url) {
10
- attributes.push({
11
- type: 'mdxJsxAttribute',
12
- name: 'src',
13
- value: node.url,
14
- });
15
- }
16
- if (node.alt) {
17
- attributes.push({
18
- type: 'mdxJsxAttribute',
19
- name: 'alt',
20
- value: node.alt,
21
- });
22
- }
23
- if (node.title) {
24
- attributes.push({
25
- type: 'mdxJsxAttribute',
26
- name: 'title',
27
- value: node.title,
28
- });
29
- }
30
- node.attributes = attributes;
31
- };
@@ -1,11 +0,0 @@
1
- import type { Root } from 'remark-mdx';
2
- /**
3
- *
4
- * @param content mdx content w/ basic md
5
- * @returns mdx content w/ basic md converted to html
6
- */
7
- export declare const mdxMdToHtml: (content: string) => Promise<string>;
8
- /**
9
- * Remark plugin that converts mdx md to html
10
- */
11
- export declare const remarkMdxMdToHtml: () => (tree: Root) => void;
@@ -1,83 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { remark } from 'remark';
11
- import { visit } from 'unist-util-visit';
12
- import { coreRemarkMdxPlugins } from '../../remark.js';
13
- import { isCode, convertCode } from './code.js';
14
- import { isImage, convertImage } from './image.js';
15
- import { isList, convertList } from './list.js';
16
- import { isTable, convertTable } from './table.js';
17
- import { willBeMdxJsxFlowElement, willBeMdxJsxTextElement, convertToMdxJsxTextElement, convertToMdxJsxFlowElementBase, convertToMdxJsxTextElementBase, convertToMdxJsxTextElementWithFirstTextChildValue, } from './utils.js';
18
- /**
19
- *
20
- * @param content mdx content w/ basic md
21
- * @returns mdx content w/ basic md converted to html
22
- */
23
- export const mdxMdToHtml = (content) => __awaiter(void 0, void 0, void 0, function* () {
24
- const convertedContent = yield remark()
25
- .use(coreRemarkMdxPlugins)
26
- .use(remarkMdxMdToHtml)
27
- .process(content);
28
- return String(convertedContent);
29
- });
30
- // TODO: Open source as remark plugin
31
- /**
32
- * Remark plugin that converts mdx md to html
33
- */
34
- export const remarkMdxMdToHtml = () => (tree) => {
35
- visit(tree, (node) => {
36
- if (isLink(node)) {
37
- node.type = 'mdxJsxTextElement';
38
- node.name = 'a';
39
- node.attributes = [
40
- {
41
- type: 'mdxJsxAttribute',
42
- name: 'href',
43
- value: node.url,
44
- },
45
- ];
46
- }
47
- else if (willBeMdxJsxTextElement(node, node.type === 'inlineCode')) {
48
- convertToMdxJsxTextElement(node, 'code', [{ type: 'text', value: node.value }]);
49
- }
50
- else if (isHeading(node)) {
51
- convertToMdxJsxTextElementWithFirstTextChildValue(node, `h${node.depth}`);
52
- }
53
- else if (willBeMdxJsxTextElement(node, node.type === 'strong')) {
54
- convertToMdxJsxTextElementWithFirstTextChildValue(node, 'strong');
55
- }
56
- else if (willBeMdxJsxTextElement(node, node.type === 'emphasis')) {
57
- convertToMdxJsxTextElementWithFirstTextChildValue(node, 'em');
58
- }
59
- else if (willBeMdxJsxTextElement(node, node.type === 'blockquote')) {
60
- convertToMdxJsxTextElementBase(node, 'blockquote');
61
- }
62
- else if (willBeMdxJsxTextElement(node, node.type === 'paragraph')) {
63
- convertToMdxJsxTextElementBase(node, 'p');
64
- }
65
- else if (isList(node)) {
66
- convertList(node);
67
- }
68
- else if (isImage(node)) {
69
- convertImage(node);
70
- }
71
- else if (willBeMdxJsxFlowElement(node, node.type === 'thematicBreak')) {
72
- convertToMdxJsxFlowElementBase(node, 'hr');
73
- }
74
- else if (isCode(node)) {
75
- convertCode(node);
76
- }
77
- else if (isTable(node)) {
78
- convertTable(node);
79
- }
80
- });
81
- };
82
- const isHeading = (node) => node.type === 'heading';
83
- const isLink = (node) => node.type === 'link';
@@ -1,11 +0,0 @@
1
- import type { MdxJsxFlowElement } from 'mdast-util-mdx-jsx';
2
- import type { Node } from 'unist';
3
- type List = MdxJsxFlowElement & {
4
- ordered: boolean;
5
- };
6
- export declare const isList: (node: Node) => node is List;
7
- /**
8
- * Converts "- list" to "<ul><li>list</li></ul>"
9
- */
10
- export declare const convertList: (node: List) => void;
11
- export {};
@@ -1,18 +0,0 @@
1
- export const isList = (node) => node.type === 'list';
2
- /**
3
- * Converts "- list" to "<ul><li>list</li></ul>"
4
- */
5
- export const convertList = (node) => {
6
- node.type = 'mdxJsxFlowElement';
7
- node.name = node.ordered ? 'ol' : 'ul';
8
- const children = node.children.reduce((acc, listItem) => {
9
- acc.push({
10
- type: 'mdxJsxTextElement',
11
- name: 'li',
12
- attributes: [],
13
- children: listItem.children[0].children,
14
- });
15
- return acc;
16
- }, []);
17
- node.children = children;
18
- };
@@ -1,16 +0,0 @@
1
- import type { Table as BaseTable, TableRow as BaseTableRow, TableCell as BaseTableCell } from 'mdast';
2
- import type { MdxJsxFlowElement } from 'mdast-util-mdx-jsx';
3
- import type { Node } from 'unist';
4
- type TableCell = MdxJsxFlowElement & Omit<BaseTableCell, 'type'>;
5
- type TableRow = Omit<MdxJsxFlowElement, 'children'> & Omit<BaseTableRow, 'type' | 'children'> & {
6
- children: TableCell[];
7
- };
8
- type Table = Omit<MdxJsxFlowElement, 'children'> & Omit<BaseTable, 'type' | 'children'> & {
9
- children: TableRow[];
10
- };
11
- export declare const isTable: (node: Node) => node is Table;
12
- /**
13
- * Converts "| table |" to "<table><tr><td>table</td></tr></table>"
14
- */
15
- export declare const convertTable: (node: Table) => void;
16
- export {};
@@ -1,37 +0,0 @@
1
- export const isTable = (node) => node.type === 'table';
2
- /**
3
- * Converts "| table |" to "<table><tr><td>table</td></tr></table>"
4
- */
5
- export const convertTable = (node) => {
6
- node.type = 'mdxJsxFlowElement';
7
- node.name = 'table';
8
- node.children = node.children.map((tableRow, i) => ({
9
- type: 'mdxJsxFlowElement',
10
- name: 'tr',
11
- attributes: [],
12
- children: tableRow.children.map((tableCell) => ({
13
- type: 'mdxJsxFlowElement',
14
- name: i === 0 ? 'th' : 'td',
15
- attributes: [],
16
- children: tableCell.children,
17
- })),
18
- }));
19
- const newChildren = [];
20
- if (node.children[0]) {
21
- newChildren.push({
22
- type: 'mdxJsxFlowElement',
23
- name: 'thead',
24
- attributes: [],
25
- children: [node.children[0]],
26
- });
27
- }
28
- if (node.children.length > 0) {
29
- newChildren.push({
30
- type: 'mdxJsxFlowElement',
31
- name: 'tbody',
32
- attributes: [],
33
- children: node.children.slice(1),
34
- });
35
- }
36
- node.children = newChildren;
37
- };
@@ -1,10 +0,0 @@
1
- import type { PhrasingContent } from 'mdast';
2
- import type { MdxJsxFlowElement } from 'mdast-util-mdx-jsx';
3
- import type { Node } from 'unist';
4
- import type { MdxJsxTextElement } from '../../../types/mdx/index.js';
5
- export declare const willBeMdxJsxTextElement: (node: Node, bool: boolean) => node is MdxJsxTextElement;
6
- export declare const willBeMdxJsxFlowElement: (node: Node, bool: boolean) => node is MdxJsxFlowElement;
7
- export declare const convertToMdxJsxTextElementBase: (node: MdxJsxTextElement, name: string) => void;
8
- export declare const convertToMdxJsxFlowElementBase: (node: MdxJsxFlowElement, name: string) => void;
9
- export declare const convertToMdxJsxTextElement: (node: MdxJsxTextElement, name: string, children: PhrasingContent[]) => void;
10
- export declare const convertToMdxJsxTextElementWithFirstTextChildValue: (node: MdxJsxTextElement, name: string) => void;
@@ -1,22 +0,0 @@
1
- export const willBeMdxJsxTextElement = (node, bool) => bool;
2
- export const willBeMdxJsxFlowElement = (node, bool) => bool;
3
- export const convertToMdxJsxTextElementBase = (node, name) => {
4
- node.type = 'mdxJsxTextElement';
5
- node.attributes = [];
6
- node.name = name;
7
- };
8
- export const convertToMdxJsxFlowElementBase = (node, name) => {
9
- node.type = 'mdxJsxFlowElement';
10
- node.attributes = [];
11
- node.name = name;
12
- };
13
- export const convertToMdxJsxTextElement = (node, name, children) => {
14
- convertToMdxJsxTextElementBase(node, name);
15
- node.children = children;
16
- };
17
- export const convertToMdxJsxTextElementWithFirstTextChildValue = (node, name) => convertToMdxJsxTextElement(node, name, [
18
- {
19
- type: 'text',
20
- value: node.children[0].value,
21
- },
22
- ]);